public static function addNew($data)
 {
     $mailing_recipient = new MailingRecipient();
     $mailing_recipient->first_name = $data['first_name'];
     $mailing_recipient->last_name = $data['last_name'];
     $mailing_recipient->email_address = $data['email_address'];
     $mailing_recipient->mobile_number = $data['mobile_number'];
     $mailing_recipient->save();
     return $mailing_recipient;
 }
Beispiel #2
0
 public function addRecipient($data)
 {
     //If this user is already a mailing recipient in the system
     if (MailingRecipient::where('email_address', $data['email_address'])->count() > 0) {
         $recipient = MailingRecipient::where('email_address', $data['email_address'])->first();
         //If the recipient is already in the list, do nothing
         if ($this->recipients()->where('id', $recipient->id)->count() > 0) {
             return 0;
         } else {
             DB::table('mailing_list_recipients')->insert(['mailing_list_id' => $this->id, 'recipient_id' => $recipient->id]);
             return 1;
         }
     } else {
         $recipient = MailingRecipient::addNew(['first_name' => $data['first_name'], 'last_name' => $data['last_name'], 'email_address' => $data['email_address'], 'mobile_number' => $data['mobile_number']]);
         DB::table('mailing_list_recipients')->insert(['mailing_list_id' => $this->id, 'recipient_id' => $recipient->id]);
         $recipient->attemptLinkToPatient();
         return 1;
     }
 }
 public function doRemoveRecipientFromList($recipient_id, $list_id)
 {
     $recipient = MailingRecipient::findOrFail($recipient_id);
     $recipient->removeFromList($list_id);
     return redirect()->back()->with('recipient-removed-from-list', true);
 }
