Exemple #1
0
 function add($data)
 {
     # a) save the main record
     $contractId = $this->_query_reader->add_data('add_contract_record', array('tender_id' => $data['tender_id'], 'organization_id' => $data['provider_id'], 'pde_id' => $data['pde_id'], 'name' => htmlentities($data['tender__tendernotices'], ENT_QUOTES), 'source_of_funds' => htmlentities($data['source_of_funds'], ENT_QUOTES), 'contract_currency' => $data['currency_code'], 'contract_amount' => $data['amount'], 'status' => $data['contract__contractstatus'], 'date_started' => date('Y-m-d', strtotime(make_us_date($data['start_date']))), 'user_id' => $this->native_session->get('__user_id')));
     # b) save the status record
     if (!empty($contractId)) {
         $result = $this->_query_reader->run('add_contract_status', array('contract_id' => $contractId, 'status' => $data['contract__contractstatus'], 'percentage' => '0', 'document_url' => implode(',', $data['documents']), 'user_id' => $this->native_session->get('__user_id'), 'organization_id' => $this->native_session->get('__organization_id'), 'notes' => 'First contract status entry'));
     }
     # c) update the winner's bid to reflect the contract amount for reporting purposes
     if (!empty($result) && $result) {
         $result = $this->_query_reader->run('update_bid_contract_amount', array('tender_id' => $data['tender_id'], 'organization_id' => $data['provider_id'], 'contract_currency' => $data['currency_code'], 'contract_amount' => $data['amount'], 'user_id' => $this->native_session->get('__user_id')));
     }
     # d) notify provider about new status
     if (!empty($result) && $result && $data['contract__contractstatus'] == 'active') {
         $users = $this->_query_reader->get_list('get_users_in_organizations', array('organization_ids' => $data['provider_id']));
         $message = array('code' => 'changed_item_status', 'item' => 'contract', 'status' => 'ACTIVE', 'name' => htmlentities($data['tender__tendernotices'], ENT_QUOTES));
         $sent = array();
         foreach ($users as $row) {
             $result = $this->_messenger->send($row['user_id'], $message, array('email'), TRUE);
             if ($result) {
                 array_push($sent, $row['email_address']);
             }
         }
         $result = !empty($sent);
     }
     # e) log action
     $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'add_contract', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "contractid=" . $contractId . "|tender_id=" . $data['tender_id'] . "|organization_id=" . $data['provider_id'] . "|contractstatus=" . $data['contract__contractstatus'] . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address()));
     return array('boolean' => $result, 'reason' => '');
 }
Exemple #2
0
 function add($data)
 {
     $result = FALSE;
     $reason = '';
     # add the tender notice
     if ($this->_query_reader->get_count('get_tender_by_reference_number', array('reference_number' => htmlentities($data['reference_number'], ENT_QUOTES))) == 0 && empty($data['tender_id']) || !empty($data['tender_id'])) {
         # user is editing and they have uploaded new documents
         if (!empty($data['tender_id']) && !empty($data['documents'])) {
             $tender = $this->details($data['tender_id']);
             $oldDocuments = !empty($tender['document_url']) ? $tender['document_url'] : '';
         }
         # update the tender database record
         $result = $this->_query_reader->run((!empty($data['tender_id']) ? 'edit' : 'add') . '_tender_notice', array('name' => htmlentities($data['tender__procurementplansubjects'], ENT_QUOTES), 'reference_number' => htmlentities($data['reference_number'], ENT_QUOTES), 'details' => htmlentities($data['summary'], ENT_QUOTES), 'type' => $data['tender__procurementtypes'], 'procurement_plan_id' => $data['plan_id'], 'subject_id' => $data['subject_id'], 'document_url' => !empty($data['documents']) ? implode(',', $data['documents']) : '', 'status' => $data['tender__tenderstatus'], 'deadline' => date('Y-m-d H:i:s', strtotime(make_us_date($data['deadline']))), 'display_start_date' => !empty($data['display_from']) ? date('Y-m-d', strtotime(make_us_date($data['display_from']))) : '0000-00-00', 'display_end_date' => !empty($data['display_to']) ? date('Y-m-d', strtotime(make_us_date($data['display_to']))) : '0000-00-00', 'user_id' => $this->native_session->get('__user_id'), 'tender_id' => !empty($data['tender_id']) ? $data['tender_id'] : ''));
         # safely remove the old documents from the server if the above update succeeded
         if ($result && !empty($oldDocuments)) {
             $documents = explode(',', $oldDocuments);
             foreach ($documents as $document) {
                 @unlink(UPLOAD_DIRECTORY . $document);
             }
         }
     } else {
         $reason = "The reference number is already in use.";
     }
     # log action
     $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'add_tender', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address()));
     return array('boolean' => $result, 'reason' => $reason);
 }
