where($map)->field('id,temple,product_code')->select(); // foreach ($productlist as $key=>$value){ // $code = substr($value['product_code'],2,2); // $db->where('id='.$value['id'])->setField('temple',$code); // } $session_config=I('session.ly_admin_');//获取登陆的session值 $userinfo=M('admin_user')->where('id='.$session_config['user_auth']['uid'])->find(); $user_product = explode(',',$userinfo['product_id']); $map = array(); $map['id'] = array('in',$user_product); $productlist=M('qcode_product')->where($map)->field('product_name,id,product_size,product_num,temple,product_code')->select(); if($session_config['addtype']==0){//最高管理员登陆渲染供应商列表到前台 $field='nickname,postcode,mobile,company_address,printer_code,id'; $companylist=M('admin_user')->field($field)->select(); $this->assign('companylist',$companylist); } $this->assign("session_config",$session_config['user_auth']); $this->assign('userinfo',$userinfo); $this->assign('productlist',$productlist); $this->display(); } public function get_bach_info(){ //获取批次相关信息 $addtobach=M('qcode_bach')->alias('a') ->join('qr_qcode_large b on a.id=b.bach_id') ->join('qr_qcode_small c on b.id=c.large.id ') ->field('bach_num,large_endnum') ->where('id='.I('get.id')) ->find(); } //批次新增 public function add_bath(){ $userid=I('post.userid');//当前用户的id $product_id=I('post.matter_id');//当前产品的id //新增批次 if (IS_POST) { if(!empty($_POST)){ $QcodeBach= M("QcodeBach"); $data=array(); $data= $_POST; // print_r($data); if(I('post.danwei')==1) { //以箱为单位 $tray_num = I('post.tray_num/d');//一托盘多少箱 $small_num = ceil(I('post.num/d') / I('post.box_num/d'));//总共多少箱 $larger_num = ceil($small_num / $tray_num);//托盘总数量 } if(I('post.danwei')==2){//以卷为单位 $tray_num = I('post.box_num1');//一托盘多少卷 $small_num = ceil(I('post.small_num'));//总共多少卷 $larger_num = ceil($small_num / $tray_num);//托盘总数量 } $reset_flow=M('reset_flow'); $codition['userid']=$userid; $codition['product_id']=$product_id; if(I('reset_large_liushui_status')==1){ //没有重置大件流水号,在原有的基础上叠加 $l_flow=GetTuopan($userid,$product_id); if($l_flow){ //找到之前已经存在托盘号 $info['l_flow']=$l_flow['l_flow']+$larger_num; $info['bach_num']=I('post.bach_num'); $reset_flow->where($codition)->save($info); //var_dump($reset_flow->getLastSql()); }else{ //没有找到就添加 $infos=[ 'userid'=>$userid, 'product_id'=>$product_id, 'l_flow'=>$larger_num, 'bach_num'=>I('post.bach_num'), ]; $reset_flow->add($infos);//加到对应的商家与产品上 //var_dump($reset_flow->getLastSql()); }; } if(I('reset_large_liushui_status')==2){//表示用户已经重置大件流水号,更新对应的托盘数 $infoss['l_flow']=$larger_num; $infoss['bach_num']=I('post.bach_num'); $l_flow=GetTuopan($userid,$product_id); // print_r($infoss);die; if($l_flow){ //找到了对应的数据就更新 $reset_flow->where($codition)->save($infoss);//更新用户的托盘数 }else{ //没有就添加 $infos=[ 'userid'=>$userid, 'product_id'=>$product_id, 'l_flow'=>$larger_num, 'bach_num'=>I('post.bach_num'), ]; $reset_flow->add($infos); } } // die; $data['small_num']=$small_num; $data['larger_num']=$larger_num; $data['manufacture_date']=((int)date('Ymd',strtotime(I('post.manufacture_date')))-20000000);//六位生产日期 $data['print_date']=((int)date('Ymd',strtotime(I('post.print_date')))-20000000);//六位打码日期 $data['userid']=$userid;//批次绑定用户id $data['bach_num']=I('post.bach_num');//生产批次列表 $data['large_endnum']=$larger_num+I('post.l_flow')-1; $data['creat_time']=time(); $Bach_id =$QcodeBach->data($data)->add(); //成功插入批次信息之后开始插入大小二维码数据 if($Bach_id){ $QcodeLarge= M("QcodeLarge"); $QcodeSmall= M("QcodeSmall"); $liushui=M("QcodeLiushui"); //不变区域 $fixed_code=''; $fixed_code.=intTochar(I('post.matter_type'),2);//2位 辅料种类 $fixed_code.=intTochar(I('post.supplier_code'),12);//12位 供应商编码 $fixed_code.=intTochar(I('post.matter_no'),20);//20位 辅料编码 $fixed_code.=((int)date('Ymd',strtotime(I('post.manufacture_date')))-20000000);//六位生产日期 $print_date=((int)date('Ymd',strtotime(I('post.print_date')))-20000000);//6位打码日期 $small_liushui=[ 'onlycode'=> "AB92".$fixed_code.$print_date, 'last_num'=> 0, 'user_id'=>$userid, 'stype'=>2, 'addtime'=>time() ]; $whereSmall=[ 'onlycode'=> $small_liushui['onlycode'], 'user_id'=> $userid ]; if($liushui->where($whereSmall)->find()){ //小件二维码重复了,更新这个批次的最后流水号 /* $liushui->where($whereSmall)->setInc('last_num',$small_num);*/ $lastnum=$liushui->field('last_num')->where($whereSmall)->find(); }else{ //没有重复,新增一条记录 $liushui->data($small_liushui)->add(); }; for($i=0;$i<$larger_num;$i++){ $l_flows=I('post.l_flow/d')+$i; $l_flow=intTochar(I('post.l_flow/d')+$i,6); $l_weight=intTochar(I('post.l_weight')*100,6);//2023年3月20日 修改大件可以有小数,小件重量不变 不能有小数 // $l_reservation=intTochar($Bach_id.I('post.l_reservation'),12);//批次id+0,不够12位在前面补0 具体点击方法看代码 $l_reservation=intTochar(I('post.bach_num'),10);//批次+0,不够10位在前面补0 第一个批次 后续会加第二个批次 $l_reservation = $l_reservation.'0000000000'; $small_n = intTochar($tray_num,3); if(I('post.danwei')==2){//以卷为单位 $remainder = $small_num - $tray_num*$i; //确定最后一个托盘大件里小件的数量 if ($remainder < $tray_num){ $small_n = intTochar($remainder,3);//小件数量3位 不足补零 } } $code_data= CodeData($this->sign,$fixed_code,$small_n,$print_date,$l_flow,$l_weight,$this->signLarge,$l_reservation); //大码数据信息 $L_data=[ 'bach_id'=>$Bach_id, 'code'=>$code_data['code'], 'code_cp1'=>$code_data['code_cp1'], 'code_cp2'=>$code_data['code_cp2'], 'print_date'=>$print_date, 'creat_time'=>time(), 'p_nums'=>0, 'userid'=>$userid,//大码绑定用户id 'l_weight'=>$l_weight//单个大件重量 ]; $large_id= $QcodeLarge->data($L_data)->add(); //小码插入循环 for($j=0;$j<$tray_num and ($j+$i*$tray_num)<$small_num;$j++){ $s_flow=intTochar(I('post.s_flow/d')+$j+$i*$tray_num+$lastnum['last_num'],6);//小码序号从一开始 $s_weight=intTochar(I('post.s_weight'),6); $small_sign = '000'; // $small_production_date = (int)date('Ymd',strtotime(I('post.manufacture_date')));//8位生产日期 $s_reservation=intTochar(I('post.bach_num'),10);//批次+0,不够10位在前面补0 第一个批次 后续会加第二个批次 $s_reservation = $s_reservation.'0000000000'; $small_code_data= CodeData($this->sign,$fixed_code,$small_sign,$print_date,$s_flow,$s_weight,$this->signSmall,$s_reservation); $S_data=[ 'large_id'=>$large_id, 'bach_id'=>$Bach_id, 'code'=>$small_code_data['code'], 'code_cp1'=>$small_code_data['code_cp1'], 'code_cp2'=>$small_code_data['code_cp2'], 'l_flow'=>$j+1, 'print_date'=>$print_date, 'creat_time'=>time(), 'p_nums'=>0, 'userid'=>$userid,//小码绑定用户id 's_weight'=>$s_weight//单个小件重量 ]; $QcodeSmall->data($S_data)->add(); } } $liushui->where($whereSmall)->setInc('last_num',$small_num); } if(($j+($i-1)*$tray_num)==$small_num){ M()->commit(); $this->success('批次新增成功', U('Qcode/small')); }else{ M()->rollback(); $this->success('批次新增失败', U('Qcode/small')); } }else{ $this->error('非法请求','NewQcode/index',5); } } } public function BachListApi(){//获取打印批次列表 $session_config=I('session.ly_admin_');//获取登陆的session值 if($_GET['sysCdNm']){//有搜索产品名称 $where['a.matter_name']=array('like','%'.$_GET['sysCdNm'].'%'); } if($_GET['nickname']){//有搜索公司名称 $where['c.nickname']=$_GET['nickname']; } if($_GET['prodBth']){//有搜索产品批次 $where['a.bach_num']=$_GET['prodBth']; } if($_GET['startDate']){//有开始打印日期 $statrtime=((int)date('Ymd',(strtotime($_GET['startDate'])))-20000000); $endtime=((int)date('Ymd',(strtotime($_GET['endDate'])))-20000000); $where['a.print_date']=array(array('egt',$statrtime),array('elt',$endtime),'AND'); } if($session_config['user_auth']['addtype']==1){ $where['a.userid']=$session_config['user_auth']['uid']; } $where['a.bach_status']=0; if ($_GET['sqrcd']){//有搜索标签代码 $map = array(); $map['code'] = array('like','%'.$_GET['sqrcd'].'%'); $large_bach = M('qcode_large')->where($map)->field('bach_id')->select(); if (!empty($large_bach)){ foreach ($large_bach as $key=>$value){ $option[$key] = $value['bach_id']; } $option = array_unique($option); $where['a.id'] = array('IN',$option); }else{ $small_bach = M('qcode_small')->where($map)->field('bach_id')->select(); if (!empty($small_bach)){ foreach ($small_bach as $key=>$value){ $option[$key] = $value['bach_id']; } $option = array_unique($option); $where['a.id'] = array('IN',$option); } } } $BatchList=M('qcode_bach')->alias('a') ->join('qr_qcode_product b on a.matter_id=b.id','LEFT') ->join('qr_admin_user c on a.userid=c.id','LEFT') ->field('a.*,b.product_num,c.nickname') ->order($_GET['sort'].' '.$_GET['order']) ->page($_GET['page'],$_GET['rows']) ->where($where) ->select(); //echo M('qcode_bach')->getLastSql(); $total = M('qcode_bach')->alias('a') ->join('qr_qcode_product b on a.matter_name=b.product_name','LEFT') ->join('qr_admin_user c on a.userid=c.id') ->where($where) ->count(); $result = []; $result['total'] = $total; $result['rows'] = $BatchList; $bachlist = json_encode($result); echo $bachlist; //echo json_encode($BatchList); } public function BachListApiTwo(){//补打界面获取补打批次列表 // $session_config=I('session.ly_admin_');//获取登陆的session值 if($_GET['sysCdNm']){//有搜索产品名称 $where['a.matter_name']=array('like','%'.$_GET['sysCdNm'].'%'); } if($_GET['nickname']){//有搜索公司名称 $where['c.nickname']=array('like','%'.$_GET['nickname'].'%'); } if($_GET['prodBth']){//有搜索产品批次 $where['a.bach_num']=$_GET['prodBth']; } if($_GET['matter_no']){//有搜索产品批次 $where['a.matter_no']=array('like','%'.$_GET['matter_no'].'%'); } if($_GET['startDate']){//有开始打印日期 $statrtime=((int)date('Ymd',(strtotime($_GET['startDate'])))-20000000); $endtime=((int)date('Ymd',(strtotime($_GET['endDate'])))-20000000); $where['a.print_date']=array(array('egt',$statrtime),array('elt',$endtime),'AND'); } // if($session_config['user_auth']['addtype']==1){ // $where['a.userid']=$session_config['user_auth']['uid']; // } $where['a.bach_status']=0; if ($_GET['sqrcd']){//有搜索标签代码 $map = array(); $map['code'] = array('like','%'.$_GET['sqrcd'].'%'); $large_bach = M('qcode_large')->where($map)->field('bach_id')->select(); if (!empty($large_bach)){ foreach ($large_bach as $key=>$value){ $option[$key] = $value['bach_id']; } $option = array_unique($option); $where['a.id'] = array('IN',$option); }else{ $result = []; $result['total'] = '0'; $result['rows'] = []; $bachlist = json_encode($result); return $bachlist; $small_bach = M('qcode_small')->where($map)->field('bach_id')->select(); if (!empty($small_bach)){ foreach ($small_bach as $key=>$value){ $option[$key] = $value['bach_id']; } $option = array_unique($option); $where['a.id'] = array('IN',$option); } } } $BatchList=M('qcode_bach')->alias('a') ->join('qr_qcode_product b on a.matter_id=b.id','LEFT') ->join('qr_admin_user c on a.userid=c.id','LEFT') ->field('a.*,b.product_num,c.nickname') ->order($_GET['sort'].' '.$_GET['order']) ->page($_GET['page'],$_GET['rows']) ->where($where) ->select(); //echo M('qcode_bach')->getLastSql(); $total = M('qcode_bach')->alias('a') ->join('qr_qcode_product b on a.matter_name=b.product_name','LEFT') ->join('qr_admin_user c on a.userid=c.id') ->where($where) ->count(); $result = []; $result['total'] = $total; $result['rows'] = $BatchList; $bachlist = json_encode($result); echo $bachlist; //echo json_encode($BatchList); } public function GetLargeLabelApi(){//获取关联批次的大件标签列表 $field = "code,print_date,p_nums,id,code_cp1,l_print,l_status,archive"; $LargeLabelList = M('qcode_large')->field($field)->where('bach_id='.I('get.product_id'))->select(); // var_dump($LargeLabelList); foreach($LargeLabelList as $key=>$val){ $qcode_small=$val['archive']?"qcode_small_".$val['archive']:"qcode_small"; $smalltotal=M('qcode_small')->field('count(large_id)')->where('large_id='.$val['id'])->find(); $LargeLabelList[$key]['code_cp1']=ltrim(substr($LargeLabelList[$key]['code_cp1'],6,10),'0'); $LargeLabelList[$key]['smalltotal']=$smalltotal['count(large_id)']; if( $LargeLabelList[$key]['l_print']==0){ $type="未打印"; } if($LargeLabelList[$key]['l_print']==1){ $type="已打印"; } $LargeLabelList[$key]['type']=$type; } echo json_encode($LargeLabelList); } public function GetSmallLabelApi(){//获取关联大标签的的小标签列表 if(I('get.large_id')){//获取小标签列表 $field="id,code,code_cp1,status,l_flow,p_nums"; $smalllist=M('qcode_small') ->field($field) ->where('large_id='.I('get.large_id')) ->select(); $large_data = M('qcode_large') ->field('code_cp1') ->where('id='.I('get.large_id')) ->find(); $large_flow = ltrim(substr($large_data['code_cp1'],6,10),'0'); foreach($smalllist as $key=>$val){ $smalllist[$key]['l_flow']= $large_flow.'-'.$smalllist[$key]['l_flow']; // if($val['id']>44091){ // $smalllist[$key]['code_cp1']=I('get.large_tuopan').'-'.ltrim(substr($smalllist[$key]['code_cp2'],12,6),'0');} // else{ // $smalllist[$key]['code_cp1']=I('get.large_tuopan').'-'.ltrim(substr($smalllist[$key]['code_cp1'],6,6),'0'); // }; } $this->ajaxReturn($smalllist); } if(I('get.code') ){//单个删除 $field="id,code,status"; $code=I('get.code'); $data['status']=1; if( M('qcode_small')->where("code='$code'")->save($data)){ $smalllist['status']=200; $smalllist['error']="操作成功"; }else{ $smalllist['status']=100; $smalllist['error']="操作失败"; }; $smalllist['list']=M('qcode_small')->field($field)->where("code='$code'")->select(); $this->ajaxReturn($smalllist); } } public function OneSmallPrint(){//单个打印小标签 // M('qcode_small')->where('id='.I('get.id'))->setInc('p_nums',I('get.reptQty'));//更新小标签的打印次数 //echo M('qcode_small')->getLastSql(); $smalllabel[]=M('qcode_small')->alias('b') ->join("qr_qcode_large c on b.large_id=c.id") ->join('qr_qcode_bach d on d.id=c.bach_id') ->field('b.*,d.id as bath_id,d.supplier_name, b.l_flow, d.matter_name,d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow,c.code as ccode,c.code_cp1 as banhao,d.box_num,d.bach_num') ->where('b.id='.I('get.id')) ->select(); /*foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容 $imgcode=$this->qrcode($val['code']); $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode; }*/ $total['smalllabel']=$smalllabel; $total['num']=I('get.reptQty'); $this->ajaxReturn($total); } //二维码打印 // public function rePrintTg(){ // header("Content-type: text/html; charset=utf-8"); // $id = I('post.idList');//选中的大件标签的列表id // $ids=explode(",",$id);//将字符串以逗号转化为数组 // $num = I('post.reptQty')?I('post.reptQty'):3;//重复打印次数 // foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息 // if(I('post.sign_type')==1){//打印的为大件标签 // //先更新大标签的打印次数 // M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num // M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num // //在查找相关的信息 // $largelabel[]=M('qcode_large')->alias('a') // ->join('qr_qcode_bach q on a.bach_id=q.id') // ->field('a.*,q.supplier_name,q.l_weight') // ->where('a.id='.$val) // ->select(); // // } // if(I('post.sign_type')==2){//打印的为小件标签 // //先更新小标签的打印次数 // M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num // /* M('qcode_small')->where('large_id='.$val)->setField('status','1');//更新小标签的打印状态$num*/ // //在查找小标签的相关内容 // // $smalllabel[]=M('qcode_small')->alias('b') // ->join("qr_qcode_large c on b.large_id=c.id") // ->join('qr_qcode_bach d on d.id=c.bach_id') // ->field('b.*,d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name,d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow, b.l_flow,c.code_cp1 as banhao,d.box_num,d.bach_num') // ->where('b.large_id='.$val) // ->select(); // } // //$sql=M('qcode_small')->getLastSql(); // } //// foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容 //// $imgcode=$this->qrcode($val['code']); //// $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode; //// } // //var_dump($smalllabel[0]); // $total['largrlabel']=$largelabel?$largelabel:''; // $total['smalllabel']=$smalllabel?$smalllabel:''; // $total['num']=$num; // $this->ajaxReturn($total); // // } public function rePrintTg(){ header("Content-type: text/html; charset=utf-8"); $id = I('post.idList');//选中的大件标签的列表id $ids=explode(",",$id);//将字符串以逗号转化为数组 $num = I('post.reptQty')?I('post.reptQty'):0;//重复打印次数 if (I('post.status')==1){//修改打印次数--自动打码 foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息 if(I('post.sign_type')==1){//打印的为大件标签 //更新大标签的打印次数 M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num } if(I('post.sign_type')==2){//打印的为小件标签 //更新小标签的打印次数 M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num } } $total['num']=$num; $this->ajaxReturn($total); }else if (I('post.status')==2){//修改打印次数--小件 foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息 M('qcode_small')->where('id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num } $total['num']=$num; $this->ajaxReturn($total); }else{ foreach($ids as $key=>$val){//获取对应的大标签以及绑定的小标签的相关信息 if(I('post.sign_type')==1){//打印的为大件标签 //先更新大标签的打印次数 // M('qcode_large')->where('id='.$val)->setInc('p_nums',$num);// 大标签的打印次数加$num // M('qcode_large')->where('id='.$val)->setField('l_print','1');//更新大标签的打印状态$num //在查找相关的信息 $largelabel[$key] = M('qcode_large')->alias('c') ->field('u.main_unit, u.sec_unit, u.proportion, d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name, d.matter_no, d.matter_size,d.num,d.manufacture_date,d.l_flow,c.code, c.code_cp1 as banhao,d.box_num,d.bach_num') ->join('qr_qcode_bach d on c.bach_id=d.id') ->join('qr_qcode_unit u on u.code=d.matter_no') ->where('c.id='.$val) ->select(); $numn = M('qcode_small')->where('large_id='.$val)->count(); $largelabel[$key][0]['numn']=$numn; } if(I('post.sign_type')==2){//打印的为小件标签 //先更新小标签的打印次数 // M('qcode_small')->where('large_id='.$val)->setInc('p_nums',$num);// 小标签的打印次数加$num /* M('qcode_small')->where('large_id='.$val)->setField('status','1');//更新小标签的打印状态$num*/ //在查找小标签的相关内容 $smalllabel[]=M('qcode_small')->alias('b') ->join("qr_qcode_large c on b.large_id=c.id") ->join('qr_qcode_bach d on d.id=c.bach_id') ->field('b.*,d.s_weight,d.id as bath_id,d.supplier_name,d.matter_name, d.matter_no, d.matter_size,d.num,d.manufacture_date,d.l_flow as dl_flow, b.l_flow,c.code as ccode, c.code_cp1 as banhao,d.box_num,d.bach_num') ->where('b.large_id='.$val) ->select(); } //$sql=M('qcode_small')->getLastSql(); } // foreach($smalllabel[0] as $key=>$val){//循环获取img标签内容 // $imgcode=$this->qrcode($val['code']); // $smalllabel[0][$key]['imgcode']="data:image/png;base64,".$imgcode; // } //var_dump($smalllabel[0]); $total['largrlabel']=$largelabel?$largelabel:''; $total['smalllabel']=$smalllabel?$smalllabel:''; $total['num']=$num; $this->ajaxReturn($total); } } public function userinfoedit() {//修改用户的相关信息 if (IS_POST) { // 密码为空表示不修改密码 if ($_POST['password'] === '') { unset($_POST['password']); } // 提交数据 $user_object = D('User'); $data = $user_object->create(); if ($data) { $result = $user_object ->field('id,nickname,username,password,email,email_bind,mobile,mobile_bind,gender,avatar,update_time,printer_code,postcode,company_address') ->save($data); if ($result) { $this->success('更新成功', U('index')); } else { $this->error('更新失败', $user_object->getError()); } } else { $this->error($user_object->getError()); } } else { // 获取账号信息 $session_config=I('session.ly_admin_'); $id=$session_config['user_auth']['uid']; $info = D('User')->find($id); unset($info['password']); // 使用FormBuilder快速建立表单页面。 $builder = new \Common\Builder\FormBuilder(); $builder->setMetaTitle('编辑用户')// 设置页面标题 ->setPostUrl(U('userinfoedit'))// 设置表单提交地址 ->addFormItem('id', 'hidden', 'ID', 'ID') ->addFormItem('nickname', 'text', '供应商名称', '供应商名称') ->addFormItem('printer_code', 'text', '供应商编码', '供应商编码') ->addFormItem('postcode', 'num', '邮政编码', '邮政编码') ->addFormItem('company_address', 'text', '地址', '详细地址') ->addFormItem('username', 'text', '用户名', '用户名') ->addFormItem('password', 'password', '密码', '密码') ->addFormItem('email', 'text', '邮箱', '邮箱') ->addFormItem('email_bind', 'radio', '邮箱绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定')) ->addFormItem('mobile', 'text', '手机号', '手机号') ->addFormItem('mobile_bind', 'radio', '手机绑定', '手机绑定', array('1' => '已绑定', '0' => '未绑定')) /*->addFormItem('avatar', 'picture', '头像', '头像')*/ ->setFormData($info) ->display(); } } public function qrcode($url)//二维码生成类 { $url=$url; $level=3; $size=4; Vendor('phpqrcode.phpqrcode');//加载生成二维码的核心类 $errorCorrectionLevel =intval($level) ;//容错级别 $matrixPointSize = intval($size);//生成图片大小 //生成二维码图片 $object = new \QRcode(); //打开缓冲区 ob_start(); $object->png($url, false, $errorCorrectionLevel, $matrixPointSize, 2); //这里就是把生成的图片流从缓冲区保存到内存对象上,使用base64_encode变成编码字符串,通过json返回给页面。 $imageString = base64_encode(ob_get_contents()); //关闭缓冲区 ob_end_clean(); //把生成的base64字符串返回给前端 return $imageString; /* $data = array( 'labelcode'=>$url, 'code'=>200, 'data'=>$imageString, 'product_code'=>$url ); $this->ajaxReturn($data);*/ } public function changestatus(){//动态改变小标签的状态 $data['status']=I('get.status'); if(M('qcode_small')->where('id='.I('get.id'))->save($data)){ $bach_id=M('qcode_large')->field('bach_id')->where('id='.I('get.large_id'))->find();//获取批次id $small_num=M('qcode_bach')->field('small_num')->where('id='.$bach_id['bach_id'])->find();//获取批次原有的小标签数量 if(I('get.status')=='0'){ //表示已删除的标签变为正常,批次小件数量加一 $infos['small_num']=$small_num['small_num']+1; M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量 // echo M('qcode_bach')->getLastSql(); } if(I('get.status')=='1'){ //表示正常的标签变为已删除,批次小件数量减一 $infos['small_num']=$small_num['small_num']-1; M('qcode_bach')->where('id='.$bach_id['bach_id'])->save($infos);//更新批次的小标签数量 //echo M('qcode_bach')->getLastSql(); } $info['code']=200; $info['error']="操作成功"; }else{ $info['code']=100; $info['error']="操作失败"; }; $this->ajaxReturn($info); } }