<?php

namespace App\Models;

use CodeIgniter\Model;

class QuoteModel extends Model
{
    protected $table = 'quotations';
    protected $primaryKey = 'qid';

    protected $allowedFields = [

        'quotation_no',
        'cid',

        'quotation_date',
        'validity_date',

        'po_number',
        'po_date',

        'subtotal',
        'discount',
        'amount_after_discount',

        'vat_amount',
        'net_amount',

        'payment_terms',
        'delivery_terms',

        'q_status'
    ];

    public function getAllQuotes()
    {
        return $this->db->table('quotations q')
            ->select('
                q.*,
                c.c_cname,
            ')
            ->join('customer c', 'c.cid = q.cid', 'left')
            ->orderBy('qid','DESC')
            ->get()
            ->getResultArray();
    }
}