コード例 #1
0
 public function index()
 {
     if (Auth::check()) {
         $user_id = Auth::user()->id;
         $colonia = Session::get("colonia");
         //obtener el rol que desempeña en la colonia
         $rol_id = AssigmentRole::where('user_id', '=', $user_id)->where('colony_id', '=', $colonia)->pluck('role_id');
         Session::put("rol_usuario", $rol_id);
         $permisos = array();
         $permisos = DB::table('permission_role')->where("role_id", "=", $rol_id)->select("permission_role.id", "permission_role.state")->orderBy("permission_role.id")->get();
         Session::put("dato", $permisos);
         $urbanism = Urbanism::where('colony_id', '=', $colonia)->first();
         $urbanismo = $urbanism->id;
         $urb_name = $urbanism->Colony->name;
         $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first();
         $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urb_name . " ]";
         $Total = DB::table('neighbors_properties')->select(DB::raw('Count(neighbors_properties.id) as total'))->where('neighbors_properties.urbanism_id', '=', $urbanismo)->get();
         $Total = $Total[0]->total;
         $PorAceptar = DB::table('invited_neighbors')->select(DB::raw('count(invited_neighbors.id) as porAceptar'))->where('invited_neighbors.confirmed', '=', 0)->where('invited_neighbors.urbanism_id', '=', $urbanismo)->get();
         $PorAceptar = $PorAceptar[0]->porAceptar;
         $Aceptadas = DB::table('invited_neighbors')->select(DB::raw('count(invited_neighbors.id) as Aceptadas'))->where('invited_neighbors.confirmed', '=', 1)->where('invited_neighbors.urbanism_id', '=', $urbanismo)->get();
         $Aceptadas = $Aceptadas[0]->Aceptadas;
         $ano = date("Y");
         $monthly_all = MonthlyFee::where('monthly_fee.urbanism_id', '=', $urbanismo)->where(DB::raw('DATE_FORMAT(monthly_fee.since,\'%Y\')'), '=', $ano)->get();
         $months = array("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Decem");
         $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;
             }
         }
         $j = (int) date("m");
         $monthly_fee = $cuotas[$months[$j - 1]];
         $mes = date("M");
         $pagoMensual = PaymentStates::join('neighbors_properties', 'payment_states.neighbor_property_id', '=', 'neighbors_properties.id')->where($mes, '>=', $monthly_fee)->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('count(neighbors_properties.id) as cant'))->get();
         if ($pagoMensual) {
             $pagoMensual = $pagoMensual[0]->cant;
         } else {
             $pagoMensual = 0;
         }
         $Egresos = Expense::join('sub_accounts', 'expenses.sub_account_id', '=', 'sub_accounts.id')->where('expenses.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(expenses.amount) as amount'), 'sub_accounts.description')->groupBy('sub_accounts.description')->get();
         $Ingresos = Payment::join('sub_accounts', 'payments.sub_account_id', '=', 'sub_accounts.id')->join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.id')->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(payments.amount) as amount'), 'sub_accounts.description')->groupBy('sub_accounts.description')->get();
         $EgresosMensual = Expense::where('expenses.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(expenses.amount) as amount'), DB::raw('DATE_FORMAT(expenses.created_at,\'%m\') as mes'))->groupBy(DB::raw('Month(expenses.created_at)'))->get();
         $IngresosMensual = Payment::join('neighbors_properties', 'payments.neighbor_property_id', '=', 'neighbors_properties.id')->where('neighbors_properties.urbanism_id', '=', $urbanismo)->select(DB::raw('sum(payments.amount) as amount'), DB::raw('DATE_FORMAT(payments.created_at,\'%m\') as mes'))->groupBy(DB::raw('Month(payments.created_at)'))->get();
         return View::make('dashboard.home', ['Total' => $Total, 'PorAceptar' => $PorAceptar, 'Aceptadas' => $Aceptadas, 'monthly_fee' => $monthly_fee, 'pagoMensual' => $pagoMensual, 'Egresos' => $Egresos, 'Ingresos' => $Ingresos, 'EgresosMensual' => $EgresosMensual, 'IngresosMensual' => $IngresosMensual, 'Nombre' => $breadcrumbs_data]);
     } else {
         return Redirect::action('UsersController@login');
     }
 }
コード例 #2
0
							  	  <!--<td bgcolor="#A7F8B3" width="20%">Dirección</td>-->
								  <td bgcolor="#A7F8B3" width="15%">Vecino</td>
								  <td bgcolor="#A7F8B3">Ene</td><td bgcolor="#A7F8B3">Feb</td>
								  <td bgcolor="#A7F8B3">Mar</td><td bgcolor="#A7F8B3">Abr</td>
								  <td bgcolor="#A7F8B3">May</td><td bgcolor="#A7F8B3">Jun</td>
								  <td bgcolor="#A7F8B3">Jul</td><td bgcolor="#A7F8B3">Ago</td>
								  <td bgcolor="#A7F8B3">Sep</td><td bgcolor="#A7F8B3">Oct</td>
								  <td bgcolor="#A7F8B3">Nov</td><td bgcolor="#A7F8B3">Dic</td>
							</tr>

						  </thead>

						  <tbody>
						<?php 
