MOON
Server: Apache
System: Linux nserver.cafsindia.com 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: cafsindia (1002)
PHP: 8.2.30
Disabled: NONE
Upload Files
File: //home/cafsindia/allyindian_com/sbltt/application/controllers/Package.php
<?php if ( ! defined('BASEPATH')) exit('No direct script is allowed');
require_once("Secure_Controller.php");
class package  extends Secure_Controller
{
 
	public function __construct()
	{
		parent::__construct('package');
		$this->load->model('Package_model');
		$this->load->model('Sms_model');
		$this->load->model('Customer');
	}
	public function index()
	{
		if(!$this->Appconfig->isAppvalid())
		{
			redirect('config');
		}
		$data['table_headers']=$this->xss_clean(get_package_headers());
		$this->load->view('package/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');
		$filters = array('start_date' => $this->input->get('start_date'),'end_date' => $this->input->get('end_date'));
		
		$booking=$this->Package_model->search($search,$filters,$limit,$offset,$sort,$order);
		$TotalRows=$this->Package_model->get_found_rows($search,$filters);
		$DataRows=array();
		foreach ($booking->result() as $person){	
			$DataRows[]=get_package_datarows($person,$this);
		}
		$DataRows=$this->xss_clean($DataRows);
		echo json_encode(array('total'=>$TotalRows,'rows'=>$DataRows));
	}

	public function view($package_id=-1){
		$info=$this->Package_model->get_info($package_id);
		foreach (get_object_vars($info) as $property => $value){
			$info->$property = $this->xss_clean($value);
		}
		$data['package']=$info;      

		$this->load->view("package/form",$data);
	}