Exemple #3
0
 function add($data)
 {
     $result = FALSE;
     $reason = '';
     # add the document record
     $result = $this->_query_reader->run('add_training_record', array('subject' => htmlentities($data['name'], ENT_QUOTES), 'category' => $data['training__trainingcategories'], 'description' => htmlentities($data['description'], ENT_QUOTES), 'event_time' => date('Y-m-d H:i:s', strtotime(make_us_date($data['eventtime']))), 'duration' => $data['duration'], 'venue' => htmlentities($data['venue'], ENT_QUOTES), 'url' => !empty($data['url']) ? $data['url'] : '', 'documents' => !empty($data['documents']) ? implode(',', $data['documents']) : '', 'user_id' => $this->native_session->get('__user_id'), 'organization_id' => $this->native_session->get('__organization_id')));
     # log action
     $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => 'add_training', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address()));
     return array('boolean' => $result, 'reason' => $reason);
 }
Exemple #4
0
 function add($data)
 {
     $result = FALSE;
     # a) save the main record
     $bidId = $this->_query_reader->add_data((!empty($data['bidid']) ? 'update' : 'add') . '_bid_record', array('tender_id' => $data['tender_id'], 'summary' => htmlentities($data['summary'], ENT_QUOTES), 'bid_currency' => !empty($data['currency_code']) ? $data['currency_code'] : '', 'bid_amount' => !empty($data['amount']) ? $data['amount'] : '0', 'status' => $data['bid__bidstatus'], 'valid_start_date' => !empty($data['valid_from']) ? date('Y-m-d', strtotime(make_us_date($data['valid_from']))) : '0000-00-00', 'valid_end_date' => !empty($data['valid_to']) ? date('Y-m-d', strtotime(make_us_date($data['valid_to']))) : '0000-00-00', 'user_id' => $this->native_session->get('__user_id'), 'organization_id' => !empty($data['provider_id']) ? $data['provider_id'] : $this->native_session->get('__organization_id'), 'bid_id' => !empty($data['bidid']) ? $data['bidid'] : ''));
     # mark the result as true if the status is still saved and the user is simply updating
     if (!empty($data['bidid']) && $data['bid__bidstatus'] == 'saved') {
         $result = TRUE;
     }
     # save the status record
     if (!empty($bidId) || !empty($data['bidid']) && $data['bid__bidstatus'] != 'saved') {
         $result = $this->_query_reader->run('add_bid_status', array('bid_id' => !empty($data['bidid']) ? $data['bidid'] : $bidId, 'status' => $data['bid__bidstatus'], 'user_id' => $this->native_session->get('__user_id')));
     }
     # save the document records
     if ($result || !(!empty($data['bidid']) && $data['bid__bidstatus'] != 'saved')) {
         # updating the bid record? remove the old documents first
         if (!empty($data['bidid']) && !empty($data['documents'])) {
             $result = $this->_query_reader->run('remove_bid_documents', array('bid_id' => $data['bidid']));
             if ($result && !empty($data['olddocuments'])) {
                 $documents = explode(',', $data['olddocuments']);
                 foreach ($documents as $document) {
                     @unlink(UPLOAD_DIRECTORY . $document);
                 }
             }
         }
         # adding the new documents
         if (!empty($data['documents'])) {
             foreach ($data['documents'] as $document) {
                 $result = $this->_query_reader->run('add_bid_document', array('bid_id' => !empty($data['bidid']) ? $data['bidid'] : $bidId, 'document_url' => $document, 'user_id' => $this->native_session->get('__user_id')));
             }
         }
     }
     # log action
     $this->_logger->add_event(array('user_id' => $this->native_session->get('__user_id'), 'activity_code' => (!empty($data['bidid']) ? 'update' : 'add') . '_bid', 'result' => $result ? 'SUCCESS' : 'FAIL', 'log_details' => "bidstatus=" . $data['bid__bidstatus'] . "|device=" . get_user_device() . "|browser=" . $this->agent->browser(), 'uri' => uri_string(), 'ip_address' => get_ip_address()));
     return array('boolean' => $result, 'reason' => '');
 }
Exemple #5
0
 function audit_trail($scope = array('date' => '', 'user_id' => '', 'activity_code' => '', 'phrase' => '', 'offset' => '0', 'limit' => NUM_OF_ROWS_PER_PAGE))
 {
     return $this->_query_reader->get_list('get_audit_trail', array('date_condition' => !empty($scope['date']) ? " AND DATE(event_time) = DATE('" . date('Y-m-d', strtotime(make_us_date($scope['date']))) . "')" : '', 'user_condition' => !empty($scope['user_id']) ? " AND user_id='" . $scope['user_id'] . "' " : '', 'activity_condition' => !empty($scope['activity_code']) ? " AND activity_code='" . $scope['activity_code'] . "' " : '', 'phrase_condition' => !empty($scope['phrase']) ? " AND MATCH(log_details) AGAINST ('+\"" . htmlentities($scope['phrase'], ENT_QUOTES) . "\"') " : '', 'limit_text' => " LIMIT " . $scope['offset'] . "," . $scope['limit'] . " "));
 }
