public function postPayments(Requests\DefaultRequest $request) { $identification = str_replace(' ', '', $request['identification']); $lawyers = Lawyer::where('identification', '=', $identification)->get(); if ($lawyers->count() == 0) { $errors = array("0" => 'No se encontró registro con la cédula ingresada!'); return $request->response($errors); } $contributions = Contribution::where('lawyer_id', '=', $lawyers[0]->id)->where('year', '=', $request['year'])->orderBy('month')->get(); if ($contributions->count() == 0) { $errors = array("0" => 'No hay registro de pago!'); return $request->response($errors); } $lawyer = $lawyers[0]; $month = array('enero', 'febrero', 'marzo', 'abril', 'mayo', 'junio', 'julio', 'agosto', 'septiembre', 'octubre', 'noviembre', 'diciembre'); $rows = ""; $cont = 0; foreach ($contributions as $item) { $cont++; $mod = $cont % 2 == 0; if ($mod == 1) { $rows .= '<tr>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: left;">' . $month[$item->month - 1] . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: center;">' . $item->amount . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: left; width: 400px;">' . $item->description . '</td>' . '</tr>'; } else { $rows .= '<tr>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: left;">' . $month[$item->month - 1] . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: center;">' . $item->amount . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: left; width: 400px;">' . $item->description . '</td>' . '</tr>'; } } $html = '<p><b style="color:#2254AD; font-size:14px; text-align:left;">Ab .' . $lawyer->first_name . ' ' . $lawyer->last_name . '</b></p>' . '<p>Año: ' . $request->year . '</p>' . '<div>' . '<table style="width:100%;">' . '<thead style="">' . '<tr>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Mes</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Monto</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px; width: 400px;">Nota</th>' . '</tr>' . '</thead>' . '<tbody style="">' . $rows . '</tbody>' . '</table>' . '</div>'; $header = '<header>' . '<div>' . '<h1 style="color:#2254AD; font-size:16px; text-align:left;">Asociación de Abogados de Manta</h1>' . '<h2 style="color:#1E252B; font-size:12px; text-align:left;">Aportaciones</h2>' . '</div>' . '<div style="position:absolute; width: 55px; margin-top:-65px; margin-left:600px;">' . '<img src="assets/image/logo.jpg" alt="" style="width: 50px; height: 50px;">' . '</div>' . '</header>' . '<hr/>'; $footer = '<footer>' . '<hr/>' . '<div style="text-align:right;"><p>{PAGENO}</p></div>' . '</footer>'; $mpdf = new \mPDF('utf-8', 'A4', '', '', '15', '15', '28', '18'); $mpdf->SetHTMLHeader($header); $mpdf->SetHTMLFooter($footer); $mpdf->WriteHTML($html); $mpdf->Output('aportaciones.pdf', 'D'); }
public function postEdit(ContributionEditRequest $request) { $contribution = Contribution::find($request['id']); $exists = Contribution::where('lawyer_id', '=', $contribution->lawyer_id)->where('year', '=', $request['year'])->where('month', '=', $request['month'])->where('id', '<>', $contribution->id)->get(); if ($exists->count() > 0) { $errors = array("0" => 'Ya existe un registro con el mismo Año-Mes'); return $request->response($errors); } $contribution->fill($request->all()); $contribution->save(); return redirect()->route('contribution_view')->with('message', 'editok'); }