HomeController.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707
  1. <?php
  2. namespace App\Http\Controllers\Admin;
  3. use App\Http\Requests;
  4. use App\Http\Controllers\Controller;
  5. use Illuminate\Http\Request;
  6. use App\User;
  7. use App\Models\Project;
  8. use App\Models\Task;
  9. use App\Models\Group;
  10. use App\Models\Note;
  11. use Auth;
  12. use App\Models\Attendance;
  13. use App\Models\CompanyModel;
  14. use App\Models\Invoice;
  15. use App\Models\InvoiceItems;
  16. use App\Models\AccountHead;
  17. use Excel;
  18. use DB;
  19. class HomeController extends Controller
  20. {
  21. public function __construct()
  22. {
  23. $this->middleware('auth');
  24. }
  25. public function index()
  26. {
  27. /*
  28. 1=Created;
  29. 2=in process;
  30. 3=Completed;
  31. 4=checking;
  32. 5=bugfixing;
  33. 6=done;
  34. */
  35. date_default_timezone_set("Asia/Dhaka");
  36. $user_id = Auth::user()->id;
  37. $data['title'] = "Admin dashboard";
  38. //todays completed task
  39. $data['all'] = User::where('utype',2)->get();
  40. $data['deadline_missed'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->where('status','!=',6)->whereDate('dead_line', '<', date('Y-m-d'))->orderBy('created_time')->get();
  41. $data['deadline_today'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->where('status','!=',6)->whereDate('dead_line', '=', date('Y-m-d'))->orderBy('created_time')->get();
  42. $data['done_today'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->where('status','=',6)->whereDate('closing_time', '=', date('Y-m-d'))->orderBy('created_time')->get();
  43. $all_users=User::all()->pluck('name','id');
  44. $working_today = Task::where('user_id','!=',0)->whereDate('start_time', '=', date('Y-m-d'))->orwhereDate('closing_time', '=', date('Y-m-d'))->whereNotIn('status',[2,3,4,5])->orderBy('created_time')->pluck('user_id');
  45. $active_users=array();
  46. foreach($working_today as $row){
  47. if($row !=0){
  48. if (!in_array($row,$active_users))
  49. {
  50. array_push($active_users,$row);
  51. }
  52. }
  53. }
  54. $inactive_users=array();
  55. foreach($all_users as $i=>$value){
  56. if (!in_array($i,$active_users))
  57. {
  58. array_push($inactive_users,$value);
  59. }
  60. }
  61. $data['inactive_users']=$inactive_users;
  62. $data['pending_task'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->where('status','!=',6)->orderBy('created_time')->get();
  63. $data['complted_yesterday'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->where('status',6)->whereDate('closing_time', '=', date('Y-m-d'))->orderBy('created_time')->get();
  64. $data['in_process_task'] = Task::with(['user','proj_name'])->where('user_id','!=',0)->whereIn('status',[2,3,4,5])->orderBy('created_time')->get();
  65. $data['all1'] = User::where('utype',3)->get();
  66. $data['notes'] = Note::where('user_id',$user_id)->orderBy('time')->get();
  67. /*
  68. Reports
  69. */
  70. $data['clients']=CompanyModel::count();
  71. $data['ttl_invoice']=
  72. Invoice::where(\DB::raw("MONTH(invoice_date)"),'=',\DB::raw('MONTH(NOW())'))->count();
  73. $data['ttl_due_invoice'] = Invoice::where(\DB::raw("MONTH(due_date)"),'<=',\DB::raw('MONTH(NOW())'))
  74. ->where('due_date','<',\DB::raw('NOW()'))
  75. ->where('status',0)->count();
  76. $sql_exp="SELECT MONTH(j.created_at) as month_name,SUM(j.amount) as total_amount FROM journal j JOIN acc_head ahd ON j.ref_id = ahd.id WHERE ahd.type_id = 2 GROUP BY YEAR(j.created_at),MONTH(j.created_at)";
  77. $expense_report_data=\DB::select($sql_exp);
  78. $exp_month=[];
  79. $exp_amount=[];
  80. if($expense_report_data)
  81. {
  82. foreach($expense_report_data as $row)
  83. {
  84. array_push($exp_month,$this->get_month_name($row->month_name));
  85. array_push($exp_amount,$row->total_amount);
  86. }
  87. }
  88. $data['exp_month']='['.implode(',',$exp_month).']';
  89. $data['exp_amount']='['.implode(',',$exp_amount).']';
  90. $sql_revenue="SELECT MONTH(j.created_at) as month_name,SUM(j.amount) as total_amount FROM journal j JOIN acc_head ahd ON j.ref_id = ahd.id WHERE ahd.type_id = 4 GROUP BY YEAR(j.created_at),MONTH(j.created_at)";
  91. $revenue_report_data=\DB::select($sql_revenue);
  92. $revenue_amount=[];
  93. if($expense_report_data)
  94. {
  95. foreach($revenue_report_data as $row)
  96. {
  97. array_push($revenue_amount,$row->total_amount);
  98. }
  99. }
  100. $data['revenue_amount']='['.implode(',',$revenue_amount).']';
  101. $all_due=Invoice::where('status','=',0)->pluck('id');
  102. $due=0;
  103. if(count($all_due)>0)
  104. {
  105. foreach($all_due as $due_id){
  106. $amounts=InvoiceItems::where('invoice_id','=',$due_id)->pluck('payable_amount');
  107. foreach($amounts as $amount)
  108. {
  109. $due+=$amount;
  110. }
  111. }
  112. }
  113. $data['dues'] = $due;
  114. /*
  115. Monthly Due
  116. */
  117. $all_month_due=Invoice::whereMonth('due_date','=',date('m'))->where('status','=',0)->pluck('id');
  118. $monthly_due=0;
  119. if(count($all_month_due)>0)
  120. {
  121. foreach($all_month_due as $due_id){
  122. $monthly_due_amounts=InvoiceItems::where('invoice_id','=',$due_id)->pluck('payable_amount');
  123. foreach($monthly_due_amounts as $monthly_due_amount)
  124. {
  125. $monthly_due+=$monthly_due_amount;
  126. }
  127. }
  128. }
  129. $data['all_month_due'] = $monthly_due;
  130. /*
  131. Monthly Collection
  132. */
  133. $all_month_collected=Invoice::whereMonth('due_date','=',date('m'))->where('status','=',1)->pluck('id');
  134. $monthly_collected=0;
  135. if(count($all_month_collected)>0)
  136. {
  137. foreach($all_month_collected as $due_id){
  138. $monthly_collected_amounts=InvoiceItems::where('invoice_id','=',$due_id)->pluck('payable_amount');
  139. foreach($monthly_collected_amounts as $monthly_collected_amount)
  140. {
  141. $monthly_collected+=$monthly_collected_amount;
  142. }
  143. }
  144. }
  145. $data['monthly_collected'] = $monthly_collected;
  146. /*$all_counselors = Invoice::with(['user'])->get();
  147. $users=array();
  148. $user_info_array=array();
  149. foreach($all_counselors as $u){
  150. if(!in_array($u->created_by, $users))
  151. {
  152. array_push($users,$u->created_by);
  153. $new_info=array('user_name'=>$u->user['name'],'user_id'=>$u->created_by);
  154. array_push($user_info_array, $new_info);
  155. }
  156. }
  157. // dd($user_info_array);
  158. //$counselor_wise_report=array();
  159. foreach($user_info_array as $counselor)
  160. {
  161. $total_amount=0;
  162. $collected_amount=0;
  163. $due_amount=0;
  164. $counselor_name = $counselor['user_name'];
  165. $counselor_invoice_ids = Invoice::whereMonth('created_at','=',date('m'))->where('created_by','=',$counselor['user_id'])->pluck('id');
  166. $counselor_collected_invoice_ids = Invoice::whereMonth('created_at','=',date('m'))->where('created_by','=',$counselor['user_id'])->where('status','=',1)->pluck('id');
  167. $counselor_due_invoice_ids = Invoice::whereMonth('created_at','=',date('m'))->where('created_by','=',$counselor['user_id'])->where('status','=',0)->pluck('id');
  168. foreach($counselor_invoice_ids as $row)
  169. {
  170. $all_billings=InvoiceItems::where('invoice_id','=',$row)->pluck('payable_amount');
  171. foreach ($all_billings as $value) {
  172. $total_amount +=$value;
  173. }
  174. }
  175. foreach($counselor_collected_invoice_ids as $row1)
  176. {
  177. $collected_billings=InvoiceItems::where('invoice_id','=',$row1)->pluck('payable_amount');
  178. foreach ($collected_billings as $value1) {
  179. $collected_amount +=$value1;
  180. }
  181. }
  182. foreach($counselor_due_invoice_ids as $row2)
  183. {
  184. $due_billings=InvoiceItems::where('invoice_id','=',$row2)->pluck('payable_amount');
  185. foreach ($due_billings as $value2) {
  186. $due_amount +=$value2;
  187. }
  188. }
  189. $counselor_wise_report[]=array(
  190. 'name'=>$counselor_name,
  191. 'total'=>$total_amount,
  192. 'collected'=>$collected_amount,
  193. 'due'=>$due_amount
  194. );
  195. }
  196. $data['counselor_wise_report'] = $counselor_wise_report;
  197. */
  198. /*
  199. Balance Information Goes Here
  200. */
  201. $banks=AccountHead::where('parent_head','=',4)->get();
  202. if(count($banks)>0)
  203. {
  204. foreach($banks as $bank)
  205. {
  206. $bank_name = $bank->name;
  207. $debit_accounts = Journal::where('debit_account','=',$bank->id)->get();
  208. $credit_accounts = Journal::where('credit_account','=',$bank->id)->get();
  209. $balance = 0;
  210. foreach($debit_accounts as $debit)
  211. {
  212. $balance = (float)($bank->opening_balance + $debit->amount);
  213. }
  214. foreach($credit_accounts as $credit)
  215. {
  216. $balance = (float)($bank->opening_balance - $credit->amount);
  217. }
  218. $total_balances[] = array('bank_name'=>$bank_name,'balance'=>$balance);
  219. }
  220. $data['banks'] = $total_balances;
  221. }
  222. else
  223. {
  224. $data['banks'] = '';
  225. }
  226. return view('admin.admin_dashboard',$data);
  227. }
  228. /**
  229. * get month name by month number
  230. *
  231. * @param integer $month_number
  232. *
  233. * @return string
  234. */
  235. function get_month_name($month_number)
  236. {
  237. $month_name='';
  238. switch ($month_number) {
  239. case '1':
  240. $month_name='January';
  241. break;
  242. case '2':
  243. $month_name='February';
  244. break;
  245. case '3':
  246. $month_name='March';
  247. break;
  248. case '4':
  249. $month_name='April';
  250. break;
  251. case '5':
  252. $month_name='May';
  253. break;
  254. case '6':
  255. $month_name='June';
  256. break;
  257. case '7':
  258. $month_name='July';
  259. break;
  260. case '8':
  261. $month_name='August';
  262. break;
  263. case '9':
  264. $month_name='September';
  265. break;
  266. case '10':
  267. $month_name='October';
  268. break;
  269. case '11':
  270. $month_name='November';
  271. break;
  272. case '12':
  273. $month_name='December';
  274. break;
  275. default:
  276. # code...
  277. break;
  278. }
  279. return $month_name;
  280. }
  281. public function check_user()
  282. {
  283. $utype = Auth::user()->utype;
  284. if($utype == 1)
  285. {
  286. return redirect('admin/dashboard');
  287. }
  288. elseif($utype == 2)
  289. {
  290. return redirect('user/user_projects');
  291. }
  292. elseif($utype == 3)
  293. {
  294. return redirect('client/client_dashboard');
  295. }
  296. else{
  297. return redirect('/logout');
  298. }
  299. }
  300. public function user_profile($user_id)
  301. {
  302. $user = User::find($user_id);
  303. return view('admin.view_resume',compact('user'));
  304. }
  305. public function user_attendace()
  306. {
  307. date_default_timezone_set("Asia/Dhaka");
  308. $uid=Auth::user()->id;
  309. $utype = Auth::user()->utype;
  310. if($utype == 1 || $uid==44)
  311. {
  312. $all = User::all();
  313. $entry_time = Attendance::whereDate('attendance_time', '=', date('Y-m-d'))->where('status','=',0)->orderBy('attendance_time','desc')->groupBy('attendance_time')->get();
  314. $exit_time = Attendance::whereDate('attendance_time', '=', date('Y-m-d',strtotime('yesterday')))->where('status','=',1)->orderBy('attendance_time','desc')->groupBy('attendance_time')->get();
  315. $title = "User Attendace";
  316. $all_dates = array();
  317. $dates = Attendance::pluck('attendance_time');
  318. $all_users = array();
  319. $users = Attendance::pluck('user_id');
  320. $a=strtotime('9:30 am');
  321. $c=date('H:i:s a', $a);
  322. $exact_time= $c;
  323. foreach($users as $user)
  324. {
  325. $new_val = $user;
  326. if(!in_array($new_val,$all_users))
  327. {
  328. array_push($all_users, $new_val);
  329. }
  330. }
  331. $late_array = array();
  332. foreach($all_users as $d)
  333. {
  334. if($d !=6 && $d !=10){
  335. $late_count=0;
  336. $test_entry_time=Attendance::select('attendance_time','user_name')->where('user_id','=',$d)->where('status','=',0)->whereMonth('attendance_time', '>=', date('m'))->get();
  337. $absent_count=Attendance::where('user_id','=',$d)->whereMonth('attendance_time', '=', date('m'))->where('absent_count','=',1)->count();
  338. if (!empty($test_entry_time) && !empty($absent_count)) {
  339. foreach ($test_entry_time as $value1) {
  340. $u_name=$value1->user_name;
  341. $et=date('H:i:s a',strtotime($value1->attendance_time));
  342. if($et>$exact_time)
  343. {
  344. $late_count++;
  345. }
  346. }
  347. $new_array=array('user_name'=>$u_name,'late_count'=>$late_count,'absent_count'=>$absent_count);
  348. array_push($late_array, $new_array);
  349. }
  350. }
  351. }
  352. return view('admin.attendace.list',compact('all','title','entry_time','exit_time','all_dates','late_array'));
  353. }
  354. }
  355. public function attendace_sheet_entry(Request $request)
  356. {
  357. date_default_timezone_set("Asia/Dhaka");
  358. if($request->file('import_file') !=''){
  359. $path = $request->file('import_file')->getRealPath();
  360. $data = Excel::load($path, function($reader) {})->get();
  361. if(!empty($data) && $data->count()){
  362. foreach ($data->toArray() as $key => $value) {
  363. if( (int)$value['user_id'] == 1)
  364. {
  365. $user_name = 'Reza';
  366. }
  367. else if((int)$value['user_id'] == 2)
  368. {
  369. $user_name = 'Mamun';
  370. }
  371. else if((int)$value['user_id'] == 3)
  372. {
  373. $user_name = 'Golam Sayed';
  374. }
  375. else if((int)$value['user_id'] == 4)
  376. {
  377. $user_name = 'Akib';
  378. }
  379. else if((int)$value['user_id'] == 5)
  380. {
  381. $user_name = 'Masum';
  382. }
  383. else if((int)$value['user_id'] == 6)
  384. {
  385. $user_name = 'Helal';
  386. }
  387. else if((int)$value['user_id'] == 7)
  388. {
  389. $user_name = 'Zeba';
  390. }
  391. else if((int)$value['user_id'] == 8)
  392. {
  393. $user_name = 'Shabuj';
  394. }
  395. else if((int)$value['user_id'] == 9)
  396. {
  397. $user_name = 'Hasib';
  398. }
  399. else if((int)$value['user_id'] == 10)
  400. {
  401. $user_name = 'Tipu';
  402. }
  403. else if((int)$value['user_id'] == 11)
  404. {
  405. $user_name = 'Niloy';
  406. }
  407. else if((int)$value['user_id'] == 12)
  408. {
  409. $user_name = 'Nishat';
  410. }
  411. else if((int)$value['user_id'] == 13)
  412. {
  413. $user_name = 'Jamil';
  414. }
  415. else if((int)$value['user_id'] == 14)
  416. {
  417. $user_name = 'Shamim';
  418. }
  419. else if((int)$value['user_id'] == 15)
  420. {
  421. $user_name = 'Payer';
  422. }
  423. if($value['attendance_time'] !='')
  424. {
  425. $att_time = date('Y-m-d H:i:s',strtotime($value['attendance_time']));
  426. } else
  427. {
  428. $att_time = "0000-00-00 00:00:00";
  429. }
  430. $absent_count=(int)$value['absent_count'];
  431. if($user_name != 'Hasib'){
  432. $insert[] = ['user_id'=>(int)$value['user_id'],'user_name' => $user_name, 'attendance_time' =>$att_time,'status'=>(int)$value['status'],'absent_count'=>$absent_count];
  433. }
  434. }
  435. if(!empty($insert)){
  436. Attendance::insert($insert);
  437. return redirect()->action('Admin\HomeController@user_attendace')->with('status', 'Data Added!');
  438. }
  439. }
  440. }
  441. return back()->with('error','Please Check your file, Something is wrong there.');
  442. }
  443. public function attendace_report()
  444. {
  445. $utype = Auth::user()->utype;
  446. if($utype == 1)
  447. {
  448. $title = "User Attendace Report";
  449. $all_attendance = Attendance::all();
  450. return view('admin.attendace.report',compact('all_attendance','title'));
  451. }
  452. }
  453. public function get_report_by_user(Request $request)
  454. {
  455. $from = $request->start_date;
  456. $to = $request->end_date;
  457. $user = $request->user;
  458. if( $user == 1)
  459. {
  460. $user_name = 'Reza';
  461. }
  462. else if($user == 2)
  463. {
  464. $user_name = 'Mamun';
  465. }
  466. else if($user == 3)
  467. {
  468. $user_name = 'Golam Sayed';
  469. }
  470. else if($user == 4)
  471. {
  472. $user_name = 'Akib';
  473. }
  474. else if($user == 5)
  475. {
  476. $user_name = 'Masum';
  477. }
  478. else if($user == 6)
  479. {
  480. $user_name = 'Helal';
  481. }
  482. else if($user == 7)
  483. {
  484. $user_name = 'Zeba';
  485. }
  486. else if($user == 8)
  487. {
  488. $user_name = 'Shabuj';
  489. }
  490. else if($user == 9)
  491. {
  492. $user_name = 'Hasib';
  493. }
  494. else if($user == 10)
  495. {
  496. $user_name = 'Tipu';
  497. }
  498. else if($user == 11)
  499. {
  500. $user_name = 'Niloy';
  501. }
  502. else if($user == 12)
  503. {
  504. $user_name = 'Nishat';
  505. }
  506. else if($user == 13)
  507. {
  508. $user_name = 'Jamil';
  509. }
  510. else if($user == 14)
  511. {
  512. $user_name = 'Shamim';
  513. }
  514. else if((int)$value['user_id'] == 15)
  515. {
  516. $user_name = 'Payer';
  517. }
  518. $entry_time = Attendance::where('user_id','=',$user)->whereBetween('attendance_time', array($from, $to))->where('status','=',0)->orderBy('attendance_time','desc')->get();
  519. $exit_time = Attendance::where('user_id','=',$user)->whereBetween('attendance_time', array($from, $to))->where('status','=',1)->orderBy('attendance_time','desc')->groupBy('attendance_time')->get();
  520. return view('admin.attendace.report_content',compact('entry_time','exit_time',''))->render();
  521. }
  522. public function leave_report()
  523. {
  524. $title = "Leave Requests";
  525. $users = User::all();
  526. foreach($users as $user)
  527. {
  528. $all_users[] = array('id'=>$user->id,'name'=>$user->name);
  529. }
  530. $leave_type = DB::table('leave_type_head')->where('is_published','=',1)->get();
  531. foreach($leave_type as $leave)
  532. {
  533. $purposes[] = array('id'=>$leave->id,'name'=>$leave->name);
  534. }
  535. $all = DB::table('leave_req')->orderBy('id','DESC')->get();
  536. return view('admin.leave_request',compact('all','all_users','title','purposes'));
  537. }
  538. public function apply(){
  539. $title = "Apply For Leave";
  540. $leave_type = DB::table('leave_type_head')->where('is_published','=',1)->get();
  541. $users = User::all();
  542. return view('admin.leave_apply',compact('title','leave_type','users'));
  543. }
  544. public function store(Request $request){
  545. $purpose= $request->purpose;
  546. $apply_to= 2;
  547. $from= $request->get('from',date('Y-m-d H:i:s'));
  548. $to= $request->get('to',date('Y-m-d H:i:s'));
  549. $from_day = strtotime($from);
  550. $to_day = strtotime($to);
  551. $days_between = (ceil(abs( $to_day - $from_day) / 86400))+1;
  552. $description = $request->description;
  553. $approval = 0;
  554. $created_at = date('Y-m-d H:i:s');
  555. $user_id = Auth::id();
  556. DB::table('leave_req')->insert(array(
  557. 'purpose'=>$purpose,
  558. 'apply_to'=>$apply_to,
  559. 'from'=>$from,
  560. 'to'=>$to,
  561. 'days'=>$days_between,
  562. 'description'=>$description,
  563. 'approval'=>$approval,
  564. 'created_at'=>$created_at,
  565. 'user_id'=>$user_id,
  566. ));
  567. return redirect('admin/leave_requests')->with('msg','Leave request apply Successful.');
  568. }
  569. public function leave_details($id)
  570. {
  571. $title = "Leave Details";
  572. $leave_req = DB::table('leave_req')->where('id',$id)->first();
  573. $all_leave_req = DB::table('leave_req')->where('user_id',$leave_req->user_id)->orderBy('id','DESC')->get();
  574. $users = User::all();
  575. foreach($users as $user)
  576. {
  577. $all_users[] = array('id'=>$user->id,'name'=>$user->name);
  578. }
  579. $leave_type = DB::table('leave_type_head')->where('is_published','=',1)->get();
  580. foreach($leave_type as $leave)
  581. {
  582. $taken = DB::table('leave_req')->where('user_id',$leave_req->user_id)->where('purpose',$leave->id)->where('approval',1)->whereYear('created_at', '=', date('Y'))->sum('days');
  583. $purposes[] = array('id'=>$leave->id,'name'=>$leave->name,'approved_days'=>$leave->approved_days,'taken'=> $taken );
  584. }
  585. return view('admin.leave_details',compact('leave_req','all_leave_req','all_users','title','purposes','leave_type'));
  586. }
  587. public function leave_accept(Request $request,$id)
  588. {
  589. $from= $request->get('from',date('Y-m-d H:i:s'));
  590. $to= $request->get('to',date('Y-m-d H:i:s'));
  591. $from_day = strtotime($from);
  592. $to_day = strtotime($to);
  593. $days_between = (ceil(abs( $to_day - $from_day) / 86400))+1;
  594. $approval = 1;
  595. DB::table('leave_req')->where('id','=',$id)->update(
  596. array('approval'=>$approval,'from'=>$from,'to'=>$to,'days'=>$days_between,)
  597. );
  598. return redirect('admin/leave_requests')->with('msg','Leave Request Approved.');
  599. }
  600. public function leave_discard($id)
  601. {
  602. $approval = 0;
  603. DB::table('leave_req')->where('id','=',$id)->update(
  604. array('approval'=>$approval)
  605. );
  606. return redirect('admin/leave_requests')->with('msg','Leave Request Discard.');
  607. }
  608. public function destroy($id)
  609. {
  610. DB::table('leave_req')->where('id','=',$id)->delete();
  611. return redirect('admin/leave_requests')->with('msg','Leave Request Deleted.');
  612. }
  613. public function change_support_status(Request $request){
  614. $ticket_ids=$request->ticket_ids;
  615. if(count($ticket_ids)>0){
  616. foreach($ticket_ids as $ticket_id){
  617. $stat=1;
  618. DB::table('ticket')->where('id','=',$ticket_id)->update(array('display_status'=>$stat));
  619. }
  620. }
  621. }
  622. }