|
|
|
@ -70,6 +70,10 @@ function resultArray($array)
|
|
|
|
|
} elseif (isset($array['error'])) {
|
|
|
|
|
$code = 400;
|
|
|
|
|
$array['data'] = '';
|
|
|
|
|
} elseif (isset($array['success'])) {
|
|
|
|
|
$array['error'] = '';
|
|
|
|
|
$array['data'] =$array['success'] ;
|
|
|
|
|
$code = 200;
|
|
|
|
|
}
|
|
|
|
|
return json([
|
|
|
|
|
'code' => $code,
|
|
|
|
@ -390,138 +394,138 @@ function advancedQuery($param, $m = '', $c = '', $a = '')
|
|
|
|
|
|
|
|
|
|
// 创建人、负责人
|
|
|
|
|
if (in_array($key, ['create_user_id', 'owner_user_id'])) {
|
|
|
|
|
if($value['condition'] == 'contains'){
|
|
|
|
|
if ($value['condition'] == 'contains') {
|
|
|
|
|
$result[$c . $key] = ['in', $value['value']];
|
|
|
|
|
}else if ($value['condition'] == 'notContains') {
|
|
|
|
|
$result[$c . $key] = ['not in', $value['value']];
|
|
|
|
|
}else if ($value['condition'] == 'isNull') {
|
|
|
|
|
$result[$c . $key] = ['eq', ''];
|
|
|
|
|
}else if ($value['condition'] == 'isNotNull') {
|
|
|
|
|
$result[$c . $key] = ['neq', ''];
|
|
|
|
|
} else if ($value['condition'] == 'notContains') {
|
|
|
|
|
$result[$c . $key] = ['not in', $value['value']];
|
|
|
|
|
} else if ($value['condition'] == 'isNull') {
|
|
|
|
|
$result[$c . $key] = ['eq', ''];
|
|
|
|
|
} else if ($value['condition'] == 'isNotNull') {
|
|
|
|
|
$result[$c . $key] = ['neq', ''];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 模块、审核状态、成交状态、产品分类、单行文本、多行文本、网址、手机、邮箱、下拉框、布尔值、多选、定位、创建人、负责人
|
|
|
|
|
if (isset($value['form_type']) && in_array($value['form_type'], ['module', 'check_status', 'deal_status', 'category', 'text', 'textarea', 'mobile', 'email', 'select', 'boolean_value', 'checkbox', 'location', 'website','user',])) {
|
|
|
|
|
if (isset($value['form_type']) && in_array($value['form_type'], ['module', 'check_status', 'deal_status', 'category', 'text', 'textarea', 'mobile', 'email', 'select', 'boolean_value', 'checkbox', 'location', 'website', 'user',])) {
|
|
|
|
|
$res = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
|
|
|
|
|
if($key == 'order_id'){
|
|
|
|
|
if ($key == 'order_id') {
|
|
|
|
|
$arr = [];
|
|
|
|
|
if($c == 'outbound.'){
|
|
|
|
|
$retreatOutboundIds = db('jxc_retreat')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_outbound b','a.retreat_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.outbound_type', '采购退货出库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('outbound_id');
|
|
|
|
|
$saleOutboundIds = db('jxc_sale')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_outbound b','a.sale_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.outbound_type', '销售出库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('outbound_id');
|
|
|
|
|
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds);
|
|
|
|
|
if ($c == 'outbound.') {
|
|
|
|
|
$retreatOutboundIds = db('jxc_retreat')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_outbound b', 'a.retreat_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.outbound_type', '采购退货出库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('outbound_id');
|
|
|
|
|
$saleOutboundIds = db('jxc_sale')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_outbound b', 'a.sale_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.outbound_type', '销售出库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('outbound_id');
|
|
|
|
|
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds, $saleOutboundIds);
|
|
|
|
|
$result[$c . 'outbound_id'] = ['in', $arr];
|
|
|
|
|
}elseif ($c == 'receipt.') {
|
|
|
|
|
$purchaseOutboundIds = db('jxc_purchase')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_receipt b','a.purchase_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.receipt_type', '采购入库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.receipt_id');
|
|
|
|
|
$salereturnOutboundIds = db('jxc_salereturn')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_receipt b','a.salereturn_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.receipt_type', '销售退货入库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.receipt_id');
|
|
|
|
|
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds);
|
|
|
|
|
} elseif ($c == 'receipt.') {
|
|
|
|
|
$purchaseOutboundIds = db('jxc_purchase')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_receipt b', 'a.purchase_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.receipt_type', '采购入库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.receipt_id');
|
|
|
|
|
$salereturnOutboundIds = db('jxc_salereturn')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_receipt b', 'a.salereturn_id = b.order_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.receipt_type', '销售退货入库')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.receipt_id');
|
|
|
|
|
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds, $salereturnOutboundIds);
|
|
|
|
|
$result[$c . 'receipt_id'] = ['in', $arr];
|
|
|
|
|
}
|
|
|
|
|
}else if($key == 'related_id'){
|
|
|
|
|
} else if ($key == 'related_id') {
|
|
|
|
|
$arr = [];
|
|
|
|
|
if($c == 'collection.'){
|
|
|
|
|
$retreatOutboundIds = db('jxc_retreat')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b','a.retreat_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '采购退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$saleOutboundIds = db('jxc_sale')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b','a.sale_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '销售回款')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds,$saleOutboundIds);
|
|
|
|
|
if ($c == 'collection.') {
|
|
|
|
|
$retreatOutboundIds = db('jxc_retreat')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b', 'a.retreat_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '采购退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$saleOutboundIds = db('jxc_sale')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b', 'a.sale_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '销售回款')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$arr = empty($retreatOutboundIds) ? $saleOutboundIds : array_merge($retreatOutboundIds, $saleOutboundIds);
|
|
|
|
|
$result[$c . 'collection_note_id'] = ['in', $arr];
|
|
|
|
|
}elseif ($c == 'payment.') {
|
|
|
|
|
$purchaseOutboundIds = db('jxc_purchase')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b','a.purchase_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '采购')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$salereturnOutboundIds = db('jxc_salereturn')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b','a.salereturn_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '销售退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds,$salereturnOutboundIds);
|
|
|
|
|
} elseif ($c == 'payment.') {
|
|
|
|
|
$purchaseOutboundIds = db('jxc_purchase')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b', 'a.purchase_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '采购')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$salereturnOutboundIds = db('jxc_salereturn')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b', 'a.salereturn_id = b.related_id')
|
|
|
|
|
->where('a.order_number', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '销售退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$arr = empty($purchaseOutboundIds) ? $salereturnOutboundIds : array_merge($purchaseOutboundIds, $salereturnOutboundIds);
|
|
|
|
|
$result[$c . 'payment_note_id'] = ['in', $arr];
|
|
|
|
|
}
|
|
|
|
|
}else if($key == 'collection_object'){
|
|
|
|
|
} else if ($key == 'collection_object') {
|
|
|
|
|
$arr = [];
|
|
|
|
|
if($c == 'collection.'){
|
|
|
|
|
$supplierOutboundIds = db('jxc_supplier')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b','a.supplier_id = b.collection_object')
|
|
|
|
|
->where('a.supplier_name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '采购退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$customerOutboundIds = db('crm_customer')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b','a.customer_id = b.collection_object')
|
|
|
|
|
->where('a.name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '销售回款')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds);
|
|
|
|
|
if ($c == 'collection.') {
|
|
|
|
|
$supplierOutboundIds = db('jxc_supplier')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b', 'a.supplier_id = b.collection_object')
|
|
|
|
|
->where('a.supplier_name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '采购退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$customerOutboundIds = db('crm_customer')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_collection b', 'a.customer_id = b.collection_object')
|
|
|
|
|
->where('a.name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.collection_type', '销售回款')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('collection_note_id');
|
|
|
|
|
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds, $customerOutboundIds);
|
|
|
|
|
$result[$c . 'collection_note_id'] = ['in', $arr];
|
|
|
|
|
}elseif ($c == 'payment.') {
|
|
|
|
|
$supplierOutboundIds = db('jxc_supplier')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b','a.supplier_id = b.collection_object')
|
|
|
|
|
->where('a.supplier_name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '采购')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$customerOutboundIds = db('crm_customer')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b','a.customer_id = b.collection_object')
|
|
|
|
|
->where('a.name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '销售退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds,$customerOutboundIds);
|
|
|
|
|
} elseif ($c == 'payment.') {
|
|
|
|
|
$supplierOutboundIds = db('jxc_supplier')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b', 'a.supplier_id = b.collection_object')
|
|
|
|
|
->where('a.supplier_name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '采购')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$customerOutboundIds = db('crm_customer')
|
|
|
|
|
->alias('a')
|
|
|
|
|
->join('jxc_payment b', 'a.customer_id = b.collection_object')
|
|
|
|
|
->where('a.name', [$res[0], $res[1]])
|
|
|
|
|
->where('b.payment_type', '销售退货')
|
|
|
|
|
// ->fetchSql()
|
|
|
|
|
->column('b.payment_note_id');
|
|
|
|
|
$arr = empty($supplierOutboundIds) ? $customerOutboundIds : array_merge($supplierOutboundIds, $customerOutboundIds);
|
|
|
|
|
$result[$c . 'payment_note_id'] = ['in', $arr];
|
|
|
|
|
}
|
|
|
|
|
// }else if($key == 'sp_data_value'){
|
|
|
|
|
// foreach ($res[1] as $key => $v) {
|
|
|
|
|
// $arr[] = '%'.$v.'%';
|
|
|
|
|
// }
|
|
|
|
|
// $w['sp_data_value'] = ['like', $arr, 'OR'];
|
|
|
|
|
// $product_ids = db('jxc_product')->where($w)->fetchSql()->column('product_id');
|
|
|
|
|
// $result[$c . 'sp_data_value'] = [$res[0], $product_ids];
|
|
|
|
|
}else{
|
|
|
|
|
// }else if($key == 'sp_data_value'){
|
|
|
|
|
// foreach ($res[1] as $key => $v) {
|
|
|
|
|
// $arr[] = '%'.$v.'%';
|
|
|
|
|
// }
|
|
|
|
|
// $w['sp_data_value'] = ['like', $arr, 'OR'];
|
|
|
|
|
// $product_ids = db('jxc_product')->where($w)->fetchSql()->column('product_id');
|
|
|
|
|
// $result[$c . 'sp_data_value'] = [$res[0], $product_ids];
|
|
|
|
|
} else {
|
|
|
|
|
$result[$c . $key] = advancedQueryFormatForCommon($value['value'], $value['condition'], $value['form_type'], $key);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -729,9 +733,9 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
|
|
|
|
|
if (in_array($formType, ['checkbox']) && $condition == 'isNot') $condition = 'notContains';
|
|
|
|
|
|
|
|
|
|
// 处理查询参数
|
|
|
|
|
if(in_array($condition, ['contains', 'notContains']) && in_array($key,['create_user_id','owner_user_id'])){
|
|
|
|
|
if (in_array($condition, ['contains', 'notContains']) && in_array($key, ['create_user_id', 'owner_user_id'])) {
|
|
|
|
|
$data = advancedQueryDataUserform($data, $condition);
|
|
|
|
|
}elseif (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])){
|
|
|
|
|
} elseif (in_array($condition, ['contains', 'notContains', 'startWith', 'endWith'])) {
|
|
|
|
|
$data = advancedQueryDataTransform($data, $condition);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -753,7 +757,7 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
|
|
|
|
|
$data[0] = str_replace('已作废', 6, $data[0]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return advancedQueryWhere($condition, $data,$key);
|
|
|
|
|
return advancedQueryWhere($condition, $data, $key);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -765,7 +769,7 @@ function advancedQueryFormatForCommon($data, $condition, $formType, $key)
|
|
|
|
|
* @since 2021-05-22
|
|
|
|
|
* @author fanqi
|
|
|
|
|
*/
|
|
|
|
|
function advancedQueryWhere($condition, $data, $key='')
|
|
|
|
|
function advancedQueryWhere($condition, $data, $key = '')
|
|
|
|
|
{
|
|
|
|
|
$result = [];
|
|
|
|
|
|
|
|
|
@ -774,9 +778,9 @@ function advancedQueryWhere($condition, $data, $key='')
|
|
|
|
|
|
|
|
|
|
if ($condition == "in") $result = ['in', $data]; // 等于
|
|
|
|
|
if ($condition == 'is') $result = ['in', $data]; // 等于
|
|
|
|
|
if ($condition == 'isNot') $result = [['notin', $data],['null'],'OR']; // 不等于
|
|
|
|
|
if ($condition == 'isNot') $result = [['notin', $data], ['null'], 'OR']; // 不等于
|
|
|
|
|
if ($condition == 'contains') $result = ['like', $data, 'OR']; // 包含
|
|
|
|
|
if ($condition == 'notContains') $result = [['notlike', $data, 'AND'],['null'],'OR']; // 不包含
|
|
|
|
|
if ($condition == 'notContains') $result = [['notlike', $data, 'AND'], ['null'], 'OR']; // 不包含
|
|
|
|
|
if ($condition == 'startWith') $result = ['like', $data, 'OR']; // 开始于
|
|
|
|
|
if ($condition == 'endWith') $result = ['like', $data, 'OR']; // 结束于
|
|
|
|
|
if ($condition == 'gt') $result = ['gt', $data]; // 大于
|
|
|
|
@ -787,8 +791,8 @@ function advancedQueryWhere($condition, $data, $key='')
|
|
|
|
|
if ($condition == 'range') $result = ['between', $data]; // 处于某个时间段
|
|
|
|
|
if ($condition == 'isNull') $result = [['eq', ''], ['null'], 'OR']; // 为空
|
|
|
|
|
if ($condition == 'isNotNull') $result = [['neq', ''], ['not null'], 'AND']; // 不为空
|
|
|
|
|
if ($condition == 'contains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['in', $data]; // 暂定为创建人 负责人 包含
|
|
|
|
|
if ($condition == 'notContains' && in_array($key,['create_user_id','owner_user_id'])) $result = ['notin', $data]; // 暂定为创建人 负责人不包含
|
|
|
|
|
if ($condition == 'contains' && in_array($key, ['create_user_id', 'owner_user_id'])) $result = ['in', $data]; // 暂定为创建人 负责人 包含
|
|
|
|
|
if ($condition == 'notContains' && in_array($key, ['create_user_id', 'owner_user_id'])) $result = ['notin', $data]; // 暂定为创建人 负责人不包含
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -834,7 +838,8 @@ function advancedQueryDataTransform($data, $condition)
|
|
|
|
|
* @version: 11.1.0
|
|
|
|
|
* Date: 2021/9/2 14:44
|
|
|
|
|
*/
|
|
|
|
|
function advancedQueryDataUserform($data, $condition){
|
|
|
|
|
function advancedQueryDataUserform($data, $condition)
|
|
|
|
|
{
|
|
|
|
|
if (in_array($condition, ['contains', 'notContains'])) {
|
|
|
|
|
array_walk($data, function ($value, $key) use (&$data) {
|
|
|
|
|
$data[$key] = $value;
|
|
|
|
@ -842,6 +847,7 @@ function advancedQueryDataUserform($data, $condition){
|
|
|
|
|
}
|
|
|
|
|
return $data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 等于(时间段)数据处理
|
|
|
|
|
*
|
|
|
|
@ -2891,7 +2897,7 @@ if (!function_exists('getFieldGrantStatus')) {
|
|
|
|
|
function getFieldGrantStatus($field, $grantData)
|
|
|
|
|
{
|
|
|
|
|
# 默认状态都是不能查看、不能编辑,通过配置来取最大权限。
|
|
|
|
|
$result = ['read' => 0, 'write' => 0,'maskType'=>0];
|
|
|
|
|
$result = ['read' => 0, 'write' => 0, 'maskType' => 0];
|
|
|
|
|
foreach ($grantData as $key => $value) {
|
|
|
|
|
$fieldBool = false;
|
|
|
|
|
|
|
|
|
@ -2906,7 +2912,7 @@ if (!function_exists('getFieldGrantStatus')) {
|
|
|
|
|
$result['write'] = $va['write'] > $result['write'] ? $va['write'] : $result['write'];
|
|
|
|
|
}
|
|
|
|
|
if ($va['field'] == $field && $va['maskType'] != 0) {
|
|
|
|
|
$result['maskType'] = !empty($va['maskType'])?$va['maskType']:0;
|
|
|
|
|
$result['maskType'] = !empty($va['maskType']) ? $va['maskType'] : 0;
|
|
|
|
|
}
|
|
|
|
|
if ($va['field'] == $field) $fieldBool = true;
|
|
|
|
|
}
|
|
|
|
@ -3301,50 +3307,50 @@ function advancedQueryFormatForTeam($requestMap, $c, $db_id)
|
|
|
|
|
// $result[$c . 'rw_user_id'] = advancedQueryFormatForPersonnel($v['value'], $v['condition']);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
$date=[];
|
|
|
|
|
$date2=[];
|
|
|
|
|
$condition=$requestMap['condition'];
|
|
|
|
|
$z='';
|
|
|
|
|
|
|
|
|
|
foreach ($requestMap['value'] as $val){
|
|
|
|
|
|
|
|
|
|
if($condition=='contains'){
|
|
|
|
|
$z='like';
|
|
|
|
|
$val="'".'%,'.$val.',%'."'";
|
|
|
|
|
}elseif($condition=='notContains'){
|
|
|
|
|
$z='NOT LIKE';
|
|
|
|
|
$val="'".'%,'.$val.',%'."'";
|
|
|
|
|
}
|
|
|
|
|
$date[]=$prefix.'ro_user_id '.$z.$val;
|
|
|
|
|
$date2[]=$prefix.'rw_user_id '.$z.$val;
|
|
|
|
|
}
|
|
|
|
|
if($condition =='isNull'){
|
|
|
|
|
$z='IS NULL';
|
|
|
|
|
$date[]=$prefix.'ro_user_id '.'= '."''";
|
|
|
|
|
$date2[]=$prefix.'rw_user_id '.'= '."''";
|
|
|
|
|
}elseif($condition =='isNotNull'){
|
|
|
|
|
$z='IS NOT NULL';
|
|
|
|
|
$date[]=$prefix.'ro_user_id '.'<> '."''";
|
|
|
|
|
$date2[]=$prefix.'rw_user_id '.'<> '."''";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if($date && $date2){
|
|
|
|
|
$rest='';
|
|
|
|
|
$date=implode('OR ', $date);
|
|
|
|
|
$date2=implode('OR ', $date2);
|
|
|
|
|
$type='';
|
|
|
|
|
switch ($z){
|
|
|
|
|
$date = [];
|
|
|
|
|
$date2 = [];
|
|
|
|
|
$condition = $requestMap['condition'];
|
|
|
|
|
$z = '';
|
|
|
|
|
|
|
|
|
|
foreach ($requestMap['value'] as $val) {
|
|
|
|
|
|
|
|
|
|
if ($condition == 'contains') {
|
|
|
|
|
$z = 'like';
|
|
|
|
|
$val = "'" . '%,' . $val . ',%' . "'";
|
|
|
|
|
} elseif ($condition == 'notContains') {
|
|
|
|
|
$z = 'NOT LIKE';
|
|
|
|
|
$val = "'" . '%,' . $val . ',%' . "'";
|
|
|
|
|
}
|
|
|
|
|
$date[] = $prefix . 'ro_user_id ' . $z . $val;
|
|
|
|
|
$date2[] = $prefix . 'rw_user_id ' . $z . $val;
|
|
|
|
|
}
|
|
|
|
|
if ($condition == 'isNull') {
|
|
|
|
|
$z = 'IS NULL';
|
|
|
|
|
$date[] = $prefix . 'ro_user_id ' . '= ' . "''";
|
|
|
|
|
$date2[] = $prefix . 'rw_user_id ' . '= ' . "''";
|
|
|
|
|
} elseif ($condition == 'isNotNull') {
|
|
|
|
|
$z = 'IS NOT NULL';
|
|
|
|
|
$date[] = $prefix . 'ro_user_id ' . '<> ' . "''";
|
|
|
|
|
$date2[] = $prefix . 'rw_user_id ' . '<> ' . "''";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ($date && $date2) {
|
|
|
|
|
$rest = '';
|
|
|
|
|
$date = implode('OR ', $date);
|
|
|
|
|
$date2 = implode('OR ', $date2);
|
|
|
|
|
$type = '';
|
|
|
|
|
switch ($z) {
|
|
|
|
|
case 'like':
|
|
|
|
|
$rest='('.$date.')'.'OR'.'('.$date2.')';
|
|
|
|
|
$rest = '(' . $date . ')' . 'OR' . '(' . $date2 . ')';
|
|
|
|
|
break;
|
|
|
|
|
case 'NOT LIKE':
|
|
|
|
|
$rest='('.$date.')'.'AND'.'('.$date2.')';
|
|
|
|
|
$rest = '(' . $date . ')' . 'AND' . '(' . $date2 . ')';
|
|
|
|
|
break;
|
|
|
|
|
case 'IS NULL':
|
|
|
|
|
$rest='('.$date.')'.'OR'.'('.$date2.')';
|
|
|
|
|
$rest = '(' . $date . ')' . 'OR' . '(' . $date2 . ')';
|
|
|
|
|
break;
|
|
|
|
|
case 'IS NOT NULL':
|
|
|
|
|
$rest='('.$date.')'.'AND'.'('.$date2.')';
|
|
|
|
|
$rest = '(' . $date . ')' . 'AND' . '(' . $date2 . ')';
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
@ -3363,15 +3369,15 @@ function advancedQueryFormatForTeam($requestMap, $c, $db_id)
|
|
|
|
|
*/
|
|
|
|
|
function getUserSuperior($structure_id, $level = 0)
|
|
|
|
|
{
|
|
|
|
|
if($level == 0){
|
|
|
|
|
if ($level == 0) {
|
|
|
|
|
$owner_user_id = db('admin_structure')->where('id', $structure_id)->value('owner_user_id');
|
|
|
|
|
if($owner_user_id == 0){
|
|
|
|
|
if ($owner_user_id == 0) {
|
|
|
|
|
$pid = db('admin_structure')->where('id', $structure_id)->value('pid');
|
|
|
|
|
$owner_user_id = db('admin_structure')->where('id', $pid)->value('owner_user_id');
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
} else {
|
|
|
|
|
$pid = db('admin_structure')->where('id', $structure_id)->value('pid');
|
|
|
|
|
return getUserSuperior($pid, $level-1);
|
|
|
|
|
return getUserSuperior($pid, $level - 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return $owner_user_id;
|
|
|
|
|