/home/bjcompany/domains/benjabhorn.com/public_html/BJconcrete/control/showPortfolioList.php


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<?php 
    $rowPerPage
=20;
            if((!
$_GET['page'])||($_GET['page']==1)){
                        
$_GET['page']=1;
                        
$startRow=0;
            }else{
                    
$startRow=($_GET['page']-1)*$rowPerPage;    
                    }
    
####################################################            
            
if($_POST['action']=='ChStatus'){
                
$query="UPDATE tbl_portfolio_data SET  product_firstpage ='".$_POST['changeValue']."'  WHERE   id=  '".$_POST['ids']."' ";
                
mysql_query($query);
                

            }
    
#################################################### number
        
if($_POST['action']=='Sort'){
                for(
$i=1;$i $_POST['Loops']; $i++){
                                 
$query="UPDATE tbl_portfolio_data SET num='".$_POST['Sort'][$i]."' WHERE id='".$_POST['HiddenId'][$i]."' ";
                                 
mysql_query($query);    
                    }
            
        }
    
####################################################
            
if($_POST['action']=='Delete'){
                                @
unlink($path_product.$_POST['image_name']);
                                @
unlink($path_product."/thb/".$_POST['image_name']);    
                                
$query="SELECT * FROM `tbl_portfolio_img` WHERE product_ID=  '".$_POST['ids']."'   ";
                                
$resultIMG=mysql_query($query);    
                                      while(
$data=mysql_fetch_assoc($resultIMG)){
                                                  @
unlink($path_product.$data['file_name']);
                                                @
unlink($path_product."/thb/".$data['file_name']);    
                                          }
                                 
$query="DELETE FROM tbl_portfolio_img WHERE product_ID=  '".$_POST['ids']."'  ";
                                 
mysql_query($query);    
                                 
$query="DELETE FROM tbl_portfolio_data WHERE id=  '".$_POST['ids']."'  ";
                                 
mysql_query($query);        
                                 
            
$query="UPDATE tbl_portfolio_data SET  num = num-1  WHERE   num >   '".$_POST['number']."' ";
                
mysql_query($query);                         
                }
    
####################################################     id DESC  
        //$query="SELECT * FROM tbl_portfolio_data WHERE  mainCateId='".$_GET['ManCateID']."' ORDER BY num ASC  ";
        
$query="SELECT * FROM tbl_portfolio_data   ORDER BY num ASC  ";
        
$queryLimit=$query." LIMIT  $startRow , $rowPerPage  ";
        
$result=mysql_query($queryLimit);
        
        
$resultBrowse2=mysql_query($query);        
        
$xrow=mysql_num_rows($resultBrowse2);
        
$totalPage=ceil($xrow/$rowPerPage);    
        
            
            

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script language="javascript">
        function DeleteThis(ids, image_name, num){
                        if(confirm('ต้องการลบรายการนี้ ?')){
                                    document.form1.action.value='Delete';
                                    document.form1.ids.value=ids;    
                                    document.form1.number.value=num;    
                                    document.form1.image_name.value=image_name;    
                                    document.form1.submit();
                            }else{
                                    return false;
                                }
            }
            //-------------------------------------------------------
            function changeStatus(ids, theValue){
                        if(theValue=='1'){
                                    document.form1.changeValue.value=0;
                            }else if(theValue=='0'){
                                    document.form1.changeValue.value=1;
                            }
                            document.form1.ids.value=ids;    
                            document.form1.action.value='ChStatus';
                            document.form1.submit();    
                }
                //------------------------------------------
                function SortOrder(){
                            if(confirm('ต้องการเรียงลำดับใหม่')){
                                
                                    document.form1.action.value='Sort';
                                    document.form1.submit();        
                            }
                    
                    }
</script>
</head>

