function GDSAction() { $img_id = $_SESSION['imag_id']; $imgAccount = ImgAccountUtil::getImgAccountById($img_id, TRUE); $v_params['sys_name'] = SysPropertiesUtil::getPropertyValue("sys_name"); $v_params['sys_slog'] = SysPropertiesUtil::getPropertyValue("sys_slog"); if (NULL != $imgAccount) { $v_params['logined'] = LoginChecker::isLogined(); if ($v_params['logined'] == $img_id) { $v_params['mysc']['main'] = TRUE; $v_params['img_name'] = $imgAccount['img_name']; $v_params['img_all_gds_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR; $v_params['img_all_blog_cats_href'] = "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR; $v_params['img_gds_cats_HTML'] = ImgGdsCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . IMAG_DIR . "?" . PROD_CAT_PARAM_NAME . "="); $v_params['img_blog_cats_HTML'] = ImgBlogCatUtil::createTreeHTML($imgAccount['id'], "/" . IMAG_PREFIX . $img_id . "/" . BLOG_DIR . "?" . ART_CAT_PARAM_NAME . "="); $v_params['img_gds_cats'] = ImgGdsCatUtil::getImgGdsCatsByAccountId($imgAccount['id']); $v_params['img_currencies'] = ImgCurrencyUtil::getImgCurrencies(); $img_albums = ImgAlbumUtil::getImgAlbumsByAccountID($imgAccount['id']); $img_album_pictures = ImgPictureUtil::getImgPicturesNoAlbum($imgAccount['id']); $v_params['img_albums'][] = array("name" => "Без альбома", "pictures" => $img_album_pictures); if (count($img_albums)) { foreach ($img_albums as $img_album) { $img_album_pictures = ImgPictureUtil::getImgPicturesByAlbumId($img_album['id'], $imgAccount['id']); $v_params['img_albums'][] = array("name" => $img_album['name'], "pictures" => $img_album_pictures); } } if (0 == strcmp("add", $_GET['act'])) { $v_params['action'] = "Добавить товар"; $v_params['gds_opt']['gds_name'] = $_POST['gds_name']; $v_params['gds_opt']['gds_price_val'] = (int) $_POST['gds_price_val']; $v_params['gds_opt']['gds_price_cur'] = (int) $_POST['gds_price_cur']; $v_params['gds_opt']['gds_code'] = $_POST['gds_code']; $v_params['gds_opt']['gds_cat'] = (int) $_POST['gds_cat']; $v_params['gds_opt']['gds_main_img'] = (int) $_POST['gds_main_img']; $v_params['gds_opt']['gds_first_img'] = (int) $_POST['gds_first_img']; $v_params['gds_opt']['gds_second_img'] = (int) $_POST['gds_second_img']; $v_params['gds_opt']['gds_third_img'] = (int) $_POST['gds_third_img']; $v_params['gds_opt']['gds_char_list'] = $_POST['gds_char_list']; $v_params['gds_opt']['gds_descr'] = $_POST['gds_descr']; $v_params['gds_opt']['gds_new'] = $_POST['gds_new']; $v_params['gds_opt']['gds_rec'] = $_POST['gds_rec']; $v_params['gds_opt']['gds_in_sale'] = $_POST['gds_in_sale']; if ($_POST['form']) { if (NULL == $_POST['gds_name'] || 0 == strcmp("", trim($_POST['gds_name']))) { $v_params['errors'][] = "Имя товара обязательно для ввода"; } if (0 >= $v_params['gds_opt']['gds_price_val']) { $v_params['errors'][] = "Цена должна быть положительным числом"; } if (NULL == $_POST['gds_code'] || 0 == strcmp("", trim($_POST['gds_code']))) { $v_params['errors'][] = "Введите код товара"; } if (0 >= $v_params['gds_opt']['gds_main_img']) { $v_params['errors'][] = "Вы должны назначить главное изображение для товара"; } if (count($v_params['errors'])) { Application::fastView('imag-admin/gds/img_gds_au', $v_params); exit; } else { $imgGds['UUID'] = $v_params['gds_opt']['gds_code']; $imgGds['name'] = $v_params['gds_opt']['gds_name']; $imgGds['price'] = $v_params['gds_opt']['gds_price_val']; $imgGds['currency_id'] = $v_params['gds_opt']['gds_price_cur']; $imgGds['main_pict_id'] = $v_params['gds_opt']['gds_main_img']; $imgGds['first_pict_id'] = $v_params['gds_opt']['gds_first_img']; $imgGds['second_pict_id'] = $v_params['gds_opt']['gds_second_img']; $imgGds['third_pict_id'] = $v_params['gds_opt']['gds_third_img']; $imgGds['img_account_id'] = $imgAccount['id']; $imgGds['img_gds_cat_id'] = $v_params['gds_opt']['gds_cat']; $imgGds['descr'] = $_POST['gds_descr']; if ($v_params['gds_opt']['gds_in_sale']) { $imgGds['in_stock'] = 1; } else { $imgGds['in_stock'] = 0; } if ($v_params['gds_opt']['gds_new']) { $imgGds['is_new'] = 1; } else { $imgGds['is_new'] = 0; } if ($v_params['gds_opt']['gds_rec']) { $imgGds['is_recommended'] = 1; } else { $imgGds['is_recommended'] = 0; } $gdsID = ImgGdsUtil::insertGDS($imgGds); $props = Splitter::splitGDSProperties($v_params['gds_opt']['gds_char_list']); ImgGdsPropUtil::insertManyImgGdsProps($gdsID, $props); header("Location: GDSs"); return; } } else { Application::fastView('imag-admin/gds/img_gds_au', $v_params); exit; } } else { if (0 == strcmp("upd", $_GET['act'])) { $v_params['action'] = "Редактировать товар"; $img_gds_id = $_GET['id']; $imgGDS = ImgGdsUtil::getImgGdsByIdAndAccountId($img_gds_id, $imgAccount['id']); if ($imgGDS) { if ($_POST['form']) { $v_params['gds_opt']['gds_name'] = $_POST['gds_name']; $v_params['gds_opt']['gds_price_val'] = (int) $_POST['gds_price_val']; $v_params['gds_opt']['gds_price_cur'] = (int) $_POST['gds_price_cur']; $v_params['gds_opt']['gds_code'] = $_POST['gds_code']; $v_params['gds_opt']['gds_cat'] = (int) $_POST['gds_cat']; $v_params['gds_opt']['gds_main_img'] = (int) $_POST['gds_main_img']; $v_params['gds_opt']['gds_first_img'] = (int) $_POST['gds_first_img']; $v_params['gds_opt']['gds_second_img'] = (int) $_POST['gds_second_img']; $v_params['gds_opt']['gds_third_img'] = (int) $_POST['gds_third_img']; $v_params['gds_opt']['gds_char_list'] = $_POST['gds_char_list']; $v_params['gds_opt']['gds_descr'] = $_POST['gds_descr']; $v_params['gds_opt']['gds_new'] = $_POST['gds_new']; $v_params['gds_opt']['gds_rec'] = $_POST['gds_rec']; $v_params['gds_opt']['gds_in_sale'] = $_POST['gds_in_sale']; if (NULL == $_POST['gds_name'] || 0 == strcmp("", trim($_POST['gds_name']))) { $v_params['errors'][] = "Имя товара обязательно для ввода"; } if (0 >= $v_params['gds_opt']['gds_price_val']) { $v_params['errors'][] = "Цена должна быть положительным числом"; } if (NULL == $_POST['gds_code'] || 0 == strcmp("", trim($_POST['gds_code']))) { $v_params['errors'][] = "Введите код товара"; } if (0 >= $v_params['gds_opt']['gds_main_img']) { $v_params['errors'][] = "Вы должны назначить главное изображение для товара"; } if (!count($v_params['errors'])) { $imgGds['id'] = $imgGDS['ig_id']; $imgGds['UUID'] = $v_params['gds_opt']['gds_code']; $imgGds['name'] = $v_params['gds_opt']['gds_name']; $imgGds['price'] = $v_params['gds_opt']['gds_price_val']; $imgGds['currency_id'] = $v_params['gds_opt']['gds_price_cur']; $imgGds['main_pict_id'] = $v_params['gds_opt']['gds_main_img']; $imgGds['first_pict_id'] = $v_params['gds_opt']['gds_first_img']; $imgGds['second_pict_id'] = $v_params['gds_opt']['gds_second_img']; $imgGds['third_pict_id'] = $v_params['gds_opt']['gds_third_img']; $imgGds['img_account_id'] = $imgAccount['id']; $imgGds['img_gds_cat_id'] = $v_params['gds_opt']['gds_cat']; $imgGds['descr'] = $_POST['gds_descr']; if ($v_params['gds_opt']['gds_in_sale']) { $imgGds['in_stock'] = 1; } else { $imgGds['in_stock'] = 0; } if ($v_params['gds_opt']['gds_new']) { $imgGds['is_new'] = 1; } else { $imgGds['is_new'] = 0; } if ($v_params['gds_opt']['gds_rec']) { $imgGds['is_recommended'] = 1; } else { $imgGds['is_recommended'] = 0; } ImgGdsUtil::updateGDS($imgGds); $props = Splitter::splitGDSProperties($v_params['gds_opt']['gds_char_list']); ImgGdsPropUtil::deleteImgGdsPropByImgGdsId($imgGds['id']); ImgGdsPropUtil::insertManyImgGdsProps($imgGds['id'], $props); } } else { $v_params['gds_opt']['gds_name'] = $imgGDS['ig_name']; $v_params['gds_opt']['gds_price_val'] = $imgGDS['price']; $v_params['gds_opt']['gds_price_cur'] = $imgGDS['currency_id']; $v_params['gds_opt']['gds_code'] = $imgGDS['UUID']; $v_params['gds_opt']['gds_cat'] = $imgGDS['img_gds_cat_id']; $v_params['gds_opt']['gds_main_img'] = $imgGDS['main_pict_id']; $v_params['gds_opt']['gds_first_img'] = $imgGDS['first_pict_id']; $v_params['gds_opt']['gds_second_img'] = $imgGDS['second_pict_id']; $v_params['gds_opt']['gds_third_img'] = $imgGDS['third_pict_id']; $imgGdsProps = ImgGdsPropUtil::getImgGdsProps($img_gds_id); $v_params['gds_opt']['gds_char_list'] = Splitter::desplitGDSProperties($imgGdsProps); $v_params['gds_opt']['gds_descr'] = ImgGdsUtil::getDescriptionOfImgGds($img_gds_id); $v_params['gds_opt']['gds_new'] = $imgGDS['is_new']; $v_params['gds_opt']['gds_rec'] = $imgGDS['is_recommended']; $v_params['gds_opt']['gds_in_sale'] = $imgGDS['in_stock']; } Application::fastView('imag-admin/gds/img_gds_au', $v_params); exit; } } else { if (0 == strcmp("del", $_GET['act'])) { $v_params['action'] = "Удалить товар"; $img_gds_id = $_GET['id']; $imgGDS = ImgGdsUtil::getImgGdsByIdAndAccountId($img_gds_id, $imgAccount['id']); if ($imgGDS) { if ($_POST['gds_del']) { ImgGdsPropUtil::deleteImgGdsPropByImgGdsId($img_gds_id); ImgGdsUtil::deleteGDSById($img_gds_id); header("Location: GDSs"); return; } $v_params['img_gds']['ig_name'] = $imgGDS['ig_name']; $v_params['img_gds']['price'] = $imgGDS['price']; $v_params['img_gds']['currency_name'] = $imgGDS['ic_name']; $v_params['img_gds']['UUID'] = $imgGDS['UUID']; $v_params['img_gds']['main_pict_id'] = $imgGDS['main_pict_id']; $v_params['img_gds']['first_pict_id'] = $imgGDS['first_pict_id']; $v_params['img_gds']['second_pict_id'] = $imgGDS['second_pict_id']; $v_params['img_gds']['third_pict_id'] = $imgGDS['third_pict_id']; $v_params['img_gds_props'] = ImgGdsPropUtil::getImgGdsProps($img_gds_id); $v_params['img_gds_descr'] = ImgGdsUtil::getDescriptionOfImgGds($img_gds_id); } Application::fastView('imag-admin/gds/img_gds_del', $v_params); exit; } } } } } Application::fastView('main/sys_error', $v_params); }
public static function getImgGdsSubCatIdsByImgGdsCatId($account_id, $img_gds_cat_id) { $imgGdsCats = ImgGdsCatUtil::getImgGdsCatsByAccountId($account_id); if (0 == count($imgGdsCats)) { return NULL; } if (NULL == $img_gds_cat_id) { foreach ($imgGdsCats as $imgGdsCat) { $subCatIds[$imgGdsCat['id']] = $imgGdsCat['id']; } } else { $subCatIds = array(); self::fillSubCatsId($img_gds_cat_id, $imgGdsCats, &$subCatIds); } return $subCatIds; }