<?php
defined('BASEPATH') OR exit('No direct script access allowed');   
    
    if(!function_exists('az_select_product_type')){
function az_select_product_type($id = 'product', $attr='', $parent='idoutlet', $b_l='') {
    $ci =& get_instance();
    $azapp = $ci->load->library('AZApp');
    $select = $ci->azapp->add_select2();
    $select->set_id($id);
    $select->set_select_parent($parent);
    // ---- filter kategori Baju (B) / Linen (L) via segmen URL ----
    $url = 'data_surya/get_data_product_type';
    $b_l = strtoupper(trim((string)$b_l));
    if (in_array($b_l, array('B', 'L'))) {
        $url .= '/' . $b_l;
    }
    $select->set_url($url);
    $select->set_placeholder('Pilih Jenis Produk');
    if (strlen($attr) > 0) {
        $select->add_attr('data-id', $ci->encrypt->encode($attr.'.idproduct'));
        $select->add_class('element-top-filter');
        $select->add_attr('data-w', 'true');
    }
    return $select->render();
}
}

    if(!function_exists('az_select_colour')){
        function az_select_colour($id = 'colour', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_colour');
            $select->set_placeholder('Pilih Warna');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.idcolour'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            

            return $select->render();
        }
    }

    
    if(!function_exists('az_select_hue')){
        function az_select_hue($id = 'hue', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_hue');
            $select->set_placeholder('Pilih Corak');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.idhue'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            

            return $select->render();
        }
    }

    if(!function_exists('az_select_payment')){
        function az_select_payment($id = 'payment', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_payment');
            $select->set_placeholder('Pilih Pembayaran');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.idpayment'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            

            return $select->render();
        }
    }

    if(!function_exists('az_convert_spot')){
        function az_convert_spot($data) {
            $ci =& get_instance();

            $the_data = '';
            if (strlen($data) > 0) {
                $xdata = explode(',', $data);
                $ci->db->where_in('idspot', $xdata);
                $rdata = $ci->db->get('spot');

                foreach ($rdata->result() as $key => $value) {
                    $comma = ', ';
                    if ($key == 0) {
                        $comma = '';
                    }
                    $the_data .= $comma.$value->spot_name;
                }
            }

            return $the_data;
        }
    }

    if(!function_exists('az_convert_colour')){
        function az_convert_colour($data) {
            $ci =& get_instance();

            $the_data = '';
            if (strlen($data) > 0) {
                $xdata = explode(',', $data);
                $ci->db->where_in('idcolour', $xdata);
                $rdata = $ci->db->get('colour');

                foreach ($rdata->result() as $key => $value) {
                    $comma = ', ';
                    if ($key == 0) {
                        $comma = '';
                    }
                    $the_data .= $comma.$value->colour_name;
                }
            }

            return $the_data;
        }
    }

    if(!function_exists('az_convert_hue')){
        function az_convert_hue($data) {
            $ci =& get_instance();

            $the_data = '';
            if (strlen($data) > 0) {
                $xdata = explode(',', $data);
                $ci->db->where_in('idhue', $xdata);
                $rdata = $ci->db->get('hue');

                foreach ($rdata->result() as $key => $value) {
                    $comma = ', ';
                    if ($key == 0) {
                        $comma = '';
                    }
                    $the_data .= $comma.$value->hue_name;
                }
            }

            return $the_data;
        }
    }

    if(!function_exists('az_select_driver')){
        function az_select_driver($id = 'driver', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_driver');
            $select->set_placeholder('Pilih Driver');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.iddriver'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            
            return $select->render();
        }
    }

    if(!function_exists('az_select_production')){
        function az_select_production($id = 'production', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_production');
            $select->set_placeholder('Pilih Produksi');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.idproduction'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            
            return $select->render();
        }
    }

    if(!function_exists('az_select_cashier')){
        function az_select_cashier($id = 'cashier', $attr='') {
            $ci =& get_instance();
            $azapp = $ci->load->library('AZApp');
            $select = $ci->azapp->add_select2();
            $select->set_id($id);
            $select->set_url('data_surya/get_data_cashier');
            $select->set_placeholder('Pilih Kasir');
            
            if (strlen($attr) > 0) {
                $select->add_attr('data-id', $ci->encrypt->encode($attr.'.iduser'));
                $select->add_class('element-top-filter');
                $select->add_attr('data-w', 'true');
            }
            
            return $select->render();
        }
    }