示例#1
0
 public function __construct()
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->cluster = \Auth::user()->cluster;
     parent::__construct(storage_path() . '/app/sxml/RISAPI.wsdl', ['trace' => true, 'exceptions' => true, 'location' => 'https://' . $this->cluster->ip . ':8443/realtimeservice/services/RisPort', 'login' => $this->cluster->username, 'password' => $this->cluster->password, 'stream_context' => $this->cluster->verify_peer ?: stream_context_create(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false)))]);
 }
示例#2
0
 /**
  *
  */
 public function __construct()
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->cluster = \Auth::user()->cluster;
     parent::__construct('https://' . $this->cluster->ip . '/controlcenterservice2/services/ControlCenterServices?wsdl', ['trace' => true, 'exceptions' => true, 'location' => 'https://' . $this->cluster->ip . ':8443/controlcenterservice2/services/ControlCenterServices', 'login' => $this->cluster->username, 'password' => $this->cluster->password, 'stream_context' => $this->cluster->verify_peer ?: stream_context_create(array('ssl' => array('verify_peer' => false, 'verify_peer_name' => false)))]);
 }
示例#3
0
 public function observationReward()
 {
     $mission = Mission::with('type')->find(\Request::get('mission_id'));
     if ($mission->type->name == 'location') {
         return $this->locationReward(\Auth::user()->id, $mission->id);
     } else {
         return $this->routeReward(\Auth::user()->id, $mission->id);
     }
 }
示例#4
0
 /**
  * Create a new user instance after a valid registration.
  *
  * @param  array  $data
  * @return User
  */
 public function create(array $data)
 {
     $role = $data['role'];
     if ($role == 'admin' && !Auth::user()->isAdmin()) {
         $role = 'person';
     }
     $user = User::create(['nickname' => $data['nickname'], 'email' => $data['email'], 'password' => bcrypt($data['password']), 'role' => $role]);
     Person::create(['user_id' => $user->id, 'first_name' => $data['first_name'], 'last_name' => $data['last_name']]);
     return $user;
 }
