47require
'../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
69if (isModEnabled(
'propal')) {
70 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
72if (isModEnabled(
'invoice')) {
73 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
75if (isModEnabled(
'order')) {
76 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
78if (isModEnabled(
'accounting')) {
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
80 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
81 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
83if (isModEnabled(
'bom')) {
84 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
87if (isModEnabled(
'workstation')) {
88 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
92$langs->loadLangs(array(
'products',
'other'));
93if (isModEnabled(
'stock')) {
94 $langs->load(
"stocks");
96if (isModEnabled(
'invoice')) {
97 $langs->load(
"bills");
99if (isModEnabled(
'productbatch')) {
100 $langs->load(
"productbatch");
107$refalreadyexists = 0;
113 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'nohtml') : null);
115 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alpha') : null);
118$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
119$cancel =
GETPOST(
'cancel',
'alpha');
120$backtopage =
GETPOST(
'backtopage',
'alpha');
121$confirm =
GETPOST(
'confirm',
'alpha');
123$duration_value =
GETPOST(
'duration_value');
124$duration_unit =
GETPOST(
'duration_unit',
'alpha');
126$accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
127$accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
128$accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
129$accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
130$accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
131$accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
133$checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
137 $label_security_check =
'nohtml';
139 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
142if (!empty($user->socid)) {
143 $socid = $user->socid;
148if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
149 $module = substr($module, 0,
dol_strlen($module) - 4);
153 $modCodeProduct =
new $module();
161$extrafields->fetch_name_optionals_label(
$object->table_element);
163if ($id > 0 || !empty($ref)) {
164 $result =
$object->fetch($id, $ref);
169 if (isModEnabled(
"product")) {
170 $upload_dir =
$conf->product->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
171 } elseif (isModEnabled(
"service")) {
172 $upload_dir =
$conf->service->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
176 if (isModEnabled(
"product")) {
177 $upload_dirold =
$conf->product->multidir_output[$entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
179 $upload_dirold =
$conf->service->multidir_output[$entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
184$modulepart =
'product';
189if (!empty($canvas)) {
190 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
191 $objcanvas =
new Canvas($db, $action);
192 $objcanvas->getCanvas(
'product',
'card', $canvas);
196$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
197$fieldtype = (!empty($id) ?
'rowid' :
'ref');
200$hookmanager->initHooks(array(
'productcard',
'globalcard'));
203 if (
$object->type == $object::TYPE_PRODUCT) {
206 if (
$object->type == $object::TYPE_SERVICE) {
210 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
227$createbarcode = isModEnabled(
'barcode');
228if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'creer_advance')) {
232$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
233$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
238if (empty($reshook)) {
239 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
241 if (empty($backtopage) || ($cancel && empty($id))) {
242 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
243 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
244 $backtopage = $backurlforlist;
246 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
252 if (!empty($backtopageforcancel)) {
253 header(
"Location: ".$backtopageforcancel);
255 } elseif (!empty($backtopage)) {
256 header(
"Location: ".$backtopage);
262 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
264 $productOriginId =
GETPOSTINT(
'product_origin');
265 $productOrigin =
new Product($db);
267 if ($productOriginId <= 0) {
268 $langs->load(
'errors');
269 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
271 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
281 $listofproperties = array(
291 'accountancy_code_buy',
292 'accountancy_code_buy_intra',
293 'accountancy_code_buy_export',
294 'accountancy_code_sell',
295 'accountancy_code_sell_intra',
296 'accountancy_code_sell_export'
298 foreach ($listofproperties as $property) {
299 if (empty(
$object->$property)) {
300 $object->$property = $productOrigin->$property;
304 $listofproperties = array(
305 'note_public',
'note_private'
307 foreach ($listofproperties as $property) {
312 if (is_array($productOrigin->array_options)) {
313 foreach ($productOrigin->array_options as $key => $val) {
314 if (empty(
$object->array_options[$key])) {
315 $object->array_options[$key] = $val;
322 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
323 $custcats = $static_cat->containing(
$object->id,
'product',
'id');
324 $custcats = array_merge($custcats, $custcats_ori);
325 $object->setCategories($custcats);
328 if ($productOrigin->barcode ==
$object->barcode) {
329 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
330 $productOrigin->barcode =
'';
346 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
347 'Bom' =>
'/bom/class/bom.class.php',
350 'Commande' =>
'/commande/class/commande.class.php',
351 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
352 'Contrat' =>
'/contrat/class/contrat.class.php',
353 'Delivery' =>
'/delivery/class/delivery.class.php',
354 'Facture' =>
'/compta/facture/class/facture.class.php',
355 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
356 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
357 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
358 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
359 'Propal' =>
'/comm/propal/class/propal.class.php',
360 'Reception' =>
'/reception/class/reception.class.php',
361 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
365 foreach ($objects as $object_name => $object_file) {
366 require_once DOL_DOCUMENT_ROOT.$object_file;
368 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id,
$object->id)) {
378 $parameters = array(
'soc_origin' => $productOrigin->id,
'soc_dest' =>
$object->id);
379 $reshook = $hookmanager->executeHooks(
396 'mergefromid' => $productOrigin->id,
400 $result =
$object->call_trigger(
'PRODUCT_MODIFY', $user);
410 if ($productOrigin->delete($user) < 1) {
417 if (!empty(
$conf->product->multidir_output[$productOrigin->entity])) {
418 $srcdir =
$conf->product->multidir_output[$productOrigin->entity].
"/".$productOrigin->ref;
423 foreach ($dirlist as $filetomove) {
424 $destfile = $destdir.
'/'.$filetomove[
'relativename'];
426 dol_move($filetomove[
'fullname'], $destfile,
'0', 0, 0, 1);
437 $langs->load(
"errors");
446 if ($action ==
'setfk_product_type' && $usercancreate) {
447 $result =
$object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
448 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
453 $upload_dir =
$conf->product->dir_output;
454 $permissiontoadd = $usercancreate;
455 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
457 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
460 if ($action ==
'setfk_barcode_type' && $usercancreate) {
461 $result =
$object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
462 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
467 if ($action ==
'setbarcode' && $usercancreate) {
471 $result =
$object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
472 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
475 $langs->load(
"errors");
477 $errors[] =
'ErrorBadBarCodeSyntax';
478 } elseif ($result == -2) {
479 $errors[] =
'ErrorBarCodeRequired';
480 } elseif ($result == -3) {
481 $errors[] =
'ErrorBarCodeAlreadyUsed';
483 $errors[] =
'FailedToValidateBarCode';
492 if ($action ==
'update_extras' && $usercancreate) {
496 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
503 $result =
$object->insertExtraFields(
'PRODUCT_MODIFY');
511 $action =
'edit_extras';
516 if ($action ==
'add' && $usercancreate) {
519 if (!
GETPOST(
'label', $label_security_check)) {
520 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
526 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'ProductRef')),
null,
'errors');
531 if (!empty($duration_value) && empty($duration_unit)) {
532 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
544 $object->mandatory_period = empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 0 : 1;
545 if (
$object->price_base_type ==
'TTC') {
550 if (
$object->price_base_type ==
'TTC') {
556 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
560 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
561 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
564 $localtax1_type =
'0';
565 $localtax2_type =
'0';
568 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
570 $vatratecode = $reg[1];
572 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
573 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
574 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
575 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
576 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
577 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
578 $resql = $db->query($sql);
580 $obj = $db->fetch_object($resql);
581 $npr = $obj->recuperableonly;
582 $localtax1 = $obj->localtax1;
583 $localtax2 = $obj->localtax2;
584 $localtax1_type = $obj->localtax1_type;
585 $localtax2_type = $obj->localtax2_type;
589 $object->default_vat_code = $vatratecode;
592 $object->localtax1_tx = $localtax1;
593 $object->localtax2_tx = $localtax2;
594 $object->localtax1_type = $localtax1_type;
595 $object->localtax2_type = $localtax2_type;
608 $stdobject->element =
'product';
609 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
610 $result = $stdobject->fetchBarCode();
613 $mesg =
'Failed to get bar code type information ';
616 $object->barcode_type_code = $stdobject->barcode_type_code;
617 $object->barcode_type_coder = $stdobject->barcode_type_coder;
618 $object->barcode_type_label = $stdobject->barcode_type_label;
629 $object->duration_value = $duration_value;
630 $object->duration_unit = $duration_unit;
649 if ($finished >= 0) {
662 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
663 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
664 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
665 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
666 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
667 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
669 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
670 $object->accountancy_code_sell =
'';
672 $object->accountancy_code_sell = $accountancy_code_sell;
674 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
675 $object->accountancy_code_sell_intra =
'';
677 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
679 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
680 $object->accountancy_code_sell_export =
'';
682 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
684 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
685 $object->accountancy_code_buy =
'';
687 $object->accountancy_code_buy = $accountancy_code_buy;
689 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
690 $object->accountancy_code_buy_intra =
'';
692 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
694 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
695 $object->accountancy_code_buy_export =
'';
697 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
703 for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
704 if (GETPOSTISSET(
"price_".$i)) {
706 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
708 $object->multiprices[
"$i"] =
"";
714 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
721 '@phan-var ModeleProductCode $modCodeProduct';
722 $ref = $modCodeProduct->getNextValue(
$object, $type);
731 $categories =
GETPOST(
'categories',
'array');
732 $object->setCategories($categories);
734 if (!empty($backtopage)) {
735 $backtopage = preg_replace(
'/__ID__/', (
string)
$object->id, $backtopage);
736 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
737 if (preg_match(
'/\?/', $backtopage)) {
738 $backtopage .=
'&productid='.$object->id;
741 header(
"Location: ".$backtopage);
744 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
751 if (
$object->error ==
'ErrorProductAlreadyExists') {
753 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters,
$object, $action);
772 if ($action ==
'update' && $usercancreate) {
773 if (
GETPOST(
'cancel',
'alpha')) {
829 if ($finished >= 0) {
835 $fk_default_bom =
GETPOSTINT(
'fk_default_bom');
836 if ($fk_default_bom >= 0) {
837 $object->fk_default_bom = $fk_default_bom;
853 $stdobject->element =
'product';
854 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
855 $result = $stdobject->fetchBarCode();
858 $mesg =
'Failed to get bar code type information ';
861 $object->barcode_type_code = $stdobject->barcode_type_code;
862 $object->barcode_type_coder = $stdobject->barcode_type_coder;
863 $object->barcode_type_label = $stdobject->barcode_type_label;
865 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
866 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
867 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
868 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
869 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
870 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
871 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
872 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
873 $object->accountancy_code_sell =
'';
875 $object->accountancy_code_sell = $accountancy_code_sell;
877 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
878 $object->accountancy_code_sell_intra =
'';
880 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
882 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
883 $object->accountancy_code_sell_export =
'';
885 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
887 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
888 $object->accountancy_code_buy =
'';
890 $object->accountancy_code_buy = $accountancy_code_buy;
892 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
893 $object->accountancy_code_buy_intra =
'';
895 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
897 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
898 $object->accountancy_code_buy_export =
'';
900 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
903 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
909 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
914 if (!$error &&
$object->check()) {
917 $categories =
GETPOST(
'categories',
'array');
918 $object->setCategories($categories);
933 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
942 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
945 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
956 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
958 $clone->status_buy = 0;
959 $clone->barcode = -1;
961 if ($clone->check()) {
964 $clone->context[
'createfromclone'] =
'createfromclone';
965 $id = $clone->create($user);
967 if (
GETPOST(
'clone_composition')) {
968 $result = $clone->clone_associations(
$object->id, $id);
976 if (!$error &&
GETPOST(
'clone_categories')) {
977 $result = $clone->cloneCategories(
$object->id, $id);
985 if (!$error &&
GETPOST(
'clone_prices')) {
986 $result = $clone->clone_price(
$object->id, $id);
994 if (!$error && isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
997 $bomstatic =
new BOM($db);
998 $bomclone = $bomstatic->createFromClone($user,
$object->fk_default_bom);
999 if ((
int) $bomclone < 0) {
1000 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1002 $defbomidac =
$object->fk_default_bom;
1003 $clone->fk_default_bom = $bomclone->id;
1004 $clone->update($id, $user);
1005 $bomclone->fk_product =
$id;
1006 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1007 $bomclone->update($user);
1008 $bomclone->validate($user);
1011 if (
GETPOST(
'clone_otherboms')) {
1012 $bomstatic =
new BOM($db);
1013 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
1014 if (is_array($bomlist)) {
1015 foreach ($bomlist as $bom2clone) {
1016 if ($bom2clone->id != $defbomidac) {
1017 $bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
1018 if ((
int) $bomclone < 0) {
1019 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1021 $bomclone->fk_product =
$id;
1022 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1023 $bomclone->update($user);
1024 $bomclone->validate($user);
1033 if ($clone->error ==
'ErrorProductAlreadyExists') {
1034 $refalreadyexists++;
1037 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
1038 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
1041 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
1046 unset($clone->context[
'createfromclone']);
1053 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
1057 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
1067 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
1070 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
1071 $result =
$object->delete($user);
1074 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.
$object->type.
'&delprod='.urlencode(
$object->ref));
1085 if (
$object->id > 0 && $action ==
'addin') {
1087 $permissiontoaddline =
false;
1093 if (
GETPOST(
'propalid') > 0) {
1094 $propal =
new Propal($db);
1095 $result = $propal->fetch(
GETPOST(
'propalid'));
1100 $thirdpartyid = $propal->socid;
1101 $permissiontoaddline = $user->hasRight(
'propal',
'creer');
1102 } elseif (
GETPOST(
'commandeid') > 0) {
1104 $result = $commande->fetch(
GETPOST(
'commandeid'));
1109 $thirdpartyid = $commande->socid;
1110 $permissiontoaddline = $user->hasRight(
'commande',
'creer');
1111 } elseif (
GETPOST(
'factureid') > 0) {
1113 $result = $facture->fetch(
GETPOST(
'factureid'));
1118 $thirdpartyid = $facture->socid;
1119 $permissiontoaddline = $user->hasRight(
'facture',
'creer');
1122 if ($thirdpartyid > 0) {
1124 $result = $soc->fetch($thirdpartyid);
1134 if (empty($tva_tx)) {
1137 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1138 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1142 $price_base_type =
$object->price_base_type;
1146 $pu_ht =
$object->multiprices[$soc->price_level];
1147 $pu_ttc =
$object->multiprices_ttc[$soc->price_level];
1148 $price_base_type =
$object->multiprices_base_type[$soc->price_level];
1150 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1154 $filter = array(
't.fk_product' =>
$object->id,
't.fk_soc' => $soc->id);
1156 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1158 if (count($prodcustprice->lines) > 0) {
1159 $pu_ht =
price($prodcustprice->lines [0]->price);
1160 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1161 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1162 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1167 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1168 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1172 if ($tmpvat != $tmpprodvat) {
1173 if ($price_base_type !=
'HT') {
1174 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1176 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1180 if (
GETPOST(
'propalid') > 0 && $permissiontoaddline && is_object($propal)) {
1183 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1184 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1187 $buyprice = $result;
1190 $result = $propal->addline(
1215 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1219 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1220 } elseif (
GETPOST(
'commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
1223 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1224 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1227 $buyprice = $result;
1230 $result = $commande->addline(
1257 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode((
string) ($commande->id)));
1261 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1262 } elseif (
GETPOST(
'factureid') > 0 && $permissiontoaddline && is_object($facture)) {
1265 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1266 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1269 $buyprice = $result;
1272 $result = $facture->addline(
1304 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1308 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1312 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1323$form =
new Form($db);
1327if (isModEnabled(
'accounting')) {
1330$sellOrEatByMandatoryList =
null;
1331if (isModEnabled(
'productbatch')) {
1337 if ($disableSellBy) {
1338 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY]);
1339 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1341 if ($disableEatBy) {
1342 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY]);
1343 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1347$title = $langs->trans(
'ProductServiceCard');
1352 if ($action ==
'create') {
1353 $title = $langs->trans(
"NewProduct");
1355 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1356 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1360 if ($action ==
'create') {
1361 $title = $langs->trans(
"NewService");
1363 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1364 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1368llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-card');
1372$modBarCodeProduct =
null;
1375 $dirbarcode = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
1376 foreach ($dirbarcode as $dirroot) {
1383 $modBarCodeProduct =
new $module();
1384 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
1388$canvasdisplayaction = $action;
1389if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
1390 $canvasdisplayaction =
'view';
1393if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
1397 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
1398 $objcanvas->display_canvas($canvasdisplayaction);
1403 if ($action ==
'create' && $usercancreate) {
1405 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1407 if (!empty(
$conf->use_javascript_ajax)) {
1408 print
'<script type="text/javascript">';
1409 print
'$(document).ready(function () {
1410 $("#selectcountry_id").change(function() {
1411 console.log("selectcountry_id change");
1412 document.formprod.action.value="create";
1413 document.formprod.submit();
1416 print
'</script>'.
"\n";
1420 $module =
getDolGlobalString(
'PRODUCT_CODEPRODUCT_ADDON',
'mod_codeproduct_leopard');
1421 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1422 $module = substr($module, 0,
dol_strlen($module) - 4);
1426 $modCodeProduct =
new $module();
1431 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1432 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1433 print
'<input type="hidden" name="action" value="add">';
1434 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1435 if (!empty($modCodeProduct->code_auto)) {
1436 print
'<input type="hidden" name="code_auto" value="1">';
1438 if (!empty($modBarCodeProduct->code_auto)) {
1439 print
'<input type="hidden" name="barcode_auto" value="1">';
1441 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1445 $title = $langs->trans(
"NewService");
1448 $title = $langs->trans(
"NewProduct");
1454 $object->country_id = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : null;
1455 if (
$object->country_id > 0) {
1457 $object->country_code = $tmparray[
'code'];
1458 $object->country = $tmparray[
'label'];
1464 $parameters = array();
1466 $reshook = $hookmanager->executeHooks(
'tabContentCreateProduct', $parameters,
$object, $action);
1467 if (empty($reshook)) {
1468 print
'<table class="border centpercent">';
1473 if (!empty($modCodeProduct->code_auto)) {
1474 $tmpcode = $modCodeProduct->getNextValue(
$object, $type);
1476 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ProductRef").
'</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1477 if ($refalreadyexists) {
1478 print $langs->trans(
"RefAlreadyExists");
1484 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td><input id="label" name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag(
GETPOST(
'label', $label_security_check)).
'"></td></tr>';
1487 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1488 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1489 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1493 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1494 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1495 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1499 if (isModEnabled(
'productbatch')) {
1500 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1501 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1502 print $form->selectarray(
'status_batch', $statutarray,
GETPOSTINT(
'status_batch'));
1506 if ($status_batch !==
'0') {
1507 $langs->load(
"admin");
1508 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1509 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1510 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1511 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1512 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1517 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1520 print
'<td id="field_mask">';
1521 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1522 print
'<script type="text/javascript">
1523 $(document).ready(function() {
1524 $("#field_mask, #mask_option").addClass("hideobject");
1525 $("#status_batch").on("change", function () {
1526 console.log("We change batch status");
1527 var optionSelected = $("option:selected", this);
1528 var valueSelected = this.value;
1529 $("#field_mask, #mask_option").addClass("hideobject");
1533 if (this.value == 1) {
1534 $("#field_mask, #mask_option").toggleClass("hideobject");
1535 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1541 if (this.value == 2) {
1542 $("#field_mask, #mask_option").toggleClass("hideobject");
1543 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1556 if (!empty($sellOrEatByMandatoryList)) {
1557 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
1558 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList,
GETPOSTINT(
'sell_or_eat_by_mandatory'));
1563 $showbarcode = isModEnabled(
'barcode');
1564 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
1568 if ($showbarcode && is_object($modBarCodeProduct)) {
1569 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1570 if (GETPOSTISSET(
'fk_barcode_type')) {
1571 $fk_barcode_type =
GETPOST(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type') : 0;
1576 $fk_barcode_type = 0;
1579 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1581 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1584 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1585 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
1586 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1587 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
1589 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1590 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1595 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1596 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1597 $doleditor->Create();
1602 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1603 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1604 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1608 if (($type != 1 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
1610 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1611 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1612 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1613 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOSTINT(
'type')).
'">';
1614 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1622 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1623 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1628 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1629 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1634 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1635 print
'<input name="desiredstock" type="hidden" value="0">';
1639 if ($type == $object::TYPE_SERVICE && isModEnabled(
"workstation")) {
1641 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1642 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1643 print $formproduct->selectWorkstations((GETPOSTISSET(
'fk_default_workstation') ?
GETPOSTINT(
'fk_default_workstation') :
''),
'fk_default_workstation', 1);
1649 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1650 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1651 print
'<input name="duration_value" class="width50" value="'.(GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value') :
'').
'">';
1652 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (GETPOSTISSET(
'duration_unit') ?
GETPOST(
'duration_unit',
'alpha') :
'h'), 0, 1);
1655 if (
$object->duration_value > 0) {
1656 print
' ';
1658 print
'<input type="checkbox" class="marginleftonly valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.(GETPOSTISSET(
'mandatoryperiod') ?
' checked="checked"' :
'').
'>';
1659 print
'<label for="mandatoryperiod">';
1660 $htmltooltip = $langs->trans(
"mandatoryHelper");
1662 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
1664 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1673 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1674 print $formproduct->selectProductNature(
'finished',
$object->finished);
1682 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1683 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1684 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1685 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units',
'alpha') : (
GETPOST(
'weight_units',
'alpha') ?:
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT', 0)), 0, 2);
1691 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1692 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1693 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1694 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1695 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1696 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') : (
GETPOST(
'size_units',
'alpha') ?:
'0'), 0, 2);
1701 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1702 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1703 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') : (
GETPOST(
'surface_units',
'alpha') ?:
'0'), 0, 2);
1708 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1709 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1710 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') : (
GETPOST(
'volume_units',
'alpha') ?:
'0'), 0, 2);
1716 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1717 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1718 print $formproduct->selectMeasuringUnits(
"net_measure_units",
'', GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units',
'alpha') : (
GETPOST(
'net_measure_units',
'alpha') ?:
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT', 0)), 0, 0);
1725 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1727 print $form->selectUnits(GETPOSTISSET(
'units') ?
GETPOST(
'units',
'alpha') : (
GETPOST(
'units',
'alpha') ?:
'0'),
'units');
1733 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1736 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1738 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1739 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1741 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1749 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1751 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1754 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1755 print $formcompany->select_state(
$object->state_id,
$object->country_code);
1762 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1763 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1767 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
1768 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1769 print $hookmanager->resPrint;
1770 if (empty($reshook)) {
1771 print
$object->showOptionals($extrafields,
'create', $parameters);
1775 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1778 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1779 $doleditor->Create();
1783 if (isModEnabled(
'category')) {
1785 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1786 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
1787 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'), 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1799 print
'<table class="border centpercent">';
1801 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1803 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1811 print
'<table class="border centpercent">';
1814 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1815 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1816 print $form->selectPriceBaseType(
getDolGlobalString(
'PRODUCT_PRICE_BASE_TYPE'),
"price_base_type");
1821 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1822 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1826 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1828 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1839 print
'<!-- accountancy codes -->'.
"\n";
1840 print
'<table class="border centpercent">';
1843 if (isModEnabled(
'accounting')) {
1846 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1849 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_ACCOUNT"));
1851 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
1853 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1857 if ($mysoc->isInEEC()) {
1858 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1861 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1863 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1865 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1870 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1873 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1875 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1877 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1881 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1884 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1886 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1888 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1892 if ($mysoc->isInEEC()) {
1893 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1896 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1898 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1900 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1905 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1908 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1910 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1912 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1915 if (!empty($accountancy_code_sell)) {
1916 $object->accountancy_code_sell = $accountancy_code_sell;
1918 if (!empty($accountancy_code_sell_intra)) {
1919 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1921 if (!empty($accountancy_code_sell_export)) {
1922 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1924 if (!empty($accountancy_code_buy)) {
1925 $object->accountancy_code_buy = $accountancy_code_buy;
1927 if (!empty($accountancy_code_buy_intra)) {
1928 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1930 if (!empty($accountancy_code_buy_export)) {
1931 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1935 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1936 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1940 if ($mysoc->isInEEC()) {
1941 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1942 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1947 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1948 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1952 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1953 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1957 if ($mysoc->isInEEC()) {
1958 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1959 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1964 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1965 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1974 print $form->buttonsSaveCancel(
"Create");
1983 if ($action ==
'edit' && $usercancreate) {
1985 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1987 if (!empty(
$conf->use_javascript_ajax)) {
1988 print
'<script type="text/javascript">';
1989 print
'$(document).ready(function () {
1990 $("#selectcountry_id").change(function () {
1991 document.formprod.action.value="edit";
1992 document.formprod.submit();
1995 print
'</script>'.
"\n";
2002 $object->country_code = $tmparray[
'code'];
2003 $object->country = $tmparray[
'label'];
2006 $type = $langs->trans(
'Product');
2008 $type = $langs->trans(
'Service');
2013 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="formprod">'.
"\n";
2014 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2015 print
'<input type="hidden" name="action" value="update">';
2016 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2017 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
2020 $titre = $langs->trans(
"CardProduct".
$object->type);
2022 print
dol_get_fiche_head($head,
'card', $titre, 0, $picto, 0,
'',
'', 0,
'', 1);
2025 $parameters = array();
2027 $reshook = $hookmanager->executeHooks(
'tabContentEditProduct', $parameters,
$object, $action);
2029 if (empty($reshook)) {
2030 print
'<table class="border allwidth">';
2034 print
'<tr><td class="titlefieldcreate fieldrequired">'.$langs->trans(
"Ref").
'</td><td colspan="3"><input name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(GETPOSTISSET(
'ref') ?
GETPOST(
'ref') :
$object->
ref).
'"></td></tr>';
2036 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>';
2040 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Label").
'</td><td colspan="3"><input name="label" class="minwidth300 maxwidth400onsmartphone" maxlength="255" value="'.
dol_escape_htmltag(GETPOSTISSET(
'label') ?
GETPOST(
'label') :
$object->label).
'"></td></tr>';
2043 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
2044 print
'<select class="flat" name="statut">';
2045 if ((GETPOSTISSET(
'statut') &&
GETPOST(
'statut')) || (!GETPOSTISSET(
'statut') &&
$object->status)) {
2046 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
2047 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
2049 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
2050 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
2056 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
2057 print
'<select class="flat" name="statut_buy">';
2058 if ((GETPOSTISSET(
'statut_buy') &&
GETPOST(
'statut_buy')) || (!GETPOSTISSET(
'statut_buy') &&
$object->status_buy)) {
2059 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2060 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2062 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2063 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2069 if (isModEnabled(
'productbatch')) {
2071 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2072 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
2074 print $form->selectarray(
'status_batch', $statutarray, GETPOSTISSET(
'status_batch') ?
GETPOSTINT(
'status_batch') :
$object->status_batch);
2076 print
'<span id="statusBatchWarning" class="warning" style="display: none;">';
2077 print
img_warning().
' '.$langs->trans(
"WarningConvertFromBatchToSerial").
'</span>';
2079 print
'<span id="statusBatchMouvToGlobal" class="warning" style="display: none;">';
2080 print
img_warning().
' '.$langs->trans(
"WarningTransferBatchStockMouvToGlobal").
'</span>';
2084 print
'<script type="text/javascript">
2085 $(document).ready(function() {
2086 console.log($("#statusBatchWarning"))
2087 $("#status_batch").on("change", function() {
2088 if ($("#status_batch")[0].value == 0){
2089 $("#statusBatchMouvToGlobal").show()
2091 $("#statusBatchMouvToGlobal").hide()
2097 if (
$object->status_batch == 1) {
2098 print
'<script type="text/javascript">
2099 $(document).ready(function() {
2100 console.log($("#statusBatchWarning"))
2101 $("#status_batch").on("change", function() {
2102 if ($("#status_batch")[0].value == 2){
2103 $("#statusBatchWarning").show()
2105 $("#statusBatchWarning").hide()
2113 if (!empty(
$object->status_batch) || !empty(
$conf->use_javascript_ajax)) {
2114 $langs->load(
"admin");
2115 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2116 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
2117 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
2118 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2119 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
2122 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
2132 print
'<td id="field_mask">';
2133 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
2135 if (!empty(
$conf->use_javascript_ajax)) {
2136 print
'<script type="text/javascript">
2137 $(document).ready(function() {
2138 $("#field_mask").parent().addClass("hideobject");
2139 var preselect = document.getElementById("status_batch");';
2141 print
'if (preselect.value == "2") {
2142 $("#field_mask").parent().removeClass("hideobject");
2146 print
'if (preselect.value == "1") {
2147 $("#field_mask").parent().removeClass("hideobject");
2150 print
'$("#status_batch").on("change", function () {
2151 var optionSelected = $("option:selected", this);
2152 var valueSelected = this.value;
2153 $("#field_mask").parent().addClass("hideobject");
2157 if (this.value == 1) {
2158 $("#field_mask").parent().removeClass("hideobject");
2159 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
2165 if (this.value == 2) {
2166 $("#field_mask").parent().removeClass("hideobject");
2167 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2181 if (!empty($sellOrEatByMandatoryList)) {
2182 if (GETPOSTISSET(
'sell_or_eat_by_mandatory')) {
2183 $sellOrEatByMandatorySelectedId =
GETPOSTINT(
'sell_or_eat_by_mandatory');
2185 $sellOrEatByMandatorySelectedId =
$object->sell_or_eat_by_mandatory;
2187 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2188 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList, $sellOrEatByMandatorySelectedId);
2194 $showbarcode = isModEnabled(
'barcode');
2195 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2200 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2201 if (GETPOSTISSET(
'fk_barcode_type')) {
2202 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2204 $fk_barcode_type =
$object->barcode_type;
2209 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2211 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2213 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2214 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2215 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2216 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2218 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2223 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2226 $doleditor =
new DolEditor(
'desc', GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') :
$object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2227 $doleditor->Create();
2234 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2235 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2236 print
'<input type="text" name="url" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') :
$object->url).
'">';
2243 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2244 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2245 print $formproduct->selectWarehouses((GETPOSTISSET(
'fk_default_warehouse') ?
GETPOST(
'fk_default_warehouse') :
$object->fk_default_warehouse),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2246 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int)
$object->id)).
'">';
2247 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2260 if (
$object->isService() && isModEnabled(
'workstation')) {
2262 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2263 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2264 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
2277 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2278 print
'<input name="duration_value" class="width50" value="'.($object->duration_value ?
$object->duration_value :
'').
'"> ';
2280 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
$object->duration_unit ?
$object->duration_unit :
'h'), 0, 1);
2284 print
' ';
2286 print
'<input type="checkbox" class="valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2287 print
'<label for="mandatoryperiod">';
2288 $htmltooltip = $langs->trans(
"mandatoryHelper");
2290 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2292 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2299 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2300 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') :
$object->finished));
2305 if (!
$object->isService() && isModEnabled(
'bom')) {
2306 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2307 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int)
$object->id).
')';
2308 print $form->selectForForms($bomkey,
'fk_default_bom', (GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') :
$object->fk_default_bom), 1);
2315 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2316 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') :
$object->weight).
'"> ';
2317 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') :
$object->weight_units, 0, 2);
2323 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2324 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') :
$object->length).
'">x';
2325 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') :
$object->width).
'">x';
2326 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') :
$object->height).
'"> ';
2327 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') :
$object->length_units, 0, 2);
2332 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2333 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') :
$object->surface).
'"> ';
2334 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') :
$object->surface_units, 0, 2);
2339 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2340 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') :
$object->volume).
'"> ';
2341 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') :
$object->volume_units, 0, 2);
2347 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2348 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') :
$object->net_measure).
'"> ';
2349 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') :
$object->net_measure_units, 0, 0);
2355 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2357 print $form->selectUnits(
$object->fk_unit,
'units');
2363 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') :
$object->customcode).
'"></td></tr>';
2365 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2367 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2368 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2370 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2378 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2380 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2383 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2384 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOSTINT(
'state_id') :
$object->state_id,
$object->country_code);
2392 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.
$object->lifetime.
'"></td></tr>';
2393 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.
$object->qc_frequency.
'"></td></tr>';
2397 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2398 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2399 print $hookmanager->resPrint;
2400 if (empty($reshook)) {
2401 print
$object->showOptionals($extrafields,
'edit', $parameters);
2405 if (isModEnabled(
'category')) {
2406 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2407 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
2409 $cats =
$c->containing(
$object->id, Categorie::TYPE_PRODUCT);
2410 $arrayselected = array();
2411 if (is_array($cats)) {
2412 foreach ($cats as $cat) {
2413 $arrayselected[] = $cat->id;
2417 foreach (
GETPOST(
'categories',
'array') as $cat) {
2418 $arrayselected[] = $cat;
2421 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2427 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2429 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2430 $doleditor->Create();
2439 print
'<table class="border centpercent">';
2442 if (isModEnabled(
'accounting')) {
2445 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2447 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell),
'accountancy_code_sell', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2451 if ($mysoc->isInEEC()) {
2452 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2454 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra') :
$object->accountancy_code_sell_intra),
'accountancy_code_sell_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2459 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2461 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export') :
$object->accountancy_code_sell_export),
'accountancy_code_sell_export', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2465 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2467 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy),
'accountancy_code_buy', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2471 if ($mysoc->isInEEC()) {
2472 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2474 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra') :
$object->accountancy_code_buy_intra),
'accountancy_code_buy_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2479 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2481 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export') :
$object->accountancy_code_buy_export),
'accountancy_code_buy_export', 1, array(), 1, 1,
'minwidth150 maxwidth300');
2486 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2487 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell).
'">';
2491 if ($mysoc->isInEEC()) {
2492 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2493 print
'<td><input name="accountancy_code_sell_intra" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra') :
$object->accountancy_code_sell_intra).
'">';
2498 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2499 print
'<td><input name="accountancy_code_sell_export" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export') :
$object->accountancy_code_sell_export).
'">';
2503 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2504 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy).
'">';
2508 if ($mysoc->isInEEC()) {
2509 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2510 print
'<td><input name="accountancy_code_buy_intra" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra') :
$object->accountancy_code_buy_intra).
'">';
2515 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2516 print
'<td><input name="accountancy_code_buy_export" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export') :
$object->accountancy_code_buy_export).
'">';
2525 print $form->buttonsSaveCancel();
2531 $showbarcode = isModEnabled(
'barcode');
2532 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2537 $titre = $langs->trans(
"CardProduct".
$object->type);
2542 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2543 $object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
2546 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
2550 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref');
2553 $parameters = array();
2555 $reshook = $hookmanager->executeHooks(
'tabContentViewProduct', $parameters,
$object, $action);
2556 if (empty($reshook)) {
2557 print
'<div class="fichecenter">';
2558 print
'<div class="fichehalfleft">';
2560 print
'<div class="underbanner clearboth"></div>';
2561 print
'<table class="border tableforfield centpercent">';
2564 if (isModEnabled(
"product") && isModEnabled(
"service")) {
2565 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2566 print
'<tr><td class="titlefield">';
2567 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2569 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat);
2575 print
'<tr><td class="nowrap">';
2576 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2577 print $langs->trans(
"BarcodeType");
2579 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2580 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>';
2582 print
'</tr></table>';
2584 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2585 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2589 $fk_barcode_type =
'';
2590 if ($action ==
'editbarcodetype' && is_object($formbarcode)) {
2591 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->barcode_type,
'fk_barcode_type');
2592 $fk_barcode_type =
$object->barcode_type;
2595 $fk_barcode_type =
$object->barcode_type;
2596 print
$object->barcode_type_label ?
$object->barcode_type_label : (
$object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2598 print
'</td></tr>'.
"\n";
2601 print
'<tr><td class="nowrap">';
2602 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2603 print $langs->trans(
"BarcodeValue");
2605 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2606 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>';
2608 print
'</tr></table>';
2609 print
'</td><td class="wordbreak">';
2610 if ($action ==
'editbarcode') {
2611 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2612 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2613 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2616 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
2617 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2618 print
'<input type="hidden" name="action" value="setbarcode">';
2619 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2620 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2621 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2626 print
'</td></tr>'.
"\n";
2630 if (isModEnabled(
'productbatch')) {
2632 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2633 print
$object->getLibStatut(0, 2);
2637 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2643 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2644 print
$object->getSellOrEatByMandatoryLabel();
2650 print
'<tr><td class="nowrap">';
2651 print $langs->trans(
"ProductAccountancySellCode");
2653 if (isModEnabled(
'accounting')) {
2654 if (!empty(
$object->accountancy_code_sell)) {
2656 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
2658 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2661 print
$object->accountancy_code_sell;
2666 if ($mysoc->isInEEC()) {
2667 print
'<tr><td class="nowrap">';
2668 print $langs->trans(
"ProductAccountancySellIntraCode");
2670 if (isModEnabled(
'accounting')) {
2671 if (!empty(
$object->accountancy_code_sell_intra)) {
2673 $accountingaccount2->fetch(0,
$object->accountancy_code_sell_intra, 1);
2675 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2678 print
$object->accountancy_code_sell_intra;
2684 print
'<tr><td class="nowrap">';
2685 print $langs->trans(
"ProductAccountancySellExportCode");
2687 if (isModEnabled(
'accounting')) {
2688 if (!empty(
$object->accountancy_code_sell_export)) {
2690 $accountingaccount3->fetch(0,
$object->accountancy_code_sell_export, 1);
2692 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2695 print
$object->accountancy_code_sell_export;
2700 print
'<tr><td class="nowrap">';
2701 print $langs->trans(
"ProductAccountancyBuyCode");
2703 if (isModEnabled(
'accounting')) {
2704 if (!empty(
$object->accountancy_code_buy)) {
2706 $accountingaccount4->fetch(0,
$object->accountancy_code_buy, 1);
2708 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2711 print
$object->accountancy_code_buy;
2716 if ($mysoc->isInEEC()) {
2717 print
'<tr><td class="nowrap">';
2718 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2720 if (isModEnabled(
'accounting')) {
2721 if (!empty(
$object->accountancy_code_buy_intra)) {
2723 $accountingaccount5->fetch(0,
$object->accountancy_code_buy_intra, 1);
2725 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2728 print
$object->accountancy_code_buy_intra;
2734 print
'<tr><td class="nowrap">';
2735 print $langs->trans(
"ProductAccountancyBuyExportCode");
2737 if (isModEnabled(
'accounting')) {
2738 if (!empty(
$object->accountancy_code_buy_export)) {
2740 $accountingaccount6->fetch(0,
$object->accountancy_code_buy_export, 1);
2742 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2745 print
$object->accountancy_code_buy_export;
2751 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
2752 print
'<td class="wordbreakimp wrapimp"><div class="longmessagecut">'.(dol_textishtml(
$object->description) ?
$object->description :
dol_nl2br(
$object->description, 1,
true)).
'</div></td></tr>';
2756 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2764 $warehouse->fetch(
$object->fk_default_warehouse);
2766 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2767 print(!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2771 if (
$object->isService() && isModEnabled(
'workstation')) {
2773 $res = $workstation->fetch(
$object->fk_default_workstation);
2775 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2776 print(!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2781 if (isModEnabled(
'variants') && (
$object->isProduct() ||
$object->isService())) {
2784 if ($combination->fetchByFkProductChild(
$object->id) > 0) {
2785 $prodstatic =
new Product($db);
2786 $prodstatic->fetch($combination->fk_product_parent);
2789 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2790 print $prodstatic->getNomUrl(1);
2797 print
'<div class="fichehalfright">';
2799 print
'<div class="underbanner clearboth"></div>';
2800 print
'<table class="border tableforfield centpercent">';
2804 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
2805 $measuringUnits =
new CUnits($db);
2808 if (
$object->duration_value > 1) {
2811 $result = $measuringUnits->fetchAll(
'',
'scale', 0, 0, [
't.active' => 1,
't.unit_type' =>
'time']);
2812 if ($result !== -1) {
2813 foreach ($measuringUnits->records as $record) {
2814 $durations[$record->short_label] =
dol_ucfirst($record->label) . $plural;
2817 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Duration").
'</td><td>';
2818 if (
$object->duration_value) {
2819 print
$object->duration_value;
2820 print (!empty(
$object->duration_unit) && isset($durations[
$object->duration_unit]) ?
" ".$langs->trans($durations[
$object->duration_unit]).
" " :
'');
2824 $htmltooltip = $langs->trans(
"mandatoryHelper");
2826 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2828 if (
$object->duration_value > 0) {
2829 print
' ';
2831 print
'<input type="checkbox" class="valignmiddle" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2832 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2838 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2839 print
$object->getLibFinished();
2844 if (!
$object->isService() && isModEnabled(
'bom') &&
$object->finished) {
2845 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2846 if (
$object->fk_default_bom) {
2847 $bom_static =
new BOM($db);
2848 $bom_static->fetch(
$object->fk_default_bom);
2849 print $bom_static->getNomUrl(1);
2857 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Weight").
'</td><td>';
2863 print
"</td></tr>\n";
2868 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2872 print
" x ".$object->width;
2875 print
" x ".$object->height;
2877 print
' '.measuringUnitString(0,
"size",
$object->length_units);
2881 print
"</td></tr>\n";
2885 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2891 print
"</td></tr>\n";
2895 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2901 print
"</td></tr>\n";
2906 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"NetMeasure").
'</td><td>';
2907 if (
$object->net_measure !=
'') {
2918 $unit =
$object->getLabelOfUnit();
2920 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2922 print $langs->trans($unit);
2929 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.
$object->customcode.
'</td></tr>';
2932 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry(
$object->country_id,
'', $db);
2933 if (!empty(
$object->state_id)) {
2934 print
' - '.getState(
$object->state_id,
'0', $db);
2941 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.
$object->lifetime.
'</td></tr>';
2942 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.
$object->qc_frequency.
'</td></tr>';
2946 $parameters = array();
2947 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2950 if (isModEnabled(
'category')) {
2951 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2952 print $form->showCategories(
$object->id, Categorie::TYPE_PRODUCT, 1);
2958 print
'<!-- show Note --> '.
"\n";
2960 print
'<!-- End show Note --> '.
"\n";
2967 print
'<div class="clearboth"></div>';
2972 } elseif ($action !=
'create') {
2978if (!empty($modCodeProduct->code_auto)) {
2979 $tmpcode = $modCodeProduct->getNextValue(
$object,
$object->type);
2985if (($action ==
'delete' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
2986 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
2987 $formconfirm = $form->formconfirm(
"card.php?id=".
$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2989if ($action ==
'merge') {
2990 $formquestion = array(
2992 'name' =>
'product_origin',
2993 'label' => $langs->trans(
'MergeOriginProduct'),
2995 'value' => $form->select_produits(0,
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2998 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
3002if (($action ==
'clone' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
3003 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
3005 $formquestionclone = array(
3006 'text' => $langs->trans(
"ConfirmClone"),
3007 0 => array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->ref : $tmpcode,
'morecss' =>
'width150'),
3008 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
3009 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
3012 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
3015 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
3017 if (isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
3018 if (
$object->fk_default_bom > 0) {
3019 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_defbom',
'label' => $langs->trans(
"CloneDefBomProduct"),
'value' =>
getDolGlobalInt(
'BOM_CLONE_DEFBOM'));
3021 $bomstatic =
new BOM($db);
3022 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
3023 if (is_array($bomlist) && count($bomlist) > 0) {
3024 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_otherboms',
'label' => $langs->trans(
"CloneOtherBomsProduct"),
'value' => 0);
3027 $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);
3031$parameters = array(
'formConfirm' => $formconfirm,
'object' =>
$object);
3032$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
3033if (empty($reshook)) {
3034 $formconfirm .= $hookmanager->resPrint;
3035} elseif ($reshook > 0) {
3036 $formconfirm = $hookmanager->resPrint;
3045if ($action !=
'create' && $action !=
'edit') {
3046 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
3047 $cloneButtonId =
'action-clone-no-ajax';
3049 print
"\n".
'<div class="tabsAction">'.
"\n";
3051 $parameters = array();
3052 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3053 if (empty($reshook)) {
3054 if ($usercancreate) {
3055 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
3059 if (!isset($hookmanager->resArray[
'no_button_copy']) || $hookmanager->resArray[
'no_button_copy'] != 1) {
3060 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3061 $cloneProductUrl =
'';
3062 $cloneButtonId =
'action-clone';
3064 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
3069 if ($usercandelete) {
3070 if (empty($object_is_used)) {
3071 if (!isset($hookmanager->resArray[
'no_button_delete']) || $hookmanager->resArray[
'no_button_delete'] != 1) {
3072 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3073 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
3079 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3082 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
3085 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3103 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
3104 $propal =
new Propal($db);
3106 $langs->load(
"propal");
3108 $otherprop = $propal->liste_array(2, 1, 0);
3110 if (is_array($otherprop) && count($otherprop)) {
3111 $html .=
'<tr><td style="width: 200px;">';
3112 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3113 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
3114 $html .=
'</td></tr>';
3116 $html .=
'<tr><td style="width: 200px;">';
3117 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3118 $html .= $langs->trans(
"NoDraftProposals");
3119 $html .=
'</td></tr>';
3124 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
3127 $langs->load(
"orders");
3129 $othercom = $commande->liste_array(2, 1,
null);
3130 if (is_array($othercom) && count($othercom)) {
3131 $html .=
'<tr><td style="width: 200px;">';
3132 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3133 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
3134 $html .=
'</td></tr>';
3136 $html .=
'<tr><td style="width: 200px;">';
3137 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3138 $html .= $langs->trans(
"NoDraftOrders");
3139 $html .=
'</td></tr>';
3144 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
3147 $langs->load(
"bills");
3149 $otherinvoice = $invoice->liste_array(2, 1,
null);
3150 if (is_array($otherinvoice) && count($otherinvoice)) {
3151 $html .=
'<tr><td style="width: 200px;">';
3152 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3153 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
3154 $html .=
'</td></tr>';
3156 $html .=
'<tr><td style="width: 200px;">';
3157 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3158 $html .= $langs->trans(
"NoDraftInvoices");
3159 $html .=
'</td></tr>';
3164 if (!empty($html)) {
3165 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
3166 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3167 print
'<input type="hidden" name="action" value="addin">';
3173 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
3174 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
3175 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
3176 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
3177 $html .=
'</td></tr>';
3179 print
'<table class="centpercent border">';
3183 print
'<div class="center">';
3184 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
3198if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
3199 print
'<div class="fichecenter"><div class="fichehalfleft">';
3200 print
'<a name="builddoc"></a>';
3204 if (!empty(
$conf->product->multidir_output[
$object->entity])) {
3205 $filedir =
$conf->product->multidir_output[
$object->entity].
'/'.$objectref;
3207 $filedir =
$conf->product->dir_output.
'/'.$objectref;
3209 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3210 $genallowed = $usercanread;
3211 $delallowed = $usercancreate;
3213 print $formfile->showdocuments($modulepart,
$object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'',
$object);
3214 $somethingshown = $formfile->numoffiles;
3216 print
'</div><div class="fichehalfright">';
3219 $morehtmlcenter =
'<div class="nowraponall">';
3220 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/product/messaging.php?id='.
$object->id);
3221 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
3222 $morehtmlcenter .=
'</div>';
3225 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3227 $somethingshown = $formactions->showactions(
$object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3229 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Class to manage accounting accounts.
Class of dictionary type of thirdparty (used by imports)
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 the relation between a product and one of its variants.
File of class to manage predefined price products or services by customer.
Class to manage products or services.
const TYPE_PRODUCT
Regular product.
static getSellOrEatByMandatoryList()
Get the array of labels of Sell by or Eat by all mandatory flags for each status.
const TYPE_SERVICE
Service.
Class to manage proposals.
Class to manage third parties objects (customers, suppliers, prospects...)
getCountry($searchkey, $withcode='', $dbtouse=null, $outputlangs=null, $entconv=1, $searchlabel='')
Return country label, code or id from an id, code or label.
print $script_file $mode $langs defaultlang(is_numeric($duration_value) ? " delay=". $duration_value :"").(is_numeric($duration_value2) ? " after cd cd cd description as description
Only used if Module[ID]Desc translation string is not found.
dol_move($srcfile, $destfile, $newmask='0', $overwriteifexists=1, $testvirus=0, $indexdatabase=1, $moreinfo=array())
Move a file into another name.
dol_dir_list($utf8_path, $types="all", $recursive=0, $filter="", $excludefilter=null, $sortcriteria="name", $sortorder=SORT_ASC, $mode=0, $nohook=0, $relativename="", $donotfollowsymlinks=0, $nbsecondsold=0)
Scan a directory and return a list of files/directories.
dol_is_dir($folder)
Test if filename is a directory.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2, $allowothertags=array())
Show picto whatever it's its name (generic function)
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
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)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
dol_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0)
Clean a string to use it as a file name.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify 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_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unitid, $measuring_style='', $unitscale='', $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.