public function record_index() { $user_id = Auth::user()->id; $AssigmentRole = Auth::user()->AssigmentRole[0]->role_id; $colonia = Session::get("colonia"); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $urbanismo = $urbanism->id; $urb_name = $urbanism->Colony->name; $neighbor = Neighbors::where('user_id', '=', $user_id)->pluck('id'); $property_id = NeighborProperty::where('urbanism_id', '=', $urbanismo)->where('neighbors_id', '=', $neighbor)->pluck('id'); $neighbor_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.collector_id', 'payments.created_at', 'payments.amount', 'payments.coments', 'neighbors.name', 'neighbors.last_name', 'sub_accounts.description')->where('neighbor_property_id', '=', $property_id)->orderBy('payments.id', 'ASC')->get(); $ano = date("Y"); $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)); $meses = array("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); $mes = array("Ene", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); $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[$i] = $cuota_mensual->amount; } } $breadcrumbs = Neighbors::with('NeighborProperty')->where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urb_name . " ]"; $total = count($neighbor_payments); return View::make('dashboard.payments.record.index_record', ['payments' => $neighbor_payments, 'breadcrumbs_data' => $breadcrumbs_data, 'AssigmentRole' => $AssigmentRole, 'total' => $total, 'cuotas' => $cuotas, 'mes_ini' => $mes_ini, 'meses' => $meses, 'mes' => $mes, 'urbanismo' => $urbanismo]); }
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'); } }
public function index() { $user_id = Auth::user()->id; $colonia = Session::get("colonia"); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $urbanism_id = $urbanism->id; $urb_name = $urbanism->Colony->name; $breadcrumbs = Neighbors::where('user_id', '=', $user_id)->first(); $breadcrumbs_data = $breadcrumbs->name . " " . $breadcrumbs->last_name . " [ " . $urb_name . " ]"; $sub_accounts = SubAccount::where('account_id', '=', 2)->where('urbanism_id', '=', $urbanism_id)->get(); $amountIngresos = 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(DB::raw('sum(payments.amount) as amountIngresos'))->where('neighbors_properties.urbanism_id', '=', $urbanism->id)->get(); return View::make('dashboard.expenses.index', ['sub_accounts' => $sub_accounts, 'urbanism_id' => $urbanism_id, 'usuario' => $breadcrumbs_data, 'amountIngresos' => $amountIngresos[0]]); }
/** * Display the specified resource. * * @param int $id * @return Response */ public function show($publicId) { $client = Client::scope($publicId)->withTrashed()->with('contacts')->first(); if ($client) { //$client = Client::scope($publicId)->with('contacts')->firstOrFail(); $getTotalCredit = Credit::scope()->where('client_id', '=', $client->id)->whereNull('deleted_at')->where('balance', '>', 0)->sum('balance'); $invoices = Invoice::join('invoice_statuses', 'invoice_statuses.id', '=', 'invoices.invoice_status_id')->where('invoices.account_id', Auth::user()->account_id)->where('invoices.client_id', $client->id)->where('invoices.branch_id', Session::get('branch_id'))->select('invoices.invoice_number', 'invoices.invoice_date', 'invoices.importe_total', 'invoices.balance', 'invoices.due_date', 'invoice_statuses.name', 'invoices.public_id')->get(); $pagos = Payment::join('invoices', 'invoices.id', '=', 'payments.invoice_id')->join('payment_types', 'payment_types.id', '=', 'payments.payment_type_id')->where('payments.account_id', Auth::user()->account_id)->where('payments.client_id', $client->id)->select('invoices.invoice_number', 'payments.transaction_reference', 'payment_types.name', 'payments.amount', 'payments.payment_date')->get(); $creditos = Credit::where('account_id', '=', Auth::user()->account_id)->where('client_id', '=', $client->getId())->get(); $data = array('title' => 'Ver Cliente', 'client' => $client, 'invoices' => $invoices, 'pagos' => $pagos, 'credit' => $getTotalCredit, 'creditos' => $creditos); // return Response::json($data); return View::make('clientes.show', $data); } Session::flash('error', 'No existe el usuario'); return Redirect::to('clientes'); }
/** * Display a listing of the resource. * * @return Response */ public function index() { // $payments = Payment::join('clients', 'clients.id', '=', 'payments.client_id')->join('invoices', 'invoices.id', '=', 'payments.invoice_id')->leftJoin('payment_types', 'payment_types.id', '=', 'payments.payment_type_id')->where('payments.account_id', '=', \Auth::user()->account_id)->select('payments.public_id', 'payments.transaction_reference', 'clients.name as client_name', 'clients.public_id as client_public_id', 'payments.amount', 'payments.payment_date', 'invoices.public_id as invoice_public_id', 'invoices.invoice_number', 'payment_types.name as payment_type')->get(); return View::make('pagos.index', array('payments' => $payments)); }
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 ajaxReportIncomes() { $desde = strftime("%Y-%m-%d", strtotime(Input::get('desde'))); $hasta = strftime("%Y-%m-%d", strtotime(Input::get('hasta'))); $neighbor_property_id = Input::get('neighbor_property_id'); if ($neighbor_property_id == 'Todos') { $colonia = Session::get("colonia"); $urbanism = Urbanism::where('colony_id', '=', $colonia)->first(); $urbanismo = $urbanism->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', 'payments.collector_id', 'neighbors.name', 'neighbors.last_name', 'sub_accounts.description')->where('neighbors_properties.urbanism_id', '=', $urbanismo)->whereBetween(DB::raw("DATE_FORMAT(payments.created_at,'%Y-%m-%d')"), [$desde, $hasta])->orderBy('created_at')->get(); } else { $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.collector_id', 'payments.created_at', 'payments.amount', 'payments.coments', 'neighbors.name', 'neighbors.last_name', 'sub_accounts.description')->where('neighbor_property_id', '=', $neighbor_property_id)->whereBetween(DB::raw("DATE_FORMAT(payments.created_at,'%Y-%m-%d')"), [$desde, $hasta])->get(); } return View::make('dashboard.reports.incomes.tableReportsIncomes', ['payments' => $neighbors_payments, 'desde' => $desde, 'hasta' => $hasta, 'neighbor_property_id' => $neighbor_property_id]); }