$v) { $$k = htmlspecialchars(stripslashes(trim($v))); } if ($checker) { $do_assign = $end_flow = 0; $check_date = date("Y-m-d H:i:s"); // 總共簽核關卡數 $db_query = "select sign_total, case when (length(sign1)>7) then 1 else 0 end + case when (length(sign2)>7) then 1 else 0 end + case when (length(sign3)>7) then 1 else 0 end + case when (length(sign4)>7) then 1 else 0 end from pricereview_sign where mid = '$id'"; $res = mysqli_query($link, $db_query); $row = mysqli_fetch_row($res); list($sign_total, $sign_now) = $row; $sql = $sql2 = ""; if ($st == 1) { $sql = "sign1 = '$checker,$status,$check_date', sign1_note = '$sign_note'"; } elseif ($st == 2) { $sql = "sign2 = '$checker,$status,$check_date', sign2_note = '$sign_note'"; } elseif ($st == 3) { $sql = "sign3 = '$checker,$status,$check_date', sign3_note = '$sign_note'"; } else { $sql = "sign4 = '$checker,$status,$check_date', sign4_note = '$sign_note'"; } if ($status == "N") { $sql2 .= "status = 'YN'"; $end_flow = 1; } elseif ($sign_total == ($sign_now+1)) { if ($user_id == "M0006") { $final_price_total = str_replace(",", "", $final_price_total); if ($final_price_total > 0) { $sql2 .= "status = 'YY', price_total = '$final_price_total'"; } else { $sql2 .= "status = 'YY'"; } } else { $sql2 .= "status = 'YY'"; } $end_flow = 1; } else { $do_assign = 1; } if ($item_no_all) { $item_no_arr = explode(",", $item_no_all); $item_price_arr = explode(",", $item_price_all); $pv_rate_arr = explode(",", $pv_rate_all); $allocate_arr = explode(",", $allocate_all); $gross_profit_arr = explode(",", $gross_profit_all); $gross_profit_rate_arr = explode(",", $gross_profit_rate_all); $note_arr = explode(",", $note_all); $mi_fix_arr = explode(",", $mi_fix_all); foreach ($item_no_arr as $k => $v) { if (empty($mi_fix_all)) $mi_fix_arr[$k] = 0; else $mi_fix_arr[$k] = str_replace(",", "", $mi_fix_arr[$k]); if (empty($gross_profit_arr[$k])) $gross_profit_arr[$k] = 0; if (empty($gross_profit_rate_arr[$k])) $gross_profit_rate_arr[$k] = 0; $db_query = "update pricereview_item set mi_fix = '$mi_fix_arr[$k]', "; $db_query .= "gross_profit = '$gross_profit_arr[$k]', gross_profit_rate = '$gross_profit_rate_arr[$k]' "; $db_query .= "where mid = '$id' and item_no = '$v'"; mysqli_query($link, $db_query); } } if ($sql) { $db_query = "update pricereview_sign set $sql where mid = '$id'"; mysqli_query($link, $db_query); } if ($sql2) { $db_query = "update pricereview_main set $sql2 where id = '$id'"; mysqli_query($link, $db_query); } if ($do_assign) { $db_query = "select concat(length(sign2), sign2), concat(length(sign3), sign3), concat(length(sign4), sign4) from pricereview_sign where mid = '$id'"; $res = mysqli_query($link, $db_query); $row = mysqli_fetch_row($res); if (strlen($row[0]) == 8) { $next_signer = substr(str_replace(",","",$row[0]), 1); } elseif (strlen($row[1]) == 8) { $next_signer = substr(str_replace(",","",$row[1]), 1); } elseif (strlen($row[2]) == 8) { $next_signer = substr(str_replace(",","",$row[2]), 1); } do_assign("prm02", $id, $contractno_h, $next_signer, $st); // 寄信給下位簽核人 $mail_list = []; $ret = accountid2email($next_signer); if (!empty($ret)) { $mail_list[0] = [$next_signer, $ret[$next_signer]]; include dirname(__DIR__)."/class/Cmail.php"; $sendmail = new Cmail; $title = "【汰改價審通知】卷號:".$contractno_h; $content = "
您有待簽核案件,請至客戶管理 > 價格審查_汰改,點擊「待簽核」進行作業,謝謝!
"; $sendmail->sendx($title, $content, $mail_list); } } if ($end_flow) { end_flow("prm", "prm02", $id, $contractno_h); } } mysqli_close($link); echo ""; } ?>