Browse Source

add con

gary
jrbin 2 years ago
parent
commit
a983f4069c
  1. 509
      wms/con/FormHelper.php
  2. 322
      wms/con/MICalculator.php
  3. 322
      wms/con/MSCalculator.php
  4. 22
      wms/con/apply.php
  5. 770
      wms/con/apply_form.php
  6. 20
      wms/con/async_req.php
  7. 14
      wms/con/con_maintance_examine_clear.php
  8. 21
      wms/con/crmm06_submit.php
  9. 168
      wms/con/list.php
  10. 29
      wms/con/model/ConMaintanceExamineApplyModel.php
  11. 33
      wms/con/model/ConMaintanceExamineClearModel.php
  12. 53
      wms/con/model/Model.php
  13. 510
      wms/con/query_form.php
  14. 507
      wms/con/review_apply_form.php
  15. 575
      wms/con/sign_form.php
  16. 149
      wms/con/sign_list.php
  17. 69
      wms/con/submit.php
  18. 1
      wms/con/success.php
  19. 84
      wms/con/t.php
  20. 174
      wms/con/test.php
  21. 20
      wms/con/wf_common.php

509
wms/con/FormHelper.php

@ -0,0 +1,509 @@
<?php
class FormHelper
{
/**
* Form opening tag
*
* @static
* @param string $action
* @param array $attributes HTML attributes
* @return string
*/
public static function open($action = '', array $attributes = array())
{
if (isset($attributes['multipart']) && $attributes['multipart']) {
$attributes['enctype'] = 'multipart/form-data';
unset($attributes['multipart']);
}
$attributes = array_merge(array('method' => 'post', 'accept-charset' => 'utf-8'), $attributes);
return "<form action=\"{$action}\"" . self::attributes($attributes) . '>';
}
/**
* Form closing tag
*
* @static
* @return string
*/
public static function close()
{
return '</form>';
}
/**
* Creates a label for an input
*
* @param string $text The label text
* @param string $fieldName Name of the input element
* @param array $attributes HTML attributes
* @return string
*/
public static function label($text, $fieldName = null, array $attributes = array())
{
if (!isset($attributes['for']) && $fieldName !== null) {
$attributes['for'] = static::autoId($fieldName);
}
if (!isset($attributes['id']) && isset($attributes['for'])) {
$attributes['id'] = $attributes['for'] . '-label';
}
return self::tag('label', $attributes, $text);
}
/**
* Creates a text field
*
* @param string $name
* @param string $value
* @param array $attributes HTML attributes
* @return string
*/
public static function text($name, $value = null, array $attributes = array(),$type='text')
{
$attributes = array_merge(array(
'id' => static::autoId($name),
'name' => $name,
'type' => $type,
'value' => $value,
), $attributes);
return self::tag('input', $attributes);
}
/**
* Creates a password input field
*
* @static
* @param string $name
* @param string $value
* @param array $attributes HTML attributes
* @return string
*/
public static function password($name, $value = null, array $attributes = array())
{
$attributes = array_merge(array(
'id' => static::autoId($name),
'name' => $name,
'type' => 'password',
'value' => $value,
), $attributes);
return self::tag('input', $attributes);
}
/**
* Creates a hidden input field
*
* @static
* @param string $name
* @param string $value
* @param array $attributes
* @return string
*/
public static function hidden($name, $value, array $attributes = array())
{
$attributes = array_merge(array(
'id' => static::autoId($name),
'name' => $name,
'type' => 'hidden',
'value' => $value,
), $attributes);
return self::tag('input', $attributes);
}
/**
* Creates a textarea
*
* @param string $name
* @param string $text
* @param array $attributes HTML attributes
* @return string
*/
public static function textArea($name, $text = null, array $attributes = array())
{
$attributes = array_merge(array(
'id' => static::autoId($name),
'name' => $name,
), $attributes);
return self::tag('textarea', $attributes, (string)$text);
}
/**
* Creates a check box.
* By default creates a hidden field with the value of 0, so that the field is present in $_POST even when not checked
*
* @param string $name
* @param bool $checked
* @param mixed $value Checked value
* @param array $attributes HTML attributes
* @param bool|string $withHiddenField Pass false to omit the hidden field or "array" to return both parts as an array
* @return string
*/
public static function checkBox(
$name,
$checked = false,
$value = 1,
array $attributes = array(),
$withHiddenField = true
) {
$auto_id = static::autoId($name);
$checkboxAttributes = array_merge(array(
'name' => $name,
'type' => 'checkbox',
'value' => $value,
'id' => $auto_id,
'checked' => (bool)$checked,
), $attributes);
$checkbox = self::tag('input', $checkboxAttributes);
if ($withHiddenField === false) {
return $checkbox;
}
$hiddenAttributes = array(
'name' => $name,
'type' => 'hidden',
'value' => 0,
'id' => $auto_id . '-hidden',
);
$hidden = self::tag('input', $hiddenAttributes);
return $withHiddenField === 'array'
? array($hidden, $checkbox)
: $hidden . $checkbox;
}
/**
* Creates multiple checkboxes for a has-many association.
*
* @param string $name
* @param array $collection
* @param array|\Traversable $checked Collection of checked values
* @param array $labelAttributes
* @param bool $returnAsArray
* @throws \InvalidArgumentException
* @return string
*/
public static function collectionCheckBoxes($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false)
{
// TODO: Does this check cover all options?
if (!(is_array($checked) || $checked instanceof \Traversable)) {
throw new \InvalidArgumentException("$name must be an array or Traversable!");
}
$checkBoxes = array();
foreach ($collection as $value => $label) {
$checkBoxes[] = self::tag(
'label',
$labelAttributes,
FormHelper::checkBox("{$name}[]", in_array($value, $checked, true), $value, array(), false) . self::escape($label),
false
);
}
return $returnAsArray ? $checkBoxes : implode('', $checkBoxes);
}
/**
* Creates a radio button
*
* @static
* @param string $name
* @param string $value
* @param bool $checked
* @param array $attributes
* @return string
*/
public static function radio($name, $value, $checked = false, array $attributes = array())
{
$attributes = array_merge(array(
'type' => 'radio',
'name' => $name,
'value' => $value,
'checked' => (bool)$checked,
), $attributes);
return self::tag('input', $attributes);
}
/**
* Creates multiple radio buttons with labels
*
* @static
* @param string $name
* @param array $collection
* @param mixed $checked Checked value
* @param array $labelAttributes
* @param bool $returnAsArray
* @return array|string
*/
public static function collectionRadios($name, array $collection, $checked, array $labelAttributes = array(), $returnAsArray = false)
{
$radioButtons = array();
foreach ($collection as $value => $label) {
$radioButtons[] = self::tag(
'label',
$labelAttributes,
FormHelper::radio($name, $value, $value === $checked) . self::escape($label),
false
);
}
return $returnAsArray ? $radioButtons : implode('', $radioButtons);
}
/**
* Creates a select tag
* <code>
* // Simple select
* select('coffee_id', array('b' => 'black', 'w' => 'white'));
*
* With option groups
* select('beverage', array(
* 'Coffee' => array('bc' => 'black', 'wc' => 'white'),
* 'Tea' => array('gt' => 'Green', 'bt' => 'Black'),
* ));
* </code>
*
* @param string $name Name of the attribute
* @param array $collection An associative array used for the option values
* @param mixed $selected Selected option Can be array or scalar
* @param array $attributes HTML attributes
* @return string
*/
public static function select($name, array $collection, $selected = null, array $attributes = array())
{
$attributes = array_merge(array(
'name' => $name,
'id' => static::autoId($name),
'multiple' => false,
), $attributes);
if (is_string($selected) || is_numeric($selected)) {
$selected = array($selected => 1);
} else if (is_array($selected)) {
$selected = array_flip($selected);
} else {
$selected = array();
}
$content = self::option('', '', $selected);
foreach ($collection as $value => $element) {
// Element is an optgroup
$content .= self::option($element['value'], $element['label'], $selected);
}
return self::tag('select', $attributes, $content, false);
}
/**
* Creates an option tag
*
* @param string $value
* @param string $label
* @param array $selected
* @return string
*/
private static function option($value, $label, $selected)
{
// Special handling of option tag contents to enable indentation with &nbsp;
//$label = str_replace('&amp;nbsp;', '&nbsp;', self::escape($label));
return self::tag(
'option',
array(
'value' => $value,
'selected' => isset($selected[$value]),
),
$label,
false
);
}
/**
* Creates a file input field
*
* @static
* @param string $name
* @param array $attributes HTML attributes
* @return string
*/
public static function file($name, array $attributes = array())
{
$attributes = array_merge(array(
'type' => 'file',
'name' => $name,
'id' => static::autoId($name),
), $attributes);
return self::tag('input', $attributes);
}
public static function button($name, $text, array $attributes = array())
{
$attributes = array_merge(array(
'id' => static::autoId($name),
'name' => $name,
), $attributes);
return self::tag('button', $attributes, $text);
}
/**
* Generate an ID given the name of an input
*
* @static
* @param string $name
* @return string|null
*/
public static function autoId($name)
{
// Don't set an id on collection inputs
if (strpos($name, '[]') !== false) {
return null;
}
// Hyphenate array keys, for example model[field][other_field] => model-field-other_field
$name = preg_replace('/\[([^]]+)\]/u', '-\\1', $name);
return $name;
}
/**
* Generates an HTML tag
*
* @param string $tagName Name of the tag
* @param array $attributes HTML attributes
* @param string $content Content of the tag. Omit to create a self-closing tag
* @param bool $escape_content
*
* @see attributes()
*
* @return string
*/
public static function tag($tagName, array $attributes = array(), $content = null, $escape_content = true)
{
$result = '<' . $tagName . static::attributes($attributes) . '>';
if ($content !== null) {
$result .= ($escape_content ? static::escape($content) : $content) . '</' . $tagName . '>';
}
return $result;
}
/**
* Converts an array of HTML attributes to a string
*
* If an attribute is false or null, it will not be set.
*
* If an attribute is true or is passed without a key, it will
* be set without an explicit value (useful for checked, disabled, ..)
*
* If an array is passed as a value, it will be joined using spaces
*
* Note: Starts with a space
* <code>
* Html::attributes(array('id' => 'some-id', 'selected' => false, 'disabled' => true, 'class' => array('a', 'b')));
* //=> ' id="some-id" disabled class="a b"'
* </code>
*
* @param array $attributes Associative array of attributes
*
* @return string
*/
public static function attributes(array $attributes)
{
$result = '';
foreach ($attributes as $attribute => $value) {
if ($value === false || $value === null) continue;
if ($value === true) {
$result .= ' ' . $attribute;
} else if (is_numeric($attribute)) {
$result .= ' ' . $value;
} else {
if (is_array($value)) { // support cases like 'class' => array('one', 'two')
$value = implode(' ', $value);
}
$result .= ' ' . $attribute . '=\'' . static::escape($value) . '\'';
}
}
return $result;
}
/**
* Escapes a string for output in HTML
*
* @static
* @param string $string
* @return string
*/
public static function escape($string)
{
return htmlspecialchars($string, ENT_QUOTES, 'UTF-8');
}
/**
* 输出表单标题
*
* @param string $title
* @return void
*/
public static function formTitle(string $title)
{
return '<div class="row form_head ">
<div class=" col-12 form_head_title ">
<b>' . $title . '</b>
</div>
</div>
';
}
/**
* 输出行标题
*
* @param string $title
* @return void
*/
public static function formRowTitle(string $title)
{
return '<div class="row " style="padding-top:10px;">
<div class=" col-lg-12 form_row_header ">
<b>' . $title . '</b>
</div>
</div>
';
}
/**
* 输出行内容
*
* @return void
*/
public static function formRowContent($fieldName, string $fieldValue, string $key)
{
return ' <div class="col-1 form_field_title">
<p>' . $fieldName . '</p>
</div>
<div class="col-3 form_field_content">
<input class=" form-control form-control-sm" value=' . $fieldValue . ' name=' . $key . ' id=' . $key . ' />
</div>
';
}
/**
* 生成Row
*
* @return void
*/
public function formRow()
{
$_div = " <div class='row' >";
$_div .= "</div>";
}
}

322
wms/con/MICalculator.php

@ -0,0 +1,322 @@
<?php
require_once '../../workflow/lib/DB.php';
class MICalculator
{
/**
* 計算MI
*
* @param array $param
* @return void
*/
public function cal(array $param)
{
$elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param);
}
return self::error();
}
/**
* 客梯報價 maintain_kind='A'
* 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void
*/
public function A_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 貨梯報價
*
* @return void
*/
public function B_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 病床梯報價
*
* @return void
*/
public function C_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 無機房報價
*
* @return void
*/
public function D_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
*家用梯報價
*
* @return void
*/
public function E_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_mi_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
public function error()
{
return [
'status' => 'fail',
'message' => '無此項目,請聯係業務部創建MI'
];
}
public function success($price)
{
return [
'status' => 'ok',
'price' => $price
];
}
}

322
wms/con/MSCalculator.php

