public function pullVersion($vksId, $versionId)
 {
     if ($versionId == 0) {
         $vks = Vks::full()->findOrFail($vksId);
         $vks->version = new stdClass();
         $vks->version->version = null;
     } else {
         $vksD = unserialize(VksVersion::where("vks_id", $vksId)->where("version", $versionId)->first(['dump'])->dump);
         $vks = new Vks();
         foreach ((array) $vksD as $param => $value) {
             $vks->{$param} = $value;
         }
         $vks->version = VksVersion::where("vks_id", $vksId)->with('changer')->where("version", $versionId)->first(['vks_id', 'version', 'created_at', 'changed_by'])->toArray();
     }
     $vksCtrl = new Vks_controller();
     $vksCtrl->humanize($vks);
     $res = array();
     foreach ($vks->toArray() as $key => $val) {
         if (!is_object($val)) {
             $res[$key] = $val;
         } else {
             $res[$key] = (array) $val;
         }
     }
     return $res;
 }
 public function isCodeInUse($code, $period_start, $period_end, $force_no_ajax = false)
 {
     $use = false;
     $period_start = $period_start instanceof DateTime ? $period_start : date_create($period_start);
     $period_end = $period_end instanceof DateTime ? $period_end : date_create($period_end);
     //        dump($period_start, $period_end);
     $vc = new Vks_controller();
     //how much digits in num
     $digits = strlen((string) $code);
     $vkses = Vks::with('connection_codes')->where('start_date_time', '<=', $period_end->modify("+" . Settings_controller::getOther('pause_gap') . " minutes"))->where('end_date_time', '>=', $period_start->modify("-" . Settings_controller::getOther('pause_gap') . " minutes"))->approved()->get(['id', 'title', 'start_date_time', 'end_date_time', 'date']);
     //        dump($vkses);
     foreach ($vkses as $vks) {
         if (count($vks->connection_codes)) {
             foreach ($vks->connection_codes as $vcode) {
                 if (substr($vcode->value, -$digits) == $code) {
                     $vks = $vc->humanize($vks);
                     $use = $vks;
                     break;
                 }
             }
         }
     }
     if ($force_no_ajax) {
         return $use;
     }
     //        ST::makeDebug($use);
     if (ST::isAjaxRequest()) {
         if ($use) {
             $use = $use->toJson();
         }
         print json_encode($use);
     } else {
         return $use;
     }
 }
Пример #3
0
 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'));
 }
Пример #4
0
 public function search($phrase)
 {
     if (ST::isAjaxRequest()) {
         $vksWSC = new Vks_controller();
         $result = [];
         $result['ws'] = Vks::where("id", $phrase)->whereIn('status', [VKS_STATUS_APPROVED, VKS_STATUS_PENDING])->take(1)->get();
         foreach ($result['ws'] as $vks) {
             $vksWSC->humanize($vks);
         }
         print json_encode($result);
     }
 }
 public function pullAndSendRequests()
 {
     $vc = new Vks_controller();
     $requests = TechSupportRequest::where("status", TechSupportRequest::STATUS_READY_FOR_SEND)->with('attendance', 'owner')->get();
     $temp_mails = 'Tomarov1-iv@mail.ca.sbrf.ru; DenisovDE@ab.srb.local';
     if (count($requests)) {
         foreach ($requests as $request) {
             $vks = Vks::full()->find($request->vks_id);
             $vc->humanize($vks);
             $appHttpPath = NODE_HTTP_PATH;
             $message = App::$instance->twig->render('mails/v2/tech_support/new.twig', compact('request', 'vks', 'appHttpPath'));
             Mail::sendMailToStack($temp_mails, 'Запрос тех. поддержки для точки ' . $request->attendance->name . ' на ВКС #' . $vks->id, $message);
             $request->status = TechSupportRequest::STATUS_DELIVERED;
             $request->save();
         }
     }
 }
 public function collect()
 {
     $vc = new Vks_controller();
     $request = $this->request->request;
     //        dump($request);
     $this->validator->validate(['Начало' => [$request->get('dates')['start'], 'required|date'], 'Окончание' => [$request->get('dates')['end'], 'required|date']]);
     if (!$this->validator->passes()) {
         $this->putUserDataAtBackPack($this->request);
         App::$instance->MQ->setMessage($this->validator->errors()->all(), 'danger');
         ST::redirect("back");
     }
     $start = date_create($request->get('dates')['start']);
     $end = date_create($request->get('dates')['end']);
     if ($start > $end) {
         $this->putUserDataAtBackPack($this->request);
         App::$instance->MQ->setMessage("Дата начала больше даты окончания", 'danger');
         ST::redirect("back");
     }
     if (date_diff($end, $start)->days > 90) {
         $this->putUserDataAtBackPack($this->request);
         App::$instance->MQ->setMessage("Задан слишком большой диапазон для выборки, максимум 60 дней", 'danger');
         ST::redirect("back");
     }
     //prepare filter
     $statuses = [];
     if ($request->has('filter') && isset($request->get('filter')['status']) && count($request->get('filter')['status'])) {
         foreach ($request->get('filter')['status'] as $status => $indicator) {
             $statuses[] = $status;
         }
     }
     //        dump($statuses);
     $collectVkses = [];
     $collectVksesRaw = Vks::where('start_date_time', '>=', $start)->where('start_date_time', "<=", $end)->whereIn('status', $statuses)->full()->get();
     if (count($collectVksesRaw)) {
         foreach ($collectVksesRaw as $vks) {
             $collectVkses[] = $vc->humanize($vks);
         }
     } else {
         $this->putUserDataAtBackPack($this->request);
         App::$instance->MQ->setMessage("ВКС в запрашиваемом периоде не найдено, попробуйте изменить запрос", 'info');
         ST::redirect("back");
     }
     //        dump($collectVkses);
     $this->makeExcel($collectVkses);
 }
 function pullAndSendFromStack()
 {
     $vc = new Vks_controller();
     $pullMails = OutlookCalendarRequest::notSended()->get();
     if (count($pullMails)) {
         foreach ($pullMails as $outlookRequest) {
             $vks = Vks::full()->find($outlookRequest->vks_id);
             if ($vks) {
                 $vc->humanize($vks);
                 Mail::sendIcalEvent($vks, $outlookRequest->request_type, $outlookRequest->user);
                 App::$instance->log->logWrite(LOG_MAIL_SENDED, 'Outlook event invite sended to: ' . $outlookRequest->user->email);
                 $outlookRequest->send_status = OutlookCalendarRequest::SEND_STATUS_COMPLETED;
                 $outlookRequest->save();
             } else {
                 App::$instance->log->logWrite(LOG_MAIL_SENDED, 'Outlook event invite can\'t be sended, vks not found, vks_id:' . $outlookRequest->vks_id . ', request_id:' . $outlookRequest->id);
             }
         }
     }
 }
