|
|
@@ -14,6 +14,7 @@ class Beihuogl extends Start_Controller {
|
|
|
$this->load->_model("Model_bhdcd","bhdcd");
|
|
|
$this->load->_model("Model_whlabellabel","whlabellabel");
|
|
|
$this->load->_model("Model_warehouse","warehouse");
|
|
|
+ $this->load->_model("Model_bhsccx","bhsccx");
|
|
|
}
|
|
|
|
|
|
//定义方法的调用规则 获取URI第二段值
|
|
|
@@ -100,6 +101,16 @@ class Beihuogl extends Start_Controller {
|
|
|
$this->_checkdcdsku($arg_array);
|
|
|
}elseif($arg == 'dcdkwyz'){
|
|
|
$this->_dcdkwyz();
|
|
|
+ }elseif($arg == 'bhcxsave'){
|
|
|
+ $this->_bhcxsave();
|
|
|
+ }elseif($arg == 'bhcxlist'){
|
|
|
+ $this->_bhcxlist();
|
|
|
+ }elseif($arg == 'bhcxshlist'){
|
|
|
+ $this->_bhcxshlist();
|
|
|
+ }elseif($arg == 'updatestatus'){
|
|
|
+ $this->_updatestatus();
|
|
|
+ }elseif($arg == 'bhcxedit'){
|
|
|
+ $this->_bhcxedit($arg_array);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
@@ -161,7 +172,7 @@ class Beihuogl extends Start_Controller {
|
|
|
$start = ($page - 1)*$perpage;
|
|
|
}
|
|
|
|
|
|
- $list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time",$order_str,$start,$perpage);
|
|
|
+ $list = $this->bhsq->find_all($where,"id,shop_id,plat_id,title,sku,sqr,sq_num,sq_status,add_time,update_time,bh_no,u9sc_no",$order_str,$start,$perpage);
|
|
|
|
|
|
if(empty($list)){
|
|
|
$rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
|
|
|
@@ -177,21 +188,25 @@ class Beihuogl extends Start_Controller {
|
|
|
$list[$k]['plat_id'] = isset($plat_list[$v['plat_id']])?$plat_list[$v['plat_id']]:"无";
|
|
|
$list[$k]['sq_status'] = isset($status_list[$v['sq_status']])?$status_list[$v['sq_status']]:"";
|
|
|
$list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
|
|
|
- $str = "";
|
|
|
+ $str = "<div style='text-align:center;'>";
|
|
|
if($v['sq_status'] == 1 || $v['sq_status'] == 3){
|
|
|
- $str .= "<div style='text-align:center;'>";
|
|
|
+
|
|
|
$str .= "<a href='javascript:void(0)'class='window' data-h='/beihuogl/dyapplyedit/".$v['id']."' data-t='修改' style='margin-right:4px;color: #fff;background-color:#228B22;padding:4px 10px;border-radius:5px;font-size:15px'>编辑</a>";
|
|
|
$str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color:#4169E1;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='2' onclick='update_status(this)'>发布</a>";
|
|
|
$str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #444;background-color: #ddd;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='0' onclick='update_status(this)'>取消</a>";
|
|
|
- $str .= "</div>";
|
|
|
+
|
|
|
|
|
|
}
|
|
|
if($v['sq_status'] == 0){
|
|
|
- $str .= "<div style='text-align:center;'>";
|
|
|
$str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #DC143C;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-type='0' onclick='del_bhsq(this)'>删除</a>";
|
|
|
- $str .= "</div>";
|
|
|
}
|
|
|
+ if(!empty($v['u9sc_no'])){
|
|
|
+ $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-title='".$v['title']."' data-id='".$v['id']."' data-u9sc_no='".$v['u9sc_no']."' data-bh_no='".$v['bh_no']."' onclick='cx_bhsq(this)'>生产撤销</a>";
|
|
|
+ }
|
|
|
+ $str .= "</div>";
|
|
|
$list[$k]['update_time'] = $str;
|
|
|
+ unset($list[$k]['bh_no']);
|
|
|
+ unset($list[$k]['u9sc_no']);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -2234,4 +2249,292 @@ class Beihuogl extends Start_Controller {
|
|
|
header( "Expires: 0" );
|
|
|
exit($str);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ private function _bhcxsave(){
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
+ $id = $this->input->post('id',true);
|
|
|
+ $cxr = $this->input->post('cxr',true);
|
|
|
+ $remark = $this->input->post('remark',true);
|
|
|
+ $num = $this->input->post('num',true);
|
|
|
+ $info = $this->bhsq->read($id);
|
|
|
+ if(empty($info)){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
|
|
|
+ }
|
|
|
+ if($info['sq_num'] < $num){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'变动后申请数不能大于申请数量']);exit;
|
|
|
+ }
|
|
|
+ if($info['sq_num'] == $num){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'变动后申请数等于申请数量???']);exit;
|
|
|
+ }
|
|
|
+ $this->db->trans_begin();
|
|
|
+ $this->db->insert('bhsccx',[
|
|
|
+ 'bh_no'=>$info['bh_no'],
|
|
|
+ 'u9sc_no'=>$info['u9sc_no'],
|
|
|
+ 'status'=>1,
|
|
|
+ 'cxr'=>trim($cxr),
|
|
|
+ 'zh'=>$info['title'],
|
|
|
+ 'jm'=>$info['jm'],
|
|
|
+ 'shop_id'=>$info['shop_id'],
|
|
|
+ 'sq_id'=>$info['id'],
|
|
|
+ 'before_num'=>$info['sq_num'],
|
|
|
+ 'after_num'=>$num,
|
|
|
+ 'remark'=>$remark,
|
|
|
+ 'add_time'=>time(),
|
|
|
+ 'update_time'=>time()
|
|
|
+ ]);
|
|
|
+ if ($this->db->trans_status() === TRUE) {
|
|
|
+ $this->db->trans_commit();
|
|
|
+ } else {
|
|
|
+ $this->db->trans_rollback();
|
|
|
+ echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ echo json_encode(['success'=>true,'msg'=>'保存成功']);exit;
|
|
|
+ }else{
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _bhcxlist(){
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
+ $page = $this->input->post('page',true);
|
|
|
+ $perpage = $this->input->post('perpage',true);
|
|
|
+ $vip_id = $this->input->post('vip_id',true);
|
|
|
+ $shop_id = $this->input->post('shop_id',true);
|
|
|
+ $cxr = $this->input->post('cxr',true);
|
|
|
+ $cxr = trim($cxr);
|
|
|
+ $status = $this->input->post('status',true);
|
|
|
+ $shop_ids = $this->input->post('shop_ids',true);
|
|
|
+ $ktime = $this->input->post('ktime',true);
|
|
|
+ $jtime = $this->input->post('jtime',true);
|
|
|
+ $ktime = strtotime($ktime);
|
|
|
+ $jtime = strtotime($jtime);
|
|
|
+
|
|
|
+ $where = "add_time >= ".$ktime." and add_time < ".$jtime." ";
|
|
|
+
|
|
|
+ if(!empty($cxr)){
|
|
|
+ $where .= " and cxr = '".$cxr."' ";
|
|
|
+ }
|
|
|
+ if($shop_id > -1){
|
|
|
+ $where .= " and shop_id = ".$shop_id." ";
|
|
|
+ }else{
|
|
|
+ if($vip_id == 1){
|
|
|
+
|
|
|
+ }else{
|
|
|
+ $where .= " and shop_id in (".$shop_ids.") ";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if($status > -1){
|
|
|
+ $where .= " and status = ".$status." ";
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据排序
|
|
|
+ $order_str = "id desc";
|
|
|
+ if(empty($page))
|
|
|
+ {
|
|
|
+ $start = 0;
|
|
|
+ $perpage = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $start = ($page - 1)*$perpage;
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = $this->bhsccx->find_all($where,"id,shop_id,bh_no,u9sc_no,zh,status,cxr,after_num,before_num,add_time",$order_str,$start,$perpage);
|
|
|
+
|
|
|
+ if(empty($list)){
|
|
|
+ $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
|
|
|
+ echo json_encode($rows);exit;
|
|
|
+ }
|
|
|
+ $shop_list = $this->shop->find_all("1=1","id,shopname");
|
|
|
+ $shop_list = array_column($shop_list,'shopname','id');
|
|
|
+ $status_list = $this->bhsccx->getCxStatus();
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无";
|
|
|
+ $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
|
|
|
+ $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
|
|
|
+ if($v['status'] == 0){
|
|
|
+ $list[$k]['after_num'] = $v['after_num'];
|
|
|
+ $list[$k]['cxr'] = $v['cxr'];
|
|
|
+ $list[$k]['u9sc_no'] = "<a href='javascript:void(0)'class='window' data-h='/beihuogl/bhcxedit/".$v['id']."' data-t='修改' >".$v['u9sc_no']."</a>";
|
|
|
+ }
|
|
|
+
|
|
|
+ $str = "<div style='text-align:center;'>";
|
|
|
+
|
|
|
+ if($v['status'] == 1){
|
|
|
+ $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-status='0' onclick='cxaction(this)'>撤回</a>";
|
|
|
+ }
|
|
|
+ if($v['status'] == 0){
|
|
|
+ $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-status='1' onclick='cxaction(this)'>发布</a>";
|
|
|
+ }
|
|
|
+
|
|
|
+ // if(!empty($v['u9sc_no'])){
|
|
|
+ // $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-title='".$v['title']."' data-id='".$v['id']."' data-u9sc_no='".$v['u9sc_no']."' data-bh_no='".$v['bh_no']."' onclick='cx_bhsq(this)'>生产撤销</a>";
|
|
|
+ // }
|
|
|
+ $str .= "</div>";
|
|
|
+ $list[$k]['update_time'] = $str;
|
|
|
+ unset($list[$k]['before_num']);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $total = $this->bhsccx->find_count($where);
|
|
|
+ $pagenum = ceil($total/$perpage);
|
|
|
+ $over = $total-($start+$perpage);
|
|
|
+ $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
|
|
|
+ echo json_encode($rows);exit;
|
|
|
+ }else{
|
|
|
+ $user = $this->user->get_api($_SESSION['api']);
|
|
|
+ $usersp = explode('|',trim($user['shop'],'|'));
|
|
|
+ $this->data['usersp'] = implode(",",$usersp);
|
|
|
+ $vip_id = 0;
|
|
|
+ if(in_array($user['id'],[10,28])){
|
|
|
+ $vip_id = 1;
|
|
|
+ }
|
|
|
+ $this->data['vip_id'] = $vip_id;
|
|
|
+ $this->data['status_list'] = $this->bhsccx->getCxStatus();
|
|
|
+ $this->_Template('beihuogl_bhcxlist',$this->data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _bhcxedit($arg_array){
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
+ $id = $this->input->post('id',true);
|
|
|
+ $cxr = $this->input->post('cxr',true);
|
|
|
+ $remark = $this->input->post('remark',true);
|
|
|
+ $after_num = $this->input->post('after_num',true);
|
|
|
+ $info = $this->bhsccx->read($id);
|
|
|
+ if(empty($info)){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
|
|
|
+ }
|
|
|
+ if($after_num > $info['before_num']){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'要生产数量不能大于之前的申报数量']);exit;
|
|
|
+ }
|
|
|
+ $this->bhsccx->save(['cxr' => $cxr, 'remark' => $remark, 'after_num' => $after_num], $id);
|
|
|
+ echo json_encode(['success'=>true,'msg'=>'操作成功']);exit;
|
|
|
+ }else{
|
|
|
+ $id = $arg_array[0];
|
|
|
+ $info = $this->bhsccx->read($id);
|
|
|
+ $this->data['info'] = $info;
|
|
|
+ $this->_Template('beihuogl_bhcxedit',$this->data);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private function _updatestatus(){
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
+ $id = $this->input->post('id',true);
|
|
|
+ $status = $this->input->post('status',true);
|
|
|
+ $info = $this->bhsccx->read($id);
|
|
|
+ $status = (int)$status;
|
|
|
+ if(empty($info)){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'数据不存在']);exit;
|
|
|
+ }
|
|
|
+ if($status == 0 || $status == 2){
|
|
|
+ if($info['status'] != 1){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'当前状态不符合修改状态']);exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if($status == 1){
|
|
|
+ if($info['status'] != 0){
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'当前状态不符合修改状态']);exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($this->bhsccx->save(['status' => $status],$id)){
|
|
|
+ echo json_encode(['success'=>true,'msg'=>'修改成功']);exit;
|
|
|
+ }else{
|
|
|
+ echo json_encode(array('msg' => '错误,请重试!', 'success' => false));
|
|
|
+ exit;
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ echo json_encode(['success'=>false,'msg'=>'请求方式错误']);exit;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private function _bhcxshlist(){
|
|
|
+ if($this->input->method() === 'post'){
|
|
|
+ $page = $this->input->post('page',true);
|
|
|
+ $perpage = $this->input->post('perpage',true);
|
|
|
+ $cxr = $this->input->post('cxr',true);
|
|
|
+ $cxr = trim($cxr);
|
|
|
+ $status = $this->input->post('status',true);
|
|
|
+ $ktime = $this->input->post('ktime',true);
|
|
|
+ $jtime = $this->input->post('jtime',true);
|
|
|
+ $ktime = strtotime($ktime);
|
|
|
+ $jtime = strtotime($jtime);
|
|
|
+
|
|
|
+ $where = "add_time >= ".$ktime." and add_time < ".$jtime." ";
|
|
|
+ $where .= " and status > 0 ";
|
|
|
+
|
|
|
+ if(!empty($cxr)){
|
|
|
+ $where .= " and cxr = '".$cxr."' ";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(!empty($status)){
|
|
|
+ $where .= " and status = ".$status." ";
|
|
|
+ }else{
|
|
|
+ $where .= " and status > 0 ";
|
|
|
+ }
|
|
|
+
|
|
|
+ //数据排序
|
|
|
+ $order_str = "id desc";
|
|
|
+ if(empty($page))
|
|
|
+ {
|
|
|
+ $start = 0;
|
|
|
+ $perpage = 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ $start = ($page - 1)*$perpage;
|
|
|
+ }
|
|
|
+
|
|
|
+ $list = $this->bhsccx->find_all($where,"id,shop_id,bh_no,u9sc_no,jm,remark,status,cxr,after_num,before_num,add_time",$order_str,$start,$perpage);
|
|
|
+
|
|
|
+ if(empty($list)){
|
|
|
+ $rows = array('total'=>0,'over'=>1,'pagenum'=>0,'rows'=>([]));
|
|
|
+ echo json_encode($rows);exit;
|
|
|
+ }
|
|
|
+ $shop_list = $this->shop->find_all("1=1","id,shopname");
|
|
|
+ $shop_list = array_column($shop_list,'shopname','id');
|
|
|
+ $status_list = $this->bhsccx->getCxStatus();
|
|
|
+ foreach($list as $k=>$v){
|
|
|
+ $list[$k]['shop_id'] = isset($shop_list[$v['shop_id']])?$shop_list[$v['shop_id']]:"无";
|
|
|
+ $list[$k]['status'] = isset($status_list[$v['status']])?$status_list[$v['status']]:"";
|
|
|
+ $list[$k]['add_time'] = date("Y-m-d",$v['add_time']);
|
|
|
+ if($v['status'] == 0){
|
|
|
+ $list[$k]['after_num'] = $v['after_num'];
|
|
|
+ $list[$k]['cxr'] = $v['cxr'];
|
|
|
+ $list[$k]['u9sc_no'] = "<a href='javascript:void(0)'class='window' data-h='/beihuogl/bhcxedit/".$v['id']."' data-t='修改' >".$v['u9sc_no']."</a>";
|
|
|
+ }
|
|
|
+
|
|
|
+ $str = "<div style='text-align:center;'>";
|
|
|
+
|
|
|
+ if($v['status'] == 1){
|
|
|
+ $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-id='".$v['id']."' data-status='2' onclick='cxaction(this)'>审核</a>";
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // if(!empty($v['u9sc_no'])){
|
|
|
+ // $str .= "<a href='javascript:void(0)' style='margin-right:4px;color: #fff;background-color: #9400D3;padding:4px 10px;border-radius:5px;font-size:15px' data-title='".$v['title']."' data-id='".$v['id']."' data-u9sc_no='".$v['u9sc_no']."' data-bh_no='".$v['bh_no']."' onclick='cx_bhsq(this)'>生产撤销</a>";
|
|
|
+ // }
|
|
|
+ $str .= "</div>";
|
|
|
+ $list[$k]['update_time'] = $str;
|
|
|
+ unset($list[$k]['before_num']);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ $total = $this->bhsccx->find_count($where);
|
|
|
+ $pagenum = ceil($total/$perpage);
|
|
|
+ $over = $total-($start+$perpage);
|
|
|
+ $rows = array('total'=>$total,'over'=>$over,'pagenum'=>$pagenum,'rows'=>($list));
|
|
|
+ echo json_encode($rows);exit;
|
|
|
+ }else{
|
|
|
+ $this->data['status_list'] = $this->bhsccx->getCxStatus();
|
|
|
+ $this->_Template('beihuogl_bhcxshlist',$this->data);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|