/**
  * Get the stations with their products
  *
  * @return \Illuminate\Database\Eloquent\Collection|static[]
  */
 public function getStationsWithProducts()
 {
     return Station::with(['products' => function ($q) {
         $q->select('id');
         $q->orderBy('sort');
     }])->get();
 }
 /**
  * Retrieve the details for a specific commodity
  * @param integer $id
  * @return array
  */
 public function actionView($id = NULL)
 {
     if ($id === NULL) {
         throw new HttpException(400, 'Missing ID parameter');
     }
     $query = Station::find()->where(['id' => $id]);
     return ResponseBuilder::build($query, 'stations', Yii::$app->request->get('sort', 'name'), Yii::$app->request->get('order', 'asc'));
 }
 public function destroy($id)
 {
     $station = Station::where('id', $id)->first();
     if (!$station) {
         return response()->not_found('Estacion no encontrada');
     } else {
         $station->delete();
         return response()->json(['message' => 'Estacion ha sido eliminada']);
     }
 }
示例#4
0
 private function validateUnique()
 {
     $stationDuplicated = Station::where('name', $this->name)->where('state', $this->state);
     if ($this->id != null) {
         $stationDuplicated->where('id', '!=', $this->id);
     }
     if ($stationDuplicated->first()) {
         return false;
     } else {
         return true;
     }
 }
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Station::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(['station_id' => $this->station_id]);
     $query->andFilterWhere(['like', 'station_name', $this->station_name]);
     return $dataProvider;
 }
示例#6
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStations()
 {
     return $this->hasMany(Station::className(), ['system_id' => 'id']);
 }
示例#7
0
$this->title = 'Wagons';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="wagon-index">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>
    <?php 
// echo $this->render('_search', ['model' => $searchModel]);
?>

    <p>
        <?php 
echo Html::button('Thêm toa', ['value' => Url::to('wagon/create'), 'class' => 'btn btn-success', 'id' => 'modalButton']);
?>
    </p>

    <?php 
