diff --git a/wms/cont/apply_form.php b/wms/cont/apply_form.php index 34fb54a8..51e8e4f1 100644 --- a/wms/cont/apply_form.php +++ b/wms/cont/apply_form.php @@ -1,796 +1,918 @@ -0) { - echo""; - exit; -} -*/ - -#係統ID -$system_id = 'con'; -#流程ID -$flow_id = 'con01'; -#表單號 $form_id; -$form_id = ""; -#價審單狀態 -$apply_st = ""; -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"); - if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 - else $apply_st = 9; // 已到下一關,無法䖺改 -} - -if ($apply_st > 2) { - echo""; - exit; -} - -if ($apply_st==1) { - $wf = new WorkFlow($system_id, $flow_id, $form_id); - $wf->initWorkFlow($user_id); - $form_key = $wf->flowContext->getFormKey(); -} else { - $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); -} - -#獲取簽核意見 -$assign_opinions = Assign::get_records($form_key); - -#會簽部門意見 -$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); - -//預設冇有摺扣 -$wf->setFormData(['discount' => 100]); -$flowName = $wf->getFlowName(); -$assigner = $wf->getAssignerList(); -$assign_status = $wf->getAssignStatus($assigner); -$if_show_assign = true; -//加載流程圖 -//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); -//$path = $fc[0]->wf_file; -//echo dirname(__DIR__)."/../"."$path"; - -//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); -#是否可會簽 -$isSplitable = $wf->isSplitable(); - -//表單數據 -#客戶表 -#1.電梯品牌選項 -$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; -$elevator_brand_opt = DB::result($sql); -#2.保養方式 -$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; -$maintain_kind_opt = DB::result($sql); -#3.電梯類型 -$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; -$elevator_kind_opt = DB::result($sql); -#4.付款方式 -$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; -$payment_kind_opt = DB::result($sql); -#5.契約性質 -$sql = "select code_name value ,content label from code where field_name='contract_kind'"; -$contract_kind_opt = DB::result($sql); -#6.是否贈送M1 -$is_m1_bundle_opt = [ - ['label' => '是', 'value' => 'Y'], - ['label' => '否', 'value' => 'N'] - -]; -#7.機種 -$sql = "select code_name value ,content label from code where field_name='fp_kind'"; -$fp_kind_opt = DB::result($sql); -#抓取有望客戶資料 - - -$vol_no = $_GET['vol_no']; -$where = " and vol_no='$vol_no'"; -$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; -$hope_contract = DB::result($sql); -$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; -#寫入 con_maintance_examine_apply -if ($apply_st==1) { - #獲取評審單號 - $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); - //var_dump($hope_contract); - $insert_data = [ - 'apply_key' => $apply_key, - 'vol_no' => $vol_no, - 'form_key' => $form_key, - 'address' => $hope_contract['address'], - 'case_name' => $hope_contract['customer'], - 'num' => $hope_contract['num'], - 'brand' => '', - 'customer' => $hope_contract['customer'], - 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], - 'progress_remark' => $hope_contract['progress_status'] - //'platform_company'=>'', - // 'platforom_company_tel'=> '' - - ]; - //var_dump($insert_data); - DB::insert_table('con_maintance_examine_apply', $insert_data); -} - -$table = 'con_maintance_examine_apply'; -#可編輯的列 -$editableColumn = [ - 'apply_key' => [ - 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', - 'attr' => [ - 'readonly=true ', - 'class' => 'form-control form-control-sm' - ] - ], - 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], - 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], - 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], - 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], - 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - - 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], - -]; -$where = " and apply_key='$apply_key'"; - -$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; -$data = []; -$data = DB::result($sql); - -#電梯詳細資料 -$con_maintance_examine_clear_columm = [ - 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], - 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], - 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], - 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], - 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], - 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']], - 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - - 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], - 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], - 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', 'colspan' => 2, 'class' => 'form-control form-control-sm']], - - 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', 'colspan' => 2, 'class' => 'form-control form-control-sm ']], - - 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], - 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], - 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], - 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], '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, 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], - 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], - -]; -$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . - " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); -$j = 0; -$col_count = 12; -$cmecRow = " "; -foreach ($con_maintance_examine_clear_columm as $key => $val) { - $fieldVal = ""; - $_input = $val['tag'] == 'select' ? - FormHelper::select('', $val['options'], $fieldVal, $val['attr']) - : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); - // : ""; - $cmecRow .= "
$_input"; - if ((++$j % $col_count) == 0) { - if ($j == $col_count) $cmecRow .= ""; - $cmecRow .= ""; - } -} - - -$cmecRow .= ""; -function base_url($url) -{ - return "https://www.masada.com.tw/static/" . $url; -} -function get_sequnece_no($seq_name = '', $p_yyyymm = '') -{ - - if (empty($p_yyyymm) || empty($seq_name)) return null; - #當前年月 - list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); - if ($p_yyyymm != $yyyymm) { - DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); - } - // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; - list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); - - - return $seq_no; -} - - -?> - - - - - - - - - - - - - - - - - - -
- - - - -
- -
- -
-
- - - ' /> - - - -
-
-
-

保養契約價格審核單

-
-
- -
-
- 契約信息 -
-
- - "; - foreach ($editableColumn as $key => $val) { - $j = (($i++) % 4); - $fieldVal = empty($data) ? "" : $data[0][$key]; - - $_input = $val['tag'] == 'select' ? - FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) - : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); - //""; - if ($i != 1 && $j == 0) { - echo " -
-
- "; - } - echo "
- " . $val['label'] . " -
-
- $_input -
- "; - } - echo "
"; - - ?> - -
-
- 洽商進度 -
-
- - -
-
-
-
- 電梯詳細資料 -
- - - - - - - - - - - empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']); - //echo ""; - if ((++$j % $col_count) == 0) { - if ($j == $col_count) echo ""; - - - echo ""; - } - } - - - - - ?> - - - - - $val) { - $j = 0; - $cmecRow = " "; - 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 .= ""; - if ((++$j % $col_count) == 0) { - $cmecRow .= ""; - $cmecRow .= ""; - } - } - - - echo $cmecRow . ""; - } - ?> - -
- 註意事項: -

1.速度單位是 米/分.

-

2.選擇贈送M1,保養月數需填寫60.

-

3.標準價格未帶出,請聯係業務部建立該規格報價.

-

4.無機房速度20~60米 以60米為標準.

- - -
" . $val['label'] . "操作
- $_input
- -
- -
-
- 簽核操作 -
-
- -
-
-
-
- 簽核狀態 -
-
- -
- -
- 下位簽核者 -
-
- - -
-
-   - -
- -
-
-
- -
-
-
- - -
- -
- - - - ' . $wf->getNodeDescriptions($as['flow_code']) . ' -
'; - $tmp_code = $as['flow_code']; - ?> -
"> -
- - - - -   - " . $as['position_name'] . " "; ?> - - - - - - -   - 申請人 "; ?> - 退回"; ?> - 會簽"; ?> - - - - 簽核於: - - - -
-
- -
- -
- -
- - - -
-
- -
-
-
- - - -
- - - - - +0) { + echo""; + exit; +} +*/ + +#係統ID +$system_id = 'con'; +#流程ID +$flow_id = 'con01'; +#表單號 $form_id; +$form_id = ""; +#價審單狀態 +$apply_st = ""; +list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); +// echo '
';
+// print_r($apply_key);
+// echo '
'; +// exit; +// if ($salesman != $user_id) { +// echo ''; +// exit; +// } +if (empty($apply_key)) $apply_st = 1; // 準備新增 +else { + //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); + list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); + if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 + else $apply_st = 9; // 已到下一關,無法䖺改 +} + +// if ($apply_st > 2) { +// echo ""; +// exit; +// } + +if ($apply_st == 1) { + $wf = new WorkFlow($system_id, $flow_id, $form_id); + $wf->initWorkFlow($user_id); + $form_key = $wf->flowContext->getFormKey(); +} else { + $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); +} + +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); + +#會簽部門意見 +$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); + +//預設冇有摺扣 +$wf->setFormData(['discount' => 100]); +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); +$if_show_assign = true; +//加載流程圖 +//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); +//$path = $fc[0]->wf_file; +//echo dirname(__DIR__)."/../"."$path"; + +//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); +#是否可會簽 +$isSplitable = $wf->isSplitable(); + +//表單數據 +#客戶表 +#1.電梯品牌選項 +$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "select code_name value ,content label from code where field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] + +]; +#7.機種 +$sql = "select code_name value ,content label from code where field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +#抓取有望客戶資料 + +$vol_no = $_GET['vol_no']; +$where = " and vol_no='$vol_no'"; +$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; +$hope_contract = DB::result($sql); +$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; +#寫入 con_maintance_examine_apply +if ($apply_st == 1) { + #獲取評審單號 + $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); + //var_dump($hope_contract); + $insert_data = [ + 'apply_key' => $apply_key, + 'vol_no' => $vol_no, + 'form_key' => $form_key, + 'address' => $hope_contract['address'], + 'case_name' => $hope_contract['customer'], + 'num' => $hope_contract['num'], + 'brand' => '', + 'customer' => $hope_contract['customer'], + 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], + 'progress_remark' => $hope_contract['progress_status'] + //'platform_company'=>'', + // 'platforom_company_tel'=> '' + + ]; + //var_dump($insert_data); + DB::insert_table('con_maintance_examine_apply', $insert_data); +} +#抓使用者主管 +$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; +list($result) = DB::result($sql); +if ($result['department_id'] == '511') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '512') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '513') { + $managerid = 'M0086'; + $managername = '李烘銘'; +} else if ($result['department_id'] == '514') { + $managerid = 'M0033'; + $managername = '吳育宗'; +} + +if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} + +if ($result['department_id'] == 'M0008') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; +$data = []; +$data = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], + 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], + + 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], + + 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . + " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); +$j = 0; +$col_count = 12; +$cmecRow = " "; +foreach ($con_maintance_examine_clear_columm as $key => $val) { + $fieldVal = ""; + $_input = $val['tag'] == 'select' ? + FormHelper::select('', $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + // : ""; + $cmecRow .= "
$_input"; + if ((++$j % $col_count) == 0) { + if ($j == $col_count) $cmecRow .= ""; + $cmecRow .= ""; + } +} + + +$cmecRow .= ""; +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #當前年月 + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} + + +?> + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + + ' /> + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[0][$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+
+
+ 電梯詳細資料 +
+ + + + + + + + + + +
+ 註意事項: +

1.速度單位是 米/分.

+

2.選擇贈送M1,保養月數需填寫60.

+

3.標準價格未帶出,請聯係業務部建立該規格報價.

+

4.無機房速度20~60米 以60米為標準.

