public function actionAdmin()
 {
     $model = new ClassGuitar('search');
     $model->unsetAttributes();
     if (isset($_GET['ClassGuitar'])) {
         $model->setAttributes($_GET['ClassGuitar']);
     }
     $this->render('admin', array('model' => $model));
 }
Example #2
0
 public function actionRegister()
 {
     $arrayAuthRoleItems = Yii::app()->authManager->getAuthItems(2, Yii::app()->user->getId());
     $arrayKeys = array_keys($arrayAuthRoleItems);
     $role = strtolower($arrayKeys[0]);
     if ($role == 'admin' || $role == 'teacher') {
         $this->redirect('/');
     }
     $this->layout = 'dangkyhoc';
     $model = new Student();
     if (isset($_GET['cid']) && (int) $_GET['cid']) {
         $model->class_id = $_GET['cid'];
     }
     $db = Yii::app()->db;
     if (isset($_POST['Student']) && $_POST['Student']) {
         $model->setAttributes($_POST['Student']);
         $gclass = ClassGuitar::model()->findByPk($model->class_id);
         $sql = "SELECT * FROM {{student}} WHERE user_id =" . Yii::app()->user->id . " ORDER BY id DESC";
         $cmd = $db->createCommand($sql);
         $student = $cmd->queryRow();
         if ($student) {
             //                var_dump($studentơclass_id);
             $gclass2 = ClassGuitar::model()->findByPk($student['class_id']);
             if ($student['status'] == 'comp') {
                 //Hoàn thành
                 if ($gclass->tid <= $gclass2->tid) {
                     $training = Training::model()->findByPk($gclass2->tid);
                     Yii::app()->user->setFlash('error', 'Bạn đã hoàn thành một lớp thuộc khóa <b>' . $training->title . '</b>. Vui lòng đăng ký khóa học cao hơn.');
                 }
             } elseif ($student['status'] == 'reg') {
                 // Mới đăng ký
                 Yii::app()->user->setFlash('error', 'Bạn đã đăng ký học tại lớp <b>' . $gclass2->title . '</b>. Vui lòng hủy đơn đăng ký này trước khi đăng ký tham gia lớp học khác!');
             } else {
                 $center = Center::model()->findByPk($gclass2->cid);
                 Yii::app()->user->setFlash('error', 'Bạn đang tham gia lớp học <b>' . $gclass2->title . '</b> tại cơ sở <b>' . $center->title . '</b>!');
             }
         } else {
         }
         if (!Yii::app()->user->hasFlash('error') && $model->save()) {
             if (Yii::app()->getRequest()->getIsAjaxRequest()) {
                 Yii::app()->end();
             } else {
                 Yii::app()->user->setFlash('success', 'Bạn đã đăng ký lớp học thành công. LNT sẽ sớm liên lạc lại với bạn.');
             }
         }
     } else {
         $oldStudent = Student::model()->find('user_id=' . Yii::app()->user->id);
         if ($oldStudent) {
             $model->name = $oldStudent->name;
             $model->email = $oldStudent->email;
             $model->tel = $oldStudent->tel;
             $model->birthday = $oldStudent->birthday;
         }
     }
     $this->render('register', array('model' => $model));
 }
Example #3
0
	<div class="row">
		<?php 
echo $form->label($model, 'time');
?>
		<?php 
echo $form->textField($model, 'time');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'class_id');
?>
		<?php 
echo $form->dropDownList($model, 'class_id', GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All')));
?>
	</div>

	<div class="row buttons">
		<?php 
echo GxHtml::submitButton(Yii::t('app', 'Search'));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- search-form -->
Example #4
0
?>
        <?php 
echo $form->error($model, 'body');
?>
    </div>
    <!-- row -->
    <div class="row">
        <?php 
echo $form->labelEx($model, 'status');
?>
        <?php 
echo $form->dropDownList($model, 'status', array(0 => 'Ẩn', 1 => 'Hiện'));
?>
        <?php 
echo $form->error($model, 'status');
?>
    </div>

    <label><?php 
echo GxHtml::encode($model->getRelationLabel('classGuitars'));
?>
</label>
    <?php 
echo $form->checkBoxList($model, 'classGuitars', GxHtml::encodeEx(GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true)), false, true));
?>

    <?php 
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
Example #5
0
		<?php 
echo $form->labelEx($model, 'end_time');
?>
		<?php 
echo $form->textField($model, 'end_time');
?>
		<?php 
echo $form->error($model, 'end_time');
?>
		</div><!-- row -->
		<div class="row">
		<?php 
echo $form->labelEx($model, 'class_id');
?>
		<?php 
echo $form->dropDownList($model, 'class_id', GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true)));
?>
		<?php 
echo $form->error($model, 'class_id');
?>
		</div><!-- row -->


<?php 
echo GxHtml::submitButton(Yii::t('app', 'Save'));
$this->endWidget();
?>
</div><!-- form -->
<script type="text/javascript">
    $(function () {
        $('#ClassCalendar_start_time').timepicker({});
Example #6
0
<?php

$this->breadcrumbs = array($model->label(2) => array('index'), Yii::t('app', 'Manage'));
$this->menu = array(array('label' => Yii::t('app', 'List') . ' ' . $model->label(2), 'url' => array('index')), array('label' => Yii::t('app', 'Create') . ' ' . $model->label(), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('student-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo Yii::t('app', 'Manage') . ' ' . GxHtml::encode($model->label(2));
?>
</h1>

<p>
You may optionally enter a comparison operator (&lt;, &lt;=, &gt;, &gt;=, &lt;&gt; or =) at the beginning of each of your search values to specify how the comparison should be done.
</p>

<?php 
echo GxHtml::link(Yii::t('app', 'Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'student-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'name', 'email', 'tel', 'birthday', array('name' => 'class_id', 'value' => 'GxHtml::valueEx($data->class)', 'filter' => GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn'))));
Example #7
0
<?php

$this->breadcrumbs = array(ClassGuitar::label(2), Yii::t('app', 'Index'));
$this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . ClassGuitar::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . ClassGuitar::label(2), 'url' => array('admin')));
?>

<h1><?php 
echo GxHtml::encode(ClassGuitar::label(2));
?>
</h1>

<?php 
$this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
Example #8
0
<?php

$this->breadcrumbs = array('TKB' => array('admin'));
$this->menu = array(array('label' => Yii::t('app', 'Tạo mới TKB'), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('class-calendar-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1>Thời khóa biểu</h1>

<?php 
function getDay($day)
{
    $days = array(1 => 'Chủ nhật', 2 => 'Thứ hai', 3 => 'Thứ ba', 4 => 'Thứ tư', 5 => 'Thứ năm', 6 => 'Thứ sáu', 7 => 'Thứ bảy');
    return $days[$day];
}
$this->widget('zii.widgets.grid.CGridView', array('id' => 'class-calendar-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', array('name' => 'day', 'value' => 'getDay($data->day)'), array('name' => 'start_time', 'value' => 'date("H:i",$data->start_time)'), array('name' => 'end_time', 'value' => 'date("H:i",$data->end_time)'), array('name' => 'class_id', 'value' => 'GxHtml::valueEx($data->class)', 'filter' => GxHtml::listDataEx(ClassGuitar::model()->findAllAttributes(null, true))), array('class' => 'CButtonColumn'))));