Exemplo n.º 1
0
 public function uploadUser($id, $role)
 {
     $data = $this->prepareData($this->data);
     $user = User::find($id);
     $user->card = $this->data['card'];
     $photo = $data['photo'];
     /*$fingerprint = $data['fingerprint'];
     
             if($photo || $fingerprint)
             {
                 if($photo){
                     $data["photo"]=sha1(time()).$photo->getClientOriginalName();
                     $photo->move("users",sha1(time()).$photo->getClientOriginalName());
                 }
                 if($fingerprint){
                     $data["fingerprint"]=sha1(time()).$fingerprint->getClientOriginalName();
                     $fingerprint->move("users",sha1(time()).$fingerprint->getClientOriginalName());
                 }
             }else{
                 $data["fingerprint"]=$user->fingerprint;
                 $data["photo"]=$user->photo;
             }*/
     if ($role == 4) {
         if ($this->date($user->updated_at)) {
             $user->update($data);
             return true;
         }
         return false;
     } else {
         $user->update($data);
         return true;
     }
 }
Exemplo n.º 2
0
 public function fire()
 {
     $dir = $_SERVER['DOCUMENT_ROOT'] . "public/toUpload/";
     try {
         Excel::filter('chunk')->load($dir . 'data.xlsx')->chunk(250, function ($reader) {
             foreach ($reader->toArray() as $data) {
                 $user = User::where('identification_card', $data['cedula'])->first();
                 if (!$user) {
                     $user = User::create(['identification_card' => $data['cedula'], 'name' => $data['nombre'], 'user_name' => str_replace(' ', '.', $data['nombre']), 'email' => $data['email'] ? $data['email'] : 'Sin registro', 'address' => $data['direccion'] ? $data['direccion'] : 'Sin registro', 'residency_city' => $data['ciudad'] ? $data['ciudad'] : 'Sin registro', 'phone' => $data['tel1'] ? $data['tel1'] : 'Sin registro', 'mobile_phone' => $data['tel2'] ? $data['tel2'] : 'Sin registro', 'document_type' => 0, 'roles_id' => 4]);
                 }
                 $credit = CreditRequest::where('user_id', intval($user->id))->first();
                 if (!$credit) {
                     $c = new CreditRequest();
                     $c->user_id = intval($user->id);
                     $c->value = intval($data['limitecredito']);
                     $c->state = 1;
                     $c->location = 3;
                     $c->responsible = 18;
                     $c->save();
                 } else {
                     $credit->value = $data['limitecredito'];
                     $credit->save();
                 }
             }
         });
         echo $message = "El archivo  se ha guardado en la base de datos.";
     } catch (Exception $e) {
         echo $message = "No se ha guardar . Intenta subirlo de nuevo.";
     }
     Mail::send('emails.excel', ['msn' => $message], function ($m) use($message) {
         $m->to('*****@*****.**', 'Creditos Lilipink')->subject('Archivos actualizados');
     });
     array_map('unlink', glob($_SERVER['DOCUMENT_ROOT'] . "/toUpload/*"));
 }
Exemplo n.º 3
0
 public function uploadUser($id, $role)
 {
     $data = $this->prepareData($this->data);
     $user = User::find($id);
     $user->update($data);
     return true;
 }
Exemplo n.º 4
0
 public function getDataEnterpricing($id)
 {
     if (Input::get('type') == 'credit') {
         $id = CreditRequest::find($id)->user_id;
     }
     $user = User::find($id);
     return ['user' => $user, 'type' => Input::get('type'), 'routes' => ['enable' => Input::get('enable'), 'disable' => Input::get('disable')]];
 }
Exemplo n.º 5
0
 private function permissionsUser()
 {
     $data = array();
     $permissions = User::join('permission_user', 'users.id', '=', 'permission_user.user_id')->join('permissions', 'permission_user.permission_id', '=', 'permissions.id')->whereRaw('users.id = ? ', [$this->idUser])->get();
     foreach ($permissions as $permission) {
         $key = $permission->name;
         $data[$key] = array('permissionName' => $key, 'available' => $permission->available, 'inherit' => true);
     }
     return $data;
 }
