/** * Display form * @return \Illuminate\Http\Response */ public function getIndex() { $response['pageTitle'] = trans('upcoming_product.upcoming_product'); $data = Model_UpcomingProduct::getUpcomingProduct(); if (!empty($data[0]) && is_array($data[0])) { foreach ($data[0] as $key => $val) { $response[$key] = $val; } } $response['blade_custom_css'] = ['global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/select2/select2', 'global/plugins/jquery-multi-select/css/multi-select', 'global/plugins/bootstrap-switch/css/bootstrap-switch.min', 'global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min']; $response['blade_custom_js'] = ['global/plugins/bootstrap-switch/js/bootstrap-switch.min', 'admin/pages/scripts/components-dropdowns', 'global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min', 'global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/select2/select2.min', 'global/plugins/jquery-multi-select/js/jquery.multi-select']; $response['products'] = Model_Products::getProducts(FALSE, ['title'], FALSE, 0, 0, TRUE); return Theme::view('upcoming_product.upcoming_product', $response); }
/** * 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; } }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function getEdit($id) { $response['pageTitle'] = trans('carousels.edit'); $response['blade_custom_css'] = ['global/plugins/select2/select2', 'global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min']; $response['blade_custom_js'] = ['global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/select2/select2.min', 'admin/pages/scripts/components-dropdowns', 'global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min']; $response['categories'] = Model_Categories::getCategory(FALSE, ['title']); $response['pages'] = Model_Pages::getPage(FALSE, ['id', 'title']); $response['products'] = Model_Products::getProducts(FALSE, ['title']); $response['carousel'] = Model_Carousels::getCarousels($id, FALSE); if (!empty($response['carousel']) && !empty($response['carousel'][0])) { $response['carousel'] = $response['carousel'][0]; } if (!empty($response['carousel']['products']) && $response['carousel']['products'] == 'newest' || $response['carousel']['products'] == 'discounted') { $response['carousel']['slider_type'] = $response['carousel']['products']; } else { $response['carousel']['slider_type'] = 'others'; } if (!empty($response['carousel']['products']) && $response['carousel']['slider_type'] == 'others') { $response['carousel']['products'] = is_array(json_decode(',', $response['carousel']['products'], TRUE)) ? json_decode(',', $response['carousel']['products'], TRUE) : explode(',', $response['carousel']['products']); } if (!empty($response['carousel']['active_from']) && $response['carousel']['active_from'] == '0000-00-00 00:00:00') { $response['carousel']['active_from'] = ''; } if (!empty($response['carousel']['active_to']) && $response['carousel']['active_to'] == '0000-00-00 00:00:00') { $response['carousel']['active_to'] = ''; } return Theme::view('carousels.create_edit_carousel', $response); }
/** * Show the form for editing the specified resource. * * @param int $id * * @return \Illuminate\Http\Response */ public function getEdit($id = FALSE) { $customCSS = ['global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5', 'global/plugins/bootstrap-summernote/summernote', 'global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/select2/select2', 'global/plugins/jquery-multi-select/css/multi-select', 'global/plugins/bootstrap-switch/css/bootstrap-switch.min', 'global/plugins/bootstrap-datetimepicker/css/bootstrap-datetimepicker.min', 'global/plugins/dropzone/css/dropzone']; $customJS = ['global/plugins/bootstrap-wysihtml5/wysihtml5-0.3.0', 'global/plugins/bootstrap-wysihtml5/bootstrap-wysihtml5', 'global/plugins/bootstrap-summernote/summernote.min', 'admin/pages/scripts/components-dropdowns', 'global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/bootstrap-select/bootstrap-select.min', 'global/plugins/select2/select2.min', 'global/plugins/jquery-multi-select/js/jquery.multi-select', 'global/plugins/fuelux/js/spinner.min', 'global/plugins/bootstrap-switch/js/bootstrap-switch.min', 'global/plugins/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min', 'global/plugins/dropzone/dropzone', 'admin/pages/scripts/form-dropzone', 'global/plugins/jquery-slugify/speakingurl', 'global/plugins/jquery-slugify/slugify.min']; $response['blade_custom_css'] = $customCSS; $response['blade_custom_js'] = $customJS; $response['categories'] = Model_Categories::getCategory(FALSE, ['title']); $response['related_categories'] = Model_Products::getProductToCategory($id); $response['products'] = Model_Products::getProducts(FALSE, ['title']); $response['groups'] = Model_Sizes::getSizes(TRUE); $response['colors'] = Model_Products::getColors(); $response['related_colors'] = Model_Products::getColor($id); $response['dimensions_tables'] = Model_Tables::getTables(); if (!empty($response['dimensions_tables']) && is_array($response['dimensions_tables'])) { foreach ($response['dimensions_tables'] as $key => $table) { if (isset($table['image'])) { unset($response['dimensions_tables'][$key]['image']); } } } //Get product and it's data $product = Model_Products::getProducts($id); //Prepare product for response if (!empty($product[$id])) { $response['product'] = $product[$id]; if (!empty($product[$id]['sizes'])) { $response['sizes'] = json_decode($product[$id]['sizes'], TRUE); } if (!empty($response['product']['discount_start']) && $response['product']['discount_start'] == '0000-00-00 00:00:00') { $response['product']['discount_start'] = ''; } if (!empty($response['product']['discount_end']) && $response['product']['discount_end'] == '0000-00-00 00:00:00') { $response['product']['discount_end'] = ''; } } //SEO Tab if (($slug = Model_Products::getURL($id)) != FALSE) { $response['seo']['friendly_url'] = $slug; } if (!empty($response['product']['page_title'])) { $response['seo']['page_title'] = $response['product']['page_title']; unset($response['product']['page_title']); } if (!empty($response['product']['meta_description'])) { $response['seo']['meta_description'] = $response['product']['meta_description']; unset($response['product']['meta_description']); } if (!empty($response['product']['meta_keywords'])) { $response['seo']['meta_keywords'] = $response['product']['meta_keywords']; unset($response['product']['meta_keywords']); } //Images Tab if (!empty($response['product']['images'])) { $response['product']['images'] = json_decode($response['product']['images'], TRUE); if (is_array($response['product']['images'])) { $response['thumbs_path'] = Config::get('system_settings.product_public_path') . $id . '/' . Config::get('images.sm_icon_size') . '/'; uasort($response['product']['images'], function ($a, $b) { if ($a == $b) { return 0; } return $a < $b ? -1 : 1; }); } } //Tags $tags = Model_Products::getTags($id); if (!empty($tags) && is_array($tags)) { foreach ($tags as $key => $tag) { $response['product']['tags'][] = $tag['title']; } $response['product']['tags'] = implode(',', $response['product']['tags']); } //Manufacturer $response['manufacturers'] = Model_Products::getManufacturers(); $response['product']['manufacturer'] = Model_Products::getManufacturer($id); //Material $response['materials'] = Model_Products::getMaterials(); $response['product']['material'] = Model_Products::getMaterial($id); if (!empty($response['product']['material'][0])) { $response['product']['material'] = $response['product']['material'][0]; } //Related products if (!empty($response['product']['related_products'])) { $response['related_products'] = json_decode($response['product']['related_products'], TRUE); unset($response['product']['related_products']); } $response['pageTitle'] = trans('products.edit'); return Theme::view('products.edit_product', $response); }
public static function returnProduct($record_id) { //Get record id $record = DB::table('order_products')->where('id', '=', $record_id)->get(); if (!empty($record[0]) && is_array($record[0]) && !empty($record[0]['product_id'])) { $product_id = $record[0]['product_id']; $product = Model_Products::getProducts($product_id, ['sizes']); if (!empty($product[$product_id]['sizes']) && is_array(json_decode($product[$product_id]['sizes'], TRUE))) { $sizes = json_decode($product[$product_id]['sizes'], TRUE); $pr_quantity = $product[$product_id]['quantity']; foreach ($sizes as $key => $size) { if ($record[0]['size'] == $size['name']) { $sizes[$key]['quantity'] = intval($sizes[$key]['quantity']) + intval($record[0]['quantity']); $pr_quantity = intval($pr_quantity) + intval($record[0]['quantity']); } } } $sizes = json_encode($sizes); return self::manageQuantities($product_id, $sizes, $pr_quantity); } else { return FALSE; } }