Ejemplo n.º 1
0
 public function actionView($id)
 {
     $model = Video::findOne($id);
     $course = $model->course;
     $author = $course->author;
     return $this->render('view', ['model' => $model, 'course' => $course, 'author' => $author, 'chapters' => Course::getVideoList($course->id)]);
 }
Ejemplo n.º 2
0
 /**
  * 课程详细页面
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = Course::findOne($id);
     //        $dataProvider = new ActiveDataProvider([
     //            'query'      => $model->getVideos(),
     //        ]);
     //var_dump(Course::getVideoList($model->id));
     return $this->render('view', ['model' => $model, 'author' => $model->getAuthor(), 'chapters' => Course::getVideoList($model->id)]);
 }
Ejemplo n.º 3
0
 /**
  * 发布教程
  */
 public function actionRelease()
 {
     $model = new Course();
     $classify = Classify::find()->all();
     $classify_arr = array();
     foreach ($classify as $k => $v) {
         $classify_arr[$v->id] = $v->name;
     }
     if (Yii::$app->request->post()) {
         $model->title = $_POST['Course']['title'];
         $model->type = $_POST['Course']['type'];
         $model->content = $_POST['Course']['content'];
         $model->create_time = time();
         if ($model->save()) {
             return $this->redirect('index');
         }
     }
     return $this->render('release', ['model' => $model, 'arr' => $classify_arr]);
 }
Ejemplo n.º 4
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'facility_id' => $this->facility_id, 'holes' => $this->holes]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     return $dataProvider;
 }
Ejemplo n.º 5
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Course::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'type' => $this->type, 'create_time' => $this->create_time]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
Ejemplo n.º 6
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params, $conditions = [])
 {
     $query = Course::find()->where($conditions);
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['updated_at' => SORT_DESC]]]);
     $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, 'created_at' => $this->created_at, 'updated_at' => $this->updated_at, 'user_id' => $this->user_id, 'course_terms' => $this->course_terms]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'content', $this->content])->andFilterWhere(['like', 'video_url', $this->video_url])->andFilterWhere(['like', 'excerpt', $this->excerpt])->andFilterWhere(['like', 'image', $this->image]);
     return $dataProvider;
 }
Ejemplo n.º 7
0
 /**
  *  @return  array id,name pairs
  */
 public static function getCourseList($with_tees = false)
 {
     $models = Course::find()->all();
     $list = [];
     foreach ($models as $model) {
         if ($with_tees) {
             if ($model->hasTees()) {
                 $list[$model->id] = $model->facility->name . ', ' . $model->name;
             }
         } else {
             $list[$model->id] = $model->facility->name . ', ' . $model->name;
         }
     }
     return $list;
 }
Ejemplo n.º 8
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCourses()
 {
     return $this->hasMany(Course::className(), ['facility_id' => 'id']);
 }
Ejemplo n.º 9
0
use common\models\Hole;
use common\models\Course;
use common\models\Tees;
use common\models\Competition;
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
use yii\helpers\Html;
use yii\helpers\Url;
use kartik\detail\DetailView;
/* @var $this yii\web\View */
/* @var $model app\models\Tees */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Facilities'), 'url' => ['facility/index']];
$this->params['breadcrumbs'][] = ['label' => $model->course->facility->name, 'url' => ['facility/view', 'id' => $model->course->facility_id]];
$this->params['breadcrumbs'][] = ['label' => $model->course->name, 'url' => ['course/view', 'id' => $model->course->id]];
$this->params['breadcrumbs'][] = $this->title . ' (' . Yii::t('igolf', ucfirst($model->color)) . ')';
?>
<div class="tees-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h2>' . $model->name . '</h2>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => [['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'label' => Yii::t('igolf', 'Course'), 'items' => ArrayHelper::map(Course::find()->asArray()->all(), 'id', 'name'), 'value' => $model->course->name], 'name', ['attribute' => 'color', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Yii::$app->params['tees_colors'], 'value' => Yii::t('igolf', ucfirst($model->color))], 'par', ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], ['attribute' => 'gender', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Tees::getLocalizedConstants('GENDER_')], ['attribute' => 'category', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Tees::getLocalizedConstants('CATEGORY_')], ['attribute' => 'front_back', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Tees::getLocalizedConstants('TEE_'), 'visible' => $model->holes == 9], 'course_rating', 'slope_rating']]);
?>