Exemplo n.º 6
0
 public function changePassword($restore_password)
 {
     $data = Input::all();
     $user = User::where('restore_password', $restore_password)->first();
     if ($data["confirmar_password"] == $data["password"]) {
         $user->password = $data["password"];
         $user->save();
     } else {
         return Redirect::to('restaurar/' . $restore_password)->withErrors(['password' => 'La confirmación de la contraseña no coincide'])->withInput();
     }
     new LogRepo(['responsible' => $user->name, 'action' => 'restauro la contraseña', 'affected_entity' => '', 'method' => 'savePassword']);
     return Redirect::route('home')->with(array('mensaje' => 'La contaseña ha sido cambiada.'));
 }
Exemplo n.º 7
0
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $users = \credits\Entities\User::whereRaw('roles_id = 5 and hasCredit = 0 and user_state = 1')->get();
     foreach ($users as $user) {
         $email = $user->email;
         Mail::send('emails.ESimpleAccept', ['msn' => 'prueba'], function ($m) use($email) {
             $m->to($email, 'Creditos Lilipink')->subject('Notificación Lilipink');
         });
     }
     Mail::send('emails.ESimpleAccept', ['msn' => 'prueba'], function ($m) {
         $m->to('*****@*****.**', 'Creditos Lilipink')->subject('Notificación Lilipink');
     });
 }
Exemplo n.º 8
0
 public function saveCredit($files, $user)
 {
     $data = $this->prepareData($this->data);
     if ($user) {
         $priority = Role::where('id', '=', $user->roles_id)->first();
         $priority = $priority->priority;
         $this->entity->responsible = $user->id;
         $credit = CreditRequest::where('user_id', '=', $user->id)->first();
         if ($credit) {
             return ["message" => "no puedes solicitar mas creditos"] + ["role" => false];
         }
     } else {
         $priority = 0;
     }
     $user = new User($data);
     $user->roles_id = 4;
     $user->save();
     $this->entity->priority = $priority;
     $this->entity->files = $files;
     $this->entity->fill($this->prepareData($this->data));
     $user->CreditRequest()->save($this->entity);
     return ["message" => "la solicitud de credito fue enviada"] + ["role" => true];
 }
Exemplo n.º 9
0
 private function setData($identification)
 {
     $extracts = Extract::where("nit", $identification)->orderBy('id', 'DESC')->get();
     if ($extracts) {
         $user = User::whereRaw("roles_id = 4 and identification_card = {$identification}")->first();
         $minPay = ExcelDaily::where("cedula", $identification)->get();
         $quota = CreditRequest::where('user_id', $user->id)->first();
         $day = explode('-', date("y-m-d"));
         $q = $quota ? $quota->value : 300000;
         $this->data = ['user' => $user, 'day' => $day, 'extracts' => $extracts, 'quota' => intval($q), 'minPay' => $minPay, 'months' => $this->getMonths()];
         return true;
     }
     return false;
 }
Exemplo n.º 10
0
 public function run()
 {
     $faker = Faker::create();
     Role::Create(['name' => 'superAdmin']);
     Role::Create(['name' => 'admin']);
     Role::Create(['name' => 'POS']);
     Role::Create(['name' => 'register']);
     foreach (range(1, 10) as $i) {
         $nameExtend = $faker->name;
         $nameExtend = explode(' ', $nameExtend);
         $name = array_shift($nameExtend);
         $last_name = implode(" ", $nameExtend);
         User::create(['name' => $name, 'last_name' => $last_name, 'user_name' => $faker->userName, 'email' => $faker->email, 'password' => \Hash::make(123456), 'roles_id' => $faker->randomElement([1, 2, 3]), 'location' => '1']);
     }
 }
