Go to the documentation of this file.
26 require
'../main.inc.php';
27 require
'class/ProductAttribute.class.php';
28 require
'class/ProductAttributeValue.class.php';
29 require
'lib/variants.lib.php';
32 $langs->loadLangs(array(
'products'));
36 $action =
GETPOST(
'action',
'aZ09');
37 $confirm =
GETPOST(
'confirm',
'alpha');
38 $cancel =
GETPOST(
'cancel',
'alpha');
39 $contextpage =
GETPOST(
'contextpage',
'aZ') ?
GETPOST(
'contextpage',
'aZ') :
'productattribute';
40 $backtopage =
GETPOST(
'backtopage',
'alpha');
41 $backtopageforcancel =
GETPOST(
'backtopageforcancel',
'alpha');
42 $lineid =
GETPOST(
'lineid',
'alpha');
45 if (empty($conf->variants->enabled)) {
48 if ($user->socid > 0) {
56 include DOL_DOCUMENT_ROOT.
'/core/actions_fetchobject.inc.php';
59 $hookmanager->initHooks(array(
'productattributecard',
'globalcard'));
61 $permissiontoread = $user->rights->variants->read;
62 $permissiontoadd = $user->rights->variants->write;
63 $permissiontoedit = $user->rights->variants->write;
64 $permissiontodelete = $user->rights->variants->delete;
76 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
81 if (empty($reshook)) {
86 if (empty($backtopage) || ($cancel && empty($id))) {
87 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
88 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
89 $backtopage = $backurlforlist;
91 $backtopage =
dol_buildpath(
'/variants/card.php', 1).
'?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
97 include DOL_DOCUMENT_ROOT.
'/core/actions_lineupdown.inc.php';
99 if (!empty($backtopage)) {
100 header(
"Location: " . $backtopage);
107 include DOL_DOCUMENT_ROOT.
'/core/actions_addupdatedelete.inc.php';
110 if ($action ==
'up' && $permissiontoedit) {
111 $object->line_up(
GETPOST(
'rowid'),
false);
113 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'#'.
GETPOST(
'rowid'));
115 } elseif ($action ==
'down' && $permissiontoedit) {
116 $object->line_down(
GETPOST(
'rowid'),
false);
118 header(
'Location: '.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'#'.
GETPOST(
'rowid'));
122 if ($action ==
'addline' && $permissiontoedit) {
123 $line_ref =
GETPOST(
'line_ref',
'alpha');
124 $line_value =
GETPOST(
'line_value',
'alpha');
126 $result = $object->addLine($line_ref, $line_value);
129 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id);
135 } elseif ($action ==
'updateline' && $permissiontoedit) {
136 $line_ref =
GETPOST(
'line_ref',
'alpha');
137 $line_value =
GETPOST(
'line_value',
'alpha');
139 $result = $object->updateLine($lineid, $line_ref, $line_value);
142 header(
"Location: " . $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id);
146 $action =
'editline';
156 $title = $langs->trans(
'ProductAttributeName',
dol_htmlentities($object->label));
157 $help_url =
'EN:Module_Products#Variants';
161 if ($action ==
'create') {
162 print
load_fiche_titre($langs->trans(
"NewObject", $langs->transnoentitiesnoconv(
"ProductAttribute")),
'',
'object_' . $object->picto);
164 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
165 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
166 print
'<input type="hidden" name="action" value="add">';
168 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
170 if ($backtopageforcancel) {
171 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
176 print
'<table class="border centpercent tableforfieldcreate">' .
"\n";
179 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_add.tpl.php';
181 print
'</table>' .
"\n";
185 print
'<div class="center">';
186 print
'<input type="submit" class="button" name="add" value="' .
dol_escape_htmltag($langs->trans(
"Create")) .
'">';
188 print
'<input type="' . ($backtopage ?
"submit" :
"button") .
'" class="button button-cancel" name="cancel" value="' .
dol_escape_htmltag($langs->trans(
"Cancel")) .
'"' . ($backtopage ?
'' :
' onclick="javascript:history.go(-1)"') .
'>';
194 } elseif (($id || $ref) && $action ==
'edit') {
196 print
load_fiche_titre($langs->trans(
"ProductAttribute"),
'',
'object_' . $object->picto);
198 print
'<form method="POST" action="' . $_SERVER[
"PHP_SELF"] .
'">';
199 print
'<input type="hidden" name="token" value="' .
newToken() .
'">';
200 print
'<input type="hidden" name="action" value="update">';
201 print
'<input type="hidden" name="id" value="' . $object->id .
'">';
203 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
205 if ($backtopageforcancel) {
206 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
211 print
'<table class="border centpercent tableforfieldedit">' .
"\n";
214 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_edit.tpl.php';
220 print
'<div class="center"><input type="submit" class="button button-save" name="save" value="' . $langs->trans(
"Save") .
'">';
221 print
' <input type="submit" class="button button-cancel" name="cancel" value="' . $langs->trans(
"Cancel") .
'">';
225 } elseif ($object->id > 0 && (empty($action) || ($action !=
'edit' && $action !=
'create'))) {
227 $res = $object->fetch_optionals();
230 print
dol_get_fiche_head($head,
'card', $langs->trans(
"ProductAttribute"), -1, $object->picto);
235 if ($action ==
'delete') {
236 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id, $langs->trans(
'DeleteMyObject'), $langs->trans(
'ProductAttributeDeleteDialog'),
'confirm_delete',
'', 0, 1);
237 } elseif ($action ==
'ask_deleteline') {
240 if ($object_value->fetch($lineid) > 0) {
241 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&lineid=' . $lineid, $langs->trans(
'DeleteLine'), $langs->trans(
'ProductAttributeValueDeleteDialog',
dol_htmlentities($object_value->value),
dol_htmlentities($object_value->ref)),
'confirm_deleteline',
'', 0, 1);
247 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
248 if (empty($reshook)) {
250 } elseif ($reshook > 0) {
259 $backtolist = (
GETPOST(
'backtolist') ?
GETPOST(
'backtolist') : DOL_URL_ROOT .
'/variants/list.php?leftmenu=?restore_lastsearch_values=1');
260 $linkback =
'<a href="' .
dol_sanitizeUrl($backtolist) .
'">' . $langs->trans(
"BackToList") .
'</a>';
264 print
'<div class="fichecenter">';
265 print
'<div class="fichehalfleft">';
266 print
'<div class="underbanner clearboth"></div>';
267 print
'<table class="border centpercent tableforfield">' .
"\n";
270 include DOL_DOCUMENT_ROOT .
'/core/tpl/commonfields_view.tpl.php';
276 print
'<div class="clearboth"></div>';
281 if ($action !=
'editline') {
282 print
'<div class="tabsAction">' .
"\n";
284 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
285 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
287 if (empty($reshook)) {
289 print
dolGetButtonAction($langs->trans(
'Modify'),
'',
'default', $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id .
'&action=edit',
'', $permissiontoedit);
292 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete', $_SERVER[
'PHP_SELF'] .
'?id=' . $object->id .
'&action=delete',
'', $permissiontodelete);
294 print
'</div>' .
"\n";
300 if (!empty($object->table_element_line)) {
302 $result = $object->getLinesArray();
304 print
load_fiche_titre($langs->trans(
"PossibleValues") . (!empty($object->lines) ?
' (' . count($object->lines) .
')' :
''));
306 print
' <form name="addproduct" id="addproduct" action="' . $_SERVER[
"PHP_SELF"] .
'?id=' . $object->id . (($action !=
'editline') ?
'' :
'#line_' .
GETPOST(
'lineid',
'int')) .
'" method="POST">
307 <input type="hidden" name="token" value="' .
newToken() .
'">
308 <input type="hidden" name="action" value="' . (($action !=
'editline') ?
'addline' :
'updateline') .
'">
309 <input type="hidden" name="mode" value="">
310 <input type="hidden" name="page_y" value="">
311 <input type="hidden" name="id" value="' . $object->id .
'">
314 print
'<input type="hidden" name="backtopage" value="' . $backtopage .
'">';
316 if ($backtopageforcancel) {
317 print
'<input type="hidden" name="backtopageforcancel" value="' . $backtopageforcancel .
'">';
320 if (!empty($conf->use_javascript_ajax)) {
321 include DOL_DOCUMENT_ROOT .
'/core/tpl/ajaxrow.tpl.php';
324 print
'<div class="div-table-responsive-no-min">';
325 if (!empty($object->lines) || ($permissiontoedit && $action !=
'selectlines' && $action !=
'editline')) {
326 print
'<table id="tablelines" class="noborder noshadow" width="100%">';
330 if ($permissiontoedit && $action !=
'selectlines') {
331 if ($action !=
'editline') {
335 $reshook = $hookmanager->executeHooks(
'formAddObjectLine',
$parameters, $object, $action);
336 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
338 $object->formAddObjectLine(1, $mysoc, $soc);
342 if (!empty($object->lines)) {
343 $object->printObjectLines($action, $mysoc,
null,
GETPOST(
'lineid',
'int'), 1);
346 if (!empty($object->lines) || ($permissiontoedit && $action !=
'selectlines' && $action !=
'editline')) {
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
restrictedArea($user, $features, $objectid=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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class ProductAttributeValue Used to represent a product attribute value.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
dolGetButtonAction($label, $html='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='rowid', $fieldref='ref', $morehtmlref='', $moreparam='', $nodbprefix=0, $morehtmlleft='', $morehtmlstatus='', $onlybanner=0, $morehtmlright='')
Show tab footer of a card.
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
Class ProductAttribute Used to represent a product attribute.
$formconfirm
if ($action == 'delbookkeepingyear') {
dol_sanitizeUrl($stringtoclean, $type=1)
Clean a string to use it as an URL (into a href or src attribute)
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
productAttributePrepareHead($object)
Prepare array with list of tabs.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
dol_htmlentities($string, $flags=ENT_QUOTES|ENT_SUBSTITUTE, $encoding='UTF-8', $double_encode=false)
Replace htmlentities functions.