<?php

if (!defined('BASEPATH'))
    exit('No direct script access allowed');

class Pdfs_model extends CI_Model {

    public function get_totalcount_exp() {
        $sta = 'A';
        $user_id = $this->ion_auth->get_user_id();
        
        $this->db->where('status', $sta);
        $this->db->where('id =', $user_id);
        
        $num = $this->db->count_all_results('engines_list');
        return $num;
    }

    public function get_listings_export() {

        $option = $this->input->post('sampleinlineradio');
        $st = "D";
        $user_id = $this->ion_auth->get_user_id();
        
        if ($option == "Monthly") {

            $this->db->where('status !=', $st);
            $this->db->where('id =', $user_id);
            $this->db->where('MONTH(date_listed)', 'MONTH(CURRENT_DATE())', FALSE);
            $qu = $this->db->get('engines_list');


            if ($qu->num_rows() > 0) {
                return $qu->result();
            }
            return false;
        }

        if ($option == "Weekly") {

            $this->db->where('status !=', $st);
            $this->db->where('id =', $user_id);
            $this->db->where('YEARWEEK(date_listed)', 'YEARWEEK(CURRENT_DATE())', FALSE);
            $qu2 = $this->db->get('engines_list');


            if ($qu2->num_rows() > 0) {
                return $qu2->result();
            }
            return false;
        }
    }

    public function get_totalpcount_exp() {
        return $this->db->count_all('engine_parts_list');
    }

    public function get_plistings_export() {

        $option = $this->input->post('sampleinlineradio');

        if ($option == "Monthly") {

            $this->db->where('MONTH(date_listed)', 'MONTH(CURRENT_DATE())', FALSE);
            $qu = $this->db->get('engine_parts_list');


            if ($qu->num_rows() > 0) {
                return $qu->result();
            }
            return false;
        }

        if ($option == "Weekly") {

            $this->db->where('YEARWEEK(date_listed)', 'YEARWEEK(CURRENT_DATE())', FALSE);
            $qu2 = $this->db->get('engine_parts_list');


            if ($qu2->num_rows() > 0) {
                return $qu2->result();
            }
            return false;
        }
    }

}
