Ejemplo n.º 1
0
 public function index()
 {
     if (Input::get('coordinates')) {
         $cd = Input::get('coordinates');
         $_cd = explode(',', $cd);
         $wd = $_cd[0];
         $jd = $_cd[1];
         $schools = School::all();
         $ret = array();
         $radius = Input::get('radius') ? Input::get('radius') : 30000;
         foreach ($schools as $v) {
             $tmp = explode(',', $v->coordinates);
             $lat1 = $tmp[0];
             $lng1 = $tmp[1];
             $dst = $this->getDistance($lat1, $lng1, $wd, $jd);
             if ($dst < $radius) {
                 $ret[floor($dst)] = $v;
             }
             ksort($ret);
             $out = [];
             foreach ($ret as $v) {
                 $out[] = $v;
             }
         }
         return $this->output(array('schoolList' => $out));
     } else {
         return $this->output(array('schoolList' => School::orderBy('ord', 'desc')->limit(4)->get()));
     }
 }
Ejemplo n.º 2
0
 public function CheckSchool($id)
 {
     $data = School::find()->where('creator_id = :userid', [':userid' => $id])->one();
     if ($data == null) {
         return false;
     } else {
         return true;
     }
 }
Ejemplo n.º 3
0
 public function getSchools(Request $request)
 {
     $filter = $request->input('filter');
     Log::info($filter);
     if (!$filter) {
         $filter = "";
     }
     $locs = School::where("name", "like", "%" . $filter . "%")->get();
     return $locs;
 }
Ejemplo n.º 4
0
 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;
 }
Ejemplo n.º 5
0
 /**
  * Store a new school.
  *
  * @param AddSchoolFormRequest $request
  * @return Response
  */
 public function addSchool(AddSchoolFormRequest $request)
 {
     $school = School::create(['name' => $request->school, 'town_id' => $request->town]);
     $user = new AuthController();
     $data = $request->all();
     $data['class'] = -1;
     $data['role'] = 1;
     $data['school'] = $school->id;
     $data['is_moderated'] = 1;
     $user->create($data);
     return redirect(route('home'));
 }
Ejemplo n.º 6
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;
 }
Ejemplo n.º 7
0
 /**
  * Show the peace school screen to the user.
  *
  * @return Response
  */
 public function school($location = null)
 {
     //Decide whether details or school list page to open
     if ($location == null) {
         $school = School::orderBy('id')->get();
         return view('publicViewables.school')->with('schools', $school);
     }
     //Convert slugged text to normal spaced text
     if (str_contains($location, '-')) {
         $location = str_replace('-', ' ', $location);
     }
     $school = School::where('location', '=', $location)->first() or abort('404');
     return view('publicViewables.viewSchool')->with('school', $school);
 }
 public function actionIndex()
 {
     $model = new UserForm(['scenario' => 'login']);
     $token = Yii::$app->request->cookies['access'];
     if (Yii::$app->user->isGuest) {
         if ($token != null) {
             if (UserIdentity::validateToken($token)) {
                 Yii::$app->user->login(UserIdentity::findIdentityByAccessToken($token));
             } else {
                 UserIdentity::logout();
             }
         }
     }
     if ($model->load(Yii::$app->request->post()) && $model->validate() && UserIdentity::login($model->login)) {
         $model->getByLogin($model->login);
         if ($model->rememberMe) {
             UserIdentity::regenerateToken($model->id, $model->login, $model->password);
         }
         $schools = School::getByUserId($model->id);
         if (count($schools) == 0) {
             return $this->redirect(['personalarea/index']);
         } else {
             if (count($schools) == 1) {
                 return $this->redirect(['school/index', 'userId' => $model->id, 'schId' => $schools[0]->sid]);
             } else {
                 if (count($schools) > 1) {
                     return $this->redirect(['selectschool']);
                 }
             }
         }
         return $this->render('index', ['model' => $model]);
     } elseif (!$model->load(Yii::$app->request->post())) {
         if (Yii::$app->user->identity != null) {
             $model->login = Yii::$app->user->identity->login;
             $model->password = Yii::$app->user->identity->password;
         } else {
             if ($token != null) {
                 $token = Yii::$app->crypto->decryptToken($token);
                 $model->login = $token['login'];
                 $model->password = $token['password'];
             }
         }
     }
     $this->layout = 'main';
     return $this->render('index', ['model' => $model]);
 }
