Example #1
0
 /**
  * 参数必须严格按照格式要求输入,不然不插入数据而且还不报错
  * @param  string  $category        [description]
  * @param  string  $reference       [description]
  * @param  string  $val             [description]
  * @param  boolean $update_plus_one [description]
  * @return [type]                   [description]
  */
 public static function handleData($category, $reference, $val = 'SYSTEM')
 {
     $dic_id = $category . ":" . $reference;
     $dictionary = Dictionary::findOne($dic_id);
     if (is_null($dictionary)) {
         self::insertLine($category, $reference, $val);
     } else {
         if ($val == 'SYSTEM') {
             $connection = \Yii::$app->db;
             $command = $connection->createCommand('UPDATE ' . self::tableName() . ' SET auto= auto + 1 WHERE dic_id = "' . $dic_id . '"');
             $command->execute();
         } else {
             if ($dictionary->val != 'SYSTEM') {
                 $dictionary->val = $val;
                 $dictionary->save();
             }
         }
     }
 }
Example #2
0
 /**
  * start MPDF
  */
 protected function createMpdf($view, $isfac = false)
 {
     $data = Yii::$app->request->get();
     if (isset($data['order_id'])) {
         $order_id = $data['order_id'];
         $connection = \Yii::$app->db;
         $command = $connection->createCommand('SELECT * FROM orders WHERE order_id=' . $order_id);
         $order = $command->queryOne();
         $user = $connection->createCommand('SELECT * FROM customer WHERE id =' . $order['action_user'])->queryOne();
         $ordergoods = $connection->createCommand('SELECT * FROM order_goods WHERE order_id =' . $order_id)->queryAll();
         if ($isfac && $order['fac_no'] == 0) {
             Dictionary::handleData("system", "factory_no");
             $dic = Dictionary::findOne("system:factory_no");
             $fac_no = $dic->auto;
             $order_model = Orders::findOne($order_id);
             $order_model->fac_no = $fac_no;
             $order_model->save();
             $order['fac_no'] = $fac_no;
         }
         $mpdf = new Pdf();
         $header = $this->renderPartial('mpdf/header', ['title' => 'nagoya']);
         $footer = $this->renderPartial('mpdf/footer');
         $mpdf->setHeader($header);
         //设置PDF页眉内容
         $mpdf->setFooter($footer);
         //设置PDF页脚内容
         $content = $this->renderPartial($view, ['order' => $order, 'ordergoods' => $ordergoods, 'user' => $user]);
         $mpdf->Output($content);
         exit;
     } else {
         echo "缺少参数";
         exit;
     }
 }