?
Path : /home/admin/public_html/old/promice/Admin/ |
Current File : /home/admin/public_html/old/promice/Admin/Products.php |
<? @session_start(); ob_start(); $useradmin = $_SESSION["useradmin"]; if(empty($useradmin)) { echo "<script>alert('หน้านี้จำกัดเฉพาะ Admin เท่านั้น');history.back();</script>"; exit(); } require_once "../include/tdate.php"; require_once "../include/connect.php"; require_once "../include/connectdb.php"; $sql="select * from useradmin where useradmin='$useradmin'"; $db_query=mysql_db_query($db,$sql); $result=mysql_fetch_array($db_query); $id=$result[id]; $adminname=$result[name]; $user_admin=$result[useradmin]; $pass_admin=$result[passadmin]; ?> <html> <head> <title><? echo "$headtxt"; ?></title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <!-- Fireworks MX Dreamweaver MX target. Created Sat Apr 02 10:29:23 GMT+0700 (SE Asia Standard Time) 2011--> <link href="../css/style.css" rel="stylesheet" type="text/css"> <link rel="shortcut icon" type="../editor/image/x-icon" href="../favicon.ico"> <link rel="stylesheet" type="text/css" href="../editor/styles.css" /> <link rel="stylesheet" type="text/css" href="../editor/jquery.cleditor.css" /> <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script type="text/javascript" src="../editor/jquery.cleditor.min.js"></script> <script type="text/javascript"> $(document).ready(function() { $(".input").cleditor({width:700, height:300})[0].focus(); }); </script> <div class=mainPanel> <div> <div class=leftPanel> </head> <body bgcolor="#ffffff"> <div align="center"><strong> </strong> <table width="89%" border="0" align="center" cellpadding="1" cellspacing="1"> <tr valign="top"> <td width="57%"><? echo "$headtxt | $e_date $etime"; ?><br> <div align="left">หน้าปัจจุบันของคุณ : <a href="Main.php">หน้าหลัก</a> --> <strong>รายการสินค้า</strong></div></td> <td width="43%"> <div align="right">ยินดีต้อนรับคุณ <? echo "<u>$adminname</u>"; ?> เข้าใช้งานในระบบ<br> [ <a href="ChangePass.php">เปลี่ยนรหัสผ่าน</a> ] <a href="logout.php">ออกจากระบบ</a> </div></td> </tr> <tr> <td colspan="2"><table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#E9E9E6"> <tr> <td><div align="center"> <table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"><br> <table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"> <table width="82%" border="0" cellspacing="1" cellpadding="1"> <tr> <td><div align="center"> <script language="JavaScript"> function checkprd() { var prd1 = document.webFormprd.productstypecode.value; var prd2 = document.webFormprd.productsname.value; var prd3 = document.webFormprd.productsdetail.value; var prd4 = document.webFormprd.productsprice.value; var prd5 = document.webFormprd.productsphoto.value; var prd6 = document.webFormprd.amount.value; var prd7 = document.webFormprd.productskeyword.value; var prd8 = document.webFormprd.productstitle.value; var prd9 = document.webFormprd.productsdesc.value; if( prd1.length ==0) { alert("กรุณาใส่ประเภทสินค้าด้วยค่ะ"); document.webFormprd.productstypecode.focus(); return false; }else if( prd2.length ==0) { alert("กรุณาใส่ชื่อสินค้าด้วยค่ะ"); document.webFormprd.productsname.focus(); return false; }else if( prd3.length ==0) { alert("กรุณาใส่ราคาิสินค้าด้วยค่ะ"); document.webFormprd.productsprice.focus(); return false; }else if( prd4.length ==0) { alert("กรุณาใส่รายละเอียดสินค้าด้วยค่ะ"); document.webFormprd.productsdetail.focus(); return false; }else if( prd5.length ==0) { alert("กรุณาใส่รูปสินค้าด้วยค่ะ"); document.webFormprd.productsphoto.focus(); return false; }else if( prd6.length ==0) { alert("กรุณาใส่จำนวนสินค้าด้วยค่ะ"); document.webFormprd.amount.focus(); return false; } else return true; } function chkForm(){ if(document.webFormprd.productstypecode.value==0){ alert("กรุณาเลือกประเภทสินค้าด้วยค่ะ"); document.form.productstypecode.focus(); return false; } return true; } </script> <table width="716" border="0" align="center" cellpadding="1" cellspacing="1"> <form method="post" action="ProductsSave.php" enctype="multipart/form-data" name="webFormprd" onSubmit="return checkprd()"> <tr bgcolor="#FFFFFF"> <td> <div align="right">ประเภทสินค้า</div></td> <td> <?php $sql2 = "select * From productstype"; $result2 = mysql_query($sql2); $Num_Rows2 = mysql_num_rows($result2); $result2 = mysql_query($sql2); echo "<select name=productstypecode id=productstypecode class=input>"; echo "<option value=0>เลือกประเภทสินค้า"; While($row2= mysql_fetch_array($result2)){ $productstypecode = $row2["productstypecode"]; $productstypename = $row2["productstypename"]; ?> <option value=<? echo "$productstypecode"; ?> onBlur="return chkForm();"><? echo "$productstypecode"; ?>-<? echo "$productstypename"; ?> <? } echo "</option></select>"; ?> </td> </tr> <tr bgcolor="#FFFFFF"> <td width="151"> <div align="right">รหัสสินค้า :</div></td> <td width="558"> <? $sql_numcode="select * from products"; $db_queryr=mysql_db_query($db,$sql_numcode); $result_numcode=mysql_fetch_array($db_queryr); $num_rows_code=mysql_num_rows($db_queryr); $run_number = $num_rows_code+1; echo "<b>PRD$run_number</b><input type=hidden name=productscode value=PRD$run_number>"; ?> </td> </tr> <tr bgcolor="#FFFFFF"> <td> <div align="right">รุ่นสินค้า :</div></td> <td> <input name="productsname" type="text" class="input" id="productsname" size="40"> </td> </tr> <tr bgcolor="#FFFFFF"> <td> <div align="right">ราคา (ราคาขาย) :</div></td> <td> <input name="productsprice" type="text" class="input" id="productsprice" / onblur="checkvalue()" value="0" size=10> </td> </tr> <tr bgcolor="#FFFFFF"> <td valign="top"><div align="right">ราคา (ราคาลด) :</div></td> <td><input name="productspricedis" type="text" class="input" id="productspricedis" / onblur="checkvalue()" value="0" size=10></td> </tr> <tr bgcolor="#FFFFFF"> <td valign="top"> <div align="right">รายละเอียดสินค้า :</div></td> <td> <textarea name="productsdetail" cols="50" rows="10" class="cleditorMain" id="productsdetail"> </textarea> </td> </tr> <tr bgcolor="#FFFFFF"> <td><div align="right">Keyword:</div></td> <td><input name="productskeyword" type="text" class="input" id="productskeyword" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td><div align="right">Title:</div></td> <td><input name="productstitle" type="text" class="input" id="productstitle" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td><div align="right">Desc:</div></td> <td><input name="productsdesc" type="text" class="input" id="productsdesc" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td> <div align="right">รูปสินค้า :</div></td> <td> <input name="productsphoto" type="file" class="input" id="productsphoto" size="40"> </td> </tr> <tr bgcolor="#FFFFFF"> <td> </td> <td><input name="productsphoto2" type="file" class="input" id="productsphoto2" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td> </td> <td><input name="productsphoto3" type="file" class="input" id="productsphoto3" size="40"></td> </tr> <tr bgcolor="#FFFFFF"> <td> </td> <td> <input name="status" type="radio" checked> ช่วงการขายปกติ <input type="radio" name="status" value="11111"> สินค้าโปรโมชั่น</td> </tr> <tr bgcolor="#FFFFFF"></tr> <tr bgcolor="#FFFFFF"> <td><div align="right">ขนาด :</div></td> <td><input name="productsize" type="text" class="input" id="productsize" / onblur="checkvalue()" value="Freesize" size=10></td> </tr> <tr bgcolor="#FFFFFF"> <td><div align="right">จำนวนสินค้า :</div></td> <td> <input name="amount" type="text" class="input" id="amount" value="100" size="2"> </td> </tr> <tr bgcolor="#FFFFFF"> <td><div align="right"></div></td> <td> <input name="submit" type="submit" class="submit" value="เพิ่มรายการสินค้า!"> </td> </tr> </form> </table> </div></td> </tr> <tr> <? $numproducts ="select * from products"; $query_select=mysql_query($numproducts); $numall=mysql_num_rows($query_select); ?> <td><table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td><strong>:: รายการสินค้าจำนวน <? echo "$numall"; ?> รายการ::</strong></td> </tr> <tr> <td><div align="center"> <table width="85%" border="0" cellspacing="0" cellpadding="0"> <tr class="jobscss"> <td bgcolor="#FFFFFF"> <? $page = $_GET['page']; $select_type="select * from products order by id asc"; $query_select=mysql_query($select_type); $num_rows=mysql_num_rows($query_select); if($num_rows<1){ echo "<br><br><center><b>ยังไม่มีการเพิ่มข้อมูลค่ะ</b></center>"; }else{ $select="select * from products order by id asc"; $q_ry = mysql_query($select); $num_rows=mysql_num_rows($q_ry); $pagesize=8; $rt=$num_rows%$pagesize; if($rt!=0) { $totalpage=floor($num_rows/$pagesize)+1; } else { $totalpage=floor($num_rows/$pagesize); $toppic_id=1; } if(empty($page)) { $page=1; } mysql_free_result($q_ry); $goto=($page-1)*$pagesize; $sql_select_mem="Select * From products order by id asc limit $goto,$pagesize"; $fect=mysql_query($sql_select_mem); if(!$fect) { ("ติดต่อฐานข้อมูลไม่ได้".mysql_error()); exit; } $bgcount=0; while($rows=mysql_fetch_array($fect)) { $idx =$rows['id']; $productstypecode =$rows['productstypecode']; $productscode = $rows['productscode']; $productsname = $rows['productsname']; $productsdetail = $rows['productsdetail']; $productsprice = $rows['productsprice']; $productskeyword = $rows['productskeyword']; $productstitle = $rows['productstitle']; $productsdesc = $rows['productsdesc']; $productsphoto = $rows['productsphoto']; $productsphoto2 = $rows['productsphoto2']; $productsphoto3 = $rows['productsphoto3']; $products_price = number_format($productsprice,2,'.',',') ; $amount = $rows['amount']; $bgcount=$bgcount+1; $bgmod=$bgcount%2; if($bgmod==0){ $bgcolor="#E9E9E8"; }else{ $bgcolor="#FFFFFF"; } ?> <table width="92%" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="763"> <div align="left"> <table width="100%" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="129"><div align="center"><? echo "<a href=ShowProducts.php?PrdID=$idx><img src=IMG/$productsphoto width=100 height=100 border=0></a>"; ?><br> สินค้าคงเหลือ : <? echo "<u><b>$amount</b></u>"; ?> <br> <? if ($amount <= 3) { echo "สินค้าใกล้หมดสต๊อก"; }else{ echo ""; } if ($amount = 0) { echo "สินค้าหมดสต๊อก"; }else{ echo ""; } ?> </div></td> <td width="295"><? echo "<b><u>$productsname</u></b><br><img src=../images/48be2683.gif> $productsdetail<br>ราคา : $products_price บาท"; ?></td> </tr> </table> </div></td> <td width="73"> <div align="center"> <table width="60" border="0" cellspacing="1" cellpadding="1"> <tr> <td width="76"><div align="center"><a href="EditProducts.php?PrdID=<? echo "$idx"; ?>"><img src="../images/pencil.jpg" width="20" height="20" border="0"></a></div></td> <td width="78"><div align="center"><a href="DelProducts.php?PrdID=<? echo "$idx"; ?>&PhotoName=<? echo "$productsphoto"; ?>"><img src="../images/delete.png" width="22" height="22" border="0"></a></div></td> </tr> </table> </div></td> </tr> <tr> <td colspan="2"><img src="images/line.jpg" width="839" height="3"></td> </tr> </table> <? } } ?> </td> </tr> <tr class="jobscss"> <td><strong><span class="maekhawtom"><br> หน้าที่ :</span></strong> <span class="maekhawtom"> <? for($i=1;$i<$page;$i++) { echo"[<a href='$PHP_SELF?page=$i'>$i</a>]"; } echo"[<b>$page</b>]"; for($i=$page+1;$i<=$totalpage;$i++) { echo"[<a href='$PHP_SELF?page=$i'>$i</a>]"; } ?> </span><span class="maekhawtom"> </span></td> </tr> <tr> <td><div align="center"></div></td> </tr> </table> </div></td> </tr> </table></td> </tr> </table> </div></td> </tr> </table> <br> <br> </div></td> </tr> </table> </div></td> </tr> </table></td> </tr> <tr> <td colspan="2"><div align="center"><br> <? echo "$buttomtxt"; ?> </div></td> </tr> </table> </div> </body> </html>