";
/*
# $img = $_POST['imgmiUp']; // Your data 'data:image/png;base64,AAAFBfj42Pj4';
$data_of_base64 = str_replace('data:image/jpeg;base64,', '', $data_of_base64);
$data_of_base64 = str_replace(' ', '+', $data_of_base64);
$data = base64_decode($data_of_base64);
file_put_contents('image.jpg', $data);
*/
$img_base64 = substr($data_of_base64,strrpos($data_of_base64,','));
$img_decode = base64_decode($img_base64);
#echo $img_base64 . "
";
#file_put_contents('abc.png',$img_decode); #在程式目錄產生png檔
}else{
$data_of_base64 = 0;
}
$star_item = (isset($_POST["star_item"])) ? $_POST["star_item"] : 5;
$star_item2 = (isset($_POST["star_item2"])) ? $_POST["star_item2"] : 5;
#echo "
" . "starts: " . $stars;
#echo "
" . "id_schedule: " . $id_schedule;
/*
echo $star_item01 . "
";
echo $star_item02 . "
";
echo $star_item03 . "
";
echo $star_item04 . "
";
echo $star_item05 . "
";
echo max($star_item01, $star_item02, $star_item03, $star_item04, $star_item05) . "
";
echo "data of base64: " . $data_of_base64;
*/
require_once "db/database.php"; # 載入db.php來連結資料庫
# 批次評價需要客戶編號
if ($batch == "Y") {
$sql_query = "select contractno from schedule where id = '$id_schedule'";
$data = mysqli_query($link, $sql_query);
$row = mysqli_fetch_row($data);
list($contractno) = $row;
mysqli_free_result($data);
}
# 將資料存入數據庫
$sql_query = "update schedule set customer_signature = '$img_base64', stars = '$star_item', stars_b2 = '$star_item2' where id = '$id_schedule'";
if ($fr == "cust") {
// 單筆更新簽名檔
$sql_upd = "update schedule set customer_self_signature = '$img_base64' where id = '$id_schedule'";
$res = mysqli_query($link, $sql_upd);
if ($batch == "Y") {
$sql_query = "update schedule set stars_c1 = '$star_item', stars_c2 = '$star_item2' where contractno = '$contractno' and actualdate <= '$tds' and stars_c1 is null";
} else {
$sql_query = "update schedule set stars_c1 = '$star_item', stars_c2 = '$star_item2' where id = '$id_schedule'";
}
}
$data = mysqli_query($link, $sql_query);
# 從數據庫讀出資料
#$sql_query = "select customer_signature where id = '$id_schedule'";
# 從資料庫取出jason並轉成array
$sql_query = "SELECT * FROM schedule where id = '$id_schedule'";
$data = mysqli_query($link, $sql_query);
foreach($data as $data){
$item = $data['item'];
$item_detail = $data['item_detail'];
$result = $data['result'];
$for_qmimg = $data['customer_signature'];
$star_item = $data['stars'];
$star_item2 = $data['stars_b2'];
if ($fr == "cust") {
$for_qmimg = $data['customer_self_signature'];
$star_item = $data['stars_c1'];
$star_item2 = $data['stars_c2'];
}
$actualdate = $data['actualdate'];
}
$item_arr = json_decode($item,true); //加上 true 才會轉成陣列
$item_detail_arr = json_decode($item_detail,true); //加上 true 才會轉成陣列
$result_arr = json_decode($result,true); //加上 true 才會轉成陣列
#$baditems = array_sum($result_arr) - count($result_arr);
$baditems = 0;
$i=count($result_arr);
for($j=0 ; $j<$i ; $j++){
#echo "[" . $item_arr[$j] . "][" . $item_detail_arr[$j] . "][" . $result_arr[$j] . "]";
if ($result_arr[$j] > 1) {
$baditems = $baditems + 1;
}
#echo "
";
}
include "include-header.php";
?>