Ejemplo n.º 9
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSchool()
 {
     return $this->hasOne(School::className(), ['id' => 'school_id']);
 }
Ejemplo n.º 10
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>
Ejemplo n.º 11
0
 /**
  * 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');
 }
Ejemplo n.º 12
0
 /**
  * @param $schoolId
  * @return \Illuminate\Http\JsonResponse
  */
 public function getClasses($schoolId)
 {
     $classes = School::findOrFail($schoolId)->classes;
     return Response::json($classes);
 }
 public function actionStudent($userId, $schId)
 {
     $dataProvider = new LessonsProvider(["sid" => 100, "uid" => $userId, "pagination" => false]);
     $school = School::getById($schId);
     return $this->render('index', ['dataProvider' => $dataProvider, 'models' => $dataProvider->getModels(), 'userdat' => ['userID' => $userId, 'curSchoolID' => $schId], 'schoolName' => $school->schoolName, 'itemView' => 'lesson']);
 }
Ejemplo n.º 14
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',
Ejemplo n.º 15
0
			<div class="col-lg-offset-1 col-lg-11">
				<?php 
echo $form->field($model, 'yearOfBirth')->textArea()->label(false)->dropDownList(DateModel::getYears(), ['prompt' => 'Год']);
?>
			</div>
		</div>
		<?php 
echo $form->field($model, 'phoneInput');
?>
		<?php 
echo $form->field($model, 'country')->dropDownList(CountryModel::getCountries());
?>
		
		
		<?php 
echo $form->field($model, 'school', ['selectors' => ['input' => '#cat-id']])->dropDownList(School::getDropDownList(), ['id' => 'cat-id', 'prompt' => 'Выберите школу']);
?>
		<!--?= $form->field($model, 'school')->dropDownList(['1'=>'test','2'=>School::getDropDownList()], ['id'=>'cat-id'])?-->
		
		<?php 
echo Html::hiddenInput('input-type-1', $model->group, ['id' => 'input-type-1']);
?>
		<?php 
echo Html::hiddenInput('input-type-2', 'Additional value 2', ['id' => 'input-type-2']);
?>
				
		<?php 
echo $form->field($model, 'group', ['selectors' => ['input' => '#subcat-id']])->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'subcat-id'], 'select2Options' => ['pluginOptions' => ['allowClear' => true]], 'pluginOptions' => ['depends' => ['cat-id'], 'placeholder' => Yii::t('registration', 'Groups'), 'initialize' => true, 'url' => Url::to(['/registration/subcat']), 'params' => ['input-type-1', 'input-type-2'], 'loadingText' => Yii::t('registration', 'Loading...')]]);
?>
			
		
Ejemplo n.º 16
0
 public function run()
 {
     DB::table('schools')->delete();
     School::create(['name' => 'Вінницька гімназія', 'town_id' => 2]);
     School::create(['name' => 'Дережицька СЗШ', 'town_id' => 1]);
 }
Ejemplo n.º 17
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSchool()
 {
     return $this->hasOne(School::className(), ['id' => 'location_id'])->via('room');
 }
Ejemplo n.º 18
0
 /**
  * Finds the School model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return School the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = School::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 19
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;
 }
Ejemplo n.º 20
0
 /**
  * Each user can only be affiliated with one school at a time;
  * Admins can change their school at any time.
  * @return \yii\db\ActiveQuery
  */
 public function getSchool()
 {
     return School::findOne($this->schoolId);
 }
Ejemplo n.º 21
0
<div class="affiliation-form">

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

   <?php 
echo Html::activeHiddenInput($model, 'active', ['value' => 1]);
?>

   <?php 
