46 require
'../main.inc.php';
47 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
48 require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
49 require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
50 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
51 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
52 require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
53 require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
54 require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
55 require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
56 require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
57 require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
58 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
61 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
64 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
67 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
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';
75 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
79 $langs->loadLangs(array(
'products',
'other'));
81 $langs->load(
"stocks");
84 $langs->load(
"bills");
87 $langs->load(
"productbatch");
90 $mesg =
''; $error = 0; $errors = array();
92 $refalreadyexists = 0;
98 $action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
99 $cancel =
GETPOST(
'cancel',
'alpha');
100 $backtopage =
GETPOST(
'backtopage',
'alpha');
101 $confirm =
GETPOST(
'confirm',
'alpha');
102 $socid =
GETPOST(
'socid',
'int');
103 $duration_value =
GETPOST(
'duration_value',
'int');
104 $duration_unit =
GETPOST(
'duration_unit',
'alpha');
106 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
107 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
108 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
109 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
110 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
111 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
113 $checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
116 $label_security_check = empty($conf->global->MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML) ?
'alphanohtml' :
'restricthtml';
118 if (!empty($user->socid)) {
119 $socid = $user->socid;
123 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
124 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
125 $module = substr($module, 0,
dol_strlen($module) - 4);
129 $modCodeProduct =
new $module();
133 $object->type = $type;
137 $extrafields->fetch_name_optionals_label($object->table_element);
139 if ($id > 0 || !empty($ref)) {
140 $result = $object->fetch($id, $ref);
145 $upload_dir = $conf->product->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
147 $upload_dir = $conf->service->multidir_output[$object->entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName($object->ref);
152 $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";
154 $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";
159 $modulepart =
'product';
162 $canvas = !empty($object->canvas) ? $object->canvas :
GETPOST(
"canvas");
164 if (!empty($canvas)) {
165 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
166 $objcanvas =
new Canvas($db, $action);
167 $objcanvas->getCanvas(
'product',
'card', $canvas);
171 $fieldvalue = (!empty($id) ? $id : (!empty($ref) ? $ref :
''));
172 $fieldtype = (!empty($id) ?
'rowid' :
'ref');
174 if ($object->id > 0) {
175 if ($object->type == $object::TYPE_PRODUCT) {
176 restrictedArea($user,
'produit', $object->id,
'product&product',
'',
'');
178 if ($object->type == $object::TYPE_SERVICE) {
179 restrictedArea($user,
'service', $object->id,
'product&product',
'',
'');
182 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
186 $hookmanager->initHooks(array(
'productcard',
'globalcard'));
202 $createbarcode = empty($conf->barcode->enabled) ? 0 : 1;
203 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->creer_advance)) {
207 $parameters = array(
'id'=>$id,
'ref'=>$ref,
'objcanvas'=>$objcanvas);
208 $reshook = $hookmanager->executeHooks(
'doActions',
$parameters, $object, $action);
213 if (empty($reshook)) {
214 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
216 if (empty($backtopage) || ($cancel && empty($id))) {
217 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
218 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
219 $backtopage = $backurlforlist;
221 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) && $id > 0) ? $id :
'__ID__');
227 if (!empty($backtopageforcancel)) {
228 header(
"Location: ".$backtopageforcancel);
230 } elseif (!empty($backtopage)) {
231 header(
"Location: ".$backtopage);
237 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->rights->societe->creer) {
239 $productOriginId =
GETPOST(
'product_origin',
'int');
240 $productOrigin =
new Product($db);
242 if ($productOriginId <= 0) {
243 $langs->load(
'errors');
244 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
246 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
256 $listofproperties = array(
266 'accountancy_code_buy',
267 'accountancy_code_buy_intra',
268 'accountancy_code_buy_export',
269 'accountancy_code_sell',
270 'accountancy_code_sell_intra',
271 'accountancy_code_sell_export'
273 foreach ($listofproperties as $property) {
274 if (empty($object->$property)) {
275 $object->$property = $productOrigin->$property;
279 $listofproperties = array(
280 'note_public',
'note_private'
282 foreach ($listofproperties as $property) {
283 $object->$property =
dol_concatdesc($object->$property, $productOrigin->$property);
287 if (is_array($productOrigin->array_options)) {
288 foreach ($productOrigin->array_options as $key => $val) {
289 if (empty($object->array_options[$key])) {
290 $object->array_options[$key] = $val;
297 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
298 $custcats = $static_cat->containing($object->id,
'product',
'id');
299 $custcats = array_merge($custcats, $custcats_ori);
300 $object->setCategories($custcats);
303 if ($productOrigin->barcode == $object->barcode) {
304 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
305 $productOrigin->barcode =
'';
310 $result = $object->update($object->id, $user, 0,
'merge');
321 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
322 'Bom' =>
'/bom/class/bom.class.php',
325 'Commande' =>
'/commande/class/commande.class.php',
326 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
327 'Contrat' =>
'/contrat/class/contrat.class.php',
328 'Delivery' =>
'/delivery/class/delivery.class.php',
329 'Facture' =>
'/compta/facture/class/facture.class.php',
330 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
331 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
332 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
333 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
334 'Propal' =>
'/comm/propal/class/propal.class.php',
335 'Reception' =>
'/reception/class/reception.class.php',
336 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
340 foreach ($objects as $object_name => $object_file) {
341 require_once DOL_DOCUMENT_ROOT.$object_file;
343 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id, $object->id)) {
353 $reshook = $hookmanager->executeHooks(
356 'soc_origin' => $productOrigin->id,
357 'soc_dest' => $object->id,
371 $object->context = array(
373 'mergefromid' => $productOrigin->id,
377 $result = $object->call_trigger(
'PRODUCT_MODIFY', $user);
388 if ($productOrigin->delete($user) < 1) {
397 $langs->load(
"errors");
406 if ($action ==
'setfk_product_type' && $usercancreate) {
407 $result = $object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
408 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
413 $upload_dir = $conf->product->dir_output;
414 $permissiontoadd = $usercancreate;
415 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
417 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
420 if ($action ==
'setfk_barcode_type' && $createbarcode) {
421 $result = $object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
422 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
427 if ($action ==
'setbarcode' && $createbarcode) {
428 $result = $object->check_barcode(
GETPOST(
'barcode'),
GETPOST(
'barcode_type_code'));
431 $result = $object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
432 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$object->id);
435 $langs->load(
"errors");
437 $errors[] =
'ErrorBadBarCodeSyntax';
438 } elseif ($result == -2) {
439 $errors[] =
'ErrorBarCodeRequired';
440 } elseif ($result == -3) {
441 $errors[] =
'ErrorBarCodeAlreadyUsed';
443 $errors[] =
'FailedToValidateBarCode';
452 if ($action ==
'add' && $usercancreate) {
455 if (!
GETPOST(
'label', $label_security_check)) {
456 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
461 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
462 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Ref')),
null,
'errors');
467 if (!empty($duration_value) && empty($duration_unit)) {
468 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
474 $units =
GETPOST(
'units',
'int');
477 $object->label =
GETPOST(
'label', $label_security_check);
478 $object->price_base_type =
GETPOST(
'price_base_type',
'aZ09');
479 $object->mandatory_period = !empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 1 : 0;
480 if ($object->price_base_type ==
'TTC') {
481 $object->price_ttc =
GETPOST(
'price');
483 $object->price =
GETPOST(
'price');
485 if ($object->price_base_type ==
'TTC') {
486 $object->price_min_ttc =
GETPOST(
'price_min');
488 $object->price_min =
GETPOST(
'price_min');
491 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
495 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
496 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
497 $localtax1 = 0; $localtax2 = 0; $localtax1_type =
'0'; $localtax2_type =
'0';
500 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
502 $vatratecode = $reg[1];
504 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
505 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
506 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
507 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
508 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
509 $resql = $db->query($sql);
511 $obj = $db->fetch_object(
$resql);
512 $npr = $obj->recuperableonly;
513 $localtax1 = $obj->localtax1;
514 $localtax2 = $obj->localtax2;
515 $localtax1_type = $obj->localtax1_type;
516 $localtax2_type = $obj->localtax2_type;
520 $object->default_vat_code = $vatratecode;
521 $object->tva_tx = $tva_tx;
522 $object->tva_npr = $npr;
523 $object->localtax1_tx = $localtax1;
524 $object->localtax2_tx = $localtax2;
525 $object->localtax1_type = $localtax1_type;
526 $object->localtax2_type = $localtax2_type;
528 $object->type = $type;
529 $object->status =
GETPOST(
'statut');
530 $object->status_buy =
GETPOST(
'statut_buy');
531 $object->status_batch =
GETPOST(
'status_batch');
532 $object->batch_mask =
GETPOST(
'batch_mask');
534 $object->barcode_type =
GETPOST(
'fk_barcode_type');
535 $object->barcode =
GETPOST(
'barcode');
538 $stdobject->element =
'product';
539 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
540 $result = $stdobject->fetch_barcode();
543 $mesg =
'Failed to get bar code type information ';
546 $object->barcode_type_code = $stdobject->barcode_type_code;
547 $object->barcode_type_coder = $stdobject->barcode_type_coder;
548 $object->barcode_type_label = $stdobject->barcode_type_label;
553 $object->note = $object->note_private;
554 $object->customcode =
GETPOST(
'customcode',
'alphanohtml');
555 $object->country_id =
GETPOST(
'country_id',
'int');
556 $object->state_id =
GETPOST(
'state_id',
'int');
557 $object->lifetime =
GETPOST(
'lifetime',
'int');
558 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
559 $object->duration_value = $duration_value;
560 $object->duration_unit = $duration_unit;
561 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
562 $object->fk_default_workstation =
GETPOST(
'fk_default_workstation');
563 $object->seuil_stock_alerte =
GETPOST(
'seuil_stock_alerte') ?
GETPOST(
'seuil_stock_alerte') : 0;
564 $object->desiredstock =
GETPOST(
'desiredstock') ?
GETPOST(
'desiredstock') : 0;
565 $object->canvas =
GETPOST(
'canvas');
566 $object->net_measure =
GETPOST(
'net_measure');
567 $object->net_measure_units =
GETPOST(
'net_measure_units');
568 $object->weight =
GETPOST(
'weight');
569 $object->weight_units =
GETPOST(
'weight_units');
570 $object->length =
GETPOST(
'size');
571 $object->length_units =
GETPOST(
'size_units');
572 $object->width =
GETPOST(
'sizewidth');
573 $object->height =
GETPOST(
'sizeheight');
574 $object->surface =
GETPOST(
'surface');
575 $object->surface_units =
GETPOST(
'surface_units');
576 $object->volume =
GETPOST(
'volume');
577 $object->volume_units =
GETPOST(
'volume_units');
578 $finished =
GETPOST(
'finished',
'int');
579 if ($finished >= 0) {
580 $object->finished = $finished;
582 $object->finished =
null;
585 $units =
GETPOST(
'units',
'int');
587 $object->fk_unit = $units;
589 $object->fk_unit =
null;
592 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
593 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
594 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
595 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
596 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
597 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
599 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
600 $object->accountancy_code_sell =
'';
602 $object->accountancy_code_sell = $accountancy_code_sell;
604 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
605 $object->accountancy_code_sell_intra =
'';
607 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
609 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
610 $object->accountancy_code_sell_export =
'';
612 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
614 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
615 $object->accountancy_code_buy =
'';
617 $object->accountancy_code_buy = $accountancy_code_buy;
619 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
620 $object->accountancy_code_buy_intra =
'';
622 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
624 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
625 $object->accountancy_code_buy_export =
'';
627 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
631 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
632 for ($i = 2; $i <= $conf->global->PRODUIT_MULTIPRICES_LIMIT; $i++) {
635 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
637 $object->multiprices[
"$i"] =
"";
643 $ret = $extrafields->setOptionalsFromPost(
null, $object);
648 if (!$ref && !empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
650 $ref = $modCodeProduct->getNextValue($object, $type);
654 $id = $object->create($user);
659 $categories =
GETPOST(
'categories',
'array');
660 $object->setCategories($categories);
662 if (!empty($backtopage)) {
663 $backtopage = preg_replace(
'/__ID__/', $object->id, $backtopage);
664 if (preg_match(
'/\?/', $backtopage)) {
665 $backtopage .=
'&socid='.$object->id;
667 header(
"Location: ".$backtopage);
670 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
674 if (count($object->errors)) {
677 if ($object->error ==
'ErrorProductAlreadyExists') {
679 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists',
$parameters, $object, $action);
683 if ($object->error) {
698 if ($action ==
'update' && $usercancreate) {
699 if (
GETPOST(
'cancel',
'alpha')) {
702 if ($object->id > 0) {
703 $object->oldcopy = clone $object;
705 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
708 $object->label =
GETPOST(
'label', $label_security_check);
711 $object->description = $desc;
714 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
716 $object->note = $object->note_private;
718 $object->customcode =
GETPOST(
'customcode',
'alpha');
719 $object->country_id =
GETPOST(
'country_id',
'int');
720 $object->state_id =
GETPOST(
'state_id',
'int');
721 $object->lifetime =
GETPOST(
'lifetime',
'int');
722 $object->qc_frequency =
GETPOST(
'qc_frequency',
'int');
723 $object->status =
GETPOST(
'statut',
'int');
724 $object->status_buy =
GETPOST(
'statut_buy',
'int');
725 $object->status_batch =
GETPOST(
'status_batch',
'aZ09');
726 $object->batch_mask =
GETPOST(
'batch_mask',
'alpha');
727 $object->fk_default_warehouse =
GETPOST(
'fk_default_warehouse');
728 $object->fk_default_workstation =
GETPOST(
'fk_default_workstation');
734 $object->duration_value =
GETPOST(
'duration_value',
'int');
735 $object->duration_unit =
GETPOST(
'duration_unit',
'alpha');
737 $object->canvas =
GETPOST(
'canvas');
738 $object->net_measure =
GETPOST(
'net_measure');
739 $object->net_measure_units =
GETPOST(
'net_measure_units');
740 $object->weight =
GETPOST(
'weight');
741 $object->weight_units =
GETPOST(
'weight_units');
742 $object->length =
GETPOST(
'size');
743 $object->length_units =
GETPOST(
'size_units');
744 $object->width =
GETPOST(
'sizewidth');
745 $object->height =
GETPOST(
'sizeheight');
747 $object->surface =
GETPOST(
'surface');
748 $object->surface_units =
GETPOST(
'surface_units');
749 $object->volume =
GETPOST(
'volume');
750 $object->volume_units =
GETPOST(
'volume_units');
752 $finished =
GETPOST(
'finished',
'int');
753 if ($finished >= 0) {
754 $object->finished = $finished;
756 $object->finished =
null;
759 $fk_default_bom =
GETPOST(
'fk_default_bom',
'int');
760 if ($fk_default_bom >= 0) {
761 $object->fk_default_bom = $fk_default_bom;
763 $object->fk_default_bom =
null;
766 $units =
GETPOST(
'units',
'int');
768 $object->fk_unit = $units;
770 $object->fk_unit =
null;
773 $object->barcode_type =
GETPOST(
'fk_barcode_type');
774 $object->barcode =
GETPOST(
'barcode');
777 $stdobject->element =
'product';
778 $stdobject->barcode_type =
GETPOST(
'fk_barcode_type');
779 $result = $stdobject->fetch_barcode();
782 $mesg =
'Failed to get bar code type information ';
785 $object->barcode_type_code = $stdobject->barcode_type_code;
786 $object->barcode_type_coder = $stdobject->barcode_type_coder;
787 $object->barcode_type_label = $stdobject->barcode_type_label;
789 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
790 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
791 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
792 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
793 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
794 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
795 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
796 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
797 $object->accountancy_code_sell =
'';
799 $object->accountancy_code_sell = $accountancy_code_sell;
801 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
802 $object->accountancy_code_sell_intra =
'';
804 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
806 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
807 $object->accountancy_code_sell_export =
'';
809 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
811 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
812 $object->accountancy_code_buy =
'';
814 $object->accountancy_code_buy = $accountancy_code_buy;
816 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
817 $object->accountancy_code_buy_intra =
'';
819 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
821 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
822 $object->accountancy_code_buy_export =
'';
824 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
826 if ($object->isService()) {
827 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
833 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
838 if (!$error && $object->check()) {
839 if ($object->update($object->id, $user) > 0) {
841 $categories =
GETPOST(
'categories',
'array');
842 $object->setCategories($categories);
846 if (count($object->errors)) {
854 if (count($object->errors)) {
857 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
866 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
869 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
876 if ($object->id > 0) {
877 $object->ref =
GETPOST(
'clone_ref',
'alphanohtml');
879 $object->status_buy = 0;
881 $object->barcode = -1;
883 if ($object->check()) {
884 $object->context[
'createfromclone'] =
'createfromclone';
885 $id = $object->create($user);
887 if (
GETPOST(
'clone_composition')) {
888 $result = $object->clone_associations($originalId, $id);
893 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
898 if (
GETPOST(
'clone_categories')) {
899 $result = $object->cloneCategories($originalId, $id);
904 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$originalId);
910 $result = $object->clone_price($originalId, $id);
915 header(
'Location: '.$_SERVER[
'PHP_SELF'].
'?id='.$originalId);
925 header(
"Location: ".$_SERVER[
"PHP_SELF"].
"?id=".$id);
930 if ($object->error ==
'ErrorProductAlreadyExists') {
936 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $object->ref);
937 $mesg .=
' <a href="'.$_SERVER[
"PHP_SELF"].
'?ref='.$object->ref.
'">'.$langs->trans(
"ShowCardHere").
'</a>.';
942 if (count($object->errors)) {
952 unset($object->context[
'createfromclone']);
962 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
965 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
966 $result = $object->delete($user);
969 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.$object->type.
'&delprod='.urlencode($object->ref));
980 if ($object->id > 0 && $action ==
'addin') {
983 $propal =
new Propal($db);
984 $result = $propal->fetch(
GETPOST(
'propalid'));
989 $thirpdartyid = $propal->socid;
990 } elseif (
GETPOST(
'commandeid') > 0) {
992 $result = $commande->fetch(
GETPOST(
'commandeid'));
997 $thirpdartyid = $commande->socid;
998 } elseif (
GETPOST(
'factureid') > 0) {
1000 $result = $facture->fetch(
GETPOST(
'factureid'));
1005 $thirpdartyid = $facture->socid;
1008 if ($thirpdartyid > 0) {
1010 $result = $soc->fetch($thirpdartyid);
1016 $desc = $object->description;
1020 if (empty($tva_tx)) {
1023 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1024 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1026 $pu_ht = $object->price;
1027 $pu_ttc = $object->price_ttc;
1028 $price_base_type = $object->price_base_type;
1031 if ($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) {
1032 $pu_ht = $object->multiprices[$soc->price_level];
1033 $pu_ttc = $object->multiprices_ttc[$soc->price_level];
1034 $price_base_type = $object->multiprices_base_type[$soc->price_level];
1035 } elseif (!empty($conf->global->PRODUIT_CUSTOMER_PRICES)) {
1036 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1040 $filter = array(
't.fk_product' => $object->id,
't.fk_soc' => $soc->id);
1042 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1044 if (count($prodcustprice->lines) > 0) {
1045 $pu_ht =
price($prodcustprice->lines [0]->price);
1046 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1047 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1048 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1053 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1054 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1058 if ($tmpvat != $tmpprodvat) {
1059 if ($price_base_type !=
'HT') {
1060 $pu_ht =
price2num($pu_ttc / (1 + ($tmpvat / 100)),
'MU');
1062 $pu_ttc =
price2num($pu_ht * (1 + ($tmpvat / 100)),
'MU');
1066 if (
GETPOST(
'propalid') > 0) {
1069 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1070 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1073 $buyprice = $result;
1076 $result = $propal->addline(
1101 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1105 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1106 } elseif (
GETPOST(
'commandeid') > 0) {
1109 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1110 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1113 $buyprice = $result;
1116 $result = $commande->addline(
1143 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode($commande->id));
1146 } elseif (
GETPOST(
'factureid') > 0) {
1149 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2), $object->id)) < 0) {
1150 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1153 $buyprice = $result;
1156 $result = $facture->addline(
1188 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1194 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1214 $title = $langs->trans(
'ProductServiceCard');
1217 $shortlabel =
dol_trunc($object->label, 16);
1219 if ($action ==
'create') {
1220 $title = $langs->trans(
"NewProduct");
1222 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1223 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1227 if ($action ==
'create') {
1228 $title = $langs->trans(
"NewService");
1230 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1231 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1239 if (
isModEnabled(
'barcode') && !empty($conf->global->BARCODE_PRODUCT_ADDON_NUM)) {
1240 $module = strtolower($conf->global->BARCODE_PRODUCT_ADDON_NUM);
1241 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
1242 foreach ($dirbarcode as $dirroot) {
1249 $modBarCodeProduct =
new $module();
1253 if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) {
1257 if (empty($object->error) && $id) {
1258 $result = $object->fetch($id);
1263 $objcanvas->assign_values($action, $object->id, $object->ref);
1264 $objcanvas->display_canvas($action);
1269 if ($action ==
'create' && $usercancreate) {
1271 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1273 if (!empty($conf->use_javascript_ajax)) {
1274 print
'<script type="text/javascript">';
1275 print
'$(document).ready(function () {
1276 $("#selectcountry_id").change(function() {
1277 document.formprod.action.value="create";
1278 document.formprod.submit();
1281 print
'</script>'.
"\n";
1285 $module = (!empty($conf->global->PRODUCT_CODEPRODUCT_ADDON) ? $conf->global->PRODUCT_CODEPRODUCT_ADDON :
'mod_codeproduct_leopard');
1286 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1287 $module = substr($module, 0,
dol_strlen($module) - 4);
1291 $modCodeProduct =
new $module();
1296 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1297 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1298 print
'<input type="hidden" name="action" value="add">';
1299 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1300 if (!empty($modCodeProduct->code_auto)) {
1301 print
'<input type="hidden" name="code_auto" value="1">';
1303 if (!empty($modBarCodeProduct->code_auto)) {
1304 print
'<input type="hidden" name="barcode_auto" value="1">';
1306 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1310 $title = $langs->trans(
"NewService");
1313 $title = $langs->trans(
"NewProduct");
1320 if ($object->country_id > 0) {
1321 $tmparray =
getCountry($object->country_id,
'all');
1322 $object->country_code = $tmparray[
'code'];
1323 $object->country = $tmparray[
'label'];
1328 print
'<table class="border centpercent">';
1330 if (empty($conf->global->PRODUCT_GENERATE_REF_AFTER_FORM)) {
1333 if (!empty($modCodeProduct->code_auto)) {
1334 $tmpcode = $modCodeProduct->getNextValue($object, $type);
1336 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).
'">';
1337 if ($refalreadyexists) {
1338 print $langs->trans(
"RefAlreadyExists");
1344 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>';
1347 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1348 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1349 print
$form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1353 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1354 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1355 print
$form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1360 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1361 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1362 print
$form->selectarray(
'status_batch', $statutarray,
GETPOST(
'status_batch'));
1365 $status_batch =
GETPOST(
'status_batch');
1366 if ($status_batch !==
'0') {
1367 $langs->load(
"admin");
1368 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1369 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1370 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1371 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1372 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1373 if ((!empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
1374 || (!empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced')) {
1375 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1378 print
'<td id="field_mask">';
1379 print
$form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1380 print
'<script type="text/javascript">
1381 $(document).ready(function() {
1382 $("#field_mask, #mask_option").addClass("hideobject");
1383 $("#status_batch").on("change", function () {
1384 console.log("We change batch status");
1385 var optionSelected = $("option:selected", this);
1386 var valueSelected = this.value;
1387 $("#field_mask, #mask_option").addClass("hideobject");
1391 if (this.value == 1) {
1392 $("#field_mask, #mask_option").toggleClass("hideobject");
1393 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1397 if ($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced') {
1399 if (this.value == 2) {
1400 $("#field_mask, #mask_option").toggleClass("hideobject");
1401 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1414 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1415 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1420 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1422 $fk_barcode_type =
GETPOST(
'fk_barcode_type')?
GETPOST(
'fk_barcode_type'):0;
1424 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
1430 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1432 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1435 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1437 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1438 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1440 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1445 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1446 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1447 $doleditor->Create();
1450 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
1452 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1453 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1454 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1460 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1461 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1462 print $formproduct->selectWarehouses(
GETPOST(
'fk_default_warehouse',
'int'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1463 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'&action=edit&token='.
newToken()).
'">';
1464 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1469 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1471 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1472 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1477 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1478 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1482 if (empty($conf->global->PRODUCT_DISABLE_STOCK_LEVELS)) {
1483 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1484 print
'<input name="desiredstock" type="hidden" value="0">';
1488 if ($type == 1 && $conf->workstation->enabled) {
1490 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1491 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1492 print $formproduct->selectWorkstations($object->fk_default_workstation,
'fk_default_workstation', 1);
1498 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1499 print
'<input name="duration_value" size="4" value="'.GETPOST(
'duration_value',
'int').
'">';
1500 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value',
'alpha') :
'h'), 0, 1);
1503 print
' ';
1504 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
1505 print
'<label for="mandatoryperiod">';
1506 $htmltooltip = $langs->trans(
"mandatoryHelper");
1507 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1514 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
1516 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1517 print $formproduct->selectProductNature(
'finished', $object->finished);
1523 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
1525 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1526 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1527 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);
1532 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
1533 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1534 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1535 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1536 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1537 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') :
'0', 0, 2);
1540 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
1542 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1543 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1544 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') :
'0', 0, 2);
1547 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
1549 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1550 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1551 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') :
'0', 0, 2);
1555 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
1557 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1558 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1559 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);
1565 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
1566 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1568 print
$form->selectUnits(empty($line->fk_unit) ? $conf->global->PRODUCT_USE_UNITS : $line->fk_unit,
'units');
1573 if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO) && empty($type)) {
1574 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1577 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1579 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
1580 print
$form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') : $object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1582 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1587 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
1589 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)) {
1590 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1592 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1595 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1596 print $formcompany->select_state($object->state_id, $object->country_code);
1602 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
1603 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1604 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1608 $parameters = array(
'colspan' =>
' colspan="2"',
'cols'=>2);
1609 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
1610 print $hookmanager->resPrint;
1611 if (empty($reshook)) {
1612 print $object->showOptionals($extrafields,
'create',
$parameters);
1618 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1621 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1622 $doleditor->Create();
1629 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1630 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
1631 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1639 if (empty($conf->global->PRODUCT_DISABLE_PRICES)) {
1640 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
1643 print
'<table class="border centpercent">';
1645 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1647 print
$form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1654 print
'<table class="border centpercent">';
1657 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1658 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1659 print
$form->selectPriceBaseType($conf->global->PRODUCT_PRICE_BASE_TYPE,
"price_base_type");
1663 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1664 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1668 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1670 print
$form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1680 print
'<!-- accountancy codes -->'.
"\n";
1681 print
'<table class="border centpercent">';
1683 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
1686 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1693 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1697 if ($mysoc->isInEEC()) {
1698 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1701 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1703 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1705 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1710 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1713 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1715 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1717 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1721 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1724 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1726 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1728 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1732 if ($mysoc->isInEEC()) {
1733 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1736 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1738 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1740 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1745 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1748 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1750 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1752 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1755 if (!empty($accountancy_code_sell)) {
1756 $object->accountancy_code_sell = $accountancy_code_sell;
1758 if (!empty($accountancy_code_sell_intra)) {
1759 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1761 if (!empty($accountancy_code_sell_export)) {
1762 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1764 if (!empty($accountancy_code_buy)) {
1765 $object->accountancy_code_buy = $accountancy_code_buy;
1767 if (!empty($accountancy_code_buy_intra)) {
1768 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1770 if (!empty($accountancy_code_buy_export)) {
1771 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1775 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1776 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1780 if ($mysoc->isInEEC()) {
1781 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1782 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1787 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1788 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1792 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1793 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1797 if ($mysoc->isInEEC()) {
1798 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1799 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1804 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1805 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1813 print
$form->buttonsSaveCancel(
"Create");
1816 } elseif ($object->id > 0) {
1822 if ($action ==
'edit' && $usercancreate) {
1824 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1826 if (!empty($conf->use_javascript_ajax)) {
1827 print
'<script type="text/javascript">';
1828 print
'$(document).ready(function () {
1829 $("#selectcountry_id").change(function () {
1830 document.formprod.action.value="edit";
1831 document.formprod.submit();
1834 print
'</script>'.
"\n";
1838 $object->country_id =
GETPOST(
'country_id') ?
GETPOST(
'country_id') : $object->country_id;
1839 if ($object->country_id) {
1840 $tmparray =
getCountry($object->country_id,
'all');
1841 $object->country_code = $tmparray[
'code'];
1842 $object->country = $tmparray[
'label'];
1845 $type = $langs->trans(
'Product');
1846 if ($object->isService()) {
1847 $type = $langs->trans(
'Service');
1852 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.$object->id.
'" method="POST" name="formprod">'.
"\n";
1853 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1854 print
'<input type="hidden" name="action" value="update">';
1855 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1856 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1859 $titre = $langs->trans(
"CardProduct".$object->type);
1864 print
'<table class="border allwidth">';
1867 if (empty($conf->global->MAIN_PRODUCT_REF_NOT_EDITABLE)) {
1868 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag($object->ref).
'"></td></tr>';
1870 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>';
1875 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag($object->label).
'"></td></tr>';
1878 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1879 print
'<select class="flat" name="statut">';
1880 if ($object->status) {
1881 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
1882 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
1884 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
1885 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
1891 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
1892 print
'<select class="flat" name="statut_buy">';
1893 if ($object->status_buy) {
1894 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1895 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1897 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
1898 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
1905 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
1906 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1907 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1908 print
$form->selectarray(
'status_batch', $statutarray, $object->status_batch);
1910 if (!empty($object->status_batch) || !empty($conf->use_javascript_ajax)) {
1911 $langs->load(
"admin");
1912 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1913 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1914 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1915 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1916 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1917 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1919 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'LOT_ADVANCED_MASK');
1922 $mask = !empty($object->batch_mask) ? $object->batch_mask :
getDolGlobalString(
'SN_ADVANCED_MASK');
1926 print
'<td id="field_mask">';
1927 print
$form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
1929 if (!empty($conf->use_javascript_ajax)) {
1930 print
'<script type="text/javascript">
1931 $(document).ready(function() {
1932 $("#field_mask").parent().addClass("hideobject");
1933 var preselect = document.getElementById("status_batch");';
1935 print
'if (preselect.value == "2") {
1936 $("#field_mask").parent().removeClass("hideobject");
1940 print
'if (preselect.value == "1") {
1941 $("#field_mask").parent().removeClass("hideobject");
1944 print
'$("#status_batch").on("change", function () {
1945 var optionSelected = $("option:selected", this);
1946 var valueSelected = this.value;
1947 $("#field_mask").parent().addClass("hideobject");
1951 if (this.value == 1) {
1952 $("#field_mask").parent().removeClass("hideobject");
1953 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1959 if (this.value == 2) {
1960 $("#field_mask").parent().removeClass("hideobject");
1961 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1976 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
1977 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
1982 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1984 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
1986 $fk_barcode_type = $object->barcode_type;
1987 if (empty($fk_barcode_type) && !empty($conf->global->PRODUIT_DEFAULT_BARCODE_TYPE)) {
1988 $fk_barcode_type = $conf->global->PRODUIT_DEFAULT_BARCODE_TYPE;
1991 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1993 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1995 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1997 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1998 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2000 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2005 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2008 $doleditor =
new DolEditor(
'desc',
GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') : $object->description,
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2009 $doleditor->Create();
2015 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
2016 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2017 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2018 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') : $object->url).
'">';
2025 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2026 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2027 print $formproduct->selectWarehouses($object->fk_default_warehouse,
'fk_default_warehouse',
'warehouseopen', 1);
2028 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=create&type='.
GETPOST(
'type',
'int')).
'"><span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2041 if ($object->isService() && $conf->workstation->enabled) {
2043 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2044 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2045 print $formproduct->selectWorkstations($object->fk_default_workstation,
'fk_default_workstation', 1);
2056 if ($object->isService()) {
2058 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2059 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
2060 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", $object->duration_unit, 0, 1);
2063 print
' ';
2064 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2065 print
'<label for="mandatoryperiod">';
2066 $htmltooltip = $langs->trans(
"mandatoryHelper");
2067 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2072 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2074 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2075 print $formproduct->selectProductNature(
'finished', $object->finished);
2081 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2082 $bomkey =
"Bom:bom/class/bom.class.php:0:t.status=1 AND t.fk_product=".((int) $object->id);
2083 print
$form->selectForForms($bomkey,
'fk_default_bom', $object->fk_default_bom, 1);
2087 if (!$object->isService()) {
2088 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2090 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2091 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') : $object->weight).
'"> ';
2092 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') : $object->weight_units, 0, 2);
2096 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2098 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2099 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') : $object->length).
'">x';
2100 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') : $object->width).
'">x';
2101 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') : $object->height).
'"> ';
2102 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') : $object->length_units, 0, 2);
2105 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2107 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2108 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') : $object->surface).
'"> ';
2109 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') : $object->surface_units, 0, 2);
2112 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2114 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2115 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') : $object->volume).
'"> ';
2116 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') : $object->volume_units, 0, 2);
2120 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2122 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2123 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') : $object->net_measure).
'"> ';
2124 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"",
GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') : $object->net_measure_units, 0, 0);
2129 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2130 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2132 print
$form->selectUnits($object->fk_unit,
'units');
2137 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2138 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.$object->customcode.
'"></td></tr>';
2140 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2142 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2143 print
$form->select_country(
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id',
'int') : $object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2145 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2150 if (empty($conf->global->PRODUCT_DISABLE_STATE)) {
2152 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)) {
2153 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2155 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2158 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2159 print $formcompany->select_state(
GETPOSTISSET(
'state_id') ?
GETPOST(
'state_id',
'int') : $object->state_id, $object->country_code);
2166 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2167 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.$object->lifetime.
'"></td></tr>';
2168 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.$object->qc_frequency.
'"></td></tr>';
2172 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2173 $reshook = $hookmanager->executeHooks(
'formObjectOptions',
$parameters, $object, $action);
2174 print $hookmanager->resPrint;
2175 if (empty($reshook)) {
2176 print $object->showOptionals($extrafields,
'edit',
$parameters);
2181 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2182 $cate_arbo =
$form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 1);
2184 $cats = $c->containing($object->id, Categorie::TYPE_PRODUCT);
2185 $arrayselected = array();
2186 if (is_array($cats)) {
2187 foreach ($cats as $cat) {
2188 $arrayselected[] = $cat->id;
2191 print
img_picto(
'',
'category').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2196 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2197 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2199 $doleditor =
new DolEditor(
'note_private', $object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2200 $doleditor->Create();
2209 print
'<table class="border centpercent">';
2211 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2214 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2216 print $formaccounting->select_account($object->accountancy_code_sell,
'accountancy_code_sell', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2220 if ($mysoc->isInEEC()) {
2221 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2223 print $formaccounting->select_account($object->accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2228 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2230 print $formaccounting->select_account($object->accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2234 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2236 print $formaccounting->select_account($object->accountancy_code_buy,
'accountancy_code_buy', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2240 if ($mysoc->isInEEC()) {
2241 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2243 print $formaccounting->select_account($object->accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2248 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2250 print $formaccounting->select_account($object->accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2255 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2256 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.$object->accountancy_code_sell.
'">';
2260 if ($mysoc->isInEEC()) {
2261 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2262 print
'<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.$object->accountancy_code_sell_intra.
'">';
2267 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2268 print
'<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.$object->accountancy_code_sell_export.
'">';
2272 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2273 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.$object->accountancy_code_buy.
'">';
2277 if ($mysoc->isInEEC()) {
2278 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2279 print
'<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="'.$object->accountancy_code_buy_intra.
'">';
2284 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2285 print
'<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.$object->accountancy_code_buy_export.
'">';
2293 print
$form->buttonsSaveCancel();
2299 $showbarcode = empty($conf->barcode->enabled) ? 0 : 1;
2300 if (!empty($conf->global->MAIN_USE_ADVANCED_PERMS) && empty($user->rights->barcode->lire_advance)) {
2305 $titre = $langs->trans(
"CardProduct".$object->type);
2310 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2311 $object->next_prev_filter =
" fk_product_type = ".$object->type;
2314 if ($user->socid && !in_array(
'product', explode(
',', $conf->global->MAIN_MODULES_FOR_EXTERNAL))) {
2321 print
'<div class="fichecenter">';
2322 print
'<div class="fichehalfleft">';
2324 print
'<div class="underbanner clearboth"></div>';
2325 print
'<table class="border tableforfield centpercent">';
2329 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2330 print
'<tr><td class="titlefield">';
2331 print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ?
$form->editfieldkey(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2333 print
$form->editfieldval(
"Type",
'fk_product_type', $object->type, $object, $usercancreate, $typeformat);
2339 print
'<tr><td class="nowrap">';
2340 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2341 print $langs->trans(
"BarcodeType");
2343 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2344 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>';
2346 print
'</tr></table>';
2348 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2349 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2353 $fk_barcode_type =
'';
2354 if ($action ==
'editbarcodetype') {
2355 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.$object->id, $object->barcode_type,
'fk_barcode_type');
2356 $fk_barcode_type = $object->barcode_type;
2358 $object->fetch_barcode();
2359 $fk_barcode_type = $object->barcode_type;
2360 print $object->barcode_type_label ? $object->barcode_type_label : ($object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2362 print
'</td></tr>'.
"\n";
2365 print
'<tr><td class="nowrap">';
2366 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2367 print $langs->trans(
"BarcodeValue");
2369 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2370 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>';
2372 print
'</tr></table>';
2374 if ($action ==
'editbarcode') {
2376 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2377 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2380 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2381 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2382 print
'<input type="hidden" name="action" value="setbarcode">';
2383 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2384 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2385 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2390 print
'</td></tr>'.
"\n";
2395 if ($object->isProduct() || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
2396 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2397 print $object->getLibStatut(0, 2);
2399 if ((($object->status_batch ==
'1' && !empty($conf->global->PRODUCTBATCH_LOT_USE_PRODUCT_MASKS) && $conf->global->PRODUCTBATCH_LOT_ADDON ==
'mod_lot_advanced')
2400 || ($object->status_batch ==
'2' && $conf->global->PRODUCTBATCH_SN_ADDON ==
'mod_sn_advanced' && !empty($conf->global->PRODUCTBATCH_SN_USE_PRODUCT_MASKS)))) {
2401 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2402 print $object->batch_mask;
2408 if (empty($conf->global->PRODUCT_DISABLE_ACCOUNTING)) {
2410 print
'<tr><td class="nowrap">';
2411 print $langs->trans(
"ProductAccountancySellCode");
2414 if (!empty($object->accountancy_code_sell)) {
2416 $accountingaccount->fetch(
'', $object->accountancy_code_sell, 1);
2418 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2421 print $object->accountancy_code_sell;
2426 if ($mysoc->isInEEC()) {
2427 print
'<tr><td class="nowrap">';
2428 print $langs->trans(
"ProductAccountancySellIntraCode");
2431 if (!empty($object->accountancy_code_sell_intra)) {
2433 $accountingaccount2->fetch(
'', $object->accountancy_code_sell_intra, 1);
2435 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2438 print $object->accountancy_code_sell_intra;
2444 print
'<tr><td class="nowrap">';
2445 print $langs->trans(
"ProductAccountancySellExportCode");
2448 if (!empty($object->accountancy_code_sell_export)) {
2450 $accountingaccount3->fetch(
'', $object->accountancy_code_sell_export, 1);
2452 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2455 print $object->accountancy_code_sell_export;
2460 print
'<tr><td class="nowrap">';
2461 print $langs->trans(
"ProductAccountancyBuyCode");
2464 if (!empty($object->accountancy_code_buy)) {
2466 $accountingaccount4->fetch(
'', $object->accountancy_code_buy, 1);
2468 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2471 print $object->accountancy_code_buy;
2476 if ($mysoc->isInEEC()) {
2477 print
'<tr><td class="nowrap">';
2478 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2481 if (!empty($object->accountancy_code_buy_intra)) {
2483 $accountingaccount5->fetch(
'', $object->accountancy_code_buy_intra, 1);
2485 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2488 print $object->accountancy_code_buy_intra;
2494 print
'<tr><td class="nowrap">';
2495 print $langs->trans(
"ProductAccountancyBuyExportCode");
2498 if (!empty($object->accountancy_code_buy_export)) {
2500 $accountingaccount6->fetch(
'', $object->accountancy_code_buy_export, 1);
2502 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2505 print $object->accountancy_code_buy_export;
2511 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>'.(
dol_textishtml($object->description) ? $object->description :
dol_nl2br($object->description, 1,
true)).
'</td></tr>';
2514 if (empty($conf->global->PRODUCT_DISABLE_PUBLIC_URL)) {
2515 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2523 $warehouse->fetch($object->fk_default_warehouse);
2525 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2526 print (!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2530 if ($object->isService() &&
isModEnabled(
'workstation')) {
2532 $res = $workstation->fetch($object->fk_default_workstation);
2534 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2535 print (!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2540 if (
isModEnabled(
'variants') && ($object->isProduct() || $object->isService())) {
2543 if ($combination->fetchByFkProductChild($object->id) > 0) {
2544 $prodstatic =
new Product($db);
2545 $prodstatic->fetch($combination->fk_product_parent);
2548 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2549 print $prodstatic->getNomUrl(1);
2556 print
'<div class="fichehalfright">';
2558 print
'<div class="underbanner clearboth"></div>';
2559 print
'<table class="border tableforfield centpercent">';
2561 if ($object->isService()) {
2563 print
'<tr><td class="titlefield">'.$langs->trans(
"Duration").
'</td><td>';
2564 print $object->duration_value;
2565 if ($object->duration_value > 1) {
2566 $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"));
2567 } elseif ($object->duration_value > 0) {
2568 $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"));
2570 print (!empty($object->duration_unit) && isset($dur[$object->duration_unit]) ?
" ".$langs->trans($dur[$object->duration_unit]).
" " :
'');
2573 if ($object->duration_value > 0) {
2574 print
' ';
2576 $htmltooltip = $langs->trans(
"mandatoryHelper");
2577 print
'<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2578 print
$form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2582 if (empty($conf->global->PRODUCT_DISABLE_NATURE)) {
2584 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2585 print $object->getLibFinished();
2590 if (!$object->isService() &&
isModEnabled(
'bom') && $object->finished) {
2591 print
'<tr><td class="titlefield">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2592 if ($object->fk_default_bom) {
2593 $bom_static =
new BOM($db);
2594 $bom_static->fetch($object->fk_default_bom);
2595 print $bom_static->getNomUrl(1);
2600 if (!$object->isService()) {
2602 if (empty($conf->global->PRODUCT_DISABLE_WEIGHT)) {
2603 print
'<tr><td class="titlefield">'.$langs->trans(
"Weight").
'</td><td>';
2604 if ($object->weight !=
'') {
2609 print
"</td></tr>\n";
2612 if (empty($conf->global->PRODUCT_DISABLE_SIZE)) {
2614 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2615 if ($object->length !=
'' || $object->width !=
'' || $object->height !=
'') {
2616 print $object->length;
2617 if ($object->width) {
2618 print
" x ".$object->width;
2620 if ($object->height) {
2621 print
" x ".$object->height;
2623 print
' '.measuringUnitString(0,
"size", $object->length_units);
2627 print
"</td></tr>\n";
2629 if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) {
2631 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2632 if ($object->surface !=
'') {
2637 print
"</td></tr>\n";
2639 if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) {
2641 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2642 if ($object->volume !=
'') {
2647 print
"</td></tr>\n";
2650 if (!empty($conf->global->PRODUCT_ADD_NET_MEASURE)) {
2652 print
'<tr><td class="titlefield">'.$langs->trans(
"NetMeasure").
'</td><td>';
2653 if ($object->net_measure !=
'') {
2663 if (!empty($conf->global->PRODUCT_USE_UNITS)) {
2664 $unit = $object->getLabelOfUnit();
2666 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2668 print $langs->trans($unit);
2674 if (!$object->isService() && empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) {
2675 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.$object->customcode.
'</td></tr>';
2678 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry($object->country_id, 0, $db);
2679 if (!empty($object->state_id)) {
2680 print
' - '.getState($object->state_id, 0, $db);
2686 if (!empty($conf->global->PRODUCT_LOT_ENABLE_QUALITY_CONTROL)) {
2687 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.$object->lifetime.
'</td></tr>';
2688 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.$object->qc_frequency.
'</td></tr>';
2693 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2697 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2698 print
$form->showCategories($object->id, Categorie::TYPE_PRODUCT, 1);
2703 if (!empty($conf->global->MAIN_DISABLE_NOTES_TAB)) {
2704 print
'<!-- show Note --> '.
"\n";
2705 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";
2706 print
'<!-- End show Note --> '.
"\n";
2713 print
'<div style="clear:both"></div>';
2717 } elseif ($action !=
'create') {
2723 if (!empty($modCodeProduct->code_auto)) {
2724 $tmpcode = $modCodeProduct->getNextValue($object, $object->type);
2730 if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2731 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2732 $formconfirm =
$form->formconfirm(
"card.php?id=".$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2734 if ($action ==
'merge') {
2735 $formquestion = array(
2737 'name' =>
'product_origin',
2738 'label' => $langs->trans(
'MergeOriginProduct'),
2740 'value' =>
$form->select_produits(
'',
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2743 $formconfirm =
$form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
2747 if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2748 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2750 $formquestionclone = array(
2751 'text' => $langs->trans(
"ConfirmClone"),
2752 array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.$object->ref : $tmpcode,
'morecss'=>
'width150'),
2753 array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2754 array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2756 if (!empty($conf->global->PRODUIT_MULTIPRICES)) {
2757 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2759 if (!empty($conf->global->PRODUIT_SOUSPRODUITS)) {
2760 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2763 $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);
2768 $reshook = $hookmanager->executeHooks(
'formConfirm',
$parameters, $object, $action);
2769 if (empty($reshook)) {
2771 } elseif ($reshook > 0) {
2781 if ($action !=
'create' && $action !=
'edit') {
2782 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
2783 $cloneButtonId =
'action-clone-no-ajax';
2785 print
"\n".
'<div class="tabsAction">'.
"\n";
2788 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons',
$parameters, $object, $action);
2789 if (empty($reshook)) {
2790 if ($usercancreate) {
2791 if (!isset($object->no_button_edit) || $object->no_button_edit <> 1) {
2792 print
dolGetButtonAction(
'', $langs->trans(
'Modify'),
'default', $_SERVER[
"PHP_SELF"].
'?action=edit&token='.
newToken().
'&id='.$object->id,
'', $usercancreate);
2795 if (!isset($object->no_button_copy) || $object->no_button_copy <> 1) {
2796 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2797 $cloneProductUrl =
'';
2798 $cloneButtonId =
'action-clone';
2800 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
2803 $object_is_used = $object->isObjectUsed($object->id);
2805 if ($usercandelete) {
2806 if (empty($object_is_used) && (!isset($object->no_button_delete) || $object->no_button_delete <> 1)) {
2807 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2808 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
2810 print
dolGetButtonAction(
'', $langs->trans(
'Delete'),
'delete', $_SERVER[
"PHP_SELF"].
'?action=delete&token='.
newToken().
'&id='.$object->id,
'');
2813 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2816 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
2819 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
2831 if (!empty($conf->global->PRODUCT_ADD_FORM_ADD_TO) && $object->id && ($action ==
'' || $action ==
'view') && $object->status) {
2837 if (
isModEnabled(
"propal") && $user->rights->propal->creer) {
2838 $propal =
new Propal($db);
2840 $langs->load(
"propal");
2842 $otherprop = $propal->liste_array(2, 1, 0);
2844 if (is_array($otherprop) && count($otherprop)) {
2845 $html .=
'<tr><td style="width: 200px;">';
2846 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2847 $html .=
$form->selectarray(
"propalid", $otherprop, 0, 1);
2848 $html .=
'</td></tr>';
2850 $html .=
'<tr><td style="width: 200px;">';
2851 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
2852 $html .= $langs->trans(
"NoDraftProposals");
2853 $html .=
'</td></tr>';
2858 if (
isModEnabled(
'commande') && $user->rights->commande->creer) {
2861 $langs->load(
"orders");
2863 $othercom = $commande->liste_array(2, 1,
null);
2864 if (is_array($othercom) && count($othercom)) {
2865 $html .=
'<tr><td style="width: 200px;">';
2866 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2867 $html .=
$form->selectarray(
"commandeid", $othercom, 0, 1);
2868 $html .=
'</td></tr>';
2870 $html .=
'<tr><td style="width: 200px;">';
2871 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
2872 $html .= $langs->trans(
"NoDraftOrders");
2873 $html .=
'</td></tr>';
2878 if (
isModEnabled(
'facture') && $user->rights->facture->creer) {
2881 $langs->load(
"bills");
2883 $otherinvoice = $invoice->liste_array(2, 1,
null);
2884 if (is_array($otherinvoice) && count($otherinvoice)) {
2885 $html .=
'<tr><td style="width: 200px;">';
2886 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2887 $html .=
$form->selectarray(
"factureid", $otherinvoice, 0, 1);
2888 $html .=
'</td></tr>';
2890 $html .=
'<tr><td style="width: 200px;">';
2891 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
2892 $html .= $langs->trans(
"NoDraftInvoices");
2893 $html .=
'</td></tr>';
2898 if (!empty($html)) {
2899 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.$object->id.
'">';
2900 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2901 print
'<input type="hidden" name="action" value="addin">';
2907 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
2908 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
2909 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
2910 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
2911 $html .=
'</td></tr>';
2913 print
'<table width="100%" class="border">';
2917 print
'<div class="center">';
2918 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
2932 if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
2933 print
'<div class="fichecenter"><div class="fichehalfleft">';
2934 print
'<a name="builddoc"></a>';
2938 if (!empty($conf->product->multidir_output[$object->entity])) {
2939 $filedir = $conf->product->multidir_output[$object->entity].
'/'.$objectref;
2941 $filedir = $conf->product->dir_output.
'/'.$objectref;
2943 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".$object->id;
2944 $genallowed = $usercanread;
2945 $delallowed = $usercancreate;
2947 print $formfile->showdocuments($modulepart, $object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'', $object);
2948 $somethingshown = $formfile->numoffiles;
2950 print
'</div><div class="fichehalfright">';
2954 $morehtmlcenter =
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.$object->id);
2957 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
2959 $somethingshown =
$formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
2961 print
'</div></div>';
if(GETPOST('button_removefilter_x', 'alpha')||GETPOST('button_removefilter.x', 'alpha')||GETPOST('button_removefilter', 'alpha')) if(GETPOST('button_search_x', 'alpha')||GETPOST('button_search.x', 'alpha')||GETPOST('button_search', 'alpha')) if($action=="save" &&empty($cancel)) $help_url
View.
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.
if(isModEnabled('facture') &&!empty($user->rights->facture->lire)) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') &&!empty($user->rights->don->lire)) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $resql
Social contributions to pay.
if($cancel &&! $id) if($action=='add' &&! $cancel) if($action=='delete') if($id) $form
Actions.
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.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='')
Show tabs of a record.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
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.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
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.
if(!function_exists('dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
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)
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
dol_print_url($url, $target='_blank', $max=32, $withpicto=0)
Show Url link.
newToken()
Return the value of token currently saved into session with name 'newtoken'.
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)
Fonction qui renvoie si tva doit etre tva percue recuperable.
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.
get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller="", $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
if(!function_exists('utf8_encode')) if(!function_exists('utf8_decode')) getDolGlobalString($key, $default='')
Return dolibarr global constant string value.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
isModEnabled($module)
Is Dolibarr module enabled.
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.
$formconfirm
if ($action == 'delbookkeepingyear') {
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.