bb_sign/app/Models/ClientDocsModel.php
2024-07-01 09:06:58 +05:30

50 lines
2.2 KiB
PHP

<?php namespace App\Models;
use CodeIgniter\Model;
class ClientDocsModel extends Model
{
protected $table = 'client_docs';
protected $primaryKey = 'id';
protected $allowedFields = ['client_branch_id','template_id','template_name','body_html','document_name','rejection_reason','is_approved','otp','ip_address','is_active' ,'place_holder_object','created_by','updated_by'];
public function getTemplate($client_id){
$this->select('template.template_name , template.template_id ,client_docs.is_approved ,client_docs.id as doc_id ,client_docs.created_at ,client_docs.document_name, services.service_name');
$this->join('template', 'template.template_id = client_docs.template_id');
$this->join('services', 'services.service_id = template.service_id');
$this->where('client_docs.is_active', 1);
$this->where('client_docs.client_branch_id', $client_id);
return $this->findAll();
}
public function getDocs(){
$this->select('template.template_name , template.template_id ,client_docs.is_approved ,client_docs.id as doc_id ,client_docs.is_active , client_docs.document_name, services.service_name');
$this->join('template', 'template.template_id = client_docs.template_id');
$this->join('services', 'services.service_id = template.service_id');
return $this->findAll();
}
public function docPreview($doc_id){
$this->select('client_docs.is_approved ,client_docs.id as doc_id,client_docs.client_branch_id ,client_docs.updated_at,client_docs.ip_address,template.template_name,client_docs.body_html ,client_docs.is_active,client_docs.document_name,client_docs.place_holder_object, services.service_name , business.header_html, business.footer_html');
$this->join('template', 'template.template_id = client_docs.template_id','left');
$this->join('services', 'services.service_id = template.service_id','left');
$this->join('business', 'business.business_id = template.template_header_business','left');
$this->where('md5(client_docs.id)', $doc_id);
return $this->get()->getRow();
}
}