46require
'../main.inc.php';
47require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
55require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
60if (isModEnabled(
'propal')) {
61 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
63if (isModEnabled(
'facture')) {
64 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
66if (isModEnabled(
'commande')) {
67 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
69if (isModEnabled(
'accounting')) {
70 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
71 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
72 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
74if (isModEnabled(
'bom')) {
75 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
79$langs->loadLangs(array(
'products',
'other'));
80if (isModEnabled(
'stock')) {
81 $langs->load(
"stocks");
83if (isModEnabled(
'facture')) {
84 $langs->load(
"bills");
86if (isModEnabled(
'productbatch')) {
87 $langs->load(
"productbatch");
90$mesg =
''; $error = 0; $errors = array();
96if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
97 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'nohtml') : null);
99 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alpha') : null);
101$type = (GETPOSTISSET(
'type') ?
GETPOST(
'type',
'int') :
Product::TYPE_PRODUCT);
102$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
103$cancel =
GETPOST(
'cancel',
'alpha');
104$backtopage =
GETPOST(
'backtopage',
'alpha');
105$confirm =
GETPOST(
'confirm',
'alpha');
106$socid =
GETPOST(
'socid',
'int');
107$duration_value =
GETPOST(
'duration_value',
'int');
108$duration_unit =
GETPOST(
'duration_unit',
'alpha');
110$accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
111$accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
112$accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
113$accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
114$accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
115$accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
117$checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
120if (!empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_REF_LABELS)) {
121 $label_security_check =
'nohtml';
123 $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ?
'alphanohtml' :
'restricthtml';
126if (!empty($user->socid)) {
127 $socid = $user->socid;
131$module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
132if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
133 $module = substr($module, 0,
dol_strlen($module) - 4);
137 $modCodeProduct =
new $module();
141$object->type = $type;
145$extrafields->fetch_name_optionals_label($object->table_element);
147if ($id > 0 || !empty($ref)) {
148 $result = $object->fetch($id, $ref);
152 $entity = (!empty($object->entity) ? $object->entity : $conf->entity);
153 if (isModEnabled(
"product")) {
154 $upload_dir = $conf->product->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
155 } elseif (isModEnabled(
"service")) {
156 $upload_dir = $conf->service->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
160 if (isModEnabled(
"product")) {
161 $upload_dirold = $conf->product->multidir_output[$entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
163 $upload_dirold = $conf->service->multidir_output[$entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
168$modulepart =
'product';
171$canvas = !empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas");
173if (!empty($canvas)) {
174 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
175 $objcanvas =
new Canvas($db, $action);
176 $objcanvas->getCanvas(
'product',
'card', $canvas);
180$fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
181$fieldtype = (!empty($id) ?
'rowid' :
'ref');
183if ($object->id > 0) {
184 if ($object->type == $object::TYPE_PRODUCT) {
185 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
187 if ($object->type == $object::TYPE_SERVICE) {
188 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
191 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
195$hookmanager->initHooks(array(
'productcard',
'globalcard'));
211$createbarcode = isModEnabled(
'barcode');
212if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) {
216$parameters = array(
'id'=>$id,
'ref'=>$ref,
'objcanvas'=>$objcanvas);
217$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
222if (empty($reshook)) {
223 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
225 if (empty($backtopage) || ($cancel && empty($id))) {
226 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
227 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
228 $backtopage = $backurlforlist;
230 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
236 if (!empty($backtopageforcancel)) {
237 header(
"Location: ".$backtopageforcancel);
239 } elseif (!empty($backtopage)) {
240 header(
"Location: ".$backtopage);
246 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
248 $productOriginId =
GETPOST(
'product_origin',
'int');
249 $productOrigin =
new Product($db);
251 if ($productOriginId <= 0) {
252 $langs->load(
'errors');
253 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
255 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
265 $listofproperties = array(
275 'accountancy_code_buy',
276 'accountancy_code_buy_intra',
277 'accountancy_code_buy_export',
278 'accountancy_code_sell',
279 'accountancy_code_sell_intra',
280 'accountancy_code_sell_export'
282 foreach ($listofproperties as $property) {
283 if (empty($object->$property)) {
284 $object->$property = $productOrigin->$property;
288 $listofproperties = array(
289 'note_public',
'note_private'
291 foreach ($listofproperties as $property) {
292 $object->$property =
dol_concatdesc($object->$property, $productOrigin->$property);
296 if (is_array($productOrigin->array_options)) {
297 foreach ($productOrigin->array_options as $key => $val) {
298 if (empty($object->array_options[$key])) {
299 $object->array_options[$key] = $val;
306 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
307 $custcats = $static_cat->containing($object->id,
'product',
'id');
308 $custcats = array_merge($custcats, $custcats_ori);
309 $object->setCategories($custcats);
312 if ($productOrigin->barcode == $object->barcode) {
313 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
314 $productOrigin->barcode =
'';
319 $result = $object->update($object->id, $user, 0,
'merge');
330 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
331 'Bom' =>
'/bom/class/bom.class.php',
334 'Commande' =>
'/commande/class/commande.class.php',
335 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
336 'Contrat' =>
'/contrat/class/contrat.class.php',
337 'Delivery' =>
'/delivery/class/delivery.class.php',
338 'Facture' =>
'/compta/facture/class/facture.class.php',
339 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
340 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
341 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
342 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
343 'Propal' =>
'/comm/propal/class/propal.class.php',
344 'Reception' =>
'/reception/class/reception.class.php',
345 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
349 foreach ($objects as $object_name => $object_file) {
350 require_once DOL_DOCUMENT_ROOT.$object_file;
352 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id, $object->id)) {
362 $parameters = array(
'soc_origin' => $productOrigin->id,
'soc_dest' => $object->id);
363 $reshook = $hookmanager->executeHooks(
378 $object->context = array(
380 'mergefromid' => $productOrigin->id,
384 $result = $object->call_trigger(
'PRODUCT_MODIFY', $user);
395 if ($productOrigin->delete($user) < 1) {
404 $langs->load(
"errors");
413 if ($action ==
'setfk_product_type' && $usercancreate) {
414 $result = $object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
415 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
420 $upload_dir = $conf->product->dir_output;
421 $permissiontoadd = $usercancreate;
422 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
424 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
427 if ($action ==
'setfk_barcode_type' && $createbarcode) {
428 $result = $object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
429 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
434 if ($action ==
'setbarcode' && $createbarcode) {
435 $result = $object->check_barcode(
GETPOST(
'barcode'),
GETPOST(
'barcode_type_code'));
438 $result = $object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
439 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
442 $langs->load(
"errors");
444 $errors[] =
'ErrorBadBarCodeSyntax';
445 } elseif ($result == -2) {
446 $errors[] =
'ErrorBarCodeRequired';
447 } elseif ($result == -3) {
448 $errors[] =
'ErrorBarCodeAlreadyUsed';
450 $errors[] =
'FailedToValidateBarCode';
459 if ($action ==
'update_extras') {
463 $ret = $extrafields->setOptionalsFromPost(
null, $object,
GETPOST(
'attribute',
'restricthtml'));
470 $result = $object->insertExtraFields(
'PRODUCT_MODIFY');
478 $action =
'edit_extras';
483 if ($action ==
'add' && $usercancreate) {
486 if (!
GETPOST(
'label', $label_security_check)) {
487 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
492 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
493 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'ProductRef')),
null,
'errors');
498 if (!empty($duration_value) && empty($duration_unit)) {
499 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
505 $units =
GETPOST(
'units',
'int');
507 $object->entity = $conf->entity;
509 $object->label =
GETPOST(
'label', $label_security_check);
510 $object->price_base_type =
GETPOST(
'price_base_type',
'aZ09');
511 $object->mandatory_period = !empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 1 : 0;
512 if ($object->price_base_type ==
'TTC') {
513 $object->price_ttc =
GETPOST(
'price');
515 $object->price =
GETPOST(
'price');
517 if ($object->price_base_type ==
'TTC') {
518 $object->price_min_ttc =
GETPOST(
'price_min');
520 $object->price_min =
GETPOST(
'price_min');
523 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
527 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
528 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
529 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
532 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
534 $vatratecode = $reg[1];
536 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
537 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
538 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
539 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
540 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
541 $resql = $db->query($sql);
543 $obj = $db->fetch_object($resql);
544 $npr = $obj->recuperableonly;
545 $localtax1 = $obj->localtax1;
546 $localtax2 = $obj->localtax2;
547 $localtax1_type = $obj->localtax1_type;
548 $localtax2_type = $obj->localtax2_type;
552 $object->default_vat_code = $vatratecode;
553 $object->tva_tx = $tva_tx;
554 $object->tva_npr = $npr;
555 $object->localtax1_tx = $localtax1;
556 $object->localtax2_tx = $localtax2;
557 $object->localtax1_type = $localtax1_type;
558 $object->localtax2_type = $localtax2_type;
560 $object->type = $type;
561 $object->status =
GETPOST(
'statut');
562 $object->status_buy =
GETPOST(
'statut_buy');
563 $object->status_batch =
GETPOST(
'status_batch');
564 $object->batch_mask =
GETPOST(
'batch_mask');
566 $object->barcode_type =
GETPOST(
'fk_barcode_type');
567 $object->barcode =
GETPOST(
'barcode');
570 $stdobject->element =
'product';
571 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
572 $result = $stdobject->fetch_barcode();
575 $mesg =
'Failed to get bar code type information ';
578 $object->barcode_type_code = $stdobject->barcode_type_code;
579 $object->barcode_type_coder = $stdobject->barcode_type_coder;
580 $object->barcode_type_label = $stdobject->barcode_type_label;
585 $object->note = $object->note_private;
586 $object->customcode =
GETPOST(
'customcode',
'alphanohtml');
587 $object->country_id =
GETPOST(
'country_id',
'int');
588 $object->state_id =
GETPOST(
'state_id',
'int');
589 $object->lifetime =
GETPOST(
'lifetime',
'int');
590 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
591 $object->duration_value = $duration_value;
592 $object->duration_unit = $duration_unit;
593 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
594 $object->fk_default_workstation =
GETPOST(
'fk_default_workstation',
'int');
595 $object->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte') ?
GETPOST(
'seuil_stock_alerte') : 0;
596 $object->desiredstock =
GETPOST(
'desiredstock') ?
GETPOST(
'desiredstock') : 0;
597 $object->canvas =
GETPOST(
'canvas');
598 $object->net_measure =
GETPOST(
'net_measure');
599 $object->net_measure_units =
GETPOST(
'net_measure_units');
600 $object->weight =
GETPOST(
'weight');
601 $object->weight_units =
GETPOST(
'weight_units');
602 $object->length =
GETPOST(
'size');
603 $object->length_units =
GETPOST(
'size_units');
604 $object->width =
GETPOST(
'sizewidth');
605 $object->height =
GETPOST(
'sizeheight');
606 $object->surface =
GETPOST(
'surface');
607 $object->surface_units =
GETPOST(
'surface_units');
608 $object->volume =
GETPOST(
'volume');
609 $object->volume_units =
GETPOST(
'volume_units');
610 $finished =
GETPOST(
'finished',
'int');
611 if ($finished >= 0) {
612 $object->finished = $finished;
614 $object->finished =
null;
617 $units =
GETPOST(
'units',
'int');
619 $object->fk_unit = $units;
621 $object->fk_unit =
null;
624 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
625 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
626 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
627 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
628 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
629 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
631 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
632 $object->accountancy_code_sell =
'';
634 $object->accountancy_code_sell = $accountancy_code_sell;
636 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
637 $object->accountancy_code_sell_intra =
'';
639 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
641 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
642 $object->accountancy_code_sell_export =
'';
644 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
646 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
647 $object->accountancy_code_buy =
'';
649 $object->accountancy_code_buy = $accountancy_code_buy;
651 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
652 $object->accountancy_code_buy_intra =
'';
654 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
656 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
657 $object->accountancy_code_buy_export =
'';
659 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
663 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
664 for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
665 if (GETPOSTISSET(
"price_".$i)) {
667 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
669 $object->multiprices[
"$i"] =
"";
675 $ret = $extrafields->setOptionalsFromPost(
null, $object);
680 if (!$ref && !empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
682 $ref = $modCodeProduct->getNextValue($object, $type);
686 $id = $object->create($user);
691 $categories =
GETPOST(
'categories',
'array');
692 $object->setCategories($categories);
694 if (!empty($backtopage)) {
695 $backtopage = preg_replace(
'/__ID__/', $object->id, $backtopage);
696 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', $object->id, $backtopage);
697 if (preg_match(
'/\?/', $backtopage)) {
698 $backtopage .=
'&socid='.$object->id;
701 header(
"Location: ".$backtopage);
704 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
708 if (count($object->errors)) {
711 if ($object->error ==
'ErrorProductAlreadyExists') {
713 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters, $object, $action);
717 if ($object->error) {
732 if ($action ==
'update' && $usercancreate) {
733 if (
GETPOST(
'cancel',
'alpha')) {
736 if ($object->id > 0) {
737 $object->oldcopy = clone $object;
739 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
742 $object->label =
GETPOST(
'label', $label_security_check);
745 $object->description = $desc;
748 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
750 $object->note = $object->note_private;
752 $object->customcode =
GETPOST(
'customcode',
'alpha');
753 $object->country_id =
GETPOST(
'country_id',
'int');
754 $object->state_id =
GETPOST(
'state_id',
'int');
755 $object->lifetime =
GETPOST(
'lifetime',
'int');
756 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
757 $object->status =
GETPOST(
'statut',
'int');
758 $object->status_buy =
GETPOST(
'statut_buy',
'int');
759 $object->status_batch =
GETPOST(
'status_batch',
'aZ09');
760 $object->batch_mask =
GETPOST(
'batch_mask',
'alpha');
761 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse',
'int');
762 $object->fk_default_workstation =
GETPOST(
'fk_default_workstation',
'int');
768 $object->duration_value =
GETPOST(
'duration_value',
'int');
769 $object->duration_unit =
GETPOST(
'duration_unit',
'alpha');
771 $object->canvas =
GETPOST(
'canvas');
772 $object->net_measure =
GETPOST(
'net_measure');
773 $object->net_measure_units =
GETPOST(
'net_measure_units');
774 $object->weight =
GETPOST(
'weight');
775 $object->weight_units =
GETPOST(
'weight_units');
776 $object->length =
GETPOST(
'size');
777 $object->length_units =
GETPOST(
'size_units');
778 $object->width =
GETPOST(
'sizewidth');
779 $object->height =
GETPOST(
'sizeheight');
781 $object->surface =
GETPOST(
'surface');
782 $object->surface_units =
GETPOST(
'surface_units');
783 $object->volume =
GETPOST(
'volume');
784 $object->volume_units =
GETPOST(
'volume_units');
786 $finished =
GETPOST(
'finished',
'int');
787 if ($finished >= 0) {
788 $object->finished = $finished;
790 $object->finished =
null;
793 $fk_default_bom =
GETPOST(
'fk_default_bom',
'int');
794 if ($fk_default_bom >= 0) {
795 $object->fk_default_bom = $fk_default_bom;
797 $object->fk_default_bom =
null;
800 $units =
GETPOST(
'units',
'int');
802 $object->fk_unit = $units;
804 $object->fk_unit =
null;
807 $object->barcode_type =
GETPOST(
'fk_barcode_type');
808 $object->barcode =
GETPOST(
'barcode');
811 $stdobject->element =
'product';
812 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
813 $result = $stdobject->fetch_barcode();
816 $mesg =
'Failed to get bar code type information ';
819 $object->barcode_type_code = $stdobject->barcode_type_code;
820 $object->barcode_type_coder = $stdobject->barcode_type_coder;
821 $object->barcode_type_label = $stdobject->barcode_type_label;
823 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
824 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
825 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
826 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
827 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
828 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
829 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
830 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
831 $object->accountancy_code_sell =
'';
833 $object->accountancy_code_sell = $accountancy_code_sell;
835 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
836 $object->accountancy_code_sell_intra =
'';
838 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
840 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
841 $object->accountancy_code_sell_export =
'';
843 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
845 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
846 $object->accountancy_code_buy =
'';
848 $object->accountancy_code_buy = $accountancy_code_buy;
850 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
851 $object->accountancy_code_buy_intra =
'';
853 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
855 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
856 $object->accountancy_code_buy_export =
'';
858 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
860 if ($object->isService()) {
861 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
867 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
872 if (!$error && $object->check()) {
873 if ($object->update($object->id, $user) > 0) {
875 $categories =
GETPOST(
'categories',
'array');
876 $object->setCategories($categories);
880 if (count($object->errors)) {
888 if (count($object->errors)) {
891 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
900 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
903 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
907 if ($object->id > 0) {
912 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
914 $clone->status_buy = 0;
915 $clone->barcode = -1;
917 if ($clone->check()) {
920 $clone->context[
'createfromclone'] =
'createfromclone';
921 $id = $clone->create($user);
923 if (
GETPOST(
'clone_composition')) {
924 $result = $clone->clone_associations($object->id, $id);
932 if (!$error &&
GETPOST(
'clone_categories')) {
933 $result = $clone->cloneCategories($object->id, $id);
941 if (!$error &&
GETPOST(
'clone_prices')) {
942 $result = $clone->clone_price($object->id, $id);
952 if ($clone->error ==
'ErrorProductAlreadyExists') {
956 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
957 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
960 if (count($clone->errors)) {
971 unset($clone->context[
'createfromclone']);
978 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
982 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
992 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
995 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
996 $result = $object->delete($user);
999 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.$object->type.
'&delprod='.urlencode($object->ref));
1010 if ($object->id > 0 && $action ==
'addin') {
1012 if (
GETPOST(
'propalid') > 0) {
1013 $propal =
new Propal($db);
1014 $result = $propal->fetch(
GETPOST(
'propalid'));
1019 $thirpdartyid = $propal->socid;
1020 } elseif (
GETPOST(
'commandeid') > 0) {
1022 $result = $commande->fetch(
GETPOST(
'commandeid'));
1027 $thirpdartyid = $commande->socid;
1028 } elseif (
GETPOST(
'factureid') > 0) {
1030 $result = $facture->fetch(
GETPOST(
'factureid'));
1035 $thirpdartyid = $facture->socid;
1038 if ($thirpdartyid > 0) {
1040 $result = $soc->fetch($thirpdartyid);
1046 $desc = $object->description;
1050 if (empty($tva_tx)) {
1053 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1054 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1056 $pu_ht = $object->price;
1057 $pu_ttc = $object->price_ttc;
1058 $price_base_type = $object->price_base_type;
1061 if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
1062 $pu_ht = $object->multiprices[$soc->price_level];
1063 $pu_ttc = $object->multiprices_ttc[$soc->price_level];
1064 $price_base_type = $object->multiprices_base_type[$soc->price_level];
1065 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1066 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1070 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' => $soc->id);
1072 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1074 if (count($prodcustprice->lines) > 0) {
1075 $pu_ht =
price($prodcustprice->lines [0]->price);
1076 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1077 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1078 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1083 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1084 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1088 if ($tmpvat != $tmpprodvat) {
1089 if ($price_base_type !=
'HT') {
1090 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1092 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1096 if (
GETPOST(
'propalid') > 0) {
1099 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1100 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1103 $buyprice = $result;
1106 $result = $propal->addline(
1131 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1135 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1136 } elseif (
GETPOST(
'commandeid') > 0) {
1139 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1140 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1143 $buyprice = $result;
1146 $result = $commande->addline(
1173 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode($commande->id));
1176 } elseif (
GETPOST(
'factureid') > 0) {
1179 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1180 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1183 $buyprice = $result;
1186 $result = $facture->addline(
1218 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1224 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1235$form =
new Form($db);
1239if (isModEnabled(
'accounting')) {
1244$title = $langs->trans(
'ProductServiceCard');
1247$shortlabel =
dol_trunc($object->label, 16);
1249 if ($action ==
'create') {
1250 $title = $langs->trans(
"NewProduct");
1252 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1253 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1257 if ($action ==
'create') {
1258 $title = $langs->trans(
"NewService");
1260 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1261 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1269if (isModEnabled(
'barcode') && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
1270 $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
1271 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
1272 foreach ($dirbarcode as $dirroot) {
1279 $modBarCodeProduct =
new $module();
1283if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1287 if (empty($object->error) && $id) {
1288 $result = $object->fetch($id);
1293 $objcanvas->assign_values($action, $object->id, $object->ref);
1294 $objcanvas->display_canvas($action);
1299 if ($action ==
'create' && $usercancreate) {
1301 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1303 if (!empty($conf->use_javascript_ajax)) {
1304 print
'<script type="text/javascript">';
1305 print
'$(document).ready(function () {
1306 $("#selectcountry_id").change(function() {
1307 document.formprod.action.value="create";
1308 document.formprod.submit();
1311 print
'</script>'.
"\n";
1315 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
1316 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1317 $module = substr($module, 0,
dol_strlen($module) - 4);
1321 $modCodeProduct =
new $module();
1326 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1327 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1328 print
'<input type="hidden" name="action" value="add">';
1329 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1330 if (!empty($modCodeProduct->code_auto)) {
1331 print
'<input type="hidden" name="code_auto" value="1">';
1333 if (!empty($modBarCodeProduct->code_auto)) {
1334 print
'<input type="hidden" name="barcode_auto" value="1">';
1336 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1340 $title = $langs->trans(
"NewService");
1343 $title = $langs->trans(
"NewProduct");
1349 $object->country_id = GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : null;
1350 if ($object->country_id > 0) {
1351 $tmparray =
getCountry($object->country_id,
'all');
1352 $object->country_code = $tmparray[
'code'];
1353 $object->country = $tmparray[
'label'];
1358 print
'<table class="border centpercent">';
1360 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
1363 if (!empty($modCodeProduct->code_auto)) {
1364 $tmpcode = $modCodeProduct->getNextValue($object, $type);
1366 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ProductRef").
'</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1367 if ($refalreadyexists) {
1368 print $langs->trans(
"RefAlreadyExists");
1374 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag(
GETPOST(
'label', $label_security_check)).
'"></td></tr>';
1377 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1378 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1379 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1383 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1384 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1385 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1389 if (isModEnabled(
'productbatch')) {
1390 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1391 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1392 print $form->selectarray(
'status_batch', $statutarray,
GETPOST(
'status_batch'));
1395 $status_batch =
GETPOST(
'status_batch');
1396 if ($status_batch !==
'0') {
1397 $langs->load(
"admin");
1398 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1399 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1400 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1401 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1402 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1403 if ((!empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
1404 || (!empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced')) {
1405 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1408 print
'<td id="field_mask">';
1409 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1410 print
'<script type="text/javascript">
1411 $(document).ready(function() {
1412 $("#field_mask, #mask_option").addClass("hideobject");
1413 $("#status_batch").on("change", function () {
1414 console.log("We change batch status");
1415 var optionSelected = $("option:selected", this);
1416 var valueSelected = this.value;
1417 $("#field_mask, #mask_option").addClass("hideobject");
1421 if (this.value == 1) {
1422 $("#field_mask, #mask_option").toggleClass("hideobject");
1423 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1427 if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced') {
1429 if (this.value == 2) {
1430 $("#field_mask, #mask_option").toggleClass("hideobject");
1431 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1444 $showbarcode = isModEnabled(
'barcode');
1445 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1450 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1451 if (GETPOSTISSET(
'fk_barcode_type')) {
1452 $fk_barcode_type =
GETPOST(
'fk_barcode_type')?
GETPOST(
'fk_barcode_type'):0;
1454 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
1460 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1462 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1465 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1466 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : $object->barcode;
1467 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1468 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1470 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1471 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1476 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1477 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1478 $doleditor->Create();
1481 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
1483 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1484 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1485 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1489 if (($type != 1 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
1491 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1492 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1493 print $formproduct->selectWarehouses(
GETPOST(
'fk_default_warehouse',
'int'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1494 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOST(
'type',
'int')).
'">';
1495 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1500 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1502 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1503 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1508 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1509 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1513 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1514 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1515 print
'<input name="desiredstock" type="hidden" value="0">';
1519 if ($type == $object::TYPE_SERVICE && isModEnabled(
"workstation")) {
1521 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1522 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1523 print $formproduct->selectWorkstations($object->fk_default_workstation,
'fk_default_workstation', 1);
1529 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1530 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1531 print
'<input name="duration_value" size="4" value="'.GETPOST(
'duration_value',
'int').
'">';
1532 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value',
'alpha') :
'h'), 0, 1);
1535 print
' ';
1536 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
1537 print
'<label for="mandatoryperiod">';
1538 $htmltooltip = $langs->trans(
"mandatoryHelper");
1539 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1546 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
1548 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1549 print $formproduct->selectProductNature(
'finished', $object->finished);
1555 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
1557 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1558 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1559 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1560 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);
1565 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
1566 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1567 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1568 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1569 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1570 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1571 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') :
'0', 0, 2);
1574 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
1576 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1577 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1578 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') :
'0', 0, 2);
1581 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
1583 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1584 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1585 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') :
'0', 0, 2);
1589 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
1591 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1592 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1593 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);
1599 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1600 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1602 print $form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
'units');
1607 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) {
1608 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1611 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1613 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1614 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1616 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1621 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
1623 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)) {
1624 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1626 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1629 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1630 print $formcompany->select_state($object->state_id, $object->country_code);
1636 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
1637 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1638 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1642 $parameters = array(
'colspan' =>
' colspan="2"',
'cols'=>2);
1643 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1644 print $hookmanager->resPrint;
1645 if (empty($reshook)) {
1646 print $object->showOptionals($extrafields,
'create', $parameters);
1652 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1655 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1656 $doleditor->Create();
1661 if (isModEnabled(
'categorie')) {
1663 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1664 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
1665 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1673 if (empty($conf->global->PRODUCT_DISABLE_PRICES)) {
1674 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1677 print
'<table class="border centpercent">';
1679 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1681 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1688 print
'<table class="border centpercent">';
1691 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1692 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1693 print $form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE,
"price_base_type");
1697 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1698 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1702 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1704 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1714 print
'<!-- accountancy codes -->'.
"\n";
1715 print
'<table class="border centpercent">';
1717 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
1718 if (isModEnabled(
'accounting')) {
1720 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1723 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_ACCOUNT"));
1725 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
1727 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1731 if ($mysoc->isInEEC()) {
1732 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1735 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1737 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1739 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1744 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1747 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1749 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1751 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1755 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1758 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1760 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1762 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1766 if ($mysoc->isInEEC()) {
1767 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1770 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1772 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1774 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1779 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1782 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1784 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1786 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1789 if (!empty($accountancy_code_sell)) {
1790 $object->accountancy_code_sell = $accountancy_code_sell;
1792 if (!empty($accountancy_code_sell_intra)) {
1793 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1795 if (!empty($accountancy_code_sell_export)) {
1796 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1798 if (!empty($accountancy_code_buy)) {
1799 $object->accountancy_code_buy = $accountancy_code_buy;
1801 if (!empty($accountancy_code_buy_intra)) {
1802 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1804 if (!empty($accountancy_code_buy_export)) {
1805 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1809 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1810 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1814 if ($mysoc->isInEEC()) {
1815 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1816 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1821 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1822 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1826 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1827 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1831 if ($mysoc->isInEEC()) {
1832 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1833 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1838 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1839 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1847 print $form->buttonsSaveCancel(
"Create");
1850 } elseif ($object->id > 0) {
1856 if ($action ==
'edit' && $usercancreate) {
1858 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1860 if (!empty($conf->use_javascript_ajax)) {
1861 print
'<script type="text/javascript">';
1862 print
'$(document).ready(function () {
1863 $("#selectcountry_id").change(function () {
1864 document.formprod.action.value="edit";
1865 document.formprod.submit();
1868 print
'</script>'.
"\n";
1872 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $object->country_id;
1873 if ($object->country_id) {
1874 $tmparray =
getCountry($object->country_id,
'all');
1875 $object->country_code = $tmparray[
'code'];
1876 $object->country = $tmparray[
'label'];
1879 $type = $langs->trans(
'Product');
1880 if ($object->isService()) {
1881 $type = $langs->trans(
'Service');
1886 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="formprod">'.
"\n";
1887 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1888 print
'<input type="hidden" name="action" value="update">';
1889 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1890 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1893 $titre = $langs->trans(
"CardProduct".$object->type);
1898 print
'<table class="border allwidth">';
1901 if (empty($conf->global->MAIN_PRODUCT_REF_NOT_EDITABLE)) {
1902 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(GETPOSTISSET(
'ref') ?
GETPOST(
'ref') : $object->
ref).
'"></td></tr>';
1904 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).
'" readonly="true"></td></tr>';
1908 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag(GETPOSTISSET(
'label') ?
GETPOST(
'label') : $object->label).
'"></td></tr>';
1911 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1912 print
'<select class="flat" name="statut">';
1913 if ((GETPOSTISSET(
'statut') &&
GETPOST(
'statut')) || (!GETPOSTISSET(
'statut') && $object->status)) {
1914 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
1915 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
1917 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
1918 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
1924 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
1925 print
'<select class="flat" name="statut_buy">';
1926 if ((GETPOSTISSET(
'statut_buy') &&
GETPOST(
'statut_buy')) || (!GETPOSTISSET(
'statut_buy') && $object->status_buy)) {
1927 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1928 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1930 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1931 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1937 if (isModEnabled(
'productbatch')) {
1938 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1939 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1940 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1941 print $form->selectarray(
'status_batch', $statutarray, (GETPOSTISSET(
'status_batch') ?
GETPOST(
'status_batch') : $object->status_batch));
1943 if (!empty($object->status_batch) || !empty($conf->use_javascript_ajax)) {
1944 $langs->load(
"admin");
1945 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1946 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1947 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1948 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1949 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1950 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1952 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'LOT_ADVANCED_MASK');
1955 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'SN_ADVANCED_MASK');
1959 print
'<td id="field_mask">';
1960 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
1962 if (!empty($conf->use_javascript_ajax)) {
1963 print
'<script type="text/javascript">
1964 $(document).ready(function() {
1965 $("#field_mask").parent().addClass("hideobject");
1966 var preselect = document.getElementById("status_batch");';
1968 print
'if (preselect.value == "2") {
1969 $("#field_mask").parent().removeClass("hideobject");
1973 print
'if (preselect.value == "1") {
1974 $("#field_mask").parent().removeClass("hideobject");
1977 print
'$("#status_batch").on("change", function () {
1978 var optionSelected = $("option:selected", this);
1979 var valueSelected = this.value;
1980 $("#field_mask").parent().addClass("hideobject");
1984 if (this.value == 1) {
1985 $("#field_mask").parent().removeClass("hideobject");
1986 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1992 if (this.value == 2) {
1993 $("#field_mask").parent().removeClass("hideobject");
1994 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2009 $showbarcode = isModEnabled(
'barcode');
2010 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2015 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2016 if (GETPOSTISSET(
'fk_barcode_type')) {
2017 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2019 $fk_barcode_type = $object->barcode_type;
2020 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
2021 $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
2024 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2026 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2028 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2029 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : $object->barcode;
2030 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2031 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2033 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2038 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2041 $doleditor =
new DolEditor(
'desc', GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') : $object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2042 $doleditor->Create();
2048 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
2049 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2050 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2051 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') : $object->url).
'">';
2056 if (($object->isProduct() ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
2058 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2059 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2060 print $formproduct->selectWarehouses((GETPOSTISSET(
'fk_default_warehouse') ?
GETPOST(
'fk_default_warehouse') : $object->fk_default_warehouse),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2061 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int) $object->id)).
'">';
2062 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2075 if ($object->isService() && $conf->workstation->enabled) {
2077 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2078 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2079 print $formproduct->selectWorkstations($object->fk_default_workstation,
'fk_default_workstation', 1);
2090 if ($object->isService()) {
2092 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2093 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
2094 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", $object->duration_unit, 0, 1);
2097 print
' ';
2098 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2099 print
'<label for="mandatoryperiod">';
2100 $htmltooltip = $langs->trans(
"mandatoryHelper");
2101 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2106 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2108 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2109 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') : $object->finished));
2114 if (!$object->isService() && isModEnabled(
'bom')) {
2115 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2116 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int) $object->id).
')';
2117 print $form->selectForForms($bomkey,
'fk_default_bom', (GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') : $object->fk_default_bom), 1);
2121 if (!$object->isService()) {
2122 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2124 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2125 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') : $object->weight).
'"> ';
2126 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') : $object->weight_units, 0, 2);
2130 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2132 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2133 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') : $object->length).
'">x';
2134 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') : $object->width).
'">x';
2135 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') : $object->height).
'"> ';
2136 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') : $object->length_units, 0, 2);
2139 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2141 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2142 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') : $object->surface).
'"> ';
2143 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') : $object->surface_units, 0, 2);
2146 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2148 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2149 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') : $object->volume).
'"> ';
2150 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') : $object->volume_units, 0, 2);
2154 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2156 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2157 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') : $object->net_measure).
'"> ';
2158 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') : $object->net_measure_units, 0, 0);
2163 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2164 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2166 print $form->selectUnits($object->fk_unit,
'units');
2171 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2172 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') : $object->customcode).
'"></td></tr>';
2174 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2176 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2177 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2179 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2184 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
2186 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)) {
2187 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2189 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2192 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2193 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'int') : $object->state_id, $object->country_code);
2200 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2201 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.$object->lifetime.
'"></td></tr>';
2202 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.$object->qc_frequency.
'"></td></tr>';
2206 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2207 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2208 print $hookmanager->resPrint;
2209 if (empty($reshook)) {
2210 print $object->showOptionals($extrafields,
'edit', $parameters);
2214 if (isModEnabled(
'categorie')) {
2215 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2216 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
2218 $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT);
2219 $arrayselected = array();
2220 if (is_array($cats)) {
2221 foreach ($cats as $cat) {
2222 $arrayselected[] = $cat->id;
2226 foreach (
GETPOST(
'categories',
'array') as $cat) {
2227 $arrayselected[] = $cat;
2230 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2235 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2236 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2238 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2239 $doleditor->Create();
2248 print
'<table class="border centpercent">';
2250 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2251 if (isModEnabled(
'accounting')) {
2253 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2255 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') : $object->accountancy_code_sell),
'accountancy_code_sell', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2259 if ($mysoc->isInEEC()) {
2260 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2262 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra') : $object->accountancy_code_sell_intra),
'accountancy_code_sell_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2267 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2269 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export') : $object->accountancy_code_sell_export),
'accountancy_code_sell_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2273 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2275 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') : $object->accountancy_code_buy),
'accountancy_code_buy', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2279 if ($mysoc->isInEEC()) {
2280 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2282 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra') : $object->accountancy_code_buy_intra),
'accountancy_code_buy_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2287 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2289 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export') : $object->accountancy_code_buy_export),
'accountancy_code_buy_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2294 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2295 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') : $object->accountancy_code_sell).
'">';
2299 if ($mysoc->isInEEC()) {
2300 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2301 print
'<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra') : $object->accountancy_code_sell_intra).
'">';
2306 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2307 print
'<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export') : $object->accountancy_code_sell_export).
'">';
2311 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2312 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') : $object->accountancy_code_buy).
'">';
2316 if ($mysoc->isInEEC()) {
2317 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2318 print
'<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra') : $object->accountancy_code_buy_intra).
'">';
2323 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2324 print
'<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export') : $object->accountancy_code_buy_export).
'">';
2332 print $form->buttonsSaveCancel();
2338 $showbarcode = isModEnabled(
'barcode');
2339 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2344 $titre = $langs->trans(
"CardProduct".$object->type);
2349 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2350 $object->next_prev_filter =
"fk_product_type = ".((int) $object->type);
2353 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
2360 print
'<div class="fichecenter">';
2361 print
'<div class="fichehalfleft">';
2363 print
'<div class="underbanner clearboth"></div>';
2364 print
'<table class="border tableforfield centpercent">';
2367 if (isModEnabled(
"product") && isModEnabled(
"service")) {
2368 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2369 print
'<tr><td class="titlefield">';
2370 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2372 print $form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
2378 print
'<tr><td class="nowrap">';
2379 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2380 print $langs->trans(
"BarcodeType");
2382 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2383 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbarcodetype&id='.$object->id.
'&token='.newToken().
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
2385 print
'</tr></table>';
2387 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2388 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2392 $fk_barcode_type =
'';
2393 if ($action ==
'editbarcodetype') {
2394 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->barcode_type,
'fk_barcode_type');
2395 $fk_barcode_type = $object->barcode_type;
2397 $object->fetch_barcode();
2398 $fk_barcode_type = $object->barcode_type;
2399 print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2401 print
'</td></tr>'.
"\n";
2404 print
'<tr><td class="nowrap">';
2405 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2406 print $langs->trans(
"BarcodeValue");
2408 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2409 print
'<td class="right"><a class="editfielda" href="'.$_SERVER[
"PHP_SELF"].
'?action=editbarcode&id='.$object->id.
'&token='.newToken().
'">'.
img_edit($langs->trans(
'Edit'), 1).
'</a></td>';
2411 print
'</tr></table>';
2413 if ($action ==
'editbarcode') {
2414 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') : $object->barcode;
2415 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2416 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2419 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2420 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2421 print
'<input type="hidden" name="action" value="setbarcode">';
2422 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2423 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2424 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2429 print
'</td></tr>'.
"\n";
2433 if (isModEnabled(
'productbatch')) {
2434 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2435 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2436 print $object->getLibStatut(0, 2);
2438 if ((($object->status_batch ==
'1' && !empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
2439 || ($object->status_batch ==
'2' && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced' && !empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS)))) {
2440 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2441 print $object->batch_mask;
2447 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2449 print
'<tr><td class="nowrap">';
2450 print $langs->trans(
"ProductAccountancySellCode");
2452 if (isModEnabled(
'accounting')) {
2453 if (!empty($object->accountancy_code_sell)) {
2455 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
2457 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2460 print $object->accountancy_code_sell;
2465 if ($mysoc->isInEEC()) {
2466 print
'<tr><td class="nowrap">';
2467 print $langs->trans(
"ProductAccountancySellIntraCode");
2469 if (isModEnabled(
'accounting')) {
2470 if (!empty($object->accountancy_code_sell_intra)) {
2472 $accountingaccount2->fetch(
'', $object->accountancy_code_sell_intra, 1);
2474 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2477 print $object->accountancy_code_sell_intra;
2483 print
'<tr><td class="nowrap">';
2484 print $langs->trans(
"ProductAccountancySellExportCode");
2486 if (isModEnabled(
'accounting')) {
2487 if (!empty($object->accountancy_code_sell_export)) {
2489 $accountingaccount3->fetch(
'', $object->accountancy_code_sell_export, 1);
2491 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2494 print $object->accountancy_code_sell_export;
2499 print
'<tr><td class="nowrap">';
2500 print $langs->trans(
"ProductAccountancyBuyCode");
2502 if (isModEnabled(
'accounting')) {
2503 if (!empty($object->accountancy_code_buy)) {
2505 $accountingaccount4->fetch(
'', $object->accountancy_code_buy, 1);
2507 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2510 print $object->accountancy_code_buy;
2515 if ($mysoc->isInEEC()) {
2516 print
'<tr><td class="nowrap">';
2517 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2519 if (isModEnabled(
'accounting')) {
2520 if (!empty($object->accountancy_code_buy_intra)) {
2522 $accountingaccount5->fetch(
'', $object->accountancy_code_buy_intra, 1);
2524 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2527 print $object->accountancy_code_buy_intra;
2533 print
'<tr><td class="nowrap">';
2534 print $langs->trans(
"ProductAccountancyBuyExportCode");
2536 if (isModEnabled(
'accounting')) {
2537 if (!empty($object->accountancy_code_buy_export)) {
2539 $accountingaccount6->fetch(
'', $object->accountancy_code_buy_export, 1);
2541 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2544 print $object->accountancy_code_buy_export;
2550 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>'.(
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true)).
'</td></tr>';
2553 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
2554 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2560 if (($object->isProduct() ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
2562 $warehouse->fetch($object->fk_default_warehouse);
2564 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2565 print (!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2569 if ($object->isService() && isModEnabled(
'workstation')) {
2571 $res = $workstation->fetch($object->fk_default_workstation);
2573 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2574 print (!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2579 if (isModEnabled(
'variants') && ($object->isProduct() || $object->isService())) {
2582 if ($combination->fetchByFkProductChild($object->id) > 0) {
2583 $prodstatic =
new Product($db);
2584 $prodstatic->fetch($combination->fk_product_parent);
2587 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2588 print $prodstatic->getNomUrl(1);
2595 print
'<div class="fichehalfright">';
2597 print
'<div class="underbanner clearboth"></div>';
2598 print
'<table class="border tableforfield centpercent">';
2600 if ($object->isService()) {
2602 print
'<tr><td class="titlefield">'.$langs->trans(
"Duration").
'</td><td>';
2603 print $object->duration_value;
2604 if ($object->duration_value > 1) {
2605 $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"));
2606 } elseif ($object->duration_value > 0) {
2607 $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"));
2609 print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ?
" ".$langs->trans($dur[$object->duration_unit]).
" " :
'');
2612 if ($object->duration_value > 0) {
2613 print
' ';
2615 $htmltooltip = $langs->trans(
"mandatoryHelper");
2616 print
'<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2617 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2621 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2623 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2624 print $object->getLibFinished();
2629 if (!$object->isService() && isModEnabled(
'bom') && $object->finished) {
2630 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2631 if ($object->fk_default_bom) {
2632 $bom_static =
new BOM($db);
2633 $bom_static->fetch($object->fk_default_bom);
2634 print $bom_static->getNomUrl(1);
2639 if (!$object->isService()) {
2641 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2642 print
'<tr><td class="titlefield">'.$langs->trans(
"Weight").
'</td><td>';
2643 if ($object->weight !=
'') {
2648 print
"</td></tr>\n";
2651 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2653 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2654 if ($object->length !=
'' || $object->width !=
'' || $object->height !=
'') {
2655 print $object->length;
2656 if ($object->width) {
2657 print
" x ".$object->width;
2659 if ($object->height) {
2660 print
" x ".$object->height;
2662 print
' '.measuringUnitString(0,
"size", $object->length_units);
2666 print
"</td></tr>\n";
2668 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2670 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2671 if ($object->surface !=
'') {
2676 print
"</td></tr>\n";
2678 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2680 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2681 if ($object->volume !=
'') {
2686 print
"</td></tr>\n";
2689 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2691 print
'<tr><td class="titlefield">'.$langs->trans(
"NetMeasure").
'</td><td>';
2692 if ($object->net_measure !=
'') {
2702 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2703 $unit = $object->getLabelOfUnit();
2705 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2707 print $langs->trans($unit);
2713 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2714 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.$object->customcode.
'</td></tr>';
2717 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry($object->country_id, 0, $db);
2718 if (!empty($object->state_id)) {
2719 print
' - '.getState($object->state_id, 0, $db);
2725 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2726 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.$object->lifetime.
'</td></tr>';
2727 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.$object->qc_frequency.
'</td></tr>';
2731 $parameters = array();
2732 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2735 if (isModEnabled(
'categorie')) {
2736 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2737 print $form->showCategories($object->id, Categorie::TYPE_PRODUCT, 1);
2742 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2743 print
'<!-- show Note --> '.
"\n";
2744 print
'<tr><td class="tdtop">'.$langs->trans(
"NotePrivate").
'</td><td>'.(
dol_textishtml($object->note_private) ? $object->note_private :
dol_nl2br($object->note_private, 1,
true)).
'</td></tr>'.
"\n";
2745 print
'<!-- End show Note --> '.
"\n";
2752 print
'<div class="clearboth"></div>';
2756 } elseif ($action !=
'create') {
2762if (!empty($modCodeProduct->code_auto)) {
2763 $tmpcode = $modCodeProduct->getNextValue($object, $object->type);
2769if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2770 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2771 $formconfirm = $form->formconfirm(
"card.php?id=".$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2773if ($action ==
'merge') {
2774 $formquestion = array(
2776 'name' =>
'product_origin',
2777 'label' => $langs->trans(
'MergeOriginProduct'),
2779 'value' => $form->select_produits(
'',
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2782 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
2786if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2787 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2789 $formquestionclone = array(
2790 'text' => $langs->trans(
"ConfirmClone"),
2791 array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.$object->ref : $tmpcode,
'morecss'=>
'width150'),
2792 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2793 array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2795 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
2796 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2798 if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
2799 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2802 $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);
2806$parameters = array(
'formConfirm' => $formconfirm,
'object' => $object);
2807$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
2808if (empty($reshook)) {
2809 $formconfirm .= $hookmanager->resPrint;
2810} elseif ($reshook > 0) {
2811 $formconfirm = $hookmanager->resPrint;
2820if ($action !=
'create' && $action !=
'edit') {
2821 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.newToken();
2822 $cloneButtonId =
'action-clone-no-ajax';
2824 print
"\n".
'<div class="tabsAction">'.
"\n";
2826 $parameters = array();
2827 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
2828 if (empty($reshook)) {
2829 if ($usercancreate) {
2830 if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) {
2831 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.newToken().
'&id='.$object->id,
'', $usercancreate);
2834 if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) {
2835 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2836 $cloneProductUrl =
'';
2837 $cloneButtonId =
'action-clone';
2839 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
2842 $object_is_used = $object->isObjectUsed($object->id);
2844 if ($usercandelete) {
2845 if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) {
2846 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2847 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
2849 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.newToken().
'&id='.$object->id,
'');
2852 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2855 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
2858 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2870if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action ==
'' || $action ==
'view') && $object->status) {
2876 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
2877 $propal =
new Propal($db);
2879 $langs->load(
"propal");
2881 $otherprop = $propal->liste_array(2, 1, 0);
2883 if (is_array($otherprop) && count($otherprop)) {
2884 $html .=
'<tr><td style="width: 200px;">';
2885 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2886 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
2887 $html .=
'</td></tr>';
2889 $html .=
'<tr><td style="width: 200px;">';
2890 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2891 $html .= $langs->trans(
"NoDraftProposals");
2892 $html .=
'</td></tr>';
2897 if (isModEnabled(
'commande') && $user->hasRight(
'commande',
'creer')) {
2900 $langs->load(
"orders");
2902 $othercom = $commande->liste_array(2, 1,
null);
2903 if (is_array($othercom) && count($othercom)) {
2904 $html .=
'<tr><td style="width: 200px;">';
2905 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2906 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
2907 $html .=
'</td></tr>';
2909 $html .=
'<tr><td style="width: 200px;">';
2910 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2911 $html .= $langs->trans(
"NoDraftOrders");
2912 $html .=
'</td></tr>';
2917 if (isModEnabled(
'facture') && $user->hasRight(
'facture',
'creer')) {
2920 $langs->load(
"bills");
2922 $otherinvoice = $invoice->liste_array(2, 1,
null);
2923 if (is_array($otherinvoice) && count($otherinvoice)) {
2924 $html .=
'<tr><td style="width: 200px;">';
2925 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2926 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
2927 $html .=
'</td></tr>';
2929 $html .=
'<tr><td style="width: 200px;">';
2930 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2931 $html .= $langs->trans(
"NoDraftInvoices");
2932 $html .=
'</td></tr>';
2937 if (!empty($html)) {
2938 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2939 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2940 print
'<input type="hidden" name="action" value="addin">';
2946 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
2947 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
2948 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
2949 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
2950 $html .=
'</td></tr>';
2952 print
'<table width="100%" class="border">';
2956 print
'<div class="center">';
2957 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
2971if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
2972 print
'<div class="fichecenter"><div class="fichehalfleft">';
2973 print
'<a name="builddoc"></a>';
2977 if (!empty($conf->product->multidir_output[$object->entity])) {
2978 $filedir = $conf->product->multidir_output[$object->entity].
'/'.$objectref;
2980 $filedir = $conf->product->dir_output.
'/'.$objectref;
2982 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2983 $genallowed = $usercanread;
2984 $delallowed = $usercancreate;
2986 print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'', $object);
2987 $somethingshown = $formfile->numoffiles;
2989 print
'</div><div class="fichehalfright">';
2993 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id);
2996 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2998 $somethingshown =
$formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3000 print
'</div></div>';
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.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader()
Empty header.
Class to manage accounting accounts.
Class to manage categories.
Class to manage customers orders.
Class to manage a WYSIWYG editor.
Class to manage warehouses.
Class to manage invoices.
const TYPE_STANDARD
Standard invoice.
Class of a generic business object.
Class ProductCombination Used to represent a product combination.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
const TYPE_SERVICE
Service.
File of class to manage predefined price products or services by customer.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=0, $outputlangs='', $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
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.
load_fiche_titre($titre, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
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.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=false, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='')
Show information for admin users or standard users.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0)
Set event messages in dol_events session object.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='float')
Show Url link.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
img_edit($titlealt='default', $float=0, $other='')
Show logo editer/modifier fiche.
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) VAT...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.