diff --git a/app/Config/Routes.php b/app/Config/Routes.php index 1f7a156d..6f6f030b 100755 --- a/app/Config/Routes.php +++ b/app/Config/Routes.php @@ -137,6 +137,7 @@ $routes->post('purchaseorder/UpdateComplaint', 'Purchaseorder::UpdateComplaint') $routes->get('purchaseorder/Savencrlist', 'Purchaseorder::Savencrlist'); $routes->get('purchaseorder/Nonconfirmativelist','Purchaseorder::Nonconfirmativelist'); $routes->post('purchaseorder/addloadfile','Purchaseorder::addloadfile'); +$routes->post('purchaseorder/uploadfile', 'Purchaseorder::uploadfile'); //Zohobooks sync $routes->match(['GET', 'POST'],'user/zohobooks_api_fetch_all','User::zohobooks_api_fetch_all'); diff --git a/app/Controllers/Purchaseorder.php b/app/Controllers/Purchaseorder.php index c0950f85..a06ca417 100755 --- a/app/Controllers/Purchaseorder.php +++ b/app/Controllers/Purchaseorder.php @@ -657,6 +657,7 @@ class Purchaseorder extends BaseController $data['getlogpodtl'] = $this->purchaseorder_model->getlogpodtl($PONO); $data['WorkStatus'] = $this->purchaseorder_model->getStatus(7); + $data['billfile'] = $this->purchaseorder_model->getBillFile($PONO); $this->global['pageTitle'] = 'Edit Revenue Purchase order form'; $this->loadViews("editRevenuepurchaseorder", $this->global, $data, NULL); @@ -4245,20 +4246,29 @@ class Purchaseorder extends BaseController } } - + if ($fcount == 0) { if (!empty($new_file_name)) { $Picture = $this->adfile(); - $filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture); - $uploadfiles = $this->purchaseorder_model->insertfile($filelist); - if ($uploadfiles > 0) { - echo "file updated successfully!"; + if($Picture){ + $filelist = array('PONO' => $pono, 'IGRNO' => $igr, 'FilePath' => $Picture); + $uploadfiles = $this->purchaseorder_model->insertfile($filelist); + if ($uploadfiles > 0) { + echo "file updated successfully!"; + return true; + } + } else{ + echo " Internal Server Error..!!"; + return false; } - } + + } + }else{ - echo " File already Uploaded"; + echo " File already Uploaded with this name..!!"; + return false; } } @@ -4270,27 +4280,41 @@ class Purchaseorder extends BaseController $file = $this->request->getFile('file'); if ($file && $file->isValid()) { + + $fileName = str_replace(" ", "", $file->getName()); + // Define the file system path for uploads - $uploadPath = FCPATH . 'uploads/BillFiles/'; // 'FCPATH' points to 'public' directory + $uploadPath = FCPATH . '/public/uploads/BillFiles/'; // 'FCPATH' points to 'public' directory // Check if the directory exists, if not, create it if (!is_dir($uploadPath)) { mkdir($uploadPath, 0777, true); // Create the directory with write permissions - } + } + + // Log file name and path to check if the upload path is correct + error_log("Upload Path: " . $uploadPath); + error_log("File Name: " . $file->getName()); // Move the file to the upload directory - if ($file->move($uploadPath)) { - $picture = $file->getName(); // Get the file name after moving + if ($file->move($uploadPath,$fileName)) { + $picture = $fileName; // Get the file name after moving + error_log("File uploaded successfully: " . $picture); } else { + // Log the error if file move fails + error_log("Failed to move file. Error: " . $file->getErrorString()); $picture = ''; } } else { + // Log invalid file or failed validation + error_log("File is not valid or not uploaded."); $picture = ''; } return $picture; } + + @@ -4351,57 +4375,35 @@ class Purchaseorder extends BaseController $oldfile = $this->request->getPost('param2'); - $newfile = $this->request->getPost('file'); - // $new_file_name =$_FILES['file']['name']; - $newfile = str_replace(" ", "", $newfile); + $newfile = $this->request->getFile('file'); + $Picture=''; + $uploadfile=0; + + if (!empty($newfile)) { - - if (!empty($_FILES['file']['name'])) { - - $Picture = $this->add(); + $Picture = $this->adfile(); } else { + $Picture = $oldfile; } - //echo $Picture;die; - $uploadfile = $this->purchaseorder_model->updatefile($bill, $Picture, $oldfile); + + if($Picture !=''){ + + $uploadfile = $this->purchaseorder_model->updatefile($bill, $Picture); + } + - // if($uploadfile > 0){ + if($uploadfile > 0){ echo "updated successfully!"; - // } - // else{ - // echo "updated successfully!"; - // } + } + else{ + echo "Update Failed (maybe same file provided for update kindly check)..!!"; + } } - // function add() - // { - // $picture = ''; - // if (!empty($_FILES['file']['name'])) { - // $config['upload_path'] = 'public/uploads/BillFiles/'; - // $config['allowed_types'] = '*'; - // //$config['file_name'] = $_FILES['file']['name']; - // $config['file_name'] = str_replace(" ", "", $_FILES['file']['name']); - - // //print_r($config) ;die; - // //Load upload library and initialize configuration - // $this->load->library('upload', $config); - // $this->upload->initialize($config); - // if ($this->upload->do_upload('file')) { - // $uploadData = $this->upload->data(); - // $picture = $uploadData['file_name']; - // } else { - // $error = array('error' => $this->upload->display_errors()); - // $picture = ''; - // } - // } else { - // $picture = ''; - // } - - // return $picture; - // } public function add() { $picture = ''; @@ -4409,8 +4411,8 @@ class Purchaseorder extends BaseController // Check if file is uploaded if ($file = $this->request->getFile('file')) { // Define upload directory and allowed file types - $uploadPath = base_url() . 'public/uploads/BillFiles/'; // You can change this path as needed - $allowedTypes = '*'; // You can change this to specific file types like 'jpg|png|gif' + $uploadPath = base_url() . 'public/uploads/BillFiles/'; + $allowedTypes = '*'; // Set the file name without spaces $fileName = str_replace(" ", "", $file->getName()); diff --git a/app/Models/Purchaseorder_model.php b/app/Models/Purchaseorder_model.php index 50084904..b2d0c71e 100755 --- a/app/Models/Purchaseorder_model.php +++ b/app/Models/Purchaseorder_model.php @@ -2322,15 +2322,12 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, /*------------------------------------------------------------------------------*/ - function updatefile($bill, $Picture, $oldfile) + function updatefile($bill, $Picture) { - // if($oldfile != ''){ - // //unlink("public/uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too - // } $this->db->table('t_purchaseorder_billupload') - ->set('FilePath', $Picture) //value that used to update column - ->where('BillNo', $bill) //which row want to upgrade + ->set('FilePath', $Picture) + ->where('BillNo', $bill) ->update(); $afftectedRows = $this->db->affectedRows(); return $afftectedRows; @@ -2338,29 +2335,13 @@ mstr.CourierNo,pom.Status,pom.POType') //,bill.BillNo,bill.FilePath, - // function newlogpo($logpo) - // { - - // $this->db->transStart(); - // $builder = $this->db->table('T_ponewlogs_Details'); - // $builder->insert($logpo); - - // $insert_id = $this->db->affectedRows(); - // $this->db->transComplete(); - // return $insert_id; - - - // // $this->db->transStart(); - // $builder = $this->db->table('t_polog_details'); - // $builder->insert($logpo); - - // // $insert_id = $this->db->affectedRows(); - // // $this->db->transComplete(); - // // return $insert_id; - - // } - + function getBillFile($PONO){ + $builder = $this->db->table('t_purchaseorder_billupload')->select('*') + ->where('PONO', $PONO); + $query = $builder->get(); + return $query->getResult(); + } function insertlogpo($logpo) { diff --git a/app/Views/editRevenuepurchaseorder.php b/app/Views/editRevenuepurchaseorder.php index 910ad50f..a9b3e997 100755 --- a/app/Views/editRevenuepurchaseorder.php +++ b/app/Views/editRevenuepurchaseorder.php @@ -2443,7 +2443,7 @@ if (!empty($getlogpodtl)) { - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/uploads/BillFiles/routes_1.txt b/uploads/BillFiles/routes_1.txt deleted file mode 100644 index a11c037a..00000000 --- a/uploads/BillFiles/routes_1.txt +++ /dev/null @@ -1,411 +0,0 @@ -routes - -//Stock Module - -$routes->get('coatingMachineDetails' , 'StockController::loadView_coatingMachineDetails'); -$routes->post('addNewCoatingMachineDetails' , 'StockController::addNewCoatingMachineDetails'); -$routes->post('editCoatingMachineDetails','StockController::editCoatingMachineDetails'); - - -//stock controller - public function editCoatingMachineDetails(){ - - $putData=$this->request->getPost(); - - $id = $putData['editCoatingMachineDetailId']; - - $updated= $this->coatingMachineDetails_model->update($id,$putData); - - if ($updated) { - // Set flashdata for success message - return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully'); - } else { - // Set flashdata for error message - return redirect()->back()->with('error', 'Failed to update Coating machine details'); - } - - - } - -//coatingMachinedetailview - - -
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Customer NameDateShiftMachine On TimeMachine Off TimeMachine Running (hrs)Total CoatingTotal Coating Sand (kgs)Total Gas ConsumptionPer Hour Gas ConsumptionPer Hour Coating Sand QTYAction
- - -     - - - - - - - -     - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/uploads/BillFiles/routes_2.txt b/uploads/BillFiles/routes_2.txt deleted file mode 100644 index a11c037a..00000000 --- a/uploads/BillFiles/routes_2.txt +++ /dev/null @@ -1,411 +0,0 @@ -routes - -//Stock Module - -$routes->get('coatingMachineDetails' , 'StockController::loadView_coatingMachineDetails'); -$routes->post('addNewCoatingMachineDetails' , 'StockController::addNewCoatingMachineDetails'); -$routes->post('editCoatingMachineDetails','StockController::editCoatingMachineDetails'); - - -//stock controller - public function editCoatingMachineDetails(){ - - $putData=$this->request->getPost(); - - $id = $putData['editCoatingMachineDetailId']; - - $updated= $this->coatingMachineDetails_model->update($id,$putData); - - if ($updated) { - // Set flashdata for success message - return redirect()->to('/coatingMachineDetails')->with('success', 'Coating Machine details updated successfully'); - } else { - // Set flashdata for error message - return redirect()->back()->with('error', 'Failed to update Coating machine details'); - } - - - } - -//coatingMachinedetailview - - -
-
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Customer NameDateShiftMachine On TimeMachine Off TimeMachine Running (hrs)Total CoatingTotal Coating Sand (kgs)Total Gas ConsumptionPer Hour Gas ConsumptionPer Hour Coating Sand QTYAction
- - -     - - - - - - - -     - - - - - -
-
-
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/uploads/BillFiles/users_table_alter _query.txt b/uploads/BillFiles/users_table_alter _query.txt deleted file mode 100644 index 0841aa8f..00000000 --- a/uploads/BillFiles/users_table_alter _query.txt +++ /dev/null @@ -1,4 +0,0 @@ -users_table_alter _query - -ALTER TABLE `trs_matri_lara`.`users` -ADD COLUMN `last_login_reminder_at` TIMESTAMP NULL DEFAULT NULL AFTER `last_login_at`; \ No newline at end of file diff --git a/uploads/BillFiles/users_table_alter _query_1.txt b/uploads/BillFiles/users_table_alter _query_1.txt deleted file mode 100644 index 0841aa8f..00000000 --- a/uploads/BillFiles/users_table_alter _query_1.txt +++ /dev/null @@ -1,4 +0,0 @@ -users_table_alter _query - -ALTER TABLE `trs_matri_lara`.`users` -ADD COLUMN `last_login_reminder_at` TIMESTAMP NULL DEFAULT NULL AFTER `last_login_at`; \ No newline at end of file