<?php
/*!
* Copyright Anucha Puangpaka
* Contacts anucha.ppk@icloud.com 062-479-9836
*/
error_reporting(E_ALL);
ini_set("display_errors", 0);
include('../../head.php');
?>
<style>
.accordionx {
background-color: #f5f5f5;
color: #444;
cursor: pointer;
padding: 15px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}
.activex, .accordionx:hover {
/*background-color: #ccc;*/
}
.panelx {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease-out;
}
.accordionx2 {
background-color: #f5f5f5;
color: #444;
cursor: pointer;
padding: 15px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}
.activex2, .accordionx2:hover {
/*background-color: #ccc;*/
}
.panelx2 {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.5s ease-out;
}
</style>
<div class="container theme-showcase body-main-row-body" role="main">
<div class="breadcrumbx">
<?php //include('../../translate.php'); ?>
<?php
if($_GET['nu']==""){
$ap_qa_header = "
<div class=\"row\">
<div class=\"col-lg-12 col-md-12 col-sm-12\">
<h2 align='center'>คำถามที่พบบ่อย [Q&A]</h2>
<p align='center'>รวบรวมรายการคำถามและคำตอบ จากผู้ใช้บริการของ$title</p>
<p align='center'>******************************</p>
</div>
</div>";
$ap_qa_header2 = "
<h2>คำถามที่พบบ่อย [Q&A]</h2>
<p>รวบรวมรายการคำถามและคำตอบ จากผู้ใช้บริการของ$title</p><hr>";
echo $ap_qa_header;
?>
<ul class="nav nav-tabs">
<li class="active"><a data-toggle="tab" href="#menu1">คำถามที่พบบ่อย</a></li>
<li><a data-toggle="tab" href="#menu2">คำถามทั่วไป</a></li>
</ul>
<div class="tab-content">
<div id="menu1" class="tab-pane fade in active">
<p></p>
<?php
echo "<div class='row'>";
$sql = "select * from ap_question_answer where lang='$_GET[lang]' and type!='' order by xgroup asc, question asc";
$query = mysqli_query($conn,$sql);
$i = 0;
while($rows = mysqli_fetch_array($query)){
$i++;
$sql_1 = "select * from ap_users where user='$rows[createBy]'";
$query_1 = mysqli_query($conn,$sql_1);
$rows_1 = mysqli_fetch_array($query_1);
if($alert=="alert-success"){
$alert = "alert-info";
}else{
$alert = "alert-success";
}
if($rows['xgroup']=='1'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>ข้อมูลห้องสมุด</font></button>";
}
$last = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(autolink(str_replace("\n", '<br>', $rows['answer'])))."</font></p></div>";
echo "</div>";
echo "</div>";
}elseif($rows['xgroup']=='2'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last2!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>บริการห้องสมุด</font></button>";
}
$last2 = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
echo "</div>";
}elseif($rows['xgroup']=='3'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last3!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>ทรัพยากรห้องสมุด</font></button>";
}
$last3 = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
echo "</div>";
}else{
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
}
/*echo "
<font color=red>คำถาม <em>Question</em> : $rows[question]</font><br>
คำตอบ <em>Answer : by $rows_1[fullname]</em>
$rows[answer]<hr>";*/
$ap_qa2 .= "<font color=red>คำถาม <em>Question</em> : $rows[question]</font><br>
คำตอบ <em>Answer : by $rows_1[fullname]</em> $rows[answer]<hr>";
}
echo "</div>";
?>
</div>
<div id="menu2" class="tab-pane fade">
<p></p>
<?php
echo "<div class='row'>";
$sql = "select * from ap_question_answer where lang='$_GET[lang]' and type='2' order by xgroup asc, question asc";
$query = mysqli_query($conn,$sql);
$i = 0;
while($rows = mysqli_fetch_array($query)){
$i++;
$sql_1 = "select * from ap_users where user='$rows[createBy]'";
$query_1 = mysqli_query($conn,$sql_1);
$rows_1 = mysqli_fetch_array($query_1);
if($alert=="alert-success"){
$alert = "alert-info";
}else{
$alert = "alert-success";
}
if($rows['xgroup']=='1'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>ข้อมูลห้องสมุด</font></button>";
}
$last = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
echo "</div>";
}elseif($rows['xgroup']=='2'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last2!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>บริการห้องสมุด</font></button>";
}
$last2 = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
echo "</div>";
}elseif($rows['xgroup']=='3'){
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
if($last3!=$rows['xgroup']){
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-bell\"></span> <font class='h4'>ทรัพยากรห้องสมุด</font></button>";
}
$last3 = $rows['xgroup'];
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"accordionx panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
echo "</div>";
}else{
echo "<div class=\"col-lg-12 col-md-12 col-sm-12\">";
echo "<button class=\"accordionx\"><span class=\"glyphicon glyphicon-question-sign\"></span> <font color=red>คำถาม <em>Question</em> : $rows[question]</font></button>";
echo "<div class=\"panelx\"><br><p><span class=\"glyphicon glyphicon-thumbs-up\"></span> คำตอบ <em>Answer : by $rows_1[fullname]</em></p>
<p><font color=#000>".autolink(str_replace("\n", '<br>', $rows['answer']))."</font></p></div>";
echo "</div>";
}
/*echo "
<font color=red>คำถาม <em>Question</em> : $rows[question]</font><br>
คำตอบ <em>Answer : by $rows_1[fullname]</em>
$rows[answer]<hr>";*/
$ap_qa2 .= "<font color=red>คำถาม <em>Question</em> : $rows[question]</font><br>
คำตอบ <em>Answer : by $rows_1[fullname]</em> $rows[answer]<hr>";
}
echo "</div>";
?>
</div>
<script>
var acc = document.getElementsByClassName("accordionx");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("activex");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>
<script>
var acc = document.getElementsByClassName("accordionx2");
var i;
for (i = 0; i < acc.length; i++) {
acc[i].addEventListener("click", function() {
this.classList.toggle("activex2");
var panel = this.nextElementSibling;
if (panel.style.maxHeight){
panel.style.maxHeight = null;
} else {
panel.style.maxHeight = panel.scrollHeight + "px";
}
});
}
</script>
</div>
<p></p>
<?php
if($_GET['pdf']==1){
require_once('../../mpdf/mpdf.php');
$header = "
<table width=\"100%\" style=\"border-bottom: 1px solid #000000; color: #000088;\">
<tr>
<td width=\"50\"><img src=\"$logo\" style=\"width: 50px\" alt=\"\"></td>
<td><font class=\"style1\">$title</font><br><font class=\"style4\">$title_en</font></span></td>
</tr>
</table>";
$today = date('Y-m-d H:i:s');
$footer = "
<table width=\"100%\" style=\"border-bottom: 0px solid #000000; color: #000088;\">
<tr>
<td><img src='$ap_site$ap_folder"."ap/qrcode/qrcode.php?data=$ap_site$ap_folder?page_id=$_GET[page_id]&lang=$_GET[lang]&size=114x114&logo=$logo' border='0' /></td>
<td align=\"right\"><font class=\"style4\">
<p>$ap_page {PAGENO}</p>
<p>$ap_date : ".date('Y-m-d H:i:s')."</p>
<p>$title<br></p>
<p>$ap_expire : ".date('Y-m-d H:i:s',strtotime("$today +1 month"))."</p>
</font></td>
</tr>
</table>";
$html = "$ap_qa_header2$ap_qa2";
$pdf = new mPDF('th', 'A4', '0', '', 20, 15, 30, 35);
$pdf->mirrorMargins = 1;
$pdf->SetDisplayMode('fullpage');
$stylesheet = file_get_contents('../../theme.css');
$pdf->WriteHTML($stylesheet,1);
$pdf->SetHTMLHeader($header);
$pdf->SetHTMLHeader($header,'E');
$pdf->SetHTMLFooter($footer);
$pdf->SetHTMLFooter($footer,'E');
$pdf->SetWatermarkText("$title_en");
$pdf->watermark_font = 'DejaVuSansCondensed';
$pdf->showWatermarkText = true;
$pdf->SetTitle("บริการตอบคำถาม [Q&A]");
$pdf->SetAuthor("$title");
$pdf->SetCreator("Anucha Puangpaka");
$pdf->SetSubject("บริการตอบคำถาม [Q&A]");
$pdf->SetKeywords("บริการตอบคำถาม [Q&A], $title");
$pdf->WriteHTML($html, 2);
$pdf->Output("../../contents/pdf/question-answer.pdf");
echo "<meta http-equiv='refresh' content='0;URL=$ap_site$ap_folder"."contents/pdf/question-answer.pdf'>";
}
/*$filename = "$ap_site$ap_folder"."contents/pdf/question-answer.pdf";
$file_headers = @get_headers($filename);
if($file_headers[0] == 'HTTP/1.1 200 OK'){*/
?>
<p><!-- <img src='https://arit.kpru.ac.th/ap/qrcode/qrcode.php?data=<?php echo $ap_site.$ap_folder."question-answer.php";?>&size=114x114&logo=<?php echo $logo;?>' border='0' alt="QRCODE" /> --><a href="<?php echo $ap_site.$ap_folder; ?>ap/question-answer/?pdf=1" target="_blank" title="เอกสาร PDF"><img src="<?php echo $ap_site.$ap_folder; ?>contents/images/pdf.png" width="50" height="50"></a></p>
<meta name="citation_pdf_url" content="<?php echo "$ap_site$ap_folder"."contents/pdf/question-answer.pdf";?>">
<?php
//}
}
?>
</div>
</div><!-- /.container -->
<?php
include ('../../footText.php');
include ('../../foot.php');
?>