327 lines
11 KiB
PHP
327 lines
11 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->load->library('form_validation');
|
|
$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 ,10);
|
|
|
|
$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()
|
|
{
|
|
|
|
$data['SupplierList'] = $this->assetdetails_model->getSupplierName();
|
|
$data['DepartmentList'] = $this->assetdetails_model->getDepartment();
|
|
$data['AssetStatus'] = $this->assetdetails_model->getConfigValue('C015');
|
|
|
|
$this->global['pageTitle'] = 'siddharth : Add Asset';
|
|
|
|
$this->loadViews("addasset", $this->global, $data, NULL);
|
|
|
|
}
|
|
/* Validation for Department Dropdown
|
|
*/
|
|
function Department_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Department_validate', 'Please Select Department.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/* Validation for Supplier Dropdown
|
|
*/
|
|
function Supplier_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Supplier_validate', 'Please Select Supplier.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
/* Validation for Supplier Dropdown
|
|
*/
|
|
function Asset_validate($selectValue)
|
|
{
|
|
//echo 'select_validate method called';
|
|
// 'none' is the first option and the text says something like "-Choose one-"
|
|
if($selectValue == '-1')
|
|
{
|
|
$this->form_validation->set_message('Asset_validate', 'Please Select Asset Status.');
|
|
return false;
|
|
}
|
|
else // user picked something
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
/**
|
|
* This function is used to add new user to the system
|
|
*/
|
|
function addNewasset()
|
|
{
|
|
|
|
$this->form_validation->set_rules('AssetName','AssetName','trim|required');
|
|
$this->form_validation->set_rules('Description','Description','trim|required');
|
|
$this->form_validation->set_rules('Department','Department','trim|callback_Department_validate');
|
|
$this->form_validation->set_rules('Location','Location','trim|required');
|
|
$this->form_validation->set_rules('User','User','trim|required');
|
|
$this->form_validation->set_rules('SupplierName','SupplierName','trim|callback_Supplier_validate');
|
|
$this->form_validation->set_rules('DateOfPurchase','DateOfPurchase','trim|required');
|
|
$this->form_validation->set_rules('DateOfCommission','DateOfCommission','trim|required');
|
|
$this->form_validation->set_rules('Assetvalue','Assetvalue','trim|required');
|
|
$this->form_validation->set_rules('AssetStatus','AssetStatus','trim|callback_Asset_validate');
|
|
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
$this->addasset();
|
|
}
|
|
else
|
|
{
|
|
$AssetName = strtoupper($this->input->post('AssetName'));
|
|
$Description = $this->input->post('Description');
|
|
$Department = $this->input->post('Department');
|
|
$Location = $this->input->post('Location');
|
|
$User = $this->input->post('User');
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$DateOfPurchase = $this->input->post('DateOfPurchase');
|
|
$DateOfCommission = $this->input->post('DateOfCommission');
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
$AssetValue = $this->input->post('Assetvalue');
|
|
$DOPurchase = $this->getDateformat($DateOfPurchase);
|
|
$DOCommission= $this->getDateformat($DateOfCommission);
|
|
$AssetStatus = $this->input->post('AssetStatus');
|
|
$Remarks = $this->input->post('Remarks');
|
|
|
|
$chked = $this->input->post('isactive');
|
|
|
|
if( $chked != '')
|
|
{
|
|
$IsActive = '1';
|
|
}
|
|
else
|
|
{
|
|
$IsActive = '0';
|
|
}
|
|
|
|
|
|
$asset = array();
|
|
|
|
|
|
$asset = array('AssetName'=>$AssetName, 'Description'=>$Description,'DEPCode'=>$Department,'Location'=>$Location,'UserName'=>$User,'SupplierCode'=>$SupplierName,'DateOfPurchase'=>$DOPurchase,'DateOfCommison'=>$DOCommission,'AssetValue'=>$AssetValue,'AssetStatus'=>$AssetStatus,'IsActive'=>$IsActive,'Remarks'=>$Remarks,'CreatedBy'=>$CreatedBy);
|
|
|
|
$result = $this->assetdetails_model->addNewasset($asset);
|
|
|
|
if($result > 0)
|
|
{
|
|
// $this->session->set_flashdata('success', 'New Asset created successfully');
|
|
|
|
redirect('assetListing','refresh');
|
|
echo "<script>alert('Asset Created successfully!');</script>";
|
|
}
|
|
else
|
|
{
|
|
redirect('assetListing','refresh');
|
|
echo "<script>alert('Asset Not Created!');</script>";
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
/**
|
|
* 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 = '')
|
|
{
|
|
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$AssetStatus = $this->input->post('AssetStatus');
|
|
$Department = $this->input->post('Department');
|
|
|
|
if($AssetCode == '')
|
|
{
|
|
$AssetID = $_GET['AssetID'];
|
|
|
|
}
|
|
else
|
|
{
|
|
$AssetID = $AssetCode;
|
|
}
|
|
//echo $AssetID;
|
|
|
|
$data['assetList'] = $this->assetdetails_model->getAssetDetails($AssetID);
|
|
$data['SupplierList'] = $this->assetdetails_model->getSupplierName($SupplierName);
|
|
$data['DepartmentList'] = $this->assetdetails_model->getDepartment($Department);
|
|
$data['AssetStatusList'] = $this->assetdetails_model->getConfigValue('C015');
|
|
$this->global['pageTitle'] = 'Siddharth : Edit Asset';
|
|
|
|
$this->loadViews("editOldasset", $this->global, $data,NULL);
|
|
|
|
}
|
|
|
|
/**
|
|
* This function is used to edit the user information
|
|
*/
|
|
function editasset()
|
|
{
|
|
|
|
|
|
$Asset_Code = $this->input->post('AssetCode');
|
|
|
|
$this->form_validation->set_rules('AssetName','AssetName','trim|required');
|
|
$this->form_validation->set_rules('Description','Description','trim|required');
|
|
$this->form_validation->set_rules('Department','Department','trim|callback_Department_validate');
|
|
$this->form_validation->set_rules('Location','Location','trim|required');
|
|
$this->form_validation->set_rules('User','User','trim|required');
|
|
$this->form_validation->set_rules('SupplierName','SupplierName','trim|callback_Supplier_validate');
|
|
$this->form_validation->set_rules('DateOfPurchase','DateOfPurchase','trim|required');
|
|
$this->form_validation->set_rules('DateOfCommission','DateOfCommission','trim|required');
|
|
$this->form_validation->set_rules('Assetvalue','Assetvalue','trim|required');
|
|
$this->form_validation->set_rules('AssetStatus','AssetStatus','trim|callback_Asset_validate');
|
|
|
|
if($this->form_validation->run() == FALSE)
|
|
{
|
|
|
|
$this->editOldasset($Asset_Code);
|
|
}
|
|
else
|
|
{
|
|
$Asset_Code = $this->input->post('AssetCode');
|
|
$AssetName = strtoupper( $this->input->post('AssetName'));
|
|
$Description = $this->input->post('Description');
|
|
$Department = $this->input->post('Department');
|
|
$Location = $this->input->post('Location');
|
|
$User = $this->input->post('User');
|
|
$SupplierName = $this->input->post('SupplierName');
|
|
$DateOfPurchase = $this->input->post('DateOfPurchase');
|
|
$DateOfCommission = $this->input->post('DateOfCommission');
|
|
$UpdatedBy = $this->session->userdata('userId');
|
|
$AssetValue = $this->input->post('Assetvalue');
|
|
$DOPurchase = $this->getDateformat($DateOfPurchase);
|
|
$DOCommission= $this->getDateformat($DateOfCommission);
|
|
$AssetStatus = $this->input->post('AssetStatus');
|
|
$Remarks = $this->input->post('Remarks');
|
|
|
|
$chked = $this->input->post('isactive');
|
|
|
|
if( $chked != '')
|
|
{
|
|
$IsActive = '1';
|
|
}
|
|
else
|
|
{
|
|
$IsActive = '0';
|
|
}
|
|
|
|
|
|
$asset = array();
|
|
|
|
|
|
$asset = array('AssetName'=>$AssetName, 'Description'=>$Description,'DEPCode'=>$Department,'Location'=>$Location,'UserName'=>$User,'SupplierCode'=>$SupplierName,'DateOfPurchase'=>$DOPurchase,'DateOfCommison'=>$DOCommission,'AssetValue'=>$AssetValue,'AssetStatus'=>$AssetStatus,'IsActive'=>$IsActive,'Remarks'=>$Remarks,'UpdatedBy'=>$UpdatedBy);
|
|
|
|
|
|
|
|
$result = $this->assetdetails_model->editasset($asset, $Asset_Code);
|
|
|
|
if($result == true)
|
|
{
|
|
redirect('assetListing','refresh');
|
|
echo "<script>alert('Asset updated successfully!');</script>";
|
|
}
|
|
else
|
|
{
|
|
redirect('assetListing','refresh');
|
|
echo "<script>alert('Asset Not updated !');</script>";
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
function getDateformat($Val)
|
|
{
|
|
$date = new DateTime($Val);
|
|
$retDate = $date->format('Y-m-d H:i:s');
|
|
return $retDate;
|
|
}
|
|
|
|
|
|
function pageNotFound()
|
|
{
|
|
$this->global['pageTitle'] = 'CodeInsect : 404 - Page Not Found';
|
|
|
|
$this->loadViews("404", $this->global, NULL, NULL);
|
|
}
|
|
}
|
|
|
|
?>
|