Пример #1
0
 public function postAdd()
 {
     $rules = ['firstname' => 'required|min:2', 'lastname' => 'required|min:2', 'address' => 'required|min:5', 'phone' => 'required|min:7'];
     if (!Auth::check()) {
         array_push($rules, ['email' => 'required|email|unique:users']);
     }
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::to("checkout")->withErrors($validator)->withInput(Input::except(''));
     } else {
         if (Auth::check()) {
             $user = User::find(Auth::user()->id);
         } else {
             $user = new User();
             $user->email = Input::get('email');
             $password = str_random(10);
             $user->password = Hash::make($password);
         }
         $user->firstname = Input::get('firstname');
         $user->lastname = Input::get('lastname');
         $user->address = Input::get('address');
         $user->phone = Input::get('phone');
         if ($user->save()) {
             $role = Role::where('name', '=', 'Customer')->first();
             if (!$user->hasRole("Customer")) {
                 $user->roles()->attach($role->id);
             }
             $order = new Order();
             $order->user_id = $user->id;
             $order->status_id = OrderStatus::where('title', '=', 'Новый')->first()->id;
             $order->comment = 'Телефон: <b>' . $user->phone . '</b><br>Адрес: <b>' . $user->address . '</b><br>Комментарий покупателя: ' . '<i>' . Input::get('comment') . '</i>';
             if ($order->save()) {
                 $cart = Cart::content();
                 foreach ($cart as $product) {
                     $orderDetails = new OrderDetails();
                     $orderDetails->order_id = $order->id;
                     $orderDetails->product_id = $product->id;
                     $orderDetails->quantity = $product->qty;
                     $orderDetails->price = $product->price;
                     $orderDetails->save();
                 }
             }
             if (!Auth::check()) {
                 Mail::send('mail.registration', ['firstname' => $user->firstname, 'login' => $user->email, 'password' => $password, 'setting' => Config::get('setting')], function ($message) {
                     $message->to(Input::get('email'))->subject("Регистрация прошла успешно");
                 });
             }
             $orderId = $order->id;
             Mail::send('mail.order', ['cart' => $cart, 'order' => $order, 'phone' => $user->phone, 'user' => $user->firstname . ' ' . $user->lastname], function ($message) use($orderId) {
                 $message->to(Input::get('email'))->subject("Ваша заявка №{$orderId} принята");
             });
             Cart::destroy();
             return Redirect::to("checkout/thanks/spasibo-vash-zakaz-prinyat")->with('successcart', 'ok', ['cart' => $cart]);
         }
     }
 }
 public function success()
 {
     $result = Session::get('result');
     setlocale(LC_MONETARY, "en_US");
     $user = Auth::user();
     $fee = Cart::total() / getenv("SV_FEE") - Cart::total();
     $total = $fee + Cart::total();
     $param = array('report_type' => 'customer_vault', 'customer_vault_id' => $user->customer_id);
     $payment = new Payment();
     $vault = $payment->ask($param);
     $items = Cart::contents();
     // Clean the cart
     Cart::destroy();
     return View::make('pages.public.success')->with('page_title', 'Payment Complete')->withUser($user)->with('products', $items)->with('result', $result)->with('vault', $vault);
 }
 public function getReservation()
 {
     Cart::destroy();
     $role = Auth::user()->role;
     if ($role == 'hotel-admin') {
         $company_id_logged_user = Auth::user()->comp_id;
         DB::setFetchMode(PDO::FETCH_ASSOC);
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.company_id', '=', $company_id_logged_user)->where('hotel_rooms.status', '=', 'available')->get();
         //            dd($data_room_details);
     } elseif ($role == 'hotel-staff') {
         $staff_id = Auth::user()->id;
         DB::setFetchMode(PDO::FETCH_ASSOC);
         $owned_branch_code = DB::table('staff')->select('staff.branch')->where('person_id', '=', $staff_id)->first();
         $data_room_details = DB::table('hotel_rooms')->join('branch', 'hotel_rooms.branch_code', '=', 'branch.branch_code')->select('hotel_rooms.room_code', 'hotel_rooms.branch_code', 'hotel_rooms.price_per_night', 'hotel_rooms.description', 'hotel_rooms.status', 'hotel_rooms.image', 'branch.branch_name', 'branch.address', 'branch.email', 'branch.city')->where('branch.branch_code', '=', $owned_branch_code)->where('hotel_rooms.status', '=', 'available')->get();
         // dd($data_room_details);
     }
     return View::make('reservations.available-bookings', array('data' => $data_room_details));
 }
Пример #4
0
 function checkout()
 {
     // process cart items
     if (count(Cart::contents()) < 1) {
         return Redirect::to('order');
     }
     $items = Cart::contents();
     $invoice_id = DB::table('invoices')->insertGetId(array('user_id' => Auth::user()->id, 'due_date' => date('Y-m-d'), 'status' => 'Unpaid'));
     foreach ($items as $item) {
         // to ensure the shopping cart was not manipulated, we use the option directly, not from the price
         $option = ServiceOption::find($item->id);
         // build description string
         $description = $option->service->name . ' ' . $option->name . ' recurring every ' . $item->quantity . ' month(s)';
         DB::table('invoice_items')->insert(array('invoice_id' => $invoice_id, 'description' => $description, 'unit_price' => $item->price));
     }
     // push invoice to e-mail queue
     // empty the cart
     Cart::destroy();
     return Redirect::to('order/thankyou');
 }
