public function actionGetSitePersons() { $companyid = Yii::app()->request->getParam('companyid', 0); $padid = Yii::app()->request->getParam('padid', 0); $stlid = Yii::app()->request->getParam('stlid', 0); $splid = Yii::app()->request->getParam('splid', 0); $ret = array(); $nowqueueno = "000"; $queueno = "A001"; $waitingno = 0; if (empty($companyid) || empty($padid)) { Yii::app()->end(json_encode(array('status' => false, 'msg' => '店铺或设备不存在!'))); } $pad = Pad::model()->with("printer")->find(' t.dpid=:companyId and t.lid=:padid', array(':companyId' => $companyid, ':padid' => $padid)); //var_dump($pad);exit; if (!empty($pad)) { //生成新的排队号 $siteType = SiteType::model()->find(" dpid=:dpid and lid=:lid", array(":dpid" => $companyid, ":lid" => $stlid)); //var_dump($siteType);exit; $criteria = new CDbCriteria(); $criteria->condition = " dpid=" . $companyid . " and stlid=" . $stlid . " and splid=" . $splid . " and create_at >='" . date('Y-m-d', time()) . " 00:00:00' and create_at <='" . date('Y-m-d', time()) . " 23:59:59'"; $criteria->order = ' lid '; $queuePerson = QueuePersons::model()->findAll($criteria); if (empty($siteType)) { Yii::app()->end(json_encode(array('status' => false, 'msg' => '座位类型不存在!'))); } //var_dump($queuePerson);exit; if (!empty($queuePerson)) { $countsp = count($queuePerson); $queueno = $siteType->simplecode . substr("000" . (string) ($countsp + 1), -3); for ($sti = $countsp - 1; $sti >= 0; $sti--) { if ($queuePerson[$sti]->status == "0") { $waitingno++; } else { break; } } } else { $queueno = $siteType->simplecode . "001"; $waitingno = 0; } $se = new Sequence("queue_persons"); $queuelid = $se->nextval(); $data = array('lid' => $queuelid, 'dpid' => $companyid, 'create_at' => date('Y-m-d H:i:s', time()), 'update_at' => date('Y-m-d H:i:s', time()), 'stlid' => $stlid, 'splid' => $splid, 'queue_no' => $queueno, 'status' => '0', 'slid' => "0000000000", 'delete_flag' => '0'); Yii::app()->db->createCommand()->insert('nb_queue_persons', $data); $waitingno++; //返回现有的等待人数 $precode = ""; $printserver = "0"; // $memo = "排队号:" . $queueno . ",(还有" . $waitingno . "组在等待)"; $ret = Helper::printQueue($pad, $precode, $printserver, $memo); if ($ret['status']) { $ret['waitingnum'] = $waitingno; } } else { $ret = array('status' => false, 'msg' => '没有找到PAD'); } Yii::app()->end(json_encode($ret)); }
public function actionIndex() { $criteria = new CDbCriteria(); $criteria->with = array('site', 'site.isfree'); $criteria->condition = 't.company_id=' . $this->companyId . ' and t.delete_flag=0'; $models = SiteType::model()->findAll($criteria); $this->render('index', array('models' => $models)); }
public function actionUpdate() { $lid = Yii::app()->request->getParam('lid'); $dpid = Yii::app()->request->getParam('companyId'); Until::isUpdateValid(array($lid), $this->companyId, $this); //0,表示企业任何时候都在云端更新。 $model = SiteType::model()->find('t.lid=:lid and t.dpid=:dpid', array(':lid' => $lid, ':dpid' => $dpid)); //var_dump($model); if (Yii::app()->request->isPostRequest) { $model->attributes = Yii::app()->request->getPost('SiteType'); $model->update_at = date('Y-m-d H:i:s', time()); if ($model->save()) { Yii::app()->user->setFlash('success', yii::t('app', '修改成功')); $this->redirect(array('siteType/index', 'companyId' => $this->companyId)); } } $this->render('update', array('model' => $model)); }
public static function getTypes($companyId) { $types = SiteType::model()->findAll('dpid=:companyId and delete_flag=0', array(':companyId' => $companyId)); $types = $types ? $types : array(); return CHtml::listData($types, 'lid', 'name'); }
public static function printList(Order $order, $orderProducts, Pad $pad, $cprecode, $printserver, $memo) { $printer = Printer::model()->find('lid=:printerId and dpid=:dpid', array(':printerId' => $pad->printer_id, ':dpid' => $order->dpid)); if (empty($printer)) { return array('status' => false, 'dpid' => $order->dpid, 'jobid' => "0", 'type' => 'none', 'msg' => yii::t('app', 'PAD还没有设置默认打印机')); } $hasData = false; //$orderProducts = OrderProduct::getOrderProducts($order->lid,$order->dpid); ///site error because tempsite and reserve************** //$listData = array("22".Helper::getPlaceholderLenBoth($order->company->company_name, 16));// $listData = array("22" . Helper::setPrinterTitle($order->company->company_name, 8)); if (!empty($memo)) { array_push($listData, "br"); array_push($listData, "11" . $memo); } array_push($listData, "00"); array_push($listData, "br"); $strSite = ""; if ($order->is_temp == 0) { $site = Site::model()->find('lid=:lid and dpid=:dpid', array(':lid' => $order->site_id, ':dpid' => $order->dpid)); $siteType = SiteType::model()->find('lid=:lid and dpid=:dpid', array(':lid' => $site->type_id, ':dpid' => $order->dpid)); //$strSite=str_pad(yii::t('app','座号:').$siteType->name.' '.$site->serial , 24,' ').str_pad(yii::t('app','人数:').$order->number,12,' '); array_push($listData, "00" . yii::t('app', '座号:')); array_push($listData, "11" . $siteType->name . ' ' . $site->serial); //array_push($listData,"00"." ".yii::t('app','人数:').$order->number); } else { //$strSite=str_pad(yii::t('app','座号:临时座').$order->site_id%10000 , 24,' ').str_pad(yii::t('app','人数:').$order->number,12,' '); array_push($listData, "00" . yii::t('app', '座号:临时座')); array_push($listData, "11" . $order->site_id % 10000); //array_push($listData,"00"." ".yii::t('app','人数:').$order->number); } array_push($listData, "00" . " " . yii::t('app', '人数:') . $order->number); if (!empty($order->callno)) { //$strSite=$strSite.str_pad(yii::t('app','呼叫号:').$order->callno,12,' '); //array_push($listData,$strcall); array_push($listData, "00" . " " . yii::t('app', '呼叫号:')); array_push($listData, "11" . $order->callno); } //$listKey = $order->dpid.'_'.$printer->ip_address; array_push($listData, "br"); //array_push($listData,"00".$strSite); array_push($listData, "00" . str_pad('', 48, '-')); foreach ($orderProducts as $product) { //var_dump($product);exit; if ($product['amount'] < 1) { continue; } $hasData = true; if (Yii::app()->language == 'jp') { //array_push($listData,Helper::getPlaceholderLen($product['product_name'],36).Helper::getPlaceholderLen($product['amount']." X ".number_format($product['price'],0),12)); array_push($listData, "11" . str_pad($product['amount'] . " X " . number_format($product['price'], 0), 10, ' ') . " " . Helper::setProductName($product['product_name'], 12, 6)); } else { //array_push($listData,Helper::getPlaceholderLen($product['product_name'],24).Helper::getPlaceholderLen($product['amount']." X ".$product['product_unit'],12).Helper::getPlaceholderLen(number_format($product['price'],2) , 12)); //array_push($listData,"00".str_pad($product['amount']." X ".number_format($product['price'],2),13,' ')." ".Helper::setProductName($product['product_name'],24,16)); array_push($listData, "11" . str_pad($product['amount'] . " X " . number_format($product['price'], 2), 10, ' ') . " " . Helper::setProductName($product['product_name'], 12, 6)); } array_push($listData, "br"); } array_push($listData, "00" . str_pad('', 48, '-')); if (Yii::app()->language == 'jp') { //array_push($listData,str_pad(yii::t('app','应付:').number_format($order->should_total,0) , 26,' ').str_pad(date('Y-m-d H:i:s',time()),20,' ')); //array_push($listData,str_pad(yii::t('app','订餐电话:').$order->company->telephone,44,' ')); array_push($listData, "11" . yii::t('app', '应付:') . number_format($order->should_total, 0) . yii::t('app', '实付:') . number_format($order->reality_total, 0)); } else { //array_push($listData,str_pad(yii::t('app','应付:').$order->should_total , 40,' ')); //array_push($listData,str_pad(yii::t('app','操作员:').Yii::app()->user->name,24,' ') // .str_pad(yii::t('app','时间:').date('Y-m-d H:i:s',time()),24,' ')); //array_push($listData,str_pad(yii::t('app','订餐电话:').$order->company->telephone,44,' ')); array_push($listData, "11" . yii::t('app', '原价:') . number_format($order->should_total, 2) . yii::t('app', '优惠价:') . number_format($order->reality_total, 2)); } array_push($listData, "br"); array_push($listData, "00" . $order->username); array_push($listData, "00" . " " . date('Y-m-d H:i:s', time())); array_push($listData, "br"); array_push($listData, "00" . yii::t('app', '订餐电话:') . $order->company->telephone); $precode = $cprecode; //后面加切纸 $sufcode = "0A0A0A0A0A0A1D5601"; //var_dump($listData);exit; $printret = array(); if ($hasData) { //$printserver='0'; $retcontent = Helper::printConetent($printer, $listData, $precode, $sufcode, $printserver, $order->lid); $retcontent['orderid'] = $order->lid; return $retcontent; } else { return array('status' => false, 'orderid' => $order->lid, 'dpid' => $printer->dpid, 'jobid' => "0", 'type' => 'none', 'msg' => yii::t('app', '没有要打印的菜品!')); } /*$listData.= str_pad('',48,'-').'<br>'; $listData.= str_pad('消费合计:'.$order->reality_total , 20,' ').'<br>'; $listData.= str_pad('收银员:'.Yii::app()->user->name,20,' ').'<br>'; $listData.= str_pad('应收金额:'.$order->reality_total,48,' ').'<br>'; $listData.= str_pad('',48,'-').str_pad('打印时间:'.time(),20,' ').'<br>' .str_pad('订餐电话:'.$order->company->telephone,20,' ').'<br>'; //echo Yii::app()->end(json_encode(array('status'=>true,'msg'=>$listData)));exit; if(!empty($listData)){ if(Yii::app()->params->has_cache){ $list = new ARedisList($listKey); if($reprint) { $listData = str_pad('丢单重打', 40 , ' ',STR_PAD_BOTH).'<br>'.$listData; $list->add($listData); } else { $list->unshift($listData); } } } //echo Yii::app()->end(json_encode(array('status'=>true,'msg'=>$listData)));exit; //$channel = new ARedisChannel($order->dpid.'_PD'); //$channel->publish($listKey); if((Yii::app()->request->isAjaxRequest)) { echo Yii::app()->end(json_encode(array('status'=>true,'msg'=>''))); } else { return array('status'=>true,'msg'=>''); }*/ }
public function actionClientSitelist() { //Yii::app()->theme="pad_cn"; $compayId = Yii::app()->request->getParam('companyId'); $padtype = Yii::app()->request->getParam('padtype'); if ($padtype == "1") { Yii::app()->language = 'jp'; Yii::app()->theme = "pad"; } else { Yii::app()->language = 'zh_cn'; Yii::app()->theme = "pad_cn"; } $criteria = new CDbCriteria(); $criteria->condition = 't.delete_flag = 0 and t.status in ("1","2","3") and t.is_temp = 1 and t.dpid=' . $compayId; $criteria->order = ' t.site_id desc '; $models_temp = SiteNo::model()->findAll($criteria); //var_dump($models_temp);exit; $criteria->condition = 't.delete_flag = 0 and t.dpid=' . $compayId; $criteria->with = "site"; $criteria->order = ' t.create_at desc '; $models_category = SiteType::model()->findAll($criteria); $this->renderPartial('clientsite', array('models_temp' => $models_temp, 'models_category' => $models_category)); }