示例#1
0
 public function actionPrint($id)
 {
     $card = Card::findOne($id);
     $type = Ref::getDesc('ctype', $card->type);
     $this->genBarCode($card->no);
     $content = $this->renderPartial('print', ['no' => $card->no, 'type' => $type]);
     $pdf = new Pdf(['content' => $content, 'orientation' => Pdf::ORIENT_PORTRAIT, 'cssFile' => 'css/card.css', 'marginLeft' => 5, 'marginRight' => 5]);
     $pdf->render();
 }
示例#2
0
 public function actionDelete()
 {
     $id = (int) Yii::$app->request->post('id');
     /** @var Card $card */
     $card = Card::findOne(['id' => $id]);
     $result = $card ? $card->delete() : false;
     Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     return ['result' => (bool) $result];
 }
示例#3
0
文件: Sales.php 项目: riros/tests
 public function afterSave($insert, $changedAttributes)
 {
     /**
      * @var Card $card ;
      */
     $card = Card::findOne(['no' => $this->card]);
     $card->activity_date = Yii::$app->formatter->asDatetime(new \DateTime(), 'Y-MM-d HH:i:s');
     $card->save();
 }
示例#4
0
 /**
  * Deletes an existing Sales model.
  * If deletion is successful, the browser will be redirected to the 'index' page.
  * @param string $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     /**
      * @var Sales $sale
      * @var Card $card
      */
     $sale = Sales::findOne(['id', $id]);
     $card = Card::findOne(['no', $sale->card]);
     $card->sum = intval($card->sum) + intval($sale->sum);
     $card->save();
     $this->findModel($id)->delete();
     return $this->redirect(['index']);
 }
示例#5
0
 /**
  * Finds the Card model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Card the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Card::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#6
0
 public function actionGenerate()
 {
     $number = rand(4000000000000000.0, 1.0E+16);
     if (Card::findOne(['number' => $number]) == null) {
         $card = new Card();
         $card->number = $number;
         $card->amount = 10000;
         $card->issue_date = date('Y-m-d H:i');
         $card->expiration_date = date(date('Y') + 1 . '-m-d H:i');
         $card->use_date = date('Y-m-d H:i');
         $card->serial = 'Master card';
         $card->status = 1;
         $card->save();
         $this->redirect('/card');
     }
 }