Пример #5
0
 public static function borrar()
 {
     $respuesta = array();
     $input = array();
     $reglas = array('id' => array('integer'));
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $respuesta['mensaje'] = $validator;
         $respuesta['error'] = true;
     } else {
         $carrito = Carrito::find(Session::get('carrito'));
         //$carrito->fecha_baja = date("Y-m-d H:i:s");
         $carrito->estado = 'B';
         //$archivo->usuario_id_baja = Auth::user()->id;
         $carrito->save();
         Cart::destroy();
         Session::forget('carrito');
         $respuesta['mensaje'] = 'Carrito eliminado.';
         $respuesta['error'] = false;
         $respuesta['data'] = $carrito;
     }
     return $respuesta;
 }
Пример #6
0
 public function process()
 {
     $factura = new Factura();
     $factura->usuario_id = Auth::user()->id;
     $factura->total = Cart::total();
     foreach (Cart::content() as $item) {
         if (Item::find($item['id'])->stock == 0) {
             Session::flash('error', 'El item ' . $item['name'] . ' se ha agotado');
             return Redirect::back();
         }
         if (Item::find($item['id'])->stock - $item['qty'] < 0) {
             Session::flash('error', 'No hay suficiente stock del item ' . $item['name'] . ' para cubrir su pedido');
             return Redirect::back();
         }
     }
     if ($factura->save()) {
         foreach (Cart::content() as $item) {
             $detalle = new Detalle();
             $detalle->factura_id = $factura->id;
             $detalle->item_id = $item['id'];
             $detalle->cantidad = $item['qty'];
             if ($detalle->save()) {
                 $deduct = Item::find($item['id']);
                 $deduct->stock -= $item['qty'];
                 $deduct->save();
             } else {
                 Session::flash('error', 'Error al procesar');
                 return Redirect::back();
             }
         }
     } else {
         Session::flash('error', 'Error al procesar');
         return Redirect::back();
     }
     Cart::destroy();
     return Redirect::to('shop');
 }
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $carts = Cart::content();
     if (Cart::count() < 1) {
         Session::flash('flash_error', 'You need add at least one product!');
     }
     $order = new Order();
     $order->user_id = Auth::user()->id;
     $order->date = date('Y-m-d h:i:s');
     $order->total = money_format('%.2n', Cart::total());
     $order->save();
     foreach ($carts as $row) {
         $product = Product::find($row->id)->firstOrFail();
         $orderDetail = new OrderDetail();
         $orderDetail->order_id = $order->id;
         $orderDetail->product_id = $product->code;
         $orderDetail->quantity = $row->qty;
         $orderDetail->sub_total = money_format('%.2n', $row->subtotal);
         $orderDetail->save();
         Cart::destroy();
     }
     Session::flash('message', 'Successfully created order!');
     return Redirect::to('orders');
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $startDate = Carbon::now();
     $from = Carbon::now()->hour(0)->minute(0)->second(0);
     $to = Carbon::now()->hour(23)->minute(59)->second(59);
     $schedules = SchedulePayment::where('status', 0)->whereBetween('date', array($from, $to))->with('member.user.profile')->get();
     //$schedules = SchedulePayment::where('status', 0)->with('member.user.profile')->get();
     $errors = array();
     $totalAmount = array();
     $errorAmount = array();
     //save daylog
     $dayLog = new ScheduleDailyLog();
     $dayLog->started_on = Carbon::now()->toDateTimeString();
     $dayLog->payments_count = count($schedules);
     $dayLog->save();
     Cart::destroy();
     foreach ($schedules as $schedule) {
         try {
             $vault = $schedule->member->user->profile->customer_vault;
             $user = User::find($schedule->member->user->id);
             $player = Player::find($schedule->member->player->id);
             $club = Club::find($schedule->club_id);
             $team = Team::find($schedule->member->team_id);
             $uuid = Uuid::generate();
             $member = Member::find($schedule->member->id);
             $history = SchedulePayment::find($schedule->id);
             //manually login user out before login new user
             Auth::logout();
             //manually login user
             Auth::login($user);
             //clear cart content
             Cart::destroy();
             //set cart item
             $itemCart = array('id' => $team->id, 'name' => "Scheduled payment for " . $team->name, 'price' => $schedule->subtotal, 'quantity' => 1, 'organization' => $club->name, 'organization_id' => $club->id, 'player_id' => $player->id, 'user_id' => $user->id, 'type' => 'full', 'autopay' => true);
             Cart::insert($itemCart);
             //check if vault exist
             if ($vault) {
                 $param = array('customer_vault_id' => $vault, 'discount' => null, 'club' => $club->id);
                 $payment = new Payment();
                 $transaction = $payment->sale($param);
                 //temp json_decode(json_encode($array), FALSE);
                 //$transaction = json_decode(json_encode(array('response' => 1, 'total'=>$schedule->total, 'fee'=>$schedule->fee)), FALSE);
                 if ($transaction->response == 3 || $transaction->response == 2) {
                     $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $transaction->transactionid . ' : ' . $transaction->responsetext, 'error_amount' => $schedule->total, 'daily_log_id' => $dayLog->id);
                     array_push($errorAmount, number_format($schedule->total, 2));
                     //Email error
                     $emailerrorstatus = $payment->error($transaction, $club->id, $player->id);
                 } else {
                     array_push($totalAmount, number_format($transaction->total, 2));
                     $payment->id = $uuid;
                     $payment->customer = $vault;
                     $payment->transaction = $transaction->transactionid;
                     $payment->subtotal = $transaction->subtotal;
                     $payment->service_fee = $transaction->fee;
                     $payment->total = $transaction->total;
                     $payment->promo = $transaction->promo;
                     $payment->tax = $transaction->tax;
                     $payment->discount = $transaction->discount;
                     $payment->club_id = $club->id;
                     $payment->user_id = $user->id;
                     $payment->player_id = $player->id;
                     $payment->event_type = null;
                     $payment->type = $transaction->type;
                     $payment->save();
                     //Email receipt
                     $payment->receipt($transaction, $club->id, $player->id);
                     $sale = new Item();
                     $sale->description = $itemCart['name'];
                     $sale->quantity = $itemCart['quantity'];
                     $sale->price = $itemCart['price'];
                     $sale->fee = $transaction->fee;
                     $sale->member_id = $member->id;
                     $sale->team_id = $team->id;
                     $sale->payment_id = $uuid;
                     $sale->save();
                     //update schedule
                     $history->status = 2;
                     $history->save();
                 }
             } else {
                 //save error that vault didnt exist
                 $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => 'Customer Vault not found', 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
                 array_push($errorAmount, number_format($schedule->total, 2));
             }
         } catch (Exception $e) {
             //save internal error
             $errors[] = array('payment_schedule_id' => $schedule->id, 'error_description' => $e, 'error_amount' => number_format($schedule->total, 2), 'daily_log_id' => $dayLog->id);
             array_push($errorAmount, number_format($schedule->total, 2));
         }
     }
     //end of foreach schedule
     //save log for everything done
     $dayLogEnd = ScheduleDailyLog::find($dayLog->id);
     $dayLogEnd->ended_on = Carbon::now()->toDateTimeString();
     $dayLogEnd->successful_count = Count($totalAmount);
     $dayLogEnd->error_count = Count($errors);
     $dayLogEnd->total_amount = array_sum($totalAmount);
     $dayLogEnd->total_amount_error = array_sum($errorAmount);
     $dayLogEnd->save();
     //save log for errors
     if (Count($errors) > 0) {
         foreach ($errors as $errorItem) {
             $scheduleError = new ScheduleDailyError();
             $scheduleError->error_description = $errorItem['error_description'];
             $scheduleError->error_amount = $errorItem['error_amount'];
             $scheduleError->payment_schedule_id = $errorItem['payment_schedule_id'];
             $scheduleError->daily_log_id = $dayLogEnd->id;
             $scheduleError->save();
         }
     }
     return Log::info($errors);
 }
 /**
  * Remove the specified cart from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id)
 {
     Cart::destroy($id);
     return Redirect::route('carts.index');
 }
 public function getSignOut()
 {
     Auth::logout();
     Cart::destroy();
     return Redirect::route('login-page');
 }
Пример #11
0
 public function postPurchaseAndNewDir()
 {
     if (Cart::count() < 1) {
         Session::flash('danger', 'Error, no posee articulos en el carrito');
         return Redirect::back();
     }
     $input = Input::all();
     $rules = array('email' => 'required|email', 'dir' => 'required');
     $msg = array('required' => 'Campo requerido', 'email' => 'El campo debe ser un email');
     $validator = Validator::make($input, $rules, $msg);
     if ($validator->fails()) {
         Redirect::back()->withError($validator)->withInput();
     }
     $dir = new Dir();
     $dir->user_id = Auth::user()->id;
     $dir->email = $input['email'];
     $dir->dir = $input['dir'];
     if ($dir->save()) {
         $fac = new Facturas();
         $fac->user_id = Auth::user()->id;
         $fac->dir = $dir->id;
         if ($fac->save()) {
             foreach (Cart::content() as $c) {
                 $misc = Misc::find($c->options['misc']);
                 $misc->item_stock = $misc->item_stock - $c->qty;
                 $misc->save();
                 $itemFac = new FacturaItem();
                 $itemFac->factura_id = $fac->id;
                 $itemFac->item_id = $c->id;
                 $itemFac->item_qty = $c->qty;
                 $itemFac->item_talla = $c->options['talla'];
                 $itemFac->item_color = $c->options['color'];
                 $itemFac->item_precio = $c->price;
                 $itemFac->save();
             }
             Cart::destroy();
             return Redirect::to('compra/procesar/' . $fac->id);
         }
     }
 }
 public function agregarPedido()
 {
     $input = Input::all();
     Input::flashOnly('nombre', 'email', 'empresa', 'telefono', 'consulta');
     $reglas = array('email' => array('required', 'email'), 'nombre' => array('required'), 'telefono' => array('required'));
     $validator = Validator::make($input, $reglas);
     if ($validator->fails()) {
         $messages = $validator->messages();
         if ($messages->has('nombre')) {
             $mensaje = $messages->first('nombre');
         } elseif ($messages->has('email')) {
             $mensaje = $messages->first('email');
         } elseif ($messages->has('telefono')) {
             $mensaje = $messages->first('telefono');
         } else {
             $mensaje = Lang::get('controllers.pedido.datos_consulta_contacto_incorrectos');
         }
         return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput();
     } else {
         $productos = array();
         if (Session::has('carrito')) {
             $carrito_id = Session::get('carrito');
             $carrito = Carrito::find($carrito_id);
             $datos = DB::table('carrito_producto')->where('carrito_id', $carrito->id)->where('estado', 'A')->get();
             foreach ($datos as $prod) {
                 $data = array('id' => $prod->producto_id, 'cantidad' => $prod->cantidad, 'precio' => $prod->precio);
                 array_push($productos, $data);
             }
         }
         if (count($productos) == 0) {
             $mensaje = Lang::get('controllers.pedido.debe_tener_producto');
             return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true)->withInput();
         } else {
             //Levanto los datos del formulario del presupuesto para
             //generar la persona correspondiente al pedido
             $datos_persona = array('email' => Input::get('email'), 'apellido' => Input::get('nombre'), 'nombre' => Input::get('empresa'), 'tipo_telefono_id' => 2, 'telefono' => Input::get('telefono'));
             $persona = Persona::agregar($datos_persona);
             if ($persona['error']) {
                 $mensaje = Lang::get('controllers.pedido.error_realizar_pedido');
                 return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true);
             } else {
                 $datos_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos);
                 $respuesta = Pedido::agregar($datos_pedido);
                 if ($respuesta['error']) {
                     return Redirect::to('/carrito')->with('mensaje', $respuesta['mensaje'])->with('error', true);
                 } else {
                     $datos_resumen_pedido = array('persona_id' => $persona['data']->id, 'productos' => $productos, 'email' => Input::get('email'), 'nombre' => Input::get('nombre'), 'telefono' => Input::get('telefono'), 'empresa' => Input::get('empresa'), 'consulta' => Input::get('consulta'));
                     $envio_mail = $this->resumenPedido($datos_resumen_pedido);
                     if ($envio_mail) {
                         Cart::destroy();
                         Session::forget('carrito');
                         $mensaje = Lang::get('controllers.pedido.presupuesto_enviado');
                         return Redirect::to('/')->with('mensaje', $mensaje)->with('ok', true);
                     } else {
                         $mensaje = Lang::get('controllers.pedido.presupuesto_no_enviado');
                         return Redirect::to('/carrito')->with('mensaje', $mensaje)->with('error', true);
                     }
                 }
             }
         }
     }
 }
 public function saveGaji()
 {
     $cart = Cart::content();
     foreach ($cart as $row) {
         $mg02 = new mg02();
         $mg02->mk01_id = $row->options['idkaryawan'];
         $mg02->mg01_id = $row->name;
         $mg02->nilgj = $row->price;
         $mg02->save();
     }
     Cart::destroy();
     return Redirect::to("master/karyawan");
 }
 public function paymentRemoveCartItem($id)
 {
     Cart::destroy();
     return Redirect::action('PlayerController@index');
 }
Пример #15
0
 /**
  * Perform user logout.
  */
 public function logout()
 {
     Cart::destroy();
     Auth::logout();
     return Redirect::to('');
 }
 public function emptyCart()
 {
     Cart::destroy();
     return Redirect::route('products.index')->with('message', 'Shopping cart emptied.');
 }
