/** * Change Item Expiration * * @param itemId - required - * Item Id. * @param expiration - required - * The expiration duration in minutes. A value of 0 indicates that the file never expires. * @return An Expiration object with expiration date as status or the error code and message * returned by the server. * */ public function changeExpiration($itemId, $expiration) { $parameters = array('expiration' => $expiration); $urld = 'dpi/v1/item/expiration/' . $itemId; $this->response = $this->_restTransportInstance->sendRequest($urld, $parameters, 'POST', $this->_authToken); $responseBody = simplexml_load_string($this->response); $returnObject = new Expiration(); if ($responseBody === false) { $errorCode = 'N/A'; $errorMessage = 'The server has encountered an error, please try again.'; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } else { if (empty($responseBody->errorStatus)) { $status = (string) $responseBody->status; $returnObject->setStatus($status); } else { $errorCode = (string) $responseBody->errorStatus->code; $errorMessage = (string) $responseBody->errorStatus->message; $errorObject = new ErrorStatus($errorCode, $errorMessage); $returnObject->setErrorStatus($errorObject); } } return $returnObject; }
public function testTimezone() { $akl = new \DateTime('2014-01-01 13:00:00', new \DateTimeZone('Pacific/Auckland')); $utc = new \DateTime('2014-01-01 00:00:00', new \DateTimeZone('UTC')); $this->claim->setValue($akl); $this->assertSame($utc->getTimestamp(), $this->claim->getValue()); }
public function index() { $user_id = Auth::user()->id; $breadcrumbs = Data_users::where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name; $colonies_inactive = Expiration::where('status', '=', 1)->get(); $admin_colonies = AssigmentRoleHab::where('role_id', '=', 2)->get(); return View::make('dashboard.colonies.inactive', ['nombre' => $breadcrumbs_data, 'colonies' => $colonies_inactive, 'admin' => $admin_colonies]); }
public function confirm($code) { $confirm = InvitedNeighbors::where('Confirmation_code', '=', $code)->first(); if (!$confirm->confirmed) { //$confirm->confirmed = true; //$confirm->update(['id']); $email = $confirm->email; $urbanism_id = $confirm->urbanism_id; $colony = Urbanism::where('id', '=', $urbanism_id)->pluck('colony_id'); $expiration = Expiration::where('colony_id', '=', $colony)->first(); $datetime2 = new DateTime($expiration->expiration); $datetime1 = new DateTime(date('Y-m-d')); $interval = $datetime1->diff($datetime2); $days_expiration = $interval->format('%a'); Session::put('days_expiration', $days_expiration); $usuario = UserNeighbors::where('email', '=', $email)->first(); if ($usuario) { $rol_vecino = AssigmentRole::where('colony_id', '=', $colony)->where('user_id', '=', $usuario->id)->where('role_id', '=', 6)->first(); if ($rol_vecino) { $notice_msg = 'Ya se encuentra como vecino en la Colonia, acceda ahora a Habitaria'; return Redirect::action('UsersController@login')->with('notice', $notice_msg); } else { $neighbor = Neighbors::where('user_id', '=', $usuario->id)->first(); if ($neighbor) { $neighborP = NeighborProperty::where('neighbors_id', '=', $neighbor->id)->where('urbanism_id', '=', $urbanism_id)->first(); if (!$neighborP) { return Redirect::action('NeighborController@register_properties', array('neighbor' => $neighbor->id, 'urbanism_id' => $urbanism_id)); } } else { return Redirect::action('NeighborController@register_neighbors', array('user' => $usuario->id, 'urbanism_id' => $urbanism_id)); } } } else { $urbanism = Urbanism::findOrFail($urbanism_id); $urbanism_name = $urbanism->name; $urbanism_type = $urbanism->urbanism_type_id; if ($urbanism_type == 3) { $catalog = BuildingCatalog::where('urbanism_id', '=', $urbanism_id)->orderBy('id', 'ASC')->lists('description', 'id'); $select = '¿Piso donde vive?'; $select_name = 'name_floor'; } else { $catalog = StreetCatalog::where('urbanism_id', '=', $urbanism_id)->orderBy('id', 'ASC')->lists('name', 'id'); $select = '¿Calle donde vive?'; $select_name = 'name_street'; } $notice_msg = Lang::get('confide::confide.alerts.confirmation_invitation'); return View::make('dashboard.neighbors.create', ['email' => $email, 'urbanism' => $urbanism_name, 'urbanism_id' => $urbanism_id, 'urbanism_type' => $urbanism_type, 'catalog' => $catalog, 'code' => $code, 'select_name' => $select_name, 'select' => ['' => $select], 'notice' => $notice_msg]); } } else { $notice_msg = 'Acceda a Habitaria con su usuario creado'; return Redirect::action('UsersController@login')->with('notice', $notice_msg); } }
public static function boot() { parent::boot(); static::creating(function ($expiration) { do { $token = sha1(uniqid() . time()); $count = Expiration::where('token', $token)->count(); } while ($count != 0); $expiration->token = $token; $minutes = intval(Setting::key('link_duration')->first()->value) > 0 ? intval(Setting::key('link_duration')->first()->value) : 60; $expiration->expiration = Carbon::now()->addMinutes($minutes); }); }
public function license_store() { $data = Input::all(); $colonia = Input::get('colony_id'); $code = Input::get('code'); $license_colonia = License::where('colony_id', '=', $colonia)->get(); $code_exist = 0; foreach ($license_colonia as $lic) { if ($code == Crypt::decrypt($lic->code)) { $code_exist = 1; $code_id = $lic->id; $lic_status = $lic->status; } } if ($code_exist == 1) { if ($lic_status == 0) { $license = License::where('id', '=', $code_id)->first(); $license->status = 1; if ($license->update(['id'])) { $expiration = Expiration::where('colony_id', '=', $colonia)->first(); $expiration->status = 2; $expiration->update(['id']); Session::put('days_expiration', 0); $expiration_lic = LicenseExpiration::where('colony_id', '=', $colonia)->first(); if ($expiration_lic->expiration == null) { $expiration_old = date('Y-m-j'); } else { $expiration_old = date('Y-m-j', strtotime($expiration_lic->expiration)); } $newExpiration = strtotime('+' . $license->months . ' month', strtotime($expiration_old)); $newExpiration = date('Y-m-j', $newExpiration); $expiration_lic->expiration = $newExpiration; $expiration_lic->update(['id']); $datetime2 = new DateTime($expiration_lic->expiration); $datetime1 = new DateTime(date('Y-m-d')); $interval = $datetime1->diff($datetime2); $days_expiration = $interval->format('%a'); Session::put('lic_fecha_expiration', $expiration_lic->expiration); Session::put('lic_expiration', $days_expiration); $notice_msg = 'Código de la licencia activado'; return Redirect::route('home')->with('notice_modal', $notice_msg); } } else { $error_msg = 'Este Código de licencia ya se fue utilizado'; return Redirect::back()->with('error_modal', $error_msg); } } else { $error_msg = 'Código de la licencia inválido'; return Redirect::back()->with('error_modal', $error_msg); } }
public function download($token) { $e = Expiration::where('token', $token)->first(); if ($e) { $expirationDate = Carbon::parse($e->expiration); $now = Carbon::now(); if ($expirationDate->lte($now)) { return Response::download(public_path() . '/uploads/plugins/' . Setting::key('plugin_zip')->first()->value); } else { echo "Su enlace ha expirado, consulte con el administraor del sistema"; } } else { App::abort(403, 'Unauthorized action.'); } }
public function promo_store() { $data = Input::all(); $colonia = Input::get('colony_id'); $code = Input::get('code'); $promo_colonia = Promo::where('colony_id', '=', $colonia)->get(); $code_exist = 0; foreach ($promo_colonia as $promo) { if ($code == Crypt::decrypt($promo->code)) { $code_exist = 1; $code_id = $promo->id; $promo_status = $promo->status; } } if ($code_exist == 1) { if ($promo_status == 0) { $promo = Promo::where('id', '=', $code_id)->first(); $promo->status = 1; if ($promo->update(['id'])) { $expiration = Expiration::where('colony_id', '=', $colonia)->first(); $expiration_old = date('Y-m-j', strtotime($expiration->expiration)); $newExpiration = strtotime('+' . $promo->days . ' day', strtotime($expiration_old)); $newExpiration = date('Y-m-j', $newExpiration); $expiration->expiration = $newExpiration; $expiration->update(['id']); $datetime2 = new DateTime($expiration->expiration); $datetime1 = new DateTime(date('Y-m-d')); $interval = $datetime1->diff($datetime2); $days_expiration = $interval->format('%a'); Session::put('days_expiration', $days_expiration); $notice_msg = 'Código de la promo activado'; return Redirect::route('home')->with('notice_modal', $notice_msg); } } else { $error_msg = 'Este Código de la promo ya se fue utilizado'; return Redirect::back()->with('error_modal', $error_msg); } } else { $error_msg = 'Código de la promo inválido'; return Redirect::back()->with('error_modal', $error_msg); } }
public function config_store() { $user_id = Auth::user()->id; $num_street_id = NULL; $num_floor_id = NULL; $data = Input::all(); $name_floor = Input::get('name_floor'); $name_street = Input::get('name_street'); //~====================SAVE STEP 1=============================== $colony = new Colony(); $colony->location_id = Input::get('city'); $colony->name = Input::get('colony_name'); if ($colony->save()) { $created_colony = date('Y-m-j', strtotime($colony->created_at)); $newExpiration = strtotime('+1 month', strtotime($created_colony)); $newExpiration = date('Y-m-j', $newExpiration); $expiration = new Expiration(); $expiration->colony_id = $colony->id; $expiration->expiration = $newExpiration; $expiration->status = 1; $expiration->save(); $expiration_lic = new LicenseExpiration(); $expiration_lic->colony_id = $colony->id; $expiration_lic->expiration = null; $expiration_lic->save(); $datetime2 = new DateTime($expiration->expiration); $datetime1 = new DateTime(date('Y-m-d')); $interval = $datetime1->diff($datetime2); $days_expiration = $interval->format('%a'); Session::put('days_expiration', $days_expiration); $role = AssigmentRole::where('user_id', '=', $user_id)->where('role_id', '=', 2)->where('colony_id', '=', 0)->first(); if ($role) { $rol = AssigmentRole::findOrFail($role->id); $rol->colony_id = $colony->id; $rol->update(['id']); } else { $rol = new AssigmentRole(); $rol->user_id = $user_id; $rol->role_id = 2; $rol->colony_id = $colony->id; $rol->save(); } } $last_colony_add = $colony->id; $urbanism = new Urbanism(); $urbanism->colony_id = $last_colony_add; $urbanism->urbanism_type_id = Input::get('urbanism_type'); //$urbanism->name = Input::get('urbanism_name'); $urbanism->save(); $last_urbanism_add = $urbanism->id; $user_id = Auth::user()->id; $neighbor = Neighbors::where('user_id', '=', $user_id)->pluck('id'); if (!$neighbor) { $admin_colonies = new Neighbors(); $admin_colonies->user_id = $user_id; $admin_colonies->name = Input::get('admin_name'); $admin_colonies->last_name = Input::get('admin_lname'); $admin_colonies->phone = Input::get('admin_phone'); $admin_colonies->save(); $last_adminColonies_add = $admin_colonies->id; } if ($neighbor) { $last_adminColonies_add = $neighbor; } $streets = $data['streets']; if ($urbanism->urbanism_type_id == 3) { foreach ($streets as $Building_name) { $Building = new BuildingCatalog(); $Building->urbanism_id = $last_urbanism_add; $Building->description = $Building_name; $Building->save(); if ($Building_name == $name_floor) { $num_floor_id = $Building->id; } } } else { foreach ($streets as $street_name) { $street = new StreetCatalog(); $street->urbanism_id = $last_urbanism_add; $street->name = $street_name; $street->save(); if ($street_name == $name_street) { $num_street_id = $street->id; } } } $neighbor_properties = new NeighborProperty(); $neighbor_properties->neighbors_id = $last_adminColonies_add; $neighbor_properties->urbanism_id = $last_urbanism_add; $neighbor_properties->num_street_id = $num_street_id; $neighbor_properties->num_floor_id = $num_floor_id; $neighbor_properties->num_house_or_apartment = Input::get('num_house_or_apartment'); $neighbor_properties->status = 1; $neighbor_properties->save(); //~====================SAVE STEP 2=============================== $monthly_fee = new MonthlyFee(); $monthly_fee->urbanism_id = $last_urbanism_add; $monthly_fee->amount = Input::get('monthly_fee'); $monthly_fee->since = date("Y-m") . "-01"; $monthly_fee->until = NULL; $monthly_fee->save(); //~====================SAVE STEP 3=============================== //~====================sub cuentas egreso e ingreso por defecto =============================== $subAccounts_ingreso = new SubAccount(); $subAccounts_ingreso->account_id = 1; $subAccounts_ingreso->urbanism_id = $urbanism->id; $subAccounts_ingreso->description = 'Pago de cuota mensual'; $subAccounts_ingreso->save(); $subAccount_egreso = new SubAccount(); $subAccount_egreso->account_id = 2; $subAccount_egreso->urbanism_id = $urbanism->id; $subAccount_egreso->description = 'Nómina de guardias'; $subAccount_egreso->save(); $cobrador = Collector::where('user_id', '=', $user_id)->where('urbanism_id', '=', $urbanism->id)->pluck('id'); if (!$cobrador) { $collector = new Collector(); $collector->user_id = $user_id; $collector->urbanism_id = $urbanism->id; $collector->save(); } $campoEmail = Input::get('email'); if ($campoEmail) { $invited_neighbors = $data['mails']; $invited_id = md5(uniqid(mt_rand(), true)); foreach ($invited_neighbors as $neighbor_email) { $encrypted = Crypt::encrypt(md5(uniqid(mt_rand(), true))); $invited = new InvitedNeighbors(); $invited->neighbor_id = $last_adminColonies_add; $invited->invited_id = $invited_id; $invited->urbanism_id = $last_urbanism_add; $invited->email = $neighbor_email; $invited->confirmed = false; $invited->confirmation_code = $encrypted; $invited->save(); } return Redirect::action('HomeController@sendMailInvitation', array('invited_id' => $invited_id, 'admin_colonia' => $last_adminColonies_add, 'urbanismo' => $last_urbanism_add)); } else { return Redirect::action('NeighborController@admin_neighbor', array('admin_colonia' => $last_adminColonies_add, 'urbanismo' => $last_urbanism_add)); } }