Files
OMS/app/omeauto/controller/autobranch.php
2025-12-28 23:13:25 +08:00

133 lines
4.3 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/**
* Copyright © ShopeX http://www.shopex.cn. All rights reserved.
* See LICENSE file for license details.
*/
/**
* 仓库分配规则
*
* @version 0.1b
* @author hzjsq
*/
class omeauto_ctl_autobranch extends omeauto_controller {
var $workground = "setting_tools";
function index() {
#过滤o2o门店虚拟仓库
$params = array(
'title' => '仓库分配规则',
'base_filter' => array('disabled' => 'false', 'is_deliv_branch' => 'true', 'b_type'=>1),
'use_buildin_new_dialog' => false,
'use_buildin_set_tag' => false,
'use_buildin_recycle' => false,
'use_buildin_export' => false,
'use_buildin_import' => false,
'use_buildin_filter' => false,
'use_view_tab' => false,
'finder_cols' => 'column_edit,name,branch_bn,column_order',
);
$this->finder('ome_mdl_branch', $params);
}
/**
* 修改仓库对应的订单分组设置
*
* @param integer $bid 仓库ID
* @return void
*/
function edit($bid) {
$this->pagedata['data'] = app::get('ome')->model('branch')->dump(array('branch_id' => $bid));
$this->pagedata['data']['area_conf'] = unserialize($this->pagedata['data']['area_conf']);
$this->pagedata['orderType'] = $this->getOrderType();
$this->page('autobranch/edit.html');
}
/**
* 设置默认仓库
*
* @param Integer $bid 仓库ID
* @return void
*/
function setDefault($bid) {
//$this->begin('');
if ($bid && $bid > 0) {
//全部取消缺省
kernel::database()->query("update sdb_ome_branch set defaulted='false'");
//全部取消缺省
kernel::database()->query("update sdb_omeauto_order_type set bid=0 where bid={$bid}");
//置指定仓库为缺省发货仓库
kernel::database()->query("update sdb_ome_branch set defaulted='true',area_conf='' where branch_id={$bid}");
}
//$this->end(true, '默认发货仓设置成功!!');
echo "<script>alert('默认发货仓设置成功!!');top.finderGroup['{$_REQUEST['finder_id']}'].refresh();</script>";
}
/**
* 取消默认仓库
*
* @param Integer $bid 仓库ID
* @return void
*/
function removeDefault($bid) {
//$this->begin('');
if ($bid && $bid > 0) {
//全部取消缺省
kernel::database()->query("update sdb_ome_branch set defaulted='false'");
//全部取消缺省
kernel::database()->query("update sdb_omeauto_order_type set bid=0 where bid={$bid}");
//置指定仓库为缺省发货仓库
kernel::database()->query("update sdb_ome_branch set defaulted='false',area_conf='N;' where branch_id={$bid}");
}
//$this->end(true, '<script>alert('xxx');</script>取消默认发货仓成功!!');
//echo '取消默认发货仓成功!!';
echo "<script>alert('取消默认发货仓成功!!');top.finderGroup['{$_REQUEST['finder_id']}'].refresh();</script>";
}
/**
* 保存仓库对应信息
*
* @return void
*/
function save() {
//$this->begin("index.php?app=omeauto&ctl=autoconfirm&act=index");
$data = $_POST;
if (empty($data['area_conf'])) {
$data['area_conf'] = array();
}
//修改
if ($data['branch_id']) {
kernel::database()->query("update sdb_omeauto_order_type set bid=0 where bid={$data[branch_id]}");
}
app::get('ome')->model('branch')->save($data);
//更新订单类型相关表
foreach ((array) $data['area_conf'] as $tid) {
kernel::database()->query("update sdb_omeauto_order_type set bid={$data[branch_id]} where tid={$tid}");
}
echo "SUCC";
}
private function getOrderType() {
$info = app::get('omeauto')->model('order_type')->getList('*', array('disabled' => 'false'), 0, -1);
foreach ($info as $idx => $rows) {
$title = '';
foreach ($rows['config'] as $row) {
$role = json_decode($row, true);
$title .= $role['caption'] . "\n";
}
$info[$idx]['title'] = $title;
}
return $info;
}
}