Пример #17
0
 public function postPaymentsuccess()
 {
     $order_info = (array) json_decode($_COOKIE['orderdetails']);
     $order_id = $order_info['txnid'];
     $product_id = implode(',', $order_info['product_id']);
     $product_quantity = implode(',', $order_info['product_quantity']);
     $product_vendor_id = implode(',', $order_info['product_vendor_id']);
     $shipping_det = (array) $order_info['shipping'];
     $billing_det = (array) $order_info['billing'];
     if (isset($order_info['addon_vendor_id'])) {
         $add_on_id = implode(',', $order_info['addon_id']);
     }
     // Saving to order table
     $order = new Order();
     $order->order_id = $order_id;
     $order->user_id = $order_info['user_id'];
     $order->product_id = $product_id;
     if (isset($add_on_id)) {
         $order->add_on_id = $add_on_id;
     }
     $order->vendor_id = $order_info['udf2'] == 'cake' ? User::cakegetid($product_vendor_id) : $product_vendor_id;
     $order->name = $shipping_det['first_name'] . " " . $shipping_det['last_name'];
     $order->contact = $shipping_det['mobile'];
     $order->shipping_address = $shipping_det['address'] . " " . $shipping_det['address2'];
     $order->shipping_city = $shipping_det['scity'];
     $order->shipping_zip = $shipping_det['zip_code'];
     $order->shipping_state = $shipping_det['state'];
     $order->price = $order_info['subtotal'];
     $order->disc_code = $order_info['coupon'];
     $order->status = 'neworder';
     $order->type = $order_info['udf2'];
     $order->user_message = $order_info['personalmessage'];
     $order->delivery_date = $order_info['delivery_date'];
     $order->payment_clearance = 'uncleared';
     $order->quantity = $product_quantity;
     // Saving to order master table
     $ordermaster = new Ordermaster();
     $ordermaster->order_id = $order_id;
     $ordermaster->transaction_id = 0;
     $ordermaster->payment_method = 'others';
     $ordermaster->name = $shipping_det['first_name'] . " " . $shipping_det['last_name'];
     $ordermaster->contact = $shipping_det['mobile'];
     $ordermaster->billing_address = $billing_det['address'] . " " . $billing_det['address2'];
     $ordermaster->billing_city = $billing_det['bcity'];
     $ordermaster->billing_zip = $billing_det['zip_code'];
     $ordermaster->billing_state = $billing_det['state'];
     $ordermaster->bill_value = $order_info['subtotal'];
     $ordermaster->status = 'uncleared';
     $ordermaster->email = $billing_det['email'];
     $ordermaster->process = 'new';
     //  Saving order details
     if ($order->save() && $ordermaster->save()) {
         // Set for Rating
         $det = Cart::contents();
         $vendor_id = $order_info['udf2'] == 'cake' ? User::cakegetid($product_vendor_id) : $product_vendor_id;
         if (Auth::check()) {
             $user_id = Auth::user()->id;
         } else {
             $user_id = uniqid();
         }
         $ordrid = $order_info['txnid'];
         foreach ($det as $item) {
             $vendor_id = $item->vendor_id;
         }
         if ($vendor_id != "") {
             setcookie("ratevendor[vendor_id]", $vendor_id, time() + 60 * 60 * 24 * 30, '/');
             setcookie("ratevendor[user_id]", $user_id, time() + 60 * 60 * 24 * 30, '/');
             setcookie("ratevendor[ordrid]", $ordrid, time() + 60 * 60 * 24 * 30, '/');
         }
         // Set for Rating
         $products = Cart::contents();
         $total = Cart::total();
         Cart::destroy();
         $billing_det = (array) $order_info['billing'];
         // Notify user for successfull payment
         Mail::send('emails.orderconfirm', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($order_info, $billing_det) {
             $message->from('*****@*****.**', 'Funfest');
             $message->subject('RE: Order successful, Funfest order no. ' . $order_info['txnid']);
             $message->to($billing_det['email']);
         });
         $vendor_email = User::getemail($vendor_id);
         $vendor_email = "*****@*****.**";
         if ($vendor_email != "") {
             Mail::send('emails.vendornotify', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($order_info, $billing_det, $vendor_email) {
                 $message->from('*****@*****.**', 'Funfest');
                 $message->subject('RE: Order successful, Funfest order no. ' . $order_info['txnid']);
                 $message->to($vendor_email);
                 //->cc('*****@*****.**');
             });
         } else {
             Mail::send('emails.vendornotify', array('details_for_order' => $order_info, 'products' => $products, 'total' => $total), function ($message) use($billing_det) {
                 $message->from('*****@*****.**', 'Funfest');
                 $message->subject('RE: Order for cake (vendor email was null).');
                 $message->to('*****@*****.**');
             });
         }
         // Send messgae to user
         $username = "******";
         $password = "******";
         $url = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=91" . $order_info['phone'] . "&sid=WebSms&msg=Your order has been placed successfully. Your order id is " . $order_info['txnid'] . "&fl=1";
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
         $response = curl_exec($ch);
         // Send messgae to vendor
         $vendor_rmn = User::getrmn($product_vendor_id);
         if ($vendor_rmn != "") {
             $username = "******";
             $password = "******";
             $url = "http://smslane.com/vendorsms/pushsms.aspx?user="******"&password="******"&msisdn=91" . $vendor_rmn . "&sid=WebSms&msg=You received a new order, order id " . $order_info['txnid'] . ". Please login to the website to get the details.&fl=1";
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
             $response = curl_exec($ch);
         }
         Ordermaster::where('order_id', '=', $_POST['txnid'])->update(array('transaction_id' => $_POST['mihpayid'], 'bank_transaction_id' => $_POST['bank_ref_num'], 'status' => 'cleared', 'process' => 'initiate'));
         Order::where('order_id', '=', $_POST['txnid'])->update(array('status' => 'neworder', 'process' => 'initiate', 'payment_clearance' => 'cleared'));
         return View::make('/home/thankyou')->with('purchase_data', $_POST)->with('message', "The transaction was successful, your order is on it's way.");
     }
 }
