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); }
function add_document() { # 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); $this->session->set_userdata('local_allowed_extensions', array('.doc', '.docx', '.pdf', '.ppt', '.pptx')); if (!empty($data['i'])) { $_POST['editid'] = decryptValue($data['i']); } if ($this->input->post('editid')) { $data['formdata'] = $this->Query_reader->get_row_as_array('get_document_by_id', array('id' => $_POST['editid'])); } #Get the document details if ($this->input->post('adddocument')) { $_POST['documenturl'] = !empty($_FILES['documenturlupload']['name']) ? $this->sysfile->local_file_upload($_FILES['documenturlupload'], 'Upload_' . strtotime('now'), 'documents', 'filename') : ''; $required_fields = array('documentname', 'description', 'section'); if (!$this->input->post('editid')) { array_push($required_fields, 'documenturl'); } $_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']) { #First remove the document record and file from the system if (!empty($data['formdata']) && $this->input->post('editid')) { if (!empty($data['formdata']['documenturl']) && !empty($_POST['documenturl'])) { @unlink(UPLOAD_DIRECTORY . "documents/" . $data['formdata']['documenturl']); } #Only update the document if the user uploaded a new document if (!empty($_POST['documenturl'])) { $_POST['urlscript'] = ", documenturl='" . $_POST['documenturl'] . "'"; } else { $_POST['urlscript'] = ""; } $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_document', $_POST)); } else { $save_result = $this->db->query($this->Query_reader->get_query_by_code('save_new_document', $_POST)); } if ($save_result) { $data['msg'] = "The document has been saved."; $this->session->set_userdata('sres', $data['msg']); redirect(base_url() . "documents/manage_documents/m/sres"); } else { $data['msg'] = "ERROR: The document 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; } #Get tabs and active links if given $data = get_tab_data_if_any($data); $this->load->view('documents/add_document_view', $data); }
function save_grading_scale() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); if ($data['save'] || $data['saveandnew']) { $data['formdata'] = $data; $required_fields = array('gradingname', 'classes'); foreach ($data as $key => $data_value) { $data[$key] = restore_bad_chars($data_value); } $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); $feename_error = ''; #Only proceed if the validation for required fields passes if ($validation_results['bool']) { #Convert classes into strings if (is_array($_POST['classes'])) { $_POST['classes'] = stringify_array($_POST['classes'], '|'); } else { $_POST['classes'] = '|' . $_POST['classes'] . '|'; } if (!empty($data['editid'])) { $result = $this->db->query($this->Query_reader->get_query_by_code('update_grading_scale', array_merge($_POST, array('id' => $data['editid'])))); } else { #Add the school id and author to the data array $_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid'))); $result = $this->db->query($this->Query_reader->get_query_by_code('add_grading_scale', $_POST)); #Check if grades have been added if (!empty($_POST['gradingdetails'])) { $grades = explode('|', trim($_POST['gradingdetails'])); #Format the data for the query $query_data = ''; foreach ($grades as $grade) { $grade_details = explode('^', $grade); $query_data .= $query_data == '' ? '(' . $this->db->insert_id() . ', "' . $grade_details[0] . '", "' . $grade_details[1] . '"' . ', "' . $grade_details[2] . '", "' . $grade_details[3] . '")' : ',(' . $this->db->insert_id() . ', "' . $grade_details[0] . '", "' . $grade_details[1] . '"' . ', "' . $grade_details[2] . '", "' . $grade_details[3] . '")'; } $papers_result = $this->db->query($this->Query_reader->get_query_by_code('add_grading_details', array('rows' => $query_data))); } } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = empty($data['editid']) ? $data['gradingname'] . ' has been added.' : 'Details for ' . $data['gradename'] . ' have been updated.'; $data['formdata'] = array(); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The grading scale could not be saved or was not saved correctly."; } } } $data['requiredfields'] = $validation_results['requiredfields']; } $data['classes'] = $this->classobj->get_classes(); $data['terms'] = $this->terms->get_terms(); $this->load->view('incl/grading_form', $data); }
function save_incident() { access_control($this); # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 's', 't')); # Pick all assigned data $data = assign_to_data($urldata); $data = restore_bad_chars($data); if ($_POST['save_incident']) { $data['formdata'] = $_POST; $required_fields = array('incidentdate', 'student', 'reportedby', 'response', 'incidentdetails', 'actiontaken'); $_POST = clean_form_data($_POST); $validation_results = validate_form('', $_POST, $required_fields); #set status as editing on destination if updating if ($this->input->post('editid')) { $data['editid'] = $_POST['editid']; } #Only proceed if the validation for required fields passes if ($validation_results['bool'] && !(empty($data['editid']) && !empty($user_details))) { if (!empty($_POST['editid'])) { #Add the school id and author to the data array $_POST = array_merge($_POST, array('author' => $this->session->userdata('userid'))); $result = $this->disciplineobj->update_incident(array_merge($_POST, array('id' => $data['editid']))); } else { #Add the school id and author to the data array $_POST = array_merge($_POST, array('author' => $this->session->userdata('userid'))); #decrypt student and reported by values $_POST['student'] = decryptValue($_POST['student']); $_POST['reportedby'] = decryptValue($_POST['reportedby']); $result = $this->disciplineobj->add_incident($_POST); } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = "The incident data has been successfully saved."; $data['formdata'] = array(); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The incident could not be saved or was not saved correctly." . $classname_error . $rank_error; } } } else { if (empty($data['editid']) && !empty($class_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: A class with the same name already exists.<br />"; } } 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 the student info if (!empty($data['s'])) { $data['student_details'] = $this->Query_reader->get_row_as_array('get_students_list', array('isactive' => 'Y', 'searchstring' => ' AND id=\'' . decryptValue($data['s']) . '\'', 'limittext' => '')); } $this->load->view('discipline/incident_form_view', $data); }
function save_marks() { 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); $_POST = clean_form_data($_POST); if (!empty($_POST['sm']) && decryptValue($_POST['sm']) == 'true') { //test if marks have already been posted for selected exam, subject and class $submitted_marks = $this->db->query($this->Query_reader->get_query_by_code('search_mark_sheet', array('limittext' => '', 'searchstring' => ' exam="' . decryptValue($_POST['e']) . '" AND subject="' . decryptValue($_POST['s']) . '" AND class="' . decryptValue($_POST['c']) . '"')))->result_array(); //format the data for the query $query_data = ''; if (!count($submitted_marks)) { foreach ($_POST['students'] as $key => $val) { $student_id = explode('_', $key); $student_id = $student_id[count($student_id) - 1]; $query_data_str = '("' . $this->myschool['id'] . '", "' . $student_id . '", "' . decryptValue($_POST['s']) . '", "' . decryptValue($_POST['c']) . '", "' . decryptValue($_POST['e']) . '", "' . $val['marks'] . '", "' . $val['comments'] . '", "' . $this->session->userdata('userid') . '")'; $query_data .= $query_data == '' ? $query_data_str : ',' . $query_data_str; } } else { //For every student, test if they exist in the already submitted marks sheet and update if any changes have been made $already_submitted = FALSE; foreach ($_POST['students'] as $key => $val) { $student_id = explode('_', $key); $student_id = $student_id[count($student_id) - 1]; foreach ($submitted_marks as $submitted_marks_key => $submitted_marks_row) { if ($submitted_marks_row['student'] == $student_id && ($submitted_marks_row['mark'] != $val['marks'] || $submitted_marks_row['comment'] != $val['comments'])) { $update_result = $this->db->query($this->Query_reader->get_query_by_code('update_student_mark', array('mark' => $val['marks'], 'comment' => $val['comments'], 'author' => $this->session->userdata('userid'), 'editid' => $submitted_marks_row['id']))); unset($submitted_marks[$submitted_marks_key]); $already_submitted = TRUE; } elseif ($submitted_marks_row['student'] == $student_id) { $already_submitted = TRUE; } } if (!$already_submitted) { $query_data_str = '("' . $this->myschool['id'] . '", "' . $student_id . '", "' . decryptValue($_POST['s']) . '", "' . decryptValue($_POST['c']) . '", "' . decryptValue($_POST['e']) . '", "' . $val['marks'] . '", "' . $val['comments'] . '", "' . $this->session->userdata('userid') . '")'; $query_data .= $query_data == '' ? $query_data_str : ',' . $query_data_str; } $already_submitted = FALSE; } } #exit($this->Query_reader->get_query_by_code('add_multiple_marks', array('rows'=>$query_data))); if ($query_data == '') { $data['msg'] = format_notice(!empty($update_result) && $update_result ? "The mark sheet data has been updated." : "WARNING: The submitted data was unchanged from the original mark sheet.<br /> No data was saved."); } else { $result = $this->db->query($this->Query_reader->get_query_by_code('add_multiple_marks', array('rows' => $query_data))); $data['msg'] = format_notice($result ? 'The mark sheet has been updated' : 'ERROR: The mark sheet could not be updated'); } } else { $data['msg'] = format_notice('ERROR: An error occured while updating the marksheet'); } $data['area'] = 'update_mark_sheet'; $this->load->view('incl/addons', $data); }
function save_sponsor() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); if ($data['save']) { $data['formdata'] = $data; $required_fields = array('firstname', 'lastname'); foreach ($data as $key => $data_value) { $data[$key] = restore_bad_chars($data_value); } $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); $feename_error = ''; #Only proceed if the validation for required fields passes if ($validation_results['bool']) { #check if sponsor photo has changed if (!empty($_POST['photo'])) { #move photo to designated folder and add value to query string if (copy(UPLOAD_DIRECTORY . "temp/" . $_POST['photo'], UPLOAD_DIRECTORY . "sponsors/" . $_POST['photo'])) { #move the thumb nail as well $temp_photo_arr = explode('.', $_POST['photo']); if (copy(UPLOAD_DIRECTORY . "temp/" . $temp_photo_arr[0] . '_thumb.' . $temp_photo_arr[1], UPLOAD_DIRECTORY . "sponsors/" . $temp_photo_arr[0] . '_thumb.' . $temp_photo_arr[1])) { if (!empty($data['editid'])) { $_POST['UPDATESTRING'] = ',photo ="' . $_POST['photo'] . '"'; } } } } else { $_POST['UPDATESTRING'] = ''; } if (!empty($data['editid'])) { $result = $this->sponsorobj->update_sponsor(array_merge($_POST, array('editid' => decryptValue($data['editid'])))); } else { #Add the school id and author to the data array $_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid'))); $result = $this->sponsorobj->add_sponsor($_POST); } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = empty($data['editid']) ? $data['firstname'] . ' ' . $data['lastname'] . ' has been added to the sponsors list' : $data['firstname'] . '\'s details have been updated.'; $data['formdata'] = array(); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The sponsor could not be saved or was not saved correctly."; } } } $data['requiredfields'] = $validation_results['requiredfields']; } $this->load->view('sponsors/sponsor_form_view', $data); }
function update_school_info() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); $data = restore_bad_chars($data); if ($data['save']) { $data['schooldetails'] = $data; $required_fields = array('schoolname', 'emailaddress', 'telephone'); $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); $classname_error = ''; $rank_error = ''; #set status as editing on destination if updating if ($this->input->post('editid')) { $data['editid'] = $_POST['editid']; } #Only proceed if the validation for required fields passes if ($validation_results['bool'] && !(empty($data['editid']) && !empty($user_details))) { #Update school info $result = $this->db->query($this->Query_reader->get_query_by_code('user_update_school_data', array_merge($_POST, array('editid' => $this->myschool['id'])))); $data['schooldetails'] = $this->Query_reader->get_row_as_array('search_schools_list', array('limittext' => '', 'searchstring' => ' AND id = ' . $this->myschool['id'])); #Format and send the errors if (!empty($result) && $result) { $data['msg'] = "The school data has been successfully saved."; #Copy school badge to designated folder if (!empty($_POST['photo'])) { $copy_image_result = copy(UPLOAD_DIRECTORY . "temp/" . $_POST['photo'], UPLOAD_DIRECTORY . "schools/" . $_POST['photo']); #copy the thumb_nail as well $thumb_nail_ext = end(explode('.', $_POST['photo'])); $copy_image_thumb_result = copy(UPLOAD_DIRECTORY . "temp/" . str_replace('.' . $thumb_nail_ext, '_thumb.' . $thumb_nail_ext, $_POST['photo']), UPLOAD_DIRECTORY . "schools/" . str_replace('.' . $thumb_nail_ext, '_thumb.' . $thumb_nail_ext, $_POST['photo'])); if (!$copy_image_result && !$copy_image_thumb_result) { $data['msg'] = 'WARNING: ' & $data['msg'] . '<br />' . 'An error occured while saving the school badge'; } else { @unlink(UPLOAD_DIRECTORY . "temp/" . $_POST['photo']); @unlink(UPLOAD_DIRECTORY . "temp/" . str_replace('.' . $thumb_nail_ext, '_thumb.' . $thumb_nail_ext, $_POST['photo'])); } } } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The school data could not be saved or was not saved correctly." . $classname_error . $rank_error; } } } 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']; } $this->load->view('schoolinfo/school_info_view', $data); }
function save_term() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); $data = restore_bad_chars($data); if ($data['save']) { $data['termdetails'] = $data; $required_fields = array('term', 'year', 'startdate', 'enddate'); $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); #set status as editing on destination if updating //if($this->input->post('editid') || $data['editid']) $data['editid'] = $_POST['editid']; #Only proceed if the validation for required fields passes if ($validation_results['bool']) { if (!empty($data['editid'])) { #Check if another term other than the current one exists with the same name and year $term_details = $this->Query_reader->get_row_as_array('search_terms_list', array('limittext' => '', 'searchstring' => ' AND term = "' . $data['termdetails']['term'] . '" AND id != ' . $data['editid'] . ' AND school =' . $this->myschool->cur_school_details['id'] . ' AND year = "' . $data['termdetails']['year'] . '"')); if (!count($term_details)) { $result = $this->db->query($this->Query_reader->get_query_by_code('update_term', $_POST)); } else { $termname_error = "WARNING: A term with the same name and year already exists."; } } else { $term_details = $this->Query_reader->get_row_as_array('search_terms_list', array('limittext' => '', 'searchstring' => ' AND isactive ="Y" AND term = "' . $data['termdetails']['term'] . '" AND school =' . $this->myschool->cur_school_details['id'] . ' AND year = "' . $data['termdetails']['year'] . '"')); if (empty($term_details)) { #Add the school id $_POST = array_merge($_POST, array('school' => $this->myschool->cur_school_details['id'])); $result = $this->terms->add_term($_POST); } } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = "The term data has been successfully saved"; $data['termdetails'] = array(); } elseif (empty($data['editid']) && !empty($term_details)) { $data['msg'] = "WARNING: A term with the same name and year already exists.<br />"; } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The term could not be saved or was 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']; } $this->load->view('incl/term_form', $data); }
function process_form_data($urldata, $formdata, $action) { $query = ''; if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($formdata['editid']) { $query = $this->Query_reader->get_query_by_code('update_payment_data', $formdata); } } return $this->db->query($query); }
function save_exam() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); if ($data['save'] || $data['saveandnew']) { $data['formdata'] = $data; $required_fields = array('exam', 'term', 'contribution', 'classes'); foreach ($data as $key => $data_value) { $data[$key] = restore_bad_chars($data_value); } $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); $feename_error = ''; #Only proceed if the validation for required fields passes if ($validation_results['bool']) { #Convert classes into strings if (is_array($_POST['classes'])) { $_POST['classes'] = stringify_array($_POST['classes'], '|'); } else { $_POST['classes'] = '|' . $_POST['classes'] . '|'; } if (!empty($data['editid'])) { $result = $this->db->query($this->Query_reader->get_query_by_code('update_exam', array_merge($_POST, array('id' => $data['editid'])))); } else { #Add the school id and author to the data array $_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid'))); $result = $this->db->query($this->Query_reader->get_query_by_code('add_exam', $_POST)); } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = empty($data['editid']) ? $data['exam'] . ' has been added.' : 'Details for ' . $data['exam'] . ' have been updated.'; $data['formdata'] = array(); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The exam could not be saved or was not saved correctly."; } } } $data['requiredfields'] = $validation_results['requiredfields']; } $data['classes'] = $this->classobj->get_classes(); $data['terms'] = $this->terms->get_terms(); $this->load->view('incl/exam_form', $data); }
function process_form_data($urldata, $formdata, $action) { $query = ''; if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($formdata['editid']) { if (trim($formdata['companylogo']) == '') { $prev_co_details = $this->Query_reader->get_row_as_array('get_company_by_id', array('id' => $formdata['editid'])); $formdata['companylogo'] = $prev_co_details['logofile']; } $query = $this->Query_reader->get_query_by_code('update_company_data', $formdata); } } return $this->db->query($query); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('deactivate_employee_record', array('id' => $urldata['id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if (isset($formdata['editid']) && trim($formdata['editid']) != '') { $query = $this->Query_reader->get_query_by_code('update_employee_record', $formdata); } else { $previous_user_array = $this->Query_reader->get_row_as_array('pick_employee_by_email', array('emailaddress' => $formdata['emailaddress'])); # User data doesnt exist if (count($previous_user_array) == 0) { $_POST['username'] = generate_user_details($this->db->insert_id(), 'username'); $_POST['password'] = generate_user_details($this->db->insert_id(), 'password'); $result = $this->db->query($this->Query_reader->get_query_by_code('insert_employee_record', $formdata)); #Send the new user an email if their record was created successfully if ($result) { #Send user email so that they can confirm their email $_POST['messageid'] = "AC" . strtotime('now'); $_POST['confirmationid'] = encryptValue("AC" . $this->db->insert_id()); $_POST['username'] = generate_user_details($this->db->insert_id(), 'username'); $_POST['password'] = generate_user_details($this->db->insert_id(), 'password'); $_POST['adminname'] = htmlentities($this->session->userdata('names')); $result = $this->db->query($this->Query_reader->get_query_by_code('update_user_credentials', array_merge(array('userid' => $this->db->insert_id()), $_POST))); // $this->Query_reader->get_query_by_code('update_user_credentials', array_merge(array('userid'=>$this->db->insert_id()), $_POST)); $response = $this->emailhandler->send_email(array('admin' => 'FROM**ACRAV Website Administration**' . SITE_ADMIN_MAILID, 'user' => 'TO**' . $this->session->userdata('emailaddress') . ', ' . $_POST['emailaddress'] . ', ' . SITE_ADMIN_MAILID, 'user' => 'CC**' . $this->session->userdata('emailaddress')), $_POST, 'newcompanyuser'); } } } } } if (!isset($result)) { $result = $this->db->query($query); } return $result; }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_jobcategory', array('id' => $urldata['id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($urldata['id'] !== FALSE) { $query = $this->Query_reader->get_query_by_code('update_jobcategory', array_merge(array('id' => $urldata['id']), $formdata)); } else { # Check whether the jobcategory is already entered $previousjob = $this->Query_reader->get_row_as_array('pick_jobcategory_title', array('jobtitle' => $_POST['jobtitle'])); if (count($previousjob) == 0) { $query = $this->Query_reader->get_query_by_code('insert_jobcategory', $formdata); } } } } return $this->db->query($query); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_db_query', array('id' => $urldata['id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($urldata['id'] !== FALSE || isset($urldata['querycode'])) { $query = $this->Query_reader->get_query_by_code('update_db_query', array_merge(array('id' => $urldata['id']), $formdata)); } else { $previous_query_array = $this->Query_reader->get_row_as_array('pick_query_by_code', array('querycode' => $formdata['querycode'])); # Query data doesnt exist if (count($previous_query_array) == 0) { $query = $this->Query_reader->get_query_by_code('insert_db_query', $formdata); } } } } return $this->db->query($query); }
function add_word() { access_control($this); # Get the passed details into the form data array if any $urldata = $this->uri->uri_to_assoc(3, array('d')); # Pick all assigned data $data = assign_to_data($urldata); if (!empty($data['i']) || $this->input->post('editid')) { $editid = $this->input->post('editid') ? $this->input->post('editid') : decryptValue($data['i']); $data['formdata'] = $this->Query_reader->get_row_as_array('get_word_by_id', array('wordid' => $editid)); $data['formdata']['synonyms'] = explode(',', $data['formdata']['synonyms']); $data['formdata']['wordtype'] = $data['formdata']['type']; $data['i'] = encryptValue($editid); } if ($this->input->post('addword')) { $required_fields = array('word', 'wordtype'); $_POST = clean_form_data($_POST); $validation_results = validate_form('', $_POST, $required_fields); if ($validation_results['bool']) { if (!empty($editid)) { $result = $this->db->query($this->Query_reader->get_query_by_code('update_word_data', array('type' => $_POST['wordtype'], 'synonyms' => implode(",", $_POST['synonyms']), 'wordid' => $editid))); } else { $result = $this->db->query($this->Query_reader->get_query_by_code('save_new_word', array('word' => htmlentities($_POST['word'], ENT_QUOTES), 'type' => $_POST['wordtype'], 'synonyms' => implode(",", $_POST['synonyms'])))); } #Called from a popup #Show the appropriate message if ($result) { $this->session->set_userdata('smsg', "The word data has been saved."); $data['msg'] = "The word data has been saved."; } else { $data['msg'] = "ERROR: The word data could not be saved."; } } if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) { $data['msg'] = "WARNING: The word data could not be saved because of some missing information."; } $this->session->set_userdata('wmsg', $data['msg']); redirect(base_url() . "search/manage_words/m/wmsg"); } $data = add_msg_if_any($this, $data); $this->load->view('search/add_word', $data); }
function add_help_topic() { access_control($this); # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('s', 'i')); # Pick all assigned data $data = restore_bad_chars_in_array(assign_to_data($urldata)); $data['docexts'] = array('.doc', '.docx', '.pdf', '.ppt', '.pptx'); $data['imageexts'] = array('.gif', '.jpeg', '.jpg', '.tiff', '.png'); $data['videoexts'] = array('.swf'); $this->session->set_userdata('local_allowed_extensions', array_merge($data['docexts'], $data['imageexts'], $data['videoexts'])); if (!empty($data['i'])) { $topic_list = $this->db->query($this->Query_reader->get_query_by_code('view_help_topic', array('topiccode' => decryptValue($data['i'])))); $data['page_list'] = $topic_list->result_array(); if (!empty($data['page_list'][0])) { $data['formdata']['helptopic'] = $data['page_list'][0]['helptopic']; $data['formdata']['topiccode'] = $data['page_list'][0]['topiccode']; } } $topics = $this->db->query("SELECT * FROM help"); $topics_list = $topics->result_array(); foreach ($topics_list as $row) { $result = $this->db->query("UPDATE help SET helptopic='" . ucwords(str_replace('_', ' ', $row['topiccode'])) . "' WHERE id='" . $row['id'] . "'"); } #The button has been clicked to update the order of the items if ($this->input->post('save')) { if (!empty($_POST['helpitem'])) { $results_array = array(); $order = 1; foreach ($_POST['helpitem'] as $itemid) { array_push($results_array, $this->db->query($this->Query_reader->get_query_by_code('update_help_order', array('id' => $itemid, 'helporder' => $order)))); $order++; } $result = get_decision($results_array); } $msg = !empty($result) && $result ? "The help content order has been updated." : "ERROR: The help content order could not be updated."; $this->session->set_userdata('hmsg', $msg); $id_string = !empty($data['i']) ? "/i/" . $data['i'] : ""; redirect(base_url() . "help/add_help_topic" . $id_string . "/m/hmsg"); } #The button has been clicked to add a new help content item if ($this->input->post('addhelp')) { $_POST['fileurl'] = !empty($_FILES['fileurl']['name']) ? $this->sysfile->local_file_upload($_FILES['fileurl'], 'Upload_' . strtotime('now'), 'documents', 'filename') : ''; $required_fields = array('helptopic'); if (empty($_POST['details']) && empty($_POST['helplink']) && empty($_POST['fileurl'])) { array_push($required_fields, 'details'); } #Make a new topic code if this is the first help item $_POST['topiccode'] = empty($_POST['topiccode']) ? str_replace(" ", "_", strtolower($_POST['helptopic'])) : $_POST['topiccode']; $_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']) { $_POST['helporder'] = count($_POST['helpitem']) + 1; $result = $this->db->query($this->Query_reader->get_query_by_code('add_help_item', array_merge($_POST, array('details' => htmlentities($_POST['details'], ENT_QUOTES))))); $msg = $result ? "The help item has been added." : "ERROR: The help item could not be added."; $this->session->set_userdata('hmsg', $msg); $id_string = !empty($data['i']) ? "/i/" . $data['i'] : ""; redirect(base_url() . "help/add_help_topic" . $id_string . "/m/hmsg"); } #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 = add_msg_if_any($this, $data); $this->load->view('help/add_help_view', $data); }
function save_borrower_form() { access_control($this); $schooldetails = $this->session->userdata('schoolinfo'); # 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 (!empty($data['i'])) { $editid = decryptValue($data['i']); $data['formdata'] = $this->Query_reader->get_row_as_array('get_borrower_by_id', array('id' => $editid)); $data['formdata']['search'] = $data['formdata']['firstname'] . " " . $data['formdata']['middlename'] . " " . $data['formdata']['lastname']; } // var_dump($data); #####comment out.. use model values #Get the Item details $stockid = decryptValue($data['s']); #$stockid = $data['s']; $data['stockdata'] = $this->Query_reader->get_row_as_array('get_stock_by_id', array('id' => $stockid)); #Get the Item details #Check if the user is simply viewing the deal #TODO: Add the force-users-without-other-permissions-to-view condition if (!empty($data['a']) && decryptValue($data['a']) == 'view') { $data['isview'] = "Y"; } if ($this->input->post('saveborrower')) { $required_fields = array('name', 'type', 'dateborrowed', 'taken', 'libraryid'); $_POST = clean_form_data($_POST); $validation_results = validate_form('', $_POST, $required_fields); $borrowerperiod = validate_borrower_period($_POST['dateborrowed'], $_POST['datereturned']); if ($validation_results['bool'] && $borrowerperiod == "") { $_POST['copiestaken'] = sizeof($_POST['items']); if (!empty($data['formdata']) && !empty($data['i'])) { $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_borrower', array_merge($_POST, array('id' => $editid)))); } else { // echo($this->Query_reader->get_query_by_code('add_borrower', array_merge($_POST, array('school' => $schooldetails['id'], 'createdby'=>$this->session->userdata('userid'))) )); // exit(); $save_result = $this->db->query($this->Query_reader->get_query_by_code('add_borrower', array_merge($_POST, array('school' => $schooldetails['id'], 'createdby' => $this->session->userdata('userid'))))); } if ($save_result) { $borrowerid = $this->db->insert_id(); for ($i = 0; $i < sizeof($_POST['items']); $i++) { $save_result2 = $this->db->query($this->Query_reader->get_query_by_code('add_borroweditems', array('borrower' => $borrowerid, 'item' => $_POST['items'][$i]))); $updateitem = $this->db->query($this->Query_reader->get_query_by_code('update_item_borrowed', array('id' => $_POST['items'][$i], 'isavailable' => 0))); } if ($save_result2 && $updateitem) { $data['msg'] = "The borrower has been saved."; #die($data['msg']); $this->session->set_userdata('sres', $data['msg']); redirect(base_url() . "library/manage_borrowers/m/sres"); } else { $data['msg'] = "ERROR: The borrower was not saved. Please contact your administrator."; } } else { $data['msg'] = "ERROR: The borrower was not saved. Please contact your administrator."; #die($data['msg']); } } #Validation if ((empty($validation_results['bool']) || !empty($validation_results['bool']) && !$validation_results['bool']) && empty($data['msg'])) { $data['msg'] = "WARNING: The highlighted fields are required."; } if ($borrowerperiod != "") { $data['msg'] = "WARNING: " . $borrowerperiod; } $data['requiredfields'] = $validation_results['requiredfields']; $data['formdata'] = $_POST; } if (!empty($data['a']) && decryptValue($data['a']) == 'view') { $data = paginate_list($this, $data, 'get_borrowed_items', array('isactive' => 'Y', 'searchstring' => ' AND b.borrower = ' . $data['formdata']['id'])); $data['isviewing'] = TRUE; $data['area'] = 'borrower_details'; $this->load->view('incl/addons', $data); } else { $this->load->view('library/new_borrower', $data); } $data['students'] = $this->librarymodel->get_students(); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_employee_record', array('id' => $urldata['id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); $userdetails = $this->session->userdata('alluserdata'); # Modify the new password for saving if (trim($formdata['password']) != '') { $formdata['password'] = md5($formdata['password']); } # User is editing if ($urldata['id'] !== FALSE) { $employee_details = $this->Query_reader->get_row_as_array('pick_employee_by_id', array('id' => $urldata['id'])); # Check if the user is updating their profile if (isset($urldata['user'])) { if (md5($formdata['oldpassword']) == $employee_details['password'] && trim($formdata['password']) != '') { # Leave the entered password } else { $formdata['password'] = $employee_details['password']; } $query = $this->Query_reader->get_query_by_code('update_employee_record', array_merge(array('id' => $urldata['id'], 'userid' => $userdetails['userid']), $formdata)); } else { if (!isset($formdata['oldpassword'])) { # Pull password from the database table if the user is not changing their password if (trim($formdata['password']) == '') { $formdata['password'] = $employee_details['password']; } $query = $this->Query_reader->get_query_by_code('update_employee_record', array_merge(array('id' => $urldata['id'], 'userid' => $userdetails['userid']), $formdata)); } } } else { # Check whether employee exists $previous_employee = $this->Query_reader->get_row_as_array('double_check_employee', $formdata); # Employee doesn't exist, Insert new employee if (count($previous_employee) == 0) { $query = $this->Query_reader->get_query_by_code('insert_employee_record', $formdata); } } } } return $this->db->query($query); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_truck', array('truck_id' => $urldata['truck_id'])); } else { if ($action == 'save') { $truckid = $this->session->userdata('sess_id'); # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($urldata['truck_id'] !== FALSE) { $query = $this->Query_reader->get_query_by_code('update_truck', array_merge(array('truck_id' => $urldata['truck_id']), $formdata)); } else { $previous_query_array = $this->Query_reader->get_row_as_array('pick_truck_by_regno', array('regnumber' => $formdata['regnumber'])); # User data doesnt exist if (count($previous_query_array) == 0) { $query = $this->Query_reader->get_query_by_code('insert_truck', $formdata); } } } } return $this->db->query($query); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { //$query = $this->Query_reader->get_query_by_code('delete_truck', array('truck_id'=>$urldata['truck_id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing $truckid = $this->session->userdata('sess_id'); $data['truck_id'] = $truckid; if ($truckid !== FALSE) { $data = array('image5' => $_FILES['img1']['name'], 'image2' => $_FILES['img2']['name'], 'image3' => $_FILES['img3']['name'], 'image4' => $_FILES['img4']['name']); $this->db->where('truck_id', $truckid); $this->db->update('trucks', $data); //$query = $this->Query_reader->get_query_by_code('update_truck_photos', array_merge(array('truck_id'=>$urldata['truck_id']), $formdata)); } else { $previous_query_array = $this->Query_reader->get_row_as_array('pick_truck_by_regno', array('regnumber' => $formdata['regnumber'])); # User data doesnt exist if (count($previous_query_array) == 0) { $query = $this->Query_reader->get_query_by_code('insert_truck', $formdata); } } } } return $this->db->query($query); }
function search_pdetypes() { access_control($this, array('admin')); # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('m')); # Pick all assigned data $data = assign_to_data($urldata); if ($this->input->post('searchQuery')) { $_POST = clean_form_data($_POST); $_POST['searchQuery'] = $searchstring = trim($_POST['searchQuery']); $_POST['searchQuery'] . '%"'; $data = $this->Pdetypes_m->search_pdetypes('in', $data, $searchstring); #print_r($data); exit(); $data['area'] = 'pdetype_list'; $this->load->view('includes/add_ons', $data); } else { $data = $this->Pdetypes_m->fetchpdetypes('Y', $data); $data['page_title'] = 'Manage PDE Types'; $this->load->view('pde/manage_pdatype_v', $data); } }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_truck', array('truck_id' => $urldata['truck_id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($urldata['truck_id'] !== FALSE) { // Check if a record exists for this SKU $query = $this->db->get_where('cur_drivers', array('truck_id' => $_POST['truck_id']), 1, 0); if ($query->num_rows() == 0) { // A record does not exist, insert one. $record = array('driver_id' => $_POST['driver_id'], 'truck_id' => $_POST['truck_id']); $query = $this->db->insert('cur_drivers', $record); } else { // A record does exist, update it. $record2 = array('driver_id' => $_POST['driver_id']); $query = $this->db->update('cur_drivers', $record2, array('truck_id' => $urldata['truck_id'])); } $query = $this->Query_reader->get_query_by_code('assign_driver_to_truck', array_merge(array('truck_id' => $urldata['truck_id']), $formdata)); $query2 = $this->Query_reader->get_query_by_code('insert_ids', $formdata); $this->db->query($query2); } else { $previous_query_array = $this->Query_reader->get_row_as_array('pick_truck_by_regno', array('regnumber' => $formdata['regnumber'])); # User data doesnt exist if (count($previous_query_array) == 0) { $query = $this->Query_reader->get_query_by_code('insert_truck', $formdata); } } } } return $this->db->query($query); }
function save_class() { 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', 't')); # Pick all assigned data $data = assign_to_data($urldata); $data = restore_bad_chars($data); if ($data['save']) { $data['classdetails'] = $data; $required_fields = array('class', 'rank'); $_POST = clean_form_data($data); $validation_results = validate_form('', $_POST, $required_fields); $classname_error = ''; $rank_error = ''; #set status as editing on destination if updating if ($this->input->post('editid')) { $data['editid'] = $_POST['editid']; } #Only proceed if the validation for required fields passes if ($validation_results['bool'] && !(empty($data['editid']) && !empty($user_details))) { if (!empty($_POST['editid'])) { #Check if another class other than the current one exists with the same name $class_details = $this->Query_reader->get_row_as_array('search_classes_list', array('limittext' => '', 'searchstring' => ' AND class = "' . $data['classdetails']['class'] . '" AND id != ' . $data['editid'] . ' AND school =' . $this->myschool['id'])); #Also check for the same rank $rank_details = $this->Query_reader->get_row_as_array('search_classes_list', array('limittext' => '', 'searchstring' => ' AND id != ' . $data['editid'] . ' AND rank =' . $data['classdetails']['rank'] . ' AND school =' . $this->myschool['id'])); if (empty($term_details) && empty($rank_details)) { #Add the school id and author to the data array $_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid'))); $result = $this->classobj->update_class(array_merge($_POST, array('id' => $data['editid']))); } else { if (!empty($class_details)) { $classname_error = "<br />WARNING: A class with the same name already exists."; } if (!empty($rank_details)) { $rank_error = "<br />WARNING: A class (" . $rank_details['class'] . ") with the same rank already exists."; } } } else { #Check if class name exists $class_details = $this->Query_reader->get_row_as_array('search_classes_list', array('limittext' => '', 'searchstring' => ' AND class = "' . $data['classdetails']['class'] . '" AND school =' . $this->myschool['id'])); #Also check for the same rank $rank_details = $this->Query_reader->get_row_as_array('search_classes_list', array('limittext' => '', 'searchstring' => ' AND rank =' . $data['classdetails']['rank'] . ' AND school =' . $this->myschool['id'])); if (empty($class_details) && empty($rank_details)) { #Add the school id and author to the data array $_POST = array_merge($_POST, array('school' => $this->myschool['id'], 'author' => $this->session->userdata('userid'))); $result = $this->classobj->add_class($_POST); } else { if (!empty($class_details)) { $classname_error = "<br />WARNING: A class with the same name already exists."; } if (!empty($rank_details)) { $rank_error = "<br />WARNING: A class (" . $rank_details['class'] . ") with the same rank already exists."; } } } #Format and send the errors if (!empty($result) && $result) { $data['msg'] = "The class data has been successfully saved."; $data['classdetails'] = array(); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: The class could not be saved or was not saved correctly." . $classname_error . $rank_error; } } } else { if (empty($data['editid']) && !empty($class_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: A class with the same name already exists.<br />"; } } 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']; } $this->load->view('incl/class_form', $data); }
function save_profile() { # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('m', 'i', 'a', 't')); # Pick all assigned data $data = assign_to_data($urldata); $userid = $this->session->userdata('userid'); if ($this->input->post('save')) { $data['formdata'] = $_POST; $required_fields = array('firstname', 'lastname', 'gender', 'emailaddress*EMAILFORMAT', 'telephone', 'username'); $_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']) { if (!empty($userid)) { $data['msg'] = ''; #test if email is unique to user being edited $user_details = $this->Query_reader->get_row_as_array('search_user_list', array('searchstring' => 'emailaddress="' . $_POST['emailaddress'] . '" AND userid != "' . $userid . '"', 'limittext' => '')); if (!empty($user_details)) { $data['msg'] = "ERROR: A user with the specified email address already exists. <br />"; } if (!empty($_POST['password']) || !empty($_POST['repeatpassword'])) { $passwordmsg = $this->user1->check_password_strength($_POST['password']); if (!$passwordmsg['bool']) { $data['msg'] .= "ERROR: " . $passwordmsg['msg']; } elseif ($_POST['password'] == $_POST['repeatpassword']) { $update_string = ", password = '******'password']) . "'"; } else { $data['msg'] .= "ERROR: The passwords provided do not match."; } } else { $update_string = ""; } if (empty($data['msg'])) { $result = $this->db->query($this->Query_reader->get_query_by_code('update_user_profile', array_merge($_POST, array('updatecond' => $update_string, 'editid' => $userid)))); } } #Format and send the errors if (!empty($result) && $result) { $this->session->set_userdata('firstname', $_POST['firstname']); $this->session->set_userdata('lastname', $_POST['lastname']); $this->session->set_userdata('usave', "Your profile details have been successfully saved"); redirect("user/dashboard/m/usave"); } else { if (empty($data['msg'])) { $data['msg'] = "ERROR: Your profile 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['page_title'] = 'My Profile'; $data['current_menu'] = ''; $data['view_to_load'] = 'users/profile_form_v'; $data['view_data']['form_title'] = $data['page_title']; $this->load->view('dashboard_v', $data); }
function process_contactus() { # Get the passed details into the url data array if any $urldata = $this->uri->uri_to_assoc(3, array('m')); # Pick all assigned data $data = assign_to_data($urldata); if ($this->input->post('sendmessage')) { $required_fields = array('emailaddress*EMAILFORMAT', 'name'); #$_POST['attachmenturl'] = !empty($_FILES['attachmenturl']['name'])? $this->sysfile->local_file_upload($_FILES['attachmenturl'], 'Upload_'.strtotime('now'), 'attachments', 'filename'): ''; $_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'] && is_valid_captcha($this, $_POST['captcha'])) if ($validation_results['bool']) { #Send the contact message to the administrator and $send_result = $this->sysemail->email_form_data(array('fromemail' => NOREPLY_EMAIL), get_confirmation_messages($this, $_POST, 'website_feedback')); if ($send_result) { $data['msg'] = "Your message has been sent. Thank you for your feedback."; $data['successful'] = 'Y'; } else { $data['msg'] = "ERROR: Your message could not be sent. Please contact us using our phone line."; } } if (!$validation_results['bool']) { $data['msg'] = "WARNING: The highlighted fields are required."; } $data['requiredfields'] = array_merge($validation_results['requiredfields'], array('captcha')); $data['formdata'] = $_POST; } $data['pagedata'] = $this->Query_reader->get_row_as_array('get_page_by_section', array('section' => 'Support', 'subsection' => 'Contact Us')); if (count($data['pagedata']) > 0) { $data['pagedata']['details'] = str_replace("&gt;", ">", str_replace("&lt;", "<", $data['pagedata']['details'])); $data['pagedata']['parsedtext'] = $this->wiki_manager->parse_text_to_HTML(htmlspecialchars_decode($data['pagedata']['details'], ENT_QUOTES)); $result = $this->db->query($this->Query_reader->get_query_by_code('get_subsections_by_section', array('section' => $data['pagedata']['section']))); $data['subsections'] = $result->result_array(); } $data = add_msg_if_any($this, $data); $this->load->view('page/contact_us_view', $data); }
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 register_scrhool() { #clean Up Form Data $_POST = clean_form_data($_POST); $required_fields = array('school_name', 'school_licence', 'phone_number', 'school_email', 'register_school_account'); #validate form fields like emails and stuff like that $validation_results = validate_form('', $_POST, $required_fields); #Run More Validation Issues to Get Information /* Mising */ # ALSO ADD THE ACCOUNT ON WHICH IT BELONGS if (empty($validation_results['bool'])) { # SCHOOL DETAILS $schooldetails = array('schoolname' => $_POST['school_name'], 'phone_number' => $_POST['phone_number'], 'school_email' => !empty($_POST['school_email']) ? $_POST['school_email'] : '', 'type_of_school' => !empty($_POST['type_of_school']) ? $_POST['type_of_school'] : '', 'school_licence' => $_POST['school_licence']); #INSERT RECORDS IN THE SYSTEM :: $result = $this->db->query($this->Query_reader->get_query_by_code('add_school_data', $schooldetails)); #IF RECORD EXISTS if ($result) { #CREATE SUPER ADMIN FOR THIS SCHOOOL $msg = "RECORD SAVED SUCCESFULLY"; $data['SUCCESS'] = $msg; } else { $msg = "RECORD SAVED SUCCESFULLY"; $data['ERROR'] = $msg; } return $data; } else { #Save School Account : $msg = "THERE HAVE BEEN VALIDATION ISSUES"; $data['ERROR'] = $msg; $data['validation_results'] = $validation_results; return $data; } print_r($_POST); }
function process_form_data($urldata, $formdata, $action) { $query = ''; # Determine what to do with the form data based on the action if ($action == 'delete') { $query = $this->Query_reader->get_query_by_code('delete_service_data', array('service_id' => $urldata['service_id'])); } else { if ($action == 'save') { # Before saving this data, add slashes so that bad additions and quotes are 'neutralised' $formdata = clean_form_data($formdata); # User is editing if ($urldata['service_id'] == FALSE) { $dat = $_POST['read']; $rd = "Y"; $query = $this->Query_reader->get_query_by_code('update_reminder', array_merge(array('service_id' => $_POST['read']))); //$result = $this->db->query('UPDATE services SET regnsd="'.$rd.'" WHERE service_id = "'.$dat.'" '); } else { $previous_query_array = $this->Query_reader->get_row_as_array('pick_truck_by_regno', array('regnumber' => $formdata['regnumber'])); # User data doesnt exist if (count($previous_query_array) == 0) { $query = $this->Query_reader->get_query_by_code('updates_reminder', $formdata); } } } } return $this->db->query($query); }
function add_organization() { 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); $this->session->set_userdata('local_allowed_extensions', array('.jpg', '.jpeg', '.gif', '.png', '.tiff', '.bmp')); if (!empty($data['i'])) { $data['formdata'] = $this->Query_reader->get_row_as_array('get_organization_by_id', array('id' => decryptValue($data['i']))); $data['isview'] = !empty($data['a']) && decryptValue($data['a']) == 'view' ? "Y" : ""; } #Save the document details if ($this->input->post('saveorgn')) { $required_fields = array('organizationname', 'datestarted', 'contactperson', 'contactemail*EMAILFORMAT', 'contactphone', 'contactaddressline1', 'contactcity', 'contactzipcode', 'contactstate'); $_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']) { $_POST['datestarted'] = empty($_POST['datestarted']) ? "" : date('Y-m-d', strtotime($_POST['datestarted'])); $_POST['logourl'] = !empty($_FILES['logourl']['name']) ? $this->sysfile->local_file_upload($_FILES['logourl'], 'Upload_' . strtotime('now'), 'images', 'filename') : ''; $_POST['iconurl'] = !empty($_FILES['iconurl']['name']) ? $this->sysfile->local_file_upload($_FILES['iconurl'], 'iUpload_' . strtotime('now'), 'images', 'filename') : ''; #Use the old versions if no new ones are entered $_POST['logourl'] = empty($_POST['logourl']) && !empty($data['formdata']['logourl']) ? $data['formdata']['logourl'] : $_POST['logourl']; $_POST['iconurl'] = empty($_POST['iconurl']) && !empty($data['formdata']['iconurl']) ? $data['formdata']['iconurl'] : $_POST['iconurl']; #First remove the document record and file from the system if (!empty($data['formdata']) && !empty($data['i'])) { $save_result = $this->db->query($this->Query_reader->get_query_by_code('update_organization', array_merge($_POST, array('editid' => decryptValue($data['i']))))); } else { $save_result = $this->db->query($this->Query_reader->get_query_by_code('save_new_organization', $_POST)); } $data['msg'] = $save_result ? "The organization has been saved." : "ERROR: The organization was not saved. Please contact your administrator."; $this->session->set_userdata('sres', $data['msg']); redirect(base_url() . "user/manage_organizations/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; } $data = add_msg_if_any($this, $data); $this->load->view('user/add_organization_view', $data); }
function search_bid_invitation() { $urldata = $this->uri->uri_to_assoc(3, array('m', 'i')); # Pick all assigned data $data = assign_to_data($urldata); $pde = $this->session->userdata('pdeid'); $userid = $this->session->userdata('userid'); $searchstring = "1 and 1 and users.userid=" . $userid . " and users.pde=" . $pde . " order by disposal_bid_invitation.dateadded DESC"; if ($this->input->post('searchQuery')) { $_POST = clean_form_data($_POST); $_POST['searchQuery'] = $searchstring = trim($_POST['searchQuery']); $_POST['searchQuery'] . '%"'; $data = $this->disposal->search_disposal_bid_invitations($data, $searchstring); } else { $data = $this->disposal->fetch_disposal_bid_invitations($data, $searchstring); } $data['page_title'] = 'View Disposal Records'; $data['current_menu'] = 'view_disposal_plan'; $data['view_to_load'] = 'disposal/view_disposals_v'; $data['view_data']['form_title'] = $data['page_title']; $data['search_url'] = 'disposal/search_bid_invitation'; $data['area'] = 'bid_invitation_list'; $this->load->view('includes/add_ons', $data); }