public function index()
{
if (! $this->input->is_ajax_request())
{ show_404(); }
$category = $this->input->post('id');
$firmware = $this->Firmware_model->get_select_firmware($category);
$json = [];
foreach($firmware as $rows){
$prod_id = $rows->prod_id;
$firmware_count = $this->General_model->get_count_where(
['prod_id' => $prod_id],
$this->tbl_firmware
);
$check_rows = ($firmware_count > 1 && $prod_id != 0) ? '1' : '0';
$product = $this->General_model->get_select_rows(
["prod_id" => $prod_id],
'tbl_product'
);
$image = '';
if(count($product) > 0 && $product != ''){
foreach($product as $prod)
{ $image = $prod->prod_image;}
}
$json1 = [
'firmware_id' => $rows->fm_id,
'firmware_name' => htmlspecialchars($rows->fm_name,ENT_QUOTES,'UTF-8'),
'firmware_url' => htmlspecialchars($rows->fm_url,ENT_QUOTES,'UTF-8'),
'firmware_size' => htmlspecialchars($rows->fm_size,ENT_QUOTES,'UTF-8'),
'firmware_version' => htmlspecialchars($rows->fm_version,ENT_QUOTES,'UTF-8'),
'firmware_build' => htmlspecialchars($rows->fm_build,ENT_QUOTES,'UTF-8'),
'modify_date' => $rows->modify_date,
'prod_id' => $prod_id,
'firmware_rows' => $check_rows,
'category_id' => $rows->category_id,
'image' => $image
];
$json[] = $json1;
}
$this->output
->set_content_type('application/json') //set Json header
->set_output(json_encode($json, JSON_UNESCAPED_UNICODE));
}
public function firmware_report()
{
if (!$this->input->is_ajax_request())
{ show_404(); }
$id = $this->input->post('id');
$data = [
'fm_id' => $id,
'fr_phone' => $this->input->post('phone'),
'fr_comment' => $this->input->post('comment'),
'fr_date' => $this->General_model->_my_date_now()
];
if(!$this->General_model->general_insert(
$data,
$this->tbl_firmware_report)
){
show_404();
} else {
if($this->General_model->general_update(
['fm_status' => 1],
['fm_id' => $id],
$this->tbl_firmware)
){
$error = array('error' => "Thank for helping us detect the error!!!");
$this->session->set_flashdata('show', '0');
} else {
$error = array('error' => 'Opp something wrong request cancel.');
$this->session->set_flashdata('show', '1');
}
}
}