Пример #18
0
 public function checkoutStore()
 {
     // dd(Input::all());
     $user = User::find(Auth::user()->id);
     $cart = Cart::content();
     $rules = ['alamat' => 'required', 'pembayaran' => 'required', 'total' => 'required'];
     Validator::make($data = Input::all(), $rules);
     $data['user_id'] = $user->id;
     $data['telp'] = $user->telp;
     $data['email'] = $user->email;
     $order = Order::create($data);
     if (!$order) {
         return Redirect::back()->with('message', 'gagal menambahkan order ke database');
     }
     $dataItems = [];
     foreach ($cart as $c) {
         $dataItems['order_id'] = $order->id;
         $dataItems['barang_id'] = $c->id;
         $dataItems['qty'] = $c->qty;
         $dataItems['price'] = $c->price;
         $dataItems['total'] = $c->price * $c->qty;
         $dataItems['berat'] = $c->options->berat * $c->qty;
         $dataItems['keterangan'] = $c->options->aroma;
         $orderItems = OrderItem::create($dataItems);
         if (!$orderItems) {
             return Redirect::back()->with('message', 'gagal menambahkan order item ke database');
         }
     }
     Cart::destroy();
     return Redirect::to('store')->with('message', 'Terima kasih, order anda berhasil masuk, silahkan tunggu untuk konfirmasi dari kami');
 }
 private function persistCart(Order $order)
 {
     if (OrdersController::checkAdminOrOrderUser($order) && Cart::totalItems() > 0) {
         $orderItemBatch = array();
         foreach (Cart::contents() as $item) {
             $orderItem = array();
             $orderItem['order_id'] = $order->id;
             $orderItem['product_id'] = $item->id;
             $orderItem['qty'] = $item->quantity;
             if ($item->prod_type === 'MP3') {
                 $orderItem['mp3_ind'] = TRUE;
             }
             //$orderItemBatch[] = new OrderItem($orderItem);
             $oi = new OrderItem($orderItem);
             Log::debug('persistCart() - order item *BEFORE* save: ' . print_r($oi, TRUE));
             $oi->save();
             Log::debug('persistCart() - order item after save: ' . print_r($oi, TRUE));
             Log::debug('persistCart - Order->id = ' . $order->id . '  OrderItem->id = ' . $oi->id);
         }
         // Empty cart
         Cart::destroy();
     }
     return TRUE;
 }
