43 require
'../main.inc.php';
44 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
45 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
46 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
47 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
56 if (!empty($conf->propal->enabled)) {
57 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
60 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
62 if (!empty($conf->commande->enabled)) {
63 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
65 if (!empty($conf->accounting->enabled)) {
66 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
67 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
68 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
70 if (!empty($conf->bom->enabled)) {
71 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
75 $langs->loadLangs(array(
'products',
'other'));
76 if (!empty($conf->stock->enabled)) {
77 $langs->load(
"stocks");
80 $langs->load(
"bills");
82 if (!empty($conf->productbatch->enabled)) {
83 $langs->load(
"productbatch");
86 $mesg =
''; $error = 0; $errors = array();
88 $refalreadyexists = 0;
93 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
94 $cancel =
GETPOST(
'cancel',
'alpha');
95 $backtopage =
GETPOST(
'backtopage',
'alpha');
96 $confirm =
GETPOST(
'confirm',
'alpha');
97 $socid =
GETPOST(
'socid',
'int');
98 $duration_value =
GETPOST(
'duration_value',
'int');
99 $duration_unit =
GETPOST(
'duration_unit',
'alpha');
101 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
102 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
103 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
104 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
105 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
106 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
108 $checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
110 $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ?
'alphanohtml' :
'restricthtml';
112 if (!empty($user->socid)) {
113 $socid = $user->socid;
117 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
118 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
119 $module = substr($module, 0,
dol_strlen($module) - 4);
123 $modCodeProduct =
new $module();
127 $object->type = $type;
131 $extrafields->fetch_name_optionals_label($object->table_element);
133 if ($id > 0 || !empty($ref)) {
134 $result = $object->fetch($id, $ref);
138 if (!empty($conf->product->enabled)) {
139 $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
140 } elseif (!empty($conf->service->enabled)) {
141 $upload_dir = $conf->service->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
144 if (!empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) {
145 if (!empty($conf->product->enabled)) {
146 $upload_dirold = $conf->product->multidir_output[$object->entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
148 $upload_dirold = $conf->service->multidir_output[$object->entity].
'/'.substr(substr(
"000".$object->id, -2), 1, 1).
'/'.substr(substr(
"000".$object->id, -2), 0, 1).
'/'.$object->id.
"/photos";
153 $modulepart =
'product';
156 $canvas = !empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas");
158 if (!empty($canvas)) {
159 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
160 $objcanvas =
new Canvas($db, $action);
161 $objcanvas->getCanvas(
'product',
'card', $canvas);
165 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
166 $fieldtype = (!empty($id) ?
'rowid' :
'ref');
168 if ($object->id > 0) {
169 if ($object->type == $object::TYPE_PRODUCT) {
170 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
172 if ($object->type == $object::TYPE_SERVICE) {
173 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
176 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
180 $hookmanager->initHooks(array(
'productcard',
'globalcard'));
195 $createbarcode = empty($conf->barcode->enabled) ? 0 : 1;
196 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) {
200 $parameters = array(
'id'=>$id,
'ref'=>$ref,
'objcanvas'=>$objcanvas);
201 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
206 if (empty($reshook)) {
207 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
209 if (empty($backtopage) || ($cancel && empty($id))) {
210 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
211 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
212 $backtopage = $backurlforlist;
214 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
220 if (!empty($backtopageforcancel)) {
221 header(
"Location: ".$backtopageforcancel);
223 } elseif (!empty($backtopage)) {
224 header(
"Location: ".$backtopage);
230 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer) {
232 $productOriginId =
GETPOST(
'product_origin',
'int');
233 $productOrigin =
new Product($db);
235 if ($productOriginId <= 0) {
236 $langs->load(
'errors');
237 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
239 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
249 $listofproperties = array(
259 'accountancy_code_buy',
260 'accountancy_code_buy_intra',
261 'accountancy_code_buy_export',
262 'accountancy_code_sell',
263 'accountancy_code_sell_intra',
264 'accountancy_code_sell_export'
266 foreach ($listofproperties as $property) {
267 if (empty($object->$property)) {
268 $object->$property = $productOrigin->$property;
272 $listofproperties = array(
273 'note_public',
'note_private'
275 foreach ($listofproperties as $property) {
276 $object->$property =
dol_concatdesc($object->$property, $productOrigin->$property);
280 if (is_array($productOrigin->array_options)) {
281 foreach ($productOrigin->array_options as $key => $val) {
282 if (empty($object->array_options[$key])) {
283 $object->array_options[$key] = $val;
290 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
291 $custcats = $static_cat->containing($object->id,
'product',
'id');
292 $custcats = array_merge($custcats, $custcats_ori);
293 $object->setCategories($custcats);
296 if ($productOrigin->barcode == $object->barcode) {
297 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
298 $productOrigin->barcode =
'';
303 $result = $object->update($object->id, $user, 0,
'merge');
314 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
315 'Bom' =>
'/bom/class/bom.class.php',
318 'Commande' =>
'/commande/class/commande.class.php',
319 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
320 'Contrat' =>
'/contrat/class/contrat.class.php',
321 'Delivery' =>
'/delivery/class/delivery.class.php',
322 'Facture' =>
'/compta/facture/class/facture.class.php',
323 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
324 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
325 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
326 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
327 'Propal' =>
'/comm/propal/class/propal.class.php',
328 'Reception' =>
'/reception/class/reception.class.php',
329 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
333 foreach ($objects as $object_name => $object_file) {
334 require_once DOL_DOCUMENT_ROOT.$object_file;
336 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id, $object->id)) {
346 $reshook = $hookmanager->executeHooks(
349 'soc_origin' => $productOrigin->id,
350 'soc_dest' => $object->id,
364 $object->context = array(
366 'mergefromid' => $productOrigin->id,
370 $result = $object->call_trigger(
'PRODUCT_MODIFY', $user);
381 if ($productOrigin->delete($user) < 1) {
390 $langs->load(
"errors");
399 if ($action ==
'setfk_product_type' && $usercancreate) {
400 $result = $object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
401 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
406 $upload_dir = $conf->product->dir_output;
407 $permissiontoadd = $usercancreate;
408 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
410 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
413 if ($action ==
'setfk_barcode_type' && $createbarcode) {
414 $result = $object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
415 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
420 if ($action ==
'setbarcode' && $createbarcode) {
421 $result = $object->check_barcode(
GETPOST(
'barcode'),
GETPOST(
'barcode_type_code'));
424 $result = $object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
425 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
428 $langs->load(
"errors");
430 $errors[] =
'ErrorBadBarCodeSyntax';
431 } elseif ($result == -2) {
432 $errors[] =
'ErrorBarCodeRequired';
433 } elseif ($result == -3) {
434 $errors[] =
'ErrorBarCodeAlreadyUsed';
436 $errors[] =
'FailedToValidateBarCode';
445 if ($action ==
'add' && $usercancreate) {
448 if (!
GETPOST(
'label', $label_security_check)) {
449 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
454 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
455 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Ref')),
null,
'errors');
460 if (!empty($duration_value) && empty($duration_unit)) {
461 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
467 $units =
GETPOST(
'units',
'int');
470 $object->label =
GETPOST(
'label', $label_security_check);
471 $object->price_base_type =
GETPOST(
'price_base_type',
'aZ09');
472 $object->mandatory_period = !empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 1 : 0;
473 if ($object->price_base_type ==
'TTC') {
474 $object->price_ttc =
GETPOST(
'price');
476 $object->price =
GETPOST(
'price');
478 if ($object->price_base_type ==
'TTC') {
479 $object->price_min_ttc =
GETPOST(
'price_min');
481 $object->price_min =
GETPOST(
'price_min');
484 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
488 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
489 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
490 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
493 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
495 $vatratecode = $reg[1];
497 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
498 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
499 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
500 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
501 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
502 $resql = $db->query($sql);
504 $obj = $db->fetch_object(
$resql);
505 $npr = $obj->recuperableonly;
506 $localtax1 = $obj->localtax1;
507 $localtax2 = $obj->localtax2;
508 $localtax1_type = $obj->localtax1_type;
509 $localtax2_type = $obj->localtax2_type;
513 $object->default_vat_code = $vatratecode;
514 $object->tva_tx = $tva_tx;
515 $object->tva_npr = $npr;
516 $object->localtax1_tx = $localtax1;
517 $object->localtax2_tx = $localtax2;
518 $object->localtax1_type = $localtax1_type;
519 $object->localtax2_type = $localtax2_type;
521 $object->type = $type;
522 $object->status =
GETPOST(
'statut');
523 $object->status_buy =
GETPOST(
'statut_buy');
524 $object->status_batch =
GETPOST(
'status_batch');
525 $object->batch_mask =
GETPOST(
'batch_mask');
527 $object->barcode_type =
GETPOST(
'fk_barcode_type');
528 $object->barcode =
GETPOST(
'barcode');
531 $stdobject->element =
'product';
532 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
533 $result = $stdobject->fetch_barcode();
536 $mesg =
'Failed to get bar code type information ';
537 setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors,
'errors');
539 $object->barcode_type_code = $stdobject->barcode_type_code;
540 $object->barcode_type_coder = $stdobject->barcode_type_coder;
541 $object->barcode_type_label = $stdobject->barcode_type_label;
546 $object->note = $object->note_private;
547 $object->customcode =
GETPOST(
'customcode',
'alphanohtml');
548 $object->country_id =
GETPOST(
'country_id',
'int');
549 $object->state_id =
GETPOST(
'state_id',
'int');
550 $object->lifetime =
GETPOST(
'lifetime',
'int');
551 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
552 $object->duration_value = $duration_value;
553 $object->duration_unit = $duration_unit;
554 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
555 $object->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte') ?
GETPOST(
'seuil_stock_alerte') : 0;
556 $object->desiredstock =
GETPOST(
'desiredstock') ?
GETPOST(
'desiredstock') : 0;
557 $object->canvas =
GETPOST(
'canvas');
558 $object->net_measure =
GETPOST(
'net_measure');
559 $object->net_measure_units =
GETPOST(
'net_measure_units');
560 $object->weight =
GETPOST(
'weight');
561 $object->weight_units =
GETPOST(
'weight_units');
562 $object->length =
GETPOST(
'size');
563 $object->length_units =
GETPOST(
'size_units');
564 $object->width =
GETPOST(
'sizewidth');
565 $object->height =
GETPOST(
'sizeheight');
566 $object->surface =
GETPOST(
'surface');
567 $object->surface_units =
GETPOST(
'surface_units');
568 $object->volume =
GETPOST(
'volume');
569 $object->volume_units =
GETPOST(
'volume_units');
570 $finished =
GETPOST(
'finished',
'int');
571 if ($finished >= 0) {
572 $object->finished = $finished;
574 $object->finished =
null;
577 $units =
GETPOST(
'units',
'int');
579 $object->fk_unit = $units;
581 $object->fk_unit =
null;
584 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
585 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
586 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
587 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
588 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
589 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
591 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
592 $object->accountancy_code_sell =
'';
594 $object->accountancy_code_sell = $accountancy_code_sell;
596 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
597 $object->accountancy_code_sell_intra =
'';
599 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
601 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
602 $object->accountancy_code_sell_export =
'';
604 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
606 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
607 $object->accountancy_code_buy =
'';
609 $object->accountancy_code_buy = $accountancy_code_buy;
611 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
612 $object->accountancy_code_buy_intra =
'';
614 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
616 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
617 $object->accountancy_code_buy_export =
'';
619 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
623 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
624 for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
627 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
629 $object->multiprices[
"$i"] =
"";
635 $ret = $extrafields->setOptionalsFromPost(
null, $object);
640 if (!$ref && !empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
642 $ref = $modCodeProduct->getNextValue($object, $type);
646 $id = $object->create($user);
651 $categories =
GETPOST(
'categories',
'array');
652 $object->setCategories($categories);
654 if (!empty($backtopage)) {
655 $backtopage = preg_replace(
'/__ID__/', $object->id, $backtopage);
656 if (preg_match(
'/\?/', $backtopage)) {
657 $backtopage .=
'&socid='.$object->id;
659 header(
"Location: ".$backtopage);
662 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
666 if (count($object->errors)) {
677 if ($action ==
'update' && $usercancreate) {
678 if (
GETPOST(
'cancel',
'alpha')) {
681 if ($object->id > 0) {
682 $object->oldcopy = clone $object;
684 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
687 $object->label =
GETPOST(
'label', $label_security_check);
690 $object->description = $desc;
693 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
695 $object->note = $object->note_private;
697 $object->customcode =
GETPOST(
'customcode',
'alpha');
698 $object->country_id =
GETPOST(
'country_id',
'int');
699 $object->state_id =
GETPOST(
'state_id',
'int');
700 $object->lifetime =
GETPOST(
'lifetime',
'int');
701 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
702 $object->status =
GETPOST(
'statut',
'int');
703 $object->status_buy =
GETPOST(
'statut_buy',
'int');
704 $object->status_batch =
GETPOST(
'status_batch',
'aZ09');
705 $object->batch_mask =
GETPOST(
'batch_mask',
'alpha');
706 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
712 $object->duration_value =
GETPOST(
'duration_value',
'int');
713 $object->duration_unit =
GETPOST(
'duration_unit',
'alpha');
715 $object->canvas =
GETPOST(
'canvas');
716 $object->net_measure =
GETPOST(
'net_measure');
717 $object->net_measure_units =
GETPOST(
'net_measure_units');
718 $object->weight =
GETPOST(
'weight');
719 $object->weight_units =
GETPOST(
'weight_units');
720 $object->length =
GETPOST(
'size');
721 $object->length_units =
GETPOST(
'size_units');
722 $object->width =
GETPOST(
'sizewidth');
723 $object->height =
GETPOST(
'sizeheight');
725 $object->surface =
GETPOST(
'surface');
726 $object->surface_units =
GETPOST(
'surface_units');
727 $object->volume =
GETPOST(
'volume');
728 $object->volume_units =
GETPOST(
'volume_units');
730 $finished =
GETPOST(
'finished',
'int');
731 if ($finished >= 0) {
732 $object->finished = $finished;
734 $object->finished =
null;
737 $fk_default_bom =
GETPOST(
'fk_default_bom',
'int');
738 if ($fk_default_bom >= 0) {
739 $object->fk_default_bom = $fk_default_bom;
741 $object->fk_default_bom =
null;
744 $units =
GETPOST(
'units',
'int');
746 $object->fk_unit = $units;
748 $object->fk_unit =
null;
751 $object->barcode_type =
GETPOST(
'fk_barcode_type');
752 $object->barcode =
GETPOST(
'barcode');
755 $stdobject->element =
'product';
756 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
757 $result = $stdobject->fetch_barcode();
760 $mesg =
'Failed to get bar code type information ';
761 setEventMessages($mesg.$stdobject->error, $mesg.$stdobject->errors,
'errors');
763 $object->barcode_type_code = $stdobject->barcode_type_code;
764 $object->barcode_type_coder = $stdobject->barcode_type_coder;
765 $object->barcode_type_label = $stdobject->barcode_type_label;
767 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
768 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
769 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
770 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
771 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
772 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
773 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
774 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
775 $object->accountancy_code_sell =
'';
777 $object->accountancy_code_sell = $accountancy_code_sell;
779 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
780 $object->accountancy_code_sell_intra =
'';
782 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
784 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
785 $object->accountancy_code_sell_export =
'';
787 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
789 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
790 $object->accountancy_code_buy =
'';
792 $object->accountancy_code_buy = $accountancy_code_buy;
794 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
795 $object->accountancy_code_buy_intra =
'';
797 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
799 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
800 $object->accountancy_code_buy_export =
'';
802 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
804 if ($object->isService()) {
805 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
811 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
816 if (!$error && $object->check()) {
817 if ($object->update($object->id, $user) > 0) {
819 $categories =
GETPOST(
'categories',
'array');
820 $object->setCategories($categories);
824 if (count($object->errors)) {
832 if (count($object->errors)) {
835 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
844 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
847 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
854 if ($object->id > 0) {
855 $object->ref =
GETPOST(
'clone_ref',
'alphanohtml');
857 $object->status_buy = 0;
859 $object->barcode = -1;
861 if ($object->check()) {
862 $object->context[
'createfromclone'] =
'createfromclone';
863 $id = $object->create($user);
865 if (
GETPOST(
'clone_composition')) {
866 $result = $object->clone_associations($originalId, $id);
871 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
876 if (
GETPOST(
'clone_categories')) {
877 $result = $object->cloneCategories($originalId, $id);
882 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
888 $result = $object->clone_price($originalId, $id);
893 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$originalId);
903 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
908 if ($object->error ==
'ErrorProductAlreadyExists') {
914 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $object->ref);
915 $mesg .=
' <a href="'.$_SERVER[
"PHP_SELF"].
'?ref='.$object->ref.
'">'.$langs->trans(
"ShowCardHere").
'</a>.';
920 if (count($object->errors)) {
930 unset($object->context[
'createfromclone']);
940 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
943 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
944 $result = $object->delete($user);
947 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.$object->type.
'&delprod='.urlencode($object->ref));
958 if ($object->id > 0 && $action ==
'addin') {
961 $propal =
new Propal($db);
962 $result = $propal->fetch(
GETPOST(
'propalid'));
967 $thirpdartyid = $propal->socid;
968 } elseif (
GETPOST(
'commandeid') > 0) {
970 $result = $commande->fetch(
GETPOST(
'commandeid'));
975 $thirpdartyid = $commande->socid;
976 } elseif (
GETPOST(
'factureid') > 0) {
978 $result = $facture->fetch(
GETPOST(
'factureid'));
983 $thirpdartyid = $facture->socid;
986 if ($thirpdartyid > 0) {
988 $result = $soc->fetch($thirpdartyid);
994 $desc = $object->description;
998 if (empty($tva_tx)) {
1001 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1002 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1004 $pu_ht = $object->price;
1005 $pu_ttc = $object->price_ttc;
1006 $price_base_type = $object->price_base_type;
1009 if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
1010 $pu_ht = $object->multiprices[$soc->price_level];
1011 $pu_ttc = $object->multiprices_ttc[$soc->price_level];
1012 $price_base_type = $object->multiprices_base_type[$soc->price_level];
1013 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1014 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1018 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' => $soc->id);
1020 $result = $prodcustprice->fetch_all(
'',
'', 0, 0, $filter);
1022 if (count($prodcustprice->lines) > 0) {
1023 $pu_ht =
price($prodcustprice->lines [0]->price);
1024 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1025 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1026 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1031 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1032 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1036 if ($tmpvat != $tmpprodvat) {
1037 if ($price_base_type !=
'HT') {
1038 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1040 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1044 if (
GETPOST(
'propalid') > 0) {
1047 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1048 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1051 $buyprice = $result;
1054 $result = $propal->addline(
1079 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1083 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1084 } elseif (
GETPOST(
'commandeid') > 0) {
1087 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1088 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1091 $buyprice = $result;
1094 $result = $commande->addline(
1121 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode($commande->id));
1124 } elseif (
GETPOST(
'factureid') > 0) {
1127 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1128 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1131 $buyprice = $result;
1134 $result = $facture->addline(
1166 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1172 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1187 if (!empty($conf->accounting->enabled)) {
1192 $title = $langs->trans(
'ProductServiceCard');
1194 $shortlabel =
dol_trunc($object->label, 16);
1196 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1197 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1200 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1201 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1208 if (!empty($conf->barcode->enabled) && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
1209 $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
1210 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
1211 foreach ($dirbarcode as $dirroot) {
1218 $modBarCodeProduct =
new $module();
1223 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1227 if (empty($object->error) && $id) {
1228 $result = $object->fetch($id);
1233 $objcanvas->assign_values($action, $object->id, $object->ref);
1234 $objcanvas->display_canvas($action);
1239 if ($action ==
'create' && $usercancreate) {
1241 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1243 if (!empty($conf->use_javascript_ajax)) {
1244 print
'<script type="text/javascript">';
1245 print
'$(document).ready(function () {
1246 $("#selectcountry_id").change(function() {
1247 document.formprod.action.value="create";
1248 document.formprod.submit();
1251 print
'</script>'.
"\n";
1255 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
1256 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1257 $module = substr($module, 0,
dol_strlen($module) - 4);
1261 $modCodeProduct =
new $module();
1266 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1267 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1268 print
'<input type="hidden" name="action" value="add">';
1269 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1270 if (!empty($modCodeProduct->code_auto)) {
1271 print
'<input type="hidden" name="code_auto" value="1">';
1273 if (!empty($modBarCodeProduct->code_auto)) {
1274 print
'<input type="hidden" name="barcode_auto" value="1">';
1276 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1280 $title = $langs->trans(
"NewService");
1283 $title = $langs->trans(
"NewProduct");
1290 if ($object->country_id > 0) {
1291 $tmparray =
getCountry($object->country_id,
'all');
1292 $object->country_code = $tmparray[
'code'];
1293 $object->country = $tmparray[
'label'];
1298 print
'<table class="border centpercent">';
1300 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
1303 if (!empty($modCodeProduct->code_auto)) {
1304 $tmpcode = $modCodeProduct->getNextValue($object, $type);
1306 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(
GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1307 if ($refalreadyexists) {
1308 print $langs->trans(
"RefAlreadyExists");
1314 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>';
1317 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1318 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1319 print
$form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1323 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1324 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1325 print
$form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1329 if (!empty($conf->productbatch->enabled)) {
1330 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1331 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1332 print
$form->selectarray(
'status_batch', $statutarray,
GETPOST(
'status_batch'));
1335 $status_batch =
GETPOST(
'status_batch');
1336 if ($status_batch !==
'0') {
1337 $langs->load(
"admin");
1338 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1339 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1340 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1341 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1342 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1343 if ((!empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
1344 || (!empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced')) {
1345 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1348 print
'<td id="field_mask">';
1349 print
$form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1350 print
'<script type="text/javascript">
1351 $(document).ready(function() {
1352 $("#field_mask, #mask_option").addClass("hideobject");
1353 $("#status_batch").on("change", function () {
1354 console.log("We change batch status");
1355 var optionSelected = $("option:selected", this);
1356 var valueSelected = this.value;
1357 $("#field_mask, #mask_option").addClass("hideobject");
1361 if (this.value == 1) {
1362 $("#field_mask, #mask_option").toggleClass("hideobject");
1363 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1367 if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced') {
1369 if (this.value == 2) {
1370 $("#field_mask, #mask_option").toggleClass("hideobject");
1371 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1384 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1385 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1390 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1392 $fk_barcode_type =
GETPOST(
'fk_barcode_type')?
GETPOST(
'fk_barcode_type'):0;
1394 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
1400 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1402 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1405 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1407 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1408 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1410 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1415 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1417 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_4,
'90%');
1418 $doleditor->Create();
1422 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
1424 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1425 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1426 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1430 if ($type != 1 && !empty($conf->stock->enabled)) {
1432 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1433 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1434 print $formproduct->selectWarehouses(
GETPOST(
'fk_default_warehouse',
'int'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1435 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')).
'">';
1436 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1441 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1443 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1444 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1449 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1450 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1454 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1455 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1456 print
'<input name="desiredstock" type="hidden" value="0">';
1462 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1463 print
'<input name="duration_value" size="4" value="'.GETPOST(
'duration_value',
'int').
'">';
1464 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value',
'alpha') :
'h'), 0, 1);
1467 print
' ';
1468 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
1469 print
'<label for="mandatoryperiod">';
1470 $htmltooltip = $langs->trans(
"mandatoryHelper");
1471 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1478 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
1480 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1481 print $formproduct->selectProductNature(
'finished', $object->finished);
1487 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
1489 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1490 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1491 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);
1496 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
1497 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1498 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1499 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1500 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1501 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') :
'0', 0, 2);
1504 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
1506 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1507 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1508 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') :
'0', 0, 2);
1511 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
1513 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1514 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1515 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') :
'0', 0, 2);
1519 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
1521 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1522 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1523 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);
1529 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1530 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1532 print
$form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
'units');
1537 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) {
1538 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1541 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1543 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1544 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1546 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1551 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
1553 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)) {
1554 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1556 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1559 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1560 print $formcompany->select_state($object->state_id, $object->country_code);
1566 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
1567 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1568 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1572 $parameters = array(
'colspan' =>
' colspan="2"',
'cols'=>2);
1573 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1574 print $hookmanager->resPrint;
1575 if (empty($reshook)) {
1576 print $object->showOptionals($extrafields,
'create',
$parameters);
1582 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1585 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_8,
'90%');
1586 $doleditor->Create();
1591 if (!empty($conf->categorie->enabled)) {
1593 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1594 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
1595 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1603 if (empty($conf->global->PRODUCT_DISABLE_PRICES)) {
1604 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1607 print
'<table class="border centpercent">';
1609 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1611 print
$form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1618 print
'<table class="border centpercent">';
1621 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1622 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1623 print
$form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE,
"price_base_type");
1627 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1628 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1632 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1634 print
$form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1644 print
'<!-- accountancy codes -->'.
"\n";
1645 print
'<table class="border centpercent">';
1647 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
1648 if (!empty($conf->accounting->enabled)) {
1650 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1657 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1661 if ($mysoc->isInEEC()) {
1662 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1665 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1667 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1669 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1674 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1677 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1679 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1681 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1685 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1688 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1690 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1692 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1696 if ($mysoc->isInEEC()) {
1697 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1700 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1702 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1704 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1709 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1712 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1714 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1716 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1719 if (!empty($accountancy_code_sell)) {
1720 $object->accountancy_code_sell = $accountancy_code_sell;
1722 if (!empty($accountancy_code_sell_intra)) {
1723 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1725 if (!empty($accountancy_code_sell_export)) {
1726 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1728 if (!empty($accountancy_code_buy)) {
1729 $object->accountancy_code_buy = $accountancy_code_buy;
1731 if (!empty($accountancy_code_buy_intra)) {
1732 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1734 if (!empty($accountancy_code_buy_export)) {
1735 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1739 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1740 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1744 if ($mysoc->isInEEC()) {
1745 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1746 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1751 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1752 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1756 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1757 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1761 if ($mysoc->isInEEC()) {
1762 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1763 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1768 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1769 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1777 print
$form->buttonsSaveCancel(
"Create");
1780 } elseif ($object->id > 0) {
1786 if ($action ==
'edit' && $usercancreate) {
1788 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1790 if (!empty($conf->use_javascript_ajax)) {
1791 print
'<script type="text/javascript">';
1792 print
'$(document).ready(function () {
1793 $("#selectcountry_id").change(function () {
1794 document.formprod.action.value="edit";
1795 document.formprod.submit();
1798 print
'</script>'.
"\n";
1802 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $object->country_id;
1803 if ($object->country_id) {
1804 $tmparray =
getCountry($object->country_id,
'all');
1805 $object->country_code = $tmparray[
'code'];
1806 $object->country = $tmparray[
'label'];
1809 $type = $langs->trans(
'Product');
1810 if ($object->isService()) {
1811 $type = $langs->trans(
'Service');
1816 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="formprod">'.
"\n";
1817 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1818 print
'<input type="hidden" name="action" value="update">';
1819 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1820 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1823 $titre = $langs->trans(
"CardProduct".$object->type);
1828 print
'<table class="border allwidth">';
1831 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>';
1834 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>';
1837 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1838 print
'<select class="flat" name="statut">';
1840 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
1841 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
1843 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
1844 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
1850 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
1851 print
'<select class="flat" name="statut_buy">';
1853 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1854 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1856 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1857 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1864 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1865 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1866 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1867 print
$form->selectarray(
'status_batch', $statutarray, (
GETPOSTISSET(
'status_batch') ?
GETPOST(
'status_batch') : $object->status_batch));
1869 if (!empty($object->status_batch) || !empty($conf->use_javascript_ajax)) {
1870 $langs->load(
"admin");
1871 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1872 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1873 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1874 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1875 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1876 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1878 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'LOT_ADVANCED_MASK');
1881 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'SN_ADVANCED_MASK');
1885 print
'<td id="field_mask">';
1886 print
$form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
1888 if (!empty($conf->use_javascript_ajax)) {
1889 print
'<script type="text/javascript">
1890 $(document).ready(function() {
1891 $("#field_mask").parent().addClass("hideobject");
1892 var preselect = document.getElementById("status_batch");';
1894 print
'if (preselect.value == "2") {
1895 $("#field_mask").parent().removeClass("hideobject");
1899 print
'if (preselect.value == "1") {
1900 $("#field_mask").parent().removeClass("hideobject");
1903 print
'$("#status_batch").on("change", function () {
1904 var optionSelected = $("option:selected", this);
1905 var valueSelected = this.value;
1906 $("#field_mask").parent().addClass("hideobject");
1910 if (this.value == 1) {
1911 $("#field_mask").parent().removeClass("hideobject");
1912 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1918 if (this.value == 2) {
1919 $("#field_mask").parent().removeClass("hideobject");
1920 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1935 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1936 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1941 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1943 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
1945 $fk_barcode_type = $object->barcode_type;
1946 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
1947 $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
1950 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1952 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1954 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1956 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1957 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1959 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1964 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1967 $doleditor =
new DolEditor(
'desc',
GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') : $object->description,
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_4,
'90%');
1968 $doleditor->Create();
1974 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
1975 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1976 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1977 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') : $object->url).
'">';
1982 if ($object->isProduct() && !empty($conf->stock->enabled)) {
1984 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1985 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1986 print $formproduct->selectWarehouses((
GETPOSTISSET(
'fk_default_warehouse') ?
GETPOST(
'fk_default_warehouse') : $object->fk_default_warehouse),
'fk_default_warehouse',
'warehouseopen', 1);
1987 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int) $object->id)).
'">';
1988 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2007 if ($object->isService()) {
2009 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2010 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
2011 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", $object->duration_unit, 0, 1);
2014 print
' ';
2015 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2016 print
'<label for="mandatoryperiod">';
2017 $htmltooltip = $langs->trans(
"mandatoryHelper");
2018 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2023 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2025 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2026 print $formproduct->selectProductNature(
'finished', (
GETPOSTISSET(
'finished') ?
GETPOST(
'finished') : $object->finished));
2031 if (!$object->isService() && !empty($conf->bom->enabled)) {
2032 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2033 $bomkey =
"Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".((int) $object->id);
2034 print
$form->selectForForms($bomkey,
'fk_default_bom', (
GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') : $object->fk_default_bom), 1);
2038 if (!$object->isService()) {
2039 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2041 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2042 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') : $object->weight).
'"> ';
2043 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') : $object->weight_units, 0, 2);
2047 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2049 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2050 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') : $object->length).
'">x';
2051 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') : $object->width).
'">x';
2052 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') : $object->height).
'"> ';
2053 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') : $object->length_units, 0, 2);
2056 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2058 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2059 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') : $object->surface).
'"> ';
2060 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') : $object->surface_units, 0, 2);
2063 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2065 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2066 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') : $object->volume).
'"> ';
2067 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') : $object->volume_units, 0, 2);
2071 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2073 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2074 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') : $object->net_measure).
'"> ';
2075 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"",
GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') : $object->net_measure_units, 0, 0);
2080 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2081 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2083 print
$form->selectUnits($object->fk_unit,
'units');
2088 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2089 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.(
GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') : $object->customcode).
'"></td></tr>';
2091 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2093 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2094 print
$form->select_country(
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2096 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2101 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
2103 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)) {
2104 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2106 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2109 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2110 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'int') : $object->state_id, $object->country_code);
2117 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2118 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.$object->lifetime.
'"></td></tr>';
2119 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.$object->qc_frequency.
'"></td></tr>';
2123 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2124 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2125 print $hookmanager->resPrint;
2126 if (empty($reshook)) {
2127 print $object->showOptionals($extrafields,
'edit',
$parameters);
2132 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2133 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
2135 $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT);
2136 $arrayselected = array();
2137 if (is_array($cats)) {
2138 foreach ($cats as $cat) {
2139 $arrayselected[] = $cat->id;
2143 foreach (
GETPOST(
'categories',
'array') as $cat) {
2144 $arrayselected[] = $cat;
2147 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2152 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2153 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2155 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_PRODUCTDESC'), ROWS_4,
'90%');
2156 $doleditor->Create();
2165 print
'<table class="border centpercent">';
2167 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2168 if (!empty($conf->accounting->enabled)) {
2170 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2172 print $formaccounting->select_account((
GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') : $object->accountancy_code_sell),
'accountancy_code_sell', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2176 if ($mysoc->isInEEC()) {
2177 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2179 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');
2184 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2186 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');
2190 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2192 print $formaccounting->select_account((
GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') : $object->accountancy_code_buy),
'accountancy_code_buy', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2196 if ($mysoc->isInEEC()) {
2197 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2199 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');
2204 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2206 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');
2211 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2212 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') : $object->accountancy_code_sell).
'">';
2216 if ($mysoc->isInEEC()) {
2217 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2218 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).
'">';
2223 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2224 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).
'">';
2228 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2229 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') : $object->accountancy_code_buy).
'">';
2233 if ($mysoc->isInEEC()) {
2234 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2235 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).
'">';
2240 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2241 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).
'">';
2249 print
$form->buttonsSaveCancel();
2255 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
2256 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2261 $titre = $langs->trans(
"CardProduct".$object->type);
2266 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2267 $object->next_prev_filter =
" fk_product_type = ".$object->type;
2270 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
2277 print
'<div class="fichecenter">';
2278 print
'<div class="fichehalfleft">';
2280 print
'<div class="underbanner clearboth"></div>';
2281 print
'<table class="border tableforfield centpercent">';
2284 if (!empty($conf->product->enabled) && !empty($conf->service->enabled)) {
2285 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2286 print
'<tr><td class="titlefield">';
2287 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2289 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
2295 print
'<tr><td class="nowrap">';
2296 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2297 print $langs->trans(
"BarcodeType");
2299 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2300 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>';
2302 print
'</tr></table>';
2304 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2305 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2309 $fk_barcode_type =
'';
2310 if ($action ==
'editbarcodetype') {
2311 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->barcode_type,
'fk_barcode_type');
2312 $fk_barcode_type = $object->barcode_type;
2314 $object->fetch_barcode();
2315 $fk_barcode_type = $object->barcode_type;
2316 print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2318 print
'</td></tr>'.
"\n";
2321 print
'<tr><td class="nowrap">';
2322 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2323 print $langs->trans(
"BarcodeValue");
2325 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2326 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>';
2328 print
'</tr></table>';
2330 if ($action ==
'editbarcode') {
2332 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2333 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2336 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2337 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2338 print
'<input type="hidden" name="action" value="setbarcode">';
2339 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2340 print
'<input size="40" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2341 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2346 print
'</td></tr>'.
"\n";
2350 if (!empty($conf->productbatch->enabled)) {
2351 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2352 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2353 print $object->getLibStatut(0, 2);
2355 if ((($object->status_batch ==
'1' && !empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
2356 || ($object->status_batch ==
'2' && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced' && !empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS)))) {
2357 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2358 print $object->batch_mask;
2364 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2366 print
'<tr><td class="nowrap">';
2367 print $langs->trans(
"ProductAccountancySellCode");
2369 if (!empty($conf->accounting->enabled)) {
2370 if (!empty($object->accountancy_code_sell)) {
2372 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
2374 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2377 print $object->accountancy_code_sell;
2382 if ($mysoc->isInEEC()) {
2383 print
'<tr><td class="nowrap">';
2384 print $langs->trans(
"ProductAccountancySellIntraCode");
2386 if (!empty($conf->accounting->enabled)) {
2387 if (!empty($object->accountancy_code_sell_intra)) {
2389 $accountingaccount2->fetch(
'', $object->accountancy_code_sell_intra, 1);
2391 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2394 print $object->accountancy_code_sell_intra;
2400 print
'<tr><td class="nowrap">';
2401 print $langs->trans(
"ProductAccountancySellExportCode");
2403 if (!empty($conf->accounting->enabled)) {
2404 if (!empty($object->accountancy_code_sell_export)) {
2406 $accountingaccount3->fetch(
'', $object->accountancy_code_sell_export, 1);
2408 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2411 print $object->accountancy_code_sell_export;
2416 print
'<tr><td class="nowrap">';
2417 print $langs->trans(
"ProductAccountancyBuyCode");
2419 if (!empty($conf->accounting->enabled)) {
2420 if (!empty($object->accountancy_code_buy)) {
2422 $accountingaccount4->fetch(
'', $object->accountancy_code_buy, 1);
2424 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2427 print $object->accountancy_code_buy;
2432 if ($mysoc->isInEEC()) {
2433 print
'<tr><td class="nowrap">';
2434 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2436 if (!empty($conf->accounting->enabled)) {
2437 if (!empty($object->accountancy_code_buy_intra)) {
2439 $accountingaccount5->fetch(
'', $object->accountancy_code_buy_intra, 1);
2441 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2444 print $object->accountancy_code_buy_intra;
2450 print
'<tr><td class="nowrap">';
2451 print $langs->trans(
"ProductAccountancyBuyExportCode");
2453 if (!empty($conf->accounting->enabled)) {
2454 if (!empty($object->accountancy_code_buy_export)) {
2456 $accountingaccount6->fetch(
'', $object->accountancy_code_buy_export, 1);
2458 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2461 print $object->accountancy_code_buy_export;
2467 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>'.(
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true)).
'</td></tr>';
2470 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
2471 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2477 if ($object->isProduct() && !empty($conf->stock->enabled)) {
2479 $warehouse->fetch($object->fk_default_warehouse);
2481 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2482 print (!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2487 if (!empty($conf->variants->enabled) && ($object->isProduct() || $object->isService())) {
2490 if ($combination->fetchByFkProductChild($object->id) > 0) {
2491 $prodstatic =
new Product($db);
2492 $prodstatic->fetch($combination->fk_product_parent);
2495 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2496 print $prodstatic->getNomUrl(1);
2503 print
'<div class="fichehalfright">';
2505 print
'<div class="underbanner clearboth"></div>';
2506 print
'<table class="border tableforfield centpercent">';
2508 if ($object->isService()) {
2510 print
'<tr><td class="titlefield">'.$langs->trans(
"Duration").
'</td><td>';
2511 print $object->duration_value;
2512 if ($object->duration_value > 1) {
2513 $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"));
2514 } elseif ($object->duration_value > 0) {
2515 $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"));
2517 print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ?
" ".$langs->trans($dur[$object->duration_unit]).
" " :
'');
2520 if ($object->duration_value > 0) {
2521 print
' ';
2523 $htmltooltip = $langs->trans(
"mandatoryHelper");
2524 print
'<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2525 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2529 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2531 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2532 print $object->getLibFinished();
2537 if (!$object->isService() && !empty($conf->bom->enabled) && $object->finished) {
2538 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2539 if ($object->fk_default_bom) {
2540 $bom_static =
new BOM($db);
2541 $bom_static->fetch($object->fk_default_bom);
2542 print $bom_static->getNomUrl(1);
2547 if (!$object->isService()) {
2549 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2550 print
'<tr><td class="titlefield">'.$langs->trans(
"Weight").
'</td><td>';
2551 if ($object->weight !=
'') {
2556 print
"</td></tr>\n";
2559 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2561 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2562 if ($object->length !=
'' || $object->width !=
'' || $object->height !=
'') {
2563 print $object->length;
2564 if ($object->width) {
2565 print
" x ".$object->width;
2567 if ($object->height) {
2568 print
" x ".$object->height;
2570 print
' '.measuringUnitString(0,
"size", $object->length_units);
2574 print
"</td></tr>\n";
2576 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2578 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2579 if ($object->surface !=
'') {
2584 print
"</td></tr>\n";
2586 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2588 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2589 if ($object->volume !=
'') {
2594 print
"</td></tr>\n";
2597 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2599 print
'<tr><td class="titlefield">'.$langs->trans(
"NetMeasure").
'</td><td>';
2600 if ($object->net_measure !=
'') {
2610 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2611 $unit = $object->getLabelOfUnit();
2613 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2615 print $langs->trans($unit);
2621 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2622 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.$object->customcode.
'</td></tr>';
2625 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry($object->country_id, 0, $db);
2626 if (!empty($object->state_id)) {
2627 print
' - '.getState($object->state_id, 0, $db);
2633 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2634 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.$object->lifetime.
'</td></tr>';
2635 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.$object->qc_frequency.
'</td></tr>';
2640 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2644 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2645 print
$form->showCategories($object->id, Categorie::TYPE_PRODUCT, 1);
2650 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2651 print
'<!-- show Note --> '.
"\n";
2652 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";
2653 print
'<!-- End show Note --> '.
"\n";
2660 print
'<div style="clear:both"></div>';
2664 } elseif ($action !=
'create') {
2670 if (!empty($modCodeProduct->code_auto)) {
2671 $tmpcode = $modCodeProduct->getNextValue($object, $object->type);
2677 if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2678 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2679 $formconfirm =
$form->formconfirm(
"card.php?id=".$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2681 if ($action ==
'merge') {
2682 $formquestion = array(
2684 'name' =>
'product_origin',
2685 'label' => $langs->trans(
'MergeOriginProduct'),
2687 'value' =>
$form->select_produits(
'',
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2690 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
2694 if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2695 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2697 $formquestionclone = array(
2698 'text' => $langs->trans(
"ConfirmClone"),
2699 array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.$object->ref : $tmpcode,
'morecss'=>
'width150'),
2700 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2701 array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2703 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
2704 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2706 if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
2707 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2710 $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);
2715 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2716 if (empty($reshook)) {
2718 } elseif ($reshook > 0) {
2728 if ($action !=
'create' && $action !=
'edit') {
2729 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
2730 $cloneButtonId =
'action-clone-no-ajax';
2732 print
"\n".
'<div class="tabsAction">'.
"\n";
2735 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2736 if (empty($reshook)) {
2737 if ($usercancreate) {
2738 if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) {
2739 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'', $usercancreate);
2742 if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) {
2743 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2744 $cloneProductUrl =
'';
2745 $cloneButtonId =
'action-clone';
2747 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
2750 $object_is_used = $object->isObjectUsed($object->id);
2752 if ($usercandelete) {
2753 if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) {
2754 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2755 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
2757 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
2760 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2763 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
2766 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2778 if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action ==
'' || $action ==
'view') && $object->status) {
2784 if (!empty($conf->propal->enabled) && $user->rights->propale->creer) {
2785 $propal =
new Propal($db);
2787 $langs->load(
"propal");
2789 $otherprop = $propal->liste_array(2, 1, 0);
2791 if (is_array($otherprop) && count($otherprop)) {
2792 $html .=
'<tr><td style="width: 200px;">';
2793 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2794 $html .=
$form->selectarray(
"propalid", $otherprop, 0, 1);
2795 $html .=
'</td></tr>';
2797 $html .=
'<tr><td style="width: 200px;">';
2798 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2799 $html .= $langs->trans(
"NoDraftProposals");
2800 $html .=
'</td></tr>';
2805 if (!empty($conf->commande->enabled) && $user->rights->commande->creer) {
2808 $langs->load(
"orders");
2810 $othercom = $commande->liste_array(2, 1,
null);
2811 if (is_array($othercom) && count($othercom)) {
2812 $html .=
'<tr><td style="width: 200px;">';
2813 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2814 $html .=
$form->selectarray(
"commandeid", $othercom, 0, 1);
2815 $html .=
'</td></tr>';
2817 $html .=
'<tr><td style="width: 200px;">';
2818 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2819 $html .= $langs->trans(
"NoDraftOrders");
2820 $html .=
'</td></tr>';
2825 if (
isModEnabled(
'facture') && $user->rights->facture->creer) {
2828 $langs->load(
"bills");
2830 $otherinvoice = $invoice->liste_array(2, 1,
null);
2831 if (is_array($otherinvoice) && count($otherinvoice)) {
2832 $html .=
'<tr><td style="width: 200px;">';
2833 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2834 $html .=
$form->selectarray(
"factureid", $otherinvoice, 0, 1);
2835 $html .=
'</td></tr>';
2837 $html .=
'<tr><td style="width: 200px;">';
2838 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2839 $html .= $langs->trans(
"NoDraftInvoices");
2840 $html .=
'</td></tr>';
2845 if (!empty($html)) {
2846 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2847 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2848 print
'<input type="hidden" name="action" value="addin">';
2854 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
2855 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
2856 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
2857 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
2858 $html .=
'</td></tr>';
2860 print
'<table width="100%" class="border">';
2864 print
'<div class="center">';
2865 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
2879 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
2880 print
'<div class="fichecenter"><div class="fichehalfleft">';
2881 print
'<a name="builddoc"></a>';
2885 if (!empty($conf->product->multidir_output[$object->entity])) {
2886 $filedir = $conf->product->multidir_output[$object->entity].
'/'.$objectref;
2888 $filedir = $conf->product->dir_output.
'/'.$objectref;
2890 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2891 $genallowed = $usercanread;
2892 $delallowed = $usercancreate;
2894 print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'', $object);
2895 $somethingshown = $formfile->numoffiles;
2897 print
'</div><div class="fichehalfright">';
2901 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id);
2904 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2906 $somethingshown =
$formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
2908 print
'</div></div>';