49 changed files with 5242 additions and 4079 deletions
File diff suppressed because it is too large
@ -0,0 +1,829 @@ |
|||
<?php |
|||
require_once '../header_nomenu.php'; |
|||
require_once './FormHelper.php'; |
|||
require_once './wf_common.php'; |
|||
$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no']; |
|||
|
|||
|
|||
/*** |
|||
* 检查是否重复生成价审单 |
|||
* con_maintance_examine_apply |
|||
*/ |
|||
/* |
|||
list($cnt)=DB::fields("select count(*) cnt from con_maintance_examine_apply where vol_no='$vol_no'"); |
|||
if($cnt>0) { |
|||
echo"<script>alert('卷號".$vol_no."已生成價審單,請勿重複生成!');history.go(-1);</script>"; |
|||
exit; |
|||
} |
|||
*/ |
|||
|
|||
#係統ID |
|||
$system_id = 'con'; |
|||
#流程ID |
|||
$flow_id = 'con01'; |
|||
#表單號 $form_id; |
|||
$form_id = ""; |
|||
#價審單狀態 |
|||
$apply_st = ""; |
|||
list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); |
|||
// echo '<pre>'; |
|||
// print_r($apply_key); |
|||
// echo '</pre>'; |
|||
// exit; |
|||
// if ($salesman != $user_id) { |
|||
// echo '<script>alert("您並不是該單營業員,無法訪問。");history.go(-1);</script>'; |
|||
// exit; |
|||
// } |
|||
if (empty($apply_key)) $apply_st = 1; // 準備新增 |
|||
else { |
|||
//list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); |
|||
list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); |
|||
if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 |
|||
else $apply_st = 9; // 已到下一關,無法䖺改 |
|||
} |
|||
|
|||
// if ($apply_st > 2) { |
|||
// echo "<script>alert('卷號" . $vol_no . "已生成價審單,請勿重複生成!');history.go(-1);</script>"; |
|||
// exit; |
|||
// } |
|||
|
|||
if ($apply_st == 1) { |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id); |
|||
$wf->initWorkFlow($user_id); |
|||
$form_key = $wf->flowContext->getFormKey(); |
|||
} else { |
|||
$wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); |
|||
} |
|||
|
|||
#獲取簽核意見 |
|||
$assign_opinions = Assign::get_records($form_key); |
|||
|
|||
#會簽部門意見 |
|||
$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); |
|||
|
|||
//預設冇有摺扣 |
|||
$wf->setFormData(['discount' => 100]); |
|||
$flowName = $wf->getFlowName(); |
|||
$assigner = $wf->getAssignerList(); |
|||
$assign_status = $wf->getAssignStatus($assigner); |
|||
$if_show_assign = true; |
|||
//加載流程圖 |
|||
//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); |
|||
//$path = $fc[0]->wf_file; |
|||
//echo dirname(__DIR__)."/../"."$path"; |
|||
|
|||
//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); |
|||
#是否可會簽 |
|||
$isSplitable = $wf->isSplitable(); |
|||
|
|||
//表單數據 |
|||
#客戶表 |
|||
#1.電梯品牌選項 |
|||
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; |
|||
$elevator_brand_opt = DB::result($sql); |
|||
#2.保養方式 |
|||
$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; |
|||
$maintain_kind_opt = DB::result($sql); |
|||
#3.電梯類型 |
|||
$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; |
|||
$elevator_kind_opt = DB::result($sql); |
|||
#4.付款方式 |
|||
$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; |
|||
$payment_kind_opt = DB::result($sql); |
|||
#5.契約性質 |
|||
$sql = "select code_name value ,content label from code where field_name='contract_kind'"; |
|||
$contract_kind_opt = DB::result($sql); |
|||
#6.是否贈送M1 |
|||
$is_m1_bundle_opt = [ |
|||
['label' => '是', 'value' => 'Y'], |
|||
['label' => '否', 'value' => 'N'] |
|||
|
|||
]; |
|||
#7.機種 |
|||
$sql = "select code_name value ,content label from code where field_name='fp_kind'"; |
|||
$fp_kind_opt = DB::result($sql); |
|||
#抓取有望客戶資料 |
|||
|
|||
$vol_no = $_GET['vol_no']; |
|||
$where = " and vol_no='$vol_no'"; |
|||
$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; |
|||
$hope_contract = DB::result($sql); |
|||
$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; |
|||
#寫入 con_maintance_examine_apply |
|||
if ($apply_st == 1) { |
|||
#獲取評審單號 |
|||
$apply_key = get_sequnece_no('cmea_apply_key', date('ym')); |
|||
//var_dump($hope_contract); |
|||
$insert_data = [ |
|||
'apply_key' => $apply_key, |
|||
'vol_no' => $vol_no, |
|||
'form_key' => $form_key, |
|||
'address' => $hope_contract['address'], |
|||
'case_name' => $hope_contract['customer'], |
|||
'num' => $hope_contract['num'], |
|||
'brand' => '', |
|||
'customer' => $hope_contract['customer'], |
|||
'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], |
|||
'progress_remark' => $hope_contract['progress_status'] |
|||
//'platform_company'=>'', |
|||
// 'platforom_company_tel'=> '' |
|||
|
|||
]; |
|||
//var_dump($insert_data); |
|||
DB::insert_table('con_maintance_examine_apply', $insert_data); |
|||
} |
|||
#抓使用者主管 |
|||
$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; |
|||
list($result) = DB::result($sql); |
|||
if ($result['department_id'] == '511') { |
|||
$managerid = 'M0137'; |
|||
$managername = '劉永德'; |
|||
} else if ($result['department_id'] == '512') { |
|||
$managerid = 'M0137'; |
|||
$managername = '劉永德'; |
|||
} else if ($result['department_id'] == '513') { |
|||
$managerid = 'M0086'; |
|||
$managername = '李烘銘'; |
|||
} else if ($result['department_id'] == '514') { |
|||
$managerid = 'M0033'; |
|||
$managername = '吳育宗'; |
|||
} |
|||
|
|||
if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { |
|||
$managerid = 'M0008'; |
|||
$managername = '詹益彰'; |
|||
} |
|||
|
|||
if ($result['department_id'] == 'M0008') { |
|||
$managerid = 'M0008'; |
|||
$managername = '詹益彰'; |
|||
} |
|||
$table = 'con_maintance_examine_apply'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'apply_key' => [ |
|||
'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', |
|||
'attr' => [ |
|||
'readonly=true ', |
|||
'class' => 'form-control form-control-sm' |
|||
] |
|||
], |
|||
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], |
|||
'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], |
|||
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], |
|||
'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
|
|||
'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], |
|||
|
|||
]; |
|||
$where = " and apply_key='$apply_key'"; |
|||
|
|||
$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
$data = []; |
|||
$data = DB::result($sql); |
|||
|
|||
#電梯詳細資料 |
|||
$con_maintance_examine_clear_columm = [ |
|||
'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], |
|||
'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], |
|||
'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], |
|||
'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], |
|||
'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], |
|||
'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], |
|||
'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], |
|||
'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], |
|||
'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], |
|||
|
|||
'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], |
|||
'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], |
|||
'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], |
|||
|
|||
'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], |
|||
|
|||
'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], |
|||
'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], |
|||
'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], |
|||
'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], |
|||
'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], |
|||
|
|||
]; |
|||
$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . |
|||
" FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); |
|||
$j = 0; |
|||
$col_count = 12; |
|||
$cmecRow = " <tr>"; |
|||
foreach ($con_maintance_examine_clear_columm as $key => $val) { |
|||
$fieldVal = ""; |
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select('', $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
// : "<input type='" . $val['tag'] . "' class=' form-control form-control-sm' " . $val['attr'] . " value='" . $fieldVal . "' name='${key}[]' id='$key' placeholder='請輸入'>"; |
|||
$cmecRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>"; |
|||
if ((++$j % $col_count) == 0) { |
|||
if ($j == $col_count) $cmecRow .= "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>"; |
|||
$cmecRow .= "</tr><tr>"; |
|||
} |
|||
} |
|||
|
|||
|
|||
$cmecRow .= "</tr>"; |
|||
function base_url($url) |
|||
{ |
|||
return "https://www.masada.com.tw/static/" . $url; |
|||
} |
|||
function get_sequnece_no($seq_name = '', $p_yyyymm = '') |
|||
{ |
|||
|
|||
if (empty($p_yyyymm) || empty($seq_name)) return null; |
|||
#當前年月 |
|||
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); |
|||
if ($p_yyyymm != $yyyymm) { |
|||
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); |
|||
} |
|||
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; |
|||
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); |
|||
|
|||
|
|||
return $seq_no; |
|||
} |
|||
|
|||
|
|||
?> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" /> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" /> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script> |
|||
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script> |
|||
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"> |
|||
|
|||
</script> |
|||
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100); ?>" /> |
|||
<script type="text/javascript"> |
|||
window.param = { |
|||
elevator_type: '', |
|||
floors: 1, |
|||
speed: 1, |
|||
persons: 6, |
|||
weight: 1000, |
|||
maintain_times: 1, //病床梯一月2次保養 |
|||
maintain_months: 12, |
|||
maintain_kind: 2, |
|||
maintain_period: 1, //預設為1月1次, 2是為2月一次 |
|||
is_m1_bundle: 'N', |
|||
}; |
|||
|
|||
let regDelStr = ""; |
|||
|
|||
$(document).ready(function() { |
|||
var tag_data; |
|||
$.ajax({ |
|||
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner', |
|||
//url: 'http://localhost/fds/index.php/DesignFlow/get_assigner', |
|||
type: 'post', |
|||
dataType: 'json', |
|||
success: function(data) { |
|||
window.tag_data = data; |
|||
$('#selectPage').selectPage({ |
|||
showField: 'show_name', |
|||
keyField: 'val', |
|||
data: data, |
|||
multiple: true, |
|||
multipleControlbar: true, |
|||
pagination: false, |
|||
focusDropList: false |
|||
}); |
|||
} |
|||
}); |
|||
|
|||
$.validator.addMethod('gt', function(value, element, param) { |
|||
return value > param; |
|||
}, $.validator.format("輸入值必須大於0")); |
|||
var assigner = eval('<?= json_encode($assigner) ?>'); |
|||
//console.log(assigner); |
|||
|
|||
var cmecRow = "<?= str_replace('"', '\'', $cmecRow) ?>"; |
|||
// $('#cmecTbody').append(cmecRow); |
|||
$('.sp_element_box').attr("disabled", true); |
|||
$("#assign_opinion").cleditor({ |
|||
height: 100, // height not including margins, borders or padding |
|||
controls: // controls to add to the toolbar |
|||
"bold italic underline strikethrough subscript superscript | font size " + |
|||
"style | color highlight removeformat | bullets numbering | outdent " + |
|||
"indent | alignleft center alignright justify | undo redo | " |
|||
}); |
|||
|
|||
$('#contract_begin_date').on('input propertychange', function(e) { |
|||
|
|||
var date = new Date(e.target.value); |
|||
var yyyy = date.getFullYear() + 1; |
|||
var mm = date.getMonth() + 1; |
|||
var dd = date.getDate(); |
|||
var time = yyyy + `-` + (mm < 10 ? '0' + mm : mm) + '-' + (dd < 10 ? '0' + dd : dd); |
|||
$('#contract_end_date').val(time); |
|||
}); |
|||
|
|||
$('#brand').change(function() { |
|||
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態 |
|||
if (_selected_status == 'Z') { |
|||
$('#brandModal').modal('show') |
|||
} |
|||
|
|||
}); |
|||
$('#assign_status').change(function() { |
|||
$("#next_users").empty(); |
|||
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態 |
|||
var _option_tmp = ""; //獲取下拉列表 |
|||
// for (a in assigner) { //遍曆assigner |
|||
// if (assigner[a][0] == _selected_status) { |
|||
// _tmp = assigner[a][1].split(','); |
|||
// for (var b in _tmp) { |
|||
// if (_tmp[b] == '') { |
|||
// continue; |
|||
// } |
|||
// _uname = _tmp[b].split('-')[1]; |
|||
// _uid = _tmp[b].split('-')[0]; |
|||
// /* console.log(_tmp[b]);*/ |
|||
// _option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>'; |
|||
// } |
|||
// } |
|||
// } |
|||
_option_tmp += '<option value=' + '<?php echo $managerid ?>' + '>' + '<?php echo $managername ?>' + '</option>'; |
|||
console.log(_option_tmp); |
|||
$("#next_users").append(_option_tmp); |
|||
}); |
|||
$('#maintain_kind').change(function() { |
|||
if ($('#cmecTbody tr').length > 0) { |
|||
alert("保養方式已更動,請開始輸入電梯資料!"); |
|||
$('#cmecTbody').find(':input').val(''); |
|||
return false; |
|||
} |
|||
}); |
|||
$("#form").validate(); |
|||
$("form").submit(function(e) { |
|||
$('#reg_del').val(regDelStr); |
|||
}); |
|||
}); |
|||
addRow = function() { |
|||
if ($('#maintain_kind').val() == "") { |
|||
alert("請選擇保養方式!"); |
|||
$('#maintain_kind').eq(0).focus(); |
|||
return false; |
|||
} |
|||
var cmecRow = "<?= $cmecRow ?>"; |
|||
$('#cmecTbody').append(cmecRow); |
|||
$("select[name^='elevator_kind'],select[name^='is_m1_bundle']").on('change', function(obj) { |
|||
//console.log('#'+$(this).attr('name')+'#'); |
|||
var elen = 1; |
|||
if ('elevator_kind[]' == $(this).attr('name')) { |
|||
var children = $(this).parent().parent().parent(); |
|||
var elementObj = $(children).next('tr').find("input[name^='stand_price']"); |
|||
//var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option:selected").val(); |
|||
} else if ('is_m1_bundle[]' == $(this).attr('name')) { |
|||
var children = $(this).parent().parent().parent().prev('tr'); |
|||
var elementObj = $(this).parent().parent().parent().find("input[name^='stand_price']"); |
|||
//var is_m1_bundle = $(this).val(); |
|||
} |
|||
|
|||
var element = elementObj; |
|||
if ('elevator_kind[]' == $(this).attr('name')) { |
|||
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle'] option: selected").val(""); |
|||
} else if ('is_m1_bundle[]' == $(this).attr('name')) { |
|||
var is_m1_bundle = $(children).next('tr').find("select[name^='is_m1_bundle']").val(); |
|||
} |
|||
|
|||
var floors = $(children).find("input[name^='floors']").val(); |
|||
var speed = $(children).find("input[name^='speed']").val(); |
|||
var weight = $(children).find("input[name^='weight']").val(); |
|||
var persons = $(children).find("input[name^='persons']").val(); |
|||
var maintain_times = $(children).find("input[name^='maintain_times']").val(); |
|||
var maintain_months = $(children).find("input[name^='maintain_months']").val(); |
|||
var maintain_period = $(children).find("input[name^='maintain_period']").val(); |
|||
var maintain_kind = $('#maintain_kind').val(); |
|||
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val(); |
|||
|
|||
var param1 = { |
|||
...param, |
|||
persons, |
|||
floors, |
|||
speed, |
|||
weight, |
|||
maintain_times, |
|||
maintain_months, |
|||
maintain_period, |
|||
maintain_kind, |
|||
elevator_type, |
|||
is_m1_bundle |
|||
} |
|||
setStandPrice(param1, element); |
|||
//console.info(param1); |
|||
}); |
|||
|
|||
$("input[name^='floors']" + |
|||
",input[name^='speed']" + |
|||
",input[name^='persons']" + |
|||
",input[name^='weight']" + |
|||
",input[name^='maintain_times']" + |
|||
",input[name^='maintain_months']" + |
|||
",input[name^='maintain_period']" |
|||
).on('input propertychange', function(obj) { |
|||
// $(obj).parent().parent().parent().remove(); |
|||
var children = $(this).parent().parent().parent().children(); |
|||
var floors = $(children).find("input[name^='floors']").val(); |
|||
var speed = $(children).find("input[name^='speed']").val(); |
|||
var weight = $(children).find("input[name^='weight']").val(); |
|||
var persons = $(children).find("input[name^='persons']").val(); |
|||
var maintain_times = $(children).find("input[name^='maintain_times']").val(); |
|||
var maintain_months = $(children).find("input[name^='maintain_months']").val(); |
|||
var maintain_period = $(children).find("input[name^='maintain_period']").val(); |
|||
var maintain_kind = $('#maintain_kind').val(); |
|||
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val(); |
|||
var is_m1_bundle = $(this).parent().parent().parent().next('tr').find("select[name^='is_m1_bundle'] option:selected").val(); |
|||
|
|||
var param1 = { |
|||
...param, |
|||
persons, |
|||
floors, |
|||
speed, |
|||
weight, |
|||
maintain_times, |
|||
maintain_months, |
|||
maintain_period, |
|||
maintain_kind, |
|||
elevator_type, |
|||
is_m1_bundle |
|||
} |
|||
var element = $(this).parent().parent().parent().next().children().find("input[name^='stand_price']"); |
|||
setStandPrice(param1, element); |
|||
|
|||
}); |
|||
} |
|||
delRow = function(btn) { |
|||
if ($(btn).attr('name') == 'btn1') { |
|||
//console.log($(btn).parent().parent().prev('tr').find('input[id=register_code]').val()); |
|||
regDelStr += $(btn).parent().parent().find('input[id=register_code]').val() + ","; |
|||
$(btn).parent().parent().next('tr').remove(); |
|||
} else { |
|||
//console.log($(btn).parent().parent().find('input[id=register_code]').val()); |
|||
$(btn).parent().parent().next('tr').remove(); |
|||
$(btn).parent().parent().remove(); |
|||
} |
|||
$(btn).parent().parent().remove(); |
|||
} |
|||
setStandPrice = function(p, obj) { |
|||
$.ajax({ |
|||
url: '../cont/t.php', |
|||
data: p, |
|||
type: 'get', |
|||
dataType: 'json', |
|||
//success: function(data) {}, |
|||
success: function(data) { |
|||
console.info(data); |
|||
if (data.status == 'ok') { |
|||
$(obj).val(data.price); |
|||
} else { |
|||
$(obj).val(data.message); |
|||
|
|||
} |
|||
} |
|||
|
|||
}); |
|||
} |
|||
addNewBrand = function() { |
|||
var new_brand = $("#new_brand").val(); |
|||
if (new_brand != '') { |
|||
p = { |
|||
new_brand: new_brand, |
|||
method: 'add_brand' |
|||
} |
|||
$.ajax({ |
|||
url: 'async_req.php', |
|||
data: p, |
|||
type: 'post', |
|||
dataType: 'json', |
|||
success: function(data) { |
|||
console.info(data); |
|||
$("#brand").append("<option value='" + data.seq + "'>" + new_brand + "</option>"); |
|||
}, |
|||
error: function(data) { |
|||
console.info(data); |
|||
} |
|||
|
|||
}); |
|||
} |
|||
|
|||
} |
|||
</script> |
|||
|
|||
|
|||
<body> |
|||
|
|||
<div id="toolbarmenu"> |
|||
<!--<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>--> |
|||
<!-- 導航欄 --> |
|||
|
|||
<ul class="nav nav-tabs" role="tablist" id="tablist"> |
|||
<li class=" nav-item "> |
|||
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">簽核表單</a> |
|||
</li> |
|||
|
|||
|
|||
</ul> |
|||
</div> |
|||
<!-- 導航欄 END--> |
|||
<div class="tab-content "> |
|||
|
|||
<div class="tab-pane active assign_content " id="tabassign"> |
|||
<form action="submit.php" id='form' method="post" style='width:98%;margin:0 auto'> |
|||
<!-- hidden域 --> |
|||
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' /> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>' /> |
|||
<input type="hidden" name="reg_del" id="reg_del"> |
|||
<input type="hidden" name="form_src" id="form_src" value="apply_form"> |
|||
<!--表單start--> |
|||
<div class=" form container-fluid pt-5"> |
|||
<div class="row form_head "> |
|||
<div class=" col-12 form_head_title "> |
|||
<h4> 保養契約價格審核單</h4> |
|||
</div> |
|||
</div> |
|||
|
|||
<div class="row " style='padding-top:30px;'> |
|||
<div class=" col-lg-12 form_row_header "> |
|||
<b>契約信息</b> |
|||
</div> |
|||
</div> |
|||
|
|||
<?php |
|||
//一行顯示三列 |
|||
$i = 0; |
|||
echo " <div class='row '>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
$j = (($i++) % 4); |
|||
$fieldVal = empty($data) ? "" : $data[0][$key]; |
|||
|
|||
$_input = $val['tag'] == 'select' ? |
|||
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) |
|||
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); |
|||
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "' |
|||
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>"; |
|||
if ($i != 1 && $j == 0) { |
|||
echo " |
|||
</div> |
|||
<div class='row'> |
|||
"; |
|||
} |
|||
echo " <div class='col-1 form_field_title'> |
|||
" . $val['label'] . " |
|||
</div> |
|||
<div class=' col-2 form_field_content ' > |
|||
$_input |
|||
</div> |
|||
"; |
|||
} |
|||
echo "</div>"; |
|||
|
|||
?> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>洽商進度</b> |
|||
</div> |
|||
<div class="col-12 " style="padding:0"> |
|||
|
|||
<textarea class='form-control textarea' id="progress_remark" name="progress_remark" value='12' rows='6'><?= $hope_contract['progress_status'] ?></textarea> |
|||
</div> |
|||
</div> |
|||
<div id="elevator_list_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>電梯詳細資料</b> |
|||
</div> |
|||
<table style='margin-top:0px;text-align:center' class=' table-condensed' id='elevator_list'> |
|||
|
|||
<thead> |
|||
<tr> |
|||
<td colspan='18' style='text-align:left;font-size:13px'> |
|||
<b>註意事項:</b> |
|||
<p>1.速度單位是 米/分.</p> |
|||
<p>2.選擇贈送M1,保養月數需填寫60.</p> |
|||
<p>3.標準價格未帶出,請聯係業務部建立該規格報價.</p> |
|||
<p>4.無機房速度20~60米 以60米為標準.</p> |
|||
|
|||
|
|||
</td> |
|||
</tr> |
|||
<tr> |
|||
<td colspan='18' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td> |
|||
</tr> |
|||
<tr style='margin-top:0px;text-align:center'> |
|||
<?php |
|||
$j = 0; |
|||
foreach ($con_maintance_examine_clear_columm as $val) { |
|||
|
|||
echo FormHelper::tag("th", ['colspan' => empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']); |
|||
//echo "<th>" . $val['label'] . "</th>"; |
|||
if ((++$j % $col_count) == 0) { |
|||
if ($j == $col_count) echo "<th>操作</th>"; |
|||
|
|||
|
|||
echo "</tr><tr style='margin-top:0px;text-align:center'>"; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
?> |
|||
|
|||
</tr> |
|||
</thead> |
|||
<tbody id='cmecTbody'> |
|||
<?php |
|||
|
|||
foreach ($con_maintance_examine_clear as $key => $val) { |
|||
$j = 0; |
|||
$cmecRow = " <td>"; |
|||
foreach ($con_maintance_examine_clear_columm as $col => $col_def) { |
|||
|
|||
$fieldVal = empty($val) ? "" : $val[$col]; |
|||
$_input = $col_def['tag'] == 'select' ? |
|||
FormHelper::select($col, $col_def['options'], $fieldVal, $col_def['attr']) |
|||
: FormHelper::text($col, $fieldVal, $col_def['attr'], $col_def['tag']); |
|||
$cmecRow .= "<td colspan='" . (empty($col_def['attr']['colspan']) ? '' : |
|||
$col_def['attr']['colspan']) . "' ><div class=' col-12'> |
|||
$_input</td>"; |
|||
if ((++$j % $col_count) == 0) { |
|||
$cmecRow .= "<td><button name='btn1' onClick='delRow(this)' type='button' class='btn btn-link btn-md '>刪除</button></td>"; |
|||
$cmecRow .= "</td><td>"; |
|||
} |
|||
} |
|||
|
|||
|
|||
echo $cmecRow . "</td>"; |
|||
} |
|||
?> |
|||
</tbody> |
|||
</table> |
|||
|
|||
</div> |
|||
|
|||
<div id="assign_area " class="row "> |
|||
<div class="col-12 form_row_header "> |
|||
<b>簽核操作</b> |
|||
</div> |
|||
<div class="col-12 col-3 form_field_content " style="padding:0"> |
|||
<textarea id="assign_opinion" name="assign_opinion" required></textarea> |
|||
</div> |
|||
</div> |
|||
<div class="row"> |
|||
<div class=" col-3 form_field_title"> |
|||
<b style='float:right'>簽核狀態</b> |
|||
</div> |
|||
<div class=" col-2 form_field_content "> |
|||
<select name="assign_status" id="assign_status" required class='form-control form-control form-control-sm '> |
|||
<?php echo $assign_status; ?> |
|||
</select> |
|||
</div> |
|||
|
|||
<div class=" col-2 form_field_title"> |
|||
<b>下位簽核者</b> |
|||
</div> |
|||
<div class="col-2 form_field_content"> |
|||
<select lect name="next_users" id="next_users" class='form-control form-control-sm '></select> |
|||
|
|||
</div> |
|||
<div class="col-3 form_field_title "> |
|||
<button type="submit" name="btn_save" class="btn btn-warning btn-sm" value="save" style='float:left;margin-right:4px;'>保存</button> |
|||
<button type="submit" name="btn_save" class="btn btn-primary btn-sm" value="tosign" style='float:left'>提交</button> |
|||
</div> |
|||
|
|||
</div> |
|||
<div id="opinion_area " class="row form_comment "> |
|||
<div class='col-12 '> |
|||
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'> |
|||
<li class="active nav-item "> |
|||
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a> |
|||
</li> |
|||
|
|||
</ul> |
|||
</div> |
|||
<div class="tab-content col-12"> |
|||
<div role="tabpanel" class="tab-pane active" id="main_flow_assign"> |
|||
<?php |
|||
$assign_departs = array(); |
|||
foreach ($assign_opinions as $as) { |
|||
$assign_departs[$as['assign_depart']] = $as['assign_depart_name']; |
|||
} |
|||
?> |
|||
|
|||
<div class="comment_items "> |
|||
<?php $cnt = 1; |
|||
$tmp_code = "0"; |
|||
foreach ($assign_opinions as $as) { ?> |
|||
<div class="comment-item"> |
|||
|
|||
<!-- <div class="comment-title"> |
|||
<b>大 </b> |
|||
</div>--> |
|||
<?php |
|||
if (($as['flow_code']) != $tmp_code) |
|||
echo ' <div class="comment-title"> |
|||
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b> |
|||
</div>'; |
|||
$tmp_code = $as['flow_code']; |
|||
?> |
|||
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>"> |
|||
<div class="comment-content-header"> |
|||
<span> |
|||
|
|||
<strong> |
|||
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?> |
|||
|
|||
<?php if ($as['lead_code'] < 90) echo |
|||
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?> |
|||
|
|||
</strong> |
|||
</span> |
|||
<span> |
|||
|
|||
<strong> |
|||
|
|||
<?php if ($as['assign_status'] == 'S') echo |
|||
" <label class='comment-content-tag'>申請人 </label>"; ?> |
|||
<?php if (substr($as['assign_status'], 0, 1) == 'B') |
|||
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?> |
|||
<?php if (substr($as['assign_status'], 0, 2) == 'X3') |
|||
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?> |
|||
</strong> |
|||
</span> |
|||
<span class="comment-content-header-time"> |
|||
簽核於:<?= $as['assign_date'] ?> |
|||
</span> |
|||
|
|||
<!-- <ul class="comment-content-tags"> |
|||
<li class="">不同意</li> |
|||
<li class="comment-content-tag-alert">退回</li> |
|||
</ul>--> |
|||
</div> |
|||
<div class="comment-content-body"> |
|||
<?= $as['assign_opinion'] ?> |
|||
</div> |
|||
<!-- <div class="comment-content-footer"> |
|||
<span>已上載附件: </span><a href="#">附件1</a> |
|||
</div>--> |
|||
</div> |
|||
|
|||
</div> |
|||
<?php } ?> |
|||
|
|||
|
|||
</div> |
|||
</div> |
|||
|
|||
</div> |
|||
</div> |
|||
</div> |
|||
</form> |
|||
<!-- 模態框(Modal) --> |
|||
<div class="modal fade" id="brandModal" tabindex="-1" role="dialog" aria-labelledby="brandModalLabel" aria-hidden="true"> |
|||
<div class="modal-dialog"> |
|||
<div class="modal-content"> |
|||
<div class="modal-header"> |
|||
新增廠牌 |
|||
</div> |
|||
<div class="modal-body"> |
|||
<input type="text" class='form-control form-control form-control-sm ' id='new_brand'> |
|||
|
|||
</div> |
|||
<div class="modal-footer"> |
|||
<button type="button" class="btn btn-primary" onClick="addNewBrand()" data-dismiss="modal">保存</button> |
|||
|
|||
</div> |
|||
</div><!-- /.modal-content --> |
|||
</div><!-- /.modal --> |
|||
</div> |
|||
</div> |
|||
|
|||
|
|||
|
|||
</div> |
|||
|
|||
</body> |
@ -1,157 +1,159 @@ |
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
$table = 'con_maintance_examine_apply'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'apply_key' => [ |
|||
'label' => "評審單號", "value" => "", "tag" => 'text', |
|||
'attr' => [ |
|||
'readonly=true ', |
|||
'class' => 'form-control form-control-sm' |
|||
] |
|||
], |
|||
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
//'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], |
|||
|
|||
]; |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; |
|||
//$where = " and salesman like '%'"; |
|||
$where = " and salesman = '$salesman'"; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["220"]; |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006") $where = ""; |
|||
|
|||
// 電梯廠牌 |
|||
$elevator_brand_arr = []; |
|||
$sql = "select code_name ,content from code where field_name='elevator_brand'"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$elevator_brand_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$sql = "SELECT |
|||
apply_key, |
|||
vol_no, |
|||
address, |
|||
case_name, |
|||
brand , |
|||
num , |
|||
f_return_name(salesman) salesman, |
|||
f_return_content('maintain_kind',maintain_kind ) maintain_kind, |
|||
date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, |
|||
date_format(contract_end_date,'%Y/%m/%d') contract_end_date , |
|||
f_return_content('contract_kind',contract_kind ) contract_kind, |
|||
platform_company, |
|||
platforom_company_tel, |
|||
form_key, |
|||
|
|||
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table |
|||
where 1=1 $where ORDER BY vol_no"; |
|||
|
|||
$data = mysqli_query($link, $sql); |
|||
?> |
|||
|
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' |
|||
style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>(契約)價審單查詢</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
|
|||
</table> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:98%" > |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
|
|||
echo "<th>".$val['label']."</th>"; |
|||
} |
|||
echo "<th>是否結案</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
if ( $key =='apply_key') { |
|||
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=".$_GET['token']."'>" . $row[$key] . "</td>"; |
|||
} elseif ($key == 'brand') { |
|||
echo "<td>" . (!empty($row[$key])?$elevator_brand_arr[$row[$key]]:"") . "</td>"; |
|||
} else { |
|||
echo "<td>" . $row[$key] . "</td>"; |
|||
} |
|||
} |
|||
//list($signer)=DB::fields("); |
|||
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ." |
|||
list($signer)=mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='". $row['form_key'] ."'" )); |
|||
|
|||
echo "<td>" .(empty($signer)?"結案":"N") . "</td>"; |
|||
|
|||
?> |
|||
|
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
$table = 'con_maintance_examine_apply'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'apply_key' => [ |
|||
'label' => "評審單號", "value" => "", "tag" => 'text', |
|||
'attr' => [ |
|||
'readonly=true ', |
|||
'class' => 'form-control form-control-sm' |
|||
] |
|||
], |
|||
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], |
|||
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], |
|||
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], |
|||
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], |
|||
//'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], |
|||
|
|||
]; |
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
|
|||
$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; |
|||
//$where = " and salesman like '%'"; |
|||
$where = " and salesman = '$salesman'"; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["220"]; |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006") $where = ""; |
|||
|
|||
// 電梯廠牌 |
|||
$elevator_brand_arr = []; |
|||
$sql = "select code_name ,content from code where field_name='elevator_brand'"; |
|||
$res = mysqli_query($link, $sql); |
|||
while ($row = mysqli_fetch_row($res)) { |
|||
$elevator_brand_arr[$row[0]] = $row[1]; |
|||
} |
|||
mysqli_free_result($res); |
|||
|
|||
$sql = "SELECT |
|||
apply_key, |
|||
vol_no, |
|||
address, |
|||
case_name, |
|||
brand , |
|||
num , |
|||
f_return_name(salesman) salesman, |
|||
f_return_content('maintain_kind',maintain_kind ) maintain_kind, |
|||
date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, |
|||
date_format(contract_end_date,'%Y/%m/%d') contract_end_date , |
|||
f_return_content('contract_kind',contract_kind ) contract_kind, |
|||
platform_company, |
|||
platforom_company_tel, |
|||
form_key, |
|||
|
|||
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table |
|||
where 1=1 $where ORDER BY vol_no"; |
|||
// echo $sql; |
|||
$data = mysqli_query($link, $sql); |
|||
// echo '<pre>'; |
|||
// print_r($data); |
|||
// echo '</pre>'; |
|||
?> |
|||
|
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>(契約)價審單查詢</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
|
|||
</table> |
|||
<table id="table_index" class="table table-striped table-bordered" style="width:98%"> |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
|
|||
echo "<th>" . $val['label'] . "</th>"; |
|||
} |
|||
echo "<th>是否結案</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
if ($key == 'apply_key') { |
|||
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=" . $_GET['token'] . "'>" . $row[$key] . "</td>"; |
|||
} elseif ($key == 'brand') { |
|||
echo "<td>" . (!empty($row[$key]) ? $elevator_brand_arr[$row[$key]] : "") . "</td>"; |
|||
} else { |
|||
echo "<td>" . $row[$key] . "</td>"; |
|||
} |
|||
} |
|||
//list($signer)=DB::fields("); |
|||
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ." |
|||
list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'")); |
|||
|
|||
echo "<td>" . (empty($signer) ? "結案" : "N") . "</td>"; |
|||
|
|||
?> |
|||
|
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
?> |
@ -1,319 +1,317 @@ |
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set ( 'date.timezone' , 'Asia/Taipei' ); |
|||
//保養簽回 |
|||
if(isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { |
|||
try{ |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno'])? $_POST['contractno'] : null; |
|||
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
|||
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] :null; |
|||
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor']: null; |
|||
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; |
|||
$email = !empty($_POST['email']) ? $_POST['email'] : null; |
|||
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; |
|||
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; |
|||
$salesman = !empty($_POST['salesman']) ?$_POST['salesman'] : null; |
|||
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; |
|||
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$area = !empty($_POST['area']) ? $_POST['area'] : null; |
|||
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
|||
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; |
|||
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; |
|||
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; |
|||
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; |
|||
$num = !empty($_POST['num']) ? $_POST['num'] : null; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; |
|||
// validate |
|||
$fail_arr = []; |
|||
if($contractno === '') return $fail_arr[] = '合約號為必填'; |
|||
|
|||
if($total_price == '') $fail_arr[] = '合約總價為必填'; |
|||
if($vat == '') $fail_arr[] = '統一編號為必填'; |
|||
if($mtype == '') $fail_arr[] = '維修型態為必填'; |
|||
if($phone == '') $fail_arr[] = '客戶電話為必填'; |
|||
if($email == '') $fail_arr[] = 'Email為必填'; |
|||
if($mworker == '') $fail_arr[] = '保養員為必填'; |
|||
if($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|||
if($salesman == '') $fail_arr[] = '營業員為必填'; |
|||
if($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; |
|||
if($contract_end_date == '') $fail_arr[] = '合約結束時間為必填'; |
|||
if($address == '') $fail_arr[] = '地址為必填'; |
|||
if($area == '') $fail_arr[] = '區域為必填'; |
|||
if($customer == '') $fail_arr[] = '客戶為必填'; |
|||
if($partyA == '') $fail_arr[] = '業務聯繫人為必填'; |
|||
if($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; |
|||
if($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; |
|||
if($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; |
|||
if($num == '') $fail_arr[] = '電梯數量為必填'; |
|||
if(count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
//create account table |
|||
$accounttype = "A"; |
|||
$accountid = $vat; |
|||
$pwd = "123"; |
|||
$name = $partyA; |
|||
$tel = $phone ?? ''; |
|||
$repairerid = $mworker; |
|||
$creater = $user_id; |
|||
$create_at = date('Y-m-d H:i:s'); |
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':accounttype' ,$accounttype); |
|||
$stmt -> bindParam(':accountid' ,$accountid); |
|||
$stmt -> bindParam(':pwd' ,$pwd); |
|||
$stmt -> bindParam(':name' ,$name); |
|||
$stmt -> bindParam(':tel' ,$tel); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':email' ,$email); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> execute(); |
|||
|
|||
//create contract table |
|||
|
|||
$contracttype = $mtype; |
|||
$company = $partyA; |
|||
$taxid = $vat; |
|||
$tel = $phone; |
|||
$promiser = $partyA; |
|||
$contractperson = $partyA; |
|||
|
|||
$contractaddress = $address; |
|||
$contracttel = $phone; |
|||
$contractemail = $email; |
|||
$contract_employee = $salesman; |
|||
$start_date = $contract_begin_date; |
|||
$end_date = $contract_end_date; |
|||
|
|||
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contracttype' ,$contracttype); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':company' ,$company); |
|||
$stmt -> bindParam(':taxid' ,$taxid); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':tel' ,$tel); |
|||
$stmt -> bindParam(':promiser' ,$promiser); |
|||
$stmt -> bindParam(':contractperson' ,$contractperson); |
|||
$stmt -> bindParam(':contractaddress' ,$contractaddress); |
|||
$stmt -> bindParam(':contracttel' ,$contracttel); |
|||
$stmt -> bindParam(':contractemail' ,$contractemail); |
|||
$stmt -> bindParam(':contract_employee' ,$contract_employee); |
|||
$stmt -> bindParam(':start_date' ,$start_date); |
|||
$stmt -> bindParam(':end_date' ,$end_date); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> execute(); |
|||
|
|||
//create facility table |
|||
$createFacilityNo = new CreateFacilityNo(); |
|||
$dailyNecessities = [ |
|||
'MAE100'=>'X', |
|||
'MAM200'=>'W', |
|||
'MAH100'=>'H', |
|||
'MAQ100'=>'Z', |
|||
'MAF100'=>'F', |
|||
'MAZ100'=>'B', |
|||
]; |
|||
$facility_arr = []; |
|||
foreach($elevators as $elevator){ |
|||
$facility_arr[] = $dailyNecessities[$elevator['spec']]; |
|||
} |
|||
echo json_encode($facility_arr); |
|||
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); |
|||
echo json_encode($facilityno); |
|||
echo '-------'; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accountid',$mworker); |
|||
$stmt->execute(); |
|||
$worker = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$customerid = $vat; |
|||
$define = "B"; |
|||
$repairtype = $mtype; |
|||
$repairerid = $mworker; |
|||
$repairername = $worker['name']; |
|||
foreach($elevators as $idx=>$elevator){ |
|||
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) |
|||
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':define' ,$define); |
|||
$stmt -> bindParam(':facilityno' ,$facilityno[$idx]); |
|||
$stmt -> bindParam(':latitude' ,$elevator['latitude']); |
|||
$stmt -> bindParam(':longitude' ,$elevator['longitude']); |
|||
$stmt -> bindParam(':customerid' ,$customerid); |
|||
$stmt -> bindParam(':weight' ,$elevator['weight']); |
|||
$stmt -> bindParam(':numberofpassenger' ,$elevator['persons']); |
|||
$stmt -> bindParam(':numberofstop' ,$elevator['stop']); |
|||
$stmt -> bindParam(':numberoffloor' ,$elevator['floors']); |
|||
$stmt -> bindParam(':opentype' ,$elevator['opendoor']); |
|||
$stmt -> bindParam(':speed' ,$elevator['speed']); |
|||
$stmt -> bindParam(':repairtype' ,$repairtype); |
|||
$stmt -> bindParam(':maintainance' ,$elevator['maintainance']); |
|||
$stmt -> bindParam(':facility_kind' ,$elevator['spec']); |
|||
$stmt -> bindParam(':address' ,$address); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':repairername' ,$repairername); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$stmt -> bindParam(':area' ,$area); |
|||
$stmt -> bindParam(':takecertificatedate' ,$elevator['takecertificatedate']); |
|||
$stmt -> bindParam(':licensedate' ,$elevator['useful_date']); |
|||
$result = $stmt -> execute(); |
|||
} |
|||
|
|||
//create schedule table |
|||
|
|||
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); |
|||
$comboArr = json_decode($comboNo->getComboNo(), true); |
|||
foreach($facilityno as $no){ |
|||
foreach($comboArr as $combo){ |
|||
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':contractno' ,$contractno); |
|||
$stmt -> bindParam(':facilityno' ,$no); |
|||
$stmt -> bindParam(':combono' ,$combo[0]); |
|||
$stmt -> bindParam(':repairerid' ,$repairerid); |
|||
$stmt -> bindParam(':repairername' ,$repairername); |
|||
$stmt -> bindParam(':duedate' ,$combo[1]); |
|||
$stmt -> bindParam(':creater' ,$creater); |
|||
$stmt -> bindParam(':create_at' ,$create_at); |
|||
$result = $stmt -> execute(); |
|||
} |
|||
} |
|||
// create contract_b_signed_back table |
|||
$contract_type = $mtype; |
|||
$company = $customer; |
|||
$customer_no = $vat; |
|||
$salesperson = $salesman; |
|||
$customer_phone = $phone; |
|||
$customer_email = $email; |
|||
$repairman = $mworker; |
|||
$cycle = $mcycle; |
|||
$contact_person = $partyA; |
|||
$contact_address = $partyAaddress; |
|||
$contact_phone = $partyAphone; |
|||
$contract_email = $partyAemail; |
|||
$elevators_number = $num; |
|||
$bonus = 1000; |
|||
$max_bonus = 2000; |
|||
|
|||
if(!empty($files)){ |
|||
$englisharr = range('a', 'z'); |
|||
$file = $_FILES['files']; |
|||
$file_name = $file['name']; |
|||
$file_type = $file['type']; |
|||
$tmp_name = $file['tmp_name']; |
|||
$file_size = $file['size']; |
|||
$error = $file['error']; |
|||
$newfiles = []; |
|||
foreach( $files as $file ){ |
|||
$i = 0; //新陣列的索引編號 |
|||
foreach( $file as $key => $val ){ |
|||
$newfiles[$i]['name'] = $files['name'][$key]; |
|||
$newfiles[$i]['type'] = $files['type'][$key]; |
|||
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
|||
$newfiles[$i]['error'] = $files['error'][$key]; |
|||
$newfiles[$i]['size'] = $files['size'][$key]; |
|||
$i++; |
|||
} //foreach 第2層 end |
|||
} |
|||
$max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) |
|||
$allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 |
|||
$path = '../images/contracts/'; |
|||
if (!file_exists($path)) { mkdir($path); } |
|||
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
|||
$datetime = (string)date('YmdHis'); |
|||
$files_id = 'b' . $datetime; // 保養=>b + 日期時間 |
|||
foreach( $newfiles as $key => $file ){ |
|||
$randNum = rand(1000,9999); |
|||
$randEnglish = $englisharr[rand(0,25)]; |
|||
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; |
|||
$msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); |
|||
if($msg==1){ |
|||
$msg = '檔案傳送成功!'; |
|||
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(':files_id' ,$files_id); |
|||
$stmt -> bindParam(':file_name' ,$file_name); |
|||
$stmt -> bindParam(':file_mime' ,$file['type']); |
|||
$stmt -> bindParam(':file_size' ,$file['size']); |
|||
$stmt -> bindParam(':created_at' ,$created_at); |
|||
$stmt -> bindParam(':created_by' ,$user_id); |
|||
$stmt ->execute(); |
|||
} |
|||
$msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
|||
$src_name = $path.$file['name']; |
|||
if( file_exists($src_name) ){ |
|||
//副檔名 |
|||
$extname = pathinfo($src_name, PATHINFO_EXTENSION); |
|||
//主檔名 |
|||
$basename = basename($src_name, '.'.$extname); |
|||
} |
|||
|
|||
} |
|||
}else{ |
|||
$files = null; |
|||
} |
|||
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) |
|||
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; |
|||
$stmt = $conn -> prepare($sql_str); |
|||
$stmt -> bindParam(":contract_no",$contractno); |
|||
$stmt -> bindParam(":contract_type",$contract_type); |
|||
$stmt -> bindParam(":company",$company); |
|||
$stmt -> bindParam(":customer_no",$customer_no); |
|||
$stmt -> bindParam(":salesperson",$salesperson); |
|||
$stmt -> bindParam(":contract_start_date",$contract_begin_date); |
|||
$stmt -> bindParam(":contract_end_date",$contract_end_date); |
|||
$stmt -> bindParam(":total_price",$total_price); |
|||
$stmt -> bindParam(":customer_phone",$customer_phone); |
|||
$stmt -> bindParam(":customer_email",$customer_email); |
|||
$stmt -> bindParam(":repairman",$repairman); |
|||
$stmt -> bindParam(":cycle",$cycle); |
|||
$stmt -> bindParam(":contact_person",$contact_person); |
|||
$stmt -> bindParam(":contact_address",$contact_address); |
|||
$stmt -> bindParam(":contact_phone",$contact_phone); |
|||
$stmt -> bindParam(":contact_email",$contact_email); |
|||
$stmt -> bindParam(":elevators_number",$elevators_number); |
|||
$stmt -> bindParam(":area",$area); |
|||
$stmt -> bindParam(":address",$address); |
|||
$stmt -> bindParam(":files_id",$files_id); |
|||
$stmt -> bindParam(":bonus",$bonus); |
|||
$stmt -> bindParam(":max_bonus",$max_bonus); |
|||
$stmt -> bindParam(":created_at", $created_at); |
|||
$stmt -> bindParam(":created_by",$user_id); |
|||
|
|||
$stmt -> execute(); |
|||
|
|||
header('Content-Type: application/json'); |
|||
$jsonData = json_encode($files); |
|||
|
|||
$conn->commit(); |
|||
}catch(PDOException $e){ |
|||
$conn->rollback(); |
|||
echo $e->getMessage(); |
|||
die('Error!:'.$e->getMessage()); |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
<?php |
|||
require_once("../conn.php"); |
|||
include_once("./getFacilityNo.php"); |
|||
include_once("./getComboNo.php"); |
|||
include_once("./upload_chk.php"); |
|||
ini_set('date.timezone', 'Asia/Taipei'); |
|||
//保養簽回 |
|||
if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'b') { |
|||
try { |
|||
$created_at = date('Y-m-d H:i:s'); |
|||
$contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; |
|||
$total_price = !empty($_POST['total_price']) ? $_POST['total_price'] : null; |
|||
$vat = !empty($_POST['vat']) ? $_POST['vat'] : null; |
|||
$mtype = !empty($_POST['mtype']) ? $_POST['mtype'] : null; |
|||
$opendoor = !empty($_POST['opendoor']) ? $_POST['opendoor'] : null; |
|||
$phone = !empty($_POST['phone']) ? $_POST['phone'] : null; |
|||
$email = !empty($_POST['email']) ? $_POST['email'] : null; |
|||
$mworker = !empty($_POST['mworker']) ? $_POST['mworker'] : null; |
|||
$mcycle = !empty($_POST['mcycle']) ? $_POST['mcycle'] : null; |
|||
$salesman = !empty($_POST['salesman']) ? $_POST['salesman'] : null; |
|||
$contract_begin_date = !empty($_POST['contract_begin_date']) ? $_POST['contract_begin_date'] : null; |
|||
$contract_end_date = !empty($_POST['contract_end_date']) ? $_POST['contract_end_date'] : null; |
|||
$address = !empty($_POST['address']) ? $_POST['address'] : null; |
|||
$area = !empty($_POST['area']) ? $_POST['area'] : null; |
|||
$customer = !empty($_POST['customer']) ? $_POST['customer'] : null; |
|||
$partyA = !empty($_POST['partyA']) ? $_POST['partyA'] : null; |
|||
$partyAaddress = !empty($_POST['partyAaddress']) ? $_POST['partyAaddress'] : null; |
|||
$partyAphone = !empty($_POST['partyAphone']) ? $_POST['partyAphone'] : null; |
|||
$partyAemail = !empty($_POST['partyAemail']) ? $_POST['partyAemail'] : null; |
|||
$user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; |
|||
$user_name = !empty($_POST['user_name']) ? $_POST['user_name'] : null; |
|||
$num = !empty($_POST['num']) ? $_POST['num'] : null; |
|||
$files = !empty($_FILES['files']) ? $_FILES['files'] : null; |
|||
$elevators = !empty($_POST['elevators']) ? json_decode($_POST['elevators'], true) : []; |
|||
// validate |
|||
$fail_arr = []; |
|||
if ($contractno === '') return $fail_arr[] = '合約號為必填'; |
|||
|
|||
if ($total_price == '') $fail_arr[] = '合約總價為必填'; |
|||
if ($vat == '') $fail_arr[] = '統一編號為必填'; |
|||
if ($mtype == '') $fail_arr[] = '維修型態為必填'; |
|||
if ($phone == '') $fail_arr[] = '客戶電話為必填'; |
|||
if ($email == '') $fail_arr[] = 'Email為必填'; |
|||
if ($mworker == '') $fail_arr[] = '保養員為必填'; |
|||
if ($mcycle == '') $fail_arr[] = '保養頻率為必填'; |
|||
if ($salesman == '') $fail_arr[] = '營業員為必填'; |
|||
if ($contract_begin_date == '') $fail_arr[] = '合約開始時間為必填'; |
|||
if ($contract_end_date == '') $fail_arr[] = '合約結束時間為必填'; |
|||
if ($address == '') $fail_arr[] = '地址為必填'; |
|||
if ($area == '') $fail_arr[] = '區域為必填'; |
|||
if ($customer == '') $fail_arr[] = '客戶為必填'; |
|||
if ($partyA == '') $fail_arr[] = '業務聯繫人為必填'; |
|||
if ($partyAaddress == '') $fail_arr[] = '業務聯繫人地址為必填'; |
|||
if ($partyAphone == '') $fail_arr[] = '業務聯繫人電話為必填'; |
|||
if ($partyAemail == '') $fail_arr[] = '業務聯繫人Email為必填'; |
|||
if ($num == '') $fail_arr[] = '電梯數量為必填'; |
|||
if (count($fail_arr) > 0) { |
|||
header("HTTP/1.1 422 Unprocessable Entity"); |
|||
echo json_encode($fail_arr); |
|||
exit(); |
|||
} |
|||
|
|||
//create account table |
|||
$accounttype = "A"; |
|||
$accountid = $vat; |
|||
$pwd = "123"; |
|||
$name = $partyA; |
|||
$tel = $phone ?? ''; |
|||
$repairerid = $mworker; |
|||
$creater = $user_id; |
|||
$create_at = date('Y-m-d H:i:s'); |
|||
|
|||
$conn->beginTransaction(); |
|||
|
|||
$sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accounttype', $accounttype); |
|||
$stmt->bindParam(':accountid', $accountid); |
|||
$stmt->bindParam(':pwd', $pwd); |
|||
$stmt->bindParam(':name', $name); |
|||
$stmt->bindParam(':tel', $tel); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':email', $email); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->execute(); |
|||
|
|||
//create contract table |
|||
|
|||
$contracttype = $mtype; |
|||
$company = $partyA; |
|||
$taxid = $vat; |
|||
$tel = $phone; |
|||
$promiser = $partyA; |
|||
$contractperson = $partyA; |
|||
|
|||
$contractaddress = $address; |
|||
$contracttel = $phone; |
|||
$contractemail = $email; |
|||
$contract_employee = $salesman; |
|||
$start_date = $contract_begin_date; |
|||
$end_date = $contract_end_date; |
|||
|
|||
$sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contracttype', $contracttype); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':company', $company); |
|||
$stmt->bindParam(':taxid', $taxid); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':tel', $tel); |
|||
$stmt->bindParam(':promiser', $promiser); |
|||
$stmt->bindParam(':contractperson', $contractperson); |
|||
$stmt->bindParam(':contractaddress', $contractaddress); |
|||
$stmt->bindParam(':contracttel', $contracttel); |
|||
$stmt->bindParam(':contractemail', $contractemail); |
|||
$stmt->bindParam(':contract_employee', $contract_employee); |
|||
$stmt->bindParam(':start_date', $start_date); |
|||
$stmt->bindParam(':end_date', $end_date); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->execute(); |
|||
|
|||
//create facility table |
|||
$createFacilityNo = new CreateFacilityNo(); |
|||
$dailyNecessities = [ |
|||
'MAE100' => 'X', |
|||
'MAM200' => 'W', |
|||
'MAH100' => 'H', |
|||
'MAQ100' => 'Z', |
|||
'MAF100' => 'F', |
|||
'MAZ100' => 'B', |
|||
]; |
|||
$facility_arr = []; |
|||
foreach ($elevators as $elevator) { |
|||
$facility_arr[] = $dailyNecessities[$elevator['spec']]; |
|||
} |
|||
echo json_encode($facility_arr); |
|||
$facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); |
|||
echo json_encode($facilityno); |
|||
echo '-------'; |
|||
$sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':accountid', $mworker); |
|||
$stmt->execute(); |
|||
$worker = $stmt->fetch(PDO::FETCH_ASSOC); |
|||
$customerid = $vat; |
|||
$define = "B"; |
|||
$repairtype = $mtype; |
|||
$repairerid = $mworker; |
|||
$repairername = $worker['name']; |
|||
foreach ($elevators as $idx => $elevator) { |
|||
$sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) |
|||
VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':define', $define); |
|||
$stmt->bindParam(':facilityno', $facilityno[$idx]); |
|||
$stmt->bindParam(':latitude', $elevator['latitude']); |
|||
$stmt->bindParam(':longitude', $elevator['longitude']); |
|||
$stmt->bindParam(':customerid', $customerid); |
|||
$stmt->bindParam(':weight', $elevator['weight']); |
|||
$stmt->bindParam(':numberofpassenger', $elevator['persons']); |
|||
$stmt->bindParam(':numberofstop', $elevator['stop']); |
|||
$stmt->bindParam(':numberoffloor', $elevator['floors']); |
|||
$stmt->bindParam(':opentype', $elevator['opendoor']); |
|||
$stmt->bindParam(':speed', $elevator['speed']); |
|||
$stmt->bindParam(':repairtype', $repairtype); |
|||
$stmt->bindParam(':maintainance', $elevator['maintainance']); |
|||
$stmt->bindParam(':facility_kind', $elevator['spec']); |
|||
$stmt->bindParam(':address', $address); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':repairername', $repairername); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$stmt->bindParam(':area', $area); |
|||
$stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); |
|||
$stmt->bindParam(':licensedate', $elevator['useful_date']); |
|||
$result = $stmt->execute(); |
|||
} |
|||
|
|||
//create schedule table |
|||
|
|||
$comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); |
|||
$comboArr = json_decode($comboNo->getComboNo(), true); |
|||
foreach ($facilityno as $no) { |
|||
foreach ($comboArr as $combo) { |
|||
$sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':contractno', $contractno); |
|||
$stmt->bindParam(':facilityno', $no); |
|||
$stmt->bindParam(':combono', $combo[0]); |
|||
$stmt->bindParam(':repairerid', $repairerid); |
|||
$stmt->bindParam(':repairername', $repairername); |
|||
$stmt->bindParam(':duedate', $combo[1]); |
|||
$stmt->bindParam(':creater', $creater); |
|||
$stmt->bindParam(':create_at', $create_at); |
|||
$result = $stmt->execute(); |
|||
} |
|||
} |
|||
// create contract_b_signed_back table |
|||
$contract_type = $mtype; |
|||
$company = $customer; |
|||
$customer_no = $vat; |
|||
$salesperson = $salesman; |
|||
$customer_phone = $phone; |
|||
$customer_email = $email; |
|||
$repairman = $mworker; |
|||
$cycle = $mcycle; |
|||
$contact_person = $partyA; |
|||
$contact_address = $partyAaddress; |
|||
$contact_phone = $partyAphone; |
|||
$contract_email = $partyAemail; |
|||
$elevators_number = $num; |
|||
$bonus = 1000; |
|||
$max_bonus = 2000; |
|||
|
|||
if (!empty($files)) { |
|||
$englisharr = range('a', 'z'); |
|||
$file = $_FILES['files']; |
|||
$file_name = $file['name']; |
|||
$file_type = $file['type']; |
|||
$tmp_name = $file['tmp_name']; |
|||
$file_size = $file['size']; |
|||
$error = $file['error']; |
|||
$newfiles = []; |
|||
foreach ($files as $file) { |
|||
$i = 0; //新陣列的索引編號 |
|||
foreach ($file as $key => $val) { |
|||
$newfiles[$i]['name'] = $files['name'][$key]; |
|||
$newfiles[$i]['type'] = $files['type'][$key]; |
|||
$newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; |
|||
$newfiles[$i]['error'] = $files['error'][$key]; |
|||
$newfiles[$i]['size'] = $files['size'][$key]; |
|||
$i++; |
|||
} //foreach 第2層 end |
|||
} |
|||
$max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) |
|||
$allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 |
|||
$path = '../images/contracts/'; |
|||
if (!file_exists($path)) { |
|||
mkdir($path); |
|||
} |
|||
$msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 |
|||
$datetime = (string)date('YmdHis'); |
|||
$files_id = 'b' . $datetime; // 保養=>b + 日期時間 |
|||
foreach ($newfiles as $key => $file) { |
|||
$randNum = rand(1000, 9999); |
|||
$randEnglish = $englisharr[rand(0, 25)]; |
|||
$file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; |
|||
$msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); |
|||
if ($msg == 1) { |
|||
$msg = '檔案傳送成功!'; |
|||
$sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(':files_id', $files_id); |
|||
$stmt->bindParam(':file_name', $file_name); |
|||
$stmt->bindParam(':file_mime', $file['type']); |
|||
$stmt->bindParam(':file_size', $file['size']); |
|||
$stmt->bindParam(':created_at', $created_at); |
|||
$stmt->bindParam(':created_by', $user_id); |
|||
$stmt->execute(); |
|||
} |
|||
$msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '<br/>'; |
|||
$src_name = $path . $file['name']; |
|||
if (file_exists($src_name)) { |
|||
//副檔名 |
|||
$extname = pathinfo($src_name, PATHINFO_EXTENSION); |
|||
//主檔名 |
|||
$basename = basename($src_name, '.' . $extname); |
|||
} |
|||
} |
|||
} else { |
|||
$files = null; |
|||
} |
|||
$sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) |
|||
VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; |
|||
$stmt = $conn->prepare($sql_str); |
|||
$stmt->bindParam(":contract_no", $contractno); |
|||
$stmt->bindParam(":contract_type", $contract_type); |
|||
$stmt->bindParam(":company", $company); |
|||
$stmt->bindParam(":customer_no", $customer_no); |
|||
$stmt->bindParam(":salesperson", $salesperson); |
|||
$stmt->bindParam(":contract_start_date", $contract_begin_date); |
|||
$stmt->bindParam(":contract_end_date", $contract_end_date); |
|||
$stmt->bindParam(":total_price", $total_price); |
|||
$stmt->bindParam(":customer_phone", $customer_phone); |
|||
$stmt->bindParam(":customer_email", $customer_email); |
|||
$stmt->bindParam(":repairman", $repairman); |
|||
$stmt->bindParam(":cycle", $cycle); |
|||
$stmt->bindParam(":contact_person", $contact_person); |
|||
$stmt->bindParam(":contact_address", $contact_address); |
|||
$stmt->bindParam(":contact_phone", $contact_phone); |
|||
$stmt->bindParam(":contact_email", $contact_email); |
|||
$stmt->bindParam(":elevators_number", $elevators_number); |
|||
$stmt->bindParam(":area", $area); |
|||
$stmt->bindParam(":address", $address); |
|||
$stmt->bindParam(":files_id", $files_id); |
|||
$stmt->bindParam(":bonus", $bonus); |
|||
$stmt->bindParam(":max_bonus", $max_bonus); |
|||
$stmt->bindParam(":created_at", $created_at); |
|||
$stmt->bindParam(":created_by", $user_id); |
|||
|
|||
$stmt->execute(); |
|||
|
|||
header('Content-Type: application/json'); |
|||
$jsonData = json_encode($files); |
|||
|
|||
$conn->commit(); |
|||
} catch (PDOException $e) { |
|||
$conn->rollback(); |
|||
http_response_code(404); |
|||
echo $e->getMessage(); |
|||
die('Error!:' . $e->getMessage()); |
|||
} |
|||
} |
|||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,172 +1,180 @@ |
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
#錶 |
|||
$table = 'hope_contract_customer'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'vol_no' => "卷號", |
|||
'customer_no' => "客戶編號", |
|||
'customer' => "客戶名稱", |
|||
'manager' => "負責人", |
|||
'source' => "客戶來源", |
|||
'linkman' => "聯係人", |
|||
'lm_tel' => "手機", |
|||
'salesman' => "營業員", |
|||
'num' => "数量", |
|||
'pre_order_date' => "預定成交日", |
|||
'status' => "有望客戶狀態", |
|||
'next_visit_date' => "下次拜訪時間", |
|||
'brand' => "廠牌", |
|||
'quote_date' => "報價日期", |
|||
'created_at' => "建立時間", |
|||
|
|||
]; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["501"]; |
|||
$sql = "select department_id from account where accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; |
|||
$where = " and vol_no like '$vol_no'"; |
|||
$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; |
|||
$where .= " and salesman like '$salesman'"; |
|||
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; |
|||
$where .= " and linkman like '$lm_name'"; |
|||
$sql_cmd = sql_myself($user_id, "salesman"); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149") $sql_cmd = ""; // M0060:Max,鄭伊岑 |
|||
if (!empty($sql_cmd)) $where .= " and ".str_replace("where", "", $sql_cmd); |
|||
|
|||
$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source, |
|||
linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, |
|||
f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
#echo $sql; |
|||
$data = mysqli_query($link, $sql); |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout:fixed; |
|||
/*width: 100%;*/ |
|||
display:inline-block; |
|||
} |
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
.pagination { |
|||
margin: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
$('#table_index2').DataTable({ |
|||
order: [[14, 'desc']] |
|||
}); |
|||
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋"; |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>有望客戶(契約)資料維護</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>卷號</th> |
|||
<td><input type="text" class='form-control' name='vol_no'></td> |
|||
<th>營業員</th> |
|||
<td><input type="text" class='form-control' name='salesman'></td> |
|||
<th>下單地區</th> |
|||
<td><input type="text" class='form-control' name='order_province'></td> |
|||
<th>聯係人姓名</th> |
|||
<td><input type="text" class='form-control' name='lm_name'></td> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>'> |
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button> |
|||
<a href="crmm06-edit.php?<?= $token_link ?>" class="btn btn-info btn-sm">新增</a> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<table id="table_index2" class="table table-striped table-bordered"> |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<th>$val</th>"; |
|||
} |
|||
echo "<th>編輯</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<td>" . (!empty($row[$key]) ? $row[$key] : '') . "</td>"; |
|||
} |
|||
?> |
|||
<td> |
|||
<p> |
|||
<a href="crmm05-edit.php?function_name=customer&<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
|
|||
<a href="../cont/apply_form.php?<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
轉價審 |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
<?php |
|||
require_once "../header.php"; |
|||
// 載入db.php來連結資料庫 |
|||
|
|||
#錶 |
|||
$table = 'hope_contract_customer'; |
|||
#可編輯的列 |
|||
$editableColumn = [ |
|||
'vol_no' => "卷號", |
|||
'customer_no' => "客戶編號", |
|||
'customer' => "客戶名稱", |
|||
'manager' => "負責人", |
|||
'source' => "客戶來源", |
|||
'linkman' => "聯係人", |
|||
'lm_tel' => "手機", |
|||
'salesman' => "營業員", |
|||
'num' => "数量", |
|||
'pre_order_date' => "預定成交日", |
|||
'status' => "有望客戶狀態", |
|||
'next_visit_date' => "下次拜訪時間", |
|||
'brand' => "廠牌", |
|||
'quote_date' => "報價日期", |
|||
'created_at' => "建立時間", |
|||
|
|||
]; |
|||
|
|||
// 可瀏覽全部資料的部門 |
|||
$depart_arr = ["501"]; |
|||
$sql = "SELECT department_id FROM account WHERE accountid = '$user_id'"; |
|||
$res = mysqli_query($link, $sql); |
|||
$row = mysqli_fetch_row($res); |
|||
$user_department_id = $row[0]; |
|||
mysqli_free_result($res); |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; |
|||
$where = " and vol_no like '$vol_no'"; |
|||
$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; |
|||
$where .= " and salesman like '$salesman'"; |
|||
$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; |
|||
$where .= " and linkman like '$lm_name'"; |
|||
$sql_cmd = sql_myself($user_id, "salesman"); |
|||
if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149") $sql_cmd = ""; // M0060:Max,鄭伊岑 |
|||
if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd); |
|||
|
|||
$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source, |
|||
linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, |
|||
f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , |
|||
date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; |
|||
|
|||
$data = mysqli_query($link, $sql); |
|||
|
|||
echo '<pre>'; |
|||
print_r($data); |
|||
echo '</pre>'; |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout: fixed; |
|||
/*width: 100%;*/ |
|||
display: inline-block; |
|||
} |
|||
|
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
|
|||
.pagination { |
|||
margin: 0; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function() { |
|||
$('#table_index2').DataTable({ |
|||
order: [ |
|||
[14, 'desc'] |
|||
] |
|||
}); |
|||
document.querySelector("#table_index2_filter > label > input").placeholder = "快速搜尋"; |
|||
}); |
|||
</script> |
|||
<?php |
|||
|
|||
if ($data) : |
|||
|
|||
if ($_SERVER["REQUEST_METHOD"] == "POST") { |
|||
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) { |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:repair-index.php"); |
|||
} |
|||
} |
|||
|
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
|
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<form method='get' action='#'> |
|||
<table class='table query-table table-striped table-bordered display compact' style='width:98%;text-align:center;margin:0 auto'> |
|||
<thead> |
|||
<tr> |
|||
<td colspan="8"> |
|||
<h3 style='text-align:center'>有望客戶(契約)資料維護</h3> |
|||
</td> |
|||
</tr> |
|||
|
|||
</thead> |
|||
<tbody> |
|||
<tr> |
|||
<th style='width:50px'>卷號</th> |
|||
<td><input type="text" class='form-control' name='vol_no'></td> |
|||
<th>營業員</th> |
|||
<td><input type="text" class='form-control' name='salesman'></td> |
|||
<th>下單地區</th> |
|||
<td><input type="text" class='form-control' name='order_province'></td> |
|||
<th>聯係人姓名</th> |
|||
<td><input type="text" class='form-control' name='lm_name'></td> |
|||
<input type="hidden" name="token" value='<?= $_GET['token'] ?>'> |
|||
</tr> |
|||
</tbody> |
|||
<tfoot> |
|||
<tr> |
|||
<td colspan="8" style='text-align:center'> |
|||
<button type="submit" style='text-align:center; margin:0 auto' class="btn btn-info btn-sm">查詢</button> |
|||
<a href="crmm06-edit.php?<?= $token_link ?>" class="btn btn-info btn-sm">新增</a> |
|||
</td> |
|||
</tr> |
|||
</tfoot> |
|||
</table> |
|||
<table id="table_index" class="table table-striped table-bordered"> |
|||
<thead> |
|||
<?php |
|||
echo "<tr>"; |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<th>$val</th>"; |
|||
} |
|||
echo "<th>編輯</th>"; |
|||
// echo "<th>刪除</th>"; |
|||
echo "</tr>"; |
|||
?> |
|||
</thead> |
|||
<tbody> |
|||
<?php foreach ($data as $row) : ?> |
|||
<tr> |
|||
<?php |
|||
foreach ($editableColumn as $key => $val) { |
|||
echo "<td>" . (!empty($row[$key]) ? $row[$key] : '') . "</td>"; |
|||
} |
|||
?> |
|||
<td> |
|||
<p> |
|||
<a href="crmm05-edit.php?function_name=customer&<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
|
|||
<a href="../cont/apply_form.php?<?= $token_link ?>&vol_no=<?php echo $row['vol_no']; ?>" class="btn btn-info btn-sm"> |
|||
轉價審 |
|||
</a> |
|||
</p> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
|
|||
<?php |
|||
|
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代錶結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
|
|||
?> |
File diff suppressed because it is too large
@ -1,352 +1,367 @@ |
|||
<?php |
|||
include "../header.php"; |
|||
|
|||
// 員工編號對應姓名表 |
|||
$accountname_arr = accountid2name(); |
|||
|
|||
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
// M0024許伃廷,M0107許紓晴,M0012李盈瑩權限全開 |
|||
if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012") { |
|||
$sql_cmd = "where create_at >= '2023-01-01 00:00:00'"; |
|||
} |
|||
if ($user_id == "M0008") { |
|||
$sql_cmd = "where creater in (select accountid from account where department_id like '5%')"; |
|||
} |
|||
if ($user_id == "M0060") { |
|||
$sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))"; |
|||
} |
|||
if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id"; |
|||
else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; |
|||
$data = mysqli_query($link,$sql); |
|||
|
|||
$para = "function_name=pricereview_renovate&".$token_link; |
|||
$sign_st = ""; |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout:fixed; |
|||
width: 100%; |
|||
display:inline-block; |
|||
} |
|||
#table_index2_filter{ |
|||
float:right; |
|||
} |
|||
#table_index2_paginate{ |
|||
float:right; |
|||
} |
|||
div.dataTables_scrollHead table.dataTable { |
|||
margin-bottom: 0 !important; |
|||
border-bottom-width: 0; |
|||
} |
|||
div.dataTables_scrollBody table.dataTable { |
|||
border-top-width: 0; |
|||
} |
|||
/* |
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
*/ |
|||
img { |
|||
width:125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width:125px; |
|||
} |
|||
|
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
div a:hover { |
|||
text-decoration:none; |
|||
} |
|||
.btn-sm { |
|||
font-size:14px; |
|||
margin: 2px 0; |
|||
line-height: 90%; |
|||
} |
|||
.glyphicon-ok, .glyphicon-ban-circle { |
|||
font-size:130%; |
|||
} |
|||
.btn-secondary { |
|||
color: #fff; |
|||
background-color: #6c757d; |
|||
border-color: #6c757d; |
|||
} |
|||
.btn-secondary:hover { |
|||
color: #fff; |
|||
background-color: #5a6268; |
|||
border-color: #545b62; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function () { |
|||
$('#table_index2').DataTable({ |
|||
"scrollX": true, |
|||
"pageLength": 50 |
|||
}); |
|||
/* |
|||
var api = $('#table_index').dataTable().api(); |
|||
//var order = api.order(); |
|||
//console.log(order); |
|||
api |
|||
.order([0, "desc"]) |
|||
.draw(); |
|||
*/ |
|||
}); |
|||
</script> |
|||
<!--改由有望客戶入口 |
|||
<p> |
|||
<a href="pricereview-create.php?vol_no=D220001&function_name=pricereview&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
--> |
|||
<?php |
|||
if ($data): |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:pricereview-index.php"); |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>卷號</th> |
|||
<th>營業員</th> |
|||
<th>客戶名稱</th> |
|||
<th>案件名稱</th> |
|||
<th>牌價總額</th> |
|||
<th>售價總額</th> |
|||
<th>價率</th> |
|||
<th>預定成交日</th> |
|||
<th>預定交期</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<th>功能</th> |
|||
<th>區經理</th> |
|||
<th>工務副總</th> |
|||
<th>總經理</th> |
|||
<th>狀態</th> |
|||
<th>合約書下載</th> |
|||
<!--<th>修改</th>--> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach($data as $data) : |
|||
$sign1 = $sign2 = $sign3 = $sign4 = ""; |
|||
$oneself = ($data["creater"]==$user_id) ? 1 : 0; // 是否為營業員本人 |
|||
// 簽核狀況 |
|||
$db_query = "select sign1, sign2, sign3, sign4 from pricereview_sign where mid = '".$data["id"]."'"; |
|||
$res_s = mysqli_query($link ,$db_query); |
|||
if ($row_s = mysqli_fetch_row($res_s)) { |
|||
list($sign1, $sign2, $sign3, $sign4) = $row_s; |
|||
// 下一位簽核人員:$sign_nt, 目前簽核進度:$sign_st |
|||
if (strlen($sign1) == 7) { |
|||
$sign_st = 1; |
|||
$sign_nt = str_replace(",,", "", $sign1); |
|||
} elseif (strlen($sign2) == 7) { |
|||
$sign_st = 2; |
|||
$sign_nt = str_replace(",,", "", $sign2); |
|||
} elseif (strlen($sign3) == 7) { |
|||
$sign_st = 3; |
|||
$sign_nt = str_replace(",,", "", $sign3); |
|||
} elseif (strlen($sign4) == 7) { |
|||
$sign_st = 4; |
|||
$sign_nt = str_replace(",,", "", $sign4); |
|||
} else { |
|||
$sign_st = 99; // 已審完 |
|||
$sign_nt = ""; |
|||
} |
|||
} |
|||
mysqli_free_result($res_s); |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['company']; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['price_lowest']); ?></td> |
|||
<td><?php echo number_format($data['price_total']); ?></td> |
|||
<td><?php echo $data['price_rate']; ?>%</td> |
|||
<td><?php echo $data['predeal_date']; ?></td> |
|||
<td><?php echo $data['facilitok_date']; ?></td> |
|||
<td><?php echo $accountname_arr[$data['creater']]; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<?php |
|||
//if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調 |
|||
if ($oneself) { |
|||
if ($data["status"] == "Y1") { |
|||
?> |
|||
<a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a> |
|||
<a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a> |
|||
<?php |
|||
} elseif ($data["status"] == "YS") { |
|||
?> |
|||
<a href="specsurvey_renovate-create.php?mid=<?=$data['id'];?>&function_name=specsurvey_renovate&token=<?=$token;?>" class="btn btn-danger btn-sm">填規調</a> |
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
<a href="pricereview_renovate-check.php?id=<?php echo $data['id']."&".$para; ?>" class="btn btn-warning btn-sm">檢視</a> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign1)) list($uperson, $ustatus, $udtte) = explode(",", $sign1); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>".$accountname_arr[$uperson]."<br>".$udtte; |
|||
} else { |
|||
if ($sign_st==1 && $sign_nt==$user_id && $data["status"]=="YS") { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-primary btn-sm\">".$str."</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
/* |
|||
if ($sign_st==1 && $sign_nt==$user_id) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
} else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 |
|||
list($uperson, $ustatus, $udtte) = explode(",", $sign1); |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
else $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
$str .= "<br>".$accountname_arr[$uperson]."<br>".$udtte; |
|||
} else $str = "--"; |
|||
*/ |
|||
|
|||
/* |
|||
if ($data["checker_1_result"] == "Y") { |
|||
$str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
} elseif ($data["checker_1_result"] == "N") { |
|||
$str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
} else { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
} |
|||
if (!$oneself) { |
|||
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"]; |
|||
} else { |
|||
if ($data["checker_1_result"]) { |
|||
$str = "<a class=\"btn btn-lg\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"]; |
|||
} |
|||
else $str = "--"; |
|||
}*/ |
|||
//echo $str; |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign3)) list($uperson, $ustatus, $udtte) = explode(",", $sign3); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>".$accountname_arr[$uperson]."<br>".$udtte; |
|||
} else { |
|||
if (($data["status"] == "YS") && ($sign_st == 3) && ($sign_nt == $user_id)) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-primary btn-sm\">".$str."</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
/* |
|||
$str = ""; |
|||
if ($sign_st==3 && $sign_nt==$user_id) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
} else $str = "--"; |
|||
*/ |
|||
|
|||
/* |
|||
if ($data["checker_3_result"] == "Y") { |
|||
$str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
} elseif ($data["checker_3_result"] == "N") { |
|||
$str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
} else { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
} |
|||
if (!$oneself) { |
|||
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"]; |
|||
} else { |
|||
if ($data["checker_3_result"]) { |
|||
$str = "<a class=\"btn btn-lg\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"]; |
|||
} |
|||
else $str = "--"; |
|||
} |
|||
*/ |
|||
//echo $str; |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign4)) list($uperson, $ustatus, $udtte) = explode(",", $sign4); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>".$accountname_arr[$uperson]."<br>".$udtte; |
|||
} else { |
|||
if (($data["status"] == "YS") && ($sign_st == 4) && ($sign_nt == $user_id)) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=4&id=".$data["id"]."&".$para."\" class=\"btn btn-primary btn-sm\">".$str."</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
?> |
|||
</td> |
|||
<td><?php echo $status_arr[$data["status"]]; ?></td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="pricereview-edit.php?id=<?php echo $data['id']."&".$para; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<td> |
|||
<?php if($data['status'] === 'YY'){ ?> |
|||
<a href="../contract/contract-renovate-download.php?id=<?php echo $data['id'] . '&' . $para?>">合約書申請</a> |
|||
<?php }else{ echo "-"; } ?> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else: |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
<?php |
|||
include "../header.php"; |
|||
|
|||
// 員工編號對應姓名表 |
|||
$accountname_arr = accountid2name(); |
|||
|
|||
$status_arr = ["Y1" => "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; |
|||
|
|||
// 設置一個空陣列來放資料 |
|||
$data = array(); |
|||
// sql語法存在變數中 |
|||
$sql_cmd = sql_myself($user_id); |
|||
// M0024許伃廷,M0107許紓晴,M0012李盈瑩權限全開 |
|||
if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012" || $user_id == "M0025") { |
|||
$sql_cmd = "where create_at >= '2023-01-01 00:00:00'"; |
|||
} |
|||
if ($user_id == "M0008") { |
|||
$sql_cmd = "where creater in (select accountid from account where department_id like '5%')"; |
|||
} |
|||
if ($user_id == "M0060") { |
|||
$sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))"; |
|||
} |
|||
if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id"; |
|||
else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; |
|||
|
|||
|
|||
$data = mysqli_query($link, $sql); |
|||
|
|||
$para = "function_name=pricereview_renovate&" . $token_link; |
|||
$sign_st = ""; |
|||
?> |
|||
<style> |
|||
#table_index2 { |
|||
table-layout: fixed; |
|||
width: 100%; |
|||
display: inline-block; |
|||
} |
|||
|
|||
#table_index2_filter { |
|||
float: right; |
|||
} |
|||
|
|||
#table_index2_paginate { |
|||
float: right; |
|||
} |
|||
|
|||
div.dataTables_scrollHead table.dataTable { |
|||
margin-bottom: 0 !important; |
|||
border-bottom-width: 0; |
|||
} |
|||
|
|||
div.dataTables_scrollBody table.dataTable { |
|||
border-top-width: 0; |
|||
} |
|||
|
|||
/* |
|||
.col-sm-12 { |
|||
width: auto; |
|||
} |
|||
*/ |
|||
img { |
|||
width: 125px; |
|||
} |
|||
|
|||
.width_style_1 { |
|||
width: 125px; |
|||
} |
|||
|
|||
label { |
|||
display: inline-flex; |
|||
margin-bottom: .5rem; |
|||
margin-top: .5rem; |
|||
|
|||
} |
|||
|
|||
div a:hover { |
|||
text-decoration: none; |
|||
} |
|||
|
|||
.btn-sm { |
|||
font-size: 14px; |
|||
margin: 2px 0; |
|||
line-height: 90%; |
|||
} |
|||
|
|||
.glyphicon-ok, |
|||
.glyphicon-ban-circle { |
|||
font-size: 130%; |
|||
} |
|||
|
|||
.btn-secondary { |
|||
color: #fff; |
|||
background-color: #6c757d; |
|||
border-color: #6c757d; |
|||
} |
|||
|
|||
.btn-secondary:hover { |
|||
color: #fff; |
|||
background-color: #5a6268; |
|||
border-color: #545b62; |
|||
} |
|||
</style> |
|||
<script> |
|||
$(function() { |
|||
$('#table_index2').DataTable({ |
|||
"scrollX": true, |
|||
"pageLength": 50 |
|||
}); |
|||
/* |
|||
var api = $('#table_index').dataTable().api(); |
|||
//var order = api.order(); |
|||
//console.log(order); |
|||
api |
|||
.order([0, "desc"]) |
|||
.draw(); |
|||
*/ |
|||
}); |
|||
</script> |
|||
<!--改由有望客戶入口 |
|||
<p> |
|||
<a href="pricereview-create.php?vol_no=D220001&function_name=pricereview&<?php echo $token_link; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-plus"></span> |
|||
</a> |
|||
</p> |
|||
--> |
|||
<?php |
|||
if ($data) : |
|||
/* |
|||
if($_SERVER["REQUEST_METHOD"] == "POST"){ |
|||
if(empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])){ |
|||
echo "<p class='error'>Please fill up the required field!</p>"; |
|||
} else { |
|||
header("Location:pricereview-index.php"); |
|||
} |
|||
} |
|||
*/ |
|||
?> |
|||
<link rel="stylesheet" href="common.css"> |
|||
<div style="overflow-x:auto; white-space:nowrap;"> |
|||
<table id="table_index2" class="table table-striped table-bordered" style="width:100%"> |
|||
<thead> |
|||
<tr> |
|||
<th>項次</th> |
|||
<th>卷號</th> |
|||
<th>營業員</th> |
|||
<th>客戶名稱</th> |
|||
<th>案件名稱</th> |
|||
<th>牌價總額</th> |
|||
<th>售價總額</th> |
|||
<th>價率</th> |
|||
<th>預定成交日</th> |
|||
<th>預定交期</th> |
|||
<th>建檔人</th> |
|||
<th>建檔時間</th> |
|||
<th>功能</th> |
|||
<th>區經理</th> |
|||
<th>工務副總</th> |
|||
<th>總經理</th> |
|||
<th>狀態</th> |
|||
<th>合約書下載</th> |
|||
<!--<th>修改</th>--> |
|||
</tr> |
|||
</thead> |
|||
<tbody> |
|||
<?php |
|||
foreach ($data as $data) : |
|||
$sign1 = $sign2 = $sign3 = $sign4 = ""; |
|||
$oneself = ($data["creater"] == $user_id) ? 1 : 0; // 是否為營業員本人 |
|||
// 簽核狀況 |
|||
$db_query = "select sign1, sign2, sign3, sign4 from pricereview_sign where mid = '" . $data["id"] . "'"; |
|||
$res_s = mysqli_query($link, $db_query); |
|||
if ($row_s = mysqli_fetch_row($res_s)) { |
|||
list($sign1, $sign2, $sign3, $sign4) = $row_s; |
|||
// 下一位簽核人員:$sign_nt, 目前簽核進度:$sign_st |
|||
if (strlen($sign1) == 7) { |
|||
$sign_st = 1; |
|||
$sign_nt = str_replace(",,", "", $sign1); |
|||
} elseif (strlen($sign2) == 7) { |
|||
$sign_st = 2; |
|||
$sign_nt = str_replace(",,", "", $sign2); |
|||
} elseif (strlen($sign3) == 7) { |
|||
$sign_st = 3; |
|||
$sign_nt = str_replace(",,", "", $sign3); |
|||
} elseif (strlen($sign4) == 7) { |
|||
$sign_st = 4; |
|||
$sign_nt = str_replace(",,", "", $sign4); |
|||
} else { |
|||
$sign_st = 99; // 已審完 |
|||
$sign_nt = ""; |
|||
} |
|||
} |
|||
mysqli_free_result($res_s); |
|||
?> |
|||
<tr> |
|||
<td><?php echo $data['id']; ?></td> |
|||
<td><?php echo $data['contractno']; ?></td> |
|||
<td><?php echo $data['person']; ?></td> |
|||
<td><?php echo $data['company']; ?></td> |
|||
<td><?php echo $data['case_name']; ?></td> |
|||
<td><?php echo number_format($data['price_lowest']); ?></td> |
|||
<td><?php echo number_format($data['price_total']); ?></td> |
|||
<td><?php echo $data['price_rate']; ?>%</td> |
|||
<td><?php echo $data['predeal_date']; ?></td> |
|||
<td><?php echo $data['facilitok_date']; ?></td> |
|||
<td><?php echo $accountname_arr[$data['creater']]; ?></td> |
|||
<td><?php echo $data['create_at']; ?></td> |
|||
<td> |
|||
<?php |
|||
//if ($oneself && !($data["status"] == "YY" || $data["status"] == "YN")) { // 自己可以進行規調 |
|||
if ($oneself) { |
|||
if ($data["status"] == "Y1") { |
|||
?> |
|||
<a href="pricereview_renovate-edit.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-primary btn-sm">修改</a> |
|||
<a href="pricereview_renovate-delete.php?id=<?php echo $data['id']; ?>&<?php echo $token_link; ?>" class="btn btn-secondary btn-sm" onClick="return confirm('Are you sure you want to delete?')">刪除</a> |
|||
<?php |
|||
} elseif ($data["status"] == "YS") { |
|||
?> |
|||
<a href="specsurvey_renovate-create.php?mid=<?= $data['id']; ?>&function_name=specsurvey_renovate&token=<?= $token; ?>" class="btn btn-danger btn-sm">填規調</a> |
|||
<?php |
|||
} |
|||
} |
|||
?> |
|||
<a href="pricereview_renovate-check.php?id=<?php echo $data['id'] . "&" . $para; ?>" class="btn btn-warning btn-sm">檢視</a> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign1)) list($uperson, $ustatus, $udtte) = explode(",", $sign1); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte; |
|||
} else { |
|||
if ($sign_st == 1 && $sign_nt == $user_id && $data["status"] == "YS") { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=1&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
/* |
|||
if ($sign_st==1 && $sign_nt==$user_id) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
} else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 |
|||
list($uperson, $ustatus, $udtte) = explode(",", $sign1); |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
else $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
$str .= "<br>".$accountname_arr[$uperson]."<br>".$udtte; |
|||
} else $str = "--"; |
|||
*/ |
|||
|
|||
/* |
|||
if ($data["checker_1_result"] == "Y") { |
|||
$str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
} elseif ($data["checker_1_result"] == "N") { |
|||
$str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
} else { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
} |
|||
if (!$oneself) { |
|||
$str = "<a href=\"pricereview-check.php?st=1&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"]; |
|||
} else { |
|||
if ($data["checker_1_result"]) { |
|||
$str = "<a class=\"btn btn-lg\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_1"]."<br>".$data["checker_1_dt"]; |
|||
} |
|||
else $str = "--"; |
|||
}*/ |
|||
//echo $str; |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign3)) list($uperson, $ustatus, $udtte) = explode(",", $sign3); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte; |
|||
} else { |
|||
if (($data["status"] == "YS") && ($sign_st == 3) && ($sign_nt == $user_id)) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=3&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
/* |
|||
$str = ""; |
|||
if ($sign_st==3 && $sign_nt==$user_id) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
} else $str = "--"; |
|||
*/ |
|||
|
|||
/* |
|||
if ($data["checker_3_result"] == "Y") { |
|||
$str = "<span class=\"glyphicon glyphicon-ok\" title=\"通過\"></span>"; |
|||
} elseif ($data["checker_3_result"] == "N") { |
|||
$str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"拒絕\"></span>"; |
|||
} else { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
} |
|||
if (!$oneself) { |
|||
$str = "<a href=\"pricereview-check.php?st=3&id=".$data["id"]."&".$para."\" class=\"btn btn-info btn-sm\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"]; |
|||
} else { |
|||
if ($data["checker_3_result"]) { |
|||
$str = "<a class=\"btn btn-lg\">".$str."</a>"; |
|||
$str .= "<br>".$data["checker_3"]."<br>".$data["checker_3_dt"]; |
|||
} |
|||
else $str = "--"; |
|||
} |
|||
*/ |
|||
//echo $str; |
|||
?> |
|||
</td> |
|||
<td> |
|||
<?php |
|||
$str = $uperson = $ustatus = $udtte = ""; |
|||
if (!empty($sign4)) list($uperson, $ustatus, $udtte) = explode(",", $sign4); |
|||
if ($ustatus) { |
|||
if ($ustatus == "Y") $str = "<span class=\"glyphicon glyphicon-ok\" title=\"同意\"></span>"; |
|||
elseif ($ustatus == "N") $str = "<span class=\"glyphicon glyphicon-ban-circle\" title=\"不同意\"></span>"; |
|||
$str .= "<br>" . $accountname_arr[$uperson] . "<br>" . $udtte; |
|||
} else { |
|||
if (($data["status"] == "YS") && ($sign_st == 4) && ($sign_nt == $user_id)) { |
|||
$str = "<span class=\"glyphicon glyphicon-user\"></span>"; |
|||
$str = "待簽核"; |
|||
$str = "<a href=\"pricereview_renovate-check.php?st=4&id=" . $data["id"] . "&" . $para . "\" class=\"btn btn-primary btn-sm\">" . $str . "</a>"; |
|||
} else $str = "--"; |
|||
} |
|||
echo $str; |
|||
?> |
|||
</td> |
|||
<td><?php echo $status_arr[$data["status"]]; ?></td> |
|||
<!--<td> |
|||
<p> |
|||
<a href="pricereview-edit.php?id=<?php echo $data['id'] . "&" . $para; ?>" class="btn btn-info btn-sm"> |
|||
<span class="glyphicon glyphicon-pencil"></span> |
|||
</a> |
|||
</p> |
|||
</td>--> |
|||
<td> |
|||
<?php if ($data['status'] === 'YY') { ?> |
|||
<a href="../contract/contract-renovate-download.php?id=<?php echo $data['id'] . '&' . $para ?>">合約書申請</a> |
|||
<?php } else { |
|||
echo "-"; |
|||
} ?> |
|||
</td> |
|||
</tr> |
|||
<?php endforeach; ?> |
|||
</tbody> |
|||
</table> |
|||
</div> |
|||
<?php |
|||
else : |
|||
echo "<h2>There is no record!</h2>"; |
|||
endif; |
|||
|
|||
#代表結束連線 |
|||
mysqli_close($link); |
|||
|
|||
include "../footer.php"; |
|||
?> |
@ -1,224 +1,224 @@ |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", ""); |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$envFile = __DIR__ . '/../.env'; // .env 文件的路径 |
|||
|
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
// 设置环境变量 |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
class DB |
|||
{ |
|||
private static $ds = array( |
|||
'default' => array('host' => 'db-104.coowo.com', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => 'x6h5E5p#u8y') |
|||
); |
|||
public static $instance; |
|||
/** |
|||
* ? |
|||
* |
|||
* @param string $db |
|||
* @return object |
|||
*/ |
|||
public static function instance($db = 'default') |
|||
{ |
|||
|
|||
$dbh = new PDO("mysql:host=" . self::$ds[$db]['host'] . ";dbname=appwms" . ";charset=utf8", self::$ds[$db]['user'], self::$ds[$db]['pwd']); |
|||
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|||
return $dbh; |
|||
} |
|||
/** |
|||
* ?insert |
|||
* |
|||
* @param [String] $table_name |
|||
* @param [Array] $cols |
|||
* @param [Array] $values |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function insert_batch($table_name, $cols, $values, $db = 'default') |
|||
{ |
|||
$_sql = 'insert into ' . $table_name . '(' . implode(",", $cols) . ')'; |
|||
$_vsql = array(); |
|||
foreach ($values as $value) { |
|||
$_vsql[] = 'select ' . implode(",", $value) . 'from dual'; |
|||
} |
|||
$_sql .= implode(' Union All ', $_vsql); |
|||
// self::query($_sql, $db); |
|||
self::instance($db)->exec($_sql); |
|||
} |
|||
/** |
|||
* insert |
|||
* |
|||
* @param [type] $table_name |
|||
* @param [type] $data |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function insert_table($table_name, $data, $db = 'default') |
|||
{ |
|||
|
|||
|
|||
// $stmt->debugDumpParams(); |
|||
|
|||
$fields = array_keys($data); |
|||
|
|||
$meta = self::metadata($table_name, array_keys($data), $db); |
|||
// var_dump( $meta); |
|||
|
|||
foreach ($fields as $f) { |
|||
|
|||
if ($meta[$f] == 'LONG' || $meta[$f] == 'NEWDECIMAL') { |
|||
$data[$f] = (int) $data[$f]; |
|||
} elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { |
|||
$data[$f] = 'NULL'; |
|||
} else { |
|||
// var_dump( $data[$f]); |
|||
// if( is_array($data[$f])){ echo "$table_name " ; echo "$f ";}; |
|||
|
|||
$data[$f] = "'" . $data[$f] . "'"; |
|||
$data[$f] = $data[$f]; |
|||
} |
|||
} |
|||
|
|||
//foreach ($fields as $f) { |
|||
|
|||
$_sql = "insert into " . $table_name . "(" . implode(",", array_keys($data)) . ") values (" . implode(",", array_values($data)) . " )"; |
|||
//echo $_sql; |
|||
self::instance($db)->exec($_sql); |
|||
// $stmt->debugDumpParams(); |
|||
|
|||
|
|||
|
|||
} |
|||
/** |
|||
* |
|||
* |
|||
* @param [String] $table_name |
|||
* @param [Array] $data |
|||
* @param [String] $data |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function update_table($table_name, $data, $where, $db = 'default') |
|||
{ |
|||
$fields = array_keys($data); |
|||
|
|||
$meta = self::metadata($table_name, array_keys($data), $db); |
|||
// var_dump( $meta); |
|||
|
|||
foreach ($fields as $f) { |
|||
|
|||
if ($meta[$f] == 'LONG') { |
|||
$data[$f] = (int) $data[$f]; |
|||
} else if ($meta[$f] == 'NEWDECIMAL') { |
|||
$data[$f] = (float) $data[$f]; |
|||
} elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { |
|||
$data[$f] = NULL; |
|||
} else { |
|||
$data[$f] = $data[$f]; |
|||
$data[$f] = $data[$f]; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
if (empty($where)) { |
|||
return false; |
|||
} |
|||
$sql = "update $table_name set "; |
|||
$i = 0; |
|||
foreach ($data as $key => $val) { |
|||
$sql .= $i++ > 0 ? " , $key=:$key " : " $key=:$key "; |
|||
$value[$key] = $val; |
|||
} |
|||
// var_dump($value); |
|||
$sql .= " where " . $where; |
|||
$stmt = self::instance($db)->prepare($sql); |
|||
|
|||
$stmt->execute($value); |
|||
// $stmt->debugDumpParams(); |
|||
} |
|||
|
|||
/** |
|||
* sql |
|||
* |
|||
* @param [String] $sql |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function fields($sql, $db = 'default') |
|||
{ |
|||
return self::query($sql)->fetch(PDO::FETCH_BOTH); |
|||
} |
|||
/** |
|||
* ?,as_array array? |
|||
* |
|||
* @param [String] $sql |
|||
* @param boolean $as_array |
|||
* @param string $db |
|||
* @return mixed |
|||
*/ |
|||
public static function result($sql, $as_array = true, $db = 'default') |
|||
{ |
|||
// echo $sql; |
|||
$resource = self::query($sql, $db); |
|||
|
|||
return $as_array == false ? $resource->fetchAll(PDO::FETCH_OBJ) : $resource->fetchAll(PDO::FETCH_BOTH); |
|||
} |
|||
/** |
|||
*sql? |
|||
* |
|||
* @param [String] $sql |
|||
* @return [int] |
|||
*/ |
|||
public static function effect_num($sql, $db = 'default') |
|||
{ |
|||
return count(self::query($sql, $db)->fetchAll()); |
|||
} |
|||
public static function query($sql, $db = 'default') |
|||
{ |
|||
|
|||
// echo $sql; |
|||
$res = self::instance($db)->prepare($sql); |
|||
|
|||
if (!$res) { |
|||
// var_dump($res->errorInfo()); |
|||
} else { |
|||
$res->execute(); |
|||
|
|||
return $res; |
|||
} |
|||
} |
|||
public function escape($filed) |
|||
{ |
|||
} |
|||
|
|||
/* |
|||
* 获取列的元数据 |
|||
* |
|||
* @param [type] $tablename |
|||
* @return void |
|||
*/ |
|||
public static function metadata($tablename = null, $col = array(), $db = 'default') |
|||
{ |
|||
$column_types = array(); |
|||
|
|||
$stmt = self::query("SELECT " . implode(",", array_values($col)) . " FROM " . $tablename . " limit 0,1"); |
|||
for ($i = 0; $i < $stmt->columnCount(); $i++) { |
|||
$meta[$i] = $stmt->getColumnMeta($i); |
|||
|
|||
$column_types[$meta[$i]['name']] = $meta[$i]['native_type']; |
|||
} |
|||
|
|||
return $column_types; |
|||
} |
|||
} |
|||
<?php |
|||
error_reporting(E_ALL); |
|||
ini_set("display_errors", ""); |
|||
date_default_timezone_set("Asia/Taipei"); |
|||
$envFile = __DIR__ . '/../.env'; // .env 文件的路径 |
|||
|
|||
if (file_exists($envFile)) { |
|||
$lines = file($envFile, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); |
|||
if ($lines !== false) { |
|||
foreach ($lines as $line) { |
|||
list($key, $value) = explode('=', $line, 2); |
|||
$key = trim($key); |
|||
$value = trim($value); |
|||
// 设置环境变量 |
|||
putenv("$key=$value"); |
|||
} |
|||
} |
|||
} |
|||
class DB |
|||
{ |
|||
private static $ds = array( |
|||
'default' => array('host' => '127.0.0.1', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => '') |
|||
); |
|||
public static $instance; |
|||
/** |
|||
* ? |
|||
* |
|||
* @param string $db |
|||
* @return object |
|||
*/ |
|||
public static function instance($db = 'default') |
|||
{ |
|||
|
|||
$dbh = new PDO("mysql:host=" . self::$ds[$db]['host'] . ";dbname=appwms" . ";charset=utf8", self::$ds[$db]['user'], self::$ds[$db]['pwd']); |
|||
$dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); |
|||
return $dbh; |
|||
} |
|||
/** |
|||
* ?insert |
|||
* |
|||
* @param [String] $table_name |
|||
* @param [Array] $cols |
|||
* @param [Array] $values |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function insert_batch($table_name, $cols, $values, $db = 'default') |
|||
{ |
|||
$_sql = 'insert into ' . $table_name . '(' . implode(",", $cols) . ')'; |
|||
$_vsql = array(); |
|||
foreach ($values as $value) { |
|||
$_vsql[] = 'select ' . implode(",", $value) . 'from dual'; |
|||
} |
|||
$_sql .= implode(' Union All ', $_vsql); |
|||
// self::query($_sql, $db); |
|||
self::instance($db)->exec($_sql); |
|||
} |
|||
/** |
|||
* insert |
|||
* |
|||
* @param [type] $table_name |
|||
* @param [type] $data |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function insert_table($table_name, $data, $db = 'default') |
|||
{ |
|||
|
|||
|
|||
// $stmt->debugDumpParams(); |
|||
|
|||
$fields = array_keys($data); |
|||
|
|||
$meta = self::metadata($table_name, array_keys($data), $db); |
|||
// var_dump( $meta); |
|||
|
|||
foreach ($fields as $f) { |
|||
|
|||
if ($meta[$f] == 'LONG' || $meta[$f] == 'NEWDECIMAL') { |
|||
$data[$f] = (int) $data[$f]; |
|||
} elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { |
|||
$data[$f] = 'NULL'; |
|||
} else { |
|||
// var_dump( $data[$f]); |
|||
// if( is_array($data[$f])){ echo "$table_name " ; echo "$f ";}; |
|||
|
|||
$data[$f] = "'" . $data[$f] . "'"; |
|||
$data[$f] = $data[$f]; |
|||
} |
|||
} |
|||
|
|||
//foreach ($fields as $f) { |
|||
|
|||
$_sql = "insert into " . $table_name . "(" . implode(",", array_keys($data)) . ") values (" . implode(",", array_values($data)) . " )"; |
|||
//echo $_sql; |
|||
self::instance($db)->exec($_sql); |
|||
// $stmt->debugDumpParams(); |
|||
|
|||
|
|||
|
|||
} |
|||
/** |
|||
* |
|||
* |
|||
* @param [String] $table_name |
|||
* @param [Array] $data |
|||
* @param [String] $data |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function update_table($table_name, $data, $where, $db = 'default') |
|||
{ |
|||
$fields = array_keys($data); |
|||
|
|||
$meta = self::metadata($table_name, array_keys($data), $db); |
|||
// var_dump( $meta); |
|||
|
|||
foreach ($fields as $f) { |
|||
|
|||
if ($meta[$f] == 'LONG') { |
|||
$data[$f] = (int) $data[$f]; |
|||
} else if ($meta[$f] == 'NEWDECIMAL') { |
|||
$data[$f] = (float) $data[$f]; |
|||
} elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { |
|||
$data[$f] = NULL; |
|||
} else { |
|||
$data[$f] = $data[$f]; |
|||
$data[$f] = $data[$f]; |
|||
} |
|||
} |
|||
|
|||
|
|||
|
|||
if (empty($where)) { |
|||
return false; |
|||
} |
|||
$sql = "update $table_name set "; |
|||
$i = 0; |
|||
foreach ($data as $key => $val) { |
|||
$sql .= $i++ > 0 ? " , $key=:$key " : " $key=:$key "; |
|||
$value[$key] = $val; |
|||
} |
|||
// var_dump($value); |
|||
$sql .= " where " . $where; |
|||
$stmt = self::instance($db)->prepare($sql); |
|||
|
|||
$stmt->execute($value); |
|||
// $stmt->debugDumpParams(); |
|||
} |
|||
|
|||
/** |
|||
* sql |
|||
* |
|||
* @param [String] $sql |
|||
* @param string $db |
|||
* @return void |
|||
*/ |
|||
public static function fields($sql, $db = 'default') |
|||
{ |
|||
return self::query($sql)->fetch(PDO::FETCH_BOTH); |
|||
} |
|||
/** |
|||
* ?,as_array array? |
|||
* |
|||
* @param [String] $sql |
|||
* @param boolean $as_array |
|||
* @param string $db |
|||
* @return mixed |
|||
*/ |
|||
public static function result($sql, $as_array = true, $db = 'default') |
|||
{ |
|||
// echo $sql; |
|||
$resource = self::query($sql, $db); |
|||
|
|||
return $as_array == false ? $resource->fetchAll(PDO::FETCH_OBJ) : $resource->fetchAll(PDO::FETCH_BOTH); |
|||
} |
|||
/** |
|||
*sql? |
|||
* |
|||
* @param [String] $sql |
|||
* @return [int] |
|||
*/ |
|||
public static function effect_num($sql, $db = 'default') |
|||
{ |
|||
return count(self::query($sql, $db)->fetchAll()); |
|||
} |
|||
public static function query($sql, $db = 'default') |
|||
{ |
|||
|
|||
// echo $sql; |
|||
$res = self::instance($db)->prepare($sql); |
|||
|
|||
if (!$res) { |
|||
// var_dump($res->errorInfo()); |
|||
} else { |
|||
$res->execute(); |
|||
|
|||
return $res; |
|||
} |
|||
} |
|||
public function escape($filed) |
|||
{ |
|||
} |
|||
|
|||
/* |
|||
* 获取列的元数据 |
|||
* |
|||
* @param [type] $tablename |
|||
* @return void |
|||
*/ |
|||
public static function metadata($tablename = null, $col = array(), $db = 'default') |
|||
{ |
|||
$column_types = array(); |
|||
|
|||
$stmt = self::query("SELECT " . implode(",", array_values($col)) . " FROM " . $tablename . " limit 0,1"); |
|||
for ($i = 0; $i < $stmt->columnCount(); $i++) { |
|||
$meta[$i] = $stmt->getColumnMeta($i); |
|||
|
|||
$column_types[$meta[$i]['name']] = $meta[$i]['native_type']; |
|||
} |
|||
|
|||
return $column_types; |
|||
} |
|||
} |
|||
|
Loading…
Reference in new issue