Example #1
0
 public function postNewUser()
 {
     // Grab the inputs and validate them
     $new_user = Input::only('email', 'username', 'password', 'first_name', 'last_name', 'is_admin');
     $validation = new Validators\SeatUserRegisterValidator();
     // Should the form validation pass, continue to attempt to add this user
     if ($validation->passes()) {
         // Because users are soft deleted, we need to check if if
         // it doesnt actually exist first.
         $user = \User::withTrashed()->where('email', Input::get('email'))->orWhere('username', Input::get('username'))->first();
         // If we found the user, restore it and set the
         // new values found in the post
         if ($user) {
             $user->restore();
         } else {
             $user = new \User();
         }
         // With the user object ready, work the update
         $user->email = Input::get('email');
         $user->username = Input::get('username');
         $user->password = Hash::make(Input::get('password'));
         $user->activated = 1;
         $user->save();
         // After user is saved and has a user_id
         // we can add it to the admin group if necessary
         if (Input::get('is_admin') == 'yes') {
             $adminGroup = \Auth::findGroupByName('Administrators');
             Auth::addUserToGroup($user, $adminGroup);
         }
         return Redirect::action('UserController@getAll')->with('success', 'User ' . Input::get('email') . ' has been added');
     } else {
         return Redirect::back()->withInput()->withErrors($validation->errors);
     }
 }
 /**
  * Checks if the parameter is a valid user id
  * @param $id int
  * @return User object if $id is found, otherwise false
  */
 private function __checkExistence($id)
 {
     if (!is_null($id) && $id != '' && $id != 1) {
         $user = User::withTrashed()->find($id);
         if (is_null($user)) {
             return false;
         }
         return $user;
     }
     return false;
 }
Example #3
0
 public function deleteOrRestoreUsers()
 {
     $input = Input::get('selected_users');
     foreach ($input as $single_input) {
         $user = User::withTrashed()->where('id', '=', $single_input);
         if (Input::get('restore')) {
             $user->restore();
         } else {
             $user->delete();
         }
     }
     return Redirect::route("admin/console");
 }
Example #4
0
 public function newclinica($data)
 {
     $ususario = \Session::get('iduser');
     $clinicas = new clinica();
     $clinicas->iduser = $ususario[0];
     $clinicas->descripcion = $data['descripcion'];
     $clinicas->direccion = $data['direccion'];
     $clinicas->latitud = $data['latitud'];
     $clinicas->longitud = $data['longitud'];
     $clinicas->save();
     $user = User::withTrashed()->find($ususario[0]);
     $user->restore();
     $user->save();
 }
