Ejemplo n.º 1
0
use backend\modules\timetable\Module as Timetable;
use backend\modules\employment\Employment;
use backend\modules\pay\Pay;
use backend\modules\ticket\Ticket;
use backend\modules\statistics\Statistics;
if (!isset(Yii::$app->i18n->translations['rbac-admin'])) {
    Yii::$app->i18n->translations['rbac-admin'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'sourceLanguage' => 'en', 'basePath' => '@mdm/admin/messages'];
}
$controllerPath = '';
$moduleId = '';
if (Yii::$app->controller->module->id) {
    $controllerPath = '/' . Yii::$app->controller->module->id;
    $moduleId = Yii::$app->controller->module->id;
}
$controllerPath .= '/' . Yii::$app->controller->id;
?>
<aside class="main-sidebar">

    <section class="sidebar">
        <?php 
echo Nav::widget(['id' => 'adminlte-sidebar-menu', 'encodeLabels' => false, 'options' => ['class' => 'sidebar-menu'], 'activateItems' => true, 'activateParents' => true, 'items' => [['label' => Config::t('configuration', 'Configuration'), 'url' => ['/config/default/index'], 'visible' => Yii::$app->user->can('/config/*'), 'icon' => Config::getIcon()], ['label' => User::t('user-admin', 'Users'), 'url' => ['/user/default/index'], 'visible' => Yii::$app->user->can('/user/*'), 'icon' => User::getIcon()], ['label' => Group::t('group-admin', 'Groups'), 'url' => ['/group/default/index'], 'visible' => Yii::$app->user->can('/group/*'), 'icon' => Group::getIcon()], ['label' => Timetable::t('timetable-admin', 'Timetable'), 'url' => ['/timetable/default/index'], 'visible' => Yii::$app->user->can('/timetable/*'), 'icon' => Timetable::getIcon()], ['label' => Ticket::t('ticket', 'Tickets'), 'url' => ['/ticket/default/index'], 'visible' => Yii::$app->user->can('/ticket/*'), 'icon' => Ticket::getIcon()], ['label' => Pay::t('pay-admin', 'Pays'), 'url' => ['/pay/default/index'], 'visible' => Yii::$app->user->can('/pay/*'), 'icon' => Pay::getIcon()], ['label' => Employment::t('employment', 'Paid employments'), 'url' => ['/employment/default/index'], 'visible' => Yii::$app->user->can('/employment/*'), 'icon' => Employment::getIcon()], ['label' => News::t('eugenekei-news', 'News'), 'url' => ['/news/admin/index'], 'visible' => Yii::$app->user->can('/news/admin/*'), 'icon' => News::getIcon(), 'active' => $moduleId === 'news'], ['label' => Statistics::t('statistics', 'Statistics'), 'url' => ['/statistics/default/index'], 'visible' => Yii::$app->user->can('/statistics/*'), 'icon' => Statistics::getIcon()], ['label' => Yii::t('rbac-admin', 'Assignments'), 'url' => ['/rbac'], 'icon' => 'fa-legal', 'visible' => Yii::$app->user->can('/rbac/*'), 'active' => $moduleId === 'rbac', 'items' => [['label' => Yii::t('rbac-admin', 'Assignments'), 'url' => ['/rbac/assignment/index'], 'active' => $controllerPath === '/rbac/assignment'], ['label' => Yii::t('rbac-admin', 'Permissions'), 'url' => ['/rbac/permission/index'], 'active' => $controllerPath === '/rbac/permission'], ['label' => Yii::t('rbac-admin', 'Roles'), 'url' => ['/rbac/role/index'], 'active' => $controllerPath === '/rbac/role'], ['label' => Yii::t('rbac-admin', 'Routes'), 'url' => ['/rbac/route/index'], 'active' => $controllerPath === '/rbac/route'], ['label' => Yii::t('rbac-admin', 'Rules'), 'url' => ['/rbac/rule/index'], 'active' => $controllerPath === '/rbac/rule']]]]]);
?>



    </section>

</aside>

<?php 
//print_r(Yii::$app->i18n->translations);
Ejemplo n.º 2
0
$this->title = Module::t('timetable-admin', 'Timetable');
$this->params['subtitle'] = Module::t('timetable-admin', 'Create item');
$this->params['breadcrumbs'][] = ['label' => $this->title, 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->params['subtitle'];
?>
<div class="timetable-create">
    <div class="box box-primary">
        <div class="box-header">
            <div class="pull-right">
                <?php 
echo Html::a('<i class="fa fa-list"></i>', ['index'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'List')]);
?>
                <?php 
