public function exacute() { $books = $this->Book->find('all', array('conditions' => array('Book.state' => 'Bet Finish'))); foreach ($books as $book) { $time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $book['Book']['time_zone']))); if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) { $bookdaystate = new BookDayState($book, $time_zone['TimeZone']['value']); if ($bookdaystate->isTimeOut() && $book['Book']['timeover_info'] == false) { /* $content = 'The result has not been selected after 24 hours from the announcement date and time the corresponding book is disabled and all points wagered are returned to all punters. The bookmaker will receive a penalty. Book Title : '.$book['Book']['title'].'<br>Total Bet : '.$book['Book']['bet_all_total'].'<br>Total User : '******'Book']['user_all_count'].' '.'<a href="http://bookbookmaker.com/books'.'/'.$book['Book']['id'].'">http://bookbookmaker.com/books'.'/'.$book['Book']['id'].'</a>'; */ $Email = new CakeEmail('sendGrid'); $Email->template('timeover'); $Email->to($book['User']['mail']); $Email->subject('Bookタイムオーバー bookbookmaker.com'); $Email->viewVars(array('book' => $book)); $Email->send(); $this->Book->seTimeover($book['Book']['id']); } else { } } } }
public function exacute() { $books = $this->Book->find('all', array('conditions' => array('Book.state' => 'Bet Now'))); foreach ($books as $book) { $time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $book['Book']['time_zone']))); if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) { $bookdaystate = new BookDayState($book, $time_zone['TimeZone']['value']); if ($bookdaystate->isBetFinish()) { $this->Book->id = $book['Book']['id']; $this->Book->set('state', 'Bet Finish'); $this->Book->save(); } else { } } } }
public function exacute() { $books = $this->Book->find('all', array('conditions' => array('Book.state' => 'Up Coming'))); foreach ($books as $book) { $time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $book['Book']['time_zone']))); if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) { $bookdaystate = new BookDayState($book, $time_zone['TimeZone']['value']); if ($bookdaystate->isBetNow()) { $this->Book->id = $book['Book']['id']; $this->Book->set('state', 'Bet Now'); $this->Book->save(); $update = array(); $update['book_id'] = $book['Book']['id']; $update['event'] = 'bet_start'; $this->Update->updateInfo($update); } else { } } } }
public function exacute() { $books = $this->Book->find('all', array('conditions' => array('Book.state' => 'Bet Finish'))); foreach ($books as $book) { $time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $book['Book']['time_zone']))); if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) { $bookdaystate = new BookDayState($book, $time_zone['TimeZone']['value']); if ($bookdaystate->isNotSetResult() && $book['Book']['result_time_info'] == false) { $Email = new CakeEmail('sendGrid'); $Email->template('betfinish'); $Email->to($book['User']['mail']); $Email->subject('Bet終了 bookbookmaker.com'); $Email->viewVars(array('book' => $book)); $Email->send(); $this->Book->id = $book['Book']['id']; $this->Book->set('result_time_info', 1); $this->Book->save(); } else { } } } }
public function view($id = null) { //$this->Book->virtualFields = array("usercount"=>"select count(distinct(user_id)) as usercount from bets where bets.book_id = Book.id"); $currentBook = $this->Book->find('first', array('conditions' => array('Book.id' => $id))); //pr($currentBook); //pr($_GET); if (!empty($currentBook)) { $currentBook = $this->bookExtension($currentBook); if (!isset($_GET['format'])) { $this->set('book', $currentBook); $time_zone = $this->Book->TimeZone->find('first', array('conditions' => array('TimeZone.id' => $currentBook['Book']['time_zone']))); if (isset($time_zone['TimeZone']) && isset($time_zone['TimeZone']['value'])) { $bookdaystate = new BookDayState($currentBook, $time_zone['TimeZone']['value']); $this->set('startTime', $bookdaystate->getStartTime()); if (ucfirst($currentBook['Book']['state']) == 'Timeover' || ucfirst($currentBook['Book']['state']) == 'Result Timeover') { $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-timeover'); } else { if (ucfirst($currentBook['Book']['state']) == 'Delete' || ucfirst($currentBook['Book']['state']) == 'Book Delete') { $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-delete'); } else { if (ucfirst($currentBook['Book']['state']) == 'Up Coming') { $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-upcoming'); } else { if (ucfirst($currentBook['Book']['state']) == 'Bet Now') { if ($this->Book->isMakeBook() == false) { $this->Session->setFlash('Please login.'); } $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-betnow'); } else { if (ucfirst($currentBook['Book']['state']) == 'Bet Finish' && !$this->Book->User->isOwner($currentBook['Book']['user_id'])) { $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-betfinish'); } else { if (ucfirst($currentBook['Book']['state']) == 'Bet Finish' && $this->Book->User->isOwner($currentBook['Book']['user_id'])) { $this->set('pagetitle', $currentBook['Book']['title']); $this->render('book-select-result'); } else { if (ucfirst($currentBook['Book']['state']) == 'Result') { $winner = array_filter($currentBook['Content'], function ($item) use($currentBook) { return $item['id'] == $currentBook['Book']['win_contents_id']; }); $this->set('pagetitle', $currentBook['Book']['title']); $this->set('winner', $winner); $this->render('book-result'); } } } } } } } } } else { if ($_GET['format'] == 'json') { foreach ($currentBook['Bet'] as $betKey => $bet) { $currentBet = $this->Book->Bet->find('first', array('conditions' => array('Bet.id' => $bet['id']))); $currentBook['Bet'][$betKey]['user'] = $currentBet['User']; } $this->sendJSON($currentBook); } } } }