Modal::begin(['header' => '<h4>THÊM TOA XE</h4>', 'id' => 'modal', 'size' => 'modal-lg']);
echo "<div id='modalContent'></div>";
Modal::end();
?>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'wagon_number', 'created_year', ['attribute' => 'start_date', 'value' => 'start_date', 'filter' => DatePicker::widget(['model' => $searchModel, 'attribute' => 'start_date', 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']])], ['attribute' => 'wagon_status_id_status', 'value' => 'wagonStatusIdStatus.name_of_status', 'filter' => Html::activeDropDownList($searchModel, 'wagon_status_id_status', ArrayHelper::map(WagonStatus::find()->all(), 'status_id', 'name_of_status'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['attribute' => 'station_station_id', 'value' => 'stationStation.station_name', 'filter' => Html::activeDropDownList($searchModel, 'station_station_id', ArrayHelper::map(\app\models\Station::find()->all(), 'station_id', 'station_name'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['attribute' => 'kind_of_wagon_kind_id', 'value' => 'kindOfWagonKind.kind_name', 'filter' => Html::activeDropDownList($searchModel, 'kind_of_wagon_kind_id', ArrayHelper::map(\app\models\KindOfWagon::find()->all(), 'kind_id', 'kind_name'), ['class' => 'form-control', 'prompt' => 'Please select...'])], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getStation()
 {
     return $this->hasOne(Station::className(), ['id' => 'station_id']);
 }
示例#9
0
    <?php 
echo $form->field($model, 'created_year')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'start_date')->widget(DatePicker::className(), ['inline' => false, 'clientOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>

    <?php 
echo $form->field($model, 'wagon_status_id_status')->dropDownList(ArrayHelper::map(WagonStatus::find()->all(), 'status_id', 'name_of_status'), ['prompt' => 'Trạng thái toa...']);
?>



    <?php 
echo $form->field($model, 'station_station_id')->dropDownList(ArrayHelper::map(Station::find()->all(), 'station_id', 'station_name'), ['prompt' => 'Chọn ga...']);
?>
    <?php 
echo $form->field($model, 'kind_of_wagon_kind_id')->dropDownList(ArrayHelper::map(KindOfWagon::find()->all(), 'kind_id', 'kind_name'), ['prompt' => 'Chọn loại toa...']);
?>



    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? 'Create' : 'Update', ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
 /**
  * The object parser for EDDB stations
  * @return function
  */
 private function getStationsObjectParser()
 {
     return function ($obj) {
         // Remove keys we don't want, and extract them as variables to the symbols table
         $exportKeys = ['economies', 'listings', 'import_commodities', 'export_commodities', 'prohibited_commodities', 'updated_at'];
         foreach ($exportKeys as $key) {
             ${$key} = $obj[0][$key];
             unset($obj[0][$key]);
         }
         $model = Station::find()->where(['id' => $obj[0]['id']])->one();
         if ($model === NULL) {
             $model = new Station();
         } else {
             if ($model->updated_at + 43200 >= time()) {
                 // If the model is less than 12 hours old, skip it.
                 $this->stdOut('.');
                 return;
             }
         }
         $this->stdOut('Importing station: ');
         $this->stdOut("{$obj[0]['name']} :: {$obj[0]['id']}\n", Console::BOLD);
         // Update the stations listing
         foreach ($obj[0] as $name => $value) {
             if ($model->hasAttribute($name)) {
                 $model->{$name} = $value;
             }
         }
         $model->save();
         $db = Yii::$app->db;
         // Update the economies listing
         $db->createCommand('DELETE FROM station_economies WHERE station_id = :station_id')->bindValue(':station_id', $obj[0]['id'])->execute();
         foreach ($economies as $economy) {
             $model = new StationEconomy();
             $model->attributes = ['station_id' => $obj[0]['id'], 'name' => $economy];
             $model->save();
         }
         foreach (['listings', 'import_commodities', 'export_commodities', 'prohibited_commodities'] as $k) {
             $this->importStationCommodity($obj[0], $k, new StationCommodity(), ${$k});
         }
     };
 }
 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return \Illuminate\Http\Response
  */
 public function destroy($sessionId = null, $examenId = null, $stationId = null)
 {
     Station::whereIdStation($stationId)->delete();
     return redirect('/session/' . $sessionId . '/examen/' . $examenId . '/station');
 }
示例#12
0
 public function getStation($stationId)
 {
     return Station::where('id_Station', '=', $stationId)->join('Banque', 'Banque.id_Banque', '=', 'Station.id_Banque')->first();
 }
示例#13
0
 public function run()
 {
     $station = Station::create(['name' => 'Pizza Oven', 'color' => 'D4B46A', 'type_id' => 1]);
     $product = Product::find(6);
     $station->products()->save($product);
 }
示例#14
0
 function calculeNoteExamen($id_Examen)
 {
     $note_Examens = Note_Examen::whereIdExamen($id_Examen)->get();
     foreach ($note_Examens as $note_Examen) {
         $note_Examen_Note = 0;
         $note_Stations = Note_Station::whereIdNoteExamen($note_Examen->id_Note_Examen)->get();
         foreach ($note_Stations as $note_Station) {
             $note_Items = Note_Item::whereIdNoteStation($note_Station->id_Note_Station)->get();
             $note_Station_Note = 0;
             foreach ($note_Items as $note_Item) {
                 if ($note_Item->note == 1) {
                     $note_Station_Note += Item::whereIdItem($note_Item->id_Item)->first()->valeur;
                 }
             }
             $note_Station->note = $note_Station_Note;
             $note_Station->save();
             $note_Examen_Note += $note_Station_Note * Station::whereIdStation($note_Station->id_Station)->first()->ponderation / 100;
         }
         $note_Examen->note = $note_Examen_Note;
         $note_Examen->save();
     }
 }
 /**
  * Finds the Station model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Station the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Station::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }