48require
'../main.inc.php';
58require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
59require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
60require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
61require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
62require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
63require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
64require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
65require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
66require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
67require_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;
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);
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';
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');
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);
417 if ($productOrigin->delete($user) < 1) {
424 if (!empty(
$conf->product->multidir_output[$productOrigin->entity ?? 1])) {
425 $srcdir =
$conf->product->multidir_output[$productOrigin->entity ?? 1].
"/".$productOrigin->ref;
430 foreach ($dirlist as $filetomove) {
431 $destfile = $destdir.
'/'.$filetomove[
'relativename'];
433 dol_move($filetomove[
'fullname'], $destfile,
'0', 0, 0, 1);
444 $langs->load(
"errors");
453 if ($action ==
'setfk_product_type' && $usercancreate) {
454 $result =
$object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
455 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
460 $upload_dir =
$conf->product->dir_output;
461 $permissiontoadd = $usercancreate;
462 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
464 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
467 if ($action ==
'setfk_barcode_type' && $usercancreate) {
468 $result =
$object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
469 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
474 if ($action ==
'setbarcode' && $usercancreate) {
478 $result =
$object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
479 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
482 $langs->load(
"errors");
484 $errors[] =
'ErrorBadBarCodeSyntax';
485 } elseif ($result == -2) {
486 $errors[] =
'ErrorBarCodeRequired';
487 } elseif ($result == -3) {
488 $errors[] =
'ErrorBarCodeAlreadyUsed';
490 $errors[] =
'FailedToValidateBarCode';
499 if ($action ==
'update_extras' && $permissiontoeditextra) {
503 $attribute_name =
GETPOST(
'attribute',
'aZ09');
506 $ret = $extrafields->setOptionalsFromPost(
null, $object, $attribute_name);
512 $result =
$object->updateExtraField($attribute_name,
'PRODUCT_MODIFY');
520 $action =
'edit_extras';
525 if ($action ==
'add' && $usercancreate) {
528 if (!
GETPOST(
'label', $label_security_check)) {
529 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
535 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities($refLabelKey)),
null,
'errors');
540 if (!empty($duration_value) && empty($duration_unit)) {
541 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
545 $stockable_product = (int) ($type == 0 || ($type == 1 &&
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')));
547 setEventMessages($langs->trans(
'ErrorBatchesNeedStockManagement'),
null,
'errors');
559 $object->mandatory_period = empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 0 : 1;
560 if (
$object->price_base_type ==
'TTC') {
565 if (
$object->price_base_type ==
'TTC') {
571 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
575 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
576 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
579 $localtax1_type =
'0';
580 $localtax2_type =
'0';
583 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
585 $vatratecode = $reg[1];
587 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
588 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
589 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape(
$mysoc->country_code).
"'";
590 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
591 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
592 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
593 $resql =
$db->query($sql);
595 $obj =
$db->fetch_object($resql);
596 $npr = $obj->recuperableonly;
597 $localtax1 = $obj->localtax1;
598 $localtax2 = $obj->localtax2;
599 $localtax1_type = $obj->localtax1_type;
600 $localtax2_type = $obj->localtax2_type;
604 $object->default_vat_code = $vatratecode;
607 $object->localtax1_tx = $localtax1;
608 $object->localtax2_tx = $localtax2;
609 $object->localtax1_type = $localtax1_type;
610 $object->localtax2_type = $localtax2_type;
623 $stdobject->element =
'product';
624 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
625 $result = $stdobject->fetchBarCode();
628 $mesg =
'Failed to get bar code type information ';
631 $object->barcode_type_code = $stdobject->barcode_type_code;
632 $object->barcode_type_coder = $stdobject->barcode_type_coder;
633 $object->barcode_type_label = $stdobject->barcode_type_label;
644 $object->duration_value = $duration_value;
645 $object->duration_unit = $duration_unit;
664 if ($finished >= 0) {
677 $object->stockable_product = $stockable_product;
679 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
680 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
681 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
682 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
683 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
684 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
686 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
687 $object->accountancy_code_sell =
'';
689 $object->accountancy_code_sell = $accountancy_code_sell;
691 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
692 $object->accountancy_code_sell_intra =
'';
694 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
696 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
697 $object->accountancy_code_sell_export =
'';
699 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
701 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
702 $object->accountancy_code_buy =
'';
704 $object->accountancy_code_buy = $accountancy_code_buy;
706 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
707 $object->accountancy_code_buy_intra =
'';
709 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
711 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
712 $object->accountancy_code_buy_export =
'';
714 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
720 for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
723 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
725 $object->multiprices[
"$i"] = 0;
731 $ret = $extrafields->setOptionalsFromPost(
null, $object);
738 '@phan-var ModeleProductCode $modCodeProduct';
740 $ref = $modCodeProduct->getNextValue($object, $type);
749 $categories =
GETPOST(
'categories',
'array:int');
750 $object->setCategories($categories);
752 if (!empty($backtopage)) {
753 $backtopage = preg_replace(
'/__ID__/', (
string)
$object->id, $backtopage);
754 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
755 if (preg_match(
'/\?/', $backtopage)) {
756 $backtopage .=
'&productid='.$object->id;
759 header(
"Location: ".$backtopage);
762 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
769 if (
$object->error ==
'ErrorProductAlreadyExists') {
771 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters, $object, $action);
790 if ($action ==
'update' && $usercancreate) {
791 if (
GETPOST(
'cancel',
'alpha')) {
828 $object->duration_value = $duration_value;
829 $object->duration_unit = $duration_unit;
847 if ($finished >= 0) {
853 $fk_default_bom =
GETPOSTINT(
'fk_default_bom');
854 if ($fk_default_bom >= 0) {
855 $object->fk_default_bom = $fk_default_bom;
863 $object->stockable_product = 1;
864 setEventMessages($langs->trans(
'ForceBatchesNeedStockManagement'),
null,
'warnings');
878 $stdobject->element =
'product';
879 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
880 $result = $stdobject->fetchBarCode();
883 $mesg =
'Failed to get bar code type information ';
886 $object->barcode_type_code = $stdobject->barcode_type_code;
887 $object->barcode_type_coder = $stdobject->barcode_type_coder;
888 $object->barcode_type_label = $stdobject->barcode_type_label;
890 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
891 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
892 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
893 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
894 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
895 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
896 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
897 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
898 $object->accountancy_code_sell =
'';
900 $object->accountancy_code_sell = $accountancy_code_sell;
902 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
903 $object->accountancy_code_sell_intra =
'';
905 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
907 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
908 $object->accountancy_code_sell_export =
'';
910 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
912 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
913 $object->accountancy_code_buy =
'';
915 $object->accountancy_code_buy = $accountancy_code_buy;
917 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
918 $object->accountancy_code_buy_intra =
'';
920 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
922 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
923 $object->accountancy_code_buy_export =
'';
925 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
928 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
933 $ret = $extrafields->setOptionalsFromPost(
null, $object,
'@GETPOSTISSET');
938 if (!$error &&
$object->check()) {
941 $categories =
GETPOST(
'categories',
'array:int');
942 $object->setCategories($categories);
957 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
966 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
969 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
980 unset($clone->date_creation);
981 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
983 $clone->status_buy = 0;
984 $clone->barcode = -1;
986 if ($clone->check()) {
989 $clone->context[
'createfromclone'] =
'createfromclone';
990 $id = $clone->create($user);
992 if (
GETPOST(
'clone_composition')) {
993 $result = $clone->clone_associations(
$object->id, $id);
1001 if (!$error &&
GETPOST(
'clone_categories')) {
1002 $result = $clone->cloneCategories(
$object->id, $id);
1010 if (!$error &&
GETPOST(
'clone_prices')) {
1011 $result = $clone->clone_price(
$object->id, $id);
1019 if (!$error &&
isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
1022 $bomstatic =
new BOM(
$db);
1023 $bomclone = $bomstatic->createFromClone($user,
$object->fk_default_bom);
1024 if ((
int) $bomclone < 0) {
1025 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1027 $defbomidac =
$object->fk_default_bom;
1028 $clone->fk_default_bom = $bomclone->id;
1029 $clone->update($id, $user);
1030 $bomclone->fk_product =
$id;
1031 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1032 $bomclone->update($user);
1033 $bomclone->validate($user);
1036 if (
GETPOST(
'clone_otherboms')) {
1037 $bomstatic =
new BOM(
$db);
1038 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
1039 if (is_array($bomlist)) {
1040 foreach ($bomlist as $bom2clone) {
1041 if ($bom2clone->id != $defbomidac) {
1042 $bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
1043 if ((
int) $bomclone < 0) {
1044 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1046 $bomclone->fk_product =
$id;
1047 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1048 $bomclone->update($user);
1049 $bomclone->validate($user);
1058 if ($clone->error ==
'ErrorProductAlreadyExists') {
1059 $refalreadyexists++;
1062 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
1063 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
1066 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
1071 unset($clone->context[
'createfromclone']);
1078 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
1082 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
1092 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
1095 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
1096 $result =
$object->delete($user);
1099 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.
$object->type.
'&delprod='.urlencode(
$object->ref));
1110 if (
$object->id > 0 && $action ==
'addin') {
1112 $permissiontoaddline =
false;
1120 $result = $propal->fetch(
GETPOSTINT(
'propalid'));
1125 $thirdpartyid = $propal->socid;
1126 $permissiontoaddline = $user->hasRight(
'propal',
'creer');
1129 $result = $commande->fetch(
GETPOSTINT(
'commandeid'));
1134 $thirdpartyid = $commande->socid;
1135 $permissiontoaddline = $user->hasRight(
'commande',
'creer');
1138 $result = $facture->fetch(
GETPOSTINT(
'factureid'));
1143 $thirdpartyid = $facture->socid;
1144 $permissiontoaddline = $user->hasRight(
'facture',
'creer');
1147 if ($thirdpartyid > 0) {
1149 $result = $soc->fetch($thirdpartyid);
1159 if (empty($tva_tx)) {
1167 $price_base_type =
$object->price_base_type;
1171 $pu_ht =
$object->multiprices[$soc->price_level];
1172 $pu_ttc =
$object->multiprices_ttc[$soc->price_level];
1173 $price_base_type =
$object->multiprices_base_type[$soc->price_level];
1175 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1179 $filter = array(
't.fk_product' => (
string)
$object->id,
't.fk_soc' => (
string) $soc->id);
1181 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1183 if (count($prodcustprice->lines) > 0) {
1184 $date_now = (int) floor(
dol_now() / 86400) * 86400;
1185 foreach ($prodcustprice->lines as $k => $custprice_line) {
1186 if ($custprice_line->date_begin <= $date_now && (empty($custprice_line->date_end) || $date_now <= $custprice_line->date_end)) {
1187 $pu_ht =
price($custprice_line->price);
1188 $pu_ttc =
price($custprice_line->price_ttc);
1189 $price_base_type = $custprice_line->price_base_type;
1190 $tva_tx = $custprice_line->tva_tx;
1198 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1199 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'',
$object->tva_tx));
1203 if ($tmpvat != $tmpprodvat) {
1204 if ($price_base_type !=
'HT') {
1205 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1207 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1211 if (
GETPOSTINT(
'propalid') > 0 && $permissiontoaddline && is_object($propal)) {
1214 if (($result = $propal->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1215 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1218 $buyprice = $result;
1221 $result = $propal->addline(
1246 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1250 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1251 } elseif (
GETPOST(
'commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
1254 if (($result = $commande->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1255 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1258 $buyprice = $result;
1261 $result = $commande->addline(
1288 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode((
string) ($commande->id)));
1292 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1293 } elseif (
GETPOST(
'factureid') > 0 && $permissiontoaddline && is_object($facture)) {
1296 if (($result = $facture->defineBuyPrice($pu_ht, (
float)
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1297 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1300 $buyprice = $result;
1303 $result = $facture->addline(
1335 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1339 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1343 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1348 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
1351 $triggersendname =
'PRODUCT_SENTBYMAIL';
1353 $autocopy =
'MAIN_MAIL_AUTOCOPY_PRODUCT_TO';
1354 $trackid =
'prod'.$object->id;
1355 include DOL_DOCUMENT_ROOT.
'/core/actions_sendmails.inc.php';
1368$formaccounting =
null;
1372$sellOrEatByMandatoryList =
null;
1379 if ($disableSellBy) {
1380 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_BY]);
1381 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1383 if ($disableEatBy) {
1384 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_EAT_BY]);
1385 unset($sellOrEatByMandatoryList[Product::SELL_OR_EAT_BY_MANDATORY_ID_SELL_AND_EAT]);
1389$title = $langs->trans(
'ProductServiceCard');
1394 if ($action ==
'create') {
1395 $title = $langs->trans(
"NewProduct");
1397 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1398 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1402 if ($action ==
'create') {
1403 $title = $langs->trans(
"NewService");
1405 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1406 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1410llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-card');
1414$modBarCodeProduct =
null;
1417 $dirbarcode = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
1418 foreach ($dirbarcode as $dirroot) {
1425 $modBarCodeProduct =
new $module();
1426 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
1430$canvasdisplayaction = $action;
1431if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
1432 $canvasdisplayaction =
'view';
1435if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
1439 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
1440 $objcanvas->display_canvas($canvasdisplayaction);
1445 if ($action ==
'create' && $usercancreate) {
1447 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1449 if (!empty(
$conf->use_javascript_ajax)) {
1450 print
'<script type="text/javascript">';
1451 print
'$(document).ready(function () {
1452 $("#selectcountry_id").change(function() {
1453 console.log("selectcountry_id change");
1454 document.formprod.action.value="create";
1455 document.formprod.submit();
1458 print
'</script>'.
"\n";
1462 $module =
getDolGlobalString(
'PRODUCT_CODEPRODUCT_ADDON',
'mod_codeproduct_leopard');
1463 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1464 $module = substr($module, 0,
dol_strlen($module) - 4);
1468 $modCodeProduct =
new $module();
1474 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1475 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1476 print
'<input type="hidden" name="action" value="add">';
1477 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1478 if (!empty($modCodeProduct->code_auto)) {
1479 print
'<input type="hidden" name="code_auto" value="1">';
1481 if (!empty($modBarCodeProduct->code_auto)) {
1482 print
'<input type="hidden" name="barcode_auto" value="1">';
1484 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1488 $title = $langs->trans(
"NewService");
1491 $title = $langs->trans(
"NewProduct");
1498 if (
$object->country_id > 0) {
1500 $object->country_code = $tmparray[
'code'];
1501 $object->country = $tmparray[
'label'];
1507 $parameters = array();
1509 $reshook = $hookmanager->executeHooks(
'tabContentCreateProduct', $parameters, $object, $action);
1510 if (empty($reshook)) {
1511 print
'<table class="border centpercent">';
1516 if (!empty($modCodeProduct->code_auto)) {
1518 $tmpcode = $modCodeProduct->getNextValue($object, $type);
1520 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans($refLabelKey).
'</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(
GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1521 if ($refalreadyexists) {
1522 print $langs->trans(
"RefAlreadyExists");
1528 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>';
1531 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1532 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1533 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1537 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1538 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1539 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1544 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1545 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1546 print $form->selectarray(
'status_batch', $statutarray,
GETPOSTINT(
'status_batch'));
1550 if ($status_batch !==
'0') {
1551 $langs->load(
"admin");
1552 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1553 $tooltip .= $langs->trans(
"GenericMaskCodes1");
1554 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1555 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1556 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1557 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1562 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1565 print
'<td id="field_mask">';
1566 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1,
'help');
1567 print
'<script type="text/javascript">
1568 $(document).ready(function() {
1569 $("#field_mask, #mask_option").addClass("hideobject");
1570 $("#status_batch").on("change", function () {
1571 console.log("We change batch status");
1572 var optionSelected = $("option:selected", this);
1573 var valueSelected = this.value;
1574 $("#field_mask, #mask_option").addClass("hideobject");
1578 if (this.value == 1) {
1579 $("#field_mask, #mask_option").toggleClass("hideobject");
1580 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1586 if (this.value == 2) {
1587 $("#field_mask, #mask_option").toggleClass("hideobject");
1588 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1601 if (!empty($sellOrEatByMandatoryList)) {
1602 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
1603 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList,
GETPOSTINT(
'sell_or_eat_by_mandatory'));
1609 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
1616 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1618 $fk_barcode_type =
GETPOST(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type') : 0;
1623 $fk_barcode_type = 0;
1626 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1628 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1633 print
'<td'.((is_object($modBarCodeProduct) && $modBarCodeProduct->code_null) ?
'' :
' class="fieldrequired"').
'>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1635 if (empty($tmpcode) && is_object($modBarCodeProduct) && !empty($modBarCodeProduct->code_auto)) {
1636 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
1638 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1639 print
'<input class="maxwidth150" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1644 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1645 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1646 $doleditor->Create();
1651 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1652 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1653 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1659 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1660 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1661 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1662 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOSTINT(
'type')).
'">';
1663 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1671 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1672 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1677 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1678 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1683 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1684 print
'<input name="desiredstock" type="hidden" value="0">';
1688 if ($type == $object::TYPE_SERVICE &&
isModEnabled(
"workstation")) {
1690 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1691 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1692 print $formproduct->selectWorkstations((
GETPOSTISSET(
'fk_default_workstation') ?
GETPOSTINT(
'fk_default_workstation') :
''),
'fk_default_workstation', 1);
1698 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1699 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1700 print
'<input name="duration_value" class="width50 valignmiddle" value="'.(GETPOSTISSET(
'duration_value') ?
GETPOST(
'duration_value') :
'').
'">';
1701 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
GETPOSTISSET(
'duration_unit') ?
GETPOST(
'duration_unit',
'alpha') :
'h'), 0, 1);
1704 if (
$object->duration_value > 0) {
1705 print
' ';
1707 print
'<input type="checkbox" class="marginleftonly valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.(GETPOSTISSET(
'mandatoryperiod') ?
' checked="checked"' :
'').
'>';
1708 print
'<label for="mandatoryperiod">';
1709 $htmltooltip = $langs->trans(
"mandatoryHelper");
1711 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
1713 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
1722 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1731 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1732 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1733 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1734 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);
1740 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1741 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1742 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1743 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1744 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1745 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') : (
GETPOST(
'size_units',
'alpha') ?:
'0'), 0, 2);
1750 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1751 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1752 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') : (
GETPOST(
'surface_units',
'alpha') ?:
'0'), 0, 2);
1757 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1758 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1759 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') : (
GETPOST(
'volume_units',
'alpha') ?:
'0'), 0, 2);
1765 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1766 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1767 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);
1774 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1782 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>';
1785 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1787 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1788 print $form->select_country((
GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1790 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1798 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1800 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
1803 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1804 print $formcompany->select_state(
$object->state_id,
$object->country_code);
1811 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1812 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1816 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
1817 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
1818 print $hookmanager->resPrint;
1819 if (empty($reshook)) {
1820 print
$object->showOptionals($extrafields,
'create', $parameters);
1824 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1827 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1828 $doleditor->Create();
1834 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1835 print $form->selectCategories(Categorie::TYPE_PRODUCT,
'categories', $object);
1847 print
'<table class="border centpercent">';
1849 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1851 print $form->load_tva(
"tva_tx", $defaultva,
$mysoc,
$mysoc, 0, 0,
'',
false, 1);
1859 print
'<table class="border centpercent">';
1862 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1863 print
'<td><input name="price" class="maxwidth50" value="'.(GETPOSTISSET(
'price') ?
GETPOST(
'price') :
$object->
price).
'">';
1864 print $form->selectPriceBaseType(
getDolGlobalString(
'PRODUCT_PRICE_BASE_TYPE'),
"price_base_type");
1869 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1870 print
'<td><input name="price_min" class="maxwidth50" value="'.(GETPOSTISSET(
'price_min') ?
GETPOST(
'price_min') :
$object->price_min).
'">';
1874 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1876 print $form->load_tva(
"tva_tx", $defaultva,
$mysoc,
$mysoc, 0, 0,
'',
false, 1);
1887 print
'<!-- accountancy codes -->'.
"\n";
1888 print
'<table class="border centpercent">';
1891 if (
isModEnabled(
'accounting') && is_object($formaccounting)) {
1894 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1901 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1906 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1909 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1911 $accountancy_code_sell_intra = (
GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1913 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1918 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1921 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1923 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1925 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1929 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1932 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1934 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1936 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1941 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1944 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1946 $accountancy_code_buy_intra = (
GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1948 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1953 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1956 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1958 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1960 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1, array(), 1, 1,
'minwidth150 maxwidth300',
'1');
1963 if (!empty($accountancy_code_sell)) {
1964 $object->accountancy_code_sell = $accountancy_code_sell;
1966 if (!empty($accountancy_code_sell_intra)) {
1967 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1969 if (!empty($accountancy_code_sell_export)) {
1970 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1972 if (!empty($accountancy_code_buy)) {
1973 $object->accountancy_code_buy = $accountancy_code_buy;
1975 if (!empty($accountancy_code_buy_intra)) {
1976 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1978 if (!empty($accountancy_code_buy_export)) {
1979 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1983 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1984 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1989 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1990 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1995 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1996 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
2000 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2001 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
2006 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2007 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
2012 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2013 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
2022 print $form->buttonsSaveCancel(
"Create");
2026 $iskit =
$object->hasFatherOrChild(1);
2029 if ($action ==
'edit' && $usercancreate) {
2031 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
2033 if (!empty(
$conf->use_javascript_ajax)) {
2034 print
'<script type="text/javascript">';
2035 print
'$(document).ready(function () {
2036 $("#selectcountry_id").change(function () {
2037 document.formprod.action.value="edit";
2038 document.formprod.submit();
2041 print
'</script>'.
"\n";
2048 $object->country_code = $tmparray[
'code'];
2049 $object->country = $tmparray[
'label'];
2052 $type = $langs->trans(
'Product');
2054 $type = $langs->trans(
'Service');
2059 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="formprod">'.
"\n";
2060 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2061 print
'<input type="hidden" name="action" value="update">';
2062 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
2063 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
2066 $titre = $langs->trans(
"CardProduct".
$object->type);
2068 print
dol_get_fiche_head($head,
'card', $titre, 0, $picto, 0,
'',
'', 0,
'', 1);
2071 $parameters = array();
2073 $reshook = $hookmanager->executeHooks(
'tabContentEditProduct', $parameters, $object, $action);
2075 if (empty($reshook)) {
2076 print
'<table class="border allwidth">';
2080 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>';
2082 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>';
2086 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>';
2089 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
2090 print
'<select class="flat" name="statut">';
2092 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
2093 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
2095 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
2096 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
2102 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
2103 print
'<select class="flat" name="statut_buy">';
2105 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2106 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2108 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2109 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2117 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2118 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
2122 print
'<span id="statusBatchWarning" class="warning" style="display: none;">';
2123 print
img_warning().
' '.$langs->trans(
"WarningConvertFromBatchToSerial").
'</span>';
2125 print
'<span id="statusBatchMouvToGlobal" class="warning" style="display: none;">';
2126 print
img_warning().
' '.$langs->trans(
"WarningTransferBatchStockMouvToGlobal").
'</span>';
2130 print
'<script type="text/javascript">
2131 $(document).ready(function() {
2132 console.log($("#statusBatchWarning"))
2133 $("#status_batch").on("change", function() {
2134 if ($("#status_batch")[0].value == 0) {
2135 $("#statusBatchMouvToGlobal").show()
2137 $("#statusBatchMouvToGlobal").hide()
2143 if (
$object->status_batch == 1) {
2144 print
'<script type="text/javascript">
2145 $(document).ready(function() {
2146 console.log($("#statusBatchWarning"))
2147 $("#status_batch").on("change", function() {
2148 if ($("#status_batch")[0].value == 2) {
2149 $("#statusBatchWarning").show()
2151 $("#statusBatchWarning").hide()
2159 if (!empty(
$object->status_batch) || !empty(
$conf->use_javascript_ajax)) {
2160 $langs->load(
"admin");
2161 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2162 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
2163 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
2164 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2165 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
2168 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
2178 print
'<td id="field_mask">';
2179 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1,
'help');
2181 if (!empty(
$conf->use_javascript_ajax)) {
2182 print
'<script type="text/javascript">
2183 $(document).ready(function() {
2184 $("#field_mask").parent().addClass("hideobject");
2185 var preselect = document.getElementById("status_batch");';
2187 print
'if (preselect.value == "2") {
2188 $("#field_mask").parent().removeClass("hideobject");
2192 print
'if (preselect.value == "1") {
2193 $("#field_mask").parent().removeClass("hideobject");
2196 print
'$("#status_batch").on("change", function () {
2197 var optionSelected = $("option:selected", this);
2198 var valueSelected = this.value;
2199 $("#field_mask").parent().addClass("hideobject");
2203 if (this.value == 1) {
2204 $("#field_mask").parent().removeClass("hideobject");
2205 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
2211 if (this.value == 2) {
2212 $("#field_mask").parent().removeClass("hideobject");
2213 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2227 if (!empty($sellOrEatByMandatoryList)) {
2229 $sellOrEatByMandatorySelectedId =
GETPOSTINT(
'sell_or_eat_by_mandatory');
2231 $sellOrEatByMandatorySelectedId =
$object->sell_or_eat_by_mandatory;
2233 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2234 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList, $sellOrEatByMandatorySelectedId);
2241 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2246 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2248 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2250 $fk_barcode_type =
$object->barcode_type;
2255 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2257 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2259 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2261 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2262 $tmpcode = $modBarCodeProduct->getNextValue($object, $fk_barcode_type);
2264 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2269 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2272 $doleditor =
new DolEditor(
'desc',
GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') :
$object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2273 $doleditor->Create();
2280 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2281 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2282 print
'<input type="text" name="url" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') :
$object->url).
'">';
2289 print
'<tr><td><input type="hidden" id="stockable_product" name="stockable_product" value="on" /></td><td></td></tr>';
2291 print
'<tr><td><label for="stockable_product">' . $langs->trans(
"StockableProduct") .
'</label></td>';
2292 $checked = empty(
$object->stockable_product) ?
"" :
"checked";
2293 print
'<td><input type="checkbox" id="stockable_product" name="stockable_product" '. $checked .
' /></td></tr>';
2297 print
'<tr class="showifstockable'.(empty(
$object->stockable_product) ?
' hidden' :
'').
'"><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2298 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2299 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');
2300 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int)
$object->id)).
'">';
2301 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2317 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2318 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2319 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
2332 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2333 print
'<input name="duration_value" class="width50" value="'.($object->duration_value ?
$object->duration_value :
'').
'"> ';
2335 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (
$object->duration_unit ?
$object->duration_unit :
'h'), 0, 1);
2339 print
' ';
2341 print
'<input type="checkbox" class="valignmiddle" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2342 print
'<label for="mandatoryperiod">';
2343 $htmltooltip = $langs->trans(
"mandatoryHelper");
2345 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2347 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
2354 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2361 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2362 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int)
$object->id).
')';
2363 print
img_picto($langs->trans(
"DefaultBOM"),
'bom',
'class="pictofixedwidth"');
2364 print $form->selectForForms($bomkey,
'fk_default_bom', (
GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') :
$object->fk_default_bom), 1);
2371 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2372 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') :
$object->weight).
'"> ';
2373 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight",
GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') : (int)
$object->weight_units, 0, 2);
2379 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2380 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') :
$object->length).
'">x';
2381 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') :
$object->width).
'">x';
2382 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') :
$object->height).
'"> ';
2383 print $formproduct->selectMeasuringUnits(
"size_units",
"size",
GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') : (int)
$object->length_units, 0, 2);
2388 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2389 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') :
$object->surface).
'"> ';
2390 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface",
GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') : (int)
$object->surface_units, 0, 2);
2395 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2396 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') :
$object->volume).
'"> ';
2397 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume",
GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') : (int)
$object->volume_units, 0, 2);
2403 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2404 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') :
$object->net_measure).
'"> ';
2405 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"",
GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') : (int)
$object->net_measure_units, 0, 0);
2411 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2413 print $form->selectUnits(
$object->fk_unit,
'units');
2419 print
'<tr><td class="wordbreak">'.$form->textwithpicto($langs->trans(
"CustomsCode"), $langs->trans(
"CustomsCodeHelp")).
'</td>';
2420 print
'<td>' .
img_picto(
'',
'fa-clipboard-check',
'class="pictofixedwidth"') .
'<input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') :
$object->customcode).
'"></td></tr>';
2422 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2424 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
2425 print $form->select_country((
string) (
GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2427 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2435 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2437 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'', $object, 0).
'</td><td>';
2440 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2449 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.
$object->lifetime.
'"></td></tr>';
2450 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.
$object->qc_frequency.
'"></td></tr>';
2454 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2455 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters, $object, $action);
2456 print $hookmanager->resPrint;
2457 if (empty($reshook)) {
2458 print
$object->showOptionals($extrafields,
'edit', $parameters);
2463 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2464 print $form->selectCategories(Categorie::TYPE_PRODUCT,
'categories', $object);
2470 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2472 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2473 $doleditor->Create();
2483 print
'<table class="border centpercent">';
2489 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2491 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');
2492 $nb = $formaccounting->nbaccounts;
2494 print
' <a href="'.DOL_URL_ROOT.
'/accountancy/admin/account.php">'.$langs->trans(
"SetupOn", $langs->trans(
"Chartofaccounts")).
'</a>';
2500 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2502 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');
2507 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2509 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');
2513 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2515 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');
2520 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2522 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');
2527 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2529 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');
2534 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2535 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell).
'">';
2540 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2541 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).
'">';
2546 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2547 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).
'">';
2551 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2552 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy).
'">';
2557 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2558 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).
'">';
2563 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2564 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).
'">';
2573 print
'$(document).ready(function() {
2574 $("#stockable_product").change(function() {
2575 $(".showifstockable").toggle(this.checked);
2584 print $form->buttonsSaveCancel();
2591 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2596 $titre = $langs->trans(
"CardProduct".
$object->type);
2599 print
dol_get_fiche_head($head,
'card', $titre, -1, $picto, 0,
'',
'', 0,
'', 1);
2601 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2602 $object->next_prev_filter =
"(te.fk_product_type:=:".((int)
$object->type).
")";
2605 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
2609 dol_banner_tab($object,
'ref', $linkback, $shownav,
'ref');
2612 $parameters = array();
2614 $reshook = $hookmanager->executeHooks(
'tabContentViewProduct', $parameters, $object, $action);
2615 if (empty($reshook)) {
2616 print
'<div class="fichecenter">';
2617 print
'<div class="fichehalfleft">';
2619 print
'<div class="underbanner clearboth"></div>';
2620 print
'<table class="border tableforfield centpercent">';
2624 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2625 print
'<tr><td class="titlefieldmiddle">';
2626 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type', (
string)
$object->type, $object, (
int) $usercancreate, $typeformat) : $langs->trans(
'Type');
2628 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type, $object, $usercancreate, $typeformat);
2634 print
'<tr><td class="titlefieldmiddle nowrap">';
2635 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
2636 print $langs->trans(
"BarcodeType");
2638 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2639 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>';
2641 print
'</tr></table>';
2643 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2644 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2648 $fk_barcode_type =
'';
2649 if ($action ==
'editbarcodetype' && is_object($formbarcode)) {
2650 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->barcode_type,
'fk_barcode_type');
2651 $fk_barcode_type =
$object->barcode_type;
2654 $fk_barcode_type =
$object->barcode_type;
2655 print
$object->barcode_type_label ?
$object->barcode_type_label : (
$object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2657 print
'</td></tr>'.
"\n";
2660 print
'<tr><td class="nowrap">';
2661 print
'<table class="centpercent nobordernopadding"><tr><td class="nowrap">';
2662 print $langs->trans(
"BarcodeValue");
2664 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2665 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>';
2667 print
'</tr></table>';
2668 print
'</td><td class="wordbreak">';
2669 if ($action ==
'editbarcode') {
2671 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2672 $tmpcode = $modBarCodeProduct->getNextValue($object, (
string) $fk_barcode_type);
2675 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
2676 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2677 print
'<input type="hidden" name="action" value="setbarcode">';
2678 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2679 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2680 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2685 print
'</td></tr>'.
"\n";
2690 print
'<tr><td class="titlefieldmiddle">' . $form->textwithpicto($langs->trans(
"StockableProduct"), $langs->trans(
'StockableProductDescription')) .
'</td>';
2693 print
'<input type="checkbox" readonly disabled> <span class="opacitymedium">' . $langs->trans(
"NotSupportedOnKits").
'</span>';
2695 print
'<input type="checkbox" readonly disabled '.($object->stockable_product == 1 ?
'checked' :
'').
'>';
2699 if (
$object->isStockManaged() && !$iskit) {
2701 $warehouse->fetch(
$object->fk_default_warehouse);
2703 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2704 print(!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2712 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2713 if (
$object->status_batch == 0) {
2714 print
'<span class="opacitymedium">'.yn(0).
'</span>';
2716 print
$object->getLibStatut(0, 2);
2721 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2727 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2728 if (
$object->sell_or_eat_by_mandatory == $object::SELL_OR_EAT_BY_MANDATORY_ID_NONE) {
2729 print
'<span class="opacitymedium">'.yn(0).
'</span>';
2731 print
$object->getSellOrEatByMandatoryLabel();
2738 $collapse = !empty($_COOKIE[
'DOLUSER_COLLAPSE_product_separator_accounting']);
2740 print
'<tr id="trseparatoraccounting" class="trseparator trseparatoraccounting">';
2741 print
'<td class="titlefieldmiddle firstcol"><span class="cursorpointer far fa-'.($collapse ?
'plus' :
'minus').
'-square"></span> <strong>'.$langs->trans(
"AccountancyCodes").
'</strong></td>';
2742 print
'<td class="secondcol">';
2743 $nbOfAccountingCodes = 0;
2744 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_sell)) ? 1 : 0;
2745 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_sell_intra)) ? 1 : 0;
2746 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_sell_export)) ? 1 : 0;
2747 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_buy)) ? 1 : 0;
2748 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_buy_intra)) ? 1 : 0;
2749 $nbOfAccountingCodes += (
isModEnabled(
'accounting') && !empty(
$object->accountancy_code_buy_export)) ? 1 : 0;
2750 print
'<span class="badge badge-secondary'.($collapse ?
'' :
' hidden').
'">'.$nbOfAccountingCodes.
'</span>';
2753 print
'<!-- Add js script to manage the collapse/uncollapse of separator accounting -->
2754 <script nonce="'.getNonce().
'" type="text/javascript">
2755 jQuery(document).ready(function(){
2756 console.log("Inject js for collapsing of separatoraccounting - keep visible and set cookie");
2757 /* document.cookie = "DOLUSER_COLLAPSE_product_separator_accounting=1; path='.DOL_URL_ROOT.
'/product/card.php"; */
2758 jQuery("#trseparatoraccounting").click(function(){
2759 console.log("We click on collapse/uncollapse to hide/show .tr_collapseaccounting");
2760 jQuery(".tr_collapseaccounting").toggle(100, function(){
2761 if (jQuery(".tr_collapseaccounting").first().is(":hidden")) {
2762 jQuery("#trseparatoraccounting td.firstcol span").addClass("fa-plus-square").removeClass("fa-minus-square");
2763 jQuery("#trseparatoraccounting td.secondcol span").removeClass("hidden");
2764 document.cookie = "DOLUSER_COLLAPSE_product_separator_accounting=1; path='.DOL_URL_ROOT.
'/product/card.php"
2766 jQuery("#trseparatoraccounting td.firstcol span").addClass("fa-minus-square").removeClass("fa-plus-square");
2767 jQuery("#trseparatoraccounting td.secondcol span").addClass("hidden");
2768 document.cookie = "DOLUSER_COLLAPSE_product_separator_accounting=0; path='.DOL_URL_ROOT.
'/product/card.php"
2776 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2777 print $langs->trans(
"ProductAccountancySellCode");
2780 if (!empty(
$object->accountancy_code_sell)) {
2782 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
2784 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2793 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2794 print $langs->trans(
"ProductAccountancySellIntraCode");
2797 if (!empty(
$object->accountancy_code_sell_intra)) {
2799 $accountingaccount2->fetch(0,
$object->accountancy_code_sell_intra, 1);
2801 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2810 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2811 print $langs->trans(
"ProductAccountancySellExportCode");
2814 if (!empty(
$object->accountancy_code_sell_export)) {
2816 $accountingaccount3->fetch(0,
$object->accountancy_code_sell_export, 1);
2818 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2826 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2827 print $langs->trans(
"ProductAccountancyBuyCode");
2830 if (!empty(
$object->accountancy_code_buy)) {
2832 $accountingaccount4->fetch(0,
$object->accountancy_code_buy, 1);
2834 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2843 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2844 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2847 if (!empty(
$object->accountancy_code_buy_intra)) {
2849 $accountingaccount5->fetch(0,
$object->accountancy_code_buy_intra, 1);
2851 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2860 print
'<tr class="tr_collapseaccounting'.($collapse ?
' hidden' :
'').
'"><td class="nowrap">';
2861 print $langs->trans(
"ProductAccountancyBuyExportCode");
2864 if (!empty(
$object->accountancy_code_buy_export)) {
2866 $accountingaccount6->fetch(0,
$object->accountancy_code_buy_export, 1);
2868 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2877 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
2878 print
'<td class="wordbreakimp wrapimp"><div class="longmessagecut">'.(dol_textishtml(
$object->description) ?
$object->description :
dol_nl2br(
$object->description, 1,
true)).
'</div></td></tr>';
2882 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2889 $res = $workstation->fetch(
$object->fk_default_workstation);
2891 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2892 print(!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2900 if ($combination->fetchByFkProductChild(
$object->id) > 0) {
2902 $prodstatic->fetch($combination->fk_product_parent);
2905 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2906 print $prodstatic->getNomUrl(1);
2914 print
'<div class="fichehalfright">';
2915 print
'<div class="underbanner clearboth"></div>';
2917 print
'<table class="border tableforfield centpercent">';
2921 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2922 print $form->showCategories(
$object->id, Categorie::TYPE_PRODUCT, 1);
2928 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
2932 if (
$object->duration_value > 1) {
2935 $result = $measuringUnits->fetchAll(
'',
'scale', 0, 0, [
't.active' => 1,
't.unit_type' =>
'time']);
2936 if ($result !== -1) {
2937 foreach ($measuringUnits->records as $record) {
2938 $durations[$record->short_label] =
dol_ucfirst((
string) $record->label) . $plural;
2941 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Duration").
'</td><td>';
2942 if (
$object->duration_value) {
2943 print
$object->duration_value;
2944 print(!empty(
$object->duration_unit) && isset($durations[
$object->duration_unit]) ?
" ".$langs->trans($durations[
$object->duration_unit]).
" " :
'');
2948 $htmltooltip = $langs->trans(
"mandatoryHelper");
2950 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2952 if (
$object->duration_value > 0) {
2953 print
' ';
2955 print
'<input type="checkbox" class="valignmiddle" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2956 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1,
'info');
2962 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2963 print
$object->getLibFinished();
2969 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2970 if (
$object->fk_default_bom) {
2971 $bom_static =
new BOM(
$db);
2972 $bom_static->fetch(
$object->fk_default_bom);
2973 print $bom_static->getNomUrl(1);
2981 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Weight").
'</td><td>';
2987 print
"</td></tr>\n";
2992 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2996 print
" x ".$object->width;
2999 print
" x ".$object->height;
3001 print
' '.measuringUnitString(0,
"size",
$object->length_units);
3005 print
"</td></tr>\n";
3010 print(
getDolGlobalString(
'PRODUCT_DISABLE_SURFACE') ?
'' : $langs->trans(
"Surface"));
3012 print (
getDolGlobalString(
'PRODUCT_DISABLE_VOLUME') ?
'' : $langs->trans(
"Volume")).
'</td><td>';
3020 print
"</td></tr>\n";
3025 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"NetMeasure").
'</td><td>';
3026 if (
$object->net_measure !=
'') {
3037 $unit =
$object->getLabelOfUnit(
'long', $langs);
3039 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
3046 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"CustomsCode"), $langs->trans(
"CustomsCodeHelp")).
'</td><td>'.
dolPrintHTML(
$object->customcode).
'</td></tr>';
3050 if (!empty(
$object->state_id)) {
3051 print
' - '.getState(
$object->state_id,
'0',
$db);
3058 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.
$object->lifetime.
'</td></tr>';
3059 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.
$object->qc_frequency.
'</td></tr>';
3063 $parameters = array();
3064 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
3068 print
'<!-- show Note --> '.
"\n";
3070 print
'<!-- End show Note --> '.
"\n";
3077 print
'<div class="clearboth"></div>';
3082 } elseif ($action !=
'create') {
3088if (!empty($modCodeProduct->code_auto)) {
3090 $tmpcode = $modCodeProduct->getNextValue($object,
$object->type);
3096if (($action ==
'delete' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
3097 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
3098 $formconfirm = $form->formconfirm(
"card.php?id=".
$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
3100if ($action ==
'merge') {
3101 $formquestion = array(
3103 'name' =>
'product_origin',
3104 'label' => $langs->trans(
'MergeOriginProduct'),
3106 'value' => $form->select_produits(0,
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
3109 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
3113if (($action ==
'clone' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
3114 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
3116 $formquestionclone = array(
3117 'text' => $langs->trans(
"ConfirmClone"),
3118 0 => array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->ref : $tmpcode,
'morecss' =>
'width150'),
3119 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
3120 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
3123 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
3126 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
3128 if (
isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
3129 if (
$object->fk_default_bom > 0) {
3130 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_defbom',
'label' => $langs->trans(
"CloneDefBomProduct"),
'value' =>
getDolGlobalInt(
'BOM_CLONE_DEFBOM'));
3132 $bomstatic =
new BOM(
$db);
3133 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
3134 if (is_array($bomlist) && count($bomlist) > 0) {
3135 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_otherboms',
'label' => $langs->trans(
"CloneOtherBomsProduct"),
'value' => 0);
3138 $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);
3142$parameters = array(
'formConfirm' => $formconfirm,
'object' => $object);
3143$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters, $object, $action);
3144if (empty($reshook)) {
3145 $formconfirm .= $hookmanager->resPrint;
3146} elseif ($reshook > 0) {
3147 $formconfirm = $hookmanager->resPrint;
3156if ($action !=
'create' && $action !=
'edit') {
3157 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
3158 $cloneButtonId =
'action-clone-no-ajax';
3160 print
"\n".
'<div class="tabsAction">'.
"\n";
3162 $parameters = array();
3163 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters, $object, $action);
3164 if (empty($reshook)) {
3165 if ($usercancreate) {
3166 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
3171 print
dolGetButtonAction(
'', $langs->trans(
'SendMail'),
'email', $_SERVER[
"PHP_SELF"] .
'?id=' .
$object->id .
'&action=presend&mode=init&token=' .
newToken() .
'#formmailbeforetitle');
3173 if (!isset($hookmanager->resArray[
'no_button_copy']) || $hookmanager->resArray[
'no_button_copy'] != 1) {
3174 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3175 $cloneProductUrl =
'';
3176 $cloneButtonId =
'action-clone';
3178 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'clone', $cloneProductUrl, $cloneButtonId, $usercancreate);
3183 if ($usercandelete) {
3184 if (empty($object_is_used)) {
3185 if (!isset($hookmanager->resArray[
'no_button_delete']) || $hookmanager->resArray[
'no_button_delete'] != 1) {
3186 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3187 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
3193 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3196 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'&token='.
newToken().
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
3199 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3217 if (
isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
3220 $langs->load(
"propal");
3222 $otherprop = $propal->liste_array(2, 1, 0);
3224 if (is_array($otherprop) && count($otherprop)) {
3225 $html .=
'<tr><td style="width: 200px;">';
3226 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3227 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
3228 $html .=
'</td></tr>';
3230 $html .=
'<tr><td style="width: 200px;">';
3231 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3232 $html .= $langs->trans(
"NoDraftProposals");
3233 $html .=
'</td></tr>';
3238 if (
isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
3241 $langs->load(
"orders");
3243 $othercom = $commande->liste_array(2, 1,
null);
3244 if (is_array($othercom) && count($othercom)) {
3245 $html .=
'<tr><td style="width: 200px;">';
3246 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3247 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
3248 $html .=
'</td></tr>';
3250 $html .=
'<tr><td style="width: 200px;">';
3251 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3252 $html .= $langs->trans(
"NoDraftOrders");
3253 $html .=
'</td></tr>';
3258 if (
isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
3261 $langs->load(
"bills");
3263 $otherinvoice = $invoice->liste_array(2, 1,
null);
3264 if (is_array($otherinvoice) && count($otherinvoice)) {
3265 $html .=
'<tr><td style="width: 200px;">';
3266 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3267 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
3268 $html .=
'</td></tr>';
3270 $html .=
'<tr><td style="width: 200px;">';
3271 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3272 $html .= $langs->trans(
"NoDraftInvoices");
3273 $html .=
'</td></tr>';
3278 if (!empty($html)) {
3279 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
3280 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3281 print
'<input type="hidden" name="action" value="addin">';
3287 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
3288 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
3289 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
3290 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
3291 $html .=
'</td></tr>';
3293 print
'<table class="centpercent border">';
3297 print
'<div class="center">';
3298 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
3312if (
GETPOST(
'modelselected')) {
3313 $action =
'presend';
3316if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
3317 print
'<div class="fichecenter"><div class="fichehalfleft">';
3318 print
'<a name="builddoc"></a>';
3322 if (!empty(
$conf->product->multidir_output[
$object->entity ??
$conf->entity])) {
3323 $filedir =
$conf->product->multidir_output[
$object->entity ??
$conf->entity].
'/'.$objectref;
3325 $filedir =
$conf->product->dir_output.
'/'.$objectref;
3327 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3328 $genallowed = $usercanread;
3329 $delallowed = $usercancreate;
3331 print $formfile->showdocuments($modulepart,
$object->ref, $filedir, $urlsource, (
int) $genallowed, (
int) $delallowed,
'', 0, 0, 0, 28, 0,
'',
'',
'', $langs->getDefaultLang(),
'', $object);
3332 $somethingshown = $formfile->numoffiles;
3334 print
'</div><div class="fichehalfright">';
3337 $morehtmlcenter =
'<div class="nowraponall">';
3338 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/product/messaging.php?id='.
$object->id);
3339 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
3340 $morehtmlcenter .=
'</div>';
3343 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3345 $somethingshown = $formactions->showactions($object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3347 print
'</div></div>';
3350 $modelmail =
'product_send';
3351 $defaulttopic =
$object->label;
3353 $trackid =
'prod' .
$object->id;
3355 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.
dolPrintHTML($s, $allowiframe=0, $moreallowedtags=array())
Return a string (that can be on several lines) ready to be output on a HTML page.
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.
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'.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
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.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
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.
GETPOSTISSET($paramname)
Return true if we are in a context of submitting the parameter $paramname from a POST of a form.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
isModEnabled($module)
Is Dolibarr module enabled.
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...
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='', $textonpictotooltip='', $cssfordropdown='info_admin')
Show information in HTML for admin users or standard users.
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...
print $langs trans("Show") . '< td style="' . $timeColor . '" align="center"> s</td > badge status0 badge status4 badge status3 Error badge status8< td align="center">< span class="badge ' . $badge . '"></span ></td >< td align="center">< a href="#" class="button button-small" onclick="openLogModal(this)" data-req="' . dol_escape_htmltag($reqSafe) . '" data-res="' . dol_escape_htmltag($resSafe) . '" data-err="' . dol_escape_htmltag($errSafe) . '">< span class="fa fa-search-plus"></span ></a ></td ></tr >< tr >< td colspan="' . $colspan . '" class="opacitymedium"></td ></tr ></table ></div ></form > logModal none logModal none s a JSON string
buildzip.php
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.