<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of Quotationm
 *
 * @author Code sys PC 7
 */
class Quotationm extends CI_Model {

    public function __construct() {
        $this->load->database();
    }

    function saveItemCost($item_cost_details) {
        $this->db->insert("item_costings", $item_cost_details);
        $insert_id = $this->db->insert_id();
        return $insert_id;
    }

    function saveQuotationDetails($quotation_details) {
        $this->db->insert("quotation_details", $quotation_details);
    }

    function sendEmail($email, $subject, $message, $attachfile) {

        $config = array(
            'protocol' => 'smtp',
            'smtp_host' => 'ssl://smtp.gmail.com',
            'smtp_port' => 465,
            'smtp_user' => 'librobookshop@gmail.com',
            'smtp_pass' => 'libro140205',
            'mailtype' => 'html',
            'charset' => 'iso-8859-1',
            'wordwrap' => TRUE
        );
        $this->load->library('email', $config);
        $this->email->set_newline("\r\n");
        $this->email->from('librobookshop@gmail.com');
        $this->email->to($email);
        $this->email->subject($subject);
        $this->email->message($message);
        $this->email->attach($attachfile);
        if ($this->email->send()) {
            echo 'Email send.';
        } else {
            show_error($this->email->print_debugger());
        }
    }

    function saveQuotation($quotation) {
        $this->db->insert("quotation", $quotation);
        $insert_id = $this->db->insert_id();
        return $insert_id;
    }

}
