コード例 #1
0
 public function notAvailable(agent $agent)
 {
     Log::info("presenceHelper::notAvailable - " . $agent->id);
     try {
         $agent->agent_available = PresenceHelper::NOT_AVAILABLE;
         $agent->save();
         $this->redis->publish("{$agent->id}_presence", PresenceHelper::NOT_AVAILABLE);
         Log::info("presenceHelper::notAvailable - true");
         LogHelper::logActivityId(gethostname(), __METHOD__, $agent->id, 0, 7, "agent unavailable", 22, 0);
         return true;
     } catch (\Exception $e) {
         Log::error(PresenceHelper::LOG_TAG . " Error: {$e->getMessage()}");
         return false;
     }
 }
コード例 #2
0
 /**
  *   Overwriting logout method to toggle availablity
  */
 public function getLogout(Request $request)
 {
     if (Auth::user() !== null) {
         $data = Auth::user();
         agent::where('id', '=', $data->id)->update(["agent_available" => 0]);
         LogHelper::logActivityId(gethostname(), __METHOD__, $data->id, 0, 0, "Last Logout", 18, 0);
     }
     return $this->authLogout();
 }
コード例 #3
0
 /**
  *	This function will use the $_REQUEST object to return 
  * an agent object representing the agent to route the call to.
  * we will route the call on the following parameters in order of importance:
  *
  *	1. Availability - Are they online accepting incoming calls?
  *	2. Access/License - Are they Licensed and have Access to the state?
  *	3. Carrier Availability - How many carriers can they sell for?
  *
  */
 public static function routeCallToAgent($callSid)
 {
     Log::info("RouteHelper::routeCallToAgent");
     //Get Zipcode
     $callInfo = lead_call::where("call_sid", "=", $callSid)->firstOrFail();
     //we need a mysqli connection because laravel can't call stored procedures
     $dbConfig = Config::get("database.connections.mysql");
     $db = new \mysqli($dbConfig['host'], $dbConfig['username'], $dbConfig['password'], $dbConfig['database']);
     if ($db->connect_errno > 0 || !$db) {
         Log::error("Could not connecto to database in RouteHelper Mysqli");
         Log::error(mysql_error());
         return array("result" => "error", "message" => "We are sorry.  An unknown error has occured.  Please try again.");
     }
     $db->query("SET @zipcode = '" . $db->real_escape_string($callInfo->zipcode) . "'");
     Log::info("SET THE ZIP TO" . $callInfo->zipcode);
     $result = $db->query("CALL agent_available_v0_0_2(@zipcode)");
     Log::info("RouteHelper::routeCallToAgent");
     if (!$result) {
         Log::error("Could not query stored procedure in RouteHelper Mysqli");
         if ($db) {
             $db->close();
         }
         return array("result" => "error", "message" => "We are sorry.  An unknown error has occured.  Please try again.");
     }
     $agentId = -1;
     Log::info("tryin to get and set agent id");
     if ($result->num_rows > 0) {
         $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
         $agentId = $row["agent_id"];
         Log::info("Got agent number: {$agentId}");
     } else {
         return array("result" => "error", "message" => "There are no available agents.");
     }
     $db->close();
     $routeAgent = agent::find($agentId);
     if ($routeAgent == null) {
         LogHelper::logCall(gethostname(), __METHOD__, null, $callSid, -1, null);
         return array("result" => "error", "message" => "The available agents do not have any carriers.");
     }
     LogHelper::logCall(gethostname(), __METHOD__, $routeAgent->id, $callSid, null, null);
     $routeAgent->total_calls_today = $routeAgent->total_calls_today + 1;
     $routeAgent->save();
     Log::info("RouteHelper::routeCallToAgent call " . $callSid . " agent " . $routeAgent->id);
     return array('result' => "success", "agent" => $routeAgent);
 }
コード例 #4
0
 public static function sendSMS($message, $to, $mediaUrl = null, $from = null)
 {
     require_once '../vendor/twilio/sdk/Services/Twilio.php';
     // Twilio credentials moved to config/services.php - this code does not work in controller
     $cfg = Config::get('services.twilio');
     $accountSid = $cfg["accountSid"];
     $authToken = $cfg['authToken'];
     $client = new \Services_Twilio($accountSid, $authToken);
     if ($from == null) {
         $agent = agent::find(Auth::user()->id);
         $from = $agent->FriendlyName->phone_number;
     }
     $messageData = array('To' => $to, 'From' => $from, 'Body' => $message);
     if ($mediaUrl != null) {
         $messageData["MediaUrl"] = $mediaUrl;
     }
     $client->account->messages->create($messageData);
 }
コード例 #5
0
ファイル: AfterLogin.php プロジェクト: Tyler-Gauch/DigiCommon
 /**
  * Handle an incoming request.
  *
  * @param  \Illuminate\Http\Request  $request
  * @param  \Closure  $next
  * @return mixed
  */
 public function handle($request, Closure $next)
 {
     $response = $next($request);
     $application = getenv("APPLICATION");
     if (Auth::check()) {
         $user = Auth::user();
         $agent = agent::find($user->id);
         // PROT-15
         if ($agent->active != 1) {
             LogHelper::logActivityId(gethostname(), __METHOD__, $user->id, 0, 0, "login attempt by inactive agent", 74, 0);
             Log::info("login attempt by inactive agent " . $request->email);
             Auth::logout();
             throw new \Exception("Access Denied");
         }
         // if the user is logging into the dashboard server they must minimally have admin rights
         // if the user is logging into the agent server they must have user rights
         if ($application == 'admin' && !$agent->hasRole("ROLE_ADMIN")) {
             LogHelper::logActivityId(gethostname(), __METHOD__, $user->id, 0, 0, "admin login failed", 74, 0);
             Log::info("login admin failed " . $request->email);
             Auth::logout();
             throw new \Exception("Access Denied");
         } elseif ($application != 'admin' && !$agent->hasRole("ROLE_USER")) {
             LogHelper::logActivityId(gethostname(), __METHOD__, $user->id, 0, 0, "agent login failed", 74, 0);
             Log::info("login agent failed " . $request->email);
             Auth::logout();
             throw new \Exception("Access Denied");
         }
         // log something informative
         if ($application == 'admin') {
             LogHelper::logActivityId(gethostname(), __METHOD__, $user->id, 0, 0, "admin login", 17, 0);
         } else {
             LogHelper::logActivityId(gethostname(), __METHOD__, $user->id, 0, 0, "agent login", 17, 0);
         }
         $agent->agent_available = 0;
         $agent->last_login = Carbon::now();
         $agent->save();
     }
     return $response;
 }