public function searchDataCase()
 {
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     return $data;
 }
 public function searchDataCase()
 {
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('created_at', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     $start_date = Input::get('start_date');
     $end_date = Input::get('end_date');
     // return $start_date;
     $datacase = DataCase::with('criminalhistory', 'criminalhistory.nametitle')->whereBetween('date_case', [$start_date, $end_date])->get();
     $person = CriminalHistory::with('datacase', 'nametitle')->whereBetween('date', [$start_date, $end_date])->get();
     $person_general = GuestHistory::with('nametitle')->whereBetween('created_at', [$start_date, $end_date])->get();
     $data = [$person, $person_general, $datacase];
     $pdf = \App::make('mpdf.wrapper', ['th', 'A4', '', '', 20, 15, 20, 25, 10, 10]);
     $pdf->SetHeader('
     <table width="100%" style="vertical-align: bottom; font-family: TH SarabunPSK; font-size: 14pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="20%"><img src="img/police.jpg" width="20" height="20"></td>
     <td width="30%" style="text-align: right; ">{PAGENO}</td>
     <td width="55%" style="text-align: right; "> สำนักงานตำรวจตรวจคนเข้าเมือง จังหวัด เชียงราย</td>
     </tr></table>
     ');
     $pdf->SetFooter('
     <table width="100%" style="vertical-align: bottom; font-family: garuda; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="33%"></td>
     <td width="33%"></td>
     <td width="55%" style="text-align: right; ">พิมพ์เมื่อ {DATE D} ที่ {DATE j-m-Y} เวลา {DATE H:i:s}  </td>
     </tr></table>
     ');
     $pdf->SetWatermarkText("");
     $pdf->SetDisplayMode('fullpage');
     $html = view('PDF.statistic')->with('data', $data)->render();
     //        return $html;
     $pdf->WriteHTML($html);
     return $data;
 }
 public function generatedPdfCase($id)
 {
     $datacase = DataCase::with('vehicle', 'weapon', 'criminalhistory', 'criminalhistory.dataspouse', 'criminalhistory.dataspouse', 'criminalhistory.addresspresent', 'criminalhistory.addressoriginal', 'criminalhistory.datamother', 'criminalhistory.addressoffice', 'criminalhistory.datafather', 'criminalhistory.datachild', 'criminalhistory.datacase')->find($id);
     //return $datacase;
     $dataperson = DataCase::find($id)->criminalhistory()->with('datacase')->get();
     //return $dataperson;
     //$pdf = \App::make('mpdf.wrapper',['ภาษา','ขนาดกระดาษ-L=แนวนอน ไม่- แนวตั้ง','','',ขอบซ้ายกระดาษ,ขอบขวากระดาษ,ขอบขนกระดาษ,ขอบล่างกระดาษ,ระยะ title,ระยะ footter]);
     //return $datacase;
     $pdf = \App::make('mpdf.wrapper', ['th', 'A4-L', '', '', 20, 15, 20, 25, 10, 10]);
     $pdf->setTitle("export");
     //$pdf->SetHeader('|{PAGENO}/{nbpg}|สำนักงานตำรวจตรวจคนเข้าเมือง จังหวัด เชียงราย');
     // $pdf->SetFooter('พิมพ์เมื่อ วัน {DATE D} ที่ {DATE j-m-Y} เวลา {DATE H:i:s}  ');
     $pdf->SetHeader('
     <table width="100%" style="vertical-align: bottom; font-family: TH SarabunPSK; font-size: 14pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="20%"></td>
     <td width="30%" style="text-align: right; ">{PAGENO}</td>
     <td width="55%" style="text-align: right; "> ตรวจคนเข้าเมืองจังหวัดเชียงราย</td>
     </tr></table>
     ');
     $pdf->SetFooter('
     <table width="100%" style="vertical-align: bottom; font-family: garuda; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     <td width="33%"></td>
     <td width="33%"></td>
     <td width="55%" style="text-align: right; ">พิมพ์เมื่อ {DATE D} ที่ {DATE j-m-Y} เวลา {DATE H:i:s}  </td>
     </tr></table>
     ');
     $pdf->SetWatermarkText("");
     $pdf->SetDisplayMode('fullpage');
     $html1 = view('PDF.summary')->with('datacase', $datacase)->render();
     $pdf->WriteHTML($html1);
     //
     //        $pdf->SetHTMLHeader('<div style="text-align: right; font-weight: bold;">My document</div>');
     //
     //        $pdf->SetHTMLFooter('
     //        <table width="100%" style="vertical-align: bottom; font-family: serif; font-size: 8pt; color: #000000; font-weight: bold; font-style: italic;"><tr>
     //        <td width="33%"><span style="font-weight: bold; font-style: italic;">{DATE j-m-Y}</span></td>
     //        <td width="33%" align="center" style="font-weight: bold; font-style: italic;">{PAGENO}/{nbpg}</td>
     //        <td width="33%" style="text-align: right; ">My document</td>
     //        </tr></table>
     //        ');
     foreach ($dataperson as $person) {
         $pdf->AddPage('P');
         $html = view('PDF.person')->with('datacase', $datacase)->with('dataperson', $person)->render();
         $pdf->WriteHTML($html);
     }
     $pdf->stream();
 }