255 lines
9.1 KiB
PHP
255 lines
9.1 KiB
PHP
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
|
|
/**
|
|
* Class : purchaseorder (PurchaseorderController)
|
|
* User Class to control all user related operations.
|
|
* @author : VenbaMail Mali
|
|
* @version : 1.1
|
|
* @since : 15 Feb 2016
|
|
*/
|
|
class supplier extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->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, 15 );
|
|
|
|
$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['SupplierName'] = $this->purchaseorder_model->getSupplierName();
|
|
//$data['users'] = $this->purchaseorder_model->getusers();
|
|
|
|
$this->global['pageTitle'] = 'siddharth : AddNew Supplier';
|
|
|
|
$this->loadViews("addsupplier", $this->global, NULL);
|
|
|
|
}
|
|
|
|
/**
|
|
* 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|');
|
|
$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('TIN','TIN','trim|required');
|
|
$this->form_validation->set_rules('PAN','PAN','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');
|
|
$TIN = $this->input->post('TIN');
|
|
$PAN = $this->input->post('PAN');
|
|
|
|
|
|
|
|
$supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'PAN'=>$PAN,'createdDate'=>date('Y-m-d H:i:sa'));
|
|
|
|
$this->load->model('supplier_model');
|
|
$result = $this->supplier_model->addNewsupplier($supplier);
|
|
|
|
if($result > 0)
|
|
{
|
|
$this->session->set_flashdata('success', 'New Supplier created successfully');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_flashdata('error', 'Supplier Not Create');
|
|
}
|
|
|
|
redirect('addsupplier');
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 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);
|
|
|
|
$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('TIN','TIN','trim|required');
|
|
$this->form_validation->set_rules('PAN','PAN','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');
|
|
$TIN = $this->input->post('TIN');
|
|
$PAN = $this->input->post('PAN');
|
|
|
|
$supplier = array();
|
|
|
|
if(empty($ContactNumber))
|
|
{
|
|
$supplier = array('SupplierID'=>$SupplierID,'SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'PAN'=>$PAN,'createdDate'=>date('Y-m-d H:i:sa'));
|
|
}
|
|
else{
|
|
$supplier = array('SupplierName'=>$SupplierName, 'Address'=>$Address, 'ContactNumber'=>$ContactNumber, 'AlternateContactNumber'=> $AlternateContactNumber,'EmailAddress'=>$EmailAddress,'TIN'=>$TIN,'PAN'=>$PAN,'createdDate'=>date('Y-m-d H:i:sa'));
|
|
}
|
|
|
|
$result = $this->supplier_model->editsupplier($supplier, $supplierID);
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
/**
|
|
* This function is used to delete the user using userId
|
|
* @return boolean $result : TRUE / FALSE
|
|
|
|
function deleteUser()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
echo(json_encode(array('status'=>'access')));
|
|
}
|
|
else
|
|
{
|
|
$userId = $this->input->post('userId');
|
|
$userInfo = array('isDeleted'=>1,'updatedBy'=>$this->vendorId, 'updatedDtm'=>date('Y-m-d H:i:sa'));
|
|
|
|
$result = $this->user_model->deleteUser($userId, $userInfo);
|
|
|
|
if ($result > 0) { echo(json_encode(array('status'=>TRUE))); }
|
|
else { echo(json_encode(array('status'=>FALSE))); }
|
|
}
|
|
}*/
|
|
|
|
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'Siddharth : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
}
|
|
|
|
?>
|