<?php
/*!
* Copyright Anucha Puangpaka
* Contact anucha.ppk@icloud.com 062-479-9836
*/
session_start();
error_reporting(E_ALL);
ini_set("display_errors", 0);
include('../../ap.php');
include('../../connDB.php');
$sql = "select * from ap_settings";
$query = mysqli_query($conn,$sql);
$rows = mysqli_fetch_array($query);
$title = $rows['title'];
$logo = $rows['logo'];
if($_GET['nu']==""){
require_once('../../mpdf/mpdf.php');
if(empty($_GET['code']) || $_GET['code']=="IndDev"){
$headTitle = "การพัฒนาบุคลากร";
}else{
$headTitle = "การบริการวิชาการ";
}
$head = "
<p class='font-8' style='text-align:right'>หน้า $ap_page {PAGENO}/{nbpg}</p>
<table class='font-12' width='100%'>
<tr>
<td align='center'><img src='$logo' style='width: 40px'></td>
</tr>
<tr>
<td align='center'>ตาราง$headTitle $title</td>
</tr>
</table>";
$foot = "
<table class='font-8' width='100%'>
<tr>
<td>$title : <a href='$ap_site$ap_folder' target='_blank'>$ap_site$ap_folder</a></td>
<td align='right'>ณ วันที่ ".date('d-m-Y')."</td>
</tr>
</table>";
$html = "
<table class='font-12' width='100%' border='1' cellpadding=\"5\" cellspacing=\"0\">
<thead>
<tr bgcolor=\"#cccccc\">
<th width='140' align=\"center\">วัน เดือน ปี</th>
<th align=\"center\">เรื่อง</th>
<th width='200' align=\"center\">รายชื่อ</th>
<th width='200' align=\"center\">สถานที่</th>
<th width='100' align=\"center\">จังหวัด</th>
</tr>
</thead>
<tbody>
";
if(empty($_GET['q'])){
$_GET['q'] = date('Y');
}
$xq = explode('/', $_GET['q']);
$cxq = count($xq);
if($cxq==1){
$sql = "select * from ap_users_job_description where code='$_GET[code]' and (date_time like '$_GET[q]%') or (listname like '%$_GET[q]%') or (title like '%$_GET[q]%') or (province like '%$_GET[q]%') or (location like '%$_GET[q]%') order by date_time asc";
}else{
$sql = "select * from ap_users_job_description where code='$_GET[code]' and (date_time > '$xq[0]%' and date_time < '$xq[1]%') order by date_time asc";
}
$query = mysqli_query($conn,$sql);
$i = 0;
while($rows = mysqli_fetch_array($query)){
$i++;
$sql2 = "select * from ap_users where user='$rows[createBy]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
$html .= "
<tr>
<td valign='top'>$rows[dateTime]</td>
<td valign='top'>$rows[title]</td>
<td valign='top'>$rows[listname]</td>
<td valign='top'>$rows[location]</td>
<td valign='top'>$rows[province]</td>
</tr>";
}
$html .= "
</tbody>
</table>";
$html2 = "
<table class='font-12' width='100%'>
<tr>
<td height='50'></td>
<td width='320'></td>
</tr>
<tr>
<td></td>
<td>(ลงนาม)</td>
</tr>
<tr>
<td></td>
<td align='center'>(...................................................................)</td>
</tr>
<tr>
<td></td>
<td align='center'>ผู้อำนวยการ/ผู้ที่ได้รับมอบหมายเท่านั้น</td>
</tr>
</table>
";
$pdf = new mPDF('th', 'A4-L', '0', '', 15, 15, 40, 15);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullpage', 'two');
$stylesheet = file_get_contents('style.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($head);
$pdf->SetHTMLHeader($head,'E');
$pdf->SetHTMLFooter($foot);
$pdf->SetHTMLFooter($foot,'E');
$pdf->SetWatermarkImage("../../contents/images/arit-logo512.png");
$pdf->showWatermarkImage = true;
$pdf->watermarkImageAlpha = 0.03;
$pdf->SetTitle("$title");
$pdf->SetAuthor("$title");
$pdf->SetCreator("Anucha Puangpaka");
$pdf->SetSubject("$title");
$pdf->SetKeywords("$title");
$pdf->WriteHTML($html, 2);
// $pdf->WriteHTML($html2, 2);
$pdf->Output();
}
/*if($_GET['nu']=="calendar_work"){
require_once('mpdf/mpdf.php');
$head = "
<p class='font-8' style='text-align:right'>$kpru_owner</p>
<table class='font-12' width='100%'>
<tr>
<td align='center'><img src='images/logo.png' style='width: 60px'></td>
</tr>
<tr>
<td align='center'>$kpru_calendar_work</td>
</tr>
<tr>
<td align='center'>$kpru_title_games</td>
</tr>
<tr>
<td align='center'>$kpru_title_games2</td>
</tr>
<tr>
<td align='center'>$kpru_title_games3</td>
</tr>
<tr>
<td align='center'>*************************************************************************</td>
</tr>
</table>";
$foot = "
<table class='font-8' width='100%'>
<tr>
<td>$kpru_sub_owner</td>
<td align='right'>ณ วันที่ ".date('d-m-Y')." / หน้า $ap_page {PAGENO}</td>
</tr>
</table>";
$html = "
<table class='font-12' width='100%' border='1' cellpadding=\"3\" cellspacing=\"0\">
<thead>
<tr bgcolor=\"#cccccc\">
<th width=\"50\">ลำดับ</th>
<th width=\"200\">วันที่</th>
<th>รายการ</th>
</tr>
</thead>
<tbody>
";
$sql = "select * from tb_calendar_work order by cDate asc";
$query = mysqli_query($conn,$sql);
$i = 0;
while($rows = mysqli_fetch_array($query)){
$i++;
$html .= "<tr>
<td>$i.</td>
<td>$rows[code]</td>
<td>$rows[name]</td>
</tr>
";
}
$html .= "
</tbody>
</table>
";
$html2 = "";
$pdf = new mPDF('th', 'A4', '0', '', 15, 15, 58, 15);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullwidth');
$stylesheet = file_get_contents('style.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($head);
$pdf->SetHTMLHeader($head,'E');
$pdf->SetHTMLFooter($foot);
$pdf->SetHTMLFooter($foot,'E');
$pdf->SetWatermarkImage('images/logo-300.png');
$pdf->showWatermarkImage = true;
$pdf->watermarkImageAlpha = 0.1;
$pdf->SetTitle("$kpru_calendar_work $kpru_title");
$pdf->SetAuthor("$kpru_owner");
$pdf->SetCreator("$kpru_owner");
$pdf->SetSubject("$kpru_title");
$pdf->SetKeywords("$kpru_title_games, $kpru_title_games2, $kpru_title_games3");
$pdf->WriteHTML($html, 2);
$pdf->WriteHTML($html2, 2);
$pdf->Output();
}
if($_GET['nu']=="calendar_event"){
require_once('mpdf/mpdf.php');
$head = "
<p class='font-8' style='text-align:right'>$kpru_owner</p>
<table class='font-12' width='100%'>
<tr>
<td align='center'><img src='images/logo.png' style='width: 60px'></td>
</tr>
<tr>
<td align='center'>$kpru_calendar_event</td>
</tr>
<tr>
<td align='center'>$kpru_title_games</td>
</tr>
<tr>
<td align='center'>$kpru_title_games2</td>
</tr>
<tr>
<td align='center'>$kpru_title_games3</td>
</tr>
<tr>
<td align='center'>*************************************************************************</td>
</tr>
</table>";
$foot = "
<table class='font-8' width='100%'>
<tr>
<td>$kpru_sub_owner</td>
<td align='right'>ณ วันที่ ".date('d-m-Y')." / หน้า $ap_page {PAGENO}</td>
</tr>
</table>";
$x_games = explode(',',$kpru_games);
$x_nums = count($x_games);
$html = "
<table class='font-10' width='100%' border='1' cellpadding=\"3\" cellspacing=\"0\">
<thead>
<tr bgcolor=\"#cccccc\">
<th rowspan=\"2\" width=\"50\">ลำดับ</th>
<th rowspan=\"2\" width=\"150\">รายการ</th>
<th colspan='$x_nums'>วันที่จัดการแข่งขัน</th>
<th rowspan=\"2\">สถานที่</th>
</tr>
<tr bgcolor=\"#cccccc\">
";
for($i=0;$i<$x_nums;$i++){
$html .= "<th width=\"50\">$x_games[$i]</th>";
}
$html .= "
</tr>
</thead>
<tbody>
<tr>
<td>1.</td>
<td>$kpru_meeting</td>
";
for($i=0;$i<$x_nums;$i++){
$html .= "<td align='center' width=\"50\">";
if($x_games[$i]=="$kpru_meeting_date"){
$html .= "<img src=\"images/logo.png\" width=\"20px\" alt=\"$kpru_title\">";
}
$html .= "</td>";
}
$html .= "<td>$kpru_meeting_room</td>
</tr>
<tr>
<td>2.</td>
<td>$kpru_meeting2</td>
";
for($i=0;$i<$x_nums;$i++){
$html .= "<td align='center' width=\"50\">";
if($x_games[$i]=="$kpru_meeting2_date"){
$html .= "<img src=\"images/logo.png\" width=\"20px\" alt=\"$kpru_title\">";
}
$html .= "</td>";
}
$html .= "<td>$kpru_meeting2_room</td>
</tr>
";
$sql = "select * from tb_calendar_event order by level asc";
$query = mysqli_query($conn,$sql);
$i = 0;
while($rows = mysqli_fetch_array($query)){
$i++;
$sql2 = "select * from tb_sports_type where code='$rows[sportType]'";
$query2 = mysqli_query($conn,$sql2);
$rows2 = mysqli_fetch_array($query2);
$html .= "<tr>
<td>".($i+2).".</td>
<td>$rows2[name]</td>
";
$xx_sport = explode(',',$rows['dates']);
for($i2x=0;$i2x<$x_nums;$i2x++){
$html .= "<td align='center' width=\"50\">";
if($x_games[$i2x]=="$xx_sport[$i2x]"){
$html .= "<img src=\"contents/sports_types/$rows2[files]\" width=\"20px\" alt=\"$kpru_title\">";
}
$html .= "</td>";
}
$html .= "<td>$rows[racecourse]</td>
</tr>
";
}
$html .= "<tr>
<td>".($i+2+1).".</td>
<td>$kpru_meeting3</td>
";
for($i2=0;$i2<$x_nums;$i2++){
$html .= "<td align='center' width=\"50\">";
if($x_games[$i2]=="$kpru_meeting3_date"){
$html .= "<img src=\"images/logo.png\" width=\"20px\" alt=\"$kpru_title\">";
}
$html .= "</td>";
}
$html .= "<td>$kpru_meeting3_room</td>
</tr>
</tbody>
</table>
";
$html2 = "";
$pdf = new mPDF('th', 'A4', '0', '', 15, 15, 58, 15);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullwidth');
$stylesheet = file_get_contents('style.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($head);
$pdf->SetHTMLHeader($head,'E');
$pdf->SetHTMLFooter($foot);
$pdf->SetHTMLFooter($foot,'E');
$pdf->SetWatermarkImage('images/logo-300.png');
$pdf->showWatermarkImage = true;
$pdf->watermarkImageAlpha = 0.1;
$pdf->SetTitle("$kpru_calendar_event $kpru_title");
$pdf->SetAuthor("$kpru_owner");
$pdf->SetCreator("$kpru_owner");
$pdf->SetSubject("$kpru_title");
$pdf->SetKeywords("$kpru_title_games, $kpru_title_games2, $kpru_title_games3");
$pdf->WriteHTML($html, 2);
$pdf->WriteHTML($html2, 2);
$pdf->Output();
}*/
include('../../logs.php');
mysqli_close($conn);
?>