<?php 
//TabularForm requires that dataProvider is build from Model::find()
$dataProvider = new ActiveDataProvider(['query' => $model->getHoles()]);
echo $this->render('../hole/_updates', ['dataProvider' => $dataProvider, 'tees' => $model]);
?>

</div>
Ejemplo n.º 10
0
?>

    <?php 
echo $form->field($model, 'gender')->radioList($model::getLocalizedConstants('GENDER_'), ['inline' => true]);
?>

    <?php 
echo $form->field($model, 'registration_special')->dropDownList(['' => ''] + $model::getLocalizedConstants('SPECIAL_'));
?>

	<?php 
if ($model->competition_type == $model::TYPE_MATCH) {
    ?>

    <?php 
    echo $form->field($model, 'course_id')->dropDownList(Course::getCourseList(true));
    ?>

	<?php 
    echo $form->field($model, 'holes')->dropDownList(array(18 => '18', 9 => '9'));
    ?>

	<div class='row'>
		<div class='col-lg-4'>
	    <?php 
    echo $form->field($model, 'start_date')->widget(DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]])->label(Yii::t('igolf', 'Start Date &amp; Time'));
    ?>
		</div>

		<div class='col-lg-8'>
		<?php 
Ejemplo n.º 11
0
}
array_pop($this->params['breadcrumbs']);
$this->params['breadcrumbs'][] = $this->title;
$recurrence = $model->recurrence;
if ($model->recurrence) {
    // strips "RRULE:" at begining of string
    $str = strpos($model->recurrence, 'RRULE:') === 0 ? substr($model->recurrence, 6) : $model->recurrence;
    $rrule = new Recurr\Rule($str);
    $textTransformer = new Recurr\Transformer\TextTransformer();
    $recurrence = ucfirst($textTransformer->transform($rrule));
}
?>
<div class="competition-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . Yii::t('igolf', $model->competition_type) . ' ' . $model->name . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => ['name', 'description', ['attribute' => 'parent_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => $model->getParentCandidates(), 'label' => Yii::t('igolf', 'Parent'), 'value' => $model->parent ? $model->parent->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['view', 'id' => $model->parent_id]) : '', 'visible' => $model->competition_type != Competition::TYPE_SEASON, 'format' => 'raw'], ['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'label' => Yii::t('igolf', 'Course'), 'items' => Course::getCourseList(true), 'value' => $model->course ? $model->course->getFullName() . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['course/view', 'id' => $model->course_id]) : '', 'format' => 'raw'], ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], ['attribute' => 'rule_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + Rule::find()->where(['competition_type' => $model->competition_type])->asArray()->all(), 'id', 'name'), 'value' => $model->rule->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['rule/view', 'id' => $model->rule_id]), 'format' => 'raw'], ['attribute' => 'final_rule_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + Rule::find()->where(['competition_type' => $model->competition_type])->asArray()->all(), 'id', 'name'), 'value' => $model->final_rule_id ? $model->finalRule->name . Html::a(' <span class="glyphicon glyphicon-share"></span>', ['rule/view', 'id' => $model->final_rule_id]) : '', 'format' => 'raw'], ['attribute' => 'start_date', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_begin ? new DateTime($model->start_date) : ''], ['attribute' => 'recurrence', 'format' => 'raw', 'type' => DetailView::INPUT_TEXT, 'value' => $recurrence], ['attribute' => 'registration_begin', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_begin ? new DateTime($model->registration_begin) : ''], ['attribute' => 'registration_end', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_end ? new DateTime($model->registration_end) : ''], 'handicap_min', 'handicap_max', 'age_min', 'age_max', ['attribute' => 'gender', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => ''] + Competition::getLocalizedConstants('GENDER_')], 'max_players', ['attribute' => 'registration_special', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => ''] + Competition::getLocalizedConstants('SPECIAL_')], 'registration_time', 'flight_size', 'flight_time', ['attribute' => 'status', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Competition::getLocalizedConstants('STATUS_')]]]);
?>

