Beispiel #1
0
 function add_report()
 {
     access_control($this);
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #Get the report details if the user is editing
     if (!empty($data['i'])) {
         $editid = decryptValue($data['i']);
         $data['formdata'] = $this->Query_reader->get_row_as_array('get_report_by_id', array('id' => $editid));
     }
     #Save the report details
     if ($this->input->post('savereport')) {
         $required_fields = array('reportname');
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             $save_result = false;
             #Save/Update an existing report's details
             if (!empty($data['formdata']) && !empty($data['i'])) {
                 $updateStr = '';
                 #check if report has changed
                 if (!empty($_FILES['fileurl']['tmp_name'])) {
                     $new_file_url = 'ny_' . strtotime('now') . generate_random_letter() . "." . end(explode('.', $_FILES['fileurl']['name']));
                     if (copy(str_replace("/kunden/", "/", $_FILES['fileurl']['tmp_name']), UPLOAD_DIRECTORY . "reports/" . $new_file_url)) {
                         #Delete the previous report from the server if it exists
                         if (!empty($data['formdata']['fileurl'])) {
                             @unlink(UPLOAD_DIRECTORY . "reports/" . $data['formdata']['fileurl']);
                         }
                         $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_report', array('updatestring' => ', fileurl = \'' . $new_file_url . '\' , uploadip = \'' . get_ip_address() . '\'', 'reportname' => $_POST['reportname'], 'id' => $editid)));
                     }
                 } else {
                     $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_report', array_merge($_POST, array('id' => $editid, 'updatestring' => ''))));
                 }
             } else {
                 $new_file_url = 'ny_' . strtotime('now') . generate_random_letter() . "." . end(explode('.', $_FILES['fileurl']['name']));
                 #First move the report to the correct folder and then add the report
                 if (copy(str_replace("/kunden/", "/", $_FILES['fileurl']['tmp_name']), UPLOAD_DIRECTORY . "reports/" . $new_file_url)) {
                     $save_result = $this->db->query($this->Query_reader->get_query_by_code('add_report', array('fileurl' => $new_file_url, 'reportname' => $_POST['reportname'], 'uploadip' => get_ip_address())));
                 }
             }
             if ($save_result) {
                 $data['msg'] = "The report has been saved.";
                 $this->session->set_userdata('sres', $data['msg']);
                 redirect(base_url() . "reports/manage_reports/m/sres");
             } else {
                 $data['msg'] = "ERROR: The report was not saved. Please contact your administrator.";
             }
         }
         #VALIDATION end
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     $this->load->view('reports/add_report_view', $data);
 }
