예제 #1
0
 public function getBetSlipData()
 {
     $userId = $this->getUserId();
     if (!isset($userId)) {
         return;
     }
     $model = new Model_BetSlipModel();
     $model->getBetSlipOdds();
     $model->addQuery('where', array('where_condition' => 'bp.bet_slip_id=' . (int) $this->getBetSlipId()));
     $model->addQuery('where', array('where_condition' => 'bp.user_id_FK=' . $userId));
     return $model->executeQuery('fetchAssoc');
 }
예제 #2
0
 public function update($forceUpdateFlag = false)
 {
     $checkIfModelIsUpdatebale = new Model_EventBetsModel();
     $checkIfModelIsUpdatebale->load($this->getEventBetsId());
     if ($checkIfModelIsUpdatebale->getCorrectType() != null) {
         return $this->setValidationError('update', 'Correct Type is set, Event can be updated anymore');
     }
     parent::update($forceUpdateFlag);
     $this->load($this->getEventBetsId());
     if ($this->getCorrectType() != null) {
         $betTypesModel = new Model_BetsTypeModel();
         $betTypesModel->load(array('event_bets_id_FK' => $this->getEventBetsId(), 'event_types_value_id_FK' => $this->getCorrectType()));
         $betTypesModel->addQuery('select', array('table' => $betTypesModel->getTableName()));
         $betTypesModel->addQuery('where', array('where_condition' => 'event_bets_id_FK=' . $this->getEventBetsId()));
         $betTypesModelCollection = new Core_Model_Adapter_ModelCollection();
         $betTypesModelCollection->getModelCollection($betTypesModel);
         $betTypesKeys = $betTypesModelCollection->getKeysArray('bet_types_id');
         $odds = new Model_OddValueModel();
         $odds->addQuery('update', array('table' => $odds->getTableName(), 'columns' => 'is_correct=0'));
         $odds->addQuery('where', array('where_condition' => 'bet_types_id_FK in (' . implode(',', $betTypesKeys) . ')'));
         $odds->executeQuery();
         $odds->load(array('bet_types_id_FK' => $betTypesModel->getBetTypesId()));
         $odds->setIsCorrect(1);
         $odds->update();
         $odds->addQuery('select', array('table' => $odds->getTableName()));
         $odds->addQuery('where', array('where_condition' => 'bet_types_id_FK in (' . implode(',', $betTypesKeys) . ')'));
         $oddsValuesCollection = new Core_Model_Adapter_ModelCollection();
         $oddsValuesCollection->getModelCollection($odds);
         $oddValuesKeys = $oddsValuesCollection->getKeysArray('odd_value_id');
         $betSlip = new Model_BetSlipModel();
         $betSlip->addQuery('update', array('table' => $betSlip->getTableName(), 'columns' => 'finished = finished+1'));
         $betSlip->addQuery('where', array('where_condition' => 'bet_slip_id in (select bet_slip_id_FK from bet_slip_odds where odd_value_id_FK in  (' . implode(',', $oddValuesKeys) . '))'));
         $betSlip->executeQuery();
         $betSlip->setStatusOne();
         $betSlip->proccessBetSlips();
         $betSlip->setStatusTwo();
     }
 }
