diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index 7189fda4..c82d54e0 100755 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -18,7 +18,7 @@ class supplier extends BaseController { parent::__construct(); $this->load->model('supplier_model'); - $this->load->library('form_validation'); + $this->load->library('form_validation'); $this->load->library('pagination'); $this->load->library('Excel'); $this->isLoggedIn(); @@ -40,8 +40,7 @@ class supplier extends BaseController { $this->load->model('supplier_model'); - - + $data['userRecords'] = $this->supplier_model->supplierListing(); $this->global['pageTitle'] = 'Siddharth Industries : Supplier Listing'; @@ -122,13 +121,10 @@ class supplier extends BaseController $this->form_validation->set_rules('SupplierName','Supplier Name','trim|required'); $this->form_validation->set_rules('Address','Address','trim|required|'); - $this->form_validation->set_rules('ContactNumber','Contact Number','trim|required|numeric|max_length[10]'); $this->form_validation->set_rules('AlternateContactNumber','Alternate Contact Number','trim|numeric|max_length[10]'); $this->form_validation->set_rules('emailid','emailid', 'valid_email|max_length[128]|required'); - $this->form_validation->set_rules('TIN','TIN','trim|required|max_length[11]'); - $this->form_validation->set_rules('panno', 'panno', 'trim|required|max_length[10]|callback_checkPanValidate'); @@ -153,7 +149,7 @@ class supplier extends BaseController $PaymentTerms = $this->input->post('PaymentTerms'); $Payment = $this->input->post('Payment'); $PayableAT = $this->input->post('PayableAT'); - $CSTNo = $this->input->post('CSTNo'); + $CSTNo = $this->input->post('CSTNo'); $CSTDt = $this->input->post('dateofCST'); @@ -165,11 +161,29 @@ class supplier extends BaseController { $CSTDate = null; } + + $EMSNo = $this->input->post('EMSNo'); + $TSNo = $this->input->post('TSNo'); + $IMSNo = $this->input->post('IMSNo'); + $ISONo = $this->input->post('ISONo'); + $OSHASNo = $this->input->post('OSHASNo'); + $accno = $this->input->post('accno'); + $ifsc = $this->input->post('ifsc'); + $branchname = $this->input->post('branchname'); + $bankaddress = $this->input->post('bankaddress'); + $Createdby = $this->session->userdata ( 'userId' ); + $date = new DateTime('now', new DateTimeZone('Asia/Kolkata')); + $createddate = $date->format('Y-m-d H:i:s'); + $service = $this->input->post('service'); + $rawmaterial =$this->input->post('rawmaterial'); + $maintenance = $this->input->post('maintenance'); + - $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'Exiseregistration'=>$Exiseregistration,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$Payment,'PayableAT'=>$PayableAT,'CSTNo'=>$CSTNo,'CSTDate'=>$CSTDate,'Createdby'=>$Createdby); + $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'Exiseregistration'=>$Exiseregistration,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$Payment,'PayableAT'=>$PayableAT,'CSTNo'=>$CSTNo,'CSTDate'=>$CSTDate,'CSTNo'=>$CSTNo,'CSTDate'=>$CSTDate,'Cert_EMS'=>$EMSNo, 'Cert_TS'=>$TSNo, 'Cert_IMS'=>$IMSNo, 'Cert_ISO'=>$ISONo, 'Cert_OSHAS'=>$OSHASNo, 'BankAcNumber'=>$accno, 'IFSCCode'=>$ifsc, 'BranchName'=>$branchname, 'BankAddress'=>$bankaddress,'Createdby'=>$Createdby,'IsService'=>$service,'IsMaintanance'=>$maintenance,'IsRawMaterial'=>$rawmaterial); $result = $this->supplier_model->addNewsupplier($supplier); + if($result > 0) { @@ -206,16 +220,17 @@ class supplier extends BaseController $this->form_validation->set_rules('emailid','emailid','valid_email|max_length[128]|required'); $this->form_validation->set_rules('TIN','TIN','trim|required|max_length[11]'); - + $this->form_validation->set_rules('panno', 'panno', 'trim|required|max_length[10]|callback_checkPanValidateSupplier'); - + + if($this->form_validation->run() == FALSE) { $this->viewsupplier($supplierID); } else { - + $SupplierName = $this->input->post('SupplierName'); $Address = $this->input->post('Address'); $ContactNumber = $this->input->post('ContactNumber'); @@ -230,7 +245,7 @@ class supplier extends BaseController $UANumber = $this->input->post('UANumber'); $PaymentTerms = $this->input->post('PaymentTerms'); $Payment = $this->input->post('Payment'); - $PayableAT = $this->input->post('PayableAT'); + //$PayableAT = $this->input->post('PayableAT'); $UpdatedBy = $this->session->userdata ( 'userId' ); $chked = $this->input->post('isactive'); @@ -244,9 +259,8 @@ class supplier extends BaseController } $CSTNo = $this->input->post('CSTNo'); - $CSTDt = $this->input->post('dateofCST'); - + if($CSTDt != '') { $CSTDate = $this->getDateformat($CSTDt); @@ -255,11 +269,27 @@ class supplier extends BaseController { $CSTDate = null; } - $supplier = array(); - - $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'Exiseregistration'=>$Exiseregistration,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$Payment,'PayableAT'=>$PayableAT,'UpdatedBy'=>$UpdatedBy,'IsActive'=>$IsActive,'CSTNo'=>$CSTNo,'CSTDate'=>$CSTDate); - - $result = $this->supplier_model->UpdateSupplier($supplier, $supplierID); + + $EMSNo = $this->input->post('EMSNo'); + $TSNo = $this->input->post('TSNo'); + $IMSNo = $this->input->post('IMSNo'); + $ISONo = $this->input->post('ISONo'); + $OSHASNo = $this->input->post('OSHASNo'); + $accno = $this->input->post('accno'); + $ifsc = $this->input->post('ifsc'); + $branchname = $this->input->post('branchname'); + $bankaddress = $this->input->post('bankaddress'); + $service = $this->input->post('service'); + $rawmaterial =$this->input->post('rawmaterial'); + $maintanance = $this->input->post('maintanance'); + + $supplier = array(); + $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'Exiseregistration'=>$Exiseregistration,'TIN'=>$TIN,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$Payment,'CSTNo'=>$CSTNo,'CSTDate'=>$CSTDate,'Cert_EMS'=>$EMSNo, 'Cert_TS'=>$TSNo, 'Cert_IMS'=>$IMSNo, 'Cert_ISO'=>$ISONo, 'Cert_OSHAS'=>$OSHASNo, 'BankAcNumber'=>$accno, 'IFSCCode'=>$ifsc, 'BranchName'=>$branchname, 'BankAddress'=>$bankaddress,'UpdatedBy'=>$UpdatedBy,'IsActive'=>$IsActive,'IsService'=>$service,'IsMaintanance'=>$maintanance,'IsRawMaterial'=>$rawmaterial); + //SupplierID, SupplierName, Address, ContactNumber, AlternateContactNumber, EmailAddress, Exiseregistration, TIN, PAN, CSTNO, CSTDate, GSTNO, GSTRange, CollectrateAddress, UANumber, PaymentTerms, PaymentDays, PayableAT, Cert_EMS, Cert_TS, Cert_IMS, Cert_ISO, Cert_OSHAS, BankAcNumber, IFSCCode, BranchName, BankAddress, Createdby, UpdatedBy, Updatedon, CreatedOn, IsActive); + print_r($supplier); + //die(); + $result = $this->supplier_model->UpdateSupplier($supplier, $supplierID); + if($result == True) { @@ -307,7 +337,6 @@ class supplier extends BaseController $this->excel->setActiveSheetIndex(0); $this->excel->getActiveSheet()->setTitle('supplier details'); - $this->excel->getActiveSheet()->setCellValue('A1', 'SupplierID'); $this->excel->getActiveSheet()->setCellValue('B1', 'SupplierName'); $this->excel->getActiveSheet()->setCellValue('C1', 'Address'); @@ -405,10 +434,6 @@ class supplier extends BaseController $this->excel->getActiveSheet()->setCellValue('S' . $i,$data['firstname']); $this->excel->getActiveSheet()->setCellValue('T' . $i,$data['Update_by']); $this->excel->getActiveSheet()->setCellValue('U' . $i,$data['IsActive']); - - - - $i++; $s++; diff --git a/application/models/supplier_model.php b/application/models/supplier_model.php index dc2f9554..96219051 100755 --- a/application/models/supplier_model.php +++ b/application/models/supplier_model.php @@ -15,7 +15,6 @@ class supplier_model extends CI_Model $this->db->select('BaseT.SupplierID, BaseT.SupplierName, BaseT.Address, BaseT.ContactNumber, BaseT.AlternateContactNumber,BaseT.EmailAddress,BaseT.Exiseregistration, BaseT.TIN, BaseT.PAN,,BaseT.GSTNO,BaseT.GSTRange,BaseT.CollectrateAddress,BaseT.UANumber,BaseT.PaymentTerms,BaseT.PaymentDays,BaseT.PayableAT,BaseT.CreatedOn'); $this->db->from('T_SupplierDetailsN as BaseT'); - $query = $this->db->get(); $result = $query->result(); @@ -67,12 +66,17 @@ class supplier_model extends CI_Model function addNewsupplier($supplier) { - - $this->db->insert('T_SupplierDetailsN', $supplier); - - $SID = $this->db->affected_rows(); - return $SID; + $this->db->insert('T_SupplierDetailsN', $supplier); + $SID = $this->db->affected_rows(); + + if($SID>0) + { + $subQuery = 'select max(SupplierID) as suppid from T_SupplierDetailsN'; + $query = $this->db->query($subQuery); + return $query->result(); + } + //return $SID; } @@ -95,7 +99,7 @@ function addNewsupplier($supplier) { $this->db->select('Address'); $this->db->from('T_SupplierDetailsN'); - $this->db->where('SupplierID', $supplierID); + $this->db->where('SupplierID', $supplierID); $query = $this->db->get(); return $query->result_array(); } @@ -103,9 +107,15 @@ function addNewsupplier($supplier) { $this->db->where('SupplierID', $supplierID); $this->db->update('T_SupplierDetailsN', $supplier); + + + return TRUE; } + + + function viewsupplier($supplier, $supplierID) { @@ -114,17 +124,29 @@ function addNewsupplier($supplier) return TRUE; } - + + function SupplierCertification($cerificate) + { + $this->db->insert_id('T_Supplier_Certification',$cerificate); + $insert_id = $this->db->affected_rows(); + + return $insert_id; + + } + function export_excel(){ $this->db->select('det.SupplierID,SupplierName,det.Address,det.ContactNumber,det.AlternateContactNumber,det.EmailAddress,det.Exiseregistration,det.TIN, -det.PAN,det.CSTNO,det.CSTDate,det.GSTNO,det.GSTRange,det.CollectrateAddress,det.UANumber,det.PaymentTerms,det.PaymentDays,det.PayableAT,emp.firstname ,emp1.firstname as Update_by,,det.IsActive'); + det.PAN,det.CSTNO,det.CSTDate,det.GSTNO,det.GSTRange,det.CollectrateAddress,det.UANumber,det.PaymentTerms,det.PaymentDays,det.PayableAT,emp.firstname ,emp1.firstname as Update_by,,det.IsActive'); $this->db->join('tbl_users as tbl',' det.createdby = tbl.userid','left'); $this->db->join('T_Employee_Details as emp', 'emp.empid=tbl.empid','left'); $this->db->join('tbl_users as tbl1',' det.UpdatedBy = tbl1.userid','left'); $this->db->join('T_Employee_Details as emp1', 'emp1.empid=tbl1.empid','left'); return $this->db->get('T_SupplierDetailsN as det')->result_array(); } + + /*SUPPLIER */ + /*SUPPLIER TYPE */ diff --git a/application/views/addsupplier.php b/application/views/addsupplier.php index 8eaa0a91..32f4a58d 100755 --- a/application/views/addsupplier.php +++ b/application/views/addsupplier.php @@ -1,4 +1,5 @@ -