function showArticleAdministration() { $artID = -1; $artSystemName = ''; $artSystemDescription = ''; $artPrice = ''; $artImagePath = ''; $action = 'add'; if (isset($_GET['origin']) && $_GET['origin'] == 'update' && isset($_GET['artId'])) { if (isset($_GET['artId'])) { $artID = $_GET['artId']; } $action = 'update'; $lang = get_language(); include_once "./includes/items.php"; $item = getSysItem($artID); $artID = $item->getId(); $artSystemName = $item->getName(); $artSystemDescription = $item->getDescription(); $artPrice = $item->getPrice(); $artImagePath = $item->getImage(); } else { if (isset($_GET['origin']) && $_GET['origin'] == 'add') { $action = 'add'; } } $categoryDB = new CategoryDB(); $categoryArticleDB = new CategoryArticleDB(); $languageDB = new LanguageDB(); $sqlcategoryArticleRes = $categoryArticleDB->getAllCategorysByArticle($artID); $sqlcategoryRes = $categoryDB->getAllCategorys(); $selectedCats = array(); while ($catArt = $sqlcategoryArticleRes->fetch_object()) { $selectedCats[] = $catArt->categoryId; } $sqllanguageRes = $languageDB->getAllLanguages(); echo "<form action=\"index.php?site=administration\" method=\"post\">"; echo "<input type=\"hidden\" name=\"artId\" value=\"{$artID}\" /input>"; echo "<table style=\"width:95%\">"; echo "<tr>"; echo "<td >Systemname: </td>"; echo "<td>"; echo "<input class=\"changeArticleForm-title\" type=\"text\" name=\"artSystemName\" maxlength=\"45\" value=\"{$artSystemName}\" /input>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td >Systemdescription: </td>"; echo "<td>"; echo "<textarea class=\"changeArticleForm-description\" type=\"text\" name=\"artSystemDescription\" >{$artSystemDescription}</textarea>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td >Price: </td>"; echo "<td>"; echo "<input class=\"changeArticleForm-price\" type=\"number\" name=\"artPrice\" value=\"{$artPrice}\" /input>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td >Imagepath: </td>"; echo "<td>"; echo "<input class=\"changeArticleForm-imagePath\" type=\"text\" name=\"artImagePath\" maxlength=\"150\" value=\"{$artImagePath}\" /input>"; echo "</td>"; echo "</tr>"; echo "<tr>"; echo "<td >Article Category: </td>"; echo "<td>"; echo "<select name=\"category[]\" size=\"4\" multiple=\"multiple\" tabindex=\"1\">"; while ($cat = $sqlcategoryRes->fetch_object()) { echo "<option value=\"{$cat->Category_ID}\" "; foreach ($selectedCats as $selected) { if ($selected == $cat->Category_ID) { echo "selected=\"selected\" "; break; } } echo ">{$cat->CategoryName}</option>"; } echo "</select>"; echo "</td>"; echo "</tr>"; printLanguagePart($sqllanguageRes, $artID); echo "</table>"; echo "<input type=\"hidden\" name=\"action\" value=\"{$action}\" /input>"; echo "<input class=\"basket-update-button\" type=\"submit\" value=\"Save\"/>"; echo "</form>"; }
function saveLanguages($artID) { require_once ROOT . "DBInterface/languageDB.php"; require_once ROOT . "DBInterface/articleTranslationDB.php"; $languageDB = new LanguageDB(); $articleTranslationDB = new ArticleTranslationDB(); $sqllanguageRes = $languageDB->getAllLanguages(); $articleTranslationDB->deleteAllTranslationsByArticle($artID); while ($language = $sqllanguageRes->fetch_object()) { if (isset($_POST[$language->Language_ID . "translatedName"]) && isset($_POST[$language->Language_ID . "translatedDescription"])) { $translatedName = $_POST[$language->Language_ID . "translatedName"]; $translatedDescription = $_POST[$language->Language_ID . "translatedDescription"]; $articleTranslationDB->insertCategoryArticle($artID, $language->Language_ID, $translatedName, $translatedDescription); } } }