Beispiel #2
0
 function save_staff()
 {
     access_control($this);
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 's'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     $data = restore_bad_chars($data);
     if ($data['save']) {
         $data['formdata'] = $data;
         $required_fields = array('firstname', 'lastname', 'address', 'emailaddress*EMAILFORMAT', 'telephone', 'username');
         $_POST = clean_form_data($data);
         $validation_results = validate_form('', $_POST, $required_fields);
         #set status as editing on destination if updating
         if (!empty($_POST['editid'])) {
             $data['editid'] = $_POST['editid'];
         }
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             if (!empty($_POST['editid'])) {
                 $update_string = '';
                 #Check if password has been changed and also meets minimum criteria
                 if (!empty($_POST['password']) || !empty($_POST['repeatpassword'])) {
                     $passwordmsg = $this->user1->check_password_strength($_POST['password']);
                     if (!$passwordmsg['bool']) {
                         $data['msg'] = $passwordmsg['msg'];
                     } elseif ($_POST['password'] == $_POST['repeatpassword']) {
                         $update_string = ", password = '******'password']) . "'";
                     } else {
                         $data['msg'] = "WARNING: The passwords provided do not match.";
                     }
                 }
                 #Check if a new photo has been uploaded
                 if (!empty($_FILES['imageurl']['tmp_name'])) {
                     $new_file_url = 'ac_' . strtotime('now') . generate_random_letter() . "." . end(explode('.', $_FILES['imageurl']['name']));
                     if (copy($_FILES['imageurl']['tmp_name'], UPLOAD_DIRECTORY . "users/" . $new_file_url)) {
                         #Create a thumb nail as well
                         $config['image_library'] = 'gd2';
                         $config['source_image'] = UPLOAD_DIRECTORY . "users/" . $new_file_url;
                         $config['create_thumb'] = TRUE;
                         $config['maintain_ratio'] = TRUE;
                         $config['width'] = 180;
                         $config['height'] = 160;
                         $this->load->library('image_lib', $config);
                         $this->image_lib->resize();
                         #Delete the previous image from the server if it exists
                         if (!empty($data['formdata']['fileurl'])) {
                             @unlink(UPLOAD_DIRECTORY . "users/" . $data['formdata']['imageurl']);
                         }
                         $update_string .= ',photo ="' . $new_file_url . '"';
                         $admission_result = $this->student_mod->update_student_data($_POST);
                     }
                 }
                 if (empty($_POST['password']) && empty($_POST['repeatpassword']) || !empty($update_string)) {
                     #Attach school id to the data
                     $_POST['school'] = $this->myschool['school'];
                     $_POST['author'] = $this->session->userdata('userid');
                     //set user type
                     $_POST['usertype'] = 'SCHOOL';
                     $result = $this->db->query($this->Query_reader->get_query_by_code('update_school_user_data', array_merge($_POST, array('updatecond' => $update_string))));
                 }
             } else {
                 #check if a similar username already exists in both users and school users tables
                 $username_error = "";
                 $usernames = $this->db->query($this->Query_reader->get_query_by_code('get_existing_usernames', array('searchstring' => ' username = "******"')));
                 #school users
                 $school_usernames = $this->db->query($this->Query_reader->get_query_by_code('search_schoolusers', array('searchstring' => ' username = "******"')));
                 #Check if the email added has already been used by system user
                 $system_user_email_details = $this->Query_reader->get_row_as_array('get_any_user_by_email', array('emailaddress' => $data['formdata']['emailaddress']));
                 #Check if the email added has already been used by school user
                 $school_user_email_details = $this->Query_reader->get_row_as_array('search_school_users', array('limittext' => '', 'searchstring' => ' AND emailaddress = "' . $data['formdata']['emailaddress'] . '"'));
                 #determine password strength
                 $passwordmsg = $this->user1->check_password_strength($_POST['password']);
                 if (strlen($_POST['username']) < 5) {
                     $data['msg'] = "WARNING: The username must be at least 5 characters long.";
                 } elseif (count($usernames->result_array()) || count($school_usernames->result_array())) {
                     $data['msg'] = "WARNING: The username is already being used by another user.";
                 } elseif (!empty($school_user_email_details) || !empty($system_user_email_details)) {
                     $data['msg'] = "WARNING: The specified email address is already in use.";
                 } elseif (!$passwordmsg['bool']) {
                     $data['msg'] = "WARNING: " . $passwordmsg['msg'];
                 } elseif ($_POST['password'] == $_POST['repeatpassword'] && !empty($_POST['password'])) {
                     $_POST['newpass'] = $_POST['password'];
                     #Attach school id to the data
                     $_POST['school'] = $this->myschool['id'];
                     $_POST['author'] = $this->session->userdata('userid');
                     //set the usertype
                     $_POST['usertype'] = 'SCHOOL';
                     #First move the photo to the correct folder and then add the user
                     /*
                     if(copy(str_replace("/kunden/", "/", $_FILES['imageurl']['tmp_name']), UPLOAD_DIRECTORY."users/".$new_image_url)) 
                     {
                     	#Create a thumb nail as well
                     	$config['image_library'] = 'gd2';
                     	$config['source_image'] = UPLOAD_DIRECTORY."users/".$new_file_url;
                     	$config['create_thumb'] = TRUE;
                     	$config['maintain_ratio'] = TRUE;
                     	$config['width'] = 180;
                     	$config['height'] = 160;
                     	$this->load->library('image_lib', $config);
                     	$this->image_lib->resize();
                     	
                     	$_POST['photo'] = $new_image_url;
                     	$result = $this->db->query($this->Query_reader->get_query_by_code('add_school_user', array_merge($_POST, array('password'=>sha1($_POST['newpass'])) )));
                     }
                     else
                     {
                     	$_POST['photo'] = '';
                     	$result = $this->db->query($this->Query_reader->get_query_by_code('add_school_user', array_merge($_POST, array('password'=>sha1($_POST['newpass'])) )));
                     }
                     */
                     $_POST['photo'] = '';
                     $result = $this->db->query($this->Query_reader->get_query_by_code('add_school_user', array_merge($_POST, array('password' => sha1($_POST['newpass'])))));
                 } else {
                     $data['msg'] = "WARNING: The passwords provided do not match.";
                 }
             }
             #Format and send the errors
             if (!empty($result) && $result) {
                 #Notify user by email on creation of an account
                 if (empty($data['editid'])) {
                     /*$send_result = $this->sysemail->email_form_data(array('fromemail'=>NOREPLY_EMAIL), 
                     		get_confirmation_messages($this, array('emailaddress'=>$_POST['emailaddress'], 'username'=>$_POST['username'], 'password'=>$_POST['newpass']), 'registration_confirm')); */
                 }
                 $data['msg'] = "The user data has been successfully saved.";
                 $data['formdata'] = array();
             } else {
                 if (empty($data['msg'])) {
                     #Get access groups
                     $usergroupsResult = $this->db->query($this->Query_reader->get_query_by_code('get_user_groups', array('searchstr' => ' AND school = ' . $_POST['school'])));
                     $data['usergroups'] = get_select_options($usergroupsResult->result_array(), 'id', 'groupname', '', 'Select');
                     $data['msg'] = "ERROR: The user could not be saved or was not saved correctly.";
                 }
             }
         } else {
             if (empty($data['editid']) && !empty($user_details)) {
                 $addn_msg = !empty($user_details['isactive']) && $user_details['isactive'] == 'N' ? "<a href='" . base_url() . "admin/load_user_form/i/" . encryptValue($user_details['id']) . "/a/" . encryptValue("reactivate") . "' style='text-decoration:underline;font-size:17px;'>Click here to  activate and  edit</a>" : "<a href='" . base_url() . "admin/load_user_form/i/" . encryptValue($user_details['id']) . "' style='text-decoration:underline;font-size:17px;'>Click here to edit</a>";
                 $data['msg'] = "WARNING: The emailaddress has already been used by another user.<br />" . $addn_msg . " this user instead.";
             }
         }
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
     }
     #Get access groups
     $usergroupsResult = $this->db->query($this->Query_reader->get_query_by_code('get_user_groups', array('searchstr' => ' AND school = ' . $this->myschool['id'])));
     $data['usergroups'] = get_select_options($usergroupsResult->result_array(), 'id', 'groupname', empty($data['formdata']['usergroup']) ? '' : $data['formdata']['usergroup'], 'Y', 'Select');
     $this->load->view('incl/staff_form', $data);
 }
Beispiel #3
0
 function upload_student_photo()
 {
     access_control($this);
     #check if recover image has been specified
     if (!empty($_FILES['insert-image']['tmp_name'])) {
         $_POST = clean_form_data($_POST);
         $new_file_url = 'ac_' . strtotime('now') . generate_random_letter() . "." . end(explode('.', $_FILES['insert-image']['name']));
         if (copy($_FILES['insert-image']['tmp_name'], UPLOAD_DIRECTORY . "students/" . $new_file_url)) {
             #Create a thumb nail as well
             $config['image_library'] = 'gd2';
             $config['source_image'] = UPLOAD_DIRECTORY . "students/" . $new_file_url;
             $config['create_thumb'] = TRUE;
             $config['maintain_ratio'] = TRUE;
             $config['width'] = 180;
             $config['height'] = 160;
             $this->load->library('image_lib', $config);
             $this->image_lib->resize();
             $temp_array = explode('.', $new_file_url);
             $data['msg'] = base_url() . "academiaimages/students/" . $temp_array[0] . '_thumb.' . $temp_array[1];
         }
     }
     if (empty($data['msg'])) {
         $data['msg'] = "ERROR";
     }
     $data['area'] = 'upload_student_img';
     $this->load->view('incl/addons', $data);
 }