echo Html::a('<i class="fa fa-eye"></i>', ['view'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'View')]);
?>
                <?php 
echo Html::a('<i class="fa fa-leanpub"></i>', ['publish'], ['class' => 'btn btn-warning btn-sm', 'title' => Module::t('timetable-admin', 'Publish')]);
?>
                <?php 
echo Html::a('<i class="fa fa-ban"></i>', ['cancel-lessons'], ['class' => 'btn btn-danger btn-sm', 'title' => Module::t('timetable-admin', 'Cancel lessons')]);
?>
            </div>
        </div>
        <div class="box-body">
            <?php 
echo $this->render('_form', ['model' => $model, 'groupsArray' => $groupsArray]);
?>
        </div>
    </div>
</div>
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => 'ID', 'start' => Module::t('timetable-admin', 'Start'), 'end' => Module::t('timetable-admin', 'End'), 'week_day' => Module::t('timetable-admin', 'Weekday'), 'group_id' => Module::t('timetable-admin', 'Group')];
 }
?>
            </div>
        </div>
        <div class="box-body">
            <div class="row">
                <?php 
$form = ActiveForm::begin(['id' => 'timetable-cansel-lessons', 'enableClientValidation' => true]);
?>
                <div class="col-sm-12">
                    <?php 
echo $form->field($model, 'date')->widget(DatePicker::className(), ['name' => '', 'type' => DatePicker::TYPE_INPUT, 'options' => ['placeholder' => Module::t('timetable-admin', 'Set the date')], 'pluginOptions' => ['autoclose' => true, 'format' => 'dd.mm.yyyy', 'todayHighlight' => true, 'todayBtn' => true]]);
?>
                </div>
                <div class="col-sm-12">
                    <?php 
echo $form->field($model, 'ids')->widget(DepDrop::className(), ['typename' => 'listBox', 'options' => ['placeholder' => Module::t('timetable-admin', 'Set the date first'), 'multiple' => true, 'size' => 7], 'pluginOptions' => ['depends' => ['timetablecancel-date'], 'url' => Url::to(['cancel-lessons']), 'placeholder' => false]]);
?>
                </div>
                <div class="col-sm-12">
                    <?php 
echo Html::submitButton(Module::t('timetable-admin', 'Cancel lessons'), ['class' => 'btn btn-primary btn-large']);
?>
                </div>
                <?php 
ActiveForm::end();
?>
            </div>
        </div>
    </div>
</div>
Ejemplo n.º 5
0
                <?php 
echo Html::a('<i class="fa fa-eye"></i>', ['view'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'View')]);
?>
                <?php 
echo Html::a('<i class="fa fa-leanpub"></i>', ['publish'], ['class' => 'btn btn-warning btn-sm', 'title' => Module::t('timetable-admin', 'Publish')]);
?>
                <?php 
echo Html::a('<i class="fa fa-plus"></i>', ['create'], ['class' => 'btn btn-primary btn-sm', 'title' => Module::t('timetable-admin', 'Create')]);
?>
                <?php 
echo Html::a('<i class="fa fa-ban"></i>', ['cancel-lessons'], ['class' => 'btn btn-danger btn-sm', 'title' => Module::t('timetable-admin', 'Cancel lessons')]);
?>
                <?php 