+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
電梯許可代碼品牌電梯類型規格型號載重(KG)速度(m/min)停數層數人乘保養次數保養月數保養周期贈送M1
+
+
+
+ +
+
+
+ +
+
+
+ +
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+
竣工檢查年度上次年檢日期年檢費用(元)標準價格(元/月)契約報價(元/月)契約成交價(元/月)刪除
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ +
+ +
+
+ 簽核操作 +
+
+ +
+
+
+
+ 簽核狀態 +
+
+ +
+ +
+ 下位簽核者 +
+
+ + +
+
+   + +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + + +
+ + + + + \ No newline at end of file diff --git a/wms/cont/apply_form3.php b/wms/cont/apply_form3.php new file mode 100644 index 00000000..39203cd3 --- /dev/null +++ b/wms/cont/apply_form3.php @@ -0,0 +1,829 @@ +0) { + echo""; + exit; +} +*/ + +#係統ID +$system_id = 'con'; +#流程ID +$flow_id = 'con01'; +#表單號 $form_id; +$form_id = ""; +#價審單狀態 +$apply_st = ""; +list($apply_key, $form_key, $salesman) = DB::fields("SELECT apply_key, form_key,salesman FROM con_maintance_examine_apply WHERE vol_no='$vol_no' ORDER BY apply_key desc limit 0, 1"); +// echo '
';
+// print_r($apply_key);
+// echo '
'; +// exit; +// if ($salesman != $user_id) { +// echo ''; +// exit; +// } +if (empty($apply_key)) $apply_st = 1; // 準備新增 +else { + //list($flow_code)=DB::fields("select flow_code from flow where form_key = '$form_key' and system_id = '$system_id' and flow_id = '$flow_id'"); + list($current_assigner) = DB::fields("SELECT current_assigner FROM subflow WHERE form_key = '$form_key' ORDER BY seq desc limit 0, 1"); + if ($current_assigner == $user_id) $apply_st = 2; // 修改中,還未提交 + else $apply_st = 9; // 已到下一關,無法䖺改 +} + +// if ($apply_st > 2) { +// echo ""; +// exit; +// } + +if ($apply_st == 1) { + $wf = new WorkFlow($system_id, $flow_id, $form_id); + $wf->initWorkFlow($user_id); + $form_key = $wf->flowContext->getFormKey(); +} else { + $wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key); +} + +#獲取簽核意見 +$assign_opinions = Assign::get_records($form_key); + +#會簽部門意見 +$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key); + +//預設冇有摺扣 +$wf->setFormData(['discount' => 100]); +$flowName = $wf->getFlowName(); +$assigner = $wf->getAssignerList(); +$assign_status = $wf->getAssignStatus($assigner); +$if_show_assign = true; +//加載流程圖 +//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID()); +//$path = $fc[0]->wf_file; +//echo dirname(__DIR__)."/../"."$path"; + +//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path); +#是否可會簽 +$isSplitable = $wf->isSplitable(); + +//表單數據 +#客戶表 +#1.電梯品牌選項 +$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc "; +$elevator_brand_opt = DB::result($sql); +#2.保養方式 +$sql = "select code_name value ,content label from code where field_name='maintain_kind'"; +$maintain_kind_opt = DB::result($sql); +#3.電梯類型 +$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'"; +$elevator_kind_opt = DB::result($sql); +#4.付款方式 +$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc"; +$payment_kind_opt = DB::result($sql); +#5.契約性質 +$sql = "select code_name value ,content label from code where field_name='contract_kind'"; +$contract_kind_opt = DB::result($sql); +#6.是否贈送M1 +$is_m1_bundle_opt = [ + ['label' => '是', 'value' => 'Y'], + ['label' => '否', 'value' => 'N'] + +]; +#7.機種 +$sql = "select code_name value ,content label from code where field_name='fp_kind'"; +$fp_kind_opt = DB::result($sql); +#抓取有望客戶資料 + +$vol_no = $_GET['vol_no']; +$where = " and vol_no='$vol_no'"; +$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no"; +$hope_contract = DB::result($sql); +$hope_contract = empty($hope_contract) ? [] : $hope_contract[0]; +#寫入 con_maintance_examine_apply +if ($apply_st == 1) { + #獲取評審單號 + $apply_key = get_sequnece_no('cmea_apply_key', date('ym')); + //var_dump($hope_contract); + $insert_data = [ + 'apply_key' => $apply_key, + 'vol_no' => $vol_no, + 'form_key' => $form_key, + 'address' => $hope_contract['address'], + 'case_name' => $hope_contract['customer'], + 'num' => $hope_contract['num'], + 'brand' => '', + 'customer' => $hope_contract['customer'], + 'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'], + 'progress_remark' => $hope_contract['progress_status'] + //'platform_company'=>'', + // 'platforom_company_tel'=> '' + + ]; + //var_dump($insert_data); + DB::insert_table('con_maintance_examine_apply', $insert_data); +} +#抓使用者主管 +$sql = "SELECT * FROM account WHERE accountid = '$user_id' "; +list($result) = DB::result($sql); +if ($result['department_id'] == '511') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '512') { + $managerid = 'M0137'; + $managername = '劉永德'; +} else if ($result['department_id'] == '513') { + $managerid = 'M0086'; + $managername = '李烘銘'; +} else if ($result['department_id'] == '514') { + $managerid = 'M0033'; + $managername = '吳育宗'; +} + +if ($result['department_id'] == 'M0137' || $result['department_id'] == 'M0086' || $result['department_id'] == 'M0033') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} + +if ($result['department_id'] == 'M0008') { + $managerid = 'M0008'; + $managername = '詹益彰'; +} +$table = 'con_maintance_examine_apply'; +#可編輯的列 +$editableColumn = [ + 'apply_key' => [ + 'label' => "評審單號", "value" => "$apply_key", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'num' => ['label' => "數量", "value" => "", "tag" => 'digits', 'attr' => ['required', 'min=1', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $maintain_kind_opt], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt], + 'introducer' => ['label' => "介紹人", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + + 'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +$where = " and apply_key='$apply_key'"; + +$sql = "SELECT * FROM $table where 1=1 $where ORDER BY vol_no"; +$data = []; +$data = DB::result($sql); + +#電梯詳細資料 +$con_maintance_examine_clear_columm = [ + 'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', 'required', 'class' => 'form-control form-control-sm']], + 'elevator_brand' => ['label' => "品牌", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'elevator_brand[]', 'class' => 'form-control form-control-sm'], 'options' => $elevator_brand_opt], + 'elevator_kind' => ['label' => "電梯類型", "value" => "", "tag" => 'select', 'attr' => ['name' => 'elevator_kind[]', 'required', 'colspan' => 2, 'class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt], + 'spec' => ['label' => "規格型號", "value" => "", "tag" => 'select', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm'], 'options' => $fp_kind_opt], + 'weight' => ['label' => "載重(KG)", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'weight[]', "placeholder" => "載重", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', "placeholder" => "速度", 'gt=0', 'min=0', 'required', 'class' => 'form-control form-control-sm']], + 'stop' => ['label' => "停數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', "placeholder" => "停數", 'class' => 'form-control form-control-sm']], + 'floors' => ['label' => "層數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'floors[]', 'min=1', 'required', "placeholder" => "層數", 'class' => 'form-control form-control-sm']], + 'persons' => ['label' => "人乘", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'persons[]', 'min=1', 'required', "placeholder" => "人乘", 'class' => 'form-control form-control-sm']], + + 'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_period[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'options' => $is_m1_bundle_opt], + 'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'digits', 'attr' => ['colspan' => 2, 'required', "placeholder" => "竣工檢查年度", 'gt=0', 'min=0', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']], + 'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'last_check_date[]', "placeholder" => "上次年檢日期", 'colspan' => 2, 'class' => 'form-control form-control-sm']], + + 'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', "placeholder" => "年檢費用", 'colspan' => 2, 'class' => 'form-control form-control-sm ']], + + 'maintain_times' => ['label' => "保養次數", "tag" => 'digits', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'register_code' => ['label' => "電梯許可證代碼", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', "placeholder" => "無證號請輸入A,B...", 'required', 'class' => 'form-control form-control-sm']], + 'maintain_months' => ['label' => "保養月數", "tag" => 'digits', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']], + 'maintain_period' => ['label' => "保養周期", "tag" => 'digits', 'attr' => ['name' => 'maintain_period[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']], + 'is_m1_bundle' => ['label' => "贈送M1", "value" => "", "tag" => 'select', 'attr' => ['name' => 'is_m1_bundle[]', 'required', 'class' => 'form-control form-control-sm'], 'option' => 'disable', 'options' => $is_m1_bundle_opt], + 'stand_price' => ['label' => "標準價格(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']], + 'contract_price' => ['label' => "契約報價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, "placeholder" => "契約報價", 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']], + 'sold_price' => ['label' => "契約成交價(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']], + +]; +$con_maintance_examine_clear = DB::result("SELECT " . implode(',', array_keys($con_maintance_examine_clear_columm)) . + " FROM con_maintance_examine_clear where 1=1 and apply_key='$apply_key' and cmstatus='Y' "); +$j = 0; +$col_count = 12; +$cmecRow = " "; +foreach ($con_maintance_examine_clear_columm as $key => $val) { + $fieldVal = ""; + $_input = $val['tag'] == 'select' ? + FormHelper::select('', $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + // : ""; + $cmecRow .= "
$_input"; + if ((++$j % $col_count) == 0) { + if ($j == $col_count) $cmecRow .= ""; + $cmecRow .= ""; + } +} + + +$cmecRow .= ""; +function base_url($url) +{ + return "https://www.masada.com.tw/static/" . $url; +} +function get_sequnece_no($seq_name = '', $p_yyyymm = '') +{ + + if (empty($p_yyyymm) || empty($seq_name)) return null; + #當前年月 + list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' "); + if ($p_yyyymm != $yyyymm) { + DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' "); + } + // echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no "; + list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no "); + + + return $seq_no; +} + + +?> + + + + + + + + + + + + + + + + + + +
+ + + + +
+ +
+ +
+
+ + + ' /> + + + +
+
+
+

保養契約價格審核單

+
+
+ +
+
+ 契約信息 +
+
+ + "; + foreach ($editableColumn as $key => $val) { + $j = (($i++) % 4); + $fieldVal = empty($data) ? "" : $data[0][$key]; + + $_input = $val['tag'] == 'select' ? + FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) + : FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']); + //""; + if ($i != 1 && $j == 0) { + echo " +
+
+ "; + } + echo "
+ " . $val['label'] . " +
+
+ $_input +
+ "; + } + echo "
"; + + ?> + +
+
+ 洽商進度 +
+
+ + +
+
+
+
+ 電梯詳細資料 +
+ + + + + + + + + + + empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']); + //echo ""; + if ((++$j % $col_count) == 0) { + if ($j == $col_count) echo ""; + + + echo ""; + } + } + + + + + ?> + + + + + $val) { + $j = 0; + $cmecRow = " "; + if ((++$j % $col_count) == 0) { + $cmecRow .= ""; + $cmecRow .= ""; + } + ?> + +
+ 註意事項: +

1.速度單位是 米/分.

+

2.選擇贈送M1,保養月數需填寫60.

+

3.標準價格未帶出,請聯係業務部建立該規格報價.

+

4.無機房速度20~60米 以60米為標準.

+ + +
" . $val['label'] . "操作
"; + 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 .= "
+ $_input
"; + } + } + + + echo $cmecRow . "
+ +
+ +
+
+ 簽核操作 +
+
+ +
+
+
+
+ 簽核狀態 +
+
+ +
+ +
+ 下位簽核者 +
+
+ + +
+
+   + +
+ +
+
+
+ +
+
+
+ + +
+ +
+ + + + ' . $wf->getNodeDescriptions($as['flow_code']) . ' +
'; + $tmp_code = $as['flow_code']; + ?> +
"> +
+ + + + +   + " . $as['position_name'] . " "; ?> + + + + + + +   + 申請人 "; ?> + 退回"; ?> + 會簽"; ?> + + + + 簽核於: + + + +
+
+ +
+ +
+ +
+ + + +
+
+ +
+
+
+ + + +
+ + + + + + \ No newline at end of file diff --git a/wms/cont/sign_list.php b/wms/cont/sign_list.php index 0d942a5e..89ef2af7 100644 --- a/wms/cont/sign_list.php +++ b/wms/cont/sign_list.php @@ -1,157 +1,159 @@ - [ - 'label' => "評審單號", "value" => "", "tag" => 'text', - 'attr' => [ - 'readonly=true ', - 'class' => 'form-control form-control-sm' - ] - ], - 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], - 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], - 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], - 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], - 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], - 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], - //'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], - -]; -// 設置一個空陣列來放資料 -$data = array(); - -$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; -//$where = " and salesman like '%'"; -$where = " and salesman = '$salesman'"; - -// 可瀏覽全部資料的部門 -$depart_arr = ["220"]; -$sql = "select department_id from account where accountid = '$user_id'"; -$res = mysqli_query($link, $sql); -$row = mysqli_fetch_row($res); -$user_department_id = $row[0]; -mysqli_free_result($res); -if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006") $where = ""; - -// 電梯廠牌 -$elevator_brand_arr = []; -$sql = "select code_name ,content from code where field_name='elevator_brand'"; -$res = mysqli_query($link, $sql); -while ($row = mysqli_fetch_row($res)) { - $elevator_brand_arr[$row[0]] = $row[1]; -} -mysqli_free_result($res); - -$sql = "SELECT - apply_key, - vol_no, - address, -case_name, -brand , -num , -f_return_name(salesman) salesman, -f_return_content('maintain_kind',maintain_kind ) maintain_kind, -date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, -date_format(contract_end_date,'%Y/%m/%d') contract_end_date , -f_return_content('contract_kind',contract_kind ) contract_kind, -platform_company, -platforom_company_tel, -form_key, - -f_return_content('payment_kind',payment_kind ) payment_kind FROM $table - where 1=1 $where ORDER BY vol_no"; - -$data = mysqli_query($link, $sql); -?> - -Please fill up the required field!

"; - } else { - header("Location:repair-index.php"); - } - } - -?> - - -
-
- - - - - - - - -
-

(契約)價審單查詢

-
- - - "; - foreach ($editableColumn as $key => $val) { - - echo ""; - } - echo ""; - // echo ""; - echo ""; - ?> - - - - - $val) { - if ( $key =='apply_key') { - echo ""; - } elseif ($key == 'brand') { - echo ""; - } else { - echo ""; - } - } - //list($signer)=DB::fields("); -//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ." - list($signer)=mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='". $row['form_key'] ."'" )); - - echo ""; - - ?> - - - - -
".$val['label']."是否結案刪除
" . $row[$key] . "" . (!empty($row[$key])?$elevator_brand_arr[$row[$key]]:"") . "" . $row[$key] . "" .(empty($signer)?"結案":"N") . "
-
- -There is no record!"; -endif; - -#代表結束連線 -mysqli_close($link); - -include "../footer.php"; - + [ + 'label' => "評審單號", "value" => "", "tag" => 'text', + 'attr' => [ + 'readonly=true ', + 'class' => 'form-control form-control-sm' + ] + ], + 'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']], + 'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']], + 'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], + 'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']], + 'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']], + 'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + 'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']], + //'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt], + +]; +// 設置一個空陣列來放資料 +$data = array(); + +$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman']; +//$where = " and salesman like '%'"; +$where = " and salesman = '$salesman'"; + +// 可瀏覽全部資料的部門 +$depart_arr = ["220"]; +$sql = "select department_id from account where accountid = '$user_id'"; +$res = mysqli_query($link, $sql); +$row = mysqli_fetch_row($res); +$user_department_id = $row[0]; +mysqli_free_result($res); +if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006") $where = ""; + +// 電梯廠牌 +$elevator_brand_arr = []; +$sql = "select code_name ,content from code where field_name='elevator_brand'"; +$res = mysqli_query($link, $sql); +while ($row = mysqli_fetch_row($res)) { + $elevator_brand_arr[$row[0]] = $row[1]; +} +mysqli_free_result($res); + +$sql = "SELECT + apply_key, + vol_no, + address, +case_name, +brand , +num , +f_return_name(salesman) salesman, +f_return_content('maintain_kind',maintain_kind ) maintain_kind, +date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date, +date_format(contract_end_date,'%Y/%m/%d') contract_end_date , +f_return_content('contract_kind',contract_kind ) contract_kind, +platform_company, +platforom_company_tel, +form_key, + +f_return_content('payment_kind',payment_kind ) payment_kind FROM $table + where 1=1 $where ORDER BY vol_no"; +// echo $sql; +$data = mysqli_query($link, $sql); +// echo '
';
+// print_r($data);
+// echo '
'; +?> + +Please fill up the required field!

