/** * Creates a registration, along with validation and notification */ public function register(array $input, array $options = []) { Log::error('time registration: ' . print_r($input, true)); $nameForLog = $input['first_name'] . ' ' . $input['last_name']; $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); $this->validator->validate($input, $options); // throws exceptions if invalid $paymentResult = null; if ($config->take_payment && !isset($options['skip_payment'])) { $paymentResult = $this->payment->takePayment($input); } $registration = $this->_saveRegistration($input, $paymentResult, $options); // send emails $this->email->sendRegistrationConfirmation($registration); if ($registration->collectParticipantInfo() && $registration->hasParticipantCountMismatch()) { $this->email->sendParticipantCountMismatchAlert($registration); } if ($config->send_reg_notification_to_staff) { $this->email->sendStaffRegistrationNotification($registration); } if ($this->_beneficiaryWantsRegNotificationFor($registration)) { $this->email->sendBeneficiaryRegistrationNotification($registration); } Log::error('successfully registered ' . $nameForLog); return $registration; }
protected function configureValidations(array $options = []) { $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); if (!$config->allow_multiple_participants) { $this->num_participants = 1; } if ($config->collect_address) { static::$rules['address1'][] = 'required'; static::$rules['city'][] = 'required'; static::$rules['state'][] = 'required'; static::$rules['postal_code'][] = 'required'; if ($config->collect_country) { static::$rules['country'][] = 'required'; } else { static::$rules['country'] = array_diff(static::$rules['country'], ['required']); } } else { static::$rules['address1'] = array_diff(static::$rules['address1'], ['required']); static::$rules['city'] = array_diff(static::$rules['city'], ['required']); static::$rules['state'] = array_diff(static::$rules['state'], ['required']); static::$rules['postal_code'] = array_diff(static::$rules['postal_code'], ['required']); static::$rules['country'] = array_diff(static::$rules['country'], ['required']); } if ($config->take_payment && !isset($options['skip_payment'])) { static::$rules['pmt_first_name'][] = 'required'; static::$rules['pmt_last_name'][] = 'required'; static::$rules['pmt_postal_code'][] = 'required'; static::$rules['pmt_country'][] = 'required'; } else { static::$rules['pmt_first_name'] = array_diff(static::$rules['pmt_first_name'], ['required']); static::$rules['pmt_last_name'] = array_diff(static::$rules['pmt_last_name'], ['required']); static::$rules['pmt_postal_code'] = array_diff(static::$rules['pmt_postal_code'], ['required']); static::$rules['pmt_country'] = array_diff(static::$rules['pmt_country'], ['required']); } }
public function run() { $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); $regularRawData = $this->regularDataSource->forOrganization($this->orgUid)->getData(); $regularData = $this->regularTransformer->transformArray($regularRawData); $cyoData = null; if ($config->allow_cyo_project_registrations) { $cyoRawData = $this->cyoDataSource->forOrganization($this->orgUid)->getData(); $cyoData = $this->cyoTransformer->transformArray($cyoRawData); } $filename = $this->getFileName(); Excel::create($filename, function ($excel) use($config, $regularData, $cyoData) { $excel->setTitle('Cyo Registrations'); $excel->sheet('Regular', function ($sheet) use($regularData) { $sheet->fromArray($regularData); $this->formatter->format($sheet, $regularData); }); if ($config->allow_cyo_project_registrations) { $excel->sheet('CYO', function ($sheet) use($cyoData) { $sheet->fromArray($cyoData); $this->formatter->format($sheet, $cyoData); }); $excel->setActiveSheetIndex(0); } })->download('xls'); }
public function setUp() { parent::setUp(); Config::$testing = true; Config::singleton(); Config::$testInstance->collect_address = false; $this->model = Factory::build(Registration::class); }
protected function _getPaymentAmount(array $input) { $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); $amount = $config->required_payment_amount; if (isset($input['additional_pmt_amount'])) { if ('other' == $input['additional_pmt_amount']) { $amount += $input['additional_pmt_amount_other']; } else { $amount += $input['additional_pmt_amount']; } } return $amount; }
public function compose(View $view) { parent::compose($view); $user_org = ''; if (Auth::check()) { try { $user_org = Organization::where('id', '=', Auth::user()->organization_id)->first(); } catch (\Exception $e) { // leave empty } } if ($now = Input::get('time')) { $now = new Carbon($now); } else { $now = Carbon::now(); } $view_data = ['userOrganization' => $user_org, 'config' => \NpmWeb\ServiceOpportunities\Models\Config::singleton(), 'now' => $now]; $view->with($view_data); }
public function create($occ_id = null, $agree = null) { // Catch bad occurrence id's and redirect them to somewhere gracefully if (!($occurrence = $this->occurrence->find($occ_id))) { return 'Bad opportunity ID'; } $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); if ($config->show_agreement_page && !$agree) { return View::make($this->package . '::frontend.registrations.agreement', compact('occurrence')); } $registration = $this->registration; $registration->occurrence_id = $occurrence->id; $data = ['title' => 'Register', 'registration' => $registration, 'occurrence' => $occurrence]; if ($config->take_payment) { try { $data['token'] = PaymentProvider::createToken(); } catch (\Exception $e) { echo 'payment error'; exit; } } return View::make($this->package . '::frontend.registrations.create', $data); }
/** * Sends a notification that an occurrence has been cancelled */ public function sendCancellationNotification(OpportunityOccurrence $occurrence) { $opportunity = $occurrence->opportunity; $occ_type = $occurrence->opportunity->type; // Process all the various attributes and form the proper email to send $fromEmail = $this->_getFromEmail($occurrence); $recipients = [$opportunity->beneficiary->organization->from_email]; if ($beneficiaryContact = $occurrence->opportunity->contact_email) { $recipients[] = $beneficiaryContact; } // All emails need these standard email fields $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); $email = ['recipients' => $recipients, 'sender' => [$fromEmail => $config->system_name . ' Admin System'], 'subject' => $config->system_name . ' Cancellation: ' . $opportunity->name]; $customData = ['organization' => $opportunity->beneficiary->organization->name, 'beneficiary' => $opportunity->beneficiary->name, 'event_title' => $opportunity->name, 'event_date' => npmso_email_date_format($occurrence->occurrence_date), 'event_start_time' => npmso_time_format($occurrence->start_time), 'event_end_time' => npmso_time_format($occurrence->end_time), 'sponsorship_end_date' => npmso_email_date_format($occurrence->sponsorship_end_date), 'email_signature' => $opportunity->beneficiary->organization->email_signature, 'email_signature_address' => $fromEmail]; $tmplData = array_merge($email, $customData); if ($occ_type == 'regular') { $this->sendEmail(['service-opportunities::backend.opportunity-occurrences.email.cancellation_regular_html', 'service-opportunities::backend.opportunity-occurrences.email.cancellation_regular_text'], $tmplData); } else { /* Is a sponsorship */ $this->sendEmail(['service-opportunities::backend.opportunity-occurrences.email.cancellation_sponsorship_html', 'service-opportunities::backend.opportunity-occurrences.email.cancellation_sponsorship_text'], $tmplData); } }
/** * Run the database seeds. * * @return void */ public function run() { DB::table('configs')->delete(); Config::create(['system_name' => 'How To Be Rich - Time', 'allow_cyo_project_registrations' => true, 'show_filter_organization' => true, 'show_filter_beneficiary' => true, 'show_filter_time_of_week' => true, 'show_filter_time_of_day' => true, 'show_agreement_page' => false, 'allow_multiple_participants' => true, 'collect_address' => true, 'collect_country' => true, 'required_payment_amount' => 0, 'allow_optional_payments' => false, 'content_search' => 'search', 'content_agreement' => '', 'content_registration_form' => '', 'send_reg_notification_to_staff' => true]); }
public function getDefaultEmailSignatureAttribute($value) { $config = \NpmWeb\ServiceOpportunities\Models\Config::singleton(); return implode(' ', ['The', $this->name, $config->system_name, 'Team']); }