load->model('supplier_model'); $this->load->library('form_validation'); $this->load->library('pagination'); $this->isLoggedIn(); } /** * This function used to load the first screen of the user */ public function index() { $this->global['pageTitle'] = 'Siddharth : Supplier'; $this->loadViews("supplierListing", $this->global, NULL , NULL); } /** * This function is used to load the Supplier list */ function supplierListing() { $this->load->model('supplier_model'); $searchText = $this->input->post('searchText'); $data['searchText'] = $searchText; $count = $this->supplier_model->supplierListingCount($searchText); $returns = $this->paginationCompress ( "supplierListing/", $count, 10 ); $data['userRecords'] = $this->supplier_model->supplierListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth Industries : Supplier Listing'; $this->loadViews("supplierListing", $this->global, $data, NULL); } /** * This function is used to load the add new supplier */ function addsupplier() { $data['payment'] = $this->supplier_model->getpayment(); //$data['users'] = $this->purchaseorder_model->getusers(); $this->global['pageTitle'] = 'siddharth : AddNew Supplier'; $this->loadViews("addsupplier", $this->global,$data, NULL); } /** * This function is used to check whether PAN already exist or not */ function CheckPAN() { $id = $this->input->post('id'); $query = $this->supplier_model->checkPAN($id ); $query = $query[0]['PAN']; print_r($query); } /* To Check the Pan Number is exists in the database or not for the selected Supplier */ function checkPanValidateSupplier() { $SupplierID = $this->input->post('SupplierID'); $PanNo = $this->input->post('panno'); // echo 'Sup'. $SupplierID ; $query = $this->supplier_model->checkPAN($PanNo,$SupplierID); if (count($query)> 0) { $this->form_validation->set_message('checkPanValidateSupplier', 'The Entered PAN Number is already exists in the Database.'); return false; } else { return true; } } /* To Check the Pan Number is exists in the database or not */ function checkPanValidate() { $PanNo = $this->input->post('panno'); $query = $this->supplier_model->checkPAN($PanNo); if (count($query)> 0) { $this->form_validation->set_message('checkPanValidate', 'The Entered PAN Number is already exists in the Database.'); return false; } else { return true; } } /** * This function is used to add new Supplier to the system */ function addNewsupplier() { $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'); if($this->form_validation->run() == FALSE) { $this->addsupplier(); } else { $SupplierName = $this->input->post('SupplierName'); $Address = $this->input->post('Address'); $ContactNumber = $this->input->post('ContactNumber'); $AlternateContactNumber = $this->input->post('AlternateContactNumber'); $EmailAddress = $this->input->post('emailid'); $Exiseregistration = $this->input->post('Exciseregistration'); $TIN = $this->input->post('TIN'); $PAN = $this->input->post('panno'); $GSTNo = $this->input->post('GSTNo'); $GSTRange = $this->input->post('GSTRange'); $CollectrateAddress = $this->input->post('CollectrateAddress'); $UANumber = $this->input->post('UANumber'); $PaymentTerms = $this->input->post('PaymentTerms'); $Payment = $this->input->post('Payment'); $PayableAT = $this->input->post('PayableAT'); $CSTNo = $this->input->post('CSTNo'); $CSTDt = $this->input->post('dateofCST'); if($CSTDt != '') { $CSTDate = $this->getDateformat($CSTDt); } else { $CSTDate = null; } $Createdby = $this->session->userdata ( 'userId' ); $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); $result = $this->supplier_model->addNewsupplier($supplier); if($result > 0) { redirect('supplierListing','refresh'); echo ""; } else { redirect('supplierListing','refresh'); echo ""; } } } function getDateformat($Val) { $date = new DateTime($Val); $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } /** * This function is used to edit the Supplier information */ function editsupplier() { $this->form_validation->set_rules('SupplierName','Supplier Name','trim|required'); $this->form_validation->set_rules('Address','Address','trim|required|'); $supplierID = $this->input->post('SupplierID'); //echo 'supID' . $supplierID ; $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_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'); $AlternateContactNumber = $this->input->post('AlternateContactNumber'); $EmailAddress = $this->input->post('emailid'); $Exiseregistration = $this->input->post('Exciseregistration'); $TIN = $this->input->post('TIN'); $PAN = $this->input->post('panno'); $GSTNo = $this->input->post('GSTNo'); $GSTRange = $this->input->post('GSTRange'); $CollectrateAddress = $this->input->post('CollectrateAddress'); $UANumber = $this->input->post('UANumber'); $PaymentTerms = $this->input->post('PaymentTerms'); $Payment = $this->input->post('Payment'); $PayableAT = $this->input->post('PayableAT'); $UpdatedBy = $this->session->userdata ( 'userId' ); $chked = $this->input->post('isactive'); if( $chked != '') { $IsActive = '1'; } else { $IsActive = '0'; } $CSTNo = $this->input->post('CSTNo'); $CSTDt = $this->input->post('dateofCST'); if($CSTDt != '') { $CSTDate = $this->getDateformat($CSTDt); } else { $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); if($result == True) { redirect('supplierListing','refresh'); echo ""; } else { redirect('supplierListing','refresh'); echo ""; } } } function viewsupplier($SID = '') { $Payment = ''; if($SID == '') { $supplierID = $_GET['SID']; $Payment = $_GET['Payment']; } else { $supplierID = $SID; } $data['supplier'] = $this->supplier_model->getSupplierInfo($supplierID); $data['payment'] = $this->supplier_model->getpayment($Payment ); $this->global['pageTitle'] = 'Siddharth : Edit Supplier'; $this->loadViews("editSupplier", $this->global,$data, NULL); } function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>