92 lines
3.1 KiB
PHP
92 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use CodeIgniter\Model;
|
|
|
|
class CoatingMachineDetailsModel extends Model
|
|
{
|
|
protected $table = 't_coatingmachinedetails';
|
|
protected $primaryKey = 'id';
|
|
protected $useAutoIncrement = true;
|
|
protected $returnType = 'array';
|
|
protected $useSoftDeletes = false;
|
|
protected $protectFields = true;
|
|
protected $allowedFields = ['shift','machineOnTime','machineOffTime','totalCoating','date',
|
|
'machineRunningInHrs' , 'perHourCoatingSandQTY' , 'perHourGasConsumption' ,'grade',
|
|
'totalCoatingSandInKg','totalGasConsumption','customerName', 'is_active','created_at','updated_at'];
|
|
|
|
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 = [];
|
|
protected $validationMessages = [];
|
|
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 = [];
|
|
|
|
public function coatingMachineDetails($startDate,$endDate){
|
|
$result = $this->db->table('t_coatingmachinedetails')
|
|
->select('t_coatingmachinedetails.*,
|
|
JSON_ARRAYAGG(
|
|
JSON_OBJECT(
|
|
"client_given_name", t_batchcard_files.client_file_name,
|
|
"filename", t_batchcard_files.filename,
|
|
"batchCardId" , t_batchcard_files.id,
|
|
"coating_id", t_batchcard_files.coating_id
|
|
)
|
|
) as batchcard_files')
|
|
->join('t_batchcard_files', 't_batchcard_files.coating_id = t_coatingmachinedetails.id', 'left')
|
|
->where('t_coatingmachinedetails.date >=', $startDate)
|
|
->where('t_coatingmachinedetails.date <=', $endDate)
|
|
->groupBy('t_coatingmachinedetails.id')
|
|
->orderBy('t_coatingmachinedetails.date', 'asc')
|
|
->get()
|
|
->getResultArray();
|
|
return $result;
|
|
}
|
|
|
|
public function isShiftExists($date, $shift)
|
|
{
|
|
$result = $this->db->table('t_coatingmachinedetails')
|
|
->where('date', $date)
|
|
->where('shift', $shift)
|
|
->where('is_active', 1)
|
|
->get()
|
|
->getResultArray();
|
|
|
|
return $result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|