/**
  * @param $attribute
  * @param \MongoDate|string|int $oldValue
  * @param \MongoDate|string|int $newValue
  * @return array|bool
  */
 private function getLogRow($attribute, $oldValue, $newValue)
 {
     $row = ['date' => new \MongoDate(), 'user' => \Yii::$app->user->identity['fullName']];
     switch ($attribute) {
         case 'date':
             $row['action'] = "Изменилась дата с " . \Yii::$app->formatter->asDate($oldValue->toDateTime()) . " на " . \Yii::$app->formatter->asDate($newValue->toDateTime());
             return $row;
         case 'beginTime':
             $row['action'] = "Изменилось время начала с " . MinuteFormatter::asString($oldValue) . " на " . MinuteFormatter::asString($newValue);
             return $row;
         case 'endTime':
             $row['action'] = "Изменилось время окончания с " . MinuteFormatter::asString($oldValue) . " на " . MinuteFormatter::asString($newValue);
             return $row;
         case 'participantsId':
             $action = '';
             foreach ($newValue as $item) {
                 $index = array_search($item, $oldValue);
                 if ($index !== false) {
                     unset($oldValue[$index]);
                 } else {
                     $action .= "Участник '" . Participant::findOne(['_id' => $item])->shortName . "' был добавлен\n";
                 }
             }
             foreach ($oldValue as $item) {
                 $action .= "Участник '" . Participant::findOne(['_id' => $item])->shortName . "' был удалён\n";
             }
             $row['action'] = $action;
             return $row;
         default:
             return false;
     }
 }
示例#2
0
 public function rules()
 {
     return [['approvedRoomId', 'required'], ['approvedRoomId', 'exist', 'targetClass' => Participant::class, 'targetAttribute' => '_id'], ['approvedRoomId', function ($attribute) {
         /** @var Collection $collection */
         $collection = \Yii::$app->get('mongodb')->getCollection(Request::collectionName());
         /** @var Request $request */
         $request = $collection->findOne(['_id' => ['$ne' => $this->request->_id], 'date' => $this->request->date, 'beginTime' => ['$lt' => $this->request->endTime], 'endTime' => ['$gt' => $this->request->beginTime], 'status' => ['$ne' => Request::STATUS_CANCEL], 'participantsId' => new \MongoId($this->{$attribute})]);
         if ($request !== null) {
             $this->addError($attribute, "Данное помещение забронировано для " . Html::a("другого совещания", ['vks-request/view', 'id' => (string) $request['_id']]) . " c " . MinuteFormatter::asString($request['beginTime']) . " по " . MinuteFormatter::asString($request['endTime']));
         }
     }, 'except' => self::SCENARIO_CANCEL_ROOM]];
 }
示例#3
0
 public function validateAttribute($model, $attribute)
 {
     $value = $model->{$attribute};
     $time = MinuteFormatter::asInt($value);
     if ($time === null) {
         $this->addError($model, $attribute, $this->message, []);
     } elseif ($this->min !== null && $time < $this->min) {
         $this->addError($model, $attribute, $this->tooSmall, ['min' => $this->minString]);
     } elseif ($this->max !== null && $time > $this->max) {
         $this->addError($model, $attribute, $this->tooBig, ['max' => $this->maxString]);
     } elseif ($this->minuteAttribute !== null) {
         $model->{$this->minuteAttribute} = $time;
     }
 }
示例#4
0
    </div>

    <small class="help-block"><span class="glyphicon glyphicon-info-sign"></span> Укажите дату не
        ранее <?php 
echo Yii::$app->formatter->asDate(time(), 'long');
?>
 и не
        позднее <?php 
echo Yii::$app->formatter->asDate(strtotime("+1 week"), 'long');
?>
        Время должно быть в интервале c <?php 
echo MinuteFormatter::asString(Yii::$app->params['vks.minTime']);
?>
        до <?php 
echo MinuteFormatter::asString(Yii::$app->params['vks.maxTime']);
?>
.
    </small>

    <?php 
echo $form->field($model, 'foreignOrganizations', ['inputOptions' => ['id' => 'foreign-organizations']])->inline()->radioList([1 => 'С участием', 0 => 'Без участия']);
?>

    <div id="rso-files-container" <?php 
echo $model->foreignOrganizations == 1 ? '' : 'hidden';
?>
>

        <?php 
