diff --git a/application/controllers/inwardgateregister.php b/application/controllers/inwardgateregister.php index 8ae1a55c..a8bbf5bb 100755 --- a/application/controllers/inwardgateregister.php +++ b/application/controllers/inwardgateregister.php @@ -13,7 +13,7 @@ class inwardgateregister extends BaseController { /** * default constructor of the class - */ + */ public function __construct() { parent::__construct(); @@ -87,39 +87,191 @@ class inwardgateregister extends BaseController /** * To upload IGR files */ - function uploadFile() + function adfile() { - $pathinfo = pathinfo($_FILES['myfile']['name']); - $config['upload_path'] = 'uploads/Igrfiles/'; - $config['allowed_types'] = 'png|jpg|jpeg|pdf|docx'; - $config['file_name'] = $_FILES['myfile']['name']; + $picture = ''; + if(!empty($_FILES['file']['name'])) + { + $config['upload_path'] = 'uploads/Igrfiles/'; + $config['allowed_types'] = '*'; + $config['file_name'] =str_replace(" ","", $_FILES['file']['name']); //Load upload library and initialize configuration $this->load->library('upload',$config); $this->upload->initialize($config); - if($this->upload->do_upload('myfile')) + if($this->upload->do_upload('file')) { $uploadData = $this->upload->data(); - $uploadfilename = $uploadData['file_name']; - return $uploadfilename; - + $picture = $uploadData['file_name']; + // return $uploadfilename; + } + else + { + $error = array('error' => $this->upload->display_errors()); + $picture = ''; + } + + + } + else + { + $picture = ''; + } + + + return $picture ; + } + + + function addloadfile() + { + + //echo 'Add new file '; + + $upfiles = ''; + $pono= $this->input->post('PONO'); + + $igr= $this->input->post('igr'); + //print_r($igr); + $new_file_name =$_FILES['file']['name']; + + $new_file_name = str_replace(" ","",$new_file_name); + + // print_r($new_file_name); + + $files = $this->inwardgateregister_model->getfies($igr); + + //print_r($files); + + $fcount = 0; + + foreach ($files as $value) + { + + $lastfile = $value->FilePath; + + + if($lastfile == $new_file_name) + { + //echo 'eqal'; + + // echo 'cm'.$fcount; + $fcount ++; + + //echo 'cp'.$fcount; + } + } + + + + if($fcount == 0) + { + //echo 'if'.$fcount.''; + + if(!empty($new_file_name)) + { + $Picture = $this->adfile(); + + // print_r($Picture); die; + $myfiles =array('PONO'=>$pono,'IGRNO'=>$igr,'FilePath'=>$Picture); + + $upfiles = $this->inwardgateregister_model->fileupload($myfiles); + //print_r($upfiles); + } + } + //echo 'filename'.$upfiles; + + if( $upfiles > 0){ + echo "file updated successfully!"; } else { + echo "File name already Exist"; + } + + } + + function add($pathname) + { + // echo "add files"; + // die(); + //echo $pathname; die(); + + $picture = ''; + if(!empty($_FILES[$pathname]['name'])) + { + + $config['upload_path'] = 'uploads/Igrfiles/'; + $config['allowed_types'] = '*'; + //$config['allowed_types'] = 'jpg|jpeg|png|gif'; + $config['file_name'] = str_replace(" ","",$_FILES[$pathname]['name']); + + + //Load upload library and initialize configuration + $this->load->library('upload',$config); + $this->upload->initialize($config); + if($this->upload->do_upload($pathname)) + { + // echo "uploadif"; + $uploadData = $this->upload->data(); + $picture = $uploadData['file_name']; + } + else + { $error = array('error' => $this->upload->display_errors()); - $uploadfilename = ''; - print_r($error); - return 0; + // $uploadfilename = ''; + // print_r($error); + // return 0; + $picture = ''; } - + } + else + { + // echo "else"; + $picture = ''; + } + + return $picture ; } /** * To Store IGR data into DB */ + function edituploadfile() + { + + + $bill= $this->input->post('param1'); + + $oldfile = $this->input->post('param2'); + + $newfile =$this->input->post('file'); + // $new_file_name =$_FILES['file']['name']; + $newfile = str_replace(" ","",$newfile); + + + + if(!empty($_FILES['file']['name'])) + { + + $Picture = $this->adfile(); + }else{ + $Picture = $oldfile ; + } + //echo $Picture;die; + $uploadfile = $this->inwardgateregister_model->updatefile($bill,$Picture,$oldfile); + + + // if($uploadfile > 0){ + echo "updated successfully!"; + // } + // else{ + // echo "updated successfully!"; + // } + } function addNewigr() { @@ -377,6 +529,19 @@ $prefile =array(); } + + function ViewIGRfile() + { + $IGRNO= $this->input->post('id'); + // echo($IGRNO); + $igrfile = $this->inwardgateregister_model->viewIGRFile($IGRNO); + $billfile = $this->inwardgateregister_model->ViewIGRfile1($IGRNO); + $data = array_merge($igrfile,$billfile); + echo json_encode($data); + + } + + /** *To Update igr Datas form ajax */ diff --git a/application/controllers/report.php b/application/controllers/report.php index 6089e430..4593536f 100755 --- a/application/controllers/report.php +++ b/application/controllers/report.php @@ -495,7 +495,46 @@ class report extends BaseController $data['cum_day']=$this->dahsboard_Model->report_cum_day($sup,$mat); $this->loadviews("Report_cumulative_day",$this->global,$data, NULL); - } + } + function Viewfiles() + { + + $PO= $this->input->post('id'); + + $PONO= substr($PO,10); + + //echo $PONO; die; + + $data = $this->dahsboard_Model->getfile($PONO); + + // print_r( $data);die; + + echo json_encode($data); + + } + + function Viewnormaligrfiles() + { + + $igr= $this->input->post('id'); + $PONO= $this->input->post('id1'); + + + // $PONO= substr($PO,5); + //echo $PONO; die; + + $igrfile= $this->dahsboard_Model->getfiles($igr,$PONO); + // $igrfile = $this->inwardgateregister_model->viewIGRFile($IGRNO); + $billfile = $this->dahsboard_Model->viewIGRFile1($igr,$PONO); + + $data = array_merge($igrfile,$billfile); + + // print_r( $data);die; + + echo json_encode($data); + + } + public function ipurchase() { @@ -1260,18 +1299,7 @@ class report extends BaseController } - function Viewfiles() - { - - $PO= $this->input->post('id'); - $PONO= substr($PO,5); - - $data = $this->dahsboard_Model->getfile($PONO); - - echo json_encode($data); - - } } ?> \ No newline at end of file diff --git a/application/models/dahsboard_model.php b/application/models/dahsboard_model.php index 3197a94c..8505fb0b 100755 --- a/application/models/dahsboard_model.php +++ b/application/models/dahsboard_model.php @@ -30,7 +30,50 @@ class dahsboard_Model extends CI_Model return $query->result(); } + function getfiles($igr,$PONO) + { + //$this->db->distinct(); + $this->db->select('*'); + $this->db->from('T_Inwardgateregister_fileupload'); + $this->db->where('IGRNO',$igr); + $this->db->where('PONO',$PONO); + + + $query = $this->db->get(); + // print_r( $this->db->last_query()); + $result = $query->result_array(); + return $result; + } + function viewIGRFile1($igr,$PONO) + { + $this->db->distinct(); + $this->db->select('igrm.file,igrm.PONO as pono'); //BillNo,IGRNO,FilePath,PONO + $this->db->from('T_IGR_Master igrm'); + $this->db->where('igrm.IGRNO',$igr); + $this->db->where('igrm.PONO',$PONO); + $query = $this->db->get(); + + $result = $query->result(); + // print_r($result);die; + //print_r($this->db->last_query()); + return $result; + +} + + function selectigrfiles() + { + $this->db->select('*'); + $this->db->from('T_Inwardgateregister_fileupload'); + //$this->db->where('PONO',$PONO); + + + $query = $this->db->get(); + // print_r( $this->db->last_query()); + $result = $query->result_array(); + return $result; + + } function totloan() { @@ -1472,7 +1515,7 @@ ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) - round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles from T_IGR_Master im left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1482,6 +1525,7 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO +left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1576,7 +1620,7 @@ ifnull((id.QuantityAsPerInvoice * pl.Rate),0))) - round(ifnull(if(POType = 'REVENUE', (id.QuantityAsPerInvoice * rt.AfterDiscount / pl.Quantity), (id.QuantityAsPerInvoice * st.Afterdiscountval / pl.Quantity)),0),2)),2) as total, - im.file as ifile,pb.FilePath as file + im.file as ifile,pb.FilePath as file,infiles.FilePath as Infiles from T_IGR_Master im left join T_PurchaseOrder_LineItem pl on pl.PONO = im.PONO join T_IGR_Details id on id.IGRNO = im.IGRNO and id.MaterialCode = pl.MaterialCode @@ -1586,6 +1630,7 @@ left join T_SupplierDetailsN sd on sd.SupplierID = pm.SupplierID left join T_Service_Tax st on st.LineItemNo = pl.LineItemNo left join T_Revenue_Tax rt on rt.LineItemNo = pl.LineItemNo left join T_PurchaseOrder_BillUpload pb on pb.IGRNO=im.IGRNO +left join T_Inwardgateregister_fileupload infiles on infiles.IGRNO = im.IGRNO where pm.Status != 'ST030' "; if ($cname!= ''){ @@ -1671,7 +1716,7 @@ $sql.="group by pono,material_name,category,supplier_name,id.IGRItemNo"; function ireport_attachment($cname,$fa,$aa,$m,$frm,$t){ - $sql="select pono,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, + $sql="select pono,igrn,potype,date_format(created_date,'%d-%m-%Y') as created_date,date_format(materialrcvddate,'%d-%m-%Y') as materialrcvddate,supplier_name, sum(total) as total,file,ifile from igr where status != 'ST030' @@ -1712,9 +1757,33 @@ if ($cname!= ''){ // echo $sid; //echo $sql; $query = $this->db->query($sql); - return $query->result(); - } + $filequery = $query->result(); + $resultArray = array(); + + foreach ($filequery as $value) { + + $tempArray['pono'] = $value->pono; + $tempArray['potype'] =$value->potype; + $tempArray['supplier_name'] = $value->supplier_name; + $tempArray['materialrcvddate'] = $value->materialrcvddate; + $tempArray['total'] = $value->total; + $tempArray['created_date'] = $value->created_date; + $tempArray['file'] = $value->file; + $tempArray['ifile'] = $value->ifile; + $tempArray['igrn'] =$value->igrn; + + $sqli ="select FilePath as Infiles from T_Inwardgateregister_fileupload where PONO =? and IGRNO =? "; + $querys = $this->db->query($sqli,array( $tempArray['pono'],$tempArray['igrn'])); + + $filepath = $querys->result(); + $tempArray['Infiles'] = $filepath; + + $resultArray[] = $tempArray; + } + return $resultArray; + + } function ireport_year_wise($a,$b){ diff --git a/application/models/inwardgateregister_model.php b/application/models/inwardgateregister_model.php index 5fbe65f5..542963ce 100755 --- a/application/models/inwardgateregister_model.php +++ b/application/models/inwardgateregister_model.php @@ -13,7 +13,7 @@ class inwardgateregister_model extends CI_Model // if($oldfile != ''){ // //unlink("uploads/BillFiles/".$oldfile);//this deletes the file on particular folder too - // } + // } $this->db->set('FilePath', $Picture); //value that used to update column $this->db->where('BillNo', $bill); //which row want to upgrade @@ -89,14 +89,16 @@ class inwardgateregister_model extends CI_Model function igrListing() { - $this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName,igr.file,igrdetail.*,POL.Quantity,MM.MaterialName'); + //$this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName,fileup.FilePath,igr.file'); + $this->db->select('igr.*,PO.DeliveryDate,sup.SupplierName,fileup.FilePath,igr.file,igrdetail.*,POL.Quantity,MM.MaterialName'); $this->db->from('T_IGR_Master igr'); $this->db->join('T_PurchaseOrder_Master PO','igr.PONO = PO.PONO'); + $this->db->join('T_Inwardgateregister_fileupload fileup',' igr.IGRNO = fileup.IGRNO','left'); $this->db->join('T_SupplierDetailsN` sup','PO.SupplierID = sup.SupplierID'); $this->db->join('T_IGR_Details igrdetail','igrdetail.IGRNO = igr.IGRNO'); $this->db->join('T_PurchaseOrder_LineItem POL','igr.PONO = POL.PONO and POL.MaterialCode=igrdetail.MaterialCode'); $this->db->join('T_MaterialMaster MM', 'MM.MaterialCode = igrdetail.MaterialCode'); - $this->db->order_by('igr.IGRNO','desc'); + $this->db->group_by('igr.IGRNO','desc'); //$this->db->group_by('igr.IGRNO'); $query = $this->db->get(); $result = $query->result(); @@ -119,10 +121,26 @@ class inwardgateregister_model extends CI_Model return $result; } - /** - * To get the po details - * @return array $result : result of the query (returns po information) - */ + function viewIGRFile1($IGRNO) + { + $this->db->distinct(); + $this->db->select('igrm.file,igrm.PONO as pono'); //BillNo,IGRNO,FilePath,PONO + $this->db->from('T_IGR_Master igrm'); + //$this->db->join('T_Inwardgateregister_fileupload igrf','igrm.IGRNO = igrf.IGRNO','left'); + //$this->db->join('T_IGR_Details igrd','igrm.IGRNO = igrd.IGRNO','left'); + + $this->db->where('igrm.IGRNO',$IGRNO); + + $query = $this->db->get(); + + $result = $query->result(); + // print_r($result);die; + //print_r($this->db->last_query()); + return $result; + + + + } function getpurchaseorder() { $this->db->distinct(); diff --git a/application/views/Report_attach_inward.php b/application/views/Report_attach_inward.php index ce97b09b..8d3bbcfd 100755 --- a/application/views/Report_attach_inward.php +++ b/application/views/Report_attach_inward.php @@ -230,32 +230,44 @@ $tot_tot = 0; foreach($purchase as $rel) - { + + { + //print_r($rel); ?> -
| S.No | +IGR No | PO No | Supplier Name | @@ -71,13 +80,13 @@ { $index = 0; foreach($IGR as $record) { - + // print_r($record); $index = $index +1; ?>|||
|---|---|---|---|---|---|---|
| - | IGRItemNo ?>" > IGRNO ?> | + +IGRItemNo ?>" > IGRNO ?> | PONO ?> | SupplierName ?> | @@ -93,18 +102,32 @@CourierNo ?> | file)) + if(!empty($record->FilePath)) { ?> - + + + + - | + } else if(!empty($record->file)) + { ?> + + + + + + + + + +
| ' + i + ' | ' + + '' + BillNO+ ' | ' + + '' + PONO+ ' | ' + + + ''+ Filename +' | ' + + + '' + + ' |