Beispiel #4
0
 public function checkNotifications(Request $request)
 {
     $notifications = [];
     if ($request->session()->has('branch-added')) {
         $notifications[] = array("type" => "success", "message" => "Your Branch has been added successfully!");
     }
     if ($request->session()->has('branch-edited')) {
         $notifications[] = array("type" => "success", "message" => "Your Branch has been edited successfully!");
     }
     if ($request->session()->has('branch-deleted')) {
         $notifications[] = array("type" => "success", "message" => "Your Branch has been deleted successfully!");
     }
     if ($request->session()->has('lab-work-added')) {
         $notifications[] = array("type" => "success", "message" => "Your Lab Work has been added successfully!");
     }
     if ($request->session()->has('lab-work-archived')) {
         $notifications[] = array("type" => "success", "message" => "Your Lab Work has been archived successfully!");
     }
     if ($request->session()->has('lab-work-unarchived')) {
         $notifications[] = array("type" => "success", "message" => "Your Lab Work has been unarchived successfully!");
     }
     if ($request->session()->has('invoice-added')) {
         $notifications[] = array("type" => "success", "message" => "Your Invoice was added successfully!");
     }
     if ($request->session()->has('lab-work-resend')) {
         $notifications[] = array("type" => "success", "message" => "Your Lab Work has been marked for Resend.");
     }
     if ($request->session()->has('dentist-assigned')) {
         $notifications[] = array("type" => "success", "message" => "Dentist assigned to Branch successfully.");
     }
     if ($request->session()->has('staff-assigned')) {
         $notifications[] = array("type" => "success", "message" => "Staff Member assigned to Branch successfully.");
     }
     if ($request->session()->has('lab-staff-assigned')) {
         $notifications[] = array("type" => "success", "message" => "Staff Member assigned to Lab successfully.");
     }
     if ($request->session()->has('dentist-detached')) {
         $notifications[] = array("type" => "success", "message" => "Dentist removed Branch successfully.");
     }
     if ($request->session()->has('staff-detached')) {
         $notifications[] = array("type" => "success", "message" => "Staff Member removed from Branch successfully.");
     }
     if ($request->session()->has('lab-staff-detached')) {
         $notifications[] = array("type" => "success", "message" => "Staff Member removed from Lab successfully.");
     }
     if ($request->session()->has('user-deleted')) {
         $notifications[] = array("type" => "success", "message" => "User deleted successfully.");
     }
     if ($request->session()->has('user-add')) {
         if ($request->session()->get('user-add') == 'success') {
             $notifications[] = array("type" => "success", "message" => "User added successfully.");
         } elseif ($request->session()->get('user-add') == 'error') {
             $notifications[] = array("type" => "error", "message" => "User was not added, please check that email address is not already in use.");
         }
     }
     if ($request->session()->has('user-edit')) {
         if ($request->session()->get('user-edit') == 'success') {
             $notifications[] = array("type" => "success", "message" => "User edited successfully.");
         } elseif ($request->session()->get('user-edit') == 'error') {
             $notifications[] = array("type" => "error", "message" => "User was not edited, please check that email address is not already\n\t\t\t\t\tin use by another user.");
         }
     }
     if ($request->session()->has('lab-added')) {
         $notifications[] = array("type" => "success", "message" => "Lab added successfully.");
     }
     if ($request->session()->has('lab-deleted')) {
         $notifications[] = array("type" => "success", "message" => "Lab deleted successfully.");
     }
     if ($request->session()->has('lab-edited')) {
         $notifications[] = array("type" => "success", "message" => "Lab edited successfully.");
     }
     if ($request->session()->has('docket_added')) {
         $notifications[] = array("type" => "success", "message" => "Docket added successfully.");
     }
     if ($request->session()->has('docket_edited')) {
         $notifications[] = array("type" => "success", "message" => "Docket edited successfully.");
     }
     if ($request->session()->has('docket_deleted')) {
         $notifications[] = array("type" => "success", "message" => "Docket deleted successfully.");
     }
     if ($request->session()->has('invoice-paid')) {
         $notifications[] = array("type" => "success", "message" => "Invoice marked as Paid successfully.");
     }
     if ($request->session()->has('password-incorrect')) {
         $notifications[] = array("type" => "error", "message" => "The password you entered was incorrect, please try again.");
     }
     if ($request->session()->has('appointment-status-changed')) {
         $notifications[] = array("type" => "success", "message" => "Appointment status changed successfully!");
     }
     if ($request->session()->has('appointment-added')) {
         $notifications[] = array("type" => "success", "message" => "Appointment added successfully!");
     }
     if ($request->session()->has('appointment-edited')) {
         $notifications[] = array("type" => "success", "message" => "Appointment edited successfully!");
     }
     if ($request->session()->has('appointment-failed-to-add')) {
         $notifications[] = array("type" => "error", "message" => "Appointment failed to add, check that it doesn't clash with another appointment for this dentist and try again.");
     }
     if ($request->session()->has('appointment-failed-to-edit')) {
         $notifications[] = array("type" => "error", "message" => "Appointment failed to edit, check that it doesn't clash with another appointment for this dentist and try again.");
     }
     if ($request->session()->has('patient_added')) {
         $notifications[] = array("type" => "success", "message" => "Patient added successfully!");
     }
     if ($request->session()->has('patient_edited')) {
         $notifications[] = array("type" => "success", "message" => "Patient edited successfully!");
     }
     if ($request->session()->has('appointment-removed')) {
         $notifications[] = array("type" => "success", "message" => "Appointment cancelled successfully!");
     }
     if ($request->session()->has('email-sent')) {
         $notifications[] = array("type" => "success", "message" => "Email sent successfully!");
     }
     if ($request->session()->has('mailbox-tag-added')) {
         $notifications[] = array("type" => "success", "message" => "Tag added successfully!");
     }
     if ($request->session()->has('stock-checked-in')) {
         $notifications[] = array("type" => "success", "message" => "Stock checked in successfully!");
     }
     if ($request->session()->has('stock-checked-out')) {
         $notifications[] = array("type" => "success", "message" => "Stock checked out successfully!");
     }
     if ($request->session()->has('stock-item-added')) {
         $notifications[] = array("type" => "success", "message" => "Inventory item added successfully!");
     }
     if ($request->session()->has('stock-item-assigned')) {
         $notifications[] = array("type" => "success", "message" => "Inventory item assigned successfully!");
     }
     if ($request->session()->has('stock-order-add-password-error')) {
         $notifications[] = array("type" => "error", "message" => "The password you entered was incorrect, please try again.");
     }
     if ($request->session()->has('stock-order-added')) {
         $notifications[] = array("type" => "success", "message" => "Your Order has been added successfully!");
     }
     if ($request->session()->has('stock-order-saved-for-later')) {
         $notifications[] = array("type" => "success", "message" => "Your Order has been saved for later.");
     }
     if ($request->session()->has('settings-saved')) {
         $notifications[] = array("type" => "success", "message" => "Settings updated successfully.");
     }
     if ($request->session()->has('campaign-deleted')) {
         $notifications[] = array("type" => "success", "message" => "Campaign deleted successfully.");
     }
     if ($request->session()->has('mailing-list-added')) {
         $notifications[] = array("type" => "success", "message" => "Mailing List added successfully, if you also imported a CSV, it will be processed shortly and you will be emailed.");
     }
     if ($request->session()->has('mailing-list-filetype-import-error')) {
         $notifications[] = array("type" => "error", "message" => "Your import file was not a CSV. Please try importing recipients to this list again.");
     }
     if ($request->session()->has('mailing-list-deleted')) {
         $notifications[] = array("type" => "success", "message" => "Mailing List has been deleted successfully.");
     }
     if ($request->session()->has('recipient-removed-from-list')) {
         $notifications[] = array("type" => "success", "message" => "Recipient has been removed from this list successfully.");
     }
     if ($request->session()->has('mailing-list-import-added')) {
         $notifications[] = array("type" => "success", "message" => "Your import is being processed and will be added shortly.");
     }
     if ($request->session()->has('recipient-added')) {
         $notifications[] = array("type" => "success", "message" => "This recipient has been added successfully.");
     }
     if ($request->session()->has('recipient-edited')) {
         $notifications[] = array("type" => "success", "message" => "This recipient has been edited successfully.");
     }
     if ($request->session()->has('recipient-already-exists')) {
         $existing_recipient = MailingRecipient::findOrFail($request->session()->get('recipient_id'));
         $notifications[] = array("type" => "success", "message" => "This recipient already exists, if you want to edit their profile, please <a href='" . url('marketing/recipient/' . $existing_recipient->id) . "/edit'>click this link</a>");
     }
     if ($request->session()->has('template-added')) {
         $notifications[] = array("type" => "success", "message" => "Template has been added successfully.");
     }
     if ($request->session()->has('template-edited')) {
         $notifications[] = array("type" => "success", "message" => "Template has been editted successfully.");
     }
     view()->share('notifications', $notifications);
 }