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');
46 $socid = $user->socid;
49 if ($id > 0 || !empty($ref)) {
51 $object->fetch($id, $ref);
54 if ($object->id > 0) {
55 if ($object->type == $object::TYPE_PRODUCT) {
56 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
58 if ($object->type == $object::TYPE_SERVICE) {
59 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
62 restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
66 $hookmanager->initHooks(array(
'producttranslationcard',
'globalcard'));
73 $parameters = array(
'id'=>$id,
'ref'=>$ref);
74 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
78 if (empty($reshook)) {
80 if ($cancel == $langs->trans(
"Cancel")) {
84 if ($action ==
'delete' &&
GETPOST(
'langtodelete',
'alpha')) {
87 $object->delMultiLangs(
GETPOST(
'langtodelete',
'alpha'), $user);
93 if ($action ==
'vadd' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
96 $current_lang = $langs->getDefaultLang();
99 if (
GETPOST(
"forcelangprod") == $current_lang) {
100 $object->label =
GETPOST(
"libelle");
104 $object->update($object->id, $user);
106 $object->multilangs[
GETPOST(
"forcelangprod")][
"label"] =
GETPOST(
"libelle");
112 if (
GETPOST(
"forcelangprod")) {
113 $result = $object->setMultiLangs($user);
115 $object->error = $langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"Language"));
128 if ($action ==
'vedit' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
131 $current_lang = $langs->getDefaultLang();
133 foreach ($object->multilangs as $key => $value) {
134 if ($key == $current_lang) {
135 $object->label =
GETPOST(
"libelle-" . $key);
139 $object->multilangs[$key][
"label"] =
GETPOST(
"libelle-" . $key);
145 $result = $object->setMultiLangs($user);
155 if ($action ==
'vdelete' && $cancel != $langs->trans(
"Cancel") && ($user->rights->produit->creer || $user->rights->service->creer)) {
158 $langtodelete =
GETPOST(
'langdel',
'alpha');
160 $result = $object->delMultiLangs($langtodelete, $user);
171 $result = $object->fetch($id, $ref);
178 $title = $langs->trans(
'ProductServiceCard');
180 $shortlabel =
dol_trunc($object->label, 16);
182 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
183 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
186 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Translation');
187 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
196 $titre = $langs->trans(
"CardProduct".$object->type);
202 if (!empty($object->multilangs)) {
203 foreach ($object->multilangs as $key => $value) {
211 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1">'.$langs->trans(
"BackToList").
'</a>';
214 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
218 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref',
'',
'',
'', 0,
'',
'', 1);
227 print
"\n".
'<div class="tabsAction">'.
"\n";
229 $parameters = array();
230 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
231 if (empty($reshook)) {
233 if ($user->rights->produit->creer || $user->rights->service->creer) {
234 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=add&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Add") .
'</a>';
235 if ($cnt_trans > 0) {
236 print
'<a class="butAction" href="' . DOL_URL_ROOT .
'/product/traduction.php?action=edit&token='.newToken().
'&id=' . $object->id .
'">' . $langs->trans(
"Modify") .
'</a>';
242 print
"\n".
'</div>'.
"\n";
246 if ($action ==
'edit') {
248 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
250 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST">';
251 print
'<input type="hidden" name="token" value="'.newToken().
'">';
252 print
'<input type="hidden" name="action" value="vedit">';
253 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
255 if (!empty($object->multilangs)) {
257 foreach ($object->multilangs as $key => $value) {
261 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>';
263 print
'<div class="underbanner clearboth"></div>';
264 print
'<table class="border centpercent">';
265 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>';
266 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
267 $doleditor =
new DolEditor(
"desc-$key", $object->multilangs[$key][
"description"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
268 $doleditor->Create();
270 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
271 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>';
272 $doleditor =
new DolEditor(
"other-$key", $object->multilangs[$key][
"other"],
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
273 $doleditor->Create();
280 $parameters = array();
281 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
285 print
$form->buttonsSaveCancel();
288 } elseif ($action !=
'add') {
289 if (!empty($object->multilangs)) {
291 foreach ($object->multilangs as $key => $value) {
295 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>';
297 print
'<div class="fichecenter">';
298 print
'<div class="underbanner clearboth"></div>';
299 print
'<table class="border centpercent">';
300 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
'Label').
'</td><td>'.$object->multilangs[$key][
"label"].
'</td></tr>';
301 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>'.$object->multilangs[$key][
"description"].
'</td></tr>';
302 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
303 print
'<tr><td>'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
')</td><td>'.$object->multilangs[$key][
"other"].
'</td></tr>';
309 if (!$cnt_trans && $action !=
'add') {
310 print
'<div class="opacitymedium">'.$langs->trans(
'NoTranslation').
'</div>';
320 if ($action ==
'add' && ($user->rights->produit->creer || $user->rights->service->creer)) {
322 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
325 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="post">';
326 print
'<input type="hidden" name="token" value="'.newToken().
'">';
327 print
'<input type="hidden" name="action" value="vadd">';
328 print
'<input type="hidden" name="id" value="'.GETPOST(
"id",
'int').
'">';
332 print
'<table class="border centpercent">';
333 print
'<tr><td class="tdtop titlefieldcreate fieldrequired">'.$langs->trans(
'Language').
'</td><td>';
334 print $formadmin->select_language(
GETPOST(
'forcelangprod'),
'forcelangprod', 0, $object->multilangs, 1);
336 print
'<tr><td class="tdtop fieldrequired">'.$langs->trans(
'Label').
'</td><td><input name="libelle" size="40"></td></tr>';
337 print
'<tr><td class="tdtop">'.$langs->trans(
'Description').
'</td><td>';
338 $doleditor =
new DolEditor(
'desc',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
339 $doleditor->Create();
342 if (!empty($conf->global->PRODUCT_USE_OTHER_FIELD_IN_TRANSLATION)) {
343 print
'<tr><td class="tdtop">'.$langs->trans(
'Other').
' ('.$langs->trans(
"NotUsed").
'</td><td>';
344 $doleditor =
new DolEditor(
'other',
'',
'', 160,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_3,
'90%');
345 $doleditor->Create();
350 $parameters = array();
351 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
355 print
$form->buttonsSaveCancel();
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
if($cancel &&!$id) if($action== 'add'&&!$cancel) if($action== 'delete') if($id) $form
Actions.
Class to manage products or services.
if(!defined('NOREQUIRESOC')) if(!defined('NOREQUIRETRAN')) if(!defined('NOCSRFCHECK')) if(!defined('NOTOKENRENEWAL')) if(!defined('NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined('NOREQUIREAJAX')) llxHeader()
Empty header.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
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...
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, $mode=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.
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= '', $notitlealt=0)
Return img flag of country for a language code or country code.
product_prepare_head($object)
Prepare array with list of tabs.