@ -25,27 +25,19 @@ $flow_id = 'con01';
$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;
// }
list($apply_key, $form_key) = DB::fields("SELECT apply_key, form_key from con_maintance_examine_apply where vol_no='$vol_no' order by apply_key desc limit 0, 1");
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");
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 > 2) {
echo "< script > alert ( '卷號" . $vol_no . "已生成價審單,請勿重複生成!' ) ; history . go ( - 1 ) ; < / script > ";
exit;
}
if ($apply_st == 1) {
$wf = new WorkFlow($system_id, $flow_id, $form_id);
@ -66,6 +58,7 @@ $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());
@ -79,19 +72,19 @@ $isSplitable = $wf->isSplitable();
//表單數據
#客戶表
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc ";
$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'";
$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'";
$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";
$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'";
$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 = [
@ -100,13 +93,15 @@ $is_m1_bundle_opt = [
];
#7.機種
$sql = "select code_name value ,content label from code where field_name='fp_kind'";
$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";
// print_r($sql);
$hope_contract = DB::result($sql);
$hope_contract = empty($hope_contract) ? [] : $hope_contract[0];
#寫入 con_maintance_examine_apply
@ -132,32 +127,7 @@ if ($apply_st == 1) {
//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 = [
@ -217,11 +187,12 @@ $con_maintance_examine_clear_columm = [
'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']],
'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'placeholder' => '契約成交價', '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 > ";
@ -237,8 +208,6 @@ foreach ($con_maintance_examine_clear_columm as $key => $val) {
$cmecRow .= "< / tr > < tr > ";
}
}
$cmecRow .= "< / tr > ";
function base_url($url)
{
@ -259,7 +228,26 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
return $seq_no;
}
$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 = '詹益彰';
}
?>
< link rel = "stylesheet" type = "text/css" href = " <?php echo base_url ( 'css/jquery.cleditor.css' ); ?> " />
@ -366,8 +354,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
// }
// }
// }
_option_tmp += '< option value = ' + ' <?php echo $managerid ?> ' + ' > ' + '<?php echo $managername ?> ' + '</ option > ';
// console.log(_option_tmp);
_option_tmp = '< option value = ' + ' <?php echo $managerid ?> ' + ' > ' + '<?php echo $managername ?> ' + '</ option > ';
$("#next_users").append(_option_tmp);
});
$('#maintain_kind').change(function() {
@ -388,9 +375,8 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
$('#maintain_kind').eq(0).focus();
return false;
}
var cmecRow = $('#elevator_list').html();
// console.log(cmecRow);
$('#elevator_list').append(cmecRow);
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;
@ -406,7 +392,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
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("" );
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();
}
@ -438,6 +424,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
//console.info(param1);
});
$("input[name^='floors']" +
",input[name^='speed']" +
",input[name^='persons']" +
@ -478,18 +465,16 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
});
}
delRow = function(btn) {
console.log($(btn).parent().parent().parent().parent().parent().remove());
if ($(btn).attr('name') == 'btn1') {
// console.log($(btn).parent().parent().prev('tr').find('input[id=register_code]').val());
regDelStr += $(btn).parent().parent().parent(). find('input[id=register_code]').val() + ",";
//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();
console.log(regDelStr)
} else {
// console.log($(btn).parent().parent().find('input[id=register_code]').val());
//console.log($(btn).parent().parent().find('input[id=register_code]').val());
$(btn).parent().parent().next('tr').remove();
$(btn).parent().parent().remove();
}
$(btn).parent().parent().parent().parent().parent(). remove();
$(btn).parent().parent().remove();
}
setStandPrice = function(p, obj) {
$.ajax({
@ -499,7 +484,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
dataType: 'json',
//success: function(data) {},
success: function(data) {
console.info(data);
// console.info(data);
if (data.status == 'ok') {
$(obj).val(data.price);
} else {
@ -523,11 +508,11 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
type: 'post',
dataType: 'json',
success: function(data) {
console.info(data);
// console.info(data);
$("#brand").append("< option value = '" + data.seq + "' > " + new_brand + "< / option > ");
},
error: function(data) {
console.info(data);
// console.info(data);
}
});
@ -619,7 +604,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
< div class = "col-12 form_row_header " >
< b > 電梯詳細資料< / b >
< / div >
< table style = 'margin-top:0px;text-align:center' class = ' table-condensed' id = 'elevator_list1 ' >
< table style = 'margin-top:0px;text-align:center' class = ' table-condensed' id = 'elevator_list' >
< thead >
< tr >
@ -636,138 +621,53 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
< tr >
< td colspan = '18' ; > < button onClick = 'addRow()' type = "button" style = 'float:right' class = "btn btn-link btn-md" > +新增< / button > < / td >
< / tr >
< / thead >
< / table >
< table class = ' table-condensed' id = 'elevator_list' >
< thead >
< tr style = ' margin-top:0px;text-align:center' >
< th colspan = "2" > 電梯許可代碼< / th >
< th colspan = "2" > 品牌< / th >
< th colspan = "2" > 電梯類型< / th >
< th colspan = "2" > 規格型號< / th >
< th > 載重(KG)< / th >
< th colspan = "2" > 速度(m/min)< / th >
< th > 停數< / th >
< th > 層數< / th >
< th > 人乘< / th >
< th colspan = "2" > 保養次數< / th >
< th > 保養月數< / th >
< th > 保養周期< / th >
< th > 贈送M1< / th >
< / tr >
<!-- <tr style='margin - top:0px;text - align:center'> -->
<?php
$j = 0;
echo "< tr style = 'margin-top:0px;text-align:center' > ";
$i = 0;
$cmecRow = '< tr > ';
foreach ($con_maintance_examine_clear_columm as $col => $col_def) {
echo FormHelper::tag("th", ['colspan' => empty($col_def['attr']['colspan']) ? 1 : $col_def['attr']['colspan']], $col_def['label']);
if ((++$j % $col_count) == 0) {
if ($j == $col_count) echo "< th > 操作< / th > ";
echo "< / tr > < tr style = 'margin-top:0px;text-align:center' > ";
}
}
echo '< / tr > ';
< / thead >
< tbody id = 'cmecTbody' >
< tr >
< td colspan = "2" >
< div class = ' col-12' > < input id = "register_code" name = "register_code[]" type = "text" value placeholder = "無證號請輸入A、B..." repuired class = "form-control form=control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = ' col-12' >
< select name = "elevator_brand[]" id = "" class = "form-control form-control-sm" >
< option value = "" > < / option >
<?php foreach ( $elevator_brand_opt as $data ) : ?>
< option value = " <?php echo $data [ 'value' ]; ?> " > <?php echo $data [ 'label' ] ?> </ option >
<?php endforeach ?>
< / select >
< / div >
< / td >
< td colspan = "2" >
< div class = ' col-12' >
< select name = "elevator_kind[]" id = "" class = "form-control form-control-sm" >
< option value = "" > < / option >
<?php foreach ( $elevator_kind_opt as $data ) : ?>
< option value = " <?php echo $data [ 'value' ] ?> " > <?php echo $data [ 'label' ] ?> </ option >
<?php endforeach ?>
< / select >
< / div >
< / td >
< td colspan = "2" >
< div class = ' col-12' >
< select name = "spec[]" id = "" class = "form-control form-control-sm" >
< option value = "" > < / option >
<?php foreach ( $fp_kind_opt as $data ) : ?>
< option value = " <?php echo $data [ 'value' ] ?> " > <?php echo $data [ 'label' ] ?> </ option >
<?php endforeach ?>
< / select >
< / div >
< / td >
<!-- <td><section name='spec'></section></td> -->
< td >
< div class = ' col-12' > < input type = "digits" id = "weight" name = "weight[]" value gt = "0" min = "0" required class = "form-control form-control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = ' col-12' > < input type = "number" id = "speed" name = "speed[]" valaue gt = "0" min = "0" require class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < input type = "number" id = "stop" name = "stop[]" class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < input type = "digits" id = "floors" name = "floors[]" value min = "1" required class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < input type = "digits" id = "persons" name = "persons[]" value min = '1' required class = "form-control form-contorl-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = ' col-12' > < input type = "digits" id = "maintain_times" name = "maintain_times[]" value = '1' min = '1' required class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < input type = "digits" id = "maintain_months" name = "maintain_months[]" value = "12" min = '12' required class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < input type = "digits" id = "maintain_period" name = "maintain_period[]" value = "1" min = '1' require class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = 'col-12' >
< select name = "is_m1_bundle[]" id required class = "form-control form-control-sm" id = "" >
< option value = "" > < / option >
<?php foreach ( $is_m1_bundle_opt as $data ) : ?>
< option value = " <?php $data [ 'value' ] ?> " > <?php echo $data [ 'label' ] ?> </ option >
<?php endforeach ?>
< / select >
< / div >
< / td >
< / tr >
< / tbody >
< thead >
< tr style = 'margin-top:0px;text-align:center' >
< th colspan = "2" > 竣工檢查年度< / th >
< th colspan = "2" > 上次年檢日期< / th >
< th colspan = "2" > 年檢費用(元)< / th >
< th colspan = "2" > 標準價格(元/月)< / th >
< th colspan = "2" > 契約報價(元/月)< / th >
< th colspan = "2" > 契約成交價(元/月)< / th >
< th > 刪除< / th >
< th colspan = "6" > < / th >
?>
< / tr >
< / thead >
< tbody id = 'cmecTbody2 ' >
< tbody id = 'cmecTbody' >
< tr >
< td colspan = "2" >
< div class = "col-12" > < input type = "text" id = "useful_years" name = "useful_years[]" type = "digits" value colspan = '2' required gt = '0' min = '0' class = "form-control form-control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = "col-12" > < input type = "number" id = "last_check_date" name = "last_check_date[]" value required colspan = "2" class = "form-control form-control-sn" > < / div >
< / td >
< td colspan = "2" >
< div class = "col-12" > < input type = "text" id = "annual_survey_expense" name = "annual_survey_exoense[]" type = "number" value required colspan = '2' class = "form-control form-control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = "col-12" > < input type = "text" id = 'stand_price' name = "stand_price[]" value required readonly colspan = '2' class = "form-control form-control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = "col-12" > < input type = "number" id = "contract_price" name = "contract_price[]" required colsapn = "2" class = "form-control form-control-sm" > < / div >
< / td >
< td colspan = "2" >
< div class = "col-12" > < input type = "number" id = "sold_price" name = "sold_price[]" colspan = '2' class = "form-control form-control-sm" > < / div >
< / td >
< td >
< div class = ' col-12' > < button onclick = "delRow(this)" type = "button" class = "btn btn-link btn md" > 刪除< / button > < / div >
< / td >
< td colspan = "6" > < / td >
<?php
foreach ($con_maintance_examine_clear as $key => $val) {
$j = 0;
$cmecRow = "< tr > ";
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 .= "< / tr > < tr > ";
}
}
echo $cmecRow . "< / tr > ";
}
?>
< / tr >
< / tbody >
< / table >
@ -796,7 +696,7 @@ function get_sequnece_no($seq_name = '', $p_yyyymm = '')
< 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 >
< select name = "next_users" id = "next_users" class = 'form-control form-control-sm ' > < / select >
< / div >
< div class = "col-3 form_field_title " >