示例#1
1
 public function actionGenHandler()
 {
     $num = $_POST['num'];
     $type = $_POST['type'];
     $arr_no = [];
     for ($i = 0; $i < $num; $i++) {
         $no = Util::next($type);
         if ($no >= 10 && $no < 100) {
             $no = '0' . $no;
         } else {
             if ($no < 10) {
                 $no = '00' . $no;
             }
         }
         $no = $type . $no;
         $arr_no[] = $no;
         $card = new Card();
         $card->no = $no;
         $card->type = $type;
         $card->status = 'A';
         $card->create_dt = date('Y-m-d');
         $card->create_by = \Yii::$app->user->id;
         $card->save();
         $this->genBarCode($no);
     }
     $ty = Ref::getDesc('ctype', $type);
     $content = $this->renderPartial('daily_card', ['arr_no' => $arr_no, 'type' => $ty]);
     $pdf = new Pdf(['content' => $content, 'orientation' => Pdf::ORIENT_PORTRAIT, 'cssFile' => 'css/card.css', 'marginLeft' => 5, 'marginRight' => 5]);
     $pdf->render();
 }
示例#2
0
 /**
  * This command echoes what you have entered as the message.
  *
  * @param string $message the message to be echoed.
  */
 public function actionIndex($message = 'Million')
 {
     $card = new Card();
     //        $post = Yii::$app->request->post();
     //        if (!empty($post)) $new = false;
     //        $card->load($post);
     //        $count = $card->count;
     $c = 50;
     $card->sum = 0;
     $card->status = 0;
     $cdate = Yii::$app->formatter->asDatetime(new \DateTime(), 'Y-MM-dd HH:i:s');
     $card->sn = '1000000';
     $card->activity_date = $cdate;
     $card->deactivation_date = $cdate;
     $card->creation_date = $cdate;
     if ($card->validate()) {
         while ($c-- > 0) {
             $newcard = new Card($card);
             $newcard->count = 1;
             $newcard->sum = rand(1, 1000000);
             $newcard->save();
             echo $c . "\r";
         }
     } else {
         var_dump($card->errors);
     }
     //return $this->render('generator', $param);
     echo $message . "\n";
 }
