the_mechanic/app/Models/JobcardOSModel.php
2024-09-25 09:12:05 +05:30

32 lines
1.4 KiB
PHP
Executable File

<?php
namespace App\Models;
use CodeIgniter\Model;
class JobcardOSModel extends Model
{
protected $table = 'job_card_os';
protected $primaryKey = 'job_card_os_id';
protected $allowedFields = ['job_card_os_id','job_card_id','os_id', 'labour_cost','product_id', 'qty', 'tax', 'amount','isactive'];
public function individual_download_os($job_card_id)
{
$this->select('
job_card.job_card_id, job_card.created_at, job_card.branch_id, job_card.isactive, job_card.vehicle_id,
job_card_os.job_card_id AS job_card_os_job_card_id, job_card_os.os_id, job_card_os.product_id,
out_source.name,
vehicle.reg_no, vehicle.make, vehicle.colour, vehicle.model,
make.make AS bike_name, model.model_name AS bike_modal_name, job_card.delivery_date
');
$this->join('job_card', 'job_card.job_card_id = job_card_os.job_card_id');
$this->join('out_source', 'out_source.id = job_card_os.os_id', 'left');
$this->join('vehicle', 'vehicle.vehicle_id = job_card.vehicle_id', 'left');
$this->join('make', 'make.make_id = vehicle.make', 'left');
$this->join('model', 'model.model_id = vehicle.model', 'left');
$this->where('job_card_os.job_card_id', $job_card_id);
$this->where('job_card_os.is_active', 1);
$this->orderBy('job_card.job_card_id', 'DESC');
return $this->findAll();
}
}