Tryag File Manager
Home
||
Turbo Force
||
B-F Config_Cpanel
Current Path :
/
home
/
thebestprx
/
public_html
/
admin
/
news
/
Or
Select Your Path :
Upload File :
New :
File
Dir
/home/thebestprx/public_html/admin/news/list.php
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <? include("../include/title.php"); include("../include/chksession.php"); include("../include/connect.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'); }); //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_news.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_name; $(".chk_show").each(function(index){ need_id = $(this).attr("data-id"); need_show = $(this).val(); need_sort =$(".news_sort").eq(index).val(); need_name =$(".news_name").eq(index).val(); param += need_id + ";;"; param += need_sort + ";;"; param += need_show + ";;"; param += need_name + "||"; }); if (param != ''){ $.ajax({ type: "POST", url:"fn_news.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"> <? $current_page=4; 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"> รายการข่าวสาร <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="fa-home"></i> <a href="<?=$server_name?>/dashboard.php">หน้าหลัก</a></li> <li><i class="fa-newspaper-o"></i> <a href="<?=$server_name?>/news/list.php"> ระบบข่าวสาร</a></li> <li class="active"><i class="fa-list"></i> รายการข่าวสาร</li> </ol> <? $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_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_id!="" || $search_price_start!="" || $search_price_end!="") { $where =" where "; if($search_title!="") $where .=" news_name_rh LIKE '%$search_title%' and"; if($search_cate!="") $where .=" (FIND_IN_SET($search_cate,news_main_cate) || FIND_IN_SET($search_cate,news_sub_cate)) and "; if($search_status!="") $where .=" news_status='$search_status' and "; $where = substr($where, 0, strrpos($where, "and")); } $sql="SELECT *, if(news_sort=0,99999,news_sort) AS order2 FROM tb_news $where ORDER BY order2 LIMIT $numrec_per_page OFFSET $start"; $sqlall="SELECT * FROM tb_news $where"; $result=mysql_query($sql); $rec=mysql_num_rows($result); $resultall=mysql_query($sqlall); $allrec=mysql_num_rows($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?>"/> <i class="fa-newspaper-o"></i> <strong>ชื่อข่าวสาร</strong> : <input type="text" name="search_title" value="<?=$search_title?>"> | <?php /*<i class="fa-sitemap"></i> <strong>หมวดหมู่</strong> : <select name="search_cate"><option value="">ทุกหมวดหมู่</option> <? $sql="SELECT *, if(cate_sort=0,99999,cate_sort) AS order2 FROM tb_news_cate WHERE cate_main='0' ORDER BY order2"; $result_cate=mysql_query($sql); while($result_cate && $r_cate=mysql_fetch_array($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>"; $sql="SELECT *, if(cate_sort=0,99999,cate_sort) AS order2 FROM tb_news_cate WHERE cate_main=$cate_id ORDER BY order2"; $result_subcate=mysql_query($sql); while($result_subcate && $r_subcate=mysql_fetch_array($result_subcate)) { $subcate_id=sprintf("%d",$r_subcate['cate_id']); if($search_cate==$subcate_id) $selected="selected"; else $selected=""; echo"<option value='".$subcate_id."' $selected> - ".$r_subcate['cate_name']."</option>"; } } ?> </select> | */?> <i class="fa-heart"></i> สถานะ</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> | <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">เพิ่มข่าวสาร</button></a> </li> <? $post_param="&search_cate=$search_cate&search_status=$search_status&search_title=$search_title"; $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>อันดับ</th> <th>รูปภาพ</th> <th>ชื่อ</th> <!--<th>หมวดหมู่</th>--> <th>สถานะ</th> <th>แก้ไข</th> </tr> <? $count=1; while($result && $r=mysql_fetch_array($result)) { $news_id=sprintf("%d",$r['news_id']); $news_code=$r['news_code']; $news_name_th=$r['news_name_th']; $news_main_cate=$r['news_main_cate']; $news_sub_cate=$r['news_sub_cate']; $news_status=$r['news_status']; $news_sort=$r['news_sort']; if($news_status==1) $publushed="publushed"; else $publushed="unpublushed"; ?> <tr> <td> <input type="checkbox" name="product-<?=$count?>" id="product-<?=$count?>" class="chk_del css-checkbox" data-id='<?=$news_id?>' value='<?=$news_id?>'/> <label for="product-<?=$count?>" class="css-label"></label> </td> <td align="center"><input name="sort" value="<?=$news_sort?>" size="3" class="text-center news_sort"/></td> <td align="center"> <? $sql="SELECT * FROM tb_news_images WHERE imag_newsID='$news_id' ORDER BY imag_sort"; $result_i=mysql_query($sql); $r_i=mysql_fetch_array($result_i); $imag_file=$r_i['imag_file']; if($imag_file!="") echo"<img src='../../album/news/small/$imag_file' width='150px'/>"; else echo"ไม่มีรูปภาพ"; ?> </td> <td><input type="text" value='<?=$news_name_th?>' class="form-control news_name" disabled/></td> <?php /* <td align="center"> <? if($news_main_cate!="") { $category=explode(",",$news_main_cate); $count_cate=count($category); for($x=0;$x<$count_cate;$x++) { if(!empty($category[$x])){ $sql="SELECT * FROM tb_news_cate WHERE cate_id=".$category[$x]; $result_cate=mysql_query($sql); $r_cate=mysql_fetch_array($result_cate); echo "<div class='selected-item-blue'>".$r_cate['cate_name']."</div><br/>"; } } } ?> </td> */?> <td align="center"> <div class="<?=$publushed?>"> <select class="select-publushed chk_show" data-id='<?=$news_id?>'> <option value="1" class="black" <? if($news_status==1) echo "selected";?>>ใช้งาน</option> <option value="0" class="black" <? if($news_status==0) echo "selected";?>>ไม่ใช้งาน</option> </select> </div> </td> <td colspan='6' align='center'><a href="index.php?id=<?=$news_id?>" class="bt-edit"><i class="fa-pencil"></i> แก้ไข</a></td> </tr> <? $count++; } if($allrec=='0') echo"<tr><td colspan='9' align='center'>ไม่พบข้อมูล</td></tr>"; ?> </table> </div> <ul class="records-info records-info-bottom"> <? $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_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_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">บันทึก</li> <li><button class="bt-clear"><i class="fa-trash"></i> ลบ</button></li> </ul> </div> </div><!--main-content--> </body> </html>