240 lines
7.1 KiB
PHP
240 lines
7.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 CostCenter 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 CostListing()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$this->load->model('costcenter_model');
|
|
|
|
$searchText = $this->input->post('searchText');
|
|
$data['searchText'] = $searchText;
|
|
|
|
$this->load->library('pagination');
|
|
|
|
$count = $this->costcenter_model->costListingCount($searchText);
|
|
|
|
$returns = $this->paginationCompress ( "costListing/", $count, 5 );
|
|
|
|
$data['userRecords'] = $this->costcenter_model->costListing($searchText, $returns["page"], $returns["segment"]);
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Cost Listing';
|
|
|
|
$this->loadViews("costListing", $this->global, $data, NULL);
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to load the add new supplier */
|
|
function addcost()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$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("addcost", $this->global, NULL);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is used to add new user to the system
|
|
*/
|
|
function addNewcost()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$this->load->library('form_validation');
|
|
|
|
$PO = $this->input->post('SupplierID');
|
|
|
|
//$this->form_validation->set_rules('CostCenterID','Supplier Name','trim');
|
|
$this->form_validation->set_rules('CostName','Address','trim|required|');
|
|
$this->form_validation->set_rules('Description','Contact Number','trim');
|
|
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->addsupplier();
|
|
}
|
|
else
|
|
{
|
|
$CostName = ucwords(strtolower($this->input->post('CostName')));
|
|
$Description = $this->input->post('Description');
|
|
|
|
|
|
|
|
|
|
$Cost = array('CostName'=>$CostName, 'Description'=>$Description,'createdDate'=>date('Y-m-d H:i:sa'));
|
|
|
|
$this->load->model('costcenter_model');
|
|
$result = $this->costcenter_model->addNewcost($Cost);
|
|
|
|
if($result > 0)
|
|
{
|
|
$this->session->set_flashdata('success', 'New PO created successfully');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_flashdata('error', 'PO Not Create');
|
|
}
|
|
|
|
redirect('codeListing');
|
|
}
|
|
}
|
|
}
|
|
/**
|
|
* This function is used load user edit information
|
|
* @param number $userId : Optional : This is user id
|
|
*/
|
|
function editOldcost($CostCenterID = NULL)
|
|
{
|
|
if($this->isAdmin() == TRUE || $CostCenterID == 1)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
if($CostCenterID == null)
|
|
{
|
|
redirect('costListing');
|
|
}
|
|
|
|
//$data['SupplierName'] = $this->purchaseorder_model->getSupplierName();
|
|
//$data['users'] = $this->purchaseorder_model->getusers();
|
|
|
|
$this->global['pageTitle'] = 'Siddharth : Edit User';
|
|
|
|
$this->loadViews("editOldcost", $this->global, NULL);
|
|
}
|
|
}
|
|
|
|
/**
|
|
* This function is used to edit the user information
|
|
*/
|
|
function editcost()
|
|
{
|
|
if($this->isAdmin() == TRUE)
|
|
{
|
|
$this->loadThis();
|
|
}
|
|
else
|
|
{
|
|
$this->load->library('form_validation');
|
|
|
|
//$PO = $this->input->post('PO');
|
|
|
|
$this->form_validation->set_rules('CostName','Cost Name','trim|required|');
|
|
$this->form_validation->set_rules('Description','Description','trim|required|');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->editPO();
|
|
}
|
|
else
|
|
{
|
|
$CostName = ucwords(strtolower($this->input->post('CostName')));
|
|
$Description = $this->input->post('Description');
|
|
|
|
$Cost = array('CostName'=>$CostName, 'Description'=>$Description,'createdDtm'=>date('Y-m-d H:i:sa'));
|
|
|
|
|
|
|
|
$Cost = array();
|
|
|
|
$result = $this->costcenter_model->editcost($Cost, $CostCentreID);
|
|
|
|
if($result == true)
|
|
{
|
|
$this->session->set_flashdata('success', 'PO updated successfully');
|
|
}
|
|
else
|
|
{
|
|
$this->session->set_flashdata('error', 'PO updation failed');
|
|
}
|
|
|
|
redirect('costListing');
|
|
}
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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'] = 'CodeInsect : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
}
|
|
|
|
?>
|