public function initValidator()
 {
     $this->validator = new Violin();
     $this->validator->addRuleMessage('required', "Поле <b>{field}</b> обязательно для заполнения");
     $this->validator->addRuleMessage('matches', 'Поле <b>{field}</b> должно совпадать с полем <b>{$0}</b>');
     $this->validator->addRuleMessage('int', 'Поле <b>{field}</b> должно содержать только цифры');
     $this->validator->addRuleMessage('email', "Поле <b>{field}</b> должно иметь корректный формат адреса электронной почты(во <b>внутреннем</b> сегменте банка), например SBT-Tomarov-IV<b>@mail.ca.sbrf.ru</b> ");
     $this->validator->addRuleMessage('pwd', 'Поле {field} должно содержать только латинские буквы, цифры или спецсимволы(!@#$%*). Минимум 5 символов');
     $this->validator->addRule('pwd', function ($value, $input, $args) {
         $result = false;
         if (preg_match("/^[0-9A-Za-z!@#\$%*]{4,}\$/", $value)) {
             $result = true;
         }
         return $result;
     });
     $this->validator->addRuleMessage('userFree', 'Пользователь с именем <b>{value}</b> уже существует в системе');
     $this->validator->addRule('userFree', function ($value, $input, $args) {
         $userCount = User::where('login', strtoupper($value))->count();
         return $userCount ? false : true;
     });
     $this->validator->addRuleMessage('attendance_is_tech_supportable', 'На выбранной точке ВКС, тех. поддержка не оказывается, извините');
     $this->validator->addRule('attendance_is_tech_supportable', function ($value, $input, $args) {
         if (!$value) {
             return true;
         }
         //if value not presented, continue
         try {
             $att = Attendance::findOrFail($value);
         } catch (Exception $e) {
             return false;
         }
         return $att->tech_supportable ? true : false;
     });
 }
 function test2($date, $attendance_id)
 {
     try {
         $attendance = Attendance::findOrFail($attendance_id);
     } catch (Exception $e) {
         $this->error('404');
     }
     $vc = new Vks_controller();
     $start = date_create($date)->setTime(0, 0);
     $end = date_create($date)->setTime(23, 59);
     $requested_participant_id = intval($attendance_id);
     $vkses = Vks::where('start_date_time', ">=", $start)->where('start_date_time', '<=', $end)->whereIn('status', [VKS_STATUS_PENDING, VKS_STATUS_APPROVED])->notSimple()->with('participants')->get();
     $filtered_vkses = array();
     if (count($vkses)) {
         foreach ($vkses as $vks) {
             if (count($vks->participants)) {
                 foreach ($vks->participants as $participant) {
                     if ($participant->id === $requested_participant_id) {
                         $filtered_vkses[] = $vc->humanize($vks);
                     }
                 }
             }
         }
     }
     return $this->render('test/test2', compact('attendance', 'filtered_vkses', 'date'));
 }
示例#3
0
                    <?php 
if ($data['backPack']->parent_id == 1) {
    ?>
                        <option value="<?php 
    echo $data['backPack']->parent_id;
    ?>
">Корневой контейнер</option>
                    <?php 
} else {
    ?>
                        <option
                            value="<?php 
    echo $data['backPack']->parent_id;
    ?>
"><?php 
    echo Attendance::findOrFail($data['backPack']->parent_id)->name;
    ?>
</option>
                    <?php 
}
?>
                    <?php 
foreach ($data['containers'] as $container) {
    ?>
                        <?php 
    if ($backPack->parent_id != $container->id) {
        ?>
                            <?php 
        if ($container->id !== $backPack->id) {
            ?>
                                <option value="<?php 
示例#4
0
                                <?php 
    if ($data['rootId'] == 1) {
        ?>
                                    <option value="<?php 
        echo $data['rootId'];
        ?>
">Корневой контейнер</option>
                                <?php 
    } else {
        ?>
                                    <option
                                        value="<?php 
        echo $data['rootId'];
        ?>
"><?php 
        echo Attendance::findOrFail($data['rootId'])->name;
        ?>
</option>
                                <?php 
    }
    ?>
                                <?php 
    foreach ($data['containers'] as $container) {
        ?>
                                    <?php 
        if ($container->id != $data['rootId']) {
            ?>
                                        <?php 
            if ($container->id == 1) {
                ?>
                                            <option value="<?php 
 public function showSchedule($showType, $date, $attendance_id)
 {
     try {
         $attendance = Attendance::findOrFail($attendance_id);
     } catch (Exception $e) {
         $this->error('404');
     }
     $filename = NODE_REAL_PATH . 'storage/user_' . md5(App::$instance->user->ip) . '.txt';
     if (is_file($filename)) {
         $last_seen_stored = json_decode(file_get_contents($filename), JSON_PRETTY_PRINT);
     } else {
         $last_seen_stored = array();
     }
     //        if (isset($_COOKIE['last_seen_stored'])) {
     //            $last_seen_stored = json_decode($_COOKIE['last_seen_stored'], JSON_PRETTY_PRINT);
     //        } else {
     //            $last_seen_stored = array();
     //        }
     $last_seen = $last_seen_stored;
     //to view
     $last_seen = array_reverse($last_seen);
     if (count($last_seen_stored) > 15) {
         array_shift($last_seen_stored);
     }
     $key = array_search($attendance->toArray(), $last_seen_stored);
     if (is_numeric($key)) {
         unset($last_seen_stored[$key]);
     }
     array_push($last_seen_stored, $attendance->toArray());
     //        setrawcookie('last_seen_stored', json_encode($last_seen_stored, JSON_FORCE_OBJECT), 60 * 60 * 24 * 90);
     file_put_contents($filename, json_encode($last_seen_stored));
     if ($showType == self::SHOW_SCHEDULE_AS_LIST) {
         $vc = new Vks_controller();
         $start = date_create($date)->setTime(0, 0);
         $end = date_create($date)->setTime(23, 59);
         $requested_participant_id = intval($attendance_id);
         $vkses = Vks::where('start_date_time', ">=", $start)->where('start_date_time', '<=', $end)->whereIn('status', [VKS_STATUS_PENDING, VKS_STATUS_APPROVED])->notSimple()->with('participants', 'connection_codes')->orderBy("start_date_time", 'desc')->get();
         $filtered_vkses = array();
         if (count($vkses)) {
             foreach ($vkses as $vks) {
                 if (count($vks->participants)) {
                     foreach ($vks->participants as $participant) {
                         if ($participant->id === $requested_participant_id) {
                             $filtered_vkses[] = $vc->humanize($vks);
                         }
                     }
                 }
             }
         }
         return $this->render('attendance/schedule_list', compact('attendance', 'filtered_vkses', 'date', 'last_seen'));
     } else {
         return $this->render('attendance/schedule_graph', compact('date', 'attendance', 'last_seen'));
     }
 }