public function postBookRequisitionForm() { $validator = Validator::make(Input::all(), ['inputAuthor' => 'required']); if ($validator->fails()) { return redirect('/bookrequisitionform')->withInput()->withErrors($validator); } $basicRequisitionFormData = BasicRequisitionForm::create(array('doctype' => Input::get('optionsDocumentType'), 'author' => Input::get('inputAuthor'), 'title' => Input::get('inputTitle'), 'publisher' => Input::get('inputPublisher'), 'agency' => Input::get('inputAgency'), 'isbn' => Input::get('inputISBN'), 'volumne' => Input::get('inputVolume'), 'price' => Input::get('inputPrice'), 'sectioncatalogue' => Input::get('inputSectionCatalogue'), 'numberofcopies' => Input::get('inputNumberOfCopies'), 'laravel_user_id' => Auth::user()->id, 'iitm_id' => Auth::user()->iitm_id, 'faculty' => Auth::user()->name, 'iitm_dept_code' => Auth::user()->iitm_dept_code)); //return Auth::user(); $lac_user_instance = DB::table('lac_users')->where('iitm_dept_code', '=', Auth::user()->iitm_dept_code)->first(); // return $lac_user_instance->name; $inputTitle = Input::get('inputTitle'); Mail::send('emails.newbrf', ['lac_user_instance' => $lac_user_instance, 'inputTitle' => $inputTitle], function ($m) use($lac_user_instance, $inputTitle) { $m->from('*****@*****.**', 'Library Portal Team'); $m->to($lac_user_instance->lac_email_id, $lac_user_instance->name)->subject('[Library] New Request for Book'); // $m->to("*****@*****.**", $lac_user_instance->name)->subject('[Library] New Request for Book'); }); return redirect('home')->with('globalalertmessage', 'Book Request Submitted')->with('globalalertclass', 'success'); }
public function postLacRequestStatusApproveBRF() { $validator = Validator::make(Input::all(), ['brf_id' => 'required', 'lac_status' => 'required']); if ($validator->fails()) { return redirect('/lac/requeststatus')->withInput()->withErrors($validator)->with('globalalertmessage', 'Failed to Aprove. Try Again')->with('globalalertclass', 'error'); } $brf_model_instance = BasicRequisitionForm::find(Input::get('brf_id')); $brf_model_instance->lac_status = Input::get('lac_status'); $brf_model_instance->remarks = Input::get('remarks'); $brf_model_instance->save(); if (Input::get('lac_status') == "denied") { # code... $brf_model_user_instance = User::find($brf_model_instance->laravel_user_id); Mail::send('emails.deniedbylac', ['brf_model_instance' => $brf_model_instance, 'brf_model_user_instance' => $brf_model_user_instance], function ($m) use($brf_model_instance, $brf_model_user_instance) { $m->from('*****@*****.**', 'Library Portal Team'); $m->to($brf_model_user_instance->email, $brf_model_user_instance->name)->subject('[Library] Request Denied for Book'); // $m->to("*****@*****.**", $brf_model_user_instance->name)->subject('[Library] Request Denied for Book'); }); } return redirect('lac/requeststatus')->with('globalalertmessage', 'Request Successfully updated.')->with('globalalertclass', 'success'); }
public function getAdminBRFAnalyticsYearDepartment($year_from_until, $iitm_dept_code) { $years = explode("-", $year_from_until); $year_from = $years[0]; $year_untill = $years[1]; // return $year_from; $lac_users_departments = DB::table('lac_users')->get(); $brf_all_count = BasicRequisitionForm::all()->count(); // Requests that are pending but have been approved by LAC Members $brf_pending_lac_approved_count = BasicRequisitionForm::where('lac_status', "approved")->where('iitm_dept_code', $iitm_dept_code)->where('librarian_status', NULL)->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // Requests that are pending but have been approved by LAC Members and Librarian $brf_pending_librarian_approved_count = BasicRequisitionForm::where('lac_status', "approved")->where('iitm_dept_code', $iitm_dept_code)->where('librarian_status', "approved")->where('download_status', NULL)->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // Requests that have been Successfully downloaded and approved $brf_approved_downloaded_count = BasicRequisitionForm::where('lac_status', "approved")->where('iitm_dept_code', $iitm_dept_code)->where('librarian_status', "approved")->where('download_status', "downloaded")->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // Requests that have been Denied by LAC Members $brf_pending_lac_denied_count = BasicRequisitionForm::where('lac_status', "denied")->where('iitm_dept_code', $iitm_dept_code)->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // Requests that have been Denied by Librarian $brf_pending_librarian_denied_count = BasicRequisitionForm::where('lac_status', "approved")->where('iitm_dept_code', $iitm_dept_code)->where('librarian_status', "denied")->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // Requests that are new and pending LAC Member Approval $brf_new_pending_lac_count = BasicRequisitionForm::where('lac_status', NULL)->where('iitm_dept_code', $iitm_dept_code)->whereDate('created_at', '>=', $years[0] . '-04-01')->whereDate('created_at', '<=', $years[1] . '-03-31')->count(); // User Analytics - Department-wise $users = DB::table('users')->where('iitm_dept_code', $iitm_dept_code)->get(); foreach ($users as $key => $user) { $brf_requests_count = BasicRequisitionForm::where('iitm_id', $user->iitm_id)->count(); $user->brf_requests_count = $brf_requests_count; } usort($users, function ($a, $b) { //Sort the array using a user defined function return $a->brf_requests_count > $b->brf_requests_count ? -1 : 1; //Compare the scores }); return view('admin.admin-brf-analytics-year')->with('iitm_dept_code', $iitm_dept_code)->with('lac_users_departments', $lac_users_departments)->with('brf_all_count', $brf_all_count)->with('brf_pending_lac_approved_count', $brf_pending_lac_approved_count)->with('brf_pending_librarian_approved_count', $brf_pending_librarian_approved_count)->with('brf_approved_downloaded_count', $brf_approved_downloaded_count)->with('brf_pending_lac_denied_count', $brf_pending_lac_denied_count)->with('brf_pending_librarian_denied_count', $brf_pending_librarian_denied_count)->with('brf_new_pending_lac_count', $brf_new_pending_lac_count)->with('year_from', $year_from)->with('users', $users)->with('year_until', $year_untill); }