%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php defined('BASEPATH') OR exit('No direct script access allowed'); class Department extends CI_Controller { /** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see https://codeigniter.com/user_guide/general/urls.html */ function __construct() { parent::__construct(); if((!isset($_SESSION['is_logged']))||($_SESSION['is_logged']==false)) { $_SESSION['redirect'] = base_url()."admin/Department/view_departments"; redirect(base_url().'admin/login'); } // redirect_admin_not_logged(); $this->load->model('department_type_model', 'types'); $this->load->model('department_model', 'department'); } public function index() { $this->view_departments(); } public function do_upload($field_name, $upload_path= '', $file_name= '') { if($upload_path!=''){ $config['upload_path'] = $upload_path; } else{ $config['upload_path'] = './uploads'; } $config['allowed_types'] = 'jpeg|jpg|png|JPEG|JPG|PNG'; $config['max_size'] = '100'; $config['max_width'] = '1024'; $config['max_height'] = '768'; if($file_name!=''){ $config['file_name'] = $file_name; } $this->upload->initialize($config); if ( ! $this->upload->do_upload($field_name)) { $error = array('error' => $this->upload->display_errors()); // $this->load->view('upload_form', $error); return 0; } else { $data = array('upload_data' => $this->upload->data()); return $this->upload->data('file_name'); } } public function add_department($id=0) { $data = array(); $data['data_string'] = ''; $departmentID = $id; echo '<script>console.log("add department")</script>'; if($id){ $records = $this->department->get_Department($id); echo '<script>console.log("update department")</script>'; if(!$records){ show_404(); } else{ $data = array( 'DepartmentID' => $records['DepartmentID'], 'DepartmentName' => $records['DepartmentName'], 'DepartmentType' => $records['DepartmentType'], 'DepartmentParentID' => $records['DepartmentParentID'], 'DepartmentOverview' => $records['DepartmentOverview'], 'DepartmentInfrastructure' => $records['DepartmentInfrastructure'], 'DepartmentFacilities' => $records['DepartmentFacilities'], 'DepartmentServices' => $records['DepartmentServices'], 'DepartmentAchievements' => $records['DepartmentAchievements'], 'DepartmentHighlights' => $records['DepartmentHighlights'], 'DepartmentThumbnail' => $records['DepartmentThumbnail'], 'DepartmentIcon' => $records['DepartmentIcon'], 'DepartmentBanner' => $records['DepartmentBanner'], 'DepartmentPriorityOrder' => $records['DepartmentPriorityOrder'], 'Status' => $records['Status'], 'DepartmentPageURL' => replace_slug_chars($records['DepartmentPageURL']) ); } } $post=$this->input->post(); if($post){ echo '<script>console.log("post")</script>'; $this->form_validation->set_rules('DepartmentName', 'Department Name', 'required'); $this->form_validation->set_rules('DepartmentType', 'Department Type', 'required'); $this->form_validation->set_rules('DepartmentOverview', 'Department Overview', 'required'); // $this->form_validation->set_rules('profile_pic', 'Profile Picture','required'); if ($this->form_validation->run() == FALSE) { echo '<script>console.log("Error in validating doctor")</script>'; //console.log("Error in validating doctor"); $this->load->view('admin/addDepartment'); } else { $icon =''; $banner = ''; $thumbnail = ''; if($_FILES['icon']['name']){ $icon = $this->do_upload('icon', './uploads/department', 'dep_icon_'.replace_slug_chars($post['DepartmentPageURL'])); $data['error'] = array('error' => $this->upload->display_errors()); } if($_FILES['banner']['name']){ $banner = $this->do_upload('banner', './uploads/department', 'dep_bn_'.replace_slug_chars($post['DepartmentPageURL'])); $data['error'] = array('error' => $this->upload->display_errors()); } if($_FILES['thumbnail']['name']){ $thumbnail = $this->do_upload('thumbnail', './uploads/department', 'dep_bn_'.replace_slug_chars($post['DepartmentPageURL'])); $data['error'] = array('error' => $this->upload->display_errors()); } if((($_FILES['icon']['name'])&&(!$icon)) || (($_FILES['banner']['name'])&&(!$banner)) || (($_FILES['thumbnail']['name'])&&(!$thumbnail))){ echo '<script>console.log("fail upload")</script>'; $this->load->view('admin/AddDepartment',$data); } else{ if(isset($post['DepartmentID'])){ $departmentID = $post['DepartmentID']; } $insert_data = array( 'DepartmentName' => $post['DepartmentName'], 'DepartmentType' => $post['DepartmentType'], 'DepartmentParentID' => $post['DepartmentParentID'], 'DepartmentOverview' => $post['DepartmentOverview'], 'DepartmentInfrastructure' => $post['DepartmentInfrastructure'], 'DepartmentFacilities' => $post['DepartmentFacilities'], 'DepartmentServices' => $post['DepartmentServices'], 'DepartmentAchievements' => $post['DepartmentAchievements'], 'DepartmentHighlights' => $post['DepartmentHighlights'], 'Status' => $post['Status'], 'DepartmentPageURL' => replace_slug_chars($post['DepartmentPageURL']), 'DepartmentPriorityOrder' => $post['DepartmentPriorityOrder'], ); if($thumbnail!=''){ $insert_data['DepartmentThumbnail'] = $thumbnail; } if($icon!=''){ $insert_data['DepartmentIcon'] = $icon; } if($banner!=''){ $insert_data['DepartmentBanner'] = $banner; } $success = ''; $msg=''; echo '<script>console.log("'.$departmentID.'")</script>'; if($departmentID){ $success = $this->department->update_department($insert_data,$departmentID); } else{ $success = $this->department->insert_department($insert_data); echo '<script>console.log("'.$success.'")</script>'; } if($success){ redirect(base_url()."admin/Department/view_departments"); } } } } $data['department_types'] = $this->types->get_department_types(); $data['coe'] = $this->department->get_departments('DepartmentID,DepartmentName', array('COE')); $this->load->view('admin/AddDepartment',$data); } public function update_department($id){ $this->add_department($id); } public function view_department($id=0) { $data = array(); $data['data_string'] = ''; if($id){ $data = $this->doctor->get_doctors(); if(!$records){ show_404(); } else{ $data = array( 'DepartmentID' => $records['DepartmentID'], 'DepartmentName' => $records['DepartmentName'], 'DepartmentType' => $records['DepartmentType'], 'DepartmentParentID' => $records['DepartmentParentID'], 'DepartmentOverview' => $records['DepartmentOverview'], 'DepartmentInfrastructure' => $records['DepartmentInfrastructure'], 'DepartmentFacilities' => $records['DepartmentFacilities'], 'DepartmentServices' => $records['DepartmentServices'], 'DepartmentAchievements' => $records['DepartmentAchievements'], 'DepartmentHighlights' => $records['DepartmentHighlights'], 'DepartmentThumbnail' => $records['DepartmentThumbnail'], 'DepartmentIcon' => $records['DepartmentIcon'], 'DepartmentBanner' => $records['DepartmentBanner'], 'DepartmentPriorityOrder' => $records['DepartmentPriorityOrder'], 'Status' => $records['Status'], 'DepartmentPageURL' => $records['DepartmentPageURL'] ); } } $this->load->view('admin/ViewDepartment',$data); } public function view_departments() { $data = array(); $data['records'] = $this->department->get_departments(); if(!$data){ show_404(); } $this->load->view('admin/ViewDepartments',$data); } public function remove_department($id) { $data = array(); if($this->department->has_dependency($id)){ $data['msg'] = 'Department Could not be deleted. Deleted dependencies (Sub-departments/Doctors/Health Conditions/Patient Story) first'; } else{ if($this->department->delete_department($id)){ $data['msg'] = 'Department deleted succesfully'; } else{ $data['msg'] = 'Department could not be deleted'; } } $data['records'] = $this->department->get_departments(); if(!$data){ show_404(); } $this->load->view('admin/ViewDepartments',$data); } }