<?php

class Workorder_model extends CI_Model {

    function __construct() {
        // Call the Model constructor
        parent::__construct();
         
    }

    function getworkorders($start, $end){

        if(null==$start){
            $start= date('Y-m-d');
        }

        $this->db->select('*');
        $this->db->join('business_supplier', 'business_supplier.id_business_supplier = workorders.workorder_supplier_id');
        $this->db->where('date(workorder_date) >=', $start);
        $this->db->where('date(workorder_date) <=', $end);
        $query = $this->db->get('workorders');

        return $query->result_array();

    }


    function getworkorderitems($id){

        $this->db->select('*');        
        $this->db->where('workorder_id=', $id);        
        $query = $this->db->get('workorder_items');

        return $query->result_array();

    }

}