zm #28

Merged
mengfucius merged 3 commits from zm into master 2 years ago

@ -390,10 +390,10 @@ class Field extends Model
if ($v['form_type'] == 'checkbox') {
$list[$k]['default_value'] = $v['default_value'] ? explode(',', $v['default_value']) : array();
}
if ($v['form_type']=='date_interval') {
$list[$k]['default_value'] = !empty($v['default_value']) ? explode(',',$v['default_value']) : [];
if ($v['form_type'] == 'date_interval') {
$list[$k]['default_value'] = !empty($v['default_value']) ? explode(',', $v['default_value']) : [];
}
if($v['form_type']=='position'){
if ($v['form_type'] == 'position') {
$list[$k]['default_value'] = !empty($v['default_value']) ? json_decode($v['default_value'], true) : [];
}
if ($v['form_type'] == 'detail_table') {
@ -485,7 +485,10 @@ class Field extends Model
}
//生成字段名
if (!$data['field']) $data['field'] = $this->createField($types, $types == 'oa_examine' ? 'oa_' : 'crm_');
if (!empty($param['field'])) {
$data['field'] = $param['field'];
} else if (!$data['field']) $data['field'] = $this->createField($types, $types == 'oa_examine' ? 'oa_' : 'crm_');
$rule = [
'field' => ['regex' => '/^[a-z]([a-z]|_)+[a-z]$/i'],
@ -713,7 +716,7 @@ class Field extends Model
$new_default_value[] = str_replace(',', '', $v);
}
$data['default_value'] = implode(',', $new_default_value);
}elseif($data['default_value'] && $data['form_type'] == 'select' && !empty($data['default_value'])){
} elseif ($data['default_value'] && $data['form_type'] == 'select' && !empty($data['default_value'])) {
$data['default_value'] = $data['default_value'];
} else {
$data['default_value'] = '';
@ -760,12 +763,12 @@ class Field extends Model
// 数值范围
if (!empty($data['minNumRestrict'])) {
$data['min_num_restrict'] = $data['minNumRestrict'];
}else{
$data['min_num_restrict']='';
} else {
$data['min_num_restrict'] = '';
}
if (!empty($data['maxNumRestrict'])){
if (!empty($data['maxNumRestrict'])) {
$data['max_num_restrict'] = $data['maxNumRestrict'];
}else{
} else {
$data['max_num_restrict'] = '';
}
// 清除坐标
@ -1125,8 +1128,8 @@ class Field extends Model
'fieldName' => 'owner_user_structure_name'
];
foreach ($field_list as $k => $v) {
if($v['field']=='invoice_type'){
$field_list[$k]['setting']=$v['setting']?explode(chr(10), $v['setting']):[];
if ($v['field'] == 'invoice_type') {
$field_list[$k]['setting'] = $v['setting'] ? explode(chr(10), $v['setting']) : [];
}
# 处理字段授权
$field_list[$k]['writeStatus'] = 1;
@ -1254,7 +1257,7 @@ class Field extends Model
foreach ($field_list as $k => $v) {
# 处理字段授权
$field_list[$k]['writeStatus'] = 1;
if($field_list[$k]['name'] == '客户级别' && !in_array(1,$adminTypes)) $field_list[$k]['writeStatus'] = 0;
if ($field_list[$k]['name'] == '客户级别' && !in_array(1, $adminTypes)) $field_list[$k]['writeStatus'] = 0;
if (!$userLevel && $param['module'] == 'crm' && !empty($grantData[$param['types']])) {
$status = getFieldGrantStatus($v['field'], $grantData[$param['types']]);
@ -1271,7 +1274,7 @@ class Field extends Model
}
if ($param['action'] == 'read') {
$field_list[$k]['maskType'] = $status['maskType'];
if($status['maskType']!=0){
if ($status['maskType'] != 0) {
$field_list[$k]['writeStatus'] = 0;
}
}
@ -1469,32 +1472,32 @@ class Field extends Model
} elseif ($v['form_type'] == 'desc_text') {
// 描述文字
$value = !empty($dataInfo[$v['field']]) ? $dataInfo[$v['field']] : $v['default_value'];
} elseif ($v['form_type']=='location') {
} elseif ($v['form_type'] == 'location') {
// 地址、定位、日期区间、明细表格
$primaryKey = getPrimaryKeyName($param['types']);
$positionJson = !empty($dataInfo[$primaryKey]) ? db($param['types'] . '_data')->where([$primaryKey => $dataInfo[$primaryKey], 'field' => $v['field']])->value($param['types'] == 'oa_examine' ? 'value' : 'content') : '';
$positionData = !empty($positionJson) ? json_decode($positionJson, true) : '';
$value = $positionData;
} elseif($v['form_type']=='detail_table'){
} elseif ($v['form_type'] == 'detail_table') {
// $fieldGrant = db('admin_field_mask')->where('types', 'contract')->select();
$primaryKey = getPrimaryKeyName($param['types']);
$positionJson = !empty($dataInfo[$primaryKey]) ? db($param['types'] . '_data')->where([$primaryKey => $dataInfo[$primaryKey], 'field' => $v['field']])->value($param['types'] == 'oa_examine' ? 'value' : 'content') : '';
$positionData = !empty($positionJson) ? json_decode($positionJson, true) : '';
foreach ($positionData as $kk => $val){
foreach ($val as $key => $values){
if($values['form_type']=='user'){
$positionData[$kk][$key]['value']= !empty($values['value'])?$userModel->getListByStr($values['value']) :[];
foreach ($positionData as $kk => $val) {
foreach ($val as $key => $values) {
if ($values['form_type'] == 'user') {
$positionData[$kk][$key]['value'] = !empty($values['value']) ? $userModel->getListByStr($values['value']) : [];
}
if($values['form_type']=='structure'){
$positionData[$kk][$key]['value']= !empty($values['value'])? $structureModel->getListByStr($values['value']) : [];
if ($values['form_type'] == 'structure') {
$positionData[$kk][$key]['value'] = !empty($values['value']) ? $structureModel->getListByStr($values['value']) : [];
}
if($values['form_type']=='datetime' && is_numeric($values['value'])){
$positionData[$kk][$key]['value']= date('Y-m-d, H:i:s',$values['value']);
if ($values['form_type'] == 'datetime' && is_numeric($values['value'])) {
$positionData[$kk][$key]['value'] = date('Y-m-d, H:i:s', $values['value']);
}
if($values['form_type']=='boolean_value'){
$positionData[$kk][$key]['value']= (string)$values['value'];
if ($values['form_type'] == 'boolean_value') {
$positionData[$kk][$key]['value'] = (string)$values['value'];
}
if($values['form_type']=='file'){
if ($values['form_type'] == 'file') {
$fileIds = stringToArray($values['value']);
$whereFile = [];
$whereFile['module'] = 'other';
@ -1514,36 +1517,36 @@ class Field extends Model
// $positionData[$kk][$key]['value'] = !empty($dataInfo[$val['fiele_id']]) ? (string)substr_replace($values['value'], '*',0,strlen($values['value'])) : null;
// }
// }
$positionData[$kk][$key]['optionsData']=!empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
$positionData[$kk][$key]['optionsData'] = !empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
}
}
$value = $positionData;
if ($v['form_type'] == 'detail_table') {
$content = db('admin_field_extend')->where(['types' => $types, 'field' => $v['field']])->value('content');
$content=json_decode($content, true);
foreach ($content as &$vv){
$vv['optionsData']=!empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
$content = json_decode($content, true);
foreach ($content as &$vv) {
$vv['optionsData'] = !empty($field_list[$k]['options']) ? json_decode($field_list[$k]['options'], true) : '';
}
$field_list[$k]['fieldExtendList'] = $content;
}
} elseif($v['form_type']=='position'){
} elseif ($v['form_type'] == 'position') {
// 地址
$default_value = !empty($v['default_value']) ? json_decode($v['default_value'], true) : [];
if(!empty($dataInfo[$v['field']])){
$position= explode(',',$dataInfo[$v['field']]);
for ($i=0; $i<count($position); $i++) {
$b[]['name'] =trim(json_encode($position[$i],JSON_UNESCAPED_UNICODE),'"');
if (!empty($dataInfo[$v['field']])) {
$position = explode(',', $dataInfo[$v['field']]);
for ($i = 0; $i < count($position); $i++) {
$b[]['name'] = trim(json_encode($position[$i], JSON_UNESCAPED_UNICODE), '"');
}
$value =$b;
$value = $b;
}
} elseif($v['form_type']=='date_interval'){
} elseif ($v['form_type'] == 'date_interval') {
if (!empty($dataInfo[$v['field']])) {
$position= explode('_',$dataInfo[$v['field']]);
$value =$position;
$position = explode('_', $dataInfo[$v['field']]);
$value = $position;
}
$default_value = !empty($v['default_value'])?explode(',',$v['default_value']):[];
$default_value = !empty($v['default_value']) ? explode(',', $v['default_value']) : [];
} else {
$value = isset($dataInfo[$v['field']]) ? $dataInfo[$v['field']] : '';
}
@ -1816,7 +1819,7 @@ class Field extends Model
foreach ($dataList as $k => $v) {
if (!$userLevel && !empty($grantData[$types])) {
$status = getFieldGrantStatus($v['field'], $grantData[$types]);
$dataList[(int)$k]['maskType']=$status['maskType'];
$dataList[(int)$k]['maskType'] = $status['maskType'];
# 查看权限
if ($status['read'] == 0) unset($dataList[(int)$k]);
}
@ -1861,7 +1864,7 @@ class Field extends Model
}
$fieldArr = $this
->where($where)
->field(['field', 'name', 'form_type', 'is_hidden','setting'])
->field(['field', 'name', 'form_type', 'is_hidden', 'setting'])
->order('order_id', 'asc')
->select();
@ -1876,7 +1879,7 @@ class Field extends Model
}
if (isset($this->orther_field_list[$newTypes])) {
foreach ($this->orther_field_list[$newTypes] as $val) {
if($val['field'] != 'product_picture'){
if ($val['field'] != 'product_picture') {
$res[] = $val;
}
}
@ -2342,13 +2345,13 @@ class Field extends Model
$val = db('jxc_purchase')->where(['purchase_id' => $val])->value('order_number');
break;
case 'order_cause' :
if($dataInfo['receipt_type'] == '销售退货入库'){
if ($dataInfo['receipt_type'] == '销售退货入库') {
$val = db('jxc_salereturn')->where(['salereturn_id' => $val])->value('order_number');
}elseif ($dataInfo['receipt_type'] == '采购入库') {
} elseif ($dataInfo['receipt_type'] == '采购入库') {
$val = db('jxc_purchase')->where(['purchase_id' => $val])->value('order_number');
}elseif ($dataInfo['outbound_type'] == '销售出库') {
} elseif ($dataInfo['outbound_type'] == '销售出库') {
$val = db('jxc_sale')->where(['sale_id' => $val])->value('order_number');
}elseif ($dataInfo['outbound_type'] == '采购退货出库') {
} elseif ($dataInfo['outbound_type'] == '采购退货出库') {
$val = db('jxc_retreat')->where(['retreat_id' => $val])->value('order_number');
}
break;
@ -2359,13 +2362,13 @@ class Field extends Model
$val = db('jxc_product')->where(['product_id' => $val])->value('product_name');
break;
case 'collection_object' :
if($dataInfo['collection_type'] == '采购退货'){
if ($dataInfo['collection_type'] == '采购退货') {
// $val = db('jxc_supplier')->where(['supplier_id' => $val])->value('supplier_name');
}elseif ($dataInfo['collection_type'] == '销售出库') {
} elseif ($dataInfo['collection_type'] == '销售出库') {
$val = db('jxc_sale')->where(['sale_id' => $val])->value('order_number');
}elseif ($dataInfo['payment_type'] == '采购') {
} elseif ($dataInfo['payment_type'] == '采购') {
$val = db('crm_customer')->where(['customer_id' => $val])->value('name');
}elseif ($dataInfo['payment_type'] == '销售退货') {
} elseif ($dataInfo['payment_type'] == '销售退货') {
$val = db('jxc_salereturn')->where(['salereturn_id' => $val])->value('order_number');
}
@ -2416,13 +2419,13 @@ class Field extends Model
}
if (!$data) return $data;
$list = db('admin_field')->where(['types' => $types, 'relevant' => ['neq', '']])->field('field,relevant')->select();
foreach ($list as &$val){
$val=!empty($val)?$val:'';
foreach ($list as &$val) {
$val = !empty($val) ? $val : '';
}
$newData = [];
//crm_hfsomz
foreach ($list as $k => $v) {
$customer_field=db('admin_field')->where(['types' => 'crm_customer', 'field_id' => $v['relevant']])->field('field')->find();
$customer_field = db('admin_field')->where(['types' => 'crm_customer', 'field_id' => $v['relevant']])->field('field')->find();
$newData[$customer_field['field']] = $data[$v['field']];
}
return $newData ?: [];
@ -2670,7 +2673,7 @@ class Field extends Model
*/
public function getFieldTypesArray($types, $form_type)
{
$fieldArr = db('admin_field')->where(['types' => $types, 'form_type' => ['in', $form_type]])->field(['field','name', 'form_type'])->select();
$fieldArr = db('admin_field')->where(['types' => $types, 'form_type' => ['in', $form_type]])->field(['field', 'name', 'form_type'])->select();
$fieldList = [];
$userField = []; // 人员类型
$structureField = []; // 部门类型

@ -609,14 +609,13 @@ class Message extends ApiCommon
unset($param['type']);
unset($param['isSub']);
$businessModel = model('Business');
$param['owner_user_id'] = $userInfo['id'];
// $param['owner_user_id'] = $userInfo['id'];
if ($isSub) {
$param['owner_user_id'] = array('in', getSubUserId(false));
}
$businessIdArray = db('crm_dealt_relation')->where(['types' => ['eq', 'crm_business_new'], 'user_id' => ['eq', $param['user_id']]])->column('types_id');
$businessIdArray = db('crm_dealt_relation')->where(['types' => ['eq', 'crm_business_new'], 'user_id' => ['eq', $userInfo['id']]])->column('types_id');
$param['businessIdArray'] = !empty($businessIdArray) ? $businessIdArray : -1;
$data = $businessModel->getDataList($param);
// p($contractModel->getLastSql());
if ($types == 'list') {
return resultArray(['data' => $data]);
}
@ -776,7 +775,7 @@ class Message extends ApiCommon
}
# 处理待审核合同、回款、发票
if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice', 'checkBusiness','checkCustomerCheck','new_business'])) {
if (in_array($type, ['checkContract', 'checkReceivables', 'checkInvoice', 'checkBusiness', 'checkCustomerCheck', 'newBusiness'])) {
$where['check_status'] = ['lt', '2'];
$where['check_user_id'] = ['like', ',%' . $userId . '%,'];
@ -807,7 +806,7 @@ class Message extends ApiCommon
}
# 新商机
if ($type == 'new_business') {
if ($type == 'newBusiness') {
$newBusinessId = !empty($typeId) ? $typeId : Db::name('crm_business')->where($where)->column('business_id');
db('crm_dealt_relation')->where('user_id', $userId)->where('types', 'crm_business_new')->whereIn('types_id', $newBusinessId)->delete();
}

@ -438,7 +438,8 @@ class Business extends Common
db('crm_business_data')->insertAll($businessData);
//站内信
$send_user_id = stringToArray(getUserSuperior($param['create_user_id']));
$userInfo = db('admin_user')->where(['id' => $param['create_user_id']])->find();
$send_user_id = stringToArray(getUserSuperior($userInfo['structure_id'],0));
(new Message())->send(
Message::CUSTOMER_CHECK_TO_DO,
[

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save