Example #1
0
 public function createCustomRecord($parameters)
 {
     $parameters['companies'] = Company::all();
     $parameters['families'] = Family::all();
     $parameters['brands'] = Brand::all();
     $parameters['products'] = Product::builder()->where('active_072', true)->get();
     // decrypt id
     $parameters['id'] = Crypt::decrypt($parameters['id']);
     $order = Order::builder()->find($parameters['id']);
     if ($order == null) {
         return redirect()->route($this->resource == 'octopus-stock' ? 'octopusStock' : 'octopusLaboratoryOrder')->with(['msg' => 2, 'txtMsg' => trans('octopus::pulsar.order_does_not_exist', ['id' => $parameters['id']])]);
     }
     if ($order->stock_id_079 != null) {
         return redirect()->route($this->resource == 'octopus-stock' ? 'octopusStock' : 'octopusLaboratoryOrder')->with(['msg' => 2, 'txtMsg' => trans('octopus::pulsar.stock_already_created', ['id' => $order->id_079])]);
     }
     $object = ['name_076' => $order->name_076, 'address_076' => $order->address_076, 'cp_076' => $order->cp_076, 'locality_076' => $order->locality_076, 'alias_077' => $order->alias_077, 'request_id_080' => $order->request_id_079, 'order_id_080' => $order->id_079, 'supervisor_id_080' => $order->supervisor_id_079, 'customer_id_080' => isset($order->customer_id_079) ? $order->customer_id_079 : null, 'shop_id_080' => $order->shop_id_079, 'company_id_080' => $order->company_id_079, 'family_id_080' => $order->family_id_079, 'brand_id_080' => $order->brand_id_079, 'product_id_080' => $order->product_id_079, 'laboratory_id_080' => $order->laboratory_id_079, 'address_id_080' => isset($order->address_id_079) ? $order->address_id_079 : null, 'company_name_080' => isset($order->company_name_079) ? $order->company_name_079 : null, 'name_080' => isset($order->name_079) ? $order->name_079 : null, 'surname_080' => isset($order->surname_079) ? $order->surname_079 : null, 'country_id_080' => $order->country_id_079, 'territorial_area_1_id_080' => isset($order->territorial_area_1_id_079) ? $order->territorial_area_1_id_079 : null, 'territorial_area_2_id_080' => isset($order->territorial_area_2_id_079) ? $order->territorial_area_2_id_079 : null, 'territorial_area_3_id_080' => isset($order->territorial_area_3_id_079) ? $order->territorial_area_3_id_079 : null, 'cp_080' => isset($order->cp_079) ? $order->cp_079 : null, 'locality_080' => isset($order->locality_079) ? $order->locality_079 : null, 'address_080' => isset($order->address_079) ? $order->address_079 : null, 'phone_080' => isset($order->phone_079) ? $order->phone_079 : null, 'email_080' => isset($order->email_079) ? $order->email_079 : null, 'observations_080' => isset($order->observations_079) ? $order->observations_079 : null, 'view_height_080' => $order->view_width_079, 'view_width_080' => $order->view_height_079, 'total_height_080' => isset($order->total_width_079) ? $order->total_width_079 : null, 'total_width_080' => isset($order->total_height_079) ? $order->total_height_079 : null, 'units_080' => $order->units_079, 'expiration_080' => isset($order->expiration_079) ? $order->expiration_079 : null, 'expiration_text_080' => isset($order->expiration_text_079) ? $order->expiration_text_079 : null, 'attachment_080' => isset($order->attachment_079) ? $order->attachment_079 : null, 'comments_080' => isset($order->comments_079) ? $order->comments_079 : null];
     $parameters['object'] = (object) $object;
     return $parameters;
 }
Example #2
0
 private function sendOrderEmail($id, $action)
 {
     // send email confirmation
     $order = Order::builder()->find($id);
     $laboratory = Laboratory::builder()->where('favorite_073', true)->get()->first();
     // get notification account
     $notificationsAccount = Preference::getValue('octopusNotificationsAccount', 8);
     $emailAccount = EmailAccount::find($notificationsAccount->value_018);
     if ($emailAccount == null) {
         return null;
     }
     config(['mail.host' => $emailAccount->outgoing_server_013]);
     config(['mail.port' => $emailAccount->outgoing_port_013]);
     config(['mail.from' => ['address' => $emailAccount->email_013, 'name' => $emailAccount->name_013]]);
     config(['mail.encryption' => $emailAccount->outgoing_secure_013 == 'null' ? null : $emailAccount->outgoing_secure_013]);
     config(['mail.username' => $emailAccount->outgoing_user_013]);
     config(['mail.password' => Crypt::decrypt($emailAccount->outgoing_pass_013)]);
     $supervisor = User::builder()->find($order->supervisor_id_079);
     $shop = Shop::builder()->find($order->shop_id_079);
     // send email to laboratory
     $dataMessage = ['emailTo' => $laboratory->email_073, 'nameTo' => $laboratory->company_name_073, 'subject' => trans($action == 'update' ? 'octopus::pulsar.order_subject_update' : 'octopus::pulsar.order_subject_create', ['id' => $order->id_079, 'name' => $supervisor->name_010, 'surname' => $supervisor->surname_010]), 'order' => $order, 'supervisor' => $supervisor, 'shop' => $shop, 'key' => Crypt::encrypt($order->id_079), 'actions' => 'laboratory_order_actions_notification'];
     Mail::send('octopus::emails.order_notification', $dataMessage, function ($m) use($dataMessage) {
         $m->to($dataMessage['emailTo'], $dataMessage['nameTo'])->subject($dataMessage['subject']);
     });
 }