43 require
'../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
56 if (!empty($conf->propal->enabled)) require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
57 if (!empty($conf->facture->enabled)) require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
58 if (!empty($conf->commande->enabled)) require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
59 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
60 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
61 if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
64 $langs->loadLangs(array(
'products',
'other'));
65 if (!empty($conf->stock->enabled)) $langs->load(
"stocks");
66 if (!empty($conf->facture->enabled)) $langs->load(
"bills");
67 if (!empty($conf->productbatch->enabled)) $langs->load(
"productbatch");
69 $mesg =
''; $error = 0; $errors = array();
71 $refalreadyexists = 0;
76 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
77 $cancel =
GETPOST(
'cancel',
'alpha');
78 $backtopage =
GETPOST(
'backtopage',
'alpha');
79 $confirm =
GETPOST(
'confirm',
'alpha');
80 $socid =
GETPOST(
'socid',
'int');
81 $duration_value =
GETPOST(
'duration_value',
'int');
82 $duration_unit =
GETPOST(
'duration_unit',
'alpha');
84 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
85 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
86 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
87 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
88 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
89 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
92 $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ?
'alphanohtml' :
'restricthtml';
94 if (!empty($user->socid)) $socid = $user->socid;
97 $object->type = $type;
101 $extrafields->fetch_name_optionals_label($object->table_element);
103 if ($id > 0 || !empty($ref))
105 $result = $object->fetch($id, $ref);
107 if (!empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
108 elseif (!empty($conf->service->enabled)) $upload_dir = $conf->service->multidir_output[$object->entity].'/'.
get_exdir(0, 0, 0, 0, $object, 'product').
dol_sanitizeFileName($object->ref);
110 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO))
112 if (!empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
113 else $upload_dirold = $conf->service->multidir_output[$object->entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
117 $modulepart =
'product';
120 $canvas = !empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas");
124 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
125 $objcanvas =
new Canvas($db, $action);
126 $objcanvas->getCanvas(
'product',
'card', $canvas);
130 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
131 $fieldtype = (!empty($id) ?
'rowid' :
'ref');
132 $result =
restrictedArea($user,
'produit|service', $fieldvalue,
'product&product',
'',
'', $fieldtype);
135 $hookmanager->initHooks(array(
'productcard',
'globalcard'));
143 if ($cancel) $action =
'';
148 $createbarcode = empty($conf->barcode->enabled) ? 0 : 1;
149 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) $createbarcode = 0;
151 $parameters = array(
'id'=>$id,
'ref'=>$ref,
'objcanvas'=>$objcanvas);
152 $reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
153 if ($reshook < 0)
setEventMessages($hookmanager->error, $hookmanager->errors,
'errors');
158 if ($action ==
'setfk_product_type' && $usercancreate)
160 $result = $object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'', null,
'text',
'', $user,
'PRODUCT_MODIFY');
161 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
166 $upload_dir = $conf->product->dir_output;
167 $permissiontoadd = $usercancreate;
168 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
170 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
173 if ($action ==
'setfk_barcode_type' && $createbarcode)
175 $result = $object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'', null,
'text',
'', $user,
'PRODUCT_MODIFY');
176 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
181 if ($action ==
'setbarcode' && $createbarcode)
183 $result = $object->check_barcode(
GETPOST(
'barcode'),
GETPOST(
'barcode_type_code'));
187 $result = $object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'', null,
'text',
'', $user,
'PRODUCT_MODIFY');
188 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
191 $langs->load(
"errors");
192 if ($result == -1) $errors[] =
'ErrorBadBarCodeSyntax';
193 elseif ($result == -2) $errors[] = 'ErrorBarCodeRequired';
194 elseif ($result == -3) $errors[] = 'ErrorBarCodeAlreadyUsed';
195 else $errors[] = 'FailedToValidateBarCode';
203 if ($action == 'add' && $usercancreate)
207 if (!
GETPOST(
'label', $label_security_check))
209 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')), null,
'errors');
215 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Ref')), null,
'errors');
219 if (!empty($duration_value) && empty($duration_unit))
221 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')), null,
'errors');
228 $units =
GETPOST(
'units',
'int');
231 $object->label =
GETPOST(
'label', $label_security_check);
232 $object->price_base_type =
GETPOST(
'price_base_type',
'aZ09');
234 if ($object->price_base_type ==
'TTC')
235 $object->price_ttc =
GETPOST(
'price');
236 else $object->price =
GETPOST(
'price');
237 if ($object->price_base_type ==
'TTC')
238 $object->price_min_ttc =
GETPOST(
'price_min');
239 else $object->price_min =
GETPOST(
'price_min');
241 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
245 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
246 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
247 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
250 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg))
253 $vatratecode = $reg[1];
255 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
256 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
257 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
258 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
259 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
260 $resql = $db->query($sql);
263 $obj = $db->fetch_object(
$resql);
264 $npr = $obj->recuperableonly;
265 $localtax1 = $obj->localtax1;
266 $localtax2 = $obj->localtax2;
267 $localtax1_type = $obj->localtax1_type;
268 $localtax2_type = $obj->localtax2_type;
272 $object->default_vat_code = $vatratecode;
273 $object->tva_tx = $tva_tx;
274 $object->tva_npr = $npr;
275 $object->localtax1_tx = $localtax1;
276 $object->localtax2_tx = $localtax2;
277 $object->localtax1_type = $localtax1_type;
278 $object->localtax2_type = $localtax2_type;
280 $object->type = $type;
281 $object->status =
GETPOST(
'statut');
282 $object->status_buy =
GETPOST(
'statut_buy');
283 $object->status_batch =
GETPOST(
'status_batch');
285 $object->barcode_type =
GETPOST(
'fk_barcode_type');
286 $object->barcode =
GETPOST(
'barcode');
289 $stdobject->element =
'product';
290 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
291 $result = $stdobject->fetch_barcode();
295 $mesg =
'Failed to get bar code type information ';
296 setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors,
'errors');
298 $object->barcode_type_code = $stdobject->barcode_type_code;
299 $object->barcode_type_coder = $stdobject->barcode_type_coder;
300 $object->barcode_type_label = $stdobject->barcode_type_label;
305 $object->note = $object->note_private;
306 $object->customcode =
GETPOST(
'customcode',
'alphanohtml');
307 $object->country_id =
GETPOST(
'country_id',
'int');
308 $object->state_id =
GETPOST(
'state_id',
'int');
309 $object->duration_value = $duration_value;
310 $object->duration_unit = $duration_unit;
311 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
312 $object->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte') ?
GETPOST(
'seuil_stock_alerte') : 0;
313 $object->desiredstock =
GETPOST(
'desiredstock') ?
GETPOST(
'desiredstock') : 0;
314 $object->canvas =
GETPOST(
'canvas');
315 $object->net_measure =
GETPOST(
'net_measure');
316 $object->net_measure_units =
GETPOST(
'net_measure_units');
317 $object->weight =
GETPOST(
'weight');
318 $object->weight_units =
GETPOST(
'weight_units');
319 $object->length =
GETPOST(
'size');
320 $object->length_units =
GETPOST(
'size_units');
321 $object->width =
GETPOST(
'sizewidth');
322 $object->height =
GETPOST(
'sizeheight');
323 $object->surface =
GETPOST(
'surface');
324 $object->surface_units =
GETPOST(
'surface_units');
325 $object->volume =
GETPOST(
'volume');
326 $object->volume_units =
GETPOST(
'volume_units');
327 $finished =
GETPOST(
'finished',
'int');
329 $object->finished = $finished;
331 $object->finished = null;
334 $units =
GETPOST(
'units',
'int');
336 $object->fk_unit = $units;
338 $object->fk_unit = null;
341 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
342 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
343 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
344 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
345 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
346 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
348 if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell =
''; }
else { $object->accountancy_code_sell = $accountancy_code_sell; }
349 if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra =
''; }
else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; }
350 if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export =
''; }
else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; }
351 if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy =
''; }
else { $object->accountancy_code_buy = $accountancy_code_buy; }
352 if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra =
''; }
else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; }
353 if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export =
''; }
else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; }
356 if (!empty($conf->global->PRODUIT_MULTIPRICES))
358 for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++)
362 $object->multiprices[
"$i"] =
price2num($_POST[
"price_".$i],
'MU');
363 $object->multiprices_base_type[
"$i"] = $_POST[
"multiprices_base_type_".$i];
365 $object->multiprices[
"$i"] =
"";
371 $ret = $extrafields->setOptionalsFromPost(null, $object);
372 if ($ret < 0) $error++;
376 $id = $object->create($user);
382 $categories =
GETPOST(
'categories',
'array');
383 $object->setCategories($categories);
385 if (!empty($backtopage))
387 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
388 if (preg_match(
'/\?/', $backtopage)) $backtopage .=
'&socid='.$object->id;
389 header(
"Location: ".$backtopage);
392 header(
"Location: ".
$_SERVER[
'PHP_SELF'].
"?id=".$id);
396 if (count($object->errors))
setEventMessages($object->error, $object->errors,
'errors');
404 if ($action ==
'update' && $usercancreate)
406 if (
GETPOST(
'cancel',
'alpha'))
412 $object->oldcopy = clone $object;
415 $object->label =
GETPOST(
'label', $label_security_check);
418 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
421 $object->note = $object->note_private;
423 $object->customcode =
GETPOST(
'customcode',
'alpha');
424 $object->country_id =
GETPOST(
'country_id',
'int');
425 $object->state_id =
GETPOST(
'state_id',
'int');
426 $object->status =
GETPOST(
'statut',
'int');
427 $object->status_buy =
GETPOST(
'statut_buy',
'int');
428 $object->status_batch =
GETPOST(
'status_batch',
'aZ09');
430 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
435 $object->duration_value =
GETPOST(
'duration_value',
'int');
436 $object->duration_unit =
GETPOST(
'duration_unit',
'alpha');
438 $object->canvas =
GETPOST(
'canvas');
439 $object->net_measure =
GETPOST(
'net_measure');
440 $object->net_measure_units =
GETPOST(
'net_measure_units');
441 $object->weight =
GETPOST(
'weight');
442 $object->weight_units =
GETPOST(
'weight_units');
443 $object->length =
GETPOST(
'size');
444 $object->length_units =
GETPOST(
'size_units');
445 $object->width =
GETPOST(
'sizewidth');
446 $object->height =
GETPOST(
'sizeheight');
448 $object->surface =
GETPOST(
'surface');
449 $object->surface_units =
GETPOST(
'surface_units');
450 $object->volume =
GETPOST(
'volume');
451 $object->volume_units =
GETPOST(
'volume_units');
453 $finished =
GETPOST(
'finished',
'int');
454 if ($finished >= 0) {
455 $object->finished = $finished;
457 $object->finished = null;
460 $units =
GETPOST(
'units',
'int');
462 $object->fk_unit = $units;
464 $object->fk_unit = null;
467 $object->barcode_type =
GETPOST(
'fk_barcode_type');
468 $object->barcode =
GETPOST(
'barcode');
471 $stdobject->element =
'product';
472 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
473 $result = $stdobject->fetch_barcode();
477 $mesg =
'Failed to get bar code type information ';
478 setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors,
'errors');
480 $object->barcode_type_code = $stdobject->barcode_type_code;
481 $object->barcode_type_coder = $stdobject->barcode_type_coder;
482 $object->barcode_type_label = $stdobject->barcode_type_label;
484 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
485 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
486 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
487 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
488 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
489 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
491 if ($accountancy_code_sell <= 0) { $object->accountancy_code_sell =
''; }
else { $object->accountancy_code_sell = $accountancy_code_sell; }
492 if ($accountancy_code_sell_intra <= 0) { $object->accountancy_code_sell_intra =
''; }
else { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; }
493 if ($accountancy_code_sell_export <= 0) { $object->accountancy_code_sell_export =
''; }
else { $object->accountancy_code_sell_export = $accountancy_code_sell_export; }
494 if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy =
''; }
else { $object->accountancy_code_buy = $accountancy_code_buy; }
495 if ($accountancy_code_buy_intra <= 0) { $object->accountancy_code_buy_intra =
''; }
else { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; }
496 if ($accountancy_code_buy_export <= 0) { $object->accountancy_code_buy_export =
''; }
else { $object->accountancy_code_buy_export = $accountancy_code_buy_export; }
499 $ret = $extrafields->setOptionalsFromPost(null, $object);
500 if ($ret < 0) $error++;
502 if (!$error && $object->check())
504 if ($object->update($object->id, $user) > 0)
507 $categories =
GETPOST(
'categories',
'array');
508 $object->setCategories($categories);
512 if (count($object->errors))
setEventMessages($object->error, $object->errors,
'errors');
517 if (count($object->errors))
setEventMessages($object->error, $object->errors,
'errors');
518 else setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"), null,
'errors');
526 if ($action ==
'confirm_clone' && $confirm !=
'yes') { $action =
''; }
527 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate)
538 $object->ref =
GETPOST(
'clone_ref',
'alphanohtml');
540 $object->status_buy = 0;
542 $object->barcode = -1;
544 if ($object->check())
546 $object->context[
'createfromclone'] =
'createfromclone';
547 $id = $object->create($user);
550 if (
GETPOST(
'clone_composition'))
552 $result = $object->clone_associations($originalId, $id);
558 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
563 if (
GETPOST(
'clone_categories'))
565 $result = $object->cloneCategories($originalId, $id);
571 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
577 $result = $object->clone_price($originalId, $id);
582 header(
'Location: '.
$_SERVER[
'PHP_SELF'].
'?id='.$originalId);
592 header(
"Location: ".
$_SERVER[
"PHP_SELF"].
"?id=".$id);
597 if ($object->error ==
'ErrorProductAlreadyExists')
604 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $object->ref);
605 $mesg .=
' <a href="'.$_SERVER[
"PHP_SELF"].
'?ref='.$object->ref.
'">'.$langs->trans(
"ShowCardHere").
'</a>.';
610 if (count($object->errors))
621 unset($object->context[
'createfromclone']);
631 if ($action ==
'confirm_delete' && $confirm !=
'yes') { $action =
''; }
632 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete)
634 $result = $object->delete($user);
638 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.$object->type.
'&delprod='.urlencode($object->ref));
649 if ($object->id > 0 && $action ==
'addin')
654 $propal =
new Propal($db);
655 $result = $propal->fetch(
GETPOST(
'propalid'));
661 $thirpdartyid = $propal->socid;
662 } elseif (
GETPOST(
'commandeid') > 0)
665 $result = $commande->fetch(
GETPOST(
'commandeid'));
671 $thirpdartyid = $commande->socid;
672 } elseif (
GETPOST(
'factureid') > 0)
675 $result = $facture->fetch(
GETPOST(
'factureid'));
681 $thirpdartyid = $facture->socid;
684 if ($thirpdartyid > 0) {
686 $result = $soc->fetch($thirpdartyid);
692 $desc = $object->description;
696 if (empty($tva_tx)) $tva_npr = 0;
697 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
698 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
700 $pu_ht = $object->price;
701 $pu_ttc = $object->price_ttc;
702 $price_base_type = $object->price_base_type;
705 if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
706 $pu_ht = $object->multiprices[$soc->price_level];
707 $pu_ttc = $object->multiprices_ttc[$soc->price_level];
708 $price_base_type = $object->multiprices_base_type[$soc->price_level];
709 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
710 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
714 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' => $soc->id);
716 $result = $prodcustprice->fetch_all(
'',
'', 0, 0, $filter);
718 if (count($prodcustprice->lines) > 0) {
719 $pu_ht =
price($prodcustprice->lines [0]->price);
720 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
721 $price_base_type = $prodcustprice->lines [0]->price_base_type;
722 $tva_tx = $prodcustprice->lines [0]->tva_tx;
727 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
728 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
732 if ($tmpvat != $tmpprodvat) {
733 if ($price_base_type !=
'HT') {
734 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
736 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
743 if (($result = $propal->defineBuyPrice($pu_ht,
GETPOST(
'remise_percent'), $object->id)) < 0)
745 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
751 $result = $propal->addline(
776 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
780 setEventMessages($langs->trans(
"ErrorUnknown").
": $result", null,
'errors');
781 } elseif (
GETPOST(
'commandeid') > 0) {
784 if (($result = $commande->defineBuyPrice($pu_ht,
GETPOST(
'remise_percent'), $object->id)) < 0)
786 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
792 $result = $commande->addline(
819 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".$commande->id);
822 } elseif (
GETPOST(
'factureid') > 0) {
825 if (($result = $facture->defineBuyPrice($pu_ht,
GETPOST(
'remise_percent'), $object->id)) < 0)
827 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
833 $result = $facture->addline(
865 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
871 setEventMessages($langs->trans(
"WarningSelectOneDocument"), null,
'warnings');
882 $title = $langs->trans(
'ProductServiceCard');
884 $shortlabel =
dol_trunc($object->label, 16);
887 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
888 $helpurl =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos';
892 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
893 $helpurl =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios';
898 $form =
new Form($db);
902 if (!empty($conf->accounting->enabled)) $formaccounting =
new FormAccounting($db);
906 if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM))
908 $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
909 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
910 foreach ($dirbarcode as $dirroot)
917 $modBarCodeProduct =
new $module();
922 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
926 if (empty($object->error) && $id)
929 $result = $object->fetch($id);
932 $objcanvas->assign_values($action, $object->id, $object->ref);
933 $objcanvas->display_canvas($action);
938 if ($action ==
'create' && $usercancreate) {
940 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
942 print '<script type="text/javascript">';
943 print '$(document).ready(function () {
944 $("#selectcountry_id").change(function() {
945 document.formprod.action.value="create";
946 document.formprod.submit();
949 print '</script>'.
"\n";
952 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
953 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php')
955 $module = substr($module, 0,
dol_strlen($module) - 4);
960 $modCodeProduct =
new $module();
965 print '<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
966 print '<input type="hidden" name="token" value="'.newToken().
'">';
967 print '<input type="hidden" name="action" value="add">';
968 print '<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
969 if (!empty($modCodeProduct->code_auto))
970 print '<input type="hidden" name="code_auto" value="1">';
971 if (!empty($modBarCodeProduct->code_auto))
972 print '<input type="hidden" name="barcode_auto" value="1">';
973 print '<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
977 $title = $langs->trans(
"NewService");
980 $title = $langs->trans(
"NewProduct");
987 if ($object->country_id > 0)
989 $tmparray =
getCountry($object->country_id,
'all');
990 $object->country_code = $tmparray[
'code'];
991 $object->country = $tmparray[
'label'];
996 print '<table class="border centpercent">';
1000 if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $type);
1001 print '<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td colspan="3"><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(
GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1002 if ($refalreadyexists)
1004 print $langs->trans(
"RefAlreadyExists");
1009 print '<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag(
GETPOST(
'label', $label_security_check)).
'"></td></tr>';
1012 print '<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1013 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1014 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1018 print '<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
1019 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1020 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1024 if (!empty($conf->productbatch->enabled))
1026 print '<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td colspan="3">';
1027 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"));
1028 print $form->selectarray(
'status_batch', $statutarray,
GETPOST(
'status_batch'));
1032 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1033 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
1037 print '<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1039 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
1041 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
1043 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1045 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1047 if ($conf->browser->layout ==
'phone')
print '</tr><tr>';
1048 print '<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1050 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type);
1051 print '<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1056 print '<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td colspan="3">';
1058 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4,
'90%');
1059 $doleditor->Create();
1064 print '<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td colspan="3">';
1065 print '<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1068 if ($type != 1 && !empty($conf->stock->enabled))
1071 print '<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1072 print $formproduct->selectWarehouses(
GETPOST(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1);
1073 print ' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit').
'">';
1074 print '<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1080 print '<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1081 print '<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1083 if ($conf->browser->layout ==
'phone')
print '</tr><tr>';
1085 print '<td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1086 print '<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1089 print '<input name="seuil_stock_alerte" type="hidden" value="0">';
1090 print '<input name="desiredstock" type="hidden" value="0">';
1096 print '<tr><td>'.$langs->trans(
"Duration").
'</td><td colspan="3">';
1097 print '<input name="duration_value" size="4" value="'.GETPOST(
'duration_value',
'int').
'">';
1098 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time",
GETPOST(
'duration_value',
'alpha'), 0, 1);
1105 print '<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td colspan="3">';
1106 $statutarray = array(
'1' => $langs->trans(
"Finished"),
'0' => $langs->trans(
"RowMaterial"));
1107 print $form->selectarray(
'finished', $statutarray,
GETPOST(
'finished',
'alpha'), 1);
1111 print '<tr><td>'.$langs->trans(
"Weight").
'</td><td colspan="3">';
1112 print '<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1113 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units',
'alpha') : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2);
1117 if (empty($conf->global->PRODUCT_DISABLE_SIZE))
1119 print '<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td colspan="3">';
1120 print '<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1121 print '<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1122 print '<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1123 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') :
'0', 0, 2);
1126 if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
1129 print '<tr><td>'.$langs->trans(
"Surface").
'</td><td colspan="3">';
1130 print '<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1131 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') :
'0', 0, 2);
1134 if (empty($conf->global->PRODUCT_DISABLE_VOLUME))
1137 print '<tr><td>'.$langs->trans(
"Volume").
'</td><td colspan="3">';
1138 print '<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1139 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') :
'0', 0, 2);
1143 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE))
1146 print '<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td colspan="3">';
1147 print '<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1148 print $formproduct->selectMeasuringUnits(
"net_measure_units",
'',
GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units',
'alpha') : (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT) ? 0 : $conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 0);
1154 if (!empty($conf->global->PRODUCT_USE_UNITS))
1156 print '<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1157 print '<td colspan="3">';
1158 print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
'units');
1163 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type))
1165 print '<tr><td>'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1168 print '<td>'.$langs->trans(
"CountryOrigin").
'</td>';
1170 print img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1171 print $form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx');
1172 if ($user->admin)
print info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1176 if (empty($conf->global->PRODUCT_DISABLE_STATE))
1178 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
1179 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1181 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1183 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1186 print $formcompany->select_state($object->state_id, $object->country_code);
1194 $parameters = array(
'colspan' => 3,
'cols' =>
'3');
1195 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1196 print $hookmanager->resPrint;
1197 if (empty($reshook))
1199 print $object->showOptionals($extrafields,
'edit', $parameters);
1205 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td colspan="3">';
1208 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_8,
'90%');
1209 $doleditor->Create();
1214 if ($conf->categorie->enabled) {
1216 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1217 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
1218 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1226 if (!empty($conf->global->PRODUIT_MULTIPRICES))
1230 print
'<table class="border centpercent">';
1232 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1234 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1240 print
'<table class="border centpercent">';
1243 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1244 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1245 print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE,
"price_base_type");
1249 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1250 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1254 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1256 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1265 print
'<table class="border centpercent">';
1267 if (!empty($conf->accounting->enabled))
1270 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1273 $accountancy_code_sell = (
GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_ACCOUNT);
1275 $accountancy_code_sell = (
GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_ACCOUNT);
1277 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1281 if ($mysoc->isInEEC())
1283 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1286 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT);
1288 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT);
1290 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1295 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1299 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') : $conf->global->ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT);
1301 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') : $conf->global->ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT);
1303 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1307 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1310 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) : $conf->global->ACCOUNTING_PRODUCT_BUY_ACCOUNT);
1312 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) : $conf->global->ACCOUNTING_SERVICE_BUY_ACCOUNT);
1314 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1318 if ($mysoc->isInEEC())
1320 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1323 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT);
1325 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT);
1327 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1332 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1336 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') : $conf->global->ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT);
1338 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') : $conf->global->ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT);
1340 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1, null, 1, 1,
'minwidth100 maxwidth300 maxwidthonsmartphone', 1);
1344 if (!empty($accountancy_code_sell)) { $object->accountancy_code_sell = $accountancy_code_sell; }
1345 if (!empty($accountancy_code_sell_intra)) { $object->accountancy_code_sell_intra = $accountancy_code_sell_intra; }
1346 if (!empty($accountancy_code_sell_export)) { $object->accountancy_code_sell_export = $accountancy_code_sell_export; }
1347 if (!empty($accountancy_code_buy)) { $object->accountancy_code_buy = $accountancy_code_buy; }
1348 if (!empty($accountancy_code_buy_intra)) { $object->accountancy_code_buy_intra = $accountancy_code_buy_intra; }
1349 if (!empty($accountancy_code_buy_export)) { $object->accountancy_code_buy_export = $accountancy_code_buy_export; }
1352 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1353 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1357 if ($mysoc->isInEEC())
1359 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1360 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1365 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1366 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1370 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1371 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1375 if ($mysoc->isInEEC())
1377 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1378 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1383 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1384 print
'<td class="maxwidthonsmartphone"><input class="minwidth100" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1391 print
'<div class="center">';
1392 print
'<input type="submit" class="button" value="'.$langs->trans(
"Create").
'">';
1393 print
' ';
1394 print
'<input type="button" class="button button-cancel" value="'.$langs->trans(
"Cancel").
'" onClick="javascript:history.go(-1)">';
1398 } elseif ($object->id > 0) {
1403 if ($action ==
'edit' && $usercancreate)
1406 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1408 print
'<script type="text/javascript">';
1409 print
'$(document).ready(function () {
1410 $("#selectcountry_id").change(function () {
1411 document.formprod.action.value="edit";
1412 document.formprod.submit();
1415 print
'</script>'.
"\n";
1418 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $object->country_id;
1419 if ($object->country_id)
1421 $tmparray =
getCountry($object->country_id,
'all');
1422 $object->country_code = $tmparray[
'code'];
1423 $object->country = $tmparray[
'label'];
1427 $type = $langs->trans(
'Product');
1428 if ($object->isService()) $type = $langs->trans(
'Service');
1432 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="formprod">'.
"\n";
1433 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1434 print
'<input type="hidden" name="action" value="update">';
1435 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1436 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1439 $titre = $langs->trans(
"CardProduct".$object->type);
1444 print
'<table class="border allwidth">';
1447 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag($object->ref).
'"></td></tr>';
1450 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag($object->label).
'"></td></tr>';
1453 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1454 print
'<select class="flat" name="statut">';
1455 if ($object->status)
1457 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
1458 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
1460 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
1461 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
1467 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
1468 print
'<select class="flat" name="statut_buy">';
1469 if ($object->status_buy)
1471 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1472 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1474 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1475 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1481 if ($conf->productbatch->enabled)
1483 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
1485 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td colspan="3">';
1486 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"));
1487 print $form->selectarray(
'status_batch', $statutarray, $object->status_batch);
1493 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1494 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
1498 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1500 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
1502 $fk_barcode_type = $object->barcode_type;
1503 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
1505 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1507 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1508 print
'</td><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1510 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type);
1511 print
'<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1516 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td colspan="3">';
1519 $doleditor =
new DolEditor(
'desc', $object->description,
'', 160,
'dolibarr_details',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4,
'90%');
1520 $doleditor->Create();
1526 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td colspan="3">';
1527 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.$object->url.
'">';
1531 if ($object->isProduct() && !empty($conf->stock->enabled))
1534 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1535 print $formproduct->selectWarehouses($object->fk_default_warehouse,
'fk_default_warehouse',
'warehouseopen', 1);
1536 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode(
$_SERVER[
'PHP_SELF'].
'?action=create&type='.
GETPOST(
'type',
'int')).
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
1555 if ($object->isService())
1558 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td colspan="3">';
1559 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
1560 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", $object->duration_unit, 0, 1);
1564 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td colspan="3">';
1565 print $formproduct->selectProductNature(
'finished', $object->finished);
1569 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td colspan="3">';
1570 print
'<input name="weight" size="5" value="'.$object->weight.
'"> ';
1571 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", $object->weight_units, 0, 2);
1574 if (empty($conf->global->PRODUCT_DISABLE_SIZE))
1577 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td colspan="3">';
1578 print
'<input name="size" size="5" value="'.$object->length.
'">x';
1579 print
'<input name="sizewidth" size="5" value="'.$object->width.
'">x';
1580 print
'<input name="sizeheight" size="5" value="'.$object->height.
'"> ';
1581 print $formproduct->selectMeasuringUnits(
"size_units",
"size", $object->length_units, 0, 2);
1584 if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
1587 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td colspan="3">';
1588 print
'<input name="surface" size="5" value="'.$object->surface.
'"> ';
1589 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", $object->surface_units, 0, 2);
1592 if (empty($conf->global->PRODUCT_DISABLE_VOLUME))
1595 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td colspan="3">';
1596 print
'<input name="volume" size="5" value="'.$object->volume.
'"> ';
1597 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", $object->volume_units, 0, 2);
1601 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE))
1604 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td colspan="3">';
1605 print
'<input name="net_measure" size="5" value="'.$object->net_measure.
'"> ';
1606 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", $object->net_measure_units, 0, 0);
1611 if (!empty($conf->global->PRODUCT_USE_UNITS))
1613 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1614 print
'<td colspan="3">';
1615 print $form->selectUnits($object->fk_unit,
'units');
1620 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO))
1622 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.
'"></td></tr>';
1624 print
'<td>'.$langs->trans(
"CountryOrigin").
'</td>';
1626 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1627 print $form->select_country($object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
1628 if ($user->admin) print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1631 if (empty($conf->global->PRODUCT_DISABLE_STATE))
1633 if ($conf->browser->layout ==
'phone') print
'</tr><tr>';
1634 if (!empty($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT) && ($conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 1 || $conf->global->MAIN_SHOW_REGION_IN_STATE_SELECT == 2))
1636 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1638 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td colspan="3">';
1641 print $formcompany->select_state($object->state_id, $object->country_code);
1648 $parameters = array(
'colspan' =>
' colspan="3"',
'cols' => 3);
1649 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1650 print $hookmanager->resPrint;
1651 if (empty($reshook))
1653 print $object->showOptionals($extrafields,
'edit', $parameters);
1657 if ($conf->categorie->enabled)
1659 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td colspan="3">';
1660 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
1662 $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT);
1663 $arrayselected = array();
1664 if (is_array($cats)) {
1665 foreach ($cats as $cat) {
1666 $arrayselected[] = $cat->id;
1669 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1674 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
1676 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td colspan="3">';
1678 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true, $conf->global->FCKEDITOR_ENABLE_PRODUCTDESC, ROWS_4,
'90%');
1679 $doleditor->Create();
1688 print
'<table class="border centpercent">';
1690 if (!empty($conf->accounting->enabled))
1693 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1695 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1);
1699 if ($mysoc->isInEEC())
1701 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1703 print $formaccounting->select_account($object->accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
'', 1, 1);
1708 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1710 print $formaccounting->select_account($object->accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
'', 1, 1);
1714 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1716 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1);
1720 if ($mysoc->isInEEC())
1722 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1724 print $formaccounting->select_account($object->accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
'', 1, 1);
1729 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1731 print $formaccounting->select_account($object->accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
'', 1, 1);
1736 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1737 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
1741 if ($mysoc->isInEEC())
1743 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1744 print
'<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.
'">';
1749 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1750 print
'<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.$object->accountancy_code_sell_export.
'">';
1754 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1755 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
1759 if ($mysoc->isInEEC())
1761 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1762 print
'<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="'.$object->accountancy_code_buy_intra.
'">';
1767 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1768 print
'<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.$object->accountancy_code_buy_export.
'">';
1775 print
'<div class="center">';
1776 print
'<input type="submit" class="button button-save" value="'.$langs->trans(
"Save").
'">';
1777 print
' ';
1778 print
'<input type="submit" class="button button-cancel" name="cancel" value="'.$langs->trans(
"Cancel").
'">';
1784 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1785 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) $showbarcode = 0;
1788 $titre = $langs->trans(
"CardProduct".$object->type);
1793 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
1794 $object->next_prev_filter =
" fk_product_type = ".$object->type;
1797 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) $shownav = 0;
1802 print
'<div class="fichecenter">';
1803 print
'<div class="fichehalfleft">';
1805 print
'<div class="underbanner clearboth"></div>';
1806 print
'<table class="border tableforfield" width="100%">';
1809 if (!empty($conf->product->enabled) && !empty($conf->service->enabled))
1812 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
1813 print
'<tr><td class="titlefield">';
1814 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
1815 print
'</td><td colspan="2">';
1816 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
1823 print
'<tr><td class="nowrap">';
1824 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1825 print $langs->trans(
"BarcodeType");
1827 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbarcodetype&id='.$object->id.
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
1828 print
'</tr></table>';
1829 print
'</td><td colspan="2">';
1830 if ($action ==
'editbarcodetype' || $action ==
'editbarcode')
1832 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1835 if ($action ==
'editbarcodetype')
1837 print $formbarcode->formBarcodeType(
$_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->barcode_type,
'fk_barcode_type');
1839 $object->fetch_barcode();
1840 print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
1842 print
'</td></tr>'.
"\n";
1845 print
'<tr><td class="nowrap">';
1846 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
1847 print $langs->trans(
"BarcodeValue");
1849 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbarcode&id='.$object->id.
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
1850 print
'</tr></table>';
1851 print
'</td><td colspan="2">';
1852 if ($action ==
'editbarcode')
1855 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) $tmpcode = $modBarCodeProduct->getNextValue($object, $type);
1857 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
1858 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1859 print
'<input type="hidden" name="action" value="setbarcode">';
1860 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
1861 print
'<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
1862 print
' <input type="submit" class="button" value="'.$langs->trans(
"Modify").
'">';
1865 print $object->barcode;
1867 print
'</td></tr>'.
"\n";
1871 print
'<tr><td class="nowrap">';
1872 print $langs->trans(
"ProductAccountancySellCode");
1873 print
'</td><td colspan="2">';
1874 if (!empty($conf->accounting->enabled))
1876 if (!empty($object->accountancy_code_sell))
1879 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
1881 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
1884 print $object->accountancy_code_sell;
1889 if ($mysoc->isInEEC())
1891 print
'<tr><td class="nowrap">';
1892 print $langs->trans(
"ProductAccountancySellIntraCode");
1893 print
'</td><td colspan="2">';
1894 if (!empty($conf->accounting->enabled))
1896 if (!empty($object->accountancy_code_sell_intra))
1899 $accountingaccount2->fetch(
'', $object->accountancy_code_sell_intra, 1);
1901 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
1904 print $object->accountancy_code_sell_intra;
1910 print
'<tr><td class="nowrap">';
1911 print $langs->trans(
"ProductAccountancySellExportCode");
1912 print
'</td><td colspan="2">';
1913 if (!empty($conf->accounting->enabled))
1915 if (!empty($object->accountancy_code_sell_export))
1918 $accountingaccount3->fetch(
'', $object->accountancy_code_sell_export, 1);
1920 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
1923 print $object->accountancy_code_sell_export;
1928 print
'<tr><td class="nowrap">';
1929 print $langs->trans(
"ProductAccountancyBuyCode");
1930 print
'</td><td colspan="2">';
1931 if (!empty($conf->accounting->enabled))
1933 if (!empty($object->accountancy_code_buy))
1936 $accountingaccount4->fetch(
'', $object->accountancy_code_buy, 1);
1938 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
1941 print $object->accountancy_code_buy;
1946 if ($mysoc->isInEEC())
1948 print
'<tr><td class="nowrap">';
1949 print $langs->trans(
"ProductAccountancyBuyIntraCode");
1950 print
'</td><td colspan="2">';
1951 if (!empty($conf->accounting->enabled))
1953 if (!empty($object->accountancy_code_buy_intra))
1956 $accountingaccount5->fetch(
'', $object->accountancy_code_buy_intra, 1);
1958 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
1961 print $object->accountancy_code_buy_intra;
1967 print
'<tr><td class="nowrap">';
1968 print $langs->trans(
"ProductAccountancyBuyExportCode");
1969 print
'</td><td colspan="2">';
1970 if (!empty($conf->accounting->enabled))
1972 if (!empty($object->accountancy_code_buy_export))
1975 $accountingaccount6->fetch(
'', $object->accountancy_code_buy_export, 1);
1977 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
1980 print $object->accountancy_code_buy_export;
1985 if (!empty($conf->productbatch->enabled))
1987 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES))
1989 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td colspan="2">';
1990 if (!empty($conf->use_javascript_ajax) && $usercancreate && !empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
1991 print
ajax_object_onoff($object,
'status_batch',
'tobatch',
'ProductStatusOnBatch',
'ProductStatusNotOnBatch');
1993 print $object->getLibStatut(0, 2);
2000 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td colspan="2">'.(
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true)).
'</td></tr>';
2003 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td colspan="2">';
2008 if ($object->isProduct() && !empty($conf->stock->enabled))
2011 $warehouse->fetch($object->fk_default_warehouse);
2013 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2014 print (!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2019 if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
2022 if ($combination->fetchByFkProductChild($object->id) > 0) {
2023 $prodstatic =
new Product($db);
2024 $prodstatic->fetch($combination->fk_product_parent);
2027 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td colspan="2">';
2028 print $prodstatic->getNomUrl(1);
2035 print
'<div class="fichehalfright"><div class="ficheaddleft">';
2037 print
'<div class="underbanner clearboth"></div>';
2038 print
'<table class="border tableforfield" width="100%">';
2040 if ($object->isService())
2043 print
'<tr><td class="titlefield">'.$langs->trans(
"Duration").
'</td><td colspan="2">'.$object->duration_value.
' ';
2044 if ($object->duration_value > 1)
2046 $dur = array(
"i"=>$langs->trans(
"Minute"),
"h"=>$langs->trans(
"Hours"),
"d"=>$langs->trans(
"Days"),
"w"=>$langs->trans(
"Weeks"),
"m"=>$langs->trans(
"Months"),
"y"=>$langs->trans(
"Years"));
2047 } elseif ($object->duration_value > 0)
2049 $dur = array(
"i"=>$langs->trans(
"Minute"),
"h"=>$langs->trans(
"Hour"),
"d"=>$langs->trans(
"Day"),
"w"=>$langs->trans(
"Week"),
"m"=>$langs->trans(
"Month"),
"y"=>$langs->trans(
"Year"));
2051 print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) :
'').
" ";
2056 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td colspan="2">';
2057 print $object->getLibFinished();
2061 print
'<tr><td class="titlefield">'.$langs->trans(
"Weight").
'</td><td colspan="2">';
2062 if ($object->weight !=
'')
2068 print
"</td></tr>\n";
2070 if (empty($conf->global->PRODUCT_DISABLE_SIZE))
2073 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td colspan="2">';
2074 if ($object->length !=
'' || $object->width !=
'' || $object->height !=
'')
2076 print $object->length;
2077 if ($object->width) print
" x ".$object->width;
2078 if ($object->height) print
" x ".$object->height;
2079 print
' '.measuringUnitString(0,
"size", $object->length_units);
2083 print
"</td></tr>\n";
2085 if (empty($conf->global->PRODUCT_DISABLE_SURFACE))
2088 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td colspan="2">';
2089 if ($object->surface !=
'')
2095 print
"</td></tr>\n";
2097 if (empty($conf->global->PRODUCT_DISABLE_VOLUME))
2100 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td colspan="2">';
2101 if ($object->volume !=
'')
2107 print
"</td></tr>\n";
2110 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE))
2113 print
'<tr><td class="titlefield">'.$langs->trans(
"NetMeasure").
'</td><td colspan="2">';
2114 if ($object->net_measure !=
'')
2124 if (!empty($conf->global->PRODUCT_USE_UNITS))
2126 $unit = $object->getLabelOfUnit();
2128 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2130 print $langs->trans($unit);
2136 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO))
2138 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td colspan="2">'.$object->customcode.
'</td>';
2141 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td colspan="2">'.
getCountry($object->country_id, 0, $db);
2142 if (!empty($object->state_id)) print
' - '.getState($object->state_id, 0, $db);
2147 $parameters = array(
'colspan' =>
' colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).
'"',
'cols' => (2 + (($showphoto || $showbarcode) ? 1 : 0)));
2148 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2151 if ($conf->categorie->enabled) {
2152 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td colspan="3">';
2153 print $form->showCategories($object->id, Categorie::TYPE_PRODUCT, 1);
2158 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB))
2160 print
'<!-- show Note --> '.
"\n";
2161 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td><td colspan="'.(2 + (($showphoto || $showbarcode) ? 1 : 0)).
'">'.(
dol_textishtml($object->note_private) ? $object->note_private :
dol_nl2br($object->note_private, 1,
true)).
'</td></tr>'.
"\n";
2162 print
'<!-- End show Note --> '.
"\n";
2168 print
'</div></div>';
2169 print
'<div style="clear:both"></div>';
2173 } elseif ($action !=
'create')
2180 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
2181 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php')
2183 $module = substr($module, 0,
dol_strlen($module) - 4);
2188 $modCodeProduct =
new $module();
2192 if (!empty($modCodeProduct->code_auto)) $tmpcode = $modCodeProduct->getNextValue($object, $object->type);
2197 if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2198 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)))
2200 $formconfirm = $form->formconfirm(
"card.php?id=".$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2204 if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2205 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)))
2208 $formquestionclone = array(
2209 'text' => $langs->trans(
"ConfirmClone"),
2210 array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.$object->ref : $tmpcode,
'size'=>24),
2211 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2212 array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2214 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
2215 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2217 if (!empty($conf->global->PRODUIT_SOUSPRODUITS))
2219 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2222 $formconfirm .= $form->formconfirm(
$_SERVER[
"PHP_SELF"].
'?id='.$object->id, $langs->trans(
'ToClone'), $langs->trans(
'ConfirmCloneProduct', $object->ref),
'confirm_clone', $formquestionclone,
'yes',
'action-clone', 350, 600);
2226 $parameters = array(
'formConfirm' => $formconfirm,
'object' => $object);
2227 $reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2228 if (empty($reshook)) $formconfirm .= $hookmanager->resPrint;
2229 elseif ($reshook > 0) $formconfirm = $hookmanager->resPrint;
2239 if ($action != 'create' && $action != 'edit')
2241 print
"\n".
'<div class="tabsAction">'.
"\n";
2243 $parameters = array();
2244 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2245 if (empty($reshook))
2249 if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=edit&id='.$object->id.
'">'.$langs->trans(
"Modify").
'</a>';
2251 if (!isset($object->no_button_copy) || $object->no_button_copy <> 1)
2253 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))
2255 print
'<span id="action-clone" class="butAction">'.$langs->trans(
'ToClone').
'</span>'.
"\n";
2257 print
'<a class="butAction" href="'.$_SERVER[
"PHP_SELF"].
'?action=clone&id='.$object->id.
'">'.$langs->trans(
"ToClone").
'</a>';
2261 $object_is_used = $object->isObjectUsed($object->id);
2265 if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1))
2267 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))
2269 print
'<span id="action-delete" class="butActionDelete">'.$langs->trans(
'Delete').
'</span>'.
"\n";
2271 print
'<a class="butActionDelete" href="'.$_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id.
'">'.$langs->trans(
"Delete").
'</a>';
2274 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"ProductIsUsed").
'">'.$langs->trans(
"Delete").
'</a>';
2277 print
'<a class="butActionRefused classfortooltip" href="#" title="'.$langs->trans(
"NotEnoughPermissions").
'">'.$langs->trans(
"Delete").
'</a>';
2288 if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action ==
'' || $action ==
'view') && $object->status)
2295 if (!empty($conf->propal->enabled) && $user->rights->propale->creer)
2297 $propal =
new Propal($db);
2299 $langs->load(
"propal");
2301 $otherprop = $propal->liste_array(2, 1, 0);
2303 if (is_array($otherprop) && count($otherprop))
2305 $html .=
'<tr><td style="width: 200px;">';
2306 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2307 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
2308 $html .=
'</td></tr>';
2310 $html .=
'<tr><td style="width: 200px;">';
2311 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2312 $html .= $langs->trans(
"NoDraftProposals");
2313 $html .=
'</td></tr>';
2318 if (!empty($conf->commande->enabled) && $user->rights->commande->creer)
2322 $langs->load(
"orders");
2324 $othercom = $commande->liste_array(2, 1, null);
2325 if (is_array($othercom) && count($othercom))
2327 $html .=
'<tr><td style="width: 200px;">';
2328 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2329 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
2330 $html .=
'</td></tr>';
2332 $html .=
'<tr><td style="width: 200px;">';
2333 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2334 $html .= $langs->trans(
"NoDraftOrders");
2335 $html .=
'</td></tr>';
2340 if (!empty($conf->facture->enabled) && $user->rights->facture->creer)
2344 $langs->load(
"bills");
2346 $otherinvoice = $invoice->liste_array(2, 1, null);
2347 if (is_array($otherinvoice) && count($otherinvoice))
2349 $html .=
'<tr><td style="width: 200px;">';
2350 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2351 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
2352 $html .=
'</td></tr>';
2354 $html .=
'<tr><td style="width: 200px;">';
2355 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2356 $html .= $langs->trans(
"NoDraftInvoices");
2357 $html .=
'</td></tr>';
2364 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2365 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2366 print
'<input type="hidden" name="action" value="addin">';
2372 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
2373 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
2374 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
2375 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
2376 $html .=
'</td></tr>';
2378 print
'<table width="100%" class="border">';
2382 print
'<div class="center">';
2383 print
'<input type="submit" class="button" value="'.$langs->trans(
"Add").
'">';
2397 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete')
2399 print
'<div class="fichecenter"><div class="fichehalfleft">';
2400 print
'<a name="builddoc"></a>';
2404 $relativepath = $comref.
'/'.$objectref.
'.pdf';
2405 if (!empty($conf->product->multidir_output[$object->entity])) {
2406 $filedir = $conf->product->multidir_output[$object->entity].
'/'.$objectref;
2408 $filedir = $conf->product->dir_output.
'/'.$objectref;
2410 $urlsource =
$_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2411 $genallowed = $usercanread;
2412 $delallowed = $usercancreate;
2414 print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $object->default_lang,
'', $object);
2415 $somethingshown = $formfile->numoffiles;
2417 print
'</div><div class="fichehalfright"><div class="ficheaddleft">';
2421 $morehtmlright =
'<a href="'.DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id.
'">';
2422 $morehtmlright .= $langs->trans(
"SeeAll");
2423 $morehtmlright .=
'</a>';
2426 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2428 $somethingshown =
$formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlright);
2430 print
'</div></div></div>';
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname= '')
Make an include_once using default root and alternate root if it fails.
File of class to manage predefined price products or services by customer.
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
img_edit($titlealt= 'default', $float=0, $other= '')
Show logo editer/modifier fiche.
if(preg_match('/set_([a-z0-9_\-]+)/i', $action, $reg)) if(preg_match('/del_([a-z0-9_\-]+)/i', $action, $reg)) if($action== 'set') elseif($action== 'specimen') elseif($action== 'setmodel') elseif($action== 'del') elseif($action== 'setdoc') $formactions
View.
const TYPE_STANDARD
Standard invoice.
dol_print_url($url, $target= '_blank', $max=32, $withpicto=0)
Show Url link.
Class to manage products or services.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
const TYPE_SERVICE
Service.
const TYPE_PRODUCT
Regular product.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Fonction qui renvoie si tva doit etre tva percue recuperable.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate, from a $thirdparty_buyer to a $thirdparty_seller Note: This function applies same rules than get_default_tva.
price($amount, $form=0, $outlangs= '', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code= '')
Function to format a value into an amount for visual output Function used into PDF and HTML pages...
setEventMessages($mesg, $mesgs, $style= 'mesgs', $messagekey= '')
Set event messages in dol_events session object.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname.
Class to manage third parties objects (customers, suppliers, prospects...)
Class to manage categories.
load_fiche_titre($titre, $morehtmlright= '', $picto= 'generic', $pictoisfullpath=0, $id= '', $morecssontable= '', $morehtmlcenter= '')
Load a title with picto.
dol_strlen($string, $stringencoding= 'UTF-8')
Make a strlen call.
price2num($amount, $rounding= '', $option=0)
Function that return a number with universal decimal format (decimal separator is '...
img_picto($titlealt, $picto, $moreatt= '', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt= '', $morecss= '', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
Class to manage customers orders.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename= '', $restricttologhandler= '', $logcontext=null)
Write log message into outputs.
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart= '')
Return a path to have a the directory according to object where files are stored. ...
if(!GETPOST('transkey', 'alphanohtml')&&!GETPOST('transphrase', 'alphanohtml')) else
View.
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_sanitizeFileName($str, $newstr= '_', $unaccent=1)
Clean a string to use it as a file name.
Class ProductCombination Used to represent a product combination.
print $_SERVER["PHP_SELF"]
Edit parameters.
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.
Class of a generic business object.
ajax_object_onoff($object, $code, $field, $text_on, $text_off, $input=array())
On/off button to change status of an object This is called when MAIN_DIRECT_STATUS_UPDATE is set and ...
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) if(!empty($conf->don->enabled)&&$user->rights->don->lire) if(!empty($conf->tax->enabled)&&$user->rights->tax->charges->lire) if(!empty($conf->facture->enabled)&&!empty($conf->commande->enabled)&&$user->rights->commande->lire &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) if(!empty($conf->facture->enabled)&&$user->rights->facture->lire) if((!empty($conf->fournisseur->enabled)&&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD)||!empty($conf->supplier_invoice->enabled))&&$user->rights->fournisseur->facture->lire) $resql
Social contributions to pay.
dol_print_error($db= '', $error= '', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) Si ...
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.
Class to manage accounting accounts.
Class to manage invoices.
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.
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin= '1', $morecss= '', $textfordropdown= '')
Show information for admin users or standard users.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
getCountry($searchkey, $withcode= '', $dbtouse=0, $outputlangs= '', $entconv=1, $searchlabel= '')
Return country label, code or id from an id, code or label.
product_prepare_head($object)
Prepare array with list of tabs.
Class to manage proposals.
measuringUnitString($unit, $measuring_style= '', $scale= '', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
Class to manage warehouses.
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...
dol_textishtml($msg, $option=0)
Return if a text is a html content.