28 require
'../main.inc.php';
29 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
32 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
35 $langs->loadLangs(array(
'products',
'languages'));
39 $action =
GETPOST(
'action',
'aZ09');
40 $cancel =
GETPOST(
'cancel',
'alpha');
43 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
44 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
45 if ($user->socid) $socid = $user->socid;
46 $result =
restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
54 if ($cancel == $langs->trans(
"Cancel"))
59 if ($action ==
'delete' &&
GETPOST(
'langtodelete',
'alpha'))
63 $object->delMultiLangs(
GETPOST(
'langtodelete',
'alpha'), $user);
67 if ($action ==
'vadd' &&
68 $cancel != $langs->trans(
"Cancel") &&
69 ($user->rights->produit->creer || $user->rights->service->creer))
73 $current_lang = $langs->getDefaultLang();
76 if ($_POST[
"forcelangprod"] == $current_lang) {
77 $object->label = $_POST[
"libelle"];
80 $object->update($object->id, $user);
82 $object->multilangs[$_POST[
"forcelangprod"]][
"label"] = $_POST[
"libelle"];
83 $object->multilangs[$_POST[
"forcelangprod"]][
"description"] =
dol_htmlcleanlastbr($_POST[
"desc"]);
84 $object->multilangs[$_POST[
"forcelangprod"]][
"other"] =
dol_htmlcleanlastbr($_POST[
"other"]);
88 if ($object->setMultiLangs($user) > 0) {
97 if ($action ==
'vedit' &&
98 $cancel != $langs->trans(
"Cancel") &&
99 ($user->rights->produit->creer || $user->rights->service->creer))
103 $current_lang = $langs->getDefaultLang();
105 foreach ($object->multilangs as $key => $value)
107 if ($key == $current_lang)
109 $object->label = $_POST[
"libelle-".$key];
113 $object->multilangs[$key][
"label"] = $_POST[
"libelle-".$key];
119 if ($object->setMultiLangs($user) > 0)
129 if ($action ==
'vdelete' &&
130 $cancel != $langs->trans(
"Cancel") &&
131 ($user->rights->produit->creer || $user->rights->service->creer))
135 $langtodelete =
GETPOST(
'langdel',
'alpha');
138 if ($object->delMultiLangs($langtodelete, $user) > 0)
148 $result = $object->fetch($id, $ref);
155 $title = $langs->trans(
'ProductServiceCard');
157 $shortlabel =
dol_trunc($object->label, 16);
160 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
161 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
165 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
166 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
171 $form =
new Form($db);
175 $titre = $langs->trans(
"CardProduct".$object->type);
181 if (!empty($object->multilangs))
183 foreach ($object->multilangs as $key => $value)
192 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
195 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
197 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'',
'',
'', 0,
'',
'', 1);
209 print "\n<div class=\"tabsAction\">\n";
213 if ($user->rights->produit->creer || $user->rights->service->creer)
215 print '<a class="butAction" href="'.DOL_URL_ROOT.
'/product/traduction.php?action=add&id='.$object->id.
'">'.$langs->trans(
"Add").
'</a>';
216 if ($cnt_trans > 0)
print '<a class="butAction" href="'.DOL_URL_ROOT.
'/product/traduction.php?action=edit&id='.$object->id.
'">'.$langs->trans(
"Update").
'</a>';
224 if ($action ==
'edit')
227 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
229 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
230 print '<input type="hidden" name="token" value="'.newToken().
'">';
231 print '<input type="hidden" name="action" value="vedit">';
232 print '<input type="hidden" name="id" value="'.$object->id.
'">';
234 if (!empty($object->multilangs))
236 foreach ($object->multilangs as $key => $value)
239 print "<br>".($s ? $s.
' ' :
'').
" <b>".$langs->trans(
'Language_'.$key).
":</b> ".
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&langtodelete='.$key.
'">'.
img_delete(
'',
'class="valigntextbottom"').
"</a><br>";
241 print '<div class="underbanner clearboth"></div>';
242 print '<table class="border centpercent">';
243 print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.
dol_escape_htmltag($object->multilangs[$key][
"label"]).
'"></td></tr>';
244 print '<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
245 $doleditor =
new DolEditor(
"desc-$key", $object->multilangs[$key][
"description"],
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
246 $doleditor->Create();
248 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
250 print '<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>';
251 $doleditor =
new DolEditor(
"other-$key", $object->multilangs[$key][
"other"],
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
252 $doleditor->Create();
261 print '<div class="center">';
262 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
263 print ' ';
264 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
268 } elseif ($action !=
'add')
270 if (!empty($object->multilangs))
272 foreach ($object->multilangs as $key => $value)
275 print ($s ? $s.
' ' :
'').
" <b>".$langs->trans(
'Language_'.$key).
":</b> ".
'<a href="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'&action=delete&token='.
newToken().
'&langtodelete='.$key.
'">'.
img_delete(
'',
'class="valigntextbottom"').
'</a>';
277 print '<div class="fichecenter">';
278 print '<div class="underbanner clearboth"></div>';
279 print '<table class="border centpercent">';
280 print '<tr><td class="titlefieldcreate">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
281 print '<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
282 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
284 print '<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
290 if (!$cnt_trans && $action !=
'add')
print '<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
299 if ($action ==
'add' && ($user->rights->produit->creer || $user->rights->service->creer))
302 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
305 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
306 print '<input type="hidden" name="token" value="'.newToken().
'">';
307 print '<input type="hidden" name="action" value="vadd">';
308 print '<input type="hidden" name="id" value="'.GETPOST(
"id",
'int').
'">';
312 print '<table class="border centpercent">';
313 print '<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Language').
'</td><td>';
314 print $formadmin->select_language(
'',
'forcelangprod', 0, $object->multilangs, 1);
316 print '<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle" size="40"></td></tr>';
317 print '<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
318 $doleditor =
new DolEditor(
'desc',
'',
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
319 $doleditor->Create();
322 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION))
324 print '<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
'</td><td>';
325 $doleditor =
new DolEditor(
'other',
'',
'', 160,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_3,
'90%');
326 $doleditor->Create();
333 print '<div class="center">';
334 print '<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
335 print ' ';
336 print '<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage products or services.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
restrictedArea($user, $features, $objectid=0, $tableandshare= '', $feature2= '', $dbt_keyfield= 'fk_soc', $dbt_select= 'rowid', $isdraft=0)
Check permissions of a user to show a page and an object.
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_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
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.
Class to manage a WYSIWYG editor.
dol_trunc($string, $size=40, $trunc= 'right', $stringencoding= 'UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '...' if string larger than length.
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.
img_delete($titlealt= 'default', $other= 'class="pictodelete"', $morecss= '')
Show delete logo.
picto_from_langcode($codelang, $moreatt= '')
Return img flag of country for a language code or country code.
product_prepare_head($object)
Prepare array with list of tabs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $keepmoretags= '', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields...