public function getValido(Request $request, $socio_numero, $plan_id) { if ($request->ajax()) { /* Traigo el id del socio cuyo numero coincida con el valor ingresado */ $socio = socio::where('numero', $socio_numero)->get()->toArray(); $socio_id = $socio[0]['id']; /* Traigo del plan el precio segun el plan elegido */ $plan = Plan::where('id', $plan_id)->get()->toArray(); $precio = $plan[0]['precio']; /* Traigo del pago la fecha del último pago para calcular la deuda según el plan elegido y socio elegido*/ $pago = Pago::where('socios_id', $socio_id)->where('planes_id', $plan_id)->orderBy('fecha', 'DESC')->first(); if (!empty($pago)) { $fecha_pago = $pago->fecha; /* Calculo la fecha de hoy */ $fecha_hoy = date('d-m-Y'); /* Convierto las fechas para poder usar diff */ $fechai = new DateTime($fecha_pago); $fechaf = new DateTime($fecha_hoy); $diferencia = $fechaf->diff($fechai); /* Calculo la diferencia de meses dentro del mismo año */ $diferencia_meses = $diferencia->format("%m"); /* Calculo la diferencia de años y la multiplicamos por 12 para tener los meses */ $diferencia_anios = $diferencia->format("%y") * 12; $meses_total = $diferencia_meses + $diferencia_anios; } else { $meses_total = 1; } $respuesta = array($meses_total, $precio); return response()->json($respuesta); } }
public function testCreate() { $user = $this->generateUser(); $this->visit('/plan')->withSession(['Auth' => $user])->type('UnitTestProject', 'pname')->type('Test', 'pdescription')->type('1000', 'pexpected')->type('10000', 'ptarget')->type('0', 'pbudget')->type('10', 'pmonth')->press('pSave')->seePageIs('/plan'); $plan = Plan::where("name", "=", "UnitTestProject")->first(); $this->assertNotNull($plan); $plan->delete(); $user->delete(); }
public function getMonto(Request $request, $plan_id) { if ($request->ajax()) { /* Traigo del plan el precio segun el plan elegido */ $plan = Plan::where('id', $plan_id)->get()->toArray(); $precio = $plan[0]['precio']; $respuesta = array($precio); return response()->json($respuesta); } }
/** * Show the form for creating a new resource. * * @param Deposit $deposit * @return \Illuminate\Http\Response * @internal param RequestMoney $money */ public function create(Deposit $deposit) { $user = \Auth::user(); $user_purchases = \DB::table('purchase')->select(\DB::raw('count(purchase.id)'))->join('users', 'purchase.user_id', '=', 'users.id')->where('purchase.user_id', $user->id)->whereNotIn('type_id', [1, 3])->where('purchase.status_admin', 1)->groupBy('purchase.id')->get(); if (count($user_purchases) > 0) { $currencies = Plan::where('type_id', 2)->get(); } else { $currencies = Plan::where('type_id', 1)->get(); } return view('request.create', compact('deposit', 'currencies', 'user')); }
public function imprimirProfesorxPlan($patronplan = null) { if (empty($patronplan)) { $planes = Plan::all(); } else { $planes = Plan::where('plan', "LIKE", "%{$patronplan}%")->orderBy('plan')->get(); } $vista = \View::make('planes.profesorxplanpdf', ['planes' => $planes])->render(); $pdf = \App::make('dompdf.wrapper'); $pdf->loadHTML($vista); return $pdf->stream('profesorxplanpdf'); }
/** * @POST("get_plan") * @param Request $request * @return \Illuminate\Http\JsonResponse */ public function get_plan(Request $request) { //dd($request->all()); $plan = Plan::where('id', $request->input('plan'))->first()->toArray(); return response()->json($plan); }
/** * Update the specified resource in storage. * * @param \Illuminate\Http\Request $request * @param int $id * @return \Illuminate\Http\Response */ public function update(PlansRequest $request, $id) { foreach ($request->all() as $key => $val) { if (substr($key, 0, 2) == "p_") { $tagname = "t_" . substr($key, 2); $tag = $request->input($tagname); if (!$tag) { $tag = null; } if ($val) { $pid = substr($val, 2); if (substr($val, 0, 1) == "M") { $ptyp = "App\\Models\\Minister"; } elseif (substr($val, 0, 1) == "P") { $ptyp = "App\\Models\\Preacher"; } else { $ptyp = "App\\Models\\Guest"; } } else { $pid = null; $ptyp = null; } $kk = array(explode('_', $key)); $plan = Plan::where('society_id', '=', $kk[0][1])->where('service_id', '=', $kk[0][2])->where('planyear', '=', $kk[0][3])->where('planmonth', '=', $kk[0][4])->where('planday', '=', $kk[0][5])->first(); if (count($plan)) { $plan->tag_id = $tag; $plan->preachable_id = $pid; $plan->preachable_type = $ptyp; if ($tag == null and $pid == null) { $plan->delete(); } else { $plan->save(); } } else { if ($tag or $pid) { $newplan = Plan::create(array('society_id' => $kk[0][1], 'service_id' => $kk[0][2], 'planyear' => $kk[0][3], 'planmonth' => $kk[0][4], 'planday' => $kk[0][5], 'preachable_id' => $pid, 'preachable_type' => $ptyp, 'tag_id' => $tag)); } } } } return Redirect::back()->with('okmessage', 'Plan details have been updated'); }
public function compose(View $view) { $plans_good = Plan::where('type_id', 1)->get(); $plans_bad = Plan::where('type_id', 2)->get(); $view->with('plans1', $plans_good)->with('plans2', $plans_bad); }
/** * Display a listing of Service Plans * filtered by user (leader/teacher) or by plan type * * @param filter (user|type) Show only plans for a certain user or of a certain type * @param value user_id or type_id * @param show (all|future) Show only future plans or all * * @return \Illuminate\Http\Response */ public function index(Request $request) { $querystringArray = $request->input(); // set default values $filterby = isset($request->filterby) ? $request->filterby : ''; $filtervalue = isset($request->filtervalue) ? $request->filtervalue : ''; $show = isset($request->show) ? $request->show : 'future'; $orderBy = isset($request->orderby) ? $request->orderby : 'date'; $order = isset($request->order) ? $request->order : 'asc'; $userIsPlanMember = []; // show only plans for certain user ids if ($filterby == 'user') { // show all plans, past and future? if ($show == 'all') { $plans = Plan::with('type')->where('leader_id', $filtervalue)->orWhere('teacher_id', $filtervalue)->orderBy($orderBy, $order); $heading = 'All Church Service Plans for '; } else { $plans = Plan::with('type')->whereDate('date', '>', Carbon::yesterday())->where('leader_id', $filtervalue)->orWhere('teacher_id', $filtervalue)->whereDate('date', '>', Carbon::yesterday())->orderBy($orderBy, $order); $heading = 'Upcoming Church Service Plans for '; } $heading .= User::find($filtervalue)->first_name; } elseif ($filterby == 'type') { if ($show == 'all') { $plans = Plan::with('type')->where('type_id', $filtervalue)->orderBy($orderBy, $order); $heading = 'Show All '; } else { $plans = Plan::with('type')->whereDate('date', '>', Carbon::yesterday())->where('type_id', $filtervalue)->orderBy($orderBy, $order); $heading = 'Show Upcoming '; } $heading .= Type::find($filtervalue)->name . 's'; } elseif ($filterby == 'future') { // get ALL future plans incl today $plans = Plan::with(['type', 'leader', 'teacher'])->whereDate('date', '>', Carbon::yesterday())->orderBy($orderBy, $order); // for an API call, return the raw data in json format (without pagination!) if (isset($request->api)) { return json_encode($plans->get()); } $heading = 'Upcoming Services or Events'; // get list of plans of which the current user is member $userIsPlanMember = listOfPlansForUser(); } elseif ($filterby == 'date') { // list only plans of a certain date $plans = Plan::with(['type', 'leader', 'teacher'])->whereDate('date', 'like', '%' . $filtervalue . '%')->orderBy($orderBy, $order); $heading = 'Events for ' . Carbon::parse($filtervalue)->formatLocalized('%A, %d %B %Y'); } else { // show only the user's own plans if ($show == 'all') { // past and future plans $plans = Plan::where('leader_id', Auth::user()->id)->orWhere('teacher_id', Auth::user()->id)->with('type')->orderBy($orderBy, $order); $heading = 'All Your Services/Events'; } else { // only future plans $plans = Plan::with('type')->whereDate('date', '>', Carbon::yesterday())->where(function ($query) { $query->where('leader_id', Auth::user()->id)->orWhere('teacher_id', Auth::user()->id); })->orderBy($orderBy, $order); $heading = 'Your Upcoming Services/Events'; } } // for pagination, always append the original query string $plans = $plans->paginate(20)->appends($querystringArray); return view($this->view_all, array('plans' => $plans, 'heading' => $heading, 'userIsPlanMember' => $userIsPlanMember)); }