foreach ($neighbors as $neighbor) {
    $neighbor_payments = PaymentStates::with('NeighborProperty')->where(DB::raw('year'), '=', date("Y"))->where('neighbor_property_id', '=', $neighbor->id)->first();
    if ($neighbor_payments) {
        $debe = 0;
        //if($neighbor->Urbanism->UrbanismType->id == 3)
        //echo '<td style="font-size:95%;" ><div align="left">'.strtolower ($neighbor->Building->description).' - Apto. '.$neighbor->num_house_or_apartment.'</div></td>';
        //else
        // echo '<td style="font-size:95%;" ><div align="left">'.strtolower ($neighbor->Street->name).' - Casa '.$neighbor->num_house_or_apartment.'</div></td>';
        echo '<td><div align="left">' . ucfirst(strtolower($neighbor->Neighbors->name)) . ' ' . ucfirst(strtolower($neighbor->Neighbors->last_name)) . '</div></td>';
        for ($j = 0; $j <= 11; $j++) {
            if ($j + 1 < $mes_ini) {
                echo '<td>&nbsp;</td>';
            } else {
                if ($j + 1 <= date("m")) {
                    if ($neighbor_payments->{$months}[$j] == Null && date("m") != $j + 1) {
                        $debe = $debe + $cuotas[$months[$j]];
                        echo '<td dir="' . $neighbor_payments->NeighborProperty->id . '"  class="modalInfo" style="color:#ED3333;  cursor: pointer; font-size:100% ;text-align: center;"> <div><i class="fa fa-2x fa-times" ></i></div></td>';
コード例 #3
0
 public function modalEstadoCuenta()
 {
     $neighbor_property_id = Input::get('neighbor_property_id');
     $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;
         }
     }
     for ($j = 0; $j <= 11; $j++) {
         if ($j + 1 < $mes_ini) {
             $saldoAnteriol[$j] = "";
             $cuataMes[$j] = "";
             $totalDebe[$j] = "";
             $pagos[$j] = "";
             $saldoTotal[$j] = "";
         } elseif ($j + 1 <= date("m")) {
             $saldoAnteriol[$j] = $saldoTotal[$j - 1];
             $cuataMes[$j] = -$cuotas[$months[$j]];
             $totalDebe[$j] = $saldoAnteriol[$j] + $cuataMes[$j];
             $neighbor_payments = PaymentStates::with('NeighborProperty')->where('neighbor_property_id', '=', $neighbor_property_id)->first();
             if ($neighbor_payments) {
                 $pagos[$j] = $neighbor_payments->{$months}[$j] == NULL ? 0 : $neighbor_payments->{$months}[$j];
             } else {
                 $pagos[$j] = 0;
             }
             $saldoTotal[$j] = $totalDebe[$j] + $pagos[$j];
         } elseif ($j + 1 > date("m")) {
             $saldoAnteriol[$j] = "";
             $cuataMes[$j] = "";
             $totalDebe[$j] = "";
             $pagos[$j] = "";
             $saldoTotal[$j] = "";
         }
     }
     $neighbor = NeighborProperty::find($neighbor_property_id);
     return View::make('dashboard.payments.neighbors.table_neigbor', compact('breadcrumbs_data', 'saldoAnteriol', 'cuataMes', 'totalDebe', 'pagos', 'saldoTotal', 'mes_ini', 'ini', 'months', 'color', 'neighbor'));
 }
コード例 #4
0
 public function delete($id)
 {
     try {
         $payment = Payment::findOrFail($id);
         $neighbor_property_id = $payment->neighbor_property_id;
         $amount = $payment->amount;
         $mes = date("M");
         if ($payment->delete(['id'])) {
             $payment_states = PaymentStates::where('neighbor_property_id', '=', $neighbor_property_id)->first();
             $payment_states->accumulated = $payment_states->accumulated - $amount;
             $payment_states->{$mes} = $payment_states->{$mes} - $amount;
             $payment_states->update(['id']);
             return Redirect::back()->with('error', false)->with('msg', 'Ingreso removido exitosamente.')->with('class', 'warning');
         } else {
             echo $exc->getMessage() . " " . $exc->getLine();
             return Redirect::back()->with('error', true)->with('msg', '¡Algo salió mal! Contacte con administrador')->with('class', 'danger');
         }
     } catch (Exception $exc) {
         echo $exc->getMessage() . " " . $exc->getLine();
         return Redirect::back()->with('error', true)->with('msg', '¡Algo salió mal! Contacte con administrador')->with('class', 'danger');
     }
 }