コード例 #1
0
 public function profile_pic()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $client_id = $this->auth->get_user()->id;
         //print_r($_FILES['profile-image']);exit;
         if (!empty($_FILES['profile-image']['name'])) {
             $tempFile = $_FILES["profile-image"]["tmp_name"];
             $filename = $_FILES["profile-image"]["name"];
             $targetPath = 'assets/uploads/';
             $temp = explode(".", $filename);
             $extension = end($temp);
             if (!is_dir($targetPath)) {
                 mkdir($targetPath, 0700);
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetPath, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             } else {
                 $salt = 'user-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetFile, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             }
         } else {
             $json = $this->auth->get_user()->user_avatar;
         }
         $data_profile_pic = array("user_avatar" => $json);
         log_helper::add("2", $this->user_log, $this->user_id, "Profile Picture was Successfully Updated");
         $this->setting_model->update_user($this->auth->get_user()->id, $data_profile_pic);
     }
 }
コード例 #2
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $supplier = $this->supplier_model->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Supplier named " . $supplier->name . ".");
         echo $this->supplier_model->delete($id);
     }
 }
コード例 #3
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $office = $this->office_model->with('district')->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Office named " . $office->name . ".");
         echo $this->office_model->delete($id);
     }
 }
コード例 #4
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $category = $this->category_model->find($id);
         echo $this->category_model->delete($category->id);
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted Category named " . $category->name . ".");
     }
 }
コード例 #5
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $request = $this->request_model->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Request deleted with reference no. " . $request->reference_no . ".");
         echo $this->request_model->delete($id);
     }
 }
コード例 #6
0
 public function delete($id)
 {
     if (request::is_ajax() and request::method() === 'post') {
         $this->auto_render = FALSE;
         $officeBudget = $this->budget_model->with('office')->find($id);
         log_helper::add("2", $this->user_log, $this->user_id, "Deleted a Office Budget for " . $officeBudget->office->name . ".");
         echo $this->budget_model->delete($id);
     }
 }
コード例 #7
0
 public function save()
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $post = security::xss_clean($this->input->post());
         log_helper::add("1", $this->user_log, $this->user_id, "Added New Purchase");
         $this->purchase_model->insert($post);
     }
 }
コード例 #8
0
 public function update($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $changes = "";
         $post = security::xss_clean($this->input->post('name'));
         $district = $this->district_model->find($id);
         $changes .= custom_helper::compare_variable("District Name", $district->name, $post);
         if ($changes != "") {
             $changes = substr($changes, 0, -2) . '.';
         }
         $district->name = $post;
         log_helper::add("1", $this->user_log, $this->user_id, "Updated a District. " . $changes);
         echo json_encode($this->district_model->getOne($district->save($id)));
     }
 }
コード例 #9
0
 public function save()
 {
     if (request::is_ajax() and request::method() === 'post') {
         $this->auto_render = FALSE;
         $office_id = Auth::instance()->get_user()->office_id;
         $post = security::xss_clean($this->input->post());
         $post['office_id'] = $office_id;
         $post['status'] = 'Received';
         $officeBudget = arr::remove('currentBudget', $post);
         if ($post['status'] == 'Approved') {
             $this->budget_model->updateBudget($post['office_id'], $officeBudget);
             echo $this->request_model->insert($post);
         }
         log_helper::add("1", $this->user_log, $this->user_id, "Requested a Budget");
         $this->request_model->insert($post);
     }
 }
コード例 #10
0
 public function save()
 {
     if (request::is_ajax() && request::method() == 'post') {
         $this->auto_render = FALSE;
         $client_id = $this->auth->get_user()->id;
         $settings = json_decode($this->setting_model->find(1)->configs);
         $site_address = $this->input->post('site-address', null, true);
         $site_name = $this->input->post('site-name', null, true);
         $site_currency = $this->input->post('site-currency', null, true);
         $item_expiration = $this->input->post('item-expiration', null, true);
         $notiftype = $this->input->post('notiftype', null, true);
         $notifdate = $this->input->post('notifdate', null, true);
         if (!empty($_FILES['site-favicon']['name'])) {
             $tempFile = $_FILES["site-favicon"]["tmp_name"];
             $filename = $_FILES["site-favicon"]["name"];
             $targetPath = 'assets/uploads/favicon/';
             $temp = explode(".", $filename);
             $extension = end($temp);
             if (!is_dir($targetPath)) {
                 mkdir($targetPath, 0700);
                 $salt = 'favicon-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetPath, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             } else {
                 $salt = 'favicon-' . $client_id . '-' . uniqid() . '-';
                 $targetFile = $targetPath . $salt . $filename;
                 $file_data_name = array("name" => $filename, "location" => $targetFile, "extension" => $extension);
                 $this->start_upload($targetFile, $tempFile);
                 $json = json_encode($file_data_name, TRUE);
             }
         } else {
             $json = $settings->favicon;
         }
         $site_currency_information = explode("|", $site_currency);
         $site_currency_symbol = "&" . $site_currency_information[0] . ";";
         $data = array("name" => $site_name, "address" => $site_address, "currency" => $site_currency_symbol, "favicon" => $json, "item_expiration" => $item_expiration, "notiftype" => $notiftype, "notifdate" => $notifdate);
         $data_json = json_encode($data, TRUE);
         $data_setting = array("configs" => $data_json);
         log_helper::add("3", $this->current_role, $this->user_id, "Updated the System Settings");
         $this->setting_model->update("1", $data_setting);
     }
 }
コード例 #11
0
 public function logout()
 {
     $this->auth->logout();
     $this->session->destroy("requested_url");
     log_helper::add("2", $this->user_log, $this->user_id, "Logged Out from the System.");
     url::redirect('/auth');
 }
コード例 #12
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $item = $this->item_model->find($id);
         log_helper::add("1", $this->user_log, $this->user_id, "Item deleted named " . $item->name . ".");
         echo $this->item_model->delete($item->id);
     }
 }
コード例 #13
0
 public function delete($id)
 {
     if (request::is_ajax() && request::method() === 'post') {
         $this->auto_render = FALSE;
         $user = $this->user_model->find($id);
         $userInfo = json_decode($user->user_information);
         if (!empty($user->user_information)) {
             $userName = $userInfo->fullname;
         } else {
             $userName = "******";
         }
         log_helper::add("1", $this->user_log, $this->user_id, "Deleted User named " . $userName . ".");
         echo $this->user_model->delete($id);
     }
 }