private function guardarItems($idFactura)
 {
     try {
         if (Session::has('carrito')) {
             $carrito = Session::get('carrito');
             if (empty($carrito)) {
                 $filasAfectadas = FacturaItem::where('factura_id', '=', $idFactura)->delete();
                 return false;
             }
             foreach ($carrito as $item) {
                 $fi = new FacturaItem();
                 $fi->factura_id = $idFactura;
                 $fi->articulo_id = $item['articulo']->id;
                 $fi->cantidad = $item['cantidad'];
                 $fi->precio = $item['articulo']->precio;
                 $fi->iva = $item['articulo']->iva;
                 $fi->save();
             }
             return true;
         }
     } catch (Exception $e) {
         $filasAfectadas = FacturaItem::where('factura_id', '=', $idFactura)->delete();
         return false;
     }
 }
Exemple #2
0
 public function getMyPurchase($id)
 {
     $title = "Factura";
     $fac = Facturas::find($id);
     $user = User::find($fac->user_id);
     $aux = FacturaItem::where('factura_id', '=', $id)->get(array('item_id', 'item_qty'));
     $i = 0;
     foreach ($aux as $a) {
         $b = Items::find($a->item_id);
         $b->qty = $a->item_qty;
         $aux = Misc::where('item_id', '=', $a->item_id)->where('deleted', '=', 0)->first();
         $b->img = Images::where('misc_id', '=', $aux->id)->where('deleted', '=', 0)->first();
         $item[$i] = $b;
         $i++;
     }
     return View::make('user.factura')->with('fact', $item)->with('title', $title)->with('user', $user)->with('factura', $fac);
 }
Exemple #3
0
 public function getProcesePurchase($id)
 {
     $title = "Metodo de pago | Nia Boutique.com";
     $fac = Facturas::find($id);
     $x = FacturaItem::where('factura_id', '=', $id)->sum('item_qty');
     $aux = FacturaItem::where('factura_id', '=', $id)->get(array('item_id', 'item_qty', 'item_talla', 'item_color', 'item_precio'));
     $i = 0;
     $auxT = 0;
     $auxQ = 0;
     $p = '';
     foreach ($aux as $a) {
         $b = Items::where('item.id', '=', $a->item_id)->first();
         $p = $p . $b->item_nomb . ', ';
         $b->qty = $a->item_qty;
         $b->precio = $a->item_precio;
         $b->item_talla = Tallas::where('id', '=', $a->item_talla)->pluck('talla_desc');
         $b->item_color = Colores::where('id', '=', $a->item_color)->pluck('color_desc');
         $auxT = $auxT + $b->qty * $b->item_precio;
         $auxQ = $auxQ + $b->qty;
         $aux = Misc::where('item_id', '=', $a->item_id)->where('deleted', '=', 0)->first();
         $b->img = Images::where('misc_id', '=', $aux->id)->where('deleted', '=', 0)->first();
         $item[$i] = $b;
         $i++;
     }
     $total = 0;
     $method = 'hola';
     $bancos = Bancos::where('deleted', '=', 0)->get();
     return View::make('indexs.showCart')->with('title', $title)->with('method', $method)->with('total', $total)->with('items', $item)->with('id', $id)->with('bancos', $bancos);
 }
Exemple #4
0
 public function postPaymentElim()
 {
     $id = Input::get('id');
     $motivo = Input::get('motivo');
     $fac = Facturas::find($id);
     $fi = FacturaItem::where('factura_id', '=', $fac->id)->get();
     foreach ($fi as $f) {
         $item = Misc::where('item_id', '=', $f->item_id)->where('item_talla', '=', $f->item_talla)->where('item_color', '=', $f->item_color)->first();
         $item->item_stock = $item->item_stock + $f->item_qty;
         $item->save();
     }
     $fac->deleted = 1;
     $fac->save();
     $user = User::find($fac->user_id);
     if ($fac->save()) {
         $data = array('username' => Auth::user()->username, 'fac' => $id, 'fecha' => date('d-m-Y', time()), 'motivo' => $motivo);
         Mail::send('emails.reject', $data, function ($message) use($id, $motivo, $user) {
             $message->subject('Correo de aviso niaboutique.com');
             $message->to($user->email);
         });
         return Response::json(array('type' => 'success', 'msg' => 'Pago eliminado correctamente.'));
     } else {
         return Response::json(array('type' => 'danger', 'msg' => 'Error al eliminar el pago.'));
     }
 }