File: //home/cafsindia/allyindian_com/sbltt/app/mobile_api.php
<?php
$frm = "";
if(isset($_POST["frm"])){
$frm = $_POST['frm'];
require ("./mobileapi_model.php");
$api_model = new mobileapi_model;
}
if($frm === "login"){
$user_name = "";
if(isset($_POST["user_name"])) {
$user_name = $_POST['user_name'];
}
$password = "";
if(isset($_POST["password"])) {
$password = $_POST['password'];
$password = md5($password);
}
$login = $api_model->login($user_name,$password);
return_rslt($frm,$login);
}else
if($frm === "city"){
$city = $api_model->city();
return_rslt($frm,$city);
}else
if($frm === "state"){
$state = $api_model->state();
return_rslt($frm,$state);
}else
if($frm === "days_count"){
$from_date = "";
if(isset($_POST["from_date"])) {
$from_date = date("Y-m-d", strtotime($_POST['from_date']));
}
$to_date = "";
if(isset($_POST["to_date"])) {
$to_date = date("Y-m-d", strtotime($_POST['to_date']));
}
$days_count = $api_model->days_count($from_date,$to_date);
return_rslt($frm,$days_count);
}else
if($frm === "status_list"){
$status_list = array('1'=>"Follow Up",'2'=>"Confirm",'3'=>"Cancelled");
return_rslt($frm,$status_list);
}else
if($frm === "prospect_list"){
$prospect_list = array('1'=>"Hot",'2'=>"Warm",'3'=>"Dropped");
return_rslt($frm,$prospect_list);
}else
if($frm === "referral_type"){
$referral_type = array('Direct'=>"Direct",'Walkin_Customer'=>"Walkin Customer",'Staff'=>"Staff",'Driver'=>"Driver",'Vehicle'=>"Vehicle",'Web_Portal'=>"Web Portal",'Advertisement'=>"Advertisement");
return_rslt($frm,$referral_type);
}else
if($frm === "booking_type"){
$booking_type = $api_model->booking_type();
return_rslt($frm,$booking_type);
}else
if($frm === "customer_list"){
$cust_id = "";
if(isset($_POST["cust_id"])) {
$cust_id = $_POST['cust_id'];
}
$search = "";
if(isset($_POST["search"])) {
$search = $_POST['search'];
}
$customer_list = $api_model->customer_list($cust_id,$search);
return_rslt($frm,$customer_list);
}else
if($frm === "employees_role"){
$employees_list = $api_model->employees_role();
return_rslt($frm,$employees_list);
}else
if($frm === "employees_list"){
$emp_id = "";
if(isset($_POST["emp_id"])) {
$emp_id = $_POST['emp_id'];
}
$role = "";
if(isset($_POST["role"])) {
$role = $_POST['role'];
}
$employees_list = $api_model->employees_list($emp_id,$role);
return_rslt($frm,$employees_list);
}else
if($frm === "trip_type"){
$trip_type = $api_model->trip_type();
return_rslt($frm,$trip_type);
}else
if($frm === "vehicle_type"){
$vehicle_type = $api_model->vehicle_type();
return_rslt($frm,$vehicle_type);
}else
if($frm === "vehicle_list"){
$vehicle_id = "";
if(isset($_POST["vehicle_id"])) {
$vehicle_id = $_POST['vehicle_id'];
}
$vehicle_type = "";
if(isset($_POST["vehicle_type"])) {
$vehicle_type = $_POST['vehicle_type'];
}
$vehicle_list = $api_model->vehicle_list($vehicle_id,$vehicle_type);
return_rslt($frm,$vehicle_list);
}else
if($frm === "average_km"){
$orgin = "";
if(isset($_POST["orgin"])) {
$orgin = $_POST['orgin'];
}
$destination = "";
if(isset($_POST["destination"])) {
$destination = $_POST['destination'];
}
$average_km = $api_model->average_km($orgin,$destination);
return_rslt($frm,$average_km);
}else
if($frm === "get_tariff"){
$trip_type = "";
if(isset($_POST["trip_type"])) {
$trip_type = $_POST['trip_type'];
}
$vehicle_type = "";
if(isset($_POST["vehicle_type"])) {
$vehicle_type = $_POST['vehicle_type'];
}
$get_tariff = $api_model->get_tariff($trip_type,$vehicle_type);
return_rslt($frm,$get_tariff);
}else
if($frm === "enquiry_list"){
$emp_id = "";
if(isset($_POST["emp_id"])) {
$emp_id = $_POST['emp_id'];
}
$role = "";
if(isset($_POST["role"])) {
$role = $_POST['role'];
}
$from_date = "";
if(isset($_POST["from_date"])) {
$from_date = date("Y-m-d", strtotime($_POST['from_date']));
}
$to_date = "";
if(isset($_POST["to_date"])) {
$to_date = date("Y-m-d", strtotime($_POST['to_date']));
}
$enquiry_sts = "";
if(isset($_POST["enquiry_sts"])) {
$enquiry_sts = $_POST['enquiry_sts'];
}
$enquiry_list = $api_model->enquiry_list($emp_id,$role,$from_date,$to_date,$enquiry_sts);
return_rslt($frm,$enquiry_list);
}else
if($frm === "enquiry_add"){
/*
$emp_id = "";
if(isset($_POST["emp_id"])) {
$emp_id = $_POST['emp_id'];
}
$role = "";
if(isset($_POST["role"])) {
$role = $_POST['role'];
}
$from_date = "";
if(isset($_POST["from_date"])) {
$from_date = date("Y-m-d", strtotime($_POST['from_date']));
}
$to_date = "";
if(isset($_POST["to_date"])) {
$to_date = date("Y-m-d", strtotime($_POST['to_date']));
}
$enquiry_sts = "";
if(isset($_POST["enquiry_sts"])) {
$enquiry_sts = $_POST['enquiry_sts'];
}
*/
$enquiry_add = $api_model->enquiry_add();
return_rslt($frm,$enquiry_add);
}else{
echo json_encode(array('success' => False, 'sts' =>"Invalid Request"));
}
function return_rslt($frm,$rslt){
$rslt_count = count($rslt);
if($rslt_count === 0){
echo json_encode(array('success' => FALSE, 'sts' =>"No Record found"));
}else{
echo json_encode(array('success' => TRUE, "$frm" => $rslt));
}
}
?>