19 require
'../main.inc.php';
20 require
'class/ProductAttribute.class.php';
21 require
'class/ProductAttributeValue.class.php';
24 $valueid =
GETPOST(
'valueid',
'alpha');
25 $action =
GETPOST(
'action',
'aZ09');
26 $label =
GETPOST(
'label',
'alpha');
28 $confirm =
GETPOST(
'confirm',
'alpha');
29 $cancel =
GETPOST(
'cancel',
'alpha');
34 if ($object->fetch($id) < 1) {
44 if ($cancel) $action =
'';
47 if ($action ==
'update') {
49 $object->label = $label;
51 if ($object->update($user) < 1) {
52 setEventMessages($langs->trans(
'CoreErrorMessage'), $object->errors,
'errors');
55 header(
'Location: '.
dol_buildpath(
'/variants/card.php?id='.$id, 2));
58 } elseif ($action ==
'update_value') {
59 if ($objectval->fetch($valueid) > 0) {
60 $objectval->ref = $ref;
61 $objectval->value =
GETPOST(
'value',
'alpha');
63 if (empty($objectval->ref))
66 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Ref")), null,
'errors');
68 if (empty($objectval->value))
71 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Label")), null,
'errors');
76 if ($objectval->update($user) > 0) {
79 setEventMessage($langs->trans(
'CoreErrorMessage'), $objectval->errors,
'errors');
84 header(
'Location: '.
dol_buildpath(
'/variants/card.php?id='.$object->id, 2));
89 if ($confirm ==
'yes') {
90 if ($action ==
'confirm_delete') {
93 $res = $objectval->deleteByFkAttribute($object->id, $user);
95 if ($res < 1 || ($object->delete($user) < 1)) {
97 setEventMessages($langs->trans(
'CoreErrorMessage'), $object->errors,
'errors');
98 header(
'Location: '.
dol_buildpath(
'/variants/card.php?id='.$object->id, 2));
105 } elseif ($action ==
'confirm_deletevalue')
107 if ($objectval->fetch($valueid) > 0) {
108 if ($objectval->delete($user) < 1) {
109 setEventMessages($langs->trans(
'CoreErrorMessage'), $objectval->errors,
'errors');
114 header(
'Location: '.
dol_buildpath(
'/variants/card.php?id='.$object->id, 2));
125 $langs->load(
'products');
127 $title = $langs->trans(
'ProductAttributeName',
dol_htmlentities($object->label));
134 $head[$h][0] = DOL_URL_ROOT.
'/variants/card.php?id='.$object->id;
135 $head[$h][1] = $langs->trans(
"ProductAttributeName");
136 $head[$h][2] =
'variant';
141 if ($action ==
'edit') {
142 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
143 print '<input type="hidden" name="token" value="'.newToken().
'">';
144 print '<input type="hidden" name="action" value="update">';
145 print '<input type="hidden" name="id" value="'.$id.
'">';
146 print '<input type="hidden" name="valueid" value="'.$valueid.
'">';
147 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
151 if ($action !=
'edit') {
152 print '<div class="fichecenter">';
153 print '<div class="underbanner clearboth"></div>';
155 print '<table class="border centpercent tableforfield">';
157 print '<td class="titlefield'.($action ==
'edit' ?
' fieldrequired' :
'').
'">'.$langs->trans(
'Ref').
'</td>';
159 if ($action ==
'edit') {
160 print '<input type="text" name="ref" value="'.$object->ref.
'">';
167 print '<td'.($action ==
'edit' ?
' class="fieldrequired"' :
'').
'>'.$langs->trans(
'Label').
'</td>';
169 if ($action ==
'edit') {
170 print '<input type="text" name="label" value="'.$object->label.
'">';
180 if ($action !=
'edit') {
186 if ($action ==
'edit') {
187 print '<div style="text-align: center;">';
188 print '<div class="inline-block divButAction">';
189 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
190 print ' ';
191 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
193 print '</div></form>';
195 if ($action ==
'delete') {
196 $form =
new Form($db);
198 print $form->formconfirm(
199 "card.php?id=".$object->id,
200 $langs->trans(
'Delete'),
201 $langs->trans(
'ProductAttributeDeleteDialog'),
207 } elseif ($action ==
'delete_value') {
208 if ($objectval->fetch($valueid) > 0) {
209 $form =
new Form($db);
211 print $form->formconfirm(
212 "card.php?id=".$object->id.
"&valueid=".$objectval->id,
213 $langs->trans(
'Delete'),
215 "confirm_deletevalue",
225 <div
class=
"tabsAction">
226 <div
class=
"inline-block divButAction">
227 <a href=
"card.php?id=<?php echo $object->id ?>&action=edit&token=<?php echo newToken(); ?>" class=
"butAction"><?php echo $langs->trans(
'Modify') ?></a>
228 <a href=
"card.php?id=<?php echo $object->id ?>&action=delete&token=<?php echo newToken(); ?>" class=
"butAction"><?php echo $langs->trans(
'Delete') ?></a>
237 if ($action ==
'edit_value') {
238 print '<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'">';
239 print '<input type="hidden" name="token" value="'.newToken().
'">';
240 print '<input type="hidden" name="action" value="update_value">';
241 print '<input type="hidden" name="id" value="'.$id.
'">';
242 print '<input type="hidden" name="valueid" value="'.$valueid.
'">';
243 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
246 print '<table class="liste">';
247 print '<tr class="liste_titre">';
248 print '<th class="liste_titre titlefield">'.$langs->trans(
'Ref').
'</th>';
249 print '<th class="liste_titre">'.$langs->trans(
'Value').
'</th>';
250 print '<th class="liste_titre"></th>';
253 foreach ($objectval->fetchAllByProductAttribute($object->id) as $attrval) {
254 print '<tr class="oddeven">';
255 if ($action ==
'edit_value' && ($valueid == $attrval->id)) {
257 <td><input
type=
"text" name=
"ref" value=
"<?php echo $attrval->ref ?>"></td>
258 <td><input type=
"text" name=
"value" value=
"<?php echo $attrval->value ?>"></td>
260 <input type=
"submit" value=
"<?php echo $langs->trans("Save
") ?>" class=
"button button-save">
262 <input type=
"submit" name=
"cancel" value=
"<?php echo $langs->trans("Cancel
") ?>" class=
"button button-cancel">
270 <a
class=
"editfielda marginrightonly" href=
"card.php?id=<?php echo $object->id ?>&action=edit_value&valueid=<?php echo $attrval->id ?>"><?php echo
img_edit() ?></a>
271 <a href=
"card.php?id=<?php echo $object->id ?>&action=delete_value&token=<?php echo newToken(); ?>&valueid=<?php echo $attrval->id ?>"><?php echo
img_delete() ?></a>
279 if ($action ==
'edit_value') {
283 print '<div class="tabsAction">';
284 print '<div class="inline-block divButAction">';
285 print '<a href="create_val.php?id='.$object->id.
'" class="butAction">'.$langs->trans(
'Create').
'</a>';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
dol_htmlentities($string, $flags=null, $encoding= 'UTF-8', $double_encode=false)
Replace htmlentities functions.
setEventMessage($mesgs, $style= 'mesgs')
Set event message in dol_events session object.
Class ProductAttributeValue Used to represent a product attribute value.
$conf db name
Only used if Module[ID]Name translation string is not found.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
Class ProductAttribute Used to represent a product attribute.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_get_fiche_head($links=array(), $active= '', $title= '', $notab=0, $picto= '', $pictoisfullpath=0, $morehtmlright= '', $morecss= '', $limittoshow=0, $moretabssuffix= '')
Show tabs of a record.
print
Draft customers invoices.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_get_fiche_end($notab=0)
Return tab footer of a card.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
if(preg_match('/crypted:/i', $dolibarr_main_db_pass)||!empty($dolibarr_main_db_encrypted_pass)) $conf db type