查看文件: body_productedit.php
大小: 22.18 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <?php if (!isset($_SESSION)){ session_start(); } if(! isset($_SESSION['login_coid']) || $_SESSION['login_coid']=='0'){ ?> <script>alert('請記的先登入');location.href = '/';</script> <? exit; } if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) { $idpath= sprintf("%07d",$_SESSION['login_coid']) ; $wwwpath='/www2/skybni'; $picpath= "/admin/upload2_image/".$idpath; if ( !file_exists( $wwwpath.$picpath ) && !is_dir( $wwwpath.$picpath ) ) { mkdir( $wwwpath.$picpath ); } $write=''; $img=$_POST['meta_img'];// date('YmdHis').sprintf("%04d",rand(1,9999)); $imgext=$_POST['rePicext']; //p_tag $tfile="fileToUpload1"; if($_FILES[$tfile]["name"]<>''){ $ext= explode('.',$_FILES[$tfile]['name']) ; $imgext=strtolower($ext[count($ext)-1]); //取最後一筆 $pic=$wwwpath.$picpath.'/'.$img.".".$imgext; move_uploaded_file($_FILES[$tfile]["tmp_name"],$pic); } // p_rank $p_explan = strip_tags($_POST['p_explan']); $p_content = strip_tags($_POST['p_content']); $updateSQL = sprintf("update product_data set p_check='%s',p_check_time='%s',p_check_time2='%s',p_hot='%s',p_hot2='%s',pic_num='%s',p_tag='%s',meta_img='%s',p_title='%s',p_explan='%s',p_size='%s',p_money='%s',p_num='%s',p_express='%s',p_count='%s',p_percent31='%s',p_percent32='%s',p_percent33='%s' ,p_percent34='%s',p_percent35='%s',p_percent36='%s',p_percent37='%s',p_content='%s' WHERE company_num='%s' AND mem_auto='%s' ", $_POST['p_check'],$_POST['p_check_time'],$_POST['p_check_time2'],$_POST['p_hot'],$_POST['p_hot2'],$_POST['pic_num'],$imgext,$img,$_POST['p_title'],$p_explan,$_POST['p_size'],$_POST['p_money'] ,$_POST['p_num'],$_POST['p_express'],$_POST['p_count'],$_POST['p_percent31'],$_POST['p_percent32'],$_POST['p_percent33'],$_POST['p_percent34'],$_POST['p_percent35'],$_POST['p_percent36'],$_POST['p_percent37'],$p_content,$_SESSION['login_coid'],$_POST['mem_auto'] ); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); $img=$_POST['meta_img']; for($i=0;$i<8;$i++){ $up=0; $imgext=$_POST['imge'.$i]; //p_tag $tfile="fileToUploade".$i; if($_POST['pid'.$i]>0){ $up=1;} if($_FILES[$tfile]["name"]<>''){ $ext= explode('.',$_FILES[$tfile]['name']) ; $imgext=strtolower($ext[count($ext)-1]); //取最後一筆 $pic=$wwwpath.$picpath.'/'.$img.$i.".".$imgext; move_uploaded_file($_FILES[$tfile]["tmp_name"],$pic); $up=1; } if($up>0){ $fck=isset($_POST['fck'.$i])?$_POST['fck'.$i]:'N'; if($_POST['pid'.$i]==0){ $Indate = sprintf("INSERT INTO product_img(mid,imgext,imgname,fck)VALUES('%s','%s','%s','%s')",$_POST['mem_auto'],$imgext,$i,$fck); }else{ $Indate = sprintf("UPDATE product_img set imgext='%s',fck='%s' where pid='%s'",$imgext,$fck,$_POST['pid'.$i]); } mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($Indate, $BE2) or die(mysql_error()); } } $write='資料已更新...'; $insertGoTo = "myproduct.html" ; echo "<script>alert('".$write."');location.href='".$insertGoTo."';</script>"; } $currentPage = "productedit.html";//$_SERVER["PHP_SELF"]; $pid='-1'; if (isset($_GET['id'])) { $pid = $_GET['id']; } mysql_select_db($database_BE2, $BE2); $query_Rtg = sprintf("SELECT * FROM product_kind WHERE company_num = '%s'",$_SESSION['login_coid']); $Rtg = mysql_query($query_Rtg, $BE2) or die(mysql_error()); $row_Rtg = mysql_fetch_assoc($Rtg); $totalRows_Rtg = mysql_num_rows($Rtg); mysql_select_db($database_BE2, $BE2); $query_Rt2 = sprintf("SELECT * FROM product_data WHERE company_num = '%s' AND mem_auto='%s'",$_SESSION['login_coid'],$pid); $Rt2 = mysql_query($query_Rt2, $BE2) or die(mysql_error()); $row_Rt2 = mysql_fetch_assoc($Rt2); $totalRows_Rt2 = mysql_num_rows($Rt2); mysql_select_db($database_BE2, $BE2); $query_Rt3 = sprintf("SELECT * FROM product_img WHERE mid = '%s' ",$row_Rt2['mem_auto']); $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error()); $row_Rt3 = mysql_fetch_assoc($Rt3); $totalRows_Rt3 = mysql_num_rows($Rt3); $imgdata=0; $imgcount=8; $arr1=array(); if($totalRows_Rt3>0){ $imgdata =0; do { $arr1[$imgdata][1]=$row_Rt3['pid']; $arr1[$imgdata][2]=$row_Rt3['imgext']; $arr1[$imgdata][3]=$row_Rt3['imgname']; $arr1[$imgdata][4]=$row_Rt3['fck']; $imgdata++; } while ($row_Rt3 = mysql_fetch_assoc($Rt3)); } if($imgdata<8){ for($i= $imgdata ;$i<8;$i++){ $arr1[$i][1]=0; $arr1[$i][2]=""; $arr1[$i][3]=""; $arr1[$i][4]=""; } } ?> <div class="main "> <div class="row"> <div class="col-lg-12"> <form action="productedit.html" method="post" name="form2" enctype="multipart/form-data"> <input name="pic_num" id="pic_num" type="hidden" value="<?= $row_Rt2['pic_num'] ?>"> <table class="table table-bordered table-hover"> <tr> <td> <div class="row"> <div class="form-group"> <label class="col-md-1 control-label" for="radio">是否上架</label> <div class="col-md-2"> <select name="p_check" id="p_check" class="form-control placeholder col-xs-2 col-sm-2 mb-2"> <option value="上架" <?= ($row_Rt2['p_check']=="上架")?"selected='selected'":"" ?>>上架 </option> <option value="下架" <?= ($row_Rt2['p_check']=="下架")?"selected='selected'":"" ?>> 下架 </option> </select> </div> <label class="col-md-1 control-label" for="p_check_time">上架時間</label> <div class="col-md-2"> <input id="p_check_time" name="p_check_time" type="text" class="form-control datepicker" data-format="yyyy-mm-dd" data-lang="en" data-RTL="false" value="<?= $row_Rt2['p_check_time'] ?>" readonly="readonly"> </div> <label class="col-md-1 control-label" for="p_check_time2">下架時間</label> <div class="col-md-2"> <input id="p_check_time2" name="p_check_time2" type="text" class="form-control datepicker" data-format="yyyy-mm-dd" data-lang="en" data-RTL="false" value="<?= $row_Rt2['p_check_time2'] ?>" > </div> </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <label class="col-md-1 control-label">食品種類</label> <div class="col-md-2"> <select name="p_hot2" id="p_hot2" class="form-control placeholder col-xs-2 col-sm-2 mb-2"> <option value="一般" <?= ($row_Rt2['p_hot2']=="一般")?"selected='selected'":"" ?>>一般 </option> <option value="冷凍" <?= ($row_Rt2['p_hot2']=="冷凍")?"selected='selected'":"" ?>>冷凍 </option> <option value="冷藏" <?= ($row_Rt2['p_hot2']=="冷藏")?"selected='selected'":"" ?>>冷藏 </option> </select> </div> <label class="col-md-1 control-label" for="p_hot">熱門商品</label> <div class="col-md-2"> <select name="p_hot" id="p_hot" class="form-control placeholder col-xs-4 col-sm-4 mb-4"> <option value="1" <?= ($row_Rt2['p_hot']==1)?"selected='selected'":"" ?>> 是 </option> <option value="0" <?= ($row_Rt2['p_hot']==0)?"selected='selected'":"" ?>> 否 </option> </select> <input name="company_num" id="company_num" type="hidden" value="<?= $_SESSION['login_coid']?>"> </div> </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <label class="col-md-3 control-label" for="fileToUpload1">上傳產品照片 (長寬比例為600*600px)</label> <div class="col-md-9"> <input name="fileToUpload1" type="file" id="fileToUpload1" /> <input name="rePicext" type="hidden" id="rePicext" value="<?= $row_Rt2['p_tag'] ?>"> <input name="rePic" type="hidden" id="rePic"> <input name="meta_img" type="hidden" id="meta_img" value="<?= $row_Rt2['meta_img'] ?>" /> <input name="mem_auto" type="hidden" id="mem_auto" value="<?= $row_Rt2['mem_auto'] ?>" /> </div> </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <div class="col-md-3"> <label>產品編號 (不要使用特殊符號或空格)</label><br> <input type="text" id="p_num" name="p_num" class="form-control" value="<?= $row_Rt2['p_num'] ?>" required> </div> <div class="col-md-5"> <label>產品名稱</label><br> <input type="text" id="p_title" name="p_title" class="form-control" value="<?= $row_Rt2['p_title'] ?>" required> </div> </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <div class="col-md-3"> <label>價格</label><br> <input type="text" id="p_money" name="p_money" class="form-control" value="<?= $row_Rt2['p_money'] ?>" required> </div> <? /* <div class="col-md-3"> <label>分3期(每期金額)</label> <label><input type="radio" name="p_money3a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money3a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money3" name="p_money3" class="form-control" value="0" required> </div> <div class="col-md-3"> <label>分6期(每期金額)</label> <label><input type="radio" name="p_money6a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money6a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money6" name="p_money6" class="form-control" value="0" required> </div> <div class="col-md-3"> <label>分12期(每期金額)</label> <label><input type="radio" name="p_money12a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money12a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money12" name="p_money12" class="form-control" value="0" required> </div> <div class="col-md-3"> <label>分18期(每期金額)</label> <label><input type="radio" name="p_money18a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money18a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money18" name="p_money18" class="form-control" value="0" required> </div> <div class="col-md-3"> <label>分24期(每期金額)</label> <label><input type="radio" name="p_money24a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money24a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money24" name="p_money24" class="form-control" value="0" required> </div> <div class="col-md-3"> <label>分30期(每期金額)</label> <label><input type="radio" name="p_money30a" value="1" checked><i></i> 顯示</label> <label><input type="radio" name="p_money30a" value="0"><i></i> 不顯示</label><br> <input type="text" id="p_money30" name="p_money30" class="form-control" value="0" required> </div> */ ?> </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <input name="p_percent" type="hidden" class="form-control" id="p_percent" value="3" > <input name="p_percent2" type="hidden" class="form-control" id="p_percent2" value="2" > <? $show1= (($_SESSION['login_coid']>1) && ($_SESSION['login_coid']<11 ))?"1":0; if($show1>0){ ?> <label class="col-md-2 control-label" for="p_percent33">開發商首推獎金(首次)</label> <div class="col-md-2"> <input name="p_percent33" type="text" required class="form-control" id="p_percent33" value="<?= $row_Rt2['p_percent33'] ?>"> </div> <label class="col-md-2 control-label" for="p_percent36">開發商續推獎金(續約)</label> <div class="col-md-2"> <input name="p_percent36" type="text" required class="form-control" id="p_percent36" value="<?= $row_Rt2['p_percent36'] ?>"> </div> <label class="col-md-1 control-label" for="p_percent37">銷售獎金</label> <div class="col-md-2"> <input name="p_percent37" type="text" required class="form-control" id="p_percent37" value="<?= $row_Rt2['p_percent37'] ?>"> </div> <div class="clearfix"></div> <label class="col-md-1 control-label" for="p_percent31">推廣獎金</label> <div class="col-md-2"> <input name="p_percent31" type="text" required class="form-control" id="p_percent31" value="<?= $row_Rt2['p_percent31'] ?>"> </div> <label class="col-md-1 control-label" for="p_percent31">經銷獎金</label> <div class="col-md-2"> <input name="p_percent32" type="text" required class="form-control" id="p_percent32" value="<?= $row_Rt2['p_percent32'] ?>"> </div> <label class="col-md-1 control-label" for="p_percent34">推廣雲點</label> <div class="col-md-2"> <input name="p_percent34" type="text" required class="form-control" id="p_percent34" value="<?= $row_Rt2['p_percent34'] ?>"> </div> <label class="col-md-1 control-label" for="p_percent35">開發雲點</label> <div class="col-md-2"> <input name="p_percent35" type="text" required class="form-control" id="p_percent35" value="<?= $row_Rt2['p_percent35'] ?>"> </div> <div class="col-md-4"> PS: 當特定商店 2 ~ 11 之間時才有 推廣獎金,經銷獎金 功能 </div> <? } else{?> <input name="p_percent31" type="hidden" id="p_percent31" value="0"> <input name="p_percent32" type="hidden" id="p_percent32" value="0"> <input name="p_percent33" type="hidden" id="p_percent33" value="0"> <input name="p_percent34" type="hidden" id="p_percent34" value="0"> <input name="p_percent35" type="hidden" id="p_percent35" value="0"> <input name="p_percent36" type="hidden" id="p_percent36" value="0"> <input name="p_percent37" type="hidden" id="p_percent37" value="0"> <? } ?> </div> </div> </td> </tr> <script type="text/javascript"> function tt1() { var x=$('#vcount').val(); var s=""; // var mdoc = $("input[name='mdoc[]']").map(function(){return $(this).val();}).get(); // alert(mdoc); var inps = document.getElementsByName('mdoc[]'); for (var i = 0; i <inps.length; i++) { var inp=inps[i]; // alert("mdoc["+i+"].value="+inp.value); if(inp.value==""){alert("商品規格 不可空白.."); exit;} } $('#vcount').val(x*1+1); $('#myTable').append('<tr><td>'+(x*1+1)+'</td>'+'<td><input name="mdoc[]" type="text" class="form-control" id="mdoc[]" value="" ></td><td><input name="mstock[]" type="text" class="form-control" id="mstock[]" value="0" ></td><td><input name="mamount[]" type="text" class="form-control" id="mamount[]" value="0" ></td><td><input name="mflag[]" type="text" class="form-control" id="mflag[]" value="Y" ></td><td><input name="mkid[]" type="text" id="mkid[]" value="0" ><input name="btx[]" type="button" class="form-control" id="btx[]" value="新增" ></td></tr>'); return false; }; </script> <tr> <td> <div class="row"> <div class="col-md-2"> <label>運費</label> </div> <div class="col-md-2"> <input name="p_express" type="text" class="form-control" id="p_express" value="0" required> </div> <div class="col-md-2"> <? if( $_SERVER['REMOTE_ADDR']=='220.130.43.119'){ ?> <input type="button" onclick="tt1();" value="新增規格" > <? } ?> </div> </div> <div class="row"> <div class="form-group"> <div class="col-md-6"> <input type="hidden" id="p_size" name="p_size" > <input type="hidden" id="vcount" name="vcount" value="1"> <? if( $_SERVER['REMOTE_ADDR']=='220.130.43.119'){ ?> <table width="100%" border="0" id="myTable"> <tr> <td>#</td> <td>商品規格</td> <td>庫存量</td> <td>金額</td> <td>有效</td> <td>EDIT</td> </tr> <tr> <?php do { ?> <td>1</td> <td><input name="mdoc[]" type="text" class="form-control" id="mdoc[]" value="<?= $row_Rtg['mdoc'] ?>" ></td> <td><input name="mstock[]" type="text" class="form-control" id="mstock[]" value="<?= $row_Rtg['mstock'] ?>" ></td> <td><input name="mamount[]" type="text" class="form-control" id="mamount[]" value="<?= $row_Rtg['mamount'] ?>" ></td> <td><input name="mflag[]" type="checkbox" id="mflag[]" <? if($row_Rtg['mflag']=='Y'){ echo 'checked="checked"' ;} ?> /> <? /* <input name="mflag[]" type="text" class="form-control" id="mflag[]" value="<?= $row_Rtg['mflag'] ?>" > */ ?></td> <td><input name="mkid[]" type="text" id="mkid[]" value="<?= $row_Rtg['kid'] ?>" ><input name="btx[]" type="button" class="form-control" id="btx[]" value="edit" ></td> <?php } while ($row_Rtg = mysql_fetch_assoc($Rtg)); ?> </tr> </table> <? } ?> </div> </div> <div class="col-md-2"> <input name="p_count" type="hidden" class="form-control" id="p_count" value="<?= $row_Rt2['p_count'] ?>" > </div> </div> </td> </tr> <tr> <td> <div class="row"> <div class="form-group"> <div class="col-md-12"> <label>商品簡短說明 </label><br> <textarea id="p_explan" name="p_explan" rows="4" class="form-control" required><?= $row_Rt2['p_explan'] ?></textarea> </div> </div> </div> <div class="row"> <div class="form-group"> <div class="col-md-12"> <label>商品詳細說明 </label><br> <textarea id="p_content" name="p_content" rows="8" class="form-control" required><?= $row_Rt2['p_content'] ?></textarea> </div> </div> </div> <? for($i=0;$i<8;$i++){ ?> <div class="row"> <div class="form-group"> <label class="col-md-1 control-label" for="fileToUploade<?= $i ?>">附圖<?= $i+1 ?>]:</label> <div class="col-md-2"> <input name="pid<?= $i ?>" type="hidden" class="form-control" id="pid<?= $i ?>" value="<?= $arr1[$i][1] ?>" > <input name="imge<?= $i ?>" type="hidden" class="form-control" id="imge<?= $i ?>" value="<?= $arr1[$i][2] ?>" > <input name="fileToUploade<?= $i ?>" type="file" id="fileToUploade<?= $i ?>" /> </div> <div class="col-md-1"> 啟用圖檔 <input name="fck<?= $i ?>" type="checkbox" id="fck<?= $i ?>" value="Y" <?= ($arr1[$i][4]=='Y')?'checked="checked"':''; ?> /> </div> <div class="col-md-2"> <? if($arr1[$i][2]<>""){ $img = "/admin/upload2_image/".sprintf("%07d",$_SESSION['login_coid'])."/".$row_Rt2['meta_img'].$arr1[$i][3].'.'.$arr1[$i][2]; ?> <img class="img-fluid" src="<?= $img ?>" width="100%" title="skybni <?= $arr1[$i][2] ?>"> <? }?> </div> </div> </div> <? } ?> </td> </tr> <tr> <td> <script type="text/javascript" src="ueditor/ueditor.config.js"></script> <script type="text/javascript" src="ueditor/ueditor.all.js"></script> <script type="text/javascript"> var ue = UE.getEditor('p_content',{ allowDivTransToP: false }); </script> </td> </tr> <tr> <td><input name="MM_insert" type="hidden" id="MM_insert" value="form1"><input type="submit" name="Submit" value="確定更新" class="btn btn-3d btn-black btn-md"></td> </tr> </table> </form> <br /> <br /> <input type ="button" onclick="javascript:location.href='myproduct.html'" value="回到上一頁"></input> </div> </div> </div> <?php mysql_free_result($Rt2); mysql_free_result($Rt3); mysql_free_result($Rtg); ?>
保存
取消
返回文件列表