查看文件: body_productadd.php
大小: 18.92 KB
类型: application/octet-stream
<?php require_once('../Connections/BE2.php'); ?> <?php ini_set('display_errors', 1); ini_set('display_startup_errors', 1); error_reporting(E_ALL); if (!isset($_SESSION)){ session_start(); } if(! isset($_SESSION['login_coid']) || $_SESSION['login_coid']=='0'){ ?> <script>alert('請記的先登入');location.href = '/';</script> <? exit; } if ( isset($_GET["deleteid"]) ) { $delSQL1 = sprintf("delete from product_size where duid='%s' AND mid='%s'",$_SESSION['login_coid'],$_GET["deleteid"]); mysql_select_db($database_BE2, $BE2); mysql_query($delSQL1, $BE2) or die(mysql_error()); $delSQL2 = sprintf("delete from product_data where company_num='%s' AND mem_auto='%s'",$_SESSION['login_coid'],$_GET["deleteid"]); mysql_select_db($database_BE2, $BE2); mysql_query($delSQL2, $BE2) or die(mysql_error()); $write='資料已更新...'; $insertGoTo = "myproduct.html" ; // header(sprintf("Location: %s", $insertGoTo)); echo "<script>alert('".$write."');</script>"; } 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=date('YmdHis').'_'.sprintf("%04d",rand(1,9999)); $imgext=''; //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); } // test double data mysql_select_db($database_BE2, $BE2); $query_Rt3 = sprintf("SELECT * FROM product_data WHERE meta_img='%s' AND company_num = '%s'",$img,$_SESSION['login_coid']); $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error()); $row_Rt3 = mysql_fetch_assoc($Rt3); $totalRows_Rt3 = mysql_num_rows($Rt3); mysql_free_result($Rt3); if($totalRows_Rt3==0){ // p_rank // 1 2 $updateSQL = sprintf("insert into product_data (mem_time,company_num,p_check,p_check_time,p_check_time2,p_hot,p_hot2,pic_num,p_tag,meta_img,p_title,p_explan,p_content,p_size,p_new,p_money,p_num,p_express,p_count,p_percent31,p_percent32,p_percent33,p_percent34,p_percent35,p_percent36)VALUES('%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s','%s' ,'%s','%s' ,'%s')",date('Y-m-d'),$_SESSION['login_coid'],$_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'],$_POST['p_explan'],$_POST['p_content'],$_POST['p_size'],'1',$_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']); mysql_select_db($database_BE2, $BE2); $Result1 = mysql_query($updateSQL, $BE2) or die(mysql_error()); //<input type="hidden" id="vcount" name="vcount" value="1"> // test double data mysql_select_db($database_BE2, $BE2); $query_Rt3 = sprintf("SELECT * FROM product_data WHERE meta_img='%s' AND company_num = '%s'",$img,$_SESSION['login_coid']); $Rt3 = mysql_query($query_Rt3, $BE2) or die(mysql_error()); $row_Rt3 = mysql_fetch_assoc($Rt3); $totalRows_Rt3 = mysql_num_rows($Rt3); $pid=$row_Rt3['mem_auto']; mysql_free_result($Rt3); for($i=0;$i<count($_POST['mstock']);$i++){ mysql_select_db($database_BE2, $BE2); $Insert_Rt3 = sprintf("INSERT into product_size (mid,mdoc,mstock,mamount,duid)VALUES('%s','%s','%s','%s','%s')",$pid,$_POST['mdoc'][$i], $_POST['mstock'][$i],$_POST['mamount'][$i],$_SESSION['login_coid']); mysql_query($Insert_Rt3, $BE2) or die(mysql_error()); } $write='資料已更新...'; $insertGoTo = "myproduct.html" ; echo "<script>alert('".$write."');location.href='". $insertGoTo."';</script>"; } } $currentPage = "productadd.html";//$_SERVER["PHP_SELF"]; 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); $mid=0; //if ($totalRows_Rtg>0) { $mid=$row_Rtg['mid']; } ?> <div class="main "> <div class="row"> <div class="col-lg-12"> <form action="productadd.html" method="post" enctype="multipart/form-data" name="form2"> <input name="pic_num" id="pic_num" type="hidden" value="<?= date('Ymdhis').'_'.sprintf("%04d",rand(1,9999)); ?>"> <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="上架" selected='selected'>上架 </option> <option value="下架" > 下架 </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="<?= date("Y-m-d")?>" 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="<?= date("Y-m-d",time()+(86400*365)); ?>" readonly="readonly"> </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="一般" selected='selected'>一般 </option> <option value="冷凍" >冷凍 </option> <option value="冷藏" >冷藏 </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" selected='selected' > 是 </option> <option value="0" > 否 </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>商品類別</label><br> <select class="form-control select" name="company_num" id="company_num" required> <option value="">請選擇</option> <?php do { ?> <option value="<?= $row_Rtg['kid'] ?>"><?= $row_Rtg['kdoc'] ?></option> <?php } while ($row_Rtg = mysql_fetch_assoc($Rtg)); ?> </select> */ ?> <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=""> <input name="rePic" type="hidden" id="rePic" value=""> <input name="meta_img" type="hidden" id="meta_img" value="" /> (PS:商品其它附圖說明可在商品編輯時再上傳...) </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" required> </div> <div class="col-md-6"> <label>產品名稱</label><br> <input type="text" id="p_title" name="p_title" class="form-control" required> </div> <div class="col-md-3"> <label>價格</label><br> <input type="text" id="p_money" name="p_money" class="form-control" value="0" required> </div> </div> </div> </td> </tr> <? /* <tr> <td> <div class="row"> <div class="form-group"> <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="0"> </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="0"> </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="0"> </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="0"> </div> <label class="col-md-1 control-label" for="p_percent32">經銷獎金</label> <div class="col-md-2"> <input name="p_percent32" type="text" required class="form-control" id="p_percent32" value="0"> </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="0"> </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="0"> </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 id="myTableRow'+(x*1+1)+'"><td></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><a onclick="delRow('+(x*1+1)+')">Delete</a></td></tr>'); return false; }; function delRow(i) { $("#myTableRow"+i).remove(); } $("#myTable").on("click", "#delButton", function() { $(this).closest("tr").remove(); }); </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"> <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"> <table width="100%%" border="0" id="myTable"> <tr> <td width="2%">#</td> <td width="32%">商品規格</td> <td width="32%">庫存量</td> <td width="22%">金額</td> <td width="12%">-</td> </tr> <tr> <td>1</td> <td><input name="mdoc[]" type="text" class="form-control" id="mdoc[]" value="" required></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></td> </tr> </table> </div> <div class="col-md-2"> <input name="p_count" type="hidden" class="form-control" id="p_count" value="0"> </div> </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></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></textarea> </div> </div> </div> </td> </tr> <tr> <td> </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> <? // echo $query_Rt21 ; ?> </div> </div> </div> <?php mysql_free_result($Rtg); ?>
保存
取消
返回文件列表