1,"errinfo"=>"用户未登录"));
exit;
}
$method=isset($_POST['method'])?$_POST['method']:'';
if ($method == ''){
echo json_encode(array("errcode"=>2,"errinfo"=>"method参数错误"));
exit;
}
$pdo=conn();
if ($method=='add'){
$hotelid=isset($_POST['hotel_testa'])?$_POST['hotel_testa']:0;
$supplier=isset($_POST['supplier_test_id'])?$_POST['supplier_test_id']:0;
$added=isset($_POST['checkbox_test'])?$_POST['checkbox_test']:0;
$payway=isset($_POST['readyPay'])?$_POST['readyPay']:0;
$paytimelimit=isset($_POST['payTime'])?$_POST['payTime']:0;
$confirm=isset($_POST['affirmStyle'])?$_POST['affirmStyle']:0;
$oversold=isset($_POST['overSale'])?$_POST['overSale']:0;
$prod=isset($_POST['textcount'])?(empty($_POST['textcount'])?0:$_POST['textcount']):0;
if($hotelid==0 || $supplier==0 || $payway ==0 || $paytimelimit==0 || $confirm==0 ||$oversold==0 || $prod==0){
echo json_encode(array("errcode"=>3,"errinfo"=>"参数错误"));
exit;
}
//$prodArr=explode("^*^", $prod);
//$json=0;
if(is_object($pdo)){
$m=0;
$n=0;//总数量
for($i=0;$i<$prod;$i++){
if(isset($_POST['productName'.$i])){
$n+=1;
$prodname=$_POST['productName'.$i];
$roomid=$_POST['select_hotelType'.$i];
$bedtypeid=$_POST['select_bed'.$i];
$breakfast=$_POST['select_breakfast'.$i];
$addbed=$_POST['ifsup'.$i];
$sql="CALL HT_ROOM_RUN_NEW_SAVE(".$userid.",'".$prodname."',".$hotelid.",".$roomid.",".$bedtypeid.",".$breakfast.",".$addbed.",".$supplier.",".$added.",".$payway.",".$paytimelimit.",".$confirm.",".$oversold.")";
$result=$pdo->query($sql);
$rowset=$result->fetchAll(PDO::FETCH_ASSOC);
$result->closeCursor();
if($rowset[0]['errcode']==0){
$m+=1;//成功的数量
}
writeLog("hotel_room_save_modify.php method=add".$sql."::".json_encode($rowset));
}
}
/* try {
$pdo->beginTransaction(); // 开启一个事务
foreach ($prodArr as $v){
$vArr=explode(",", $v);
if(count($vArr) != 5){
continue;
}
$prodname=$vArr[0];
$roomid=$vArr[1];
$bedtypeid=$vArr[2];
$breakfast=$vArr[3];
$addbed=$vArr[4];
$sql="CALL HT_ROOM_RUN_NEW_SAVE(".$userid.",'".$prodname."',".$hotelid.",".$roomid.",".$bedtypeid.",".$breakfast.",".$addbed.",".$supplier.",".$added.",".$payway.",".$paytimelimit.",".$confirm.",".$oversold.")";
$result=$pdo->query($sql);
$rowset=$result->fetchAll(PDO::FETCH_ASSOC);
$result->closeCursor();
writeLog($sql."::".json_encode($rowset));
}
$pdo->commit();
} catch (PDOException $e) {
$pdo->rollback(); // 执行失败,事务回滚
writeLog("CALL HT_ROOM_RUN_NEW_SAVE:".$e->getMessage());
$json=1;
} */
}
/* if($m==$n)
echo json_encode(array("errcode"=>0,"errinfo"=>"成功添加".$m."条记录"));
else
echo json_encode(array("errcode"=>0,"errinfo"=>"有".($n-$m)."条添加失败")); */
if($m>0){
$url= "http://".$_SERVER['HTTP_HOST']."/hotel_list.html";
echo "";
//header("Location: $url");
exit;
}else{
$url= "http://".$_SERVER['HTTP_HOST']."/add_hotel.html";
echo "";
exit;
}
}else if ($method =='modify'){
$prod_id=isset($_POST['produID'])?$_POST['produID']:0;
$added=isset($_POST['checkbox_test'])?$_POST['checkbox_test']:0;
$bedtypeid=isset($_POST['select_bed'])?$_POST['select_bed']:0;
$breakfast=isset($_POST['select_breakfast'])?$_POST['select_breakfast']:0;
$addbed=isset($_POST['ifsup'])?$_POST['ifsup']:0;
$supplier=isset($_POST['supplier_test_id'])?$_POST['supplier_test_id']:0;
$payway=isset($_POST['readyPay'])?$_POST['readyPay']:0;
$paytimelimit=isset($_POST['payTime'])?$_POST['payTime']:0;
$confirm=isset($_POST['affirmStyle'])?$_POST['affirmStyle']:0;
$oversold=isset($_POST['overSale'])?$_POST['overSale']:0;
if($prod_id == 0 || $bedtypeid==0 || $breakfast==0 || $supplier==0 || $payway ==0 || $paytimelimit==0 || $confirm==0 ||$oversold==0){
echo json_encode(array("errcode"=>2,"errinfo"=>"参数错误"));
exit;
}
$sql="CALL HT_ROOM_RUN_NEW_MODIFY(".$userid.",".$prod_id.",".$added.",".$bedtypeid.",".$breakfast.",".$addbed.",".$supplier.",".$payway.",".$paytimelimit.",".$confirm.",".$oversold.")";
$result=$pdo->query($sql);
$rowset=$result->fetchAll(PDO::FETCH_ASSOC);
$result->closeCursor();
writeLog("hotel_room_save_modify.php method=modify".$sql."::".json_encode($rowset));
$url= "http://".$_SERVER['HTTP_HOST']."/change_hotel.html?productId=".$prod_id;
if ($rowset[0]['errcode']==0){
echo "";
exit;
}else{
echo "";
exit;
}
}