Guest User

Untitled

a guest
Jul 7th, 2017
26
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.04 KB | None | 0 0
  1. <?php namespace App\Http\Controllers;
  2.  
  3. use Auth;
  4. use Input;
  5. use Response;
  6. use App\Models\Notification;
  7. use App\Jobs\KHRMSLib;
  8. use DB;
  9. use Request;
  10. use App\Models\User;
  11.  
  12. class RecordController extends Controller {
  13.  
  14.  
  15. public function __construct()
  16. {
  17. $this->middleware('auth');
  18. $this->middleware('module_access');
  19. }
  20.  
  21. public function index()
  22. {
  23. return view('layout.module.record.index',array());
  24. }
  25. public function create()
  26. {
  27. //
  28. }
  29. public function store()
  30. {
  31. $data=array();
  32. $data['wakka'] = new KHRMSLib();
  33. $action=Input::get("action");
  34. $client=Input::get("client");
  35. $data['wakka']->HRFillNames($client);
  36. if($action=="show")
  37. {
  38. return view('layout.module.record.show',$data);
  39. }
  40. if($action=="save")
  41. {
  42. return view('layout.module.record.save',$data);
  43. }
  44. if($action=="quicksearch")
  45. {
  46. return view('layout.module.record.quicksearch',$data);
  47. }
  48. if($action=="textsearch")
  49. {
  50. return view('layout.module.record.textsearch',$data);
  51. }
  52. if($action=="addkey")
  53. {
  54. $wakka = new KHRMSLib();
  55.  
  56. $varid=Input::get("varid");
  57. $keys=explode(",",Input::get("keys"));
  58. $record=$wakka->getPerson($varid);
  59. if(!empty($keys))foreach($keys as $key)
  60. {
  61. $val=Input::get($key);
  62. $record["peopledata"][$key]=$val;
  63. }
  64.  
  65. $wakka->setPerson($varid,$record);
  66.  
  67. return Response::make("");
  68. }
  69. if($action=="delaltphone")
  70. {
  71. $wakka = new KHRMSLib();
  72.  
  73. $varid=Input::get("varid");
  74. $i=Input::get("i");
  75.  
  76. $record=$wakka->getPerson($varid);
  77. for($k=$i+1;$k<=10;$k++,$i++)
  78. {
  79. $record["peopledata"]["altphone$i"]=$record["peopledata"]["altphone$k"];
  80. $record["peopledata"]["altphone_lbl_$i"]=$record["peopledata"]["altphone_lbl_$k"];
  81. }
  82. $record["peopledata"]["altphone10"]="";
  83. $record["peopledata"]["altphone_lbl_10"]="";
  84.  
  85. $wakka->setPerson($varid,$record);
  86. }
  87. if($action=="bulkupload")
  88. {
  89. return view('layout.module.record.bulkupload',$data);
  90. }
  91. if($action=="Appointment")
  92. {
  93. $wakka = new KHRMSLib();
  94.  
  95. $CustomerName=Input::get("CustomerName");
  96. $AppntLocation=Input::get("AppntLocation");
  97. $AppntTime=Input::get("AppntTime");
  98. $Address=Input::get("Address");
  99. $AppntDate=Input::get("AppntDate");
  100. $ContactPerson=Input::get("ContactPerson");
  101. $Phone=Input::get("Phone");
  102.  
  103. $AppntDate=date("d-M-Y",strtotime($AppntDate));
  104. $h = $AppntTime;
  105. $hm = $h * 60;
  106. $ms = $hm * 60;
  107. $AppntTime=gmdate("g A",$ms);
  108.  
  109. $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";
  110.  
  111. $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";
  112. $EnMsgContent=urlencode($MsgContent);
  113. $smsurl=$smsapi."&to=".$Phone."&text=".$EnMsgContent;
  114.  
  115. $MessageID=$wakka->get_response($smsurl);
  116.  
  117. if($MessageID)
  118. print $MessageID;
  119. else
  120. print "Failed";
  121. //echo $CustomerName . ' = ' . $AppntLocation . ' = ' . $AppntTime . ' = ' . $Address . ' = ' . $AppntDate . ' = ' . $ContactPerson;
  122. }
  123. }
  124. public function show($id)
  125. {
  126. $data=array();
  127. $data['wakka'] = new KHRMSLib();
  128. if($id=="bulkupload")
  129. {
  130. return view('layout.module.record.bulkupload',$data);
  131. }
  132. if($id=="textsearch")
  133. {
  134. return view('layout.module.record.textsearch',$data);
  135. }
  136. }
  137. public function edit($id)
  138. {
  139. //
  140. }
  141. public function update($id)
  142. {
  143. //
  144. }
  145. public function destroy($id)
  146. {
  147.  
  148. }
  149.  
  150.  
  151. public function dashboard()
  152. {
  153. //echo "OK";
  154. }
  155.  
  156. public function churnData()
  157. {
  158. $data=array();
  159. $wakka = new KHRMSLib();
  160.  
  161. $useType = array("CRO");
  162. $ulist = User::whereIn('usertype',$useType)->get();
  163.  
  164. $listVal = DB::table('currentqueue_list')->first();
  165. $holdVal = DB::table('cq_logic')->where('type','=','hold')->where('status','=','Held')->get();
  166.  
  167. $rclientlst=$wakka->clientsReadAccess();
  168.  
  169. $data['listVal'] = $listVal;
  170. $data['cntlistVal'] = count($listVal);
  171. $data['rclientlst'] = $rclientlst;
  172. $data['holdVal'] = $holdVal;
  173. $data['ulist'] = $ulist;
  174.  
  175. return view('layout.module.record.churn',$data);
  176. }
  177.  
  178. function saveCurrentQueueList()
  179. {
  180. $crmCol = Input::get('crmCol');
  181.  
  182. $exitListVal = DB::table('currentqueue_list')->first();
  183.  
  184. if($exitListVal == "")
  185. {
  186. DB::statement("insert into currentqueue_list set updated_at='".date("Y-m-d H:i:s")."', list_value='".$crmCol."'");
  187. }
  188. return;
  189. }
  190.  
  191. function delCurrentQueueList()
  192. {
  193. DB::statement("TRUNCATE table currentqueue_list");
  194. }
  195.  
  196. public function saveChurnData()
  197. {
  198. $empdata = array();
  199. $updateArr = array();
  200. $client=Input::get('client');
  201. $data = $_POST['data'];
  202.  
  203. $exitAgent = DB::table('cq_logic')->where('user_agent','=',$client)->where('type','=','churn')->first();
  204.  
  205. $dataArr = json_decode($data);
  206.  
  207. foreach ($dataArr as $key => $val) {
  208. if($val != "")
  209. {
  210. $updateArr[] = (array)$val;
  211. }
  212. }
  213.  
  214. $empdata['churn'] = "";
  215. $empdata['client'] =$client;
  216. $empdata['peopledata']['status'] ='New';
  217.  
  218. $wakka = new KHRMSLib();
  219. $wakka->setPerson($updateArr, $empdata);
  220.  
  221.  
  222. if($exitAgent)
  223. {
  224. DB::update("update cq_logic set updated_at='".date("Y-m-d H:i:s")."', data='".$data."' where type='churn' and user_agent='".$client."'");
  225. }
  226. else
  227. {
  228. 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")."', type='churn', user_agent='".$client."', data='".$data."'");
  229. }
  230.  
  231. return ;
  232. }
  233.  
  234. public function getFields()
  235. {
  236. $client = Input::get('client');
  237.  
  238. $optionsstr=array();
  239.  
  240. $optionsstr[]="cluster";
  241. $optionsstr[]="Branch_Code";
  242. $optionsstr[]="MOB";
  243. $optionsstr[]="dialer_status";
  244.  
  245. return $optionsstr;
  246. }
  247.  
  248. public function getCampFields()
  249. {
  250. $campField = Input::get('camp_field');
  251.  
  252. if($campField == "cluster")
  253. $campField="State";
  254.  
  255. $optionsstr=array();
  256.  
  257. $optionsstr = DB::table('records')->groupBy($campField)->get();
  258.  
  259. return $optionsstr;
  260. }
  261.  
  262. public function holdData()
  263. {
  264. $camp = Input::get('client');
  265. $campField = Input::get('field');
  266. $campFieldVal = Input::get('fieldVal');
  267.  
  268. //For Temp
  269. if($campField == "cluster")
  270. {
  271. $campField = "State";
  272. }
  273.  
  274. $optionsstr=array();
  275. $dialerStatusArr=array("","No contact");
  276.  
  277. DB::table('records')->where('client',$camp)->where($campField, $campFieldVal)->whereIn('dialer_status',$dialerStatusArr)->update(['passportstatus'=>'Hold']);
  278.  
  279. $existAgent = DB::table('cq_logic')->where('type','=','hold')->where('user_agent','=',$camp)->where('field','=',$campField)->where('field_value','=',$campFieldVal)->where('status','=','Held')->first();
  280.  
  281. if($existAgent)
  282. {
  283. DB::update("update cq_logic set updated_at='".date("Y-m-d H:i:s")."' where user_agent='".$camp."'");
  284. }
  285. else
  286. {
  287. 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")."', type='hold', user_agent='".$camp."', field='".$campField."', field_value='".$campFieldVal."',status='Held'");
  288. }
  289.  
  290. return;
  291. }
  292.  
  293. public function relData()
  294. {
  295. $camp = Input::get('client');
  296. $campField = Input::get('field');
  297. $campFieldVal = Input::get('fieldVal');
  298.  
  299. $optionsstr=array();
  300. $dialerStatusArr=array("","No contact");
  301.  
  302. DB::table('records')->where('client',$camp)->where($campField, $campFieldVal)->whereIn('dialer_status',$dialerStatusArr)->update(['passportstatus'=>'Unhold']);
  303.  
  304. $existAgent = DB::table('cq_logic')->where('type','=','hold')->where('user_agent','=',$camp)->where('field','=',$campField)->where('field_value','=',$campFieldVal)->where('status','=','Held')->first();
  305.  
  306. if($existAgent)
  307. {
  308. DB::update("update cq_logic set updated_at='".date("Y-m-d H:i:s")."', status='Released' where user_agent='".$camp."' and field='".$campField."' and field_value='".$campFieldVal."'");
  309. }
  310.  
  311. return;
  312. }
  313.  
  314. }
Add Comment
Please, Sign In to add comment