From 7828743022dbeafc31d6245d54a27de103aca2b8 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Fri, 15 Jun 2018 17:04:34 +0530 Subject: [PATCH] file upload --- .../controllers/emergencypurchaseorder.php | 10 ++-- application/controllers/purchaseorder.php | 46 +++++++++++-------- .../controllers/servicepurchaseorder.php | 46 +++++++++++++++---- application/models/purchaseorder_model.php | 22 +++++++-- 4 files changed, 88 insertions(+), 36 deletions(-) mode change 100755 => 100644 application/controllers/emergencypurchaseorder.php mode change 100755 => 100644 application/controllers/servicepurchaseorder.php mode change 100755 => 100644 application/models/purchaseorder_model.php diff --git a/application/controllers/emergencypurchaseorder.php b/application/controllers/emergencypurchaseorder.php old mode 100755 new mode 100644 index 338a0744..93a50c9f --- a/application/controllers/emergencypurchaseorder.php +++ b/application/controllers/emergencypurchaseorder.php @@ -2,7 +2,7 @@ require APPPATH . '/libraries/BaseController.php'; -/** +/** * Class : purchaseorder (PurchaseorderController) * User Class to control all user related operations. * @author : VenbaMail Mali @@ -224,7 +224,7 @@ class emergencypurchaseorder extends BaseController /*----------------------------------special po file upload service----------------------------------*/ function add($pathname) { - echo "add files"; + // echo "add files"; // die(); //echo $pathname; die(); @@ -236,13 +236,13 @@ function add($pathname) $config['allowed_types'] = '*'; //$config['allowed_types'] = 'jpg|jpeg|png|gif'; $config['file_name'] = $_FILES[$pathname]['name']; - echo "if"; + // echo "if"; //Load upload library and initialize configuration $this->load->library('upload',$config); $this->upload->initialize($config); if($this->upload->do_upload($pathname)) { - echo "uploadif"; + // echo "uploadif"; $uploadData = $this->upload->data(); $picture = $uploadData['file_name']; } @@ -254,7 +254,7 @@ function add($pathname) } else { - echo "else"; + // echo "else"; $picture = ''; } diff --git a/application/controllers/purchaseorder.php b/application/controllers/purchaseorder.php index b4d5a639..be4a5cb2 100644 --- a/application/controllers/purchaseorder.php +++ b/application/controllers/purchaseorder.php @@ -8,7 +8,7 @@ require APPPATH . '/third_party/mpdf/mpdf.php'; * Class : purchaseorder (PurchaseorderController) * User Class to control all user related operations. * @author : Venba InfoTech - * @version : 1.1 + * @version : 1.1 * @since : 09/06 Feb 2017 */ class purchaseorder extends BaseController @@ -4165,29 +4165,39 @@ function addloadfile() $igr= $this->input->post('igr'); $new_file_name =$_FILES['file']['name']; - //echo $new_file_name;die; - if(!empty($new_file_name)) + + + $file = $this->purchaseorder_model->getfies($pono); + +$fcount=0; + + foreach ($file as $value) + { + + $lastfile = $value->FilePath; + + + if($lastfile == $new_file_name) + { + $fcount++; + echo 'File name already Exist'; + + } +} + + + + if($fcount == 0) { $Picture = $this->adfile(); + $filelist =array('PONO'=>$pono,'IGRNO'=>$igr,'FilePath'=>$Picture); + $uploadfile = $this->purchaseorder_model->insertfile($filelist); } - else - { - $Picture =''; - } -//echo $Picture;die; -$filelist =array('PONO'=>$pono,'IGRNO'=>$igr,'FilePath'=>$Picture); - - - - $uploadfile = $this->purchaseorder_model->insertfile($filelist); - - if($uploadfile > 0){ + if($uploadfile > 0){ echo "file updated successfully!"; } - else{ - echo "file not updated!"; - } + } function adfile() diff --git a/application/controllers/servicepurchaseorder.php b/application/controllers/servicepurchaseorder.php old mode 100755 new mode 100644 index 97fe7077..93187f53 --- a/application/controllers/servicepurchaseorder.php +++ b/application/controllers/servicepurchaseorder.php @@ -666,26 +666,52 @@ function uploadfile() $new_file_name =$_FILES['file']['name']; //echo $new_file_name;die; - if(!empty($new_file_name)) + // if(!empty($new_file_name)) + // { + // $Picture = $this->adfile(); + // } + // else + // { + // $Picture =''; + // } +//echo $Picture;die; + $file = $this->purchaseorder_model->getfies($pono); + +$fcount=0; + + foreach ($file as $value) + { + + $lastfile = $value->FilePath; + + + if($lastfile == $new_file_name) + { + $fcount++; + + + } +} + +$upfile=''; + + if($fcount == 0) { $Picture = $this->adfile(); + $filelist =array('PONO'=>$pono,'FilePath'=>$Picture); + $upfile = $this->purchaseorder_model->insertfile($filelist); } - else - { - $Picture =''; - } -//echo $Picture;die; -$filelist =array('PONO'=>$pono,'FilePath'=>$Picture); - $uploadfile = $this->purchaseorder_model->insertfile($filelist); + + - if($uploadfile > 0){ + if($upfile > 0){ echo "file updated successfully!"; } else{ - echo "file not updated!"; + echo "File name already Exist"; } } diff --git a/application/models/purchaseorder_model.php b/application/models/purchaseorder_model.php old mode 100755 new mode 100644 index 25f0cc23..ab91f684 --- a/application/models/purchaseorder_model.php +++ b/application/models/purchaseorder_model.php @@ -23,7 +23,25 @@ class purchaseorder_model extends CI_Model -/*-----------may25-------------------*/ + +/*------------jun15------------------*/ + + +function getfies($pono) + { + + $this->db->select('*'); + + + $this->db->from('T_PurchaseOrder_BillUpload bill'); + + $this->db->where('PONO',$pono); + + $query = $this->db->get(); + + return $query->result(); + } +/*-----------jun15-------------------*/ function updateMatStock($itemNo, @@ -38,9 +56,7 @@ class purchaseorder_model extends CI_Model return $r; } -/*-----------may25-------------------*/ -/*------------------------------*/ function updateReqDetails($Reqnumber,$MaterialCode,$ReqDetail){