siddharth_application/application/controllers/assetdetails.php
2017-03-28 16:59:25 +05:30

279 lines
10 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 assetdetails extends BaseController
{
/**
* This is default constructor of the class
*/
public function __construct()
{
parent::__construct();
$this->load->model('assetdetails_model');
$this->isLoggedIn();
}
/**
* This function used to load the first screen of the user
*/
public function index()
{
$this->global['pageTitle'] = 'Siddharth : Asset Details';
$this->loadViews("assetListing", $this->global, NULL , NULL);
}
/**
* This function is used to load the Supplier list
*/
function assetListing()
{
$this->load->model('assetdetails_model');
$searchText = $this->input->post('searchText');
$data['searchText'] = $searchText;
$this->load->library('pagination');
$count = $this->assetdetails_model->assetListingCount($searchText);
$returns = $this->paginationCompress ( "assetListing/", $count ,5);
$data['userRecords'] = $this->assetdetails_model->assetListing($searchText, $returns["page"], $returns["segment"]);
$this->global['pageTitle'] = 'Siddharth : Asset List';
$this->loadViews("assetListing", $this->global, $data, NULL);
}
/**
* This function is used to load the add new supplier */
function addasset()
{
$this->load->model('assetdetails_model');
$data['SupplierName'] = $this->assetdetails_model->getSupplierName();
//$data['POdate'] = $this->assetdetails_model->getPODate();
$this->global['pageTitle'] = 'siddharth : Add Asset';
$this->loadViews("addasset", $this->global, $data, NULL);
}
/**
* This function is used to add new user to the system
*/
function addNewasset()
{
$this->load->library('form_validation');
//$PO = $this->input->post('SupplierID');
//$this->form_validation->set_rules('CostCenterID','Supplier Name','trim');
$this->form_validation->set_rules('Asset_Name','AssetName','trim');
$this->form_validation->set_rules('Description','Description','trim');
$this->form_validation->set_rules('Department','Department','trim');
$this->form_validation->set_rules('Location','Location','trim');
$this->form_validation->set_rules('AssetOwner','AssetOwner','trim');
$this->form_validation->set_rules('SupplierName','SupplierName','trim');
$this->form_validation->set_rules('DateOfPurchase','DateOfPurchase','trim');
$this->form_validation->set_rules('DateOfCommission','DateOfCommission','trim');
$this->form_validation->set_rules('SupportVendor','SupportVendor','trim');
$this->form_validation->set_rules('SupportFrom','SupportFrom','trim');
$this->form_validation->set_rules('SupportTo','SupportTo','trim');
if($this->form_validation->run() == FALSE)
{
$this->addasset();
}
else
{
$AssetName = ucwords(strtolower($this->input->post('Asset_Name')));
$Description = $this->input->post('Description');
$Department = $this->input->post('Department');
$Location = $this->input->post('Location');
$AssetOwner = $this->input->post('AssetOwner');
$SupplierName = $this->input->post('SupplierName');
$DateOfPurchase = $this->input->post('DateOfPurchase');
$DateOfCommission = $this->input->post('DateOfCommission');
$SupportVendor = $this->input->post('SupportVendor');
$SupportFrom = $this->input->post('SupportFrom');
$SupportTo = $this->input->post('SupportTo');
$asset = array('Asset_Name'=>$AssetName, 'Description'=>$Description,'Department'=>$Department,'Location'=>$Location,'AssetOwner'=>$AssetOwner,'SupplierName'=>$SupplierName,'DateOfPurchase'=>$DateOfPurchase,'DateOfCommission'=>$DateOfCommission,'SupportVendor'=>$SupportVendor,'SupportFrom'=>$SupportFrom,'SupportTo'=>$SupportTo,'createdDate'=>date('Y-m-d H:i:sa'));
$this->load->model('assetdetails_model');
$result = $this->assetdetails_model->addNewasset($asset);
if($result > 0)
{
$this->session->set_flashdata('success', 'New PO created successfully');
}
else
{
$this->session->set_flashdata('error', 'PO Not Create');
}
redirect('assetdetails/assetListing');
}
}
/**
* This function is used load user edit information
* @param number $userId : Optional : This is user id
function ech(){
echo $this->input->post('Asset_Code');
}*/
function editOldasset($assetcode = NULL)
{
if($assetcode == null)
{
redirect('assetListing');
}
$data['asset'] = $this->assetdetails_model->getUserInfo($assetcode);
$data['SupplierName'] = $this->assetdetails_model->getSupplierName();
$this->global['pageTitle'] = 'Siddharth : Edit Asset';
$this->loadViews("editOldasset", $this->global, $data,NULL);
}
/**
* This function is used to edit the user information
*/
function editasset()
{
$this->load->library('form_validation');
$Asset_Code = $this->input->post('Asset_Code');
$this->form_validation->set_rules('Asset_Name','AssetName','trim|required');
$this->form_validation->set_rules('Description','Description','trim|required');
$this->form_validation->set_rules('Department','Department','trim|required');
$this->form_validation->set_rules('Location','Location','trim');
$this->form_validation->set_rules('AssetOwner','AssetOwner','trim');
$this->form_validation->set_rules('SupplierName','SupplierName','trim|required');
$this->form_validation->set_rules('DateOfPurchase','DateOfPurchase','trim');
$this->form_validation->set_rules('DateOfCommission','DateOfCommission','trim');
$this->form_validation->set_rules('SupportVendor','SupportVendor','trim');
$this->form_validation->set_rules('SupportFrom','SupportFrom','trim');
$this->form_validation->set_rules('SupportTo','SupportTo','trim');
if($this->form_validation->run() == FALSE)
{
$this->editasset($Asset_Code);
}
else
{
$Asset_Code = $this->input->post('Asset_Code');
$AssetName = ucwords(strtolower($this->input->post('Asset_Name')));
$Description = $this->input->post('Description');
$Department = $this->input->post('Department');
$Location = $this->input->post('Location');
$AssetOwner = $this->input->post('AssetOwner');
$SupplierName = $this->input->post('SupplierName');
$DateOfPurchase = $this->input->post('DateOfPurchase');
$DateOfCommission = $this->input->post('DateOfCommission');
$SupportVendor = $this->input->post('SupportVendor');
$SupportFrom = $this->input->post('SupportFrom');
$SupportTo = $this->input->post('SupportTo');
$asset = array();
$asset = array('Asset_Code'=>$Asset_Code,'Asset_Name'=>$AssetName, 'Description'=>$Description,'Department'=>$Department,'Location'=>$Location,'AssetOwner'=>$AssetOwner,'SupplierName'=>$SupplierName,'DateOfPurchase'=>$DateOfPurchase,'DateOfCommission'=>$DateOfCommission,'SupportVendor'=>$SupportVendor,'SupportFrom'=>$SupportFrom,'SupportTo'=>$SupportTo,'createdDate'=>date('Y-m-d H:i:sa'));
$result = $this->assetdetails_model->editasset($asset, $Asset_Code);
if($result == true)
{
$this->session->set_flashdata('success', 'Asset updated successfully');
}
else
{
$this->session->set_flashdata('error', 'Asset updation failed');
}
redirect('assetListing');
}
}
/**
* 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 viewasset($Asset_code = NULL)
{
if($Asset_code == null)
{
redirect('assetListing');
}
$data['asset'] = $this->assetdetails_model->getUserInfo($Asset_code);
$data['SupplierName'] = $this->assetdetails_model->getSupplierName();
$this->global['pageTitle'] = 'Siddharth : View Asset';
$this->loadViews("viewasset", $this->global, $data,NULL);
}
function pageNotFound()
{
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
$this->loadViews("404", $this->global, NULL, NULL);
}
}
?>