Example #5
0
 public function getUsersArray($withMe = false)
 {
     $list = array();
     if (isset($this->id) && (int) $this->id > 0) {
         $ids = $this->getUsersIds();
         if (count($ids) > 0) {
             $chat = $this;
             User::withTrashed()->whereIn('id', $ids)->get()->each(function ($user) use(&$list, $chat, $withMe) {
                 if ($withMe || $user->id != Auth::user()->id) {
                     $list[] = array('id' => $user->id, 'name' => $user->name, 'img' => array('middle' => $user->img_middle));
                 }
             });
         }
     }
     return $list;
 }
 public function render_edit_miembro_comite($idexpediente_tecnico = null)
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if (($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4) && $idexpediente_tecnico) {
             $data["expediente_tecnico_data"] = ExpedienteTecnico::withTrashed()->find($idexpediente_tecnico);
             $data["presidente_data"] = User::withTrashed()->find($data["expediente_tecnico_data"]->idpresidente);
             $data["miembro1_data"] = User::withTrashed()->find($data["expediente_tecnico_data"]->idmiembro1);
             $data["miembro2_data"] = User::withTrashed()->find($data["expediente_tecnico_data"]->idmiembro2);
             $data["miembro3_data"] = User::withTrashed()->find($data["expediente_tecnico_data"]->idmiembro3);
             return View::make('miembro_comite/editMiembroComite', $data);
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
 /**
  * Checks if the parameter is a valid supplier id
  * @param $id int
  * @return User object if $id is found, otherwise false
  */
 private function __checkExistence($id)
 {
     if (!is_null($id) && $id != '') {
         if (Auth::user()->profile_type != 'admin') {
             if ($id == Auth::user()->id) {
                 $supplier = User::withTrashed()->find($id);
                 if (is_null($supplier)) {
                     return false;
                 }
                 return $supplier;
             } else {
                 return false;
             }
         } else {
             $supplier = User::withTrashed()->find($id);
             if (is_null($supplier)) {
                 return false;
             }
             return $supplier;
         }
     }
     return false;
 }
 public function getRestoreUser($id)
 {
     User::withTrashed()->where('id', $id)->restore();
     return Redirect::route('archive')->with('alert', 'success|User successfully restored');
 }
 /**
  * Stores new account
  *
  */
 public function save($userPublicId = false)
 {
     $rules = ['first_name' => 'required', 'last_name' => 'required'];
     if ($userPublicId) {
         $user = User::where('account_id', '=', Auth::user()->account_id)->where('public_id', '=', $userPublicId)->firstOrFail();
         $rules['email'] = 'required|email|unique:users,email,' . $user->id . ',id';
     } else {
         $rules['email'] = 'required|email|unique:users';
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to($userPublicId ? 'users/edit' : 'users/create')->withInput()->withErrors($validator);
     }
     if ($userPublicId) {
         $user->first_name = trim(Input::get('first_name'));
         $user->last_name = trim(Input::get('last_name'));
         $user->username = trim(Input::get('email'));
         $user->email = trim(Input::get('email'));
     } else {
         $lastUser = User::withTrashed()->where('account_id', '=', Auth::user()->account_id)->orderBy('public_id', 'DESC')->first();
         $user = new User();
         $user->account_id = Auth::user()->account_id;
         $user->first_name = trim(Input::get('first_name'));
         $user->last_name = trim(Input::get('last_name'));
         $user->username = trim(Input::get('email'));
         $user->email = trim(Input::get('email'));
         $user->registered = true;
         $user->password = str_random(RANDOM_KEY_LENGTH);
         $user->password_confirmation = $user->password;
         $user->public_id = $lastUser->public_id + 1;
     }
     $user->save();
     if (!$user->confirmed) {
         $this->userMailer->sendConfirmation($user, Auth::user());
         $message = trans('texts.sent_invite');
     } else {
         $message = trans('texts.updated_user');
     }
     Session::flash('message', $message);
     return Redirect::to('company/advanced_settings/user_management');
 }
 public function test2()
 {
     $error = "";
     $regs = DB::table('registration')->get();
     foreach ($regs as $reg) {
         $user = new User();
         $user->name1 = strtoupper($reg->name1);
         $user->name2 = strtoupper($reg->name2);
         $user->email1 = $reg->email1;
         $user->email2 = $reg->email2;
         $user->contact1 = $reg->contact1;
         $user->contact2 = $reg->contact2;
         $user->squad = $reg->squad;
         $user->language = $reg->language;
         $school = strtoupper($reg->school);
         $city_name = ucwords(strtolower($reg->city));
         if (School::where('name', $school)->count() && City::where('name', $city_name)->count()) {
             $cityid = City::where('name', $city_name)->first();
             $school_name = School::where('name', $school)->where('city_id', $cityid->id)->first();
             $user->school_id = $school_name->id;
             $user->city_id = $cityid->id;
             $user->centre_city = $cityid->id * 10;
             $roll = "";
             if ($reg->squad === 'JUNIOR') {
                 $roll = "J";
             } else {
                 $roll = "H";
             }
             if ($reg->language === 'en') {
                 $roll .= "E";
             } else {
                 $roll .= "H";
             }
             $roll .= strval($cityid->code) . '0';
             $lastroll = User::withTrashed()->where('roll', 'LIKE', "%{$roll}%")->count();
             $roll .= str_pad(strval($lastroll + 1), 4, "0", STR_PAD_LEFT);
             $user->roll = $roll;
             $user->year = 2015;
             $user->paid = true;
             $user->comments = $reg->comments;
             $user->save();
         } else {
             if (School::where('name', $school)->count()) {
                 $error .= $city_name . '<br>';
             } elseif (City::where('name', $city_name)->count()) {
                 $error .= $school . '<br>';
             } else {
                 $error .= $school . '   ' . $city_name;
             }
         }
     }
     //        Auth::logout();
     return View::make('layouts.test3')->with('error', $error);
 }
 /**
  * Display the specified resource.
  * GET /admin/users/{id}
  *
  * @param  int  $id
  * @return Response
  */
 public function show($id)
 {
     $user = User::withTrashed()->find($id);
     return View::make('admin.users.show', ['title' => $user->name, 'img' => $user->img_middle, 'id' => $user->id, 'user' => [['Имя', $user->name], ['Пол', $user->sex], ['День рождения', $user->birthday], ['Город', $this->returnIfPresent(CityRef::find($user->city), 'ru')], ['Телефон', $this->returnIfPresent($user->phone, 'number')], ['Почта', $user->email], ['О себе', $user->about]], 'actions' => $this->makeLinks($this->expandList([['show', 'Профиль'], ['cars', 'Список машин'], ['chats', 'Чаты'], ['blackList', 'Блокированные пользователи'], ['posts', 'Посты'], ['comments', 'Комментарии'], ['devices', 'Устройства'], ['images', 'Изображения']]), ['controller' => 'AdminUsersController', 'params' => [$user->id]]), 'statistics' => [['string' => 'отправленных сообщений', 'value' => $user->messages()->count()], ['string' => 'отправленных срочных вызовов', 'value' => $user->emergencies()->count()], ['string' => 'сделанных пользователем первых контактов', 'value' => 12], ['string' => 'постов', 'value' => $user->posts->count()], ['string' => 'полученныз пользователем комментариев', 'value' => $user->comments->count()], ['string' => 'полученных пользователем лайков', 'value' => $user->likes->count()], ['string' => 'отправленных жалоб', 'value' => $user->complaints()->count()], ['string' => 'жалоб на пользователя', 'value' => $user->complaintsToMe()->count()], ['string' => 'блокированных пользователем', 'value' => $user->blockedUsers()->count()], ['string' => 'пользователей заблокировавших данного пользователя', 'value' => $user->blockedMeUsers()->count()]]]);
 }
 public function getEditUser($user)
 {
     $user = User::withTrashed()->where('username', '=', $user)->first();
     return View::make('admin/edituser/index')->with('user', $user);
 }
 public function render_view_expediente_tecnico($id = null)
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if (($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4 || $data["user"]->idrol == 5 || $data["user"]->idrol == 6 || $data["user"]->idrol == 7 || $data["user"]->idrol == 8 || $data["user"]->idrol == 9 || $data["user"]->idrol == 10 || $data["user"]->idrol == 11 || $data["user"]->idrol == 12) && $id) {
             $data["tipos_adquisicion_expediente"] = TipoAdquisicionExpediente::orderBy('nombre', 'asc')->lists('nombre', 'idtipo_adquisicion_expediente');
             $data["tipos_compra_expediente"] = TipoCompraExpediente::orderBy('nombre', 'asc')->lists('nombre', 'idtipo_compra_expediente');
             $data["areas"] = Area::orderBy('nombre', 'asc')->lists('nombre', 'idarea');
             $data["servicios"] = Servicio::orderBy('nombre', 'asc')->lists('nombre', 'idservicio');
             $data["expediente_tecnico_info"] = ExpedienteTecnico::searchExpedienteTecnicoByNumeroExpediente($id)->get()[0];
             $data["ofertas_expediente_data"] = OfertaExpediente::searchOfertaExpedienteByNumeroExpediente($id)->get();
             $data["ofertas_evaluada_expediente_data"] = OfertaEvaluadaExpediente::select('oferta_evaluada_expediente.*')->get();
             $data["observaciones_expediente_data"] = ObservacionExpediente::join('tipo_observacion_expediente', 'tipo_observacion_expediente.idtipo_observacion_expediente', '=', 'observacion_expediente.idtipo_observacion_expediente')->select('tipo_observacion_expediente.nombre as tipo_observacion', 'observacion_expediente.*')->get();
             $data["presidente_data"] = User::withTrashed()->find($data["expediente_tecnico_info"]->idpresidente);
             $data["miembro1_data"] = User::withTrashed()->find($data["expediente_tecnico_info"]->idmiembro1);
             $data["miembro2_data"] = User::withTrashed()->find($data["expediente_tecnico_info"]->idmiembro2);
             $data["miembro3_data"] = User::withTrashed()->find($data["expediente_tecnico_info"]->idmiembro3);
             return View::make('expediente_tecnico/viewExpedienteTecnico', $data);
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
Example #14
0
 public function checkEmail()
 {
     $email = User::withTrashed()->where('email', '=', Input::get('email'))->where('id', '<>', Auth::user()->id)->first();
     if ($email) {
         return "taken";
     } else {
         return "available";
     }
 }
 /**
  * Remove the specified user from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function activate()
 {
     $id = Input::all()['id'];
     $user = User::withTrashed()->findOrFail($id);
     if ($user->trashed()) {
         $user->restore();
         $status = "Activado";
     } else {
         $user->delete();
         $status = "Desactivado";
     }
     return Response::json(array('status' => true, 'user_status' => $status));
 }
 public function uploadedreg()
 {
     $details = '';
     if (Session::has('file')) {
         $file = Session::get('file');
         $city = City::find(Session::get('city'));
         $result = Excel::load('regs/uploads/' . $file)->get();
         $kv = Session::get('kv') == 'yes';
         foreach ($result as $reg) {
             $user = new User();
             $user->name1 = strtoupper($reg->name1);
             $user->name2 = strtoupper($reg->name2);
             $user->email1 = $reg->email1;
             $user->email2 = $reg->email2;
             $user->contact1 = $reg->contact1;
             $user->contact2 = $reg->contact2;
             $user->squad = $reg->squad;
             $user->language = $reg->language;
             $user->city_id = $city->id;
             $user->centre_city = $city->id * 10;
             $user->school_id = Session::get('school');
             $roll = $user->squad == 'HAUTS' ? 'H' : 'J';
             $roll .= $user->language == 'en' ? 'E' : 'H';
             $roll .= strval($city->code);
             $roll .= $kv ? '2' : '0';
             $lastroll = User::withTrashed()->where('roll', 'LIKE', "%{$roll}%")->count();
             $roll .= str_pad(strval($lastroll + 1), 4, "0", STR_PAD_LEFT);
             $user->roll = $roll;
             $user->year = 2015;
             $pass = str_random(6);
             $user->password = Hash::make($pass);
             $user->paid = $kv ? 2 : 1;
             $user->status = $kv ? 2 : 0;
             if ($kv) {
                 $user->result_pass = Crypt::encrypt($pass);
             }
             $user->comments = 'Added by ' . Auth::admin()->get()->name . ' on ' . date('H:i:s d-m-Y', time());
             $user->save();
             $details .= '<tr>
                             <td>' . $user->name1 . '</td>
                             <td>' . $user->name2 . '</td>
                             <td>' . $user->roll . '</td>
                             <td>' . $pass . '</td>
                         </tr>';
         }
         if ($kv) {
             File::move(public_path() . '/regs/uploads/' . $file, public_path() . '/regs/kvuploads/' . $file);
         } else {
             File::move(public_path() . '/regs/uploads/' . $file, public_path() . '/regs/adminuploads/' . $file);
         }
         return View::make('admin.uploadedreg')->with('details', $details);
     } else {
         return Redirect::route('adminuploadreg');
     }
 }
 /**
  * Display a listing of notifications.
  *
  * @param int|null $lastNotificationId Last chat ID
  * @param int $size Response size
  * @return Response
  */
 public function getList($lastNotificationId = null, $size = 20)
 {
     $result = array();
     $size = (int) $size > 0 ? (int) $size : 20;
     $query = sprintf('select max(x.id) as "before" from (select id from notifications n where n.owner_id = %d order by n.timestamp desc offset %d) x;', Auth::user()->id, self::AMOUNT_LIMIT);
     if (($data = DB::select($query)) && !is_null($idBeforeRemove = $data[0]->before)) {
         Notification::whereRaw('owner_id = ? and id < ?', array(Auth::user()->id, $idBeforeRemove))->update(array('is_removed' => 1));
     }
     Notification::whereRaw('owner_id = ? and is_removed = 0 and timestamp > (CURRENT_TIMESTAMP - INTERVAL \'' . self::TIME_LIMIT . ' second\')' . (is_null($lastNotificationId) ? '' : ' and id < ' . (int) $lastNotificationId), array(Auth::user()->id))->orderBy('timestamp', 'desc')->orderBy('id', 'desc')->get()->take($size)->each(function ($notification) use(&$result) {
         $notificationUsers = NotificationUser::whereRaw('notification_id = ? and is_removed = 0', array($notification->id))->orderBy('timestamp', 'desc')->get();
         $usersCount = $notificationUsers->count();
         $type = $notification->object;
         $event = $notification->event;
         $data = array('id' => $notification->id, 'type' => $type, 'amount' => $usersCount, 'timestamp' => $notification->getTimeStamp());
         //						var_dump($type.' '.$event);
         $self = $this;
         if ($type == 'post') {
             $post = Post::find($notification->object_id);
             $data['post_id'] = $post->id;
             $data['post_title'] = $post->text;
             if ($event == 'commented') {
                 $notificationUsers->take(2)->each(function ($user) use(&$data, $self) {
                     $comment = Comment::find($user->subject_id);
                     if ($comment) {
                         $data['comments'][] = $self->collectionTransformer->transformComment($comment);
                     } else {
                         unset($data['id']);
                         unset($data['type']);
                         unset($data['amount']);
                         unset($data['timestamp']);
                         unset($data['post_id']);
                         unset($data['post_title']);
                     }
                 });
             } else {
                 if ($event == 'liked') {
                     $notificationUsers->take(2)->each(function ($user) use(&$data, $self) {
                         $user = User::withTrashed()->find($user->user_id);
                         $data['likes'][] = $self->collectionTransformer->transformUserToSmall($user);
                     });
                 } else {
                     unset($data['id']);
                     unset($data['type']);
                     unset($data['amount']);
                     unset($data['timestamp']);
                     unset($data['post_id']);
                     unset($data['post_title']);
                 }
             }
         } else {
             if ($type == 'comment') {
                 $comment = Comment::find($notification->object_id);
                 if ($comment) {
                     $post = Post::find($comment->post_id);
                     if ($post) {
                         $data['post_id'] = $post->id;
                         $data['post_title'] = $post->text;
                         $data['comment_id'] = $comment->id;
                     }
                     if ($event == 'liked') {
                         $notificationUsers->take(2)->each(function ($user) use(&$data, $self) {
                             $user = User::withTrashed()->find($user->user_id);
                             $data['likes'][] = $self->collectionTransformer->transformUserToSmall($user);
                         });
                     }
                 } else {
                     unset($data['id']);
                     unset($data['type']);
                     unset($data['amount']);
                     unset($data['timestamp']);
                     unset($data['post_id']);
                     unset($data['post_title']);
                 }
             } else {
                 unset($data['id']);
                 unset($data['type']);
                 unset($data['amount']);
                 unset($data['timestamp']);
                 unset($data['post_id']);
                 unset($data['post_title']);
             }
         }
         //						$filter = function ($data) {
         //							return array_filter($data) != [];
         //						};
         //                        $result['notifications'][] = array_filter($data, $filter);
         if (!empty($data)) {
             $result['notifications'][] = $data;
         }
     });
     if (is_null($lastNotificationId)) {
         foreach (Auth::user()->getTokens() as $token) {
             $state = new StateSender($token);
             $state->setAllPostsAsRead();
             $state->setAllCommentsAsRead();
             $state->send();
         }
     }
     return $this->respond($result);
 }
Example #18
0
 /**
  * Display the specified resource.
  * GET /users/{id}
  *
  * @param int $id
  * @return Response
  */
 public function show($id)
 {
     $user = Auth::user();
     //FIXME Ineffiecent code, double query
     $otherUser = User::withTrashed()->find($id);
     if (!$otherUser) {
         return $this->respondNotFound('user.not-found');
     }
     if ($otherUser->deleted_at) {
         return Response::json(['response' => ['id' => $otherUser->id, 'name' => $otherUser->name, 'status' => 'deleted', 'img' => ['thumb' => $otherUser->img_small, 'middle' => $otherUser->img_middle, 'origin' => $otherUser->img_origin]]]);
     }
     if ($user->isBlocked($id)) {
         return Response::json(['response' => ['id' => $otherUser->id, 'name' => $otherUser->name, 'status' => 'blocked', 'reason' => 'User blocked you', 'img' => ['thumb' => $otherUser->img_smal, 'middle' => $otherUser->img_middle, 'origin' => $otherUser->img_origin], 'in_blacklist' => $user->inBlackList($otherUser->id) ? 1 : 0]], 403);
     }
     if (!$otherUser) {
         return $this->respondNotFound('user.not-found');
     }
     $otherUser->load('cars', 'phones');
     return $this->respond($this->collectionTransformer->transformOtherUser($otherUser, Request::header('Locale')));
 }
Example #19
0
 /**
  * Stores new account
  *
  */
 public function save($userPublicId = false)
 {
     if (Input::get('password') && Input::get('password_confirmation')) {
         $rules = ['password' => 'required|between:4,11|confirmed', 'password_confirmation' => 'between:4,11'];
         $validator = Validator::make(Input::all(), $rules);
         if ($validator->fails()) {
             return Redirect::to('company/details')->withErrors($validator)->withInput();
         }
     }
     $rules = ['first_name' => 'required', 'last_name' => 'required'];
     if ($userPublicId) {
         $user = User::where('account_id', '=', Auth::user()->account_id)->where('public_id', '=', $userPublicId)->firstOrFail();
         $rules['email'] = 'required|email|unique:users,email,' . $user->id . ',id';
     } else {
         $rules['email'] = 'required|email|unique:users';
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to($userPublicId ? 'users/edit' : 'users/create')->withInput()->withErrors($validator);
     }
     if ($userPublicId) {
         $user->first_name = trim(Input::get('first_name'));
         $user->last_name = trim(Input::get('last_name'));
         $user->username = trim(Input::get('username')) . "@" . Auth::user()->account->getNit();
         $user->password = trim(Input::get('password'));
         $user->is_admin = trim(Input::get('is_admin'));
         $user->email = trim(Input::get('email'));
         $user->phone = trim(Input::get('phone'));
         if (Input::get('facturador')) {
             $user->branch_id = Input::get('branch_id') ? Input::get('branch_id') : null;
             $user->is_admin = 0;
         } else {
             $user->is_admin = 1;
         }
     } else {
         $lastUser = User::withTrashed()->where('account_id', '=', Auth::user()->account_id)->orderBy('public_id', 'DESC')->first();
         $user = new User();
         $user->account_id = Auth::user()->account_id;
         $user->first_name = trim(Input::get('first_name'));
         $user->last_name = trim(Input::get('last_name'));
         $user->username = trim(Input::get('username')) . "@" . Auth::user()->account->getNit();
         $user->password = trim(Input::get('password'));
         $user->email = trim(Input::get('email'));
         $user->phone = trim(Input::get('phone'));
         $user->registered = true;
         $user->public_id = $lastUser->public_id + 1;
         if (Input::get('facturador')) {
             $user->branch_id = Input::get('branch_id') ? Input::get('branch_id') : null;
             $user->is_admin = 0;
         } else {
             $user->is_admin = 1;
         }
     }
     $user->save();
     if ($userPublicId) {
         // $this->userMailer->sendConfirmation($user, Auth::user());
         $message = trans('texts.created_user');
     } else {
         $message = trans('texts.updated_user');
     }
     Session::flash('message', $message);
     return Redirect::to('company/user_management');
 }
 public function render_view_reporte_priorizacion($id = null)
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if ($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4 || $data["user"]->idrol == 7 || $data["user"]->idrol == 8 || $data["user"]->idrol == 9 || $data["user"]->idrol == 10 || $data["user"]->idrol == 11 || $data["user"]->idrol == 12) {
             $data["areas"] = Area::lists('nombre', 'idarea');
             $data["servicios"] = Servicio::lists('nombre', 'idservicio');
             $data["reporte_priorizacion_info"] = ReportePriorizacion::withTrashed()->find($id);
             $data["responsable_info"] = User::withTrashed()->find($data["reporte_priorizacion_info"]->iduser);
             return View::make('reportes_priorizacion/viewReportesPriorizacion', $data);
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
 public function render_view_documento($id = null)
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if (($data["user"]->idrol == 1 || $data["user"]->idrol == 2 || $data["user"]->idrol == 3 || $data["user"]->idrol == 4 || $data["user"]->idrol == 5 || $data["user"]->idrol == 6 || $data["user"]->idrol == 7 || $data["user"]->idrol == 8 || $data["user"]->idrol == 9 || $data["user"]->idrol == 10 || $data["user"]->idrol == 11 || $data["user"]->idrol == 12) && $id) {
             $data["tipo_compra"] = TipoCompra::orderBy('nombre', 'asc')->lists('nombre', 'idtipo_compra');
             $data["unidad_medida"] = UnidadMedida::orderBy('nombre', 'asc')->lists('nombre', 'idunidad_medida');
             $data["areas"] = Area::lists('nombre', 'idarea');
             $data["servicios"] = Servicio::lists('nombre', 'idservicio');
             $data["programacion_compra_info"] = ProgramacionCompraAdquisicion::withTrashed()->find($id);
             $data["usuario_info"] = User::withTrashed()->find($data["programacion_compra_info"]->iduser);
             $data["responsable_info"] = User::withTrashed()->find($data["programacion_compra_info"]->idresponsable);
             return View::make('programacion_compras/viewProgramacionCompra', $data);
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
 public function submit_enable_user()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_nuevo_usuario', $data["permisos"])) {
             $user_id = Input::get('user_id');
             $url = "user/edit_user/" . $user_id;
             $user = User::withTrashed()->find($user_id);
             $user->restore();
             // Elimino su información de voluntario
             $v = Voluntario::getVoluntarioPorUserTrashed($user_id)->get();
             if (!$v->isEmpty()) {
                 $voluntario = Voluntario::withTrashed()->find($v[0]->idvoluntarios);
                 $voluntario->restore();
             }
             // Elimino su información de padrino
             $p = Padrino::getPadrinoPorUserTrashed($user_id)->get();
             if (!$p->isEmpty()) {
                 $padrino = Padrino::withTrashed()->find($p[0]->idpadrinos);
                 $padrino->restore();
             }
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se habilitó al usuario con id {{$user_id}}";
             Helpers::registrarLog(6, $descripcion_log);
             Session::flash('message', 'Se habilitó correctamente al usuario.');
             return Redirect::to($url);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registrarLog(10, $descripcion_log);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
Example #23
0
 /**
  * Restore
  */
 public function postRestore()
 {
     // check for valid user
     $userId = Input::get("userId");
     if (!($user = User::withTrashed()->find($userId))) {
         throw new Exception("Invalid user to restore");
     }
     // restore and redirect back to list
     $user->restore();
     Session::flash("restore-success", $user);
     return Redirect::to("admin/list");
 }
 /**
  * Tests the update function in the UserController
  * @param  void
  * @return void
  */
 public function testDelete()
 {
     Input::replace($this->userData);
     $user = new UserController();
     $user->store();
     $user->delete(1);
     $usersSaved = User::withTrashed()->find(1);
     $this->assertNotNull($usersSaved->deleted_at);
 }
Example #25
0
 public function submit_enable_user()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         // Verifico si el usuario es un Webmaster
         if ($data["user"]->idrol == 1) {
             $user_id = Input::get('user_id');
             $url = "user/edit_user" . "/" . $user_id;
             $user = User::withTrashed()->find($user_id);
             $user->restore();
             Session::flash('message', 'Se habilitó correctamente al usuario.');
             return Redirect::to($url);
         } else {
             return View::make('error/error', $data);
         }
     } else {
         return View::make('error/error', $data);
     }
 }
 public function submit_enable_padrino()
 {
     if (Auth::check()) {
         $data["inside_url"] = Config::get('app.inside_url');
         $data["user"] = Session::get('user');
         $data["permisos"] = Session::get('permisos');
         if (in_array('side_listar_padrinos', $data["permisos"])) {
             $user_id = Input::get('user_id');
             $padrino_id = Input::get('padrino_id');
             $url = "padrinos/edit_padrino/" . $user_id;
             $padrino = Padrino::withTrashed()->find($padrino_id);
             $user = User::withTrashed()->find($user_id);
             $padrino->restore();
             $user->restore();
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se habilitó al padrino con id {{$padrino_id}}";
             Helpers::registrarLog(6, $descripcion_log);
             Session::flash('message', 'Se habilitó correctamente al padrino.');
             return Redirect::to($url);
         } else {
             // Llamo a la función para registrar el log de auditoria
             $descripcion_log = "Se intentó acceder a la ruta '" . Request::path() . "' por el método '" . Request::method() . "'";
             Helpers::registrarLog(10, $descripcion_log);
             Session::flash('error', 'Usted no tiene permisos para realizar dicha acción.');
             return Redirect::to('/dashboard');
         }
     } else {
         return View::make('error/error');
     }
 }
 public function postImportEmp()
 {
     if (\Request::ajax()) {
         $efile = \Input::file('upload');
         /* Validation of file */
         $validate = \Validator::make(array('file' => $efile), array('file' => 'required|mimes:xls,csv|max:2000|min:1'));
         if ($validate->fails()) {
             $error = array('error' => $validate->messages()->first());
             echo json_encode($error);
             return;
         } else {
             $handle = file($efile->getRealPath());
             /* Call Excel Class */
             $objPHPExcel = \PHPExcel_IOFactory::load($efile->getRealPath());
             $mainArr = array();
             foreach ($objPHPExcel->getWorksheetIterator() as $worksheet) {
                 // Sheet names
                 switch ($worksheet->getTitle()) {
                     case 'User':
                         $index = 'users';
                         break;
                     case 'PersonalDetails':
                         $index = 'PersonalDetails';
                         break;
                     case 'ContactInfo':
                         $index = 'ContactInfo';
                         break;
                     case 'IdentificationandBankInfo':
                         $index = 'IdentificationandBankInfo';
                         break;
                     case 'PFandESIInformation':
                         $index = 'PFandESIInformation';
                         break;
                     case 'JobDetails':
                         $index = 'JobDetails';
                         break;
                     case 'EducationalBackground':
                         $index = 'EducationalBackground';
                         break;
                     case 'WorkExperience':
                         $index = 'WorkExperience';
                         break;
                 }
                 // Getting all cells
                 $subArr = array();
                 $rows = $worksheet->getRowIterator();
                 foreach ($rows as $row) {
                     $cells = $row->getCellIterator();
                     // cells store into data array
                     $data = array();
                     foreach ($cells as $cell) {
                         $data[] = $cell->getCalculatedValue();
                     }
                     if ($data) {
                         // one set of row stored in indexed array
                         $arr[$index] = $data;
                         // indexed array store into subarr
                         $subArr[] = $arr;
                         // remove indexd array for optimiced douplicated
                         unset($arr);
                     }
                 }
                 // every sheet of array store in main Arr
                 $mainArr[$index] = $subArr;
                 unset($subArr);
             }
             $emails = array_fetch($mainArr['users'], 'users.1');
             // Validate emails
             foreach ($emails as $value) {
                 if (preg_match("/^[^0-9][A-z0-9_]+([.][A-z0-9_]+)*[@][A-z0-9_]+([.][A-z0-9_]+)*[.][A-z]{2,4}\$/", $value)) {
                 } else {
                     $error = array('error' => "{$value} InValid Email");
                     echo json_encode($error);
                     return;
                 }
             }
             // validation email unique from excel
             if (count($emails) != count(array_unique($emails))) {
                 $error = array('error' => "Douplicate emails are available");
                 echo json_encode($error);
                 return;
             }
             //end email unique in excel
             //Check Email Id is unique or not
             $user = \User::withTrashed()->whereIn('email', $emails)->first();
             if ($user) {
                 $error = array('error' => "{$user->email} already registered");
                 echo json_encode($error);
                 return;
             }
             // Database insertion starts here
             $users = $mainArr['users'];
             $PersonalDetails = $mainArr['PersonalDetails'];
             $ContactInfo = $mainArr['ContactInfo'];
             $IdentificationandBankInfo = $mainArr['IdentificationandBankInfo'];
             $PFandESIInformation = $mainArr['PFandESIInformation'];
             $JobDetails = $mainArr['JobDetails'];
             $EducationalBackground = $mainArr['EducationalBackground'];
             $WorkExperience = $mainArr['WorkExperience'];
             // Create UserId
             $userID = \Auth::user()->id;
             $branch = \Branch::where('user_id', '=', $userID)->first();
             $prifix = $branch->branch_code;
             // branch prifix code
             $count = \BranchEmp::withTrashed()->where('branch_id', '=', $userID)->count();
             // count all registered user of this branch
             $i = 0;
             foreach ($users as $val) {
                 \DB::beginTransaction();
                 $temp = $count + 1;
                 // increase one
                 $count++;
                 $postfix = sprintf('%04d', $temp);
                 // manupulate 000$temp
                 $username = $prifix . $postfix;
                 $password = str_random(10);
                 $hashPassword = \Hash::make($password);
                 $email = $val['users'][1];
                 $uId = \User::insertGetId(array('username' => $username, 'password' => $hashPassword, 'displayname' => $val['users'][0], 'email' => $val['users'][1], 'profilesId' => 4, 'active' => 'Y'));
                 //create branch employee
                 $branchEmployee = \BranchEmp::insertGetId(array('branch_id' => $userID, 'emp_id' => $uId));
                 // Insert Personal detail
                 $empId = \Employee::insertGetId(array('user_id' => $uId, 'firstname' => $PersonalDetails[$i]['PersonalDetails'][0], 'lastname' => $PersonalDetails[$i]['PersonalDetails'][2], 'middlename' => $PersonalDetails[$i]['PersonalDetails'][1], 'fathername' => $PersonalDetails[$i]['PersonalDetails'][3], 'mothermaiden' => $PersonalDetails[$i]['PersonalDetails'][8], 'dateofbirth' => $PersonalDetails[$i]['PersonalDetails'][4], 'maritialstatus' => $PersonalDetails[$i]['PersonalDetails'][5], 'spousename' => $PersonalDetails[$i]['PersonalDetails'][6], 'sibling' => $PersonalDetails[$i]['PersonalDetails'][8], 'bloodgroup' => $PersonalDetails[$i]['PersonalDetails'][9]));
                 // Contact Information
                 $contact = \UserContact::insertGetId(array('user_id' => $uId, 'address' => $ContactInfo[$i]['ContactInfo'][0], 'city' => $ContactInfo[$i]['ContactInfo'][1], 'state' => $ContactInfo[$i]['ContactInfo'][2], 'pin' => $ContactInfo[$i]['ContactInfo'][3], 'p_address' => $ContactInfo[$i]['ContactInfo'][4], 'p_city' => $ContactInfo[$i]['ContactInfo'][5], 'p_state' => $ContactInfo[$i]['ContactInfo'][6], 'p_pin' => $ContactInfo[$i]['ContactInfo'][7], 'mobile' => $ContactInfo[$i]['ContactInfo'][8], 'phone' => $ContactInfo[$i]['ContactInfo'][9], 'alt_mobile' => $ContactInfo[$i]['ContactInfo'][10], 'alt_email' => $ContactInfo[$i]['ContactInfo'][11]));
                 //IdentificationandBankInfo
                 $identification = \EmpIdentification::insertGetId(array('user_id' => $uId, 'pan' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][0], 'passport_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][1], 'adhar_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][2], 'voter_id' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][3], 'driving_licence' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][4]));
                 // Bank Detail
                 $bankDetails = \EmpBankDetail::insertGetId(array('user_id' => $uId, 'account_no' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][5], 'bank_name' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][6], 'branch' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][7], 'IFSC' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][8], 'micrno' => $IdentificationandBankInfo[$i]['IdentificationandBankInfo'][9]));
                 // Esi and PF Detail
                 $PfEsi = \PfEsi::insertGetId(array('user_id' => $uId, 'isPF' => $PFandESIInformation[$i]['PFandESIInformation'][0], 'pfno' => $PFandESIInformation[$i]['PFandESIInformation'][1], 'pfenno' => $PFandESIInformation[$i]['PFandESIInformation'][2], 'epfno' => $PFandESIInformation[$i]['PFandESIInformation'][3], 'relationship' => $PFandESIInformation[$i]['PFandESIInformation'][4], 'isESI' => $PFandESIInformation[$i]['PFandESIInformation'][5], 'esino' => $PFandESIInformation[$i]['PFandESIInformation'][6]));
                 // Job details
                 $jobdetailsId = \JobDetails::insertGetId(array('user_id' => $uId, 'joining_date' => $JobDetails[$i]['JobDetails'][0], 'job_type' => $JobDetails[$i]['JobDetails'][1], 'designation' => $JobDetails[$i]['JobDetails'][2], 'department' => $JobDetails[$i]['JobDetails'][3], 'reporting_manager' => $JobDetails[$i]['JobDetails'][4], 'payment_mode' => $JobDetails[$i]['JobDetails'][5], 'hr_verification' => $JobDetails[$i]['JobDetails'][6], 'police_verification' => $JobDetails[$i]['JobDetails'][7], 'emp_type' => $JobDetails[$i]['JobDetails'][8], 'client_id' => $JobDetails[$i]['JobDetails'][9]));
                 //EducationalBackground
                 $eduction = \EmpEducation::insertGetId(array('user_id' => $uId, 'school_name' => $EducationalBackground[$i]['EducationalBackground'][0], 'school_location' => $EducationalBackground[$i]['EducationalBackground'][1], 'school_percentage' => $EducationalBackground[$i]['EducationalBackground'][2], 'puc_name' => $EducationalBackground[$i]['EducationalBackground'][3], 'puc_location' => $EducationalBackground[$i]['EducationalBackground'][4], 'puc_percentage' => $EducationalBackground[$i]['EducationalBackground'][5], 'diploma_name' => $EducationalBackground[$i]['EducationalBackground'][6], 'diploma_location' => $EducationalBackground[$i]['EducationalBackground'][7], 'diploma_percentage' => $EducationalBackground[$i]['EducationalBackground'][8], 'degree_name' => $EducationalBackground[$i]['EducationalBackground'][9], 'degree_location' => $EducationalBackground[$i]['EducationalBackground'][10], 'degree_percentage' => $EducationalBackground[$i]['EducationalBackground'][11], 'master_name' => $EducationalBackground[$i]['EducationalBackground'][12], 'master_location' => $EducationalBackground[$i]['EducationalBackground'][13], 'master_percentage' => $EducationalBackground[$i]['EducationalBackground'][14]));
                 // Experiance
                 $companyDetails = \WorkExperiance::insertGetId(array('user_id' => $uId, 'company_name' => $WorkExperience[$i]['WorkExperience'][0], 'location' => $WorkExperience[$i]['WorkExperience'][1], 'designation' => $WorkExperience[$i]['WorkExperience'][2], 'last_ctc' => $WorkExperience[$i]['WorkExperience'][3], 'join_date' => $WorkExperience[$i]['WorkExperience'][4], 'leaving_date' => $WorkExperience[$i]['WorkExperience'][5]));
                 \DB::commit();
                 \Mail::send('emails.user_credential', array('name' => $val['users'][0], 'username' => $username, 'password' => $password), function ($message) use($email, $username) {
                     $message->to($email, $username)->subject('User Credential');
                 });
                 $i++;
             }
             // end foreach of database insertion
             // success message
             $success = array('success' => "Successfully uploaded your Employees");
             echo json_encode($success);
             return;
         }
         // end else part
     }
     // end ajax condition
 }