28/10/2024 vadivel J
This commit is contained in:
parent
a3c013a743
commit
1764388a1b
@ -7,25 +7,19 @@ use CodeIgniter\Model;
|
|||||||
class BagStockDetailsModel extends Model
|
class BagStockDetailsModel extends Model
|
||||||
{
|
{
|
||||||
protected $table = 't_bagStockDetails';
|
protected $table = 't_bagStockDetails';
|
||||||
protected $primaryKey = 'id';
|
|
||||||
protected $useAutoIncrement = true;
|
|
||||||
protected $returnType = 'array';
|
protected $returnType = 'array';
|
||||||
protected $useSoftDeletes = false;
|
protected $useSoftDeletes = false;
|
||||||
protected $protectFields = true;
|
protected $protectFields = true;
|
||||||
protected $allowedFields = [];
|
protected $allowedFields = [
|
||||||
|
'date', 'materialCode', 'customer', 'opening', 'receipt', 'used', 'balanceStock'
|
||||||
|
];
|
||||||
|
|
||||||
protected bool $allowEmptyInserts = false;
|
protected bool $allowEmptyInserts = false;
|
||||||
protected bool $updateOnlyChanged = true;
|
protected bool $updateOnlyChanged = true;
|
||||||
|
|
||||||
protected array $casts = [];
|
|
||||||
protected array $castHandlers = [];
|
|
||||||
|
|
||||||
// Dates
|
// Dates
|
||||||
protected $useTimestamps = false;
|
protected $useTimestamps = false;
|
||||||
protected $dateFormat = 'datetime';
|
protected $dateFormat = 'datetime';
|
||||||
protected $createdField = 'created_at';
|
|
||||||
protected $updatedField = 'updated_at';
|
|
||||||
protected $deletedField = 'deleted_at';
|
|
||||||
|
|
||||||
// Validation
|
// Validation
|
||||||
protected $validationRules = [];
|
protected $validationRules = [];
|
||||||
@ -33,14 +27,35 @@ class BagStockDetailsModel extends Model
|
|||||||
protected $skipValidation = false;
|
protected $skipValidation = false;
|
||||||
protected $cleanValidationRules = true;
|
protected $cleanValidationRules = true;
|
||||||
|
|
||||||
// Callbacks
|
/**
|
||||||
protected $allowCallbacks = true;
|
* Custom method to handle composite key updates.
|
||||||
protected $beforeInsert = [];
|
* @param array $data Array of records to be updated in bulk.
|
||||||
protected $afterInsert = [];
|
* @return bool
|
||||||
protected $beforeUpdate = [];
|
*/
|
||||||
protected $afterUpdate = [];
|
public function updateBatchWithCompositeKey(array $data)
|
||||||
protected $beforeFind = [];
|
{
|
||||||
protected $afterFind = [];
|
$db = \Config\Database::connect();
|
||||||
protected $beforeDelete = [];
|
$db->transBegin();
|
||||||
protected $afterDelete = [];
|
|
||||||
|
foreach ($data as $record) {
|
||||||
|
$db->table($this->table)
|
||||||
|
->where('date', $record['date'])
|
||||||
|
->where('materialCode', $record['materialCode'])
|
||||||
|
->update([
|
||||||
|
'customer' => $record['customer'],
|
||||||
|
'opening' => $record['opening'],
|
||||||
|
'receipt' => $record['receipt'],
|
||||||
|
'used' => $record['used'],
|
||||||
|
'balanceStock' => $record['balanceStock']
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($db->transStatus() === FALSE) {
|
||||||
|
$db->transRollback();
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
$db->transCommit();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -218,6 +218,7 @@
|
|||||||
|
|
||||||
<th colspan="1">material </th>
|
<th colspan="1">material </th>
|
||||||
|
|
||||||
|
<!-- this will loop till materials present -->
|
||||||
<th colspan="4">material 1</th>
|
<th colspan="4">material 1</th>
|
||||||
|
|
||||||
<th colspan="4">material 2</th>
|
<th colspan="4">material 2</th>
|
||||||
@ -226,6 +227,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<th colspan="1">Customer </th>
|
<th colspan="1">Customer </th>
|
||||||
|
|
||||||
|
<!-- this will loop till materials present -->
|
||||||
<th colspan="4" contenteditable="true">
|
<th colspan="4" contenteditable="true">
|
||||||
<?php echo $customer??'Customer' ?>
|
<?php echo $customer??'Customer' ?>
|
||||||
</th>
|
</th>
|
||||||
@ -239,6 +241,7 @@
|
|||||||
|
|
||||||
<th colspan="1">Date </th>
|
<th colspan="1">Date </th>
|
||||||
|
|
||||||
|
<!-- this will loop till materials present -->
|
||||||
<th style="display:none">Date</th>
|
<th style="display:none">Date</th>
|
||||||
<th style="display:none"> material</th>
|
<th style="display:none"> material</th>
|
||||||
<th style="display:none"> customer</th>
|
<th style="display:none"> customer</th>
|
||||||
@ -269,7 +272,7 @@
|
|||||||
<td style="display:none"> customer 1</td>
|
<td style="display:none"> customer 1</td>
|
||||||
<td class="celda_normal">472</td>
|
<td class="celda_normal">472</td>
|
||||||
<td class="celda_normal" >11212</td>
|
<td class="celda_normal" >11212</td>
|
||||||
<td class="celda_normal">-</td>
|
<td class="celda_normal" contenteditable="true" >-</td>
|
||||||
<td class="celda_normal" >472</td>
|
<td class="celda_normal" >472</td>
|
||||||
|
|
||||||
<td style="display:none">23-10-2024</td>
|
<td style="display:none">23-10-2024</td>
|
||||||
@ -277,28 +280,28 @@
|
|||||||
<td style="display:none"> customer 2</td>
|
<td style="display:none"> customer 2</td>
|
||||||
<td class="celda_normal" >472</td>
|
<td class="celda_normal" >472</td>
|
||||||
<td class="celda_normal">11212</td>
|
<td class="celda_normal">11212</td>
|
||||||
<td class="celda_normal">-</td>
|
<td class="celda_normal" contenteditable="true" >-</td>
|
||||||
<td class="celda_normal">472</td>
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td class="celda_normal" >23-10-2024</td>
|
<td class="celda_normal" >24-10-2024</td>
|
||||||
<td style="display:none">Date</td>
|
<td style="display:none">24-10-2024</td>
|
||||||
<td style="display:none"> material 1</td>
|
<td style="display:none"> material 1</td>
|
||||||
<td style="display:none"> customer 1</td>
|
<td style="display:none"> customer 1</td>
|
||||||
<td class="celda_normal" >472</td>
|
<td class="celda_normal" >472</td>
|
||||||
<td class="celda_normal">11212</td>
|
<td class="celda_normal">11212</td>
|
||||||
<td class="celda_normal">-</td>
|
<td class="celda_normal" contenteditable="true" >-</td>
|
||||||
<td class="celda_normal">472</td>
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
<td style="display:none">Date</td>
|
<td style="display:none">24-10-2024</td>
|
||||||
<td style="display:none"> material 1</td>
|
<td style="display:none"> material 2</td>
|
||||||
<td style="display:none"> customer 1</td>
|
<td style="display:none"> customer 2</td>
|
||||||
<td class="celda_normal" >472</td>
|
<td class="celda_normal" >472</td>
|
||||||
<td class="celda_normal">11212</td>
|
<td class="celda_normal">11212</td>
|
||||||
<td class="celda_normal">-</td>
|
<td class="celda_normal" contenteditable="true" >-</td>
|
||||||
<td class="celda_normal">472</td>
|
<td class="celda_normal">472</td>
|
||||||
|
|
||||||
|
|
||||||
@ -342,9 +345,7 @@
|
|||||||
|
|
||||||
//table to json function
|
//table to json function
|
||||||
|
|
||||||
var updateBagStockDetails = $("#bagStockDetailsTableId").tableToJSON();
|
var updateBagStockDetails = tableToJSON();
|
||||||
|
|
||||||
updateBagStockDetails = JSON.stringify(incomingSilicaSandDetailsData);
|
|
||||||
|
|
||||||
$('#loader').show();
|
$('#loader').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@ -406,8 +407,5 @@
|
|||||||
|
|
||||||
console.log(tableToJson());
|
console.log(tableToJson());
|
||||||
|
|
||||||
$('#saveId').on('click', function() {
|
|
||||||
const jsonResult = tableToJson();
|
|
||||||
console.log(jsonResult);
|
|
||||||
});
|
|
||||||
</script>
|
</script>
|
||||||
Loading…
Reference in New Issue
Block a user