Exemplo n.º 1
0
 public function deleteBulk(Request $req, Note $Note, Step $step)
 {
     if (!$req->has('table_records')) {
         return redirect()->route('cities.index');
     }
     $ids = $req->input('table_records');
     $Note->destroy($ids);
     return redirect()->route('registration.notes.index', $step->id)->with('success', trans('registration::notes.delete_bulk_success'));
 }
Exemplo n.º 2
0
 /**
  * Handle the event.
  *
  * @param  RegistrationStepChanged  $event
  * @return void
  */
 public function handle($event)
 {
     $registration = $event->registration;
     $extra = $event->extra;
     $registration->load('step', 'step.notes', 'period', 'period.year', 'type', 'speciality');
     $step = $registration->step;
     $password = isset($extra['password']) ? $extra['password'] : '';
     if (empty($step->email_template)) {
         return true;
     }
     $notes = [];
     $comment = '';
     if (isset($extra['comment'])) {
         $comment = $extra['comment'];
     }
     if (isset($extra['notes'])) {
         $notes = $extra['notes'];
     }
     /**
      * get next semester
      */
     $firstday = '';
     $semester = semester();
     //Semester::where('id', semester()->id)->orderBy('academycycle_semesters.id', 'ASC')->first();
     if ($semester) {
         $firstday = $semester->start_at;
     }
     /**
      * get subejcts for registrar
      */
     $hours = 0;
     $fees = 0;
     if ($registration->academystructure_specialty_id) {
         $department = Department::where('spec_id', $registration->academystructure_specialty_id)->where(function ($w) {
             $w->orWhere('parent_id', 0);
             $w->orWhereNull('parent_id');
         })->first();
         $equation_subjects_ids = RegistrationEquationSubject::whereNotNull('subject_id')->where('status', 'accepted')->whereHas('equation', function ($w) use($registration) {
             $w->where('registration_id', $registration->id);
         })->pluck('subject_id')->toArray();
         $subject_ids = $department ? json_decode($department->subject_ids, TRUE) : [];
         $subject_ids = array_diff($subject_ids, $equation_subjects_ids);
         $subjects = Subject::select('name', 'hour')->whereIn('id', $subject_ids)->get();
         $hours = $subjects->sum('hour');
         $study_fee = FinancialInvoiceItem::where('slug', 'study_fee')->first();
         $fees = $hours * ($registration->subject_fee > 0 ? $registration->subject_fee : $study_fee->amount);
     }
     $years = 0;
     if ($registration->academystructure_specialty_id) {
         $years = Specialty::selectRaw('COUNT(adt.id) as terms, COUNT(DISTINCT ady.id) as years')->leftJoin('academystructure_departments as adp', 'adp.spec_id', '=', 'asp.id')->leftJoin('academystructure_terms as adt', 'adt.id', '=', 'adp.term_id')->leftJoin('academystructure_years as ady', 'ady.id', '=', 'adt.year_id')->from('academystructure_specialties as asp')->groupBy('asp.id')->where('asp.id', $registration->academystructure_specialty_id)->first()->years;
     }
     /**
      * end get registrar subjects
      */
     $notes_html = '';
     if ($notes = RegistrationStepNote::whereIn('id', $notes)->pluck('content')->toArray()) {
         $notes_html = '<ul><li>' . implode('</li><li>', $notes) . '</li></ul>';
     }
     /*
      *   calculate first term fees
      */
     /*
      *   end fees calculations
      */
     $template = str_replace(['{reg_portal}', '{debit}', '{name}', '{code}', '{mobile}', '{username}', '{year}', '{nid}', '{shortname}', '{specialty}', '{today}', '{hours}', '{firstday}', '{notes}', '{years}', '{fees}', '{comment}', '{password}'], [env('REGSITRAR_EMAIL_EMAIL_VERIFIED_REDIRECT'), $registration->debit, $registration->fullname, $registration->code, $registration->contact_mobile, $registration->username, $registration->period->year->name, $registration->national_id, $registration->shortname, $registration->speciality ? $registration->speciality->name : '', date('Y-m-d'), $hours, $firstday, $notes_html, $years, $fees, $comment, $password], $step->email_template);
     $data = ['fullname' => $registration->fullname, 'template' => $template, 'verification_token' => $registration->verification_token];
     $view = 'email_step';
     if ($step->verify_email == 1) {
         $view = 'email_verification_token';
     }
     if (!empty($registration)) {
         $payload = ['data' => $data, 'send_to' => $registration->contact_email, 'send_to_name' => $registration->fullname, 'subject' => $registration->step->name, 'view' => $view];
         $job = new SendRegistrationStepChangedEmail($payload);
         $this->dispatch($job);
     }
 }