function get_deal_id($idtype = 'deal')
{
    if ($idtype == 'order') {
        return "OD" . strtotime('now') . generate_random_letter();
    } else {
        return strtotime('now') . generate_random_letter();
    }
}
Beispiel #5
0
 function save_disposal_plan()
 {
     $segment = $this->uri->segment(3);
     $post = $_POST;
     switch ($segment) {
         case 'update':
             # code...
             $id = $this->uri->segment(4);
             $result = $this->disposal->update_disposal_plan($post, $id);
             redirect('disposal/view_disposal_plan/m/usave');
             #print_r($result);
             break;
         case 'insert':
             #SETTING UP SOME ISSUES
             #first save disposal plan and get the insert id
             $insertid = $this->disposal->save_disposal_plan($post);
             #Upload allowed xsl
             $this->session->set_userdata('local_allowed_extensions', array('.xls', '.xlsx'));
             $extramsg = "";
             $MAX_FILE_SIZE = 1000000;
             $MAX_FILE_ROWS = 1000;
             #detailed plan as well
             if (!empty($_FILES['detailed_plan']['name'])) {
                 $new_plan_name = 'disposalplan' . 'Upload_' . strtotime('now') . generate_random_letter();
                 $_POST['disposalplan'] = !empty($_FILES['detailed_plan']['name']) ? $this->sysfile->local_file_upload($_FILES['detailed_plan'], $new_plan_name, 'documents', 'filename') : '';
             }
             if (!empty($_POST['disposalplan'])) {
                 $file_url = UPLOAD_DIRECTORY . "documents/" . $_POST['disposalplan'];
                 #   exit($file_url);
                 $file_size = filesize($file_url);
                 #Break up file if it is bigger than allowed
                 if ($file_size > $MAX_FILE_SIZE) {
                     $data['file_siblings'] = $this->sysfile->break_up_file($file_url, $MAX_FILE_ROWS);
                     $this->session->set_userdata('file_siblings', $data['file_siblings']);
                     $msg = "WARNING: The uploaded file exceeded single processing requirements and was <br>broken up into " . count($data['file_siblings']) . " files. <br><br>Please click on each file, one at a time, to update the procurement plan and <br><a href='" . base_url() . "grades/manage_grades' class='bluelink' style='font-size:17px;'>click here</a> to refresh.";
                     print_r($msg);
                 } else {
                     $result_array = read_excel_data($file_url);
                     #print_r($result_array); exit();
                     #Remove file after upload
                     @unlink($file_url);
                     if (count($result_array)) {
                         #1. format insert string
                         #2. sheet 1 is supplies
                         if (!empty($result_array['Disposal']) && count($result_array['Disposal']) > 1) {
                             #$project_plan = $this->procurement_plan_entry_m->create_bulk($plan_data);
                             $sheet_info = $result_array['Disposal'];
                             $x = 0;
                             #exit("movest 11");
                             foreach ($sheet_info as $key => $value) {
                                 $x++;
                                 if ($x <= 5) {
                                     continue;
                                 }
                                 $disposal_serial_number = '';
                                 $subject_of_disposal = '';
                                 $method_of_disposal = '';
                                 $asset_location = '';
                                 $amount = '';
                                 $currency = '';
                                 $strategic_asset = '';
                                 $date_of_approval = '';
                                 $date_of_aoapproval = '';
                                 // information
                                 $disposal_serial_number = $value['C'];
                                 if ($disposal_serial_number == '') {
                                     continue;
                                 }
                                 $subject_of_disposal = $value['B'];
                                 $method_of_disposal = $value['F'];
                                 $asset_location = $value['G'];
                                 $amount = $value['D'];
                                 $currency = $value['E'];
                                 $strategic_asset = $value['H'];
                                 $date_of_approval = $value['I'];
                                 $date_of_aoapproval = $value['J'];
                                 $_POST['disposal_plan'] = $insertid;
                                 $_POST['disposal_serial_number'] = $disposal_serial_number;
                                 $_POST['subject_of_disposal'] = $subject_of_disposal;
                                 #print_r($method_of_disposal);
                                 $record = $this->db->query(" SELECT * FROM `disposal_method` WHERE `method` LIKE '%" . $method_of_disposal . "%' limit 1 ")->result_array();
                                 $method_ofdisposal = !empty($record[0]) ? $record[0]['id'] : 0;
                                 $q = "select * from  disposal_method where method like '% " . $method_of_disposal . " %' limit 1 ";
                                 print_r($method_ofdisposal);
                                 $_POST['method_of_disposal'] = $method_ofdisposal;
                                 $_POST['asset_location'] = $asset_location;
                                 $_POST['amount'] = $amount;
                                 $_POST['currency'] = $currency;
                                 $_POST['strategic_asset'] = $strategic_asset;
                                 $_POST['date_of_approval'] = $date_of_approval;
                                 $_POST['date_of_aoapproval'] = $date_of_aoapproval;
                                 //call the model and send data to the model ::
                                 $result = $this->disposal->insert_disposal($_POST);
                             }
                         }
                     }
                 }
             }
             if ($insertid > 0) {
                 redirect('disposal/view_disposal_plan/m/usave');
             }
             break;
         default:
             # code...
             break;
     }
 }