"; + } else { + header("Location:repair-index.php"); + } + } + +?> + + +
+ + + + + + + + + +
+

(契約)價審單查詢

+
+ + + "; + foreach ($editableColumn as $key => $val) { + + echo ""; + } + echo ""; + // echo ""; + echo ""; + ?> + + + + + $val) { + if ($key == 'apply_key') { + echo ""; + } elseif ($key == 'brand') { + echo ""; + } else { + echo ""; + } + } + //list($signer)=DB::fields("); + //echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ." + list($signer) = mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='" . $row['form_key'] . "'")); + + echo ""; + + ?> + + + + +
" . $val['label'] . "是否結案刪除
" . $row[$key] . "" . (!empty($row[$key]) ? $elevator_brand_arr[$row[$key]] : "") . "" . $row[$key] . "" . (empty($signer) ? "結案" : "N") . "
+
+ +There is no record!"; +endif; + +#代表結束連線 +mysqli_close($link); + +include "../footer.php"; + ?> \ No newline at end of file diff --git a/wms/contract-repair/api/postContractData.php b/wms/contract-repair/api/postContractData.php index b82a8cf2..b4815669 100644 --- a/wms/contract-repair/api/postContractData.php +++ b/wms/contract-repair/api/postContractData.php @@ -323,6 +323,8 @@ if (isset($_POST["contractno"]) && $_POST["contractno"] != "" && isset($_POST['c /// 時間 : ////////////////////////////// if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['contracttype']) && $_POST['contracttype'] == 'r') { + // echo $_POST; + // exit; try { $created_at = date('Y-m-d H:i:s'); $contractno = !empty($_POST['contractno']) ? $_POST['contractno'] : null; @@ -337,7 +339,7 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c $user_id = !empty($_POST['user_id']) ? $_POST['user_id'] : null; $type = !empty($_POST['type']) ? $_POST['type'] : null; $sign_date = !empty($_POST['sign_date']) ? $_POST['sign_date'] : null; - $contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : null; + $contract_status = !empty($_POST['contract_status']) ? $_POST['contract_status'] : 1; $fail_arr = []; @@ -400,7 +402,7 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c $stmt->bindParam(":address", $address); $stmt->bindParam(":type", $type); $stmt->bindParam(":invoice", $invoice); - $stmt->bindParam(":repaireid", $repaireid); + $stmt->bindParam(":repaireid", $repairid); $stmt->bindParam(":total_price", $total_price); $stmt->bindParam(":sign_date", $sign_date); $stmt->bindParam(":contract_status", $contract_status); @@ -414,6 +416,7 @@ if (isset($_POST['contractno']) && $_POST['contractno'] != "" && isset($_POST['c $conn->commit(); } catch (PDOException $e) { $conn->rollback(); + header("HTTP/1.1 422 Unprocessable Entity"); echo $e->getMessage(); die('Error!' . $e->getMessage()); } diff --git a/wms/contract-repair/contract-repair-edit.php b/wms/contract-repair/contract-repair-edit.php index fdd86381..c1b940e9 100644 --- a/wms/contract-repair/contract-repair-edit.php +++ b/wms/contract-repair/contract-repair-edit.php @@ -2,14 +2,17 @@ include("../header.php"); require_once("./conn.php"); $id = $_GET['contractid']; -$sql_str = "SELECT * FROM contract_r_signed_back WHERE id = :id ORDER BY id DESC"; +$sql_str = "SELECT a.*,b.name FROM contract_r_signed_back AS a LEFT JOIN account AS b ON a.repaireid = b.accountid + WHERE a.id = :id ORDER BY id DESC"; $stmt = $conn->prepare($sql_str); $stmt->bindParam(':id', $id); $stmt->execute(); $contract = $stmt->fetch(PDO::FETCH_ASSOC); + // echo '
';
-// print_r($contract);
+// print_r($contract['contract_status'] + 1);
 // echo '
'; + // $files_id = $contract['files_id']; // $sql_str = "SELECT * FROM contract_back_files WHERE files_id = :files_id "; // $stmt = $conn->prepare($sql_str); @@ -40,6 +43,7 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修 + @@ -78,7 +82,7 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修 維保人員 $status) : ?> - +

未填寫

diff --git a/wms/contract-repair/contract-repair-input.php b/wms/contract-repair/contract-repair-input.php index 7de93f97..12bb9fd4 100644 --- a/wms/contract-repair/contract-repair-input.php +++ b/wms/contract-repair/contract-repair-input.php @@ -14,7 +14,13 @@ $stmt = $conn->prepare($sql_str); $stmt->bindParam(':accounttype', $accounttype); $stmt->execute(); $contractpersons = $stmt->fetchAll(PDO::FETCH_ASSOC); - +$persons = array_map(function ($person) { + return [ + 'view' => $person['accountid'] . '-' . $person['name'], + 'value' => $person['accountid'], + 'name' => $person['name'] + ]; +}, $contractpersons); $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修理完成"]; ?> @@ -73,9 +79,14 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修

未填寫

維保人員 - - -

未填寫

+ + +

未填寫

