dolibarr 21.0.0-beta
orderAttribute.php
1<?php
2/* Copyright (C) 2016 Marcos García <marcosgdf@gmail.com>
3 * Copyright (C) 2022 Open-Dsi <support@open-dsi.fr>
4 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
20if (!defined('NOTOKENRENEWAL')) {
21 define('NOTOKENRENEWAL', '1'); // Disable token renewal
22}
23if (!defined('NOREQUIREMENU')) {
24 define('NOREQUIREMENU', '1');
25}
26if (!defined('NOREQUIREHTML')) {
27 define('NOREQUIREHTML', '1');
28}
29if (!defined('NOREQUIREAJAX')) {
30 define('NOREQUIREAJAX', '1');
31}
32if (!defined('NOREQUIRESOC')) {
33 define('NOREQUIRESOC', '1');
34}
35if (!defined('NOREQUIRETRAN')) {
36 define('NOREQUIRETRAN', '1');
37}
38
39// Load Dolibarr environment
40require '../../main.inc.php';
41require DOL_DOCUMENT_ROOT . '/variants/class/ProductAttribute.class.php';
42
51// Security check
52if (!isModEnabled('variants')) {
53 accessforbidden('Module not enabled');
54}
55if ($user->socid > 0) { // Protection if external user
57}
58$result = restrictedArea($user, 'variants');
59
60
61/*
62 * View
63 */
64
66
67print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
68
69// Registering the location of boxes
70if (GETPOST('roworder', 'alpha', 3)) {
71 $roworder = GETPOST('roworder', 'alpha', 3);
72
73 dol_syslog("AjaxOrderAttribute roworder=" . $roworder, LOG_DEBUG);
74
75 $rowordertab = explode(',', $roworder);
76 $newrowordertab = array();
77 foreach ($rowordertab as $value) {
78 if (!empty($value)) {
79 $newrowordertab[] = $value;
80 }
81 }
82
83 $row = new ProductAttribute($db);
84
85 $row->attributesAjaxOrder($newrowordertab); // This update field rank or position in table row->table_element_line
86} else {
87 print 'Bad parameters for orderAttribute.php';
88}
Class ProductAttribute Used to represent a Product attribute Examples:
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.