Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if (!$this->periodModel) {
         throw new InvalidParamException(Module::t('res', 'No period model given!'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Returns day name
  * @return string
  */
 public function getDayName()
 {
     $dayName = '';
     switch ($this->day_nr) {
         case self::DAY_MONDAY:
             $dayName = Module::t('res', 'monday');
             break;
         case self::DAY_TUESDAY:
             $dayName = Module::t('res', 'tuesday');
             break;
         case self::DAY_WEDNESDAY:
             $dayName = Module::t('res', 'wednesday');
             break;
         case self::DAY_THURSDAY:
             $dayName = Module::t('res', 'thursday');
             break;
         case self::DAY_FRIDAY:
             $dayName = Module::t('res', 'friday');
             break;
         case self::DAY_SATURDAY:
             $dayName = Module::t('res', 'saturday');
             break;
         case self::DAY_SUNDAY:
             $dayName = Module::t('res', 'sunday');
             break;
     }
     return $dayName;
 }
Ejemplo n.º 3
0
 public function validateAttribute($model, $attribute)
 {
     $error = false;
     $conflictPlans = [];
     $value1 = \Yii::$app->formatter->asTimestamp($model->{$this->firstAttribute});
     $value2 = \Yii::$app->formatter->asTimestamp($model->{$attribute});
     /** @var $plans Plan */
     /** @noinspection PhpUndefinedFieldInspection */
     if ($model->item_id) {
         /** @noinspection PhpUndefinedFieldInspection */
         $plans = Plan::find()->where(['device_id' => $model->device_id])->andWhere(['!=', 'id', $model->item_id])->all();
     } else {
         /** @noinspection PhpUndefinedFieldInspection */
         $plans = Plan::findAll(['device_id' => $model->device_id]);
     }
     foreach ($plans as $plan) {
         $timestamp1 = \Yii::$app->formatter->asTimestamp($plan->date_from);
         $timestamp2 = \Yii::$app->formatter->asTimestamp($plan->date_to);
         if ($value1 < $timestamp1 && $value2 >= $timestamp1 || $value1 <= $timestamp2 && $value2 > $timestamp2) {
             $conflictPlans[] = \Yii::$app->formatter->asDate($plan->date_from, 'php:d.m.Y') . ' - ' . \Yii::$app->formatter->asDate($plan->date_to, 'php:d.m.Y');
             $error = true;
         }
     }
     if ($error === true) {
         $this->message = Module::t('res', 'This plan is in conflict with one or more other plans') . ': ' . implode(', ', $conflictPlans);
         $model->addError($attribute, $this->message);
     }
 }
Ejemplo n.º 4
0
 /**
  * Deletes an existing record model.
  * If deletion is successful, the browser will be redirected to the 'device/view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionDelete($id)
 {
     $model = $this->findModel($id);
     if ($model->delete()) {
         $session = Yii::$app->session;
         $session->setFlash('info', Module::t('res', 'Usage successfully deleted!'));
     }
     return $this->redirect(['/reservation/device/view', 'id' => $this->plan->device->id]);
 }
Ejemplo n.º 5
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->plan_id) {
         $query = Day::find()->where(['plan_id' => $this->plan_id])->orderBy(['day_nr' => SORT_ASC]);
         $this->_dataProvider = new ActiveDataProvider(['query' => $query]);
     } else {
         throw new InvalidParamException(Module::t('res', 'No plan ID given!'));
     }
 }
Ejemplo n.º 6
0
 /**
  * @inheritdoc
  */
 public function init()
 {
     parent::init();
     if ($this->device_id) {
         $query = Price::find()->where(['device_id' => $this->device_id])->orderBy(['title' => SORT_ASC]);
         $this->_dataProvider = new ActiveDataProvider(['query' => $query]);
     } else {
         throw new InvalidParamException(Module::t('res', 'No device ID given!'));
     }
 }
Ejemplo n.º 7
0
 /**
  * Updates an existing record model.
  * If update is successful, the browser will be redirected to the 'plan/view' page.
  * @param integer $id
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = new DayForm(['plan_id' => $this->plan->id, 'item_id' => $id, 'action' => $this->action->id]);
     if ($model->load(Yii::$app->request->post()) && $model->validate()) {
         $model->save(false);
         $session = Yii::$app->session;
         $session->setFlash('info', Module::t('res', 'Day successfully updated!'));
         return $this->redirect(['/reservation/plan/view', 'device_id' => $this->plan->device->id, 'id' => $this->plan->id]);
     }
     return $this->render('update', compact('model'));
 }
Ejemplo n.º 8
0
 /**
  * Sets default period dates
  *
  * @throws Exception
  */
 public function setDefaultPeriod()
 {
     if (!$this->firstDate && !$this->lastDate) {
         $actualDate = date('Y-m-d', time());
         if ((new Query())->select('date_from')->from('dr_plan')->where(['device_id' => $this->device->id])->andWhere(['<=', 'date_from', $actualDate])->andWhere(['>=', 'date_to', $actualDate])->count()) {
             $firstDate = $actualDate;
         } else {
             $firstDate = (new Query())->select('date_from')->from('dr_plan')->where(['device_id' => $this->device->id])->andWhere(['>=', 'date_from', $actualDate])->scalar();
         }
         $this->firstDate = $firstDate;
         $this->lastDate = date('Y-m-d', strtotime($firstDate) + Yii::$app->modules['reservation']->params['dayListDefaultPeriod'] * 86400);
     } else {
         throw new Exception(Module::t('res', 'No date period set!'));
     }
 }
Ejemplo n.º 9
0
 public function validateAttribute($model, $attribute)
 {
     $error = false;
     $value1 = \Yii::$app->formatter->asTimestamp($model->{$attribute});
     $value2 = \Yii::$app->formatter->asTimestamp($model->{$this->compareAttribute});
     switch ($this->operator) {
         case "<":
             if (!($value1 < $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must be smaller then') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
         case "<=":
             if (!($value1 <= $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must be smaller or equal then') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
         case "!=":
             if (!($value1 != $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must not be equal') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
         case ">":
             if (!($value1 > $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must be greater then') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
         case ">=":
             if (!($value1 >= $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must be greater or equal then') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
         default:
             if (!($value1 == $value2)) {
                 $this->message = $model->getAttributeLabel($attribute) . ' ' . Module::t('res', 'must be equal then') . ' ' . $model->getAttributeLabel($this->compareAttribute) . '!';
                 $error = true;
             }
             break;
     }
     if ($error === true) {
         $model->addError($attribute, $this->message);
     }
 }
Ejemplo n.º 10
0
 /**
  * BackendForm constructor.
  *
  * @param array $config
  *
  * @throws Exception
  * @throws UnknownPropertyException
  */
 public function __construct($config)
 {
     if (isset($this->modelClass)) {
         parent::__construct();
         if ($config['item_id']) {
             /** @var ActiveRecord $model */
             $model = call_user_func([$this->modelClass, 'findOne'], $config['item_id']);
             if ($model) {
                 if ($config['action'] != 'copy') {
                     $this->item_id = $model->id;
                 }
                 $data = $model->toArray();
                 $this->attributes = $data;
             } else {
                 /** @noinspection PhpToStringImplementationInspection */
                 throw new Exception(Module::t('res', 'model not found') . ' ' . $this->modelClass . ' ID ' . $config['item_id']);
             }
         }
     } else {
         throw new UnknownPropertyException(Module::t('res', 'modelClass property not set'));
     }
 }
Ejemplo n.º 11
0
 /**
  * Sets day times array
  */
 private function setDayTimes()
 {
     if ($this->date == null) {
         throw new InvalidArgumentException(Module::t('res', 'Date not set!'));
     }
     $dayWeekNr = date('N', Yii::$app->formatter->asTimestamp($this->date));
     $day = Day::find()->where(['plan_id' => $this->_plan->id])->andWhere(['day_nr' => $dayWeekNr])->one();
     $dayTimes = [];
     for ($i = strtotime($this->_plan->time_from), $j = 1; $i <= strtotime($this->_plan->time_to); $i += 60 * $this->_plan->hour_length) {
         if ($i >= strtotime($day->time_from) && $i <= strtotime($day->time_to)) {
             $dayTimes[strval($j)] = date('H:i', $i);
         }
         ++$j;
     }
     $this->_dayTimes = $dayTimes;
 }
Ejemplo n.º 12
0
$this->params['breadcrumbs'][] = ['label' => $controller->device->title, 'url' => ['/reservation/device/view', 'id' => $controller->device->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div>

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

	<p>
		<?php 
echo Html::a(Module::t('res', 'Update'), ['update', 'device_id' => $controller->device->id, 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
		<?php 
echo Html::a(Module::t('res', 'Delete'), ['delete', 'device_id' => $controller->device->id, 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => Module::t('res', 'Are you sure you want to delete this item?'), 'method' => 'post']]);
?>
	</p>

	<?php 
echo DetailView::widget(['model' => $model, 'attributes' => [['attribute' => 'date_from', 'format' => ['date', 'php:d.m.Y']], ['attribute' => 'date_to', 'format' => ['date', 'php:d.m.Y']], ['attribute' => 'time_from', 'format' => ['date', 'php:H:i']], ['attribute' => 'time_to', 'format' => ['date', 'php:H:i']], 'hour_length']]);
?>

	<div class="row">
		<div class="col-xs-12">
			<?php 
echo DayList::widget(['plan_id' => $model->id]);
?>
		</div>
	</div>
Ejemplo n.º 13
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['title' => Module::t('res', 'Title'), 'price' => Module::t('res', 'Price in CZK'), 'notice' => Module::t('res', 'Notice'), 'device_id' => Module::t('res', 'Device ID')];
 }
Ejemplo n.º 14
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['name' => Module::t('res', 'Name'), 'email' => Module::t('res', 'Email'), 'phone' => Module::t('res', 'Phone')];
 }
Ejemplo n.º 15
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('res', 'ID'), 'device_id' => Module::t('res', 'Device ID'), 'date' => Module::t('res', 'Date'), 'time_from' => Module::t('res', 'Time from'), 'time_to' => Module::t('res', 'Time to'), 'subject_name' => Module::t('res', 'Subject name'), 'subject_email' => Module::t('res', 'Subject email'), 'subject_phone' => Module::t('res', 'Subject phone'), 'notice' => Module::t('res', 'Notice')];
 }
Ejemplo n.º 16
0
?>

		<?php 
echo $form->field($model, 'date_to')->widget(DateControl::className(), ['type' => DateControl::FORMAT_DATE, 'language' => Yii::$app->language]);
?>

		<?php 
echo $form->field($model, 'time_from')->widget(TimePicker::className(), ['pluginOptions' => ['defaultTime' => false, 'showSeconds' => false, 'showMeridian' => false], 'options' => ['class' => 'form-control']]);
?>

		<?php 
echo $form->field($model, 'time_to')->widget(TimePicker::className(), ['pluginOptions' => ['defaultTime' => false, 'showSeconds' => false, 'showMeridian' => false], 'options' => ['class' => 'form-control']]);
?>

		<?php 
echo $form->field($model, 'hour_length')->widget(Spinner::className());
?>

		<div class="form-group">
			<?php 
echo Html::submitButton($actionId != 'update' ? Module::t('res', 'Create') : Module::t('res', 'Update'), ['class' => $actionId == 'create' ? 'btn btn-success' : 'btn btn-primary']);
?>
		</div>

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

	</div>

</div>
Ejemplo n.º 17
0
<?php

/* @var $this yii\web\View */
/* @var $model \backend\modules\reservation\models\SubjectForm */
use backend\modules\reservation\Module;
use yii\helpers\Html;
/** @var \backend\modules\reservation\controllers\SubjectController $controller */
$controller = $this->context;
$modelClass = Module::t('res', 'Subject');
$this->title = Module::t('res', 'Create {modelClass}', compact('modelClass'));
$this->params['breadcrumbs'][] = ['label' => Module::t('res', 'Subjects'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div>

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

	<?php 
echo $this->render('_form', compact('model'));
?>

</div>
Ejemplo n.º 18
0
<?php

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
use backend\modules\reservation\Module;
use yii\grid\GridView;
use yii\helpers\Html;
use yii\helpers\Url;
?>
<h2><?php 
echo Module::t('res', 'Prices');
?>
</h2>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "{items}", 'columns' => ['title', 'price', 'notice', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete} {copy}', 'urlCreator' => function ($action, $model, $key) {
    $params = ['/reservation/price/' . $action, 'device_id' => $model->device_id, 'id' => $key];
    return Url::toRoute($params);
}, 'buttons' => ['copy' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span>', $url, ['title' => Module::t('res', 'Copy'), 'class' => 'btn btn-link', 'style' => 'padding: 0 0 3px']);
}]]]]);
Ejemplo n.º 19
0
 public function validateAttribute($model, $attribute)
 {
     if (empty($this->limitsAttributes) || count($this->limitsAttributes) != 2) {
         throw new InvalidParamException(Module::t('res', 'No time limits parameters!'));
     } else {
         $error = false;
         $conflictUsages = [];
         $requestedUsages = [];
         /** @noinspection PhpUndefinedFieldInspection */
         if ($model->item_id) {
             /** @noinspection PhpUndefinedFieldInspection */
             /** @noinspection PhpUndefinedMethodInspection */
             $usages = Usage::find()->where(['device_id' => $model->plan->device_id])->andWhere(['!=', 'id', $model->item_id])->all();
         } else {
             /** @noinspection PhpUndefinedFieldInspection */
             /** @noinspection PhpUndefinedMethodInspection */
             $usages = Usage::findAll(['device_id' => $model->plan->device_id]);
         }
         /** @var UsageForm $model */
         $dayTimeValue = 86400;
         switch ($model->{$attribute}) {
             case UsageForm::DAY_REPEAT:
                 $additionalTime = $dayTimeValue;
                 break;
             case UsageForm::WEEK_REPEAT:
                 $additionalTime = 7 * $dayTimeValue;
                 break;
             case UsageForm::TWO_WEEK_REPEAT:
                 $additionalTime = 14 * $dayTimeValue;
                 break;
             case UsageForm::THREE_WEEK_REPEAT:
                 $additionalTime = 21 * $dayTimeValue;
                 break;
             case UsageForm::FOUR_WEEK_REPEAT:
                 $additionalTime = 28 * $dayTimeValue;
                 break;
             default:
                 $model->repetition_end_date = $model->date;
                 $additionalTime = $dayTimeValue;
                 break;
         }
         /** @noinspection PhpUndefinedFieldInspection */
         for ($i = \Yii::$app->formatter->asTimestamp($model->date); $i <= \Yii::$app->formatter->asTimestamp($model->repetition_end_date); $i += $additionalTime) {
             for ($j = $model->{$this->limitsAttributes[0]}; $j < $model->{$this->limitsAttributes[1]}; ++$j) {
                 $requestedUsages[] = ['date' => \Yii::$app->formatter->asDate($i, 'y-MM-dd'), 'hour_nr' => $j];
             }
         }
         /** @var Usage $usage */
         foreach ($usages as $usage) {
             $searchedArray = ['date' => $usage->date, 'hour_nr' => $usage->hour_nr];
             if (array_search($searchedArray, $requestedUsages)) {
                 /** @noinspection PhpUndefinedFieldInspection */
                 $conflictUsages[] = \Yii::$app->formatter->asDate($usage->date, 'dd.MM.y') . ' ' . $model->dayTimes[$usage->hour_nr] . ': ' . $usage->subject->name;
                 $error = true;
             }
         }
         if ($error === true) {
             $this->message = Module::t('res', 'This usage is in conflict with one or more other usages') . ': ' . implode(', ', $conflictUsages);
             $model->addError($attribute, $this->message);
         }
     }
 }
Ejemplo n.º 20
0
</h2>

				<?php 
    $form = ActiveForm::begin(['layout' => 'inline', 'fieldClass' => ActiveField::className(), 'fieldConfig' => ['labelOptions' => ['class' => ''], 'enableError' => true]]);
    ?>

				<?php 
    echo $form->field($periodModel, 'firstDate')->widget(DateControl::className(), ['type' => DateControl::FORMAT_DATE, 'language' => Yii::$app->language]);
    ?>

				<?php 
    echo $form->field($periodModel, 'lastDate')->widget(DateControl::className(), ['type' => DateControl::FORMAT_DATE, 'language' => Yii::$app->language]);
    ?>

				<?php 
    echo Html::submitButton(Module::t('res', 'OK'), ['class' => 'btn btn-default', 'style' => 'position: relative; top: -5px;']);
    ?>

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

			</div>
		</div>

		<?php 
    echo UsageOverview::widget(['periodModel' => $periodModel]);
    ?>

	<?php 
}
Ejemplo n.º 21
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('res', 'ID'), 'device_id' => Module::t('res', 'Device ID'), 'subject_id' => Module::t('res', 'Subject ID'), 'date' => Module::t('res', 'Date'), 'hour_nr' => Module::t('res', 'Hour Nr.'), 'notice' => Module::t('res', 'Notice')];
 }
Ejemplo n.º 22
0
/* @var $dataProvider yii\data\ActiveDataProvider */
use backend\modules\reservation\Module;
use yii\helpers\Html;
use yii\grid\GridView;
$this->title = Module::t('res', 'Devices');
$this->params['breadcrumbs'][] = $this->title;
$modelClass = Module::t('res', 'Device');
?>
<div>

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

	<p>
		<?php 
echo Html::a(Module::t('res', 'Create {modelClass}', compact('modelClass')), ['create'], ['class' => 'btn btn-success']);
?>
	</p>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'title', 'value' => function ($model, $key) {
    return Html::a($model->title, ['/reservation/device/view', 'id' => $key], ['title' => Module::t('res', 'Details of device')]);
}, 'format' => 'html'], 'text_id', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update} {delete} {copy}', 'buttons' => ['copy' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-duplicate" aria-hidden="true"></span>', ['/reservation/device/copy', 'id' => $key], ['title' => Module::t('res', 'Copy'), 'class' => 'btn btn-link', 'style' => 'padding: 0 0 3px']);
}]]]]);
?>

