public function getAll($num = 10) { if (!is_numeric($num)) { $num = 10; } if ($num == 0) { $lawyers = Lawyer::All(); } else { $lawyers = Lawyer::orderBy('last_name')->orderBy('first_name')->paginate($num); } return view('lawyer.list', compact('lawyers')); }
public function postReports(Request $request) { $lawyer = Lawyer::orderBy('last_name')->orderBy('first_name'); if ($request['gender'] != 'X') { $lawyer = $lawyer->where('gender', '=', $request['gender']); } $last_name = str_replace(' ', '', $request['last_name']); if ($last_name != "") { $lawyer = $lawyer->where('last_name', 'like', $last_name . '%'); } $first_name = str_replace(' ', '', $request['first_name']); if ($first_name != "") { $lawyer = $lawyer->where('first_name', 'like', $first_name . '%'); } $lawyers = $lawyer->get(); $rows = ""; if ($lawyers->count() == 0) { $html = '<div style="text-align:center"><p>Sin datos para mostrar</p></div>'; } else { $cont = 0; foreach ($lawyers as $lawyer) { $cont++; $mod = $cont % 2 == 0; if ($mod == 1) { $rows .= '<tr>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: left;">' . $lawyer->last_name . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: left;">' . $lawyer->first_name . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: center;">' . $lawyer->identification . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: center;">' . $lawyer->registration_number . '</td>' . '<td style="background: #E8EDFF; color: #1E252B; font-size: 12px; text-align: center; width: 150px;"></td>' . '</tr>'; } else { $rows .= '<tr>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: left;">' . $lawyer->last_name . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: left;">' . $lawyer->first_name . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: center;">' . $lawyer->identification . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: center;">' . $lawyer->registration_number . '</td>' . '<td style="background: #F5F5F5; color: #1E252B; font-size: 12px; text-align: center; width: 150px;"></td>' . '</tr>'; } } $html = '<div>' . '<table style="width:100%;">' . '<thead style="">' . '<tr>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Apellidos</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Nombres</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Cédula</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px;">Matricula</th>' . '<th style="background: #D0DAFD; color: #2355AE; font-size: 14px; width: 150px;">Firma</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;">Padrón Electoral</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('padron.pdf', 'D'); }