662 lines
23 KiB
PHP
Executable File
662 lines
23 KiB
PHP
Executable File
<?php if(!defined('BASEPATH')) exit('No direct script access allowed');
|
|
|
|
require APPPATH . '/libraries/BaseController.php';
|
|
require APPPATH . '/third_party/mpdf/mpdf.php';
|
|
/**
|
|
* Class : Batch card Controller (batchcard)
|
|
* batch card to control all user related operations.
|
|
* @author : Gandhimathi
|
|
* @version : 1.1
|
|
* @since : 26 June 2018
|
|
*/
|
|
class batchcard extends BaseController
|
|
{
|
|
/**
|
|
* This is default constructor of the class
|
|
*/
|
|
public function __construct()
|
|
{
|
|
parent::__construct();
|
|
$this->load->model('batchcard_model');
|
|
$this->isLoggedIn();
|
|
$this->load->helper(array('form','url'));
|
|
date_default_timezone_set('Asia/Kolkata');
|
|
$this->CompanyName = $this->global['CompanyName'];
|
|
}
|
|
|
|
function FinalProductCalculation()
|
|
{
|
|
|
|
$data['inv_final_product'] = $this->batchcard_model->getinvoice_products();
|
|
$data['consumable_material']= $this->batchcard_model->get_consumablematerials();
|
|
$data['Raw_material'] = $this->batchcard_model->get_rawmaterials();
|
|
$data['Pack_material'] = $this->batchcard_model->get_packmaterials();
|
|
$data['supplier'] = $this->batchcard_model->getSupplierlist();
|
|
|
|
//print_r($data['allhourdata']);die();
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Final Product';
|
|
$this->loadViews("FinalProduct", $this->global,$data,NULL);
|
|
}
|
|
|
|
|
|
function EditFinalProduct()
|
|
{
|
|
|
|
$FPId = $_GET['FPId'];
|
|
$data['masterproduct'] = $this->batchcard_model->getmasterProductDetails($FPId);
|
|
$data['rawmaterial'] = $this->batchcard_model->getrawmaterialDetails($FPId);
|
|
$data['consumaterial'] = $this->batchcard_model->getconsumaterialDetails($FPId);
|
|
$data['packagematerial'] = $this->batchcard_model->getpackagematerialDetails($FPId);
|
|
$data['coproductmaterial'] = $this->batchcard_model->getcoproductmaterial($FPId);
|
|
$data['inv_final_product'] = $this->batchcard_model->getinvoice_products();
|
|
$data['consumable_material']= $this->batchcard_model->get_consumablematerials();
|
|
$data['Raw_material'] = $this->batchcard_model->get_rawmaterials();
|
|
$data['Pack_material'] = $this->batchcard_model->get_packmaterials();
|
|
$data['supplier'] = $this->batchcard_model->getSupplierlist();
|
|
|
|
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Final Product';
|
|
$this->loadViews("editFinalProduct", $this->global,$data,NULL);
|
|
// $this->loadViews("finaledit", $this->global,$data,NULL);
|
|
|
|
|
|
}
|
|
|
|
|
|
function FinalProductlisting()
|
|
{
|
|
$data['final_product'] = $this->batchcard_model->getFinalProductDetaisl();
|
|
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Final Product';
|
|
$this->loadViews("FinalProductlisting", $this->global,$data,NULL);
|
|
}
|
|
|
|
|
|
|
|
function FinalProductHistory()
|
|
{
|
|
|
|
$data['inv_final_product'] = $this->batchcard_model->getinvoice_products();
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Final Product';
|
|
$this->loadViews("FinalProductHistory", $this->global,$data,NULL);
|
|
}
|
|
|
|
|
|
function MaterailAdjustment()
|
|
{
|
|
$data['MaterialCode'] = $this->batchcard_model->getMaterial();
|
|
$data['Supplier'] = $this->batchcard_model->getSupplierlist();
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Material Adjustment';
|
|
$this->loadViews("materialadjustment", $this->global,$data,NULL);
|
|
}
|
|
|
|
|
|
|
|
function MaterailAdjustmentlist()
|
|
{
|
|
$data['materailAdjustmentlist'] = $this->batchcard_model->getAllMaterialAdjustments();
|
|
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Material Adjustment';
|
|
$this->loadViews("materialadjustmentlist", $this->global,$data,NULL);
|
|
}
|
|
|
|
function getQuantity()
|
|
{
|
|
$MaterialCode = $this->input->post('materialcode');
|
|
$date = $this->input->post('date');
|
|
$Supplier = $this->input->post('Supplier');
|
|
|
|
$netQtyarray = $this->batchcard_model->GetNetQty($MaterialCode,$date,$Supplier);
|
|
|
|
echo json_encode($netQtyarray);
|
|
//print_r($netQtyarray);
|
|
|
|
// echo $MaterialCode;
|
|
// echo $date;
|
|
// echo $Supplier;
|
|
}
|
|
|
|
|
|
|
|
function getFinishedProduct()
|
|
{
|
|
$starting_date = $this->input->post('from_date');
|
|
$end_date = $this->input->post('to_date');
|
|
$product_id = $this->input->post('productid');
|
|
|
|
$productlist = $this->batchcard_model->GetFinishedProductList($starting_date,$end_date,$product_id);
|
|
|
|
$obj=json_encode($productlist);
|
|
echo $obj;
|
|
|
|
//print_r($productlist);
|
|
}
|
|
|
|
|
|
|
|
|
|
// function displaying_stockvalues()
|
|
// {
|
|
// $MaterialCode = $this->input->post('MaterialCode');
|
|
// $date = $this->input->post('date');
|
|
|
|
// $Qtyarray = $this->batchcard_model->GettotalQty($MaterialCode,$date);
|
|
// //print_r($Qtyarray);
|
|
// $obj=json_encode($Qtyarray);
|
|
// echo $obj;
|
|
|
|
// }
|
|
|
|
|
|
function displaying_stockvalues()
|
|
{
|
|
$AdjustmentId = $this->input->post('AdjustmentId');
|
|
$historydetais = $this->batchcard_model->GetMaterialHistory($AdjustmentId);
|
|
$SupplierID='';
|
|
// if(!empty($historydetais))
|
|
// {
|
|
// foreach($historydetais as $hi)
|
|
// {
|
|
// $SupplierID = $hi->SupplierID;
|
|
// }
|
|
// }
|
|
|
|
$obj=json_encode($historydetais);
|
|
echo $obj;
|
|
|
|
}
|
|
|
|
|
|
function addNewMaterialHistory()
|
|
{
|
|
$supplier = $this->input->post('supplier');
|
|
$materialcode = $this->input->post('materialcode');
|
|
$date = $this->input->post('date');
|
|
$ActualQty = $this->input->post('ActualQty');
|
|
$Qty = $this->input->post('AdjustableQty');
|
|
$reason = $this->input->post('reason');
|
|
$Description = $this->input->post('Description');
|
|
$status = $this->input->post('transtatus');
|
|
$CreatedBy = $this->session->userdata('userId');
|
|
$absaluteQty = abs($Qty);
|
|
$Isactive=1;
|
|
|
|
// echo $Qty;
|
|
// echo "abs";
|
|
// echo abs($Qty);
|
|
//die();
|
|
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
//echo $dt;
|
|
|
|
// echo $createddt;
|
|
// die();
|
|
|
|
$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);
|
|
|
|
$adjustId ='';
|
|
|
|
if(!empty($materialadjust))
|
|
{
|
|
foreach($materialadjust as $ig)
|
|
{
|
|
$adjustId = $ig->AdjustmentId;
|
|
}
|
|
}
|
|
|
|
|
|
$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);
|
|
|
|
|
|
if((count($materialadjust)>0) &&(count($historyadd)))
|
|
{
|
|
echo "Material Details Added Successfully";
|
|
}
|
|
else
|
|
{
|
|
echo "Something Went Wrong,Please Try Again";
|
|
}
|
|
}
|
|
|
|
|
|
function Final_Product_Save()
|
|
{
|
|
// echo "from batchcard controller";
|
|
// die();
|
|
$final_product = $this->input->post('DEPTFN');
|
|
$final_qty = $this->input->post('Quantity');
|
|
$product_date = $this->input->post('Date');
|
|
//$pdt = $product_date->format('Y-m-d');
|
|
$pdt = date("Y-m-d", strtotime($product_date));
|
|
$product_value = $this->input->post('values');
|
|
$createdby = $this->session->userdata('userId');
|
|
//echo $createdby;
|
|
|
|
|
|
$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'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
|
|
|
|
if(!empty($final_master_save))
|
|
{
|
|
foreach($final_master_save as $pm)
|
|
{
|
|
$final_product_id = $pm->PId;
|
|
}
|
|
}
|
|
|
|
|
|
$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');
|
|
$coproline = $this->input->post('CopRow');
|
|
|
|
//echo $coproline;
|
|
|
|
for($i=1;$i<=$rawilne;$i++)
|
|
{
|
|
$rawmaterial = $this->input->post('rawmaterialcode'.$i);
|
|
$rawsupplier =$this->input->post('rawSupplierID'.$i);
|
|
$rawqty = $this->input->post('rawQty'.$i);
|
|
$rawvalue = $this->input->post('rawprice'.$i);
|
|
|
|
|
|
$rawarray =array('FPId'=>$final_product_id,'MaterialCode'=>$rawmaterial,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'Price'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
$rawmaterialhistory= array('MaterialCode'=>$rawmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'ItemValue'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory);
|
|
|
|
// print_r($rawarray);
|
|
// print_r($rawmaterialhistory);
|
|
|
|
$this->batchcard_model->save_finalraw($rawarray);
|
|
}
|
|
|
|
|
|
for($i=1;$i<=$consuline;$i++)
|
|
{
|
|
$conmaterial = $this->input->post('consumematerialcode'.$i);
|
|
$consupplier =$this->input->post('consumeSupplierID'.$i);
|
|
$conqty = $this->input->post('consumeQty'.$i);
|
|
$convalue = $this->input->post('consumeprice'.$i);
|
|
|
|
$conarray =array('FPId'=>$final_product_id,'MaterialCode'=>$conmaterial,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'Price'=>$convalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
$consuhistory= array('MaterialCode'=>$conmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'ItemValue'=>$convalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($consuhistory);
|
|
|
|
$this->batchcard_model->save_finalcon($conarray);
|
|
}
|
|
|
|
|
|
for($i=1;$i<=$packline;$i++)
|
|
{
|
|
$packmaterial = $this->input->post('packmaterialcode'.$i);
|
|
$packsupplier =$this->input->post('packSupplierID'.$i);
|
|
$packqty = $this->input->post('packQty'.$i);
|
|
$packvalue = $this->input->post('packprice'.$i);
|
|
|
|
$packarray =array('FPId'=>$final_product_id,'MaterialCode'=>$packmaterial,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'Price'=>$packvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
$packmathistory= array('MaterialCode'=>$packmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$final_product_id,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'ItemValue'=>$packvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($packmathistory);
|
|
|
|
$this->batchcard_model->save_finalpacking($packarray);
|
|
}
|
|
|
|
|
|
for($i=1;$i<=$coproline;$i++)
|
|
{
|
|
|
|
$copmaterial = $this->input->post('Copmaterialcode'.$i);
|
|
$codate =$this->input->post('CopDate'.$i);
|
|
$copqty = $this->input->post('CopQty'.$i);
|
|
$copvalue = $this->input->post('Copprice'.$i);
|
|
|
|
$coparray =array('FPId'=>$final_product_id,'MaterialCode'=>$copmaterial,'CoDate'=>$codate,'Quantity'=>$copqty,'Price'=>$copvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
// 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";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function UpdateFinal_Product_Save()
|
|
{
|
|
|
|
|
|
$FPID = $this->input->post('FPId');
|
|
$final_product = $this->input->post('DEPTFN');
|
|
$final_qty = $this->input->post('Quantity');
|
|
|
|
$product_date = $this->input->post('Date');
|
|
//$pdt = $product_date->format('Y-m-d H:i:s');
|
|
//$pdt = date("Y-m-d", strtotime($product_date));
|
|
|
|
$product_value = $this->input->post('values');
|
|
$createdby = $this->session->userdata('userId');
|
|
$dt = new DateTime('now', new DateTimeZone('Asia/Kolkata'));
|
|
$createddt = $dt->format('Y-m-d H:i:s');
|
|
|
|
|
|
$final_master =array('MaterialCode'=>$final_product,'Quantity'=>$final_qty,'Price'=>$product_value,'CreatedBy'=>$createdby,'ProductDate'=>$product_date);
|
|
|
|
// / print_r($final_master);
|
|
|
|
$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');
|
|
$consuline = $this->input->post('ConsuRow');
|
|
$packline = $this->input->post('PkgRow');
|
|
$coproline = $this->input->post('CopRow');
|
|
|
|
|
|
for($i=1;$i<=$rawilne;$i++)
|
|
{
|
|
$rawmaterial = $this->input->post('rawmaterialcode'.$i);
|
|
$rawsupplier =$this->input->post('rawSupplierID'.$i);
|
|
$rawqty = $this->input->post('rawQty'.$i);
|
|
$rawvalue = $this->input->post('rawprice'.$i);
|
|
$rawilneno = $this->input->post('RawId'.$i);
|
|
//echo $rawilneno;
|
|
if($rawmaterial == '' && $rawsupplier == '' & $rawqty == '')
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
$rawarray =array('FPId'=>$FPID,'MaterialCode'=>$rawmaterial,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'Price'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
|
|
|
|
|
|
$rawmaterialhistory= array('MaterialCode'=>$rawmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$rawsupplier,'Quantity'=>$rawqty,'ItemValue'=>$rawvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
|
|
$checkrawid=$this->batchcard_model->GetRawid($rawilneno);
|
|
|
|
$checkrawhistory = $this->batchcard_model->GetRawCheck($rawmaterial,$FPID);
|
|
|
|
// echo $checkrawhistory;
|
|
|
|
|
|
if(count($checkrawid)==0)
|
|
{
|
|
$this->batchcard_model->save_finalraw($rawarray);
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory);
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
$this->batchcard_model->update_finalraw($rawarray,$rawilneno);
|
|
$this->batchcard_model->update_rawmaterialto_materialHistory($rawmaterialhistory,$rawmaterial,$FPID);
|
|
//$this->batchcard_model->save_rawmaterialto_materialHistory($rawmaterialhistory);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
for($i=1;$i<=$consuline;$i++)
|
|
{
|
|
$conmaterial = $this->input->post('consumematerialcode'.$i);
|
|
$consupplier =$this->input->post('consumeSupplierID'.$i);
|
|
$conqty = $this->input->post('consumeQty'.$i);
|
|
$convalue = $this->input->post('consumeprice'.$i);
|
|
$consuline = $this->input->post('Consumable'.$i);
|
|
|
|
if($conmaterial == '' && $consupplier == '' & $conqty == '')
|
|
{
|
|
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
$conarray =array('FPId'=>$FPID,'MaterialCode'=>$conmaterial,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'Price'=>$convalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
$consuhistory= array('MaterialCode'=>$conmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$consupplier,'Quantity'=>$conqty,'ItemValue'=>$convalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
|
|
$checkconsuid=$this->batchcard_model->Getconsuid($consuline);
|
|
|
|
if(count($checkconsuid)>0)
|
|
{
|
|
$this->batchcard_model->update_finalconsu($conarray,$consuline);
|
|
$this->batchcard_model->update_rawmaterialto_materialHistory($consuhistory,$conmaterial,$FPID);
|
|
}
|
|
|
|
else
|
|
{
|
|
$this->batchcard_model->save_finalcon($conarray);
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($consuhistory);
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
for($i=1;$i<=$packline;$i++)
|
|
{
|
|
$packmaterial = $this->input->post('packmaterialcode'.$i);
|
|
$packsupplier =$this->input->post('packSupplierID'.$i);
|
|
$packqty = $this->input->post('packQty'.$i);
|
|
$packvalue = $this->input->post('packprice'.$i);
|
|
$packlineId = $this->input->post('packId'.$i);
|
|
|
|
if($packmaterial == '' && $packsupplier == '' & $packqty == '')
|
|
{
|
|
|
|
}
|
|
|
|
else{
|
|
|
|
$packarray =array('FPId'=>$FPID,'MaterialCode'=>$packmaterial,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'Price'=>$packvalue,'CreatedBy'=>$createdby,'CreatedDate'=>$createddt);
|
|
|
|
//print_r($packarray);
|
|
$packmathistory= array('MaterialCode'=>$packmaterial,'Transaction_type'=>'Reduce','Ref_Type'=>'Final Product','Ref_No'=>$FPID,'SupplierID'=>$packsupplier,'Quantity'=>$packqty,'ItemValue'=>$packvalue,'CreatedBy'=>$createdby,'CreatedOn'=>$createddt);
|
|
|
|
$checkpackid=$this->batchcard_model->Getpackid($packlineId);
|
|
|
|
if(count($checkpackid)>0)
|
|
{
|
|
$this->batchcard_model->update_finalpacking($packarray,$packlineId);
|
|
|
|
$this->batchcard_model->update_rawmaterialto_materialHistory($packmathistory,$packmaterial,$FPID);
|
|
}
|
|
|
|
else
|
|
{
|
|
|
|
$this->batchcard_model->save_rawmaterialto_materialHistory($packmathistory);
|
|
|
|
$this->batchcard_model->save_finalpacking($packarray);
|
|
}
|
|
}
|
|
//echo "Updated";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for($i=1;$i<=$coproline;$i++)
|
|
{
|
|
|
|
$copmaterial = $this->input->post('Copmaterialcode'.$i);
|
|
$codate =$this->input->post('CopDate'.$i);
|
|
$cddt = date("Y-m-d", strtotime($codate) );
|
|
$copqty = $this->input->post('CopQty'.$i);
|
|
$copvalue = $this->input->post('Copprice'.$i);
|
|
$coplineId = $this->input->post('CopId'.$i);
|
|
|
|
if($copmaterial == '' && $codate == '' & $copqty == '')
|
|
{
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
$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);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
echo "Updated Successfully";
|
|
|
|
}
|
|
|
|
|
|
function EditMaterialAdjustment()
|
|
{
|
|
|
|
$AdjustmentId = $_GET['AdjustmentId'];
|
|
$Supplier = $_GET['sn'];
|
|
$date =$_GET['date'];
|
|
$MaterialCode =$_GET['mc'];
|
|
$this->global['pageTitle'] = $this->CompanyName.' : 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();
|
|
|
|
$this->loadViews("editmaterialadjustment", $this->global,$data,NULL);
|
|
|
|
//return true;
|
|
}
|
|
function material_history()
|
|
{
|
|
$this->global['pageTitle'] = $this->CompanyName.' : Material History';
|
|
if ($this->input->post('btn_submit')) {
|
|
$prod = $this->input->post('item_name');
|
|
$frm = $this->input->post('from_date');
|
|
$t = $this->input->post('to_date');
|
|
$data['material']=$this->batchcard_model->getMaterial_history($prod,$frm,$t);
|
|
}
|
|
$data['material_name']=$this->batchcard_model->material_name();
|
|
//$data['firstinvoice'] = $this->batchcard_model->selectquery();
|
|
|
|
$this->loadviews("MaterialHistory",$this->global,$data,NULL);
|
|
|
|
|
|
}
|
|
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);
|
|
}
|
|
|
|
|
|
}
|
|
?>
|