final product history

This commit is contained in:
venbatechnologies@gmail.com 2018-06-15 16:58:47 +05:30
parent 250c6d3b2d
commit 21ddba9de4
3 changed files with 91 additions and 19 deletions

View File

@ -1489,6 +1489,9 @@ class batchcard extends BaseController
$final_master =array('MaterialCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'CreatedBy'=>$createdby,'ProductDate'=>$pdt,'ProductType'=>'Inward');
$final_master_save =$this->batchcard_model->insert_final_product($final_master);
// $final_product_id= $final_master_save[0]['PId'];
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
@ -1504,6 +1507,12 @@ class batchcard extends BaseController
}
}
$final_history= array('RefID'=>$final_product_id,'ProductCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'Transactiondate'=>$createddt,'TransactionType'=>'Inward');
$final_history_save= $this->batchcard_model->SaveFinalHistory($final_history);
$rawilne = $this->input->post('RawRow');
$consuline = $this->input->post('ConsuRow');
$packline = $this->input->post('PkgRow');
@ -1578,6 +1587,11 @@ class batchcard extends BaseController
// print_r($coparray);
$this->batchcard_model->save_finalcoproduct($coparray);
$copfinal_history = array('RefID'=>$final_product_id,'ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward');
$final_cophistory_save= $this->batchcard_model->SaveFinalHistory($copfinal_history);
}
echo "Details Saved Successfully";
@ -1614,6 +1628,12 @@ class batchcard extends BaseController
$final_master_save =$this->batchcard_model->update_final_product($final_master,$FPID);
$lastId='';
$final_history= array('ProductCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'Transactiondate'=>$createddt,'TransactionType'=>'Inward');
//print_r($final_history);
//die();
$finalHistoryupdate = $this->batchcard_model->UpdateFinalHistory($final_history,$FPID,$final_product);
$rawilne = $this->input->post('RawRow');
@ -1779,16 +1799,26 @@ class batchcard extends BaseController
$coparray =array('FPId'=>$FPID,'MaterialCode'=>$copmaterial,'CoDate'=>$cddt,'Quantity'=>$copqty,'Price'=>$copvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
$checkpackid=$this->batchcard_model->Getcopid($coplineId);
// $copfinal_history = array('ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward');
$copfinal_history = array('RefID'=>$FPID,'ProductCode'=>$copmaterial,'Quantity'=>$copqty,'Price'=>$copvalue,'Transactiondate'=>$createddt,'TransactionType'=>'Inward');
// print_r($coparray);
if(count($checkpackid)>0)
{
$this->batchcard_model->update_finalcoproduct($coparray,$coplineId);
$finalHistoryupdate = $this->batchcard_model->UpdateFinalHistory($copfinal_history,$FPID,$copmaterial);
}
else
{
$this->batchcard_model->save_finalcoproduct($coparray);
$final_cophistory_save= $this->batchcard_model->SaveFinalHistory($copfinal_history);
}
}
}

View File

