예제 #1
0
 public function postItemLoad()
 {
     if (Request::ajax()) {
         $id = Input::get('id');
         $art = Items::find($id);
         $a = new stdClass();
         $a->id = $art->id;
         $a->item_nomb = $art->item_nomb;
         $a->item_desc = $art->item_desc;
         $a->item_cod = $art->item_cod;
         $a->item_precio = $art->item_precio;
         $currency = " USD.";
         $a->tallas = array();
         $misc = Misc::where('item_id', '=', $art->id)->get();
         $aux2 = array();
         $aux3 = array();
         $i = 0;
         $j = 0;
         $k = 0;
         $images = array();
         foreach ($misc as $m) {
             $aux2[$j] = $m->item_talla;
             $auxMisc = new stdClass();
             $auxMisc->id = $m->id;
             $auxMisc->ta = $m->item_talla;
             $aux3[$j] = $auxMisc;
             $j++;
             $x = Images::where('misc_id', '=', $m->id)->where('deleted', '=', 0)->get(array('id', 'misc_id', 'image', 'order'));
             foreach ($x as $y) {
                 $aux = new stdClass();
                 $aux->id = $y->id;
                 $aux->misc_id = $y->misc_id;
                 $aux->image = $y->image;
                 $aux->order = $y->order;
                 $images[$k] = $aux;
                 $k++;
             }
         }
         for ($i = 0; $i < count($images); $i++) {
             for ($j = 0; $j < count($images) - 1; $j++) {
                 if ($images[$j]->order > $images[$j + 1]->order) {
                     $bub = new stdClass();
                     $bub = $images[$j + 1];
                     $images[$j + 1] = $images[$j];
                     $images[$j] = $bub;
                 }
             }
         }
         $t = Misc::where('item_id', '=', $art->id)->groupBy('item_talla')->get(array('id'));
         $a->tallas = $t;
         $a->misc = $aux3;
         return Response::json(array('item' => $a, 'princ' => $images[0]->image, 'images' => $images, 'tallas' => $aux2, 'currency' => $currency));
     }
 }
예제 #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);
 }
예제 #3
0
 public function updateOrderDetails($id)
 {
     $response = array();
     $output = array();
     try {
         $order = new Orders();
         if (!Input::has('items')) {
             /*
              * User id has not been included here as it's not reuqired here, opposed to the create order request where it's mandtatory..
              * There shd be a single class which handles all this.
              */
             $response['response_code'] = ResponseCodes::$response_code['missing_param']['code'];
             $response['response_message'] = ResponseCodes::$response_code['missing_param']['response_message'];
             echo json_encode($response);
             die;
         }
         /*
          * Only the order item will be updated here. This is bcoz we have api to update the order payment and status.
          * So nothign else is left in the order table to be updated.
          */
         /*
          * While updating the items we assume that we are getting a json encoded data for the list of item with item id. 
          * like this [{"name":"shirt","quantity":"1","item_id":123},{"name":"saree","quantity":"3","item_id":"125"}]
          * with the product name and the quanity.Each item added belongs to a specific type which has a fixed price whc are intrenally mapped 
          */
         $list_of_items = json_decode(Input::get('items'), true);
         foreach ($list_of_items as $key => $item_data) {
             if (isset($item_data['item_id']) && !empty($item_data['item_id'])) {
                 $item = Items::find($item_data['item_id']);
                 $item->name = $item_data['name'];
                 $item->quantity = $item_data['quantity'];
                 // assuming the item type is correct.
                 $item->price = Price::$price_mapping[$item_data['name']] * $item_data['quantity'];
                 $item->save();
             }
         }
         // $output['order_id'] = $order->id;
         $response['response_code'] = ResponseCodes::$response_code['success']['code'];
         $response['response_message'] = ResponseCodes::$response_code['success']['response_message'];
         $response['output'] = $output;
         echo json_encode($response);
     } catch (Exception $e) {
         Log::error($e->getMessage());
         $response['response_code'] = ResponseCodes::$response_code['internal_server_error']['code'];
         $response['response_message'] = ResponseCodes::$response_code['internal_server_error']['response_message'];
         $response['output'] = $output;
         echo json_encode($response);
     }
 }
예제 #4
0
 public function getNewImgPos($id)
 {
     $title = "Cambiar posición de las imagenes";
     $item = Items::find($id);
     $misc = Misc::where('item_id', '=', $item->id)->get(array('id'));
     $images = array();
     $j = 0;
     foreach ($misc as $m) {
         $x = Images::where('misc_id', '=', $m->id)->where('deleted', '=', 0)->get(array('id', 'misc_id', 'image', 'order'));
         foreach ($x as $y) {
             $aux = new stdClass();
             $aux->id = $y->id;
             $aux->misc_id = $y->misc_id;
             $aux->image = $y->image;
             $aux->order = $y->order;
             $images[$j] = $aux;
             $j++;
         }
     }
     for ($i = 0; $i < count($images); $i++) {
         for ($j = 0; $j < count($images) - 1; $j++) {
             if ($images[$j]->order > $images[$j + 1]->order) {
                 $bub = new stdClass();
                 $bub = $images[$j + 1];
                 $images[$j + 1] = $images[$j];
                 $images[$j] = $bub;
             }
         }
     }
     return View::make('admin.changeImagePos')->with('title', $title)->with('item', $images);
 }