File: /home/cafsindia/ntc_cafsinfotech_in/application/controllers/Maintenance_tool_inspection_report.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Action_controller.php");
class Maintenance_tool_inspection_report extends Action_controller{
public function __construct(){
parent::__construct('maintenance_tool_inspection_report');
$this->collect_base_info();
}
// LOAD PAGE QUICK LINK,FILTERS AND TABLE HEADERS
public function index(){
$this->load->view("$this->control_name/manage");
}
//LOAD TABEL WITH FILTERS
public function check_log_details(){
$start_date = str_replace("/","-",$this->input->post('start_date'));
$end_date = str_replace("/","-",$this->input->post('end_date'));
$from_date = date('Y-m-d',strtotime($start_date));
$to_date = date('Y-m-d',strtotime($end_date));
$this->db->select('*');
$this->db->from('cw_equipment_tools_and_equipment_inspection_information');
$this->db->join('cw_equipment_tools_and_equipment', 'cw_equipment_tools_and_equipment.prime_equipment_tools_and_equipment_id = cw_equipment_tools_and_equipment_inspection_information.prime_equipment_tools_and_equipment_id','left');
$this->db->where('test_date >=',$from_date);
$this->db->where('due_date <=',$to_date);
$get_data_rslt = $this->db->get()->result();
$tr_line = "";
foreach ($get_data_rslt as $key => $value){
if($value->test_date !="1970-01-01")
{
$test_date = date("d.m.Y", strtotime($value->test_date));
}
else {
$test_date = "NULL";
}
if($value->due_date !="1970-01-01")
{
$due_date = date("d.m.Y", strtotime($value->due_date));
}
else{
$due_date = "NULL";
}
$tr_line .="<tr>
<td>".$test_date = $test_date."</td>
<td>".$due_date = $due_date."</td>
<td>".$equipment_name = $value->equipment_name."</td>
<td>".$current_condition = $value->current_condition."</td>
</tr>";
}
if($get_data_rslt){
$table_content = "<div style='margin:20px;'>
<table class='table table-striped table-bordered' id='trip_report'>
<thead>
<tr>
<td>TEST DATE</td>
<td>DUE DATE</td>
<td>NAME OF TOOL</td>
<td>CONDITION SINCE LAST INSPECTION</td>
</tr>
</thead>
<tbody>
$tr_line
</tbody>
</table>
</div>";
echo json_encode(array('success'=>true,'table_content'=>$table_content));
}else{
echo json_encode(array('success'=>false,'message'=>'NO DATA AVAILABLE','table_content'=>$table_content));
}
}
}
?>