@ -1133,26 +1133,68 @@ and CreatedOn >= ? and CreatedOn<=? and SupplierID=? group by Addqty';
function GetFinishedProductList($starting_date,$end_date,$product_id)
{
// function GetFinishedProductList($starting_date,$end_date,$product_id)
// {
$subQuery ='select ip_products.product_id,ip_products.product_name,ip_invoices.invoice_id,ip_invoice_items.item_quantity,ip_invoice_items.item_price,ip_invoices.invoice_number as IDnumber,ip_invoices.receivedstatus as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id join ip_invoices on ip_invoice_items.invoice_id = ip_invoices.invoice_id
join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where (ip_invoices.invoice_date_modified>=? and ip_invoices.invoice_date_modified<=? and ip_invoice_items.item_product_id=?) union
// $subQuery ='select ip_products.product_id,ip_products.product_name,ip_invoices.invoice_id,ip_invoice_items.item_quantity,ip_invoice_items.item_price,ip_invoices.invoice_number as IDnumber,ip_invoices.receivedstatus as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id join ip_invoices on ip_invoice_items.invoice_id = ip_invoices.invoice_id
// join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where (ip_invoices.invoice_date_modified>=? and ip_invoices.invoice_date_modified<=? and ip_invoice_items.item_product_id=?) union
select ip_products.product_id,ip_products.product_name,T_FinalProduct_Master.FPId,T_FinalProduct_Master.Quantity,T_FinalProduct_Master.Price,T_FinalProduct_Master.FPId as IDnumber,T_FinalProduct_Master.ProductType as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id
join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where
(T_FinalProduct_Master.ProductDate<=? and T_FinalProduct_Master.ProductDate>=? and T_FinalProduct_Master.MaterialCode=?) group by FPId';
// select ip_products.product_id,ip_products.product_name,T_FinalProduct_Master.FPId,T_FinalProduct_Master.Quantity,T_FinalProduct_Master.Price,T_FinalProduct_Master.FPId as IDnumber,T_FinalProduct_Master.ProductType as Type from ip_products join ip_invoice_items on ip_products.product_id = ip_invoice_items.item_product_id
// join T_FinalProduct_Master on ip_products.product_id = T_FinalProduct_Master.MaterialCode where
// (T_FinalProduct_Master.ProductDate<=? and T_FinalProduct_Master.ProductDate>=? and T_FinalProduct_Master.MaterialCode=?) group by FPId';
$query = $this->db->query($subQuery,array($starting_date,$end_date,$product_id,$end_date,$starting_date,$product_id));
// $query = $this->db->query($subQuery,array($starting_date,$end_date,$product_id,$end_date,$starting_date,$product_id));
//print_r($this->db->last_query());
// //print_r($this->db->last_query());
return $query->result_array();
// return $query->result_array();
}
// }
function GetFinishedProductList($starting_date,$end_date,$product_id)
{
// $subQuery = 'select * from T_FinalProduct_History,ip_products.product_name
// join ip_products on T_FinalProduct_History.ProductCode = ip_products.product_id
// where ProductCode=?
// and Transactiondate >= ? and Transactiondate <= ?';
$subQuery='select RefID,ProductCode,Quantity,Price,Transactiondate,TransactionType,product_name
from T_FinalProduct_History
join ip_products on ip_products.product_id= T_FinalProduct_History.ProductCode
where ProductCode=? and Transactiondate >= ? and Transactiondate <= ?';
$query = $this->db->query($subQuery,array($product_id,$starting_date,$end_date));
return $query->result_array();
}
function SaveFinalHistory($final_history)
{
$this->db->trans_start();
$this->db->insert('T_FinalProduct_History',$final_history);
$insert_id = $this->db->affected_rows();
$this->db->trans_complete();
return true;
}
function UpdateFinalHistory($final_history,$FPID,$rawmaterial)
{
//print_r($final_history);
$this->db->where('RefID', $FPID);
$this->db->where('ProductCode',$rawmaterial);
$this->db->update('T_FinalProduct_History',$final_history);
//print_r($this->db->last_query());
return TRUE;
}
}

View File

@ -162,7 +162,7 @@ $(function() {
<table class="table table-striped table-condensed no-margin" id="tab">
<thead>
<tr>
<th>Invoice ID/Final Product ID</th>
<th>Invoice No/Final Product ID</th>
<th>Product Code</th>
<th>Product Name</th>
<th>Price</th>
@ -216,25 +216,25 @@ $(function() {
var idno = '';
if(item.Type == 'Inward')
if(item.TransactionType == 'Inward')
{
datatype = "Final Product";
idno = "FP"+item.IDnumber;
idno = "FP"+item.RefID;
}
else
{
datatype = "Invoice";
idno = item.IDnumber;
idno = item.RefID;
}
tble +='<tr class="amount">'+
'<td>'+idno+'</td>'+
'<td>'+item.product_id+'</td>'+
'<td>'+item.ProductCode+'</td>'+
'<td>'+item.product_name+'</td>'+
'<td>'+item.item_price+'</td>'+
'<td>'+item.item_quantity+'</td>'+
'<td>'+datatype+'</td>'+
'<td>'+item.Price+'</td>'+
'<td>'+item.Quantity+'</td>'+
'<td>'+item.TransactionType+'</td>'+
'</tr>';
});