Beispiel #6
0
 function save_ifb_addenda()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'b'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #check user access
     #1: for editing
     if (!empty($data['i'])) {
         check_user_access($this, 'edit_bid_invitation', 'redirect');
     } else {
         check_user_access($this, 'create_invitation_for_bids', 'redirect');
     }
     if (!empty($_POST['save_addenda'])) {
         $required_fields = array('title', 'refno');
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             #check if a document with the specified reference number exists for this IFB
             $similar_ref_no = $this->db->query($this->Query_reader->get_query_by_code('search_table', array('table' => 'addenda', 'orderby' => 'bidid', 'limittext' => '', 'searchstring' => ' bidid = "' . decryptValue($data['b']) . '" AND refno ="' . $_POST['refno'] . '" AND isactive="Y"' . (!empty($data['i']) ? ' AND id !="' . decryptValue($data['i']) . '"' : ''))))->result_array();
             if (!empty($similar_ref_no)) {
                 $data['msg'] = "WARNING: An addenda for the selected IFB with a similar reference number exists";
             } else {
                 if (!empty($_FILES['addenda']['name'])) {
                     $this->session->set_userdata('local_allowed_extensions', array('.pdf'));
                     $extramsg = "";
                     $MAX_FILE_SIZE = 1000000;
                     $new_file_name = 'addenda_' . strtotime('now') . decryptValue($data['b']) . generate_random_letter();
                     $_POST['fileurl'] = !empty($_FILES['addenda']['name']) ? $this->sysfile->local_file_upload($_FILES['addenda'], $new_file_name, 'documents/addenda', 'filename') : '';
                 }
                 if (!empty($data['i'])) {
                     $_POST = array_merge($_POST, array('id' => decryptValue($data['i'])));
                     $_POST['updatestr'] = '';
                     if (!empty($_FILES['addenda']['name']) && !empty($_POST['fileurl'])) {
                         $_POST['updatestr'] = ', fileurl = "' . $new_file_name . '" ';
                         $result = $this->db->query($this->Query_reader->get_query_by_code('update_addenda', $_POST));
                     } elseif (!empty($_FILES['addenda']['name']) && empty($_POST['fileurl'])) {
                         $data['msg'] = 'ERROR: ' . $this->sysfile->processing_errors;
                     } else {
                         $result = $this->db->query($this->Query_reader->get_query_by_code('update_addenda', $_POST));
                     }
                 } else {
                     $_POST['author'] = $this->session->userdata('userid');
                     $_POST['bidid'] = decryptValue($data['b']);
                     if (!empty($_POST['fileurl'])) {
                         $result = $this->db->query($this->Query_reader->get_query_by_code('create_addenda', $_POST));
                         $addenda_id = $this->db->insert_id();
                     } elseif (empty($_FILES['addenda']['name'])) {
                         $data['msg'] = 'ERROR: Please select a file to upload';
                     } else {
                         $data['msg'] = 'ERROR: ' . $this->sysfile->processing_errors;
                     }
                 }
             }
             #event has been added successfully
             if (!empty($result) && $result) {
                 /*
                 #Notify approvers
                 $procurement_details = $this->Query_reader->get_row_as_array('procurement_plan_details', array('searchstring'=>' procurement_plan_entries.procurement_ref_no ="'. $_POST['procurement_ref_no'] .'"', 'limittext'=>'', 'orderby'=>' procurement_plan_entries.dateadded ' ));
                 
                 if(!empty($procurement_details))
                 {
                 	$this->load->model('notification_m', 'notifications');
                 
                 	$receipients = $this->notifications->notification_access('approve_invitation_for_bids', $procurement_details['pde_id']);
                 
                 	if(!empty($receipients))
                 	{
                 		$msg_title = 'Request to approve Invitation for Bids';
                 
                 		$msg_body = 'Hello'.
                 				'<p>An Invitation for bids process that needs your approval has been initiated by '.
                 				$this->session->userdata('firstname') . ' ' . $this->session->userdata('lastname') .'.</p>'.
                 				'<p>The procurement reference number '. $_POST['procurement_ref_no'] .' and subject of procurement is '.
                 				$procurement_details['subject_of_procurement'] .'. To view more details and approve/reject the IFB click '.
                 				'<a href="'. base_url() .'bids/approve_bid_invitation/i/'. encryptValue($bid_invitation_id) .'">here</a>'.' </p>'.
                 				'<p>regards, <br /> System message</p>';
                 
                 
                 		$notification_result = $this->db->insert('notifications', array('triggeredby'=>$this->session->userdata('userid'),
                 								'title'=>$msg_title, 'body'=>$msg_body, 'receipients'=>$receipients, 'msgtype'=>'IFB_Approval_Request'));
                 	}
                 }
                 */
                 $data['msg'] = "SUCCESS: The addenda details have been saved.";
                 $this->session->set_userdata('sres', $data['msg']);
                 redirect('bids/view_addenda/m/sres' . (!empty($data['b']) ? "/b/" . $data['b'] : ''));
             } else {
                 if (empty($data['msg'])) {
                     $data['msg'] = "ERROR: The addenda details could not be saved or were not saved correctly.";
                 }
             }
         }
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
             $data['requiredfields'] = $validation_results['requiredfields'];
         }
     }
     $data['formdata'] = $_POST;
     $app_select_str = ' procurement_plan_entries.isactive="Y" ';
     if ($this->session->userdata('isadmin') == 'N') {
         $userdetails = $this->db->get_where('users', array('userid' => $this->session->userdata('userid')))->result_array();
         $app_select_str .= ' AND procurement_plans.pde_id ="' . $userdetails[0]['pde'] . '" ';
     }
     if (!empty($data['b'])) {
         #the bid details
         $app_select_str .= ' AND bidinvitations.id ="' . decryptValue($data['b']) . '"';
         $data['procurement_details'] = $this->Query_reader->get_row_as_array('procurement_plan_details', array('searchstring' => $app_select_str, 'limittext' => '', 'orderby' => ' procurement_plan_entries.dateadded '));
         $data['bid_invitation_details'] = $this->Query_reader->get_row_as_array('search_table', array('table' => 'bidinvitations', 'limittext' => '', 'orderby' => 'id', 'searchstring' => ' id="' . decryptValue($data['b']) . '" AND isactive="Y"'));
     }
     #exit($this->db->last_query());
     #user is editing
     if (!empty($data['i'])) {
         $addenda_id = decryptValue($data['i']);
         $data['formdata'] = $this->Query_reader->get_row_as_array('search_table', array('table' => 'addenda', 'limittext' => '', 'orderby' => 'id', 'searchstring' => ' id="' . $addenda_id . '" AND isactive="Y"'));
         #get procurement plan details
         if (!empty($data['formdata']['procurement_ref_no'])) {
             $data['formdata']['procurement_details'] = $this->Query_reader->get_row_as_array('procurement_plan_details', array('searchstring' => $app_select_str . ' AND procurement_plan_entries.procurement_ref_no="' . $data['formdata']['procurement_ref_no'] . '"', 'limittext' => '', 'orderby' => ' procurement_plan_entries.dateadded '));
         }
     }
     $data['page_title'] = !empty($data['i']) ? 'Edit addenda' : 'Add IFB addenda';
     $data['current_menu'] = 'view_bid_invitations';
     $data['view_to_load'] = 'bids/ifb_addenda_form';
     $data['view_data']['form_title'] = $data['page_title'];
     $this->load->view('dashboard_v', $data);
 }
