public function verificatorCredit($id) { $credit = CreditRequest::where('user_id', $id)->first(); $locations = Location::where('id', $credit->location)->first(); $variables = General_variables::all(); $data = $this->prepareData($this->data); $message = []; $countCredit = 0; if ($variables[0]->value < $data['data_credit']) { $countCredit++; } else { $message = $message + ['data_credit' => 'no superado datacredito']; } if ($variables[1]->value < $data['data_monthly']) { $countCredit++; } else { $message = $message + ['data_monthly' => 'no superado datos mensuales']; } if ($variables[2]->value < $data['value_monthly']) { $countCredit++; } else { $message = $message + ['value_monthly' => 'no superado el valor mensual']; } if ($variables[2]->value < $data['value_monthly']) { $countCredit++; } else { $message = $message + ['value_monthly' => 'no superado el valor mensual']; } if (isset($data['reference1']) or isset($data['reference2'])) { $countCredit++; } else { $message = $message + ['reference' => 'no tienen ninguna referencia confirmada']; } if (isset($data['files'])) { $countCredit++; } else { $message = $message + ['files' => 'Los archivos no estan correctos']; } if (strtolower($locations->name) == "medellin") { if ($data['fenalco'] > 0) { $countCredit++; } else { $message = $message + ['fenalco' => 'Fenalco no fue superado']; } if ($countCredit == 7) { return ['return' => true]; } else { return $message + ['accept' => '1']; } } else { if ($countCredit == 6) { return ['return' => true]; } else { return $message + ['accept' => '1']; } } }
protected function getRegister() { $locations[0] = 'Seleccione una ciudad'; $points = Location::join('points', 'locations.id', '=', 'points.location_id')->select('locations.id as location_id', 'locations.name as location_name', 'points.id as point_id', 'points.name as point_name')->where('isEnterpricingShop', 1)->get(); foreach ($points as $point) { if (!in_array($point['location_name'], $locations)) { $locations[$point['location_id']] = $point['location_name']; } } return View::make('front.enterprisingRegister', compact('locations', 'points')); }
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; }
public function run() { Location::create(['id' => 1, 'name' => 'Bogota']); Location::create(['name' => 'Medellin']); }
public function deleteLocation($id) { $user = User::where('location', $id)->first(); $credit = CreditRequest::where('location', $id)->first(); if ($user or $credit) { return Redirect::route('location')->with(array('messages' => "No se pudo eliminar la region por que esta siendo usada")); } $location = Location::find($id); $location->delete(); new LogRepo(['responsible' => Auth::user()->user_name, 'action' => 'ha eliminado una region ', 'affected_entity' => 'Regiones', 'method' => 'deleteLocation']); return Redirect::route('location')->with(array('message' => "La region ha sido eliminada")); }
public function newUser() { $location = ["seleccione una region" => "seleccione una region"] + Location::all()->lists('name'); $roles = ["seleccione un role" => "seleccione un role"] + Role::all()->lists('name', 'id'); return View::make('back.userNew', compact('roles', 'location')); }
public function show() { $locations = ['' => 'seleccione una region'] + Location::all()->lists('name', 'id'); $points = Point::all(); return View::make('back.point', compact('points', 'locations')); }