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
|
||||
{
|
||||
protected $table = 't_bagStockDetails';
|
||||
protected $primaryKey = 'id';
|
||||
protected $useAutoIncrement = true;
|
||||
protected $returnType = 'array';
|
||||
protected $useSoftDeletes = false;
|
||||
protected $protectFields = true;
|
||||
protected $allowedFields = [];
|
||||
protected $allowedFields = [
|
||||
'date', 'materialCode', 'customer', 'opening', 'receipt', 'used', 'balanceStock'
|
||||
];
|
||||
|
||||
protected bool $allowEmptyInserts = false;
|
||||
protected bool $updateOnlyChanged = true;
|
||||
|
||||
protected array $casts = [];
|
||||
protected array $castHandlers = [];
|
||||
|
||||
// Dates
|
||||
protected $useTimestamps = false;
|
||||
protected $dateFormat = 'datetime';
|
||||
protected $createdField = 'created_at';
|
||||
protected $updatedField = 'updated_at';
|
||||
protected $deletedField = 'deleted_at';
|
||||
|
||||
// Validation
|
||||
protected $validationRules = [];
|
||||
@ -33,14 +27,35 @@ class BagStockDetailsModel extends Model
|
||||
protected $skipValidation = false;
|
||||
protected $cleanValidationRules = true;
|
||||
|
||||
// Callbacks
|
||||
protected $allowCallbacks = true;
|
||||
protected $beforeInsert = [];
|
||||
protected $afterInsert = [];
|
||||
protected $beforeUpdate = [];
|
||||
protected $afterUpdate = [];
|
||||
protected $beforeFind = [];
|
||||
protected $afterFind = [];
|
||||
protected $beforeDelete = [];
|
||||
protected $afterDelete = [];
|
||||
/**
|
||||
* Custom method to handle composite key updates.
|
||||
* @param array $data Array of records to be updated in bulk.
|
||||
* @return bool
|
||||
*/
|
||||
public function updateBatchWithCompositeKey(array $data)
|
||||
{
|
||||
$db = \Config\Database::connect();
|
||||
$db->transBegin();
|
||||
|
||||
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>
|
||||
|
||||
<!-- this will loop till materials present -->
|
||||
<th colspan="4">material 1</th>
|
||||
|
||||
<th colspan="4">material 2</th>
|
||||
@ -226,6 +227,7 @@
|
||||
<tr>
|
||||
<th colspan="1">Customer </th>
|
||||
|
||||
<!-- this will loop till materials present -->
|
||||
<th colspan="4" contenteditable="true">
|
||||
<?php echo $customer??'Customer' ?>
|
||||
</th>
|
||||
@ -239,6 +241,7 @@
|
||||
|
||||
<th colspan="1">Date </th>
|
||||
|
||||
<!-- this will loop till materials present -->
|
||||
<th style="display:none">Date</th>
|
||||
<th style="display:none"> material</th>
|
||||
<th style="display:none"> customer</th>
|
||||
@ -267,38 +270,38 @@
|
||||
<td style="display:none">23-10-2024</td>
|
||||
<td style="display:none"> material 1</td>
|
||||
<td style="display:none"> customer 1</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
<td class="celda_normal">11212</td>
|
||||
<td class="celda_normal">-</td>
|
||||
<td class="celda_normal">472</td>
|
||||
<td class="celda_normal" >11212</td>
|
||||
<td class="celda_normal" contenteditable="true" >-</td>
|
||||
<td class="celda_normal" >472</td>
|
||||
|
||||
<td style="display:none">23-10-2024</td>
|
||||
<td style="display:none"> material 2</td>
|
||||
<td style="display:none"> customer 2</td>
|
||||
<td class="celda_normal" >472</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>
|
||||
|
||||
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td class="celda_normal" >23-10-2024</td>
|
||||
<td style="display:none">Date</td>
|
||||
<td class="celda_normal" >24-10-2024</td>
|
||||
<td style="display:none">24-10-2024</td>
|
||||
<td style="display:none"> material 1</td>
|
||||
<td style="display:none"> customer 1</td>
|
||||
<td class="celda_normal" >472</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 style="display:none">Date</td>
|
||||
<td style="display:none"> material 1</td>
|
||||
<td style="display:none"> customer 1</td>
|
||||
<td style="display:none">24-10-2024</td>
|
||||
<td style="display:none"> material 2</td>
|
||||
<td style="display:none"> customer 2</td>
|
||||
<td class="celda_normal" >472</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>
|
||||
|
||||
|
||||
@ -342,9 +345,7 @@
|
||||
|
||||
//table to json function
|
||||
|
||||
var updateBagStockDetails = $("#bagStockDetailsTableId").tableToJSON();
|
||||
|
||||
updateBagStockDetails = JSON.stringify(incomingSilicaSandDetailsData);
|
||||
var updateBagStockDetails = tableToJSON();
|
||||
|
||||
$('#loader').show();
|
||||
$.ajax({
|
||||
@ -391,8 +392,8 @@
|
||||
material: rowCells.eq(i+1).text().trim(),
|
||||
customer: rowCells.eq(i+2).text().trim(),
|
||||
opening: rowCells.eq(i+3).text().trim(),
|
||||
receipt: rowCells.eq(i + 4).text().trim(),
|
||||
used: rowCells.eq(i + 5).text().trim(),
|
||||
receipt: rowCells.eq(i+4).text().trim(),
|
||||
used: rowCells.eq(i+5).text().trim(),
|
||||
balanceStock: rowCells.eq(i + 6).text().trim()
|
||||
};
|
||||
|
||||
@ -406,8 +407,5 @@
|
||||
|
||||
console.log(tableToJson());
|
||||
|
||||
$('#saveId').on('click', function() {
|
||||
const jsonResult = tableToJson();
|
||||
console.log(jsonResult);
|
||||
});
|
||||
|
||||
</script>
|
||||
Loading…
Reference in New Issue
Block a user