<commit_before><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace MotAttendance\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
/**
 * MotAttendance\Controller\OBController
 *
 * @package MotAttendance\Controller
 */
class OfficialBusinessController extends AbstractActionController{
    
     public function officialBusinessAction()
    {
      
    }
     public function earlyObAction()
    {
    
    } 
     public function obReportAction()
    {
         $result=[
                    ['01/03/15','approved','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','Lugait','ocular inspection','fare & snacks','1,000.00','','5:00PM'],
                    ['01/03/15','approved','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','Lugait','ocular inspection','fare & snacks','1,000.00','','5:00PM'],
                    ['01/03/15','pending','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','','ocular inspection','fare & snacks','','','5:00PM'],
                 ];
         $data=[];
         
         if($result){
         foreach ($result as $value){
             array_push($data,$this->setColor($value));
         }
         }
    $OBStatus = [
            'title' => strtoupper('OB Report'),
            'name' => 'datatables14',
            'header' => ['Date','Status','Processed by', 'Comment', 'Type', 'Date Requested', 'Time Requested', 'Destination From', 
                         'Destination To', 'Purpose','Expense Description','Expense Amount','OB Out','OB In'],        
            'data'=>$data 
        ];
        
             
        return new ViewModel(['result' => [$OBStatus]]);
        
    } 
    
    public function obStatusMonitoringAction()
    {
        $result=[
                    ['Denied','Jermaine Obial', 'No Budget for OB Trip', 'Early OB', '12/13/14', '10:30 AM', 'Iligan City', '','Apply for ATM Card'],
                    ['Denied','Jermaine Obial', '', 'Early OB', '12/13/14', '10:30 AM', 'Iligan City', 'BDO Iligan','Apply for ATM Card'],
                    ['Denied','Jermaine Obial', 'No Budget for OB Trip', 'Early OB', '', '10:30 AM', 'Iligan City', 'BDO Iligan','Apply for ATM Card'],
                 ];
         $data=[];
         
         if($result){
         foreach ($result as $value){
             array_push($data,$this->setColor($value));
         }
         }
        
        $OBStatus = [
            'title' => strtoupper('OB Status'),
            'name' => 'datatables9',
            'header' => ['Status','Processed by', 'Comment', 'Type', 'Date', 'Time', 'Destination From', 'Destination To', 'Purpose'],
            'data'  =>$data
        ];
        
             
        return new ViewModel(['result' => [$OBStatus]]);
    }    
   
    public function obApprovalAction()
    {   
        $result=[
                [1,'<NAME>','Corp','HR','early','04/26/15','9:00 AM',
                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
                  '1,000.00'],
                [2,'<NAME>','Corp','HR','early','04/26/15','9:00 AM',
                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
                  '1,000.00'],
                [3,'<NAME>','Corp','HR','early','04/26/15','9:00 AM',
                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
                  '1,000.00']
                ];
        $data=[];
        
         if($result){
            foreach ($result as $value){
                array_push($data,$this->setColorWithButtons($value));
            }
         }
        
        $OBApproval = [
            'title' => strtoupper('OB Approval'),
            'name' => 'datatables12',
            'header' => ['Name','Branch', 'Department', 'Type', 'Date', 'Time', 'Destination From', 'Destination To', 'Purpose',
                         'Expense Description','Expense Amount','Action'],
            'data'=>$data
//            'data'  => [
//                ['<NAME>','Corp','HR','early','04/26/15','9:00 AM',
//                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
//                  '1,000.00',$this->createButtons(1) ],
//                ['<NAME>','Corp','HR','early','04/26/15','9:00 AM',
//                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
//                  '1,000.00',$this->createButtons(2) ],
//                ['<NAME>','Corp','HR','early','04/26/15','9:00 AM',
//                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
//                  '1,000.00',$this->createButtons(3)],
//            ]
        ];
        
        $modal=$this->setModal(1,'Approved').$this->setModal(1,'Denied');
        $modal.=$this->setModal(2,'Approved').$this->setModal(2,'Denied');        
        $modal.=$this->setModal(3,'Approved').$this->setModal(3,'Denied');        
             
        return new ViewModel(['result' => [$OBApproval],'modal'=>$modal]);
    }
    private function setColorWithButtons($result){
        
        $returnValue=[];
        
        $id= array_shift($result);             
        foreach ($result as $data){
            
            if($data==''){
               array_push($returnValue,'<b><font color="red">---</font></b>');
            }else{
               array_push($returnValue,$data); 
            }
        }
        
        return array_push($returnValue,$this->createButtons($id));
    }
    
    private function setColor($result){
        
        $returnValue=[];
        
        foreach ($result as $data){
            if($data==''){
               array_push($returnValue,'<b><font color="red">---</font></b>');
            }else{
               array_push($returnValue,$data); 
            }
        }
        return $returnValue;
    }
    
