XoopsModules25x /
oledrion
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /* |
||
| 3 | You may not change or alter any portion of this comment or credits |
||
| 4 | of supporting developers from this source code or any supporting source code |
||
| 5 | which is considered copyrighted (c) material of the original comment or credit authors. |
||
| 6 | |||
| 7 | This program is distributed in the hope that it will be useful, |
||
| 8 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||
| 9 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||
| 10 | */ |
||
| 11 | |||
| 12 | /** |
||
| 13 | * oledrion |
||
| 14 | * |
||
| 15 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 16 | * @license {@link http://www.fsf.org/copyleft/gpl.html GNU public license} |
||
| 17 | * @author Hervé Thouzard (http://www.herve-thouzard.com/) |
||
| 18 | */ |
||
| 19 | |||
| 20 | /** |
||
| 21 | * Gestion des produits (dans l'administration) |
||
| 22 | */ |
||
| 23 | if (!defined('OLEDRION_ADMIN')) { |
||
| 24 | exit(); |
||
| 25 | } |
||
| 26 | |||
| 27 | switch ($action) { |
||
| 28 | // **************************************************************************************************************** |
||
| 29 | case 'default': // Gestion des produits |
||
| 30 | // **************************************************************************************************************** |
||
| 31 | xoops_cp_header(); |
||
| 32 | $adminObject = \Xmf\Module\Admin::getInstance(); |
||
| 33 | $adminObject->displayNavigation('index.php?op=products'); |
||
| 34 | |||
| 35 | $products = $categories = array(); |
||
| 36 | |||
| 37 | // Récupération des données uniques |
||
| 38 | $categories = $h_oledrion_cat->getAllCategories(new Oledrion_parameters(array( |
||
| 39 | 'start' => 0, |
||
| 40 | 'limit' => 0, |
||
| 41 | 'sort' => 'cat_title', |
||
| 42 | 'order' => 'ASC', |
||
| 43 | 'idaskey' => true |
||
| 44 | ))); |
||
| 45 | |||
| 46 | $form = "<form method='post' action='$baseurl' name='frmadddproduct' id='frmadddproduct'><input type='hidden' name='op' id='op' value='products'><input type='hidden' name='action' id='action' value='add'><input type='submit' name='btngo' id='btngo' value='" |
||
| 47 | . _AM_OLEDRION_ADD_ITEM |
||
| 48 | . "'></form>"; |
||
| 49 | echo $form; |
||
| 50 | echo "<br><form method='get' action='$baseurl' name='frmaddeditproduct' id='frmaddeditproduct'>" |
||
| 51 | . _OLEDRION_PRODUCT_ID |
||
| 52 | . " <input type='text' name='id' id='id' value='' size='4'> <input type='hidden' name='op' id='op' value='products'><input type='radio' name='action' id='action' value='edit'>" |
||
| 53 | . _OLEDRION_EDIT |
||
| 54 | . " <input type='radio' name='action' id='action' value='confdelete'>" |
||
| 55 | . _OLEDRION_DELETE |
||
| 56 | . " <input type='submit' name='btngo' id='btngo' value='" |
||
| 57 | . _GO |
||
| 58 | . "'></form>"; |
||
| 59 | |||
| 60 | $vats = array(); |
||
| 61 | $vats = $h_oledrion_vat->getAllVats(new Oledrion_parameters()); |
||
| 62 | |||
| 63 | $start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
||
| 64 | |||
| 65 | $filter_product_id = $filter_product_cid = $filter_product_recommended = $filter_product_price = $filter_product_online = 0; |
||
| 66 | |||
| 67 | // B.R. New |
||
| 68 | // TODO: Code Reviewers Are these filters neccessary? Not sure what they do. |
||
| 69 | $filter_skip_packing = $filter_skip_location = $filter_skip_delivery = 0; |
||
| 70 | // B.R. End |
||
| 71 | $filter_product_title = $filter_product_sku = ''; |
||
| 72 | |||
| 73 | $newFilter = false; |
||
| 74 | $criteria = new CriteriaCompo(); |
||
| 75 | $criteria->add(new Criteria('product_id', 0, '<>')); |
||
| 76 | |||
| 77 | View Code Duplication | if (isset($_POST['filter_product_id'])) { |
|
| 78 | if ((int)$_POST['filter_product_id'] != 0) { |
||
| 79 | $criteria->add(new Criteria('product_id', (int)$_POST['filter_product_id']), '='); |
||
| 80 | } |
||
| 81 | $filter_product_id = (int)$_POST['filter_product_id']; |
||
| 82 | $newFilter = true; |
||
| 83 | } |
||
| 84 | View Code Duplication | if (isset($_POST['filter_product_cid']) && (int)$_POST['filter_product_cid'] != 0) { |
|
| 85 | $criteria->add(new Criteria('product_cid', (int)$_POST['filter_product_cid']), '='); |
||
| 86 | $filter_product_cid = (int)$_POST['filter_product_cid']; |
||
| 87 | $newFilter = true; |
||
| 88 | } |
||
| 89 | if (isset($_POST['filter_product_recommended']) && (int)$_POST['filter_product_recommended'] != 0) { |
||
| 90 | if ((int)$_POST['filter_product_recommended'] == 1) { |
||
| 91 | $criteria->add(new Criteria('product_recommended', '0000-00-00', '<>')); |
||
| 92 | } else { |
||
| 93 | $criteria->add(new Criteria('product_recommended', '0000-00-00', '=')); |
||
| 94 | } |
||
| 95 | $filter_product_recommended = (int)$_POST['filter_product_recommended']; |
||
| 96 | $newFilter = true; |
||
| 97 | } |
||
| 98 | View Code Duplication | if (isset($_POST['filter_product_title']) && xoops_trim($_POST['filter_product_title']) != '') { |
|
| 99 | $criteria->add(new Criteria('product_title', '%' . $_POST['filter_product_title'] . '%', 'LIKE')); |
||
| 100 | $filter_product_title = $_POST['filter_product_title']; |
||
| 101 | $newFilter = true; |
||
| 102 | } |
||
| 103 | View Code Duplication | if (isset($_POST['filter_product_sku']) && xoops_trim($_POST['filter_product_sku']) != '') { |
|
| 104 | $criteria->add(new Criteria('product_sku', '%' . $_POST['filter_product_sku'] . '%', 'LIKE')); |
||
| 105 | $filter_product_sku = $_POST['filter_product_sku']; |
||
| 106 | $newFilter = true; |
||
| 107 | } |
||
| 108 | View Code Duplication | if (isset($_POST['filter_product_online']) && (int)$_POST['filter_product_online'] != 0) { |
|
| 109 | $criteria->add(new Criteria('product_online', (int)$_POST['filter_product_online'] - 1, '=')); |
||
| 110 | $filter_product_online = (int)$_POST['filter_product_online']; |
||
| 111 | $newFilter = true; |
||
| 112 | } |
||
| 113 | View Code Duplication | if (isset($_POST['filter_product_price']) && (int)$_POST['filter_product_price'] != 0) { |
|
| 114 | $criteria->add(new Criteria('product_price', (int)$_POST['filter_product_price']), '>='); |
||
| 115 | $filter_product_price = (int)$_POST['filter_product_price']; |
||
| 116 | $newFilter = true; |
||
| 117 | } |
||
| 118 | // B.R. Added: $filter_skip_packing $filter_skip_location $filter_skip_delivery |
||
| 119 | if ($filter_product_id == 0 |
||
| 120 | && $filter_product_cid == 0 |
||
| 121 | && $filter_product_recommended == 0 |
||
| 122 | && $filter_product_price == 0 |
||
| 123 | && $filter_product_online == 0 |
||
| 124 | && $filter_product_title == '' |
||
| 125 | && $filter_product_sku == '' |
||
| 126 | && $filter_skip_packing == 0 |
||
| 127 | && $filter_skip_location == 0 |
||
| 128 | && $filter_skip_delivery == 0) { |
||
| 129 | $newFilter = true; |
||
| 130 | } |
||
| 131 | |||
| 132 | if (!$newFilter && isset($_SESSION['oledrion_filter'])) { |
||
| 133 | $criteria = unserialize($_SESSION['oledrion_filter']); |
||
| 134 | $filter_product_id = $_SESSION['filter_product_id']; |
||
| 135 | $filter_product_cid = $_SESSION['filter_product_cid']; |
||
| 136 | $filter_product_recommended = $_SESSION['filter_product_recommended']; |
||
| 137 | $filter_product_title = $_SESSION['filter_product_title']; |
||
| 138 | $filter_product_sku = $_SESSION['filter_product_sku']; |
||
| 139 | $filter_product_online = $_SESSION['filter_product_online']; |
||
| 140 | $filter_product_price = $_SESSION['filter_product_price']; |
||
| 141 | // B.R. New |
||
| 142 | $filter_skip_packing = $_SESSION['filter_skip_packing']; |
||
| 143 | $filter_skip_location = $_SESSION['filter_skip_location']; |
||
| 144 | $filter_skip_delivery = $_SESSION['filter_skip_delivery']; |
||
| 145 | // B.R. End |
||
| 146 | } |
||
| 147 | |||
| 148 | $_SESSION['oledrion_filter'] = serialize($criteria); |
||
| 149 | $_SESSION['filter_product_id'] = $filter_product_id; |
||
| 150 | $_SESSION['filter_product_cid'] = $filter_product_cid; |
||
| 151 | $_SESSION['filter_product_recommended'] = $filter_product_recommended; |
||
| 152 | $_SESSION['filter_product_title'] = $filter_product_title; |
||
| 153 | $_SESSION['filter_product_sku'] = $filter_product_sku; |
||
| 154 | $_SESSION['filter_product_online'] = $filter_product_online; |
||
| 155 | $_SESSION['filter_product_price'] = $filter_product_price; |
||
| 156 | // B.R. New |
||
| 157 | $_SESSION['filter_skip_packing'] = $filter_skip_packing; |
||
| 158 | $_SESSION['filter_skip_location'] = $filter_skip_location; |
||
| 159 | $_SESSION['filter_skip_delivery'] = $filter_skip_delivery; |
||
| 160 | // B.R. End |
||
| 161 | |||
| 162 | $itemsCount = $h_oledrion_products->getCount($criteria); // Recherche du nombre total de produits répondants aux critères |
||
| 163 | OledrionUtility::htitle(_MI_OLEDRION_ADMENU4 . ' (' . $itemsCount . ')', 4); |
||
| 164 | |||
| 165 | if ($itemsCount > $limit) { |
||
| 166 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
| 167 | $pagenav = new XoopsPageNav($itemsCount, $limit, $start, 'start', 'op=products'); |
||
| 168 | } |
||
| 169 | $mytree = new XoopsObjectTree($categories, 'cat_cid', 'cat_pid'); |
||
| 170 | |||
| 171 | View Code Duplication | if (OledrionUtility::checkVerXoops($module, '2.5.9')) { |
|
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 172 | $selectCateg0 = $mytree->makeSelectElement('filter_product_cid', 'cat_title', '-', $filter_product_cid, true, 0, '', ''); |
||
| 173 | $selectCateg = $selectCateg0->render(); |
||
| 174 | } else { |
||
| 175 | $selectCateg = $mytree->makeSelBox('filter_product_cid', 'cat_title', '-', $filter_product_cid, '---', 0, "style='width: 170px; max-width: 170px;'"); |
||
| 176 | } |
||
| 177 | |||
| 178 | $onlineSelect = OledrionUtility::htmlSelect('filter_product_online', array(2 => _YES, 1 => _NO), $filter_product_online); |
||
| 179 | // B.R. New |
||
| 180 | $skipPackingSelect = OledrionUtility::htmlSelect('filter_skip_packing', array(2 => _YES, 1 => _NO), $filter_skip_packing); |
||
| 181 | $skipLocationSelect = OledrionUtility::htmlSelect('filter_skip_location', array(2 => _YES, 1 => _NO), $filter_skip_location); |
||
| 182 | $skipDeliverySelect = OledrionUtility::htmlSelect('filter_skip_delivery', array(2 => _YES, 1 => _NO), $filter_skip_delivery); |
||
| 183 | // B.R. End |
||
| 184 | $recommendedSelect = OledrionUtility::htmlSelect('filter_product_recommended', array(1 => _YES, 2 => _NO), $filter_product_recommended); |
||
| 185 | |||
| 186 | $criteria->setLimit($limit); |
||
| 187 | $criteria->setStart($start); |
||
| 188 | $criteria->setSort('product_id'); |
||
| 189 | |||
| 190 | $products = $h_oledrion_products->getObjects($criteria); |
||
| 191 | $class = ''; |
||
| 192 | $span = 8; |
||
| 193 | if (isset($pagenav) && is_object($pagenav)) { |
||
| 194 | echo "<div align='left'>" . $pagenav->renderNav() . '</div>'; |
||
| 195 | } |
||
| 196 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
||
| 197 | echo "<tr><th align='center'>" |
||
| 198 | . _AM_OLEDRION_ID |
||
| 199 | . "</th><th align='center'>" |
||
| 200 | . _OLEDRION_TITLE |
||
| 201 | . "</th><th align='center'>" |
||
| 202 | . _OLEDRION_CATEGORY |
||
| 203 | . "</th><th align='center'>" |
||
| 204 | . _OLEDRION_NUMBER |
||
| 205 | . '<br>' |
||
| 206 | . _OLEDRION_EXTRA_ID |
||
| 207 | . "</th><th align='center'>" |
||
| 208 | . _OLEDRION_ONLINE |
||
| 209 | . "</th><th align='center'>" |
||
| 210 | . _AM_OLEDRION_RECOMMENDED |
||
| 211 | . "</th><th align='center'>" |
||
| 212 | . _OLEDRION_DATE |
||
| 213 | . '</th>'; |
||
| 214 | if (OledrionUtility::getModuleOption('use_price')) { |
||
| 215 | echo "<th align='center'>" . _OLEDRION_PRICE . '</th>'; |
||
| 216 | $span = 9; |
||
| 217 | } |
||
| 218 | echo "<th align='center'>" . _AM_OLEDRION_ACTION . '</th></tr>'; |
||
| 219 | |||
| 220 | echo "<tr><form method='post' action='$baseurl'><th align='center'><input type='text' size='3' name='filter_product_id' id='filter_product_id' value='$filter_product_id'></th>\n"; |
||
| 221 | echo "<th align='center'><input type='text' size='25' name='filter_product_title' id='filter_product_title' value='$filter_product_title'></th>\n"; |
||
| 222 | echo "<th align='center'>" . $selectCateg . "</th>\n"; |
||
| 223 | echo "<th align='center'><input type='text' size='25' name='filter_product_sku' id='filter_product_sku' value='$filter_product_sku'></th>\n"; |
||
| 224 | echo "<th align='center'>" . $onlineSelect . "</th>\n"; |
||
| 225 | // B.R. Start |
||
| 226 | echo "<th align='center'>" . $skipPackingSelect . "</th>\n"; |
||
| 227 | echo "<th align='center'>" . $skipLocationSelect . "</th>\n"; |
||
| 228 | echo "<th align='center'>" . $skipDeliverySelect . "</th>\n"; |
||
| 229 | // B.R. End |
||
| 230 | echo "<th align='center'>" . $recommendedSelect . "</th>\n"; |
||
| 231 | echo "<th align='center'> </th>\n"; |
||
| 232 | echo "<th align='center'><input type='text' size='5' name='filter_product_price' id='filter_product_price' value='$filter_product_price'></th>\n"; |
||
| 233 | echo "<th align='center'><input type='hidden' name='op' id='op' value='products'><input type='submit' name='btngo' id='btngo' value='" . _GO . "'></th></form></tr>\n"; |
||
| 234 | foreach ($products as $item) { |
||
| 235 | $class = ($class === 'even') ? 'odd' : 'even'; |
||
| 236 | $id = $item->getVar('product_id'); |
||
| 237 | $recommended = ''; |
||
| 238 | if ($item->isRecommended()) { // Si le produit est recommandé, on affiche le lien qui permet d'arrêter de le recommander |
||
| 239 | $recommended = "<a href='" . $baseurl . '?op=products&action=unrecommend&product_id=' . $id . "' title='" . _AM_OLEDRION_DONOTRECOMMEND_IT . "'><img alt='" . _AM_OLEDRION_DONOTRECOMMEND_IT . "' src='" . OLEDRION_IMAGES_URL . "heart_delete.png' alt=''></a>"; |
||
| 240 | } else { // Sinon on affiche le lien qui permet de le recommander |
||
| 241 | $recommended = "<a href='" . $baseurl . '?op=products&action=recommend&product_id=' . $id . "' title='" . _AM_OLEDRION_RECOMMEND_IT . "'><img alt='" . _AM_OLEDRION_RECOMMEND_IT . "' src='" . OLEDRION_IMAGES_URL . "heart_add.png' alt=''></a>"; |
||
| 242 | } |
||
| 243 | |||
| 244 | $actions = array(); |
||
| 245 | |||
| 246 | $actions[] = "<a href='$baseurl?op=products&action=related&id=" . $id . "' title='" . _OLEDRION_RELATED_PRODUCTS . "'>" . $icones['details'] . '</a>'; |
||
| 247 | |||
| 248 | $actions[] = "<a href='$baseurl?op=products&action=edit&id=" . $id . "' title='" . _OLEDRION_EDIT . "'>" . $icones['edit'] . '</a>'; |
||
| 249 | $actions[] = "<a href='$baseurl?op=products&action=copy&id=" . $id . "' title='" . _OLEDRION_DUPLICATE_PRODUCT . "'>" . $icones['copy'] . '</a>'; |
||
| 250 | $actions[] = "<a href='$baseurl?op=products&action=confdelete&id=" . $id . "' title='" . _OLEDRION_DELETE . "'>" . $icones['delete'] . '</a>'; |
||
| 251 | $online = $item->getVar('product_online') == 1 ? _YES : _NO; |
||
| 252 | // B.R. New |
||
| 253 | $skipPacking = $item->getVar('skip_packing') == 1 ? _YES : _NO; |
||
| 254 | $skipLocation = $item->getVar('skip_location') == 1 ? _YES : _NO; |
||
| 255 | $skipDelivery = $item->getVar('skip_delivery') == 1 ? _YES : _NO; |
||
| 256 | // B.R. End |
||
| 257 | echo "<tr class='" . $class . "'>\n"; |
||
| 258 | if (isset($categories[$item->getVar('product_cid')])) { |
||
| 259 | $productCategory = $categories[$item->getVar('product_cid')]->getVar('cat_title'); |
||
| 260 | $categoryUrl = $categories[$item->getVar('product_cid')]->getLink(); |
||
| 261 | } else { |
||
| 262 | $productCategory = ''; |
||
| 263 | $categoryUrl = '#'; |
||
| 264 | } |
||
| 265 | $productLink = "<a href='" . $item->getLink() . "' target='blank'>" . $item->getVar('product_title') . '</a>'; |
||
| 266 | if ((float)$item->getVar('product_discount_price') > 0) { |
||
| 267 | $priceLine = '<s>' . $oledrion_Currency->amountForDisplay($item->getVar('product_price')) . '</s> ' . $oledrion_Currency->amountForDisplay($item->getVar('product_discount_price')); |
||
| 268 | } else { |
||
| 269 | $priceLine = $oledrion_Currency->amountForDisplay($item->getVar('product_price')); |
||
| 270 | } |
||
| 271 | |||
| 272 | echo "<td align='center'>" |
||
| 273 | . $id |
||
| 274 | . "</td><td align ='left'>" |
||
| 275 | . $productLink |
||
| 276 | . "</td><td align='left'><a href='" |
||
| 277 | . $categoryUrl |
||
| 278 | . "' target='blank'>" |
||
| 279 | . $productCategory |
||
| 280 | . "</a></td><td align='center'>" |
||
| 281 | . $item->getVar('product_sku') |
||
| 282 | . ' / ' |
||
| 283 | . $item->getVar('product_extraid') |
||
| 284 | . "</td><td align='center'>" |
||
| 285 | . $online |
||
| 286 | . "</td><td align='center'>" |
||
| 287 | . $recommended |
||
| 288 | . "</td><td align='center'>" |
||
| 289 | . $item->getVar('product_date') |
||
| 290 | . '</td>'; |
||
| 291 | if (OledrionUtility::getModuleOption('use_price')) { |
||
| 292 | echo "<td align='right'>" . $priceLine . '</td>'; |
||
| 293 | } |
||
| 294 | echo "<td align='center'>" . implode(' ', $actions) . "</td>\n"; |
||
| 295 | echo "<tr>\n"; |
||
| 296 | } |
||
| 297 | $class = ($class === 'even') ? 'odd' : 'even'; |
||
| 298 | echo "<tr class='" . $class . "'>\n"; |
||
| 299 | echo "<td colspan='$span' align='center'>" . $form . "</td>\n"; |
||
| 300 | echo "</tr>\n"; |
||
| 301 | echo '</table>'; |
||
| 302 | if (isset($pagenav) && is_object($pagenav)) { |
||
| 303 | echo "<div align='right'>" . $pagenav->renderNav() . '</div>'; |
||
| 304 | } |
||
| 305 | //require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 306 | break; |
||
| 307 | |||
| 308 | // **************************************************************************************************************** |
||
| 309 | View Code Duplication | case 'unrecommend': // Arrêter de recommander un produit |
|
| 310 | // **************************************************************************************************************** |
||
| 311 | $opRedirect = '?op=products'; |
||
| 312 | if (isset($_GET['product_id'])) { |
||
| 313 | $product_id = (int)$_GET['product_id']; |
||
| 314 | $product = null; |
||
| 315 | $product = $h_oledrion_products->get($product_id); |
||
| 316 | if (is_object($product)) { |
||
| 317 | $product->unsetRecommended(); |
||
| 318 | if ($h_oledrion_products->insert($product, true)) { |
||
| 319 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . $opRedirect, 1); |
||
| 320 | } else { |
||
| 321 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . $opRedirect, 4); |
||
| 322 | } |
||
| 323 | } else { |
||
| 324 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . $opRedirect, 4); |
||
| 325 | } |
||
| 326 | } else { |
||
| 327 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . $opRedirect, 4); |
||
| 328 | } |
||
| 329 | break; |
||
| 330 | |||
| 331 | // **************************************************************************************************************** |
||
| 332 | View Code Duplication | case 'recommend': // Recommander un produit |
|
| 333 | // **************************************************************************************************************** |
||
| 334 | $opRedirect = '?op=products'; |
||
| 335 | if (isset($_GET['product_id'])) { |
||
| 336 | $product_id = (int)$_GET['product_id']; |
||
| 337 | $product = null; |
||
| 338 | $product = $h_oledrion_products->get($product_id); |
||
| 339 | if (is_object($product)) { |
||
| 340 | $product->setRecommended(); |
||
| 341 | if ($h_oledrion_products->insert($product, true)) { |
||
| 342 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . $opRedirect, 1); |
||
| 343 | } else { |
||
| 344 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . $opRedirect, 4); |
||
| 345 | } |
||
| 346 | } else { |
||
| 347 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . $opRedirect, 4); |
||
| 348 | } |
||
| 349 | } else { |
||
| 350 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl . $opRedirect, 4); |
||
| 351 | } |
||
| 352 | break; |
||
| 353 | |||
| 354 | // **************************************************************************************************************** |
||
| 355 | case 'add': // Ajout d'un produit |
||
| 356 | case 'edit': // Edition d'un produit |
||
| 357 | // **************************************************************************************************************** |
||
| 358 | xoops_cp_header(); |
||
| 359 | global $xoopsUser; |
||
| 360 | |||
| 361 | if ($action === 'edit') { |
||
| 362 | $title = _AM_OLEDRION_EDIT_PRODUCT; |
||
| 363 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
| 364 | if (empty($id)) { |
||
| 365 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
| 366 | } |
||
| 367 | // Item exits ? |
||
| 368 | $item = null; |
||
| 369 | $item = $h_oledrion_products->get($id); |
||
| 370 | if (!is_object($item)) { |
||
| 371 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
| 372 | } |
||
| 373 | $edit = true; |
||
| 374 | $label_submit = _AM_OLEDRION_MODIFY; |
||
| 375 | } else { |
||
| 376 | $title = _AM_OLEDRION_ADD_PRODUCT; |
||
| 377 | $item = $h_oledrion_products->create(true); |
||
| 378 | $item->setVar('product_online', 1); |
||
| 379 | // B.R. Start |
||
| 380 | $item->setVar('skip_packing', 0); |
||
| 381 | $item->setVar('skip_location', 0); |
||
| 382 | $item->setVar('skip_delivery', 0); |
||
| 383 | // B.R. End |
||
| 384 | if (OLEDRION_AUTO_FILL_MANUAL_DATE) { |
||
| 385 | $item->setVar('product_date', formatTimestamp(time(), 's')); |
||
| 386 | } |
||
| 387 | $label_submit = _AM_OLEDRION_ADD; |
||
| 388 | $edit = false; |
||
| 389 | } |
||
| 390 | |||
| 391 | $categories = $h_oledrion_cat->getAllCategories(new Oledrion_parameters()); |
||
| 392 | if (count($categories) == 0) { |
||
| 393 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_8, $baseurl, 5); |
||
| 394 | } |
||
| 395 | // TVA |
||
| 396 | $vats = $vatsForDisplay = array(); |
||
| 397 | $vats = $h_oledrion_vat->getAllVats(new Oledrion_parameters()); |
||
| 398 | if (count($vats) == 0 && OledrionUtility::getModuleOption('use_price')) { |
||
| 399 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_9, $baseurl, 5); |
||
| 400 | } |
||
| 401 | foreach ($vats as $onevat) { |
||
| 402 | $vatsForDisplay[$onevat->getVar('vat_id')] = $onevat->getVar('vat_rate'); |
||
| 403 | } |
||
| 404 | |||
| 405 | $mytree = new XoopsObjectTree($categories, 'cat_cid', 'cat_pid'); |
||
| 406 | $select_categ = $mytree->makeSelBox('product_cid', 'cat_title', '-', $item->getVar('product_cid')); |
||
| 407 | |||
| 408 | $sform = new XoopsThemeForm($title, 'frmproduct', $baseurl); |
||
| 409 | $sform->setExtra('enctype="multipart/form-data"'); |
||
| 410 | $sform->addElement(new XoopsFormHidden('op', 'products')); |
||
| 411 | $sform->addElement(new XoopsFormHidden('action', 'saveedit')); |
||
| 412 | $sform->addElement(new XoopsFormHidden('product_id', $item->getVar('product_id'))); |
||
| 413 | $sform->addElement(new XoopsFormHidden('product_submitter', $xoopsUser->getVar('uid'))); |
||
| 414 | |||
| 415 | $sform->addElement(new XoopsFormText(_OLEDRION_TITLE, 'product_title', 50, 255, $item->getVar('product_title', 'e')), true); |
||
| 416 | |||
| 417 | // Vendeurs ************************************************************* |
||
| 418 | $vendors = $vendorsForDisplay = array(); |
||
| 419 | $vendors = $h_oledrion_vendors->getAllVendors(new Oledrion_parameters()); |
||
| 420 | foreach ($vendors as $oneVendor) { |
||
| 421 | $vendorsForDisplay[$oneVendor->getVar('vendor_id')] = $oneVendor->getVar('vendor_name'); |
||
| 422 | } |
||
| 423 | $vendorsSelect = new XoopsFormSelect(_OLEDRION_VENDOR, 'product_vendor_id', $item->getVar('product_vendor_id')); |
||
| 424 | $vendorsSelect->addOptionArray($vendorsForDisplay); |
||
| 425 | $sform->addElement($vendorsSelect, true); |
||
| 426 | |||
| 427 | View Code Duplication | if (OledrionUtility::checkVerXoops($module, '2.5.9')) { |
|
|
0 ignored issues
–
show
The method
checkVerXoops() does not seem to exist on object<OledrionUtility>.
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. Loading history...
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. Loading history...
|
|||
| 428 | $select_categ = $mytree->makeSelectElement('product_cid', 'cat_title', '-', $item->getVar('product_cid'), true, 0, '', _AM_OLEDRION_CATEG_HLP); |
||
| 429 | $form->addElement($select_categ); |
||
| 430 | } else { |
||
| 431 | $select_categ = $mytree->makeSelBox('product_cid', 'cat_title', '-', $item->getVar('product_cid')); |
||
| 432 | $sform->addElement(new XoopsFormLabel(_AM_OLEDRION_CATEG_HLP, $select_categ), true); |
||
| 433 | } |
||
| 434 | // B.R. New |
||
| 435 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_SKIP_PACKING, 'skip_packing', $item->getVar('skip_packing')), true); |
||
| 436 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_SKIP_LOCATION, 'skip_location', $item->getVar('skip_location')), true); |
||
| 437 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_SKIP_DELIVERY, 'skip_delivery', $item->getVar('skip_delivery')), true); |
||
| 438 | // End New |
||
| 439 | |||
| 440 | $deliveryTime = new XoopsFormText(_OLEDRION_DELIVERY_TIME, 'product_delivery_time', 5, 5, $item->getVar('product_delivery_time', 'e')); |
||
| 441 | $deliveryTime->setDescription(_OLEDRION_IN_DAYS); |
||
| 442 | $sform->addElement($deliveryTime, false); |
||
| 443 | |||
| 444 | $sform->addElement(new XoopsFormText(_OLEDRION_NUMBER, 'product_sku', 10, 60, $item->getVar('product_sku', 'e')), false); |
||
| 445 | $sform->addElement(new XoopsFormText(_OLEDRION_EXTRA_ID, 'product_extraid', 10, 50, $item->getVar('product_extraid', 'e')), false); |
||
| 446 | $sform->addElement(new XoopsFormText(_OLEDRION_LENGTH, 'product_length', 10, 50, $item->getVar('product_length', 'e')), false); |
||
| 447 | $sform->addElement(new XoopsFormText(_OLEDRION_WIDTH, 'product_width', 10, 50, $item->getVar('product_width', 'e')), false); |
||
| 448 | |||
| 449 | $sform->addElement(new XoopsFormText(_OLEDRION_MEASURE1, 'product_unitmeasure1', 10, 20, $item->getVar('product_unitmeasure1', 'e')), false); |
||
| 450 | $sform->addElement(new XoopsFormText(_OLEDRION_WEIGHT, 'product_weight', 10, 20, $item->getVar('product_weight', 'e')), false); |
||
| 451 | $sform->addElement(new XoopsFormText(_OLEDRION_MEASURE2, 'product_unitmeasure2', 10, 20, $item->getVar('product_unitmeasure2', 'e')), false); |
||
| 452 | |||
| 453 | $downloadUrl = new XoopsFormText(_OLEDRION_DOWNLOAD_URL, 'product_download_url', 50, 255, $item->getVar('product_download_url', 'e')); |
||
| 454 | $downloadUrl->setDescription(_AM_OLEDRION_DOWNLOAD_EXAMPLE . ' ' . XOOPS_UPLOAD_PATH . '/' . 'image.png'); |
||
| 455 | $sform->addElement($downloadUrl, false); |
||
| 456 | |||
| 457 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_URL_HLP1, 'product_url', 50, 255, $item->getVar('product_url', 'e')), false); |
||
| 458 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_URL_HLP2, 'product_url2', 50, 255, $item->getVar('product_url2', 'e')), false); |
||
| 459 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_URL_HLP3, 'product_url3', 50, 255, $item->getVar('product_url3', 'e')), false); |
||
| 460 | |||
| 461 | // Images ************************************************************* |
||
| 462 | View Code Duplication | if ($action === 'edit' && $item->pictureExists()) { |
|
| 463 | $pictureTray = new XoopsFormElementTray(_AM_OLEDRION_IMAGE1_HELP, '<br>'); |
||
| 464 | $pictureTray->addElement(new XoopsFormLabel('', "<img src='" . $item->getPictureUrl() . "' alt='' border='0'>")); |
||
| 465 | $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture1'); |
||
| 466 | $deleteCheckbox->addOption(1, _DELETE); |
||
| 467 | $pictureTray->addElement($deleteCheckbox); |
||
| 468 | $sform->addElement($pictureTray); |
||
| 469 | unset($pictureTray, $deleteCheckbox); |
||
| 470 | } |
||
| 471 | $sform->addElement(new XoopsFormFile(_AM_OLEDRION_IMAGE1_CHANGE, 'attachedfile1', OledrionUtility::getModuleOption('maxuploadsize')), false); |
||
| 472 | |||
| 473 | if (!OledrionUtility::getModuleOption('create_thumbs')) { // L'utilisateur se charge de créer la vignette lui même |
||
| 474 | View Code Duplication | if ($action === 'edit' && $item->thumbExists()) { |
|
| 475 | $pictureTray = new XoopsFormElementTray(_AM_OLEDRION_IMAGE2_HELP, '<br>'); |
||
| 476 | $pictureTray->addElement(new XoopsFormLabel('', "<img src='" . $item->getThumbUrl() . "' alt='' border='0'>")); |
||
| 477 | $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture2'); |
||
| 478 | $deleteCheckbox->addOption(1, _DELETE); |
||
| 479 | $pictureTray->addElement($deleteCheckbox); |
||
| 480 | $sform->addElement($pictureTray); |
||
| 481 | unset($pictureTray, $deleteCheckbox); |
||
| 482 | } |
||
| 483 | $sform->addElement(new XoopsFormFile(_AM_OLEDRION_IMAGE2_CHANGE, 'attachedfile2', OledrionUtility::getModuleOption('maxuploadsize')), false); |
||
| 484 | } |
||
| 485 | |||
| 486 | // En ligne ? ********************************************************* |
||
| 487 | $sform->addElement(new XoopsFormRadioYN(_OLEDRION_ONLINE_HLP, 'product_online', $item->getVar('product_online')), true); |
||
| 488 | $sform->addElement(new XoopsFormText(_OLEDRION_DATE, 'product_date', 50, 255, $item->getVar('product_date', 'e')), false); |
||
| 489 | |||
| 490 | $date_submit = new XoopsFormTextDateSelect(_OLEDRION_DATE_SUBMIT, 'product_submitted', 15, $item->getVar('product_submitted', 'e')); |
||
| 491 | $date_submit->setDescription(_AM_OLEDRION_SUBDATE_HELP); |
||
| 492 | $sform->addElement($date_submit, false); |
||
| 493 | |||
| 494 | $sform->addElement(new XoopsFormHidden('product_hits', $item->getVar('product_hits'))); |
||
| 495 | $sform->addElement(new XoopsFormHidden('product_rating', $item->getVar('product_rating'))); |
||
| 496 | $sform->addElement(new XoopsFormHidden('product_votes', $item->getVar('product_votes'))); |
||
| 497 | $sform->addElement(new XoopsFormHidden('product_comments', $item->getVar('product_comments'))); |
||
| 498 | |||
| 499 | // Fabricants ************************************************************ |
||
| 500 | $manufacturers = $productsManufacturers = $manufacturers_d = $productsManufacturers_d = array(); |
||
| 501 | // Recherche de tous les fabricants |
||
| 502 | $criteria = new Criteria('manu_id', 0, '<>'); |
||
| 503 | $criteria->setSort('manu_name'); |
||
| 504 | $manufacturers = $h_oledrion_manufacturer->getObjects($criteria); |
||
| 505 | foreach ($manufacturers as $oneitem) { |
||
| 506 | $manufacturers_d[$oneitem->getVar('manu_id')] = xoops_trim($oneitem->getVar('manu_name')) . ' ' . xoops_trim($oneitem->getVar('manu_commercialname')); |
||
| 507 | } |
||
| 508 | // Recherche des fabricants de ce produit |
||
| 509 | View Code Duplication | if ($edit) { |
|
| 510 | $criteria = new CriteriaCompo(); |
||
| 511 | $criteria->add(new Criteria('pm_product_id', $item->getVar('product_id'), '=')); |
||
| 512 | $productsManufacturers = $h_oledrion_productsmanu->getObjects($criteria); |
||
| 513 | foreach ($productsManufacturers as $oneproduct) { |
||
| 514 | $productsManufacturers_d[] = $oneproduct->getVar('pm_manu_id'); |
||
| 515 | } |
||
| 516 | } |
||
| 517 | $manufacturersSelect = new XoopsFormSelect(_OLEDRION_MANUFACTURER, 'manufacturers', $productsManufacturers_d, 5, true); |
||
| 518 | $manufacturersSelect->addOptionArray($manufacturers_d); |
||
| 519 | $manufacturersSelect->setDescription(_AM_OLEDRION_SELECT_HLP); |
||
| 520 | $sform->addElement($manufacturersSelect, true); |
||
| 521 | |||
| 522 | // Produits relatifs **************************************************** |
||
| 523 | $relatedProducts = $productRelated = $relatedProducts_d = $productRelated_d = array(); |
||
| 524 | // Recherche de tous les produits sauf celui-là |
||
| 525 | $criteria = new Criteria('product_id', $item->getVar('product_id'), '<>'); |
||
| 526 | $criteria->setSort('product_title'); |
||
| 527 | $relatedProducts = $h_oledrion_products->getObjects($criteria); |
||
| 528 | foreach ($relatedProducts as $oneitem) { |
||
| 529 | $relatedProducts_d[$oneitem->getVar('product_id')] = xoops_trim($oneitem->getVar('product_title')); |
||
| 530 | } |
||
| 531 | // Recherche des produits relatifs à ce produit |
||
| 532 | View Code Duplication | if ($edit) { |
|
| 533 | $criteria = new CriteriaCompo(); |
||
| 534 | $criteria->add(new Criteria('related_product_id', $item->getVar('product_id'), '=')); |
||
| 535 | $productRelated = $h_oledrion_related->getObjects($criteria); |
||
| 536 | foreach ($productRelated as $oneproduct) { |
||
| 537 | $productRelated_d[] = $oneproduct->getVar('related_product_related'); |
||
| 538 | } |
||
| 539 | } |
||
| 540 | $productsSelect = $h_oledrion_products->productSelector(new Oledrion_parameters(array( |
||
| 541 | 'caption' => _OLEDRION_RELATED_PRODUCTS, |
||
| 542 | 'name' => 'relatedproducts', |
||
| 543 | 'value' => $productRelated_d, |
||
| 544 | 'size' => 5, |
||
| 545 | 'multiple' => true, |
||
| 546 | 'values' => $productRelated_d, |
||
| 547 | 'showAll' => true, |
||
| 548 | 'sort' => 'product_title', |
||
| 549 | 'order' => 'ASC', |
||
| 550 | 'formName' => 'frmproduct' |
||
| 551 | ))); |
||
| 552 | $sform->addElement($productsSelect); |
||
| 553 | // ******************************************************************** |
||
| 554 | |||
| 555 | if (OledrionUtility::getModuleOption('use_price')) { |
||
| 556 | // TVA **************************************************************** |
||
| 557 | $vatSelect = new XoopsFormSelect(_OLEDRION_VAT, 'product_vat_id', $item->getVar('product_vat_id')); |
||
| 558 | $vatSelect->addOptionArray($vatsForDisplay); |
||
| 559 | $sform->addElement($vatSelect, true); |
||
| 560 | |||
| 561 | $sform->addElement(new XoopsFormText(_OLEDRION_PRICE, 'product_price', 20, 20, $item->getVar('product_price', 'e')), true); |
||
| 562 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_DISCOUNT_HLP, 'product_discount_price', 20, 20, $item->getVar('product_discount_price', 'e')), false); |
||
| 563 | |||
| 564 | $sform->addElement(new XoopsFormText(_OLEDRION_SHIPPING_PRICE, 'product_shipping_price', 20, 20, $item->getVar('product_shipping_price', 'e')), false); |
||
| 565 | $sform->addElement(new XoopsFormText(_OLEDRION_ECOTAXE, 'product_ecotaxe', 10, 10, $item->getVar('product_ecotaxe', 'e')), false); |
||
| 566 | } |
||
| 567 | $sform->addElement(new XoopsFormText(_OLEDRION_STOCK_QUANTITY, 'product_stock', 10, 10, $item->getVar('product_stock', 'e')), false); |
||
| 568 | |||
| 569 | $alertStock = new XoopsFormText(_OLEDRION_STOCK_ALERT, 'product_alert_stock', 10, 10, $item->getVar('product_alert_stock', 'e')); |
||
| 570 | $alertStock->setDescription(_AM_OLEDRION_STOCK_HLP); |
||
| 571 | $sform->addElement($alertStock, false); |
||
| 572 | |||
| 573 | $editor2 = OledrionUtility::getWysiwygForm(_OLEDRION_SUMMARY, 'product_summary', $item->getVar('product_summary', 'e'), 15, 60, 'summary_hidden'); |
||
| 574 | if ($editor2) { |
||
| 575 | $sform->addElement($editor2, false); |
||
| 576 | } |
||
| 577 | |||
| 578 | $editor = OledrionUtility::getWysiwygForm(_OLEDRION_DESCRIPTION, 'product_description', $item->getVar('product_description', 'e'), 15, 60, 'description_hidden'); |
||
| 579 | if ($editor) { |
||
| 580 | $sform->addElement($editor, false); |
||
| 581 | } |
||
| 582 | |||
| 583 | // Tags |
||
| 584 | if (OledrionUtility::getModuleOption('use_tags')) { |
||
| 585 | require_once XOOPS_ROOT_PATH . '/modules/tag/include/formtag.php'; |
||
| 586 | $sform->addElement(new TagFormTag('item_tag', 60, 255, $item->getVar('product_id'), 0)); |
||
| 587 | } |
||
| 588 | |||
| 589 | // META Data |
||
| 590 | View Code Duplication | if ($manual_meta) { |
|
| 591 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_META_KEYWORDS, 'product_metakeywords', 50, 255, $item->getVar('product_metakeywords', 'e')), false); |
||
| 592 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_META_DESCRIPTION, 'product_metadescription', 50, 255, $item->getVar('product_metadescription', 'e')), false); |
||
| 593 | $sform->addElement(new XoopsFormText(_AM_OLEDRION_META_PAGETITLE, 'product_metatitle', 50, 255, $item->getVar('product_metatitle', 'e')), false); |
||
| 594 | } |
||
| 595 | // Fichier attaché |
||
| 596 | if ($action === 'edit' && trim($item->getVar('product_attachment')) != '' |
||
| 597 | && file_exists(XOOPS_UPLOAD_PATH . '/' . trim($item->getVar('product_attachment')))) { |
||
| 598 | $pictureTray = new XoopsFormElementTray(_OLEDRION_ATTACHED_FILE, '<br>'); |
||
| 599 | $pictureTray->addElement(new XoopsFormLabel('', "<a href='" . XOOPS_UPLOAD_URL . '/' . $item->getVar('product_attachment') . "' target='_blank'>" . XOOPS_UPLOAD_URL . '/' . $item->getVar('product_attachment') . '</a>')); |
||
| 600 | $deleteCheckbox = new XoopsFormCheckBox('', 'delpicture3'); |
||
| 601 | $deleteCheckbox->addOption(1, _DELETE); |
||
| 602 | $pictureTray->addElement($deleteCheckbox); |
||
| 603 | $sform->addElement($pictureTray); |
||
| 604 | unset($pictureTray, $deleteCheckbox); |
||
| 605 | } |
||
| 606 | $downloadFile = new XoopsFormFile(_OLEDRION_ATTACHED_FILE, 'attachedfile3', OledrionUtility::getModuleOption('maxuploadsize')); |
||
| 607 | $downloadFile->setDescription(_AM_OLEDRION_ATTACHED_HLP); |
||
| 608 | $sform->addElement($downloadFile, false); |
||
| 609 | |||
| 610 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property1')) { |
|
| 611 | $property1select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property1_title'), 'product_property1', $item->getVar('product_property1')); |
||
| 612 | $property1Array = explode('|', OledrionUtility::getModuleOption('product_property1')); |
||
| 613 | foreach ($property1Array as $property1) { |
||
| 614 | $property1select->addOption($property1); |
||
| 615 | } |
||
| 616 | $sform->addElement($property1select, false); |
||
| 617 | } |
||
| 618 | |||
| 619 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property2')) { |
|
| 620 | $property2select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property2_title'), 'product_property2', $item->getVar('product_property2')); |
||
| 621 | $property2Array = explode('|', OledrionUtility::getModuleOption('product_property2')); |
||
| 622 | foreach ($property2Array as $property2) { |
||
| 623 | $property2select->addOption($property2); |
||
| 624 | } |
||
| 625 | $sform->addElement($property2select, false); |
||
| 626 | } |
||
| 627 | |||
| 628 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property3')) { |
|
| 629 | $property3select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property3_title'), 'product_property3', $item->getVar('product_property3')); |
||
| 630 | $property3Array = explode('|', OledrionUtility::getModuleOption('product_property3')); |
||
| 631 | foreach ($property3Array as $property3) { |
||
| 632 | $property3select->addOption($property3); |
||
| 633 | } |
||
| 634 | $sform->addElement($property3select, false); |
||
| 635 | } |
||
| 636 | |||
| 637 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property4')) { |
|
| 638 | $property4select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property4_title'), 'product_property4', $item->getVar('product_property4')); |
||
| 639 | $property4Array = explode('|', OledrionUtility::getModuleOption('product_property4')); |
||
| 640 | foreach ($property4Array as $property4) { |
||
| 641 | $property4select->addOption($property4); |
||
| 642 | } |
||
| 643 | $sform->addElement($property4select, false); |
||
| 644 | } |
||
| 645 | |||
| 646 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property5')) { |
|
| 647 | $property5select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property5_title'), 'product_property5', $item->getVar('product_property5')); |
||
| 648 | $property5Array = explode('|', OledrionUtility::getModuleOption('product_property5')); |
||
| 649 | foreach ($property5Array as $property5) { |
||
| 650 | $property5select->addOption($property5); |
||
| 651 | } |
||
| 652 | $sform->addElement($property5select, false); |
||
| 653 | } |
||
| 654 | |||
| 655 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property6')) { |
|
| 656 | $property6select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property6_title'), 'product_property6', $item->getVar('product_property6')); |
||
| 657 | $property6Array = explode('|', OledrionUtility::getModuleOption('product_property6')); |
||
| 658 | foreach ($property6Array as $property6) { |
||
| 659 | $property6select->addOption($property6); |
||
| 660 | } |
||
| 661 | $sform->addElement($property6select, false); |
||
| 662 | } |
||
| 663 | |||
| 664 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property7')) { |
|
| 665 | $property7select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property7_title'), 'product_property7', $item->getVar('product_property7')); |
||
| 666 | $property7Array = explode('|', OledrionUtility::getModuleOption('product_property7')); |
||
| 667 | foreach ($property7Array as $property7) { |
||
| 668 | $property7select->addOption($property7); |
||
| 669 | } |
||
| 670 | $sform->addElement($property7select, false); |
||
| 671 | } |
||
| 672 | |||
| 673 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property8')) { |
|
| 674 | $property8select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property8_title'), 'product_property8', $item->getVar('product_property8')); |
||
| 675 | $property8Array = explode('|', OledrionUtility::getModuleOption('product_property8')); |
||
| 676 | foreach ($property8Array as $property8) { |
||
| 677 | $property8select->addOption($property8); |
||
| 678 | } |
||
| 679 | $sform->addElement($property8select, false); |
||
| 680 | } |
||
| 681 | |||
| 682 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property9')) { |
|
| 683 | $property9select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property9_title'), 'product_property9', $item->getVar('product_property9')); |
||
| 684 | $property9Array = explode('|', OledrionUtility::getModuleOption('product_property9')); |
||
| 685 | foreach ($property9Array as $property9) { |
||
| 686 | $property9select->addOption($property95); |
||
| 687 | } |
||
| 688 | $sform->addElement($property9select, false); |
||
| 689 | } |
||
| 690 | |||
| 691 | View Code Duplication | if (OledrionUtility::getModuleOption('product_property10')) { |
|
| 692 | $property10select = new XoopsFormSelect(OledrionUtility::getModuleOption('product_property10_title'), 'product_property10', $item->getVar('product_property10')); |
||
| 693 | $property10Array = explode('|', OledrionUtility::getModuleOption('product_property10')); |
||
| 694 | foreach ($property10Array as $property10) { |
||
| 695 | $property10select->addOption($property10); |
||
| 696 | } |
||
| 697 | $sform->addElement($property10select, false); |
||
| 698 | } |
||
| 699 | |||
| 700 | $button_tray = new XoopsFormElementTray('', ''); |
||
| 701 | $submit_btn = new XoopsFormButton('', 'post', $label_submit, 'submit'); |
||
| 702 | $button_tray->addElement($submit_btn); |
||
| 703 | $sform->addElement($button_tray); |
||
| 704 | |||
| 705 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
| 706 | $sform->display(); |
||
| 707 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 708 | break; |
||
| 709 | |||
| 710 | // **************************************************************************************************************** |
||
| 711 | case 'saveedit': // Sauvegarde des informations d'un produit |
||
| 712 | // **************************************************************************************************************** |
||
| 713 | xoops_cp_header(); |
||
| 714 | $id = isset($_POST['product_id']) ? (int)$_POST['product_id'] : 0; |
||
| 715 | View Code Duplication | if ($id > 0) { |
|
| 716 | $edit = true; |
||
| 717 | $item = $h_oledrion_products->get($id); |
||
| 718 | if (!is_object($item)) { |
||
| 719 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
| 720 | } |
||
| 721 | $item->unsetNew(); |
||
| 722 | $add = false; |
||
| 723 | } else { |
||
| 724 | $item = $h_oledrion_products->create(true); |
||
| 725 | $edit = false; |
||
| 726 | $add = true; |
||
| 727 | } |
||
| 728 | $opRedirect = 'products'; |
||
| 729 | $item->setVars($_POST); |
||
| 730 | $item->setVar('product_submitted', strtotime($_POST['product_submitted'])); |
||
| 731 | |||
| 732 | // Suppression de l'image principale |
||
| 733 | if (isset($_POST['delpicture1']) && (int)$_POST['delpicture1'] == 1) { |
||
| 734 | $item->deletePicture(); |
||
| 735 | } |
||
| 736 | |||
| 737 | // Suppression de la vignette |
||
| 738 | if (isset($_POST['delpicture2']) && (int)$_POST['delpicture2'] == 1) { |
||
| 739 | $item->deleteThumb(); |
||
| 740 | } |
||
| 741 | if (isset($_POST['delpicture3']) && (int)$_POST['delpicture3'] == 1) { |
||
| 742 | $item->deleteAttachment(); |
||
| 743 | } |
||
| 744 | |||
| 745 | // Upload de la grande image |
||
| 746 | $destname = ''; |
||
| 747 | $mainPicture = ''; |
||
| 748 | $res1 = OledrionUtility::uploadFile(0, OLEDRION_PICTURES_PATH); |
||
| 749 | View Code Duplication | if ($res1 === true) { |
|
| 750 | $mainPicture = $destname; |
||
| 751 | if (OledrionUtility::getModuleOption('resize_main')) { // On redimensionne l'image principale |
||
| 752 | OledrionUtility::resizePicture(OLEDRION_PICTURES_PATH . '/' . $destname, OLEDRION_PICTURES_PATH . '/' . $destname, OledrionUtility::getModuleOption('images_width'), OledrionUtility::getModuleOption('images_height'), true); |
||
| 753 | } |
||
| 754 | $item->setVar('product_image_url', basename($destname)); |
||
| 755 | } else { |
||
| 756 | if ($res1 !== false) { |
||
| 757 | echo $res1; |
||
| 758 | } |
||
| 759 | } |
||
| 760 | |||
| 761 | $indiceAttached = 2; |
||
| 762 | // Upload de la vignette |
||
| 763 | if (!OledrionUtility::getModuleOption('create_thumbs')) { // L'utilisateur se charge de créer la vignette lui-même |
||
| 764 | $destname = ''; |
||
| 765 | $res2 = OledrionUtility::uploadFile(1, OLEDRION_PICTURES_PATH); |
||
| 766 | if ($res2 === true) { |
||
| 767 | $item->setVar('product_thumb_url', basename($destname)); |
||
| 768 | } else { |
||
| 769 | if ($res2 !== false) { |
||
| 770 | echo $res2; |
||
| 771 | } |
||
| 772 | } |
||
| 773 | } else { // Il faut créer la vignette pour l'utilisateur |
||
| 774 | $indiceAttached = 1; |
||
| 775 | if (xoops_trim($mainPicture) != '') { |
||
| 776 | $thumbName = OLEDRION_THUMBS_PREFIX . $mainPicture; |
||
| 777 | OledrionUtility::resizePicture(OLEDRION_PICTURES_PATH . '/' . $mainPicture, OLEDRION_PICTURES_PATH . '/' . $thumbName, OledrionUtility::getModuleOption('thumbs_width'), OledrionUtility::getModuleOption('thumbs_height'), true); |
||
| 778 | $item->setVar('product_thumb_url', $thumbName); |
||
| 779 | } |
||
| 780 | } |
||
| 781 | |||
| 782 | // Téléchargement du fichier attaché |
||
| 783 | $destname = ''; |
||
| 784 | $res3 = OledrionUtility::uploadFile($indiceAttached, OLEDRION_ATTACHED_FILES_PATH); |
||
| 785 | if ($res3 === true) { |
||
| 786 | $item->setVar('product_attachment', basename($destname)); |
||
| 787 | } else { |
||
| 788 | if ($res3 !== false) { |
||
| 789 | echo $res3; |
||
| 790 | } |
||
| 791 | } |
||
| 792 | |||
| 793 | $res = $h_oledrion_products->insert($item); |
||
| 794 | if ($res) { |
||
| 795 | if (OledrionUtility::getModuleOption('use_tags')) { |
||
| 796 | $tagHandler = xoops_getModuleHandler('tag', 'tag'); |
||
| 797 | $tagHandler->updateByItem($_POST['item_tag'], $item->getVar('product_id'), $xoopsModule->getVar('dirname'), 0); |
||
| 798 | } |
||
| 799 | |||
| 800 | $id = $item->getVar('product_id'); |
||
| 801 | // Notifications ****************************************************** |
||
| 802 | if (true === $add) { |
||
| 803 | //$plugins = Oledrion_plugins::getInstance(); |
||
| 804 | //$plugins->fireAction(Oledrion_plugins::EVENT_ON_PRODUCT_CREATE, new Oledrion_parameters(array('product' => $item))); |
||
| 805 | } |
||
| 806 | // Gestion des fabricants ************************************************ |
||
| 807 | if ($edit) { |
||
| 808 | // Suppression préalable |
||
| 809 | $criteria = new CriteriaCompo(); |
||
| 810 | $criteria->add(new Criteria('pm_product_id', $id, '=')); |
||
| 811 | $h_oledrion_productsmanu->deleteAll($criteria); |
||
| 812 | } |
||
| 813 | // Puis sauvegarde des données |
||
| 814 | if (isset($_POST['manufacturers'])) { |
||
| 815 | foreach ($_POST['manufacturers'] as $id2) { |
||
| 816 | $item2 = $h_oledrion_productsmanu->create(true); |
||
| 817 | $item2->setVar('pm_product_id', $id); |
||
| 818 | $item2->setVar('pm_manu_id', (int)$id2); |
||
| 819 | $res = $h_oledrion_productsmanu->insert($item2); |
||
| 820 | } |
||
| 821 | } |
||
| 822 | |||
| 823 | // Gestion des produits relatifs **************************************** |
||
| 824 | if ($edit) { |
||
| 825 | // Suppression préalable |
||
| 826 | $criteria = new CriteriaCompo(); |
||
| 827 | $criteria->add(new Criteria('related_product_id', $id, '=')); |
||
| 828 | $h_oledrion_related->deleteAll($criteria); |
||
| 829 | } |
||
| 830 | // Puis sauvegarde des données |
||
| 831 | if (isset($_POST['relatedproducts'])) { |
||
| 832 | foreach ($_POST['relatedproducts'] as $id2) { |
||
| 833 | $item2 = $h_oledrion_related->create(true); |
||
| 834 | $item2->setVar('related_product_id', $id); |
||
| 835 | $item2->setVar('related_product_related', (int)$id2); |
||
| 836 | $res = $h_oledrion_related->insert($item2); |
||
| 837 | } |
||
| 838 | } |
||
| 839 | OledrionUtility::updateCache(); |
||
| 840 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
| 841 | } else { |
||
| 842 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
| 843 | } |
||
| 844 | break; |
||
| 845 | |||
| 846 | // **************************************************************************************************************** |
||
| 847 | View Code Duplication | case 'copy': // Copier un produit |
|
| 848 | // **************************************************************************************************************** |
||
| 849 | xoops_cp_header(); |
||
| 850 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
| 851 | if (empty($id)) { |
||
| 852 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
| 853 | } |
||
| 854 | $opRedirect = 'products'; |
||
| 855 | $product = null; |
||
| 856 | $product = $h_oledrion_products->get($id); |
||
| 857 | if (is_object($product)) { |
||
| 858 | $newProduct = $h_oledrion_products->cloneProduct($product); |
||
| 859 | $newProductId = $newProduct->product_id; |
||
| 860 | if ($newProduct !== false) { |
||
| 861 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect . '&action=edit&id=' . $newProductId, 2); |
||
| 862 | } else { |
||
| 863 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
| 864 | } |
||
| 865 | } |
||
| 866 | break; |
||
| 867 | |||
| 868 | // **************************************************************************************************************** |
||
| 869 | View Code Duplication | case 'confdelete': // Confirmation de la suppression d'un produit |
|
| 870 | // **************************************************************************************************************** |
||
| 871 | xoops_cp_header(); |
||
| 872 | |||
| 873 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
| 874 | if ($id == 0) { |
||
| 875 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
| 876 | } |
||
| 877 | $item = $h_oledrion_products->get($id); |
||
| 878 | if (!is_object($item)) { |
||
| 879 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
| 880 | } |
||
| 881 | xoops_confirm(array('op' => 'products', 'action' => 'delete', 'id' => $id), 'index.php', _AM_OLEDRION_CONF_DELITEM . '<br>' . $item->getVar('product_title')); |
||
| 882 | break; |
||
| 883 | |||
| 884 | // **************************************************************************************************************** |
||
| 885 | case 'delete': // Suppression d'un produit |
||
| 886 | // **************************************************************************************************************** |
||
| 887 | xoops_cp_header(); |
||
| 888 | $id = isset($_POST['id']) ? (int)$_POST['id'] : 0; |
||
| 889 | if ($id == 0) { |
||
| 890 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
| 891 | } |
||
| 892 | $opRedirect = 'products'; |
||
| 893 | $tblTmp = array(); |
||
| 894 | $tblTmp = $h_oledrion_caddy->getCommandIdFromProduct($id); |
||
| 895 | if (count($tblTmp) == 0) { |
||
| 896 | $item = null; |
||
| 897 | $item = $h_oledrion_products->get($id); |
||
| 898 | if (is_object($item)) { |
||
| 899 | $res = $oledrion_shelf->deleteProduct($item, true); |
||
| 900 | if ($res) { |
||
| 901 | OledrionUtility::updateCache(); |
||
| 902 | xoops_notification_deletebyitem($xoopsModule->getVar('mid'), 'new_product', $id); |
||
| 903 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 2); |
||
| 904 | } else { |
||
| 905 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_PB, $baseurl . '?op=' . $opRedirect, 5); |
||
| 906 | } |
||
| 907 | } else { |
||
| 908 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl . '?op=' . $opRedirect, 5); |
||
| 909 | } |
||
| 910 | View Code Duplication | } else { |
|
| 911 | OledrionUtility::htitle(_AM_OLEDRION_SORRY_NOREMOVE, 4); |
||
| 912 | $tblTmp2 = array(); |
||
| 913 | $tblTmp2 = $h_oledrion_commands->getObjects(new Criteria('cmd_id', '(' . implode(',', $tblTmp) . ')', 'IN'), true); |
||
| 914 | echo "<table width='100%' cellspacing='1' cellpadding='3' border='0' class='outer'>"; |
||
| 915 | $class = ''; |
||
| 916 | echo "<tr><th align='center'>" . _AM_OLEDRION_ID . "</th><th align='center'>" . _AM_OLEDRION_DATE . "</th><th align='center'>" . _AM_OLEDRION_CLIENT . "</th><th align='center'>" . _AM_OLEDRION_TOTAL_SHIPP . '</th></tr>'; |
||
| 917 | foreach ($tblTmp2 as $item) { |
||
| 918 | $class = ($class === 'even') ? 'odd' : 'even'; |
||
| 919 | $date = formatTimestamp(strtotime($item->getVar('cmd_date')), 's'); |
||
| 920 | echo "<tr class='" . $class . "'>\n"; |
||
| 921 | echo "<td align='right'>" |
||
| 922 | . $item->getVar('cmd_id') |
||
| 923 | . "</td><td align='center'>" |
||
| 924 | . $date |
||
| 925 | . "</td><td align='center'>" |
||
| 926 | . $item->getVar('cmd_lastname') |
||
| 927 | . ' ' |
||
| 928 | . $item->getVar('cmd_firstname') |
||
| 929 | . "</td><td align='center'>" |
||
| 930 | . $item->getVar('cmd_total') |
||
| 931 | . ' ' |
||
| 932 | . OledrionUtility::getModuleOption('money_short') |
||
| 933 | . ' / ' |
||
| 934 | . $item->getVar('cmd_shipping') |
||
| 935 | . ' ' |
||
| 936 | . OledrionUtility::getModuleOption('money_short') |
||
| 937 | . "</td>\n"; |
||
| 938 | echo "<tr>\n"; |
||
| 939 | } |
||
| 940 | echo '</table>'; |
||
| 941 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 942 | } |
||
| 943 | break; |
||
| 944 | |||
| 945 | // ********************************************************************************************** |
||
| 946 | case 'related': |
||
| 947 | // ****************************************************************************************** |
||
| 948 | xoops_cp_header(); |
||
| 949 | global $xoopsUser; |
||
| 950 | |||
| 951 | $id = isset($_GET['id']) ? (int)$_GET['id'] : 0; |
||
| 952 | if (empty($id)) { |
||
| 953 | OledrionUtility::redirect(_AM_OLEDRION_ERROR_1, $baseurl, 5); |
||
| 954 | } |
||
| 955 | // Item exits ? |
||
| 956 | $item = null; |
||
| 957 | $item = $h_oledrion_products->get($id); |
||
| 958 | if (!is_object($item)) { |
||
| 959 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
| 960 | } |
||
| 961 | |||
| 962 | $criteria = new Criteria(/*'product_id', $item->getVar('product_id'), '<>'*/); |
||
| 963 | $criteria->setSort('product_title'); |
||
| 964 | $relatedProducts = $h_oledrion_products->getObjects($criteria); |
||
| 965 | foreach ($relatedProducts as $oneitem) { |
||
| 966 | $relatedProducts_d[$oneitem->getVar('product_id')] = xoops_trim($oneitem->getVar('product_title')); |
||
| 967 | } |
||
| 968 | |||
| 969 | $criteria = new CriteriaCompo(); |
||
| 970 | $criteria->add(new Criteria('related_product_id', $item->getVar('product_id'), '=')); |
||
| 971 | $productRelated = $h_oledrion_related->getObjects($criteria); |
||
| 972 | foreach ($productRelated as $oneproduct) { |
||
| 973 | $productRelated_d[$oneproduct->getVar('related_product_related')]['id'] = $oneproduct->getVar('related_product_related'); |
||
| 974 | $productRelated_d[$oneproduct->getVar('related_product_related')]['title'] = $relatedProducts_d[$oneproduct->getVar('related_product_related')]; |
||
| 975 | $productRelated_d[$oneproduct->getVar('related_product_related')]['percent'] = $oneproduct->getVar('related_product_percent'); |
||
| 976 | } |
||
| 977 | |||
| 978 | $sform = new XoopsThemeForm(_D, 'frmproduct', $baseurl); |
||
| 979 | $sform->setExtra('enctype="multipart/form-data"'); |
||
| 980 | $sform->addElement(new XoopsFormHidden('op', 'products')); |
||
| 981 | $sform->addElement(new XoopsFormHidden('action', 'relatedsave')); |
||
| 982 | $sform->addElement(new XoopsFormHidden('product_id', $item->getVar('product_id'))); |
||
| 983 | |||
| 984 | foreach ($productRelated_d as $value) { |
||
| 985 | $sform->addElement(new XoopsFormText($value['title'], $value['id'], 5, 5, $value['percent']), false); |
||
| 986 | } |
||
| 987 | |||
| 988 | $button_tray = new XoopsFormElementTray('', ''); |
||
| 989 | $submit_btn = new XoopsFormButton('', 'post', _SUBMIT, 'submit'); |
||
| 990 | $button_tray->addElement($submit_btn); |
||
| 991 | $sform->addElement($button_tray); |
||
| 992 | $sform =& OledrionUtility::formMarkRequiredFields($sform); |
||
| 993 | $sform->display(); |
||
| 994 | |||
| 995 | require_once OLEDRION_ADMIN_PATH . 'admin_footer.php'; |
||
| 996 | break; |
||
| 997 | |||
| 998 | // ********************************************************************************************** |
||
| 999 | case 'relatedsave': |
||
| 1000 | // ****************************************************************************************** |
||
| 1001 | xoops_cp_header(); |
||
| 1002 | $id = isset($_POST['product_id']) ? (int)$_POST['product_id'] : 0; |
||
| 1003 | $item = $h_oledrion_products->get($id); |
||
| 1004 | if (!is_object($item)) { |
||
| 1005 | OledrionUtility::redirect(_AM_OLEDRION_NOT_FOUND, $baseurl, 5); |
||
| 1006 | } |
||
| 1007 | |||
| 1008 | foreach ($_POST as $related => $percent) { |
||
| 1009 | if (is_numeric($related)) { |
||
| 1010 | $h_oledrion_related->updatePercent($id, $related, $percent); |
||
| 1011 | } |
||
| 1012 | } |
||
| 1013 | |||
| 1014 | $opRedirect = 'products'; |
||
| 1015 | OledrionUtility::redirect(_AM_OLEDRION_SAVE_OK, $baseurl . '?op=' . $opRedirect, 5); |
||
| 1016 | break; |
||
| 1017 | } |
||
| 1018 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.