Exemplo n.º 11
0
 public function saveCredit($id, $responsible)
 {
     $credit = CreditRequest::where('user_id', $id)->first();
     $min = General_variables::where('name', 'min')->first();
     $max = General_variables::where('name', 'max')->first();
     $data = $this->prepareData($this->data);
     $this->entity->fill($data);
     $this->entity->credit_id = $credit->id;
     $credit->value = 300000;
     $credit->update();
     $this->save();
     $credit->state = 1;
     $credit->responsible = $responsible;
     $credit->save();
     $user = User::find($id);
     $user->user_state = 1;
     $user->save();
     return ['return' => true] + ['mail' => $user->email];
 }
Exemplo n.º 12
0
 private function exportUsers()
 {
     $users = User::where('roles_id', '>=', '4')->select('id', 'roles_id', 'card as Tarjeta', 'identification_card as Cedula', 'name as Nombre1', 'second_name as Nombre2', 'last_name as Apellido1', 'second_last_name as Apellido2', 'email as Email', 'mobile_phone as Celular', 'location as Ciudad', 'created_at as Fecha de creación')->orderBy('roles_id', 'DESC')->get();
     foreach ($users as $key => $user) {
         $credit = CreditRequest::where('user_id', $user->id)->first();
         $users[$key]['Referencia1'] = $credit ? $credit->name_reference : null;
         $users[$key]['Tel_Referencia1'] = $credit ? $credit->phone_reference : null;
         $users[$key]['Referencia2'] = $credit ? $credit->name_reference2 : null;
         $users[$key]['Tel_Referencia2'] = $credit ? $credit->phone_reference2 : null;
         $users[$key]['Ciudad'] = $user->Ciudad ? Location::find($user->Ciudad)->name : 'Sin región';
         $users[$key]['Tienda'] = $credit ? Point::find($credit->point)['name'] : 'Sin punto';
         $users[$key]['Cupo_Credito'] = $credit ? $credit->value : null;
         $users[$key]['Emprend'] = $user->roles_id == 5 ? 'Si' : 'No';
         $users[$key]['¿Empr. credito?'] = $credit && $user->roles_id == 5 ? 'Si' : $user->roles_id == 5 ? 'No' : 'N/A';
         $users[$key]['Nombre referido'] = $user->roles_id == 5 ? $user['referred_name'] : 'N/A';
         $users[$key]['Cedula referido'] = $user->roles_id == 5 ? $user['referred_document'] : 'N/A';
     }
     return $users;
 }
Exemplo n.º 13
0
 public function reprobateCredit($id)
 {
     $user = User::find($id);
     $credit = CreditRequest::where('user_id', '=', $id)->first();
     $credit->state = 2;
     $credit->save();
     $user->user_state = 2;
     $user->save();
     if ($user->email) {
         $data = ["link" => 1];
         if ($user->roles_id == 4) {
             Mail::send('emails.rejected', $data, function ($message) use($user) {
                 $message->to($user->email, 'creditos lilipink')->subject('su solicitud de credito no fue aprobada');
             });
         } else {
             Mail::send('emails.ECreditDelivery', ['email' => 'email'], function ($m) use($user) {
                 $m->to($user->email, 'Creditos Lilipink')->subject('Credito emprendedora rechazado');
             });
         }
     }
     return Redirect::route('request')->with(array('message' => "el credito no fue aprobado"));
 }
Exemplo n.º 14
0
 private function createUser($input)
 {
     $user = User::create($input);
     $user->user_name = str_replace(' ', '.', $input['name'] . '.' . $input['last_name']);
     $user->roles_id = 5;
     $user->birth_city = $input['instead_expedition'];
     $user->whereIsWorking = $input['whereIsWorking'];
     $user->isWorking = $input['isWorking'];
     $user->save();
     return $user;
 }
Exemplo n.º 15
0
 public function createUser()
 {
     $data = $this->prepareData($this->data);
     $user = new User($data);
     $user->save();
 }
Exemplo n.º 16
0
 public function searchUsersCard()
 {
     $users = User::where('card', 0)->paginate(10);
     $points = Point::all();
     return View::make('back.userCard', compact('users', 'points'));
 }