コード例 #1
0
 /**
  * Store a newly created resource in storage.
  *
  * @param  \Illuminate\Http\Request $request
  * @param string                    $rp_id
  * @param string                    $header_id
  *
  * @return \Illuminate\Http\Response
  */
 public function store(Request $request, $rp_id, $header_id)
 {
     $this->validate($request, ['reason' => 'required|ands_full']);
     if (request()->ajax()) {
         if ($this->headerRepository->getHeaderById(decode($header_id))) {
             $header = $this->headerRepository->getModel();
             if ($this->repository->storeCancellation($request, $header)) {
                 $mail = new MailController($request->user());
                 $mail->subject = 'Anulacion de Poliza No. ' . $header->prefix . '-' . $header->issue_number;
                 $mail->template = 'de.cancellation';
                 array_push($mail->receivers, ['email' => $header->user->email, 'name' => $header->user->full_name]);
                 if ($mail->send(decode($rp_id), ['header' => $header])) {
                 }
                 return response()->json(['location' => route('td.cancel.lists', ['rp_id' => $rp_id])]);
             }
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back();
 }
コード例 #2
0
ファイル: BaseRepository.php プロジェクト: sibasbo/sibas
 /**
  * @param MailController $mail
  * @param string         $rp_id
  * @param bool           $response
  *
  * @return bool
  */
 public function sendMail(MailController $mail, $rp_id, $response = false)
 {
     $profiles = '';
     $process = '';
     $subject = ':process : Respuesta :response a Caso Facultativo No. ' . $this->header->prefix . '-' . $this->header->issue_number . ' ' . $this->client->full_name;
     $template = 'de.facultative.';
     switch ($this->approved) {
         case 1:
             $process = 'Aprobado';
             $template .= 'process';
             break;
         case 0:
             $process = 'Rechazado';
             $template .= 'process';
             break;
         case 2:
             $process = $this->fa->observations->last()->state->state;
             if ($response) {
                 $template .= 'response';
                 $subject = str_replace(':response', 'del Oficial de Credito', $subject);
             } else {
                 $template .= 'observation';
             }
             break;
     }
     $subject = str_replace(':response', 'de la aseguradora', $subject);
     $subject = str_replace(':process', $process, $subject);
     $mail->subject = $subject;
     $mail->template = $template;
     if ($this->approved >= 0 && !$response) {
         array_push($mail->receivers, ['email' => $this->header->user->email, 'name' => $this->header->user->full_name]);
     } elseif ($response) {
         array_push($mail->receivers, ['email' => $this->fa->observations->last()->user->email, 'name' => $this->fa->observations->last()->user->full_name]);
     }
     $fa = $this->fa;
     $client = $this->client;
     if ($mail->send(decode($rp_id), compact('fa', 'client'), $profiles)) {
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: HeaderController.php プロジェクト: sibasbo/sibas
 /**
  *
  * @param \Sibas\Http\Requests\Td\FacultativeRequestFormRequest $request
  * @param type                                                  $rp_id
  * @param type                                                  $header_id
  *
  * @return type
  */
 public function requestStore(FacultativeRequestFormRequest $request, $rp_id, $header_id)
 {
     if ($this->repository->getHeaderById(decode($header_id)) && $this->repository->storeFacultative($request)) {
         $header = $this->repository->getModel();
         /**/
         $mail = new MailController($request->user());
         $mail->subject = 'Solicitud de aprobación: Caso Facultativo No. ' . $header->prefix . ' - ' . $header->issue_number;
         $mail->template = 'td.request-approval';
         /**/
         if ($mail->send(decode($rp_id), ['header' => $header], 'COP')) {
             $this->repository->storeSent();
         }
         return redirect()->route('td.edit', ['rp_id' => $rp_id, 'header_id' => $header_id])->with(['success_header' => 'Solicitud de aprobación enviada.']);
     }
     return redirect()->back();
 }
コード例 #4
0
ファイル: HeaderController.php プロジェクト: sibasbo/sibas
 /**
  * @param FacultativeRequestFormRequest $request
  * @param string                        $rp_id
  * @param string                        $header_id
  *
  * @return $this|\Illuminate\Http\RedirectResponse
  */
 public function requestStore(FacultativeRequestFormRequest $request, $rp_id, $header_id)
 {
     if ($request->ajax()) {
         if ($this->repository->storeFacultative($request, decode($header_id))) {
             $header = $this->repository->getModel();
             $mail = new MailController($request->user());
             $mail->subject = 'Solicitud de aprobación: Caso Facultativo No. ' . $header->prefix . ' - ' . $header->issue_number;
             $mail->template = 'de.request-approval';
             if ($mail->send(decode($rp_id), ['header' => $header], 'COP')) {
                 $this->repository->storeSent();
             }
             return response()->json(['location' => route('de.edit', compact('rp_id', 'header_id'))]);
         }
         return response()->json(['err' => 'Unauthorized action.'], 401);
     }
     return redirect()->back()->with(['error_header' => 'La solicitud no pudo ser enviada']);
 }