echo $form->field($model, 'rsoUploadedFiles[]', ['enableClientValidation' => false])->fileInput(['multiple' => true])->label("Документы для режимно-секретного отдела");
示例#5
0
 * @var $dataProvider \yii\data\ActiveDataProvider
 * @var $model \frontend\models\vks\RequestSearch
 * @var $participantsCountPerHour array
 */
$minMinute = Yii::$app->params['vks.minTime'];
$maxMinute = Yii::$app->params['vks.maxTime'];
?>
    <p class="lead">Расписание на <?php 
echo Yii::$app->formatter->asDate($model->date->sec, 'long');
?>
</p>

    <div id="vks-schedule">

        <?php 
$currentMinute = \common\components\MinuteFormatter::asInt(date('H:i'));
?>

        <?php 
if (gmmktime(0, 0, 0) == $model->date->sec && $currentMinute >= $minMinute && $currentMinute <= $maxMinute) {
    ?>

            <?php 
    echo Html::tag('div', '', ['id' => 'current-time', 'data' => ['top' => $currentMinute - $minMinute + 1]]);
    ?>

        <?php 
}
?>

        <?php 
示例#6
0
?>
&raquo;</b> <?php 
echo Html::a('Подробнее >', ['vks-request/view', 'id' => $requestIdStr]);
?>
    </p>

    <p>Дата и время <b><?php 
echo Yii::$app->formatter->asDate($request->date->sec);
?>
</b>
        с <b><?php 
echo MinuteFormatter::asString($request->beginTime);
?>
</b> до
        <b><?php 
echo MinuteFormatter::asString($request->endTime);
?>
</b>
    </p>

    <p>Помещение забронировал <b><?php 
echo $request->owner->fullName;
?>
</b>, тел:
        <b><?php 
echo $request->owner->phone;
?>
</b> <?php 
echo Html::mailto('<span class="glyphicon glyphicon-envelope"></span>', $request->owner->email, ['title' => "Написать письмо"]);
?>
</p>
示例#7
0
 public function rules()
 {
     return array_merge(parent::rules(), [[['topic', 'dateInput', 'beginTimeInput', 'endTimeInput', 'mode', 'foreignOrganizations'], 'required'], ['dateInput', MongoDateValidator::className(), 'format' => 'dd.MM.yyyy', 'min' => \Yii::$app->formatter->asDate(mktime(0, 0, 0), 'dd.MM.yyyy'), 'max' => \Yii::$app->formatter->asDate(strtotime("+1 week"), 'dd.MM.yyyy')], ['beginTimeInput', MinuteValidator::className(), 'min' => MinuteFormatter::asString(\Yii::$app->params['vks.minTime']), 'max' => $this->endTimeInput, 'minuteAttribute' => 'beginTime'], ['beginTimeInput', 'compare', 'compareAttribute' => 'endTimeInput', 'operator' => '!=='], ['beginTimeInput', function ($attribute) {
         if (\Yii::$app->user->can(SystemPermission::APPROVE_REQUEST)) {
             return;
         }
         $allowTimeStamp = $this->date->sec + ($this->beginTime - \Yii::$app->params['vks.allowRequestUpdateMinute']) * 60;
         $now = time() + 3 * 60 * 60;
         if ($now > $allowTimeStamp) {
             $this->addError($attribute, "Должно быть не меньше 20 минут от текущего времени");
         }
     }], ['endTimeInput', MinuteValidator::className(), 'min' => $this->beginTimeInput, 'max' => MinuteFormatter::asString(\Yii::$app->params['vks.maxTime']), 'minuteAttribute' => 'endTime'], ['audioRecord', 'boolean'], ['audioRecord', 'filter', 'filter' => function ($value) {
         return boolval($value);
     }], ['mode', 'in', 'range' => [self::MODE_WITH_VKS, self::MODE_WITHOUT_VKS]], ['mode', 'filter', 'filter' => function ($value) {
         return intval($value);
     }], ['participantsId', 'required', 'on' => 'default', 'message' => 'Необходимо выбрать участников'], ['participantsId', function ($attribute) {
         $value = $this->{$attribute};
         if ($this->mode === self::MODE_WITH_VKS && count($value) < 2) {
             $this->addError($attribute, 'Количество участников должно быть не менее двух');
             return;
         }
         if ($this->mode === self::MODE_WITHOUT_VKS && count($value) !== 1) {
             $this->addError($attribute, 'Помещение для совещания должно быть только одно');
             return;
         }
         $allParticipants = Participant::findAllByRequest($this);
         $allParticipantsId = ArrayHelper::getColumn($allParticipants, '_id');
         foreach ($value as $participant) {
             $key = array_search($participant, $allParticipantsId);
             if ($key === false) {
                 $this->addError($attribute, 'Участник не найден');
                 return;
             } elseif ($allParticipants[$key]->isBusy) {
                 $busyParticipant = $allParticipants[$key];
                 $this->addError($attribute, "Участник '{$busyParticipant->name}' занят с " . MinuteFormatter::asString($busyParticipant->busyFrom) . " до " . MinuteFormatter::asString($busyParticipant->busyTo));
             }
         }
     }, 'on' => 'default'], ['foreignOrganizations', 'boolean'], ['rsoUploadedFiles', 'file', 'skipOnEmpty' => false, 'mimeTypes' => ['image/*', 'application/pdf', 'application/msword', 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', 'application/excel', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'], 'maxSize' => 3 * 1024 * 1024, 'maxFiles' => 3, 'when' => function ($model) {
         return (bool) $model->foreignOrganizations && count($model->rsoFiles) == 0;
     }], [['note', 'equipment'], 'safe']]);
 }
