Example #1
0
 public function delete($id)
 {
     $credit = CreditRequest::where('point', $id)->first();
     if ($credit) {
         return Redirect::route('point')->with('message_error', 'el punto de venta no se puede eliminar por que esta siendo utilizado');
     }
     $point = Point::find($id);
     $point->delete();
     return Redirect::route('point')->with('message', 'el punto de venta se elimino exitosamente');
 }
Example #2
0
 public function showCreditRequest($id)
 {
     $user = User::find($id);
     $locations = Location::where('id', $user->CreditRequest->location)->first();
     $point = Point::where('id', $user->CreditRequest->point)->first();
     $images = explode(",", $user->CreditRequest->files);
     $priority = $user->CreditRequest->priority;
     return View::make('back.acceptCredit', compact('user', 'credit', 'images', 'locations', 'point', 'priority'));
 }
Example #3
0
 public function searchUsersCard()
 {
     $users = User::where('card', 0)->paginate(10);
     $points = Point::all();
     return View::make('back.userCard', compact('users', 'points'));
 }
Example #4
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;
 }