/**
  * Used to display partials or do ajax requests
  *
  * @param id
  * @param $request
  *
  * @return \Illuminate\Http\Response
  * @internal param int $id
  */
 public function getShow($id = FALSE, $request = FALSE, $form_method = FALSE)
 {
     if ($request == 'add_product') {
         $response['blade_standalone'] = TRUE;
         $response['products'] = Model_Products::getProducts(FALSE, ['title']);
         return Theme::View('orders.add_product_partial', $response);
     } elseif ($request == 'add_product_info' && is_numeric($id)) {
         if ($product = Model_Products::getProducts($id, ['sizes'])) {
             $response['blade_standalone'] = TRUE;
             $response['total_quantity'] = 0;
             if (!empty($product[$id]) && is_array($product[$id])) {
                 $product = $product[$id];
             }
             //Sizes
             if (!empty($product['sizes']) && is_array($sizes = json_decode($product['sizes'], TRUE))) {
                 $response['sizes'] = $sizes;
                 foreach ($sizes as $key => $size) {
                     if (!empty($size['quantity'])) {
                         $response['total_quantity'] = $response['total_quantity'] + intval($size['quantity']);
                     }
                 }
             }
             $response['product_id'] = $id;
             return Theme::View('orders.add_product_info_partial', $response);
         } else {
             return FALSE;
         }
     } elseif ($request == 'products_table' && is_numeric($id)) {
         $response = [];
         $response['blade_standalone'] = TRUE;
         if ($order_products = Model_Orders::getOrderProducts($id)) {
             $products_list = [];
             $products_images = [];
             $response['thumbs_path'] = Config::get('system_settings.product_public_path');
             $response['icon_size'] = Config::get('images.sm_icon_size');
             $upload_path = Config::get('system_settings.product_upload_path');
             if (!empty($order_products) && is_array($order_products)) {
                 foreach ($order_products as $product) {
                     if (!in_array($product['product_id'], $products_list)) {
                         $products_list[] = $product['product_id'];
                     }
                 }
             }
             //Fetch images
             if (!empty($products_list) && is_array($products_list)) {
                 if ($products = Model_Products::getProducts($products_list, ['title', 'images'])) {
                     foreach ($products as $key => $product) {
                         if (!empty($product['images'])) {
                             $product['images'] = json_decode($product['images'], TRUE);
                             if (is_array($product['images'])) {
                                 uasort($product['images'], function ($a, $b) {
                                     if ($a == $b) {
                                         return 0;
                                     }
                                     return $a < $b ? -1 : 1;
                                 });
                                 reset($product['images']);
                                 $product['images'] = key($product['images']);
                                 if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') {
                                     if (file_exists(iconv("UTF-8", "WINDOWS-1251", $upload_path . $product['id'] . DIRECTORY_SEPARATOR . $response['icon_size'] . DIRECTORY_SEPARATOR . $product['images']))) {
                                         $products_images[$product['id']] = $product['images'];
                                     }
                                 } else {
                                     if (file_exists($upload_path . $product['id'] . DIRECTORY_SEPARATOR . $response['icon_size'] . DIRECTORY_SEPARATOR . $product['images'])) {
                                         $products_images[$product['id']] = $product['images'];
                                     }
                                 }
                             }
                         }
                     }
                     foreach ($order_products as $key => $product) {
                         if (array_key_exists($product['product_id'], $products_images)) {
                             $order_products[$key]['image'] = $products_images[$product['product_id']];
                             if (!empty($products[$product['product_id']]['title'])) {
                                 $order_products[$key]['title'] = $products[$product['product_id']]['title'];
                             }
                         }
                     }
                     $response['products'] = $order_products;
                 }
             }
         }
         $response['method'] = $form_method;
         return Theme::View('orders.products_list_partial', $response);
     } elseif (is_numeric($id) && $request == FALSE) {
         $response['method'] = 'locked';
         $order = Model_Orders::getOrders($id, FALSE);
         if (!empty($order[0]) && is_array($order[0])) {
             $response['order'] = $order[0];
             switch ($response['order']['status']) {
                 case 'pending':
                     $response['order']['status_color'] = 'bg-green-jungle';
                     break;
                 case 'confirmed':
                     $response['order']['status_color'] = 'bg-yellow-casablanca';
                     break;
                 case 'completed':
                     $response['order']['status_color'] = 'bg-blue-madison';
                     break;
                 case 'canceled':
                     $response['order']['status_color'] = 'bg-red-thunderbird';
                     break;
             }
         }
         foreach ($this->states as $state) {
             $response['states'][$state] = trans('orders.' . $state);
         }
         $response['pageTitle'] = trans('orders.preview_order');
         return Theme::view('orders.create_edit_order', $response);
     } else {
         return FALSE;
     }
 }