File: /home/pengthai/domains/pengthaicurry.com/public_html/admin/contact/list.php
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<?php
include("../include/chksession.php");
include("../include/connect.php");
include("../include/title.php");
?>
<link href="../css/style.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" href="../css/bootstrap-theme.css"/>
<link rel="stylesheet" type="text/css" href="../css/bootstrap.css"/>
<link rel="stylesheet" type="text/css" href="../css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="../css/component.css"/>
<script type="text/javascript" src="../js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="../js/bootstrap.js"></script>
<script src="../js/jquery.easing.1.3.js"></script>
<script type="text/javascript" src="../js/modernizr.custom.js"></script>
<script src="../js/jquery-ui-1.9.2.custom.js"></script>
<script>
$(function(){
//INPUT FOCUS
$('.product-list input').not('input[type=checkbox]')
.focus(function(){
$(this).parents('tr').addClass('info');
})
.blur(function(){
$(this).parents('tr').removeClass('info');
});
//CHECK ALL PRODUCR
$('#all-product').click(function(){
var checkBox = $('input[type=checkbox]');
var productRow = $('.product-list').find('tr').not('tr:first');
if($(this).is(":checked") == true )
{
checkBox.prop( "checked",true );
productRow.addClass('warning');
}
else
{
checkBox.prop( "checked",false );
productRow.removeClass('warning');
}
});
//CHECK PRODUCR LIST
$('input[type=checkbox]').not('#all-product').change(function(){
var productRow = $(this).parents('tr');
if($(this).is(":checked") == true )
productRow.addClass('warning');
else
productRow.removeClass('warning');
});
//ADD PRODUCT CATE
$('.add-cate').click(function(){
var cateBox = $(this).parent('.widget-select').next('.widget-inbox-cate');
var addCateBox =cateBox.next('.add-cate-box');
if(cateBox.css('display')=='block')
{
cateBox.hide();
addCateBox.hide();
}
else
{
cateBox.show();
addCateBox.show();
}
});
//CHANGE CLASS SELECT PUBLUSHED
$('.select-publushed').change(function(){
var $publushed = $(this).parent();
var value = $(this).val();
if(value=='1')
$publushed.removeClass('unpublushed').addClass('publushed');
else
$publushed.removeClass('publushed').addClass('unpublushed');
});
//CHANGE CLASS SELECT PUBLUSHED
$('.select-publushed-home').change(function(){
var $publushed_home = $(this).parent();
var value = $(this).val();
if(value=='1')
$publushed_home.removeClass('unpublushed').addClass('publushed');
else
$publushed_home.removeClass('publushed').addClass('unpublushed');
});
//DELETE RECORD
$(".bt-clear").click(function(){
if( confirm('หากต้องการลบ กรุณายืนยันอีกครั้ง')==false )
{
return false;
}
var $chkdel = $(".chk_del");
data = "";
$chkdel.each(function(index, value){
if ($(this).is(":checked")) {
data += $(this).attr("data-id") + "," ;
}
});
if (data != ''){
$.ajax({
type: "POST",
url:"fn_save.php",
data: {del:data, action:"del-list"},
/* data: $(this).serialize(),*/
dataType: "json",
success: function(data){
if (parseInt(data.stat) == 1)
{
alert(data.txt);
location.reload();
}
else
alert(data.txt);
}
});
}
return false;
});
//SAVE RECORD
$(".bt-save").click(function(){
var param ="";
var need_id ;
var need_sort ;
var need_show;
var need_showhome;
var need_name;
$(".chk_show").each(function(index){
need_id = $(this).attr("data-id");
need_show = $(this).val();
need_showhome = $(".chk_showhome").eq(index).val();
need_sort =$(".prod_sort").eq(index).val();
need_name =$(".prod_name").eq(index).val();
param += need_id + ";;";
param += need_sort + ";;";
param += need_show + ";;";
param += need_showhome + ";;";
param += need_name + "||";
});
if (param != ''){
$.ajax({
type: "POST",
url:"fn_save.php",
data : {save:param, action:"save-list"},
dataType: "json",
success: function(data){
alert(data.txt);
if (parseInt(data.stat) == 1)
location.reload();
}
});
}
});
//เปลี่ยนจำนวนการแสดงสินค้าต่อหน้า
$('.show-rec-no').change(function(){
var value = $(this).val();
window.location.href = value;
});
});
</script>
</head>
<body>
<div id="header" class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<?php
include("config.inc.php");
$current_page= $current_page ;
include("../include/header-left-menu.inc.php");
include("../include/function.php");
?>
</div>
</div>
<div class="h20"></div>
<div id="main-content" class="page-product">
<div class="title"><?=$topic_titlelist?>
<ul class="tool">
<li><button class="bt-clear"><i class="fa-trash"></i> ลบ</button></li>
<li><button class="bt-save">บันทึก</button></li>
</ul>
</div>
<ol class="breadcrumb margin0">
<li><i class="<?=$icon_main?>"></i> <a href="<?=$server_name?>/dashboard.php"><?=$topic_main?></a></li>
<li><i class="<?=$icon_system?>"></i> <a href="<?=$server_name?>/<?=$path_system?>/list.php"><?=$topic_system?></a></li>
<li class="active"><i class="<?=$icon_list?>"></i> <?=$topic_titlelist?></li>
</ol>
<?php
$noPg = $_GET['no-pg'];
if(empty($noPg))
$noPg=10;
$numrec_per_page = $noPg; //กำหนดแสดงกี่เรคคอร์ดต่อ 1 หน้า
$showpage = $_GET[pg];
if( $showpage == "" or $showpage <= 0 )
$showpage = 1;
$start = ($showpage-1)*$numrec_per_page;
$search_cate=$_GET['search_cate'];
$search_status=$_GET['search_status'];
$search_home=$_GET['search_home'];
$search_title=$_GET['search_title'];
$search_id=$_GET['search_id'];
$search_price_start=$_GET['search_price_start'];
$search_price_end=$_GET['search_price_end'];
if($search_title!="" || $search_cate!="" || $search_status!="" || $search_home!="" || $search_id!="" || $search_price_start!="" || $search_price_end!="")
{
$where =" where ";
if($search_title!="")
$where .=" ((data_name_th LIKE '%$search_title%' ) || (data_name_en LIKE '%$search_title%' ) )and";
if($search_cate!="")
$where .=" FIND_IN_SET($search_cate,data_main_cate) and ";
if($search_status!="")
$where .=" data_status='$search_status' and ";
if($search_home!="")
$where .=" data_show='$search_home' and ";
if($search_id!="")
$where .=" data_id='$search_id' and ";
if($search_price_start!="" && $search_price_end=="")
$where .=" data_price >= '$search_price_start' and ";
if($search_price_start=="" && $search_price_end!="")
$where .=" data_price <= '$search_price_end' and ";
if($search_price_start!="" && $search_price_end!="")
$where .=" data_price BETWEEN $search_price_start AND $search_price_end and";
$where = substr($where, 0, strrpos($where, "and"));
}
$sql="SELECT *, IF(data_sort=0,99999,data_sort) AS order2 FROM $table_main $where ORDER BY order2, data_date DESC ,data_id DESC LIMIT $numrec_per_page OFFSET $start";
$sqlall="SELECT * FROM $table_main $where";
$result=mysql_queryx($sql);
$rec=mysql_num_rowsx($result);
$resultall=mysql_queryx($sqlall);
$allrec=mysql_num_rowsx($resultall);
?>
<div class="h10"></div>
<div class="alert alert-info list-search" role="alert">
<form action="list.php" method="get" id="Form1" enctype="multipart/form-data">
<input name="no-pg" type="hidden" value="<?=$noPg?>"/>
<!--<strong># รหัส</strong> : <input type="text" name="search_id" value="<?=$search_id?>"> | -->
<i class="<?=$icon_system?>"></i> <strong>ชื่อ<?=$title_main?></strong> : <input type="text" name="search_title" value="<?=$search_title?>"> |
<div class="display-none">
<i class="fa-sitemap"></i> <strong>หมวดหมู่</strong> :
<select name="search_cate">
<option value="">ทุกหมวดหมู่</option>
<?php
$sql="SELECT *, IF(cate_sort=0,99999,cate_sort) AS order2 FROM $table_cate ORDER BY order2";
$result_cate=mysql_queryx($sql);
while($result_cate && $r_cate=mysql_fetch_arrayx($result_cate))
{
$cate_id=sprintf("%d",$r_cate['cate_id']);
if($search_cate==$cate_id)
$selected="selected";
else
$selected="";
echo"<option value='".$cate_id."' $selected>".$r_cate['cate_name']."</option>";
}
?>
</select> |
</div>
<i class="fa-heart"></i> <strong>สถานะ</strong></strong> :
<select name="search_status"><option value="">ทุกสถานะ</option>
<option value="1" <? if($search_status==1) echo"selected"; ?>>ใช้งาน</option>
<option value="0" <? if($search_status=='0') echo"selected"; ?>>ไม่ใช้งาน</option>
</select> |
<div class="display-none">
<i class="fa-home"></i> <strong>หน้าแรก</strong></strong> :
<select name="search_home"><option value="">ทุกสถานะ</option>
<option value="1" <? if($search_home==1) echo"selected"; ?>>ใช้งาน</option>
<option value="0" <? if($search_home=='0') echo"selected"; ?>>ไม่ใช้งาน</option>
</select> |
</div>
<button class="bt-search"><strong><i class="fa-search"></i> ค้นหา</strong></button>
</form>
</div>
<div class="h10"></div>
<ul class="records-info">
<li><a href="index.php"><button class="btn btn-info"><?=$topic_add?></button></a> </li>
<?php
$post_param="&search_cate=$search_cate&search_status=$search_status&search_home=$search_home&search_title=$search_title&search_id=$search_id&search_price_start=$search_price_start&search_price_end=$search_price_end";
$allnumpage = ceil($allrec/$numrec_per_page); //ceil ปัดเศษขึ้นเสมอ
echo "<li>".$main_admin['page']." </li>";
//ถอยหลังทีละหนึ่งหน้า
$prevpage = $showpage-1;
if( $prevpage <= 0 )
echo " <a class='bt-prev'><i class='fa-caret-left'></i></a> ";
else
echo " <a href='list.php?pg=$prevpage$post_param&no-pg=$noPg' class='bt-prev'><i class='fa-caret-left'></i></a> ";
//แสดงตัวเลขหน้า + - 3 หน้า
$runpagestart = $showpage-0;
if( $runpagestart <= 0 )
$runpagestart = 1;
$runpagestop = $showpage+0;
if( $runpagestop > $allnumpage )
$runpagestop = $allnumpage;
//echo $runpagestart; echo $runpagestop;
for( $x=0 ; $x < ($runpagestop-$runpagestart+1) ; $x++ )
{
$count = $x+$runpagestart;
if( $count==$showpage ){
echo '<input type="text" size="3" value="'.$count.'" disabled/>';
}else{
echo '<input type="text" size="3" value="'.$count.'" disabled/>';
}
}
//เดินหน้าทีละหนึ่งหน้า
$nextpage = $showpage+1;
if( ($showpage*$numrec_per_page) >= $allrec )
echo " <a class='bt-next'><i class='fa-caret-right'></i></a> ";
else
echo " <a href='list.php?pg=$nextpage$post_param&no-pg=$noPg' class='bt-next'><i class='fa-caret-right'></i></a>";
echo " จาก $allnumpage หน้า";
?>
<li> <strong>|</strong> </li>
<li> หน้าละ
<select class="show-rec-no">
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=10" <? if($noPg=='10') echo "selected"; else echo""; ?>>10</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=20" <? if($noPg=='20') echo "selected"; else echo""; ?>>20</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=50" <? if($noPg=='50') echo "selected"; else echo""; ?>>50</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=100" <? if($noPg=='100') echo "selected"; else echo""; ?>>100</option>
</select> แถว </li>
<li> <strong>|</strong> </li>
<li>พบทั้งหมด <strong><?=$allrec?></strong> รายการ</li>
</ul>
<div class="scroll-x">
<table class="table table-bordered product-list">
<tr>
<th width="40px"><input type="checkbox" name="all-product" id="all-product" class="css-checkbox" /><label for="all-product" class="css-label"></label></th>
<th width="8%">อันดับ</th>
<!--<th>รหัส สินค้า</th>
<th width="15%">รูปภาพ</th>-->
<th>ชื่อ<?=$title_main?></th>
<!--<th width="15%">หมวดหมู่</th>-->
<th width="15%">สถานะ</th>
<!--<th width="10%">หน้าแรก</th>-->
<th width="10%">แก้ไข</th>
</tr>
<?php
$count=1;
while($result && $r=mysql_fetch_arrayx($result))
{
$data_id=sprintf("%d",$r['data_id']);
$data_code=$r['data_code'];
$data_name_th=$r['data_name_th'];
$data_name_en=$r['data_name_en'];
$data_price=$r['data_price'];
$data_price2=$r['data_price2'];
$data_main_cate=$r['data_main_cate'];
$data_sub_cate=$r['data_sub_cate'];
$data_status=$r['data_status'];
$data_sort=$r['data_sort'];
$data_show=$r['data_show'];
$data_vdo=$r['data_vdo'];
if($data_status==1)
$publushed="publushed";
else
$publushed="unpublushed";
if($data_show==1)
$publushed_home="publushed";
else
$publushed_home="unpublushed";
?>
<tr>
<td>
<input type="checkbox" name="product-<?=$count?>" id="product-<?=$count?>" class="chk_del css-checkbox" data-id='<?=$data_id?>' value='<?=$data_id?>'/>
<label for="product-<?=$count?>" class="css-label"></label>
</td>
<td align="center"><input name="sort" value="<?=$data_sort?>" size="3" class="text-center prod_sort"/></td>
<!--<td align="center"><?=$data_code?></td>-->
<td align="center" class="display-none">
<?php
$sql="SELECT *, IF(imag_sort=0,99999,imag_sort) AS order2 FROM $table_img WHERE imag_mainID='$data_id' ORDER BY order2 ASC LIMIT 1";
$result_i=mysql_queryx($sql);
$r_i=mysql_fetch_arrayx($result_i);
$imag_file=$r_i['imag_file'];
if(!empty($imag_file)){
echo"<img src='../../album/$folder_main/small/$imag_file' width='100px'/>";
}else{
if (!empty($data_vdo)) {
// $filename= "http://img.youtube.com/vi/$prod_vdo/maxresdefault.jpg" ;
echo"<img src='http://img.youtube.com/vi/$data_vdo/maxresdefault.jpg' width='100px'/>";
} else {
echo"<img src='../images/nopic.png' width='100px'/>";
}
}
?>
</td>
<td><span class="lang">TH</span> : <?=$data_name_th?><div class="h10"></div><span class="lang">EN</span> : <?=$data_name_en?></td>
<!-- <td align="center">
<?php
if($data_main_cate!=""){
$category=explode(",",$data_main_cate);
$count_cate=count($category);
for($x=0;$x<$count_cate;$x++){
if(!empty($category[$x])){
$sql="SELECT * FROM $table_cate WHERE cate_id=".$category[$x];
$result_cate=mysql_queryx($sql);
$r_cate=mysql_fetch_arrayx($result_cate);
echo "<div class='selected-item-blue'>".$r_cate['cate_name']."</div><div class='cleaner'></div>";
}
}
}
?>
</td>-->
<td align="center">
<div class="<?=$publushed?>">
<select class="select-publushed chk_show" data-id='<?=$data_id?>'>
<option value="1" class="black" <? if($data_status==1) echo "selected";?>>ใช้งาน</option>
<option value="0" class="black" <? if($data_status==0) echo "selected";?>>ไม่ใช้งาน</option>
</select>
</div>
</td>
<!--<td align="center">
<div class="<?=$publushed_home?>">
<select class="select-publushed-home chk_showhome" data-id='<?=$data_id?>'>
<option value="1" class="black" <? if($data_show==1) echo "selected";?>>ใช้งาน</option>
<option value="0" class="black" <? if($data_show==0) echo "selected";?>>ไม่ใช้งาน</option>
</select>
</div>
</td>-->
<td colspan='6' align='center'><a href="index.php?id=<?=$data_id?>" class="bt-edit"><i class="fa-pencil"></i> แก้ไข</a></td>
</tr>
<?php
$count++;
}
if($allrec=='0')
echo"<tr><td colspan='9' align='center'>ไม่พบข้อมูล</td></tr>";
?>
</table>
</div>
<ul class="records-info records-info-bottom">
<?php
$allnumpage = ceil($allrec/$numrec_per_page); //ceil ปัดเศษขึ้นเสมอ
echo "<li>".$main_admin['page']." </li>";
//ถอยหลังทีละหนึ่งหน้า
$prevpage = $showpage-1;
if( $prevpage <= 0 )
echo " <a class='bt-prev'><i class='fa-caret-left'></i></a> ";
else
echo " <a href='list.php?pg=$prevpage&search_cate=$search_cate&search_status=$search_status&search_home=$search_home&search_title=$search_title&no-pg=$noPg' class='bt-prev'><i class='fa-caret-left'></i></a> ";
//แสดงตัวเลขหน้า + - 3 หน้า
$runpagestart = $showpage-0;
if( $runpagestart <= 0 )
$runpagestart = 1;
$runpagestop = $showpage+0;
if( $runpagestop > $allnumpage )
$runpagestop = $allnumpage;
//echo $runpagestart; echo $runpagestop;
for( $x=0 ; $x < ($runpagestop-$runpagestart+1) ; $x++ )
{
$count = $x+$runpagestart;
if( $count==$showpage )
{
echo '<input type="text" size="3" value="'.$count.'" disabled/>';
}
else
{
echo '<input type="text" size="3" value="'.$count.'" disabled/>';
}
}
//เดินหน้าทีละหนึ่งหน้า
$nextpage = $showpage+1;
if( ($showpage*$numrec_per_page) >= $allrec )
echo " <a class='bt-next'><i class='fa-caret-right'></i></a> ";
else
echo " <a href='list.php?pg=$nextpage&search_cate=$search_cate&search_status=$search_status&search_home=$search_home&search_title=$search_title&no-pg=$noPg' class='bt-next'><i class='fa-caret-right'></i></a>";
echo " จาก $allnumpage หน้า";
?>
<li> <strong>|</strong> </li>
<li> หน้าละ
<select class="show-rec-no">
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=10" <? if($noPg=='10') echo "selected"; else echo""; ?>>10</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=20" <? if($noPg=='20') echo "selected"; else echo""; ?>>20</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=50" <? if($noPg=='50') echo "selected"; else echo""; ?>>50</option>
<option value="list.php?pg=<?=$count.$post_param?>&no-pg=100" <? if($noPg=='100') echo "selected"; else echo""; ?>>100</option>
</select> แถว </li>
<li> <strong>|</strong> </li>
<li>พบทั้งหมด <strong><?=$allrec?></strong> รายการ</li>
</ul>
<div class="tool-bottom col-xs-12">
<ul>
<li><button class="bt-save">บันทึก</button></li>
<li><button class="bt-clear"><i class="fa-trash"></i> ลบ</button></li>
</ul>
</div>
</div><!--main-content-->
</body>
</html>