示例#8
0
 /**
  * @return string
  */
 public function getEndTimeString()
 {
     return $this->endTime ? MinuteFormatter::asString($this->endTime) : '';
 }
示例#9
0
            </div>

            <div class="col-lg-7">

                <div class="row">

                    <?php 
echo BaseHtml::activeCheckboxList($model, 'participantsId', ArrayHelper::map($participants, function ($item) {
    /** @var $item \common\models\vks\Participant */
    return (string) $item->primaryKey;
}, 'name'), ['item' => function ($index, $label, $name, $checked, $value) use($participants) {
    /** @var Participant $participant */
    $participant = $participants[$index];
    $defaultOptions = ['value' => $value, 'data' => ['company-id' => (string) $participant->companyId]];
    $label .= $participant->ahuConfirmation ? '&nbsp;<span class="glyphicon glyphicon-star text-warning"></span>' : '';
    $options = array_merge_recursive($defaultOptions, $participant->isBusy ? ['label' => $label . '<p><small>занято с ' . MinuteFormatter::asString($participant->busyFrom) . ' до ' . MinuteFormatter::asString($participant->busyTo) . '</small></p>', 'labelOptions' => ['class' => 'disabled'], 'disabled' => true] : ['label' => $label, 'data' => ['name' => $participant->name, 'short-name' => $participant->shortName, 'company-name' => $participant->company->name, 'contact' => $participant->contact, 'ip-address' => $participant->ipAddress]]);
    $tooltip = $participant->ahuConfirmation ? ['data' => ['toggle' => 'tooltip', 'html' => true, 'placement' => 'top', 'container' => '#vks-participants', 'title' => Html::tag('div', 'Бронь необходимо согласовать с') . Html::tag('div', $participant->confirmPerson->fullName) . Html::tag('div', $participant->confirmPerson->post) . Html::tag('div', 'тел: ' . $participant->confirmPerson->phone . ', ' . $participant->confirmPerson->email)]] : [];
    return Html::beginTag('div', array_merge(['class' => 'col-lg-4 vks-room', 'style' => 'display:none'], $tooltip)) . Html::checkbox($name, $checked, $options) . Html::endTag('div');
}]);
?>

                </div>

            </div>

        </div>

    </div>

    <small class="help-block"><span class="glyphicon glyphicon-info-sign"></span> Если участник отсутствует в списке,
        укажите информацию о нем в примечании:
示例#10
0
 * Created: 19.05.16 17:04
 * @copyright Copyright (c) 2016 OSKR NIAEP
 *
 * @var $list array
 * @var $this \yii\web\View
 */
use kartik\helpers\Html;
use common\components\MinuteFormatter;
$this->title = "Помещения на согласование";
?>
<div>

    <ul>

        <?php 
foreach ($list as $item) {
    ?>

            <li><?php 
    echo Html::a($item['name'] . " " . Yii::$app->formatter->asDate($item['request']->date->sec) . " c " . MinuteFormatter::asString($item['request']->beginTime) . " по " . MinuteFormatter::asString($item['request']->endTime), ['vks-request/approve-booking', 'roomId' => (string) $item['_id'], 'requestId' => (string) $item['request']->_id]);
    ?>
</li>

        <?php 
}
?>

    </ul>

</div>