RecordController.php 4.4 KB
<?php namespace App\Http\Controllers;

use Auth;
use Input;
use Response;
use App\Models\Notification;
use App\Jobs\KHRMSLib;
use DB;


class RecordController extends Controller {


	public function __construct()
	{
	  $this->middleware('auth');
	  $this->middleware('module_access');
	}

	public function index()
	{
	  return view('layout.module.record.index',array());
	}
	public function create()
	{
		//
	}
	public function store()
	{
		$data=array();
		$data['wakka'] = new KHRMSLib();
		$action=Input::get("action");
		$client=Input::get("client");
		$data['wakka']->HRFillNames($client);
		if($action=="show")
		{
			return view('layout.module.record.show',$data);
		}
		if($action=="save")
		{
			return view('layout.module.record.save',$data);
		}
		if($action=="quicksearch")
		{
			return view('layout.module.record.quicksearch',$data);
		}
		if($action=="textsearch")
		{
			return view('layout.module.record.textsearch',$data);
		}
		if($action=="addkey")
		{
			$wakka = new KHRMSLib();

			$varid=Input::get("varid");
			$keys=explode(",",Input::get("keys"));
			$record=$wakka->getPerson($varid);
			if(!empty($keys))foreach($keys as $key)
			{
				$val=Input::get($key);
				$record["peopledata"][$key]=$val;
			}
			
			$wakka->setPerson($varid,$record);
			
			return Response::make("");
		}
		if($action=="delaltphone")
		{
			$wakka = new KHRMSLib();
			
			$varid=Input::get("varid");
			$i=Input::get("i");
			
			$record=$wakka->getPerson($varid);
			for($k=$i+1;$k<=10;$k++,$i++)
			{
				$record["peopledata"]["altphone$i"]=$record["peopledata"]["altphone$k"];
				$record["peopledata"]["altphone_lbl_$i"]=$record["peopledata"]["altphone_lbl_$k"];
			}
			$record["peopledata"]["altphone10"]="";
			$record["peopledata"]["altphone_lbl_10"]="";
			
			$wakka->setPerson($varid,$record);
		}
		if($action=="bulkupload")
		{
			return view('layout.module.record.bulkupload',$data);
		}
		if($action=="Appointment")
		{
			$wakka = new KHRMSLib();

			$CustomerName=Input::get("CustomerName");
			$AppntLocation=Input::get("AppntLocation");
			$AppntTime=Input::get("AppntTime");
			$Address=Input::get("Address");
			$AppntDate=Input::get("AppntDate");
			$ContactPerson=Input::get("ContactPerson");
			$Phone=Input::get("Phone");

			$AppntDate=date("d-M-Y",strtotime($AppntDate));
			$h = $AppntTime;
			$hm = $h * 60;
			$ms = $hm * 60;
			$AppntTime=gmdate("g A",$ms);

			$smsapi="http://115.114.132.71/servlet/com.aclwireless.pushconnectivity.listeners.TextListener?userId=idcamps&pass=pacamps1&contenttype=1&from=HEROFC&selfid=true&alert=1&dlrreq=true";

			$MsgContent="Dear $CustomerName, Your appointment is fixed at $AppntLocation. Appointment Date - $AppntDate, Time - $AppntTime. Address: $Address Contact Person - $ContactPerson. In case of any assistence Please give a missed call. $Tollfree";
			$EnMsgContent=urlencode($MsgContent);
			$smsurl=$smsapi."&to=".$Phone."&text=".$EnMsgContent;
			
			$MessageID=$wakka->get_response($smsurl);
			
			if($MessageID)
			print $MessageID;
			else
			print "Failed";
			//echo $CustomerName . ' = ' . $AppntLocation . ' = ' . $AppntTime . ' = ' . $Address . ' = ' . $AppntDate . ' = ' . $ContactPerson;			
		}
	}
	public function show($id)
	{
		$data=array();
		$data['wakka'] = new KHRMSLib();
		if($id=="bulkupload")
		{
			return view('layout.module.record.bulkupload',$data);
		}
		if($id=="textsearch")
		{
			return view('layout.module.record.textsearch',$data);
		}
	}
	public function edit($id)
	{
		//
	}
	public function update($id)
	{
		//
	}
	public function destroy($id)
	{

	}


	public function dashboard()
	{
		//echo "OK";
	}

	public function churnData()
	{
		$data=array();
		$wakka = new KHRMSLib();

		$listVal = DB::table('currentqueue_list')->get();

		$rclientlst=$wakka->clientsReadAccess();

		$data['listVal'] = $listVal;
		$data['cntlistVal'] = count($listVal);
		$data['rclientlst'] = $rclientlst;

		return view('layout.module.record.churn',$data);	
	}

	public function saveChurnData()
	{
		$user_agent=Input::get('agent');
		$data = $_POST['data'];

		$exitAgent = DB::table('cq_logic')->where('user_agent','=',$user_agent)->first();

		if($exitAgent)
		{
			DB::update("update cq_logic set updated_at='".date("Y-m-d H:i:s")."', data='".$data."' where user_agent='".$user_agent."'");
		}
		else
		{
			DB::statement("insert into cq_logic set created_at='".date("Y-m-d H:i:s")."', updated_at='".date("Y-m-d H:i:s")."', user_agent='".$user_agent."', data='".$data."'");
		}

		return ;
	}

}