示例#5
0
 /**
  * @param $phoneIP
  * @throws SoapException
  */
 function __construct($phoneIP)
 {
     if (!\Auth::user()->cluster) {
         throw new SoapException("You have no Active Cluster Selected");
     }
     $this->phoneIP = $phoneIP;
     $this->cluster = \Auth::user()->cluster;
     $this->client = new Client(['base_uri' => 'http://' . $this->phoneIP, 'verify' => false, 'connect_timeout' => 2, 'headers' => ['Accept' => 'application/xml', 'Content-Type' => 'application/xml'], 'auth' => [$this->cluster->username, $this->cluster->password]]);
     $this->reader = new Reader();
 }
 public function store()
 {
     //TODO: maybe the name of the device is not needed -> retrieve it from jwt
     $responseObs = $this->validateObservation();
     if ($responseObs->status == 'error') {
         return $responseObs;
     } else {
         $device = Device::where('device_uuid', \Request::get('device_uuid'))->first();
         //first check if the device is registered for this mission to radical
         //for our db, that means that there's a row in devices_missions table
         if (!$this->deviceService->isRegistered(\Request::get('mission_id'), \Request::get('device_uuid'))) {
             if ($this->mission == null) {
                 $this->mission = Mission::find(\Request::get('mission_id'));
             }
             if (!\Request::has('latitude') || \Request::get('latitude') == '') {
                 $latitude = number_format(0, 6);
             } else {
                 $latitude = number_format(\Request::get('latitude'), 6);
             }
             if (!\Request::has('longitude') || \Request::get('longitude') == '') {
                 $longitude = number_format(0, 6);
             } else {
                 $longitude = number_format(\Request::get('longitude'), 6);
             }
             //first create a row in devices_missions table
             $device->missions()->attach($this->mission->id, ['device_uuid' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'latitude' => $latitude, 'longitude' => $longitude, 'registration_date' => date('Y-m-d H:i:s')]);
             $this->mission->users()->attach(\Auth::user()->id);
             //then send data to radical api
             $tmp_device = ['Device_UUID' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'Model' => $device->model, 'Manufacturer' => $device->manufacturer, 'Latitude' => $latitude, 'Longitude' => $longitude, 'Type' => $device->type, 'Status' => intval($device->status), 'Registration_Date' => date('Y-m-d H:i:s')];
             $this->deviceService->registerToRadical($tmp_device);
         }
         $responseMeas = $this->validateMeasurements(\Request::get('measurements'));
         if ($responseMeas->status == 'error') {
             return \Response::json($responseMeas);
         }
         if ($this->mission == null) {
             $this->mission = Mission::find(\Request::get('mission_id'));
         }
         $observation = new Observation(['device_uuid' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'latitude' => \Request::get('latitude'), 'longitude' => \Request::get('longitude'), 'observation_date' => \Request::get('observation_date'), 'device_id' => $device->id]);
         //save new observation to the db
         $observation->save();
         $radicalMeasurements = $this->getMeasurements($observation->id);
         $radicalObservation = ['Device_UUID' => env('RADICAL_CITYNAME') . '.' . $this->mission->radical_service_id . '.' . $device->device_uuid, 'Latitude' => \Request::get('latitude'), 'Longitude' => \Request::get('longitude'), 'Observation_Date' => \Request::get('observation_date'), 'Measurements' => $radicalMeasurements];
         $this->radicalIntegrationManager->storeObservation($radicalObservation);
         return $observation;
     }
 }
 /**
  * @param $account
  * @param $data
  * @param $expenses
  * @param $vendorMap
  * @return mixed
  */
 private function parseTransactions($account, $data, $expenses, $vendorMap)
 {
     $ofxParser = new \OfxParser\Parser();
     $ofx = $ofxParser->loadFromString($data);
     $account->start_date = $ofx->BankAccount->Statement->startDate;
     $account->end_date = $ofx->BankAccount->Statement->endDate;
     $account->transactions = [];
     foreach ($ofx->BankAccount->Statement->transactions as $transaction) {
         // ensure transactions aren't imported as expenses twice
         if (isset($expenses[$transaction->uniqueId])) {
             continue;
         }
         if ($transaction->amount >= 0) {
             continue;
         }
         // if vendor has already been imported use current name
         $vendorName = trim(substr($transaction->name, 0, 20));
         $key = strtolower($vendorName);
         $vendor = isset($vendorMap[$key]) ? $vendorMap[$key] : null;
         $transaction->vendor = $vendor ? $vendor->name : $this->prepareValue($vendorName);
         $transaction->info = $this->prepareValue(substr($transaction->name, 20));
         $transaction->memo = $this->prepareValue($transaction->memo);
         $transaction->date = \Auth::user()->account->formatDate($transaction->date);
         $transaction->amount *= -1;
         $account->transactions[] = $transaction;
     }
     return $account;
 }
示例#8
0
 public function hashMatch($attribute, $value, $parameters)
 {
     return Hash::check($value, Auth::user()->{$parameters}[0]);
 }
示例#9
0
 public function addText()
 {
     $this->_methodName = 'addText';
     $this->resolveParams();
     $this->checkAuth();
     $arNeed = ['userTaskId' => 'required|numeric', 'text' => 'required'];
     $this->checkAttr($arNeed);
     $task_user = \App\UserTask::where('id', $this->_request_params['userTaskId'])->where('id_user', Auth::user()->id)->first();
     if (is_null($task_user)) {
         throw new \App\Exceptions\ExceptionApiContactnotfound($this->_request_params, $this->_typeName, $this->_methodName);
     }
     $infoTask = \App\InfoTask::where('id_taskUser', $task_user->id)->first();
     if (is_null($infoTask)) {
         $infoTask = new \App\InfoTask();
         $infoTask->id_taskUser = $task_user->id;
     }
     $infoTask->text = $this->_request_params['text'];
     $infoTask->save();
     return $this;
 }
示例#10
0
 public function changePassword()
 {
     $this->_methodName = 'edit';
     $this->resolveParams();
     // TODO Сделать изменения для админов
     $this->checkAuth();
     if (!Auth::checkAdmin()) {
         $user = Auth::user();
         $arNeed = ['oldpasswd' => 'required|min:8|max:32', 'newpasswd' => 'required|min:8|max:32'];
         $this->checkAttr($arNeed);
         if (Hash::check($this->_request_params['oldpasswd'], $user->password)) {
             $user->password = Hash::make(strip_tags(trim($this->_request_params['newpasswd'])));
             $user->save();
             return $this;
         } else {
             throw new \App\Exceptions\ExceptionApiAuthCodeinactive(['token' => $this->_request_params['token']], $this->_typeName, $this->_methodName);
         }
     } else {
         return $this;
     }
 }
