From e3e2bc642d799c81d2d4ccec086be855930ab1db Mon Sep 17 00:00:00 2001 From: Cheng Date: Wed, 17 Jan 2024 17:42:52 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A5=91=E7=B4=84=E5=83=B9=E5=AF=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wms/crm/crmm05-edit.php | 520 ++++++++++---------- wms/crm/crmm06-edit.php | 5 +- wms/crm/crmm06_submit.php | 38 +- wms/crm/model/HopeContractCustomerModel.php | 69 +-- wms/crm/model/Model.php | 159 +++--- wms/fun_global.php | 32 +- workflow/lib/DB.php | 2 +- workflow/model/Subflow.php | 296 ++++++----- workflow/model/SubflowManager.php | 494 ++++++++++--------- 9 files changed, 819 insertions(+), 796 deletions(-) diff --git a/wms/crm/crmm05-edit.php b/wms/crm/crmm05-edit.php index 7dc2dde2..913d2dbe 100644 --- a/wms/crm/crmm05-edit.php +++ b/wms/crm/crmm05-edit.php @@ -1,264 +1,258 @@ - '是', '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 = " "; -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']); - // : ""; - $cmecRow .= "
$_input"; -} -$cmecRow .= ""; -*/ -#電梯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 = " "; -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']); - // : ""; - $hpeoRow .= "
$_input"; -} -$hpeoRow .= ""; - -*/ - -function base_url($url) -{ - return "https://www.masada.com.tw/static/" . $url; -} - - -?> - - - - - - - 有望客戶新增 - - - - - - - - - - - - - - - - - - -
- -
-
-
-
- - - ' /> - - -
-
-
-

有望客戶(契約)訂正

-
-
- -
-
- 有望客戶資料 -
-
- - "; - 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 " -
-
- "; - } - echo "
- " . $val['label'] . " -
-
- $_input -
- "; - } - echo "
"; - - ?> - -
-
- 洽商進度 -
-
- - -
-
- - -
- - - -
- - - -
- + '是', '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 = " "; +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']); + // : ""; + $cmecRow .= "
$_input"; +} +$cmecRow .= ""; +*/ +#電梯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 = " "; +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']); + // : ""; + $hpeoRow .= "
$_input"; +} +$hpeoRow .= ""; + +*/ + +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} + + +?> + + + + + + + 有望客戶新增 + + + + + + + + + + + + + + + + + + +
+ +
+
+
+
+ + + ' /> + + +
+
+
+

有望客戶(契約)訂正

+
+
+ +
+
+ 有望客戶資料 +
+
+ + "; + 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 " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+ + +
+ + + +
+ + + +
+ \ No newline at end of file diff --git a/wms/crm/crmm06-edit.php b/wms/crm/crmm06-edit.php index a8cdb8e1..dd2e4e68 100644 --- a/wms/crm/crmm06-edit.php +++ b/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 diff --git a/wms/crm/crmm06_submit.php b/wms/crm/crmm06_submit.php index 48fde4fc..6c8df61a 100644 --- a/wms/crm/crmm06_submit.php +++ b/wms/crm/crmm06_submit.php @@ -1,18 +1,20 @@ -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""; -header("Location:"."https://www.masada.com.tw/wms/crm/crmm02-index.php?token=".$request['token']); +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 ""; +header("Location:" . "https://www.masada.com.tw/wms/crm/crmm02-index.php?token=" . $request['token']); diff --git a/wms/crm/model/HopeContractCustomerModel.php b/wms/crm/model/HopeContractCustomerModel.php index 51918443..bc0d619e 100644 --- a/wms/crm/model/HopeContractCustomerModel.php +++ b/wms/crm/model/HopeContractCustomerModel.php @@ -1,34 +1,35 @@ -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 []; - } -} +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 []; + } +} diff --git a/wms/fun_global.php b/wms/fun_global.php index ef5159c7..3a0d9f1a 100644 --- a/wms/fun_global.php +++ b/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) +{ +} /** * 檢查使用者選單權限 * diff --git a/workflow/lib/DB.php b/workflow/lib/DB.php index ca316873..193f49cb 100644 --- a/workflow/lib/DB.php +++ b/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; /** diff --git a/workflow/model/Subflow.php b/workflow/model/Subflow.php index 5a6e8f72..c5ea199e 100644 --- a/workflow/model/Subflow.php +++ b/workflow/model/Subflow.php @@ -1,150 +1,146 @@ -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); - } -} - +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); + } +} diff --git a/workflow/model/SubflowManager.php b/workflow/model/SubflowManager.php index 619ce9d5..7acbf558 100644 --- a/workflow/model/SubflowManager.php +++ b/workflow/model/SubflowManager.php @@ -1,242 +1,252 @@ -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); - } - -} \ No newline at end of file +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); + } +}