echo Html::activeHiddenInput($model, 'student_id', ['value' => $student->id]);
?>

   <?php 
echo $form->field($model, 'school_id')->dropDownList(School::getMap());
?>

   <?php 
echo $form->field($model, 'role_id')->dropDownList(Role::getMap());
?>

   <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();
?>
Ejemplo n.º 22
0
    <h2><?php 
echo Yii::t('newrequest', 'New Request');
?>
</h2>
	
    <?php 
$form = ActiveForm::begin(['id' => 'newrequest-form', 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]);
?>
	
	<?php 
$this->params['breadcrumbs'] = [['label' => Yii::t('guestlk', 'Guest cabinet'), 'url' => ['guestlk/index', 'username' => $model->username]], $this->title];
?>


		<?php 
echo $form->field($model, 'school')->dropDownList(School::getDropDownList(), ['id' => 'cat-id']);
?>
		
		<?php 
echo Html::hiddenInput('input-type-1', 'Additional value 1', ['id' => 'input-type-1']);
?>
		<?php 
echo Html::hiddenInput('input-type-2', 'Additional value 2', ['id' => 'input-type-2']);
?>
				
		<?php 
echo $form->field($model, 'group')->widget(DepDrop::classname(), ['type' => DepDrop::TYPE_SELECT2, 'options' => ['id' => 'subcat-id'], 'select2Options' => ['pluginOptions' => ['allowClear' => true]], 'pluginOptions' => ['depends' => ['cat-id'], 'placeholder' => Yii::t('registration', 'Groups'), 'initialize' => true, 'url' => Url::to(['/newrequest/subcat']), 'params' => ['input-type-1', 'input-type-2'], 'loadingText' => Yii::t('registration', 'Loading...')]]);
?>
		
		
		<?php 
use app\models\School;
$this->title = Yii::t('school', 'Select school');
$this->params['breadcrumbs'][] = $this->title;
NavBar::begin(['brandLabel' => Yii::t('index', 'Logo'), 'brandUrl' => Yii::$app->homeUrl, 'options' => ['class' => 'navbar-inverse navbar-fixed-top']]);
echo Nav::widget(['options' => ['class' => 'navbar-nav navbar-right'], 'items' => [['label' => 'Информация', 'items' => [['label' => 'О проекте (например)', 'url' => '#'], '<li class="divider"></li>', ['label' => 'Контакты (например)', 'url' => '#']]], Yii::$app->user->isGuest ? ['label' => Yii::t('user', 'Guest')] : ['label' => Yii::t('index', 'Logout') . ' (' . Yii::$app->user->identity->login . ')', 'url' => ['/site/logout'], 'linkOptions' => ['data-method' => 'post']]]]);
NavBar::end();
?>

<h1><?php 
echo Html::encode($this->title);
?>
</h1>

<?php 
$form = ActiveForm::begin(['id' => 'registration-form', 'enableClientValidation' => true, 'options' => ['class' => 'form-horizontal'], 'fieldConfig' => ['template' => "{label}\n<div class=\"col-lg-3\">{input}</div>\n<div class=\"col-lg-8\">{error}</div>", 'labelOptions' => ['class' => 'col-lg-1 control-label']]]);
?>



<?php 
echo $form->field($model, 'school')->dropDownList(School::getDropDownListByUserId(Yii::$app->user->identity->id), ['id' => 'cat-id'])->label(false);
?>

<?php 
echo Html::submitButton(Yii::t('school', 'Next'), ['class' => 'btn btn-primary', 'name' => 'login-button']);
?>



<?php 
ActiveForm::end();
Ejemplo n.º 24
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 
Ejemplo n.º 25
0
 public static function getMap()
 {
     return ArrayHelper::map(School::findAll(['active' => 1]), 'id', 'name');
 }
Ejemplo n.º 26
0
Archivo: City.php Proyecto: araks74/dnb
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getSchools()
 {
     return $this->hasMany(School::className(), ['cityId' => 'id']);
 }