示例#11
0
 /**
  * Remove book from wishlist.
  * @param  [type] $book_id [description]
  * @return [type]          [description]
  */
 public function removeBookFromWishlist($bookId)
 {
     $user_id = Auth::user()->id;
     DB::table('book_wishlist')->where('user_id', '=', $bookId)->where('book_id', '=', $book_id)->delete();
 }
示例#12
0
 public function selectOnlyReferrals($description, $referral_date, $benefiter_id, $referral_type_id)
 {
     $datesHelper = new DatesHelper();
     $referralDb = array('description' => $description, 'referral_date' => $datesHelper->makeDBFriendlyDate($referral_date), 'user_id' => \Auth::user()->id, 'benefiter_id' => $benefiter_id, 'referral_lookup_id' => $referral_type_id);
     return $referralDb;
 }
示例#13
0
 public function show()
 {
     return View::make('view.setting')->withPoints(Auth::user()->point);
 }
示例#14
0
 private function getPsychosocialSessionArrayForDBInsert($request, $socialFolderId)
 {
     $temp = $this->getPsychosocialSessionArrayForDBEdit($request);
     $temp['social_folder_id'] = $socialFolderId;
     $temp['psychologist_id'] = \Auth::user()->id;
     return $temp;
 }
示例#15
0
 private function getLegalSessionArrayForDBInsert($request, $legalFolderId)
 {
     return array('legal_folder_id' => $legalFolderId, 'legal_date' => $this->datesHelper->makeDBFriendlyDate($request['legal_date']), 'legal_comments' => $request['legal_comments'], 'user_id' => \Auth::user()->id, 'medical_location_id' => $request['medical_location_id']);
 }
 private function parseBankAccount($account, $bankAccounts, $expenses, $includeTransactions, $vendorMap)
 {
     $obj = new stdClass();
     $obj->account_name = '';
     // look up bank account name
     foreach ($bankAccounts as $bankAccount) {
         if (Hash::check($account->id, $bankAccount->account_number)) {
             $obj->account_name = $bankAccount->account_name;
         }
     }
     // if we can't find a match skip the account
     if (count($bankAccounts) && !$obj->account_name) {
         return false;
     }
     $obj->masked_account_number = Utils::maskAccountNumber($account->id);
     $obj->hashed_account_number = bcrypt($account->id);
     $obj->type = $account->type;
     $obj->balance = Utils::formatMoney($account->ledgerBalance, CURRENCY_DOLLAR);
     if ($includeTransactions) {
         $ofxParser = new \OfxParser\Parser();
         $ofx = $ofxParser->loadFromString($account->response);
         $obj->start_date = $ofx->BankAccount->Statement->startDate;
         $obj->end_date = $ofx->BankAccount->Statement->endDate;
         $obj->transactions = [];
         foreach ($ofx->BankAccount->Statement->transactions as $transaction) {
             // ensure transactions aren't imported as expenses twice
             if (isset($expenses[$transaction->uniqueId])) {
                 continue;
             }
             if ($transaction->amount >= 0) {
                 continue;
             }
             // if vendor has already been imported use current name
             $vendorName = trim(substr($transaction->name, 0, 20));
             $key = strtolower($vendorName);
             $vendor = isset($vendorMap[$key]) ? $vendorMap[$key] : null;
             $transaction->vendor = $vendor ? $vendor->name : $this->prepareValue($vendorName);
             $transaction->info = $this->prepareValue(substr($transaction->name, 20));
             $transaction->memo = $this->prepareValue($transaction->memo);
             $transaction->date = \Auth::user()->account->formatDate($transaction->date);
             $transaction->amount *= -1;
             $obj->transactions[] = $transaction;
         }
     }
     return $obj;
 }
示例#17
0
 protected function checkUserUnable()
 {
     $validator = Validator::make(Auth::user()->toArray(), ['first_name' => 'required|max:32', 'last_name' => 'required|max:32', 'street' => 'required|max:128', 'occupation' => 'required|max:64', 'city' => 'required|max:64']);
     $mes = $validator->messages();
     //dd($mes);
     if ($validator->fails()) {
         return false;
     }
     return true;
 }