From 1f86b079f3a15ac2a4cb90c63064e013a75ce096 Mon Sep 17 00:00:00 2001 From: gayathri1990 Date: Thu, 31 May 2018 11:43:38 +0530 Subject: [PATCH] stock adjustments --- application/controllers/batchcard.php | 75 ++++++---- application/logs/log-2018-05-31.php | 4 + application/models/batchcard_model.php | 72 ++++++++-- application/views/editmaterialadjustment.php | 142 ++++++++++--------- application/views/materialadjustmentlist.php | 5 +- 5 files changed, 189 insertions(+), 109 deletions(-) create mode 100644 application/logs/log-2018-05-31.php diff --git a/application/controllers/batchcard.php b/application/controllers/batchcard.php index abecdede..0aa0ca09 100755 --- a/application/controllers/batchcard.php +++ b/application/controllers/batchcard.php @@ -1352,6 +1352,7 @@ class batchcard extends BaseController $status = $this->input->post('transtatus'); $CreatedBy = $this->session->userdata('userId'); $absaluteQty = abs($Qty); + $Isactive=1; // echo $Qty; // echo "abs"; @@ -1366,7 +1367,8 @@ class batchcard extends BaseController // echo $createddt; // die(); - $adjustmentaarray = array('MaterialCode'=>$materialcode,'ActualQuantity'=>$ActualQty,'Quantity'=>$absaluteQty,'SupplierID'=>$supplier,'Reason'=>$reason,'Description'=>$Description,'CreatedOn'=>$createddt,'CreatedBy'=>$CreatedBy); + $adjustmentaarray = array('MaterialCode'=>$materialcode,'ActualQuantity'=>$ActualQty,'Quantity'=>$absaluteQty,'SupplierID'=>$supplier,'Reason'=>$reason,'Description'=>$Description,'CreatedOn'=>$createddt, + 'CreatedBy'=>$CreatedBy,'Isactive'=>$Isactive); $materialadjust = $this->batchcard_model->AddmaterialAdjustment($adjustmentaarray); @@ -1381,7 +1383,7 @@ class batchcard extends BaseController } - $historytable = array('SupplierID'=>$supplier,'MaterialCode'=>$materialcode,'Transaction_type'=>$status,'Ref_Type'=>'Adjust','Quantity'=>$absaluteQty,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt,'Ref_No'=>$adjustId); + $historytable = array('SupplierID'=>$supplier,'MaterialCode'=>$materialcode,'Transaction_type'=>$status,'Ref_Type'=>'Adjust','Quantity'=>$absaluteQty,'CreatedBy'=>$CreatedBy,'CreatedOn'=>$createddt,'Ref_No'=>$adjustId,'Isactive'=>$Isactive); $historyadd = $this->batchcard_model->AddMaterialHistory($historytable); @@ -1710,25 +1712,6 @@ class batchcard extends BaseController } } - - - - - - - - - - - - - - - - - - echo "Updated"; - @@ -1740,18 +1723,56 @@ class batchcard extends BaseController { $AdjustmentId = $_GET['AdjustmentId']; + $Supplier = $_GET['sn']; + $date =$_GET['date']; + $MaterialCode =$_GET['mc']; + $this->global['pageTitle'] = 'Siddharth : Material Adjustment'; + $data['netQuantityarray'] = $this->batchcard_model->GetNetQty($MaterialCode,$date,$Supplier); + //print_r($data['netQuantityarray']); $data['materailAdjustmentlist'] = $this->batchcard_model->getEditMaterialAdjustments($AdjustmentId); $data['materiallist'] = $this->batchcard_model->getMaterial(); $data['getSupplierlist'] = $this->batchcard_model->getSupplierlist(); - // print_r($data['materailAdjustmentlist']); - - - - $this->global['pageTitle'] = 'Siddharth : Material Adjustment'; - $this->loadViews("editmaterialadjustment", $this->global,$data,NULL); + $this->loadViews("editmaterialadjustment", $this->global,$data,NULL); + + //return true; + } + function UpdateQuantity() + { + $adjquantity =$this->input->post('adjquantity'); + $reason =$this->input->post('reason'); + $id = $this->input->post('adid'); + //echo $id; + $adjustquantity = $this->input->post('editquantity'); + $description = $this->input->post('desc'); + $updatequantitydes = array('Quantity'=>$adjustquantity,'Description'=>$description,'Reason'=>$reason,'ActualQuantity'=>$adjquantity); + //print_r($updatequantitydes); + $updatequantity=array('Quantity'=>$adjustquantity); + $UpdateQuantityHistory = $this->batchcard_model->updateQuantityStockHistory($updatequantity,$id); + $UpdateQuantityAdj = $this->batchcard_model->updateQuantityAdjusment($updatequantitydes,$id); + + // print_r($updatequantityadj); + + if((count($updatequantityadj)>0) &&(count($updatequantityhistory))) + { + echo "Details Added Successfully"; + } + else + { + echo "Something Went Wrong,Please Try Again"; + } + //$this->loadViews("editmaterialadjustment", $this->global,$data,NULL); + } + function Deletequantity() + { + $AdjustmentId = $_GET['AdjustmentId']; + $Isactive=0; + $Updateactive =array('Isactive'=>$Isactive); + $this->batchcard_model->updateisactiveadjusment($Updateactive,$AdjustmentId); + $this->batchcard_model->updateisactiveastockhistory($Updateactive,$AdjustmentId); + $this->loadViews("editmaterialadjustment", $this->global,$data,NULL); } diff --git a/application/logs/log-2018-05-31.php b/application/logs/log-2018-05-31.php new file mode 100644 index 00000000..ec234979 --- /dev/null +++ b/application/logs/log-2018-05-31.php @@ -0,0 +1,4 @@ + + +ERROR - 2018-05-31 11:30:40 --> Severity: Notice --> Use of undefined constant Adjust - assumed 'Adjust' C:\xampp\htdocs\siddharth_application\application\models\batchcard_model.php 781 +ERROR - 2018-05-31 11:30:41 --> Severity: Notice --> Undefined variable: updatequantityadj C:\xampp\htdocs\siddharth_application\application\controllers\batchcard.php 1507 diff --git a/application/models/batchcard_model.php b/application/models/batchcard_model.php index 4aadbd31..ec464140 100755 --- a/application/models/batchcard_model.php +++ b/application/models/batchcard_model.php @@ -758,18 +758,7 @@ and CreatedOn >= ? and CreatedOn<=? and SupplierID=? group by Addqty'; } - function getEditMaterialAdjustments($AdjustmentId) - { - - $this->db->select('T_Material_Adjustment.*,SupplierName,MaterialName'); - $this->db->from('T_Material_Adjustment'); - $this->db->join('T_SupplierDetailsN', 'T_Material_Adjustment.SupplierID = T_SupplierDetailsN.SupplierID'); - $this->db->join('T_MaterialMaster', 'T_MaterialMaster.MaterialCode = T_Material_Adjustment.MaterialCode'); - $this->db->where('T_Material_Adjustment.AdjustmentId',$AdjustmentId); - $res = $this->db->get(); - return $res->result(); - } - + function save_rawmaterialto_materialHistory($materialhistory) { @@ -971,6 +960,65 @@ and CreatedOn >= ? and CreatedOn<=? and SupplierID=? group by Addqty'; $this->db->update('T_FinalProduct_CoProduct_Materials', $coparray); return TRUE; } + function getEditMaterialAdjustments($AdjustmentId) + { + + $this->db->select('T_Material_Adjustment.*,SupplierName,MaterialName,Description,AdjustmentId,ActualQuantity,T_Material_stock_history.Quantity'); + $this->db->from('T_Material_Adjustment'); + $this->db->join('T_Material_stock_history', 'T_Material_Adjustment.AdjustmentId = T_Material_stock_history.Ref_No'); + $this->db->join('T_SupplierDetailsN', 'T_Material_Adjustment.SupplierID = T_SupplierDetailsN.SupplierID'); + $this->db->join('T_MaterialMaster', 'T_MaterialMaster.MaterialCode = T_Material_Adjustment.MaterialCode'); + $this->db->where('T_Material_Adjustment.AdjustmentId',$AdjustmentId); + $res = $this->db->get(); + return $res->result(); + } + //created by TamilBala + //for update quantity stockhistory + function updateQuantityStockHistory($updatequantity,$id) + { + + $this->db->where('Ref_No',$id); + $this->db->where('Ref_Type',Adjust); + $this->db->update('T_Material_stock_history',$updatequantity); + $r = $this->db->affected_rows(); + //return $r->result(); + //echo "HIS"; + + } + + //created by TamilBala + //for update quantity T_Material_Adjustment + + function updateQuantityAdjusment($updatequantitydes,$id) + { + $this->db->where('AdjustmentId',$id); + $this->db->update('T_Material_Adjustment',$updatequantitydes); + $r = $this->db->affected_rows(); + return $r; + + } + //created by TamilBala + //for update isactive T_Material_Adjustment + function updateisactiveadjusment($Updateactive,$AdjustmentId) + { + $this->db->where('AdjustmentId',$AdjustmentId); + $this->db->update('T_Material_Adjustment',$Updateactive); + $r = $this->db->affected_rows(); + return $r; + + } + + //created by TamilBala + //for update isactive stockhistory + function updateisactiveastockhistory($Updateactive,$AdjustmentId) + { + $this->db->where('Ref_No',$AdjustmentId); + $this->db->where('Ref_Type',Adjust); + $this->db->update('T_Material_stock_history',$Updateactive); + $r = $this->db->affected_rows(); + return $r; + } + } diff --git a/application/views/editmaterialadjustment.php b/application/views/editmaterialadjustment.php index c3c48540..2287315e 100644 --- a/application/views/editmaterialadjustment.php +++ b/application/views/editmaterialadjustment.php @@ -5,24 +5,31 @@ $edit_Qty_aspersystem=''; $edit_Actual_Qty= ''; $edit_Adjustable_qty= ''; $edit_Description=''; +$editquantity=''; +$editid=''; +$latestupdate=''; if(!empty($materailAdjustmentlist)) { +//print_r($materailAdjustmentlist); foreach($materailAdjustmentlist as $mat) { - + $editid = $mat->AdjustmentId; $supplier = $mat->SupplierID; + $suppliername=$mat->SupplierName; $materialcode = $mat->MaterialCode; $date = $mat->CreatedOn; - // $edit_Qty_aspersystem= $mat->; + $editquantity= $mat->Quantity; $edit_Actual_Qty= $mat->ActualQuantity; - $edit_Adjustable_qty= ''; - $edit_Description=''; + + // $edit_Adjustable_qty= ''; + $edit_Description= $mat->Description; } } - +//$latestupdate=parseFloat($Addqty)-parseFloat($reduceqty); +//print_r($latestupdate); ?> @@ -78,7 +85,7 @@ $(function() {
-
+
- + +
@@ -125,40 +133,27 @@ $(function() {
- 'Select Supplier'); - - if(!empty($Supplier)) - { - foreach ($Supplier as $PO): - $options[$PO->SupplierID] =$PO->SupplierID.' '.' - '.' '.$PO->SupplierName; +
+ 'Supplier','value' => set_value('Supplier',$suppliername),'id'=>'Supplier', 'class' => 'form-control num','readonly'=>'true' ); + echo form_input($data); - - //$RL[$SID->ReqNo] = $SID->ReqNo.' '.' - '.' '.$SID->DepartmentName; - endforeach; - } - - - - - echo form_dropdown('supplier', $options,set_value('SupplierID'),'id="supplier"' ,'class="form-control select2"' , 'required="true"' ); - ?> + ?> +
+
-
+
-
-
- + @@ -174,7 +169,16 @@ $(function() {
'Qty_aspersystem','value' => set_value('Qty_aspersystem',0),'id'=>'Qty_aspersystem', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);','onchange'=>'', 'readonly'=>'true'); + if(!empty($netQuantityarray)) + { + + $Addqty=$netQuantityarray[0]['Addqty'];//->AddQty; + + $reduceqty=$netQuantityarray[0]['ReduceQty']; + } + + $latestupdate=$Addqty-$reduceqty; + $data = array('name' => 'Qty_aspersystem','value' => set_value('Qty_aspersystem', $latestupdate),'id'=>'Qty_aspersystem', 'class' => 'form-control num' ,'onkeypress'=>'return isNumberKey(event);'); echo form_input($data); ?> @@ -193,7 +197,7 @@ $(function() {
'ActualQty','value' => set_value('ActualQty',0),'id'=>'ActualQty', 'class' => 'form-control num' ,'onchange'=>'calculateamount()'); + $data = array('name' => 'ActualQty','value' => set_value('ActualQty',$editquantity),'id'=>'ActualQty', 'class' => 'form-control num' ,'onchange'=>'calculateamount()'); echo form_input($data); ?> @@ -220,9 +224,6 @@ $(function() {
-
-
-
@@ -269,28 +270,31 @@ $(function() {
'Description','value' => set_value('Description'),'id'=>'Description', 'class' => 'form-control' ,'rows' => '5', 'cols' => '100','maxlength' => '250'); + $data = array('name' => 'Description','value' => set_value('Description',$edit_Description),'id'=>'Description', 'class' => 'form-control' ,'rows' => '5', 'cols' => '100','maxlength' => '250'); echo Form_textarea($data); ?>
+ +
+
+   Save +
-



-   Save -
-
+ + @@ -357,7 +361,13 @@ $('.getdetails').click(function() function calculateamount() { + var quapersystem=$('#Qty_aspersystem').val(); + var aq=$('#ActualQuantity').val(); var actualqty = $('#ActualQty').val(); + var updatequantity=parseFloat(quapersystem) - parseFloat(actualqty); + + $('#AdjustableQty').val(updatequantity); + var resultant = $('#Qty_aspersystem').val(); var adjustQty = parseFloat(actualqty) - parseFloat(resultant); if(adjustQty<0) @@ -382,7 +392,7 @@ function calculateamount() //$('#AdjustableQty').val(status+" "+absalutevale); - $('#AdjustableQty').val(adjustQty); + //$('#AdjustableQty').val(adjustQty); } } @@ -393,47 +403,41 @@ function calculateamount() $('.Save').click(function() { - if($('#materialcode').val()==0) - { - alert("Please Select Material"); - } - - else if($('#date').val()=="") - { - alert("Please Select Date"); - } - - else if($('#supplier').val()==0) - { - alert("Please Select Supplier"); - } - - else if($('#ActualQty').val()=="") - { - alert("Please Enter the Quantity to Adjust") - } - - else - { + // if($('#ActualQty').val()=="") + // { + // alert("Please Enter the Quantity to Adjust") + // } + + var quapersystem=$('#Qty_aspersystem').val(); + //console.log(quapersystem); + var reason = $('#reason').val(); + var adquantity = $('#AdjustableQty').val(); + //alert(adquantity); + var actualqty = $('#ActualQty').val(); + var desc = $('#Description').val(); + var adjid=$('#adjusmentid').val(); $('#content').loader('show'); $.ajax({ - data:$('.materialadjustment').serialize(), + data:{editquantity:actualqty,description:desc,adid:adjid,adjquantity:adquantity,reason:reason}, type:"POST", - url:"batchcard/addNewMaterialHistory", + url:"batchcard/UpdateQuantity", + // url:"batchcard/addNewMaterialHistory", success:function(data) { + if(data) + { $('#content').loader('hide'); - alert(data); - location.reload(); - + alert('saved successfully'); + window.location.href="MaterailAdjustmentlist"; + } } }); - } + diff --git a/application/views/materialadjustmentlist.php b/application/views/materialadjustmentlist.php index 42d43f9e..71df81f0 100644 --- a/application/views/materialadjustmentlist.php +++ b/application/views/materialadjustmentlist.php @@ -52,7 +52,10 @@ -     +     +     +