Asset module
This commit is contained in:
parent
92ea9ea738
commit
0a47a51109
@ -18,6 +18,7 @@ class assetdetails extends BaseController
|
||||
{
|
||||
parent::__construct();
|
||||
$this->load->model('assetdetails_model');
|
||||
$this->load->library('form_validation');
|
||||
$this->isLoggedIn();
|
||||
}
|
||||
/**
|
||||
@ -45,7 +46,7 @@ class assetdetails extends BaseController
|
||||
|
||||
$count = $this->assetdetails_model->assetListingCount($searchText);
|
||||
|
||||
$returns = $this->paginationCompress ( "assetListing/", $count ,5);
|
||||
$returns = $this->paginationCompress ( "assetListing/", $count ,10);
|
||||
|
||||
$data['userRecords'] = $this->assetdetails_model->assetListing($searchText, $returns["page"], $returns["segment"]);
|
||||
|
||||
@ -59,48 +60,89 @@ class assetdetails extends BaseController
|
||||
function addasset()
|
||||
{
|
||||
|
||||
$this->load->model('assetdetails_model');
|
||||
$data['SupplierName'] = $this->assetdetails_model->getSupplierName();
|
||||
$data['Department'] = $this->assetdetails_model->getDepartment();
|
||||
//$data['POdate'] = $this->assetdetails_model->getPODate();
|
||||
$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->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('User','User','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('AssetValue','AssetValue','trim');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$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 = ucwords(strtolower($this->input->post('Asset_Name')));
|
||||
$AssetName = strtoupper($this->input->post('AssetName'));
|
||||
$Description = $this->input->post('Description');
|
||||
$Department = $this->input->post('Department');
|
||||
$Location = $this->input->post('Location');
|
||||
@ -108,28 +150,45 @@ class assetdetails extends BaseController
|
||||
$SupplierName = $this->input->post('SupplierName');
|
||||
$DateOfPurchase = $this->input->post('DateOfPurchase');
|
||||
$DateOfCommission = $this->input->post('DateOfCommission');
|
||||
$Createdby = $this->input->post('Createdby');
|
||||
$AssetValue = $this->input->post('AssetValue');
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$asset = array('Asset_Name'=>$AssetName, 'Description'=>$Description,'Department'=>$Department,'Location'=>$Location,'User'=>$User,'SupplierName'=>$SupplierName,'DateOfPurchase'=>$DateOfPurchase,'DateOfCommission'=>$DateOfCommission,'AssetValue'=>$AssetValue,'Createdby'=>$Createdby,'createdDate'=>date('Y-m-d H:i:sa'));
|
||||
|
||||
$this->load->model('assetdetails_model');
|
||||
$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');
|
||||
// $this->session->set_flashdata('success', 'New Asset created successfully');
|
||||
|
||||
redirect('assetListing','refresh');
|
||||
echo "<script>alert('Asset Created successfully!');</script>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set_flashdata('error', 'Asset Not Create');
|
||||
}
|
||||
redirect('assetListing','refresh');
|
||||
echo "<script>alert('Asset Not Created!');</script>";
|
||||
}
|
||||
|
||||
redirect('assetdetails/assetListing');
|
||||
}
|
||||
|
||||
}
|
||||
@ -142,20 +201,28 @@ class assetdetails extends BaseController
|
||||
|
||||
echo $this->input->post('Asset_Code');
|
||||
}*/
|
||||
function editOldasset($assetcode = NULL)
|
||||
function editOldasset($AssetCode = '')
|
||||
{
|
||||
|
||||
|
||||
if($assetcode == null)
|
||||
{
|
||||
|
||||
redirect('assetListing');
|
||||
}
|
||||
|
||||
$data['asset'] = $this->assetdetails_model->getUserInfo($assetcode);
|
||||
$data['SupplierList'] = $this->assetdetails_model->getSupplierName();
|
||||
$data['DepartmentList'] = $this->assetdetails_model->getDepartment();
|
||||
//$data['roles'] = $this->assetdetails_model->getUserRoles();
|
||||
|
||||
$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);
|
||||
@ -168,29 +235,29 @@ class assetdetails extends BaseController
|
||||
function editasset()
|
||||
{
|
||||
|
||||
$this->load->library('form_validation');
|
||||
|
||||
$Asset_Code = $this->input->post('AssetCode');
|
||||
|
||||
$Asset_Code = $this->input->post('Asset_Code');
|
||||
|
||||
$this->form_validation->set_rules('Asset_Name','AssetName','trim|required');
|
||||
$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|required');
|
||||
$this->form_validation->set_rules('Location','Location','trim');
|
||||
$this->form_validation->set_rules('User','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('AssetValue','AssetValue','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->editasset($Asset_Code);
|
||||
$this->editOldasset($Asset_Code);
|
||||
}
|
||||
else
|
||||
{
|
||||
$Asset_Code = $this->input->post('Asset_Code');
|
||||
$AssetName = ucwords(strtolower($this->input->post('Asset_Name')));
|
||||
$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');
|
||||
@ -198,13 +265,29 @@ class assetdetails extends BaseController
|
||||
$SupplierName = $this->input->post('SupplierName');
|
||||
$DateOfPurchase = $this->input->post('DateOfPurchase');
|
||||
$DateOfCommission = $this->input->post('DateOfCommission');
|
||||
$Createdby = $this->input->post('Createdby');
|
||||
$AssetValue = $this->input->post('AssetValue');
|
||||
|
||||
$asset = array();
|
||||
$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('Asset_Name'=>$AssetName, 'Description'=>$Description,'Department'=>$Department,'Location'=>$Location,'User'=>$User,'SupplierName'=>$SupplierName,'DateOfPurchase'=>$DateOfPurchase,'DateOfCommission'=>$DateOfCommission,'AssetValue'=>$AssetValue,'Createdby'=>$Createdby,'createdDate'=>date('Y-m-d H:i:sa'));
|
||||
$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);
|
||||
|
||||
|
||||
|
||||
@ -212,58 +295,27 @@ class assetdetails extends BaseController
|
||||
|
||||
if($result == true)
|
||||
{
|
||||
$this->session->set_flashdata('success', 'Asset updated successfully');
|
||||
redirect('assetListing','refresh');
|
||||
echo "<script>alert('Asset updated successfully!');</script>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->session->set_flashdata('error', 'Asset updation failed');
|
||||
}
|
||||
echo $asset;
|
||||
// redirect('assetListing');
|
||||
redirect('assetListing','refresh');
|
||||
echo "<script>alert('Asset Not updated !');</script>";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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';
|
||||
|
||||
Loading…
Reference in New Issue
Block a user