Esempio n. 1
0
 public function CheckSchool($id)
 {
     $data = School::find()->where('creator_id = :userid', [':userid' => $id])->one();
     if ($data == null) {
         return false;
     } else {
         return true;
     }
 }
 public function search($params)
 {
     $query = School::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Esempio n. 3
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = School::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, 'active' => $this->active]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
 /**
  * @return array data for editable school dropdown
  */
 public function actionSelect()
 {
     $query = School::find();
     if (!Yii::$app->user->can('changeSchool')) {
         $allowedSchools = [Yii::$app->user->identity->schoolId];
         $query->where(['id' => $allowedSchools]);
     }
     $models = $query->all();
     $data = [];
     foreach ($models as $m) {
         $data[] = ['value' => $m->id, 'text' => $m->name];
     }
     return $this->renderJson($data);
 }
Esempio n. 5
0
 public function actionGetCitySchools($city_id)
 {
     $schools = \app\models\School::find()->where(['city_id' => $city_id])->all();
     $content = '';
     foreach ($schools as $school) {
         $content .= '<option value="' . $school->id . '">' . $school->name . '</option>';
     }
     return $content;
 }
Esempio n. 6
0
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 175]);
?>

    <?php 
echo $form->field($model, 'short_name')->textInput(['maxlength' => 20]);
?>

    <?php 
echo $form->field($model, 'area_id')->dropDownList(ArrayHelper::map(Area::find()->orderBy('name ASC')->all(), 'id', 'name'));
?>
	
	<?php 
echo $form->field($model, 'school_id')->dropDownList(ArrayHelper::map(School::find()->orderBy('name ASC')->all(), 'id', 'name'));
?>
	
	<?php 
echo $form->field($model, 'active')->checkbox([], false);
?>

    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
		<?php 
echo Html::a('Cancelar', ['index'], ['class' => 'btn btn-danger btn-md', 'style' => 'float:right;']);
?>
    </div>
 /**
  * Edit usertype
  *
  * @return Response
  */
 public function editSchool(Request $request)
 {
     //Validate the Request
     $this->validate($request, ['id' => 'required', 'image' => 'image']);
     $school = School::find($request->id);
     $school->name = $request->name;
     $school->location = $request->location;
     $school->contact_person = $request->contact_person;
     $school->address = $request->address;
     $school->short_description = $request->short_description;
     $school->long_description = $request->long_description;
     if (isset($request['image'])) {
         $imageName = $request['name'] . '.' . $request['image']->getClientOriginalExtension();
         $location = 'staticPages/images/schools/' . $request['location'] . '/';
         $request['image']->move($location, $imageName);
         $school->image_path = url($location . $imageName);
         $school->thumbnail_path = url($location . $imageName);
     }
     $school->save();
     \Session::flash('flash_message', $school->name . " " . $school->location . ' has been updated!');
     \Session::flash('flash_message_level', 'success');
     return Redirect::to('admin/school');
 }
Esempio n. 8
0
<?php

use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use app\models\Region;
use app\models\City;
use app\models\School;
$this->title = 'Регистрация';
$this->params['breadcrumbs'][] = $this->title;
$region = new Region();
$regions = ArrayHelper::toArray(Region::find()->all(), ['app\\models\\Region' => ['id', 'title']]);
$listOfRegions = ArrayHelper::map($regions, 'id', 'title');
$cities = ArrayHelper::toArray(City::find()->all(), ['app\\models\\City' => ['id', 'title']]);
$listOfCities = ArrayHelper::map($cities, 'id', 'title');
$schools = ArrayHelper::toArray(School::find()->where(['city_id' => $model->city])->all(), ['app\\models\\School' => ['id', 'name']]);
$listOfSchools = ArrayHelper::map($schools, 'id', 'name');
$years = range(2014, date("Y") + 4);
/* @var $this yii\web\View */
/* @var $model app\models\User */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="user-form">

    <?php 
$form = ActiveForm::begin();
?>
        

    <?php 
Esempio n. 9
0
/* Custom timepicker widget */
use kartik\time\TimePicker;
use kartik\date\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\Classes */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="classes-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'school_id')->dropdownList(School::find()->select(['name'])->indexBy('id')->column(), ['prompt' => 'Select School']);
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'instructor')->textInput(['maxlength' => true]);
?>

    <?php 
/*echo DatePicker::widget([
      'model' => $model,
      'attribute' => 'date',
      //'language' => 'ru',