<?php

class MaintenanceAjax extends mainController {
    private $db;

    public function __construct() {
        parent::__construct();
        $this->db = DBConnectorFactory::loadDriver();
        $this->controller_permission = Session::getPermissionsObject();
        $this->load->model('maintenance');
    }

    public function landing() {
    }
    public function getChecklist(){
        $columns = array('checklist_name', 'checklist_description',
                         array('db' => 'checklist_id', 'dt' => 2, 'formatter' => function( $d ) {
                             $html = Forms::action_snippet(["color" => "success-dark", 
                                                            "isDropDown" => true,
                                                            "data_id" => $d,
                                                            "ActionOption" => [
                                                                ["title" => CommonLanguage::getMessage("delete"),
                                                                 "class" => "delete_checklist",
                                                                 "permission" => "delete_checklist",
                                                                 "icon" => "fa-trash"
                                                                ],
                                                                ["title" => CommonLanguage::getMessage("Edit"),
                                                                 "class" => "edit_checklist",
                                                                 "data-target"=>"#add-edit-checklist-modal",
                                                                 "permission" => "edit_checklist",
                                                                 "icon" => "fa-pencil"
                                                                ]                                                ]
                                                           ]);
                             return $html;
                         })
                        );
        $key = 'checklist_id';
        $table = 'tbl_checklist';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);

    }
    public function getChecklistSchedule(){
        $columns = array('schedule_title', 'schedule_start_date','checklist_name','line_name','product_full_name','product_part_note',
                         array('db' => 'schedule_id', 'dt' => 6, 'formatter' => function( $d ) {
                             $html = Forms::action_snippet(["color" => "success-dark", 
                                                            "isDropDown" => true,
                                                            "data_id" => $d,
                                                            "ActionOption" => [
                                                                ["title" => CommonLanguage::getMessage("delete"),
                                                                 "class" => "delete_schedule_checklist",
                                                                 "permission" => "delete_schedule_checklist",
                                                                 "icon" => "fa-trash"
                                                                ],
                                                                ["title" => CommonLanguage::getMessage("Edit"),
                                                                 "class" => "edit_checklist_schedule",
                                                                 "data-target"=>"#checklist-schedule-modal",
                                                                 "permission" => "edit_schedule_checklist",
                                                                 "icon" => "fa-pencil"
                                                                ]                                                ]
                                                           ]);
                             return $html;
                         })
                        );
        $key = 'schedule_id';
        $table = 'checklist_schedule_list';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);
    }
    public function getChecklistScheduleAnswerList(){
        $columns = array('schedule_title','line_name','product_full_name','product_part_note','checklist_name','date_created',
                         array('db' => 'answer_main_id', 'dt' =>6, 'formatter' => function( $d ) {
                             $html = Forms::action_snippet(["color" => "success-dark", 
                                                            "isDropDown" => true,
                                                            "data_id" => $d,
                                                            "ActionOption" => [
                                                                ["title" => CommonLanguage::getMessage("delete"),
                                                                 "class" => "delete_checklist_schedule_answers",
                                                                 "permission" => "delete_checklist_schedule_answers",
                                                                 "icon" => "fa-trash"
                                                                ],
                                                                ["title" => CommonLanguage::getMessage("Edit"),
                                                                 "class" => "edit_checklist_schedule_answers",
                                                                 "data-target"=>"#checklist-schedule-answers-modal",
                                                                 "permission" => "delete_checklist_schedule_answers",
                                                                 "icon" => "fa-pencil"
                                                                ]                                                ]
                                                           ]);
                             return $html;
                         })
                        );
        $key = 'answer_main_id';
        $table = 'answer_main_list';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);
    }
    public function getScheduleChecklistHistory(){
        $condition = !empty($_GET['section_id']) ? ' and section_id = "'.$_GET['section_id'].'"' : '';
        $condition .= !empty($_GET['Product_ID']) ? ' and Product_ID = "'.$_GET['Product_ID'].'"' : '';
        $condition .= !empty($_GET['line_id']) ? ' and line_id = "'.$_GET['line_id'].'"' : '';
        $condition .= ' AND SUBSTR(`date_created`, 1, 10) between "' . $_GET['start_date'] . '" and "' . $_GET['end_date'] . '"';
        $columns = array('schedule_title', 'checklist_name','line_name','product_full_name','product_part_note','date_created',
                         array('db' => 'answer_main_id', 'dt' =>6, 'formatter' => function( $d ) {
                             $html = Forms::action_snippet(["color" => "success-dark", 
                                                            "isDropDown" => false,
                                                            "data_id" => $d,
                                                            "ActionOption" => [
                                                                ["title" => CommonLanguage::getMessage("view"),
                                                                 "data-target"=>"#view-answers-modal",
                                                                 "class" => "view_answers",
                                                                 "icon" => "fa-eye"
                                                                ]]
                                                           ]);
                             return $html;
                         }));
        $key = 'answer_main_id';
        $table = 'answer_main_list';
        $data = DataTable::complex($_GET, $table, $key, $columns,' 1=1 '.$condition);
        echo json_encode($data);
    }
    public function getMissedScheduledChecklist(){
        $condition = !empty($_GET['section_id']) ? ' and section_id = "'.$_GET['section_id'].'"' : '';
        $condition .= !empty($_GET['Product_ID']) ? ' and Product_ID = "'.$_GET['Product_ID'].'"' : '';
        $condition .= !empty($_GET['line_id']) ? ' and line_id = "'.$_GET['line_id'].'"' : '';
        $_GET['current_date_time'] = date('Y-m-d H:i:s');
        $condition .= ' AND (SUBSTR(`schedule_next_date`, 1, 10) between "' . $_GET['start_date'] . '" and "' . $_GET['end_date'] . '" and schedule_type_id = 1) or (isnull(schedule_next_date) and schedule_type_id = 2)';

        $columns = array('schedule_title', 'checklist_name','line_name','product_full_name','product_part_note',
                         array('db' => 'schedule_next_date', 'dt' =>5, 
                               'formatter' => function( $d,$row ) {
                                   return  $row[10] == 1 ? '<span style="color:'.($d < $_GET['current_date_time'] ? 'red' : 'green').'">'.$d.'</span>' : '-- --';
                               }),'last_run_date',
                         array('db' => 'property_value', 'dt' =>7, 
                               'formatter' => function( $d,$row ) {
                                   $datediff =  CommonFunctions::calc_date_diff(($row[6] ? $row[6] : date('Y-m-d H:i:s')),$row[5]);
                                   return $row[10] == 1 ? $datediff : floatval($row[11] - $d).$row[12];

                               }),
                         array('db' => 'schedule_id', 'dt' =>8, 
                               'formatter' => function( $d,$row ) {
                                   return '<input type="checkbox" name="answer_schedule" data-id="'.$d.'"/>';

                               }),
                         array('db' => 'schedule_id', 'dt' =>9, 'formatter' => function( $d,$row ) {
                             $html = Forms::action_snippet(["color" => "success-dark", 
                                                            "isDropDown" => false,
                                                            "data_id" => $d,
                                                            "ActionOption" => [
                                                                ["title" => CommonLanguage::getMessage("schedule_checklist"),
                                                                 "class" => "view_answers openFrame",
                                                                 "attr" => "data-src='Maintenance/answers_checklist_schedule?is_pop=1&schedule_id={$d}&schedule_name={$row[0]}'",
                                                                 "icon" => "fa-check"
                                                                ]]
                                                           ]);
                             return $html;
                         }),'schedule_type_id','schedule_repeat_value','property_name');
        $key = 'schedule_id';
        $table = 'checklist_schedule_list';
        $data = DataTable::complex($_GET, $table, $key, $columns,' 1=1 '.$condition);
        echo json_encode($data);
    }
    public function missedChecklistScheduleData(){
        $data = $this->_registry->checklist->setData($_GET)->missedChecklistScheduleData();
        //        $html = Forms::build_missed_checklist($data);
        $html=Forms::build_table_html($data);
        die($html);
    }

    public function submitChecklist(){
        $submit = $this->_registry->checklist->setData($_POST)->submitChecklist();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage($_POST['checklist_id'] == 0 ? 'checklist_added' : 'checklist_updated'), 'success' ] : [$submit[0] == 'unable_edit_checklist' ? CommonLanguage::getMessage('unable_edit_checklist') : $submit[0], 'danger']));
    }
    public function submitChecklistSchedule(){
        $submit = $this->_registry->checklist->setData($_POST)->submitChecklistSchedule();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage($_POST['schedule_id'] == 0 ? 'checklist_schedule_added' : 'checklist_schedule_updated'), 'success' ] : [$submit[0] == 'unable_edit_checklist_schedule' ? CommonLanguage::getMessage('unable_edit_checklist_schedule') : $submit[0], 'danger']));
    } 
    public function submitLineChecklistSchedule(){
        $submit = $this->_registry->checklist->setData($_POST)->submitLineChecklistSchedule();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage('checklist_schedule_added'), 'success' ] : [$submit[0], 'danger']));
    }
    public function submitChecklistScheduleAnswers(){
        $submit = $this->_registry->checklist->setData($_POST)->submitChecklistScheduleAnswers();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage($_POST['answer_main_id'] == 0 ? 'answers_added' : 'answers_updated'), 'success' ] : [$submit[0], 'danger']));
    }
    public function deleteChecklist(){
        $delete_checklist = $this->_registry->checklist->setData($_GET)->deleteChecklist();
        die(empty($delete_checklist) ? "ok" : "error");
    }
    public function submitDefaultScheduleAnswers(){
        $submit = $this->_registry->checklist->setData($_POST)->submitDefaultScheduleAnswers();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage('answers_added' ), 'success' ] : [$submit[0], 'danger']));
    }
    public function deleteChecklistSchedule(){
        $delete_checklist_schedule = $this->_registry->checklist->setData($_GET)->deleteChecklistSchedule();
        die(empty($delete_checklist_schedule) ? "ok" : "error");
    }
    public function deleteAnswers(){
        $delete_checklist_schedule = $this->_registry->checklist->setData($_GET)->deleteAnswers();
        die(empty($delete_checklist_schedule) ? "ok" : "error");
    }
    public function getChecklistData(){
        $data['main'] = CommonFunctions::CommonView('tbl_checklist',['checklist_id'],[$_GET['checklist_id']])[0];
        $data['details'] = $this->_registry->checklist->setData($_GET)->getChecklistQuestions();
        die(json_encode($data));
    }
    public function getScheduleAnswers(){
        $data['main'] = CommonFunctions::CommonView('answer_main_list',['answer_main_id'],[$_GET['answer_main_id']])[0];
        $data['details'] = $this->_registry->checklist->setData($_GET)->getAnsweredQuestions();
        die(json_encode($data));
    }
    public function getAnswers(){
        $data = $this->_registry->checklist->setData($_GET)->getAnsweredQuestions();
        die(json_encode($data)); 
    }
    public function getChecklistScheduleData(){
        $data = CommonFunctions::CommonView('checklist_schedule_list',['schedule_id'],[$_GET['schedule_id']]);
        die(json_encode($data));
    }
    public function getScheduleQuestions(){
        $_GET['checklist_id'] = CommonFunctions::SpecificAttribute('tbl_checklist_schedule',['schedule_id'],[$_GET['schedule_id']],'checklist_id');
        $data = $this->_registry->checklist->setData($_GET)->getChecklistQuestions();
        die(json_encode($data));
    }

    public function get_product_maintenance(){
        $data = $this->_registry->product->get_product_maintenance($_GET['id']);
        die(json_encode($data));
    }
    public function machine_prop_values_ajax() {
        $columns = array('product_full_name','note','value_date_time',
                         array(
                             'db' => 'value_id',
                             'dt' => 3,
                             'formatter' => function( $d ) {
                                 $html = Forms::action_snippet(["color" => "success-dark", "isDropDown" => false,
                                                                "ActionOption" => [["title" => CommonLanguage::getMessage("Edit"),
                                                                                    "class" => "edit_value",
                                                                                    "icon" => "fa-pencil",
                                                                                    "attr" => "data-id={$d}",
                                                                                    "permission" => "edit_machine_properties_values"
                                                                                   ]
                                                                                  ]]);
                                 return $html;
                             }
                         ));
        $key = 'value_id';
        $table = 'product_property_values';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);
    }
    public function machine_expenses_ajax() {
        $columns = array(array('db' => 'ex_nb', 'dt' => 0, "formatter" => function($d, $row) {
                if ($this->controller_permission->hasPermission('delete_multi_machine_expenses')) {
                    return '<input type="checkbox" data-id="' . $row['expense_id'] . '" data-nb="' . $d . '"  class="exp_del_td pull-left multi_delete"/>' . $d;
                } else
                    return $d;
            }),'line_name','product_full_name','note','expense_date_time',
                         array(
                             'db' => 'expense_id',
                             'dt' => 5,
                             'formatter' => function( $d ) {
                                 $html = Forms::action_snippet(["color" => "success-dark", "isDropDown" => true,
                                                                "ActionOption" => [["title" => CommonLanguage::getMessage("Edit"),
                                                                                    "class" => "edit_exp",
                                                                                    "icon" => "fa-pencil",
                                                                                    "attr" => "data-id={$d}",
                                                                                    "permission" => "edit_machine_expenses"
                                                                                   ],["title" => CommonLanguage::getMessage("Delete"),
                                                                                    "class" => "delete_exp",
                                                                                    "icon" => "fa-trash",
                                                                                    "attr" => "data-id={$d}",
                                                                                    "permission" => "delete_machine_expenses"
                                                                                   ]
                                                                                  ]]);
                                 return $html;
                             }
                         ));
        $key = 'expense_id';
        $table = 'product_expenses';
        $opts = ['order'=>' expense_id desc '];
        $data = DataTable::complex($_GET, $table, $key, $columns,null,null,null,$opts);
        echo json_encode($data);
    }

    public function add_edit_property_values(){
        $insert = $this->_registry->product->setData($_POST)->add_edit_property_values();
        die(empty($insert) ? 'OK' : 'error');
    }


    public function get_property_value_by_id(){
        $data = $this->_registry->product->get_property_value_by_id($_GET['id']);
        die(json_encode($data));
    }
    public function get_product_expense_by_id(){
        $data = $this->_registry->product->get_product_expense_by_id($_GET['id']);
        die(json_encode($data));
    }
    public function add_edit_machine_expenses(){
        if($_POST['is_edit']==0){
            $insert = $this->_registry->product->setData($_POST)->add_product_expenses();
        }else{
            $insert = $this->_registry->product->setData($_POST)->edit_product_expenses($_POST['expense_id']);
        }
        die(empty($insert) ? 'OK' : 'error');
    }

    public function get_current_cost(){
        $cost = CommonBusiness::get_current_cost_by_uom($_GET['pid'],$_GET['uom']);
        die(json_encode($cost));
    }

    public function get_total_machine_expense_report() {

        $data_result = $this->_registry->product->total_product_expenses_report($_GET['date_from'],$_GET['date_to'],$_GET['currency_id'],$_GET['section_id'],$_GET['line_id']);
        //                                                                                                                                                                        echo"<pre>";
        $html = Forms::build_table_html($data_result['details']);
        die(json_encode(["html" => $html, "data" => $data_result]));
        //                                                                                                                                                                        echo json_encode(array("stock_total" => $data_result['total'], "data" => $data, "draw" => 1, "recordsFiltered" => count($data), "recordsTotal" => count($data)));
    }

    public function get_detail_machine_expense_report() {

        $data_result = $this->_registry->product->detail_product_expenses_report($_GET['date_from'],$_GET['date_to'],$_GET['machine_id'],$_GET['currency_id'],$_GET['line_id']);
        //                                                                                                                                                                        echo"<pre>";
        $html = Forms::build_table_html($data_result['details']);
        die(json_encode(["html" => $html, "data" => $data_result]));
        //                                                                                                                                                                        echo json_encode(array("stock_total" => $data_result['total'], "data" => $data, "draw" => 1, "recordsFiltered" => count($data), "recordsTotal" => count($data)));
    }
    public function submitLine() {
        $submit = $this->_registry->product->setData($_POST)->submitLine();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage('Submitted_Successfully'), 'success'] : [$submit[0], 'danger']));
    }
    public function getLineList() {
        $columns = array('line_name','machines_name',
                         array(
                             'db' => 'line_id',
                             'dt' => 2,
                             'formatter' => function( $d ) {
                                 $html = Forms::action_snippet(["color" => "success-dark", "isDropDown" => true,
                                                                "ActionOption" => [["title" => CommonLanguage::getMessage("view"),
                                                                                    "class" => "view_line",
                                                                                    "icon" => "fa-eye",
                                                                                    "permission" => "line_machines",
                                                                                    "href"=>"Maintenance/line_machines/{$d}"
                                                                                   ],["title" => CommonLanguage::getMessage("Edit"),
                                                                                      "class" => "edit_line",
                                                                                      "icon" => "fa-pencil",
                                                                                      "attr" => "data-id={$d}",
                                                                                      "data-target"=>"#add-edit-line-modal",
                                                                                      "permission" => "edit_line"
                                                                                     ],
                                                                                   ["title" => CommonLanguage::getMessage("Delete"),
                                                                                    "class" => "delete_line",
                                                                                    "icon" => "fa-trash",
                                                                                    "attr" => "data-id={$d}",
                                                                                    "permission" => "delete_line"
                                                                                   ]
                                                                                  ]]);
                                 return $html;
                             }
                         ));
        $key = 'line_id';
        $table = 'line_machines_list';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);
    }
    public function deleteLine() {
        $delete = $this->_registry->product->setData($_GET)->deleteLine();
        die(empty($delete) ? "ok" : CommonLanguage::getMessage($delete[0]));
    } 
    public function getLineData() {
        $data = $this->_registry->product->setData($_GET)->getLineData();
        die(json_encode($data));
    } 
    public function getLineMachineParts() {
        $data = $this->_registry->product->setData($_GET)->getLineMachineParts();
        die(json_encode($data));
    }
    public function production_report(){
        $cond = '';
        if (!empty($_GET['From_Date'])) {
            $cond .= ' and  date between "' . $_GET['From_Date'] . '" AND  "' . $_GET['To_Date'] . '"';
        }
        if (!empty($_GET['From_Date_Created'])) {
            $cond .= ' and  date_time between "' . $_GET['From_Date_Created'] . '" AND  "' . $_GET['To_Date_Created'] . '"';
        }
        if (!empty($_GET['category_id'])) {
            $cond .= ' AND Category_ID = "' . $_GET['category_id'] . '"';
        }
        if (!empty($_GET['production_template_id'])) {
            $cond .= ' AND template_id = "' . $_GET['production_template_id'] . '"';
        }
        if (!empty($_GET['production_type_id'])) {
            $cond .= ' AND operation = "'.$_GET['production_type_id'].'"';
        }
        $columns = array('Product_Name',
            array('db'=>!empty($_GET['is_group_by']) ? 'SUM(current_quantity)' :'current_quantity',
                'formatter'=>function($d){
                return CommonFunctions::formatNumber($d);
            }),
            'UOM_Name');
        $group = !empty($_GET['is_group_by']) ? 'group by Product_ID,UOM_ID' : '';
        
       // echo $cond;exit;
        
        $key = 'process_detail_id';
        $table = 'production_process_details';
        $data = DataTable::complex($_GET, $table, $key, $columns,' 1=1 '.$cond,null,$group);
        echo json_encode($data);

    }
    public function submitProductionEmployeeTypes() {
        $submit = $this->_registry->production->setData($_POST)->submitProductionEmployeeTypes();
        die(json_encode(empty($submit) ? [CommonLanguage::getMessage('Submitted_Successfully'), 'success'] : [$submit[0], 'danger']));
    }
     public function deleteProductionEmpType() {
        $delete = $this->_registry->production->setData($_GET)->deleteProductionEmpType();
        die(empty($delete) ? "ok" : $error[0]);
    }
    public function production_emp_type_list() {
        $columns = array('type_name',
                         array(
                             'db' => 'type_id',
                             'dt' => 1,
                             'formatter' => function( $d,$row ) {
                                 $html = Forms::action_snippet(["color" => "success-dark",
                                                                "isDropDown" => true,
                                                                "data_id" => $d,
                                                                "ActionOption" => [
                                                                    ["title" => CommonLanguage::getMessage("Edit"),
                                                                     'data-target' => '#production_employee_type_modal',
                                                                     "class" => "edit",
                                                                     "icon" => "fa-pencil",
                                                                     "permission"=>"edit_production_emp_type"
                                                                    ],
                                                                    ["title" => CommonLanguage::getMessage("delete"),
                                                                     "class" => "delete",
                                                                     "icon" => "fa-trash",
                                                                     "permission"=>"delete_production_emp_type"
                                                                    ]
                                                                ]]);
                                 return $html;
                             })
                        );
        $key = 'type_id';
        $table = 'tbl_production_emp_types';
        $data = DataTable::complex($_GET, $table, $key, $columns);
        echo json_encode($data);
    }
    public function production_process_template_report() {
        $_GET['template_arr'] = array();
        $query = $this->db->query('select * from tbl_production_template_details  where operation="-"');
        while($row = $this->db->assoc($query)){
            $_GET['template_arr'][$row['template_id']][$row['Product_ID']] = $row;
        }
        $_GET['template_names_arr'] = array();
        $query = $this->db->query('select * from tbl_production_template ');
        while($row = $this->db->assoc($query)){
            $_GET['template_names_arr'][$row['template_id']]=$row['template_name'];
        }
        $cond = ' operation="-" ';
        if(!empty($_GET['From_Date']) && !empty($_GET['To_Date']))
            $cond.=' and date between "'.$_GET['From_Date'].'" and "'.$_GET['To_Date'].'" ';
        if(!empty($_GET['production_template_id']) )
            $cond.=' and template_id = "'.$_GET['production_template_id'].'"  ';
        if(!empty($_GET['category_id']) )
            $cond.=' and Category_ID = "'.$_GET['category_id'].'"  ';
//        echo"<pre>";
//        die(print_r($_GET['template_arr']));
        $columns = array(
            array('db'=>'process_id','formatter'=>function($d,$row){
                return '<span data-id="'.$d.'">'.$_GET['template_names_arr'][$row['template_id']].'</span>';
            }),'date','process_quantity','Product_Name',
            array('db'=>'current_quantity','formatter'=>function($d,$row){
                return CommonFunctions::formatNumber($d*$row['process_quantity']).' '.$row['UOM_Name'];
            }),
            array('db'=>'current_quantity','formatter'=>function($d,$row){
                $temp_qty =  0;
                if(!empty($_GET['template_arr'][$row['template_id']][$row['Product_ID']]))
                    $temp_qty = $_GET['template_arr'][$row['template_id']][$row['Product_ID']]['current_quantity'];
                return CommonFunctions::formatNumber($temp_qty*$row['process_quantity']).' '.$row['UOM_Name'];
            }),
            array('db'=>'current_quantity','formatter'=>function($d,$row){
                $temp_qty =  0;
                if(!empty($_GET['template_arr'][$row['template_id']][$row['Product_ID']]))
                    $temp_qty = $_GET['template_arr'][$row['template_id']][$row['Product_ID']]['current_quantity'];
                return CommonFunctions::formatNumber(($d-$temp_qty)*$row['process_quantity']).' '.$row['UOM_Name'];
            }),'UOM_Name','template_id','Product_ID','process_quantity'
                         
                        );
        $key = 'process_detail_id';
        $table = 'production_process_details';
        $data = DataTable::complex($_GET, $table, $key, $columns,$cond);
        echo json_encode($data);
    }
        public function delete_product_expense(){
        $delete = $this->_registry->product->delete_product_expense($_GET['ids']);
        die(empty($delete) ? 'ok' : $delete[0]);
    }
        public function delete_production_template(){
        $delete = $this->_registry->production->delete_production_template($_GET['id']);
        die(empty($delete) ? 'ok' : $delete[0]);
    }
    
    public function get_production_templates(){
        $data = $this->_registry->production->get_production_templates($_GET['id']);
        die(json_encode($data));
    }
    public function get_production_categories(){
        $data = $this->_registry->production->get_production_categories();
        die(json_encode($data));
    }
    
    public function get_group_temp_products(){
        $data = $this->_registry->production->setData($_GET)->get_group_temp_products();
        die(json_encode($data));
    }
}