初始版本
This commit is contained in:
264
application/controllers/basedata/assist.php
Executable file
264
application/controllers/basedata/assist.php
Executable file
@@ -0,0 +1,264 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Assist extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$typeNumber = str_enhtml($this->input->get('typeNumber',TRUE));
|
||||
$skey = str_enhtml($this->input->get('skey',TRUE));
|
||||
$where = '(isDelete=0) and typeNumber="'.$typeNumber.'"';
|
||||
$where .= $skey ? ' and name like "%'.$skey.'%"' : '';
|
||||
$list = $this->mysql_model->get_results('category',$where,'path');
|
||||
$parentId = array_column($list, 'parentId');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['detail'] = in_array($row['id'],$parentId) ? false : true;
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['level'] = $row['level'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['parentId'] = intval($row['parentId']);
|
||||
$v[$arr]['remark'] = $row['remark'];
|
||||
$v[$arr]['sortIndex'] = intval($row['sortIndex']);
|
||||
$v[$arr]['status'] = intval($row['isDelete']);
|
||||
$v[$arr]['typeNumber'] = $row['typeNumber'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//分类
|
||||
public function getAssistType(){
|
||||
$v = array(
|
||||
0 => array('id'=>1001,'name'=>'商品类别','number'=>'trade'),
|
||||
1 => array('id'=>1002,'name'=>'客户类别','number'=>'customertype'),
|
||||
2 => array('id'=>1003,'name'=>'供应商类别','number'=>'supplytype'),
|
||||
3 => array('id'=>1004,'name'=>'收入类别','number'=>'raccttype'),
|
||||
4 => array('id'=>1005,'name'=>'支出类别','number'=>'paccttype')
|
||||
);
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = $v;
|
||||
$json['data']['totalsize'] = 5;
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$data = $this->validform(str_enhtml($this->input->post(NULL,TRUE)));
|
||||
switch ($data['typeNumber']) {
|
||||
case 'trade':
|
||||
$this->common_model->checkpurview(168);
|
||||
$this->trade_add($data);break;
|
||||
case 'supplytype':
|
||||
$this->common_model->checkpurview(164);
|
||||
$success = '新增供应商类别:';break;
|
||||
case 'customertype':
|
||||
$this->common_model->checkpurview(74);
|
||||
$success = '新增客户类别:';break;
|
||||
case 'raccttype':
|
||||
$this->common_model->checkpurview(176);
|
||||
$success = '新增收入类别:';break;
|
||||
case 'paccttype':
|
||||
$this->common_model->checkpurview(172);
|
||||
$success = '新增支出类别:';break;
|
||||
case 'PayMethod':
|
||||
$this->common_model->checkpurview(160);
|
||||
$success = '新增结算方式:';break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$sql = $this->mysql_model->insert('category',elements(array('name','typeNumber'),$data));
|
||||
if ($sql) {
|
||||
$this->common_model->logs($success.$data['name']);
|
||||
die('{"status":200,"msg":"success","data":{"coId":0,"detail":true,"id":'.$sql.',"level":1,"name":"'.$data['name'].'","parentId":0,"remark":"","sortIndex":2,"status":0,"typeNumber":"'.$data['typeNumber'].'","uuid":""}}');
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
|
||||
//商品分类添加
|
||||
private function trade_add($data){
|
||||
if ($data['parentId']==0) {
|
||||
$data['level'] = 1;
|
||||
$newid = $this->mysql_model->insert('category',elements(array('name','typeNumber','level','parentId'),$data));
|
||||
$sql = $this->mysql_model->update('category',array('path'=>$newid),array('id'=>$newid));
|
||||
} else {
|
||||
$cate = $this->mysql_model->get_rows('category',array('id'=>$data['parentId']));
|
||||
count($cate)<1 && str_alert(-1,'参数错误');
|
||||
$data['level'] = $cate['level'] + 1;
|
||||
$newid = $this->mysql_model->insert('category',elements(array('name','typeNumber','level','parentId'),$data));
|
||||
$sql = $this->mysql_model->update('category',array('path'=>$cate['path'].','.$newid),array('id'=>$newid));
|
||||
}
|
||||
if ($sql) {
|
||||
$this->common_model->logs('新增商品类别:'.$data['name']);
|
||||
die('{"status":200,"msg":"success","data":{"coId":0,"detail":true,"id":'.$newid.',"level":'.$data['level'].',"name":"'.$data['name'].'","parentId":'.$data['parentId'].',"remark":"","sortIndex":1,"status":0,"typeNumber":"'.$data['typeNumber'].'","uuid":""}}');
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$data = $this->validform(str_enhtml($this->input->post(NULL,TRUE)));
|
||||
switch ($data['typeNumber']) {
|
||||
case 'trade':
|
||||
$this->common_model->checkpurview(169);
|
||||
$this->trade_update($data);break;
|
||||
case 'supplytype':
|
||||
$this->common_model->checkpurview(165);
|
||||
$success = '修改供应商类别:';break;
|
||||
case 'customertype':
|
||||
$this->common_model->checkpurview(75);
|
||||
$success = '修改客户类别:';break;
|
||||
case 'raccttype':
|
||||
$this->common_model->checkpurview(177);
|
||||
$success = '修改收入类别:';break;
|
||||
case 'paccttype':
|
||||
$this->common_model->checkpurview(173);
|
||||
$success = '修改支出类别:';break;
|
||||
case 'PayMethod':
|
||||
$this->common_model->checkpurview(161);
|
||||
$success = '修改结算方式:';break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$sql = $this->mysql_model->update('category',elements(array('name','typeNumber'),$data),array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$this->common_model->logs($success.$data['name']);
|
||||
die('{"status":200,"msg":"success","data":{"coId":0,"detail":true,"id":'.$data['id'].',"level":1,"name"
|
||||
:"'.$data['name'].'","parentId":0,"remark":"","sortIndex":2,"status":0,"typeNumber":"'.$data['typeNumber'].'","uuid":""
|
||||
}}');
|
||||
}
|
||||
str_alert(-1,'修改失败');
|
||||
}
|
||||
|
||||
|
||||
//商品分类修改
|
||||
private function trade_update($data){
|
||||
$cate = $this->mysql_model->get_rows('category',array('id'=>$data['id'])); //获取原ID数据
|
||||
count($cate)<1 && str_alert(-1,'参数错误');
|
||||
$old_pid = $cate['parentId'];
|
||||
$old_path = $cate['path'];
|
||||
$pid_list = $this->mysql_model->get_results('category','(id<>'.$data['id'].') and find_in_set('.$data['id'].',path)'); //是否有子栏目
|
||||
$data['parentId'] == $data['id'] && str_alert(-1,'当前分类和上级分类不能相同');
|
||||
if ($data['parentId']==0) { //多级转顶级
|
||||
$pare_depth = 1;
|
||||
if (count($pid_list)==0) { //ID不存在子栏目
|
||||
$this->mysql_model->update('category',array('parentId'=>0,'path'=>$data['id'],'level'=>1,'name'=>$data['name']),array('id'=>$data['id']));
|
||||
} else { //ID存在子栏目
|
||||
$this->mysql_model->update('category',array('parentId'=>0,'path'=>$data['id'],'level'=>1,'name'=>$data['name']),array('id'=>$data['id']));
|
||||
foreach($pid_list as $arr=>$row) {
|
||||
$path = str_replace(''.str_replace($data['id'],'',$old_path).'','',''.$row['path'].'');
|
||||
$pare_depth = substr_count($path,',')+1;
|
||||
$info[] = array('id'=>$row['id'],'path'=>$path,'level'=>$pare_depth);
|
||||
}
|
||||
$this->mysql_model->update('category',$info,'id');
|
||||
}
|
||||
} else { //pid<>0时,顶级转多级 多级转多级
|
||||
$cate = $this->mysql_model->get_rows('category',array('id'=>$data['parentId'])); //获取原PID数据
|
||||
count($cate)<1 && str_alert(-1,'参数错误');
|
||||
$pare_pid = $cate['parentId'];
|
||||
$pare_path = $cate['path'];
|
||||
$pare_depth = $cate['level'];
|
||||
if ($old_pid==0) { //顶级转多级
|
||||
if (count($pid_list)==0) { //ID不存在子栏目
|
||||
$this->mysql_model->update('category',array('name'=>$data['name'],'parentId'=>$data['parentId'],'path'=>$pare_path.','.$data['id'],'level'=>$pare_depth+1),array('id'=>$data['id']));
|
||||
} else { //ID存在子栏目
|
||||
$this->mysql_model->update('category',array('name'=>$data['name'],'parentId'=>$data['parentId'],'path'=>$pare_path.','.$data['id'],'level'=>$pare_depth+1),array('id'=>$data['id']));
|
||||
foreach ($pid_list as $arr=>$row) {
|
||||
$path = $pare_path.','.$row['path'];
|
||||
$pare_depth = substr_count($path,',')+1;
|
||||
$info[] = array('id'=>$row['id'],'path'=>$path,'level'=>$pare_depth);
|
||||
}
|
||||
$this->mysql_model->update('category',$info,'id');
|
||||
}
|
||||
} else { //多级转多级
|
||||
if (count($pid_list)==0) { //ID不存在子栏目
|
||||
$this->mysql_model->update('category',array('name'=>$data['name'],'parentId'=>$data['parentId'],'path'=>$pare_path.','.$data['id'],'level'=>$pare_depth+1),array('id'=>$data['id']));
|
||||
} else { //ID存在子栏目
|
||||
$this->mysql_model->update('category',array('name'=>$data['name'],'parentId'=>$data['parentId'],'path'=>$pare_path.','.$data['id'],'level'=>$pare_depth+1),array('id'=>$data['id']));
|
||||
foreach ($pid_list as $arr=>$row) {
|
||||
$path = $pare_path.','.str_replace(str_replace($data['id'],'',$old_path),'',$row['path']);
|
||||
$pare_depth = substr_count($path,',')+1;
|
||||
$info[] = array('id'=>$row['id'],'path'=>$path,'level'=>$pare_depth+1);
|
||||
}
|
||||
$this->mysql_model->update('category',$info,'id');
|
||||
}
|
||||
}
|
||||
}
|
||||
$data['level'] = $pare_depth;
|
||||
$this->mysql_model->update('goods',array('categoryName'=>$data['name']),array('categoryId'=>$data['id']));
|
||||
$this->common_model->logs('修改类别:ID='.$data['id'].' 名称:'.$data['name']);
|
||||
die('{"status":200,"msg":"success","data":{"coId":0,"detail":true,"id":'.$data['id'].',"level":'.$data['level'].',"name":"'.$data['name'].'","parentId":'.$data['parentId'].',"remark":"","sortIndex":0,"status":0,"typeNumber":"trade","uuid":""}}');
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
|
||||
|
||||
//分类删除
|
||||
public function delete() {
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$type = str_enhtml($this->input->get_post('typeNumber',TRUE));
|
||||
switch ($type) {
|
||||
case 'trade':
|
||||
$this->common_model->checkpurview(170);
|
||||
$success = '删除商品类别:';break;
|
||||
case 'supplytype':
|
||||
$this->common_model->checkpurview(166);
|
||||
$success = '删除供应商类别:';break;
|
||||
case 'customertype':
|
||||
$this->common_model->checkpurview(76);
|
||||
$success = '删除客户类别:';break;
|
||||
case 'raccttype':
|
||||
$this->common_model->checkpurview(178);
|
||||
$success = '删除收入类别:';break;
|
||||
case 'paccttype':
|
||||
$this->common_model->checkpurview(174);
|
||||
$success = '删除支出类别:';break;
|
||||
case 'PayMethod':
|
||||
$this->common_model->checkpurview(162);
|
||||
$success = '删除结算方式:';break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$data = $this->mysql_model->get_rows('category',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'categoryId'=>$id))>0 && str_alert(-1,'辅助资料已经被使用');
|
||||
$this->mysql_model->get_count('contact',array('isDelete'=>0,'cCategory'=>$id))>0 && str_alert(-1,'辅助资料已经被使用');
|
||||
$this->mysql_model->get_count('category','(isDelete=0) and find_in_set('.$id.',path)')>1 && str_alert(-1,'不能删除,请先删除子分类!');
|
||||
$sql = $this->mysql_model->update('category',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs($success.'ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'删除成功','id'=>'['.$id.']'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$data['typeNumber'] = str_enhtml($this->input->get_post('typeNumber',TRUE)); //结算方式是GET
|
||||
$data['id'] = isset($data['id']) ? intval($data['id']) :0;
|
||||
$data['parentId'] = isset($data['parentId']) ? intval($data['parentId']):0;
|
||||
strlen($data['name']) < 1 && str_alert(-1,'类别名称不能为空');
|
||||
strlen($data['typeNumber']) < 1 && str_alert(-1,'参数错误');
|
||||
$where['isDelete'] = 0;
|
||||
$where['name'] = $data['name'];
|
||||
$where['typeNumber'] = $data['typeNumber'];
|
||||
$where['id !='] = $data['id']>0 ? $data['id'] :0;
|
||||
$this->mysql_model->get_count('category',$where) > 0 && str_alert(-1,'类别名称重复');
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
69
application/controllers/basedata/assistSku.php
Executable file
69
application/controllers/basedata/assistSku.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Assistsku extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//组合属性规格
|
||||
public function index(){
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$where['isDelete'] = 0;
|
||||
$where['skuClassId'] = intval($this->input->get('skuClassId',TRUE));
|
||||
$list = $this->mysql_model->get_results('assistsku',$where,'skuId desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['skuClassId'] = $row['skuClassId'];
|
||||
$v[$arr]['skuAssistId'] = $row['skuAssistId'];
|
||||
$v[$arr]['skuId'] = intval($row['skuId']);
|
||||
$v[$arr]['skuName'] = $row['skuName'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data['skuAssistId'] = $this->input->get_post('skuAssistId',TRUE);
|
||||
$data['skuClassId'] = $this->input->get_post('skuClassId',TRUE);
|
||||
$data['skuName'] = $this->input->get_post('skuName',TRUE);
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('assistsku',array('skuAssistId'=>$data['skuAssistId'])) > 0 && str_alert(-1,'辅助属性组已存在!');
|
||||
$sql = $this->mysql_model->insert('assistsku',$data);
|
||||
if ($sql) {
|
||||
$data['skuId'] = $sql;
|
||||
$this->common_model->logs('新增规格:'.$data['skuName']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('assistsku',array('skuId'=>$id));
|
||||
if (count($data)>0) {
|
||||
$sql = $this->mysql_model->update('assistsku',array('isDelete'=>1),array('skuId'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除规格:ID='.$id.' 名称:'.$data['skuName']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
91
application/controllers/basedata/assistType.php
Executable file
91
application/controllers/basedata/assistType.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Assisttype extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//辅助属性列表
|
||||
public function index() {
|
||||
$list = $this->mysql_model->get_results('assistingprop',array('isDelete'=>0),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['del'] = false;
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$type = $this->input->post('type',TRUE);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
$this->mysql_model->get_count('assistingprop','(isDelete=0) and (name="'.$data['name'].'")') > 0 && str_alert(-1,'名称重复');
|
||||
$sql = $this->mysql_model->insert('assistingprop',$data);
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增辅助属性:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$id = intval($data['id']);
|
||||
unset($data['id']);
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
$this->mysql_model->get_count('assistingprop','(id<>'.$id.') and (name="'.$data['name'].'")') > 0 && str_alert(-1,'名称重复');
|
||||
$sql = $this->mysql_model->update('assistingprop',$data,'(id='.$id.')');
|
||||
if ($sql) {
|
||||
$data['id'] = $id;
|
||||
$this->common_model->logs('更新辅助属性:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->get_post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('assistingprop','(id='.$id.')');
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count(GOODS,'(isDelete=0) and find_in_set('.$id.',skuAssistId)')>0 && str_alert(-1,'数据在使用中,不能删除');
|
||||
$info['isDelete'] = 1;
|
||||
$sql = $this->mysql_model->update('assistingprop',$info,'(id='.$id.')');
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除辅助属性:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$data['id'] = intval($data['id']);
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
strlen($data['type']) < 1 && str_alert(-1,'编号不能为空');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
394
application/controllers/basedata/contact.php
Executable file
394
application/controllers/basedata/contact.php
Executable file
@@ -0,0 +1,394 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Contact extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//客户、供应商列表
|
||||
public function index() {
|
||||
$type = intval($this->input->get('type',TRUE))==10 ? 10 : -10;
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$categoryid = intval($this->input->get_post('categoryId',TRUE));
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$where = '(isDelete=0) and type='.$type;
|
||||
$where .= $this->common_model->get_contact_purview();
|
||||
$where .= $skey ? ' and (number like "%'.$skey.'%" or name like "%'.$skey.'%" or linkMans like "%'.$skey.'%")' : '';
|
||||
$where .= $categoryid>0 ? ' and cCategory = '.$categoryid.'' : '';
|
||||
$list = $this->mysql_model->get_results('contact',$where,'id desc',$rows*($page-1),$rows);
|
||||
//if($type == 10){
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['cCategory'] = intval($row['cCategory']);
|
||||
$v[$arr]['customerType'] = $row['cCategoryName'];
|
||||
$v[$arr]['pinYin'] = $row['pinYin'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['type'] = $row['type'];
|
||||
$v[$arr]['delete'] = intval($row['disable'])==1 ? true : false;
|
||||
$v[$arr]['cLevel'] = intval($row['cLevel']);
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['periodMoney'] = (float)$row['periodMoney'];
|
||||
$v[$arr]['difMoney'] = (float)$row['difMoney'];
|
||||
$v[$arr]['remark'] = $row['remark'];
|
||||
$v[$arr]['taxRate'] = (float)$row['taxRate'];
|
||||
$v[$arr]['links'] = '';
|
||||
$v[$arr]['linkMen'] = $row['linkMans'];//add by michen 20170724
|
||||
if (strlen($row['linkMans'])>0) {
|
||||
$list = (array)json_decode($row['linkMans'],true);
|
||||
foreach ($list as $arr1=>$row1) {
|
||||
if ($row1['linkFirst']==1) {
|
||||
$v[$arr]['contacter'] = $row1['linkName'];
|
||||
$v[$arr]['mobile'] = $row1['linkMobile'];
|
||||
$v[$arr]['place'] = $row1['linkPlace'];
|
||||
$v[$arr]['telephone'] = $row1['linkPhone'];
|
||||
$v[$arr]['linkIm'] = $row1['linkIm'];
|
||||
$v[$arr]['city'] = $row1['city'];
|
||||
$v[$arr]['county'] = $row1['county'];
|
||||
$v[$arr]['province'] = $row1['province'];
|
||||
$v[$arr]['deliveryAddress'] = $row1['address'];
|
||||
$v[$arr]['firstLink']['first'] = $row1['linkFirst'];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*}else{
|
||||
//add by michen 20170720 begin
|
||||
$gid = 1;
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['cCategory'] = intval($row['cCategory']);
|
||||
$v[$arr]['customerType'] = $row['cCategoryName'];
|
||||
$v[$arr]['pinYin'] = $row['pinYin'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['type'] = $row['type'];
|
||||
$v[$arr]['delete'] = intval($row['disable'])==1 ? true : false;
|
||||
$v[$arr]['cLevel'] = intval($row['cLevel']);
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['periodMoney'] = (float)$row['periodMoney'];
|
||||
$v[$arr]['difMoney'] = (float)$row['difMoney'];
|
||||
$v[$arr]['remark'] = $row['remark'];
|
||||
$v[$arr]['taxRate'] = (float)$row['taxRate'];
|
||||
$v[$arr]['links'] = '';
|
||||
$i = 1;
|
||||
if (strlen($row['linkMans'])>0) {
|
||||
$list = (array)json_decode($row['linkMans'],true);
|
||||
foreach ($list as $arr1=>$row1) {
|
||||
if ($i==1) {
|
||||
$v[$arr]['contacter'] = $row1['linkName'];
|
||||
$v[$arr]['mobile'] = $row1['linkMobile'];
|
||||
$v[$arr]['place'] = $row1['linkPlace'];
|
||||
$v[$arr]['telephone'] = $row1['linkPhone'];
|
||||
$v[$arr]['linkIm'] = $row1['linkIm'];
|
||||
$v[$arr]['city'] = $row1['city'];
|
||||
$v[$arr]['county'] = $row1['county'];
|
||||
$v[$arr]['province'] = $row1['province'];
|
||||
$v[$arr]['deliveryAddress'] = $row1['address'];
|
||||
$v[$arr]['firstLink']['first'] = $row1['linkFirst'];
|
||||
$v[$arr]['isFirst'] = $row1['linkFirst']==1?1:2;
|
||||
$v[$arr]['gid'] = $gid;
|
||||
}else{
|
||||
$v[$arr.$i]['id'] = intval($row['id']);
|
||||
$v[$arr.$i]['number'] = $row['number'];
|
||||
$v[$arr.$i]['cCategory'] = intval($row['cCategory']);
|
||||
$v[$arr.$i]['customerType'] = $row['cCategoryName'];
|
||||
$v[$arr.$i]['pinYin'] = $row['pinYin'];
|
||||
$v[$arr.$i]['name'] = $row['name'];
|
||||
$v[$arr.$i]['type'] = $row['type'];
|
||||
$v[$arr.$i]['delete'] = intval($row['disable'])==1 ? true : false;
|
||||
$v[$arr.$i]['cLevel'] = intval($row['cLevel']);
|
||||
$v[$arr.$i]['amount'] = (float)$row['amount'];
|
||||
$v[$arr.$i]['periodMoney'] = (float)$row['periodMoney'];
|
||||
$v[$arr.$i]['difMoney'] = (float)$row['difMoney'];
|
||||
$v[$arr.$i]['remark'] = $row['remark'];
|
||||
$v[$arr.$i]['taxRate'] = (float)$row['taxRate'];
|
||||
$v[$arr.$i]['links'] = '';
|
||||
$v[$arr.$i]['contacter'] = $row1['linkName'];
|
||||
$v[$arr.$i]['mobile'] = $row1['linkMobile'];
|
||||
$v[$arr.$i]['place'] = $row1['linkPlace'];
|
||||
$v[$arr.$i]['telephone'] = $row1['linkPhone'];
|
||||
$v[$arr.$i]['linkIm'] = $row1['linkIm'];
|
||||
$v[$arr.$i]['city'] = $row1['city'];
|
||||
$v[$arr.$i]['county'] = $row1['county'];
|
||||
$v[$arr.$i]['province'] = $row1['province'];
|
||||
$v[$arr.$i]['deliveryAddress'] = $row1['address'];
|
||||
$v[$arr.$i]['firstLink']['first'] = $row1['linkFirst'];
|
||||
$v[$arr.$i]['isFirst'] = $row1['linkFirst']==1?1:2;
|
||||
$v[$arr]['gid'] = $gid;
|
||||
}
|
||||
$i++;
|
||||
$gid++;
|
||||
}
|
||||
}
|
||||
}
|
||||
//add by michen 20170720 end
|
||||
}
|
||||
//add by michen 20170720 begin
|
||||
uasort($v,function ($x,$y){
|
||||
return strcasecmp($x['id'].$x['isFirst'],$y['id'].$x['isFirst']);
|
||||
}
|
||||
);
|
||||
$values = array_values($v);
|
||||
//add by michen 20170720 end
|
||||
*/
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['page'] = $page;
|
||||
$json['data']['records'] = $this->mysql_model->get_count('contact',$where);
|
||||
$json['data']['total'] = ceil($json['data']['records']/$rows);
|
||||
$json['data']['rows'] = isset($v) ? array_values($v) : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//校验客户编号
|
||||
public function getNextNo(){
|
||||
$type = intval($this->input->get('type',TRUE));
|
||||
$skey = intval($this->input->post('skey',TRUE));
|
||||
str_alert(200,'success',array('number'=>$skey));
|
||||
}
|
||||
|
||||
|
||||
//检测客户名称
|
||||
public function checkName(){
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$name = str_enhtml($this->input->post('name',TRUE));
|
||||
$where['name'] = $name;
|
||||
$where['isDelete'] = 0;
|
||||
$where['id !='] = $id>0 ? $id :'';
|
||||
$data = $this->mysql_model->get_rows('contact',array_filter($where));
|
||||
if (count($data)>0) {
|
||||
str_alert(-1,'客户名称重复');
|
||||
}
|
||||
str_alert(200,'success');
|
||||
}
|
||||
|
||||
function my_filter($item){
|
||||
if($item['linkFirst'] === 1)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
public function getRecentlyContact(){
|
||||
$billType = str_enhtml($this->input->post('billType',TRUE));
|
||||
$transType = intval($this->input->post('transType',TRUE));
|
||||
$where = '(isDelete=0)';
|
||||
$where .= ($transType==150501||$transType==150502) ? ' and type=10' :' and type=-10';//mody by michen 20170820 修正购货退货单默认供应商不正确
|
||||
$where .= $this->common_model->get_contact_purview();
|
||||
$data = $this->mysql_model->get_rows('contact',$where);
|
||||
//die(var_export($data,true));
|
||||
if (count($data)>0) {
|
||||
//add by michen 20170724 begin
|
||||
/*$linkMen = (array)json_decode($data['linkMans'],true);
|
||||
$linkMan = "null";
|
||||
if(count($linkMen)>0){
|
||||
foreach ($linkMen as $key => $item){
|
||||
if($item['linkFirst'] === 1){
|
||||
$linkMan = $item;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}*/
|
||||
//add by michen 20170724 end
|
||||
die('{"status":200,"msg":"success","data":{"linkMen":'.$data['linkMans'].',"contactName":"'.$data['name'].'","buId":'.$data['id'].',"cLevel":0}}');
|
||||
} else {
|
||||
str_alert(-1,'');
|
||||
}
|
||||
}
|
||||
|
||||
public function getLinkMen(){
|
||||
$buId = intval($this->input->get('buId',TRUE));
|
||||
$data = $this->mysql_model->get_rows('contact','(isDelete=0) and id='.$buId);
|
||||
die($data['linkMans']);
|
||||
}
|
||||
|
||||
|
||||
//获取信息
|
||||
public function query() {
|
||||
$id = intval($this->input->get_post('id',TRUE));
|
||||
$type = intval($this->input->get_post('type',TRUE));
|
||||
$data = $this->mysql_model->get_rows('contact',array('isDelete'=>0,'id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$info['id'] = $id;
|
||||
$info['cCategory'] = intval($data['cCategory']);
|
||||
$info['cLevel'] = intval($data['cLevel']);
|
||||
$info['number'] = $data['number'];
|
||||
$info['name'] = $data['name'];
|
||||
$info['amount'] = (float)$data['amount'];
|
||||
$info['remark'] = $data['remark'];
|
||||
$info['beginDate'] = $data['beginDate'];
|
||||
$info['periodMoney'] = (float)$data['periodMoney'];
|
||||
$info['difMoney'] = (float)$data['difMoney'];
|
||||
if ($type==10) {
|
||||
$info['taxRate'] = (float)$data['taxRate'];
|
||||
}
|
||||
$info['pinYin'] = $data['pinYin'];
|
||||
if (strlen($data['linkMans'])>0) {
|
||||
$list = (array)json_decode($data['linkMans'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['address'] = $row['address'];
|
||||
$v[$arr]['city'] = $row['city'];
|
||||
$v[$arr]['contactId'] = time();
|
||||
$v[$arr]['county'] = $row['county'];
|
||||
$v[$arr]['email'] = isset($row['email']) ? $row['email'] : '';
|
||||
$v[$arr]['first'] = $row['linkFirst']==1 ? true : '';
|
||||
$v[$arr]['id'] = $arr+1;
|
||||
$v[$arr]['im'] = $row['linkIm'];
|
||||
$v[$arr]['mobile'] = $row['linkMobile'];
|
||||
$v[$arr]['place'] = $row['linkPlace'];
|
||||
$v[$arr]['name'] = $row['linkName'];
|
||||
$v[$arr]['phone'] = $row['linkPhone'];
|
||||
$v[$arr]['province'] = $row['province'];
|
||||
$v[$arr]['tempId'] = 0;
|
||||
}
|
||||
}
|
||||
$info['links'] = isset($v) ? $v : array();
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data'] = $info;
|
||||
die(json_encode($json));
|
||||
}
|
||||
str_alert(-1,'没有数据');
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$data = $this->validform($this->input->post(NULL,TRUE));
|
||||
switch ($data['type']) {
|
||||
case 10:
|
||||
$this->common_model->checkpurview(59);
|
||||
$success = '新增客户:';
|
||||
break;
|
||||
case -10:
|
||||
$this->common_model->checkpurview(64);
|
||||
$success = '新增供应商:';
|
||||
break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$this->mysql_model->get_count('contact',array('isDelete'=>0,'type'=>$data['type'],'number'=>$data['number'])) > 0 && str_alert(-1,'编号重复');
|
||||
$data = elements(array(
|
||||
'name','number','amount','beginDate','cCategory',
|
||||
'cCategoryName','cLevel','cLevelName','linkMans'
|
||||
,'periodMoney','remark','type','difMoney'),$data,NULL);
|
||||
$sql = $this->mysql_model->insert('contact',$data);
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$data['cCategory'] = intval($data['cCategory']);
|
||||
$data['linkMans'] = (array)json_decode($data['linkMans'],true);
|
||||
$this->common_model->logs($success.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$data = $this->validform($this->input->post(NULL,TRUE));
|
||||
switch ($data['type']) {
|
||||
case 10:
|
||||
$this->common_model->checkpurview(60);
|
||||
$success = '修改客户:';
|
||||
break;
|
||||
case -10:
|
||||
$this->common_model->checkpurview(65);
|
||||
$success = '修改供应商:';
|
||||
break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$this->mysql_model->get_count('contact',array('id !='=>$data['id'],'isDelete'=>0,'type'=>$data['type'],'number'=>$data['number'])) > 0 && str_alert(-1,'编号重复');
|
||||
$info = elements(array(
|
||||
'name','number','amount','beginDate','cCategory',
|
||||
'cCategoryName','cLevel','cLevelName','linkMans'
|
||||
,'periodMoney','remark','type','difMoney'),$data,NULL);
|
||||
$sql = $this->mysql_model->update('contact',$info,array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$data['cCategory'] = intval($data['cCategory']);
|
||||
$data['customerType'] = $data['cCategoryName'];
|
||||
$data['linkMans'] = (array)json_decode($data['linkMans'],true);
|
||||
$this->common_model->logs($success.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$id = str_enhtml($this->input->post('id',TRUE));
|
||||
$type = intval($this->input->get_post('type',TRUE))==10 ? 10 : -10;
|
||||
switch ($type) {
|
||||
case 10:
|
||||
$this->common_model->checkpurview(61);
|
||||
$success = '删除客户:';
|
||||
break;
|
||||
case -10:
|
||||
$this->common_model->checkpurview(66);
|
||||
$success = '删除供应商:';
|
||||
break;
|
||||
default:
|
||||
str_alert(-1,'参数错误');
|
||||
}
|
||||
$data = $this->mysql_model->get_results('contact','(id in('.$id.'))');
|
||||
if (count($data) > 0) {
|
||||
$info['isDelete'] = 1;
|
||||
$this->mysql_model->get_count('invoice','(isDelete=0) and (buId in('.$id.'))')>0 && str_alert(-1,'不能删除有业务往来的客户或供应商!');
|
||||
$sql = $this->mysql_model->update('contact',$info,'(id in('.$id.'))');
|
||||
if ($sql) {
|
||||
$name = array_column($data,'name');
|
||||
$this->common_model->logs($success.'ID='.$id.' 名称:'.join(',',$name));
|
||||
die('{"status":200,"msg":"success","data":{"msg":"","id":['.$id.']}}');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'客户或供应商不存在');
|
||||
}
|
||||
|
||||
|
||||
//状态
|
||||
public function disable(){
|
||||
$this->common_model->checkpurview();
|
||||
$disable = intval($this->input->post('disable',TRUE));
|
||||
$id = str_enhtml($this->input->post('contactIds',TRUE));
|
||||
if (strlen($id) > 0) {
|
||||
$sql = $this->mysql_model->update('contact',array('disable'=>$disable),'(id in('.$id.'))');
|
||||
if ($sql) {
|
||||
$this->common_model->logs('客户'.$disable==1?'禁用':'启用'.':ID:'.$id.'');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'操作失败');
|
||||
}
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$this->load->library('lib_pinyin');
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
strlen($data['number']) < 1 && str_alert(-1,'编号不能为空');
|
||||
$data['cCategory'] = intval($data['cCategory']);
|
||||
$data['cLevel'] = (float)$data['cLevel'];
|
||||
$data['taxRate'] = isset($data['taxRate']) ? (float)$data['taxRate'] :0;
|
||||
$data['periodMoney'] = (float)$data['periodMoney'];
|
||||
$data['amount'] = (float)$data['amount'];
|
||||
$data['linkMans'] = $data['linkMans'] ? $data['linkMans'] :"[]";
|
||||
$data['beginDate'] = $data['beginDate'] ? $data['beginDate'] : date('Y-m-d');
|
||||
$data['type'] = intval($this->input->get_post('type',TRUE))==10 ? 10 : -10;
|
||||
$data['pinYin'] = $this->lib_pinyin->str2pinyin($data['name']);
|
||||
$data['contact'] = $data['number'].' '.$data['name'];
|
||||
$data['difMoney'] = $data['amount'] - $data['periodMoney'];
|
||||
$data['cCategoryName'] = $this->mysql_model->get_row('category',array('id'=>$data['cCategory']),'name');
|
||||
$data['cCategory'] < 1 && str_alert(-1,'类别名称不能为空');
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
163
application/controllers/basedata/cst.php
Executable file
163
application/controllers/basedata/cst.php
Executable file
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Cst extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//员工列表
|
||||
public function index(){
|
||||
$cstno = ($this->input->get('cstno',TRUE));
|
||||
if(!empty($cstno)){
|
||||
$customer = explode("_",$cstno);
|
||||
$cstno = $customer[0];
|
||||
}
|
||||
$sql = 'select
|
||||
a.*,b.name as deptName
|
||||
from '.$this->db->dbprefix('staff').' as a
|
||||
left join '.$this->db->dbprefix('contact').' as b on b.id=a.deptId
|
||||
where a.isDelete=0 and a.deptId<>0 '.(empty($cstno)?'':' and deptId='.$cstno).' order by id desc';
|
||||
$list = $this->mysql_model->query($sql,2);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['birthday'] =$row['birthday'];
|
||||
$v[$arr]['allowNeg'] = false;
|
||||
$v[$arr]['commissionrate'] = $row['commissionrate'];
|
||||
$v[$arr]['creatorId'] = $row['creatorId'];
|
||||
$v[$arr]['deptId'] = $row['deptId'];
|
||||
$v[$arr]['deptName'] = $row['deptName'];
|
||||
$v[$arr]['description'] = $row['description'];
|
||||
$v[$arr]['email'] = $row['name'];
|
||||
$v[$arr]['empId'] = $row['empId'];
|
||||
$v[$arr]['empType'] = $row['empType'];
|
||||
$v[$arr]['fullId'] = $row['fullId'];
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['leftDate'] = NULL;
|
||||
$v[$arr]['mobile'] = $row['mobile'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['parentId'] = $row['parentId'];
|
||||
$v[$arr]['sex'] = $row['sex'];
|
||||
$v[$arr]['userName'] = $row['userName'];
|
||||
$v[$arr]['passWord'] = $row['passWord'];
|
||||
$v[$arr]['score'] = $row['score'];
|
||||
$v[$arr]['delete'] = intval($row['disable'])==1 ? true : false; //是否禁用
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('staff',array('isDelete'=>0,'number'=>$data['number'])) > 0 && str_alert(-1,'编号/账号重复');
|
||||
$sql = $this->mysql_model->insert('staff',elements(array('name','number','score','passWord','deptId'),$data));
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增客户账号:编号'.$data['number'].' 名称'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('staff',array('isDelete'=>0,'number'=>$data['number'],'id !='=>$data['id'])) > 0 && str_alert(-1,'编号/账号重复');
|
||||
$sql = $this->mysql_model->update('staff',elements(array('name','number','score','passWord','deptId'),$data),array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('更新客户账号:编号'.$data['number'].' 名称'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('staff',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('invoice',array('isDelete'=>0,'salesId'=>$data['id']))>0 && str_alert(-1,'其中有客户发生业务不可删除');
|
||||
$info['isDelete'] = 1;
|
||||
$sql = $this->mysql_model->update('staff',$info,array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除员工:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
//状态
|
||||
public function disable(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = str_enhtml($this->input->post('employeeIds',TRUE));
|
||||
$data = $this->mysql_model->get_rows('staff',array('id'=>$id));
|
||||
if (count($data) > 0) {
|
||||
$info['disable'] = intval($this->input->post('disable',TRUE));
|
||||
$sql = $this->mysql_model->update('staff',$info,'(id in('.$id.'))');
|
||||
if ($sql) {
|
||||
$action = $info['disable']==1 ? '客户账号禁用' : '客户账号启用';
|
||||
$this->common_model->logs($action.':ID:'.$id.'名称:'.$data['name']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'操作失败');
|
||||
}
|
||||
|
||||
//名称查询
|
||||
public function findByNumberOrName(){
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$where = '(depId=0)';
|
||||
$where .= $skey ? ' and (name like "%'.$skey.'%" or number like "%'.$skey.'%")' : '';
|
||||
$offset = $rows * ($page-1);
|
||||
$list = $this->mysql_model->get_results('staff',$where,'id desc',$offset,$rows);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['totalsize'] = $this->mysql_model->get_count('staff',$where);
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$data['id'] = intval($data['id']);
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
strlen($data['number']) < 1 && str_alert(-1,'编号不能为空');
|
||||
$data['score'] = floatval($data['score']);
|
||||
if(isset($data['passWord'])){
|
||||
strlen($data['passWord']) < 1 && str_alert(-1,'密码不能为空');
|
||||
}else{
|
||||
$data['passWord'] = '';
|
||||
}
|
||||
$customer = explode("_",$data['deptName']);
|
||||
$data['deptId'] = $customer[0];
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
27
application/controllers/basedata/customer.php
Executable file
27
application/controllers/basedata/customer.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Customer extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview(62);
|
||||
}
|
||||
|
||||
public function exporter(){
|
||||
$name = 'customer_'.date('YmdHis').'.xls';
|
||||
sys_csv($name);
|
||||
$this->common_model->logs('导出客户:'.$name);
|
||||
$skey = str_enhtml($this->input->get('skey',TRUE));
|
||||
$categoryId = intval($this->input->get_post('categoryId',TRUE));
|
||||
$where = '(isDelete=0) and type=-10 ';
|
||||
$where .= $this->common_model->get_customer_purview();
|
||||
$where .= $categoryId>0 ? ' and cCategory = '.$categoryId.'' : '';
|
||||
$where .= $skey ? ' and (number like "%'.$skey.'%" or name like "%'.$skey.'%" or linkMans like "%'.$skey.'%")' : '';
|
||||
$data['list'] = $this->mysql_model->get_results('contact',$where,'id desc');
|
||||
$this->load->view('settings/customer-export',$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
109
application/controllers/basedata/deliveryAddr.php
Executable file
109
application/controllers/basedata/deliveryAddr.php
Executable file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Deliveryaddr extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//发货地址列表
|
||||
public function index(){
|
||||
$list = $this->mysql_model->get_results('address',array('isDelete'=>0),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = $row['id'];
|
||||
$v[$arr]['shortName'] = $row['shortName'];
|
||||
$v[$arr]['postalcode'] = $row['postalcode'];
|
||||
$v[$arr]['province'] = $row['province'];
|
||||
$v[$arr]['city'] = $row['city'];
|
||||
$v[$arr]['area'] = $row['area'];
|
||||
$v[$arr]['address'] = $row['address'];
|
||||
$v[$arr]['linkman'] = $row['linkman'];
|
||||
$v[$arr]['phone'] = $row['phone'];
|
||||
$v[$arr]['mobile'] = $row['mobile'];
|
||||
$v[$arr]['isDefault'] = 1;
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$sql = $this->mysql_model->insert('address',$data);
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增地址:'.$data['shortName']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$id = intval($data['id']);
|
||||
unset($data['id']);
|
||||
$sql = $this->mysql_model->update('address',$data,array('id'=>$id));
|
||||
if ($sql) {
|
||||
$data['id'] = $id;
|
||||
$this->common_model->logs('更新地址:ID='.$id.',名称:'.$data['shortName']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('address',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
//$this->mysql_model->get_count(INVSA,'(contactid in('.$id.'))')>0 && str_alert(-1,'其中有客户发生业务不可删除');
|
||||
$sql = $this->mysql_model->update('address',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除地址:ID='.$id.' 名称:'.$data['shortname']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
//查询
|
||||
public function query(){
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('address',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$json['data']['id'] = intval($data['id']);
|
||||
$json['data']['shortName'] = $data['shortName'];
|
||||
$json['data']['postalcode'] = $data['postalcode'];
|
||||
$json['data']['province'] = $data['province'];
|
||||
$json['data']['city'] = $data['city'];
|
||||
$json['data']['area'] = $data['area'];
|
||||
$json['data']['address'] = $data['address'];
|
||||
$json['data']['linkman'] = $data['linkman'];
|
||||
$json['data']['phone'] = $data['phone'];
|
||||
$json['data']['mobile'] = $data['mobile'];
|
||||
$json['data']['isDefault'] = intval($data['isdefault']);
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
die(json_encode($json));
|
||||
}
|
||||
str_alert(-1,'地址不存在');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
150
application/controllers/basedata/employee.php
Executable file
150
application/controllers/basedata/employee.php
Executable file
@@ -0,0 +1,150 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Employee extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//员工列表
|
||||
public function index(){
|
||||
$list = $this->mysql_model->get_results('staff',array('isDelete'=>0,'deptId'=>0),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['birthday'] =$row['birthday'];
|
||||
$v[$arr]['allowNeg'] = false;
|
||||
$v[$arr]['commissionrate'] = $row['commissionrate'];
|
||||
$v[$arr]['creatorId'] = $row['creatorId'];
|
||||
$v[$arr]['deptId'] = $row['deptId'];
|
||||
$v[$arr]['description'] = $row['description'];
|
||||
$v[$arr]['email'] = $row['name'];
|
||||
$v[$arr]['empId'] = $row['empId'];
|
||||
$v[$arr]['empType'] = $row['empType'];
|
||||
$v[$arr]['fullId'] = $row['fullId'];
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['leftDate'] = NULL;
|
||||
$v[$arr]['mobile'] = $row['mobile'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['parentId'] = $row['parentId'];
|
||||
$v[$arr]['sex'] = $row['sex'];
|
||||
$v[$arr]['userName'] = $row['userName'];
|
||||
$v[$arr]['passWord'] = $row['passWord'];
|
||||
$v[$arr]['score'] = $row['score'];
|
||||
$v[$arr]['delete'] = intval($row['disable'])==1 ? true : false; //是否禁用
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('staff',array('isDelete'=>0,'number'=>$data['number'])) > 0 && str_alert(-1,'编号/账号重复');
|
||||
$sql = $this->mysql_model->insert('staff',elements(array('name','number','score','passWord'),$data));
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增员工:编号'.$data['number'].' 名称'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('staff',array('isDelete'=>0,'number'=>$data['number'],'id !='=>$data['id'])) > 0 && str_alert(-1,'编号/账号重复');
|
||||
$sql = $this->mysql_model->update('staff',elements(array('name','number','score','passWord'),$data),array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('更新员工:编号'.$data['number'].' 名称'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('staff',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('invoice',array('isDelete'=>0,'salesId'=>$data['id']))>0 && str_alert(-1,'其中有客户发生业务不可删除');
|
||||
$info['isDelete'] = 1;
|
||||
$sql = $this->mysql_model->update('staff',$info,array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除员工:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
//状态
|
||||
public function disable(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = str_enhtml($this->input->post('employeeIds',TRUE));
|
||||
$data = $this->mysql_model->get_rows('staff',array('id'=>$id));
|
||||
if (count($data) > 0) {
|
||||
$info['disable'] = intval($this->input->post('disable',TRUE));
|
||||
$sql = $this->mysql_model->update('staff',$info,'(id in('.$id.'))');
|
||||
if ($sql) {
|
||||
$action = $info['disable']==1 ? '员工禁用' : '员工启用';
|
||||
$this->common_model->logs($action.':ID:'.$id.'名称:'.$data['name']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'操作失败');
|
||||
}
|
||||
|
||||
//名称查询
|
||||
public function findByNumberOrName(){
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$where = '(depId=0)';
|
||||
$where .= $skey ? ' and (name like "%'.$skey.'%" or number like "%'.$skey.'%")' : '';
|
||||
$offset = $rows * ($page-1);
|
||||
$list = $this->mysql_model->get_results('staff',$where,'id desc',$offset,$rows);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['totalsize'] = $this->mysql_model->get_count('staff',$where);
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$data['id'] = intval($data['id']);
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
strlen($data['number']) < 1 && str_alert(-1,'编号不能为空');
|
||||
$data['score'] = floatval($data['score']);
|
||||
if(isset($data['passWord'])){
|
||||
strlen($data['passWord']) < 1 && str_alert(-1,'密码不能为空');
|
||||
}else{
|
||||
$data['passWord'] = '';
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
351
application/controllers/basedata/import.php
Executable file
351
application/controllers/basedata/import.php
Executable file
@@ -0,0 +1,351 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Import extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
$this->load->helper('download');
|
||||
$this->load->library('excel/excel_reader2');
|
||||
$this->load->library('pinyin/getpinyin');
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$dir = './data/upfile/' . date('Ymd') . '/';
|
||||
//$path = '/data/upfile/' . date('Ymd') . '/';
|
||||
$err = json_encode(array('url' => '', 'title' => '', 'state' => '请登录'));
|
||||
$info = upload('resume_file', $dir);
|
||||
if (is_array($info) && count($info) > 0) {
|
||||
//$array = array('url' => $path . $info['file'], 'title' => $path . $info['file'], 'state' => 'SUCCESS');
|
||||
print_r($info);
|
||||
die();
|
||||
} else {
|
||||
die($err);
|
||||
}
|
||||
}
|
||||
|
||||
//客户
|
||||
public function downloadtemplate1() {
|
||||
$info = read_file('./data/download/customer.xls');
|
||||
$this->common_model->logs('下载文件名:客户导入_'.date("YmdHis").'.xls');
|
||||
force_download('客户导入_'.date("YmdHis").'.xls', $info);
|
||||
}
|
||||
|
||||
//供应商
|
||||
public function downloadtemplate2() {
|
||||
$info = read_file('./data/download/vendor.xls');
|
||||
$this->common_model->logs('下载文件名:供应商导入_'.date("YmdHis").'.xls');
|
||||
force_download('供应商导入_'.date("YmdHis").'.xls', $info);
|
||||
}
|
||||
|
||||
//商品
|
||||
public function downloadtemplate3() {
|
||||
$info = read_file('./data/download/goods.xls');
|
||||
$this->common_model->logs('下载文件名:商品导入_'.date("YmdHis").'.xls');
|
||||
force_download('商品导入_'.date("YmdHis").'.xls', $info);
|
||||
}
|
||||
|
||||
//价格预警
|
||||
public function downloadtemplate4() {
|
||||
$info = read_file('./data/download/preprice.xls');
|
||||
$this->common_model->logs('下载文件名:价格预警导入_'.date("YmdHis").'.xls');
|
||||
force_download('价格预警导入_'.date("YmdHis").'.xls', $info);
|
||||
}
|
||||
|
||||
//客户导入
|
||||
public function findDataImporter() {
|
||||
$fn = (isset($_SERVER['HTTP_X_FILENAME']) ? $_SERVER['HTTP_X_FILENAME'] : false);
|
||||
print_r($fn);
|
||||
die();
|
||||
if ($fn) {
|
||||
file_put_contents(
|
||||
'upload/' . $fn,
|
||||
file_get_contents('php://input')
|
||||
);
|
||||
echo "http://119.10.11.187:82/AAAUPIMG/1/uploads/".$fn;
|
||||
exit();
|
||||
}
|
||||
print_r($_FILES);
|
||||
die();
|
||||
// $dir = './data/upfile/' . date('Ymd') . '/';
|
||||
// //$path = '/data/upfile/' . date('Ymd') . '/';
|
||||
// $err = json_encode(array('url' => '', 'title' => '', 'state' => '请登录'));
|
||||
// $info = upload('resume_file', $dir);
|
||||
// if (is_array($info) && count($info) > 0) {
|
||||
// //$array = array('url' => $path . $info['file'], 'title' => $path . $info['file'], 'state' => 'SUCCESS');
|
||||
// print_r($info);
|
||||
// die();
|
||||
// } else {
|
||||
// die($err);
|
||||
// }
|
||||
die('{"status":200,"msg":"success","data":{"items":[{"id":1294598139109696,"date":"2015-04-25 14:41:35","uploadPath"
|
||||
:"customer_20150425024011.xls","uploadName":"customer_20150425024011.xls","resultPath":"uploadfiles/88887901
|
||||
/customer_20150425024011.xls","resultName":"customer_20150425024011.xls","resultInfo":"商品导入完毕。<br/>商
|
||||
品一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕。<br/>客户一共:10条数
|
||||
据,成功导入:10条数据,失败:0条数据。<br/>","status":2,"spendTime":0},{"id":1294598139109659,"date":"2015-04-25 14:40
|
||||
:49","uploadPath":"customer_20150425024011.xls","uploadName":"customer_20150425024011.xls","resultPath"
|
||||
:"uploadfiles/88887901/customer_20150425024011.xls","resultName":"customer_20150425024011.xls","resultInfo"
|
||||
:"商品导入完毕。<br/>商品一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕
|
||||
。<br/>客户一共:10条数据,成功导入:10条数据,失败:0条数据。<br/>","status":2,"spendTime":0},{"id":1294597559113847,"date":"2015-04-17
|
||||
16:54:39","uploadPath":"蓝港新系统xls.xls","uploadName":"蓝港新系统xls.xls","resultPath":"uploadfiles/88887901
|
||||
/蓝港新系统xls.xls","resultName":"蓝港新系统xls.xls","resultInfo":"商品导入完毕。<br/>商品一共:557条数据,成功导入:0条数据,失败:557条数据
|
||||
。<br/>(请检查模板是否匹配,建议重新下载模板导入)<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕。<br/>客户一共:0条数
|
||||
据,成功导入:0条数据,失败:0条数据。<br/>","status":2,"spendTime":0}],"totalsize":3}}');
|
||||
die('{"status":200,"msg":"success"}');
|
||||
}
|
||||
|
||||
//上传文件
|
||||
public function upload() {
|
||||
die('{"status":200,"msg":"success","data":{"items":[{"id":1294598139109696,"date":"2015-04-25 14:41:35","uploadPath"
|
||||
:"customer_20150425024011.xls","uploadName":"customer_20150425024011.xls","resultPath":"uploadfiles/88887901
|
||||
/customer_20150425024011.xls","resultName":"customer_20150425024011.xls","resultInfo":"商品导入完毕。<br/>商
|
||||
品一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕。<br/>客户一共:10条数
|
||||
据,成功导入:10条数据,失败:0条数据。<br/>","status":2,"spendTime":0},{"id":1294598139109659,"date":"2015-04-25 14:40
|
||||
:49","uploadPath":"customer_20150425024011.xls","uploadName":"customer_20150425024011.xls","resultPath"
|
||||
:"uploadfiles/88887901/customer_20150425024011.xls","resultName":"customer_20150425024011.xls","resultInfo"
|
||||
:"商品导入完毕。<br/>商品一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕
|
||||
。<br/>客户一共:10条数据,成功导入:10条数据,失败:0条数据。<br/>","status":2,"spendTime":0},{"id":1294597559113847,"date":"2015-04-17
|
||||
16:54:39","uploadPath":"蓝港新系统xls.xls","uploadName":"蓝港新系统xls.xls","resultPath":"uploadfiles/88887901
|
||||
/蓝港新系统xls.xls","resultName":"蓝港新系统xls.xls","resultInfo":"商品导入完毕。<br/>商品一共:557条数据,成功导入:0条数据,失败:557条数据
|
||||
。<br/>(请检查模板是否匹配,建议重新下载模板导入)<br/>供应商导入完毕。<br/>供应商一共:0条数据,成功导入:0条数据,失败:0条数据。<br/>客户导入完毕。<br/>客户一共:0条数
|
||||
据,成功导入:0条数据,失败:0条数据。<br/>","status":2,"spendTime":0}],"totalsize":3}}');
|
||||
}
|
||||
|
||||
public function uploadExcel() {
|
||||
$path=$_FILES['file'];
|
||||
if($path['error']!= 0)
|
||||
str_alert(-1,'文件上传失败!');
|
||||
if($path['size']>20*1024*1024)
|
||||
str_alert(-1,'上传文件大小超过限制!');
|
||||
if($path['type']!='application/vnd.ms-excel' && strrchr($path['name'],'xls')!='xls'){
|
||||
str_alert(200,'上传的文件不是excel类型!');
|
||||
}
|
||||
//$filePath = "data/upload/".$path["name"];
|
||||
//move_uploaded_file($path["tmp_name"],$filePath);
|
||||
|
||||
//$reader = new Excel_reader2(); // 实例化解析类Spreadsheet_Excel_Reader
|
||||
$reader = $this->excel_reader2;
|
||||
$reader->setOutputEncoding("utf-8"); // 设置编码方式
|
||||
$reader->read("{$path['tmp_name']}");
|
||||
$data = $reader->sheets[0]['cells'];
|
||||
if(!isset($data[2])||!isset($data[2][1]))
|
||||
str_alert(-1,'无可导入的数据!');
|
||||
$first = array_shift($data);
|
||||
$itype = "";
|
||||
$this->db->trans_begin();
|
||||
if($first[1]=='商品编号'){
|
||||
$itype = "商品";
|
||||
foreach ($data as $arr=>$row) {
|
||||
if(empty($row[1]))
|
||||
continue;
|
||||
$good['number'] = $row[1];
|
||||
$good['name'] = $row[2];
|
||||
$good['barCode'] = $row[3];
|
||||
$good['spec'] = $row[4];
|
||||
//$good['categoryId'] = 1;
|
||||
//$good['categoryName'] = $row[5];
|
||||
//$good['locationId'] = $row[6];
|
||||
//$good['baseUnitId'] = $row[9];
|
||||
$good['purPrice'] = floatval($row[10]);
|
||||
$good['wholesalePrice'] = floatval($row[12]);
|
||||
$good['salePrice'] = floatval($row[11]);
|
||||
$good['pinYin'] = $this->getpinyin->getFirstPY($row[2]);
|
||||
$good['sonGoods'] = '[]';
|
||||
$good['dopey'] = 0;
|
||||
empty($row[5])&&str_alert(-1,'商品【'.$row[2].'】类别不能为空!');
|
||||
empty($row[6])&&str_alert(-1,'商品【'.$row[2].'】仓库不能为空!');
|
||||
empty($row[9])&&str_alert(-1,'商品【'.$row[2].'】计量单位不能为空!');
|
||||
$list = $this->mysql_model->get_rows('storage',array('isDelete'=>0,'name'=>$row[6]));
|
||||
if (count($list) > 0) {
|
||||
$good['locationId']= $list['id'];
|
||||
$good['locationName']= $row[6];
|
||||
}else
|
||||
str_alert(-1,'仓库【'.$row[6].'】不存在,请先添加仓库后再导入!');
|
||||
$list = $this->mysql_model->get_rows('category',array('name'=>$row[5],'typeNumber'=>'trade'));
|
||||
if (count($list) > 0) {
|
||||
$good['categoryId']= $list['id'];
|
||||
$good['categoryName']= $row[5];
|
||||
}else{
|
||||
str_alert(-1,'商品类别【'.$row[5].'】不存在,请先添加商品类别再导入!');
|
||||
}
|
||||
$list = $this->mysql_model->get_rows('unit',array('name'=>$row[9]));
|
||||
if (count($list) > 0) {
|
||||
$good['baseUnitId']= $list['id'];
|
||||
$good['unitName']= $row[9];
|
||||
}else{
|
||||
str_alert(-1,'计量单位【'.$row[9].'】不存在,请先添加计量单位再导入!');
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'number','name','barCode','spec','categoryId','locationId','baseUnitId','purPrice','salePrice',
|
||||
'locationName','unitName','categoryName','pinYin','sonGoods','dopey','wholesalePrice'
|
||||
);
|
||||
$info = elements($info,$good,NULL);
|
||||
|
||||
$existgood = $this->mysql_model->get_rows('goods',array('isDelete'=>0,'number'=>$good['number']));
|
||||
// if($this->mysql_model->get_count('goods',array('isDelete'=>0,'number'=>$good['number'])) <= 0){
|
||||
if(count($existgood) <= 0){
|
||||
$rtn['id'] = $this->mysql_model->insert('goods',$info);
|
||||
}else {
|
||||
$rtn['id'] = $existgood['id'];
|
||||
$this->mysql_model->delete('invoice_info',array('billType'=>'INI','invId'=>$rtn['id']));
|
||||
$this->mysql_model->update('goods',$info,array('number'=>$good['number']));
|
||||
}
|
||||
if(!empty($row[19])){
|
||||
$list = $this->mysql_model->get_rows('storage',array('isDelete'=>0,'name'=>$row[19]));
|
||||
if (count($list) > 0) {
|
||||
$arr = 0;
|
||||
$v[$arr]['invId'] = $rtn['id'];
|
||||
$v[$arr]['locationId'] = $list['id'];
|
||||
$v[$arr]['qty'] = floatval($row[21]);
|
||||
$v[$arr]['price'] = floatval($row[22]);
|
||||
$v[$arr]['amount'] = floatval($row[21])*floatval($row[22]);
|
||||
$v[$arr]['skuId'] = 0;
|
||||
$v[$arr]['billDate'] = date('Y-m-d');;
|
||||
$v[$arr]['billNo'] = '期初数量';
|
||||
$v[$arr]['billType'] = 'INI';
|
||||
$v[$arr]['transTypeName'] = '期初数量';
|
||||
if (isset($v)) {
|
||||
$this->mysql_model->insert('invoice_info',$v);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}else if($first[1]=='客户编号'){
|
||||
$itype = "客户";
|
||||
foreach ($data as $arr=>$row) {
|
||||
if(empty($row[1]))
|
||||
continue;//add by michen 20170917 for
|
||||
$cust['number'] = strval($row[1]);
|
||||
$cust['name'] = $row[2];
|
||||
//$cust['cCategory'] = $row[3];
|
||||
//$cust['cCategoryName'] = $row[4];
|
||||
$cust['cLevel'] = 0;
|
||||
$cust['remark'] = $row[8];
|
||||
$linkMan['linkName'] = $row[9];
|
||||
$linkMan['linkMobile'] = $row[10];
|
||||
$linkMan['linkPhone'] = $row[11];
|
||||
$linkMan['linkPlace'] = $row[12];
|
||||
$linkMan['linkIm'] = $row[13];
|
||||
$linkMan['address'] = $row[14];
|
||||
$linkMan['linkFirst'] = 1;
|
||||
$linkMan['id'] = 0;
|
||||
$linkMans[0] = $linkMan;
|
||||
$cust['linkMans'] = json_encode($linkMans);
|
||||
$cust['type'] = -10;
|
||||
empty($row[1])&&str_alert(-1,'第'.$arr.'行客户编号不能为空!');
|
||||
empty($row[2])&&str_alert(-1,'第'.$arr.'行客户名称不能为空!');
|
||||
empty($row[3])&&str_alert(-1,'第'.$arr.'行客户类别不能为空!');
|
||||
$list = $this->mysql_model->get_rows('category',array('name'=>$row[3],'typeNumber'=>'customertype'));
|
||||
if (count($list) > 0) {
|
||||
$cust['cCategory']= $list['id'];
|
||||
$cust['cCategoryName']= $row[3];
|
||||
}else{
|
||||
str_alert(-1,'第'.$arr.'行客户类别【'.$row[3].'】不存在,请先添加客户类别再导入!');
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'number','name','cLevel','remark','cCategory','cCategoryName','linkMans','type'
|
||||
);
|
||||
$info = elements($info,$cust,NULL);
|
||||
//die(var_export($cust,true));
|
||||
if($this->mysql_model->get_count('contact',array('isDelete'=>0,'number'=>$cust['number'],'type'=>-10)) <= 0){
|
||||
$rtn['id'] = $this->mysql_model->insert('contact',$info);
|
||||
}else {
|
||||
$this->mysql_model->update('contact',$info,array('number'=>$cust['number'],'type'=>-10));
|
||||
}
|
||||
}
|
||||
}else if($first[1]=='供应商编号'){
|
||||
$itype = "供应商";
|
||||
foreach ($data as $arr=>$row) {
|
||||
if(empty($row[1]))
|
||||
continue;
|
||||
$sup['number'] = strval($row[1]);
|
||||
$sup['name'] = $row[2];
|
||||
//$cust['cCategory'] = $row[3];
|
||||
//$cust['cCategoryName'] = $row[4];
|
||||
$sup['cLevel'] = 0;
|
||||
$sup['remark'] = $row[7];
|
||||
$linkMan['linkName'] = $row[8];
|
||||
$linkMan['linkMobile'] = $row[9];
|
||||
$linkMan['linkPhone'] = $row[10];
|
||||
$linkMan['linkPlace'] = $row[11];
|
||||
$linkMan['linkIm'] = $row[12];
|
||||
$linkMan['address'] = $row[13];
|
||||
$linkMan['linkFirst'] = 1;
|
||||
$linkMan['id'] = 0;
|
||||
$linkMans[0] = $linkMan;
|
||||
$sup['linkMans'] = json_encode($linkMans);
|
||||
$sup['type'] = 10;
|
||||
empty($row[1])&&str_alert(-1,'第'.$arr.'行供应商编号不能为空!');
|
||||
empty($row[2])&&str_alert(-1,'第'.$arr.'行供应商名称不能为空!');
|
||||
empty($row[3])&&str_alert(-1,'第'.$arr.'行供应商类别不能为空!');
|
||||
$list = $this->mysql_model->get_rows('category',array('name'=>$row[3],'typeNumber'=>'supplytype'));
|
||||
if (count($list) > 0) {
|
||||
$sup['cCategory']= $list['id'];
|
||||
$sup['cCategoryName']= $row[3];
|
||||
}else{
|
||||
str_alert(-1,'第'.$arr.'行供应商类别【'.$row[3].'】不存在,请先添加供应商类别再导入!');
|
||||
}
|
||||
|
||||
$info = array(
|
||||
'number','name','cLevel','remark','cCategory','cCategoryName','linkMans','type'
|
||||
);
|
||||
$info = elements($info,$sup,NULL);
|
||||
|
||||
if($this->mysql_model->get_count('contact',array('isDelete'=>0,'number'=>$sup['number'],'type'=>10)) <= 0){
|
||||
$rtn['id'] = $this->mysql_model->insert('contact',$info);
|
||||
}else {
|
||||
$this->mysql_model->update('contact',$info,array('number'=>$sup['number'],'type'=>10));
|
||||
}
|
||||
}
|
||||
}else if($first[1]=='商品编码'){
|
||||
$itype = "价格预警";
|
||||
foreach ($data as $arr=>$row) {
|
||||
if(empty($row[1]))
|
||||
continue;
|
||||
$preprice['number'] = trim(strval($row[1]));
|
||||
$preprice['supplier'] = trim(strval($row[2]));
|
||||
$preprice['price'] = floatval($row[3]);
|
||||
empty($row[1])&&str_alert(-1,'第'.$arr.'行商品编码不能为空!');
|
||||
empty($row[2])&&str_alert(-1,'第'.$arr.'行供应商编码不能为空!');
|
||||
empty($row[3])&&str_alert(-1,'第'.$arr.'行价格不能为空!');
|
||||
$list = $this->mysql_model->get_rows('goods',array('number'=>$preprice['number'],'isDelete'=>0));
|
||||
if (count($list) > 0) {
|
||||
$preprice['invId'] = $list['id'];
|
||||
}else{
|
||||
str_alert(-1,'第'.$arr.'行商品编码【'.$row[1].'】不存在,请先添加商品再导入!');
|
||||
}
|
||||
$list = $this->mysql_model->get_rows('contact',array('number'=>$preprice['supplier'],'isDelete'=>0,'type'=>10));
|
||||
if (count($list) > 0) {
|
||||
$preprice['buId'] = $list['id'];
|
||||
}else{
|
||||
str_alert(-1,'第'.$arr.'行供应商编码【'.$row[2].'】不存在,请先添加供应商再导入!');
|
||||
}
|
||||
$preprice['billDate'] = date('Y-m-d');
|
||||
$info = array(
|
||||
'invId','buId','price','billDate'
|
||||
);
|
||||
$info = elements($info,$preprice,NULL);
|
||||
$rtn['id'] = $this->mysql_model->insert('preprice',$info);
|
||||
}
|
||||
}
|
||||
if ($this->db->trans_status() === FALSE) {
|
||||
$this->db->trans_rollback();
|
||||
str_alert(-1,'SQL错误回滚');
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
str_alert(200,'恭喜您,导入'.$itype.'信息成功!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
647
application/controllers/basedata/inventory.php
Executable file
647
application/controllers/basedata/inventory.php
Executable file
@@ -0,0 +1,647 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Inventory extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//商品列表
|
||||
public function index() {
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$categoryid = intval($this->input->get_post('assistId',TRUE));
|
||||
$barCode = intval($this->input->get_post('barCode',TRUE));
|
||||
$where = '(a.isDelete=0)';
|
||||
$where .= $skey ? ' and (sonGoods like "%'.$skey.'%" or name like "%'.$skey.'%" or number like "%'.$skey.'%" or spec like "%'.$skey.'%")' : '';
|
||||
$where .= $barCode ? ' and barCode="'.$barCode.'"' : '';
|
||||
if ($categoryid > 0) {
|
||||
$cid = array_column($this->mysql_model->get_results('category','(isDelete=0) and find_in_set('.$categoryid.',path)'),'id');
|
||||
if (count($cid)>0) {
|
||||
$cid = join(',',$cid);
|
||||
$where .= ' and categoryid in('.$cid.')';
|
||||
}
|
||||
}
|
||||
$list = $this->data_model->get_goods($where.' order by a.id desc limit '.$rows*($page-1).','.$rows);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['amount'] = (float)$row['iniamount'];
|
||||
$v[$arr]['barCode'] = $row['barCode'];
|
||||
$v[$arr]['categoryName'] = $row['categoryName'];
|
||||
$v[$arr]['currentQty'] = $row['totalqty']; //当前库存
|
||||
$v[$arr]['delete'] = intval($row['disable'])==1 ? true : false; //是否禁用
|
||||
$v[$arr]['discountRate'] = 0;
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['isSerNum'] = intval($row['isSerNum']);
|
||||
$v[$arr]['josl'] = $row['josl'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['pinYin'] = $row['pinYin'];
|
||||
$v[$arr]['locationId'] = intval($row['locationId']);
|
||||
$v[$arr]['locationName'] = $row['locationName'];
|
||||
$v[$arr]['locationNo'] = '';
|
||||
$v[$arr]['purPrice'] = $row['purPrice'];
|
||||
$v[$arr]['quantity'] = $row['iniqty'];
|
||||
$v[$arr]['salePrice'] = $row['salePrice'];
|
||||
$v[$arr]['skuClassId'] = $row['skuClassId'];
|
||||
$v[$arr]['spec'] = $row['spec'];
|
||||
$v[$arr]['unitCost'] = $row['iniunitCost'];
|
||||
$v[$arr]['unitId'] = intval($row['unitId']);
|
||||
$v[$arr]['unitName'] = $row['unitName'];
|
||||
$v[$arr]['remark'] = $row['remark'];
|
||||
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['page'] = $page;
|
||||
$json['data']['records'] = $this->data_model->get_goods($where,3);
|
||||
$json['data']['total'] = ceil($json['data']['records']/$rows);
|
||||
$json['data']['rows'] = isset($v) ? $v :'';
|
||||
die(json_encode($json));
|
||||
|
||||
}
|
||||
|
||||
//商品选择 最近出售价格
|
||||
public function listBySelected() {
|
||||
$arr = array('so'=>150601,'sa'=>150501);
|
||||
$contactid = intval($this->input->post('contactId',TRUE));
|
||||
$type = str_enhtml($this->input->post('type',TRUE));
|
||||
$id = intval($this->input->post('ids',TRUE));
|
||||
$list = $this->data_model->get_invoice_info('a.isDelete=0 and transType='.$arr[$type].' and a.invId='.$id.' and a.buId='.$contactid.' limit 0,3',2);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['advanceDays'] = 0;
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['barCode'] = '';
|
||||
$v[$arr]['categoryName'] = '';
|
||||
$v[$arr]['currentQty'] = 0;
|
||||
$v[$arr]['delete'] = false;
|
||||
$v[$arr]['discountRate'] = 0;
|
||||
$v[$arr]['id'] = intval($row['invId']);
|
||||
$v[$arr]['isSerNum'] = 0;
|
||||
$v[$arr]['isWarranty'] = 0;
|
||||
$v[$arr]['josl'] = '';
|
||||
$v[$arr]['locationId'] = intval($row['locationId']);
|
||||
$v[$arr]['locationName'] = $row['locationName'];
|
||||
$v[$arr]['locationNo'] = $row['locationNo'];
|
||||
$v[$arr]['name'] = $row['invName'];
|
||||
$v[$arr]['nearPrice'] = $row['price'];
|
||||
$v[$arr]['number'] = $row['invNumber'];
|
||||
$v[$arr]['pinYin'] = $row['pinYin'];
|
||||
$v[$arr]['purPrice'] = $row['purPrice'];
|
||||
$v[$arr]['quantity'] = $row['quantity'];
|
||||
$v[$arr]['salePrice'] = $row['salePrice'];
|
||||
$v[$arr]['skuClassId'] = 0;
|
||||
$v[$arr]['skuId'] = 0;
|
||||
$v[$arr]['skuName'] = 0;
|
||||
$v[$arr]['skuNumber'] = 0;
|
||||
$v[$arr]['spec'] = $row['invSpec'];
|
||||
$v[$arr]['unitCost'] = 0;
|
||||
$v[$arr]['unitId'] = intval($row['unitId']);
|
||||
$v[$arr]['unitName'] = $row['mainUnit'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['result'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
//获取信息
|
||||
public function query() {
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
str_alert(200,'success',$this->get_goods_info($id));
|
||||
}
|
||||
|
||||
|
||||
//检测编号
|
||||
public function getNextNo() {
|
||||
$skey = str_enhtml($this->input->post('skey',TRUE));
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'number'=>$skey)) > 0 && str_alert(-1,'商品编号已经存在');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
|
||||
//检测条码
|
||||
public function checkBarCode() {
|
||||
$barCode = str_enhtml($this->input->post('barCode',TRUE));
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'barCode'=>$barCode)) > 0 && str_alert(-1,'商品条码已经存在');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
|
||||
//检测规格
|
||||
public function checkSpec() {
|
||||
$spec = str_enhtml($this->input->post('spec',TRUE));
|
||||
$this->mysql_model->get_count('assistsku',array('isDelete'=>0,'skuName'=>$spec)) > 0 && str_alert(-1,'商品规格已经存在');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
|
||||
//检测名称
|
||||
public function checkname() {
|
||||
$skey = str_enhtml($this->input->post('barCode',TRUE));
|
||||
echo '{"status":200,"msg":"success","data":{"number":""}}';
|
||||
}
|
||||
|
||||
//获取图片信息
|
||||
public function getImagesById() {
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$list = $this->mysql_model->get_results('goods_img',array('isDelete'=>0,'invId'=>$id));
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['pid'] = $row['id'];
|
||||
$v[$arr]['status'] = 1;
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['url'] = site_url().'/basedata/inventory/getImage?action=getImage&pid='.$row['id'];
|
||||
$v[$arr]['thumbnailUrl'] = site_url().'/basedata/inventory/getImage?action=getImage&pid='.$row['id'];
|
||||
$v[$arr]['deleteUrl'] = '';
|
||||
$v[$arr]['deleteType'] = '';
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['files'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//上传图片信息
|
||||
public function uploadImages() {
|
||||
require_once './application/libraries/UploadHandler.php';
|
||||
$config = array(
|
||||
'script_url' => base_url().'inventory/uploadimages',
|
||||
'upload_dir' => dirname($_SERVER['SCRIPT_FILENAME']).'/data/upfile/goods/',
|
||||
'upload_url' => base_url().'data/upfile/goods/',
|
||||
'delete_type' =>'',
|
||||
'print_response' =>false
|
||||
);
|
||||
$uploadHandler = new UploadHandler($config);
|
||||
$list = (array)json_decode(json_encode($uploadHandler->response['files'][0]), true);
|
||||
$info = elements(array('name','size','type','url','thumbnailUrl','deleteUrl','deleteType'),$list,NULL);
|
||||
$newid = $this->mysql_model->insert('goods_img',$info);
|
||||
$files[0]['pid'] = intval($newid);
|
||||
$files[0]['status'] = 1;
|
||||
$files[0]['size'] = (float)$list['size'];
|
||||
$files[0]['name'] = $list['name'];
|
||||
$files[0]['url'] = site_url().'/basedata/inventory/getImage?action=getImage&pid='.$newid;
|
||||
$files[0]['thumbnailUrl'] = site_url().'/basedata/inventory/getImage?action=getImage&pid='.$newid;
|
||||
$files[0]['deleteUrl'] = '';
|
||||
$files[0]['deleteType'] = '';
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['files'] = $files;
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//保存上传图片信息
|
||||
public function addImagesToInv() {
|
||||
$data = $this->input->post('postData');
|
||||
if (strlen($data)>0) {
|
||||
$v = $s = array();
|
||||
$data = (array)json_decode($data, true);
|
||||
$id = isset($data['id']) ? $data['id'] : 0;
|
||||
!isset($data['files']) || count($data['files']) < 1 && str_alert(-1,'请先添加图片!');
|
||||
foreach($data['files'] as $arr=>$row) {
|
||||
if ($row['status']==1) {
|
||||
$v[$arr]['id'] = $row['pid'];
|
||||
$v[$arr]['invId'] = $id;
|
||||
} else {
|
||||
$s[$arr]['id'] = $row['pid'];
|
||||
$s[$arr]['invId'] = $id;
|
||||
$s[$arr]['isDelete'] = 1;
|
||||
}
|
||||
}
|
||||
$this->mysql_model->update('goods_img',array_values($v),'id');
|
||||
$this->mysql_model->update('goods_img',array_values($s),'id');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
str_alert(-1,'保存失败');
|
||||
}
|
||||
|
||||
//获取图片信息
|
||||
public function getImage() {
|
||||
$id = intval($this->input->get_post('pid',TRUE));
|
||||
$data = $this->mysql_model->get_rows('goods_img',array('id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$url = './data/upfile/goods/'.$data['name'];
|
||||
$info = getimagesize($url);
|
||||
$imgdata = fread(fopen($url,'rb'),filesize($url));
|
||||
header('content-type:'.$info['mime'].'');
|
||||
echo $imgdata;
|
||||
}
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(69);
|
||||
$data = $this->input->post(NULL,TRUE);
|
||||
if ($data) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'number'=>$data['number'])) > 0 && str_alert(-1,'商品编号重复');
|
||||
$this->db->trans_begin();
|
||||
$info = array(
|
||||
'barCode','baseUnitId','unitName','categoryId','categoryName','propertys',
|
||||
'discountRate1','discountRate2','highQty','locationId','pinYin',
|
||||
'locationName','lowQty','name','number','purPrice','warehouseWarning',
|
||||
'remark','salePrice','spec','vipPrice','wholesalePrice','warehousePropertys','sonGoods','dopey'
|
||||
);
|
||||
//add by michen 20170715
|
||||
$data['dopey']=0;
|
||||
if(strlen($data['sonGoods'])>0){
|
||||
$sonlist = (array)json_decode($data['sonGoods'],true) ;
|
||||
if(count($sonlist)>0){
|
||||
$data['dopey']=1;
|
||||
foreach ($sonlist as $sonkey => $sonrow){
|
||||
if(empty($sonrow['gid']))
|
||||
str_alert(-1,'您所选择的商品ID不存在!请重新选择!');
|
||||
else if($this->mysql_model->get_count('goods',array('isDelete'=>0,'id'=>$sonrow['gid'],'number'=>$sonrow['number'])) <= 0)
|
||||
str_alert(-1,'您所选择的子商品编号“'.$sonrow['number'].'”不存在!请重新选择!');
|
||||
}
|
||||
}
|
||||
}
|
||||
$info = elements($info,$data,NULL);
|
||||
$data['id'] = $this->mysql_model->insert('goods',$info);
|
||||
if (strlen($data['propertys'])>0) {
|
||||
$list = (array)json_decode($data['propertys'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['invId'] = $data['id'];
|
||||
$v[$arr]['locationId'] = intval($row['locationId']);
|
||||
$v[$arr]['qty'] = (float)$row['quantity'];
|
||||
$v[$arr]['price'] = (float)$row['unitCost'];
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['skuId'] = intval($row['skuId']);
|
||||
$v[$arr]['billDate'] = date('Y-m-d');;
|
||||
$v[$arr]['billNo'] = '期初数量';
|
||||
$v[$arr]['billType'] = 'INI';
|
||||
$v[$arr]['transTypeName'] = '期初数量';
|
||||
}
|
||||
if (isset($v)) {
|
||||
$this->mysql_model->insert('invoice_info',$v);
|
||||
}
|
||||
}
|
||||
if (strlen($data['warehousePropertys'])>0) {
|
||||
$list = (array)json_decode($data['warehousePropertys'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$s[$arr]['invId'] = $data['id'];
|
||||
$s[$arr]['locationId'] = intval($row['locationId']);
|
||||
$s[$arr]['highQty'] = (float)$row['highQty'];
|
||||
$s[$arr]['lowQty'] = (float)$row['lowQty'];
|
||||
}
|
||||
if (isset($s)) {
|
||||
$this->mysql_model->insert('warehouse',$s);
|
||||
}
|
||||
}
|
||||
if ($this->db->trans_status() === FALSE) {
|
||||
$this->db->trans_rollback();
|
||||
str_alert(-1,'SQL错误回滚');
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
$this->common_model->logs('新增商品:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(70);
|
||||
$data = $this->input->post(NULL,TRUE);
|
||||
if ($data) {
|
||||
$data = $this->validform($data);
|
||||
$this->mysql_model->get_count('goods',array('id !='=>$data['id'],'isDelete'=>0,'number'=>$data['number'])) > 0 && str_alert(-1,'商品编号重复');
|
||||
$this->db->trans_begin();
|
||||
$info = array(
|
||||
'barCode','baseUnitId','unitName','categoryId','categoryName','propertys',
|
||||
'discountRate1','discountRate2','highQty','locationId','pinYin',
|
||||
'locationName','lowQty','name','number','purPrice','warehouseWarning',
|
||||
'remark','salePrice','spec','vipPrice','wholesalePrice','warehousePropertys','sonGoods','dopey'
|
||||
);
|
||||
//add by michen 20170715
|
||||
$data['dopey']=0;
|
||||
if(strlen($data['sonGoods'])>0){
|
||||
$sonlist = (array)json_decode($data['sonGoods'],true) ;
|
||||
if(count($sonlist)>0){
|
||||
$data['dopey']=1;
|
||||
foreach ($sonlist as $sonkey => $sonrow){
|
||||
if(empty($sonrow['gid']))
|
||||
str_alert(-1,'您所选择的商品ID不存在!请重新选择!');
|
||||
else if($this->mysql_model->get_count('goods',array('isDelete'=>0,'id'=>$sonrow['gid'],'number'=>$sonrow['number'])) <= 0)
|
||||
str_alert(-1,'您所选择的子商品编号“'.$sonrow['number'].'”不存在!请重新选择!');
|
||||
}
|
||||
}
|
||||
}
|
||||
$info = elements($info, $data,NULL);
|
||||
$this->mysql_model->update('goods',$info,array('id'=>$data['id']));
|
||||
if (strlen($data['propertys'])>0) {
|
||||
$list = (array)json_decode($data['propertys'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['invId'] = $data['id'];
|
||||
$v[$arr]['locationId'] = isset($row['locationId']) ? $row['locationId'] : 0;
|
||||
$v[$arr]['qty'] = isset($row['quantity']) ? $row['quantity']:0;
|
||||
$v[$arr]['price'] = isset($row['unitCost']) ? $row['unitCost']:0;
|
||||
$v[$arr]['amount'] = isset($row['amount']) ? $row['amount']:0;
|
||||
$v[$arr]['skuId'] = isset($row['skuId']) ? $row['skuId']:0;
|
||||
$v[$arr]['billDate'] = date('Y-m-d');
|
||||
$v[$arr]['billNo'] = '期初数量';
|
||||
$v[$arr]['billType'] = 'INI';
|
||||
$v[$arr]['transTypeName'] = '期初数量';
|
||||
}
|
||||
if (isset($v)) {
|
||||
$this->mysql_model->delete('invoice_info',array('invId'=>$data['id'],'billType'=>'INI'));
|
||||
$this->mysql_model->insert('invoice_info',$v);
|
||||
}
|
||||
}
|
||||
if (strlen($data['warehousePropertys'])>0) {
|
||||
$list = (array)json_decode($data['warehousePropertys'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$s[$arr]['invId'] = $data['id'];
|
||||
$s[$arr]['locationId'] = isset($row['locationId']) ? $row['locationId'] : 0;
|
||||
$s[$arr]['highQty'] = isset($row['highQty']) ? $row['highQty']:0;
|
||||
$s[$arr]['lowQty'] = isset($row['lowQty']) ? $row['lowQty']:0;
|
||||
}
|
||||
if (isset($s)) {
|
||||
$this->mysql_model->delete('warehouse',array('invId'=>$data['id']));
|
||||
$this->mysql_model->insert('warehouse',$s);
|
||||
}
|
||||
}
|
||||
if ($this->db->trans_status() === FALSE) {
|
||||
$this->db->trans_rollback();
|
||||
str_alert(-1,'SQL错误回滚');
|
||||
} else {
|
||||
$this->db->trans_commit();
|
||||
$this->common_model->logs('修改商品:ID='.$data['id'].'名称:'.$data['name']);
|
||||
str_alert(200,'success',$this->get_goods_info($data['id']));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'修改失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(71);
|
||||
$id = str_enhtml($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_results('goods','(id in('.$id.')) and (isDelete=0)');
|
||||
if (count($data) > 0) {
|
||||
$this->mysql_model->get_count('invoice_info','(invId in('.$id.')) and (isDelete=0) and (billType<>"INI")')>0 && str_alert(-1,'其中有商品发生业务不可删除');
|
||||
$sql = $this->mysql_model->update('goods',array('isDelete'=>1),'(id in('.$id.'))');
|
||||
$this->mysql_model->update('invoice_info',array('isDelete'=>1),'(invId in('.$id.'))');
|
||||
if ($sql) {
|
||||
$name = array_column($data,'name');
|
||||
$this->common_model->logs('删除商品:ID='.$id.' 名称:'.join(',',$name));
|
||||
str_alert(200,'success',array('msg'=>'','id'=>'['.$id.']'));
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
}
|
||||
|
||||
//导出
|
||||
public function exporter() {
|
||||
$this->common_model->checkpurview(72);
|
||||
$name = 'goods_'.date('YmdHis').'.xls';
|
||||
sys_csv($name);
|
||||
$this->common_model->logs('导出商品:'.$name);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$categoryid = intval($this->input->get_post('assistId',TRUE));
|
||||
$barCode = intval($this->input->get_post('barCode',TRUE));
|
||||
$where = '(a.isDelete=0)';
|
||||
$where .= $skey ? ' and (name like "%'.$skey.'%" or number like "%'.$skey.'%" or spec like "%'.$skey.'%")' : '';
|
||||
$where .= $barCode ? ' and barCode="'.$barCode.'"' : '';
|
||||
if ($categoryid > 0) {
|
||||
$cid = array_column($this->mysql_model->get_results('category','(isDelete=1) and find_in_set('.$categoryid.',path)'),'id');
|
||||
if (count($cid)>0) {
|
||||
$cid = join(',',$cid);
|
||||
$where .= ' and categoryid in('.$cid.')';
|
||||
}
|
||||
}
|
||||
$data['storage'] = array_column($this->mysql_model->get_results('storage'),'name','id');
|
||||
$data['list'] = $this->data_model->get_goods($where.' order by a.id desc');
|
||||
$this->load->view('settings/goods-export',$data);
|
||||
|
||||
}
|
||||
|
||||
//状态
|
||||
public function disable(){
|
||||
$this->common_model->checkpurview(72);
|
||||
$disable = intval($this->input->post('disable',TRUE));
|
||||
$id = str_enhtml($this->input->post('invIds',TRUE));
|
||||
if (strlen($id) > 0) {
|
||||
$sql = $this->mysql_model->update('goods',array('disable'=>$disable),'(id in('.$id.'))');
|
||||
if ($sql) {
|
||||
$this->common_model->logs('商品'.$disable==1?'禁用':'启用'.':ID:'.$id.'');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'操作失败');
|
||||
}
|
||||
|
||||
//库存预警
|
||||
public function listinventoryqtywarning() {
|
||||
$locationId = intval($this->input->get_post('locationId',TRUE));
|
||||
$warnType = intval($this->input->get_post('warnType',TRUE));
|
||||
$assistId = intval($this->input->get_post('assistId',TRUE));
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),20);
|
||||
$where = 'a.isDelete=0';
|
||||
if ($warnType==1) {
|
||||
$having = 'HAVING qty<lowQty';
|
||||
} elseif($warnType==2) {
|
||||
$having = 'HAVING qty>highQty';
|
||||
} else {
|
||||
$having = 'HAVING qty>highQty or qty<lowQty';
|
||||
}
|
||||
if ($assistId > 0) {
|
||||
$cid = array_column($this->mysql_model->get_results('category','(isDelete=1) and find_in_set('.$assistId.',path)'),'id');
|
||||
if (count($cid)>0) {
|
||||
$cid = join(',',$cid);
|
||||
$where .= ' and b.categoryId in('.$cid.')';
|
||||
}
|
||||
}
|
||||
$where .= $skey ? ' and (b.name like "%'.$skey.'%" or b.number like "%'.$skey.'%" or b.spec like "%'.$skey.'%")' : '';
|
||||
$where .= $locationId>0 ? ' and a.locationId='.$locationId.'' : '';
|
||||
$where .= $this->common_model->get_location_purview();
|
||||
$offset = $rows*($page-1);
|
||||
$list = $this->data_model->get_inventory($where.' GROUP BY invId,locationId '.$having.' limit '.$offset.','.$rows);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['highQty'] = (float)$row['highQty'];
|
||||
$v[$arr]['id'] = intval($row['invId']);
|
||||
$v[$arr]['lowQty'] = (float)$row['lowQty'];
|
||||
$v[$arr]['name'] = $row['invName'];
|
||||
$v[$arr]['locationName'] = $row['locationName'];
|
||||
$v[$arr]['number'] = $row['invNumber'];
|
||||
$v[$arr]['categoryName'] = $row['categoryName'];
|
||||
$v[$arr]['warning'] = $row['qty1'] > 0 ? $row['qty1'] : $row['qty2'];
|
||||
$v[$arr]['qty'] = (float)$row['qty'];
|
||||
$v[$arr]['unitName'] = $row['unitName'];
|
||||
$v[$arr]['spec'] = $row['invSpec'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['page'] = $page;
|
||||
$json['data']['records'] = $this->data_model->get_inventory($where.' GROUP BY invId,locationId '.$having,3);
|
||||
$json['data']['total'] = ceil($json['data']['records']/$rows);
|
||||
$json['data']['rows'] = isset($v) ? array_values($v) : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
public function warningExporter() {
|
||||
$this->common_model->checkpurview();
|
||||
$name = 'InventoryWarning_'.date('YmdHis').'.xls';
|
||||
sys_csv($name);
|
||||
$this->common_model->logs('导出库存预警商品:'.$name);
|
||||
$locationId = intval($this->input->get_post('locationId',TRUE));
|
||||
$warnType = intval($this->input->get_post('warnType',TRUE));
|
||||
$assistId = intval($this->input->get_post('assistId',TRUE));
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$where = 'a.isDelete=0';
|
||||
if ($warnType==1) {
|
||||
$having = 'HAVING qty<lowQty';
|
||||
} elseif($warnType==2) {
|
||||
$having = 'HAVING qty>highQty';
|
||||
} else {
|
||||
$having = 'HAVING qty>highQty or qty<lowQty';
|
||||
}
|
||||
if ($assistId > 0) {
|
||||
$cid = array_column($this->mysql_model->get_results('category','(isDelete=1) and find_in_set('.$assistId.',path)'),'id');
|
||||
if (count($cid)>0) {
|
||||
$cid = join(',',$cid);
|
||||
$where .= ' and b.categoryId in('.$cid.')';
|
||||
}
|
||||
}
|
||||
$where .= $skey ? ' and (b.name like "%'.$skey.'%" or b.number like "%'.$skey.'%" or b.spec like "%'.$skey.'%")' : '';
|
||||
$where .= $locationId>0 ? ' and a.locationId='.$locationId.'' : '';
|
||||
$where .= $this->common_model->get_location_purview();
|
||||
$data['list'] = $this->data_model->get_inventory($where.' GROUP BY invId,locationId '.$having);
|
||||
$this->load->view('settings/inventory-warning-exporter',$data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
//通过ID 获取商品信息
|
||||
private function get_goods_info($id) {
|
||||
$data = $this->mysql_model->get_rows('goods',array('id'=>$id,'isDelete'=>0));
|
||||
if (count($data)>0) {
|
||||
$data['id'] = $id;
|
||||
$data['count'] = 0;
|
||||
$data['name'] = $data['name'];
|
||||
$data['spec'] = $data['spec'];
|
||||
$data['number'] = $data['number'];
|
||||
$data['salePrice'] = (float)$data['salePrice'];
|
||||
$data['purPrice'] = (float)$data['purPrice'];
|
||||
$data['wholesalePrice']= (float)$data['wholesalePrice'];
|
||||
$data['vipPrice'] = (float)$data['vipPrice'];
|
||||
$data['discountRate1'] = (float)$data['discountRate1'];
|
||||
$data['discountRate2'] = (float)$data['discountRate2'];
|
||||
$data['unitTypeId'] = intval($data['unitTypeId']);
|
||||
$data['baseUnitId'] = intval($data['baseUnitId']);
|
||||
$data['locationId'] = intval($data['locationId']);
|
||||
$data['assistIds'] = '';
|
||||
$data['assistName'] = '';
|
||||
$data['assistUnit'] = '';
|
||||
$data['remark'] = $data['remark'];
|
||||
$data['categoryId'] = intval($data['categoryId']);
|
||||
$data['unitId'] = intval($data['unitId']);
|
||||
$data['length'] = '';
|
||||
$data['weight'] = '';
|
||||
$data['jianxing'] = '';
|
||||
$data['barCode'] = $data['barCode'];
|
||||
$data['josl'] = '';
|
||||
$data['warehouseWarning'] = intval($data['warehouseWarning']);
|
||||
$data['warehouseWarningSku'] = 0;
|
||||
$data['skuClassId'] = 0;
|
||||
$data['isSerNum'] = 0;
|
||||
$data['pinYin'] = $data['pinYin'];
|
||||
$data['delete'] = false;
|
||||
$data['isWarranty'] = 0;
|
||||
$data['safeDays'] = 0;
|
||||
$data['advanceDay'] = 0;
|
||||
$data['property'] = $data['property'] ? $data['property'] : NULL;
|
||||
$propertys = $this->data_model->get_invoice_info('a.isDelete=0 and a.invId='.$id.' and a.billType="INI"');
|
||||
foreach ($propertys as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['locationId'] = intval($row['locationId']);
|
||||
$v[$arr]['inventoryId'] = intval($row['invId']);
|
||||
$v[$arr]['locationName'] = $row['locationName'];
|
||||
$v[$arr]['quantity'] = (float)$row['qty'];
|
||||
$v[$arr]['unitCost'] = (float)$row['price'];
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['skuId'] = intval($row['skuId']);
|
||||
$v[$arr]['skuName'] = '';
|
||||
$v[$arr]['date'] = $row['billDate'];
|
||||
$v[$arr]['tempId'] = 0;
|
||||
$v[$arr]['batch'] = '';
|
||||
$v[$arr]['invSerNumList'] = '';
|
||||
}
|
||||
$data['propertys'] = isset($v) ? $v : array();
|
||||
if ($data['warehousePropertys']) {
|
||||
$warehouse = (array)json_decode($data['warehousePropertys'],true);
|
||||
foreach ($warehouse as $arr=>$row) {
|
||||
$s[$arr]['locationId'] = intval($row['locationId']);
|
||||
$s[$arr]['locationName'] = $row['locationName'];
|
||||
$s[$arr]['highQty'] = (float)$row['highQty'];
|
||||
$s[$arr]['lowQty'] = (float)$row['lowQty'];
|
||||
}
|
||||
}
|
||||
$data['warehousePropertys'] = isset($s) ? $s : array();
|
||||
if (strlen($data['sonGoods'])>0) {
|
||||
$list = (array)json_decode($data['sonGoods'],true);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['spec'] = $row['spec'];
|
||||
$v[$arr]['unitName'] = $row['unitName'];
|
||||
$v[$arr]['qty'] = intval($row['qty']);
|
||||
$v[$arr]['salePrice'] = intval($row['salePrice']);
|
||||
$v[$arr]['gid'] = intval($row['gid']);//add by michen 20170719
|
||||
}
|
||||
}
|
||||
$data['sonGoods'] = isset($v) ? $v : array();
|
||||
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$this->load->library('lib_cn2pinyin');
|
||||
strlen($data['name']) < 1 && str_alert(-1,'商品名称不能为空');
|
||||
strlen($data['number']) < 1 && str_alert(-1,'商品编号不能为空');
|
||||
$data['categoryId'] = intval($data['categoryId']);
|
||||
$data['baseUnitId'] = intval($data['baseUnitId']);
|
||||
$data['categoryId'] < 1 && str_alert(-1,'商品类别不能为空');
|
||||
$data['baseUnitId'] < 1 && str_alert(-1,'计量单位不能为空');
|
||||
$data['id'] = isset($data['id']) ? intval($data['id']):0;
|
||||
$data['lowQty'] = isset($data['lowQty']) ? (float)$data['lowQty'] :0;
|
||||
$data['highQty'] = isset($data['highQty']) ? (float)$data['highQty']:0;
|
||||
$data['purPrice'] = isset($data['purPrice']) ? (float)$data['purPrice']:0;
|
||||
$data['salePrice'] = isset($data['salePrice']) ? (float)$data['salePrice']:0;
|
||||
$data['vipPrice'] = isset($data['vipPrice']) ? (float)$data['vipPrice']:0;
|
||||
$data['warehouseWarning'] = isset($data['warehouseWarning']) ? intval($data['warehouseWarning']):0;
|
||||
$data['discountRate1'] = (float)$data['discountRate1'];
|
||||
$data['discountRate2'] = (float)$data['discountRate2'];
|
||||
$data['wholesalePrice'] = isset($data['wholesalePrice']) ? (float)$data['wholesalePrice']:0;
|
||||
$data['unitName'] = $this->mysql_model->get_row('unit',array('id'=>$data['baseUnitId']),'name');
|
||||
$data['categoryName'] = $this->mysql_model->get_row('category',array('id'=>$data['categoryId']),'name');
|
||||
$data['pinYin'] = $this->lib_cn2pinyin->encode($data['name']);
|
||||
!$data['categoryName'] && str_alert(-1,'商品类别不存在');
|
||||
if (strlen($data['propertys'])>0) {
|
||||
$list = (array)json_decode($data['propertys'],true);
|
||||
$storage = $this->mysql_model->get_results('storage',array('disable'=>0));
|
||||
$locationId = array_column($storage,'id');
|
||||
$locationName = array_column($storage,'name','id');
|
||||
foreach ($list as $arr=>$row) {
|
||||
!in_array($row['locationId'],$locationId) && str_alert(-1,$locationName[$row['locationId']].'仓库不存在或不可用!');
|
||||
}
|
||||
}
|
||||
$data['warehousePropertys'] = isset($data['warehousePropertys']) ? $data['warehousePropertys'] :'[]';
|
||||
$data['warehousePropertys'] = count(json_decode($data['warehousePropertys'],true))>0 ? $data['warehousePropertys'] :'';
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
116
application/controllers/basedata/invlocation.php
Executable file
116
application/controllers/basedata/invlocation.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Invlocation extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//仓库列表
|
||||
public function index(){
|
||||
$list = $this->mysql_model->get_results('storage','(isDelete=0) '.$this->common_model->get_location_purview(1).' order by id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['address'] = $row['address'];
|
||||
$v[$arr]['delete'] = $row['disable'] > 0 ? true : false;
|
||||
$v[$arr]['allowNeg'] = false;
|
||||
$v[$arr]['deptId'] = intval($row['deptId']);;
|
||||
$v[$arr]['empId'] = intval($row['empId']);;
|
||||
$v[$arr]['groupx'] = $row['groupx'];
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['locationNo'] = $row['locationNo'];
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['phone'] = $row['phone'];
|
||||
$v[$arr]['type'] = intval($row['type']);
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['rows'] = isset($v) ? $v : array();
|
||||
$json['data']['total'] = 1;
|
||||
$json['data']['records'] = count($list);
|
||||
$json['data']['page'] = 1;
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(156);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$sql = $this->mysql_model->insert('storage',elements(array('name','locationNo'),$data));
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增仓库:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(157);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$sql = $this->mysql_model->update('storage',elements(array('name','locationNo'),$data),array('id'=>$data['locationId']));
|
||||
if ($sql) {
|
||||
$data['id'] = $data['locationId'];
|
||||
$this->common_model->logs('更新仓库:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(158);
|
||||
$id = intval($this->input->post('locationId',TRUE));
|
||||
$data = $this->mysql_model->get_rows('storage',array('id'=>$id,'isDelete'=>0));
|
||||
if (count($data) > 0) {
|
||||
$this->mysql_model->get_count('invoice_info',array('locationId'=>$id,'isDelete'=>0))>0 && str_alert(-1,'不能删除有业务关联的仓库!');
|
||||
$sql = $this->mysql_model->update('storage',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除仓库:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
//启用禁用
|
||||
public function disable(){
|
||||
$this->common_model->checkpurview(158);
|
||||
$id = intval($this->input->post('locationId',TRUE));
|
||||
$data = $this->mysql_model->get_rows('storage',array('id'=>$id,'isDelete'=>0));
|
||||
if (count($data) > 0) {
|
||||
$info['disable'] = intval($this->input->post('disable',TRUE));
|
||||
$sql = $this->mysql_model->update('storage',$info,array('id'=>$id));
|
||||
if ($sql) {
|
||||
$actton = $info['disable']==0 ? '仓库启用' : '仓库禁用';
|
||||
$this->common_model->logs($actton.':ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'操作失败');
|
||||
}
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
strlen($data['name']) < 1 && str_alert(-1,'仓库名称不能为空');
|
||||
strlen($data['locationNo']) < 1 && str_alert(-1,'编号不能为空');
|
||||
$data['locationId'] = intval($data['locationId']);
|
||||
$where = $data['locationId']>0 ? ' and id<>'.$data['locationId'].'' :'';
|
||||
$this->mysql_model->get_count('storage','(isDelete=0) and name="'.$data['name'].'" '.$where) > 0 && str_alert(-1,'名称重复');
|
||||
$this->mysql_model->get_count('storage','(isDelete=0) and locationNo="'.$data['locationNo'].'" '.$where) > 0 && str_alert(-1,'编号重复');
|
||||
return $data;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
79
application/controllers/basedata/log.php
Executable file
79
application/controllers/basedata/log.php
Executable file
@@ -0,0 +1,79 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Log extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview(83);
|
||||
}
|
||||
|
||||
public function index(){
|
||||
$fromDate = str_enhtml($this->input->get_post('fromDate',TRUE));
|
||||
$toDate = str_enhtml($this->input->get_post('toDate',TRUE));
|
||||
$page = max(intval($this->input->get_post('page',TRUE)),1);
|
||||
$rows = max(intval($this->input->get_post('rows',TRUE)),100);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$user = str_enhtml($this->input->get_post('user',TRUE));
|
||||
$where['name'] = $user ? $user :'';
|
||||
$where['adddate >='] = $fromDate ? $fromDate :'';
|
||||
$where['adddate <='] = $toDate ? $toDate :'';
|
||||
$list = $this->mysql_model->get_results('log',array_filter($where),'id desc',$rows*($page-1),$rows);
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['loginName'] = $row['loginName'];
|
||||
$v[$arr]['operateTypeName'] = $row['operateTypeName'];
|
||||
$v[$arr]['operateType'] = 255;
|
||||
$v[$arr]['userId'] = $row['userId'];
|
||||
$v[$arr]['log'] = $row['log'];
|
||||
$v[$arr]['modifyTime'] = $row['modifyTime'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['page'] = $page;
|
||||
$json['data']['records'] = $this->mysql_model->get_count('log',array_filter($where));
|
||||
$json['data']['total'] = ceil($json['data']['records']/$rows);
|
||||
$json['data']['rows'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
public function initloglist(){
|
||||
$this->load->view('settings/log-initloglist');
|
||||
}
|
||||
|
||||
//用户列表
|
||||
public function queryAllUser(){
|
||||
$list = $this->mysql_model->get_results('admin','(1=1)','uid desc',0,0,'uid,name');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['userid'] = intval($row['uid']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['totalsize'] = count($list);
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
//操作类型
|
||||
public function queryAllOperateType(){
|
||||
$menu = array_column($this->mysql_model->get_results('menu',array('pid'=>0),'id desc'),'title','id');
|
||||
$list = $this->mysql_model->get_results('menu',array('depth>'=>1),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['indexid'] = $row['id'];
|
||||
$v[$arr]['operateTypeName'] = $row['title'].isset($menu[$row['pid']]) ? $menu[$row['pid']] : '';
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['totalsize'] = count($list);
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
17
application/controllers/basedata/resultInfo.php
Executable file
17
application/controllers/basedata/resultInfo.php
Executable file
@@ -0,0 +1,17 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class ResultInfo extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$this->load->view('settings/resultInfo');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
133
application/controllers/basedata/settAcct.php
Executable file
133
application/controllers/basedata/settAcct.php
Executable file
@@ -0,0 +1,133 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Settacct extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//结算账户列表
|
||||
public function index(){
|
||||
$list = $this->mysql_model->get_results('account',array('isDelete'=>0),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['date'] = $row['date'];
|
||||
$v[$arr]['amount'] = (float)$row['amount'];
|
||||
$v[$arr]['del'] = false;
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['number'] = $row['number'];
|
||||
$v[$arr]['type'] = intval($row['type']);
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//查询
|
||||
public function query(){
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('account',array('id'=>$id,'isDelete'=>0));
|
||||
if (count($data)>0) {
|
||||
$v = array();
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['date'] = $data['date'];
|
||||
$json['data']['amount'] = (float)$data['amount'];
|
||||
$json['data']['del'] = false;
|
||||
$json['data']['id'] = intval($data['id']);
|
||||
$json['data']['name'] = $data['name'];
|
||||
$json['data']['number'] = $data['number'];
|
||||
$json['data']['type'] = intval($data['type']);
|
||||
die(json_encode($json));
|
||||
}
|
||||
}
|
||||
|
||||
//当前余额
|
||||
public function findAmountOver(){
|
||||
$ids = str_enhtml($this->input->post('ids',TRUE));
|
||||
if (strlen($ids)>0) {
|
||||
$list = $this->data_model->get_account('','a.isDelete=0 and a.id in('.$ids.')');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['amountOver'] = (float)$row['amount'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
} else {
|
||||
str_alert(200,'');
|
||||
}
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(160);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$info = elements(array('name','number','amount','date','type'),$data);
|
||||
$sql = $this->mysql_model->insert('account',$info);
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增账户:'.$data['number'].$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(161);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (count($data)>0) {
|
||||
$data = $this->validform($data);
|
||||
$info = elements(array('name','number','amount','date','type'),$data);
|
||||
$sql = $this->mysql_model->update('account',$info,array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('更新账户:'.$data['number'].$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(162);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('account',array('id'=>$id,'isDelete'=>0));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('account_info',array('accId'=>$id,'isDelete'=>0))>0 && str_alert(-1,'账户资料已经被使用');
|
||||
$sql = $this->mysql_model->update('account',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除账户:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
$data['id'] = isset($data['id']) ? intval($data['id']) :0;
|
||||
$data['amount'] = (float)$data['amount'];
|
||||
$data['type'] = intval($data['type']);
|
||||
strlen($data['name']) < 1 && str_alert(-1,'名称不能为空');
|
||||
strlen($data['number']) < 1 && str_alert(-1,'编号不能为空');
|
||||
$where = $data['id']>0 ? ' and (id<>'.$data['id'].')' : '';
|
||||
$this->mysql_model->get_count('account','(isDelete=0) and name="'.$data['name'].'" '.$where) > 0 && str_alert(-1,'名称重复');
|
||||
$this->mysql_model->get_count('account','(isDelete=0) and number="'.$data['number'].'" '.$where) > 0 && str_alert(-1,'编号重复');
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
27
application/controllers/basedata/supplier.php
Executable file
27
application/controllers/basedata/supplier.php
Executable file
@@ -0,0 +1,27 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Supplier extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview(67);
|
||||
}
|
||||
|
||||
public function exporter(){
|
||||
$name = 'supplier_'.date('YmdHis').'.xls';
|
||||
sys_csv($name);
|
||||
$this->common_model->logs('导出供应商:'.$name);
|
||||
$skey = str_enhtml($this->input->get_post('skey',TRUE));
|
||||
$categoryId = intval($this->input->get_post('categoryId',TRUE));
|
||||
$where = '(isDelete=0) and type=10 ';
|
||||
$where .= $this->common_model->get_vendor_purview();
|
||||
$where .= $skey ? ' and (number like "%'.$skey.'%" or name like "%'.$skey.'%" or linkMans like "%'.$skey.'%")' : '';
|
||||
$where .= $categoryId >0 ? ' and cCategory = '.$categoryId.'' : '';
|
||||
$data['list'] = $this->mysql_model->get_results('contact',$where,'id desc');
|
||||
$this->load->view('settings/vendor-export',$data);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
58
application/controllers/basedata/systemProfile.php
Executable file
58
application/controllers/basedata/systemProfile.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Systemprofile extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//单据编号
|
||||
public function generateDocNo() {
|
||||
$billType = str_enhtml($this->input->post('billType',TRUE));
|
||||
$info = array(
|
||||
'PUR'=>'CG',
|
||||
'SALE'=>'XS',
|
||||
'TRANSFER'=>'DB',
|
||||
'OO'=>'QTCK',
|
||||
'PO'=>'CGDD',
|
||||
'SO'=>'XSDD',
|
||||
'OI'=>'QTRK',
|
||||
'CADJ'=>'CBTZ',
|
||||
'PAYMENT'=>'FKD',
|
||||
'RECEIPT'=>'SKD',
|
||||
'QTSR'=>'QTSR',
|
||||
'QTZC'=>'QTZC'
|
||||
);
|
||||
if (isset($info[$billType])) {
|
||||
str_alert(200,'success',array('billNo'=>str_no($info[$billType])));
|
||||
}
|
||||
str_alert(-1,'生成失败');
|
||||
}
|
||||
|
||||
|
||||
//系统设置
|
||||
public function update() {
|
||||
$this->common_model->checkpurview(81);
|
||||
$data = str_enhtml($this->input->post(NULL,TRUE));
|
||||
if (is_array($data) && count($data)>0) {
|
||||
if ($this->common_model->insert_option('system',$data)) {
|
||||
$this->common_model->logs('系统设置成功');
|
||||
str_alert(200,'success');
|
||||
}
|
||||
}
|
||||
str_alert(-1,'设置失败');
|
||||
}
|
||||
|
||||
//切换皮肤
|
||||
public function changeSysSkin() {
|
||||
$skin = $this->input->post('skin',TRUE) ? $this->input->post('skin',TRUE) : 'green';
|
||||
$this->input->set_cookie('skin',$skin,360000);
|
||||
$this->common_model->logs('切换皮肤:'.$skin);
|
||||
str_alert(200,'success');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
97
application/controllers/basedata/unit.php
Executable file
97
application/controllers/basedata/unit.php
Executable file
@@ -0,0 +1,97 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Unit extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
//单位列表
|
||||
public function index(){
|
||||
$unittypeid = intval($this->input->get_post('unitTypeId',TRUE));
|
||||
if ($unittypeid>0) {
|
||||
$where['unittypeid'] = $unittypeid;
|
||||
}
|
||||
$where['isDelete'] = 0;
|
||||
$list = $this->mysql_model->get_results('unit',$where,'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['default'] = $row['default']==1 ? true : false;
|
||||
$v[$arr]['guid'] = $row['guid'];
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
$v[$arr]['rate'] = intval($row['rate']);
|
||||
$v[$arr]['isDelete'] = intval($row['isDelete']);
|
||||
$v[$arr]['unitTypeId'] = intval($row['unitTypeId']);
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add(){
|
||||
$this->common_model->checkpurview(78);
|
||||
$data = $this->validform(str_enhtml($this->input->post(NULL,TRUE)));
|
||||
$sql = $this->mysql_model->insert('unit',elements(array('name','default'),$data));
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增单位:'.$data['name']);
|
||||
die('{"status":200,"msg":"success","data":{"default":false,"guid":"","id":'.$sql.',"isdelete":0,"name":"'.$data['name'].'","rate":1,"unitTypeId":0}}');
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(79);
|
||||
$data = $this->validform(str_enhtml($this->input->post(NULL,TRUE)));
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'unitId'=>$data['id']))>0 && str_alert(-1,'该单位已经被使用,不允许更改组');
|
||||
$sql = $this->mysql_model->update('unit',elements(array('name','default'),$data),array('id'=>$data['id']));
|
||||
if ($sql) {
|
||||
$this->mysql_model->update('goods',array('unitName'=>$data['name']),array('baseUnitId'=>$data['id']));
|
||||
$this->common_model->logs('更新单位:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(80);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('unit',array('isDelete'=>0,'id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('goods',array('isDelete'=>0,'unitId'=>$id))>0 && str_alert(-1,'该单位已经被使用,不允许删除');
|
||||
$sql = $this->mysql_model->update('unit',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除单位:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除','id'=>'['.$id.']'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
//公共验证
|
||||
private function validform($data) {
|
||||
strlen($data['name']) < 1 && str_alert(-1,'单位名称不能为空');
|
||||
$data['id'] = isset($data['id']) ? intval($data['id']) :0;
|
||||
$data['rate'] = isset($data['rate']) ? intval($data['rate']) :0;
|
||||
$data['default'] = isset($data['default']) ? $data['default'] :'';
|
||||
$data['unitTypeId'] = isset($data['unitTypeId']) ? intval($data['unitTypeId']):0;
|
||||
$data['default'] = $data['default']== 'true' ? 1 : 0;
|
||||
$where['isDelete'] = 0;
|
||||
$where['name'] = $data['name'];
|
||||
$where['id !='] = $data['id']>0 ? $data['id'] :0;
|
||||
$this->mysql_model->get_count('unit',$where) && str_alert(-1,'单位名称重复');
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
82
application/controllers/basedata/unitType.php
Executable file
82
application/controllers/basedata/unitType.php
Executable file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
defined('BASEPATH') OR exit('No direct script access allowed');
|
||||
|
||||
class Unittype extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
public function index() {
|
||||
$list = $this->mysql_model->get_results('unittype',array('isDelete'=>0),'id desc');
|
||||
foreach ($list as $arr=>$row) {
|
||||
$v[$arr]['entries'] = array();
|
||||
$v[$arr]['guid'] = '';
|
||||
$v[$arr]['id'] = intval($row['id']);
|
||||
$v[$arr]['name'] = $row['name'];
|
||||
}
|
||||
$json['status'] = 200;
|
||||
$json['msg'] = 'success';
|
||||
$json['data']['items'] = isset($v) ? $v : array();
|
||||
$json['data']['totalsize'] = count($list);
|
||||
die(json_encode($json));
|
||||
}
|
||||
|
||||
//新增
|
||||
public function add() {
|
||||
$this->common_model->checkpurview(59);
|
||||
$data['name'] = $name = $this->input->post('name',TRUE);
|
||||
strlen($name) < 1 && str_alert(-1,'名称不能为空');
|
||||
$this->mysql_model->get_count('unittype',array('name'=>$name)) && str_alert(-1,'单位组名称重复');
|
||||
$sql = $this->mysql_model->insert('unittype',$data);
|
||||
if ($sql) {
|
||||
$data['id'] = $sql;
|
||||
$this->common_model->logs('新增单位组:'.$name);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
str_alert(-1,'添加失败');
|
||||
}
|
||||
|
||||
//修改
|
||||
public function update(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$name = str_enhtml($this->input->post('name',TRUE));
|
||||
$info = $this->mysql_model->get_rows('unittype','(id='.$id.') and (isDelete=0)');
|
||||
if (count($info)>0) {
|
||||
strlen($name) < 1 && str_alert(-1,'名称不能为空');
|
||||
$this->mysql_model->get_count('unittype',array('isDelete'=>$isDelete,'name'=>$name,'id !='=>$id)) > 0 && str_alert(-1,'单位组名称重复');
|
||||
$sql = $this->mysql_model->update('unittype',array('name'=>$name),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$data['id'] = $id;
|
||||
$data['name'] = $name;
|
||||
$data['entries'] = array();
|
||||
$data['guid'] = '';
|
||||
$this->common_model->logs('更新单位组:'.$data['name']);
|
||||
str_alert(200,'success',$data);
|
||||
}
|
||||
}
|
||||
str_alert(-1,'更新失败');
|
||||
}
|
||||
|
||||
//删除
|
||||
public function delete(){
|
||||
$this->common_model->checkpurview(59);
|
||||
$id = intval($this->input->post('id',TRUE));
|
||||
$data = $this->mysql_model->get_rows('unittype',array('isDelete'=>$isDelete,'id'=>$id));
|
||||
if (count($data)>0) {
|
||||
$this->mysql_model->get_count('unit',array('isDelete'=>$isDelete,'unittypeid'=>$id))>0 && str_alert(-1,'发生业务不可删除');
|
||||
$sql = $this->mysql_model->update('unittype',array('isDelete'=>1),array('id'=>$id));
|
||||
if ($sql) {
|
||||
$this->common_model->logs('删除单位组:ID='.$id.' 名称:'.$data['name']);
|
||||
str_alert(200,'success',array('msg'=>'成功删除','id'=>'['.$id.']'));
|
||||
}
|
||||
}
|
||||
str_alert(-1,'删除失败');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
33
application/controllers/basedata/userSetting.php
Executable file
33
application/controllers/basedata/userSetting.php
Executable file
File diff suppressed because one or more lines are too long
31
application/controllers/basedata/warranty.php
Executable file
31
application/controllers/basedata/warranty.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
|
||||
|
||||
class Warranty extends CI_Controller {
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
$this->common_model->checkpurview();
|
||||
}
|
||||
|
||||
|
||||
public function index() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function getAdvancedList(){
|
||||
$data['status'] = 200;
|
||||
$data['msg'] = 'success';
|
||||
$data['data']['page'] = 1;
|
||||
$data['data']['total'] = 0;
|
||||
$data['data']['records'] = 0;
|
||||
$data['data']['rows'] = array();
|
||||
die(json_encode($data));
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* End of file welcome.php */
|
||||
/* Location: ./application/controllers/welcome.php */
|
||||
Reference in New Issue
Block a user