mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-22 18:35:35 +08:00
211 lines
7.4 KiB
PHP
211 lines
7.4 KiB
PHP
<?php
|
|
/**
|
|
* Copyright 2012-2026 ShopeX (https://www.shopex.cn)
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
class ome_ctl_admin_group extends desktop_controller{
|
|
var $name = "管理员组";
|
|
var $workground = "setting_tools";
|
|
/**
|
|
* __construct
|
|
* @param mixed $app app
|
|
* @return mixed 返回值
|
|
*/
|
|
public function __construct($app)
|
|
{
|
|
parent::__construct($app);
|
|
$this->_request = kernel::single('base_component_request');
|
|
}
|
|
|
|
function index(){
|
|
|
|
//check shop permission
|
|
$organization_permissions = kernel::single('desktop_user')->get_organization_permission();
|
|
if($organization_permissions){
|
|
$base_filter['org_id'] = $organization_permissions;
|
|
}
|
|
|
|
$this->finder('ome_mdl_groups',array(
|
|
'title'=>'管理员组管理',
|
|
'actions'=>array(
|
|
array(
|
|
'label'=>'添加管理员组',
|
|
'href'=>'index.php?app=ome&ctl=admin_group&act=addgroups&finder_id='.$_GET['finder_id'],
|
|
'target' => 'dialog::{width:500,height:300,title:\'管理员组\'}',
|
|
),
|
|
array(
|
|
'label'=>'删除管理员组',
|
|
//'href'=>'index.php?app=ome&ctl=admin_group&act=addgroups&finder_id='.$_GET['finder_id'],
|
|
'submit' => 'index.php?app=ome&ctl=admin_group&act=delgroups&finder_id='.$_GET['finder_id'],
|
|
// 'target' => 'refresh',
|
|
),
|
|
),
|
|
'use_buildin_new_dialog' => false,
|
|
'use_buildin_set_tag'=>false,
|
|
'use_buildin_recycle'=>false,
|
|
'use_buildin_export'=>false,
|
|
'use_buildin_import'=>false,
|
|
'base_filter' => $base_filter,
|
|
));
|
|
}
|
|
|
|
function save_group(){
|
|
$oGroup_ops = $this->app->model("group_ops");
|
|
$oGroups = $this->app->model("groups");
|
|
$this->begin('index.php?app=ome&ctl=admin_group&act=index');
|
|
$groups = $_POST['groups'];
|
|
if(!array_key_exists('description',$groups)){
|
|
$groups['description'] = NULL;
|
|
}
|
|
|
|
$oGroups->save($groups);
|
|
if($_POST['groups']['group_id']){
|
|
$oGroup_ops->delete(array('group_id'=>$_POST['groups']['group_id']));
|
|
}
|
|
if ($_POST['groups']['op_id']){
|
|
foreach($_POST['groups']['op_id'] as $k=>$v){
|
|
$data=array(
|
|
'group_id'=>$groups['group_id'],
|
|
'op_id'=>$v
|
|
);
|
|
//增加一个操作员只能属于一个订单确认小组的判断
|
|
$oGroup_ops->delete(array('op_id'=>$v));
|
|
$oGroup_ops->save($data);
|
|
}
|
|
}
|
|
$this->end(true, app::get('base')->_('保存成功'));
|
|
}
|
|
|
|
/**
|
|
* 添加管理员
|
|
*
|
|
*/
|
|
function addgroups(){
|
|
$operationOrgObj = $this->app->model('operation_organization');
|
|
$orgs = $operationOrgObj->getList('*', $filter, 0, -1);
|
|
$this->pagedata['orgs'] = $orgs;
|
|
|
|
$oGroups = $this->app->model("groups");
|
|
$operators = $oGroups->get_confirm_ops();
|
|
|
|
$this->pagedata['operators'] = $operators;
|
|
$this->pagedata['title'] = '添加订单确认小组';
|
|
$this->page("admin/system/groups.html");
|
|
}
|
|
|
|
/* 编辑管理员 */
|
|
function editgroups($group_id){
|
|
$oOperators = app::get('desktop')->model('users');
|
|
$oGroups = $this->app->model("groups");
|
|
|
|
$operationOrgObj = $this->app->model('operation_organization');
|
|
$orgs = $operationOrgObj->getList('*', $filter, 0, -1);
|
|
$this->pagedata['orgs'] = $orgs;
|
|
|
|
$oGroup_ops = $this->app->model("group_ops");
|
|
$operators = $oGroups->get_confirm_ops();
|
|
|
|
$groupInfo = $oGroups->dump($group_id);
|
|
$org_id = $groupInfo['org_id'];
|
|
|
|
$operationOrgLib = kernel::single('ome_operation_organization');
|
|
$ops = $operationOrgLib->getOrgOps($org_id);
|
|
if(!$ops){
|
|
unset($operators);
|
|
}
|
|
|
|
if($operators){
|
|
foreach($operators as $k => $operator){
|
|
if($ops){
|
|
if(!in_array($operator['user_id'],$ops)){
|
|
unset($operators[$k]);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
if ($operators)
|
|
foreach($operators as $k=>$v){
|
|
$O_exist = array('group_id'=>$group_id,'op_id'=>$v['user_id']);
|
|
if($oGroup_ops->dump($O_exist)){
|
|
$operators[$k]['checked']='checked=\"checked\"';
|
|
}
|
|
}
|
|
$this->pagedata['operators'] = $operators;
|
|
$this->pagedata['group'] = $groupInfo;
|
|
$this->pagedata['title'] = '编辑订单确认小组';
|
|
$this->page("admin/system/groups.html");
|
|
}
|
|
|
|
function get_op($group_id,$op_id="",$ajax='false'){
|
|
$oGroup = $this->app->model('groups');
|
|
$ops = $oGroup->get_ops($group_id);
|
|
if($ajax == 'true'){
|
|
$options = "<option value=''>请选择……</option>";
|
|
if($ops && is_array($ops)){
|
|
foreach($ops as $v){
|
|
if($v['user_id'] == $op_id){
|
|
$options .= "<option value=".$v['user_id']." selected>".$v['name']." (".$v['login_name'].")</option>";
|
|
}else{
|
|
$options .= "<option value=".$v['user_id'].">".$v['name']." (".$v['login_name'].")</option>";
|
|
}
|
|
}
|
|
}
|
|
echo $options;
|
|
}else{
|
|
return $ops;
|
|
}
|
|
}
|
|
|
|
#删除订单确认小组
|
|
function delgroups(){
|
|
$arr_group_id = $this->_request->get_post('group_id');
|
|
$obj_group = $this->app->model('groups');
|
|
$this->begin('index.php?app=ome&ctl=admin_group&act=index');
|
|
$msg = null;
|
|
$rs = $obj_group->checkedGourpInfo($arr_group_id,$msg);
|
|
if(!$rs){
|
|
$this->end(false, $this->app->_($msg));
|
|
}
|
|
if( $obj_group->delete(array('group_id'=>$arr_group_id))){
|
|
$this->end(true, $this->app->_('删除成功'));
|
|
}else{
|
|
$this->end(false, $this->app->_('删除失败'));
|
|
}
|
|
}
|
|
|
|
function ajax_get_ops_html($org_id){
|
|
$oGroups = $this->app->model("groups");
|
|
$operators = $oGroups->get_confirm_ops();
|
|
|
|
$operationOrgLib = kernel::single('ome_operation_organization');
|
|
$ops = $operationOrgLib->getOrgOps($org_id);
|
|
|
|
if($operators){
|
|
foreach($operators as $operator){
|
|
if($ops){
|
|
if(in_array($operator['user_id'],$ops)){
|
|
$tmp[] = $operator;
|
|
}
|
|
}
|
|
}
|
|
$this->pagedata['operators'] = $tmp;
|
|
}
|
|
|
|
$this->display('admin/system/groups_ops_ajax.html');
|
|
}
|
|
}
|
|
?>
|