Exemple #6
0
 function record_registration_track($data)
 {
     $ids = explode(',', $data['idlist']);
     # end the current registration status
     $result = $this->_query_reader->run('end_registration_status', array('id_list' => implode("','", $ids), 'user_id' => $this->native_session->get('__user_id')));
     # add the suspended registration status
     if ($result) {
         $result = $this->_query_reader->run('add_registration_status', array('id_list' => implode("','", $ids), 'reason' => htmlentities($data['reason'], ENT_QUOTES), 'status' => $data['status'], 'end_date' => !empty($data['expiry_date']) ? date('Y-m-d', strtotime(make_us_date($data['expiry_date']))) : '0000-00-00', 'user_id' => $this->native_session->get('__user_id')));
     }
     return $result;
 }
 function add_details($data)
 {
     $reason = '';
     $data['financialperiod'] = $data['fystart__financialperiods'] . '-all';
     if (empty($data['plan_id'])) {
         $planCount = $this->_query_reader->get_count('get_procurement_plan_by_data', array('pde_id' => $data['pde_id'], 'financial_year_start' => get_quarter_date($data['financialperiod'], 'start'), 'financial_year_end' => get_quarter_date($data['financialperiod'], 'end')));
     }
     # proceed with the addition if this is a unique plan
     if (!empty($data['plan_id']) || empty($data['plan_id']) && $planCount == 0) {
         $planId = $this->_query_reader->add_data((!empty($data['plan_id']) ? 'edit' : 'add') . '_procurement_plan', array('organization_id' => $data['pde_id'], 'financial_year_start' => get_quarter_date($data['financialperiod'], 'start'), 'financial_year_end' => get_quarter_date($data['financialperiod'], 'end'), 'title' => htmlentities($data['name'], ENT_QUOTES), 'details' => '', 'document_url' => '', 'status' => $data['status__procurementplanstatus'], 'user_id' => $this->native_session->get('__user_id'), 'plan_id' => !empty($data['plan_id']) ? $data['plan_id'] : ''));
         $planId = !empty($data['plan_id']) ? $data['plan_id'] : $planId;
         # proceed with processing the procurement plan details
         if (!empty($planId)) {
             $this->native_session->set('plan_id', $planId);
             require_once HOME_URL . 'external_libraries/phpexcel/PHPExcel.php';
             $objPHPExcel = PHPExcel_IOFactory::load(UPLOAD_DIRECTORY . $data['document']);
             $sheetData = $objPHPExcel->getActiveSheet()->toArray('', true, true, true);
             $DATA_START = 9;
             $result = TRUE;
             $usefulData = array();
             # extract the useful data
             foreach ($sheetData as $i => $row) {
                 if ($i >= $DATA_START && !is_empty_row($row)) {
                     # where they can not edit
                     if (!empty($row['B']) && trim($row['B']) == 'DO NOT EDIT BELOW THIS LINE') {
                         break;
                     }
                     # put only categories with data
                     if (in_array(trim(strtolower($row['B'])), get_option_list($this, 'procurementcategories', 'array')) && !empty($sheetData[$i + 1]['D'])) {
                         array_push($usefulData, $row);
                     } else {
                         if (!empty($row['D'])) {
                             # convert back to UK format if excel importer converted the dates to US format
                             $tempRow = $row;
                             foreach ($tempRow as $key => $value) {
                                 if (strtolower($key) > 'd') {
                                     if (strpos($value, '/', 3) !== FALSE) {
                                         $value = date('m-d-y', strtotime(make_us_date($value)));
                                     }
                                     # correct dates in the format 12-31-15 as they can not be converted correctly
                                     if (strpos($value, '-', 3) !== FALSE && strlen($value) == 8) {
                                         $valueParts = explode('-', $value);
                                         if (count($valueParts) > 2) {
                                             $value = substr(@date('Y'), 0, 2) . $valueParts[2] . '-' . $valueParts[0] . '-' . $valueParts[1];
                                         }
                                     }
                                     $row[$key] = !empty($value) ? date('d/m/Y', strtotime($value)) : '';
                                 }
                             }
                             array_push($usefulData, $row);
                         }
                     }
                 }
             }
             # remove the old sheet data
             if (!empty($usefulData) && !empty($data['plan_id'])) {
                 $result = $this->_query_reader->run('remove_plan_detail_rows', array('plan_id' => $data['plan_id']));
             }
             # add the new sheet data
             foreach ($usefulData as $row) {
                 # save the rows with data
                 $rowData = array_merge($row, array('plan_id' => $planId, 'user_id' => $this->native_session->get('__user_id')));
                 $result = $this->_query_reader->run('add_plan_detail_row', $rowData);
             }
             # return with the list of added items for immediate display
             if ($result) {
                 return $this->_query_reader->get_list('get_procurement_plan_details', array('plan_id' => $planId));
             } else {
                 $reason = "The plan details could not be fully recorded.";
             }
         } else {
             $reason = "The plan headers could not be recorded.";
         }
     } else {
         $reason = "This PDE already has a plan for the same financial period. Please edit that instead.";
     }
     return $reason;
 }