Example #1
0
 public function setDefaults()
 {
     $A = $this->sheetData[1]['A'];
     // templateID
     $B = $this->sheetData[1]['B'];
     // TPIN
     $C = strcmp($this->sheetData[1]['C'], '') == 0 ? null : $this->sheetData[1]['C'];
     // government entity
     $D = strcmp($this->sheetData[1]['D'], '') == 0 ? null : $this->sheetData[1]['D'];
     // reportID
     $E = $this->sheetData[1]['E'];
     // period
     $F = strcmp($this->sheetData[1]['F'], '') == 0 ? null : $this->sheetData[1]['F'];
     // status
     // validate if the templates being edited already approved in the case of non management users
     if (strcmp($_SESSION['user']->getRole(), 'mu') != 0 && (strcasecmp($F, 'Approved') == 0 || strcasecmp($F, 'Reconciled') == 0) || strcasecmp($F, 'Reconciled') == 0) {
         exit(json_encode(['success' => false, 'error' => 'You are not permitted to edit an already approved submission.']));
     }
     // validate TPIN
     $mines = ZP::getExtractiveCompanies();
     $isTPIN = false;
     foreach ($mines as $v) {
         if ($v->TPIN == $B) {
             $isTPIN = true;
             break;
         }
     }
     // validate government entity entityID
     $isEntity = is_null($C) ? true : false;
     if (!$isEntity) {
         $entities = ZP::getEntities();
         if (!$entities['success']) {
             exit(json_encode($entities));
         }
         $entities = $entities['entities'];
         //exit(json_encode($entities));
         foreach ($entities as $v) {
             if ($v->entityID = $C) {
                 $isEntity = true;
                 break;
             }
         }
     }
     // validate reportID
     $isReport = is_null($D) ? true : false;
     if (!$isReport) {
         $reports = ZP::getReports();
         foreach ($reports as $v) {
             if ($v->reportID == $D) {
                 $isReport = true;
                 break;
             }
         }
     }
     //validate status
     $isStatus = is_null($F) ? true : false;
     if (!$isStatus) {
         $status = ['Approved', 'Rejected', 'Not Approved'];
         if (in_array($F, $status)) {
             $isStatus = true;
         }
     }
     // valid templates
     $isTemplate = intval($A) > 0 && intval($A) <= 10;
     // validate period
     $isPeriod = intval($E) > 2000 && $E <= date('Y');
     if (!$isTPIN || !$isReport || !$isStatus || !$isPeriod || !$isTemplate) {
         exit(json_encode(['success' => false, 'error' => 'Invalid templates uploaded. Please download the templates from the portal.']));
     }
     $this->defaults = (object) ['templateID' => $A, 'mine' => $B, 'entity' => $C, 'reportID' => $D, 'period' => $E];
     //exit(json_encode(['success'=>false, 'error'=>'done here']));
 }
Example #2
0
             if (array_key_exists($data->receiptNumber, $test)) {
                 array_push($duplicates, $data->Id);
                 array_push($duplicates, $test[$data->receiptNumber]);
             } else {
                 $test[$data->receiptNumber] = $data->Id;
             }
         }
         if (count($duplicates)) {
             exit(json_encode(['success' => false, 'errors' => ['payment-flow' => $duplicates]]));
         }
         return $obj;
     }, $_FILES['receipt'], $obj);
 }
 // validate reportID
 if (intval($reportID) > 0 && !call_user_func(function ($reportID) {
     $reports = \ZP\ZP::getReports();
     foreach ($reports as $v) {
         if ($reportID == $v->reportID) {
             return true;
         }
     }
     return false;
 }, $reportID)) {
     exit(json_encode(['success' => false, 'message' => 'You have submitted an invalid report. Please refresh page and try again.']));
 }
 // validate entity
 if ($_SESSION['entity']->isGovernmentEntity()) {
     $entityID = $_SESSION['entity']->getID();
 } else {
     if (intval($_REQUEST['entity']) > 0) {
         if (!\ZP\ZP::getEntity($_REQUEST['entity'])) {