Пример #20
0
 /**
  * Log the user out of the application.
  *
  * @return  Illuminate\Http\Response
  */
 public function logout()
 {
     Confide::logout();
     Cart::destroy();
     return Redirect::to('store');
 }
Пример #21
0
 function createOrder()
 {
     $user_id = 0;
     if (Auth::user()->check()) {
         $user_id = Auth::user()->get()->id;
     }
     //Add billing address
     $billing_address = array();
     if (Session::has('billing_address')) {
         $billing_address = Session::get('billing_address');
         $billing_address['user_id'] = $user_id;
         $billing_address['country_name'] = Address::countryName($billing_address['country_a2']);
         if (!empty($billing_address['state_a2'])) {
             $billing_address['state_name'] = Address::stateName($billing_address['state_a2'], $billing_address['country_a2']);
         }
         $billing_address['is_billing'] = 1;
         $obj_billing_address = $this->createAddress($billing_address);
     }
     //add shipping address
     $shipping_address = array();
     if (Session::has('shipping_address')) {
         $shipping_address = Session::get('shipping_address');
         $shipping_address['user_id'] = $user_id;
         $shipping_address['country_name'] = Address::countryName($shipping_address['country_a2']);
         if (!empty($shipping_address['state_a2'])) {
             $shipping_address['state_name'] = Address::stateName($shipping_address['state_a2'], $shipping_address['country_a2']);
         }
         $shipping_address['is_billing'] = 0;
         $obj_shipping_address = $this->createAddress($shipping_address);
     }
     if (isset($obj_billing_address) && isset($obj_shipping_address)) {
         //Add to order table
         $cart_total = Cart::total();
         $order = Order::create(["user_id" => $user_id, "sum_amount" => $cart_total, "billing_address_id" => $obj_billing_address->id, "shipping_address_id" => $obj_shipping_address->id, "status" => "New"]);
         //Add to order_details
         if ($order) {
             $cart_content = Cart::content();
             foreach ($cart_content as $item) {
                 $options = [];
                 foreach ($item->options->options as $option) {
                     $options[] = $option['key'];
                 }
                 $option_keys = implode(",", $options);
                 $orderDetail = OrderDetail::create(["order_id" => $order->id, "image_id" => $item->id, "quantity" => $item->qty, "sell_price" => $item->price, "sum_amount" => $item->subtotal, "type" => $item->options->order_type, "size" => $item->options->size, "option" => $option_keys]);
             }
             //Clear session
             Cart::destroy();
             Session::forget('billing_address');
             Session::forget('shipping_address');
             return $order;
         }
     }
     return false;
 }
 function dobuy()
 {
     self::is_login();
     if (!$_POST) {
         exit;
     }
     if (!is_array($_POST['id'])) {
         $this->error('您的购物为空!');
         exit;
     }
     if ($_POST['realname'] == '' || $_POST['tel'] == '') {
         $this->error('收货人信息为空!');
         exit;
     }
     $trade_type = (int) $_POST['trade_type'];
     $iscart = (int) $_POST['iscart'];
     $group_trade_no = "GB" . time() . "-" . $_SESSION['dami_uid'];
     if ($iscart == 1) {
         import('ORG.Util.Cart');
         $cart = new Cart();
         $cart->destroy();
     }
     $_POST = array_map('remove_xss', $_POST);
     $trade = M('member_trade');
     if (C('TOKEN_ON') && !$trade->autoCheckToken($_POST)) {
         $this->error(L('_TOKEN_ERROR_'));
     }
     //防止乱提交表单
     //循环出购物车 写进数据库
     if ($trade_type == 1) {
         $title = '';
         $subject = '';
         $total_fee = 0;
         $total_num = 0;
         for ($i = 0; $i < count($_POST['id']); $i++) {
             if (!is_numeric($_POST['id'][$i]) || !is_numeric($_POST['price'][$i]) || !is_numeric($_POST['qty'][$i])) {
                 continue;
             }
             $data['gid'] = $_POST['id'][$i];
             $data['uid'] = $_SESSION['dami_uid'];
             $data['price'] = (double) M('article')->where('aid=' . $data['gid'])->getField('price');
             //必须,信任客户端表单可以改写哈$_POST['price'][$i]
             $data['province'] = $_POST['province'];
             $data['city'] = $_POST['city'];
             $data['area'] = $_POST['area'];
             $data['sh_name'] = $_POST['realname'];
             $data['sh_tel'] = $_POST['tel'];
             $data['address'] = $_POST['address'];
             $data['group_trade_no'] = $group_trade_no;
             $data['out_trade_no'] = "DB" . time() . "-" . $_SESSION['dami_uid'];
             $data['servial'] = $_POST['gtype'][$i];
             $data['status'] = 0;
             $data['trade_type'] = 1;
             $data['addtime'] = time();
             $data['num'] = (int) $_POST['qty'][$i];
             $total_fee += $data['num'] * $data['price'] * 1;
             $total_num += $data['num'];
             $trade->add($data);
             if (strlen($subject) < 200) {
                 $subject .= $_POST['name'][$i];
             }
             if (strlen($title) < 400) {
                 $title .= $_POST['name'][$i] . "&nbsp;&nbsp;数量:" . $data['num'] . ' 单价:' . $data['price'] . '<br>';
             }
         }
         if (intval(C('MAIL_TRADE')) == 1) {
             $config = F('basic', '', './Web/Conf/');
             $user_name = $config[sitetitle] . '管理员';
             $subject = $config[sitetitle] . '订单提醒';
             $bodyurl = '下单时间:' . date('Y-m-d H:i:s', time()) . '<br>会员编号:' . $_SESSION['dami_uid'] . '<br>姓名:' . $_POST['realname'] . '<br>订单号:' . $group_trade_no . '<br>付款方式:支付宝在线交易<br>订购物件:<br>' . $title . '<br>总数量:' . $total_num . '<br>总金额:' . $total_fee . '元';
             $sendto_email = C('MAIL_TOADMIN');
             $email_port = C('MAIL_PORT');
             send_mail($sendto_email, $user_name, $subject, $bodyurl, $email_port);
         }
         //构造支付宝表单并输出
         $t_path = intval(C('AP_TYPE')) == 1 ? 'ap_jishi' : 'ap_danbao';
         $url = "http://" . $_SERVER['HTTP_HOST'] . __ROOT__ . "/Trade/" . $t_path . "/alipayapi.php";
         $post_data = array("WIDtotal_fee" => $total_fee, "WIDsubject" => $subject, "WIDreceive_name" => $_POST['realname'], "WIDreceive_address" => $_POST['address'], "WIDreceive_mobile" => $_POST['tel'], "WIDreceive_phone" => "", "WIDout_trade_no" => $group_trade_no, "WIDshow_url" => "http://www.damicms.com/Public/donate", "WIDbody" => "", "WIDreceive_zip" => "", "WIDseller_email" => C("AP_EMAIL"));
         $ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
         $output = curl_exec($ch);
         curl_close($ch);
         echo $output;
     } else {
         if ($trade_type == 2) {
             //货到付款
             $title = '';
             $total_fee = 0;
             $total_num = 0;
             for ($i = 0; $i < count($_POST['id']); $i++) {
                 if (!is_numeric($_POST['id'][$i]) || !is_numeric($_POST['price'][$i]) || !is_numeric($_POST['qty'][$i])) {
                     continue;
                 }
                 $data['gid'] = $_POST['id'][$i];
                 $data['uid'] = $_SESSION['dami_uid'];
                 $data['price'] = (double) M('article')->where('aid=' . $data['gid'])->getField('price');
                 //必须
                 $data['province'] = $_POST['province'];
                 $data['city'] = $_POST['city'];
                 $data['area'] = $_POST['area'];
                 $data['sh_name'] = $_POST['realname'];
                 $data['sh_tel'] = $_POST['tel'];
                 $data['address'] = $_POST['address'];
                 $data['group_trade_no'] = $group_trade_no;
                 $data['out_trade_no'] = "DB" . time() . "-" . $_SESSION['dami_uid'];
                 $data['servial'] = $_POST['gtype'][$i];
                 $data['status'] = 11;
                 //等待付款,等待发货
                 $data['trade_type'] = 2;
                 $data['addtime'] = time();
                 $data['num'] = (int) $_POST['qty'][$i];
                 $total_fee += $data['num'] * $data['price'] * 1;
                 $total_num += $data['num'];
                 $trade->add($data);
                 if (strlen($title) < 400) {
                     $title .= $_POST['name'][$i] . "&nbsp;&nbsp;数量:" . $data['num'] . ' 单价:' . $data['price'] . '<br>';
                 }
             }
             if (intval(C('MAIL_TRADE')) == 1) {
                 $config = F('basic', '', './Web/Conf/');
                 $user_name = $config[sitetitle] . '管理员';
                 $subject = $config[sitetitle] . '订单提醒';
                 $bodyurl = '下单时间:' . date('Y-m-d H:i:s', time()) . '<br>会员编号:' . $_SESSION['dami_uid'] . '<br>姓名:' . $_POST['realname'] . '<br>订单号:' . $group_trade_no . '<br>付款方式:货到付款<br>订购物件:<br>' . $title . '<br>总数量:' . $total_num . '<br>总金额:' . $total_fee . '元';
                 $sendto_email = C('MAIL_TOADMIN');
                 $email_port = C('MAIL_PORT');
                 send_mail($sendto_email, $user_name, $subject, $bodyurl, $email_port);
             }
             $this->assign('group_trade_no', $group_trade_no);
             $this->display('buysuccess');
         } else {
             if ($trade_type == 3) {
                 $title = '';
                 $total_fee = 0;
                 $total_num = 0;
                 for ($i = 0; $i < count($_POST['id']); $i++) {
                     $price = (double) M('article')->where('aid=' . intval($_POST['id'][$i]))->getField('price');
                     if (!is_numeric($_POST['id'][$i]) || !is_numeric($_POST['price'][$i]) || !is_numeric($_POST['qty'][$i])) {
                         continue;
                     }
                     $total_fee += intval($_POST['qty'][$i]) * $price * 1;
                 }
                 $have_money = M('member')->where('id=' . $_SESSION['dami_uid'])->getField('money');
                 if ($have_money < $total_fee) {
                     $this->assign('jumpUrl', U('Member/chongzhi'));
                     $this->error('您的余额不足,请充值!');
                     exit;
                 }
                 for ($i = 0; $i < count($_POST['id']); $i++) {
                     if (!is_numeric($_POST['id'][$i]) || !is_numeric($_POST['price'][$i]) || !is_numeric($_POST['qty'][$i])) {
                         continue;
                     }
                     $data['gid'] = $_POST['id'][$i];
                     $data['uid'] = $_SESSION['dami_uid'];
                     $data['price'] = (double) M('article')->where('aid=' . $data['gid'])->getField('price');
                     //必须
                     $data['province'] = $_POST['province'];
                     $data['city'] = $_POST['city'];
                     $data['area'] = $_POST['area'];
                     $data['sh_name'] = $_POST['realname'];
                     $data['sh_tel'] = $_POST['tel'];
                     $data['address'] = $_POST['address'];
                     $data['group_trade_no'] = $group_trade_no;
                     $data['out_trade_no'] = "DB" . time() . "-" . $_SESSION['dami_uid'];
                     $data['servial'] = $_POST['gtype'][$i];
                     $data['status'] = 1;
                     //已付款等待发货
                     $data['trade_type'] = 3;
                     $data['addtime'] = time();
                     $data['num'] = (int) $_POST['qty'][$i];
                     $total_num += $data['num'];
                     $trade->add($data);
                     if (strlen($title) < 400) {
                         $title .= $_POST['name'][$i] . "&nbsp;&nbsp;数量:" . $data['num'] . ' 单价:' . $data['price'] . '<br>';
                     }
                 }
                 //扣款
                 M('member')->setDec('money', 'id=' . $_SESSION['dami_uid'], $total_fee);
                 if (intval(C('MAIL_TRADE')) == 1) {
                     $config = F('basic', '', './Web/Conf/');
                     $user_name = $config[sitetitle] . '管理员';
                     $subject = $config[sitetitle] . '订单提醒';
                     $bodyurl = '下单时间:' . date('Y-m-d H:i:s', time()) . '<br>会员编号:' . $_SESSION['dami_uid'] . '<br>姓名:' . $_POST['realname'] . '<br>订单号:' . $group_trade_no . '<br>付款方式:站内扣款<br>订购物件:<br>' . $title . '<br>总数量:' . $total_num . '<br>总金额:' . $total_fee . '元';
                     $sendto_email = C('MAIL_TOADMIN');
                     $email_port = C('MAIL_PORT');
                     send_mail($sendto_email, $user_name, $subject, $bodyurl, $email_port);
                 }
                 $this->assign('group_trade_no', $group_trade_no);
                 $this->display('buysuccess');
             } else {
                 $this->error('交易方式不确定!');
                 exit;
             }
         }
     }
 }
