File: //home/cafsindia/allyindian_com/sbltt/application/controllers/Trip_type.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class Trip_type extends Secure_Controller
{
public function __construct()
{
parent::__construct('trip_type');
$this->load->model('Trip_type_model');
}
public function index()
{
if(!$this->Appconfig->isAppvalid())
{
redirect('config');
}
$data['table_headers']=$this->xss_clean(get_trip_type_headers());
$this->load->view('trip_type/manage',$data);
}
public function search()
{
$search=$this->input->get('search');
$limit=$this->input->get('limit');
$offset=$this->input->get('offset');
$sort=$this->input->get('sort');
$order=$this->input->get('order');
$trip_type=$this->Trip_type_model->search($search,$limit,$offset,$sort,$order);
$TotalRows=$this->Trip_type_model->get_found_rows($search);
$DataRows=array();
foreach ($trip_type->result() as $person)
{
$DataRows[]=get_trip_type_datarows($person,$this);
}
$DataRows=$this->xss_clean($DataRows);
echo json_encode(array('total'=>$TotalRows,'rows'=>$DataRows));
}
public function view($trip_type_id=-1)
{
$info=$this->Trip_type_model->get_info($trip_type_id);
foreach (get_object_vars($info) as $property => $value)
{
$info->$property = $this->xss_clean($value);
}
$data['trip_type']=$info;
$this->load->view("trip_type/form",$data);
}
public function save($trip_type_id = -1)
{
$trip_type_data = array(
'trip_type_id' => $this->input->post('trip_type_id'),
'trip_basis' => $this->input->post('trip_basis'),
'trip_type_name' => $this->input->post('trip_type_name'),
'created_by' => $this->session->userdata('emp_id'),
'created_date' => date("Y-m-d h:i:s"),
);
if($this->Trip_type_model->save_trip_type($trip_type_data, $trip_type_id)){
$trip_type_data = $this->xss_clean($trip_type_data);
//New trip_type
if($trip_type_id == -1)
{
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('trip_type_successful_adding').' '.
$trip_type_data['trip_type_name'], 'id' => $trip_type_data['trip_type_id']));
}else {
//Existing trip_types
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('trip_type_successful_updating').' '.
$trip_type_data['trip_type_name'], 'id' => $trip_type_id));
}
}else{
//failure
$trip_type_data = $this->xss_clean($trip_type_data);
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('trip_type_error_adding_updating').' '.
$trip_type_data['trip_type_name'], 'id' => -1));
}
}
public function get_row($trip_type_ids)
{
$trip_type_infos = $this->Trip_type_model->get_multiple_info($trip_type_ids);
$result = array();
foreach($trip_type_infos as $item_info)
{
$result[$item_info->trip_type_id] = $this->xss_clean(get_item_data_row($item_info, $this));
}
echo json_encode($result);
}
public function delete(){
$trip_type_to_delete = $this->xss_clean($this->input->post('ids'));
if($this->Trip_type_model->delete_list($trip_type_to_delete))
{
echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('trip_type_successful_deleted').' '.
count($trip_type_to_delete).' '.$this->lang->line('trip_type_one_or_multiple')));
}
else
{
echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('trip_type_cannot_be_deleted')));
}
}
}
?>