Exemplo n.º 1
0
 function save_user()
 {
     $this->load->model('email_handler', 'emailhandler');
     #Pick the user name and password if th euser is editing
     if ($this->input->post('editid')) {
         $user_array = $this->Query_reader->get_row_as_array('pick_employee_by_id', array('id' => $_POST['editid']));
         $_POST['username'] = $user_array['username'];
         $_POST['password'] = $user_array['password'];
     }
     $_POST['passwordexpirydate'] = changeDateFromPageToMySQLFormat($_POST['passwordexpirydate']);
     # Display appropriate message based on the results
     if ($this->input->post('save') && $this->process_form_data($urldata, $_POST, 'save')) {
         $this->session->set_userdata('usersave', 'The user data was successfully saved.');
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $msg = "ERROR: The user data was not saved or may not be saved correctly. Please contact your administrator.";
         # Check if error is because user with email already exists
         if (!$this->input->post('editid')) {
             $msg .= $this->Control_check->check_if_already_exists('pick_employee_by_email', array('emailaddress' => $_POST['emailaddress']));
         }
         $this->session->set_userdata('usersave', $msg);
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $users_array = $this->db->query($this->Query_reader->get_query_by_code('get_company_users', array('companyid' => $id)));
     $data['user_array'] = $users_array->result_array();
     $data['user_array_count'] = $users_array->num_rows();
     $this->load->view('companyprofile/manageusers', $data);
 }
Exemplo n.º 2
0
 function save_step1()
 {
     security($this);
     $urldata = $this->uri->uri_to_assoc(4, array('m', 'action'));
     $data = assign_to_data($urldata);
     $_POST['dateestablished'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
     # If a file has been uploaded, and there are no errors process it before continuing
     if (trim($_FILES['companylogo']['name']) != '' && $_FILES['companylogo']['error'] == '' && $this->input->post('editid')) {
         #The file name
         $file_stamp = 'companylogo_' . $_POST['editid'];
         # Upload the file and return the results of the upload
         $processing_results = $this->acravfile->perfom_file_upload($this->libfileobj, $_FILES['companylogo'], $file_stamp, UPLOAD_DIRECTORY, $this->session->userdata('local_allowed_extensions'));
         $_FILES['companylogo']['error'] = $processing_results['errors'];
         # Will be saved in the database as the event's document file name
         $_POST['companylogo'] = $processing_results['filename'];
     }
     # Display appropriate message based on the results
     if ($this->input->post('save') && (isset($_FILES['companylogo']['error']) && $_FILES['companylogo']['error'] == "" || !isset($_POST['companylogo'])) && $this->process_form_data($urldata, $_POST, 'save')) {
         $data['msg'] = "The company data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The company data was not saved or may not be saved correctly. Please contact your administrator.";
     }
     $data['action'] = 'view';
     $data['id'] = $this->input->post('editid');
     # User is updating the company profile
     if (isset($data['id'])) {
         $data['companydetails'] = $this->Query_reader->get_row_as_array('pick_company_and_user_by_id', array('companyid' => $data['id']));
     }
     $this->load->view('companyprofile/managecompany', $data);
 }
Exemplo n.º 3
0
    function save_truck()
    {
        $truckid = $this->session->userdata('sess_id');
        $data['truck_id'] = $truckid;
        $data['url2'] = 'acc';
        # Get the passed details into the url data array if any
        $urldata = $this->uri->uri_to_assoc(4, array('action', 'accident_id'));
        $_POST['total'] = $_POST['qty'] * $_POST['cost'];
        $_POST['occured'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
        # Display appropriate message based on the results
        if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
            # Load view base on where the user wants to go
            if ($this->input->post('saveandnew')) {
                $view_to_load = 'managetruck/specif ications';
            }
            $data['msg'] = "The truck accident was successfully saved.";
        } else {
            # For each error to be displayed as an error, it should start with "ERROR:"
            $data['msg'] = "ERROR: The truck data was not saved or may not be saved correctly.";
            # Check if error is because query already exists
            if ($urldata['truck_id'] === FALSE) {
                $data['msg'] .= $this->Control_check->check_if_already_exists('pick_truck_by_regno', array('regnumber' => $_POST['regnumber']));
            }
        }
        if ($urldata['accident_id'] !== FALSE) {
            $data['accident_id'] = $urldata['accident_id'];
            $data['userdetails'] = $this->session->userdata('alluserdata');
            $id = $data['userdetails']['companyid'];
            $truckid = $this->session->userdata('sess_id');
            $data['truck_id'] = $truckid;
            $data['truckaccident'] = $this->Query_reader->get_row_as_array('pick_accident_by_id', array('accident_id' => $urldata['accident_id']));
        }
        $data['url2'] = 'acc';
        $data['companytruckdetails'] = $this->Query_reader->get_row_as_array('pick_truck_by_id', array('truck_id' => $truckid));
        $data['userdetails'] = $this->session->userdata('alluserdata');
        $id = $data['userdetails']['companyid'];
        $query2 = $this->Query_reader->get_query_by_code('pick_drivers_by_company_id', array('companyid' => $id));
        $result2 = $this->db->query($query2);
        $data['companydriverdetails'] = $result2->result_array();
        $result = $this->db->query('SELECT
accidents.company_id,
drivers.fname,
drivers.lname,
drivers.driver_id,
accidents.occured,
accidents.date_created,
accidents.truck_id,
accidents.accident_id
FROM
drivers
LEFT OUTER JOIN accidents ON drivers.driver_id = accidents.driver_id
WHERE
accidents.company_id = "' . $id . '" AND
accidents.truck_id = "' . $truckid . '"');
        $data['returned'] = $result->num_rows();
        $data['accident_array'] = $result->result_array();
        $this->load->view('managetruck/specifications', $data);
    }
Exemplo n.º 4
0
    function save_truck()
    {
        $truckid = $this->session->userdata('sess_id');
        $data['url2'] = 'rm';
        $data['truck_id'] = $truckid;
        # Get the passed details into the url data array if any
        $urldata = $this->uri->uri_to_assoc(4, array('action', 'service_id'));
        $_POST['duenext'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
        #
        # Display appropriate message based on the results
        if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
            # Load view base on where the user wants to go
            if ($this->input->post('save')) {
                $view_to_load = 'managetruck/specifications';
            }
            $data['msg'] = "The truck data was successfully saved.";
        } else {
            # For each error to be displayed as an error, it should start with "ERROR:"
            $data['msg'] = "ERROR: The truck data was not saved or may not be saved correctly.";
            # Check if error is because query already exists
            if ($urldata['Service_id'] === FALSE) {
                $data['msg'] .= $this->Control_check->check_if_already_exists('pick_truck_by_regno', array('regnumber' => $_POST['regnumber']));
            }
        }
        $truckid = $this->session->userdata('sess_id');
        $data['truck_id'] = $truckid;
        $data['companytruckdetails'] = $this->Query_reader->get_row_as_array('pick_truck_by_id', array('truck_id' => $truckid));
        $data['userdetails'] = $this->session->userdata('alluserdata');
        $id = $data['userdetails']['companyid'];
        $rd = "N";
        $data['ty'] = date("Y-m-d");
        $tym = date("Y-m-d");
        $data['userdetails'] = $this->session->userdata('alluserdata');
        $id = $data['userdetails']['companyid'];
        $rd = "N";
        $tym = date("Y-m-d");
        $result = $this->db->query('SELECT trucks.regnumber, services.`name`, services.duenext, services.service_id, services.truck_id,
                                   services.company_id FROM services INNER JOIN trucks ON trucks.truck_id = services.truck_id
                                    WHERE services.company_id = "' . $id . '" AND "' . $tym . '" >= services.lastdate AND trucks.odoqui >=                                     services.set_odo AND services.regnsd = "' . $rd . '"');
        $data['returned'] = $result->num_rows();
        $data['rm'] = $data['returned'];
        $data['service_array'] = $result->result_array();
        //insurance remiders
        $result2 = $this->db->query('SELECT trucks.show_lice_on, trucks.inscompany, trucks.endlicedate, trucks.enddate, trucks.show_ins_on,
                                  trucks.regnumber  FROM  trucks WHERE trucks.company_id = "' . $id . '" AND "' . $tym . '" 
								  >=trucks.show_ins_on');
        $data['ins'] = $result2->num_rows();
        $data['insnumm'] = $data['ins'];
        $data['ins_array'] = $result2->result_array();
        //licence reminders
        $result3 = $this->db->query('SELECT trucks.show_lice_on, trucks.endlicedate, trucks.regnumber FROM trucks WHERE "' . $tym . '" >=                                   trucks.show_lice_on AND trucks.company_id = "' . $id . '"');
        $data['lic'] = $result3->num_rows();
        $data['licnumm'] = $data['lic'];
        $data['lic_array'] = $result3->result_array();
        $this->load->view('managetruck/specifications', $data);
    }
Exemplo n.º 5
0
 function save_driver()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(4, array('driver_id', 'action'));
     $_POST['dateofbirth'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
     # If a file has been uploaded, and there are no errors process it before continuing
     if (trim($_FILES['driverphoto']['name']) != '' && $_FILES['driverphoto']['error'] == '' && $this->input->post('editid')) {
         #The file name
         $file_stamp = 'driverphoto_' . $_POST['editid'];
         # Upload the file and return the results of the upload
         $processing_results = $this->acravfile->perfom_file_upload($this->libfileobj, $_FILES['driverphoto'], $file_stamp, UPLOAD_DIRECTORY, $this->session->userdata('local_allowed_extensions'));
         $_FILES['driverphoto']['error'] = $processing_results['errors'];
         # Will be saved in the database as the event's document file name
         $_POST['driverphoto'] = $processing_results['filename'];
     }
     # Display appropriate message based on the results
     if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
         # Load view base on where the user wants to go
         if ($this->input->post('save')) {
             $view_to_load = 'userprofile/drivers';
         }
         $data['msg'] = "The driver data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The driver data was not saved or may not be saved correctly.";
         # Check if error is because query already exists
         if ($urldata['driver_id'] === FALSE) {
             $data['msg'] .= $this->Control_check->check_if_already_exists('pick_driver_by_name', array('fname' => $_POST['fname']));
         }
     }
     if (!isset($view_to_load)) {
         $data['userdetails'] = $this->session->userdata('alluserdata');
         $id = $data['userdetails']['companyid'];
         $data['id'] = $id;
         $query = $this->Query_reader->get_query_by_code('pick_drivers_by_company_id', array('companyid' => $id));
         $result = $this->db->query($query);
         $data['returned'] = $result->num_rows();
         $data['companydriverdetails'] = $result->result_array();
         $view_to_load = 'userprofile/drivers';
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $data['id'] = $id;
     $query = $this->Query_reader->get_query_by_code('pick_drivers_by_company_id', array('companyid' => $id));
     $result = $this->db->query($query);
     $data['returned'] = $result->num_rows();
     $data['companydriverdetails'] = $result->result_array();
     $this->load->view('userprofile/drivers', $data);
 }
Exemplo n.º 6
0
 function save_truck()
 {
     $truckid = $this->session->userdata('sess_id');
     $data['truck_id'] = $truckid;
     $data['url2'] = 'pur';
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(4, array('action', 'truck_id'));
     $_POST['datebought'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
     $_POST['warrdate'] = changeDateFromPageToMySQLFormat($_POST['startyear5'] . "-" . $_POST['startmonth5'] . "-" . $_POST['startday5']);
     $_POST['datesold'] = changeDateFromPageToMySQLFormat($_POST['startyear2'] . "-" . $_POST['startmonth2'] . "-" . $_POST['startday2']);
     #
     if (is_array($_POST['allowedcargo'])) {
         foreach ($_POST['allowedcargo'] as $value) {
             #
             $_POST['allowedcargo'] = $value;
             #
         }
     }
     # Display appropriate message based on the results
     if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
         # Load view base on where the user wants to go
         if ($this->input->post('save')) {
             $view_to_load = 'managetruck/specifications';
         }
         $data['msg'] = "The truck data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The truck data was not saved or may not be saved correctly.";
         # Check if error is because query already exists
         if ($urldata['truck_id'] === FALSE) {
             $data['msg'] .= $this->Control_check->check_if_already_exists('pick_truck_by_regno', array('regnumber' => $_POST['regnumber']));
         }
     }
     if ($truckid !== FALSE) {
         $data['truck_id'] = $truckid;
         $data['companytruckdetails'] = $this->Query_reader->get_row_as_array('pick_truck_by_id', array('truck_id' => $truckid));
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $query = $this->Query_reader->get_query_by_code('pick_all_trucks', array('company_id' => $id));
     $result = $this->db->query($query);
     $data['returned'] = $result->num_rows();
     $data['truck_array'] = $result->result_array();
     $this->load->view('managetruck/specifications', $data);
 }
Exemplo n.º 7
0
 function save_user()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(4, array('user_id'));
     $_POST['passwordexpirydate'] = changeDateFromPageToMySQLFormat($_POST['passwordexpirydate']);
     $_POST['username'] = generate_user_details($this->db->insert_id(), 'username');
     $pass = generate_user_details($this->db->insert_id(), 'password');
     $_POST['password'] = md5($pass);
     $_POST['iscoplete'] = 'Y';
     $_POST['isactive'] = 'Y';
     //$this->email->from('*****@*****.**', 'FROM**ACRAV Website Administration**'.SITE_ADMIN_MAILID.'');
     //$this->email->to("'".$_POST['emailaddress']."'");
     //$this->email->cc('*****@*****.**');
     //$this->email->bcc('*****@*****.**');
     $link = base_url() . "index.php/user/login.html";
     $msg = "Dear " . $_POST['firstname'] . "" . "\r\n" . "" . "Your account on Automated Cargo Route and Vehicle Management (ACRAV) has been created" . "\r\n" . "Please click the link below (or copy and paste the complete URL into your browser) and " . "login to start using ACRAV:" . "\r\n" . "http://" . $link . "" . "\r\n" . "These are your login details:" . "\r\n" . "User Name: " . $_POST['username'] . "\r\n" . "Password: "******"";
     //$this->email->subject('Your ACRAV account has been created');
     //$this->email->message("".$msg."");
     //$this->email->send();
     $to = $_POST['emailaddress'];
     $subject = "Your ACRAV account has been created";
     $message = "Hello! This is a simple email message.";
     $from = "*****@*****.**";
     $headers = "FROM**ACRAV Website Administration**'" . SITE_ADMIN_MAILID . "";
     mail($to, $subject, $msg, $headers);
     # Display appropriate message based on the results
     if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
         # Load view base on where the user wants to go
         if ($this->input->post('save')) {
             $view_to_load = 'userprofile/users';
         }
         $data['msg'] = "The user data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The user data was not saved or may not be saved correctly.";
         # Check if error is because query already exists
         if ($urldata['user_id'] === FALSE) {
             $data['msg'] .= $this->Control_check->check_if_already_exists('pick_user_by_email', array('emailaddress' => $_POST['emailaddress']));
         }
     }
     if (!isset($view_to_load)) {
         $data['userdetails'] = $this->session->userdata('alluserdata');
         $id = $data['userdetails']['companyid'];
         $query = $this->Query_reader->get_query_by_code('pick_all_users', array('company_id' => $id));
         $result = $this->db->query($query);
         $data['returned'] = $result->num_rows();
         $data['user_array'] = $result->result_array();
         $view_to_load = 'userprofile/users';
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $query = $this->Query_reader->get_query_by_code('pick_all_users', array('company_id' => $id));
     $result = $this->db->query($query);
     $data['returned'] = $result->num_rows();
     $data['user_array'] = $result->result_array();
     $data['curPage'] = 'company';
     $data['service'] = $this->reminder->get_reminders();
     $data['insurance'] = $this->reminder->insurance_reminder();
     $data['license'] = $this->reminder->license_reminder();
     // notices
     $this->db->where('to_employee', $data['userdetails']['userid']);
     $this->db->where('has_read', '0');
     $notices = $this->db->get('notice_details');
     $data['count_notices'] = $notices->num_rows();
     $data['notice_details'] = $notices->result_array();
     $this->load->view('companyprofile/manageusers', $data);
 }
Exemplo n.º 8
0
 /**
  * Populate the attributes of the object with the data. Also add the auditing data, createdby and lastupdatedby to 
  * the relationships if not specified
  *
  * @param Array $post_array The array of data values to populate the object attributes
  * @return boolean true if the object validates after populaton, or false if there are any validation errors
  */
 function processPost($post_array)
 {
     // $post_array = trimArray($post_array);
     # format the date fields
     foreach ($this->datefields as $fieldname) {
         if (isArrayKeyAnEmptyString($fieldname, $post_array)) {
             // remove the empty string from the array otherwise the date will be set to January 1, 1970
             unset($post_array[$fieldname]);
         } else {
             $post_array[$fieldname] = changeDateFromPageToMySQLFormat($post_array[$fieldname]);
             // TODO: SM - 09/17/10 - Cleanup this funny hack for dates,
             // I am not sure why new values for the dates are not picked up,
             // make the dates an empty string so that they can be updated
             $this->_set($fieldname, "");
         }
     }
     $relations = $this->getTable()->getRelations();
     # loop through each relation and add auditing fields
     foreach ($relations as $alias => $arelation) {
         if (!isArrayKeyAnEmptyString($alias, $post_array)) {
             foreach ($post_array[$alias] as $key => $value) {
                 # force the loading of only the hasOne relationships to conserve memory
                 if ($arelation['type'] == 0) {
                     $this->{$alias};
                 }
                 if (!isArrayKeyAnEmptyString('createdby', $post_array)) {
                     // add createdby to each relation
                     if ($arelation['type'] == 0) {
                         // hasOne so only one item in the relation
                         $post_array[$alias]['createdby'] = $post_array['createdby'];
                     } else {
                         // hasMany, use a key to populate each item in the relation
                         $post_array[$alias][$key]['createdby'] = $post_array['createdby'];
                     }
                 }
                 // check if the createdby field is still empty then use the lastupdatedby field since the relation is new
                 if (isArrayKeyAnEmptyString('createdby', $post_array[$alias])) {
                     if (!isArrayKeyAnEmptyString('lastupdatedby', $post_array)) {
                         if ($arelation['type'] == 0) {
                             // hasOne so only one item in the relation
                             $post_array[$alias]['createdby'] = $post_array['lastupdatedby'];
                         } else {
                             // hasMany, use a key to populate each item in the relation
                             $post_array[$alias][$key]['createdby'] = $post_array['lastupdatedby'];
                         }
                     }
                 }
                 if (!isArrayKeyAnEmptyString('lastupdatedby', $post_array)) {
                     // add lastupdatedby to each data item
                     if ($arelation['type'] == 0) {
                         // hasOne so only one item in the relation
                         $post_array[$alias]['lastupdatedby'] = $post_array['lastupdatedby'];
                     } else {
                         // hasMany, use a key to populate each item in the relation
                         $post_array[$alias][$key]['lastupdatedby'] = $post_array['lastupdatedby'];
                     }
                 }
                 // remove any empty id columns
                 if ($arelation['type'] == 0) {
                     // unset any empty id columns which have been sent - hasOne
                     if (isArrayKeyAnEmptyString('id', $post_array[$alias])) {
                         // remove the empty id field
                         unset($post_array[$alias]['id']);
                     }
                 } else {
                     // unset any empty id columns which have been sent - hasMany
                     if (isArrayKeyAnEmptyString('id', $post_array[$alias][$key])) {
                         // remove the empty id field
                         unset($post_array[$alias][$key]['id']);
                     }
                 }
             }
         }
         // end check whether alias exists in the data for population to eliminate PHP warnings
     }
     # remove the ID field if it is empty
     if (isArrayKeyAnEmptyString('id', $post_array)) {
         unset($post_array['id']);
     }
     $this->synchronizeWithArray($post_array, true);
     return $this->isValid(true);
 }
Exemplo n.º 9
0
 function updateFromArray($table, $data, $id_field, $id_value, $fieldstoignore = array(), $datefields = array(), $password_field = array(), $foreignkeyfields = array())
 {
     # check the table name
     if (trim($table) == "") {
         $this->setError("There is no table specified");
         return false;
     }
     # no data
     if (count($data) == 0) {
         $this->setError("There is no data specified");
         return false;
     }
     # no id field
     if (trim($id_field) == "") {
         $this->setError("There is no id field specified");
         return false;
     }
     # no id field
     if (trim($id_value) == "") {
         $this->setError("There is no id value specified, cannot update all the rows in the table");
         return false;
     }
     foreach ($data as $field => $value) {
         #check whether the field exists in the array of field to ignore.
         #If it does do not add it to the query fields
         if (!in_array($field, $fieldstoignore)) {
             #check whether the field is a date field, if it is do not
             #escape it using the mysql escape characters or quotation marks
             if (in_array($field, $datefields)) {
                 $fields[] = sprintf("`%s` = %s", $field, changeDateFromPageToMySQLFormat($value));
             } else {
                 if (in_array($field, $password_field)) {
                     $fields[] = sprintf("`%s` = %s", $field, "SHA('" . mysql_real_escape_string($value) . "')");
                 } else {
                     if (in_array($field, $foreignkeyfields)) {
                         // possible values that result into a null foreign key
                         if (isEmptyString($value) or strval($value) == "0" or strtolower($value) == "null") {
                             $fields[] = sprintf("`%s` = %s", $field, 'NULL');
                         } else {
                             $fields[] = sprintf("`%s` = '%s'", $field, mysql_real_escape_string($value));
                         }
                     } else {
                         $fields[] = sprintf("`%s` = '%s'", $field, mysql_real_escape_string($value));
                     }
                 }
             }
         }
     }
     $field_list = join(',', $fields);
     $query = sprintf("UPDATE `%s` SET %s WHERE `%s` = %s", $table, $field_list, $id_field, intval($id_value));
     //echo "<br>Update query: <br>".$query."<br>";exit;
     $result = $this->CI->db->query($query);
     if (!$result) {
         # error occured
         $this->setError("An error occured while updating the database. Please try again later" . $this->CI->db->_error_message());
         return false;
     } else {
         # return the number of rows updated
         return $result;
     }
 }
Exemplo n.º 10
0
 function save_driver()
 {
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(4, array('driver_id', 'action'));
     $_POST['dateofbirth'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
     # If a file has been uploaded, and there are no errors process it before continuing
     $_POST['driverphoto'] = $_FILES['driverphoto']['name'];
     if (!empty($_POST['driverphoto'])) {
         $_POST['driverphoto'] = $_POST['driverphoto'];
     } else {
         $_POST['driverphoto'] = $_POST['dphoto'];
     }
     $config['upload_path'] = './system/application/views/documents/';
     $config['allowed_types'] = 'gif|jpg|png|pdf|doc';
     $config['max_size'] = '70000000000000';
     $config['max_width'] = '1024000000000';
     $config['max_height'] = '768000000000';
     $this->load->library('upload', $config);
     if ($this->upload->do_upload('driverphoto')) {
         $data = $this->upload->data();
     }
     # Display appropriate message based on the results
     if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
         # Load view base on where the user wants to go
         if ($this->input->post('save')) {
             $view_to_load = 'userprofile/drivers';
         }
         $data['msg'] = "The driver data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The driver data was not saved or may not be saved correctly.";
         # Check if error is because query already exists
         if ($urldata['driver_id'] === FALSE) {
             $data['msg'] .= $this->Control_check->check_if_already_exists('pick_driver_by_name', array('fname' => $_POST['fname']));
         }
     }
     if ($urldata['driver_id'] !== FALSE) {
         $data['driver_id'] = $urldata['driver_id'];
         $data['driverdetails'] = $this->Query_reader->get_row_as_array('pick_driver_by_id', array('driver_id' => $urldata['driver_id']));
     }
     if (!isset($view_to_load)) {
         $data['userdetails'] = $this->session->userdata('alluserdata');
         $id = $data['userdetails']['companyid'];
         $data['id'] = $id;
         $result = $this->db->query('SELECT drivers.fname, drivers.lname,drivers.telephone1,drivers.driver_id, trucks.regnumber
            FROM  cur_drivers RIGHT OUTER JOIN drivers ON drivers.driver_id = cur_drivers.driver_id
            LEFT OUTER JOIN trucks ON drivers.driver_id = trucks.driver_id AND trucks.truck_id = cur_drivers.truck_id
            WHERE drivers.company_id = "' . $id . '"');
         $data['returned'] = $result->num_rows();
         $data['companydriverdetails'] = $result->result_array();
         $view_to_load = 'userprofile/drivers';
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $data['id'] = $id;
     $result = $this->db->query('SELECT drivers.fname, drivers.lname,drivers.telephone1,drivers.driver_id, trucks.regnumber
                                 FROM cur_drivers RIGHT OUTER JOIN drivers ON drivers.driver_id = cur_drivers.driver_id
                     LEFT OUTER JOIN trucks ON drivers.driver_id = trucks.driver_id AND trucks.truck_id = cur_drivers.truck_id
                            WHERE drivers.company_id = "' . $id . '"');
     $data['returned'] = $result->num_rows();
     $data['companydriverdetails'] = $result->result_array();
     $data['curPage'] = 'company';
     $data['service'] = $this->reminder->get_reminders();
     $data['insurance'] = $this->reminder->insurance_reminder();
     $data['license'] = $this->reminder->license_reminder();
     $this->load->view('userprofile/drivers', $data);
 }
Exemplo n.º 11
0
    function save_truck()
    {
        $truckid = $this->session->userdata('sess_id');
        $truck['truck_id'] = $truckid;
        # Get the passed details into the url data array if any
        $urldata = $this->uri->uri_to_assoc(4, array('action', 'truck_id'));
        security($this);
        $this->session->set_userdata('local_allowed_extensions', '.gif,.png,.jpeg,.jpg');
        $this->session->set_userdata('local_max_file_size', 1000000);
        $_POST['datebought'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
        #
        $_POST['startdate'] = changeDateFromPageToMySQLFormat($_POST['startyear3'] . "-" . $_POST['startmonth3'] . "-" . $_POST['startday3']);
        $_POST['enddate'] = changeDateFromPageToMySQLFormat($_POST['startyear2'] . "-" . $_POST['startmonth2'] . "-" . $_POST['startday2']);
        $_POST['puchdate'] = changeDateFromPageToMySQLFormat($_POST['startyear4'] . "-" . $_POST['startmonth4'] . "-" . $_POST['startday4']);
        $_POST['warrdate'] = changeDateFromPageToMySQLFormat($_POST['startyear5'] . "-" . $_POST['startmonth5'] . "-" . $_POST['startday5']);
        $_POST['licedate'] = changeDateFromPageToMySQLFormat($_POST['startyear6'] . "-" . $_POST['startmonth6'] . "-" . $_POST['startday6']);
        $_POST['endlicedate'] = changeDateFromPageToMySQLFormat($_POST['startyear7'] . "-" . $_POST['startmonth7'] . "-" . $_POST['startday7']);
        // insurance & waranty + license deadlines
        $time = $_POST['enddate'];
        $num2 = $_POST['num'];
        $period2 = $_POST['dayy'];
        $my = strtotime(date("Y-m-d", strtotime($time)) . " -{$num2} {$period2}");
        $_POST['show'] = date("Y-m-d", $my);
        $time2 = $_POST['endlicedate'];
        $num3 = $_POST['nums'];
        $period3 = $_POST['dayys'];
        $my2 = strtotime(date("Y-m-d", strtotime($time2)) . " -{$num3} {$period3}");
        $_POST['licdate'] = date("Y-m-d", $my2);
        //processing an image
        $_POST['image'] = $_FILES['image']['name'];
        if (!empty($_POST['image'])) {
            $_POST['image'] = $_POST['image'];
        } else {
            $_POST['image'] = $_POST['dphoto'];
        }
        //upload image
        $config['upload_path'] = './system/application/views/documents/';
        $config['allowed_types'] = 'gif|jpg|png|pdf|doc';
        $config['max_size'] = '70000000000000';
        $config['max_width'] = '1024000000000';
        $config['max_height'] = '768000000000';
        $this->load->library('upload', $config);
        if ($this->upload->do_upload('image')) {
            $data = $this->upload->data();
        }
        if (is_array($_POST['allowedcargo'])) {
            foreach ($_POST['allowedcargo'] as $value) {
                #
                $_POST['allowedcargo'] = $value;
                #
            }
        }
        # Display appropriate message based on the results
        if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
            # Load view base on where the user wants to go
            if ($this->input->post('save')) {
                $view_to_load = 'userprofile/trucks';
            }
            $data['msg'] = "The truck data was successfully saved.";
        } else {
            # For each error to be displayed as an error, it should start with "ERROR:"
            $data['msg'] = "ERROR: The truck data was not saved or may not be saved correctly.";
            # Check if error is because query already exists
            if ($urldata['truck_id'] === FALSE) {
                $data['msg'] .= $this->Control_check->check_if_already_exists('pick_truck_by_regno', array('regnumber' => $_POST['regnumber']));
            }
        }
        if ($truckid !== FALSE) {
            $data['truck'] = $this->session->userdata('sess_id');
            $data['truck_id'] = $truckid;
            $data['companytruckdetails'] = $this->Query_reader->get_row_as_array('pick_truck_by_id', array('truck_id' => $truckid));
        }
        $data['userdetails'] = $this->session->userdata('alluserdata');
        $id = $data['userdetails']['companyid'];
        $query2 = $this->Query_reader->get_query_by_code('pick_drivers_by_company_id', array('companyid' => $id));
        $result2 = $this->db->query($query2);
        $data['companydriverdetails'] = $result2->result_array();
        $result = $this->db->query('SELECT drivers.company_id,drivers.fname,drivers.lname,trucks.regnumber,trucks.company_id,drivers.driver_id,trucks.truck_id FROM drivers RIGHT OUTER JOIN trucks ON drivers.driver_id = trucks.driver_id WHERE trucks.company_id = "' . $id . '"');
        $data['returned'] = $result->num_rows();
        $data['truck_array'] = $result->result_array();
        #pick fuel used
        $fquery = $this->Query_reader->get_query_by_code('pick_all_fuel_for_truck', array('truck_id' => $truckid));
        $fresult = $this->db->query($fquery);
        $data['freturned'] = $fresult->num_rows();
        $data['fuel_array'] = $fresult->result_array();
        # service views
        $squery = $this->Query_reader->get_query_by_code('pick_all_services_for_truck', array('truck_id' => $truckid));
        $sresult = $this->db->query($squery);
        $data['returneds'] = $sresult->num_rows();
        $data['service_array'] = $sresult->result_array();
        #aCCIDENT VIEW
        $resultt = $this->db->query('SELECT
accidents.company_id,
drivers.fname,
drivers.lname,
drivers.driver_id,
accidents.occured,
accidents.date_created,
accidents.truck_id,
accidents.accident_id
FROM
drivers
LEFT OUTER JOIN accidents ON drivers.driver_id = accidents.driver_id
WHERE
accidents.company_id = "' . $id . '" AND
accidents.truck_id = "' . $truckid . '"');
        $data['returnedt'] = $resultt->num_rows();
        $data['accident_array'] = $resultt->result_array();
        #tire view
        $tquery = $this->Query_reader->get_query_by_code('pick_all_tires_for_truck', array('truck_id' => $truckid));
        $tresult = $this->db->query($tquery);
        $data['treturned'] = $tresult->num_rows();
        $data['tire_array'] = $tresult->result_array();
        //pick all service reminders
        $data['userdetails'] = $this->session->userdata('alluserdata');
        $id = $data['userdetails']['companyid'];
        $rd = "N";
        $tym = date("Y-m-d");
        $rmresult = $this->db->query('SELECT trucks.regnumber, services.`name`, services.duenext, services.service_id, services.truck_id,
                                   services.company_id FROM services INNER JOIN trucks ON trucks.truck_id = services.truck_id
                                    WHERE services.company_id = "' . $id . '" AND "' . $tym . '" >= services.lastdate AND trucks.odoqui >=                                     services.set_odo AND services.regnsd = "' . $rd . '"');
        $data['returnedserv'] = $rmresult->num_rows();
        $data['rm'] = $data['returned'];
        $data['service_array2'] = $rmresult->result_array();
        //insurance remiders
        $result2 = $this->db->query('SELECT trucks.show_lice_on, trucks.inscompany, trucks.endlicedate, trucks.enddate, trucks.show_ins_on,
                                  trucks.regnumber FROM trucks WHERE trucks.company_id = "' . $id . '" AND "' . $tym . '" >= trucks.show_ins_on                                    ');
        $data['ins'] = $result2->num_rows();
        $data['insnumm'] = $data['ins'];
        $data['ins_array'] = $result2->result_array();
        //licence reminders
        $result3 = $this->db->query('SELECT trucks.show_lice_on, trucks.endlicedate, trucks.regnumber FROM trucks WHERE
                                  "' . $tym . '" >= trucks.show_lice_on AND trucks.company_id = "' . $id . '"');
        $data['lic'] = $result3->num_rows();
        $data['licnumm'] = $data['lic'];
        $data['lic_array'] = $result3->result_array();
        // notices
        $this->db->where('to_employee', $data['userdetails']['userid']);
        $this->db->where('has_read', '0');
        $notices = $this->db->get('notice_details');
        $data['count_notices'] = $notices->num_rows();
        $data['notice_details'] = $notices->result_array();
        $data['curPage'] = 'company';
        $data['service'] = $this->reminder->get_reminders();
        $data['insurance'] = $this->reminder->insurance_reminder();
        $data['license'] = $this->reminder->license_reminder();
        $this->load->view('userprofile/trucks', $data);
    }
Exemplo n.º 12
0
 function updateFromArray($table, $data, $id_field, $id_value, $fieldstoignore = array(), $datefields = array())
 {
     # check the table name
     if (trim($table) == "") {
         $this->error_msg = "There is no table specified";
         return false;
     }
     # no data
     if (count($data) == 0) {
         $this->error_msg = "There is no data specified";
         return false;
     }
     # no id field
     if (trim($id_field) == "") {
         $this->error_msg = "There is no id field specified";
         return false;
     }
     # no id field
     if (trim($id_value) == "") {
         $this->error_msg = "There is no id valued specified, cannot update all the rows in the table";
         return false;
     }
     foreach ($data as $field => $value) {
         #check whether the field exists in the array of field to ignore.
         #If it does do not add it to the query fields
         if (!in_array($field, $fieldstoignore)) {
             #check whether the field is a date field, if it is do not
             #escape it using the mysql escape characters or quotation marks
             if (in_array($field, $datefields)) {
                 $fields[] = sprintf("`%s` = %s", $field, changeDateFromPageToMySQLFormat($value));
             } else {
                 $fields[] = sprintf("`%s` = '%s'", $field, mysql_real_escape_string($value));
             }
         }
     }
     $field_list = join(',', $fields);
     $query = sprintf("UPDATE `%s` SET %s WHERE `%s` = %s", $table, $field_list, $id_field, intval($id_value));
     $result = $this->CI->db->query($query);
     if (!$result) {
         # error occured
         $this->error_msg = "An error occured while updating the database. Please try again later <br>" . $this->CI->db->_error_message();
         return false;
     } else {
         # return the number of rows updated
         return $result;
     }
 }
Exemplo n.º 13
0
 /**
  * Return an SQL statement for the Filter Columns
  * 
  * @return String The Filter SQL statement
  */
 function getFilterSQL()
 {
     $filtercolumns = $this->getFilterColumns();
     $datefiltercolumns = $this->getDateFilterColumns();
     $request_data = $this->getDataArray();
     // the default filter is the start and end date filter
     $filtersql = $this->getStartAndEndDateFilter();
     // loop through each of the filters and only add those which have data
     if (count($filtercolumns) == 0) {
         return $filtersql;
     }
     foreach ($filtercolumns as $columnname) {
         $request_variable_name = str_replace(".", HTML_TABLE_COLUMN_SEPARATOR, $columnname);
         if (!isArrayKeyAnEmptyString($request_variable_name, $request_data)) {
             // the value to be applied as a filter
             $filtervalue = $request_data[$request_variable_name];
             // if the value is a date change it into MYSQL format
             // change the name of the $value to remove any separators for HTML
             if (in_array($columnname, $datefiltercolumns)) {
                 $filtervalue = changeDateFromPageToMySQLFormat($filtervalue);
             }
             $filtersql .= " AND " . $columnname . " = '" . $filtervalue . "'";
         }
     }
     return $filtersql;
 }
Exemplo n.º 14
0
 function createAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender(TRUE);
     $session = SessionWrapper::getInstance();
     /* debugMessage('pms: '.ini_get('post_max_size'));
     		debugMessage('ums: '.ini_get("upload_max_filesize"));
     		$size = (int) $_SERVER['CONTENT_LENGTH']; debugMessage('content length '.$size);
     		ini_set("memory_limit", "1024M");
     		$memory_limit = ini_get('memory_limit'); debugMessage('memory is '.$memory_limit); */
     $formvalues = $this->_getAllParams();
     // debugMessage($formvalues);
     $restoredata = objectToArray(json_decode(decode($session->getVar('restoredata'))));
     $formvalues = array_merge_maintain_keys($formvalues, $restoredata);
     // debugMessage($formvalues);
     // exit;
     // determine employees on the payroll
     $employees = array();
     $all_results_query = decode($formvalues['employeequery']);
     // debugMessage($all_results_query); exit;
     $conn = Doctrine_Manager::connection();
     $employees = $conn->fetchAll($all_results_query);
     // debugMessage($employees);
     // format payroll data
     $dataarray = array();
     $dataarray['companyid'] = getCompanyID();
     $dataarray['type'] = $formvalues['payrolltype'];
     $dataarray['status'] = $formvalues['status'];
     $dataarray['payrolldate'] = changeDateFromPageToMySQLFormat($formvalues['enddate']);
     $dataarray['url'] = $formvalues['failureurl'];
     $dataarray['startdate'] = changeDateFromPageToMySQLFormat($formvalues['startdate']);
     $dataarray['enddate'] = changeDateFromPageToMySQLFormat($formvalues['enddate']);
     $dataarray['middate'] = changeDateFromPageToMySQLFormat($formvalues['middate']);
     $dataarray['createdby'] = $session->getVar('userid');
     $dataarray['remarks'] = isArrayKeyAnEmptyString('remarks', $formvalues) ? '' : $formvalues['remarks'];
     $dataarray['ignorelist'] = $formvalues['ignorelist'];
     if (count($employees) > 0) {
         foreach ($employees as $key => $employee) {
             $dataarray['details'][$key]['userid'] = $employee['id'];
             $dataarray['details'][$key]['empstatus'] = $employee['empstatus'];
             $dataarray['details'][$key]['ratetype'] = $employee['ratetype'];
             $dataarray['details'][$key]['payrolltype'] = $employee['payrolltype'];
             $dataarray['details'][$key]['rate'] = $employee['rate'];
             $dataarray['details'][$key]['istimesheetuser'] = $employee['istimesheetuser'];
             $dataarray['details'][$key]['daysworked'] = $formvalues['daysworked_' . $employee['id']];
             $dataarray['details'][$key]['hourspending'] = $formvalues['_' . $employee['id']];
             $dataarray['details'][$key]['halfhoursworked'] = $formvalues['halfhoursworked_' . $employee['id']];
             $dataarray['details'][$key]['fullhoursworked'] = $formvalues['fullhoursworked_' . $employee['id']];
             $dataarray['details'][$key]['leavehrs'] = $formvalues['leavehrs_' . $employee['id']];
             $dataarray['details'][$key]['sickhrs'] = $formvalues['sickhrs_' . $employee['id']];
             $dataarray['details'][$key]['midgross'] = str_replace(',', '', $formvalues['midgross_' . $employee['id']]);
             $dataarray['details'][$key]['endgross'] = str_replace(',', '', $formvalues['endgross_' . $employee['id']]);
             $dataarray['details'][$key]['nssf'] = str_replace(',', '', $formvalues['nssf_' . $employee['id']]);
             $dataarray['details'][$key]['paye'] = str_replace(',', '', $formvalues['paye_' . $employee['id']]);
             $dataarray['details'][$key]['otherdebit'] = str_replace(',', '', $formvalues['otherdebit_' . $employee['id']]);
             $dataarray['details'][$key]['netearning'] = str_replace(',', '', $formvalues['netearning_' . $employee['id']]);
             $dataarray['details'][$key]['transport'] = str_replace(',', '', $formvalues['transport_' . $employee['id']]);
             $dataarray['details'][$key]['othercredit'] = str_replace(',', '', $formvalues['othercredit_' . $employee['id']]);
             $dataarray['details'][$key]['netpay'] = str_replace(',', '', $formvalues['netpay_' . $employee['id']]);
             $dataarray['details'][$key]['totaltaxable'] = str_replace(',', '', $formvalues['totaltaxable_' . $employee['id']]);
             $dataarray['details'][$key]['totalbenefits'] = str_replace(',', '', $formvalues['totalbenefits_' . $employee['id']]);
             $dataarray['details'][$key]['benefitdetails'] = $formvalues['benefitdetails_' . $employee['id']];
             $dataarray['details'][$key]['deductiondetails'] = $formvalues['deductiondetails_' . $employee['id']];
             $dataarray['details'][$key]['recurringtrxns'] = $formvalues['recurringtrxns_' . $employee['id']];
             $dataarray['details'][$key]['isignored'] = $formvalues['isignored_' . $employee['id']];
         }
     }
     // debugMessage('url '.decode($this->_getParam(URL_SUCCESS))); // exit;
     $payroll = new Payroll();
     if (!isArrayKeyAnEmptyString('reloadid', $formvalues)) {
         $payroll->populate($formvalues['reloadid']);
     }
     $payroll->processPost($dataarray);
     /* debugMessage($payroll->toArray());
     		debugMessage('errors are '.$payroll->getErrorStackAsString()); exit(); */
     if ($payroll->hasError()) {
         $url = decode($formvalues[URL_FAILURE]);
         $session->setVar(ERROR_MESSAGE, $payroll->getErrorStackAsString());
     } else {
         try {
             if ($payroll->payrollExists() && isArrayKeyAnEmptyString('reloadid', $formvalues)) {
                 $id = $payroll->existingPayroll();
                 $proll = new Payroll();
                 $proll->populate($id);
                 // debugMessage($proll->toArray()); exit();
                 $proll->delete();
             }
             // debugMessage($payroll->toArray()); exit();
             $payroll->save();
             $session->setVar(SUCCESS_MESSAGE, "Successfully saved as Draft");
             if ($dataarray['status'] == 2) {
                 $session->setVar(SUCCESS_MESSAGE, "Successfully marked as Completed and Locked");
             }
             $url = decode($formvalues[URL_SUCCESS]) . encode($payroll->getID());
         } catch (Exception $e) {
             $session->setVar(ERROR_MESSAGE, $e->getMessage());
             // debugMessage($e->getMessage());
             $url = decode($formvalues[URL_FAILURE]);
         }
     }
     // debugMessage($url);
     $this->_helper->redirector->gotoUrl($url);
 }
Exemplo n.º 15
0
 function save_truck()
 {
     $truckid = $this->session->userdata('sess_id');
     $truck['truck_id'] = $truckid;
     # Get the passed details into the url data array if any
     $urldata = $this->uri->uri_to_assoc(4, array('action', 'truck_id'));
     security($this);
     $this->session->set_userdata('local_allowed_extensions', '.gif,.png,.jpeg,.jpg');
     $this->session->set_userdata('local_max_file_size', 1000000);
     $_POST['datebought'] = changeDateFromPageToMySQLFormat($_POST['startyear'] . "-" . $_POST['startmonth'] . "-" . $_POST['startday']);
     #
     $_POST['startdate'] = changeDateFromPageToMySQLFormat($_POST['startyear3'] . "-" . $_POST['startmonth3'] . "-" . $_POST['startday3']);
     $_POST['enddate'] = changeDateFromPageToMySQLFormat($_POST['startyear2'] . "-" . $_POST['startmonth2'] . "-" . $_POST['startday2']);
     $_POST['puchdate'] = changeDateFromPageToMySQLFormat($_POST['startyear4'] . "-" . $_POST['startmonth4'] . "-" . $_POST['startday4']);
     $_POST['warrdate'] = changeDateFromPageToMySQLFormat($_POST['startyear5'] . "-" . $_POST['startmonth5'] . "-" . $_POST['startday5']);
     $_POST['licedate'] = changeDateFromPageToMySQLFormat($_POST['startyear6'] . "-" . $_POST['startmonth6'] . "-" . $_POST['startday6']);
     $_POST['endlicedate'] = changeDateFromPageToMySQLFormat($_POST['startyear7'] . "-" . $_POST['startmonth7'] . "-" . $_POST['startday7']);
     // insurance & waranty + license deadlines
     $time = $_POST['enddate'];
     $num2 = $_POST['num'];
     $period2 = $_POST['dayy'];
     $my = strtotime(date("Y-m-d", strtotime($time)) . " -{$num2} {$period2}");
     $_POST['show'] = date("Y-m-d", $my);
     $time2 = $_POST['endlicedate'];
     $num3 = $_POST['nums'];
     $period3 = $_POST['dayys'];
     $my2 = strtotime(date("Y-m-d", strtotime($time2)) . " -{$num3} {$period3}");
     $_POST['licdate'] = date("Y-m-d", $my2);
     //processing an image
     $_POST['image'] = $_FILES['image']['name'];
     if (!empty($_POST['image'])) {
         $_POST['image'] = $_POST['image'];
     } else {
         $_POST['image'] = $_POST['dphoto'];
     }
     //upload image
     $config['upload_path'] = './system/application/views/documents/';
     $config['allowed_types'] = 'gif|jpg|png|pdf|doc';
     $config['max_size'] = '70000000000000';
     $config['max_width'] = '1024000000000';
     $config['max_height'] = '768000000000';
     $this->load->library('upload', $config);
     if ($this->upload->do_upload('image')) {
         $data = $this->upload->data();
     }
     if (is_array($_POST['allowedcargo'])) {
         foreach ($_POST['allowedcargo'] as $value) {
             #
             $_POST['allowedcargo'] = $value;
             #
         }
     }
     # Display appropriate message based on the results
     if (($this->input->post('saveandnew') || $this->input->post('save')) && $this->process_form_data($urldata, $_POST, 'save')) {
         # Load view base on where the user wants to go
         if ($this->input->post('save')) {
             $view_to_load = 'userprofile/trucks';
         }
         $data['msg'] = "The truck data was successfully saved.";
     } else {
         # For each error to be displayed as an error, it should start with "ERROR:"
         $data['msg'] = "ERROR: The truck data was not saved or may not be saved correctly.";
         # Check if error is because query already exists
         if ($urldata['truck_id'] === FALSE) {
             $data['msg'] .= $this->Control_check->check_if_already_exists('pick_truck_by_regno', array('regnumber' => $_POST['regnumber']));
         }
     }
     if ($truckid !== FALSE) {
         $data['truck'] = $this->session->userdata('sess_id');
         $data['truck_id'] = $truckid;
         $data['companytruckdetails'] = $this->Query_reader->get_row_as_array('pick_truck_by_id', array('truck_id' => $truckid));
     }
     $data['userdetails'] = $this->session->userdata('alluserdata');
     $id = $data['userdetails']['companyid'];
     $result = $this->db->query('SELECT drivers.company_id,drivers.fname,drivers.lname,trucks.regnumber,trucks.company_id,drivers.driver_id,trucks.truck_id FROM drivers RIGHT OUTER JOIN trucks ON drivers.driver_id = trucks.driver_id WHERE trucks.company_id = "' . $id . '"');
     $data['returned'] = $result->num_rows();
     $data['truck_array'] = $result->result_array();
     $this->load->view('userprofile/trucks', $data);
 }