示例#3
0
 /**
  * Creates a new Card model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Card();
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->number]);
     } else {
         return $this->render('create', ['model' => $model]);
     }
 }
示例#4
0
 public function createCard()
 {
     if (!Auth::check()) {
         return redirect("/");
     }
     if (Auth::user()->Level_id == 1) {
         return redirect('/managementAccount');
     }
     //return \Input::get();
     $dateEscard = preg_split('[-]', \Input::get('date'));
     $BoardId = session()->get('Board');
     $Card = new Card();
     $Card->name = \Input::get('name');
     $Card->detail = \Input::get('detail');
     $Card->color = \Input::get('color');
     $Card->estimate_start = $dateEscard[0];
     $Card->estimate_end = $dateEscard[1];
     if (!empty(\Input::get('preCard'))) {
         $Card->child_id = \Input::get('preCard');
     }
     $Card->priority_id = 1;
     $Card->status_id = \Input::get('status');
     $Card->type_id = 1;
     $Card->Board_id = session()->get('Board');
     $Card->MemberManagement_id = \Input::get('member');
     $Card->save();
     $getCard = Card::where('id', '=', $Card->id)->select('id')->get();
     if (\Input::get('sub') != null) {
         $sub = \Input::get('sub');
         $check = \Input::get('checkL');
         foreach ($sub as $index => $s) {
             $CheckL = new Checklist();
             $CheckL->Card_id = $getCard[0]->id;
             $CheckL->name = $s;
             $CheckL->status = $check[$index];
             $CheckL->save();
         }
     }
     $BoardCheckStart = Board::all()->find($BoardId);
     if ($BoardCheckStart->start_date == null) {
         $BoardCheckStart->start_date = date('Y-m-d');
         $BoardCheckStart->save();
     }
     return redirect("/board/{$BoardId}#/");
 }
 public function actionIndex()
 {
     $decks = Deck::find()->all();
     foreach ($decks as $deck) {
         foreach ($deck->cards as $card) {
             var_dump($card->name);
         }
     }
     exit;
     $endpoint = "https://omgvamp-hearthstone-v1.p.mashape.com/cards";
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'X-Mashape-Key: aIpC7Lq0bvmshWtxepdzWC7ywu85p13p5YcjsnMJjyZDCBCv03'));
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_URL, $endpoint);
     $result = curl_exec($ch);
     curl_close($ch);
     $arr = json_decode($result, true);
     //var_dump(count($arr)); exit();
     foreach ($arr as $set) {
         //echo $set.PHP_EOL;
         foreach ($set as $card) {
             if ($card['type'] == "Minion" || $card['type'] == "Spell" || $card['type'] == "Weapon") {
                 //var_dump($card); exit();
                 $mod_card = new Card();
                 $mod_card->name = $card['name'];
                 $mod_card->orig_id = $card['cardId'];
                 $mod_card->cardSet = $card['cardSet'];
                 $mod_card->type = $card['type'];
                 if (isset($card['faction'])) {
                     $mod_card->faction = $card['faction'];
                 }
                 if (isset($card['rarity'])) {
                     $mod_card->rarity = $card['rarity'];
                 }
                 if (isset($card['cost'])) {
                     $mod_card->cost = $card['cost'];
                 }
                 if (isset($card['attack'])) {
                     $mod_card->attack = $card['attack'];
                 }
                 if (isset($card['health'])) {
                     $mod_card->health = $card['health'];
                 }
                 if (isset($card['text'])) {
                     $mod_card->text = $card['text'];
                 }
                 if (isset($card['flavor'])) {
                     $mod_card->flavor = $card['flavor'];
                 }
                 if (isset($card['artist'])) {
                     $mod_card->artist = $card['artist'];
                 }
                 if (isset($card['collectible'])) {
                     $mod_card->collectible = $card['collectible'];
                 }
                 if (isset($card['elite'])) {
                     $mod_card->elite = $card['elite'];
                 }
                 $mod_card->img = $card['img'];
                 $mod_card->imgGold = $card['imgGold'];
                 $mod_card->locale = $card['locale'];
                 if ($mod_card->save()) {
                     echo "save successful" . PHP_EOL;
                 } else {
                     echo "Save failed" . PHP_EOL;
                     var_dump($mod_card->getErrors());
                 }
                 echo "Done: " . $card['name'] . PHP_EOL;
             }
         }
     }
 }
示例#6
0
 public function actionGen()
 {
     $card = new Card();
     $new = true;
     $post = Yii::$app->request->post();
     if (!empty($post)) {
         $new = false;
     }
     $card->load($post);
     $count = $card->count;
     $param = ['model' => $card, 'cnt' => $count, 'message' => "Готово. <a href='/card'>Перейти к списку.</a>", 'opstatus' => 'success', 'new' => $new];
     if ($count <= 1000000) {
         $c = $count;
         $card->sum = 0;
         $card->status = 0;
         $cdate = date('Y-m-d H:i:s');
         //            $cdate = Yii::$app->formatter->asDatetime(new \DateTime(), 'php:d-M-Y H:i:s');
         $card->creation_date = $cdate;
         if ($card->validate()) {
             while ($c-- > 0) {
                 $newcard = new Card($card);
                 $newcard->count = 1;
                 $newcard->sum = rand(1, 10000);
                 $newcard->save();
             }
         } else {
             $param['message'] = 'Ошибка проверки модели';
             $param['opstatus'] = 'danger';
         }
     } else {
         $param['message'] = 'Слишком большое число карточек > 1000000. Тут нужно использовать менеджер очереди. (например rabbitmq)';
         $param['opstatus'] = 'danger';
     }
     return $this->render('generator', $param);
 }
示例#7
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');
     }
 }