load->model('supplier_model'); $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; $this->load->library('pagination'); $count = $this->supplier_model->supplierListingCount($searchText); $returns = $this->paginationCompress ( "supplierListing/", $count, 5 ); $data['userRecords'] = $this->supplier_model->supplierListing($searchText, $returns["page"], $returns["segment"]); $this->global['pageTitle'] = 'Siddharth : Supplier Listing'; $this->loadViews("supplierListing", $this->global, $data, NULL); } /** * This function is used to load the add new supplier */ function addsupplier() { $this->load->model('supplier_model'); $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'); $this->load->model('supplier_model'); $query = $this->supplier_model->checkPAN($id ); // $result = array_shift($result); $query = $query[0]['PAN']; print_r($query); //return $PAN; } /** * This function is used to add new user to the system */ function addNewsupplier() { $this->load->library('form_validation'); $SupplierID = $this->input->post('SupplierID'); $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'); $this->form_validation->set_rules('AlternateContactNumber','Alternate Contact Number','trim|required|numeric'); $this->form_validation->set_rules('EmailAddress','Email Address|valid_email|xss_clean|max_length[128]|required'); $this->form_validation->set_rules('Exiseregistration','Exiseregistration','trim|required'); $this->form_validation->set_rules('TIN','TIN','trim|required'); $this->form_validation->set_rules('PAN', 'PAN', 'trim|required'); $this->form_validation->set_rules('GSTNo','GST No','trim|required'); $this->form_validation->set_rules('GSTRange','GST Range','trim|required'); $this->form_validation->set_rules('CollectrateAddress','CollectrateAddress','trim|required'); $this->form_validation->set_rules('UANumber','UANumber','trim|required'); $this->form_validation->set_rules('PaymentTerms','PaymentTerms','trim|required'); $this->form_validation->set_rules('PaymentDays','PaymentTerms','trim|required'); $this->form_validation->set_rules('PayableAT','PayableAT','trim|required'); if($this->form_validation->run() == FALSE) { $this->addsupplier(); } else { $SupplierName = ucwords(strtolower($this->input->post('SupplierName'))); $Address = $this->input->post('Address'); $ContactNumber = $this->input->post('ContactNumber'); $AlternateContactNumber = $this->input->post('AlternateContactNumber'); $EmailAddress = $this->input->post('EmailAddress'); $Exiseregistration = $this->input->post('Exiseregistration'); $TIN = $this->input->post('TIN'); $PAN = $this->input->post('PAN'); $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'); $PaymentDays = $this->input->post('PaymentDays'); $PayableAT = $this->input->post('PayableAT'); $Createdby = $this->input->post('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'=>$PaymentDays,'PayableAT'=>$PayableAT,'Createdby'=>$Createdby,'createdDate'=>date('Y-m-d H:i:sa')); $this->load->model('supplier_model'); $result = $this->supplier_model->addNewsupplier($supplier); echo $supplier; if($result > 0) { $this->session->set_flashdata('success', 'New Supplier created successfully'); } else { $this->session->set_flashdata('error', 'Supplier Not Create'); } redirect('supplierListing'); } } /** * This function is used load user edit information * @param number $userId : Optional : This is user id */ function editOldsupplier($supplierID = NULL) { //$data['SupplierName'] = $this->purchaseorder_model->getSupplierName(); $data['supplier'] = $this->supplier_model->getUserInfo($supplierID); $data['payment'] = $this->supplier_model->getpayment(); $this->global['pageTitle'] = 'Siddharth : Edit Supplier'; $this->loadViews("editOldsupplier", $this->global,$data, NULL); } /** * This function is used to edit the user information */ function editsupplier() { $this->load->library('form_validation'); $supplierID = $this->input->post('supplierID'); $this->form_validation->set_rules('SupplierName','Supplier Name','trim'); $this->form_validation->set_rules('Address','Address','trim|required|'); $this->form_validation->set_rules('ContactNumber','Contact Number','trim||numeric'); $this->form_validation->set_rules('AlternateContactNumber','Alternate Contact Number','trim||numeric'); $this->form_validation->set_rules('EmailAddress','Email Address|valid_email|xss_clean|max_length[128]'); $this->form_validation->set_rules('Exiseregistration','Exiseregistration','trim|required'); $this->form_validation->set_rules('TIN','TIN','trim|required'); $this->form_validation->set_rules('PAN','PAN','required'); $this->form_validation->set_rules('GSTNo','GST No','trim|required'); $this->form_validation->set_rules('GSTRange','GST Range','trim|required'); $this->form_validation->set_rules('CollectrateAddress','CollectrateAddress','trim|required'); $this->form_validation->set_rules('UANumber','UANumber','trim|required'); $this->form_validation->set_rules('PaymentTerms','PaymentTerms','trim|required'); $this->form_validation->set_rules('PaymentDays','PaymentTerms','trim|required'); $this->form_validation->set_rules('PayableAT','PaymentTerms','trim|required'); if($this->form_validation->run() == FALSE) { $this->editsupplier($supplierID); } else { $supplierID = $this->input->post('SupplierID'); $SupplierName = ucwords(strtolower($this->input->post('SupplierName'))); $Address = $this->input->post('Address'); $ContactNumber = $this->input->post('ContactNumber'); $AlternateContactNumber = $this->input->post('AlternateContactNumber'); $EmailAddress = $this->input->post('EmailAddress'); $Exiseregistration = $this->input->post('Exiseregistration'); $TIN = $this->input->post('TIN'); $PAN = $this->input->post('PAN'); $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'); $PaymentDays = $this->input->post('PaymentDays'); $PayableAT = $this->input->post('PayableAT'); $UpdatedBy = $this->input->post('UpdatedBy'); $Createdby = $this->input->post('Createdby'); $supplier = array(); if(empty($ContactNumber)) { $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'Exiseregistration'=>$Exiseregistration,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'UpdatedBy'=>$UpdatedBy,'Createdby'=>$Createdby,'createdDate'=>date('Y-m-d H:i:sa')); } else{ $supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'Exiseregistration'=>$Exiseregistration,'PAN'=>$PAN,'GSTNo'=>$GSTNo,'GSTRange'=>$GSTRange,'CollectrateAddress'=>$CollectrateAddress,'UANumber'=>$UANumber,'PaymentTerms'=>$PaymentTerms,'PaymentDays'=>$PaymentDays,'PayableAT'=>$PayableAT,'UpdatedBy'=>$UpdatedBy,'Createdby'=>$Createdby,'createdDate'=>date('Y-m-d H:i:sa')); } $result = $this->supplier_model->editsupplier($supplier, $supplierID); echo $PaymentDays; if($result == true) { $this->session->set_flashdata('success', 'supplier updated successfully'); } else { $this->session->set_flashdata('error', 'supplier updation failed'); } redirect('supplierListing'); } } function viewsupplier($supplierID = NULL) { //$data['SupplierName'] = $this->purchaseorder_model->getSupplierName(); $data['supplier'] = $this->supplier_model->getuserInfo($supplierID); $this->global['pageTitle'] = 'Siddharth : view Supplier'; $this->loadViews("viewsupplier", $this->global,$data, NULL); } function pageNotFound() { $this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found'; $this->loadViews("404", $this->global, NULL, NULL); } } ?>