Exemplo n.º 1
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire(Almaty $almaty, Astana $astana)
 {
     $city = $this->option('city');
     if ($city == 1) {
         $this->city = $almaty;
     } else {
         $this->city = $astana;
     }
     $data = ['driver' => $this->argument('driver'), 'op' => $this->argument('op'), 'summ' => $this->argument('summ'), 'reason' => $this->argument('reason'), 'time' => $this->argument('time')];
     \App\Models\Operations::on($this->city->db)->insert($data);
 }
Exemplo n.º 2
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Operations::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'using_date' => $this->using_date, 'debit_kredit' => $this->debit_kredit]);
     $query->andFilterWhere(['like', 'serial_number', $this->serial_number]);
     return $dataProvider;
 }
Exemplo n.º 3
0
 public function actionAdmin()
 {
     $postData = Yii::$app->getRequest()->post();
     // Проверка свободно ли имя (ajax)
     if (isset($postData['checkUserName'])) {
         $user = Users::find()->where(['name' => $postData['checkUserName']])->one();
         return $user === null;
     }
     // Добавление пользователя
     if (isset($postData['Users'])) {
         Users::addUser($postData['Users']['name']);
         $this->goHome();
     }
     // Добавление денег на счёт (ajax)
     if (isset($postData['addMoneyTo'])) {
         echo Operations::giveMoney($postData['addMoneyTo'], $postData['moneyToAdd']);
         exit;
     }
     // Все операции
     $operations = Operations::getList();
     // Все пользователи
     $users = Users::find()->orderBy('id')->asArray()->all();
     return $this->render('admin', ['operations' => $operations, 'users' => $users, 'model' => new Users()]);
 }
Exemplo n.º 4
0
 /**
  * Finds the Operations model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Operations the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Operations::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }