48require
'../main.inc.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
56require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
69 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
72 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
75 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
78 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
79 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
80 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
83 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
87 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
91$langs->loadLangs(array(
'products',
'other'));
93 $langs->load(
"stocks");
96 $langs->load(
"bills");
99 $langs->load(
"productbatch");
102$backtopageforcancel =
GETPOST(
'backtopageforcancel');
108$refalreadyexists = 0;
114 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'nohtml') : null);
116 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alpha') : null);
119$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
120$cancel =
GETPOST(
'cancel',
'alpha');
121$backtopage =
GETPOST(
'backtopage',
'alpha');
122$confirm =
GETPOST(
'confirm',
'alpha');
124$duration_value =
GETPOST(
'duration_value') ===
'' ? null :
GETPOSTINT(
'duration_value');
125$duration_unit =
GETPOST(
'duration_unit',
'alpha');
127$accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
128$accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
129$accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
130$accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
131$accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
132$accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
134$checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
138 $label_security_check =
'nohtml';
140 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
143if (!empty($user->socid)) {
144 $socid = $user->socid;
149if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
150 $module = substr($module, 0,
dol_strlen($module) - 4);
154 $modCodeProduct =
new $module();
163$extrafields->fetch_name_optionals_label(
$object->table_element);
165if ($id > 0 || !empty($ref)) {
166 $result =
$object->fetch($id, (
string) $ref);
170 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
172 $upload_dir = $conf->product->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName(
$object->ref);
174 $upload_dir = $conf->service->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0, $object,
'product').dol_sanitizeFileName(
$object->ref);
179 $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";
181 $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";
186$modulepart =
'product';
191if (!empty($canvas)) {
192 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
193 $objcanvas =
new Canvas($db, $action);
194 $objcanvas->getCanvas(
'product',
'card', $canvas);
198$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
199$fieldtype = (!empty($id) ?
'rowid' :
'ref');
202$hookmanager->initHooks(array(
'productcard',
'globalcard'));
205 if (
$object->type == $object::TYPE_PRODUCT) {
208 if (
$object->type == $object::TYPE_SERVICE) {
212 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
219$permissiontoeditextra = $usercancreate;
220if (
GETPOST(
'attribute',
'aZ09') && isset($extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')])) {
222 $permissiontoeditextra =
dol_eval((
string) $extrafields->attributes[
$object->table_element][
'perms'][
GETPOST(
'attribute',
'aZ09')]);
235if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'creer_advance')) {
239$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
240$reshook = $hookmanager->executeHooks(
'doActions', $parameters, $object, $action);
245if (empty($reshook)) {
246 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
248 if (empty($backtopage) || ($cancel && empty($id))) {
249 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
250 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
251 $backtopage = $backurlforlist;
253 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
259 if (!empty($backtopageforcancel)) {
260 header(
"Location: ".$backtopageforcancel);
262 } elseif (!empty($backtopage)) {
263 header(
"Location: ".$backtopage);
269 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
271 $productOriginId =
GETPOSTINT(
'product_origin');
272 $productOrigin =
new Product($db);
274 if ($productOriginId <= 0) {
275 $langs->load(
'errors');
276 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
278 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
288 $listofproperties = array(
298 'accountancy_code_buy',
299 'accountancy_code_buy_intra',
300 'accountancy_code_buy_export',
301 'accountancy_code_sell',
302 'accountancy_code_sell_intra',
303 'accountancy_code_sell_export'
305 foreach ($listofproperties as $property) {
306 if (empty(
$object->$property)) {
307 $object->$property = $productOrigin->$property;
311 $listofproperties = array(
312 'note_public',
'note_private'
314 foreach ($listofproperties as $property) {
319 if (is_array($productOrigin->array_options)) {
320 foreach ($productOrigin->array_options as $key => $val) {
321 if (empty(
$object->array_options[$key])) {
322 $object->array_options[$key] = $val;
329 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
330 $custcats = $static_cat->containing(
$object->id,
'product',
'id');
331 $custcats = array_merge($custcats, $custcats_ori);
332 $object->setCategories($custcats);
335 if ($productOrigin->barcode ==
$object->barcode) {
336 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
337 $productOrigin->barcode =
'';
353 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
354 'Bom' =>
'/bom/class/bom.class.php',
357 'Commande' =>
'/commande/class/commande.class.php',
358 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
359 'Contrat' =>
'/contrat/class/contrat.class.php',
360 'Delivery' =>
'/delivery/class/delivery.class.php',
361 'Facture' =>
'/compta/facture/class/facture.class.php',
362 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
363 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
364 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
365 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
366 'Propal' =>
'/comm/propal/class/propal.class.php',
367 'Reception' =>
'/reception/class/reception.class.php',
368 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
372 foreach ($objects as $object_name => $object_file) {
373 require_once DOL_DOCUMENT_ROOT.$object_file;
375 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id,
$object->id)) {
385 $parameters = array(
'soc_origin' => $productOrigin->id,
'soc_dest' =>
$object->id);
386 $reshook = $hookmanager->executeHooks(
403 'mergefromid' => $productOrigin->id,
407 $result =
$object->call_trigger(
'PRODUCT_MODIFY', $user);
421 if (!empty($conf->product->multidir_output[$productOrigin->entity])) {
422 $srcdir = $conf->product->multidir_output[$productOrigin->entity].
"/".$productOrigin->ref;
423 $destdir = $conf->product->multidir_output[
$object->entity].
"/".
$object->ref;
427 foreach ($dirlist as $filetomove) {
428 $destfile = $destdir.
'/'.$filetomove[
'relativename'];
430 dol_move($filetomove[
'fullname'], $destfile,
'0', 0, 0, 1);
437 if ($productOrigin->delete($user) < 1) {
446 $langs->load(
"errors");
455 if ($action ==
'setfk_product_type' && $usercancreate) {
456 $result =
$object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
457 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
462 $upload_dir = $conf->product->dir_output;
463 $permissiontoadd = $usercancreate;
464 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
466 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
469 if ($action ==
'setfk_barcode_type' && $usercancreate) {
470 $result =
$object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
471 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
476 if ($action ==
'setbarcode' && $usercancreate) {
480 $result =
$object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
481 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
484 $langs->load(
"errors");
486 $errors[] =
'ErrorBadBarCodeSyntax';
487 } elseif ($result == -2) {
488 $errors[] =
'ErrorBarCodeRequired';
489 } elseif ($result == -3) {
490 $errors[] =
'ErrorBarCodeAlreadyUsed';
492 $errors[] =
'FailedToValidateBarCode';
501 if ($action ==
'update_extras' && $permissiontoeditextra) {
505 $attribute_name =
GETPOST(
'attribute',
'aZ09');
508 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
514 $result =
$object->updateExtraField($attribute_name,
'PRODUCT_MODIFY');
522 $action =
'edit_extras';
527 if ($action ==
'add' && $usercancreate) {
530 if (!
GETPOST(
'label', $label_security_check)) {
531 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
537 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'ProductRef')),
null,
'errors');
542 if (!empty($duration_value) && empty($duration_unit)) {
543 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
547 $stockable_product = (int) ($type == 0 || ($type == 1 &&
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')));
549 setEventMessages($langs->trans(
'ErrorBatchesNeedStockManagement'),
null,
'errors');
557 $object->entity = $conf->entity;
561 $object->mandatory_period = empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 0 : 1;
562 if (
$object->price_base_type ==
'TTC') {
567 if (
$object->price_base_type ==
'TTC') {
573 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
577 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
578 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
581 $localtax1_type =
'0';
582 $localtax2_type =
'0';
585 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
587 $vatratecode = $reg[1];
589 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
590 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
591 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
592 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
593 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
594 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
595 $resql = $db->query($sql);
597 $obj = $db->fetch_object($resql);
598 $npr = $obj->recuperableonly;
599 $localtax1 = $obj->localtax1;
600 $localtax2 = $obj->localtax2;
601 $localtax1_type = $obj->localtax1_type;
602 $localtax2_type = $obj->localtax2_type;
606 $object->default_vat_code = $vatratecode;
609 $object->localtax1_tx = $localtax1;
610 $object->localtax2_tx = $localtax2;
611 $object->localtax1_type = $localtax1_type;
612 $object->localtax2_type = $localtax2_type;
625 $stdobject->element =
'product';
626 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
627 $result = $stdobject->fetchBarCode();
630 $mesg =
'Failed to get bar code type information ';
633 $object->barcode_type_code = $stdobject->barcode_type_code;
634 $object->barcode_type_coder = $stdobject->barcode_type_coder;
635 $object->barcode_type_label = $stdobject->barcode_type_label;
646 $object->duration_value = $duration_value;
647 $object->duration_unit = $duration_unit;
666 if ($finished >= 0) {
679 $object->stockable_product = $stockable_product;
681 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
682 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
683 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
684 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
685 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
686 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
688 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
689 $object->accountancy_code_sell =
'';
691 $object->accountancy_code_sell = $accountancy_code_sell;
693 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
694 $object->accountancy_code_sell_intra =
'';
696 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
698 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
699 $object->accountancy_code_sell_export =
'';
701 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
703 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
704 $object->accountancy_code_buy =
'';
706 $object->accountancy_code_buy = $accountancy_code_buy;
708 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
709 $object->accountancy_code_buy_intra =
'';
711 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
713 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
714 $object->accountancy_code_buy_export =
'';
716 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
722 for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
723 if (GETPOSTISSET(
"price_".$i)) {
725 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
727 $object->multiprices[
"$i"] = 0;
733 $ret = $extrafields->setOptionalsFromPost(
null, $object);
740 '@phan-var ModeleProductCode $modCodeProduct';
742 $ref = $modCodeProduct->getNextValue($object, $type);
751 $categories =
GETPOST(
'categories',
'array:int');
752 $object->setCategories($categories);
754 if (!empty($backtopage)) {
755 $backtopage = preg_replace(
'/__ID__/', (
string)
$object->id, $backtopage);
756 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
757 if (preg_match(
'/\?/', $backtopage)) {
758 $backtopage .=
'&productid='.$object->id;
761 header(
"Location: ".$backtopage);
764 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
771 if (
$object->error ==
'ErrorProductAlreadyExists') {
773 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters, $object, $action);
792 if ($action ==
'update' && $usercancreate) {
793 if (
GETPOST(
'cancel',
'alpha')) {
830 $object->duration_value = $duration_value;
831 $object->duration_unit = $duration_unit;
849 if ($finished >= 0) {
855 $fk_default_bom =
GETPOSTINT(
'fk_default_bom');
856 if ($fk_default_bom >= 0) {
857 $object->fk_default_bom = $fk_default_bom;
863 $object->stockable_product = (int) GETPOSTISSET(
'stockable_product');
865 $object->stockable_product = 1;
866 setEventMessages($langs->trans(
'ForceBatchesNeedStockManagement'),
null,
'warnings');
880 $stdobject->element =
'product';
881 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
882 $result = $stdobject->fetchBarCode();
885 $mesg =
'Failed to get bar code type information ';
888 $object->barcode_type_code = $stdobject->barcode_type_code;
889 $object->barcode_type_coder = $stdobject->barcode_type_coder;
890 $object->barcode_type_label = $stdobject->barcode_type_label;
892 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
893 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
894 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
895 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
896 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
897 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
898 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
899 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
900 $object->accountancy_code_sell =
'';
902 $object->accountancy_code_sell = $accountancy_code_sell;
904 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
905 $object->accountancy_code_sell_intra =
'';
907 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
909 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
910 $object->accountancy_code_sell_export =
'';
912 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
914 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
915 $object->accountancy_code_buy =
'';
917 $object->accountancy_code_buy = $accountancy_code_buy;
919 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
920 $object->accountancy_code_buy_intra =
'';
922 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
924 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
925 $object->accountancy_code_buy_export =
'';
927 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
930 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
935 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
942 if (!GETPOSTISSET(
'status_batch')) {
945 if (!GETPOSTISSET(
'sell_or_eat_by_mandatory')) {
946 $object->sell_or_eat_by_mandatory =
$object->oldcopy->sell_or_eat_by_mandatory;
948 if (!GETPOSTISSET(
'batch_mask')) {
952 if (!$error &&
$object->check()) {
955 $categories =
GETPOST(
'categories',
'array:int');
956 $object->setCategories($categories);
971 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
980 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
983 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
994 unset($clone->date_creation);
995 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
997 $clone->status_buy = 0;
998 $clone->barcode = -1;
1000 if ($clone->check()) {
1003 $clone->context[
'createfromclone'] =
'createfromclone';
1004 $id = $clone->create($user);
1006 if (
GETPOST(
'clone_composition')) {
1007 $result = $clone->clone_associations(
$object->id, $id);
1015 if (!$error &&
GETPOST(
'clone_categories')) {
1016 $result = $clone->cloneCategories(
$object->id, $id);
1024 if (!$error &&
GETPOST(
'clone_prices')) {
1025 $result = $clone->clone_price(
$object->id, $id);
1033 if (!$error &&
isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
1036 $bomstatic =
new BOM($db);
1037 $bomclone = $bomstatic->createFromClone($user,
$object->fk_default_bom);
1038 if ((
int) $bomclone < 0) {
1039 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1041 $defbomidac =
$object->fk_default_bom;
1042 $clone->fk_default_bom = $bomclone->id;
1043 $clone->update($id, $user);
1044 $bomclone->fk_product =
$id;
1045 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1046 $bomclone->update($user);
1047 $bomclone->validate($user);
1050 if (
GETPOST(
'clone_otherboms')) {
1051 $bomstatic =
new BOM($db);
1052 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
1053 if (is_array($bomlist)) {
1054 foreach ($bomlist as $bom2clone) {
1055 if ($bom2clone->id != $defbomidac) {
1056 $bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
1057 if ((
int) $bomclone < 0) {
1058 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1060 $bomclone->fk_product =
$id;
1061 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1062 $bomclone->update($user);
1063 $bomclone->validate($user);
1072 if ($clone->error ==
'ErrorProductAlreadyExists') {
1073 $refalreadyexists++;
1076 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
1077 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
1080 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
1085 unset($clone->context[
'createfromclone']);
1092 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
1096 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
1106 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
1109 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
1110 $result =
$object->delete($user);
1113 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.
$object->type.
'&delprod='.urlencode(
$object->ref));
1124 if (
$object->id > 0 && $action ==
'addin') {
1126 $permissiontoaddline =
false;
1133 $propal =
new Propal($db);
1134 $result = $propal->fetch(
GETPOSTINT(
'propalid'));
1139 $thirdpartyid = $propal->socid;
1140 $permissiontoaddline = $user->hasRight(
'propal',
'creer');
1143 $result = $commande->fetch(
GETPOSTINT(
'commandeid'));
1148 $thirdpartyid = $commande->socid;
1149 $permissiontoaddline = $user->hasRight(
'commande',
'creer');
1152 $result = $facture->fetch(
GETPOSTINT(
'factureid'));
1157 $thirdpartyid = $facture->socid;
1158 $permissiontoaddline = $user->hasRight(
'facture',
'creer');
1161 if ($thirdpartyid > 0) {
1163 $result = $soc->fetch($thirdpartyid);
1173 if (empty($tva_tx)) {
1181 $price_base_type =
$object->price_base_type;
1185 $pu_ht =
$object->multiprices[$soc->price_level];
1186 $pu_ttc =
$object->multiprices_ttc[$soc->price_level];
1187 $price_base_type =
$object->multiprices_base_type[$soc->price_level];
1189 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1193 $filter = array(
't.fk_product' => (
string)
$object->id,
't.fk_soc' => (
string) $soc->id);
1195 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1197 if (count($prodcustprice->lines) > 0) {
1198 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1199 foreach ($prodcustprice->lines as $k => $custprice_line) {
1200 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1201 $pu_ht =
price($custprice_line->price);
1202 $pu_ttc =
price($custprice_line->price_ttc);
1203 $price_base_type = $custprice_line->price_base_type;
1204 $tva_tx = $custprice_line->tva_tx;
1212 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1213 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'',
$object->tva_tx));
1217 if ($tmpvat != $tmpprodvat) {
1218 if ($price_base_type !=
'HT') {
1219 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1221 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1225 if (
GETPOSTINT(
'propalid') > 0 && $permissiontoaddline && is_object($propal)) {
1228 if (($result = $propal->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1229 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1232 $buyprice = $result;
1235 $result = $propal->addline(
1260 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1264 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1265 } elseif (
GETPOST(
'commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
1268 if (($result = $commande->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1269 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1272 $buyprice = $result;
1275 $result = $commande->addline(
1302 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode((
string) ($commande->id)));
1306 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1307 } elseif (
GETPOST(
'factureid') > 0 && $permissiontoaddline && is_object($facture)) {
1310 if (($result = $facture->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1311 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1314 $buyprice = $result;
1317 $result = $facture->addline(
1349 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1353 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1357 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1362 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1365 $triggersendname =
'PRODUCT_SENTBYMAIL';
1367 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_TO';
1368 $trackid =
'prod'.$object->id;
1369 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1378$form =
new Form($db);
1385$sellOrEatByMandatoryList =
null;
1392 if ($disableSellBy) {
1393 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY]);
1394 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1396 if ($disableEatBy) {
1397 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY]);
1398 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1402$title = $langs->trans(
'ProductServiceCard');
1407 if ($action ==
'create') {
1408 $title = $langs->trans(
"NewProduct");
1410 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1411 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1415 if ($action ==
'create') {
1416 $title = $langs->trans(
"NewService");
1418 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1419 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1423llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-card');
1427$modBarCodeProduct =
null;
1430 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
1431 foreach ($dirbarcode as $dirroot) {
1438 $modBarCodeProduct =
new $module();
1439 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
1443$canvasdisplayaction = $action;
1444if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
1445 $canvasdisplayaction =
'view';
1448if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
1452 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
1453 $objcanvas->display_canvas($canvasdisplayaction);
1458 if ($action ==
'create' && $usercancreate) {
1460 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1462 if (!empty($conf->use_javascript_ajax)) {
1463 print
'<script type="text/javascript">';
1464 print
'$(document).ready(function () {
1465 $("#selectcountry_id").change(function() {
1466 console.log("selectcountry_id change");
1467 document.formprod.action.value="create";
1468 document.formprod.submit();
1471 print
'</script>'.
"\n";
1475 $module =
getDolGlobalString(
'PRODUCT_CODEPRODUCT_ADDON',
'mod_codeproduct_leopard');
1476 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1477 $module = substr($module, 0,
dol_strlen($module) - 4);
1481 $modCodeProduct =
new $module();
1487 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1488 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1489 print
'<input type="hidden" name="action" value="add">';
1490 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1491 if (!empty($modCodeProduct->code_auto)) {
1492 print
'<input type="hidden" name="code_auto" value="1">';
1494 if (!empty($modBarCodeProduct->code_auto)) {
1495 print
'<input type="hidden" name="barcode_auto" value="1">';
1497 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1501 $title = $langs->trans(
"NewService");
1504 $title = $langs->trans(
"NewProduct");
1510 $object->country_id = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : null;
1511 if (
$object->country_id > 0) {
1513 $object->country_code = $tmparray[
'code'];
1514 $object->country = $tmparray[
'label'];
1520 $parameters = array();
1522 $reshook = $hookmanager->executeHooks(
'tabContentCreateProduct', $parameters, $object, $action);
1523 if (empty($reshook)) {
1524 print
'<table class="border centpercent">';
1529 if (!empty($modCodeProduct->code_auto)) {
1531 $tmpcode = $modCodeProduct->getNextValue($object, $type);
1533 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).
'">';
1534 if ($refalreadyexists) {
1535 print $langs->trans(
"RefAlreadyExists");
1541 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>';
1544 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1545 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1546 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1550 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1551 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1552 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1557 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1558 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1559 print $form->selectarray(
'status_batch', $statutarray,
GETPOSTINT(
'status_batch'));
1563 if ($status_batch !==
'0') {
1564 $langs->load(
"admin");
1565 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1566 $tooltip .= $langs->trans(
"GenericMaskCodes1");
1567 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1568 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1569 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1570 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1575 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1578 print
'<td id="field_mask">';
1579 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1,
'help');
1580 print
'<script type="text/javascript">
1581 $(document).ready(function() {
1582 $("#field_mask, #mask_option").addClass("hideobject");
1583 $("#status_batch").on("change", function () {
1584 console.log("We change batch status");
1585 var optionSelected = $("option:selected", this);
1586 var valueSelected = this.value;
1587 $("#field_mask, #mask_option").addClass("hideobject");
1591 if (this.value == 1) {
1592 $("#field_mask, #mask_option").toggleClass("hideobject");
1593 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1599 if (this.value == 2) {
1600 $("#field_mask, #mask_option").toggleClass("hideobject");
1601 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1614 if (!empty($sellOrEatByMandatoryList)) {
1615 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
1616 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList,
GETPOSTINT(
'sell_or_eat_by_mandatory'));
1622 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
1629 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1630 if (GETPOSTISSET(
'fk_barcode_type')) {
1631 $fk_barcode_type =
GETPOST(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type') : 0;
1636 $fk_barcode_type = 0;
1639 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1641 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1646 print
'<td'.((is_object($modBarCodeProduct) && $modBarCodeProduct->code_null) ?
'' :
' class="fieldrequired"').
'>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1647 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
1648 if (empty($tmpcode) && is_object($modBarCodeProduct) && !empty($modBarCodeProduct->code_auto)) {
1649 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1651 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1652 print
'<input class="maxwidth150" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1657 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1658 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1659 $doleditor->Create();
1664 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1665 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1666 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1672 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1673 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1674 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1675 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOSTINT(
'type')).
'">';
1676 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1684 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1685 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1690 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1691 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1696 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1697 print
'<input name="desiredstock" type="hidden" value="0">';
1701 if ($type == $object::TYPE_SERVICE &&
isModEnabled(
"workstation")) {
1703 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1704 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1705 print $formproduct->selectWorkstations((GETPOSTISSET(
'fk_default_workstation') ?
GETPOSTINT(
'fk_default_workstation') :
''),
'fk_default_workstation', 1);
1711 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1712 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1713 print
'<input name="duration_value" class="width50 valignmiddle" value="'.(GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value') :
'').
'">';
1714 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (GETPOSTISSET(
'duration_unit') ?
GETPOST(
'duration_unit',
'alpha') :
'h'), 0, 1);
1717 if (
$object->duration_value > 0) {
1718 print
' ';
1720 print
'<input type="checkbox" class="marginleftonly valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.(GETPOSTISSET(
'mandatoryperiod') ?
' checked="checked"' :
'').
'>';
1721 print
'<label for="mandatoryperiod">';
1722 $htmltooltip = $langs->trans(
"mandatoryHelper");
1724 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
1726 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
1735 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1736 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') : (string)
$object->finished));
1744 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1745 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1746 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1747 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);
1753 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1754 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1755 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1756 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1757 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1758 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') : (
GETPOST(
'size_units',
'alpha') ?:
'0'), 0, 2);
1763 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1764 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1765 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') : (
GETPOST(
'surface_units',
'alpha') ?:
'0'), 0, 2);
1770 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1771 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1772 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') : (
GETPOST(
'volume_units',
'alpha') ?:
'0'), 0, 2);
1778 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1779 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1780 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);
1787 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1789 print $form->selectUnits(GETPOSTISSET(
'units') ?
GETPOST(
'units',
'alpha') : (
GETPOST(
'units',
'alpha') ?:
'0'),
'units');
1795 print
'<tr><td class="wordbreak">'.$form->textwithpicto($langs->trans(
"CustomsCode"), $langs->trans(
"CustomsCodeHelp")).
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1798 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1800 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1801 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1803 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1811 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1813 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1816 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1817 print $formcompany->select_state(
$object->state_id,
$object->country_code);
1824 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1825 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1829 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
1830 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1831 print $hookmanager->resPrint;
1832 if (empty($reshook)) {
1833 print
$object->showOptionals($extrafields,
'create', $parameters);
1837 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1840 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1841 $doleditor->Create();
1847 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1848 print $form->selectCategories(Categorie::TYPE_PRODUCT,
'categories', $object);
1860 print
'<table class="border centpercent">';
1862 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1864 print $form->load_tva(
"tva_tx", $defaultva,
$mysoc,
$mysoc, 0, 0,
'',
false, 1);
1872 print
'<table class="border centpercent">';
1875 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1876 print
'<td><input name="price" class="maxwidth50" value="'.(GETPOSTISSET(
'price') ?
GETPOST(
'price') :
$object->
price).
'">';
1877 print $form->selectPriceBaseType(
getDolGlobalString(
'PRODUCT_PRICE_BASE_TYPE'),
"price_base_type");
1882 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1883 print
'<td><input name="price_min" class="maxwidth50" value="'.(GETPOSTISSET(
'price_min') ?
GETPOST(
'price_min') :
$object->price_min).
'">';
1887 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1889 print $form->load_tva(
"tva_tx", $defaultva,
$mysoc,
$mysoc, 0, 0,
'',
false, 1);
1900 print
'<!-- accountancy codes -->'.
"\n";
1901 print
'<table class="border centpercent">';
1907 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1910 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_ACCOUNT"));
1912 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
1914 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1919 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1922 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1924 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1926 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1931 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1934 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1936 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1938 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1942 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1945 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1947 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1949 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1954 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1957 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1959 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1961 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1966 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1969 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1971 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1973 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1976 if (!empty($accountancy_code_sell)) {
1977 $object->accountancy_code_sell = $accountancy_code_sell;
1979 if (!empty($accountancy_code_sell_intra)) {
1980 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1982 if (!empty($accountancy_code_sell_export)) {
1983 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1985 if (!empty($accountancy_code_buy)) {
1986 $object->accountancy_code_buy = $accountancy_code_buy;
1988 if (!empty($accountancy_code_buy_intra)) {
1989 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1991 if (!empty($accountancy_code_buy_export)) {
1992 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1996 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1997 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
2002 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2003 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
2008 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2009 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
2013 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2014 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
2019 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2020 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
2025 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2026 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
2035 print $form->buttonsSaveCancel(
"Create");
2043 $iskit =
$object->hasFatherOrChild(1);
2046 if ($action ==
'edit' && $usercancreate) {
2048 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2050 if (!empty($conf->use_javascript_ajax)) {
2051 print
'<script type="text/javascript">';
2052 print
'$(document).ready(function () {
2053 $("#selectcountry_id").change(function () {
2054 document.formprod.action.value="edit";
2055 document.formprod.submit();
2058 print
'</script>'.
"\n";
2065 $object->country_code = $tmparray[
'code'];
2066 $object->country = $tmparray[
'label'];
2069 $type = $langs->trans(
'Product');
2071 $type = $langs->trans(
'Service');
2076 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="formprod">'.
"\n";
2077 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2078 print
'<input type="hidden" name="action" value="update">';
2079 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2080 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
2083 $titre = $langs->trans(
"CardProduct".
$object->type);
2085 print
dol_get_fiche_head($head,
'card', $titre, 0, $picto, 0,
'',
'', 0,
'', 1);
2088 $parameters = array();
2090 $reshook = $hookmanager->executeHooks(
'tabContentEditProduct', $parameters, $object, $action);
2092 if (empty($reshook)) {
2093 print
'<table class="border allwidth">';
2097 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>';
2099 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>';
2103 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>';
2106 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
2107 print
'<select class="flat" name="statut">';
2108 if ((GETPOSTISSET(
'statut') &&
GETPOST(
'statut')) || (!GETPOSTISSET(
'statut') &&
$object->status)) {
2109 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
2110 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
2112 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
2113 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
2119 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
2120 print
'<select class="flat" name="statut_buy">';
2121 if ((GETPOSTISSET(
'statut_buy') &&
GETPOST(
'statut_buy')) || (!GETPOSTISSET(
'statut_buy') &&
$object->status_buy)) {
2122 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2123 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2125 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2126 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2134 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2135 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
2137 print $form->selectarray(
'status_batch', $statutarray, GETPOSTISSET(
'status_batch') ?
GETPOSTINT(
'status_batch') :
$object->status_batch);
2139 print
'<span id="statusBatchWarning" class="warning" style="display: none;">';
2140 print
img_warning().
' '.$langs->trans(
"WarningConvertFromBatchToSerial").
'</span>';
2142 print
'<span id="statusBatchMouvToGlobal" class="warning" style="display: none;">';
2143 print
img_warning().
' '.$langs->trans(
"WarningTransferBatchStockMouvToGlobal").
'</span>';
2147 print
'<script type="text/javascript">
2148 $(document).ready(function() {
2149 console.log($("#statusBatchWarning"))
2150 $("#status_batch").on("change", function() {
2151 if ($("#status_batch")[0].value == 0) {
2152 $("#statusBatchMouvToGlobal").show()
2154 $("#statusBatchMouvToGlobal").hide()
2160 if (
$object->status_batch == 1) {
2161 print
'<script type="text/javascript">
2162 $(document).ready(function() {
2163 console.log($("#statusBatchWarning"))
2164 $("#status_batch").on("change", function() {
2165 if ($("#status_batch")[0].value == 2) {
2166 $("#statusBatchWarning").show()
2168 $("#statusBatchWarning").hide()
2176 if (!empty(
$object->status_batch) || !empty($conf->use_javascript_ajax)) {
2177 $langs->load(
"admin");
2178 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2179 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
2180 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
2181 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2182 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
2185 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
2195 print
'<td id="field_mask">';
2196 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1,
'help');
2198 if (!empty($conf->use_javascript_ajax)) {
2199 print
'<script type="text/javascript">
2200 $(document).ready(function() {
2201 $("#field_mask").parent().addClass("hideobject");
2202 var preselect = document.getElementById("status_batch");';
2204 print
'if (preselect.value == "2") {
2205 $("#field_mask").parent().removeClass("hideobject");
2209 print
'if (preselect.value == "1") {
2210 $("#field_mask").parent().removeClass("hideobject");
2213 print
'$("#status_batch").on("change", function () {
2214 var optionSelected = $("option:selected", this);
2215 var valueSelected = this.value;
2216 $("#field_mask").parent().addClass("hideobject");
2220 if (this.value == 1) {
2221 $("#field_mask").parent().removeClass("hideobject");
2222 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
2228 if (this.value == 2) {
2229 $("#field_mask").parent().removeClass("hideobject");
2230 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2244 if (!empty($sellOrEatByMandatoryList)) {
2245 if (GETPOSTISSET(
'sell_or_eat_by_mandatory')) {
2246 $sellOrEatByMandatorySelectedId =
GETPOSTINT(
'sell_or_eat_by_mandatory');
2248 $sellOrEatByMandatorySelectedId =
$object->sell_or_eat_by_mandatory;
2250 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2251 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList, $sellOrEatByMandatorySelectedId);
2258 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2263 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2264 if (GETPOSTISSET(
'fk_barcode_type')) {
2265 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2267 $fk_barcode_type =
$object->barcode_type;
2272 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2274 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2276 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2277 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2278 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2279 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2281 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2286 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2289 $doleditor =
new DolEditor(
'desc', GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') :
$object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2290 $doleditor->Create();
2297 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2298 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2299 print
'<input type="text" name="url" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') :
$object->url).
'">';
2306 print
'<tr><td><input type="hidden" id="stockable_product" name="stockable_product" value="on" /></td><td></td></tr>';
2308 print
'<tr><td><label for="stockable_product">' . $langs->trans(
"StockableProduct") .
'</label></td>';
2309 $checked = empty(
$object->stockable_product) ?
"" :
"checked";
2310 print
'<td><input type="checkbox" id="stockable_product" name="stockable_product" '. $checked .
' /></td></tr>';
2314 print
'<tr class="showifstockable'.(empty(
$object->stockable_product) ?
' hidden' :
'').
'"><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2315 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2316 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(),
'minwidth200 maxwidth500 widthcentpercentminusxx');
2317 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int)
$object->id)).
'">';
2318 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2334 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2335 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2336 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
2349 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2350 print
'<input name="duration_value" class="width50" value="'.($object->duration_value ?
$object->duration_value :
'').
'"> ';
2352 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
$object->duration_unit ?
$object->duration_unit :
'h'), 0, 1);
2356 print
' ';
2358 print
'<input type="checkbox" class="valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2359 print
'<label for="mandatoryperiod">';
2360 $htmltooltip = $langs->trans(
"mandatoryHelper");
2362 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2364 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
2371 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2372 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') :
$object->finished));
2378 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2379 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int)
$object->id).
')';
2380 print
img_picto($langs->trans(
"DefaultBOM"),
'bom',
'class="pictofixedwidth"');
2381 print $form->selectForForms($bomkey,
'fk_default_bom', (GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') :
$object->fk_default_bom), 1);
2388 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2389 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') :
$object->weight).
'"> ';
2390 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') : (int)
$object->weight_units, 0, 2);
2396 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2397 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') :
$object->length).
'">x';
2398 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') :
$object->width).
'">x';
2399 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') :
$object->height).
'"> ';
2400 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') : (int)
$object->length_units, 0, 2);
2405 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2406 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') :
$object->surface).
'"> ';
2407 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') : (int)
$object->surface_units, 0, 2);
2412 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2413 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') :
$object->volume).
'"> ';
2414 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') : (int)
$object->volume_units, 0, 2);
2420 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2421 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') :
$object->net_measure).
'"> ';
2422 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') : (int)
$object->net_measure_units, 0, 0);
2428 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2430 print $form->selectUnits(
$object->fk_unit,
'units');
2436 print
'<tr><td class="wordbreak">'.$form->textwithpicto($langs->trans(
"CustomsCode"), $langs->trans(
"CustomsCodeHelp")).
'</td>';
2437 print
'<td>' .
img_picto(
'',
'fa-clipboard-check',
'class="pictofixedwidth"') .
'<input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') :
$object->customcode).
'"></td></tr>';
2439 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2441 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
2442 print $form->select_country((
string) (GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2444 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2452 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2454 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2457 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2458 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOSTINT(
'state_id') :
$object->state_id,
$object->country_code);
2466 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.
$object->lifetime.
'"></td></tr>';
2467 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.
$object->qc_frequency.
'"></td></tr>';
2471 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2472 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2473 print $hookmanager->resPrint;
2474 if (empty($reshook)) {
2475 print
$object->showOptionals($extrafields,
'edit', $parameters);
2480 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2481 print $form->selectCategories(Categorie::TYPE_PRODUCT,
'categories', $object);
2487 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2489 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2490 $doleditor->Create();
2500 print
'<table class="border centpercent">';
2505 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2507 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');
2508 $nb = $formaccounting->nbaccounts;
2510 print
' <a href="'.DOL_URL_ROOT.
'/accountancy/admin/account.php">'.$langs->trans(
"SetupOn", $langs->trans(
"Chartofaccounts")).
'</a>';
2516 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2518 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');
2523 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2525 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');
2529 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2531 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');
2536 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2538 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');
2543 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2545 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');
2550 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2551 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell).
'">';
2556 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2557 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).
'">';
2562 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2563 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).
'">';
2567 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2568 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy).
'">';
2573 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2574 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).
'">';
2579 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2580 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).
'">';
2589 print
'$(document).ready(function() {
2590 $("#stockable_product").change(function() {
2591 $(".showifstockable").toggle(this.checked);
2600 print $form->buttonsSaveCancel();
2607 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2612 $titre = $langs->trans(
"CardProduct".
$object->type);
2615 print
dol_get_fiche_head($head,
'card', $titre, -1, $picto, 0,
'',
'', 0,
'', 1);
2617 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2618 $object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
2621 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
2625 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
2628 $parameters = array();
2630 $reshook = $hookmanager->executeHooks(
'tabContentViewProduct', $parameters, $object, $action);
2631 if (empty($reshook)) {
2632 print
'<div class="fichecenter">';
2633 print
'<div class="fichehalfleft">';
2635 print
'<div class="underbanner clearboth"></div>';
2636 print
'<table class="border tableforfield centpercent">';
2640 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2641 print
'<tr><td class="titlefield">';
2642 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, (
int) $usercancreate, $typeformat) : $langs->trans(
'Type');
2644 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat);
2650 print
'<tr><td class="nowrap">';
2651 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
2652 print $langs->trans(
"BarcodeType");
2654 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2655 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>';
2657 print
'</tr></table>';
2659 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2660 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2664 $fk_barcode_type =
'';
2665 if ($action ==
'editbarcodetype' && is_object($formbarcode)) {
2666 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->barcode_type,
'fk_barcode_type');
2667 $fk_barcode_type =
$object->barcode_type;
2670 $fk_barcode_type =
$object->barcode_type;
2671 print
$object->barcode_type_label ?
$object->barcode_type_label : (
$object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2673 print
'</td></tr>'.
"\n";
2676 print
'<tr><td class="nowrap">';
2677 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
2678 print $langs->trans(
"BarcodeValue");
2680 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2681 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>';
2683 print
'</tr></table>';
2684 print
'</td><td class="wordbreak">';
2685 if ($action ==
'editbarcode') {
2686 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2687 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2688 $tmpcode = $modBarCodeProduct->getNextValue($object, (
string) $fk_barcode_type);
2691 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
2692 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2693 print
'<input type="hidden" name="action" value="setbarcode">';
2694 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2695 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2696 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2701 print
'</td></tr>'.
"\n";
2706 print
'<tr><td>' . $form->textwithpicto($langs->trans(
"StockableProduct"), $langs->trans(
'StockableProductDescription')) .
'</td>';
2709 print
'<input type="checkbox" readonly disabled> <span class="opacitymedium">' . $langs->trans(
"NotSupportedOnKits").
'</span>';
2711 print
'<input type="checkbox" readonly disabled '.($object->stockable_product == 1 ?
'checked' :
'').
'>';
2715 if (
$object->isStockManaged() && !$iskit) {
2717 $warehouse->fetch(
$object->fk_default_warehouse);
2719 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2720 print(!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2728 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2729 print
$object->getLibStatut(0, 2);
2733 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2739 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2740 print
$object->getSellOrEatByMandatoryLabel();
2746 print
'<tr><td class="nowrap">';
2747 print $langs->trans(
"ProductAccountancySellCode");
2750 if (!empty(
$object->accountancy_code_sell)) {
2752 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
2754 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2757 print
$object->accountancy_code_sell;
2763 print
'<tr><td class="nowrap">';
2764 print $langs->trans(
"ProductAccountancySellIntraCode");
2767 if (!empty(
$object->accountancy_code_sell_intra)) {
2769 $accountingaccount2->fetch(0,
$object->accountancy_code_sell_intra, 1);
2771 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2774 print
$object->accountancy_code_sell_intra;
2780 print
'<tr><td class="nowrap">';
2781 print $langs->trans(
"ProductAccountancySellExportCode");
2784 if (!empty(
$object->accountancy_code_sell_export)) {
2786 $accountingaccount3->fetch(0,
$object->accountancy_code_sell_export, 1);
2788 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2791 print
$object->accountancy_code_sell_export;
2796 print
'<tr><td class="nowrap">';
2797 print $langs->trans(
"ProductAccountancyBuyCode");
2800 if (!empty(
$object->accountancy_code_buy)) {
2802 $accountingaccount4->fetch(0,
$object->accountancy_code_buy, 1);
2804 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2807 print
$object->accountancy_code_buy;
2813 print
'<tr><td class="nowrap">';
2814 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2817 if (!empty(
$object->accountancy_code_buy_intra)) {
2819 $accountingaccount5->fetch(0,
$object->accountancy_code_buy_intra, 1);
2821 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2824 print
$object->accountancy_code_buy_intra;
2830 print
'<tr><td class="nowrap">';
2831 print $langs->trans(
"ProductAccountancyBuyExportCode");
2834 if (!empty(
$object->accountancy_code_buy_export)) {
2836 $accountingaccount6->fetch(0,
$object->accountancy_code_buy_export, 1);
2838 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2841 print
$object->accountancy_code_buy_export;
2847 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
2848 print
'<td class="wordbreakimp wrapimp"><div class="longmessagecut">'.(dol_textishtml(
$object->description) ?
$object->description :
dol_nl2br(
$object->description, 1,
true)).
'</div></td></tr>';
2852 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2859 $res = $workstation->fetch(
$object->fk_default_workstation);
2861 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2862 print(!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2870 if ($combination->fetchByFkProductChild(
$object->id) > 0) {
2871 $prodstatic =
new Product($db);
2872 $prodstatic->fetch($combination->fk_product_parent);
2875 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2876 print $prodstatic->getNomUrl(1);
2884 print
'<div class="fichehalfright">';
2885 print
'<div class="underbanner clearboth"></div>';
2887 print
'<table class="border tableforfield centpercent">';
2891 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
2892 $measuringUnits =
new CUnits($db);
2895 if (
$object->duration_value > 1) {
2898 $result = $measuringUnits->fetchAll(
'',
'scale', 0, 0, [
't.active' => 1,
't.unit_type' =>
'time']);
2899 if ($result !== -1) {
2900 foreach ($measuringUnits->records as $record) {
2901 $durations[$record->short_label] =
dol_ucfirst((
string) $record->label) . $plural;
2904 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Duration").
'</td><td>';
2905 if (
$object->duration_value) {
2906 print
$object->duration_value;
2907 print(!empty(
$object->duration_unit) && isset($durations[
$object->duration_unit]) ?
" ".$langs->trans($durations[
$object->duration_unit]).
" " :
'');
2911 $htmltooltip = $langs->trans(
"mandatoryHelper");
2913 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2915 if (
$object->duration_value > 0) {
2916 print
' ';
2918 print
'<input type="checkbox" class="valignmiddle" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2919 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
2925 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2926 print
$object->getLibFinished();
2932 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2933 if (
$object->fk_default_bom) {
2934 $bom_static =
new BOM($db);
2935 $bom_static->fetch(
$object->fk_default_bom);
2936 print $bom_static->getNomUrl(1);
2944 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Weight").
'</td><td>';
2950 print
"</td></tr>\n";
2955 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2959 print
" x ".$object->width;
2962 print
" x ".$object->height;
2964 print
' '.measuringUnitString(0,
"size",
$object->length_units);
2968 print
"</td></tr>\n";
2973 print (
getDolGlobalString(
'PRODUCT_DISABLE_SURFACE') ?
'' : $langs->trans(
"Surface"));
2975 print (
getDolGlobalString(
'PRODUCT_DISABLE_VOLUME') ?
'' : $langs->trans(
"Volume")).
'</td><td>';
2983 print
"</td></tr>\n";
2988 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"NetMeasure").
'</td><td>';
2989 if (
$object->net_measure !=
'') {
3000 $unit =
$object->getLabelOfUnit(
'long', $langs);
3002 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
3009 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"CustomsCode"), $langs->trans(
"CustomsCodeHelp")).
'</td><td>'.
dolPrintHTML(
$object->customcode).
'</td></tr>';
3012 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry(
$object->country_id,
'', $db);
3013 if (!empty(
$object->state_id)) {
3014 print
' - '.getState(
$object->state_id,
'0', $db);
3021 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.
$object->lifetime.
'</td></tr>';
3022 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.
$object->qc_frequency.
'</td></tr>';
3026 $parameters = array();
3027 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3031 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
3032 print $form->showCategories(
$object->id, Categorie::TYPE_PRODUCT, 1);
3038 print
'<!-- show Note --> '.
"\n";
3040 print
'<!-- End show Note --> '.
"\n";
3047 print
'<div class="clearboth"></div>';
3052 } elseif ($action !=
'create') {
3058if (!empty($modCodeProduct->code_auto)) {
3060 $tmpcode = $modCodeProduct->getNextValue($object,
$object->type);
3066if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
3067 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
3068 $formconfirm = $form->formconfirm(
"card.php?id=".
$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
3070if ($action ==
'merge') {
3071 $formquestion = array(
3073 'name' =>
'product_origin',
3074 'label' => $langs->trans(
'MergeOriginProduct'),
3076 'value' => $form->select_produits(0,
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
3079 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
3083if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
3084 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
3086 $formquestionclone = array(
3087 'text' => $langs->trans(
"ConfirmClone"),
3088 0 => array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->ref : $tmpcode,
'morecss' =>
'width150'),
3089 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
3090 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
3093 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
3096 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
3098 if (
isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
3099 if (
$object->fk_default_bom > 0) {
3100 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_defbom',
'label' => $langs->trans(
"CloneDefBomProduct"),
'value' =>
getDolGlobalInt(
'BOM_CLONE_DEFBOM'));
3102 $bomstatic =
new BOM($db);
3103 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
3104 if (is_array($bomlist) && count($bomlist) > 0) {
3105 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_otherboms',
'label' => $langs->trans(
"CloneOtherBomsProduct"),
'value' => 0);
3108 $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);
3112$parameters = array(
'formConfirm' => $formconfirm,
'object' => $object);
3113$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3114if (empty($reshook)) {
3115 $formconfirm .= $hookmanager->resPrint;
3116} elseif ($reshook > 0) {
3117 $formconfirm = $hookmanager->resPrint;
3126if ($action !=
'create' && $action !=
'edit') {
3127 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
3128 $cloneButtonId =
'action-clone-no-ajax';
3130 print
"\n".
'<div class="tabsAction">'.
"\n";
3132 $parameters = array();
3133 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3134 if (empty($reshook)) {
3135 if ($usercancreate) {
3136 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
3141 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=presend&mode=init&token=' .
newToken() .
'#formmailbeforetitle');
3143 if (!isset($hookmanager->resArray[
'no_button_copy']) || $hookmanager->resArray[
'no_button_copy'] != 1) {
3144 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
3145 $cloneProductUrl =
'';
3146 $cloneButtonId =
'action-clone';
3148 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
3153 if ($usercandelete) {
3154 if (empty($object_is_used)) {
3155 if (!isset($hookmanager->resArray[
'no_button_delete']) || $hookmanager->resArray[
'no_button_delete'] != 1) {
3156 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
3157 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
3163 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3166 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
3169 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3187 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
3188 $propal =
new Propal($db);
3190 $langs->load(
"propal");
3192 $otherprop = $propal->liste_array(2, 1, 0);
3194 if (is_array($otherprop) && count($otherprop)) {
3195 $html .=
'<tr><td style="width: 200px;">';
3196 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3197 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
3198 $html .=
'</td></tr>';
3200 $html .=
'<tr><td style="width: 200px;">';
3201 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3202 $html .= $langs->trans(
"NoDraftProposals");
3203 $html .=
'</td></tr>';
3208 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
3211 $langs->load(
"orders");
3213 $othercom = $commande->liste_array(2, 1,
null);
3214 if (is_array($othercom) && count($othercom)) {
3215 $html .=
'<tr><td style="width: 200px;">';
3216 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3217 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
3218 $html .=
'</td></tr>';
3220 $html .=
'<tr><td style="width: 200px;">';
3221 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3222 $html .= $langs->trans(
"NoDraftOrders");
3223 $html .=
'</td></tr>';
3228 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
3231 $langs->load(
"bills");
3233 $otherinvoice = $invoice->liste_array(2, 1,
null);
3234 if (is_array($otherinvoice) && count($otherinvoice)) {
3235 $html .=
'<tr><td style="width: 200px;">';
3236 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3237 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
3238 $html .=
'</td></tr>';
3240 $html .=
'<tr><td style="width: 200px;">';
3241 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3242 $html .= $langs->trans(
"NoDraftInvoices");
3243 $html .=
'</td></tr>';
3248 if (!empty($html)) {
3249 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
3250 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3251 print
'<input type="hidden" name="action" value="addin">';
3257 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
3258 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
3259 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
3260 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
3261 $html .=
'</td></tr>';
3263 print
'<table class="centpercent border">';
3267 print
'<div class="center">';
3268 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
3282if (
GETPOST(
'modelselected')) {
3283 $action =
'presend';
3286if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
3287 print
'<div class="fichecenter"><div class="fichehalfleft">';
3288 print
'<a name="builddoc"></a>';
3292 if (!empty($conf->product->multidir_output[
$object->entity ?? $conf->entity])) {
3293 $filedir = $conf->product->multidir_output[
$object->entity ?? $conf->entity].
'/'.$objectref;
3295 $filedir = $conf->product->dir_output.
'/'.$objectref;
3297 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3298 $genallowed = $usercanread;
3299 $delallowed = $usercancreate;
3301 print $formfile->showdocuments($modulepart,
$object->ref, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed,
'', 0, 0, 0, 28, 0,
'',
'',
'', $langs->getDefaultLang(),
'', $object);
3302 $somethingshown = $formfile->numoffiles;
3304 print
'</div><div class="fichehalfright">';
3307 $morehtmlcenter =
'<div class="nowraponall">';
3308 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/product/messaging.php?id='.
$object->id);
3309 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
3310 $morehtmlcenter .=
'</div>';
3313 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3315 $somethingshown = $formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3317 print
'</div></div>';
3320 $modelmail =
'product_send';
3321 $defaulttopic =
$object->label;
3322 $diroutput = $conf->product->multidir_output[
$object->entity ?? $conf->entity];
3323 $trackid =
'prod' .
$object->id;
3325 include DOL_DOCUMENT_ROOT.
'/core/tpl/card_presend.tpl.php';
$id
Support class for third parties, contacts, members, users or resources.
if(! $sortfield) if(! $sortorder) $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(), $entity=null)
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.
dol_now($mode='gmt')
Return date for now.
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, $morecssdiv='')
Show tabs of a record.
dolPrintHTML($s, $allowiframe=0)
Return a string (that can be on several lines) ready to be output on a HTML page.
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_eval($s, $returnvalue=1, $hideerrors=1, $onlysimplestring='1')
Replace eval function to add more security.
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_sanitizeFileName($str, $newstr='_', $unaccent=1, $includequotes=0, $allowdash=0)
Clean a string to use it as a file name.
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.
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'.
GETPOSTFLOAT($paramname, $rounding='', $option=2)
Return the value of a $_GET or $_POST supervariable, converted into float.
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.
dol_clone($srcobject, $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...
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='', $morecssonpicto='widthpictotitle')
Load a title with picto.
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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 rate, 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...
measuringUnitString($unitid, $measuring_style='', $unitscale=null, $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
product_prepare_head($object)
Prepare array with list of tabs.
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.