mirror of
https://gitee.com/ShopeX/OMS
synced 2026-03-22 18:35:35 +08:00
112 lines
3.8 KiB
PHP
112 lines
3.8 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_specification extends desktop_controller{
|
|
|
|
var $workground = 'goods_manager';
|
|
|
|
function index(){
|
|
$this->finder('ome_mdl_specification',array(
|
|
'title'=>'商品规格',
|
|
'actions'=>array(
|
|
array('label'=>'新建','href'=>'index.php?app=ome&ctl=admin_specification&act=add','target'=>'_blank'),
|
|
),
|
|
'use_buildin_new_dialog' => false,
|
|
'use_buildin_set_tag'=>false,
|
|
'use_buildin_recycle'=>true,
|
|
'use_buildin_export'=>true,
|
|
'use_buildin_import'=>true,
|
|
'use_buildin_filter'=>true,
|
|
'orderBy' =>'spec_id DESC'
|
|
));
|
|
}
|
|
|
|
function add(){
|
|
$this->pagedata['title'] = '新建商品规格';
|
|
$this->singlepage('admin/goods/specification/detail.html');
|
|
}
|
|
|
|
function save(){
|
|
$this->begin('index.php?app=ome&ctl=admin_specification&act=index');
|
|
$oSpec = $this->app->model('specification');
|
|
if(!$_POST['spec']['spec_value']){
|
|
$this->end(false,'请输入规格值');
|
|
exit;
|
|
}
|
|
$spec_value = array();
|
|
foreach( $_POST['spec']['spec_value'] as $specValue ){
|
|
|
|
if( $specValue['spec_value'] == '' ){
|
|
$this->end(false,'规格值不能为空');
|
|
exit;
|
|
}
|
|
$spec_value[] = $specValue['spec_value'];
|
|
|
|
}
|
|
$spec_value_count = array_count_values($spec_value);
|
|
foreach($spec_value_count as $spec=>$value){
|
|
if($value>1){
|
|
$this->end(false,$spec.':规格值重复');
|
|
}
|
|
}
|
|
if(empty($_POST['spec']['spec_id'])){
|
|
$specinfo = $oSpec->dump(array('spec_name'=>$_POST['spec']['spec_name']),'*');
|
|
if(!empty($specinfo)){
|
|
$this->end(false,'规格名称已经存在');
|
|
}
|
|
}
|
|
$this->end($oSpec->save($_POST['spec']),'操作成功');
|
|
}
|
|
|
|
function edit( $specId ){
|
|
$oSpec = $this->app->model('specification');
|
|
$subsdf = array(
|
|
'spec_value'=>array('*')
|
|
);
|
|
$this->pagedata['spec'] = $oSpec->dump($specId,'*',$subsdf);
|
|
$this->singlepage('admin/goods/specification/detail.html');
|
|
}
|
|
|
|
function check_spec_value_id(){
|
|
$oSpecIndex = $this->app->model('goods_spec_index');
|
|
if( !$oSpecIndex->dump($_POST) )
|
|
echo "can";
|
|
else
|
|
echo app::get('base')->_("该规格值已绑定商品");
|
|
}
|
|
|
|
function selSpecDialog($typeId = 0) {
|
|
$aSpec = array();
|
|
if($typeId){
|
|
//$aSpec = $objSpec->getListByTypeId($typeId);
|
|
}else{
|
|
$oSpec = $this->app->model('specification');
|
|
$aSpec = $oSpec->getList('spec_id,spec_name,spec_memo',null,0,-1);
|
|
}
|
|
$this->pagedata['specs'] = $aSpec;
|
|
$this->display('admin/goods/specification/spec_select.html');
|
|
}
|
|
|
|
function previewSpec(){
|
|
$oSpec = $this->app->model('specification');
|
|
$this->pagedata['spec'] = $oSpec->dump( $_POST['spec_id'], '*',array('spec_value'=>array('*')));
|
|
$this->pagedata['spec_default_pic'] = $this->app->getConf('spec.default.pic');
|
|
$this->display('admin/goods/specification/spec_value_preview.html');
|
|
}
|
|
|
|
}
|