Browse Source

契約價審

main
Cheng 1 year ago
parent
commit
e3e2bc642d
  1. 520
      wms/crm/crmm05-edit.php
  2. 5
      wms/crm/crmm06-edit.php
  3. 38
      wms/crm/crmm06_submit.php
  4. 69
      wms/crm/model/HopeContractCustomerModel.php
  5. 159
      wms/crm/model/Model.php
  6. 32
      wms/fun_global.php
  7. 2
      workflow/lib/DB.php
  8. 296
      workflow/model/Subflow.php
  9. 494
      workflow/model/SubflowManager.php

520
wms/crm/crmm05-edit.php

@ -1,264 +1,258 @@
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
require_once './FormHelper.php';
require_once './wf_common.php';
$vol_no = $_GET['vol_no'];
//錶單數據
#客戶錶
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc ";
$elevator_brand_opt = DB::result($sql);
#2.客戶來源
$sql = "select code_name value ,content label from code where field_name='customer_source'";
$customer_source_opt = DB::result($sql);
#3.電梯類型
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.營業員
$sql = "select employee_no value ,name label from employee w";
$salesman_opt = DB::result($sql);
#5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'";
$hope_customer_status_opt = DB::result($sql);
#6.是否汰改
$is_renovation_opt = [
['label' => '是', 'value' => 'Y'],
['label' => '否', 'value' => 'N'],
];
$sql = "select code_name value ,content label from code where field_name='open_kind'";
$open_kind_opt = DB::result($sql);
#生成新梯卷號
#抓取有望客戶資料
$table_hope_contract_customer = 'hope_contract_customer';
$hope_contract_customer_column = [
'vol_no' => ['label' => "卷號", "tag" => 'text', 'attr' => ['required','readonly', "value" => "$vol_no", 'class' => 'form-control form-control-sm']],
//'form_key' => ['label' => "錶單號","tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]],
'customer' => ['label' => "客戶名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $customer_source_opt],
//'linkman' => ['label' => "聯係人", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'lm_tel' => ['label' => "手機", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'salesman' => ['label' => "營業員", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $salesman_opt],
'num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['min=1','class' => 'form-control form-control-sm']],
'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']],
// 'case_name' => ['label' => "现场名称", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']],
'floors' => ['label' => '樓層', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'persons' => ['label' => '人乘', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'speed' => ['label' => '速度', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'completed_date' => ['label' => '竣工(民國年)', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'pre_order_date' => ['label' => "預定成交日", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
'status' => ['label' => "有望客戶狀態", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $hope_customer_status_opt],
'next_visit_date' => ['label' => "下次拜訪時間", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'brand' => ['label' => "廠牌", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm '], 'options' => $elevator_brand_opt],
'quote_date' => ['label' => "報價日期", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required','class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt],
];
$where = " and vol_no='$vol_no'";
$sql = " SELECT vol_no,customer,manager,source,
linkman,lm_tel,salesman,num,address,floors,persons,speed,completed_date,
date_format(pre_order_date,'%Y-%m-%d') pre_order_date,
status, date_format(next_visit_date,'%Y-%m-%d') next_visit_date ,brand ,
date_format(quote_date,'%Y-%m-%d') quote_date ,progress_status FROM $table_hope_contract_customer where 1=1 $where ";
$hope_contract_customer = DB::result($sql);
//var_dump($hope_elevator_customer );
#電梯規格 契约客户不用输入下面的
/*
$table_hope_project_elevator_spec = 'hope_project_elevator_spec';
$hope_project_elevator_spec_columm = [
'spec' => ['label' => "規格", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm']],
'person' => ['label' => "人", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'person[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt],
'weight' => ['label' => "載重(KG)", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'class' => 'form-control form-control-sm']],
'stop' => ['label' => "停數", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']],
'open' => ['label' => "開門方式", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'open[]', 'class' => 'form-control form-control-sm'],'options' => $open_kind_opt],
'speed' => ['label' => "速度(m/s)", "tag" => 'number', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm']],
'spec_num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['name' => 'spec_num[]', 'class' => 'form-control form-control-sm']],
'spec_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'spec_price[]', 'class' => 'form-control form-control-sm']],
];
$sql = " SELECT * FROM $table_hope_project_elevator_spec where 1=1 $where ";
$hope_project_elevator_spec = DB::result($sql);
$i = 0;
$cmecRow = " <tr>";
foreach ($hope_project_elevator_spec_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>";
}
$cmecRow .= "<td><button onClick='delCmecRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
*/
#電梯Option
/*
$table_hope_project_elevator_option = 'hope_project_elevator_option';
$hope_project_elevator_option_column = [
'option' => ['label' => "OPTION", "tag" => 'text', 'attr' => ['colspan' => 9, 'name' => 'option[]', 'class' => 'form-control form-control-sm']],
'option_num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['name' => 'option_num[]', 'class' => 'form-control form-control-sm']],
'option_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'option_price[]', 'class' => 'form-control form-control-sm']],
];
$sql = " SELECT * FROM $table_hope_project_elevator_option where 1=1 $where ";
$hope_project_elevator_option = DB::result($sql);
$hpeoRow = " <tr>";
foreach ($hope_project_elevator_option_column 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='請輸入'>";
$hpeoRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>";
}
$hpeoRow .= "<td><button onClick='delHpeoRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
*/
function base_url($url)
{
return "https://www.masada.com.tw/static/" . $url;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>有望客戶新增</title>
<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'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<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>
<script type="text/javascript">
$(document).ready(function() {
// $('#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 | "
});
$("#form").validate();
});
</script>
</head>
<body>
<div id="toolbarmenu">
<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>
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="crmm05_submit.php" id='form' method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type='hidden' name='vol_no' value='<?= $vol_no ?>'>
<input type='hidden' name='token' value='<?= $_GET['token'] ?>' />
<!--錶單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 ($hope_contract_customer_column as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($hope_contract_customer) ? "" : $hope_contract_customer[0][$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
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_status"
name="progress_status" value='<?= $hope_contract_customer[0]['progress_status']?>'
rows='6'><?= $hope_contract_customer[0]['progress_status']?></textarea>
</div>
</div>
<button style='margin:20px auto;width:50px' type="submit" class="btn btn-primary btn-sm">保存</button>
</div>
</form>
</div>
</div>
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
require_once './FormHelper.php';
require_once './wf_common.php';
$vol_no = $_GET['vol_no'];
//錶單數據
#客戶錶
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc ";
$elevator_brand_opt = DB::result($sql);
#2.客戶來源
$sql = "select code_name value ,content label from code where field_name='customer_source'";
$customer_source_opt = DB::result($sql);
#3.電梯類型
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514','515','314')";
$salesman_opt = DB::result($sql);
#5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'";
$hope_customer_status_opt = DB::result($sql);
#6.是否汰改
$is_renovation_opt = [
['label' => '是', 'value' => 'Y'],
['label' => '否', 'value' => 'N'],
];
$sql = "select code_name value ,content label from code where field_name='open_kind'";
$open_kind_opt = DB::result($sql);
#生成新梯卷號
#抓取有望客戶資料
$table_hope_contract_customer = 'hope_contract_customer';
$hope_contract_customer_column = [
'vol_no' => ['label' => "卷號", "tag" => 'text', 'attr' => ['required', 'readonly', "value" => "$vol_no", 'class' => 'form-control form-control-sm']],
//'form_key' => ['label' => "錶單號","tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]],
'customer' => ['label' => "客戶名稱", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'manager' => ['label' => "負責人", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'source' => ['label' => "客戶來源", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $customer_source_opt],
//'linkman' => ['label' => "聯係人", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'lm_tel' => ['label' => "手機", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'salesman' => ['label' => "營業員", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $salesman_opt],
'num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['min=1', 'class' => 'form-control form-control-sm']],
'address' => ['label' => "地址", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']],
// 'case_name' => ['label' => "现场名称", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm']],
'floors' => ['label' => '樓層', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'persons' => ['label' => '人乘', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'speed' => ['label' => '速度', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'completed_date' => ['label' => '竣工(民國年)', 'tag' => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'pre_order_date' => ['label' => "預定成交日", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
'status' => ['label' => "有望客戶狀態", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $hope_customer_status_opt],
'next_visit_date' => ['label' => "下次拜訪時間", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'brand' => ['label' => "廠牌", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm '], 'options' => $elevator_brand_opt],
'quote_date' => ['label' => "報價日期", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required','class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt],
];
$where = " and vol_no='$vol_no'";
$sql = " SELECT vol_no,customer,manager,source,
linkman,lm_tel,salesman,num,address,floors,persons,speed,completed_date,
date_format(pre_order_date,'%Y-%m-%d') pre_order_date,
status, date_format(next_visit_date,'%Y-%m-%d') next_visit_date ,brand ,
date_format(quote_date,'%Y-%m-%d') quote_date ,progress_status FROM $table_hope_contract_customer where 1=1 $where ";
$hope_contract_customer = DB::result($sql);
//var_dump($hope_elevator_customer );
#電梯規格 契约客户不用输入下面的
/*
$table_hope_project_elevator_spec = 'hope_project_elevator_spec';
$hope_project_elevator_spec_columm = [
'spec' => ['label' => "規格", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm']],
'person' => ['label' => "人", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'person[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt],
'weight' => ['label' => "載重(KG)", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'class' => 'form-control form-control-sm']],
'stop' => ['label' => "停數", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']],
'open' => ['label' => "開門方式", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'open[]', 'class' => 'form-control form-control-sm'],'options' => $open_kind_opt],
'speed' => ['label' => "速度(m/s)", "tag" => 'number', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm']],
'spec_num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['name' => 'spec_num[]', 'class' => 'form-control form-control-sm']],
'spec_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'spec_price[]', 'class' => 'form-control form-control-sm']],
];
$sql = " SELECT * FROM $table_hope_project_elevator_spec where 1=1 $where ";
$hope_project_elevator_spec = DB::result($sql);
$i = 0;
$cmecRow = " <tr>";
foreach ($hope_project_elevator_spec_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>";
}
$cmecRow .= "<td><button onClick='delCmecRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
*/
#電梯Option
/*
$table_hope_project_elevator_option = 'hope_project_elevator_option';
$hope_project_elevator_option_column = [
'option' => ['label' => "OPTION", "tag" => 'text', 'attr' => ['colspan' => 9, 'name' => 'option[]', 'class' => 'form-control form-control-sm']],
'option_num' => ['label' => "臺數", "tag" => 'number', 'attr' => ['name' => 'option_num[]', 'class' => 'form-control form-control-sm']],
'option_price' => ['label' => "單價", "tag" => 'number', 'attr' => ['name' => 'option_price[]', 'class' => 'form-control form-control-sm']],
];
$sql = " SELECT * FROM $table_hope_project_elevator_option where 1=1 $where ";
$hope_project_elevator_option = DB::result($sql);
$hpeoRow = " <tr>";
foreach ($hope_project_elevator_option_column 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='請輸入'>";
$hpeoRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>";
}
$hpeoRow .= "<td><button onClick='delHpeoRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
*/
function base_url($url)
{
return "https://www.masada.com.tw/static/" . $url;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>有望客戶新增</title>
<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'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<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>
<script type="text/javascript">
$(document).ready(function() {
// $('#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 | "
});
$("#form").validate();
});
</script>
</head>
<body>
<div id="toolbarmenu">
<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>
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="crmm05_submit.php" id='form' method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type='hidden' name='vol_no' value='<?= $vol_no ?>'>
<input type='hidden' name='token' value='<?= $_GET['token'] ?>' />
<!--錶單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 ($hope_contract_customer_column as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($hope_contract_customer) ? "" : $hope_contract_customer[0][$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
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_status" name="progress_status" value='<?= $hope_contract_customer[0]['progress_status'] ?>' rows='6'><?= $hope_contract_customer[0]['progress_status'] ?></textarea>
</div>
</div>
<button style='margin:20px auto;width:50px' type="submit" class="btn btn-primary btn-sm">保存</button>
</div>
</form>
</div>
</div>
</body>

5
wms/crm/crmm06-edit.php

@ -19,7 +19,7 @@ $customer_source_opt = DB::result($sql);
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.營業員
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514','515','314')";
$sql = "select employee_no value ,name label from employee where depart_no in ('511','512','513','514','515','314')";
$salesman_opt = DB::result($sql);
#5.有望客戶狀態
$sql = "select code_name value ,content label from code where field_name='hope_customer_status'";
@ -60,8 +60,7 @@ $hope_contract_customer_column = [
'next_visit_date' => ['label' => "下次拜訪時間", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'brand' => ['label' => "廠牌", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm '], 'options' => $elevator_brand_opt],
'quote_date' => ['label' => "報價日期", "tag" => 'date', 'attr' => ['class' => 'date form-control form-control-sm']],
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required','class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt],
// 'is_renovation' => ['label' => "是否汰改", "tag" => 'select', 'attr' => ['required', 'class' => ' form-control form-control-sm'], 'options' => $is_renovation_opt],
];
$data = [
'salesman' => $user_id

38
wms/crm/crmm06_submit.php

@ -1,18 +1,20 @@
<?php
require_once './wf_common.php';
require_once './model/HopeContractCustomerModel.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
$hecm = new HopeContractCustomerModel();
$cols = $hecm->fillable;
foreach ($cols as $col) {
if (!in_array($col, array_keys($request))) {
continue;
}
$data[$col] = empty($request[$col]) ? NULL : $request[$col];
}
$hecm->create( $data);
echo"<script>alert('已保存');</script>";
header("Location:"."https://www.masada.com.tw/wms/crm/crmm02-index.php?token=".$request['token']);
<?php
require_once './wf_common.php';
require_once './model/HopeContractCustomerModel.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
$hecm = new HopeContractCustomerModel();
$cols = $hecm->fillable;
foreach ($cols as $col) {
if (!in_array($col, array_keys($request))) {
continue;
}
$data[$col] = empty($request[$col]) ? NULL : $request[$col];
}
$hecm->create($data);
echo "<script>alert('已保存');</script>";
header("Location:" . "https://www.masada.com.tw/wms/crm/crmm02-index.php?token=" . $request['token']);

69
wms/crm/model/HopeContractCustomerModel.php

@ -1,34 +1,35 @@
<?php
require_once 'Model.php';
class HopeContractCustomerModel extends Model
{
protected $table = 'hope_contract_customer';
public $fillable = [
'vol_no',
'customer_no',
'customer',
'manager',
'source',
'linkman',
'lm_tel',
'salesman_name',
'salesman',
'num',
'pre_order_date',
'status',
'progress_status',
'recently_status',
'next_visit_date',
'address',
'tel',
'mail',
'quote_date',
'is_renovation',
'file',
'floors',
'persons',
'speed',
'completed_date',
'creater_name',
'creater'];
}
<?php
require_once 'Model.php';
class HopeContractCustomerModel extends Model
{
protected $table = 'hope_contract_customer';
public $fillable = [
'vol_no',
'customer_no',
'customer',
'manager',
'source',
'linkman',
'lm_tel',
'salesman_name',
'salesman',
'num',
'pre_order_date',
'status',
'progress_status',
'recently_status',
'next_visit_date',
'address',
'tel',
'mail',
'quote_date',
'is_renovation',
'file',
'floors',
'persons',
'speed',
'completed_date',
'creater_name',
'creater'
];
}

159
wms/crm/model/Model.php

@ -1,79 +1,80 @@
<?php
class Model
{
protected $table = '';
protected $fillable = [];
/**
* 创建记录
*
* @param array $data
* @return void
*/
public function create(array $data)
{
$_data = [];
foreach ($this->fillable as $col) {
$_data[$col] = empty($data[$col]) ? '' : $data[$col];
}
DB::insert_table($this->table, $_data);
}
/**
* 创建或更新
*
* @return void
*/
public function createOrUpdate(array $keyCol, array $data)
{
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
// echo "select count(*) from $this->table where $where ";
list($cnt) = DB::fields(
"select count(*) from $this->table where $where "
);
if ($cnt == 0) {
foreach ($keyCol as $key => $col) {
$data[$col[0]] = $col[1];
}
self::create($data);
} else {
self::update($keyCol, $data);
}
}
public function delete(array $keyCol, array $data)
{
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
// echo "delete from $this->table where $where ";
DB::query(
"delete from $this->table where $where "
);
}
public function update(array $keyCol, array $data)
{
$_data = [];
foreach ($this->fillable as $col) {
if (in_array($col, array_keys($data))) $_data[$col] = empty($data[$col]) ? '' : $data[$col];
}
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
DB::update_table($this->table, $_data, $where);
}
/**
* 获取记录
*
* @param array $cond
* @return void
*/
public function get(array $cond)
{
return [];
}
}
<?php
class Model
{
protected $table = '';
protected $fillable = [];
/**
* 创建记录
*
* @param array $data
* @return void
*/
public function create(array $data)
{
$_data = [];
foreach ($this->fillable as $col) {
$_data[$col] = empty($data[$col]) ? '' : $data[$col];
}
DB::insert_table($this->table, $_data);
}
/**
* 创建或更新
*
* @return void
*/
public function createOrUpdate(array $keyCol, array $data)
{
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
// echo "select count(*) from $this->table where $where ";
list($cnt) = DB::fields(
"select count(*) from $this->table where $where "
);
if ($cnt == 0) {
foreach ($keyCol as $key => $col) {
$data[$col[0]] = $col[1];
}
self::create($data);
} else {
self::update($keyCol, $data);
}
}
public function delete(array $keyCol, array $data)
{
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
// echo "delete from $this->table where $where ";
DB::query(
"delete from $this->table where $where "
);
}
public function update(array $keyCol, array $data)
{
$_data = [];
foreach ($this->fillable as $col) {
if (in_array($col, array_keys($data))) $_data[$col] = empty($data[$col]) ? '' : $data[$col];
}
$where = ' 1=1 ';
foreach ($keyCol as $key => $col) {
$where .= " and " . $col[0] . " = '" . $col[1] . "'";
}
DB::update_table($this->table, $_data, $where);
}
/**
* 获取记录
*
* @param array $cond
* @return void
*/
public function get(array $cond)
{
return [];
}
}

32
wms/fun_global.php

@ -89,6 +89,7 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
$sql = "select manager from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$i = 0;
while ($row = mysqli_fetch_assoc($res)) {
if ($row["manager"] == "M0001") return; // 董事長略過
if ($user_id == 'TEST01') {
@ -99,13 +100,30 @@ function pricereview_class($rate, $user_id, &$ret = [], $special_fee)
return $ret;
exit;
} else {
if ($i == 0 && ($user_id == 'M0033' || $user_id == "M0137" || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == "M0086")) {
$ret[1] = $user_id . ",,";
$ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) {
$ret[4] = "M0006,,"; // 總經理
}
return $ret;
exit();
}
if ($row["manager"] != "M0060" && $row["manager"] != "M0006" && $row["manager"] != "M0008") {
$ret[1] = $row["manager"] . ",,";
pricereview_class($rate, $row["manager"], $ret, $special_fee);
} else {
if ($user_id == 'M0033' || $user_id == 'M0137' || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == 'M0086') {
$ret[1] = $user_id . ",,";
if ($row["manager"] == 'M0029') {
$ret[1] = "M0147,,";
$i++;
pricereview_class($rate, $row["manager"], $ret, $special_fee);
} else {
$ret[1] = $row["manager"] . ",,";
$i++;
pricereview_class($rate, $row["manager"], $ret, $special_fee);
}
} else {
// if ($user_id == 'M0033' || $user_id == 'M0137' || $user_id == 'M0029' || $user_id == 'M0054' || $user_id == 'M0086') {
// $ret[1] = $user_id . ",,";
// }
$ret[2] = "M0024,,<##>M0107,,"; // 業務部專員:M0024許伃廷、M0107許紓晴(第2關有多位審核人)
$ret[3] = "M0060,,"; // 業務協理
if ($rate < 80 || $special_fee > 0) {
@ -164,7 +182,9 @@ function pricereview_renovate_class($rate, $user_id, $renovate_flag)
return $ret;
}
function pricereview_maintainance_class($rate, $user_id, $renovate_flag)
{
}
/**
* 檢查使用者選單權限
*

2
workflow/lib/DB.php

@ -19,7 +19,7 @@ if (file_exists($envFile)) {
class DB
{
private static $ds = array(
'default' => array('host' => '127.0.0.1', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => '')
'default' => array('host' => '127.0.0.1', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => 'x6h5E5p#u8y')
);
public static $instance;
/**

296
workflow/model/Subflow.php

@ -1,150 +1,146 @@
<?php
class Subflow
{
private $form_key;
private $seq = 0;
public $current_assigner;
private $real_id;
private $receive_date;
private $pre_finish_date;
#会签 状态 S0001
const SUSPEND_STATE = "S0001";
public function __construct(Flow $flow)
{
if ($flow->getFormKey() == null) {
$this->form_key = Flow::getNewFormKey();
} else {
$this->form_key = $flow->getFormKey();
}
}
function getFormKey()
{
return $this->form_key;
}
public static function delete($formKey = null)
{
DB::query("DELETE subflow WHERE Form_Key = '" . $formKey . "'");
}
/**
* @param $userId
* @return $this
*/
public function setCurrentUser($userId)
{
$this->current_assigner = $userId;
return $this;
}
/**
*变更当前签核人员
* @param $formKey
* @param $userId
*/
public static function updateCurrentUser($formKey, $userId)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"current_assigner" => $userId,
), $where);
}
/**
* 获取当前签核者
* @param $formKey
* @return userId
*/
public static function getCurrentUser($formKey)
{
list($currentAssigner) = DB::fields("SELECT current_assigner
FROM subflow where form_key ='$formKey'");
return $currentAssigner;
}
/***
*
*关闭签核
* @param null $formKey
*/
public static function close($formKey = null)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"current_assigner" => '00000'
), $where);
}
/**
*
* @param null $formKey
*/
public static function suspend($formKey = null)
{
self::updateRealId($formKey, self::getCurrentUser($formKey));
$where = "form_key = '" . $formKey . "'";
DB::update_table("subflow", array(
"current_assigner" => self::SUSPEND_STATE,
), $where);
}
/**
*
* @param $formKey
* @param $userId
*/
public static function updateRealId($formKey, $userId)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"real_id" => $userId,
), $where);
}
/**
*
* @param $formKey
* @param $userId
* @return
*/
public static function getRealId($formKey)
{
list($real_id) = DB::fields("SELECT real_id
FROM subflow where form_key ='$formKey'");
return $real_id;
}
/**
* 插入记录
* @return int
*/
public function insert()
{
list($cnt) = DB::fields("select count(*) from subflow where from_key='" . $this->form_key . "' ");
if ($cnt == 0) {
DB::insert_table("subflow", array(
"form_key" => $this->form_key,
"seq" => $this->seq + 1,
"current_assigner" => $this->current_assigner,
"real_id" => $this->real_id
));
return 1;
}
return -1;
}
public function __toString()
{
return json_encode($this);
}
}
<?php
class Subflow
{
private $form_key;
private $seq = 0;
public $current_assigner;
private $real_id;
private $receive_date;
private $pre_finish_date;
#会签 状态 S0001
const SUSPEND_STATE = "S0001";
public function __construct(Flow $flow)
{
if ($flow->getFormKey() == null) {
$this->form_key = Flow::getNewFormKey();
} else {
$this->form_key = $flow->getFormKey();
}
}
function getFormKey()
{
return $this->form_key;
}
public static function delete($formKey = null)
{
DB::query("DELETE subflow WHERE Form_Key = '" . $formKey . "'");
}
/**
* @param $userId
* @return $this
*/
public function setCurrentUser($userId)
{
$this->current_assigner = $userId;
return $this;
}
/**
*变更当前签核人员
* @param $formKey
* @param $userId
*/
public static function updateCurrentUser($formKey, $userId)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"current_assigner" => $userId,
), $where);
}
/**
* 获取当前签核者
* @param $formKey
* @return userId
*/
public static function getCurrentUser($formKey)
{
list($currentAssigner) = DB::fields("SELECT current_assigner
FROM subflow where form_key ='$formKey'");
return $currentAssigner;
}
/***
*
*关闭签核
* @param null $formKey
*/
public static function close($formKey = null)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"current_assigner" => '00000'
), $where);
}
/**
*
* @param null $formKey
*/
public static function suspend($formKey = null)
{
self::updateRealId($formKey, self::getCurrentUser($formKey));
$where = "form_key = '" . $formKey . "'";
DB::update_table("subflow", array(
"current_assigner" => self::SUSPEND_STATE,
), $where);
}
/**
*
* @param $formKey
* @param $userId
*/
public static function updateRealId($formKey, $userId)
{
$where = "form_key = '" . $formKey . "'";;
DB::update_table("subflow", array(
"real_id" => $userId,
), $where);
}
/**
*
* @param $formKey
* @param $userId
* @return
*/
public static function getRealId($formKey)
{
list($real_id) = DB::fields("SELECT real_id
FROM subflow where form_key ='$formKey'");
return $real_id;
}
/**
* 插入记录
* @return int
*/
public function insert()
{
list($cnt) = DB::fields("select count(*) from subflow where form_key='" . $this->form_key . "' ");
if ($cnt == 0) {
DB::insert_table("subflow", array(
"form_key" => $this->form_key,
"seq" => $this->seq + 1,
"current_assigner" => $this->current_assigner,
"real_id" => $this->real_id
));
return 1;
}
return -1;
}
public function __toString()
{
return json_encode($this);
}
}

494
workflow/model/SubflowManager.php

@ -1,242 +1,252 @@
<?php
/***
* Class SubflowManager
* @desc 对workflow_sublow 新增查询操作
* @date 2018年8月5日11:42:58
* @author u73376@yuntay.com.cn
*/
class SubflowManager
{
private $parent_key;
private $seq = 0;
public function __construct(Flow $parentFlow = null)
{
if (!empty($parentFlow)) {
$this->parent_key = $parentFlow->getFormKey();
}
$this->seq = $this->_getSeq();
}
public function __toString()
{
return json_encode($this);
}
public static function getDetail($parentKey, $seq = 0)
{
$detail = DB::result("select * from workflow_subflow where
seq='" . $seq . "' and parent_key ='" . $parentKey . "'");
return $detail;
}
/**
* @desc workflow_sublow 新增一条记录
* @param Subflow $subflow
* @param $sender
* @param int $seq
*/
public function append(Subflow $subflow, $sender, $seq = null)
{
DB::query("insert into workflow_subflow (FORM_KEY, SEQ, PARENT_KEY, LEADER_NO, CREATE_DATE, SENDER)
values ('" . $subflow->getFormKey() . "',
'" . $this->seq . "',
'" . $this->parent_key . "',
'" . $subflow->current_assigner . "',
now(),
'" . $sender . "' ) ");
}
static function getChildNode($childFormKey)
{
$node = DB::result("select * from workflow_subflow where form_key
='" . $childFormKey . "'");
return $node[0];
}
/**
* 未回复统计
* @return integer|null
*/
public function getUnReplyCount($seq = null)
{
if ($seq == null) {
return null;
}
list($cnt) = DB::fields("select count(*) from workflow_subflow where
reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 未回复明细
* @return array|void
*/
public function getUnReplyDetail($seq = null)
{
if ($seq == null) {
return null;
}
list($detail) = DB::fields("select * from workflow_subflow where
reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $detail;
}
/**
* 已回复统计
* @param null $seq
* @return integer
*/
public function getReplyCount($seq = null)
{
if ($seq == null) {
return null;
}
list($cnt) = DB::fields("select count(*) from workflow_subflow where
reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 已回复明细
* @param null $seq 会签的序号
* @return integer
*/
public function getReplyDetail($seq = null)
{
if ($seq == null) {
return null;
}
$detail = DB::result("select * from workflow_subflow where
reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $detail;
}
/**
* 获取$parentKey 已经会签或拆分的次数
* @return integer
*/
private function _getSeq()
{
list($cnt) = DB::fields("select nvl(max(seq),-1)+1 from workflow_subflow where
parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 获取$parentKey已经会签或拆分的次数
* @return integer
*/
public static function getSeqByFormKey($formKey)
{
list($seq) = DB::fields("select seq from workflow_subflow where
form_key ='" . $formKey . "'");
return $seq;
}
/**
* 获取该节点
* @param $formKey
* @return integer
*/
public static function getCurrentParentFlowCode($formKey)
{
$flow = new Flow($formKey);
list($flow_code) = DB::fields("select flow_code from flow where
form_key ='" . $flow->getParentKey() . "'");
return $flow_code;
}
/**
* @param $formKey
* @param $flag REPLY_FLAG
*/
public static function updateReplyFlag($formKey, $flag)
{
$where = "form_key = '" . $formKey . "'";
DB::update_table("workflow_subflow", array(
"REPLY_FLAG" => "'" . $flag . "'"
), $where);
}
/**
*
* 获取会签中不同意的数量
* @param $seq
* @return null
*/
public function getRejectOpinionCount($seq)
{
if ($seq == null) {
return null;
}
$details = $this->getReplyDetail($seq);
$cnt = 0;
foreach ($details as $row) {
if ($row['reply_flag'] == 'N') {
$cnt++;
}
}
return $cnt;
}
/**
*
* 获取会签中不同意的数量
*/
public function getAcceptOpinionCount($seq)
{
if ($seq == null) {
return null;
}
$details = $this->getReplyDetail($seq);
$cnt = 0;
foreach ($details as $row) {
if ($row['reply_flag'] == 'Y') {
$cnt++;
}
}
return $cnt;
}
public static function updateReplyComment($formKey, $comment)
{
$where = "form_key = '" . $formKey . "'";
DB::update_table("workflow_subflow", array(
"REPLY_COMMENT" => "'" . $comment . "'"
), $where);
self::updateChangeDate($formKey);
}
public static function getReplyComment($formKey)
{
$detail = DB::result("select reply_comment from workflow_subflow where
form_key='" . $formKey . "'");
return $detail;
}
public static function getCounterSignComments($parentKey)
{
$sql = "select rownum seq ,seq CS_SEQ ,LEADER_NO ASSIGNER,reply_comment ASSIGN_OPINION ,change_date ASSIGN_DATE , LEAD_CODE,
f_return_content('lead_code',LEAD_CODE) POSITION_NAME,case Reply_flag when 'Y' then 'F1'
when 'N' then 'Y1' else 'A4' end ASSIGN_STATUS,'' FLOW_CODE from workflow_subflow a,employee b
where parent_key='" . $parentKey . "' and a.leader_no=b.employee_no";
return DB::result($sql);
}
public static function updateChangeDate($formKey)
{
$sql = "update workflow_subflow set change_date=sysdate where form_key='" . $formKey . "'";
DB::query($sql);
}
}
<?php
/***
* Class SubflowManager
* @desc 对workflow_sublow 新增查询操作
* @date 2018年8月5日11:42:58
* @author u73376@yuntay.com.cn
*/
class SubflowManager
{
private $parent_key;
private $seq = 0;
public function __construct(Flow $parentFlow = null)
{
if (!empty($parentFlow)) {
$this->parent_key = $parentFlow->getFormKey();
}
$this->seq = $this->_getSeq();
}
public function __toString()
{
return json_encode($this);
}
public static function getDetail($parentKey, $seq = 0)
{
$detail = DB::result("select * from workflow_subflow where
seq='" . $seq . "' and parent_key ='" . $parentKey . "'");
return $detail;
}
/**
* @desc workflow_sublow 新增一条记录
* @param Subflow $subflow
* @param $sender
* @param int $seq
*/
public function append(Subflow $subflow, $sender, $seq = null)
{
DB::query("insert into workflow_subflow (FORM_KEY, SEQ, PARENT_KEY, LEADER_NO, CREATE_DATE, SENDER)
values ('" . $subflow->getFormKey() . "',
'" . $this->seq . "',
'" . $this->parent_key . "',
'" . $subflow->current_assigner . "',
now(),
'" . $sender . "' ) ");
}
static function getChildNode($childFormKey)
{
$node = DB::result("select * from workflow_subflow where form_key
='" . $childFormKey . "'");
return $node[0];
}
/**
* 未回复统计
* @return integer|null
*/
public function getUnReplyCount($seq = null)
{
if ($seq == null) {
return null;
}
list($cnt) = DB::fields("select count(*) from workflow_subflow where
reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 未回复明细
* @return array|void
*/
public function getUnReplyDetail($seq = null)
{
if ($seq == null) {
return null;
}
list($detail) = DB::fields("select * from workflow_subflow where
reply_flag is null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $detail;
}
/**
* 已回复统计
* @param null $seq
* @return integer
*/
public function getReplyCount($seq = null)
{
if ($seq == null) {
return null;
}
list($cnt) = DB::fields("select count(*) from workflow_subflow where
reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 已回复明细
* @param null $seq 会签的序号
* @return integer
*/
public function getReplyDetail($seq = null)
{
if ($seq == null) {
return null;
}
$detail = DB::result("select * from workflow_subflow where
reply_flag is not null and seq='" . $seq . "' and parent_key ='" . $this->parent_key . "'");
return $detail;
}
/**
* 获取$parentKey 已经会签或拆分的次数
* @return integer
*/
private function _getSeq()
{
list($cnt) = DB::fields("select nvl(max(seq),-1)+1 from workflow_subflow where
parent_key ='" . $this->parent_key . "'");
return $cnt;
}
/**
* 获取$parentKey已经会签或拆分的次数
* @return integer
*/
public static function getSeqByFormKey($formKey)
{
list($seq) = DB::fields("select seq from workflow_subflow where
form_key ='" . $formKey . "'");
return $seq;
}
/**
* 获取该节点
* @param $formKey
* @return integer
*/
public static function getCurrentParentFlowCode($formKey)
{
$flow = new Flow($formKey);
list($flow_code) = DB::fields("select flow_code from flow where
form_key ='" . $flow->getParentKey() . "'");
return $flow_code;
}
/**
* @param $formKey
* @param $flag REPLY_FLAG
*/
public static function updateReplyFlag($formKey, $flag)
{
$where = "form_key = '" . $formKey . "'";
DB::update_table("workflow_subflow", array(
"REPLY_FLAG" => "'" . $flag . "'"
), $where);
}
/**
*
* 获取会签中不同意的数量
* @param $seq
* @return null
*/
public function getRejectOpinionCount($seq)
{
if ($seq == null) {
return null;
}
$details = $this->getReplyDetail($seq);
$cnt = 0;
foreach ($details as $row) {
if ($row['reply_flag'] == 'N') {
$cnt++;
}
}
return $cnt;
}
/**
*
* 获取会签中不同意的数量
*/
public function getAcceptOpinionCount($seq)
{
if ($seq == null) {
return null;
}
$details = $this->getReplyDetail($seq);
$cnt = 0;
foreach ($details as $row) {
if ($row['reply_flag'] == 'Y') {
$cnt++;
}
}
return $cnt;
}
public static function updateReplyComment($formKey, $comment)
{
$where = "form_key = '" . $formKey . "'";
DB::update_table("workflow_subflow", array(
"REPLY_COMMENT" => "'" . $comment . "'"
), $where);
self::updateChangeDate($formKey);
}
public static function getReplyComment($formKey)
{
$detail = DB::result("select reply_comment from workflow_subflow where
form_key='" . $formKey . "'");
return $detail;
}
public static function getCounterSignComments($parentKey)
{
$sql = "SELECT
rownum AS seq,
seq AS CS_SEQ,
LEADER_NO AS ASSIGNER,
reply_comment AS ASSIGN_OPINION,
change_date AS ASSIGN_DATE,
LEAD_CODE,
f_return_content('lead_code', LEAD_CODE) AS POSITION_NAME,
CASE Reply_flag
WHEN 'Y' THEN 'F1'
WHEN 'N' THEN 'Y1'
ELSE 'A4'
END AS ASSIGN_STATUS,
'' AS FLOW_CODE
FROM
workflow_subflow a,
employee b
WHERE
parent_key = '" . $parentKey . "' AND
a.leader_no = b.employee_no;";
return DB::result($sql);
}
public static function updateChangeDate($formKey)
{
$sql = "update workflow_subflow set change_date=sysdate where form_key='" . $formKey . "'";
DB::query($sql);
}
}

Loading…
Cancel
Save