29 require
'../main.inc.php';
30 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
31 require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
32 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
33 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
36 $langs->loadLangs(array(
'products',
'languages'));
40 $action =
GETPOST(
'action',
'aZ09');
41 $cancel =
GETPOST(
'cancel',
'alpha');
44 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
45 $fieldtype = (!empty($ref) ?
'ref' :
'rowid');
47 $socid = $user->socid;
50 if ($id > 0 || !empty($ref)) {
52 $object->fetch($id, $ref);
55 if ($object->id > 0) {
56 if ($object->type == $object::TYPE_PRODUCT) {
57 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
59 if ($object->type == $object::TYPE_SERVICE) {
60 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
63 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
67 $hookmanager->initHooks(array(
'producttranslationcard',
'globalcard'));
74 $parameters = array(
'id'=>$id,
'ref'=>$ref);
75 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
79 if (empty($reshook)) {
81 if ($cancel == $langs->trans(
"Cancel")) {
85 if ($action ==
'delete' &&
GETPOST(
'langtodelete',
'alpha')) {
88 $object->delMultiLangs(
GETPOST(
'langtodelete',
'alpha'), $user);
94 if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
97 $current_lang = $langs->getDefaultLang();
100 if (
GETPOST(
"forcelangprod") == $current_lang) {
101 $object->label =
GETPOST(
"libelle");
105 $object->update($object->id, $user);
107 $object->multilangs[
GETPOST(
"forcelangprod")][
"label"] =
GETPOST(
"libelle");
113 if (
GETPOST(
"forcelangprod")) {
114 $result = $object->setMultiLangs($user);
116 $object->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language"));
129 if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
132 $current_lang = $langs->getDefaultLang();
134 foreach ($object->multilangs as $key => $value) {
135 if ($key == $current_lang) {
136 $object->label =
GETPOST(
"libelle-" . $key);
140 $object->multilangs[$key][
"label"] =
GETPOST(
"libelle-" . $key);
146 $result = $object->setMultiLangs($user);
156 if ($action ==
'vdelete' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
159 $langtodelete =
GETPOST(
'langdel',
'alpha');
161 $result = $object->delMultiLangs($langtodelete, $user);
172 $result = $object->fetch($id, $ref);
179 $title = $langs->trans(
'ProductServiceCard');
181 $shortlabel =
dol_trunc($object->label, 16);
183 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
184 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
187 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
188 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
197 $titre = $langs->trans(
"CardProduct".$object->type);
203 if (!empty($object->multilangs)) {
204 foreach ($object->multilangs as $key => $value) {
212 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
215 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
219 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'',
'',
'', 0,
'',
'', 1);
228 print
"\n".
'<div class="tabsAction">'.
"\n";
230 $parameters = array();
231 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
232 if (empty($reshook)) {
234 if ($user->rights->produit->creer || $user->rights->service->creer) {
235 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=add&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Add") .
'</a>';
236 if ($cnt_trans > 0) {
237 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=edit&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Modify") .
'</a>';
243 print
"\n".
'</div>'.
"\n";
247 if ($action ==
'edit') {
249 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
251 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
252 print
'<input type="hidden" name="token" value="'.newToken().
'">';
253 print
'<input type="hidden" name="action" value="vedit">';
254 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
256 if (!empty($object->multilangs)) {
258 foreach ($object->multilangs as $key => $value) {
262 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>';
264 print
'<div class="underbanner clearboth"></div>';
265 print
'<table class="border centpercent">';
266 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>';
267 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
268 $doleditor =
new DolEditor(
"desc-$key", $object->multilangs[$key][
"description"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
269 $doleditor->Create();
271 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
272 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>';
273 $doleditor =
new DolEditor(
"other-$key", $object->multilangs[$key][
"other"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
274 $doleditor->Create();
281 $parameters = array();
282 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
286 print
$form->buttonsSaveCancel();
289 } elseif ($action !=
'add') {
290 if (!empty($object->multilangs)) {
292 foreach ($object->multilangs as $key => $value) {
296 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>';
298 print
'<div class="fichecenter">';
299 print
'<div class="underbanner clearboth"></div>';
300 print
'<table class="border centpercent">';
301 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
302 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
303 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
304 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
310 if (!$cnt_trans && $action !=
'add') {
311 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
321 if ($action ==
'add' && ($user->rights->produit->creer || $user->rights->service->creer)) {
323 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
326 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
328 print
'<input type="hidden" name="action" value="vadd">';
329 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
'int').
'">';
333 print
'<table class="border centpercent">';
334 print
'<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Language').
'</td><td>';
335 print $formadmin->select_language(
GETPOST(
'forcelangprod'),
'forcelangprod', 0, $object->multilangs, 1);
337 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle" size="40"></td></tr>';
338 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
339 $doleditor =
new DolEditor(
'desc',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
340 $doleditor->Create();
343 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
344 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
'</td><td>';
345 $doleditor =
new DolEditor(
'other',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
346 $doleditor->Create();
351 $parameters = array();
352 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
356 print
$form->buttonsSaveCancel();
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage a WYSIWYG editor.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
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='')
Show tabs of a record.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
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.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
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.
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, $mode=0)
Check permissions of a user to show a page and an object.