	public function add_package($package_id=-1){
		$info=$this->Package_model->get_info($package_id);
		foreach (get_object_vars($info) as $property => $value){
			$info->$property = $this->xss_clean($value);
		}
		$data['package']=$info;      
		$data['package_line'] = $this->Package_model->package_line_list($package_id);
		$state_info[""] = "--Select State--";
		foreach($this->Package_model->get_state()->result_array() as $row){
		    $state_info[$this->xss_clean($row['state_code'])] = $this->xss_clean($row['state_name']);
		}
		$data['state_info'] = $state_info;
		$this->load->view("package/add_package",$data);
	}
	public function save_package_line($package_id){
		$mobile = $this->input->post('phone_number');
		$customer_data = array(
			'customer_name'  => $this->input->post('customer_name'),
			'phone_number'   => $this->input->post('phone_number'),
			'alt_number'     => $this->input->post('alt_number'),
			'land_line'      => $this->input->post('land_line'),
			'cust_email'     => $this->input->post('email'),
			'cust_address'   => $this->input->post('cust_address'),
			'city'           => $this->input->post('city'),
			'state'          => $this->input->post('state'),
			'dob'            => date('Y-m-d',strtotime($this->input->post('dob'))),
			//'cust_type'      => "4",
			'created_by'     => $this->session->userdata('emp_id'),
			'created_date'   => date("Y-m-d h:i:s"),
		);
		$cust_id = $this->Customer->lead_save_customer($customer_data, $mobile);
		
		$package_id      = $this->input->post('package_id');
		$package_line_id = $this->input->post('package_line_id');
		$package_data = array(
			'package_id'        => $this->input->post('package_id'),
			'cust_id'           => $cust_id,
			'pickup_point'      => $this->input->post('pickup_point'),
			'amount'            => $this->input->post('amount'),
			'discount'          => $this->input->post('discount'),
			'balance'           => $this->input->post('balance'),
			'pnr'               => $this->input->post('pnr'),
			'seat_no'           => $this->input->post('seat_no'),
			'sourcing'          => $this->input->post('sourcing'),
			'payment_type'      => $this->input->post('payment_type'),
			'enquiry_sts'       => $this->input->post('enquiry_sts'),
			'feedback'          => $this->input->post('feedback'),
			'driving_driver'    => $this->input->post('driving_driver'),
			'feed_vehicle'      => $this->input->post('feed_vehicle'),
			'feed_food'         => $this->input->post('feed_food'),
			'feed_accomodation' => $this->input->post('feed_accomodation'),
			'feed_overall'      => $this->input->post('feed_overall'),
			'remark'            => $this->input->post('remark'),
			'created_by'        => $this->session->userdata('emp_id'),
			'created_date'      => date("Y-m-d h:i:s"),
		);
		if($this->Package_model->save_package_line($package_data,$package_line_id)){
			$package_line_info = $this->Package_model->package_line_list($package_id);
			echo json_encode(array('success' => TRUE, 'package_line_info' =>$package_line_info));
			if($this->input->post('enquiry_sts') === "2"){
				if($mobile){
					$this->Sms_model->send_sms($package_line_id,$mobile,"package_enquiry");
				}
			}
		}else{
			echo "Unable process your request";
		}
	}
	public function get_pack_line(){
		$package_line_id    = $this->input->post('package_line_id');		
		$package_line_info  = $this->Package_model->get_pack_line($package_line_id);		
		echo json_encode(array('success' => TRUE, 'package_line_info' => $package_line_info));
	}
	/*
	Inserts/updates a package
	*/
	public function save($package_id = -1){
		$package_data = array(
			'package_id'      => $this->input->post('package_id'),
			'package_name'    => $this->input->post('package_name'),
			'from_date'         => date('Y-m-d',strtotime($this->input->post('from_date'))),
			'to_date'           => date('Y-m-d',strtotime($this->input->post('to_date'))),
			'trip_days'       => $this->input->post('trip_days'),
			'bus_count'       => $this->input->post('bus_count'),
			'person_count'    => $this->input->post('person_count'),
			'gurusamy_name'    => $this->input->post('gurusamy_name'),
			'catering_name'    => $this->input->post('catering_name'),
			'coordinator_one'    => $this->input->post('coordinator_one'),
			'coordinator_two'    => $this->input->post('coordinator_two'),
			'coordinator_three'    => $this->input->post('coordinator_three'),
			'package_sts'     => $this->input->post('package_sts'),
			'package_remarks' => $this->input->post('package_remarks'),
			'created_by'     => $this->session->userdata('emp_id'),
			'created_date'   => date("Y-m-d h:i:s"),
		);

		if($this->Package_model->save_package($package_data, $package_id)){
			$package_data = $this->xss_clean($package_data);
			if($package_id == -1){
				echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('package_successful_adding').' '.
								$package_data['package_name'], 'id' => $package_data['package_id']));
			}else {
				echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('package_successful_updating').' '.
								$package_data['package_name'], 'id' => $package_id));
			}
		}else{
			$package_data = $this->xss_clean($package_data);
			echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('package_error_adding_updating').' '.
							$package_data['package_name'], 'id' => -1));
		}

	}

	public function get_row($package_ids)
	{
		$package_infos = $this->Package_model->get_multiple_info($package_ids);

		$result = array();
		foreach($package_infos as $item_info)
		{
			$result[$item_info->package_id] = $this->xss_clean(get_item_data_row($item_info, $this));
		}

		echo json_encode($result);
	}
	public function date_difference(){
		$from_date = date("Y-m-d", strtotime($this->input->post('from_date')));
		$to_date   = date("Y-m-d", strtotime($this->input->post('to_date')));
		
		$diff = abs(strtotime($to_date) - strtotime($from_date));
		$years = floor($diff / (365*60*60*24));
		$months = floor(($diff - $years * 365*60*60*24) / (30*60*60*24));
		$days = floor(($diff - $years * 365*60*60*24 - $months*30*60*60*24)/ (60*60*24));
		$days = $days +1;
		echo "$days";
	}
	public function suggest_customer(){
		$suggestions = $this->xss_clean($this->Package_model->get_customer_suggestions($this->input->post('term')));
		echo json_encode(array('success' => TRUE, 'search' => $suggestions));
	}
	public function get_customer(){
		$suggestions = $this->xss_clean($this->Package_model->get_customer_info($this->input->post('term')));
		echo json_encode(array('success' => TRUE, 'search' => $suggestions));
	}
	public function delete(){
		$package_to_delete = $this->xss_clean($this->input->post('ids'));

		if($this->Package_model->delete_list($package_to_delete))
		{
			echo json_encode(array('success' => TRUE, 'message' => $this->lang->line('package_successful_deleted').' '.
							count($package_to_delete).' '.$this->lang->line('package_one_or_multiple')));
		}
		else
		{
			echo json_encode(array('success' => FALSE, 'message' => $this->lang->line('package_cannot_be_deleted')));
		}
	}
}
?>