public function storeSlave(Request $request) { $name = $request->input('data.name', null); if ($name != null) { $dominio = Domain::where('name', '=', $name)->first(); if ($dominio != null) { return response()->json(['error' => 'zoneSlave_exists'], 409); } $slave = new Domain(); $slave->name = $request->input('data.name'); $slave->master = $request->input('data.nameserver'); $slave->type = 'SLAVE'; $slave->save(); $id = $slave->id; $zones = new Zone(); $zones->domain_id = $id; $zones->owner = '1'; $zones->comment = ''; $zones->zone_templ_id = '0'; $zones->save(); return response()->json(['success' => 'zoneSlave_created'], 200); } else { return response()->json(['error' => 'zoneSlave_error'], 400); } }
public function destroy($id) { $domain = Domain::find($id); if ($domain = null) { return response()->json(['error' => 'domain_does_not_existe'], 400); } $domain_id = $id; $zones = Zone::where('domain_id', '=', $domain_id)->delete(); $records = Record::where('domain_id', '=', $domain_id)->delete(); $domain = Domain::where('id', '=', $id)->delete(); return response()->json(['success'], 200); }
public function storePayBooking(BookingRequest $request) { $reserve_id = $request->input('reserve_id'); $ticket = Ticket::where('reserve', $reserve_id)->get()->first(); if (empty($ticket)) { return redirect()->back()->withErrors(['error' => 'no hay reservas para el codigo especificado']); } $nTickets = $ticket->quantity; $ticket->payment_date = new Carbon(); $ticket->cancelled = false; $ticket->salesman_id = \Auth::user()->id; $ticket->picked_up = true; $ticket->updated_at = new Carbon(); $ticket->reserve = null; $id = $ticket->id; $ticket->save(); $tickets = array(); $user = Auth::user(); if ($request['promotion_id'] != "") { $promo = Promotions::find($request['promotion_id']); if ($promo->desc != null) { DB::table('tickets')->where('id', $id)->update(['discount' => $promo->desc]); DB::table('tickets')->where('id', $id)->decrement('total_price', $promo->desc / 100 * ($nTickets * $zone->price)); } else { $pu = Zone::find($ticket->zone_id)->price; $quantity = $ticket->quantity; $pt = $pu * $quantity; $discTickets = $quantity / $promo->carry; $discTickets = floor($discTickets); $pd = $pt - $discTickets * $pu; $desc = 100 - $pd / $pt * 100; DB::table('tickets')->where('id', $id)->update(['discount' => $desc]); DB::table('tickets')->where('id', $id)->update(['total_price' => $pd]); } DB::table('tickets')->where('id', $id)->update(['promo_id' => $promo->id]); } $price = $ticket->total_price; if ($request['payMode'] == config('constants.credit')) { DB::table('tickets')->where('id', $id)->update(['credit_amount' => $price]); } else { if ($request['payMode'] == config('constants.cash')) { DB::table('tickets')->where('id', $id)->update(['cash_amount' => $price]); if ($user->role_id == config('constants.salesman')) { DB::table('modules')->where('id', $user->module_id)->increment('actual_cash', $price); } } else { if ($request['payMode'] == config('constants.mix')) { DB::table('tickets')->where('id', $id)->update(['cash_amount' => $request['paymentMix']]); DB::table('tickets')->where('id', $id)->update(['credit_amount' => $price - $request['paymentMix']]); if ($user->role_id == config('constants.salesman')) { DB::table('modules')->where('id', $user->module_id)->increment('actual_cash', $request['paymentMix']); } } } } array_push($tickets, $ticket->id); DB::table('users')->where('id', $ticket->owner_id)->increment('points', $nTickets); DB::table('slot_presentation')->where('sale_id', $ticket->id)->update(['status' => config('constants.seat_taken')]); session(['tickets' => $id]); return redirect()->route('ticket.success.salesman'); }
public function getPromo(request $request) { $maxDiscount = 0; $bestPromo = null; if ($request['type_id'] == config('constants.credit')) { $promo_disc = Promotions::where('event_id', $request['event_id'])->where('access_id', 2)->where('startday', '<', Carbon::now())->where('endday', '>', Carbon::now())->get(); } else { if ($request['type_id'] == config('constants.cash')) { $promo_disc = Promotions::where('event_id', $request['event_id'])->where('access_id', 1)->where('startday', '<', Carbon::now())->where('endday', '>', Carbon::now())->get(); } else { $promos = null; return null; } } $promos = Promotions::where('event_id', $request['event_id'])->where('typePromotion', 2)->where('startday', '<', Carbon::now())->where('endday', '>', Carbon::now())->get(); $promos = $promos->merge($promo_disc); if ($promos) { foreach ($promos as $promo) { if ($promo->typePromotion == config('constants.discount')) { if ($promo->desc > $maxDiscount) { $pu = Zone::find($request['zone_id'])->price; $quantity = $request['quantity']; $pt = $pu * $quantity; $pd = $pt - $pt * $promo->desc / 100; $maxDiscount = $promo->desc; $bestPromo = ['id' => $promo->id, 'amount' => $pd]; } } else { if ($promo->zone_id == $request['zone_id']) { $pu = Zone::find($request['zone_id'])->price; $quantity = $request['quantity']; $pt = $pu * $quantity; $discTickets = $quantity / $promo->carry; $discTickets = floor($discTickets); $pd = $pt - $discTickets * $pu * ($promo->carry - $promo->pay); $desc = 100 - $pd / $pt * 100; if ($desc >= $maxDiscount) { $maxDiscount = $desc; $promo->desc = $desc; $bestPromo = ['id' => $promo->id, 'amount' => $pd]; } } } } } return $bestPromo; /* $maxDiscount = 0; $bestPromo = null; if($request['type_id']==config('constants.credit')){ $promo_disc = Promotions::where('event_id',$request['event_id'])->where('access_id',2)->where('startday','<',Carbon::now())->where('endday','>',Carbon::now())->get(); }else if($request['type_id']==config('constants.cash')){ $promo_disc = Promotions::where('event_id',$request['event_id'])->where('access_id',1)->where('startday','<',Carbon::now())->where('endday','>',Carbon::now())->get(); }else{ $promos = null; } $promos = Promotions::where('event_id',$request['event_id'])->where('typePromotion',2)->where('startday','<',Carbon::now())->where('endday','>',Carbon::now())->get(); $promos = $promos->merge($promo_disc); if($promos){ foreach ($promos as $promo) { if ($promo->typePromotion == config('constants.discount')){ if ($promo->desc > $maxDiscount){ $maxDiscount = $promo->desc; $bestPromo = $promo; } }else{ if($promo->zone_id == $request['zone_id']){ $pu = Zone::find($request['zone_id'])->price; $quantity = $request['quantity']; $pt = $pu * $quantity; $discTickets = $quantity / $promo->carry; $discTickets = floor($discTickets); $pd = $pt - $discTickets*$pu; $desc = 100 - ($pd/$pt)*100; if ($desc >= $maxDiscount){ $maxDiscount = $desc; $promo->desc = $desc; $bestPromo = $promo; } } } } } return $bestPromo; */ }
public function getZoneSeatsIds(Request $request) { $zona = Zone::find($request['zone_id']); $local = $zona->event->place; $arreglo = array(); $slots = $zona->slots; foreach ($slots as $slot) { $id = $slot->row . "_" . $slot->column; array_push($arreglo, $id); } return $arreglo; }
public function ajax($event_id) { $zones = Zone::where('event_id', $event_id)->lists('name', 'id'); return json_encode($zones); }