public function vistaPermisos()
 {
     $roles = Role::select("id", "name")->orderBy("id")->get();
     $permisos = PermissionRole::where("role_id", "=", "2")->select("id", "state")->orderBy("id")->get();
     $user_id = Auth::user()->id;
     $breadcrumbs = Neighbors::select('neighbors.name as name_ne', 'neighbors.last_name', 'urbanisms.name as name_ur ')->join('neighbors_properties', 'neighbors.id', '=', 'neighbors_properties.neighbors_id')->join('urbanisms', 'neighbors_properties.urbanism_id', '=', 'urbanisms.id')->where('neighbors.user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name_ne . " " . $breadcrumbs->last_name . " [ " . $breadcrumbs->name_ur . " ]";
     return View::make("dashboard.roles.rolPermisos")->with(array("roles" => $roles, "permisos" => $permisos, 'breadcrumbs_data' => $breadcrumbs_data));
 }
 public function GeneraReportePagos()
 {
     $user_id = Auth::user()->id;
     ini_set('max_execution_time', 900000);
     $idurbanismo = Neighbors::where('user_id', '=', $user_id)->first();
     $idurbanismo = $idurbanismo->urbanism_id;
     $breadcrumbs = Neighbors::select('neighbors.name as name_ne', 'neighbors.last_name', 'urbanisms.name as name_ur ')->join('neighbors_properties', 'neighbors.id', '=', 'neighbors_properties.neighbors_id')->join('urbanisms', 'neighbors_properties.urbanism_id', '=', 'urbanisms.id')->where('neighbors.user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name_ne . " " . $breadcrumbs->last_name . " [" . $breadcrumbs->name_ur . "]";
     $payments = Payment::select()->join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.neighbors_id')->where('neighbors_properties.urbanism_id', '=', $idurbanismo)->count();
     if ($payments == 0) {
         $isEmpty = true;
     } else {
         $isEmpty = false;
     }
     return View::make("dashboard.reports.report", ['isEmpty' => $isEmpty, 'idurbanismo' => $idurbanismo, 'breadcrumbs_data' => $breadcrumbs_data]);
 }
 public function send_cupon($id)
 {
     $promo = Promo::where('id', '=', $id)->first();
     $user_id = AssigmentRoleHab::where('role_id', '=', 2)->where('colony_id', '=', $promo->colony_id)->pluck('user_id');
     $admin_user = DB::connection('habitaria_dev')->select('select email from users where id = ? ', [$user_id]);
     foreach ($admin_user as $user) {
         $admin_email = $user->email;
     }
     $admin_neighbor = Neighbors::where('user_id', '=', $user_id)->first();
     $colony_data = Colony::where('id', '=', $promo->colony_id)->first();
     $colony_name = $colony_data->name;
     $data = array('email' => $admin_email, 'days' => $promo->days, 'code' => Crypt::decrypt($promo->code), 'colony' => $colony_name, 'admin' => $admin_neighbor->name . ' ' . $admin_neighbor->last_name);
     Mail::send('emails.cupon_promo', $data, function ($message) use($admin_email) {
         $message->subject('Promo de HABITARIA');
         $message->to($admin_email);
     });
     $notice_msg = 'Promo enviada al administrador de la Colonia: ' . $colony_name;
     return Redirect::back()->with('error', false)->with('msg', $notice_msg)->with('class', 'info');
 }
Ejemplo n.º 4
0
 public function sendMailInvitation()
 {
     $last_invited_add = Input::get('invited_id');
     $inv_admin = Input::get('admin_colonia');
     $admin_colonia = Neighbors::where('id', '=', $inv_admin)->first();
     $neighbors = InvitedNeighbors::where('invited_id', '=', $last_invited_add)->get();
     $urbanism_id = Input::get('urbanismo');
     $urbanism = Urbanism::findOrFail($urbanism_id);
     $code = Session::get('code');
     foreach ($neighbors as $inv_neighbor) {
         $email = $inv_neighbor->email;
         $data = array('email' => $email, 'link' => 'ConfirmationController@confirm', 'code' => $inv_neighbor->confirmation_code, 'name_inv' => $admin_colonia->name, 'lname_inv' => $admin_colonia->last_name, 'urbanism' => $urbanism->name);
         Mail::send('emails.confirm_neighbors', $data, function ($message) use($email) {
             $message->subject('Invitación HABITARIA');
             $message->to($email);
         });
     }
     $notice_msg = "<h4>A concluido el proceso de registro</h4><p>Vecinos invitados con éxito</p>";
     return Redirect::action('NeighborController@admin_neighbor', array('admin_colonia' => $inv_admin, 'urbanismo' => $urbanism_id));
 }
 public function confirm_data_fam($code)
 {
     if (!$code) {
         $error_msg = new InvalidConfirmationCodeException();
         return Redirect::action('UsersController@login')->with('error', $error_msg);
     }
     $confirm = InvitedNeighbors::where('Confirmation_code', '=', $code)->first();
     if (!$confirm) {
         $error_msg = Lang::get('confide::confide.alerts.wrong_confirmation');
         return Redirect::action('UsersController@login')->with('error', $error_msg);
     }
     if (!$confirm->confirmed) {
         $email = $confirm->email;
         $reg_user = User::where('email', '=', $email)->first();
         if ($reg_user) {
             $reg_neighbor = Neighbors::where('user_id', '=', $reg_user->id)->first();
             $property = NeighborProperty::where('neighbors_id', '=', $reg_neighbor->id)->first();
             $urbanism_id = $confirm->urbanism_id;
             $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)->first();
             } else {
                 $catalog = StreetCatalog::where('urbanism_id', '=', $urbanism_id)->first();
             }
             $notice_msg = Lang::get('confide::confide.alerts.confirmation_invitation');
             return View::make('dashboard.neighbors.edit_fam', ['email' => $email, 'urbanism' => $urbanism_name, 'urbanism_id' => $urbanism_id, 'code' => $code, 'urbanism_type' => $urbanism_type, 'catalog' => $catalog, 'neighbor' => $reg_neighbor, 'property' => $property, 'notice' => $notice_msg]);
         } else {
             return Redirect::action('ConfirmationController@confirm', $code);
         }
     } else {
         $notice_msg = 'Acceda a Habitaria con su usuario creado';
         return Redirect::action('UsersController@login')->with('notice', $notice_msg);
     }
 }
 public function record_neighbors()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $urbanismo = $urbanism->id;
     $urb_name = $urbanism->Colony->name;
     $property_id = NeighborProperty::where('urbanism_id', '=', $urbanismo)->pluck('id');
     $vigencia = date("Y-m");
     $months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Decem");
     $today = date("Y-m-d");
     $ano = date("Y");
     $selano = Payment::select(DB::raw('DATE_FORMAT(payments.created_at,\'%Y\') as y'))->groupBy(DB::raw('Year(payments.created_at)'))->orderBy(DB::raw('Year(payments.created_at)'))->get();
     $monthly_all = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->get();
     $monthly_ini = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->orderBy('monthly_fee.created_at', 'ASC')->pluck('since');
     $mes_ini = (int) date("m", strtotime($monthly_ini));
     $cuotas = array();
     foreach ($monthly_all as $cuota_mensual) {
         $ini = (int) date("m", strtotime($cuota_mensual->since));
         $fin = (int) date("m", strtotime($cuota_mensual->until));
         if ($cuota_mensual->until == NULL) {
             $fin = (int) date("m");
         }
         for ($i = $ini; $i <= $fin; $i++) {
             $cuotas[$months[$i - 1]] = $cuota_mensual->amount;
         }
     }
     $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanismo)->get();
     $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urb_name . " ]";
     return View::make('dashboard.payments.neighbors.index', ['cuotas' => $cuotas, 'mes_ini' => $mes_ini, 'months' => $months, 'selano' => $selano, 'urbanism' => $urbanismo, 'breadcrumbs_data' => $breadcrumbs_data, 'neighbors' => $neighbors, 'ini' => $ini, 'fin' => $fin, 'ano' => $ano]);
 }
 public function permission_tree()
 {
     $attendant_id = Auth::user()->id;
     $attendant = Neighbors::with('NeighborProperty')->findOrFail($attendant_id);
     return View::make('dashboard.admin.permission.tree', ['attendant' => $attendant]);
 }
 public function catologo_egreso()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $catalog = SubAccount::where('urbanism_id', '=', $urbanism->id)->where('account_id', '=', 2)->orderBy('id', 'ASC')->get();
     $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urbanism->Colony->name . " ]";
     return View::make('dashboard.expenses.catalogo_egresos', ['usuario' => $breadcrumbs_data, 'urbanism_id' => $urbanism->id, 'catalog' => $catalog]);
 }
 public function record_index()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $AssigmentRole = Auth::user()->AssigmentRole[0]->role_id;
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $urb_name = $urbanism->Colony->name;
     $collector = Collector::where('user_id', '=', $user_id)->where('urbanism_id', '=', $urbanism->id)->first();
     $collector_neighbor = Neighbors::where('user_id', '=', $user_id)->first();
     $collector_properties = NeighborProperty::where('neighbors_id', '=', $collector_neighbor->id)->pluck('id');
     $neighbors_payments = Payment::join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.id')->join('neighbors', 'neighbors_properties.neighbors_id', '=', 'neighbors.id')->join('sub_accounts', 'payments.sub_account_id', '=', 'sub_accounts.id')->select('payments.id', 'payments.created_at', 'payments.amount', 'payments.coments', 'neighbors.name', 'neighbors.last_name', 'sub_accounts.description')->where('neighbors_properties.urbanism_id', '=', $urbanism->id)->orderBy('created_at')->get();
     $breadcrumbs = Neighbors::with('NeighborProperty')->where('user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [" . $urb_name . "]";
     return View::make('dashboard.incomes.record.index', ['incomes' => $neighbors_payments, 'breadcrumbs_data' => $breadcrumbs_data, 'AssigmentRole' => $AssigmentRole, 'total' => 0]);
 }
 public function sugerenciasPapelera()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $neighbor = Neighbors::where('user_id', '=', $user_id)->first();
     $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanism->id)->where('neighbors_id', '!=', $neighbor->id)->get();
     $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urbanism->Colony->name . " ]";
     $suggestions = Suggestion::where('user_id', '=', $user_id)->where('tray', '=', 0)->where('bd_inbox', '=', 1)->orderBy('created_at', 'desc')->paginate(10);
     $count = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('bd_inbox', '=', 2)->where('mark', '<>', 'read')->count();
     return View::make('dashboard.colonies.suggestions.suggestions_trash', ['usuario' => $breadcrumbs_data, 'urbanism' => $urbanism, 'admin' => $neighbor->id, 'suggestions' => $suggestions, 'count' => $count, 'contador' => 1, 'neighbor' => $neighbor]);
 }
 public function suggestion()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $neighbor = Neighbors::where('user_id', '=', $user_id)->first();
     $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanism->id)->where('neighbors_id', '!=', $neighbor->id)->get();
     $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
     $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urbanism->Colony->name . " ]";
     $suggestions = DB::table('suggestions')->select('suggestions.id', 'suggestions.user_id', 'neighbors.name', 'neighbors.last_name', 'suggestions.asunto', 'suggestions.contenido', 'suggestions.id_mensaje', 'suggestions.mark', 'suggestions.created_at')->join('neighbors', 'neighbors.user_id', '=', 'suggestions.user_id')->where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->orderBy('created_at', 'desc')->paginate(10);
     $count = Suggestion::where('id_receptor', '=', $user_id)->where('tray', '<>', 0)->where('mark', '<>', 'read')->count();
     $suggestionsSent = Suggestion::where('user_id', '=', $user_id)->where('tray', '<>', 0)->get();
     return View::make('dashboard.colonies.suggestions.suggestion', ['usuario' => $breadcrumbs_data, 'urbanism' => $urbanism->id, 'admin' => $neighbor->id, 'suggestions' => $suggestions, 'count' => $count, 'suggestionsSent' => $suggestionsSent, 'contador' => 1]);
 }
 public function reportStatus()
 {
     $user_id = Auth::user()->id;
     $colonia = Session::get("colonia");
     $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
     $urbanismo = $urbanism->id;
     $urb_name = $urbanism->name;
     $property_id = NeighborProperty::where('urbanism_id', '=', $urbanismo)->pluck('id');
     $vigencia = date("Y-m");
     $months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Decem");
     $today = date("Y-m-d");
     $ano = date("Y");
     $selano = Payment::select(DB::raw('DATE_FORMAT(payments.created_at,\'%Y\') as y'))->groupBy(DB::raw('Year(payments.created_at)'))->orderBy(DB::raw('Year(payments.created_at)'))->get();
     $monthly_all = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->get();
     $monthly_ini = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->orderBy('monthly_fee.created_at', 'ASC')->pluck('since');
     $mes_ini = (int) date("m", strtotime($monthly_ini));
     $cuotas = array();
     foreach ($monthly_all as $cuota_mensual) {
         $ini = (int) date("m", strtotime($cuota_mensual->since));
         $fin = (int) date("m", strtotime($cuota_mensual->until));
         if ($cuota_mensual->until == NULL) {
             $fin = (int) date("m");
         }
         for ($i = $ini; $i <= $fin; $i++) {
             $cuotas[$months[$i - 1]] = $cuota_mensual->amount;
         }
     }
     $neighbors = NeighborProperty::with('Neighbors')->where('urbanism_id', '=', $urbanismo)->get();
     $breadcrumbs = Neighbors::select('neighbors.name as name_ne', 'neighbors.last_name', 'urbanisms.name as name_ur ')->join('neighbors_properties', 'neighbors.id', '=', 'neighbors_properties.neighbors_id')->join('urbanisms', 'neighbors_properties.urbanism_id', '=', 'urbanisms.id')->where('neighbors.user_id', '=', self::getUserId())->first();
     $breadcrumbs_data = $breadcrumbs->name_ne . " " . $breadcrumbs->last_name . " [" . $breadcrumbs->name_ur . "]";
     $data = ['mes_ini' => $mes_ini, 'months' => $months, 'cuotas' => $cuotas, 'selano' => $selano, 'urbanism' => $urbanismo, 'breadcrumbs_data' => $breadcrumbs_data, 'neighbors' => $neighbors, 'ini' => $ini, 'fin' => $fin, 'ano' => $ano, 'breadcrumbs_data' => $breadcrumbs_data];
     $pdf = PDF::loadView('dashboard.reports.status.pdf', $data);
     return $pdf->download('reporte_Estato_cuanta_general.pdf');
 }
 public function store_register_neighbors()
 {
     $post = Input::All();
     $urbanismNeigh = Input::get('urbanism');
     $neighbor = new Neighbors();
     $neighbor->user_id = Input::get('user_id');
     //$neighbor->urbanism_id =  Input::get('urbanism');
     $neighbor->name = Input::get('firstname');
     $neighbor->last_name = Input::get('lastname');
     $neighbor->phone = Input::get('phone');
     $neighbor->save();
     $last_neighbor_add = $neighbor->id;
     $urbanism_type = Input::get('urbanism_type');
     $neighbor_properties = new NeighborProperty();
     $neighbor_properties->neighbors_id = $last_neighbor_add;
     $neighbor_properties->urbanism_id = Input::get('urbanism');
     if ($urbanism_type == 3) {
         $neighbor_properties->num_floor_id = Input::get('name_floor');
     } else {
         $neighbor_properties->num_street_id = Input::get('name_street');
     }
     $neighbor_properties->num_house_or_apartment = Input::get('num_house_or_apartment');
     if ($neighbor_properties->save()) {
         $role = Role::where('name', '=', 'vecino')->first();
         $colony = Urbanism::where('id', '=', Input::get('urbanism'))->pluck('colony_id');
         $rol = new AssigmentRole();
         $rol->user_id = Input::get('user_id');
         $rol->role_id = $role->id;
         $rol->colony_id = $colony;
         $rol->save();
     }
     $colonies = Colony::select('colonies.id')->join('urbanisms', 'urbanisms.colony_id', '=', 'colonies.id')->join('neighbors_properties', 'urbanisms.id', '=', 'neighbors_properties.urbanism_id')->where('neighbors_properties.urbanism_id', '=', $urbanismNeigh)->first();
     $user = Neighbors::where('id', '=', $last_neighbor_add)->pluck('user_id');
     $user_auth = User::where('id', '=', $user)->first();
     Auth::login($user_auth);
     if (Auth::check()) {
         Session::put('colonia', $colonies->id);
         return Redirect::action('HomeController@index');
     } else {
         return Redirect::action('UsersController@login');
     }
 }