@ -0,0 +1,322 @@
<?php
require_once '../../workflow/lib/DB.php';
class MSCalculator
{
/**
* 計算报价
*
* @param array $param
* @return void
*/
public function cal(array $param)
{
$elevator_type = $param['elevator_type'];
$func = $elevator_type . "_price";
if (method_exists($this, $elevator_type . "_price")) {
return call_user_func([$this, $func], $param);
}
return self::error();
}
/**
* 客梯成本maintain_kind='A'
* 1.每月2次保養價格*1.25倍
* 2.全包價格按半包價+1500元/臺
* 3.簽5年長約免費送M1係統的+2600元/臺"
* @return void
*/
public function A_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['speed'] . " between min_speed and max_speed
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 貨梯成本
*
* @return void
*/
public function B_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 病床梯成本
*
* @return void
*/
public function C_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['weight'] . " between min_weight and max_weight
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
* 無機房成本
*
* @return void
*/
public function D_price($item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_months= " . $item['maintain_months'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
/**
*家用梯成本
*
* @return void
*/
public function E_price(array $item)
{
$floors = $item['floors'];
$maintain_times = $item['maintain_times'];
$sql_get_price = "
select
elevator_type,
base_price,
floors_price,
min_floors,
min_maintain_times,
maintain_months,
maintain_kind,
maintain_period,
is_m1_bundle,
all_inclusive_fee,
maintenance_fee_coefficient,
m1_bundle_fee
from maintain_standard_option where
elevator_type='" . $item['elevator_type'] . "'
and " . $item['floors'] . " between min_floors and max_floors
and " . $item['persons'] . " between min_persons and max_persons
and " . $item['maintain_times'] . " between min_maintain_times and max_maintain_times
and maintain_period= " . $item['maintain_period'] . "
and maintain_kind='" . $item['maintain_kind'] . "'
and is_m1_bundle='" . $item['is_m1_bundle'] . "'
";
list($row) = DB::result($sql_get_price);
if (empty($row)) return self::error();
#1基礎價格
$floors = $item['floors'] - $row['min_floors'];
$price1 = $row['base_price'] + ($floors) * $row['floors_price'];
// echo $price1;
#判斷是否全包
$price2 = $row['maintain_kind'] == 3 ? $price1 + $row['all_inclusive_fee'] : $price1;
// echo $price2;
#判斷是否五年M1套餐
$price3 = $row['is_m1_bundle'] == 'Y' ? $price2 + $row['m1_bundle_fee'] : $price2;
// echo $price3;
if ($maintain_times - $row['min_maintain_times'] < 1) return self::success($price3);
#判斷是否增加保養次數 用戶輸入的保養次數大於min_maintain_times
$price4 = $price3;
for ($i = 0; $i < $maintain_times - $row['min_maintain_times']; $i++) {
$price4 = $price4 + $price3 * $row['maintenance_fee_coefficient'];
}
return self::success($price4);
}
public function error()
{
return [
'status' => 'fail',
'message' => '無此項目,請聯係業務部創建標準成本'
];
}
public function success($price)
{
return [
'status' => 'ok',
'price' => $price
];
}
}

22
wms/con/apply.php

@ -0,0 +1,22 @@
<?php
/**
* 发起流程
*/
error_reporting(E_ALL);
ini_set("display_errors", "on");
require_once "./wf_common.php";
require_once "../database.php";
#系统ID
$system_id = 'psm';
#流程ID
$flow_id = 'psm01';
#表单号 $form_id;
$form_id = "";
$wf = new WorkFlow($system_id, $flow_id, $form_id);
$wf->initWorkFlow(ID);
//加载视图
echo '<a href="https://www.masada.com.tw/wms/sign/list.php">查看全部待签</a>';

770
wms/con/apply_form.php

@ -0,0 +1,770 @@
<?php
require_once '../header_nomenu.php';
require_once './FormHelper.php';
require_once './wf_common.php';
$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no'];
/***
* 检查是否重复生成价审单
* con_maintance_examine_apply
*/
/*
list($cnt)=DB::fields("select count(*) cnt from con_maintance_examine_apply where vol_no='$vol_no'");
if($cnt>0) {
echo"<script>alert('卷號".$vol_no."已生成價審單,請勿重複生成!');history.go(-1);</script>";
exit;
}
*/
#係統ID
$system_id = 'con';
#流程ID
$flow_id = 'con01';
#表單號 $form_id;
$form_id = "";
#價審單狀態
$apply_st = "";
list($apply_key, $form_key)=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"<script>alert('卷號".$vol_no."已生成價審單,請勿重複生成!');history.go(-1);</script>";
exit;
}
if ($apply_st==1) {
$wf = new WorkFlow($system_id, $flow_id, $form_id);
$wf->initWorkFlow($user_id);
$form_key = $wf->flowContext->getFormKey();
} else {
$wf = new WorkFlow($system_id, $flow_id, $form_id, $form_key);
}
#獲取簽核意見
$assign_opinions = Assign::get_records($form_key);
#會簽部門意見
$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key);
//預設冇有摺扣
$wf->setFormData(['discount' => 100]);
$flowName = $wf->getFlowName();
$assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner);
$if_show_assign = true;
//加載流程圖
//$fc = WorkFLowItems::get_records($flow->getSystemID(), $flow->getFlowID());
//$path = $fc[0]->wf_file;
//echo dirname(__DIR__)."/../"."$path";
//$flow_chart = file_get_contents(dirname(__DIR__) . '/' . $path);
#是否可會簽
$isSplitable = $wf->isSplitable();
//表單數據
#客戶表
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by code_name asc ";
$elevator_brand_opt = DB::result($sql);
#2.保養方式
$sql = "select code_name value ,content label from code where field_name='maintain_kind'";
$maintain_kind_opt = DB::result($sql);
#3.電梯類型
$sql = "select code_name value ,content label from code where field_name='maintain_elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.付款方式
$sql = "select code_name value ,content label from code where field_name='payment_kind' order by code_name+ 0 asc";
$payment_kind_opt = DB::result($sql);
#5.契約性質
$sql = "select code_name value ,content label from code where field_name='contract_kind'";
$contract_kind_opt = DB::result($sql);
#6.是否贈送M1
$is_m1_bundle_opt = [
['label' => '是', 'value' => 'Y'],
['label' => '否', 'value' => 'N']
];
#7.機種
$sql = "select code_name value ,content label from code where field_name='fp_kind'";
$fp_kind_opt = DB::result($sql);
#抓取有望客戶資料
$vol_no = $_GET['vol_no'];
$where = " and vol_no='$vol_no'";
$sql = "SELECT * FROM hope_contract_customer where 1=1 $where ORDER BY vol_no";
$hope_contract = DB::result($sql);
$hope_contract = empty($hope_contract) ? [] : $hope_contract[0];
#寫入 con_maintance_examine_apply
if ($apply_st==1) {
#獲取評審單號
$apply_key = get_sequnece_no('cmea_apply_key', date('ym'));
//var_dump($hope_contract);
$insert_data = [
'apply_key' => $apply_key,
'vol_no' => $vol_no,
'form_key' => $form_key,
'address' => $hope_contract['address'],
'case_name' => $hope_contract['customer'],
'num' => $hope_contract['num'],
'brand' => '',
'customer' => $hope_contract['customer'],
'salesman' => empty($hope_contract['salesman']) ? $user_id : $hope_contract['salesman'],
'progress_remark' => $hope_contract['progress_status']
//'platform_company'=>'',
// 'platforom_company_tel'=> ''
];
//var_dump($insert_data);
DB::insert_table('con_maintance_examine_apply', $insert_data);
}
$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[]', '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']],
'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 = " <tr>";
foreach ($con_maintance_examine_clear_columm as $key => $val) {
$fieldVal = "";
$_input = $val['tag'] == 'select' ?
FormHelper::select('', $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
// : "<input type='" . $val['tag'] . "' class=' form-control form-control-sm' " . $val['attr'] . " value='" . $fieldVal . "' name='${key}[]' id='$key' placeholder='請輸入'>";
$cmecRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>";
if ((++$j % $col_count) == 0) {
if ($j == $col_count) $cmecRow .= "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md'>刪除</button></td>";
$cmecRow .= "</tr><tr>";
}
}
$cmecRow .= "</tr>";
function base_url($url)
{
return "https://www.masada.com.tw/static/" . $url;
}
function get_sequnece_no($seq_name = '', $p_yyyymm = '')
{
if (empty($p_yyyymm) || empty($seq_name)) return null;
#當前年月
list($yyyymm, $prefix) = DB::fields("select yyyymm ,prefix from sequence where seq_name='$seq_name' ");
if ($p_yyyymm != $yyyymm) {
DB::query("update sequence set yyyymm='$p_yyyymm' , current_val='10000' where seq_name='$seq_name' ");
}
// echo "SELECT concat( $prefix,,substring(nextval('$seq_name'),2)) seq_no ";
list($seq_no) = DB::fields("SELECT concat( '$prefix','$p_yyyymm',substring( appwms.nextval('$seq_name'),2)) seq_no ");
return $seq_no;
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" />
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>">
</script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100); ?>" />
<script type="text/javascript">
window.param = {
elevator_type: '',
floors: 1,
speed: 1,
persons: 6,
weight: 1000,
maintain_times: 1, //病床梯一月2次保養
maintain_months: 12,
maintain_kind: 2,
maintain_period: 1, //預設為1月1次, 2是為2月一次
is_m1_bundle: 'N',
};
let regDelStr = "";
$(document).ready(function() {
var tag_data;
$.ajax({
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner',
//url: 'http://localhost/fds/index.php/DesignFlow/get_assigner',
type: 'post',
dataType: 'json',
success: function(data) {
window.tag_data = data;
$('#selectPage').selectPage({
showField: 'show_name',
keyField: 'val',
data: data,
multiple: true,
multipleControlbar: true,
pagination: false,
focusDropList: false
});
}
});
$.validator.addMethod('gt', function(value, element, param) {
return value > param;
}, $.validator.format("輸入值必須大於0"));
var assigner = eval('<?= json_encode($assigner) ?>');
//console.log(assigner);
var cmecRow = "<?= str_replace('"', '\'', $cmecRow) ?>";
// $('#cmecTbody').append(cmecRow);
$('.sp_element_box').attr("disabled", true);
$("#assign_opinion").cleditor({
height: 100, // height not including margins, borders or padding
controls: // controls to add to the toolbar
"bold italic underline strikethrough subscript superscript | font size " +
"style | color highlight removeformat | bullets numbering | outdent " +
"indent | alignleft center alignright justify | undo redo | "
});
$('#contract_begin_date').on('input propertychange', function(e) {
var date = new Date(e.target.value);
var yyyy = date.getFullYear() + 1;
var mm = date.getMonth() + 1;
var dd = date.getDate();
var time = yyyy + `-` + (mm < 10 ? '0' + mm : mm) + '-' + (dd < 10 ? '0' + dd : dd);
$('#contract_end_date').val(time);
});
$('#brand').change(function() {
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
if (_selected_status == 'Z') {
$('#brandModal').modal('show')
}
});
$('#assign_status').change(function() {
$("#next_users").empty();
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
var _option_tmp = ""; //獲取下拉列表
for (a in assigner) { //遍曆assigner
if (assigner[a][0] == _selected_status) {
_tmp = assigner[a][1].split(',');
for (var b in _tmp) {
if (_tmp[b] == '') {
continue;
}
_uname = _tmp[b].split('-')[1];
_uid = _tmp[b].split('-')[0];
/* console.log(_tmp[b]);*/
_option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>';
}
}
}
$("#next_users").append(_option_tmp);
});
$("#form").validate();
$("form").submit(function(e){
$('#reg_del').val(regDelStr);
});
});
addRow = function() {
var cmecRow = "<?= $cmecRow ?>";
$('#cmecTbody').append(cmecRow);
$("select[name^='elevator_kind'],select[name^='is_m1_bundle'] ").on('change', function(obj) {
//var children = $(this).parent().parent().parent().children();
var children = $(this).parent().parent().parent().prev('tr');
var floors = $(children).find("input[name^='floors']").val();
var speed = $(children).find("input[name^='speed']").val();
var weight = $(children).find("input[name^='weight']").val();
var persons = $(children).find("input[name^='persons']").val();
var maintain_times = $(children).find("input[name^='maintain_times']").val();
var maintain_months = $(children).find("input[name^='maintain_months']").val();
var maintain_period = $(children).find("input[name^='maintain_period']").val();
var maintain_kind = $('#maintain_kind').val();
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val();
var is_m1_bundle = $(this).val();//$(children).find("select[name^='is_m1_bundle'] option:selected").val();
//console.info($(this).parent().parent().parent().parent().parent().next());
//.val(maintain_months)
var element = $(this).parent().parent().parent().find("input[name^='stand_price']");
var param1 = {
...param,
persons,
floors,
speed,
weight,
maintain_times,
maintain_months,
maintain_period,
maintain_kind,
elevator_type,
is_m1_bundle
}
setStandPrice(param1, element);
//console.info(param1);
});
$("input[name^='floors']" +
",input[name^='speed']" +
",input[name^='persons']" +
",input[name^='weight']" +
",input[name^='maintain_times']" +
",input[name^='maintain_months']" +
",input[name^='maintain_period']"
).on('input propertychange', function(obj) {
// $(obj).parent().parent().parent().remove();
var children = $(this).parent().parent().parent().children();
var floors = $(children).find("input[name^='floors']").val();
var speed = $(children).find("input[name^='speed']").val();
var weight = $(children).find("input[name^='weight']").val();
var persons = $(children).find("input[name^='persons']").val();
var maintain_times = $(children).find("input[name^='maintain_times']").val();
var maintain_months = $(children).find("input[name^='maintain_months']").val();
var maintain_period = $(children).find("input[name^='maintain_period']").val();
var maintain_kind = $('#maintain_kind').val();
var elevator_type = $(children).find("select[name^='elevator_kind'] option:selected").val();
var is_m1_bundle = $(this).parent().parent().parent().next('tr').find("select[name^='is_m1_bundle'] option:selected").val();
var param1 = {
...param,
persons,
floors,
speed,
weight,
maintain_times,
maintain_months,
maintain_period,
maintain_kind,
elevator_type,
is_m1_bundle
}
var element = $(this).parent().parent().parent().next().children().find("input[name^='stand_price']");
setStandPrice(param1, element);
});
}
delRow = function(btn) {
if ($(btn).attr('name')=='btn1') {
//console.log($(btn).parent().parent().prev('tr').find('input[id=register_code]').val());
regDelStr += $(btn).parent().parent().find('input[id=register_code]').val()+",";
$(btn).parent().parent().next('tr').remove();
}
else {
//console.log($(btn).parent().parent().find('input[id=register_code]').val());
$(btn).parent().parent().next('tr').remove();
$(btn).parent().parent().remove();
}
$(btn).parent().parent().remove();
}
setStandPrice = function(p, obj) {
$.ajax({
url: '../con/t.php',
data: p,
type: 'get',
dataType: 'json',
//success: function(data) {},
success: function(data) {
console.info(data);
if (data.status == 'ok') {
$(obj).val(data.price);
} else {
$(obj).val(data.message);
}
}
});
}
addNewBrand = function() {
var new_brand = $("#new_brand").val();
if (new_brand != '') {
p = {
new_brand: new_brand,
method: 'add_brand'
}
$.ajax({
url: 'async_req.php',
data: p,
type: 'post',
dataType: 'json',
success: function(data) {
console.info(data);
$("#brand").append("<option value='" + data.seq + "'>" + new_brand + "</option>");
},
error: function(data) {
console.info(data);
}
});
}
}
</script>
<body>
<div id="toolbarmenu">
<!--<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>-->
<!-- 導航欄 -->
<ul class="nav nav-tabs" role="tablist" id="tablist">
<li class=" nav-item ">
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">簽核表單</a>
</li>
</ul>
</div>
<!-- 導航欄 END-->
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="submit.php" id='form' method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' />
<input type="hidden" name="token" value='<?= $_GET['token'] ?>' />
<input type="hidden" name="reg_del" id="reg_del">
<!--表單start-->
<div class=" form container-fluid pt-5">
<div class="row form_head ">
<div class=" col-12 form_head_title ">
<h4> 保養契約價格審核單</h4>
</div>
</div>
<div class="row " style='padding-top:30px;'>
<div class=" col-lg-12 form_row_header ">
<b>契約信息</b>
</div>
</div>
<?php
//一行顯示三列
$i = 0;
echo " <div class='row '>";
foreach ($editableColumn as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($data) ? "" : $data[0][$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "'
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>";
if ($i != 1 && $j == 0) {
echo "
</div>
<div class='row'>
";
}
echo " <div class='col-1 form_field_title'>
" . $val['label'] . "
</div>
<div class=' col-2 form_field_content ' >
$_input
</div>
";
}
echo "</div>";
?>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>洽商進度</b>
</div>
<div class="col-12 " style="padding:0">
<textarea class='form-control textarea' id="progress_remark" name="progress_remark" value='12' rows='6'><?= $hope_contract['progress_status'] ?></textarea>
</div>
</div>
<div id="elevator_list_area " class="row ">
<div class="col-12 form_row_header ">
<b>電梯詳細資料</b>
</div>
<table style='margin-top:0px;text-align:center' class=' table-condensed' id='elevator_list'>
<thead>
<tr>
<td colspan='18' style='text-align:left;font-size:13px'>
<b>註意事項:</b>
<p>1.速度單位是 米/分.</p>
<p>2.選擇贈送M1,保養月數需填寫60.</p>
<p>3.標準價格未帶出,請聯係業務部建立該規格報價.</p>
<p>4.無機房速度20~60米 以60米為標準.</p>
</td>
</tr>
<tr>
<td colspan='18' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td>
</tr>
<tr style='margin-top:0px;text-align:center'>
<?php
$j = 0;
foreach ($con_maintance_examine_clear_columm as $val) {
echo FormHelper::tag("th", ['colspan' => empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']);
//echo "<th>" . $val['label'] . "</th>";
if ((++$j % $col_count) == 0) {
if ($j == $col_count) echo "<th>操作</th>";
echo "</tr><tr style='margin-top:0px;text-align:center'>";
}
}
?>
</tr>
</thead>
<tbody id='cmecTbody'>
<?php
foreach ($con_maintance_examine_clear as $key => $val) {
$j = 0;
$cmecRow = " <tr>";
foreach ($con_maintance_examine_clear_columm as $col => $col_def) {
$fieldVal = empty($val) ? "" : $val[$col];
$_input = $col_def['tag'] == 'select' ?
FormHelper::select($col, $col_def['options'], $fieldVal, $col_def['attr'])
: FormHelper::text($col, $fieldVal, $col_def['attr'], $col_def['tag']);
$cmecRow .= "<td colspan='" . (empty($col_def['attr']['colspan']) ? '' :
$col_def['attr']['colspan']) . "' ><div class=' col-12'>
$_input</td>";
if ((++$j % $col_count) == 0) {
$cmecRow .= "<td><button name='btn1' onClick='delRow(this)' type='button' class='btn btn-link btn-md '>刪除</button></td>";
$cmecRow .= "</tr><tr>";
}
}
echo $cmecRow . "</tr>";
}
?>
</tbody>
</table>
</div>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>簽核操作</b>
</div>
<div class="col-12 col-3 form_field_content " style="padding:0">
<textarea id="assign_opinion" name="assign_opinion" required></textarea>
</div>
</div>
<div class="row">
<div class=" col-3 form_field_title">
<b style='float:right'>簽核狀態</b>
</div>
<div class=" col-2 form_field_content ">
<select name="assign_status" id="assign_status" required class='form-control form-control form-control-sm '>
<?php echo $assign_status; ?>
</select>
</div>
<div class=" col-2 form_field_title">
<b>下位簽核者</b>
</div>
<div class="col-2 form_field_content">
<select name="next_users" id="next_users" class='form-control form-control-sm '></select>
</div>
<div class="col-3 form_field_title ">
<button type="submit" name="btn_save" class="btn btn-warning btn-sm" value="save" style='float:left;margin-right:4px;'>保存</button>&nbsp;
<button type="submit" name="btn_save" class="btn btn-primary btn-sm" value="tosign" style='float:left'>提交</button>
</div>
</div>
<div id="opinion_area " class="row form_comment ">
<div class='col-12 '>
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'>
<li class="active nav-item ">
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a>
</li>
</ul>
</div>
<div class="tab-content col-12">
<div role="tabpanel" class="tab-pane active" id="main_flow_assign">
<?php
$assign_departs = array();
foreach ($assign_opinions as $as) {
$assign_departs[$as['assign_depart']] = $as['assign_depart_name'];
}
?>
<div class="comment_items ">
<?php $cnt = 1;
$tmp_code = "0";
foreach ($assign_opinions as $as) { ?>
<div class="comment-item">
<!-- <div class="comment-title">
<b></b>
</div>-->
<?php
if (($as['flow_code']) != $tmp_code)
echo ' <div class="comment-title">
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b>
</div>';
$tmp_code = $as['flow_code'];
?>
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>">
<div class="comment-content-header">
<span>
<strong>
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?>
&nbsp;
<?php if ($as['lead_code'] < 90) echo
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?>
</strong>
</span>
<span>
<strong>
&nbsp;
<?php if ($as['assign_status'] == 'S') echo
" <label class='comment-content-tag'>申請人 </label>"; ?>
<?php if (substr($as['assign_status'], 0, 1) == 'B')
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?>
<?php if (substr($as['assign_status'], 0, 2) == 'X3')
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?>
</strong>
</span>
<span class="comment-content-header-time">
簽核於:<?= $as['assign_date'] ?>
</span>
<!-- <ul class="comment-content-tags">
<li class="">不同意</li>
<li class="comment-content-tag-alert">退回</li>
</ul>-->
</div>
<div class="comment-content-body">
<?= $as['assign_opinion'] ?>
</div>
<!-- <div class="comment-content-footer">
<span>已上載附件:&nbsp;</span><a href="#">附件1</a>
</div>-->
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</form>
<!-- 模態框(Modal) -->
<div class="modal fade" id="brandModal" tabindex="-1" role="dialog" aria-labelledby="brandModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
新增廠牌
</div>
<div class="modal-body">
<input type="text" class='form-control form-control form-control-sm ' id='new_brand'>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" onClick="addNewBrand()" data-dismiss="modal">保存</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal -->
</div>
</div>
</div>
</body>

20
wms/con/async_req.php

@ -0,0 +1,20 @@
<?php
require_once './wf_common.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
//echo json_encode($request);
$func = $request['method'];
if (function_exists($func)) {
call_user_func($func, $request);
}
function add_brand($req)
{
$new_brand = $req['new_brand'];
list($code_name) = DB::fields("select cast(count(code_name) as SIGNED) +1 from code where field_name='elevator_brand' and code_name!='Z' ");
DB::query("INSERT INTO `code` (`field_name`, `code_name`, `content`, `remark`, `creator`, `create_at`) VALUES
('elevator_brand', '$code_name', '$new_brand', '电梯品牌', '', now());
");
echo json_encode(['seq' => $code_name]);
}

14
wms/con/con_maintance_examine_clear.php

@ -0,0 +1,14 @@
<?php
#电梯详细资料
$con_maintance_examine_clear_columm = [
'register_code' => ['label' => "电梯注册代码", "value" => "", "tag" => 'text', 'class' => ''],
'brand' => ['label' => "品牌", "value" => "", "tag" => 'text', 'class' => ''],
'spec' => ['label' => "规格型号", "value" => "", "tag" => 'text', 'class' => ''],
'weight' => ['label' => "载重", "value" => "", "tag" => 'text', 'class' => ''],
'speed' => ['label' => "速度", "value" => "", "tag" => 'text', 'class' => ''],
'stop' => ['label' => "停数", "value" => "", "tag" => 'text', 'class' => ''],
'useful_years' => ['label' => "使用年限", "value" => "", "tag" => 'text', 'class' => ''],
'last_check_date' => ['label' => "最近一次年检日期", "value" => "", "tag" => 'text', 'class' => ''],
'speed_governors_check_expense' => ['label' => "限速器校验费", "value" => "", "tag" => 'text', 'class' => ''],
];
$con_maintance_examine_clear = DB::result("SELECT * FROM con_maintance_examine_clear where 1=1 and cmstatus='Y' ");

21
wms/con/crmm06_submit.php

@ -0,0 +1,21 @@
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
require_once './wf_common.php';
require_once './model/HopeContractCustomerModel.php';
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
$hecm = new HopeContractCustomerModel();
$cols = $hecm->fillable;
foreach ($cols as $col) {
if (!in_array($col, array_keys($request))) {
continue;
}
$data[$col] = empty($request[$col]) ? NULL : $request[$col];
}
$hecm->create( $data);
echo"<script>alert('已保存');history.go(-1);</script>";

168
wms/con/list.php

@ -0,0 +1,168 @@
<?php
error_reporting(E_ALL);
ini_set("display_errors", "on");
/**
* 显示所有的待签 员工所有待签
*/
// 載入db.php來連結資料庫
require_once "../database.php";
require_once "../header.php";
$system_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['system_id'] : @$_POST['system_id'];
$where_system_id = " and a.system_id like '" . $system_id . "%'";
$flow_id = $_SERVER['REQUEST_METHOD'] == 'GET' ? @$_GET['flow_id'] : @$_POST['flow_id'];
$where_flow_id = " and b.flow_id like '" . $flow_id . "%'";
$sql_get = "select c.form_key, a.system_id,b.flow_id ,a.system_name,c.current_assigner,
concat(c.current_assigner ,'-',f_return_name(c.current_assigner)) current_assigner_name ,
flow_name,c.update_date ,c.create_date from system_main a,flow_main b ,subflow c,flow d
where a.system_id=b.system_id
and b.flow_id=d.flow_id
and d.flow_id=b.flow_id
and c.form_key=d.form_key
$where_system_id
$where_flow_id
";
//echo $sql_get;
$res_get = mysqli_fetch_all(mysqli_query($link, $sql_get), MYSQLI_ASSOC);
$system_name_opt = array_map(function ($item) {
return array('system_id' => $item['system_id'], 'system_name' => $item['system_name']);
}, $res_get);
$system_name_opt = (array_unique($system_name_opt, SORT_REGULAR));
$flow_name_opt = array_map(function ($item) {
return array('flow_id' => $item['flow_id'], 'flow_name' => $item['flow_name']);
}, $res_get);
$flow_name_opt = (array_unique($flow_name_opt, SORT_REGULAR));
?>
<style>
table {
table-layout: fixed;
width: 90%;
}
td {
word-wrap: break-word;
}
img {
width: 125px;
}
.width_style_1 {
width: 125px;
}
.table>tbody>tr>td,
.table>tbody>tr>th,
.table>tfoot>tr>td,
.table>tfoot>tr>th,
.table>thead>tr>td,
.table>thead>tr>th {
vertical-align: middle !important;
}
#table_index_filter {
float: right;
}
#table_index_paginate {
float: right;
}
table.query-table th {
text-align: right;
}
</style>
<form method='post' action='#'>
<table class='table query-table table-striped table-bordered display compact' style='width:90%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>待签查询</h3>
</td>
</tr>
</thead>
<tbody>
<tr>
<th style='width:50px'>系统名称</th>
<td colspan='1'>
<select class='form-control' name='system_id'>
<?php
echo " <option class='form-control' value='%' >全部</option>";
foreach ($system_name_opt as $opt) {
echo " <option class='form-control' value=" . $opt['system_id'] . " >" . $opt['system_name'] . "</option>";
}
?>
</select>
</td>
<th>流程名称</th>
<td colspan='1'> <select class='form-control' name='flow_id'>
<?php
echo " <option class='form-control' value='%' >全部</option>";
foreach ($flow_name_opt as $opt) {
echo " <option class='form-control' value=" . $opt['flow_id'] . " >" . $opt['flow_name'] . "</option>";
}
?>
</select> </td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="8" style='text-align:center'>
<button type="submit" style='text-align:center; margin:0 auto;width:50px' class="btn btn-primary">查询</button>
</td>
</tr>
</tfoot>
</table>
<div style="overflow-x:auto;width:92%;margin:0 auto">
<table id="table_index" style='width:100%;margin:0 auto' class="table table-striped table-bordered display compact">
<thead>
<tr>
<th>序号</th>
<th>系统名称</th>
<th>流程名称</th>
<th>接收日期</th>
<th>当前签核者</th>
</tr>
</thead>
<tbody>
<?php
$rowspan = 1;
foreach ($res_get as $key => $data) :
?>
<tr>
<td><a href="sign_form.php?form_key=<?= $data['form_key']; ?>"><?= $data['form_key']; ?></a></td>
<td><?php echo $data['system_name']; ?></td>
<td><?php echo $data['flow_name']; ?></td>
<td><?php echo $data['update_date']; ?></td>
<td><?php echo $data['current_assigner_name']; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
</form>
<?php
#代錶結束連線
mysqli_close($link);
require_once "../footer.php";
?>

29
wms/con/model/ConMaintanceExamineApplyModel.php

@ -0,0 +1,29 @@
<?php
require_once 'Model.php';
class ConMaintanceExamineApplyModel extends Model
{
protected $table = 'con_maintance_examine_apply';
protected $fillable = [
'apply_key',
'vol_no',
'form_key',
'customer',
'address',
'case_name',
'brand',
'num',
'salesman',
'maintain_kind',
'contract_begin_date',
'contract_end_date',
'contract_kind',
'platform_company',
'platforom_company_tel',
'payment_kind',
'progress_remark',
'introducer',
'creater',
'updated_at',
];
}

33
wms/con/model/ConMaintanceExamineClearModel.php

@ -0,0 +1,33 @@
<?php
require_once 'Model.php';
class ConMaintanceExamineClearModel extends Model
{
protected $table = 'con_maintance_examine_clear';
public $fillable = [
'apply_key',
'register_code',
'elevator_brand',
'elevator_kind',
'spec',
'weight',
'speed',
'stop',
'floors',
'persons',
'elevator_num',
'useful_years',
'last_check_date',
'speed_governors_check_expense',
'maintain_times',
'is_m1_bundle',
'maintain_months',
'maintain_period',
'stand_price',
'contract_price',
'sold_price',
// 'commission_expense',
//// 'management_expense',
'annual_survey_expense',
// 'service_expense',
];
}

53
wms/con/model/Model.php

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

510
wms/con/query_form.php

@ -0,0 +1,510 @@
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
require_once "../header_nomenu.php";
$apply_key = $_GET['apply_key'];
#$vol_no = $qword->vol_no;
require_once './MICalculator.php';
require_once './FormHelper.php';
require_once './wf_common.php';
list($form_key) = DB::fields("select form_key from con_maintance_examine_apply where apply_key='$apply_key'");
//echo $form_key;
$flow = new Flow($form_key);
// 當前節點簽核開始
//var_dump($flow);
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $form_key);
#獲取簽核意見
$assign_opinions = Assign::get_records($form_key);
$flowName = $wf->getFlowName();
$assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner);
//表單數據
#客戶表
#客戶表
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand'";
$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='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.付款方式
$sql = "select code_name value ,content label from code where field_name='payment_kind'";
$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);
$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" => 'number', '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' => ['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']],
// '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],
];
$where = " and apply_key='$apply_key'";
$sql = "SELECT * FROM $table where 1=1 $where ORDER BY apply_key";
$data = [];
list($data) = DB::result($sql);
#電梯詳細資料
$con_maintance_examine_clear_columm = [
'register_code' => ['label' => "電梯許可證代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', '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" => 'number', 'attr' => ['name' => 'weight[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', '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" => 'number', 'attr' => ['name' => 'floors[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'persons' => ['label' => "人乘", "value" => "", "tag" => 'number', 'attr' => ['name' => 'persons[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'number', '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],
// 'elevator_num' => ['label' => "臺數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']],
'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'required', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']],
'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'date', 'attr' => ['required', 'name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']],
//'speed_governors_check_expense' => ['label' => "限速器校驗費", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed_governors_check_expense[]', 'class' => 'form-control form-control-sm']],
// 'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']],
// 'commission_expense' => ['label' => "分成費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'commission_expense[]', 'class' => 'form-control form-control-sm']],
// 'management_expense' => ['label' => "管理費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'management_expense[]', 'class' => 'form-control form-control-sm']],
'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', 'colspan' => 2, 'class' => 'date form-control form-control-sm ']],
//'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']],
'maintain_times' => ['label' => "保養次數", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']],
'maintain_period' => ['label' => "保養周期", "tag" => 'number', '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' => "標準價格A(元/月)", "value" => "", "tag" => 'text', 'attr' => ['required', "readonly", 'colspan' => 2, 'name' => 'stand_price[]', 'class' => 'form-control form-control-sm']],
'contract_price' => ['label' => "契約報價B(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'contract_price[]', 'class' => 'form-control form-control-sm']],
'sold_price' => ['label' => "契約成交價C(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']],
'mi_cost' => ['label' => "標準成本D(元/月)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true','disabled', 'colspan' => 2, 'name' => 'mi_cost[]', 'class' => 'form-control form-control-sm']],
'discount' => ['label' => "折扣率E(%)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true','disabled', 'colspan' => 2, 'name' => 'mi_cost_rate[]', 'class' => 'form-control form-control-sm']],
'gross_profit' => ['label' => "毛利率F(%)", "value" => "", "tag" => 'number', 'attr' => ['readonly=true','disabled', 'colspan' => 2, 'name' => 'gross_profit[]', 'class' => 'form-control form-control-sm']],
];
$con_maintance_examine_clear = DB::result("SELECT register_code,
f_return_content('elevator_brand',elevator_brand) elevator_brand,
f_return_content('maintain_elevator_kind',elevator_kind) elevator_kind,
elevator_kind con_elevator_kind,
spec,
weight,
speed,
floors,
persons,
maintain_times,
maintain_months,
maintain_period,
is_m1_bundle,
useful_years,
last_check_date,
speed_governors_check_expense,
service_expense,
commission_expense,
management_expense,
annual_survey_expense,
stand_price,
contract_price,
sold_price,
0 mi_cost ,
0 discount,
0 gross_profit
FROM
con_maintance_examine_clear
WHERE
1 = 1
AND apply_key='" . $apply_key . "' and cmstatus = 'Y'");
function base_url($url)
{
return "https://www.masada.com.tw/static/" . $url;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> <?php echo $flowName; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" />
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<script type="text/javascript">
$(document).ready(function() {
var tag_data;
$.ajax({
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner',
type: 'post',
dataType: 'json',
success: function(data) {
window.tag_data = data;
$('#selectPage').selectPage({
showField: 'show_name',
keyField: 'val',
data: data,
multiple: true,
multipleControlbar: true,
pagination: false,
focusDropList: false
});
}
});
var assigner = eval('<?= json_encode($assigner) ?>');
// $('#cmecTbody').append(cmecRow);
$('.sp_element_box').attr("disabled", true);
$("#assign_opinion").cleditor({
height: 100, // height not including margins, borders or padding
controls: // controls to add to the toolbar
"bold italic underline strikethrough subscript superscript | font size " +
"style | color highlight removeformat | bullets numbering | outdent " +
"indent | alignleft center alignright justify | undo redo | "
});
$('#assign_status').change(function() {
$("#next_users").empty();
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
var _option_tmp = ""; //獲取下拉列表
for (a in assigner) { //遍曆assigner
if (assigner[a][0] == _selected_status) {
_tmp = assigner[a][1].split(',');
for (var b in _tmp) {
if (_tmp[b] == '') {
continue;
}
_uname = _tmp[b].split('-')[1];
_uid = _tmp[b].split('-')[0];
/* console.log(_tmp[b]);*/
_option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>';
}
}
}
$("#next_users").append(_option_tmp);
});
});
</script>
</head>
<body>
<!-- 導航欄 END-->
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="submit.php" method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' />
<input type="hidden" name="apply_key" value='<?php echo $apply_key; ?>' />
<!--表單start-->
<div class=" form container-fluid pt-5">
<div class="row form_head ">
<div class=" col-12 form_head_title ">
<h4> 保養契約價格審核單</h4>
</div>
</div>
<div class="row " style='padding-top:30px;'>
<div class=" col-lg-12 form_row_header ">
<b>契約信息</b>
</div>
</div>
<?php
//一行顯示三列
$i = 0;
echo " <div class='row '>";
foreach ($editableColumn as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($data) ? "" : $data[$key];
$fieldVal = empty($data) ? "" : $data[$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) :
FormHelper::tag("label", $val['attr'], $fieldVal);
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "'
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>";
if ($i != 1 && $j == 0) {
echo "
</div>
<div class='row'>
";
}
echo " <div class='col-1 form_field_title'>
" . $val['label'] . "
</div>
<div class=' col-2 form_field_content ' >
$_input
</div>
";
}
echo "</div>";
?>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>洽商進度</b>
</div>
<div class="col-12 " style="padding:0">
<textarea class='form-control textarea' disabled id="progress_remark" name="progress_remark" value='12' rows='6'><?= $data['progress_remark'] ?></textarea>
</div>
</div>
<div id="elevator_list_area " class="row ">
<div class="col-12 form_row_header ">
<b>電梯詳細資料</b>
</div>
<table style='margin-top:0px;text-align:center' id='elevator_list'>
<thead>
<tr style='margin-top:0px;text-align:center'>
<?php
$j = 0;
foreach ($con_maintance_examine_clear_columm as $val) {
echo FormHelper::tag("th", ['colspan' => empty($val['attr']['colspan'])
? 1 : $val['attr']['colspan']], $val['label']);
if ((++$j % 14) == 0) {
// if ($j == 12) echo "<th>操作</th>";
echo "</tr><tr style='margin-top:0px;text-align:center'>";
}
}
?>
</tr>
</thead>
<tbody id='cmecTbody'>
<?php
$i = 0;
$tr_class = "odd";
foreach ($con_maintance_examine_clear as $key => $val) {
$j = 0;
$cmecRow = " <tr $i class='$tr_class'>";
foreach ($con_maintance_examine_clear_columm as $col => $col_def) {
$fieldVal = empty($val) ? "" : $val[$col];
if ($col == 'mi_cost') {
$param = [
'elevator_type' => $val['con_elevator_kind'],
'floors' => $val['floors'],
'speed' => $val['speed'],
'persons' => $val['persons'],
'weight' => $val['weight'],
'maintain_times' => $val['maintain_times'],
'maintain_months' => $val['maintain_months'],
'maintain_kind' => $data['maintain_kind'],
'maintain_period' => $val['maintain_period'],
'is_m1_bundle' => $val['is_m1_bundle'],
];
$mic = new MICalculator();
$res = $mic->cal($param);
#MI報價
$con_maintance_examine_clear[$key]['mi_cost'] = $fieldVal = $res['status'] == 'ok' ? $res['price'] : $res['message'];
$con_maintance_examine_clear[$key]['gross_profit'] = $val['gross_profit'] = "/"; //$fieldVal==0?0: (round(($val['sold_price'] - $val['mi_cost']) / $fieldVal, 2) * 100) . "%"
#扣率
$val['discount'] = (100 * round($val['sold_price'] / $val['stand_price'], 4)) . "%";
}
$_input = FormHelper::tag("label", ['colspan' => empty($col_def['attr']['colspan']) ? 1
: $col_def['attr']['colspan']], $fieldVal);
$cmecRow .= "<td colspan='" . (empty($col_def['attr']['colspan']) ? ''
: $col_def['attr']['colspan']) . "' ><div class=' col-12'> $_input</td>";
$cmecRow = (++$j % 14 == 0) ? $cmecRow . "</tr ><tr $i class='$tr_class'>" : $cmecRow;
}
$tr_class = $tr_class == 'odd' ? "even" : "odd";
echo $cmecRow . "</tr>";
}
?>
</tbody>
<tfoot>
<?php
#總臺數
$count = count($con_maintance_examine_clear);
#總成交價
$total_sold_price = 0;
#總標準價格
$total_stand_price = 0;
#總標準成本
$total_mi_cost = 0;
foreach ($con_maintance_examine_clear as $val) {
$total_sold_price += $val['sold_price'];
$total_stand_price += $val['stand_price'];
$total_mi_cost += $val['mi_cost'];
}
$total_discount_rate = $total_sold_price == 0 ? 0 : (100 * round($total_sold_price / $total_stand_price, 4)) . "%"
?>
<tr>
<td colspan='20'>
<div style='float:right'>
<label>合計成交價:<?= $count == 0 ? $count : $total_sold_price ?>; </label>
<label>合計成本:<?= $count == 0 ? $count : $total_mi_cost ?>; </label>
<label>折扣率(C/A):<?= $total_discount_rate ?>; </label>
<label>毛利率:/</label>
</div>
</td>
</tr>
</tfoot>
</table>
</div>
<div id="opinion_area " class="row form_comment ">
<div class='col-12 '>
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'>
<li class="active nav-item ">
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a>
</li>
</ul>
</div>
<div class="tab-content col-12">
<div role="tabpanel" class="tab-pane active" id="main_flow_assign">
<?php
$assign_departs = array();
foreach ($assign_opinions as $as) {
$assign_departs[$as['assign_depart']] = $as['assign_depart_name'];
}
?>
<div class="comment_items ">
<?php $cnt = 1;
$tmp_code = "0";
foreach ($assign_opinions as $as) { ?>
<div class="comment-item">
<!-- <div class="comment-title">
<b></b>
</div>-->
<?php
if (($as['flow_code']) != $tmp_code)
echo ' <div class="comment-title">
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b>
</div>';
$tmp_code = $as['flow_code'];
?>
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>">
<div class="comment-content-header">
<span>
<strong>
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?>
&nbsp;
<?php if ($as['lead_code'] < 90) echo
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?>
</strong>
</span>
<span>
<strong>
&nbsp;
<?php if ($as['assign_status'] == 'S') echo
" <label class='comment-content-tag'>申請人 </label>"; ?>
<?php if (substr($as['assign_status'], 0, 1) == 'B')
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?>
<?php if (substr($as['assign_status'], 0, 2) == 'X3')
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?>
</strong>
</span>
<span class="comment-content-header-time">
簽核於:<?= $as['assign_date'] ?>
</span>
<!-- <ul class="comment-content-tags">
<li class="">不同意</li>
<li class="comment-content-tag-alert">退回</li>
</ul>-->
</div>
<div class="comment-content-body">
<?= $as['assign_opinion'] ?>
</div>
<!-- <div class="comment-content-footer">
<span>已上載附件:&nbsp;</span><a href="#">附件1</a>
</div>-->
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>

507
wms/con/review_apply_form.php

@ -0,0 +1,507 @@
<?php
error_reporting(E_ALL);
ini_set("display_errors", "On");
$q = empty($_GET['q']) ? "" : $_GET['q'];
$qword = json_decode(base64_decode(pack("H*", $q)));
$user_id = $qword->user_id;
$apply_key = 'MB23060422';
require_once './FormHelper.php';
require_once './wf_common.php';
#系统ID
$system_id = 'con';
#流程ID
$flow_id = 'con01';
#表单号 $form_id;
$form_id = "";
$wf = new WorkFlow($system_id, $flow_id, $form_id);
$wf->initWorkFlow($user_id);
$form_key = $wf->flowContext->getFormKey();
#获取签核意见
$assign_opinions = Assign::get_records($form_key);
#会签部门意见
$subflow_assign_opinions = SubflowManager::getCounterSignComments($form_key);
$flowName = $wf->getFlowName();
$assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner);
$if_show_assign = true;
#是否可会签
$isSplitable = $wf->isSplitable();
//表单数据
#客户表
#1.电梯品牌选项
$sql = "select code_name value ,content label from code where field_name='elevator_brand' order by convert(content using gbk) asc ";
$elevator_brand_opt = DB::result($sql);
#2.保养方式
$sql = "select code_name value ,content label from code where field_name='maintain_kind'";
$maintain_kind_opt = DB::result($sql);
#3.电梯类型
$sql = "select code_name value ,content label from code where field_name='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.付款方式
$sql = "select code_name value ,content label from code where field_name='payment_kind'";
$payment_kind_opt = DB::result($sql);
#5.合约性质
$sql = "select code_name value ,content label from code where field_name='hope_contract_customer_kind'";
$contract_kind_opt = DB::result($sql);
#抓取有
$where = " and apply_key='$apply_key'";
$sql = "SELECT * FROM con_maintance_examine_apply where 1=1 $where ";
$res_cmea = DB::result($sql);
$cmea = empty($res_cmea) ? [] : $res_cmea[0];
#写入 con_maintance_review_apply
#获取评审单号
//$cmea['payment_kind']; //付款方式
//月付 12; 季付 三月一次;半年付 6个月一次, 年付 12个月
//
$insert_data = [
'apply_key' => $apply_key,
'vol_no' => $cmea['vol_no'],
'form_key' => $cmea,
'address' => $cmea['address'],
'case_name' => $cmea['case_name'],
'num' => $cmea['num'],
'brand' => $cmea['brand'],
'customer' => $hope_contract['customer'],
'salesman' => $hope_contract['salesman'],
'progress_remark' => $hope_contract['progress_remark'],
'platform_company' => empty(trim($hope_contract['common_platform_company'])) ? $hope_contract['sales_platform_company'] : $hope_contract['common_platform_company'],
'platforom_company_tel' => empty(trim($hope_contract['common_platform_tel'])) ? $hope_contract['sales_platform_tel'] : $hope_contract['common_platform_tel']
];
//var_dump($insert_data);
DB::insert_table('con_maintance_examine_apply', $insert_data);
// $ins_sql="INSERT INTO `adm824727563_db`.`hope_contract_customer` (`vol_no`, `customer_kind`, `num`, `case_name`, `customer`,
// `salesman`, `address`, `lm_name`, `lm_tel`, `pre_order_date`, `order_rate`, `visit_date`, `progress_remark`, `common_platform_lm`, `common_platform_tel`,
// `common_platform_company`, `sales_platform_lm`, `sales_platform_tel`, `sales_platform_company`, `is_strategic_customer`,
// `strategic_customer`, `brand`, `partya_end_date`, `created_at`, `creator`, `updated_at`) VALUES ('Q2305047', '1', '47', '辰富佳苑', '上海新桃源物业管理有限公司', 'P0053', '松江广富林路3939弄', '周总', '13482376166', '2023-06-30 00:00:00', '中', '2023-05-23 18:13:05', '该物业为国有企业,本次 拜访物业沈经理引荐周总。经过与周总交流要求我司进行投标,今天进公司注册云采购账号,等公示后进一步了解如何投标再与周总会面细谈。', NULL, NULL, NULL, NULL, NULL, NULL, 'N', NULL, '永大', '2023-06-30 00:00:00', '2023-05-25 10:15:31', 'P0053', '2023-05-29 14:22:35');
// ";
$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']],
//'form_key' => ['label' => "表单号", "value" => "", "tag" => 'text', 'attr'=>['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" => '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'], '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']],
'elevator_kind' => ['label' => "电梯类型", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $elevator_kind_opt],
'contract_kind' => ['label' => "合约性质", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm'], 'options' => $contract_kind_opt],
'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']],
'stand_price' => ['label' => "标准价格(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'contract_price' => ['label' => "合约报价(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'sold_price' => ['label' => "合约成交价(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt],
'commission_expense' => ['label' => "加盟分成费(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'management_expense' => ['label' => "我司管理费(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'annual_survey_expense' => ['label' => "年检费用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'date form-control form-control-sm ']],
'service_expense' => ['label' => "服务费", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => ' form-control form-control-sm ']],
// 'postgress_remark' => ['label' => "洽商进度", "value" => "", "tag" => 'text', 'attr'=>['class' => 'form-control form-control-sm' ]]
];
$vol_no = empty($_GET['vol_no']) ? "" : $_GET['vol_no'];
$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[]', '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],
'spec' => ['label' => "规格型号", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'spec[]', 'class' => 'form-control form-control-sm']],
'weight' => ['label' => "载重(KG)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'weight[]', 'class' => 'form-control form-control-sm']],
'speed' => ['label' => "速度(m/s)", "value" => "", "tag" => 'number', 'attr' => ['name' => 'speed[]', 'class' => 'form-control form-control-sm']],
'stop' => ['label' => "停数", "value" => "", "tag" => 'number', 'attr' => ['name' => 'stop[]', 'class' => 'form-control form-control-sm']],
'elevator_num' => ['label' => "台数", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']],
'useful_years' => ['label' => "使用年限", "value" => "", "tag" => 'number', 'attr' => ['name' => 'useful_years[]', 'class' => 'form-control form-control-sm']],
'last_check_date' => ['label' => "最近一次年检日期", "value" => "", "tag" => 'date', 'attr' => ['name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']],
'speed_governors_check_expense' => ['label' => "限速器校验费", "value" => "", "tag" => 'number', 'attr' => ['name' => 'speed_governors_check_expense[]', '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' ");
$i = 0;
$cmecRow = " <tr>";
foreach ($con_maintance_examine_clear_columm as $key => $val) {
$fieldVal = "";
$_input = $val['tag'] == 'select' ?
FormHelper::select('', $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
// : "<input type='" . $val['tag'] . "' class=' form-control form-control-sm' " . $val['attr'] . " value='" . $fieldVal . "' name='${key}[]' id='$key' placeholder='请输入'>";
$cmecRow .= "<td colspan='" . (empty($val['attr']['colspan']) ? '' : $val['attr']['colspan']) . "' ><div class=' col-12' > $_input</td>";
}
$cmecRow .= "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md'>删除</button></td>";
function base_url($url)
{
return "https://web.platform-cn.com/static/" . $url;
}
function get_sequnece_no($seq_name = '', $p_yyyymm = '')
{
if (empty($p_yyyymm) || empty($seq_name)) return null;
#当前年月
//echo "select yyyymm from sequence where seq_name='$seq_name' ";
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(nextval('$seq_name'),2)) seq_no ");
return $seq_no;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title> <?php echo $flowName; ?></title>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" />
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script>
<script src="https://static.runoob.com/assets/jquery-validation-1.14.0/dist/jquery.validate.min.js"></script>
<script src="https://static.runoob.com/assets/jquery-validation-1.14.0/dist/localization/messages_zh.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<script type="text/javascript">
$(document).ready(function() {
var tag_data;
$.ajax({
url: 'https://web.platform-cn.com/fds/index.php/DesignFlow/get_assigner',
type: 'post',
dataType: 'json',
success: function(data) {
window.tag_data = data;
$('#selectPage').selectPage({
showField: 'show_name',
keyField: 'val',
data: data,
multiple: true,
multipleControlbar: true,
pagination: false,
focusDropList: false
});
}
});
var assigner = eval('<?= json_encode($assigner) ?>');
var cmecRow = "<?= str_replace('"', '\'', $cmecRow) ?>";
// $('#cmecTbody').append(cmecRow);
$('.sp_element_box').attr("disabled", true);
$("#assign_opinion").cleditor({
height: 100, // height not including margins, borders or padding
controls: // controls to add to the toolbar
"bold italic underline strikethrough subscript superscript | font size " +
"style | color highlight removeformat | bullets numbering | outdent " +
"indent | alignleft center alignright justify | undo redo | "
});
$('#assign_status').change(function() {
$("#next_users").empty();
var _selected_status = $(this).children('option:selected').val(); //获取被选择的状态
var _option_tmp = ""; //获取下拉列表
for (a in assigner) { //遍历assigner
if (assigner[a][0] == _selected_status) {
_tmp = assigner[a][1].split(',');
for (var b in _tmp) {
if (_tmp[b] == '') {
continue;
}
_uname = _tmp[b].split('-')[1];
_uid = _tmp[b].split('-')[0];
/* console.log(_tmp[b]);*/
_option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>';
}
}
}
$("#next_users").append(_option_tmp);
});
$("#form").validate();
});
addRow = function() {
var cmecRow = "<?= $cmecRow ?>";
$('#cmecTbody').append(cmecRow);
}
delRow = function(btn) {
$(btn).parent().parent().remove();
}
</script>
</head>
<body>
<div id="toolbarmenu">
<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>
<!-- 导航栏 -->
<ul class="nav nav-tabs" role="tablist" id="tablist">
<li class=" nav-item ">
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">签核表单</a>
</li>
</ul>
</div>
<!-- 导航栏 END-->
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="submit.php" id='form' method="post" style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' />
<input type="hidden" value="" name="sheet_no" />
<!--表单start-->
<div class=" form container-fluid pt-5">
<div class="row form_head ">
<div class=" col-12 form_head_title ">
<h4> 保養合約價格審核單</h4>
</div>
</div>
<div class="row " style='padding-top:30px;'>
<div class=" col-lg-12 form_row_header ">
<b>合约信息</b>
</div>
</div>
<?php
//一行显示三列
$i = 0;
echo " <div class='row '>";
foreach ($editableColumn as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($data) ? "" : $data[0][$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr'])
: FormHelper::text("$key", $fieldVal, $val['attr'], $val['tag']);
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "'
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='请输入'>";
if ($i != 1 && $j == 0) {
echo "
</div>
<div class='row'>
";
}
echo " <div class='col-1 form_field_title'>
" . $val['label'] . "
</div>
<div class=' col-2 form_field_content ' >
$_input
</div>
";
}
echo "</div>";
?>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>洽商进度</b>
</div>
<div class="col-12 " style="padding:0">
<textarea class='form-control textarea' id="progress_remark" name="progress_remark" value='12' rows='6'><?= $data[0]['progress_remark'] ?></textarea>
</div>
</div>
<div id="elevator_list_area " class="row ">
<div class="col-12 form_row_header ">
<b>电梯详细资料</b>
</div>
<table style='margin-top:0px;text-align:center' id='elevator_list'>
<thead>
<tr>
<td colspan='15' ;><button onClick='addRow()' type="button" style='float:right' class="btn btn-link btn-md">+新增</button></td>
</tr>
<tr style='margin-top:0px;text-align:center'>
<?php
foreach ($con_maintance_examine_clear_columm as $val) {
echo FormHelper::tag("th", ['colspan' => empty($val['attr']['colspan']) ? 1 : $val['attr']['colspan']], $val['label']);
//echo "<th>" . $val['label'] . "</th>";
}
echo "<th>操作</th>";
?>
</tr>
</thead>
<tbody id='cmecTbody'>
<?php
foreach ($con_maintance_examine_clear as $key => $val) {
$cmecRow = " <tr>";
foreach ($con_maintance_examine_clear_columm as $col => $col_def) {
$fieldVal = empty($val) ? "" : $val[$col];
$_input = $col_def['tag'] == 'select' ?
FormHelper::select($col, $col_def['options'], $fieldVal, $col_def['attr'])
: FormHelper::text($col, $fieldVal, $col_def['attr'], $col_def['tag']);
$cmecRow .= "<td colspan='" . (empty($col_def['attr']['colspan']) ? '' : $col_def['attr']['colspan']) . "' ><div class=' col-12'> $_input</td>";
}
echo $cmecRow . "<td><button onClick='delRow(this)' type='button' class='btn btn-link btn-md '>删除</button></td></tr>";
}
?>
</tbody>
</table>
</div>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>签核操作</b>
</div>
<div class="col-12 col-3 form_field_content " style="padding:0">
<textarea id="assign_opinion" name="assign_opinion" required></textarea>
</div>
</div>
<div class="row">
<div class=" col-3 form_field_title">
<b style='float:right'>签核状态</b>
</div>
<div class=" col-2 form_field_content ">
<select name="assign_status" id="assign_status" required class='form-control form-control form-control-sm '>
<?php echo $assign_status; ?>
</select>
</div>
<div class=" col-2 form_field_title">
<b>下位签核者</b>
</div>
<div class="col-2 form_field_content">
<select name="next_users" id="next_users" required class='form-control form-control-sm '></select>
</div>
<div class="col-3 form_field_title ">
<button type="submit" class="btn btn-primary btn-sm" style='float:left'>提交</button>
</div>
</div>
<div id="opinion_area " class="row form_comment ">
<div class='col-12 '>
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'>
<li class="active nav-item ">
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">签核意见</a>
</li>
</ul>
</div>
<div class="tab-content col-12">
<div role="tabpanel" class="tab-pane active" id="main_flow_assign">
<?php
$assign_departs = array();
foreach ($assign_opinions as $as) {
$assign_departs[$as['assign_depart']] = $as['assign_depart_name'];
}
?>
<div class="comment_items ">
<?php $cnt = 1;
$tmp_code = "0";
foreach ($assign_opinions as $as) { ?>
<div class="comment-item">
<!-- <div class="comment-title">
<b></b>
</div>-->
<?php
if (($as['flow_code']) != $tmp_code)
echo ' <div class="comment-title">
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b>
</div>';
$tmp_code = $as['flow_code'];
?>
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>">
<div class="comment-content-header">
<span>
<strong>
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?>
&nbsp;
<?php if ($as['lead_code'] < 90) echo
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?>
</strong>
</span>
<span>
<strong>
&nbsp;
<?php if ($as['assign_status'] == 'S') echo
" <label class='comment-content-tag'>申请人 </label>"; ?>
<?php if (substr($as['assign_status'], 0, 1) == 'B')
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?>
<?php if (substr($as['assign_status'], 0, 2) == 'X3')
echo " <label class='comment-content-tag red-tag'>会签</label>"; ?>
</strong>
</span>
<span class="comment-content-header-time">
签核于:<?= $as['assign_date'] ?>
</span>
<!-- <ul class="comment-content-tags">
<li class="">不同意</li>
<li class="comment-content-tag-alert">退回</li>
</ul>-->
</div>
<div class="comment-content-body">
<?= $as['assign_opinion'] ?>
</div>
<!-- <div class="comment-content-footer">
<span>已上传附件:&nbsp;</span><a href="#">附件1</a>
</div>-->
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>

575
wms/con/sign_form.php

@ -0,0 +1,575 @@
<?php
#error_reporting(E_ALL);
#ini_set("display_errors", "On");
require_once '../header_nomenu.php';
//echo $user_id;
$apply_key = "";
$form_key = $_GET['form_key'];
$token = $_GET['token'];
#$vol_no = $qword->vol_no;
require_once './FormHelper.php';
require_once '../con/MICalculator.php';
require_once './wf_common.php';
$flow = new Flow($form_key);
// 當前節點簽核開始
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $form_key);
#獲取簽核意見
$assign_opinions = Assign::get_records($form_key);
$flowName = $wf->getFlowName();
//表單數據
#客戶表
#1.電梯品牌選項
$sql = "select code_name value ,content label from code where field_name='elevator_brand'";
$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='elevator_kind'";
$elevator_kind_opt = DB::result($sql);
#4.付款方式
$sql = "select code_name value ,content label from code where field_name='payment_kind'";
$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);
$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" => 'number', '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' => ['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 form_key='$form_key'";
$sql = "SELECT " . implode(',', array_keys($editableColumn)) .
" ,progress_remark FROM $table where 1=1 $where ORDER BY apply_key";
$data = [];
list($data) = DB::result($sql);
#電梯詳細資料
$con_maintance_examine_clear_columm = [
'register_code' => ['label' => "電梯註冊代碼", "value" => "", "tag" => 'text', 'attr' => ['colspan' => 2, 'name' => 'register_code[]', '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" => 'number', 'attr' => ['name' => 'weight[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'speed' => ['label' => "速度(m/min)", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed[]', '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" => 'number', 'attr' => ['name' => 'floors[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'persons' => ['label' => "人乘", "value" => "", "tag" => 'number', 'attr' => ['name' => 'persons[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_times' => ['label' => "保養次數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "value" => "", "tag" => 'number', '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],
// 'elevator_num' => ['label' => "臺數", "value" => "", "tag" => 'number', 'attr' => ['name' => 'brand_num[]', 'class' => 'form-control form-control-sm']],
'useful_years' => ['label' => "竣工檢查年度", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'required', 'name' => 'useful_years[]', 'class' => 'form-control form-control-sm']],
'last_check_date' => ['label' => "上次年檢日期", "value" => "", "tag" => 'date', 'attr' => ['required', 'name' => 'last_check_date[]', 'colspan' => 2, 'type' => 'date', 'class' => 'form-control form-control-sm']],
//'speed_governors_check_expense' => ['label' => "限速器校驗費", "value" => "", "tag" => 'number', 'attr' => ['colspan' => 2, 'name' => 'speed_governors_check_expense[]', 'class' => 'form-control form-control-sm']],
// 'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']],
// 'commission_expense' => ['label' => "分成費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'commission_expense[]', 'class' => 'form-control form-control-sm']],
// 'management_expense' => ['label' => "管理費(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'management_expense[]', 'class' => 'form-control form-control-sm']],
//'annual_survey_expense' => ['label' => "年檢費用(元)", "value" => "", "tag" => 'number', 'attr' => ['required', 'name' => 'annual_survey_expense[]', 'colspan' => 2, 'class' => 'date form-control form-control-sm ']],
//'service_expense' => ['label' => "服務費", "value" => "", "tag" => 'text', 'attr' => ['required', 'name' => 'service_expense[]', 'class' => ' form-control form-control-sm ']],
'maintain_times' => ['label' => "保養次數", "tag" => 'number', 'attr' => ['name' => 'maintain_times[]', "value" => "1", 'min=1', 'required', 'class' => 'form-control form-control-sm']],
'maintain_months' => ['label' => "保養月數", "tag" => 'number', 'attr' => ['name' => 'maintain_months[]', "value" => "12", 'min=12', 'required', 'class' => 'form-control form-control-sm']],
'maintain_period' => ['label' => "保養周期", "tag" => 'number', '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']],
'sold_price' => ['label' => "契約成交價C(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'sold_price[]', 'class' => 'form-control form-control-sm']],
'mi_cost' => ['label' => "標準成本D(元/月)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'mi_cost[]', 'class' => 'form-control form-control-sm']],
'discount' => ['label' => "折扣率E(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'mi_cost_rate[]', 'class' => 'form-control form-control-sm']],
'gross_profit' => ['label' => "毛利率F(%)", "value" => "", "tag" => 'number', 'attr' => ['required', 'colspan' => 2, 'name' => 'gross_profit[]', 'class' => 'form-control form-control-sm']],
];
$con_maintance_examine_clear = DB::result("SELECT register_code,
f_return_content('elevator_brand',elevator_brand) elevator_brand,
f_return_content('maintain_elevator_kind',elevator_kind) elevator_kind,
elevator_kind con_elevator_kind,
spec,
weight,
speed,
floors,
persons,
maintain_times,
maintain_months,
maintain_period,
is_m1_bundle,
useful_years,
last_check_date,
speed_governors_check_expense,
service_expense,
stand_price,
contract_price,
sold_price,
0 mi_cost ,
0 discount,
0 gross_profit
FROM
con_maintance_examine_clear
WHERE
1 = 1
AND apply_key='" . $data['apply_key'] . "' and cmstatus='Y'");
#總臺數
$count = count($con_maintance_examine_clear);
$total_sold_price = 0;
#總成交價
#總標準價格
$total_stand_price = 0;
#總標準成本
foreach ($con_maintance_examine_clear as $val) {
$total_sold_price += $val['sold_price'];
$total_stand_price += $val['stand_price'];
}
$total_discount_rate = $total_sold_price == 0 ? 0
: (100*round($total_sold_price / $total_stand_price, 4)) . "%";
$wf->setFormData(['discount' => substr($total_discount_rate, 0, -1)]);
$assigner = $wf->getAssignerList();
$assign_status = $wf->getAssignStatus($assigner);
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;
#當前年月
//echo "select yyyymm from sequence where seq_name='$seq_name' ";
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(nextval('$seq_name'),2)) seq_no ");
return $seq_no;
}
?>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/jquery.cleditor.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('bootstrap4/css/bootstrap.min.css'); ?>" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/layui.css'); ?>" />
<script type="text/javascript" src="<?php echo base_url('js/jquery3.7.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/selectpage.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/jquery.cleditor.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('bootstrap4/js/bootstrap.min.js'); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/layui.js?' . rand(10, 100)); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/wf_property.js?') . rand(10, 100); ?>"></script>
<script type="text/javascript" src="<?php echo base_url('js/flow_chart.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/jquery.validate.min.js?' . rand(10, 100)); ?>"></script>
<script src="<?php echo base_url('js/validate/messages_zh_TW.js?' . rand(10, 100)); ?>"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url('css/form.css?') . rand(10, 100);; ?>" />
<script type="text/javascript">
$(document).ready(function() {
var tag_data;
$.ajax({
url: 'https://www.masada.com.tw/fds/index.php/DesignFlow/get_assigner',
type: 'post',
dataType: 'json',
success: function(data) {
window.tag_data = data;
$('#selectPage').selectPage({
showField: 'show_name',
keyField: 'val',
data: data,
multiple: true,
multipleControlbar: true,
pagination: false,
focusDropList: false
});
}
});
var assigner = eval('<?= json_encode($assigner) ?>');
$("#form").validate();
// $('#cmecTbody').append(cmecRow);
$('.sp_element_box').attr("disabled", true);
$("#assign_opinion").cleditor({
height: 100, // height not including margins, borders or padding
controls: // controls to add to the toolbar
"bold italic underline strikethrough subscript superscript | font size " +
"style | color highlight removeformat | bullets numbering | outdent " +
"indent | alignleft center alignright justify | undo redo | "
});
$('#assign_status').change(function() {
$("#next_users").empty();
var _selected_status = $(this).children('option:selected').val(); //獲取被選擇的狀態
var _option_tmp = ""; //獲取下拉列表
for (a in assigner) { //遍曆assigner
if (assigner[a][0] == _selected_status) {
_tmp = assigner[a][1].split(',');
for (var b in _tmp) {
if (_tmp[b] == '') {
continue;
}
_uname = _tmp[b].split('-')[1];
_uid = _tmp[b].split('-')[0];
/* console.log(_tmp[b]);*/
_option_tmp += '<option value=' + _uid + '>' + _tmp[b] + '</option>';
}
}
}
$("#next_users").append(_option_tmp);
});
});
</script>
</head>
<body>
<div id="toolbarmenu">
<span id="objName" style="font-size:16px;margin-bottom:0px;margin-top:1px">流程:<?php echo $flowName; ?></span>
<!-- 導航欄 -->
<ul class="nav nav-tabs" role="tablist" id="tablist">
<li class=" nav-item ">
<a href="#tabassign" aria-controls="tabassign" role="tab" class=" active nav-link" data-toggle="tab">簽核表單</a>
</li>
</ul>
</div>
<!-- 導航欄 END-->
<div class="tab-content ">
<div class="tab-pane active assign_content " id="tabassign">
<form action="submit.php" method="post" id='form' style='width:98%;margin:0 auto'>
<!-- hidden域 -->
<input type="hidden" name="form_key" value='<?php echo $form_key; ?>' />
<input type="hidden" name="apply_key" value='<?php echo $data['apply_key']; ?>' />
<input type="hidden" name="token" value='<?php echo $token; ?>' />
<!--表單start-->
<div class=" form container-fluid pt-5">
<div class="row form_head ">
<div class=" col-12 form_head_title ">
<h4> 保養契約價格審核單</h4>
</div>
</div>
<div class="row " style='padding-top:30px;'>
<div class=" col-lg-12 form_row_header ">
<b>契約信息</b>
</div>
</div>
<?php
//一行顯示三列
$i = 0;
echo " <div class='row '>";
foreach ($editableColumn as $key => $val) {
$j = (($i++) % 4);
$fieldVal = empty($data) ? "" : $data[$key];
$_input = $val['tag'] == 'select' ?
FormHelper::select("$key", $val['options'], $fieldVal, $val['attr']) :
FormHelper::tag("label", $val['attr'], $fieldVal);
//"<input type='" . $val['tag'] . "' class=' form-control form-control-sm " . $val['class'] . "'
// value='" . $fieldVal . "' name='$key' id='$key' placeholder='請輸入'>";
if ($i != 1 && $j == 0) {
echo "
</div>
<div class='row'>
";
}
echo " <div class='col-1 form_field_title'>
" . $val['label'] . "
</div>
<div class=' col-2 form_field_content ' >
$_input
</div>
";
}
echo "</div>";
?>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>洽商進度</b>
</div>
<div class="col-12 " style="padding:0">
<textarea class='form-control textarea' disabled id="progress_remark" name="progress_remark" value='12' rows='6'> <?empty($data['progress_remark'])?'':$data['progress_remark']?> </textarea>
</div>
</div>
<div id="elevator_list_area " class="row ">
<div class="col-12 form_row_header ">
<b>電梯詳細資料</b>
</div>
<table style='margin-top:0px;text-align:center' id='elevator_list'>
<thead>
<tr style='margin-top:0px;text-align:center'>
<?php
$j = 0;
foreach ($con_maintance_examine_clear_columm as $val) {
echo FormHelper::tag("th", ['colspan' => empty($val['attr']['colspan'])
? 1 : $val['attr']['colspan']], $val['label']);
if ((++$j % 14) == 0) {
// if ($j == 12) echo "<th>操作</th>";
echo "</tr><tr style='margin-top:0px;text-align:center'>";
}
}
?>
</tr>
</thead>
<tbody id='cmecTbody'>
<?php
$i = 0;
$tr_class = "odd";
foreach ($con_maintance_examine_clear as $key => $val) {
$j = 0;
$cmecRow = " <tr $i class='$tr_class'>";
foreach ($con_maintance_examine_clear_columm as $col => $col_def) {
$fieldVal = empty($val) ? "" : $val[$col];
if ($col == 'mi_cost') {
$param = [
'elevator_type' => $val['con_elevator_kind'],
'floors' => $val['floors'],
'speed' => $val['speed'],
'persons' => $val['persons'],
'weight' => $val['weight'],
'maintain_times' => $val['maintain_times'],
'maintain_months' => $val['maintain_months'],
'maintain_kind' => $data['maintain_kind'],
'maintain_period' => $val['maintain_period'],
'is_m1_bundle' => $val['is_m1_bundle'],
];
$mic = new MICalculator();
$res = $mic->cal($param);
#MI報價
$con_maintance_examine_clear[$key]['mi_cost'] = $fieldVal = ($res['status']
== 'ok' ? $res['price'] : $res['message']);
$con_maintance_examine_clear[$key]['gross_profit'] = $val['gross_profit'] = "/"; //$fieldVal==0?0: (round(($val['sold_price'] - $val['mi_cost']) / $fieldVal, 2) * 100) . "%"
#扣率
$val['discount'] = (100*round($val['sold_price'] / $val['stand_price'], 4)) . "%";
}
$_input = FormHelper::tag("label", ['colspan' => empty($col_def['attr']['colspan']) ? 1
: $col_def['attr']['colspan']], $fieldVal);
$cmecRow .= "<td colspan='" . (empty($col_def['attr']['colspan']) ? ''
: $col_def['attr']['colspan']) . "' ><div class=' col-12'> $_input</td>";
$cmecRow = (++$j % 14 == 0) ? $cmecRow . "</tr ><tr $i class='$tr_class'>" : $cmecRow;
}
$tr_class = $tr_class == 'odd' ? "even" : "odd";
echo $cmecRow . "</tr>";
}
?>
</tbody>
<tfoot>
<?php
$total_mi_cost = 0;
foreach ($con_maintance_examine_clear as $val) {
$total_mi_cost += $val['mi_cost'];
}
?>
<tr>
<td colspan='20'>
<div style='float:right'>
<label>合計成交價:<?= $count == 0 ? $count : $total_sold_price ?>; </label>
<label>合計成本:<?= $count == 0 ? $count : $total_mi_cost ?>; </label>
<label>折扣率(C/A):<?= $total_discount_rate ?>; </label>
<label>毛利率:/</label>
</div>
</td>
</tr>
</tfoot>
</table>
</div>
<div id="assign_area " class="row ">
<div class="col-12 form_row_header ">
<b>簽核意見</b>
</div>
<div class="col-12 form_field_content " style="padding:0">
<textarea id="assign_opinion" name="assign_opinion"></textarea>
</div>
</div>
<div class="row">
<div class=" col-3 form_field_title">
<b style='float:right'>簽核狀態</b>
</div>
<div class=" col-2 form_field_content ">
<select name="assign_status" id="assign_status" class='form-control form-control form-control-sm '>
<?php echo $assign_status; ?>
</select>
</div>
<div class=" col-2 form_field_title">
<b>下位簽核者</b>
</div>
<div class="col-2 form_field_content">
<select name="next_users" id="next_users" class='form-control form-control-sm '></select>
</div>
<div class="col-3 form_field_title ">
<button type="submit" class="btn btn-primary btn-sm" style='float:left'>提交</button>
</div>
</div>
<div id="opinion_area " class="row form_comment ">
<div class='col-12 '>
<ul class=" form-control-md nav nav-tabs" role="tablist" style='line-height:20px'>
<li class="active nav-item ">
<a href="#main_flow_assign" aria-controls="main_flow_assign" role="tab" class=" active nav-link" role="tab" data-toggle="tab">簽核意見</a>
</li>
</ul>
</div>
<div class="tab-content col-12">
<div role="tabpanel" class="tab-pane active" id="main_flow_assign">
<?php
$assign_departs = array();
foreach ($assign_opinions as $as) {
$assign_departs[$as['assign_depart']] = $as['assign_depart_name'];
}
?>
<div class="comment_items ">
<?php $cnt = 1;
$tmp_code = "0";
foreach ($assign_opinions as $as) { ?>
<div class="comment-item">
<!-- <div class="comment-title">
<b></b>
</div>-->
<?php
if (($as['flow_code']) != $tmp_code)
echo ' <div class="comment-title">
<b>' . $wf->getNodeDescriptions($as['flow_code']) . '</b>
</div>';
$tmp_code = $as['flow_code'];
?>
<div class="comment-content <?php if ($cnt++ % 2 == 0) echo "comment-odd" ?>">
<div class="comment-content-header">
<span>
<strong>
<?php echo Employee::get_employee($as['assigner'], 'name-employee_no') ?>
&nbsp;
<?php if ($as['lead_code'] < 90) echo
" <label class='comment-content-tag'>" . $as['position_name'] . " </label>"; ?>
</strong>
</span>
<span>
<strong>
&nbsp;
<?php if ($as['assign_status'] == 'S') echo
" <label class='comment-content-tag'>申請人 </label>"; ?>
<?php if (substr($as['assign_status'], 0, 1) == 'B')
echo " <label class='comment-content-tag red-tag'>退回</label>"; ?>
<?php if (substr($as['assign_status'], 0, 2) == 'X3')
echo " <label class='comment-content-tag red-tag'>會簽</label>"; ?>
</strong>
</span>
<span class="comment-content-header-time">
簽核於:<?= $as['assign_date'] ?>
</span>
<!-- <ul class="comment-content-tags">
<li class="">不同意</li>
<li class="comment-content-tag-alert">退回</li>
</ul>-->
</div>
<div class="comment-content-body">
<?= $as['assign_opinion'] ?>
</div>
<!-- <div class="comment-content-footer">
<span>已上載附件:&nbsp;</span><a href="#">附件1</a>
</div>-->
</div>
</div>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</form>
</div>
</div>
</body>

149
wms/con/sign_list.php

@ -0,0 +1,149 @@
<?php
require_once "../header.php";
// 載入db.php來連結資料庫
$table = 'con_maintance_examine_apply';
#可編輯的列
$editableColumn = [
'apply_key' => [
'label' => "評審單號", "value" => "", "tag" => 'text',
'attr' => [
'readonly=true ',
'class' => 'form-control form-control-sm'
]
],
'vol_no' => ['label' => "卷號", "value" => "", "tag" => 'text', 'attr' => ['readonly=true ', 'class' => 'form-control form-control-sm']],
'address' => ['label' => "現場地址", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'case_name' => ['label' => "現場名稱", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'brand' => ['label' => "電梯品牌", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'num' => ['label' => "電梯臺數", "value" => "", "tag" => 'number', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'salesman' => ['label' => "營業員", "value" => "", "tag" => 'text', 'attr' => ['required', 'class' => 'form-control form-control-sm']],
'maintain_kind' => ['label' => "保養方式", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
'contract_begin_date' => ['label' => "契約期限開始", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_end_date' => ['label' => "契約期限結束", "value" => "", "tag" => 'date', 'attr' => ['required', 'class' => 'date form-control form-control-sm']],
'contract_kind' => ['label' => "契約性質", "value" => "", "tag" => 'select', 'attr' => ['class' => 'form-control form-control-sm']],
'platform_company' => ['label' => "加盟公司名稱", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
'platforom_company_tel' => ['label' => "加盟公司電話", "value" => "", "tag" => 'text', 'attr' => ['class' => 'form-control form-control-sm']],
//'payment_kind' => ['label' => "付款方式", "value" => "", "tag" => 'select', 'attr' => ['required', 'class' => 'form-control form-control-sm'], 'options' => $payment_kind_opt],
];
// 設置一個空陣列來放資料
$data = array();
$salesman = empty($_GET['salesman']) ? $user_id : $_GET['salesman'];
//$where = " and salesman like '%'";
$where = " and salesman = '$salesman'";
// 可瀏覽全部資料的部門
$depart_arr = ["220"];
$sql = "select department_id from account where accountid = '$user_id'";
$res = mysqli_query($link, $sql);
$row = mysqli_fetch_row($res);
$user_department_id = $row[0];
mysqli_free_result($res);
if (in_array($user_department_id, $depart_arr) || $user_id == "M0008" || $user_id == "M0012" || $user_id == "M0006") $where = "";
$sql = "SELECT
apply_key,
vol_no,
address,
case_name,
brand ,
num ,
f_return_name(salesman) salesman,
f_return_content('maintain_kind',maintain_kind ) maintain_kind,
date_format(contract_begin_date,'%Y/%m/%d') contract_begin_date,
date_format(contract_end_date,'%Y/%m/%d') contract_end_date ,
f_return_content('contract_kind',contract_kind ) contract_kind,
platform_company,
platforom_company_tel,
form_key,
f_return_content('payment_kind',payment_kind ) payment_kind FROM $table
where 1=1 $where ORDER BY vol_no";
$data = mysqli_query($link, $sql);
?>
<?php
if ($data) :
if ($_SERVER["REQUEST_METHOD"] == "POST") {
if (empty($_POST["name"]) && empty($_POST["email"]) && empty($_POST["website"])) {
echo "<p class='error'>Please fill up the required field!</p>";
} else {
header("Location:repair-index.php");
}
}
?>
<link rel="stylesheet" href="common.css">
<div style="overflow-x:auto;">
<form method='get' action='#'>
<table class='table query-table table-striped table-bordered display compact'
style='width:98%;text-align:center;margin:0 auto'>
<thead>
<tr>
<td colspan="8">
<h3 style='text-align:center'>(契約)價審單查詢</h3>
</td>
</tr>
</thead>
</table>
<table id="table_index" class="table table-striped table-bordered" style="width:98%" >
<thead>
<?php
echo "<tr>";
foreach ($editableColumn as $key => $val) {
echo "<th>".$val['label']."</th>";
}
echo "<th>是否結案</th>";
// echo "<th>刪除</th>";
echo "</tr>";
?>
</thead>
<tbody>
<?php foreach ($data as $row) : ?>
<tr>
<?php
foreach ($editableColumn as $key => $val) {
if( $key =='apply_key'){
echo "<td> <a href='query_form.php?apply_key=$row[$key]&token=".$_GET['token']."'>" . $row[$key] . "</td>";
}else{
echo "<td>" . $row[$key] . "</td>";
}
}
//list($signer)=DB::fields(");
//echo " select f_return_name(current_assigner) signer from subflow where form_key='". $row['form_key'] ."'"; ". (is_array($row['form_key'])?'': $row['form_key']) ."
list($signer)=mysqli_fetch_array(mysqli_query($link, "select max(f_return_name(current_assigner) ) signer from subflow where form_key='". $row['form_key'] ."'" ));
echo "<td>" .(empty($signer)?"結案":$signer) . "</td>";
?>
</tr>
<?php endforeach; ?>
</tbody>
</table>
</div>
<?php
else :
echo "<h2>There is no record!</h2>";
endif;
#代表結束連線
mysqli_close($link);
include "../footer.php";
?>

69
wms/con/submit.php

@ -0,0 +1,69 @@
<?php
//require_once "../database.php";
require_once './wf_common.php';
require_once './model/ConMaintanceExamineApplyModel.php';
require_once './model/ConMaintanceExamineClearModel.php';
//print_r($_POST);exit;
$request = $_SERVER['REQUEST_METHOD'] == "GET" ? $_GET : $_POST;
$tosign = ($request["btn_save"] == "tosign") ? 1 : 0; // 1:提交
//更新表单ConMaintanceExamineApplyModel
$cmea = new ConMaintanceExamineApplyModel();
$apply_key=$request['apply_key'];
$cmea->update(['apply_key', $apply_key], array_diff_key($request, ['apply_key' => '']));
//更新电梯列表
if (!empty($request["reg_del"])) {
$register_code_del_arr = explode(",", rtrim($request["reg_del"], ","));
foreach ($register_code_del_arr as $val) {
$sql = "update con_maintance_examine_clear set cmstatus = 'D' where apply_key = '$apply_key' and register_code = '$val' and cmstatus <> 'D'";
DB::query($sql);
}
}
if (!empty($request['register_code']) && count($request['register_code']) > 0) {
$cmec = new ConMaintanceExamineClearModel();
for ($i = 0; $i < count($request['register_code']); $i++) {
$data = [
'apply_key' => $request['apply_key']
];
$cols = array_diff($cmec->fillable, ['apply_key']);
foreach ($cols as $col) {
$data[$col] = empty($request[$col][$i]) ? '' : $request[$col][$i];
if ($col=="annual_survey_expense") $data[$col] = '0.00';
}
$cmec->create($data);
}
}
//var_dump($_POST);
//var_dump($_GET);
if ($tosign) {
#流程开始,var_dump($request);
$flow = new Flow($request['form_key']);
// 当前节点签核开始
$wf = new WorkFlow($flow->system_id, $flow->flow_id, $flow->form_id, $request['form_key']);
$wf->setFormData($request);
$wf->submit($request['next_users'], $request['assign_status'], $request['assign_opinion']);
//当前节点签核结束
$responses['flowName'] = $wf->getFlowName();
$responses['form_key'] = $request['form_key'];
//var_dump($request);
#結案發通知給營業員
if ($request['assign_status'] == 'F4') {
list($salesman, $case_name ) = DB::fields("select salesman ,case_name from con_maintance_examine_apply where apply_key='" . $apply_key. "' ");
$ins_notice_sql = "INSERT INTO `notice` ( `kind`,`title`, `content`, `permission`)
VALUES ( '1', '契約價審單結案通知(" .$case_name . ")', '契約價審單結案通知(" . $case_name . ")', ' $salesman')";
DB::query($ins_notice_sql);
// echo $ins_notice_sql;
}
}
echo "<script type = 'text/JavaScript'>";
//echo "<h4 style='text-align:center'>成功提交<a href='https://www.masada.com.tw/wms/sign/list.php?function_name=show&token=" . $request['token'] . "'>返回待签 </a></h4>";
if ($tosign) {
echo "alert('成功提交');";
echo "location.href='../con/sign_list.php?function_name=sign_list&token=".$request['token']."';";
} else {
echo "alert('資料已保存');";
echo "location.href='../crm/crmm02-index.php?function_name=contract_customer&token=".$request['token']."';";
}
echo "</script>";

1
wms/con/success.php

@ -0,0 +1 @@
<h4 style='text-align:center'>成功提交<a href='https://crm.platform-cn.com/pqm/pqmm01'>返回待签 </a></h4>

84
wms/con/t.php

@ -0,0 +1,84 @@
<?php
error_reporting(E_ALL);
ini_set('dispaly_errors', "On");
require_once './MSCalculator.php';
/* //客梯
$param = [
'elevator_type' => 'A',
'floors' => 7,
'speed' => 1,
'persons' => 6,
'weight' => 1000,
'maintain_times' => 1,
'maintain_months' => 12,
'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N',
];
*/
/* //货梯
$param = [
'elevator_type' => 'B',
'floors' => 7,
'speed' => 1,
'persons' => 6,
'weight' => 1000,
'maintain_times' => 1,
'maintain_months' => 12,
'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N',
];
*/
/*//病床梯
$param = [
'elevator_type' => 'C',
'floors' => 28,
'speed' => 1,
'persons' => 6,
'weight' => 1000,
'maintain_times' => 2, //病床梯一月2次保养
'maintain_months' => 12,
'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N',
];*/
/*//无机房
$param = [
'elevator_type' => 'D',
'floors' => 3,
'speed' => 1,
'persons' => 6,
'weight' => 1000,
'maintain_times' => 1, //病床梯一月2次保养
'maintain_months' => 12,
'maintain_kind' => 3,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'N',
];
*/
//家用梯
$param = [
'elevator_type' => 'E',
'floors' => 3,
'speed' => 1,
'persons' => 6,
'weight' => 1000,
'maintain_times' => 1, //病床梯一月2次保养
'maintain_months' => 60,
'maintain_kind' => 2,
'maintain_period' => 1, //默认为1月1次, 2是为2月一次
'is_m1_bundle' => 'Y',
];
$mic = new MSCalculator();
$price = $mic->cal($_GET);
echo json_encode($price);

174
wms/con/test.php

@ -0,0 +1,174 @@
<?php
require_once './wf_common.php';
#遍历所有大区
$yyyymm = '202306';
$res_regions = DB::result("select code_name,content from code where field_name='regions' ");
$region_data = [];
#遍历所有大区
foreach ($res_regions as $regions) {
echo $regions['code_name'];
$region_data[$regions['code_name']] = [
'depart_name' => $regions['content'],
#当月件数
'd_item_cnt' => 0,
#当月台数
'd_mfg_cnt' => 0,
#直销件数
'z_item_cnt' => 0,
#直销台数
'z_mfg_cnt' => 0,
#平台件数
'p_item_cnt' => 0,
#平台台数
'p_mfg_cnt' => 0,
#台数合计
'mfg_total' => 0,
#件数合计
'item_total' => 0,
#营业人数
'persons' => 0,
#人均台数
'avg_mfg_total' => 0,
#人均件数
'avg_item_total' => 0,
];
#遍历大区下面所有分公司
$res_branch = DB::result("select depart_no,depart_name from depart where regions='" . $regions['code_name'] . "' ");
foreach ($res_branch as $branch) {
#遍历分公司下面所有人
$depart_data = [];
$res_salesman = DB::result("select employee_no,name from employee
where depart_no='" . $branch['depart_no'] . "' ");
$depart_data = [
'depart_name' => $branch['depart_name'],
];
foreach ($res_salesman as $salesman) {
//当月预定成交台数 件数
$d_item_cnt = $d_mfg_cnt = $z_item_cnt = $z_mfg_cnt = $p_item_cnt = $p_mfg_cnt = 0;
list($d_item_cnt, $d_mfg_cnt) = DB::fields("select count(vol_no) item_cnt ,sum(num) mfg_cnt
From hope_contract_customer where salesman='" . $salesman['employee_no'] . "'
and pre_order_date between DATE_FORMAT(concat('$yyyymm','01'),'%Y-%m-%d')
and LAST_DAY(STR_TO_DATE('$yyyymm', '%Y%m'))");
// 直销 台数 件数
list($z_item_cnt, $z_mfg_cnt) = DB::fields("select count(vol_no) z_item_cnt ,sum(num)
z_mfg_cnt From hope_contract_customer where salesman=''" . $salesman['employee_no'] . "'
and customer_kind='1'");
// 平台 台数 件数
list($p_item_cnt, $p_mfg_cnt) = DB::fields("select count(vol_no) p_item_cnt ,sum(num)
p_mfg_cnt From hope_contract_customer where salesman='" . $salesman['employee_no'] . "'
and customer_kind!='1'
");
#当月件数
$d_item_cnt = empty($d_item_cnt) ? 0 : $d_item_cnt;
#当月台数
$d_mfg_cnt = empty($d_mfg_cnt) ? 0 : $d_mfg_cnt;
#直销件数
$z_item_cnt = empty($z_item_cnt) ? 0 : $z_item_cnt;
#直销台数
$z_mfg_cnt = empty($z_mfg_cnt) ? 0 : $z_mfg_cnt;
#平台件数
$p_item_cnt = empty($p_item_cnt) ? 0 : $p_item_cnt;
#平台台数
$p_mfg_cnt = empty($p_mfg_cnt) ? 0 : $p_mfg_cnt;
#台数合计
$mfg_total = $z_mfg_cnt + $p_mfg_cnt;
#件数合计
$item_total = $z_item_cnt + $p_item_cnt;
#营业人数
$persons = 1;
#人均台数
$avg_mfg_total = $z_mfg_cnt + $p_mfg_cnt;
#人均件数
$avg_item_total = $z_item_cnt + $p_item_cnt;
#部门数据
$depart_data = [
#当月件数
'd_item_cnt' => $depart_data['d_item_cnt'] + $d_item_cnt,
#当月台数
'd_mfg_cnt' => $depart_data['d_mfg_cnt'] + $d_mfg_cnt,
#直销件数
'z_item_cnt' => $depart_data['z_item_cnt'] + $z_item_cnt,
#直销台数
'z_mfg_cnt' => $depart_data['z_mfg_cnt'] + $z_mfg_cnt,
#平台件数
'p_item_cnt' => $depart_data['p_item_cnt'] + $p_item_cnt,
#平台台数
'p_mfg_cnt' => $depart_data['p_mfg_cnt'] + $p_mfg_cnt,
#台数合计
'mfg_total' => $depart_data['mfg_total'] + $mfg_total,
#件数合计
'item_total' => $depart_data['item_total'] + $item_total,
#营业人数
'persons' => $depart_data['persons'] + $persons,
#人均台数 $z_mfg_cnt + $p_mfg_cnt
'avg_mfg_total' => ($depart_data['z_mfg_cnt'] + $z_mfg_cnt) / ($depart_data['persons'] + $persons),
#人均件数
'avg_item_total' => ($depart_data['z_item_cnt'] + $z_item_cnt) / ($depart_data['persons'] + $persons)
];
$region_data[$regions['code_name']] = [
#当月件数
'd_item_cnt' => $region_data[$regions['code_name']]['d_item_cnt'] + $depart_data['d_item_cnt'],
#当月台数
'd_mfg_cnt' => $region_data[$regions['code_name']]['d_mfg_cnt'] + $depart_data['d_mfg_cnt'],
#直销件数
'z_item_cnt' => $region_data[$regions['code_name']]['z_item_cnt'] + $depart_data['z_item_cnt'],
#直销台数
'z_mfg_cnt' => $region_data[$regions['code_name']]['z_mfg_cnt'] + $depart_data['z_mfg_cnt'],
#平台件数
'p_item_cnt' => $region_data[$regions['code_name']]['p_item_cnt'] + $depart_data['p_item_cnt'],
#平台台数
'p_mfg_cnt' => $region_data[$regions['code_name']]['p_mfg_cnt'] + $depart_data['p_mfg_cnt'],
#台数合计
'mfg_total' => $region_data[$regions['code_name']]['mfg_total'] + $depart_data['mfg_total'],
#件数合计
'item_total' => $region_data[$regions['code_name']]['item_total'] + $depart_data['item_total'],
#营业人数
'persons' => $region_data[$regions['code_name']]['persons'] + $depart_data['persons'],
#人均台数 $z_mfg_cnt + $p_mfg_cnt
'avg_mfg_total' => ($region_data[$regions['code_name']]['z_mfg_cnt'])
/ ($region_data[$regions['persons']]),
#人均件数
'avg_item_total' => ($region_data[$regions['code_name']]['z_item_cnt'])
/ ($region_data[$regions['persons']]),
];
$depart_data['children'][] = [
'depart_name' => $salesman['name'],
#当月件数
'd_item_cnt' => $d_item_cnt,
#当月台数
'd_mfg_cnt' => $d_mfg_cnt,
#直销件数
'z_item_cnt' => $z_item_cnt,
#直销台数
'z_mfg_cnt' => $z_mfg_cnt,
#平台件数
'p_item_cnt' => $p_item_cnt,
#平台台数
'p_mfg_cnt' => $p_mfg_cnt,
#台数合计
'mfg_total' => $z_mfg_cnt + $p_mfg_cnt,
#件数合计
'item_total' => $z_item_cnt + $p_item_cnt,
#营业人数
'persons' => 1,
#人均台数
'avg_mfg_total' => $z_mfg_cnt + $p_mfg_cnt,
#人均件数
'avg_item_total' => $z_item_cnt + $p_item_cnt,
];
}
#大区资料
if (empty($region_data[$regions['code_name']])) $region_data[$regions['code_name']] = [];
if ($region_data[$regions['code_name']]['children']) $region_data[$regions['code_name']]['children'] = [];
array_push($region_data[$regions['code_name']]['children'], $depart_data);
}
echo "<pre>";
var_dump($region_data);
}

20
wms/con/wf_common.php

@ -0,0 +1,20 @@
<?php
//require_once "../header_nomenu.php";
#当前登陆者
define("ID", 'P0044');
$arr = array(
'../../workflow/impl/*.php',
'../../workflow/model/*.php',
'../../workflow/lib/*.php',
'../../workflow/Handler/*.php',
'../../workflow/*.php'
);
foreach ($arr as $dir) {
$files = glob($dir);
foreach ($files as $file) {
require_once $file;
}
}
Loading…
Cancel
Save