コード例 #1
0
ファイル: front-end-ajax.php プロジェクト: abdoumej/libsamy
 public static function loadPageDefault()
 {
     $langId = Context::getContext()->language->id;
     $shopId = Context::getContext()->shop->id;
     $groupID = intval($_POST['groupID']);
     $type = $_POST['type'];
     $itemId = intval($_POST['itemId']);
     $page = intval($_POST['page']);
     $itemWidth = intval($_POST['itemWidth']);
     $itemHeight = round($_POST['itemHeight'], 3);
     $css = 'width: ' . $itemWidth . 'px; height:' . $itemHeight . "px;";
     $group = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_groups Where id = " . $groupID);
     $response = '';
     $products = array();
     if ($group) {
         $module = new GroupCategory();
         $itemConfig = json_decode($group['itemConfig']);
         if (!$itemConfig->countItem || (int) $itemConfig->countItem <= 0) {
             $pageSize = 3;
         } else {
             $pageSize = $itemConfig->countItem;
         }
         $offset = $page * $pageSize;
         if ($itemId == 0) {
             $arrSubCategory = GroupCategoryLibraries::getCategoryIds($group['categoryId']);
             $arrSubCategory[] = $group['categoryId'];
             if ($type == 'saller') {
                 $products = GroupCategoryLibraries::getProducts_Sales($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'view') {
                 $products = GroupCategoryLibraries::getProducts_View($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'special') {
                 $products = GroupCategoryLibraries::getProducts_Special($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } elseif ($type == 'arrival') {
                 $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
             } else {
                 if ($group['type_default'] == 'saller') {
                     $products = GroupCategoryLibraries::getProducts_Sales($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } elseif ($group['type_default'] == 'view') {
                     $products = GroupCategoryLibraries::getProducts_View($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } elseif ($group['type_default'] == 'special') {
                     $products = GroupCategoryLibraries::getProducts_Special($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 } else {
                     $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
                 }
             }
         } else {
             $item = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_items Where id = " . $itemId);
             if ($item) {
                 $arrSubCategory = GroupCategoryLibraries::getCategoryIds($item['categoryId']);
                 $arrSubCategory[] = $item['categoryId'];
                 $products = GroupCategoryLibraries::getProducts_AddDate($langId, $arrSubCategory, null, false, $pageSize, $offset);
             }
         }
         if ($products) {
             $response = $module->generationHtml_default($products, $css);
         }
     }
     die(Tools::jsonEncode($response));
 }
コード例 #2
0
ファイル: ajax.php プロジェクト: abdoumej/libsamy
 public static function loadGroupByLang()
 {
     $shopId = Context::getContext()->shop->id;
     $langId = intval($_POST['langId']);
     $itemId = intval($_POST['itemId']);
     $item = GroupCategoryLibraries::getGroupLangById($itemId, $langId, $shopId);
     // DB::getInstance()->getRow("Select * From "._DB_PREFIX_."flexiblecustom_modules_lang Where module_id = ".$itemId." AND id_lang = ".$langId." AND id_shop = ".$shopId);
     $response = new stdClass();
     if ($item) {
         $response->name = $item['name'];
         $response->banner = $item['banner'];
         $response->banner_link = $item['banner_link'];
     } else {
         $response->name = '';
         $response->banner = '';
         $response->banner_link = '';
     }
     die(Tools::jsonEncode($response));
 }
コード例 #3
0
ファイル: ajax.php プロジェクト: habypk/zocart
 public static function loadItemsByGroup()
 {
     $module = new GroupCategory();
     $response = new stdClass();
     $groupId = intval($_POST['groupId']);
     $group = DB::getInstance()->getRow("Select * From " . _DB_PREFIX_ . "groupcategory_groups Where id = " . $groupId);
     if ($group) {
         $langId = Context::getContext()->language->id;
         $shopId = Context::getContext()->shop->id;
         $items = DB::getInstance()->executeS("Select * From " . _DB_PREFIX_ . "groupcategory_items Where groupId = {$groupId} Order By ordering");
         $response->categoryOptions = $module->getCategoryOptions(0, $group['categoryId']);
         $response->status = 1;
         $response->msg = '';
         $response->content = '';
         if ($items) {
             foreach ($items as $item) {
                 if ($item['status'] == "1") {
                     $status = '<a title="Enabled" class="list-action-enable action-enabled lik-item-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>';
                 } else {
                     $status = '<a title="Disabled" class="list-action-enable action-disabled lik-item-status" item-id="' . $item['id'] . '" value="' . $item['status'] . '"><i class="icon-check"></i></a>';
                 }
                 $itemLang = GroupCategoryLibraries::getItemLangById($item['id'], $langId, $shopId);
                 $response->content .= '<tr id="it_' . $item['id'] . '">
                                             <td>' . $item['id'] . '</td>
                                             <td>' . $itemLang['name'] . '</td>
                                             <td class="center">' . GroupCategoryLibraries::getCategoryLangNameById($item['categoryId'], $langId, $shopId) . '</td>
                                             <td class="pointer dragHandle center" ><div class="dragGroup"><div class="positions">' . $item['ordering'] . '</div></div></td>
                                             <td class="center">' . $status . '</td>
                                             <td class="center">
                                                 <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-item-edit"><i class="icon-edit"></i></a>&nbsp;
                                                 <a href="javascript:void(0)" item-id="' . $item['id'] . '" class="lik-item-delete"><i class="icon-trash" ></i></a>
                                             </td>
                                         </tr>';
             }
         } else {
             $response->msg = "Items empty.";
         }
     } else {
         $response->status = 0;
         $response->msg = "Group do not exist";
         $response->content = '';
     }
     die(Tools::jsonEncode($response));
 }
コード例 #4
0
 public function getCategoryOptions($selected = 0, $parentId = 0)
 {
     $langId = Context::getContext()->language->id;
     $shopId = Context::getContext()->shop->id;
     $categoryOptions = '';
     if ($parentId <= 0) {
         $parentId = Configuration::get('PS_HOME_CATEGORY');
     }
     $items = GroupCategoryLibraries::getAllCategories($langId, $shopId, $parentId, '- ', null);
     if ($items) {
         foreach ($items as $item) {
             if ($item['id_category'] == $selected) {
                 $categoryOptions .= '<option selected="selected" value="' . $item['id_category'] . '">' . $item['sp'] . $item['name'] . '</option>';
             } else {
                 $categoryOptions .= '<option value="' . $item['id_category'] . '">' . $item['sp'] . $item['name'] . '</option>';
             }
         }
     }
     return $categoryOptions;
 }
コード例 #5
0
 static function getCategoryIds($parentId = 0, $arr = null)
 {
     if ($arr == null) {
         $arr = array();
     }
     $items = DB::getInstance()->executeS("Select id_category From " . _DB_PREFIX_ . "category Where id_parent = {$parentId}");
     if ($items) {
         foreach ($items as $item) {
             $arr[] = $item['id_category'];
             $arr = GroupCategoryLibraries::getCategoryIds($item['id_category'], $arr);
         }
     }
     return $arr;
 }