Esempio n. 1
0
 /**
  * Updates a particular model.
  * If update is successful, the browser will be redirected to the 'view' page.
  * @param integer $id the ID of the model to be updated
  */
 public function actionUpdate($new = false)
 {
     if ($new === true) {
         $model = new Games();
     } else {
         $model = $this->loadModel($_GET['id']);
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Games'])) {
         $model->attributes = $_POST['Games'];
         if ($model->save()) {
             $this->redirect(array('index'));
         } else {
             $this->addFlashMessage($model->errors, 'error');
         }
     }
     if (isset($_POST['setting'])) {
         $var = $_POST;
         extract($var);
         $connection = Yii::app()->db;
         $sql = "UPDATE crzsettings SET value='{$get_more_than_bet_freq}' where name='get_more_than_bet_freq'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$max_part_of_bank_at_once}' where name='max_part_of_bank_at_once'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$max_gain_at_once}' where name='max_gain_at_once'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$max_gain_in_double}' where name='max_gain_in_double'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$max_gain_on_rope}' where name='max_gain_on_rope'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$max_super_prize}' where name='max_super_prize'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus_freq}' where name='bonus_freq'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$banana_freq}' where name='banana_freq'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus_min}' where name='bonus_min'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus_max}' where name='bonus_max'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$double_freq}' where name='double_freq'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus2_50}' where name='bonus2_50'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus2_100}' where name='bonus2_100'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus2_150}' where name='bonus2_150'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus2_200}' where name='bonus2_200'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         $sql = "UPDATE crzsettings SET value='{$bonus2_250}' where name='bonus2_250'";
         $command = $connection->createCommand($sql);
         $rowCount = $command->execute();
         for ($i = 1; $i <= 9; $i++) {
             for ($j = 1; $j < 4; $j++) {
                 if (isset(${'wl' . "{$i}" . "{$j}"})) {
                     $per = ${'wl' . "{$i}" . "{$j}"};
                     $sql = "UPDATE crzsettings SET value='" . $per . "' where name='wl,{$i},{$j}'";
                     $command = $connection->createCommand($sql);
                     $rowCount = $command->execute();
                     if (isset(Yii::app()->session["wl" . "{$i}" . "{$j}"])) {
                         unset(Yii::app()->session["wl" . "{$i}" . "{$j}"]);
                     }
                 }
             }
         }
         $this->refresh();
     }
     if (isset($_POST['GameSettings'])) {
         $vars = $_POST['GameSettings'];
         if (!empty($vars)) {
             foreach ($vars as $key => $val) {
                 $gs = GameSettings::model()->find(array('condition' => 'game_id=:game_id and name=:name', 'params' => array(':game_id' => $model->id, ':name' => $key)));
                 if ($gs) {
                     $gs->value = $val;
                     $gs->save();
                 }
             }
         }
         $this->refresh();
     }
     $this->render('update', array('model' => $model));
 }