From a702878f09ff03a01dc046e2cc3cc069cdc2f385 Mon Sep 17 00:00:00 2001 From: "venbatechnologies@gmail.com" Date: Fri, 4 Aug 2017 17:37:07 +0530 Subject: [PATCH] Add/Edit Asset Details --- application/controllers/assetdetails.php | 46 +++++++++++++++-------- application/models/assetdetails_model.php | 4 +- application/views/addasset.php | 2 +- application/views/editOldasset.php | 45 +++++++++++----------- 4 files changed, 57 insertions(+), 40 deletions(-) diff --git a/application/controllers/assetdetails.php b/application/controllers/assetdetails.php index 87300668..c730c515 100755 --- a/application/controllers/assetdetails.php +++ b/application/controllers/assetdetails.php @@ -38,9 +38,7 @@ class assetdetails extends BaseController { $this->load->model('assetdetails_model'); - - - + $data['userRecords'] = $this->assetdetails_model->assetListing(); $this->global['pageTitle'] = 'Siddharth : Asset List'; @@ -129,11 +127,11 @@ class assetdetails extends BaseController echo json_encode($ser); die(); } - function getlin(){ - $line = $this->input->post('line'); + // function getlin(){ + // $line = $this->input->post('line'); - } + // } /* Validation for Department Dropdown */ function Department_validate($selectValue) @@ -217,9 +215,15 @@ class assetdetails extends BaseController $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'); + if($DateOfCommission != '') + { + $DOPurchase = $this->getDateformat($DateOfPurchase); + } + if($DateOfPurchase != '') + { + $DOCommission= $this->getDateformat($DateOfCommission); + } + $AssetStatus = $this->input->post('AssetStatus'); $Remarks = $this->input->post('Remarks'); $PONO = $this->input->post('PONO'); $lineitem = $this->input->post('lineitem'); @@ -265,12 +269,13 @@ class assetdetails extends BaseController /** * This function is used load user edit information * @param number $userId : Optional : This is user id - + */ - function ech(){ + /*function ech(){ echo $this->input->post('Asset_Code'); }*/ + function editOldasset($AssetCode = '',$PO='') { @@ -300,6 +305,7 @@ class assetdetails extends BaseController $this->loadViews("editOldasset", $this->global, $data,NULL); } + /** * This function is used to edit the user information @@ -340,9 +346,17 @@ class assetdetails extends BaseController // $DateOfPurchase = $DateOfPurchase ->format('d-m-y'); $DateOfCommission = $this->input->post('DateOfCommission'); $UpdatedBy = $this->session->userdata('userId'); - $AssetValue = $this->input->post('Assetvalue'); - $DOPurchase = $this->getDateformat($DateOfPurchase); - $DOCommission= $this->getDateformat($DateOfCommission); + $Assetvalue = $this->input->post('Assetvalue'); + if($DateOfCommission != '') + { + $DOPurchase = $this->getDateformat($DateOfPurchase); + } + if($DateOfPurchase != '') + { + $DOCommission= $this->getDateformat($DateOfCommission); + } + + $AssetStatus = $this->input->post('AssetStatus'); $Remarks = $this->input->post('Remarks'); $PONO = $this->input->post('PONO'); @@ -364,7 +378,7 @@ class assetdetails extends BaseController $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,'PONO'=>$PONO,'POLineItem'=>$lineitem,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity); + $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,'PONO'=>$PONO,'POLineItem'=>$lineitem,'MaterialCode'=>$MaterialCode,'Quantity'=>$Quantity); //print_r($asset);die(); @@ -388,7 +402,7 @@ class assetdetails extends BaseController function getDateformat($Val) { $date = new DateTime($Val); - $retDate = $date->format('d-m-y H:i:s'); + $retDate = $date->format('Y-m-d H:i:s'); return $retDate; } diff --git a/application/models/assetdetails_model.php b/application/models/assetdetails_model.php index eb86ce78..5fb55dde 100755 --- a/application/models/assetdetails_model.php +++ b/application/models/assetdetails_model.php @@ -15,7 +15,7 @@ class assetdetails_model extends CI_Model $this->db->select('asd.*,dep.DepartmentName,sup.SupplierName'); $this->db->from('T_Asset_Details asd'); $this->db->join('T_DepartmentDetails dep', ' dep.DEPCode = asd.DEPCode','left'); - $this->db->join ('T_SupplierDetailsN sup','sup.SupplierID = asd.SupplierCode'); + $this->db->join ('T_SupplierDetailsN sup','sup.SupplierID = asd.SupplierCode','left'); $query = $this->db->get(); @@ -222,7 +222,7 @@ function addNewasset($asset) $query = $this->db->get(); - // print_r($this->db->last_query()); + //print_r($this->db->last_query()); return $query->result(); } function editasset($asset, $Asset_Code) diff --git a/application/views/addasset.php b/application/views/addasset.php index 2f948059..f59b162a 100755 --- a/application/views/addasset.php +++ b/application/views/addasset.php @@ -234,7 +234,7 @@ $("#DeliveryDate").datepicker({ Delivery Date - +
diff --git a/application/views/editOldasset.php b/application/views/editOldasset.php index 74bdb5a4..c8fb9e44 100755 --- a/application/views/editOldasset.php +++ b/application/views/editOldasset.php @@ -14,6 +14,7 @@ $AssetStatus = ''; $IsActive =''; $Remarks = ''; $DepartmentName =''; +$Department =''; $SupplierCode = ''; $MaterialCode = ''; $PONO = ''; @@ -26,22 +27,23 @@ if(!empty($assetList)) { foreach ($assetList as $Asset) { + //print_r($Asset);die(); $AssetCode = $Asset->AssetCode; $AssetName = $Asset->AssetName; $Description = $Asset->Description; - $Department = $Asset->DepartmentName ; + $Department = $Asset->DEPCode; $DepartmentName = $Asset->DepartmentName; $Location = $Asset->Location; $User = $Asset->UserName; $SupplierName = $Asset->SupplierName; $SupplierCode = $Asset->SupplierCode; - $DateOfPurchase = $Asset->DateOfPurchase; + $DateOfPurchase = $Asset->DateOfPurchase;//print_r($Asset->DateOfPurchase); $PODate = new DateTime($DateOfPurchase); $DateOfPurchase = $PODate->format('Y-m-d'); - $DateOfCommission = $Asset->DateOfCommison; - $assetDate = new DateTime($DateOfCommison); - $DateOfCommison = $assetDate->format('Y-m-d'); - + //print_r($Asset->DateOfCommison); + //$assetDate = new DateTime($DateOfCommison); + $DateOfCommission= new DateTime($Asset->DateOfCommison, new DateTimeZone('Asia/Kolkata')); + $DateOfCommison = $DateOfCommission->format('Y-m-d'); $AssetValue = $Asset->AssetValue; $AssetStatus = $Asset->AssetStatus; $MaterialCode = $Asset->MaterialCode; @@ -50,10 +52,10 @@ if(!empty($assetList)) $Quantity = $Asset->Quantity; $MaterialName = $Asset->MaterialName; $UOM = $Asset->UOM; - $DeliveryDate = $Asset->DeliveryDate; - $PODelivery = new DateTime($DeliveryDate); - $DeliveryDate = $PODelivery ->format('Y-m-d'); - + $DDate = new DateTime($Asset->DeliveryDate, new DateTimeZone('Asia/Kolkata')); + //$PODelivery = new DateTime($DeliveryDate);//print_r($Asset->DeliveryDate); + $DeliveryDate = $DDate ->format('Y-m-d'); + //print_r($DateOfPurchase);print_r($DateOfCommison);print_r($DeliveryDate); $Remarks = $Asset->Remarks; $chk = $Asset->IsActive; @@ -71,11 +73,11 @@ if(!empty($assetList)) $dtpurchase = new DateTime($DateOfPurchase); $DOPurchase = $dtpurchase ->format('Y-m-d'); } - if($DateOfCommission != '') - { - $dtCommission = new DateTime($DateOfCommission); - $DOCommission = $dtCommission ->format('Y-m-d'); - } + // if($DateOfCommission != '') + // { + // $dtCommission = new DateTime($DateOfCommission); + // $DOCommission = $dtCommission ->format('Y-m-d'); + // } } } @@ -291,10 +293,10 @@ $("#DeliveryDate").datepicker({
- + Asset Department - +
@@ -312,15 +314,15 @@ $("#DeliveryDate").datepicker({
Supplier Name - - + +
Delivery Date - +
@@ -491,13 +493,14 @@ $("#DeliveryDate").datepicker({ $('#DeliveryDate').val(item.DeliveryDate); $('#SupplierName').val(item.SupplierName); $('#SupID').val(item.SupplierID); + //alert(item.SupplierID); $('#MaterialCode').val(item.MaterialCode); $('#UOM').val(item.UOM); $('#Quantity').val(item.Quantity); $('#depcode').val(item.Departmentcode); $('#AssetDept').val(item.DepartmentName); $('#PODescription').val(item.MaterialName); - //alert(item.TotalValue); + //salert(item.TotalValue); $('#Assetvalue').val(item.TotalValue); var date = new Date(item.DeliveryDate);