PageRenderTime 64ms CodeModel.GetById 13ms RepoModel.GetById 1ms app.codeStats 0ms

/web choi.vn php/chon.vn/user/productedit.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 165 lines | 160 code | 2 blank | 3 comment | 11 complexity | 6335e454e1fd2e119822ace65778b90c MD5 | raw file
  1. <?php include_once pathtodir.'lib/tbl_partner.php';
  2. include_once pathtodir.'lib/tbl_product_category.php';
  3. include_once pathtodir.'lib/tbl_manufacturer.php';
  4. include_once pathtodir.'lib/tbl_product.php';
  5. $cate=new ProductCategory();
  6. $manufacturerclass=new Manufacturer();
  7. $arrmanufer=$manufacturerclass->getArrayCategory("=");
  8. $arrcategory=$cate->getArrayCategory("=");
  9. //server code
  10. $pro=new Product();
  11. $kw=new KW_Hook();
  12. if($_POST['txtsubmit']==1)
  13. {
  14. if(isset($_POST['txtnew']))
  15. $products_new=1;
  16. else
  17. $products_new=0;
  18. $name=strip_tags($_POST['txtname']);
  19. $code=strip_tags($_POST['txtcode']);
  20. $sort=strip_tags($_POST['txtsort']);
  21. $price=strip_tags($_POST['txtprice']);
  22. $txtshortcontent=strip_tags($_POST['txtshortcontent']);
  23. $txtcontent=$_POST['txtcontent'];
  24. $txtvanhanh=$_POST['txtvanhanh'];
  25. $txtcongnghe=$_POST['txtcongnghe'];
  26. $txttinhnang=$_POST['txttinhnang'];
  27. $txtthongso=$_POST['txtthongso'];
  28. $txttieuchuan=$_POST['txttieuchuan'];
  29. $txtcategory=strip_tags($_POST['txtcategory']);
  30. $txtmanuafer=strip_tags($_POST['txtmanuafer']);
  31. $txtsupplier=strip_tags($_POST['txtsupplier']);
  32. $image2=$_FILES['txtfile'];
  33. $err=array();
  34. if(strlen(trim($name))<2)
  35. {
  36. $err[]="Product name is short";
  37. }
  38. if(count($err)==0)
  39. {
  40. $err=$pro ->EditProduct1($_GET['idproduct'],$code,$name,$image2,$price,$sort,$txtshortcontent,$txtcontent,$txtcategory,$txtmanuafer,$txtsupplier,$_SESSION['username'],$txtvanhanh,$txtcongnghe,$txttieuchuan,$products_new,$txttinhnang);
  41. if(count($err)==0)
  42. {
  43. //$kw->Redirect("?page=product&idcate=".$_GET['idcate']);
  44. }
  45. }
  46. }elseif($_POST['txtsubmit']==2)
  47. {
  48. if(isset($_POST['txtnew']))
  49. $products_new=1;
  50. else
  51. $products_new=0;
  52. $name=strip_tags($_POST['txtname']);
  53. $code=strip_tags($_POST['txtcode']);
  54. $sort=strip_tags($_POST['txtsort']);
  55. $price=strip_tags($_POST['txtprice']);
  56. $txtshortcontent=strip_tags($_POST['txtshortcontent']);
  57. $txtcontent=$_POST['txtcontent'];
  58. $txtvanhanh=$_POST['txtvanhanh'];
  59. $txtcongnghe=$_POST['txtcongnghe'];
  60. $txttinhnang=$_POST['txttinhnang'];
  61. $txtthongso=$_POST['txtthongso'];
  62. $txttieuchuan=$_POST['txttieuchuan'];
  63. $txtcategory=strip_tags($_POST['txtcategory']);
  64. $txtmanuafer=strip_tags($_POST['txtmanuafer']);
  65. $txtsupplier=strip_tags($_POST['txtsupplier']);
  66. $image2=$_FILES['txtfile'];
  67. $err=array();
  68. if(strlen(trim($name))<2)
  69. {
  70. $err[]="Product name is short";
  71. }
  72. if(count($err)==0)
  73. {
  74. $result=$pro ->InsertProduct2($code,$name,$image2,$price,$sort,$txtshortcontent,$txtcontent,$txtcategory,$txtmanuafer,$txtsupplier,$_SESSION['username'],$txtvanhanh,$txtcongnghe,$txttieuchuan,$products_new);
  75. }
  76. }
  77. $product=$pro->GetProduct("products_id=".$_GET['idproduct']);
  78. ?>
  79. <style type="text/css">
  80. #content select {
  81. width: 250px !important;
  82. }
  83. </style>
  84. <div class="grid_16" id="content">
  85. <div class="grid_7" style="float: left;" >
  86. <h1 class="content_edit">Sửa sản phẩm</h1>
  87. </div>
  88. <div class="grid_7" style="float: left;">
  89. <div style="float: right;width: 48px;margin-right: 10px">
  90. <a href="#"><img style="float: left;" title="Thoát" src="<?php echo pathtoadminweb?>images/exit.png"></a>
  91. </div>
  92. <div style="float: right;width: 48px;margin-right: 10px">
  93. <a href="?page=product"><img style="float: left;" title="Quay lại" src="<?php echo pathtoadminweb?>images/Paper-arrow-back.png"></a>
  94. </div>
  95. <div style="float: right;width: 48px;margin-right: 10px">
  96. <a href="#" onclick="javascript:submitfrom()"><img style="float: left;" title="Lưu nội dung" src="<?php echo pathtoadminweb?>images/save.png"></a>
  97. </div>
  98. <div style="float: right;width: 48px;margin-right: 10px">
  99. <a href="#" onclick="javascript:submitfrom2()"><img style="float: left;" title="Thêm nội dung" src="<?php echo pathtoadminweb?>images/save.png"></a>
  100. </div>
  101. </div>
  102. </div>
  103. <div class="grid_16" id="content">
  104. <div class="grid_15" id="textcontent">
  105. <form id="edit" action="" method="post" enctype="multipart/form-data">
  106. <input name="txtsubmit" id="txtsubmit" value="0" type="hidden"/>
  107. <label>Tên sản phẩm</label>
  108. <input type="text" class="smallInput wide" name="txtname" value="<?php echo $product[0][2]; ?>"/>
  109. <label> số sản phẩm</label>
  110. <input type="text" class="smallInput" name="txtcode" value="<?php echo $product[0][1]; ?>"/>
  111. <label>Sắp sếp</label>
  112. <input type="text" class="smallInput" name="txtsort" value="<?php echo $product[0][9]; ?>"/>
  113. <label>Giá bán</label>
  114. <input type="text" class="smallInput" name="txtprice" value="<?php echo $product[0][5]; ?>"/>
  115. <label>Màu sắc</label>
  116. <input type="text" class="smallInput" name="txtvanhanh" value="<?php echo $product[0][20]; ?>"/>
  117. <label>Kích thước</label>
  118. <input type="text" class="smallInput" name="txttinhnang" value="<?php echo $product[0][25]; ?>"/>
  119. <label>Chất liệu</label>
  120. <input type="text" class="smallInput" name="txttieuchuan" value="<?php echo $product[0][22]; ?>"/>
  121. <label>Đơn vị tính</label>
  122. <input type="text" class="smallInput" name="txtcongnghe" value="<?php echo $product[0][21]; ?>"/>
  123. <label>Sản phẩm mới </label>
  124. <input type="checkbox" class="smallInput" name="txtnew" <?php if($product[0][24]==1){?> checked="checked" <?php }?>/>
  125. <label>Hình lớn</label>
  126. <input type="file" name="txtfile">
  127. <!--WYSIWYG Editor is linked to the textarea with id: #wysiwyg-->
  128. <label> tả ngắn</label>
  129. <div style="width: 896px; " class="wysiwyg">
  130. <textarea name="txtshortcontent" rows="5" cols="109"><?php echo $product[0][10]; ?></textarea>
  131. </div>
  132. <label>Giới thiệu sản phẩm</label>
  133. <div style="width: 896px; " class="wysiwyg">
  134. <?php
  135. include_once pathtoadmindir.'fckeditor/fckeditor_php5.php';
  136. $fck=new FCKeditor("txtcontent");
  137. $fck->Value=$product[0][11];
  138. $fck->BasePath=pathtoadminweb."fckeditor/";
  139. $fck->Height=600;
  140. $fck->Create();
  141. ?>
  142. </div>
  143. <label>Chọn danh mục</label>
  144. <?php
  145. $out=$cate->comboCategory('txtcategory',$arrcategory,'smallInput',$product[0][19],1);
  146. echo $out;
  147. ?> <br />
  148. </form><br>
  149. <div class="clear"></div><br>
  150. </div>
  151. <div class="clear"> </div>
  152. <!-- END CONTENT-->
  153. </div>
  154. <script type="text/javascript" >
  155. function submitfrom() {
  156. document.getElementById('txtsubmit').value=1;
  157. document.forms["edit"].submit();
  158. }
  159. function submitfrom2() {
  160. document.getElementById('txtsubmit').value=2;
  161. document.forms["edit"].submit();
  162. }
  163. </script>