diff --git a/application/controllers/supplier.php b/application/controllers/supplier.php index 143fe018..ced6cb41 100755 --- a/application/controllers/supplier.php +++ b/application/controllers/supplier.php @@ -77,6 +77,7 @@ class supplier extends BaseController print_r($query); } + /* To Check the Pan Number is exists in the database or not for the selected Supplier */ function checkPanValidateSupplier() { @@ -113,6 +114,56 @@ class supplier extends BaseController return true; } } + + + + function CheckGST() + { + //alert('check validation GST'); + $id = $this->input->post('id'); + $query = $this->supplier_model->checkGST($id); + $query = $query[0]['GSTNO']; + print_r($query); + + } + + + /* To Check the GST Number is exists in the database or not for the selected Supplier */ + function checkGstValidateSupplier() { + //alert(' gst validation GST'); + $SupplierID = $this->input->post('SupplierID'); + $GstNo = $this->input->post('GSTNo'); + //echo 'Sup'. $SupplierID ; + $query = $this->supplier_model->checkGST($GstNo,$SupplierID); + if (count($query)> 0) + { + $this->form_validation->set_message('checkGstValidateSupplier', 'The Entered GST Number is already exists in the Database.'); + return false; + } + else + { + return true; + } + } + + + /* To Check the GST Number is exists in the database or not */ + function checkGstValidate() + { + + $GstNo = $this->input->post('GSTNo'); + $query = $this->supplier_model->checkGST($GstNo); + if (count($query)> 0) + { + $this->form_validation->set_message('checkGstValidate', 'The Entered GST Number is already exists in the Database.'); + return false; + } + else + { + return true; + } + } + /** * This function is used to add new Supplier to the system @@ -128,7 +179,7 @@ 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_checkPanValidate'); - + $this->form_validation->set_rules('GSTNo','GSTNo','trim|requried|max_length[15]|callback_checkGstValidate'); if($this->form_validation->run() == FALSE) { @@ -144,7 +195,7 @@ class supplier extends BaseController $Exiseregistration = $this->input->post('Exciseregistration'); $TIN = $this->input->post('TIN'); $PAN = strtoupper($this->input->post('panno')); - $GSTNo = $this->input->post('GSTNo'); + $GSTNo = strtoupper($this->input->post('GSTNo')); $GSTRange = $this->input->post('GSTRange'); $CollectrateAddress = $this->input->post('CollectrateAddress'); $UANumber = $this->input->post('UANumber'); @@ -183,7 +234,7 @@ class supplier extends BaseController $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); - + //print_r($supplier);die(); $result = $this->supplier_model->addNewsupplier($supplier); @@ -222,8 +273,9 @@ 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'); + $this->form_validation->set_rules('GSTNo','GSTNo','trim|requried|max_length[15]|callback_checkGstValidateSupplier'); + if($this->form_validation->run() == FALSE) @@ -241,7 +293,7 @@ class supplier extends BaseController $Exiseregistration = $this->input->post('Exciseregistration'); $TIN = $this->input->post('TIN'); $PAN = strtoupper($this->input->post('panno')); - $GSTNo = $this->input->post('GSTNo'); + $GSTNo = strtoupper($this->input->post('GSTNo')); $GSTRange = $this->input->post('GSTRange'); $CollectrateAddress = $this->input->post('CollectrateAddress'); $UANumber = $this->input->post('UANumber'); @@ -288,7 +340,7 @@ class supplier extends BaseController $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(); + //print_r($supplier);die(); $result = $this->supplier_model->UpdateSupplier($supplier, $supplierID); diff --git a/application/models/supplier_model.php b/application/models/supplier_model.php index f389d323..e7c8f41f 100755 --- a/application/models/supplier_model.php +++ b/application/models/supplier_model.php @@ -61,6 +61,24 @@ class supplier_model extends CI_Model } + function checkGST($GST,$SID = '') + { + $this->db->select('GSTNO'); + $this->db->from('T_SupplierDetailsN'); + $this->db->where('GSTNO',$GST); + if ($SID != '') + { + $this->db->where('SupplierID !=',$SID); + } + $query = $this->db->get(); + //print_r($this->db->last_query()); + if ($query->num_rows > 0) { + // echo $query->num_rows; + return $query->result_array(); + } + + } + diff --git a/application/views/addsupplier.php b/application/views/addsupplier.php index 21bc2e2a..32ad7d97 100755 --- a/application/views/addsupplier.php +++ b/application/views/addsupplier.php @@ -75,6 +75,33 @@ function validatePAN() { } } + +function validateGST() { + var reg = /(?=.*[0-9]).{2}(?=.*[A-Za-z]).{5}(?=.*[0-9]).{4}(?=.*[A-Za-z]).{1}(?=.*[0-9]).{1}(?=.*[A-Za-z]).{1}(?=.*[0-9]).{1}$/; + //alert('gst'); + var GST = $('#GSTNo').val(); + + if(GST != '') + { + if (reg.test(GST) == false) + { + alert('Please Enter Valid GST Number Format should be 22AAAAA1111S1Z1'); + return (false); + } + else + { + return true; + } + } + else + { + alert('Please Enter GST Number'); + return (false); + } + +} + + function validateECCNumber() { var reg = /(?=.*[A-Za-z]).{5,}(?=.*[0-9]).{4,}(?=.*[A-Za-z]).{1,}(?=.*[A-Za-z]).{2,}(?=.*[0-9]).{3,}$/; @@ -190,6 +217,7 @@ $(function() {