Beispiel #7
0
 function save_procurement_plan()
 {
     #check user access
     if (!empty($data['i'])) {
         check_user_access($this, 'edit_procurement_plan', 'redirect');
     } else {
         check_user_access($this, 'create_procurement_plan', 'redirect');
     }
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('m', 'i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     //if there is an ajax post
     if ($this->input->post('ajax') || $this->input->post('save_plan')) {
         $data['msg'] = '';
         $this->form_validation->set_rules($this->procurement_plan_m->validate_plan);
         $data['formdata'] = $_POST;
         if ($this->form_validation->run() == FALSE) {
             //if there were errors add them to the errors array
             $data['msg'] .= validation_errors();
         } else {
             // print_array($_POST);
             //ensure that no previous year is entered
             if ($this->input->post('start_year') < 1900) {
                 $data['msg'] = 'ERROR: You can not make a plan for past years';
             } else {
                 $financial_year = trim($this->input->post('start_year')) . '-' . trim($this->input->post('end_year'));
                 //check for duplicity
                 if ($this->session->userdata('isadmin') == 'Y' && !empty($data['i'])) {
                     $plan_info = $this->Query_reader->get_row_as_array('search_table', array('table' => 'procurement_plans', 'limittext' => '', 'orderby' => 'id', 'searchstring' => ' id="' . decryptValue($data['i']) . '" AND isactive="Y"'));
                     $plan_pde = $plan_info['pde_id'];
                 } else {
                     $plan_pde = $this->session->userdata('pdeid');
                 }
                 $similar_plan = $this->db->query($this->Query_reader->get_query_by_code('search_table', array('table' => ' procurement_plans', 'orderby' => '   dateadded', 'limittext' => '', 'searchstring' => ' financial_year = "' . $financial_year . '" AND pde_id = "' . $plan_pde . '" AND isactive="Y"' . (!empty($data['i']) ? ' AND id !="' . decryptValue($data['i']) . '"' : ''))))->result_array();
                 #exit($this->db->last_query());
                 if ($similar_plan) {
                     $data['msg'] = 'ERROR: There is already a plan for the year ' . $financial_year;
                 } elseif ($this->input->post('end_year') != $this->input->post('start_year') + 1) {
                     $data['msg'] = 'ERROR: Invalid end year';
                     //print_array($_POST);
                 } else {
                     $plan_data = array('pde_id' => get_user_info_by_id($this->session->userdata('userid'), 'pde'), 'financial_year' => $financial_year, 'title' => $this->input->post('title'), 'author' => $this->session->userdata('userid'), 'description' => $this->input->post('description'));
                     $this->session->set_userdata('local_allowed_extensions', array('.xls', '.xlsx'));
                     $extramsg = "";
                     $MAX_FILE_SIZE = 1000000;
                     $MAX_FILE_ROWS = 1000;
                     #summarized plan
                     if (!empty($_FILES['summarized_plan']['name'])) {
                         $new_file_name = 'summarizedplan_' . $_POST['start_year'] . '_' . $_POST['end_year'] . '_' . strtotime('now') . generate_random_letter();
                         $plan_data['summarized_plan'] = !empty($_FILES['summarized_plan']['name']) ? $this->sysfile->local_file_upload($_FILES['summarized_plan'], $new_file_name, 'documents/summarizedplans', 'filename') : '';
                     }
                     #detailed plan as well
                     if (!empty($_FILES['detailed_plan']['name'])) {
                         $new_plan_name = 'detailed_plan_' . 'Upload_' . strtotime('now') . generate_random_letter();
                         $_POST['detailed_plan'] = !empty($_FILES['detailed_plan']['name']) ? $this->sysfile->local_file_upload($_FILES['detailed_plan'], $new_plan_name, 'documents', 'filename') : '';
                     }
                     #user is editing
                     if (!empty($_FILES['summarized_plan']['name']) && empty($plan_data['summarized_plan'])) {
                         $data['msg'] = 'ERROR: ' . $this->sysfile->processing_errors;
                     } elseif (!empty($_FILES['detailed_plan']['name']) && empty($_POST['detailed_plan'])) {
                         $data['msg'] = 'ERROR: ' . $this->sysfile->processing_errors;
                     } elseif (!empty($data['i'])) {
                         $project_plan = decryptValue($data['i']);
                         $result = $this->procurement_plan_m->update($project_plan, $plan_data);
                         $result = decryptValue($data['i']);
                     } else {
                         $project_plan = $this->procurement_plan_m->create($plan_data);
                         $result = $project_plan;
                     }
                     if (!empty($result) && $result) {
                         if (!empty($_POST['detailed_plan'])) {
                             $file_url = UPLOAD_DIRECTORY . "documents/" . $_POST['detailed_plan'];
                             $file_size = filesize($file_url);
                             #Break up file if it is bigger than allowed
                             if ($file_size > $MAX_FILE_SIZE) {
                                 $data['file_siblings'] = $this->sysfile->break_up_file($file_url, $MAX_FILE_ROWS);
                                 $this->session->set_userdata('file_siblings', $data['file_siblings']);
                                 $msg = "WARNING: The uploaded file exceeded single processing requirements and was <br>broken up into " . count($data['file_siblings']) . " files. <br><br>Please click on each file, one at a time, to update the procurement plan and <br><a href='" . base_url() . "grades/manage_grades' class='bluelink' style='font-size:17px;'>click here</a> to refresh.";
                             } else {
                                 $result_array = read_excel_data($file_url);
                                 #Remove file after upload
                                 @unlink($file_url);
                                 if (count($result_array)) {
                                     #1. format insert string
                                     #2. sheet 1 is supplies
                                     if (!empty($result_array['Supplies']) && count($result_array['Supplies']) > 9) {
                                         #$project_plan = $this->procurement_plan_entry_m->create_bulk($plan_data);
                                         $sheet_info = $result_array['Supplies'];
                                         $supplies_ins_str = '';
                                         $last_proc_ref_no = procurement_plan_ref_number_hint($this->session->userdata('pdeid'), 1, $financial_year, $project_plan);
                                         $last_proc_ref_no_parts = explode('/', $last_proc_ref_no);
                                         $last_proc_ref_figure = intval(end($last_proc_ref_no_parts));
                                         $rows = array();
                                         $row_ctr = 0;
                                         for ($i = 10; $i < count($sheet_info); $i++) {
                                             if (!empty($sheet_info[$i]['A']) && is_numeric($sheet_info[$i]['A']) && !empty($sheet_info[$i]['C'])) {
                                                 $rows[$row_ctr]['subject_of_procurement'] = $sheet_info[$i]['C'];
                                                 $rows[$row_ctr]['procurement_type'] = 1;
                                                 $rows[$row_ctr]['procurement_method'] = ($sheet_info[$i]['F'] = 'ODB') ? 2 : $sheet_info[$i]['F'];
                                                 $rows[$row_ctr]['pde_department'] = $sheet_info[9]['D'];
                                                 $rows[$row_ctr]['funding_source'] = $sheet_info[9]['E'];
                                                 $rows[$row_ctr]['funder_name'] = $sheet_info[9]['E'];
                                                 $last_proc_ref_no_parts[count($last_proc_ref_no_parts) - 1] = pad_string(++$last_proc_ref_figure, 4);
                                                 $rows[$row_ctr]['procurement_ref_no'] = implode('/', $last_proc_ref_no_parts);
                                                 $rows[$row_ctr]['estimated_amount'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[$i]['D']);
                                                 $rows[$row_ctr]['currency'] = 'usd';
                                                 $rows[$row_ctr]['pre_bid_events_date'] = format_excel_date($sheet_info[$i]['G']);
                                                 $rows[$row_ctr]['pre_bid_events_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['G']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date'] = format_excel_date($sheet_info[$i]['H']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['H']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date'] = format_excel_date($sheet_info[$i]['I']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['I']);
                                                 $rows[$row_ctr]['proposal_submission_date'] = format_excel_date($sheet_info[$i]['J']);
                                                 $rows[$row_ctr]['proposal_submission_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['J']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date'] = format_excel_date($sheet_info[$i]['L']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['L']);
                                                 $rows[$row_ctr]['bid_issue_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_issue_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['secure_necessary_approval_date'] = '';
                                                 $rows[$row_ctr]['secure_necessary_approval_date_duration'] = '';
                                                 $rows[$row_ctr]['contract_award'] = format_excel_date($sheet_info[$i]['Y']);
                                                 $rows[$row_ctr]['contract_award_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['Y']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date'] = format_excel_date($sheet_info[$i]['V']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['V']);
                                                 $rows[$row_ctr]['contract_sign_date'] = format_excel_date($sheet_info[$i]['V']);
                                                 $rows[$row_ctr]['contract_sign_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['V']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['negotiation_date'] = format_excel_date($sheet_info[$i]['O']);
                                                 $rows[$row_ctr]['negotiation_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['O']);
                                                 $rows[$row_ctr]['negotiation_approval_date'] = format_excel_date($sheet_info[$i]['P']);
                                                 $rows[$row_ctr]['negotiation_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['P']);
                                                 $rows[$row_ctr]['advanced_payment_date'] = '';
                                                 $rows[$row_ctr]['advanced_payment_date_duration'] = '';
                                                 $rows[$row_ctr]['mobilise_advance_payment'] = '';
                                                 $rows[$row_ctr]['mobilise_advance_payment_duration'] = '';
                                                 $rows[$row_ctr]['substantial_completion'] = '';
                                                 $rows[$row_ctr]['substantial_completion_duration'] = '';
                                                 $rows[$row_ctr]['final_acceptance'] = '';
                                                 $rows[$row_ctr]['final_acceptance_duration'] = '';
                                                 $rows[$row_ctr]['procurement_plan_id'] = $project_plan;
                                                 $rows[$row_ctr]['author'] = $this->session->userdata('userid');
                                                 $row_ctr++;
                                             }
                                         }
                                         $this->procurement_plan_entry_m->create_bulk($rows);
                                     }
                                     #3. sheet 2 is works
                                     if (!empty($result_array['Works'])) {
                                         #$project_plan = $this->procurement_plan_m->create_bulk($plan_data);
                                         #$project_plan = $this->procurement_plan_entry_m->create_bulk($plan_data);
                                         $sheet_info = $result_array['Supplies'];
                                         $supplies_ins_str = '';
                                         $last_proc_ref_no = procurement_plan_ref_number_hint($this->session->userdata('pdeid'), 1, $financial_year, $project_plan);
                                         $last_proc_ref_no_parts = explode('/', $last_proc_ref_no);
                                         $last_proc_ref_figure = intval(end($last_proc_ref_no_parts));
                                         $rows = array();
                                         $row_ctr = 0;
                                         for ($i = 7; $i < count($sheet_info); $i++) {
                                             if (!empty($sheet_info[$i]['A']) && is_numeric($sheet_info[$i]['A']) && !empty($sheet_info[$i]['C'])) {
                                                 $rows[$row_ctr]['subject_of_procurement'] = $sheet_info[$i]['C'];
                                                 $rows[$row_ctr]['procurement_type'] = 2;
                                                 $rows[$row_ctr]['procurement_method'] = ($sheet_info[$i]['F'] = 'ODB') ? 2 : $sheet_info[$i]['F'];
                                                 $rows[$row_ctr]['pde_department'] = $sheet_info[9]['D'];
                                                 $rows[$row_ctr]['funding_source'] = $sheet_info[9]['E'];
                                                 $rows[$row_ctr]['funder_name'] = $sheet_info[9]['E'];
                                                 $last_proc_ref_no_parts[count($last_proc_ref_no_parts) - 1] = pad_string(++$last_proc_ref_figure, 4);
                                                 $rows[$row_ctr]['procurement_ref_no'] = implode('/', $last_proc_ref_no_parts);
                                                 $rows[$row_ctr]['estimated_amount'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[$i]['D']);
                                                 $rows[$row_ctr]['currency'] = 'usd';
                                                 $rows[$row_ctr]['pre_bid_events_date'] = format_excel_date($sheet_info[$i]['G']);
                                                 $rows[$row_ctr]['pre_bid_events_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['G']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date'] = format_excel_date($sheet_info[$i]['H']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['H']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date'] = format_excel_date($sheet_info[$i]['I']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['I']);
                                                 $rows[$row_ctr]['proposal_submission_date'] = format_excel_date($sheet_info[$i]['J']);
                                                 $rows[$row_ctr]['proposal_submission_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['J']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date'] = format_excel_date($sheet_info[$i]['L']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['L']);
                                                 $rows[$row_ctr]['bid_issue_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_issue_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['secure_necessary_approval_date'] = '';
                                                 $rows[$row_ctr]['secure_necessary_approval_date_duration'] = '';
                                                 $rows[$row_ctr]['contract_award'] = format_excel_date($sheet_info[$i]['Y']);
                                                 $rows[$row_ctr]['contract_award_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['Y']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date'] = format_excel_date($sheet_info[$i]['V']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['V']);
                                                 $rows[$row_ctr]['contract_sign_date'] = format_excel_date($sheet_info[$i]['V']);
                                                 $rows[$row_ctr]['contract_sign_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['V']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['N']);
                                                 $rows[$row_ctr]['negotiation_date'] = format_excel_date($sheet_info[$i]['O']);
                                                 $rows[$row_ctr]['negotiation_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['O']);
                                                 $rows[$row_ctr]['negotiation_approval_date'] = format_excel_date($sheet_info[$i]['P']);
                                                 $rows[$row_ctr]['negotiation_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['P']);
                                                 $rows[$row_ctr]['advanced_payment_date'] = '';
                                                 $rows[$row_ctr]['advanced_payment_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['AC']);
                                                 $rows[$row_ctr]['mobilise_advance_payment'] = format_excel_date($sheet_info[$i]['AA']);
                                                 $rows[$row_ctr]['mobilise_advance_payment_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['AA']);
                                                 $rows[$row_ctr]['substantial_completion'] = format_excel_date($sheet_info[$i]['AB']);
                                                 $rows[$row_ctr]['substantial_completion_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['AB']);
                                                 $rows[$row_ctr]['final_acceptance'] = format_excel_date($sheet_info[$i]['AC']);
                                                 $rows[$row_ctr]['final_acceptance_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['AC']);
                                                 $rows[$row_ctr]['procurement_plan_id'] = $project_plan;
                                                 $rows[$row_ctr]['author'] = $this->session->userdata('userid');
                                                 $row_ctr++;
                                             }
                                         }
                                         $this->procurement_plan_entry_m->create_bulk($rows);
                                     }
                                     #4. sheet 3 is services
                                     if (!empty($result_array['Services'])) {
                                         $sheet_info = $result_array['Services'];
                                         $supplies_ins_str = '';
                                         $last_proc_ref_no = procurement_plan_ref_number_hint($this->session->userdata('pdeid'), 1, $financial_year, $project_plan);
                                         $last_proc_ref_no_parts = explode('/', $last_proc_ref_no);
                                         $last_proc_ref_figure = intval(end($last_proc_ref_no_parts));
                                         $rows = array();
                                         $row_ctr = 0;
                                         for ($i = 8; $i < count($sheet_info); $i++) {
                                             if (!empty($sheet_info[$i]['A']) && is_numeric($sheet_info[$i]['A']) && !empty($sheet_info[$i]['C'])) {
                                                 $rows[$row_ctr]['subject_of_procurement'] = $sheet_info[$i]['C'];
                                                 $rows[$row_ctr]['procurement_type'] = 3;
                                                 $rows[$row_ctr]['procurement_method'] = ($sheet_info[$i]['F'] = 'ODB') ? 2 : $sheet_info[$i]['F'];
                                                 $rows[$row_ctr]['pde_department'] = $sheet_info[9]['D'];
                                                 $rows[$row_ctr]['funding_source'] = $sheet_info[9]['E'];
                                                 $rows[$row_ctr]['funder_name'] = $sheet_info[9]['E'];
                                                 $last_proc_ref_no_parts[count($last_proc_ref_no_parts) - 1] = pad_string(++$last_proc_ref_figure, 4);
                                                 $rows[$row_ctr]['procurement_ref_no'] = implode('/', $last_proc_ref_no_parts);
                                                 $rows[$row_ctr]['estimated_amount'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[$i]['D']);
                                                 $rows[$row_ctr]['currency'] = 'usd';
                                                 $rows[$row_ctr]['pre_bid_events_date'] = format_excel_date($sheet_info[$i]['G']);
                                                 $rows[$row_ctr]['pre_bid_events_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[7]['G']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date'] = format_excel_date($sheet_info[$i]['H']);
                                                 $rows[$row_ctr]['contracts_committee_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['H']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date'] = format_excel_date($sheet_info[$i]['I']);
                                                 $rows[$row_ctr]['publication_of_pre_qualification_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['I']);
                                                 $rows[$row_ctr]['proposal_submission_date'] = format_excel_date($sheet_info[$i]['J']);
                                                 $rows[$row_ctr]['proposal_submission_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['J']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date'] = format_excel_date($sheet_info[$i]['L']);
                                                 $rows[$row_ctr]['contracts_committee_approval_of_shortlist_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['L']);
                                                 $rows[$row_ctr]['bid_issue_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_issue_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['bid_submission_opening_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['N']);
                                                 $rows[$row_ctr]['bid_closing_date'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['O']);
                                                 $rows[$row_ctr]['submission_of_evaluation_report_to_cc'] = format_excel_date($sheet_info[$i]['P']);
                                                 $rows[$row_ctr]['submission_of_evaluation_report_to_cc_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['P']);
                                                 $rows[$row_ctr]['secure_necessary_approval_date'] = '';
                                                 $rows[$row_ctr]['secure_necessary_approval_date_duration'] = '';
                                                 $rows[$row_ctr]['contract_award'] = format_excel_date($sheet_info[$i]['X']);
                                                 $rows[$row_ctr]['contract_award_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['X']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date'] = format_excel_date($sheet_info[$i]['V']);
                                                 $rows[$row_ctr]['best_evaluated_bidder_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['V']);
                                                 $rows[$row_ctr]['contract_sign_date'] = format_excel_date($sheet_info[$i]['Y']);
                                                 $rows[$row_ctr]['contract_sign_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['Y']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report'] = format_excel_date($sheet_info[$i]['N']);
                                                 $rows[$row_ctr]['cc_approval_of_evaluation_report_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['N']);
                                                 $rows[$row_ctr]['contract_amount_in_ugx'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[$i]['U']);
                                                 $rows[$row_ctr]['negotiation_date'] = format_excel_date($sheet_info[$i]['R']);
                                                 $rows[$row_ctr]['negotiation_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['R']);
                                                 $rows[$row_ctr]['negotiation_approval_date'] = format_excel_date($sheet_info[$i]['S']);
                                                 $rows[$row_ctr]['negotiation_approval_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['S']);
                                                 $rows[$row_ctr]['advanced_payment_date'] = format_excel_date($sheet_info[$i]['AA']);
                                                 $rows[$row_ctr]['advanced_payment_date_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['AA']);
                                                 $rows[$row_ctr]['mobilise_advance_payment'] = format_excel_date($sheet_info[$i]['AA']);
                                                 $rows[$row_ctr]['mobilise_advance_payment_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['AA']);
                                                 $rows[$row_ctr]['substantial_completion'] = '';
                                                 $rows[$row_ctr]['substantial_completion_duration'] = '';
                                                 $rows[$row_ctr]['final_acceptance'] = '';
                                                 $rows[$row_ctr]['final_acceptance_duration'] = '';
                                                 $rows[$row_ctr]['procurement_plan_id'] = $project_plan;
                                                 $rows[$row_ctr]['author'] = $this->session->userdata('userid');
                                                 $rows[$row_ctr]['solicitor_general_approval_date'] = format_excel_date($sheet_info[$i]['AA']);
                                                 $rows[$row_ctr]['solicitor_general_approval_duration'] = preg_replace("/[^0-9\\.]/", '', $sheet_info[8]['Y']);
                                                 $row_ctr++;
                                             }
                                         }
                                         $this->procurement_plan_entry_m->create_bulk($rows);
                                     }
                                 }
                             }
                         }
                         //generate notification
                         #$recipients = get_users_by_group(20, get_user_info_by_id($this->session->userdata('userid'), 'pde'));
                         #$message = 'New financial plan <b>' . $this->input->post('title') . '</b> for the year ' . $financial_year . ' had been added by <b>' . get_user_info_by_id($this->session->userdata('userid'), 'fullname') . '</b> on ' . mysqldate();
                         #send_notification($recipients, 'New Annual Procurement Plan Created', 'Annual Plan Creation Alert', $message);
                         $this->session->set_userdata('usave', 'You have successfully created the ' . $financial_year . ' procurement plan');
                         redirect("procurement/page/m/usave");
                     } elseif (empty($data['msg'])) {
                         $data['msg'] = 'ERROR: Plan was not created. Please try again';
                         //echo $this->db->_error_message();
                     }
                     //===================================================================================
                 }
             }
         }
     }
     $data['page_title'] = (!empty($data['i']) ? 'Edit ' : ' New ') . get_pde_info_by_id(get_user_info_by_id($this->session->userdata('userid'), 'pde'), 'title') . ' Procurement plan';
     $data['current_menu'] = 'create_procurement_plan';
     $data['pde_title'] = get_pde_info_by_id(get_user_info_by_id($this->session->userdata('userid'), 'pde'), 'title');
     $data['pde_id'] = get_user_info_by_id($this->session->userdata('userid'), 'pde');
     $data['view_to_load'] = 'procurement/admin/new_plan_v';
     $data['view_data']['form_title'] = $data['page_title'];
     $this->load->view('dashboard_v', $data);
 }
Beispiel #8
0
 function settings()
 {
     access_control($this);
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(3, array('i'));
     # Pick all assigned data
     $data = assign_to_data($urldata);
     #Get user settings
     $editid = $this->session->userdata('userid');
     if ($this->session->userdata('usertype') == 'SCHOOL') {
         $data['formdata'] = $this->Query_reader->get_row_as_array('get_school_user_by_id', array('id' => $editid));
     } elseif ($this->session->userdata('usertype') == 'MSR') {
         $data['formdata'] = $this->Query_reader->get_row_as_array('get_user_by_id', array('id' => $editid));
     }
     $data['isview'] = !empty($data['a']) && decryptValue($data['a']) == 'view' ? "Y" : "";
     if ($this->input->post('savesettings')) {
         $required_fields = array('firstname', 'lastname', 'address', 'emailaddress*EMAILFORMAT', 'telephone');
         $_POST = clean_form_data($_POST);
         $validation_results = validate_form('', $_POST, $required_fields);
         $update_string = '';
         #Only proceed if the validation for required fields passes
         if ($validation_results['bool']) {
             #Check if the password has been changed, is strong enough and the repeated value is the same
             if (!empty($_POST['password']) || !empty($_POST['repeatpassword'])) {
                 $passwordmsg = $this->user1->check_password_strength($_POST['password']);
                 if (!$passwordmsg['bool']) {
                     $data['msg'] = "WARNING: " . $passwordmsg['msg'];
                 } elseif ($_POST['password'] == $_POST['repeatpassword']) {
                     $update_string = ", password = '******'password']) . "'";
                 } else {
                     $data['msg'] = "WARNING: The passwords provided do not match.";
                 }
             }
             #Check if a new photo has been uploaded
             if (!empty($_FILES['imageurl']['tmp_name'])) {
                 $new_file_url = 'ac_' . strtotime('now') . generate_random_letter() . "." . end(explode('.', $_FILES['imageurl']['name']));
                 if (copy($_FILES['imageurl']['tmp_name'], UPLOAD_DIRECTORY . "users/" . $new_file_url)) {
                     #Create a thumb nail as well
                     $config['image_library'] = 'gd2';
                     $config['source_image'] = UPLOAD_DIRECTORY . "users/" . $new_file_url;
                     $config['create_thumb'] = TRUE;
                     $config['maintain_ratio'] = TRUE;
                     $config['width'] = 100;
                     $config['height'] = 80;
                     $this->load->library('image_lib', $config);
                     $this->image_lib->resize();
                     #Delete the previous image from the server if it exists
                     if (!empty($data['formdata']['photo'])) {
                         @unlink(UPLOAD_DIRECTORY . "users/" . $data['formdata']['photo']);
                     }
                     $update_string .= ',photo ="' . $new_file_url . '"';
                 }
             }
             #Update or Save the new form data
             if (empty($data['msg'])) {
                 if ($this->session->userdata('usertype') == 'SCHOOL') {
                     $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_school_user_data', array_merge(array('editid' => $editid, 'usertype' => $this->session->userdata('usertype'), 'usergroup' => $this->session->userdata('usergroup'), 'isschooladmin' => $this->session->userdata('isschooladmin'), 'updatecond' => $update_string), $_POST)));
                 } elseif ($this->session->userdata('usertype') == 'MSR') {
                     $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_user_data', array('editid' => $editid, 'firstname' => $_POST['firstname'], 'lastname' => $_POST['lastname'], 'middlename' => $_POST['middlename'], 'addressline1' => $_POST['addressline1'], 'emailaddress' => $_POST['emailaddress'], 'telephone' => $_POST['telephone'], 'usertype' => $this->session->userdata('usertype'), 'isadmin' => $_POST['isadmin'], 'updatecond' => $update_string)));
                 }
                 $msg = !empty($save_result) && $save_result ? "Your settings have been saved." : "ERROR: Your settings were not saved.";
                 $this->session->set_userdata('sres', $msg);
                 redirect($this->user1->get_dashboard() . "/m/sres");
             }
         }
         #VALIDATION end
         if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) {
             $data['msg'] = "WARNING: The highlighted fields are required.";
         }
         $data['requiredfields'] = $validation_results['requiredfields'];
         $data['formdata'] = $_POST;
     }
     if (empty($data['formdata'])) {
         $this->session->set_userdata('suser', "ERROR: Your settings could not be resolved.");
         redirect($this->user1->get_dashboard() . "/m/suser");
     }
     $data = add_msg_if_any($this, $data);
     $this->load->view('admin/settings_view', $data);
 }