public static function queryUserInfo($keyword, $user_id = null) { $user_records = Watchdog::getUserRecords($user_id); $user_queues = Analytics::getUserQueues($user_id); $user_data = array_merge($user_records, $user_queues); $values = []; foreach ($user_data as $data) { if ($keyword === 'geolocation' && isset($data['latitude'])) { $values[] = $data['latitude'] . ', ' . $data['longitude']; } else { if ($keyword === 'broadcast' && isset($data['business_id'])) { try { $values[] = Business::name($data['business_id']); } catch (Exception $e) { $values[] = 'Deleted Businesses'; } } else { if (isset($data[$keyword])) { $values[] = $data[$keyword]; } } } } $numbers = array_count_values($values); return $numbers; }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(Request $request, $id) { $validacao = Validator::make($request->all(), ['codigo' => 'required|string']); if ($validacao->fails()) { return redirect('admin/configuracoes/analytics')->withErrors($validacao)->withInput(); } else { try { $analytic = Analytics::find($id); $analytic->codigo = $request->codigo; $analytic->save(); session()->flash('flash_message', 'Registro atualizado com sucesso!'); return redirect('admin/configuracoes/analytics'); } catch (\Exception $e) { LogR::exception($analytic, $e); session()->flash('flash_message', 'Ops!! Ocorreu algum problema!. ' . $e->getMessage()); } } }
/** * Bootstrap any application services. * * @return void */ public function boot() { if (collect(Analytics::find(1))->contains(1)) { view()->share('analytics', Analytics::find(1)); } if (collect(Configuracao::find(1))->contains(1)) { view()->share('confsite', Configuracao::find(1)); } if (collect(Comentarios::where('id_status_comentario', 1)->get())->count()) { view()->share('comments', collect(Comentarios::where('id_status_comentario', 1)->get())->count()); } view()->share('sobre', Sobres::findOrFail(1)); if (Request::is('blog') or Request::is('blog/*')) { view()->share('categorias', Categoria::where('id_tipo_categoria', 3)->get()); view()->share('ultimas', collect(Noticia::todas())->take(4)); } if (Request::is('admin') or Request::is('admin/*')) { view()->share('ajuda', Helps::all()); } }
public static function sendNumberNextAndroid($transaction_number, $diff) { $priority_queue = PriorityQueue::find($transaction_number); if ($priority_queue) { $user_id = $priority_queue->user_id; $priority_number = $priority_queue->priority_number; $queue_platform = $priority_queue->queue_platform; $email = $priority_queue->email; $terminal_id = TerminalTransaction::terminalId($transaction_number); $terminal_name = $terminal_id != 0 ? Terminal::name($terminal_id) : ''; $business_id = $terminal_id != 0 ? Business::getBusinessIdByTerminalId($terminal_id) : 0; $business_name = $business_id != 0 ? Business::name($business_id) : ''; $waiting_time = Analytics::getWaitingTime($business_id); $estimated_time = Helper::millisecondsToHMSFormat($waiting_time); $message = "Your number ({$priority_number}) will be called in approximately {$estimated_time}. "; if ($diff == 1) { $message .= "There is currently {$diff} person ahead of you at the {$terminal_name} at {$business_name}."; } else { $message .= "There are currently {$diff} people ahead of you at the {$terminal_name} at {$business_name}."; } if ($queue_platform != 'web' && $queue_platform != 'specific') { $gcm_token = User::gcmToken($user_id); if ($gcm_token) { Notifier::sendAndroid($gcm_token, $message); } } else { if (($queue_platform == 'web' || $queue_platform == 'specific') && $email != null) { $user = User::searchByEmail($email); $gcm_token = $user ? User::gcmToken($user['user_id']) : null; if ($gcm_token) { Notifier::sendAndroid($gcm_token, $message); } } } } }
public static function countNumbersByCountry($business_id, $temp_start_date, $action) { $count = []; for ($i = 0; $i < count($business_id); $i++) { $temp_count = Analytics::where('business_id', '=', $business_id[$i]->business_id)->where('date', '=', $temp_start_date)->where('action', '=', $action)->count(); array_push($count, $temp_count); } return array_sum($count); }
/** * ARA merges active businesses and other businesses * @return array */ public static function getDashboardBusinesses() { $businesses = array(); $active_businesses = Business::getProcessingBusinesses(); $all_businesses = Business::where('status', '=', 1)->get()->toArray(); foreach ($all_businesses as $index => $business) { $open_time_string = $business['open_hour'] . ':' . Helper::doubleZero($business['open_minute']) . ' ' . $business['open_ampm']; $closing_time_string = $business['close_hour'] . ':' . Helper::doubleZero($business['close_minute']) . ' ' . $business['close_ampm']; $waiting_time = Analytics::getWaitingTimeString($business['business_id']); //get time before the next available number is called. should be in minutes //ARA more info for business cards $first_service = Service::getFirstServiceOfBusiness($business['business_id']); $all_numbers = ProcessQueue::allNumbers($first_service->service_id); $last_number_called = count($all_numbers->called_numbers) > 0 ? $all_numbers->called_numbers[0]['priority_number'] : 'none'; $next_number = $all_numbers->next_number; $is_calling = count($all_numbers->called_numbers) > 0 ? true : false; $is_issuing = count($all_numbers->uncalled_numbers) + count($all_numbers->timebound_numbers) > 0 ? true : false; $last_active = Analytics::getLastActive($business['business_id']); $business_details = array('business_id' => $business['business_id'], 'name' => $business['name'], 'local_address' => $business['local_address'], 'open_time' => $open_time_string, 'close_time' => $closing_time_string, 'waiting_time' => $waiting_time, 'last_number_called' => $last_number_called, 'next_available_number' => $next_number, 'is_calling' => $is_calling, 'is_issuing' => $is_issuing, 'last_active' => $last_active); //Add active business to top of list if (isset($active_businesses[$business['business_id']])) { array_unshift($businesses, $business_details); } else { array_push($businesses, $business_details); } } return $businesses; }