예제 #3
0
파일: UserBets.php 프로젝트: berksonj/bet
 private function setUserBetsTable()
 {
     $user = new Core_Auth_User();
     $role = $user->getRole();
     $userId = $this->getUserId();
     if ($role == 'admin' || $role == 'superadmin') {
         $bets = new Extension_View_Yui35_DataTableEdit();
         $bets->isAddButtonEnabled(false);
         $bets->isEditEnabled(false);
     } else {
         $bets = new Extension_View_Yui35_DataTablePF();
         if ($userId === null) {
             return;
         }
     }
     $table = $bets->getTable();
     $model = new Model_BetSlipModel();
     $model->getBetSlipsTransaction();
     if ($userId !== null) {
         $model->addQuery('where', array('where_condition' => 'bs.user_id_FK=' . (int) $userId));
     }
     $model->addQuery('order', array('order' => implode($model->getPrimaryKeys(), ",") . ' DESC'));
     $model->addQuery('limit', array('limit' => 20));
     $bets->setModel($model);
     $url = Application::getRouter()->getFullUrl(array('controller' => 'servicehtml', 'action' => 'view'));
     $table->addColumn(array('key' => 'bet_slip_id', 'label' => 'ID'));
     $table->addColumn(array('key' => 'date_created', 'label' => 'Played'));
     $table->addColumn('{key:status,label: "Status",allowHTML:true,formatter:function(o){if(o.data.status==2){return "Finished"} else {return "In Play"}}}', false, 'transaction_type_id_FK');
     $table->addColumn('{key:"bet_slip_id",label: "Details",allowHTML:true,formatter:"<a class=\'systemSubServiceLinkBets\' servicehtml=\'' . $url . '&view=View_Frontend_UserBetSlip&bet_slip_id={value}\' href=\'javascript:void(0)\' >View</a>"}', false, 'bet_slip_id_view');
     $table->addColumn(array('key' => 'money', 'label' => 'Money'));
     $status = new Extension_View_Html_Form_Elements_Select();
     $status->setModel(array(array('label' => 'Finished', 'value' => '2'), array('label' => 'In play', 'value' => '0')));
     $status->setOptionLabelKey('label');
     $status->setOptionValueKey('value');
     $status->setAttributes(array('name' => 'status', 'type' => 'text'));
     $status->setPrependHtml('Status: ');
     $bets->addFilter($status);
     $filterCalendar = new Extension_View_Html_Form_Elements_Calendar();
     $filterCalendar->setPrependHtml('<br />Date from:');
     $filterCalendar->setAttribute('name', 'date_created');
     $bets->addFilter($filterCalendar, array('group' => 'added', 'operator' => 'and', 'comparison' => '>'));
     $filterCalendar = new Extension_View_Html_Form_Elements_Calendar();
     $filterCalendar->setPrependHtml('Date to:');
     $filterCalendar->setAttribute('name', 'date_created');
     $bets->addFilter($filterCalendar, array('group' => 'added', 'operator' => 'and', 'comparison' => '<'));
     $filterMoney = new Extension_View_Html_Form_Elements_Input();
     $filterMoney->setPrependHtml('<br />Money from:');
     $filterMoney->setAttribute('name', 'money');
     $bets->addFilter($filterMoney, array('group' => 'money', 'operator' => 'and', 'comparison' => '>'));
     $filterMoney = new Extension_View_Html_Form_Elements_Input();
     $filterMoney->setPrependHtml('Money to:');
     $filterMoney->setAppendHtml('</br>');
     $filterMoney->setAttribute('name', 'money');
     $bets->addFilter($filterMoney, array('group' => 'money', 'operator' => 'and', 'comparison' => '<'));
     if ($role == 'admin' || $role == 'superadmin') {
         $userIdFiterId = new Extension_View_Html_Form_Elements_Input();
         $userIdFiterId->setAttributes(array('type' => 'hidden', 'name' => 'bs.user_id_FK', 'value' => $userId, 'class' => 'filterInput'));
         $bets->addFilter($userIdFiterId);
         $method = new Extension_View_Html_Form_Elements_Input();
         $method->setAttributes(array('type' => 'hidden', 'name' => 'method', 'value' => 'getBetSlipsTransaction', 'class' => 'filterInput'));
         $bets->addAdditionalFilterElement($method);
     } else {
         $method = new Extension_View_Html_Form_Elements_Input();
         $method->setAttributes(array('type' => 'hidden', 'name' => 'method', 'value' => 'getBetSlipsTransactionByUser', 'class' => 'filterInput'));
         $bets->addAdditionalFilterElement($method);
     }
     $this->userBetsTable = $bets;
 }