</div>
Ejemplo n.º 23
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['text_id' => Module::t('res', 'Text ID'), 'title' => Module::t('res', 'Title'), 'description' => Module::t('res', 'Description')];
 }
Ejemplo n.º 24
0
 public function init()
 {
     parent::init();
     $this->message = Module::t('res', 'must be in any valid plan!');
 }
Ejemplo n.º 25
0
<?php

use backend\modules\reservation\Module;
use yii\helpers\Html;
/* @var $this yii\web\View */
/* @var $model \backend\modules\reservation\models\PlanForm */
/** @var \backend\modules\reservation\controllers\PlanController $controller */
$controller = $this->context;
$modelClass = Module::t('res', 'Plan');
$this->title = Module::t('res', 'Update {modelClass} for', compact('modelClass')) . ': ' . Yii::$app->formatter->asDate($model->date_from, 'php:d.m.Y') . ' - ' . Yii::$app->formatter->asDate($model->date_to, 'php:d.m.Y');
$this->params['breadcrumbs'][] = ['label' => Module::t('res', 'Devices'), 'url' => ['/reservation/device/index']];
$this->params['breadcrumbs'][] = ['label' => $controller->device->title, 'url' => ['/reservation/device/view', 'id' => $controller->device->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div>

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

	<?php 
echo $this->render('_form', compact('model'));
?>

</div>
Ejemplo n.º 26
0
 public function init()
 {
     parent::init();
     $this->message = Module::t('res', 'This name of subject is already used!');
 }
Ejemplo n.º 27
0
        if ($day = Day::find()->where(['plan_id' => $plan->id])->andWhere(['day_nr' => date('N', $i)])->one()) {
            if ($day->is_open == 1) {
                echo '<div class="col-xs-6 col-md-4 col-lg-3"><table class="table table-bordered table-striped table-condensed">';
                echo '<tr><th colspan="3">' . $day->getDayName() . ' ' . date('d.m.Y', $i) . '</th></tr>';
                for ($j = strtotime(date('Y-m-d', $i) . ' ' . $plan->time_from), $k = 1; $j < strtotime(date('Y-m-d', $i) . ' ' . $plan->time_to); $j += $plan->hour_length * 60) {
                    if (date('H:i', $j) >= date('H:i', strtotime($day->time_from)) && date('H:i', $j) < date('H:i', strtotime($day->time_to))) {
                        $usage = Usage::find()->where(['device_id' => $device->id])->andWhere(['date' => date('Y-m-d', $i)])->andWhere(['hour_nr' => $k])->one();
                        echo '<tr' . ($usage ? ' class="used"' : '') . '>';
                        echo '<td style="width: 3em;">' . date('H:i', $j) . '</td>';
                        echo '<td>' . ($usage ? Html::tag('span', StringHelper::truncate($usage->subject->name, 12), ['data' => ['toggle' => 'tooltip', 'placement' => 'top', 'html' => true, 'title' => $usage->subject->name . '<br />' . $usage->subject->email . '<br />' . $usage->subject->phone]]) : '&nbsp;') . '</td>';
                        echo '<td style="text-align: center; width: 4em;">';
                        if ($usage) {
                            echo Html::a('<span class="glyphicon glyphicon-pencil" aria-hidden="true"></span>', ['/reservation/usage/update', 'plan_id' => $plan->id, 'id' => $usage->id], ['title' => Module::t('res', 'Update usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;']);
                            echo Html::a('<span class="glyphicon glyphicon-trash" aria-hidden="true"></span>', ['/reservation/usage/delete', 'plan_id' => $plan->id, 'id' => $usage->id], ['title' => Module::t('res', 'Delete usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;', 'data-confirm' => Module::t('res', 'Are you sure you want to delete this item?'), 'data-method' => 'post', 'data-pjax' => '0']);
                        } else {
                            echo Html::a('<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>', ['/reservation/usage/create', 'plan_id' => $plan->id, 'date' => date('Y-m-d', $i), 'hour_nr' => $k], ['title' => Module::t('res', 'Add usage'), 'class' => 'btn btn-link', 'style' => 'padding: 0;']);
                        }
                        echo '</td>';
                        echo '</tr>';
                    } else {
                        echo '<tr><td colspan="3" style="text-align: center;"><span class="glyphicon glyphicon-minus btn" aria-hidden="true" style="padding: 0; cursor: default;"></span></td></tr>';
                    }
                    ++$k;
                }
                echo '</table></div>';
            }
        }
    }
}
?>
</div>
Ejemplo n.º 28
0
<?php

/* @var $this yii\web\View */
/* @var $model \backend\modules\reservation\models\DayForm */
use backend\modules\reservation\Module;
use yii\helpers\Html;
/** @var \backend\modules\reservation\controllers\DayController $controller */
$controller = $this->context;
$modelClass = Module::t('res', 'Day');
$this->title = Module::t('res', 'Update {modelClass}', compact('modelClass')) . ': ' . $model->getDay()->getDayName();
$this->params['breadcrumbs'][] = ['label' => Module::t('res', 'Devices'), 'url' => ['/reservation/device/index']];
$this->params['breadcrumbs'][] = ['label' => $controller->plan->device->title, 'url' => ['/reservation/device/view', 'id' => $controller->plan->device->id]];
$this->params['breadcrumbs'][] = ['label' => Module::t('res', 'Plan for', compact('modelClass')) . ': ' . Yii::$app->formatter->asDate($controller->plan->date_from, 'php:d.m.Y') . ' - ' . Yii::$app->formatter->asDate($controller->plan->date_to, 'php:d.m.Y'), 'url' => ['/plan/view', 'device_id' => $controller->plan->device->id, 'id' => $controller->plan->id]];
$this->params['breadcrumbs'][] = $this->title;
?>
<div>

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

	<?php 
echo $this->render('_form', compact('model'));
?>

</div>
Ejemplo n.º 29
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['date_from' => Module::t('res', 'Date from'), 'date_to' => Module::t('res', 'Date to'), 'time_from' => Module::t('res', 'Time from'), 'time_to' => Module::t('res', 'Time to'), 'hour_length' => Module::t('res', 'Length of hour (min.)'), 'device_id' => Module::t('res', 'Device ID')];
 }
Ejemplo n.º 30
0
<?php

/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
use backend\modules\reservation\Module;
use backend\modules\reservation\models\Day;
use yii\grid\GridView;
use yii\helpers\Url;
?>
<h2><?php 
echo Module::t('res', 'Days');
?>
</h2>

<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'layout' => "{items}", 'columns' => [['attribute' => 'day_nr', 'value' => function ($model) {
    /** @var $model Day */
    return $model->getDayName();
}], ['attribute' => 'is_open', 'value' => function ($model) {
    return $model->is_open == 1 ? Module::t('res', 'yes') : Module::t('res', 'no');
}], ['attribute' => 'time_from', 'value' => function ($model) {
    return $model->is_open ? Yii::$app->formatter->asDate($model->time_from, 'php:H:i') : '---';
}], ['attribute' => 'time_to', 'value' => function ($model) {
    return $model->is_open ? Yii::$app->formatter->asDate($model->time_to, 'php:H:i') : '---';
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}', 'urlCreator' => function ($action, $model, $key) {
    $params = ['/reservation/day/' . $action, 'plan_id' => $model->plan_id, 'id' => $key];
    return Url::toRoute($params);
}]]]);