<?php

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

class Public_C extends MY_Controller
{
     public function __construct()
    {
        parent::__construct();

        $this->load->admin_model('pos_model');
        $this->load->helper('text');
        $this->pos_settings           = $this->pos_model->getSetting();
        $this->pos_settings->pin_code = $this->pos_settings->pin_code ? md5($this->pos_settings->pin_code) : null;
        $this->data['pos_settings']   = $this->pos_settings;
        $this->session->set_userdata('last_activity', now());
        $this->lang->admin_load('pos', $this->Settings->user_language);
        $this->load->library('form_validation');
    }
     /**
     * This function helps to send invoice to the sms
     * Function: sms_c()
     * Author: Kowshiga A
     */
    public function sms_c()
    {
         $sale_id = $this->uri->segment(3);
         $this->data['rows']            = $this->pos_model->getAllInvoiceItems($sale_id);
         // print_r($this->data['rows']);
         // exit();
        $inv                           = $this->pos_model->getInvoiceByID($sale_id);
         // print_r($inv);
         // exit();
        $biller_id                     = $inv->biller_id;
        $customer_id                   = $inv->customer_id;

        $this->data['biller']          = $this->pos_model->getCompanyByID($biller_id);

        $this->data['customer']        = $this->pos_model->getCompanyByID($customer_id);

        $this->data['payments']        = $this->pos_model->getInvoicePayments($sale_id);

        $this->data['pos']             = $this->pos_model->getSetting();

        // $this->data['barcode']         = $this->barcode($inv->reference_no, 'code128', 30);
         
        // $this->data['return_sale']     = $inv->return_id ? $this->pos_model->getInvoiceByID($inv->return_id) : null;

        // $this->data['return_rows']     = $inv->return_id ? $this->pos_model->getAllInvoiceItems($inv->return_id) : null;
        // $this->data['return_payments'] = $this->data['return_sale'] ? $this->pos_model->getInvoicePayments($this->data['return_sale']->id) : null;
        $this->data['inv']             = $inv;
        $this->data['sid']             = $sale_id;
       
     $this->data['created_by']      = $this->pos_model->created_by($inv->created_by);
        $this->data['page_title']      = "Invoice";
 
         $this->load->view($this->theme . 'public/public_view', $this->data);
    }
    

    
}