Пример #23
0
 public function getRemoveitem()
 {
     Cart::destroy();
     return Redirect::to('store/cart');
 }
Пример #24
0
    $cartContentArr = [];
    foreach ($cartContentObj as $item) {
        $item->thumbnail = $item->ware->thumbnail;
        $item->options['slug'] = 'sdfsd';
        $cartContentArr[] = $item;
    }
    return $cartContentArr;
});
Route::get('get-data', function () {
    $html = new Htmldom('http://dmtoys.com.ua/catalog/igrushki/interaktivnye-igrushki/angry-birds');
    foreach ($html->find('#primary-menu-inner a') as $item) {
        echo $item->href . '<br>';
    }
});
Route::get('cart-destroy', function () {
    Cart::destroy();
});
Route::get('cart', 'HomeController@cart');
Route::get('adm', 'AdminController@index');
Route::post('adm/categories', 'CategoriesController@store');
Route::get('adm/categories', 'CategoriesController@adminIndex');
Route::get('adm/categories/create', 'CategoriesController@create');
Route::get('adm/categories/{id}', 'CategoriesController@edit');
Route::put('adm/categories/{id}', 'CategoriesController@update');
Route::get('adm/categories/{id}/destroy', 'CategoriesController@destroy');
Route::get('adm/wares', 'WaresController@adminIndex');
Route::post('adm/wares', 'WaresController@store');
Route::get('adm/wares/create', 'WaresController@create');
Route::get('adm/wares/import', 'WaresController@waresImport');
Route::post('adm/wares/import', 'WaresController@waresImportStore');
Route::get('adm/wares/{id}', 'WaresController@edit');
 public function removeFromCart()
 {
     $item = Input::get('product');
     $customer_id = Session::get('cart_id');
     Cart::destroy($item);
     return Redirect::route('carts.index');
 }
