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['Department'] = $this->assetdetails_model->getDepartment(); //$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('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'); 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'); $User = $this->input->post('User'); $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'); $result = $this->assetdetails_model->addNewasset($asset); if($result > 0) { $this->session->set_flashdata('success', 'New Asset created successfully'); } else { $this->session->set_flashdata('error', 'Asset Not Create'); } redirect('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['SupplierList'] = $this->assetdetails_model->getSupplierName(); $data['DepartmentList'] = $this->assetdetails_model->getDepartment(); //$data['roles'] = $this->assetdetails_model->getUserRoles(); $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('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'); 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'); $User = $this->input->post('User'); $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 = 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')); $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'); } //echo success; 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); } } ?>