echo Html::a('<i class="fa fa-trash"></i>', ['batch-delete'], ['class' => 'btn btn-danger btn-sm', 'id' => 'batch-delete', 'title' => Module::t('timetable-admin', 'Delete selected')]);
?>
            </div>
        </div>
        <div class="box-body">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'id' => $gridId, 'filterModel' => $searchModel, 'export' => false, 'columns' => [['class' => CheckboxColumn::classname()], ['attribute' => 'week_day', 'pageSummary' => true, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'dropDownList', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form'], 'data' => Timetable::getWeekArray()], 'value' => function ($model) {
    return $model->weekArray[$model->week_day];
}, 'filter' => Html::activeDropDownList($searchModel, 'week_day', Timetable::getWeekArray(), ['class' => 'form-control', 'prompt' => ''])], ['attribute' => 'start', 'filter' => false, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'textInput', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']]], ['attribute' => 'end', 'filter' => false, 'class' => 'kartik\\grid\\EditableColumn', 'editableOptions' => ['inputType' => 'textInput', 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']]], ['attribute' => 'group_id', 'class' => 'kartik\\grid\\EditableColumn', 'format' => 'html', 'editableOptions' => ['inputType' => 'dropDownList', 'data' => Group::getGroupArray(), 'type' => 'post', 'formOptions' => ['action' => Url::toRoute('edit'), 'id' => 'timetable-form']], 'value' => function ($model) {
    return Group::getGroupArray()[$model->group_id];
}, 'filter' => Html::activeDropDownList($searchModel, 'group_id', Group::getGroupArray(), ['class' => 'form-control', 'prompt' => ''])], ['class' => 'yii\\grid\\ActionColumn', 'buttons' => ['clone' => function ($url) {
    return Html::a('<i class="fa fa-files-o"></i>', $url, ['title' => Module::t('timetable-admin', 'Clone row'), 'class' => 'btn btn-default btn-xs']);
}], 'template' => '{clone} {update} {delete}', 'buttonOptions' => ['class' => 'btn btn-default btn-xs'], 'headerOptions' => ['style' => 'width:100px;'], 'header' => Module::t('timetable-admin', 'Actions')]]]);
?>
        </div>
    </div>
</div>
Ejemplo n.º 6
0
            <?php 
echo $form->field($model, 'end')->textInput();
?>

        </div>
        <div class="col-sm-3">
            <?php 
echo $form->field($model, 'week_day')->textInput()->dropDownList($model->WeekArray);
?>

        </div>
        <div class="col-sm-3">
            <?php 
echo $form->field($model, 'group_id')->textInput()->dropDownList($groupsArray);
?>

        </div>
    </div>

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

    <?php 
ActiveForm::end();
?>