<body><form action="<?php $_SERVER['PHP_SELF']?>" method="post" name="form1" enctype="multipart/form-data">
<table width="99%" border="0" align="center" cellpadding="2" cellspacing="2">
  <tr class="red">
    <td width="4%" height="25" align="center" bgcolor="#D9D9B3"><img src="images/black_icon/16x16/app_window.png" width="16" height="16" /></td>
    <td width="96%" bgcolor="#D9D9B3">รายชื่อผลงาน  
      <input name="action" type="hidden"/>
    <input name="ids" type="hidden"/>
    <input name="image_name" type="hidden" />
    <input name="changeValue" type="hidden"  />
    <input name="number" type="hidden"  />   
     </td>
  </tr>
  
  <tr>
    <td colspan="2" class="txt10-black"><table width="100%" border="0" cellspacing="1" cellpadding="0">
         <tr>
        <td height="25" bgcolor="#E0E0E0">&nbsp;</td>
        <td align="center" bgcolor="#E0E0E0" class="txt10-black">ชื่อผลงาน</td>
        <td align="center" bgcolor="#E0E0E0" class="txt10-black">หมายเลขเรียงลำดับ</td>
        <td align="center" bgcolor="#E0E0E0" class="txt10-black">แสดงหน้าแรก</td>
        <td align="center" bgcolor="#E0E0E0" class="txt10-black">แก้ไข</td>
        <td align="center" bgcolor="#E0E0E0" class="txt10-black">ลบ</td>
      </tr>
      <?php $n=1; while($data=mysql_fetch_assoc($result)){ ?>
      <tr>
        <td width="4%" height="25" align="center" bgcolor="#EBEBEB"><img src="images/black_icon/16x16/box.png" width="16" height="16" /></td>
        <td width="56%" bgcolor="#EBEBEB" class="txt10-black">&nbsp;<?php echo $data['product_name_th']?></td>
        <td width="13%" align="center" bgcolor="#EBEBEB" class="txt10-black">
            
          <input type="hidden" name="HiddenId[<?php echo $n?>]" id="HiddenId[<?php echo $n?>]" value="<?php echo $data['id']?>" />
          <select name="Sort[<?php echo $n?>]" id="Sort[<?php echo $n?>]">
                  <?php for($i=1$i<= $xrow$i++){?>
                <option value="<?php echo $i?><?php if($data['num']==$i){ echo "selected";}?>><?php echo $i?></option>
                <?php ?>
                
          </select>
          
          </td>
        <td width="11%" align="center" bgcolor="#EBEBEB" class="txt10-black"><input type="checkbox" name="checkbox[]" id="checkbox[]"  <?php if($data['product_firstpage']==1){ echo "checked";}?> onclick="changeStatus('<?php echo $data['id']?>' , '<?php echo $data['product_firstpage']?>')" /></td>
        <td width="8%" align="center" bgcolor="#EBEBEB">
          <a href="main.php?work=portfolioAdd&currID=<?php echo $data['id']?>" title="แก้ไข <?php echo $data['cate_name']?>">
            <img src="images/black_icon/16x16/doc_edit.png" width="16" height="16" border="0" /></a>
        </td>
        <td width="8%" align="center" bgcolor="#EBEBEB">
        <a href="#" title="ลบ <?php echo $data['product_name_th']?>" onClick="DeleteThis('<?php echo $data['id']?>','<?php echo $data['product_image']?>','<?php echo $data['num']?>')"><img src="images/black_icon/16x16/sq_minus.png" width="16" height="16" border="0" /></a>        
        </td>
      </tr>
    
   <?php $n++; } ?>
     <tr>
        <td height="25" align="center" bgcolor="#EBEBEB">&nbsp;</td>
        <td bgcolor="#EBEBEB" class="txt10-black">&nbsp;</td>
        <td align="center" bgcolor="#EBEBEB" class="txt10-black">
           <input name="Loops" type="hidden" value="<?php echo $n?>" />
            <input type="button" name="button" id="button" value="แก้ไขเรียงลำดับ" onclick="SortOrder()" /></td>
        <td align="center" bgcolor="#EBEBEB" class="txt10-black">&nbsp;</td>
        <td align="center" bgcolor="#EBEBEB">&nbsp;</td>
        <td align="center" bgcolor="#EBEBEB">&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2"><span class="txt10-black">&nbsp;
      หน้า :
          <?php $thisFile"main.php?work=".$_GET['work']; PageDisplay($query,$rowPerPage,$_GET['page'],$thisFile)?>
    </span></td>
  </tr>
</table>
</form>
</body>
</html>