Пример #8
0
 public function show($filter = 'all')
 {
     Auth::isLoggedOrDie(App::$instance);
     $selectedFilter = mb_strtolower($filter);
     $filters = ['all', 'meaning', 'pending', 'status', 'invited', 'deleted'];
     if (!in_array($selectedFilter, $filters)) {
         App::$instance->MQ->setMessage("Фильтр не определен, вам будут показаны все записи");
     }
     $statusesForSelect = [];
     switch ($selectedFilter) {
         case 'all':
             $statusesForSelect = [VKS_STATUS_DELETED, VKS_STATUS_APPROVED, VKS_STATUS_PENDING, VKS_STATUS_DROP_BY_USER];
             break;
         case 'meaning':
             $statusesForSelect = [VKS_STATUS_APPROVED, VKS_STATUS_PENDING];
             break;
         case 'pending':
             $statusesForSelect = [VKS_STATUS_PENDING];
             break;
         case 'status':
             $statusesForSelect = [VKS_STATUS_APPROVED];
             break;
         case 'deleted':
             $statusesForSelect = [VKS_STATUS_DELETED, VKS_STATUS_DROP_BY_USER];
             break;
         default:
             $statusesForSelect = [VKS_STATUS_DELETED, VKS_STATUS_APPROVED, VKS_STATUS_PENDING, VKS_STATUS_DROP_BY_USER];
             break;
     }
     $vksList = Vks::where('owner_id', App::$instance->user->id)->whereIn('status', $statusesForSelect)->full()->take($this->getQlimit(30))->skip($this->getQOffset())->orderBy($this->getQOrder(), $this->getQVector())->get();
     $vksCtrl = new Vks_controller();
     foreach ($vksList as &$vks) {
         $vks->manipulatable = VKSTimeAnalizator::isManipulatable($vks);
         $vks->dayBeforeStart = VKSTimeAnalizator::is24ForBegin($vks);
         $vks = $vksCtrl->humanize($vks);
         //            dump($vks);
     }
     $recordsCount = Vks::where('owner_id', App::$instance->user->id)->whereIn('status', $statusesForSelect)->count();
     //pages
     $pages = RenderEngine::makePagination($recordsCount, $this->getQlimit(30), 'route');
     $this->render("lk/index", compact('vksList', 'pages', 'filter'));
 }
require_once NODE_REAL_PATH . 'config/autoloader.php';
//local autoloader
require_once CORE_REPOSITORY_REAL_PATH . 'vendor/autoload.php';
//vendor
$app = App::get_instance($params);
require_once NODE_REAL_PATH . 'init.php';
$app->user = new Auth();
$app->node = MY_NODE;
//------------------------ !main load end!------------------
ini_set("max_execution_time", 0);
$connection = new AMQPConnection($credentials);
$connection->connect();
//Create and declare channel
$channel = new AMQPChannel($connection);
//AMQPC Exchange is the publishing mechanism
$vc = new Vks_controller();
$callback_func = function (AMQPEnvelope $message, AMQPQueue $q) use(&$max_consume, $vc) {
    $data = json_decode($message->getBody());
    print '---------------query--------------' . "\r\n";
    echo sprintf(" QueueName: %s", $q->getName()), PHP_EOL;
    print '---------------received!--------------' . "\r\n";
    try {
        $vks = Vks::approved()->notEnded()->findOrFail($data->vks_id);
        $vc->humanize($vks);
        $user = User::find($data->user_id);
        if (!OutlookCalendarRequest::where('user_id', $user->id)->where('vks_id', $vks->id)->count()) {
            $reSend = OutlookCalendarRequest::create(array('user_id' => $user->id, 'vks_id' => $vks->id, 'request_type' => $data->request_type, 'send_status' => OutlookCalendarRequest::SEND_STATUS_COMPLETED));
            App::$instance->log->logWrite(LOG_OTHER_EVENTS, "New Outlook request create for " . $user->id . ', vks: ' . $vks->id);
        } else {
            if ($data->force) {
                $reSend = OutlookCalendarRequest::where('user_id', $user->id)->where('vks_id', $vks->id)->first();
Пример #10
0
 private function getLoadAtPeriod($timeSpot1, $timeSpot2, $serverNum)
 {
     $result = Null;
     switch ($serverNum) {
         case 0:
             foreach (Vks::where('start_date_time', '<=', $timeSpot2)->where('end_date_time', '>=', $timeSpot1)->approved()->get(['id']) as $vks) {
                 $result += Vks_controller::countParticipants($vks->id);
             }
             break;
     }
     return $result;
 }
 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'));
     }
 }