32require
'../main.inc.php';
41require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
42require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
43require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
44require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
45require_once DOL_DOCUMENT_ROOT.
'/product/class/productlang.class.php';
56$langs->loadLangs(array(
'products',
'languages'));
60$action =
GETPOST(
'action',
'aZ09');
61$cancel =
GETPOST(
'cancel',
'alpha');
64$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
65$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
67 $socid = $user->socid;
71if ($id > 0 || !empty($ref)) {
76$extrafields->fetch_name_optionals_label(
'product_lang');
77$productlanghasextrafields = !empty($extrafields->attributes[
'product_lang'][
'count']);
78if (
$object->id > 0 && $productlanghasextrafields) {
83$hookmanager->initHooks(array(
'producttranslationcard',
'globalcard'));
86 if (
$object->type == $object::TYPE_PRODUCT) {
89 if (
$object->type == $object::TYPE_SERVICE) {
93 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
104$parameters = array(
'id'=>$id,
'ref'=>$ref);
105$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
107 setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
109if (empty($reshook)) {
111 if ($cancel == $langs->trans(
"Cancel")) {
115 if ($action ==
'delete' &&
GETPOST(
'langtodelete',
'alpha') && $usercancreate) {
117 setEventMessages($langs->trans(
"RecordDeleted"),
null,
'mesgs');
118 header(
'Location:'.$_SERVER[
'PHP_SELF'].
'?id='.$id);
123 if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && $usercancreate) {
124 $current_lang = $langs->getDefaultLang();
127 if (
GETPOST(
"forcelangprod") == $current_lang) {
142 if ($productlanghasextrafields &&
GETPOST(
"forcelangprod")) {
143 $object->multilangs[
GETPOST(
"forcelangprod")][
"array_options"] = $extrafields->getOptionalsFromPost(
'product_lang');
147 if (
GETPOST(
"forcelangprod")) {
148 $result =
$object->setMultiLangs($user);
150 $object->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language"));
155 header(
'Location:'.$_SERVER[
'PHP_SELF'].
'?id='.$id);
164 if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && $usercancreate) {
165 $current_lang = $langs->getDefaultLang();
167 foreach (
$object->multilangs as $key => $value) {
168 if ($key == $current_lang) {
182 if ($productlanghasextrafields) {
183 $object->multilangs[$key][
"array_options"] = $extrafields->getOptionalsFromPost(
'product_lang',
'-'.$key);
187 $result =
$object->setMultiLangs($user);
189 header(
'Location:'.$_SERVER[
'PHP_SELF'].
'?id='.$id);
198 if ($action ==
'vdelete' && $cancel != $langs->trans(
"Cancel") && $usercancreate) {
199 $langtodelete =
GETPOST(
'langdel',
'alpha');
201 $result =
$object->delMultiLangs($langtodelete, $user);
203 header(
'Location:'.$_SERVER[
'PHP_SELF'].
'?id='.$id);
217$title = $langs->trans(
'ProductServiceCard');
221 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
222 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
225 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
226 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
229llxHeader(
'', $title, $helpurl,
'', 0, 0,
'',
'',
'',
'mod-product page-translation');
231$form =
new Form($db);
235$titre = $langs->trans(
"CardProduct".
$object->type);
241if (!empty(
$object->multilangs)) {
242 foreach (
$object->multilangs as $key => $value) {
250$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
253if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
257dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'',
'',
'', 0,
'',
'', 1);
266print
"\n".
'<div class="tabsAction">'.
"\n";
268$parameters = array();
269$reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
270if (empty($reshook)) {
272 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
273 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=add&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"Add") .
'</a>';
274 if ($cnt_trans > 0) {
275 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=edit&token='.newToken().
'&id=' .
$object->id .
'">' . $langs->trans(
"Modify") .
'</a>';
281print
"\n".
'</div>'.
"\n";
285if ($action ==
'edit') {
287 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
289 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
290 print
'<input type="hidden" name="token" value="'.newToken().
'">';
291 print
'<input type="hidden" name="action" value="vedit">';
292 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
294 if (!empty(
$object->multilangs)) {
296 foreach (
$object->multilangs as $key => $value) {
300 print($i > 1 ?
"<br>" :
"").($s ? $s.
' ' :
'').
' <div class="inline-block margintop marginbottomonly"><b>'.$langs->trans(
'Language_'.$key).
'</b></div><div class="inline-block floatright"><a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&langtodelete='.$key.
'">'.img_delete(
'',
'class="valigntextbottom marginrightonly"').
'</a></div>';
302 print
'<div class="underbanner clearboth"></div>';
303 print
'<table class="border centpercent">';
304 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle-'.$key.
'" size="40" value="'.
dol_escape_htmltag(
$object->multilangs[$key][
"label"]).
'"></td></tr>';
305 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
306 $doleditor =
new DolEditor(
"desc-$key",
$object->multilangs[$key][
"description"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
307 $doleditor->Create();
310 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td><td>';
311 $doleditor =
new DolEditor(
"other-$key",
$object->multilangs[$key][
"other"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
312 $doleditor->Create();
316 if ($productlanghasextrafields) {
318 $productlang->id =
$object->multilangs[$key][
"rowid"];
319 $productlang->array_options = (empty(
$object->multilangs[$key][
"array_options"]) ? array() :
$object->multilangs[$key][
"array_options"]);
320 print $productlang->showOptionals($extrafields,
'edit', array(),
'-'.$key);
326 $parameters = array();
327 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
331 print $form->buttonsSaveCancel();
334} elseif ($action !=
'add') {
335 if (!empty(
$object->multilangs)) {
337 foreach (
$object->multilangs as $key => $value) {
341 print($i > 1 ?
"<br>" :
"").($s ? $s.
' ' :
'').
' <div class="inline-block marginbottomonly"><b>'.$langs->trans(
'Language_'.$key).
'</b></div><div class="inline-block floatright"><a href="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'&action=delete&token='.
newToken().
'&langtodelete='.$key.
'">'.img_delete(
'',
'class="valigntextbottom marginrightonly"').
'</a></div>';
343 print
'<div class="fichecenter">';
344 print
'<div class="underbanner clearboth"></div>';
345 print
'<table class="border centpercent">';
346 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Label').
'</td><td>'.
$object->multilangs[$key][
"label"].
'</td></tr>';
347 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>'.
$object->multilangs[$key][
"description"].
'</td></tr>';
349 print
'<tr><td>'.$langs->trans(
"NotePrivate").
'</td><td>'.
$object->multilangs[$key][
"other"].
'</td></tr>';
352 if ($productlanghasextrafields) {
354 $productlang->id =
$object->multilangs[$key][
"rowid"];
355 $productlang->array_options = (empty(
$object->multilangs[$key][
"array_options"]) ? array() :
$object->multilangs[$key][
"array_options"]);
356 print $productlang->showOptionals($extrafields,
'view');
362 if (!$cnt_trans && $action !=
'add') {
363 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
373if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
375 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
378 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
379 print
'<input type="hidden" name="token" value="'.newToken().
'">';
380 print
'<input type="hidden" name="action" value="vadd">';
381 print
'<input type="hidden" name="id" value="'.GETPOSTINT(
"id").
'">';
385 print
'<table class="border centpercent">';
386 print
'<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Language').
'</td><td>';
387 print $formadmin->select_language(
GETPOST(
'forcelangprod'),
'forcelangprod', 0,
$object->multilangs, 1);
389 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle" size="40"></td></tr>';
390 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
391 $doleditor =
new DolEditor(
'desc',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
392 $doleditor->Create();
396 print
'<tr><td class="tdtop">'.$langs->trans(
'NotePrivate').
'</td><td>';
397 $doleditor =
new DolEditor(
'other',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
398 $doleditor->Create();
402 if ($productlanghasextrafields) {
404 print $productlang->showOptionals($extrafields,
'create');
408 $parameters = array();
409 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
413 print $form->buttonsSaveCancel();
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $object
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage a WYSIWYG editor.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
Class of a translation of a product (a row of llx_product_lang).
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
product_prepare_head($object)
Prepare array with list of tabs.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $nodie=0, $mode='')
Check permissions of a user to show a page and an object.