30require
'../main.inc.php';
31require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
32require_once DOL_DOCUMENT_ROOT.
'/core/lib/functions2.lib.php';
33require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
34require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formadmin.class.php';
37$langs->loadLangs(array(
'products',
'languages'));
41$action =
GETPOST(
'action',
'aZ09');
42$cancel =
GETPOST(
'cancel',
'alpha');
45$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
46$fieldtype = (!empty($ref) ?
'ref' :
'rowid');
48 $socid = $user->socid;
51if ($id > 0 || !empty($ref)) {
53 $object->fetch($id, $ref);
57 if ($object->type == $object::TYPE_PRODUCT) {
58 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
60 if ($object->type == $object::TYPE_SERVICE) {
61 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
64 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
68$hookmanager->initHooks(array(
'producttranslationcard',
'globalcard'));
75$parameters = array(
'id'=>$id,
'ref'=>$ref);
76$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
82 if ($cancel == $langs->trans(
"Cancel")) {
86 if ($action ==
'delete' &&
GETPOST(
'langtodelete',
'alpha')) {
89 $object->delMultiLangs(
GETPOST(
'langtodelete',
'alpha'), $user);
95 if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
98 $current_lang = $langs->getDefaultLang();
101 if (
GETPOST(
"forcelangprod") == $current_lang) {
102 $object->label =
GETPOST(
"libelle");
106 $object->update($object->id, $user);
108 $object->multilangs[
GETPOST(
"forcelangprod")][
"label"] =
GETPOST(
"libelle");
114 if (
GETPOST(
"forcelangprod")) {
115 $result = $object->setMultiLangs($user);
117 $object->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language"));
130 if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
133 $current_lang = $langs->getDefaultLang();
135 foreach ($object->multilangs as $key => $value) {
136 if ($key == $current_lang) {
137 $object->label =
GETPOST(
"libelle-" . $key);
141 $object->update($object->id, $user);
143 $object->multilangs[$key][
"label"] =
GETPOST(
"libelle-" . $key);
149 $result = $object->setMultiLangs($user);
159 if ($action ==
'vdelete' && $cancel != $langs->trans(
"Cancel") && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
162 $langtodelete =
GETPOST(
'langdel',
'alpha');
164 $result = $object->delMultiLangs($langtodelete, $user);
175$result = $object->fetch($id, $ref);
182$title = $langs->trans(
'ProductServiceCard');
184$shortlabel =
dol_trunc($object->label, 16);
186 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
187 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
190 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
191 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
196$form =
new Form($db);
200$titre = $langs->trans(
"CardProduct".$object->type);
206if (!empty($object->multilangs)) {
207 foreach ($object->multilangs as $key => $value) {
215$linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
218if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
222dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'',
'',
'', 0,
'',
'', 1);
231print
"\n".
'<div class="tabsAction">'.
"\n";
233$parameters = array();
234$reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
235if (empty($reshook)) {
237 if ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer')) {
238 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=add&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Add") .
'</a>';
239 if ($cnt_trans > 0) {
240 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=edit&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Modify") .
'</a>';
246print
"\n".
'</div>'.
"\n";
250if ($action ==
'edit') {
252 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
254 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
255 print
'<input type="hidden" name="token" value="'.newToken().
'">';
256 print
'<input type="hidden" name="action" value="vedit">';
257 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
259 if (!empty($object->multilangs)) {
261 foreach ($object->multilangs as $key => $value) {
265 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>';
267 print
'<div class="underbanner clearboth"></div>';
268 print
'<table class="border centpercent">';
269 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>';
270 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
271 $doleditor =
new DolEditor(
"desc-$key", $object->multilangs[$key][
"description"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
272 $doleditor->Create();
274 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
275 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>';
276 $doleditor =
new DolEditor(
"other-$key", $object->multilangs[$key][
"other"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
277 $doleditor->Create();
284 $parameters = array();
285 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
289 print $form->buttonsSaveCancel();
292} elseif ($action !=
'add') {
293 if (!empty($object->multilangs)) {
295 foreach ($object->multilangs as $key => $value) {
299 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>';
301 print
'<div class="fichecenter">';
302 print
'<div class="underbanner clearboth"></div>';
303 print
'<table class="border centpercent">';
304 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
305 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
306 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
307 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
313 if (!$cnt_trans && $action !=
'add') {
314 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
324if ($action ==
'add' && ($user->hasRight(
'produit',
'creer') || $user->hasRight(
'service',
'creer'))) {
326 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
329 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
330 print
'<input type="hidden" name="token" value="'.newToken().
'">';
331 print
'<input type="hidden" name="action" value="vadd">';
332 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
'int').
'">';
336 print
'<table class="border centpercent">';
337 print
'<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Language').
'</td><td>';
338 print $formadmin->select_language(
GETPOST(
'forcelangprod'),
'forcelangprod', 0, $object->multilangs, 1);
340 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle" size="40"></td></tr>';
341 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
342 $doleditor =
new DolEditor(
'desc',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
343 $doleditor->Create();
346 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
347 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
'</td><td>';
348 $doleditor =
new DolEditor(
'other',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_3,
'90%');
349 $doleditor->Create();
354 $parameters = array();
355 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
359 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.
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.
img_delete($titlealt='default', $other='class="pictodelete"', $morecss='')
Show delete logo.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
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_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
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.