電梯編號 @@ -121,11 +132,12 @@ $contract_stauts = ["合約簽回", "採購", "工程發包", "工程中", "修 工程確認 - +

未填寫

diff --git a/wms/contract-repair/js/alpine.js b/wms/contract-repair/js/alpine.js index 0d53a94a..d6108f6e 100644 --- a/wms/contract-repair/js/alpine.js +++ b/wms/contract-repair/js/alpine.js @@ -943,7 +943,7 @@ const contractRepair = () => { contractno: '', company: '', repairer: '', - repairid: '', + repaireid: '', facilityno: '', taxid: '', invoice: '', //發票抬頭 @@ -993,8 +993,9 @@ const contractRepair = () => { this.data.address = res.data.address; this.data.repair_no = res.data.repair_no; this.data.total_price = res.data.total_price; - this.data.repairid = res.data.accountid; + this.data.repaireid = res.data.accountid; this.data.sign_date = res.data.sign_date; + this.data.contract_status = res.data.contract_status; } this.step = 2; this.isLoading = false; @@ -1019,8 +1020,9 @@ const contractRepair = () => { this.data.address = ''; this.data.repair_no = ''; this.data.total_price = ''; - this.data.repairid = ''; + this.data.repaireid = ''; this.data.sign_date = ''; + this.data.contract_status = ''; return; } @@ -1031,7 +1033,7 @@ const contractRepair = () => { const form = new FormData(); form.append('contractno', this.data.contractno); form.append('company', this.data.company); - form.append('repairid', this.data.repairid); + form.append('repairid', this.data.repaireid); form.append('facilityno', this.data.facilityno); form.append('taxid', this.data.taxid); form.append('invoice', this.data.invoice); @@ -1050,7 +1052,7 @@ const contractRepair = () => { this.step = 1; this.data.contractno = ''; this.data.company = ''; - this.data.repairid = ''; + this.data.repaireid = ''; this.data.facilityno = ''; this.data.repairer = ''; this.data.taxid = ''; @@ -1069,6 +1071,7 @@ const contractRepair = () => { if (code == 422) { this.fail_arr = error.response.data; this.errorFn(); + console.log(error.response.data); } if (code == 500) { alert('儲存失敗!可能為以下錯誤:\n' + error.response.data); diff --git a/wms/contract/api/postContractData.php b/wms/contract/api/postContractData.php index 69e7d859..349557ee 100644 --- a/wms/contract/api/postContractData.php +++ b/wms/contract/api/postContractData.php @@ -1,319 +1,317 @@ - 0) { - header("HTTP/1.1 422 Unprocessable Entity"); - echo json_encode($fail_arr); - exit(); - } - - //create account table - $accounttype = "A"; - $accountid = $vat; - $pwd = "123"; - $name = $partyA; - $tel = $phone ?? ''; - $repairerid = $mworker; - $creater = $user_id; - $create_at = date('Y-m-d H:i:s'); - - $conn->beginTransaction(); - - $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(':accounttype' ,$accounttype); - $stmt -> bindParam(':accountid' ,$accountid); - $stmt -> bindParam(':pwd' ,$pwd); - $stmt -> bindParam(':name' ,$name); - $stmt -> bindParam(':tel' ,$tel); - $stmt -> bindParam(':address' ,$address); - $stmt -> bindParam(':email' ,$email); - $stmt -> bindParam(':repairerid' ,$repairerid); - $stmt -> bindParam(':creater' ,$creater); - $stmt -> bindParam(':create_at' ,$create_at); - $stmt -> execute(); - - //create contract table - - $contracttype = $mtype; - $company = $partyA; - $taxid = $vat; - $tel = $phone; - $promiser = $partyA; - $contractperson = $partyA; - - $contractaddress = $address; - $contracttel = $phone; - $contractemail = $email; - $contract_employee = $salesman; - $start_date = $contract_begin_date; - $end_date = $contract_end_date; - - $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(':contracttype' ,$contracttype); - $stmt -> bindParam(':contractno' ,$contractno); - $stmt -> bindParam(':company' ,$company); - $stmt -> bindParam(':taxid' ,$taxid); - $stmt -> bindParam(':address' ,$address); - $stmt -> bindParam(':tel' ,$tel); - $stmt -> bindParam(':promiser' ,$promiser); - $stmt -> bindParam(':contractperson' ,$contractperson); - $stmt -> bindParam(':contractaddress' ,$contractaddress); - $stmt -> bindParam(':contracttel' ,$contracttel); - $stmt -> bindParam(':contractemail' ,$contractemail); - $stmt -> bindParam(':contract_employee' ,$contract_employee); - $stmt -> bindParam(':start_date' ,$start_date); - $stmt -> bindParam(':end_date' ,$end_date); - $stmt -> bindParam(':creater' ,$creater); - $stmt -> bindParam(':create_at' ,$create_at); - $stmt -> execute(); - - //create facility table - $createFacilityNo = new CreateFacilityNo(); - $dailyNecessities = [ - 'MAE100'=>'X', - 'MAM200'=>'W', - 'MAH100'=>'H', - 'MAQ100'=>'Z', - 'MAF100'=>'F', - 'MAZ100'=>'B', - ]; - $facility_arr = []; - foreach($elevators as $elevator){ - $facility_arr[] = $dailyNecessities[$elevator['spec']]; - } - echo json_encode($facility_arr); - $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); - echo json_encode($facilityno); - echo '-------'; - $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; - $stmt = $conn->prepare($sql_str); - $stmt->bindParam(':accountid',$mworker); - $stmt->execute(); - $worker = $stmt->fetch(PDO::FETCH_ASSOC); - $customerid = $vat; - $define = "B"; - $repairtype = $mtype; - $repairerid = $mworker; - $repairername = $worker['name']; - foreach($elevators as $idx=>$elevator){ - $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) - VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(':contractno' ,$contractno); - $stmt -> bindParam(':define' ,$define); - $stmt -> bindParam(':facilityno' ,$facilityno[$idx]); - $stmt -> bindParam(':latitude' ,$elevator['latitude']); - $stmt -> bindParam(':longitude' ,$elevator['longitude']); - $stmt -> bindParam(':customerid' ,$customerid); - $stmt -> bindParam(':weight' ,$elevator['weight']); - $stmt -> bindParam(':numberofpassenger' ,$elevator['persons']); - $stmt -> bindParam(':numberofstop' ,$elevator['stop']); - $stmt -> bindParam(':numberoffloor' ,$elevator['floors']); - $stmt -> bindParam(':opentype' ,$elevator['opendoor']); - $stmt -> bindParam(':speed' ,$elevator['speed']); - $stmt -> bindParam(':repairtype' ,$repairtype); - $stmt -> bindParam(':maintainance' ,$elevator['maintainance']); - $stmt -> bindParam(':facility_kind' ,$elevator['spec']); - $stmt -> bindParam(':address' ,$address); - $stmt -> bindParam(':repairerid' ,$repairerid); - $stmt -> bindParam(':repairername' ,$repairername); - $stmt -> bindParam(':creater' ,$creater); - $stmt -> bindParam(':create_at' ,$create_at); - $stmt -> bindParam(':area' ,$area); - $stmt -> bindParam(':takecertificatedate' ,$elevator['takecertificatedate']); - $stmt -> bindParam(':licensedate' ,$elevator['useful_date']); - $result = $stmt -> execute(); - } - - //create schedule table - - $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); - $comboArr = json_decode($comboNo->getComboNo(), true); - foreach($facilityno as $no){ - foreach($comboArr as $combo){ - $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(':contractno' ,$contractno); - $stmt -> bindParam(':facilityno' ,$no); - $stmt -> bindParam(':combono' ,$combo[0]); - $stmt -> bindParam(':repairerid' ,$repairerid); - $stmt -> bindParam(':repairername' ,$repairername); - $stmt -> bindParam(':duedate' ,$combo[1]); - $stmt -> bindParam(':creater' ,$creater); - $stmt -> bindParam(':create_at' ,$create_at); - $result = $stmt -> execute(); - } - } - // create contract_b_signed_back table - $contract_type = $mtype; - $company = $customer; - $customer_no = $vat; - $salesperson = $salesman; - $customer_phone = $phone; - $customer_email = $email; - $repairman = $mworker; - $cycle = $mcycle; - $contact_person = $partyA; - $contact_address = $partyAaddress; - $contact_phone = $partyAphone; - $contract_email = $partyAemail; - $elevators_number = $num; - $bonus = 1000; - $max_bonus = 2000; - - if(!empty($files)){ - $englisharr = range('a', 'z'); - $file = $_FILES['files']; - $file_name = $file['name']; - $file_type = $file['type']; - $tmp_name = $file['tmp_name']; - $file_size = $file['size']; - $error = $file['error']; - $newfiles = []; - foreach( $files as $file ){ - $i = 0; //新陣列的索引編號 - foreach( $file as $key => $val ){ - $newfiles[$i]['name'] = $files['name'][$key]; - $newfiles[$i]['type'] = $files['type'][$key]; - $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; - $newfiles[$i]['error'] = $files['error'][$key]; - $newfiles[$i]['size'] = $files['size'][$key]; - $i++; - } //foreach 第2層 end - } - $max_size = 4096*4096; //設定允許上傳檔案容量的最大值(1M) - $allow_ext = array('jpeg', 'jpg', 'png','JPG','JPEG','PNG','GIF'); //設定允許上傳檔案的類型 - $path = '../images/contracts/'; - if (!file_exists($path)) { mkdir($path); } - $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 - $datetime = (string)date('YmdHis'); - $files_id = 'b' . $datetime; // 保養=>b + 日期時間 - foreach( $newfiles as $key => $file ){ - $randNum = rand(1000,9999); - $randEnglish = $englisharr[rand(0,25)]; - $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum.$file['name']; - $msg = upload_chk( $file,$path, $max_size, $allow_ext, $file_name ); - if($msg==1){ - $msg = '檔案傳送成功!'; - $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(':files_id' ,$files_id); - $stmt -> bindParam(':file_name' ,$file_name); - $stmt -> bindParam(':file_mime' ,$file['type']); - $stmt -> bindParam(':file_size' ,$file['size']); - $stmt -> bindParam(':created_at' ,$created_at); - $stmt -> bindParam(':created_by' ,$user_id); - $stmt ->execute(); - } - $msg_result .= '第' . ($key+1) . '個上傳檔案的結果:' . $msg . '
'; - $src_name = $path.$file['name']; - if( file_exists($src_name) ){ - //副檔名 - $extname = pathinfo($src_name, PATHINFO_EXTENSION); - //主檔名 - $basename = basename($src_name, '.'.$extname); - } - - } - }else{ - $files = null; - } - $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) - VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; - $stmt = $conn -> prepare($sql_str); - $stmt -> bindParam(":contract_no",$contractno); - $stmt -> bindParam(":contract_type",$contract_type); - $stmt -> bindParam(":company",$company); - $stmt -> bindParam(":customer_no",$customer_no); - $stmt -> bindParam(":salesperson",$salesperson); - $stmt -> bindParam(":contract_start_date",$contract_begin_date); - $stmt -> bindParam(":contract_end_date",$contract_end_date); - $stmt -> bindParam(":total_price",$total_price); - $stmt -> bindParam(":customer_phone",$customer_phone); - $stmt -> bindParam(":customer_email",$customer_email); - $stmt -> bindParam(":repairman",$repairman); - $stmt -> bindParam(":cycle",$cycle); - $stmt -> bindParam(":contact_person",$contact_person); - $stmt -> bindParam(":contact_address",$contact_address); - $stmt -> bindParam(":contact_phone",$contact_phone); - $stmt -> bindParam(":contact_email",$contact_email); - $stmt -> bindParam(":elevators_number",$elevators_number); - $stmt -> bindParam(":area",$area); - $stmt -> bindParam(":address",$address); - $stmt -> bindParam(":files_id",$files_id); - $stmt -> bindParam(":bonus",$bonus); - $stmt -> bindParam(":max_bonus",$max_bonus); - $stmt -> bindParam(":created_at", $created_at); - $stmt -> bindParam(":created_by",$user_id); - - $stmt -> execute(); - - header('Content-Type: application/json'); - $jsonData = json_encode($files); - - $conn->commit(); - }catch(PDOException $e){ - $conn->rollback(); - echo $e->getMessage(); - die('Error!:'.$e->getMessage()); - } -} - - - - + 0) { + header("HTTP/1.1 422 Unprocessable Entity"); + echo json_encode($fail_arr); + exit(); + } + + //create account table + $accounttype = "A"; + $accountid = $vat; + $pwd = "123"; + $name = $partyA; + $tel = $phone ?? ''; + $repairerid = $mworker; + $creater = $user_id; + $create_at = date('Y-m-d H:i:s'); + + $conn->beginTransaction(); + + $sql_str = "INSERT INTO account (accounttype, accountid, pwd, name, tel, address, email, repairerid, creater, create_at) VALUES (:accounttype, :accountid, :pwd, :name, :tel, :address, :email, :repairerid, :creater, :create_at)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':accounttype', $accounttype); + $stmt->bindParam(':accountid', $accountid); + $stmt->bindParam(':pwd', $pwd); + $stmt->bindParam(':name', $name); + $stmt->bindParam(':tel', $tel); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':email', $email); + $stmt->bindParam(':repairerid', $repairerid); + $stmt->bindParam(':creater', $creater); + $stmt->bindParam(':create_at', $create_at); + $stmt->execute(); + + //create contract table + + $contracttype = $mtype; + $company = $partyA; + $taxid = $vat; + $tel = $phone; + $promiser = $partyA; + $contractperson = $partyA; + + $contractaddress = $address; + $contracttel = $phone; + $contractemail = $email; + $contract_employee = $salesman; + $start_date = $contract_begin_date; + $end_date = $contract_end_date; + + $sql_str = "INSERT INTO contract (contracttype, contractno, company, taxid, address, tel, promiser, contractperson, contractaddress, contracttel, contractemail, contract_employee, start_date, end_date, creater, create_at) VALUES (:contracttype, :contractno, :company, :taxid, :address, :tel, :promiser, :contractperson, :contractaddress, :contracttel, :contractemail, :contract_employee, :start_date, :end_date, :creater, :create_at)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':contracttype', $contracttype); + $stmt->bindParam(':contractno', $contractno); + $stmt->bindParam(':company', $company); + $stmt->bindParam(':taxid', $taxid); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':tel', $tel); + $stmt->bindParam(':promiser', $promiser); + $stmt->bindParam(':contractperson', $contractperson); + $stmt->bindParam(':contractaddress', $contractaddress); + $stmt->bindParam(':contracttel', $contracttel); + $stmt->bindParam(':contractemail', $contractemail); + $stmt->bindParam(':contract_employee', $contract_employee); + $stmt->bindParam(':start_date', $start_date); + $stmt->bindParam(':end_date', $end_date); + $stmt->bindParam(':creater', $creater); + $stmt->bindParam(':create_at', $create_at); + $stmt->execute(); + + //create facility table + $createFacilityNo = new CreateFacilityNo(); + $dailyNecessities = [ + 'MAE100' => 'X', + 'MAM200' => 'W', + 'MAH100' => 'H', + 'MAQ100' => 'Z', + 'MAF100' => 'F', + 'MAZ100' => 'B', + ]; + $facility_arr = []; + foreach ($elevators as $elevator) { + $facility_arr[] = $dailyNecessities[$elevator['spec']]; + } + echo json_encode($facility_arr); + $facilityno = $createFacilityNo->makeBFacilityNo("T", $facility_arr, (int)$num); + echo json_encode($facilityno); + echo '-------'; + $sql_str = "SELECT accountid, name FROM account WHERE accountid = :accountid"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':accountid', $mworker); + $stmt->execute(); + $worker = $stmt->fetch(PDO::FETCH_ASSOC); + $customerid = $vat; + $define = "B"; + $repairtype = $mtype; + $repairerid = $mworker; + $repairername = $worker['name']; + foreach ($elevators as $idx => $elevator) { + $sql_str = "INSERT INTO facility (contractno, define, facilityno, latitude, longitude, customerid, weight, numberofpassenger, numberofstop, numberoffloor, opentype, speed, repairtype, maintainance, facility_kind, address, repairerid, repairername, creater, create_at, area, takecertificatedate, licensedate) + VALUES (:contractno, :define, :facilityno, :latitude, :longitude, :customerid, :weight, :numberofpassenger, :numberofstop, :numberoffloor, :opentype, :speed, :repairtype, :maintainance, :facility_kind, :address, :repairerid, :repairername, :creater, :create_at, :area, :takecertificatedate, :licensedate)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':contractno', $contractno); + $stmt->bindParam(':define', $define); + $stmt->bindParam(':facilityno', $facilityno[$idx]); + $stmt->bindParam(':latitude', $elevator['latitude']); + $stmt->bindParam(':longitude', $elevator['longitude']); + $stmt->bindParam(':customerid', $customerid); + $stmt->bindParam(':weight', $elevator['weight']); + $stmt->bindParam(':numberofpassenger', $elevator['persons']); + $stmt->bindParam(':numberofstop', $elevator['stop']); + $stmt->bindParam(':numberoffloor', $elevator['floors']); + $stmt->bindParam(':opentype', $elevator['opendoor']); + $stmt->bindParam(':speed', $elevator['speed']); + $stmt->bindParam(':repairtype', $repairtype); + $stmt->bindParam(':maintainance', $elevator['maintainance']); + $stmt->bindParam(':facility_kind', $elevator['spec']); + $stmt->bindParam(':address', $address); + $stmt->bindParam(':repairerid', $repairerid); + $stmt->bindParam(':repairername', $repairername); + $stmt->bindParam(':creater', $creater); + $stmt->bindParam(':create_at', $create_at); + $stmt->bindParam(':area', $area); + $stmt->bindParam(':takecertificatedate', $elevator['takecertificatedate']); + $stmt->bindParam(':licensedate', $elevator['useful_date']); + $result = $stmt->execute(); + } + + //create schedule table + + $comboNo = new CreateComboNo($mcycle, $contract_begin_date, $contract_end_date); + $comboArr = json_decode($comboNo->getComboNo(), true); + foreach ($facilityno as $no) { + foreach ($comboArr as $combo) { + $sql_str = 'INSERT INTO schedule (contractno, facilityno, combono, repairerid, repairername, duedate, creater, create_at) VALUES (:contractno, :facilityno, :combono, :repairerid, :repairername, :duedate, :creater, :create_at)'; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':contractno', $contractno); + $stmt->bindParam(':facilityno', $no); + $stmt->bindParam(':combono', $combo[0]); + $stmt->bindParam(':repairerid', $repairerid); + $stmt->bindParam(':repairername', $repairername); + $stmt->bindParam(':duedate', $combo[1]); + $stmt->bindParam(':creater', $creater); + $stmt->bindParam(':create_at', $create_at); + $result = $stmt->execute(); + } + } + // create contract_b_signed_back table + $contract_type = $mtype; + $company = $customer; + $customer_no = $vat; + $salesperson = $salesman; + $customer_phone = $phone; + $customer_email = $email; + $repairman = $mworker; + $cycle = $mcycle; + $contact_person = $partyA; + $contact_address = $partyAaddress; + $contact_phone = $partyAphone; + $contract_email = $partyAemail; + $elevators_number = $num; + $bonus = 1000; + $max_bonus = 2000; + + if (!empty($files)) { + $englisharr = range('a', 'z'); + $file = $_FILES['files']; + $file_name = $file['name']; + $file_type = $file['type']; + $tmp_name = $file['tmp_name']; + $file_size = $file['size']; + $error = $file['error']; + $newfiles = []; + foreach ($files as $file) { + $i = 0; //新陣列的索引編號 + foreach ($file as $key => $val) { + $newfiles[$i]['name'] = $files['name'][$key]; + $newfiles[$i]['type'] = $files['type'][$key]; + $newfiles[$i]['tmp_name'] = $files['tmp_name'][$key]; + $newfiles[$i]['error'] = $files['error'][$key]; + $newfiles[$i]['size'] = $files['size'][$key]; + $i++; + } //foreach 第2層 end + } + $max_size = 4096 * 4096; //設定允許上傳檔案容量的最大值(1M) + $allow_ext = array('jpeg', 'jpg', 'png', 'JPG', 'JPEG', 'PNG', 'GIF'); //設定允許上傳檔案的類型 + $path = '../images/contracts/'; + if (!file_exists($path)) { + mkdir($path); + } + $msg_result = ''; //負責接收所有檔案檢測後的回傳訊息 + $datetime = (string)date('YmdHis'); + $files_id = 'b' . $datetime; // 保養=>b + 日期時間 + foreach ($newfiles as $key => $file) { + $randNum = rand(1000, 9999); + $randEnglish = $englisharr[rand(0, 25)]; + $file_name = 'b' . (string)date('YmdHis') . $randNum . $randEnglish . $randNum . $file['name']; + $msg = upload_chk($file, $path, $max_size, $allow_ext, $file_name); + if ($msg == 1) { + $msg = '檔案傳送成功!'; + $sql_str = "INSERT INTO contract_back_files (files_id, file_name, file_mime, file_size, created_at, created_by) VALUES (:files_id, :file_name, :file_mime, :file_size, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(':files_id', $files_id); + $stmt->bindParam(':file_name', $file_name); + $stmt->bindParam(':file_mime', $file['type']); + $stmt->bindParam(':file_size', $file['size']); + $stmt->bindParam(':created_at', $created_at); + $stmt->bindParam(':created_by', $user_id); + $stmt->execute(); + } + $msg_result .= '第' . ($key + 1) . '個上傳檔案的結果:' . $msg . '
'; + $src_name = $path . $file['name']; + if (file_exists($src_name)) { + //副檔名 + $extname = pathinfo($src_name, PATHINFO_EXTENSION); + //主檔名 + $basename = basename($src_name, '.' . $extname); + } + } + } else { + $files = null; + } + $sql_str = "INSERT INTO contract_b_signed_back (contract_no, contract_type, company, customer_no, salesperson, contract_start_date, contract_end_date, total_price, customer_phone, customer_email, repairman, cycle, contact_person, contact_address, contact_phone, contact_email, elevators_number, area, address, files_id, bonus, max_bonus, created_at, created_by) + VALUES (:contract_no, :contract_type, :company, :customer_no, :salesperson, :contract_start_date, :contract_end_date, :total_price, :customer_phone, :customer_email, :repairman, :cycle, :contact_person, :contact_address, :contact_phone, :contact_email, :elevators_number, :area, :address, :files_id, :bonus, :max_bonus, :created_at, :created_by)"; + $stmt = $conn->prepare($sql_str); + $stmt->bindParam(":contract_no", $contractno); + $stmt->bindParam(":contract_type", $contract_type); + $stmt->bindParam(":company", $company); + $stmt->bindParam(":customer_no", $customer_no); + $stmt->bindParam(":salesperson", $salesperson); + $stmt->bindParam(":contract_start_date", $contract_begin_date); + $stmt->bindParam(":contract_end_date", $contract_end_date); + $stmt->bindParam(":total_price", $total_price); + $stmt->bindParam(":customer_phone", $customer_phone); + $stmt->bindParam(":customer_email", $customer_email); + $stmt->bindParam(":repairman", $repairman); + $stmt->bindParam(":cycle", $cycle); + $stmt->bindParam(":contact_person", $contact_person); + $stmt->bindParam(":contact_address", $contact_address); + $stmt->bindParam(":contact_phone", $contact_phone); + $stmt->bindParam(":contact_email", $contact_email); + $stmt->bindParam(":elevators_number", $elevators_number); + $stmt->bindParam(":area", $area); + $stmt->bindParam(":address", $address); + $stmt->bindParam(":files_id", $files_id); + $stmt->bindParam(":bonus", $bonus); + $stmt->bindParam(":max_bonus", $max_bonus); + $stmt->bindParam(":created_at", $created_at); + $stmt->bindParam(":created_by", $user_id); + + $stmt->execute(); + + header('Content-Type: application/json'); + $jsonData = json_encode($files); + + $conn->commit(); + } catch (PDOException $e) { + $conn->rollback(); + http_response_code(404); + echo $e->getMessage(); + die('Error!:' . $e->getMessage()); + } +} diff --git a/wms/contract/option/option.xlsx b/wms/contract/option/option.xlsx new file mode 100644 index 00000000..36c0cece Binary files /dev/null and b/wms/contract/option/option.xlsx differ diff --git a/wms/contract/option/option1.xlsx b/wms/contract/option/option1.xlsx new file mode 100644 index 00000000..4a197ec5 Binary files /dev/null and b/wms/contract/option/option1.xlsx differ diff --git a/wms/contract/option/option10.xlsx b/wms/contract/option/option10.xlsx new file mode 100644 index 00000000..4087ccf5 Binary files /dev/null and b/wms/contract/option/option10.xlsx differ diff --git a/wms/contract/option/option11.xlsx b/wms/contract/option/option11.xlsx new file mode 100644 index 00000000..9dc16b7e Binary files /dev/null and b/wms/contract/option/option11.xlsx differ diff --git a/wms/contract/option/option1127/option.xlsx b/wms/contract/option/option1127/option.xlsx new file mode 100644 index 00000000..36c0cece Binary files /dev/null and b/wms/contract/option/option1127/option.xlsx differ diff --git a/wms/contract/option/option1127/option1.xlsx b/wms/contract/option/option1127/option1.xlsx new file mode 100644 index 00000000..4a197ec5 Binary files /dev/null and b/wms/contract/option/option1127/option1.xlsx differ diff --git a/wms/contract/option/option1127/option10.xlsx b/wms/contract/option/option1127/option10.xlsx new file mode 100644 index 00000000..4087ccf5 Binary files /dev/null and b/wms/contract/option/option1127/option10.xlsx differ diff --git a/wms/contract/option/option1127/option11.xlsx b/wms/contract/option/option1127/option11.xlsx new file mode 100644 index 00000000..9dc16b7e Binary files /dev/null and b/wms/contract/option/option1127/option11.xlsx differ diff --git a/wms/contract/option/option1127/option12.xlsx b/wms/contract/option/option1127/option12.xlsx new file mode 100644 index 00000000..1f57b701 Binary files /dev/null and b/wms/contract/option/option1127/option12.xlsx differ diff --git a/wms/contract/option/option1127/option13.xlsx b/wms/contract/option/option1127/option13.xlsx new file mode 100644 index 00000000..df84bbc7 Binary files /dev/null and b/wms/contract/option/option1127/option13.xlsx differ diff --git a/wms/contract/option/option1127/option14.xlsx b/wms/contract/option/option1127/option14.xlsx new file mode 100644 index 00000000..a36ca847 Binary files /dev/null and b/wms/contract/option/option1127/option14.xlsx differ diff --git a/wms/contract/option/option1127/option15.xlsx b/wms/contract/option/option1127/option15.xlsx new file mode 100644 index 00000000..7ef897bc Binary files /dev/null and b/wms/contract/option/option1127/option15.xlsx differ diff --git a/wms/contract/option/option1127/option16.xlsx b/wms/contract/option/option1127/option16.xlsx new file mode 100644 index 00000000..8e6bce19 Binary files /dev/null and b/wms/contract/option/option1127/option16.xlsx differ diff --git a/wms/contract/option/option1127/option2.xlsx b/wms/contract/option/option1127/option2.xlsx new file mode 100644 index 00000000..17daba20 Binary files /dev/null and b/wms/contract/option/option1127/option2.xlsx differ diff --git a/wms/contract/option/option1127/option20.xlsx b/wms/contract/option/option1127/option20.xlsx new file mode 100644 index 00000000..e2422b5d Binary files /dev/null and b/wms/contract/option/option1127/option20.xlsx differ diff --git a/wms/contract/option/option1127/option3.xlsx b/wms/contract/option/option1127/option3.xlsx new file mode 100644 index 00000000..5c39ee18 Binary files /dev/null and b/wms/contract/option/option1127/option3.xlsx differ diff --git a/wms/contract/option/option1127/option4.xlsx b/wms/contract/option/option1127/option4.xlsx new file mode 100644 index 00000000..c44f5df5 Binary files /dev/null and b/wms/contract/option/option1127/option4.xlsx differ diff --git a/wms/contract/option/option1127/option5.xlsx b/wms/contract/option/option1127/option5.xlsx new file mode 100644 index 00000000..170ca69c Binary files /dev/null and b/wms/contract/option/option1127/option5.xlsx differ diff --git a/wms/contract/option/option1127/option6.xlsx b/wms/contract/option/option1127/option6.xlsx new file mode 100644 index 00000000..68f18ef9 Binary files /dev/null and b/wms/contract/option/option1127/option6.xlsx differ diff --git a/wms/contract/option/option1127/option7.xlsx b/wms/contract/option/option1127/option7.xlsx new file mode 100644 index 00000000..ee4d39eb Binary files /dev/null and b/wms/contract/option/option1127/option7.xlsx differ diff --git a/wms/contract/option/option1127/option8.xlsx b/wms/contract/option/option1127/option8.xlsx new file mode 100644 index 00000000..5f431522 Binary files /dev/null and b/wms/contract/option/option1127/option8.xlsx differ diff --git a/wms/contract/option/option1127/option9.xlsx b/wms/contract/option/option1127/option9.xlsx new file mode 100644 index 00000000..90616cc0 Binary files /dev/null and b/wms/contract/option/option1127/option9.xlsx differ diff --git a/wms/contract/option/option12.xlsx b/wms/contract/option/option12.xlsx new file mode 100644 index 00000000..1f57b701 Binary files /dev/null and b/wms/contract/option/option12.xlsx differ diff --git a/wms/contract/option/option13.xlsx b/wms/contract/option/option13.xlsx new file mode 100644 index 00000000..df84bbc7 Binary files /dev/null and b/wms/contract/option/option13.xlsx differ diff --git a/wms/contract/option/option14.xlsx b/wms/contract/option/option14.xlsx new file mode 100644 index 00000000..a36ca847 Binary files /dev/null and b/wms/contract/option/option14.xlsx differ diff --git a/wms/contract/option/option15.xlsx b/wms/contract/option/option15.xlsx new file mode 100644 index 00000000..7ef897bc Binary files /dev/null and b/wms/contract/option/option15.xlsx differ diff --git a/wms/contract/option/option16.xlsx b/wms/contract/option/option16.xlsx new file mode 100644 index 00000000..8e6bce19 Binary files /dev/null and b/wms/contract/option/option16.xlsx differ diff --git a/wms/contract/option/option2.xlsx b/wms/contract/option/option2.xlsx new file mode 100644 index 00000000..17daba20 Binary files /dev/null and b/wms/contract/option/option2.xlsx differ diff --git a/wms/contract/option/option20.xlsx b/wms/contract/option/option20.xlsx new file mode 100644 index 00000000..e2422b5d Binary files /dev/null and b/wms/contract/option/option20.xlsx differ diff --git a/wms/contract/option/option3.xlsx b/wms/contract/option/option3.xlsx new file mode 100644 index 00000000..5c39ee18 Binary files /dev/null and b/wms/contract/option/option3.xlsx differ diff --git a/wms/contract/option/option4.xlsx b/wms/contract/option/option4.xlsx new file mode 100644 index 00000000..c44f5df5 Binary files /dev/null and b/wms/contract/option/option4.xlsx differ diff --git a/wms/contract/option/option5.xlsx b/wms/contract/option/option5.xlsx new file mode 100644 index 00000000..170ca69c Binary files /dev/null and b/wms/contract/option/option5.xlsx differ diff --git a/wms/contract/option/option6.xlsx b/wms/contract/option/option6.xlsx new file mode 100644 index 00000000..68f18ef9 Binary files /dev/null and b/wms/contract/option/option6.xlsx differ diff --git a/wms/contract/option/option7.xlsx b/wms/contract/option/option7.xlsx new file mode 100644 index 00000000..ee4d39eb Binary files /dev/null and b/wms/contract/option/option7.xlsx differ diff --git a/wms/contract/option/option8.xlsx b/wms/contract/option/option8.xlsx new file mode 100644 index 00000000..5f431522 Binary files /dev/null and b/wms/contract/option/option8.xlsx differ diff --git a/wms/contract/option/option9.xlsx b/wms/contract/option/option9.xlsx new file mode 100644 index 00000000..90616cc0 Binary files /dev/null and b/wms/contract/option/option9.xlsx differ diff --git a/wms/crm/crmm02-index.php b/wms/crm/crmm02-index.php index 671b7b2f..e076ba54 100644 --- a/wms/crm/crmm02-index.php +++ b/wms/crm/crmm02-index.php @@ -1,172 +1,180 @@ - "卷號", - 'customer_no' => "客戶編號", - 'customer' => "客戶名稱", - 'manager' => "負責人", - 'source' => "客戶來源", - 'linkman' => "聯係人", - 'lm_tel' => "手機", - 'salesman' => "營業員", - 'num' => "数量", - 'pre_order_date' => "預定成交日", - 'status' => "有望客戶狀態", - 'next_visit_date' => "下次拜訪時間", - 'brand' => "廠牌", - 'quote_date' => "報價日期", - 'created_at' => "建立時間", - -]; - -// 可瀏覽全部資料的部門 -$depart_arr = ["501"]; -$sql = "select department_id from account where accountid = '$user_id'"; -$res = mysqli_query($link, $sql); -$row = mysqli_fetch_row($res); -$user_department_id = $row[0]; -mysqli_free_result($res); - -// 設置一個空陣列來放資料 -$data = array(); -// sql語法存在變數中 -$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; -$where = " and vol_no like '$vol_no'"; -$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; -$where .= " and salesman like '$salesman'"; -$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; -$where .= " and linkman like '$lm_name'"; -$sql_cmd = sql_myself($user_id, "salesman"); -if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149") $sql_cmd = ""; // M0060:Max,鄭伊岑 -if (!empty($sql_cmd)) $where .= " and ".str_replace("where", "", $sql_cmd); - -$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source, -linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, - f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , - date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; -#echo $sql; -$data = mysqli_query($link, $sql); -?> - - -Please fill up the required field!

"; - } else { - header("Location:repair-index.php"); - } - } - -?> - - -
- - - - - - - - - - - - - - - - - - - '> - - - - - - - -
-

有望客戶(契約)資料維護

-
卷號營業員下單地區聯係人姓名
- - 新增 -
- - - "; - foreach ($editableColumn as $key => $val) { - echo ""; - } - echo ""; - // echo ""; - echo ""; - ?> - - - - - $val) { - echo ""; - } - ?> - - - - -
$val編輯刪除
" . (!empty($row[$key]) ? $row[$key] : '') . " -

- - - - - - 轉價審 - -

-
-
- -There is no record!"; -endif; - -#代錶結束連線 -mysqli_close($link); - -include "../footer.php"; - + "卷號", + 'customer_no' => "客戶編號", + 'customer' => "客戶名稱", + 'manager' => "負責人", + 'source' => "客戶來源", + 'linkman' => "聯係人", + 'lm_tel' => "手機", + 'salesman' => "營業員", + 'num' => "数量", + 'pre_order_date' => "預定成交日", + 'status' => "有望客戶狀態", + 'next_visit_date' => "下次拜訪時間", + 'brand' => "廠牌", + 'quote_date' => "報價日期", + 'created_at' => "建立時間", + +]; + +// 可瀏覽全部資料的部門 +$depart_arr = ["501"]; +$sql = "SELECT department_id FROM account WHERE accountid = '$user_id'"; +$res = mysqli_query($link, $sql); +$row = mysqli_fetch_row($res); +$user_department_id = $row[0]; +mysqli_free_result($res); + +// 設置一個空陣列來放資料 +$data = array(); +// sql語法存在變數中 +$vol_no = empty($_GET['vol_no']) ? "%" : $_GET['vol_no']; +$where = " and vol_no like '$vol_no'"; +$salesman = empty($_GET['salesman']) ? "%" : $_GET['salesman']; +$where .= " and salesman like '$salesman'"; +$lm_name = empty($_GET['linkman']) ? "%" : $_GET['linkman']; +$where .= " and linkman like '$lm_name'"; +$sql_cmd = sql_myself($user_id, "salesman"); +if (in_array($user_department_id, $depart_arr) || $user_id == "M0060" || $user_id == "M0149") $sql_cmd = ""; // M0060:Max,鄭伊岑 +if (!empty($sql_cmd)) $where .= " and " . str_replace("where", "", $sql_cmd); + +$sql = "SELECT vol_no,customer,manager,f_return_content('customer_source',source ) source, +linkman,lm_tel,f_return_name(salesman) salesman,num ,date_format(pre_order_date,'%Y/%m/%d') pre_order_date, + f_return_content('hope_customer_status',status ) status, date_format(next_visit_date,'%Y/%m/%d') next_visit_date ,brand , + date_format(quote_date,'%Y/%m/%d') quote_date, created_at FROM $table where 1=1 $where ORDER BY vol_no"; + +$data = mysqli_query($link, $sql); + +echo '
';
+print_r($data);
+echo '
'; +?> + + +Please fill up the required field!

"; + } else { + header("Location:repair-index.php"); + } + } + +?> + + +
+ + + + + + + + + + + + + + + + + + + '> + + + + + + + +
+

有望客戶(契約)資料維護

+
卷號營業員下單地區聯係人姓名
+ + 新增 +
+ + + "; + foreach ($editableColumn as $key => $val) { + echo ""; + } + echo ""; + // echo ""; + echo ""; + ?> + + + + + $val) { + echo ""; + } + ?> + + + + +
$val編輯刪除
" . (!empty($row[$key]) ? $row[$key] : '') . " +

+ + + + + + 轉價審 + +

+
+
+ +There is no record!"; +endif; + +#代錶結束連線 +mysqli_close($link); + +include "../footer.php"; + ?> \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-edit.php b/wms/mkt/pricereview_renovate-edit.php index b78b4679..36a3080c 100644 --- a/wms/mkt/pricereview_renovate-edit.php +++ b/wms/mkt/pricereview_renovate-edit.php @@ -1,2044 +1,2211 @@ - 0) { - echo ""; - exit; -} - -$data = $item_arr = $option_arr = $mn_arr = $ex_arr = $demolition_arr = $pay_arr = array(); - -$db_query = "select * from pricereview_main where id = '$id' and creater = '$user_id'"; -$res = mysqli_query($link, $db_query); -foreach ($res as $data) { - $data["qty_total"] = 0; - $db_query = "select * from pricereview_item where mid = '$id' order by item_group, item_no"; - $res_i = mysqli_query($link, $db_query); - while ($row = mysqli_fetch_assoc($res_i)) { - if ($row['item_group'] == "A") { - $item_arr[$row['item_no']]['id'] = $row['id']; - $item_arr[$row['item_no']]['fp_id'] = $row['price_id']; - $item_arr[$row['item_no']]['item_op'] = $row['item_op']; - $item_arr[$row['item_no']]['item_weight'] = $row['item_weight']; - $item_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $item_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $item_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $item_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $item_arr[$row['item_no']]['item_price_ct'] = $row['item_price_ct']; - $item_arr[$row['item_no']]['item_price'] = $row['item_price']; - $item_arr[$row['item_no']]['pv_rate'] = $row['pv_rate']; - $item_arr[$row['item_no']]['allocate'] = $row['allocate']; - $item_arr[$row['item_no']]['gross_profit'] = $row['gross_profit']; - $item_arr[$row['item_no']]['gross_profit_rate'] = $row['gross_profit_rate']; - $item_arr[$row['item_no']]['note'] = $row['note']; - $item_arr[$row['item_no']]['mi_fix'] = $row['mi_fix']; - $data["qty_total"] += $row["item_qty"]; - } elseif ($row['item_group'] == "B") { - $option_arr[$row['item_no']]['id'] = $row['id']; - $option_arr[$row['item_no']]['op_id'] = $row['price_id']; - $option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $option_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; - $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $option_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $option_arr[$row['item_no']]['memo'] = $row['memo']; - } elseif ($row['item_group'] == "D") { - $mn_arr[$row['item_no']]['id'] = $row['id']; - $mn_arr[$row['item_no']]['mn_id'] = $row['price_id']; - $mn_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $mn_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; - $mn_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $mn_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $mn_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $mn_arr[$row['item_no']]['note'] = $row['note']; - $mn_arr[$row['item_no']]['memo'] = $row['memo']; - } elseif ($row['item_group'] == "E") { - $ex_arr[$row['item_no']]['id'] = $row['id']; - $ex_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $ex_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $ex_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $ex_arr[$row['item_no']]['note'] = $row['note']; // 詢價單號 - } elseif ($row['item_group'] == "C") { - $demolition_arr[$row['item_no']]['id'] = $row['id']; - $demolition_arr[$row['item_no']]['dem_id'] = $row['price_id']; - $demolition_arr[$row['item_no']]['item_spec'] = $row['item_spec']; - $demolition_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; - $demolition_arr[$row['item_no']]['item_qty'] = $row['item_qty']; - $demolition_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; - $demolition_arr[$row['item_no']]['note'] = $row['note']; // 樓層 - } - } - mysqli_free_result($res_i); - - // 付款辦法 - $pay_all_scale = $pay_all_amount = 0; - $sql = "select * from pricereview_pay where mid = '$id' order by pay_kind"; - $res_p = mysqli_query($link, $sql); - while ($row_p = mysqli_fetch_assoc($res_p)) { - $pay_arr[$row_p["pay_kind"]]["id"] = $row_p["id"]; - $pay_arr[$row_p["pay_kind"]]["pay_scale"] = $row_p["pay_scale"]; - $pay_arr[$row_p["pay_kind"]]["pay_amount"] = $row_p["pay_amount"]; - $pay_arr[$row_p["pay_kind"]]["pay_period"] = $row_p["pay_period"]; - $pay_arr[$row_p["pay_kind"]]["pay_note"] = $row_p["pay_note"]; - $pay_all_scale += $row_p["pay_scale"]; - $pay_all_amount += $row_p["pay_amount"]; - } - mysqli_free_result($res_p); - - // Option Data - $opt_data_arr = []; - $opt_kind_arr = ["A" => "小電梯型錄選配加價報價", "B" => "客梯型錄選配加價報價", "C" => "550-1600kg選配業務報價", "D" => "其它"]; - $sql = "select * from option_price where status = 'Y' order by kind, id"; - $res = mysqli_query($link, $sql); - while ($row = mysqli_fetch_assoc($res)) { - $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["spec"] = $row["spec"]; - $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["memo"] = $row["memo"]; - $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["optional"] = $row["optional"]; - $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["unit"] = $row["unit"]; - $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["price"] = $row["price"]; - } - mysqli_free_result($res); - $option_str = ''; - $option_str .= ' - - - - - - - - '; - foreach ($opt_data_arr as $k => $v) { - //$option_str .= ''; - foreach ($v as $k2 => $v2) { - foreach ($v2 as $k3 => $v3) { - if ($v3["optional"] == "1") $optional = "標"; - elseif ($v3["optional"] == "2") $optional = "選"; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - } - } - /* - $group_nums = count($v2); - $i = 1; - foreach ($v2 as $k3 => $v3) { - if ($v3["optional"] == "1") $optional = "標"; - elseif ($v3["optional"] == "2") $optional = "選"; - $option_str .= ""; - if ($i==1) { - $option_str .= ''; - } else { - $option_str .= ''; - } - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $option_str .= ""; - $i++; - } - */ - } - $option_str .= "
名稱規格備註配置單位定價
'.$opt_kind_arr[$k].'
".$k2."".$v3["spec"]."".$v3["memo"]."".$optional."".$v3["unit"]."".number_format($v3["price"])."
'.$k2.''.$k2.'".$v3["spec"]."".$v3["memo"]."".$optional."".$v3["unit"]."".number_format($v3["price"])."
"; -?> - - - -
- -
- -
- -
- - - - - - - -
- -
- - - - - - - - - - - - - - - - - - - - - 0) { - foreach ($item_arr as $item_no => $v) { - if (!empty($v["note"])) list($spec, $seat, $stop, $speed) = explode(",", $v["note"]); - else $spec = $seat = $floor = $speed = ""; - ?> - - - - - - - - - - - - - - - - - - -
整機單價
電梯人乘/載重停數速度開門方式規格單價數量複價售價
- - - - - - - - - - - - - " readonly>" required> - - - - - - - - X -
小計
-
-
-
- - - - - - - - - - - - - - - - - 0) { - foreach ($option_arr as $item_no => $v) { - ?> - - - - - - - - - - - - - - - - - - - - - - - - - -
OPTION加價
選配規格單價數量複價備註
所屬電梯 - - - - -
功能
- - " readonly >">" readonly> - - - - - - "; - } - } - } - ?> - 電梯 - X -
- 點選 - - - - - - 電梯 - X -
小計
-
-
-
- - - - - - - - - - - - - - - 0) { - foreach ($ex_arr as $item_no => $v) { - ?> - - - - - - - - - - - - - - - - - - - - - -
除外項目
詢價單號名稱單價數量複價
">">">">">" readonly> - - - - X -
- - - X -
小計
-
-
-
- - - - - - - - - - - - - - - - - - - - 0) { - foreach ($mn_arr as $item_no => $v) { - if (!empty($v["note"])) list($seat, $stop, $speed) = explode(",", $v["note"]); - else $seat = $stop = $speed = ""; - ?> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
保固延長
電梯人乘/載重停數速度單價數量(月)複價備註所屬電梯功能
- - - - - - - - " readonly>">" readonly> - - - - - - "; - } - } - } - ?> - 電梯 - X -
- - - - - - - - - - - - 電梯 - X -
小計
-
- -
- -
- - - - - - - - - - - - - - - 0) { - foreach ($demolition_arr as $item_no => $v) { - if (!empty($v["note"])) $floor = $v["note"]; - else $floor = ""; - ?> - - - - - - - - - - - - - - - - - - - - - -
拆梯價格
人乘/載重樓層單價數量複價
- - - - " readonly>">" readonly> - - - - X -
- - - - - - - - X -
小計
-
- -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
付款辦法款別比例%金額票期
材料1、訂金">" readonly> - - -
2、二次款">" readonly> - - -
3、貨到工地款">" readonly> - - -
4、其它">" readonly> - - -
安裝5、安裝完畢款">" readonly> - - -
6、驗收款">" readonly> - - -
7、其它">" readonly> - - -
合計
備註
-
- -
-
- - " readonly> -
-
- - " required> - "> -
-
- - " readonly> -
-
- - -
-
- - -
-
- - "> -
-
- - -
-
-
- " required> -
-
-
- " required> -
-
-
- - "> -
-
- - "> -
-
- - "> -
-
- - "> -
- -
- -
- - - - - - - - - - - -
-
- - -
- - ".substr($data["attatch1"], strrpos($data["attatch1"],"/")+1)." "; - echo 'X'; - } - ?> -
- X -
- - ".substr($data["attatch2"], strrpos($data["attatch2"],"/")+1)." "; - echo 'X'; - } - ?> -
- X -

-   - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - 0) { + echo ""; + exit; +} + +$data = $item_arr = $option_arr = $mn_arr = $ex_arr = $demolition_arr = $pay_arr = array(); + +$db_query = "select * from pricereview_main where id = '$id' and creater = '$user_id'"; +$res = mysqli_query($link, $db_query); +foreach ($res as $data) { + $data["qty_total"] = 0; + $db_query = "select * from pricereview_item where mid = '$id' order by item_group, item_no"; + $res_i = mysqli_query($link, $db_query); + while ($row = mysqli_fetch_assoc($res_i)) { + if ($row['item_group'] == "A") { + $item_arr[$row['item_no']]['id'] = $row['id']; + $item_arr[$row['item_no']]['fp_id'] = $row['price_id']; + $item_arr[$row['item_no']]['item_op'] = $row['item_op']; + $item_arr[$row['item_no']]['item_weight'] = $row['item_weight']; + $item_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $item_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $item_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $item_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $item_arr[$row['item_no']]['item_price_ct'] = $row['item_price_ct']; + $item_arr[$row['item_no']]['item_price'] = $row['item_price']; + $item_arr[$row['item_no']]['pv_rate'] = $row['pv_rate']; + $item_arr[$row['item_no']]['allocate'] = $row['allocate']; + $item_arr[$row['item_no']]['gross_profit'] = $row['gross_profit']; + $item_arr[$row['item_no']]['gross_profit_rate'] = $row['gross_profit_rate']; + $item_arr[$row['item_no']]['note'] = $row['note']; + $item_arr[$row['item_no']]['mi_fix'] = $row['mi_fix']; + $data["qty_total"] += $row["item_qty"]; + } elseif ($row['item_group'] == "B") { + $option_arr[$row['item_no']]['id'] = $row['id']; + $option_arr[$row['item_no']]['op_id'] = $row['price_id']; + $option_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $option_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; + $option_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $option_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $option_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $option_arr[$row['item_no']]['memo'] = $row['memo']; + } elseif ($row['item_group'] == "D") { + $mn_arr[$row['item_no']]['id'] = $row['id']; + $mn_arr[$row['item_no']]['mn_id'] = $row['price_id']; + $mn_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $mn_arr[$row['item_no']]['option_relate_spec'] = $row['option_relate_spec']; + $mn_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $mn_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $mn_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $mn_arr[$row['item_no']]['note'] = $row['note']; + $mn_arr[$row['item_no']]['memo'] = $row['memo']; + } elseif ($row['item_group'] == "E") { + $ex_arr[$row['item_no']]['id'] = $row['id']; + $ex_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $ex_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $ex_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $ex_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $ex_arr[$row['item_no']]['note'] = $row['note']; // 詢價單號 + } elseif ($row['item_group'] == "C") { + $demolition_arr[$row['item_no']]['id'] = $row['id']; + $demolition_arr[$row['item_no']]['dem_id'] = $row['price_id']; + $demolition_arr[$row['item_no']]['item_spec'] = $row['item_spec']; + $demolition_arr[$row['item_no']]['item_unit_price'] = $row['item_unit_price']; + $demolition_arr[$row['item_no']]['item_qty'] = $row['item_qty']; + $demolition_arr[$row['item_no']]['item_price_bp'] = $row['item_price_bp']; + $demolition_arr[$row['item_no']]['note'] = $row['note']; // 樓層 + } + } + mysqli_free_result($res_i); + + // 付款辦法 + $pay_all_scale = $pay_all_amount = 0; + $sql = "select * from pricereview_pay where mid = '$id' order by pay_kind"; + $res_p = mysqli_query($link, $sql); + while ($row_p = mysqli_fetch_assoc($res_p)) { + $pay_arr[$row_p["pay_kind"]]["id"] = $row_p["id"]; + $pay_arr[$row_p["pay_kind"]]["pay_scale"] = $row_p["pay_scale"]; + $pay_arr[$row_p["pay_kind"]]["pay_amount"] = $row_p["pay_amount"]; + $pay_arr[$row_p["pay_kind"]]["pay_period"] = $row_p["pay_period"]; + $pay_arr[$row_p["pay_kind"]]["pay_note"] = $row_p["pay_note"]; + $pay_all_scale += $row_p["pay_scale"]; + $pay_all_amount += $row_p["pay_amount"]; + } + mysqli_free_result($res_p); + + // Option Data + $opt_data_arr = []; + $opt_kind_arr = ["A" => "小電梯型錄選配加價報價", "B" => "客梯型錄選配加價報價", "C" => "550-1600kg選配業務報價", "D" => "其它"]; + $sql = "select * from option_price where status = 'Y' order by kind, id"; + $res = mysqli_query($link, $sql); + while ($row = mysqli_fetch_assoc($res)) { + $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["spec"] = $row["spec"]; + $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["memo"] = $row["memo"]; + $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["optional"] = $row["optional"]; + $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["unit"] = $row["unit"]; + $opt_data_arr[$row["kind"]][$row["group_name"]][$row["id"]]["price"] = $row["price"]; + } + mysqli_free_result($res); + $option_str = ''; + $option_str .= ' + + + + + + + + '; + foreach ($opt_data_arr as $k => $v) { + //$option_str .= ''; + foreach ($v as $k2 => $v2) { + foreach ($v2 as $k3 => $v3) { + if ($v3["optional"] == "1") $optional = "標"; + elseif ($v3["optional"] == "2") $optional = "選"; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + } + } + /* + $group_nums = count($v2); + $i = 1; + foreach ($v2 as $k3 => $v3) { + if ($v3["optional"] == "1") $optional = "標"; + elseif ($v3["optional"] == "2") $optional = "選"; + $option_str .= ""; + if ($i==1) { + $option_str .= ''; + } else { + $option_str .= ''; + } + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $option_str .= ""; + $i++; + } + */ + } + $option_str .= "
名稱規格備註配置單位定價
'.$opt_kind_arr[$k].'
" . $k2 . "" . $v3["spec"] . "" . $v3["memo"] . "" . $optional . "" . $v3["unit"] . "" . number_format($v3["price"]) . "
'.$k2.''.$k2.'".$v3["spec"]."".$v3["memo"]."".$optional."".$v3["unit"]."".number_format($v3["price"])."
"; +?> + + + +
+ +
+ +
+ +
+ + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + 0) { + foreach ($item_arr as $item_no => $v) { + if (!empty($v["note"])) list($spec, $seat, $stop, $speed) = explode(",", $v["note"]); + else $spec = $seat = $floor = $speed = ""; + ?> + + + + + + + + + + + + + + + + + + +
整機單價
電梯人乘/載重停數速度開門方式規格單價數量複價售價
+ + + + + + + + + + + + + " readonly>" required> + + + + + + + + X +
小計
+
+
+
+ + + + + + + + + + + + + + + + + 0) { + foreach ($option_arr as $item_no => $v) { + ?> + + + + + + + + + + + + + + + + + + + + + + + + + +
OPTION加價
選配規格單價數量複價備註 +
所屬電梯 + + + + +
+
功能
+ + " readonly>">" readonly> + + + + + + "; + } + } + } + ?> + 電梯 + X +
+ 點選 + + + + + + 電梯 + X +
小計
+
+
+
+ + + + + + + + + + + + + + + 0) { + foreach ($ex_arr as $item_no => $v) { + ?> + + + + + + + + + + + + + + + + + + + + + +
除外項目
詢價單號名稱單價數量複價
">">">">">" readonly> + + + + X +
+ + + X +
小計
+
+
+
+ + + + + + + + + + + + + + + + + + + + 0) { + foreach ($mn_arr as $item_no => $v) { + if (!empty($v["note"])) list($seat, $stop, $speed) = explode(",", $v["note"]); + else $seat = $stop = $speed = ""; + ?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
保固延長
電梯人乘/載重停數速度單價數量(月)複價備註所屬電梯 + + 功能
+ + + + + + + + " readonly>">" readonly> + + + + + + "; + } + } + } + ?> + 電梯 + X +
+ + + + + + + + + + + + 電梯 + X +
小計
+
+ +
+ +
+ + + + + + + + + + + + + + + 0) { + foreach ($demolition_arr as $item_no => $v) { + if (!empty($v["note"])) $floor = $v["note"]; + else $floor = ""; + ?> + + + + + + + + + + + + + + + + + + + + + +
拆梯價格
人乘/載重樓層單價數量複價
+ + + + " readonly>">" readonly> + + + + X +
+ + + + + + + + X +
小計
+
+ +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
付款辦法款別比例%金額票期
材料1、訂金">" readonly> + + +
2、二次款">" readonly> + + +
3、貨到工地款">" readonly> + + +
4、其它">" readonly> + + +
安裝5、安裝完畢款">" readonly> + + +
6、驗收款">" readonly> + + +
7、其它">" readonly> + + +
合計
備註
+
+ +
+
+ + " readonly> +
+
+ + " required> + "> +
+
+ + " readonly> +
+
+ + +
+
+ + +
+
+ + "> +
+
+ + +
+
+
+ " required> +
+
+
+ " required> +
+
+
+ + "> +
+
+ + "> +
+
+ + "> +
+
+ + "> +
+ +
+ +
+ + + + + + + + + + + +
+
+ + +
+ + " . substr($data["attatch1"], strrpos($data["attatch1"], "/") + 1) . " "; + echo 'X'; + } + ?> +
+ X +
+ + " . substr($data["attatch2"], strrpos($data["attatch2"], "/") + 1) . " "; + echo 'X'; + } + ?> +
+ X +

+   + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + \ No newline at end of file diff --git a/wms/mkt/pricereview_renovate-index.php b/wms/mkt/pricereview_renovate-index.php index 9ad5e544..8b77b52d 100644 --- a/wms/mkt/pricereview_renovate-index.php +++ b/wms/mkt/pricereview_renovate-index.php @@ -1,352 +1,367 @@ - "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; - -// 設置一個空陣列來放資料 -$data = array(); -// sql語法存在變數中 -$sql_cmd = sql_myself($user_id); -// M0024許伃廷,M0107許紓晴,M0012李盈瑩權限全開 -if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012") { - $sql_cmd = "where create_at >= '2023-01-01 00:00:00'"; -} -if ($user_id == "M0008") { - $sql_cmd = "where creater in (select accountid from account where department_id like '5%')"; -} -if ($user_id == "M0060") { - $sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))"; -} -if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id"; -else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; -$data = mysqli_query($link,$sql); - -$para = "function_name=pricereview_renovate&".$token_link; -$sign_st = ""; -?> - - - -Please fill up the required field!

"; - } else { - header("Location:pricereview-index.php"); - } - } - */ -?> - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
項次卷號營業員客戶名稱案件名稱牌價總額售價總額價率預定成交日預定交期建檔人建檔時間功能區經理工務副總總經理狀態合約書下載
% - - 修改 - 刪除 - - 填規調 - - " class="btn btn-warning btn-sm">檢視 - - "; - elseif ($ustatus == "N") $str = ""; - $str .= "
".$accountname_arr[$uperson]."
".$udtte; - } else { - if ($sign_st==1 && $sign_nt==$user_id && $data["status"]=="YS") { - $str = ""; - $str = "待簽核"; - $str = "".$str.""; - } else $str = "--"; - } - echo $str; - /* - if ($sign_st==1 && $sign_nt==$user_id) { - $str = ""; - $str = "".$str.""; - } else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 - list($uperson, $ustatus, $udtte) = explode(",", $sign1); - if ($ustatus == "Y") $str = ""; - else $str = ""; - $str .= "
".$accountname_arr[$uperson]."
".$udtte; - } else $str = "--"; - */ - - /* - if ($data["checker_1_result"] == "Y") { - $str = ""; - } elseif ($data["checker_1_result"] == "N") { - $str = ""; - } else { - $str = ""; - } - if (!$oneself) { - $str = "".$str.""; - $str .= "
".$data["checker_1"]."
".$data["checker_1_dt"]; - } else { - if ($data["checker_1_result"]) { - $str = "".$str.""; - $str .= "
".$data["checker_1"]."
".$data["checker_1_dt"]; - } - else $str = "--"; - }*/ - //echo $str; - ?> -
- "; - elseif ($ustatus == "N") $str = ""; - $str .= "
".$accountname_arr[$uperson]."
".$udtte; - } else { - if (($data["status"] == "YS") && ($sign_st == 3) && ($sign_nt == $user_id)) { - $str = ""; - $str = "待簽核"; - $str = "".$str.""; - } else $str = "--"; - } - echo $str; - /* - $str = ""; - if ($sign_st==3 && $sign_nt==$user_id) { - $str = ""; - $str = "".$str.""; - } else $str = "--"; - */ - - /* - if ($data["checker_3_result"] == "Y") { - $str = ""; - } elseif ($data["checker_3_result"] == "N") { - $str = ""; - } else { - $str = ""; - } - if (!$oneself) { - $str = "".$str.""; - $str .= "
".$data["checker_3"]."
".$data["checker_3_dt"]; - } else { - if ($data["checker_3_result"]) { - $str = "".$str.""; - $str .= "
".$data["checker_3"]."
".$data["checker_3_dt"]; - } - else $str = "--"; - } - */ - //echo $str; - ?> -
- "; - elseif ($ustatus == "N") $str = ""; - $str .= "
".$accountname_arr[$uperson]."
".$udtte; - } else { - if (($data["status"] == "YS") && ($sign_st == 4) && ($sign_nt == $user_id)) { - $str = ""; - $str = "待簽核"; - $str = "".$str.""; - } else $str = "--"; - } - echo $str; - ?> -
- - 合約書申請 - -
-
-There is no record!"; -endif; - -#代表結束連線 -mysqli_close($link); - -include "../footer.php"; + "暫存", "YS" => "簽核中", "YY" => "結案同意", "YN" => "結案不同意"]; + +// 設置一個空陣列來放資料 +$data = array(); +// sql語法存在變數中 +$sql_cmd = sql_myself($user_id); +// M0024許伃廷,M0107許紓晴,M0012李盈瑩權限全開 +if ($user_id == "M0024" || $user_id == "M0107" || $user_id == "M0012" || $user_id == "M0025") { + $sql_cmd = "where create_at >= '2023-01-01 00:00:00'"; +} +if ($user_id == "M0008") { + $sql_cmd = "where creater in (select accountid from account where department_id like '5%')"; +} +if ($user_id == "M0060") { + $sql_cmd = "where creater in (select accountid from account where (department_id like '3%' or department_id like '5%'))"; +} +if (empty($sql_cmd)) $sql = "select * from pricereview_main where status like 'Y%' and ekind = '汰改' order by id"; +else $sql = "select * from pricereview_main $sql_cmd and status like 'Y%' and ekind = '汰改' order by id"; + + +$data = mysqli_query($link, $sql); + +$para = "function_name=pricereview_renovate&" . $token_link; +$sign_st = ""; +?> + + + +Please fill up the required field!

"; + } else { + header("Location:pricereview-index.php"); + } + } + */ +?> + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
項次卷號營業員客戶名稱案件名稱牌價總額售價總額價率預定成交日預定交期建檔人建檔時間功能區經理工務副總總經理狀態合約書下載
% + + 修改 + 刪除 + + 填規調 + + " class="btn btn-warning btn-sm">檢視 + + "; + elseif ($ustatus == "N") $str = ""; + $str .= "
" . $accountname_arr[$uperson] . "
" . $udtte; + } else { + if ($sign_st == 1 && $sign_nt == $user_id && $data["status"] == "YS") { + $str = ""; + $str = "待簽核"; + $str = "" . $str . ""; + } else $str = "--"; + } + echo $str; + /* + if ($sign_st==1 && $sign_nt==$user_id) { + $str = ""; + $str = "".$str.""; + } else if ($sign_st > 1 || $data['last_check_result']) { // 過了這關或已完成流程 + list($uperson, $ustatus, $udtte) = explode(",", $sign1); + if ($ustatus == "Y") $str = ""; + else $str = ""; + $str .= "
".$accountname_arr[$uperson]."
".$udtte; + } else $str = "--"; + */ + + /* + if ($data["checker_1_result"] == "Y") { + $str = ""; + } elseif ($data["checker_1_result"] == "N") { + $str = ""; + } else { + $str = ""; + } + if (!$oneself) { + $str = "".$str.""; + $str .= "
".$data["checker_1"]."
".$data["checker_1_dt"]; + } else { + if ($data["checker_1_result"]) { + $str = "".$str.""; + $str .= "
".$data["checker_1"]."
".$data["checker_1_dt"]; + } + else $str = "--"; + }*/ + //echo $str; + ?> +
+ "; + elseif ($ustatus == "N") $str = ""; + $str .= "
" . $accountname_arr[$uperson] . "
" . $udtte; + } else { + if (($data["status"] == "YS") && ($sign_st == 3) && ($sign_nt == $user_id)) { + $str = ""; + $str = "待簽核"; + $str = "" . $str . ""; + } else $str = "--"; + } + echo $str; + /* + $str = ""; + if ($sign_st==3 && $sign_nt==$user_id) { + $str = ""; + $str = "".$str.""; + } else $str = "--"; + */ + + /* + if ($data["checker_3_result"] == "Y") { + $str = ""; + } elseif ($data["checker_3_result"] == "N") { + $str = ""; + } else { + $str = ""; + } + if (!$oneself) { + $str = "".$str.""; + $str .= "
".$data["checker_3"]."
".$data["checker_3_dt"]; + } else { + if ($data["checker_3_result"]) { + $str = "".$str.""; + $str .= "
".$data["checker_3"]."
".$data["checker_3_dt"]; + } + else $str = "--"; + } + */ + //echo $str; + ?> +
+ "; + elseif ($ustatus == "N") $str = ""; + $str .= "
" . $accountname_arr[$uperson] . "
" . $udtte; + } else { + if (($data["status"] == "YS") && ($sign_st == 4) && ($sign_nt == $user_id)) { + $str = ""; + $str = "待簽核"; + $str = "" . $str . ""; + } else $str = "--"; + } + echo $str; + ?> +
+ + 合約書申請 + +
+
+There is no record!"; +endif; + +#代表結束連線 +mysqli_close($link); + +include "../footer.php"; ?> \ No newline at end of file diff --git a/wms/sign/list.php b/wms/sign/list.php index 9304204f..76795832 100644 --- a/wms/sign/list.php +++ b/wms/sign/list.php @@ -38,10 +38,10 @@ if ($result == false) { die(mysqli_error($link)); } $res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC); -// echo '
';
-// print_r($sql_get);
-// echo '
'; -// exit; +echo '
';
+print_r($sql_get);
+echo '
'; +exit; $system_name_opt = array_map(function ($item) { return array('system_id' => $item['system_id'], 'system_name' => $item['system_name']); diff --git a/workflow/lib/DB.php b/workflow/lib/DB.php index 639061ef..9fcf6dff 100644 --- a/workflow/lib/DB.php +++ b/workflow/lib/DB.php @@ -1,224 +1,224 @@ - array('host' => 'db-104.coowo.com', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => 'x6h5E5p#u8y') - ); - public static $instance; - /** - * ? - * - * @param string $db - * @return object - */ - public static function instance($db = 'default') - { - - $dbh = new PDO("mysql:host=" . self::$ds[$db]['host'] . ";dbname=appwms" . ";charset=utf8", self::$ds[$db]['user'], self::$ds[$db]['pwd']); - $dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); - return $dbh; - } - /** - * ?insert - * - * @param [String] $table_name - * @param [Array] $cols - * @param [Array] $values - * @param string $db - * @return void - */ - public static function insert_batch($table_name, $cols, $values, $db = 'default') - { - $_sql = 'insert into ' . $table_name . '(' . implode(",", $cols) . ')'; - $_vsql = array(); - foreach ($values as $value) { - $_vsql[] = 'select ' . implode(",", $value) . 'from dual'; - } - $_sql .= implode(' Union All ', $_vsql); - // self::query($_sql, $db); - self::instance($db)->exec($_sql); - } - /** - * insert - * - * @param [type] $table_name - * @param [type] $data - * @param string $db - * @return void - */ - public static function insert_table($table_name, $data, $db = 'default') - { - - - // $stmt->debugDumpParams(); - - $fields = array_keys($data); - - $meta = self::metadata($table_name, array_keys($data), $db); - // var_dump( $meta); - - foreach ($fields as $f) { - - if ($meta[$f] == 'LONG' || $meta[$f] == 'NEWDECIMAL') { - $data[$f] = (int) $data[$f]; - } elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { - $data[$f] = 'NULL'; - } else { - // var_dump( $data[$f]); - // if( is_array($data[$f])){ echo "$table_name " ; echo "$f ";}; - - $data[$f] = "'" . $data[$f] . "'"; - $data[$f] = $data[$f]; - } - } - - //foreach ($fields as $f) { - - $_sql = "insert into " . $table_name . "(" . implode(",", array_keys($data)) . ") values (" . implode(",", array_values($data)) . " )"; -//echo $_sql; - self::instance($db)->exec($_sql); - // $stmt->debugDumpParams(); - - - - } - /** - * - * - * @param [String] $table_name - * @param [Array] $data - * @param [String] $data - * @param string $db - * @return void - */ - public static function update_table($table_name, $data, $where, $db = 'default') - { - $fields = array_keys($data); - - $meta = self::metadata($table_name, array_keys($data), $db); - // var_dump( $meta); - - foreach ($fields as $f) { - - if ($meta[$f] == 'LONG') { - $data[$f] = (int) $data[$f]; - } else if ($meta[$f] == 'NEWDECIMAL') { - $data[$f] = (float) $data[$f]; - } elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { - $data[$f] = NULL; - } else { - $data[$f] = $data[$f]; - $data[$f] = $data[$f]; - } - } - - - - if (empty($where)) { - return false; - } - $sql = "update $table_name set "; - $i = 0; - foreach ($data as $key => $val) { - $sql .= $i++ > 0 ? " , $key=:$key " : " $key=:$key "; - $value[$key] = $val; - } - // var_dump($value); - $sql .= " where " . $where; - $stmt = self::instance($db)->prepare($sql); - - $stmt->execute($value); - // $stmt->debugDumpParams(); - } - - /** - * sql - * - * @param [String] $sql - * @param string $db - * @return void - */ - public static function fields($sql, $db = 'default') - { - return self::query($sql)->fetch(PDO::FETCH_BOTH); - } - /** - * ?,as_array array? - * - * @param [String] $sql - * @param boolean $as_array - * @param string $db - * @return mixed - */ - public static function result($sql, $as_array = true, $db = 'default') - { - // echo $sql; - $resource = self::query($sql, $db); - - return $as_array == false ? $resource->fetchAll(PDO::FETCH_OBJ) : $resource->fetchAll(PDO::FETCH_BOTH); - } - /** - *sql? - * - * @param [String] $sql - * @return [int] - */ - public static function effect_num($sql, $db = 'default') - { - return count(self::query($sql, $db)->fetchAll()); - } - public static function query($sql, $db = 'default') - { - - // echo $sql; - $res = self::instance($db)->prepare($sql); - - if (!$res) { - // var_dump($res->errorInfo()); - } else { - $res->execute(); - - return $res; - } - } - public function escape($filed) - { - } - - /* - * 获取列的元数据 - * - * @param [type] $tablename - * @return void - */ - public static function metadata($tablename = null, $col = array(), $db = 'default') - { - $column_types = array(); - - $stmt = self::query("SELECT " . implode(",", array_values($col)) . " FROM " . $tablename . " limit 0,1"); - for ($i = 0; $i < $stmt->columnCount(); $i++) { - $meta[$i] = $stmt->getColumnMeta($i); - - $column_types[$meta[$i]['name']] = $meta[$i]['native_type']; - } - - return $column_types; - } -} + array('host' => '127.0.0.1', 'db_name' => 'appwms', 'user' => 'masadaroot', 'pwd' => '') + ); + public static $instance; + /** + * ? + * + * @param string $db + * @return object + */ + public static function instance($db = 'default') + { + + $dbh = new PDO("mysql:host=" . self::$ds[$db]['host'] . ";dbname=appwms" . ";charset=utf8", self::$ds[$db]['user'], self::$ds[$db]['pwd']); + $dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER); + return $dbh; + } + /** + * ?insert + * + * @param [String] $table_name + * @param [Array] $cols + * @param [Array] $values + * @param string $db + * @return void + */ + public static function insert_batch($table_name, $cols, $values, $db = 'default') + { + $_sql = 'insert into ' . $table_name . '(' . implode(",", $cols) . ')'; + $_vsql = array(); + foreach ($values as $value) { + $_vsql[] = 'select ' . implode(",", $value) . 'from dual'; + } + $_sql .= implode(' Union All ', $_vsql); + // self::query($_sql, $db); + self::instance($db)->exec($_sql); + } + /** + * insert + * + * @param [type] $table_name + * @param [type] $data + * @param string $db + * @return void + */ + public static function insert_table($table_name, $data, $db = 'default') + { + + + // $stmt->debugDumpParams(); + + $fields = array_keys($data); + + $meta = self::metadata($table_name, array_keys($data), $db); + // var_dump( $meta); + + foreach ($fields as $f) { + + if ($meta[$f] == 'LONG' || $meta[$f] == 'NEWDECIMAL') { + $data[$f] = (int) $data[$f]; + } elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { + $data[$f] = 'NULL'; + } else { + // var_dump( $data[$f]); + // if( is_array($data[$f])){ echo "$table_name " ; echo "$f ";}; + + $data[$f] = "'" . $data[$f] . "'"; + $data[$f] = $data[$f]; + } + } + + //foreach ($fields as $f) { + + $_sql = "insert into " . $table_name . "(" . implode(",", array_keys($data)) . ") values (" . implode(",", array_values($data)) . " )"; + //echo $_sql; + self::instance($db)->exec($_sql); + // $stmt->debugDumpParams(); + + + + } + /** + * + * + * @param [String] $table_name + * @param [Array] $data + * @param [String] $data + * @param string $db + * @return void + */ + public static function update_table($table_name, $data, $where, $db = 'default') + { + $fields = array_keys($data); + + $meta = self::metadata($table_name, array_keys($data), $db); + // var_dump( $meta); + + foreach ($fields as $f) { + + if ($meta[$f] == 'LONG') { + $data[$f] = (int) $data[$f]; + } else if ($meta[$f] == 'NEWDECIMAL') { + $data[$f] = (float) $data[$f]; + } elseif ($meta[$f] == 'DATETIME' && empty($data[$f])) { + $data[$f] = NULL; + } else { + $data[$f] = $data[$f]; + $data[$f] = $data[$f]; + } + } + + + + if (empty($where)) { + return false; + } + $sql = "update $table_name set "; + $i = 0; + foreach ($data as $key => $val) { + $sql .= $i++ > 0 ? " , $key=:$key " : " $key=:$key "; + $value[$key] = $val; + } + // var_dump($value); + $sql .= " where " . $where; + $stmt = self::instance($db)->prepare($sql); + + $stmt->execute($value); + // $stmt->debugDumpParams(); + } + + /** + * sql + * + * @param [String] $sql + * @param string $db + * @return void + */ + public static function fields($sql, $db = 'default') + { + return self::query($sql)->fetch(PDO::FETCH_BOTH); + } + /** + * ?,as_array array? + * + * @param [String] $sql + * @param boolean $as_array + * @param string $db + * @return mixed + */ + public static function result($sql, $as_array = true, $db = 'default') + { + // echo $sql; + $resource = self::query($sql, $db); + + return $as_array == false ? $resource->fetchAll(PDO::FETCH_OBJ) : $resource->fetchAll(PDO::FETCH_BOTH); + } + /** + *sql? + * + * @param [String] $sql + * @return [int] + */ + public static function effect_num($sql, $db = 'default') + { + return count(self::query($sql, $db)->fetchAll()); + } + public static function query($sql, $db = 'default') + { + + // echo $sql; + $res = self::instance($db)->prepare($sql); + + if (!$res) { + // var_dump($res->errorInfo()); + } else { + $res->execute(); + + return $res; + } + } + public function escape($filed) + { + } + + /* + * 获取列的元数据 + * + * @param [type] $tablename + * @return void + */ + public static function metadata($tablename = null, $col = array(), $db = 'default') + { + $column_types = array(); + + $stmt = self::query("SELECT " . implode(",", array_values($col)) . " FROM " . $tablename . " limit 0,1"); + for ($i = 0; $i < $stmt->columnCount(); $i++) { + $meta[$i] = $stmt->getColumnMeta($i); + + $column_types[$meta[$i]['name']] = $meta[$i]['native_type']; + } + + return $column_types; + } +}