/**
  * speed : agents info 
  */
 public function index()
 {
     $where = array('id' => $this->agents_id);
     $user = $this->agents->where($where)->find();
     if ($user) {
         if (!empty($user['qrcode_pic_url'])) {
             $this->assign('qrcode_url', $user['qrcode_pic_url']);
             $this->assign('product_url', pinet_generate_shorturl($user['pic_url_link']));
         } else {
             import("@.ORG.qrcode.QRCodeGenerator");
             $gen = new QRCodeGenerator();
             $product_url = 'http://' . C('wx_handler_server') . U('Fxs/Shop/index', array('fxs_id' => $user['id'], 'token' => $this->token));
             $gen->build($product_url, 'reguser', $this->token, array('comp' => $user['headimgurl']));
             $qrcode_pic_url = $gen->getUrl();
             $this->agents->where($where)->save(array('qrcode_pic_url' => $qrcode_pic_url, 'pic_url_link' => $product_url));
             $this->assign('qrcode_url', $qrcode_pic_url);
             $this->assign('product_url', pinet_generate_shorturl($product_url));
         }
         $payment = $this->payment->where(array('user_id' => $this->agents_id))->find();
         $payinfo = '请填写支付方式';
         if ($payment) {
             $payinfo = $payment['pay_name'] . ':' . $payment['pay_account'];
         }
         $this->assign('payinfo', $payinfo);
         $this->assign('payment', $payment);
         $this->assign('photo', $user['headimgurl']);
         $this->assign('user', $user);
     } else {
         $this->error('该记录不存在', U(MODULE_NAME . '/index'));
     }
     $this->display('info/agents');
 }
 /**
  * Desc :  generate qrcode
  *
  * @since 2014-9-15
  */
 public function qr()
 {
     $partner_id = $this->_get('partner_id');
     $partner_db = M('partner');
     $where = array('id' => $partner_id);
     $partner = $partner_db->where($where)->find();
     if ($partner) {
         if (!empty($partner['qrcode_pic_url'])) {
             $this->assign('qrcode_url', $partner['qrcode_pic_url']);
         } else {
             import("@.ORG.qrcode.QRCodeGenerator");
             $gen = new QRCodeGenerator();
             $product_url = 'http://' . C('wx_handler_server') . U('Wsc/Shop/index', array('partner_id' => $partner_id, 'token' => $this->token));
             //exit($product_url);
             $gen->build($product_url, 'partner', $this->token);
             $qrcode_pic_url = $gen->getUrl();
             $partner_db->where($where)->save(array('qrcode_pic_url' => $qrcode_pic_url));
             $this->assign('qrcode_url', $qrcode_pic_url);
         }
         $this->display('partner/qr');
     } else {
         $this->error('该记录不存在', U(MODULE_NAME . '/partner_index'));
     }
 }
 /**
  * Desc :生成产品二维码图片
  *
  * @author Morgan Zhao
  * @since 2014-9-15
  */
 public function product_qr()
 {
     $product_id = $this->_get('gid');
     $partner_id = $this->_get('bid');
     $this->branch_id = $this->_get('bid');
     $product_db = M('b2c_product');
     $where = array('product_id' => $product_id, 'token' => $this->token, 'branch_id' => $this->branch_id, 'function' => $this->function);
     $product = $product_db->where($where)->find();
     if ($product != false) {
         if (!empty($product['qrcode_pic_url'])) {
             $this->assign('qrcode_url', $product['qrcode_pic_url']);
         } else {
             import("@.ORG.qrcode.QRCodeGenerator");
             $gen = new QRCodeGenerator();
             $product_url = 'http://' . C('wx_handler_server') . U('Wap/Shop/product', array('id' => $product_id, 'bid' => $partner_id, 'token' => $this->token));
             $gen->build($product_url, 'product', $this->token);
             $qrcode_pic_url = $gen->getUrl();
             $product_db->where($where)->save(array('qrcode_pic_url' => $qrcode_pic_url));
             $this->assign('qrcode_url', $qrcode_pic_url);
         }
         $this->display();
     } else {
         $this->error('商品不存在', U(MODULE_NAME . '/products', array('bid' => $this->branch_id)));
     }
 }
 public function qr()
 {
     $ver = $_GET['ver'];
     $store = $this->_post('store');
     $appoint_db = D('appointment');
     $data['develop_name'] = $this->_post('develop_name');
     $data['code'] = 'LgX4xmIYEtvA7b6azux3UQ==';
     $this->token = '20140911';
     //exit($data['address']);
     if ($ver != null) {
         if (!empty($partner['qrcode_pic_url'])) {
             $this->assign('qrcode_url', $partner['qrcode_pic_url']);
         } else {
             import("@.ORG.qrcode.QRCodeGenerator");
             $gen = new QRCodeGenerator();
             //$data['qrcode_pic_url']=$qrcode_pic_url;
             $id = $appoint_db->add($data);
             $product_url = 'http://' . C('wx_handler_server') . U('App/App/activity', array('store' => $store, 'id' => $id));
             $res['qrcode_pic_url'] = $product_url;
             //exit($product_url);
             $gen->build($product_url, 'partner', $this->token);
             $qrcode_pic_url = $gen->getUrl();
             $res['img'] = $qrcode_pic_url;
             $res = $appoint_db->where("id='{$id}'")->save($res);
             $this->assign('qrcode_url', $qrcode_pic_url);
             $this->assign('link', $product_url);
         }
         $this->display('qr');
     } else {
         $this->error('该记录不存在', U(MODULE_NAME . '/qr_code'));
     }
 }
 public function qr()
 {
     $db_lottery = M('lottery');
     $this->token = session('token');
     $lottery = $db_lottery->where(array('token' => $this->token, 'type' => 3, 'status' => array('neq', 3)))->find();
     if ($lottery) {
         import("@.ORG.qrcode.QRCodeGenerator");
         $gen = new QRCodeGenerator();
         $product_url = C('site_url') . U('Wap/Coupons/index', array('coupon_id' => $lottery['id'], 'token' => $this->token));
         $gen->build($product_url, 'coupon', $this->token, array('comp' => ''));
         $qrcode_pic_url = $gen->getUrl();
         $this->assign('link_url', $product_url);
         $this->assign('qrcode_url', $qrcode_pic_url);
     } else {
         $this->error('该记录不存在', U(MODULE_NAME . '/index'));
     }
     $this->display();
 }
 public function compile()
 {
     QRCodeGenerator::addQRCodeToTemplate($this, $this->Template);
 }
 /**
  * Sigleton method.
  */
 public function _addQRCodeToTemplate($objData, $objTemplate)
 {
     if ($objData instanceof Module) {
         $size = deserialize($objData->imgSize);
     } else {
         if (in_array($objData->floating, array('left', 'right'))) {
             $objTemplate->floatClass = ' float_' . $objData->floating;
             $objTemplate->float = 'float:' . $objData->floating . ';';
         }
         $size = deserialize($objData->size);
     }
     $objTemplate->alt = specialchars($objData->alt);
     $objTemplate->fullsize = $objData->fullsize ? true : false;
     $objTemplate->margin = $this->generateMargin(deserialize($objData->imagemargin), 'margin');
     $objTemplate->qrcode = QRCodeGenerator::generate($objData->replaceInsertTags($objData->qrcode), $objData->qrcode_ecclevel, $objData->qrcode_size, $objData->qrcode_margin);
     // Image link
     if (strlen($objData->imageUrl) && TL_MODE == 'FE') {
         $objTemplate->href = $objData->imageUrl;
         $objTemplate->attributes = $objData->fullsize ? LINK_NEW_WINDOW : '';
     } elseif ($objData->fullsize && TL_MODE == 'FE') {
         $objTemplate->href = $objTemplate->qrcode;
         $objTemplate->attributes = ' rel="lightbox"';
     }
     if ($size[0] > 0 || $size[1] > 0) {
         $objTemplate->src = $this->getImage($objTemplate->qrcode, $size[0], $size[1], $size[2]);
         $objTemplate->width = $size[0];
         $objTemplate->height = $size[1];
     } else {
         $objTemplate->src = $objTemplate->qrcode;
     }
     // Image dimensions
     if (($imgSize = @getimagesize(TL_ROOT . '/' . $objTemplate->src)) !== false) {
         $objTemplate->width = $imgSize[0];
         $objTemplate->height = $imgSize[1];
     }
 }