    private function createButtons($id){
        $buttons='<button type="button" class="btn btn-xs" data-toggle="modal" data-target="#Approved'.$id.'">
                    <i class="fa fa-check"></i></button>
                    <button type="button" class="btn btn-xs" data-toggle="modal" data-target="#Denied'.$id.'">
                    <i class="fa fa-times"></i>
                </button>';<commit_msg>updated controller. Data sanitation function added and tested<commit_after><?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace MotAttendance\Controller;

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
/**
 * MotAttendance\Controller\OBController
 *
 * @package MotAttendance\Controller
 */
class OfficialBusinessController extends AbstractActionController{
    
     public function officialBusinessAction()
    {
      
    }
     public function earlyObAction()
    {
    
    } 
     public function obReportAction()
    {
         $result=[
                    ['01/03/15','approved','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','Lugait','ocular inspection','fare & snacks','1,000.00','','5:00PM'],
                    ['01/03/15','approved','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','Lugait','ocular inspection','fare & snacks','1,000.00','','5:00PM'],
                    ['01/03/15','pending','R.J.E.','important','early','01/02/15','9:10 AM',
                  'Iligan','','ocular inspection','fare & snacks','','','5:00PM'],
                 ];
         $data=[];
         
         if($result){
         foreach ($result as $value){
             array_push($data,$this->setColor($value));
         }
         }
    $OBStatus = [
            'title' => strtoupper('OB Report'),
            'name' => 'datatables14',
            'header' => ['Date','Status','Processed by', 'Comment', 'Type', 'Date Requested', 'Time Requested', 'Destination From', 
                         'Destination To', 'Purpose','Expense Description','Expense Amount','OB Out','OB In'],        
            'data'=>$data 
        ];
        
             
        return new ViewModel(['result' => [$OBStatus]]);
        
    } 
    
    public function obStatusMonitoringAction()
    {
        $result=[
                    ['Denied','Jermaine Obial', 'No Budget for OB Trip', 'Early OB', '12/13/14', '10:30 AM', 'Iligan City', '','Apply for ATM Card'],
                    ['Denied','Jermaine Obial', '', 'Early OB', '12/13/14', '10:30 AM', 'Iligan City', 'BDO Iligan','Apply for ATM Card'],
                    ['Denied','Jermaine Obial', 'No Budget for OB Trip', 'Early OB', '', '10:30 AM', 'Iligan City', 'BDO Iligan','Apply for ATM Card'],
                 ];
         $data=[];
         
         if($result){
         foreach ($result as $value){
             array_push($data,$this->setColor($value));
         }
         }
        
        $OBStatus = [
            'title' => strtoupper('OB Status'),
            'name' => 'datatables9',
            'header' => ['Status','Processed by', 'Comment', 'Type', 'Date', 'Time', 'Destination From', 'Destination To', 'Purpose'],
            'data'  =>$data
        ];
        
             
        return new ViewModel(['result' => [$OBStatus]]);
    }    
   
    public function obApprovalAction()
    {   
        $result=[
                [1,'<NAME>','Corp','HR','early','04/26/15','9:00 AM',
                  'Iligan City','','mag-loan ug lovelife','fare & snacks',
                  '1,000.00'],
                [2,'<NAME>','Corp','HR','early','','9:00 AM',
                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','fare & snacks',
                  '1,000.00'],
                [3,'<NAME>','Corp','HR','early','04/26/15','9:00 AM',
                  'Iligan City','Pag-Ibig','mag-loan ug lovelife','',
                  '1,000.00']
                ];
        $data=[];
        
         if($result){
            foreach ($result as $value){
                $id=array_shift($value);
                $temp=$this->setColor($value);
                array_push($temp,$this->createButtons($id));
                array_push($data,$temp);
            }
         }
        
        $OBApproval = [
            'title' => strtoupper('OB Approval'),
            'name' => 'datatables12',
            'header' => ['Name','Branch', 'Department', 'Type', 'Date', 'Time', 'Destination From', 'Destination To', 'Purpose',
                         'Expense Description','Expense Amount','Action'],
            'data'=>$data

        ];
        
        $modal=$this->setModal(1,'Approved').$this->setModal(1,'Denied');
        $modal.=$this->setModal(2,'Approved').$this->setModal(2,'Denied');        
        $modal.=$this->setModal(3,'Approved').$this->setModal(3,'Denied');        
             
        return new ViewModel(['result' => [$OBApproval],'modal'=>$modal]);
    }
   
    private function setColor($result){
        
        $returnValue=[];
        
        foreach ($result as $data){
            if($data==''){
               array_push($returnValue,'<b><font color="red">---</font></b>');
            }else{
               array_push($returnValue,$data); 
            }
        }
        return $returnValue;
    }
    
    private function createButtons($id){
        $buttons='<button type="button" class="btn btn-xs" data-toggle="modal" data-target="#Approved'.$id.'">
                    <i class="fa fa-check"></i></button>
                    <button type="button" class="btn btn-xs" data-toggle="modal" data-target="#Denied'.$id.'">
                    <i class="fa fa-times"></i>
                </button>';
{'fraction_non_alphanumeric': 0.19062868700488791, 'fraction_numerical': 0.02865329512893983, 'mean_word_length': 1.895802830649097, 'pattern_counts': {'":': 0, '<': 42, '<?xml version=': 0, '>': 96, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6034399', 'n_tokens_mistral': 3714, 'n_tokens_neox': 3423, 'n_words': 622}