changes in stock controller
This commit is contained in:
parent
c6821967d6
commit
8653ea2889
@ -459,6 +459,10 @@ class StockController extends BaseController
|
||||
|
||||
$updateDustAndRoughStockDetailsData = json_decode($postData['updateDustAndRoughStockDetails'], true);
|
||||
|
||||
$updates = [];
|
||||
|
||||
$inserts = [];
|
||||
|
||||
foreach($updateDustAndRoughStockDetailsData as $data){
|
||||
|
||||
$date = $data['date'];
|
||||
@ -474,18 +478,31 @@ class StockController extends BaseController
|
||||
$resultExists=$this->dustAndRoughStockDetails_model
|
||||
->where('date',$date)
|
||||
->first();
|
||||
|
||||
|
||||
if(empty($resultExists)){
|
||||
$inserted = $this->dustAndRoughStockDetails_model->insert($dbData);
|
||||
}else{
|
||||
$updated=$this->dustAndRoughStockDetails_model
|
||||
->where('date',$date)
|
||||
->set($dbData)
|
||||
->update();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (empty($resultExists)) {
|
||||
$inserts[] = $dbData;
|
||||
|
||||
} else {
|
||||
$updates[] = $dbData;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($inserts)) {
|
||||
$this->dustAndRoughStockDetails_model->insertBatch($inserts);
|
||||
}
|
||||
|
||||
if (!empty($updates)) {
|
||||
|
||||
$updateResult = $this->dustAndRoughStockDetails_model->updateBatch($updates, 'date');
|
||||
|
||||
if ($updateResult === FALSE) {
|
||||
echo "Error during update";
|
||||
} else {
|
||||
echo "Data Updated Successfully";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
echo "Data Saved Successfully";
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user