<?php 
if (in_array($model->competition_type, [Competition::TYPE_SEASON, Competition::TYPE_TOURNAMENT])) {
    switch ($model->competition_type) {
        case Competition::TYPE_SEASON:
            $searchModel = new TournamentSearch();
            $dataProvider = $searchModel->search(['TournamentSearch' => ['parent_id' => $model->id]]);
            $type = Competition::TYPE_TOURNAMENT;
            break;
        case Competition::TYPE_TOURNAMENT:
            $searchModel = new MatchSearch();
            $dataProvider = $searchModel->search(['MatchSearch' => ['parent_id' => $model->id]]);
            $type = Competition::TYPE_MATCH;
            break;
Ejemplo n.º 12
0
 public function actionChapterlist()
 {
     \yii::$app->response->format = \yii\web\Response::FORMAT_JSON;
     $course_id = \Yii::$app->request->post('course_id');
     if ($course_id) {
         return Course::getChaptersByCourse($course_id);
     }
     return [];
 }
Ejemplo n.º 13
0
 /**
  * Finds the Course model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Course the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Course::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 14
0
 public function actionTees()
 {
     $out = [];
     if (isset($_POST['depdrop_parents'])) {
         $parents = $_POST['depdrop_parents'];
         if ($parents != null) {
             $course_id = $parents[0];
             if ($course = Course::findOne($course_id)) {
                 $selected = null;
                 foreach ($course->getTeesWithHoles() as $tees) {
                     if (!$selected) {
                         $selected = $tees->id;
                     }
                     $out[] = ['id' => $tees->id, 'name' => $tees->name];
                 }
             }
             echo Json::encode(['output' => $out, 'selected' => '']);
             return;
         }
     }
     echo Json::encode(['output' => '', 'selected' => '']);
 }
Ejemplo n.º 15
0
<?php

use kartik\detail\DetailView;
use yii\helpers\ArrayHelper;
use common\models\Course;
use common\models\Practice;
use yii\helpers\Url;
/* @var $this yii\web\View */
/* @var $model app\models\Practice */
?>
<div class="practice-view">
	
    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . $this->title . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => [['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'options' => ['id' => 'course-id'], 'items' => ArrayHelper::map(Course::find()->asArray()->all(), 'id', 'name'), 'value' => $model->course ? $model->course->name : ''], ['attribute' => 'tees_id', 'type' => DetailView::INPUT_DEPDROP, 'value' => $model->tees ? $model->tees->name : '', 'widgetOptions' => ['pluginOptions' => ['depends' => ['course-id'], 'placeholder' => 'Select...', 'url' => Url::to(['/golfer/practice/tees'])], 'data' => $model->tees ? [$model->tees_id => $model->tees->name] : []]], ['attribute' => 'start_time', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]], ['attribute' => 'start_hole', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(1 => '1', 10 => '10')], ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], 'handicap', ['attribute' => 'status', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Practice::getLocalizedConstants('STATUS_')]]]);
?>

</div>
Ejemplo n.º 16
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCourses()
 {
     return $this->hasMany(Course::className(), ['course_terms' => 'id']);
 }
Ejemplo n.º 17
0
use yii\helpers\Html;
use yii\helpers\Url;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\Practice */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="practice-form">

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

    <?php 
echo $form->field($model, 'course_id')->dropDownList(Course::getCourseList(), ['id' => 'course-id']);
?>

    <?php 
echo $form->field($model, 'tees_id')->widget(DepDrop::classname(), ['options' => ['id' => 'tees-id'], 'pluginOptions' => ['depends' => ['course-id'], 'placeholder' => 'Select...', 'url' => Url::to(['/golfer/practice/tees'])]]);
?>
	
    <?php 
echo $form->field($model, 'start_time')->widget(DateTimePicker::classname(), ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]);
?>

	<?php 
echo $form->field($model, 'start_hole')->dropDownList(array(1 => '1', 10 => '10'));
?>

	<?php 
Ejemplo n.º 18
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCourseToTake2()
 {
     return $this->hasOne(Course::className(), ['course_name' => 'course_to_take2']);
 }
Ejemplo n.º 19
0
/* @var $model common\models\Chapter */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="chapter-form">

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

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

    <?php 
echo $form->field($model, 'course_id')->dropDownList(Course::getCourseArray());
?>

    <?php 
echo $form->field($model, 'sort_order')->textInput();
?>

    <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.º 20
0
 /**
  * php页面方法
  */
 public function actionPhps()
 {
     $data = Course::find()->all();
     return $this->render('phps', ['data' => $data]);
 }
Ejemplo n.º 21
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getCourse()
 {
     return $this->hasOne(Course::className(), ['id' => 'course_id']);
 }
Ejemplo n.º 22
0
/* @var $this yii\web\View */
/* @var $model common\models\Season */
$this->title = $model->name;
$this->params['breadcrumbs'][] = ['label' => Yii::t('igolf', 'Competitions'), 'url' => ['index']];
if ($bcs = $model->breadcrumbs()) {
    foreach ($bcs as $bc) {
        $this->params['breadcrumbs'][] = $bc;
    }
}
array_pop($this->params['breadcrumbs']);
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="season-view">

    <?php 
echo DetailView::widget(['model' => $model, 'panel' => ['heading' => '<h3>' . Yii::t('igolf', $model->competition_type) . ' ' . $model->name . '</h3>'], 'labelColOptions' => ['style' => 'width: 30%'], 'attributes' => ['name', 'description', ['attribute' => 'parent_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => $model->getParentCandidates(), 'value' => $model->parent ? $model->parent->name : '', 'visible' => $model->competition_type != Competition::TYPE_SEASON], ['attribute' => 'course_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'label' => Yii::t('igolf', 'Course'), 'items' => ArrayHelper::map(Course::find()->asArray()->all(), 'id', 'name'), 'value' => $model->course ? $model->course->name : ''], ['attribute' => 'holes', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => array(18 => '18', 9 => '9')], ['attribute' => 'rule_id', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ArrayHelper::map(['' => ''] + Rule::find()->where(['competition_type' => $model->competition_type])->asArray()->all(), 'id', 'name'), 'value' => $model->rule_id ? $model->rule->name : ''], ['attribute' => 'start_date', 'format' => 'date', 'type' => DetailView::INPUT_DATE, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]]], ['attribute' => 'registration_begin', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_begin ? new DateTime($model->registration_begin) : ''], ['attribute' => 'registration_end', 'format' => 'datetime', 'type' => DetailView::INPUT_DATETIME, 'widgetOptions' => ['pluginOptions' => ['format' => 'yyyy-mm-dd hh:ii:ss', 'todayHighlight' => true]], 'value' => $model->registration_end ? new DateTime($model->registration_end) : ''], 'handicap_min', 'handicap_max', 'age_min', 'age_max', ['attribute' => 'gender', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => ['' => ''] + Competition::getLocalizedConstants('GENDER_')], ['attribute' => 'status', 'type' => DetailView::INPUT_DROPDOWN_LIST, 'items' => Competition::getLocalizedConstants('STATUS_')]]]);
?>

<?php 
if (in_array($model->competition_type, [Competition::TYPE_SEASON, Competition::TYPE_TOURNAMENT])) {
    switch ($model->competition_type) {
        case Competition::TYPE_SEASON:
            $searchModel = new TournamentSearch();
            $dataProvider = $searchModel->search(['TournamentSearch' => ['parent_id' => $model->id]]);
            $type = Competition::TYPE_TOURNAMENT;
            break;
        case Competition::TYPE_TOURNAMENT:
            $searchModel = new MatchSearch();
            $dataProvider = $searchModel->search(['MatchSearch' => ['parent_id' => $model->id]]);
            $type = Competition::TYPE_MATCH;
            break;