Пример #26
0
 /**
  * Empties the shopping cart
  *
  * Note that $full=true will not log the User off; it just flushes the
  * static Customer object.  That's somewhat experimental.
  * @param   boolean   $full     If true, drops the entire Shop session
  *                              and the Customer
  * @static
  */
 static function destroyCart($full = null)
 {
     // Necessary, otherwise no successive orders are possible
     $_SESSION['shop']['order_id'] = $_SESSION['shop']['order_id_checkin'] = NULL;
     $_SESSION['shop']['coupon_code'] = NULL;
     // TEST ONLY, to not clear the cart: return;
     Cart::destroy();
     // In case you want to flush everything, including the Customer:
     if ($full) {
         unset($_SESSION['shop']);
         self::$objCustomer = null;
     }
 }
Пример #27
0
 public function cleanUp()
 {
     // Destroy cart
     \Cart::destroy();
     session()->forget('noShipping');
     session()->forget('coupon');
 }
Пример #28
0
 public function testCartCanDestroy()
 {
     Cart::add(1, 'test', 1, 10.0, array('size' => 'L'));
     Cart::destroy();
     $this->assertEquals(Cart::count(), 0);
     $this->assertInstanceOf('Gloudemans\\Shoppingcart\\CartCollection', Cart::content());
 }
 public function PaymentRemoveCartItemTeam($club, $id)
 {
     $club = Club::find($club);
     $team = Team::find($id);
     Cart::destroy();
     return Redirect::action('ClubPublicController@paymentSelectTeam', array($club->id, $team->id));
 }