</div>
Ejemplo n.º 7
0
        </div>
    <?php 
}
if (Yii::$app->user->can('/timetable/*')) {
    ?>
        <div class="col-lg-3 col-md-4 col-xs-6">
            <a class="btn btn-default btn-square-200px"
               href="<?php 
    echo Url::toRoute('/timetable/default/cancel-lessons');
    ?>
">
                <i class="fa fa-close fa-10x text-danger">
                </i>
                <br/>
                <h4><?php 
    echo Timetable::t('timetable-admin', 'Cancel lessons');
    ?>
</h4>
            </a>
        </div>
    <?php 
}
if (Yii::$app->user->can('/statistics/*')) {
    ?>
        <div class="col-lg-3 col-md-4 col-xs-6 center-block">
            <a class="btn btn-default btn-square-200px"
               href="<?php 
    echo Url::toRoute('/statistics/default/index');
    ?>
">
                <i class="fa fa-bar-chart fa-10x text-info">
 /**
  * Cancel lessons on a date
  * @return string|void
  * @throws \yii\db\Exception
  */
 public function actionCancelLessons()
 {
     $model = new TimetableCancel();
     $parents = Yii::$app->request->post('depdrop_parents');
     if (is_array(Yii::$app->request->post('TimetableCancel')['ids']) && $model->load(Yii::$app->request->post()) && $model->validate()) {
         $date = Carbon::createFromFormat('d.m.Y', $model->date);
         $updatedCount = 0;
         $needUpdate = PaidEmployment::find()->asArray()->joinWith(['timetable', 'pay'])->where(['date' => "{$date->toDateString()}", 'timetable_id' => $model->ids])->all();
         foreach ($needUpdate as $needRow) {
             $maxPaidDateOnGroupForUser = PaidEmployment::find()->asArray()->select('MAX(date) as max_date')->joinWith(['timetable', 'pay'])->where(['pay.user_id' => $needRow['pay']['user_id'], 'timetable_id' => $needRow['timetable_id']])->one();
             if (!$maxPaidDateOnGroupForUser) {
                 continue;
             }
             $carbonMaxDate = Carbon::createFromFormat('Y-m-d', $maxPaidDateOnGroupForUser['max_date']);
             //Все элементы расписания для группы
             $allTimetableOnGroup = Timetable::find()->asArray()->where(['group_id' => $needRow['timetable']['group_id']])->all();
             $allTimetableWeekDaysOnGroup = ArrayHelper::getColumn($allTimetableOnGroup, function ($array) {
                 return ArrayHelper::getValue($array, 'week_day');
             });
             $i = 0;
             while (7 >= $i) {
                 ++$i;
                 $currDate = clone $carbonMaxDate;
                 $carbonMaxDate->addDay();
                 if (!in_array($currDate->dayOfWeek, $allTimetableWeekDaysOnGroup)) {
                     continue;
                 }
                 $notPaidTimetables = Timetable::find()->asArray()->where(['week_day' => $currDate->dayOfWeek, 'group_id' => $needRow['timetable']['group_id']])->andWhere('NOT EXISTS ' . '( ' . 'SELECT * FROM paid_employment pe ' . 'LEFT JOIN pay p ON p.id = pe.pay_id ' . 'WHERE p.user_id = ' . $needRow['pay']['user_id'] . ' ' . 'AND `pe`.`date` = "' . $currDate->toDateString() . '" ' . 'AND timetable_id = timetable.id' . ')')->orderBy('start, end')->all();
                 if ($notPaidTimetables) {
                     $command = Yii::$app->db->createCommand('UPDATE paid_employment SET `date` = "' . $currDate->toDateString() . '", ' . 'timetable_id = ' . $notPaidTimetables[0]['id'] . ' ' . 'WHERE id = ' . $needRow['id']);
                     if (is_int($command->execute())) {
                         ++$updatedCount;
                         break;
                     }
                 } else {
                 }
             }
         }
         if (0 < $updatedCount) {
             Yii::$app->session->setFlash('success', Module::t('timetable-admin', 'Moved training schedule clients: {sum}', ['sum' => $updatedCount]));
         } else {
             Yii::$app->session->setFlash('danger', Module::t('timetable-admin', Module::t('timetable-admin', 'No records found in the timetable of customers at that date.')));
         }
         return $this->render('cancellessons', ['model' => $model]);
     } elseif ($parents !== null) {
         $out = [];
         $date = Carbon::createFromFormat('d.m.Y', $parents[0]);
         $condition = 'week_day = :week_day';
         $params = [':week_day' => $date->dayOfWeek];
         $groups = Timetable::find()->with('group')->where($condition, $params)->orderBy('start, end')->all();
         foreach ($groups as $row) {
             $out[] = ['id' => $row->id, 'name' => $row->group->name . ' ' . $row->start . ' - ' . $row->end];
         }
         echo Json::encode(['output' => $out, 'selected' => '']);
         return;
     } else {
         return $this->render('cancellessons', ['model' => $model]);
     }
 }
Ejemplo n.º 9
0
    <div class="box box-success">
        <div class="box-header">
            <div class="pull-right">
                <?php 
echo Html::a('<i class="fa fa-list"></i>', ['index'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'List')]);
?>
                <?php 
echo Html::a('<i class="fa fa-eye"></i>', ['view'], ['class' => 'btn btn-default btn-sm', 'title' => Module::t('timetable-admin', 'View')]);
?>
                <?php 
echo Html::a('<i class="fa fa-leanpub"></i>', ['publish'], ['class' => 'btn btn-warning btn-sm', 'title' => Module::t('timetable-admin', 'Publish')]);
?>
                <?php 
echo Html::a('<i class="fa fa-plus"></i>', ['create'], ['class' => 'btn btn-primary btn-sm', 'title' => Module::t('timetable-admin', 'Create')]);
?>
                <?php 
echo Html::a('<i class="fa fa-ban"></i>', ['cancel-lessons'], ['class' => 'btn btn-danger btn-sm', 'title' => Module::t('timetable-admin', 'Cancel lessons')]);
?>
                <?php 
echo Html::a('<i class="fa fa-trash"></i>', ['delete', 'id' => $user->id], ['class' => 'btn btn-danger btn-sm', 'title' => Module::t('group-admin', 'Delete'), 'data-confirm' => Module::t('timetable-admin', 'Are you sure to delete this item?'), 'data-method' => 'post']);
?>
            </div>
        </div>
        <div class="box-body">
            <?php 
echo $this->render('_form', ['model' => $model, 'groupsArray' => $groupsArray]);
?>
        </div>
    </div>
</div>