47require
'../main.inc.php';
48require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
49require_once DOL_DOCUMENT_ROOT.
'/core/class/extrafields.class.php';
50require_once DOL_DOCUMENT_ROOT.
'/core/class/genericobject.class.php';
51require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formcompany.class.php';
52require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formfile.class.php';
53require_once DOL_DOCUMENT_ROOT.
'/core/lib/company.lib.php';
54require_once DOL_DOCUMENT_ROOT.
'/core/lib/product.lib.php';
55require_once DOL_DOCUMENT_ROOT.
'/core/modules/product/modules_product.class.php';
56require_once DOL_DOCUMENT_ROOT.
'/categories/class/categorie.class.php';
57require_once DOL_DOCUMENT_ROOT.
'/product/class/html.formproduct.class.php';
58require_once DOL_DOCUMENT_ROOT.
'/product/class/product.class.php';
69if (isModEnabled(
'propal')) {
70 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
72if (isModEnabled(
'invoice')) {
73 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
75if (isModEnabled(
'order')) {
76 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
78if (isModEnabled(
'accounting')) {
79 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
80 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
81 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
83if (isModEnabled(
'bom')) {
84 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
87if (isModEnabled(
'workstation')) {
88 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
92$langs->loadLangs(array(
'products',
'other'));
93if (isModEnabled(
'stock')) {
94 $langs->load(
"stocks");
96if (isModEnabled(
'invoice')) {
97 $langs->load(
"bills");
99if (isModEnabled(
'productbatch')) {
100 $langs->load(
"productbatch");
107$refalreadyexists = 0;
113 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'nohtml') : null);
115 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alpha') : null);
118$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
119$cancel =
GETPOST(
'cancel',
'alpha');
120$backtopage =
GETPOST(
'backtopage',
'alpha');
121$confirm =
GETPOST(
'confirm',
'alpha');
123$duration_value =
GETPOSTINT(
'duration_value');
124$duration_unit =
GETPOST(
'duration_unit',
'alpha');
126$accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
127$accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
128$accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
129$accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
130$accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
131$accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
133$checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
137 $label_security_check =
'nohtml';
139 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
142if (!empty($user->socid)) {
143 $socid = $user->socid;
148if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
149 $module = substr($module, 0,
dol_strlen($module) - 4);
153 $modCodeProduct =
new $module();
161$extrafields->fetch_name_optionals_label(
$object->table_element);
163if ($id > 0 || !empty($ref)) {
164 $result =
$object->fetch($id, $ref);
169 if (isModEnabled(
"product")) {
170 $upload_dir =
$conf->product->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
171 } elseif (isModEnabled(
"service")) {
172 $upload_dir =
$conf->service->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
176 if (isModEnabled(
"product")) {
177 $upload_dirold =
$conf->product->multidir_output[$entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
179 $upload_dirold =
$conf->service->multidir_output[$entity].
'/'.substr(substr(
"000".
$object->id, -2), 1, 1).
'/'.substr(substr(
"000".
$object->id, -2), 0, 1).
'/'.
$object->id.
"/photos";
184$modulepart =
'product';
189if (!empty($canvas)) {
190 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
191 $objcanvas =
new Canvas($db, $action);
192 $objcanvas->getCanvas(
'product',
'card', $canvas);
196$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
197$fieldtype = (!empty($id) ?
'rowid' :
'ref');
200$hookmanager->initHooks(array(
'productcard',
'globalcard'));
203 if (
$object->type == $object::TYPE_PRODUCT) {
206 if (
$object->type == $object::TYPE_SERVICE) {
210 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
227$createbarcode = isModEnabled(
'barcode');
228if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'creer_advance')) {
232$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
233$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
238if (empty($reshook)) {
239 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
241 if (empty($backtopage) || ($cancel && empty($id))) {
242 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
243 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
244 $backtopage = $backurlforlist;
246 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
252 if (!empty($backtopageforcancel)) {
253 header(
"Location: ".$backtopageforcancel);
255 } elseif (!empty($backtopage)) {
256 header(
"Location: ".$backtopage);
262 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
264 $productOriginId =
GETPOSTINT(
'product_origin');
265 $productOrigin =
new Product($db);
267 if ($productOriginId <= 0) {
268 $langs->load(
'errors');
269 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
271 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
281 $listofproperties = array(
291 'accountancy_code_buy',
292 'accountancy_code_buy_intra',
293 'accountancy_code_buy_export',
294 'accountancy_code_sell',
295 'accountancy_code_sell_intra',
296 'accountancy_code_sell_export'
298 foreach ($listofproperties as $property) {
299 if (empty(
$object->$property)) {
300 $object->$property = $productOrigin->$property;
304 $listofproperties = array(
305 'note_public',
'note_private'
307 foreach ($listofproperties as $property) {
312 if (is_array($productOrigin->array_options)) {
313 foreach ($productOrigin->array_options as $key => $val) {
314 if (empty(
$object->array_options[$key])) {
315 $object->array_options[$key] = $val;
322 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
323 $custcats = $static_cat->containing(
$object->id,
'product',
'id');
324 $custcats = array_merge($custcats, $custcats_ori);
325 $object->setCategories($custcats);
328 if ($productOrigin->barcode ==
$object->barcode) {
329 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
330 $productOrigin->barcode =
'';
346 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
347 'Bom' =>
'/bom/class/bom.class.php',
350 'Commande' =>
'/commande/class/commande.class.php',
351 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
352 'Contrat' =>
'/contrat/class/contrat.class.php',
353 'Delivery' =>
'/delivery/class/delivery.class.php',
354 'Facture' =>
'/compta/facture/class/facture.class.php',
355 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
356 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
357 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
358 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
359 'Propal' =>
'/comm/propal/class/propal.class.php',
360 'Reception' =>
'/reception/class/reception.class.php',
361 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
365 foreach ($objects as $object_name => $object_file) {
366 require_once DOL_DOCUMENT_ROOT.$object_file;
368 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id,
$object->id)) {
378 $parameters = array(
'soc_origin' => $productOrigin->id,
'soc_dest' =>
$object->id);
379 $reshook = $hookmanager->executeHooks(
396 'mergefromid' => $productOrigin->id,
400 $result =
$object->call_trigger(
'PRODUCT_MODIFY', $user);
411 if ($productOrigin->delete($user) < 1) {
420 $langs->load(
"errors");
429 if ($action ==
'setfk_product_type' && $usercancreate) {
430 $result =
$object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
431 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
436 $upload_dir =
$conf->product->dir_output;
437 $permissiontoadd = $usercancreate;
438 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
440 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
443 if ($action ==
'setfk_barcode_type' && $usercancreate) {
444 $result =
$object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
445 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
450 if ($action ==
'setbarcode' && $usercancreate) {
454 $result =
$object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
455 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
458 $langs->load(
"errors");
460 $errors[] =
'ErrorBadBarCodeSyntax';
461 } elseif ($result == -2) {
462 $errors[] =
'ErrorBarCodeRequired';
463 } elseif ($result == -3) {
464 $errors[] =
'ErrorBarCodeAlreadyUsed';
466 $errors[] =
'FailedToValidateBarCode';
475 if ($action ==
'update_extras' && $usercancreate) {
479 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
486 $result =
$object->insertExtraFields(
'PRODUCT_MODIFY');
494 $action =
'edit_extras';
499 if ($action ==
'add' && $usercancreate) {
502 if (!
GETPOST(
'label', $label_security_check)) {
503 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
509 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'ProductRef')),
null,
'errors');
514 if (!empty($duration_value) && empty($duration_unit)) {
515 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
527 $object->mandatory_period = !empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 1 : 0;
528 if (
$object->price_base_type ==
'TTC') {
533 if (
$object->price_base_type ==
'TTC') {
539 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
543 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
544 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
547 $localtax1_type =
'0';
548 $localtax2_type =
'0';
551 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
553 $vatratecode = $reg[1];
555 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
556 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
557 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
558 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
559 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
560 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
561 $resql = $db->query($sql);
563 $obj = $db->fetch_object($resql);
564 $npr = $obj->recuperableonly;
565 $localtax1 = $obj->localtax1;
566 $localtax2 = $obj->localtax2;
567 $localtax1_type = $obj->localtax1_type;
568 $localtax2_type = $obj->localtax2_type;
572 $object->default_vat_code = $vatratecode;
575 $object->localtax1_tx = $localtax1;
576 $object->localtax2_tx = $localtax2;
577 $object->localtax1_type = $localtax1_type;
578 $object->localtax2_type = $localtax2_type;
591 $stdobject->element =
'product';
592 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
593 $result = $stdobject->fetchBarCode();
596 $mesg =
'Failed to get bar code type information ';
599 $object->barcode_type_code = $stdobject->barcode_type_code;
600 $object->barcode_type_coder = $stdobject->barcode_type_coder;
601 $object->barcode_type_label = $stdobject->barcode_type_label;
612 $object->duration_value = $duration_value;
613 $object->duration_unit = $duration_unit;
632 if ($finished >= 0) {
645 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
646 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
647 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
648 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
649 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
650 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
652 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
653 $object->accountancy_code_sell =
'';
655 $object->accountancy_code_sell = $accountancy_code_sell;
657 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
658 $object->accountancy_code_sell_intra =
'';
660 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
662 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
663 $object->accountancy_code_sell_export =
'';
665 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
667 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
668 $object->accountancy_code_buy =
'';
670 $object->accountancy_code_buy = $accountancy_code_buy;
672 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
673 $object->accountancy_code_buy_intra =
'';
675 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
677 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
678 $object->accountancy_code_buy_export =
'';
680 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
686 for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
687 if (GETPOSTISSET(
"price_".$i)) {
689 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
691 $object->multiprices[
"$i"] =
"";
697 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
704 '@phan-var ModeleProductCode $modCodeProduct';
705 $ref = $modCodeProduct->getNextValue(
$object, $type);
714 $categories =
GETPOST(
'categories',
'array');
715 $object->setCategories($categories);
717 if (!empty($backtopage)) {
718 $backtopage = preg_replace(
'/__ID__/', (
string)
$object->id, $backtopage);
719 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
720 if (preg_match(
'/\?/', $backtopage)) {
721 $backtopage .=
'&productid='.$object->id;
724 header(
"Location: ".$backtopage);
727 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
734 if (
$object->error ==
'ErrorProductAlreadyExists') {
736 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters,
$object, $action);
755 if ($action ==
'update' && $usercancreate) {
756 if (
GETPOST(
'cancel',
'alpha')) {
812 if ($finished >= 0) {
818 $fk_default_bom =
GETPOSTINT(
'fk_default_bom');
819 if ($fk_default_bom >= 0) {
820 $object->fk_default_bom = $fk_default_bom;
836 $stdobject->element =
'product';
837 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
838 $result = $stdobject->fetchBarCode();
841 $mesg =
'Failed to get bar code type information ';
844 $object->barcode_type_code = $stdobject->barcode_type_code;
845 $object->barcode_type_coder = $stdobject->barcode_type_coder;
846 $object->barcode_type_label = $stdobject->barcode_type_label;
848 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
849 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
850 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
851 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
852 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
853 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
854 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
855 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
856 $object->accountancy_code_sell =
'';
858 $object->accountancy_code_sell = $accountancy_code_sell;
860 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
861 $object->accountancy_code_sell_intra =
'';
863 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
865 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
866 $object->accountancy_code_sell_export =
'';
868 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
870 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
871 $object->accountancy_code_buy =
'';
873 $object->accountancy_code_buy = $accountancy_code_buy;
875 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
876 $object->accountancy_code_buy_intra =
'';
878 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
880 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
881 $object->accountancy_code_buy_export =
'';
883 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
886 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
892 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
897 if (!$error &&
$object->check()) {
900 $categories =
GETPOST(
'categories',
'array');
901 $object->setCategories($categories);
916 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
925 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
928 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
939 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
941 $clone->status_buy = 0;
942 $clone->barcode = -1;
944 if ($clone->check()) {
947 $clone->context[
'createfromclone'] =
'createfromclone';
948 $id = $clone->create($user);
950 if (
GETPOST(
'clone_composition')) {
951 $result = $clone->clone_associations(
$object->id, $id);
959 if (!$error &&
GETPOST(
'clone_categories')) {
960 $result = $clone->cloneCategories(
$object->id, $id);
968 if (!$error &&
GETPOST(
'clone_prices')) {
969 $result = $clone->clone_price(
$object->id, $id);
977 if (!$error && isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
980 $bomstatic =
new BOM($db);
981 $bomclone = $bomstatic->createFromClone($user,
$object->fk_default_bom);
982 if ((
int) $bomclone < 0) {
983 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
985 $defbomidac =
$object->fk_default_bom;
986 $clone->fk_default_bom = $bomclone->id;
987 $clone->update($id, $user);
988 $bomclone->fk_product =
$id;
989 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
990 $bomclone->update($user);
991 $bomclone->validate($user);
994 if (
GETPOST(
'clone_otherboms')) {
995 $bomstatic =
new BOM($db);
996 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
997 if (is_array($bomlist)) {
998 foreach ($bomlist as $bom2clone) {
999 if ($bom2clone->id != $defbomidac) {
1000 $bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
1001 if ((
int) $bomclone < 0) {
1002 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
1004 $bomclone->fk_product =
$id;
1005 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
1006 $bomclone->update($user);
1007 $bomclone->validate($user);
1016 if ($clone->error ==
'ErrorProductAlreadyExists') {
1017 $refalreadyexists++;
1020 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
1021 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
1024 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
1029 unset($clone->context[
'createfromclone']);
1036 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
1040 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
1050 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
1053 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
1054 $result =
$object->delete($user);
1057 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.
$object->type.
'&delprod='.urlencode(
$object->ref));
1068 if (
$object->id > 0 && $action ==
'addin') {
1070 $permissiontoaddline =
false;
1076 if (
GETPOST(
'propalid') > 0) {
1077 $propal =
new Propal($db);
1078 $result = $propal->fetch(
GETPOST(
'propalid'));
1083 $thirdpartyid = $propal->socid;
1084 $permissiontoaddline = $user->hasRight(
'propal',
'creer');
1085 } elseif (
GETPOST(
'commandeid') > 0) {
1087 $result = $commande->fetch(
GETPOST(
'commandeid'));
1092 $thirdpartyid = $commande->socid;
1093 $permissiontoaddline = $user->hasRight(
'commande',
'creer');
1094 } elseif (
GETPOST(
'factureid') > 0) {
1096 $result = $facture->fetch(
GETPOST(
'factureid'));
1101 $thirdpartyid = $facture->socid;
1102 $permissiontoaddline = $user->hasRight(
'facture',
'creer');
1105 if ($thirdpartyid > 0) {
1107 $result = $soc->fetch($thirdpartyid);
1117 if (empty($tva_tx)) {
1120 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1121 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1125 $price_base_type =
$object->price_base_type;
1129 $pu_ht =
$object->multiprices[$soc->price_level];
1130 $pu_ttc =
$object->multiprices_ttc[$soc->price_level];
1131 $price_base_type =
$object->multiprices_base_type[$soc->price_level];
1133 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1137 $filter = array(
't.fk_product' =>
$object->id,
't.fk_soc' => $soc->id);
1139 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1141 if (count($prodcustprice->lines) > 0) {
1142 $pu_ht =
price($prodcustprice->lines [0]->price);
1143 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1144 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1145 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1150 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1151 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1155 if ($tmpvat != $tmpprodvat) {
1156 if ($price_base_type !=
'HT') {
1157 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1159 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1163 if (
GETPOST(
'propalid') > 0 && $permissiontoaddline && is_object($propal)) {
1166 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1167 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1170 $buyprice = $result;
1173 $result = $propal->addline(
1198 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1202 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1203 } elseif (
GETPOST(
'commandeid') > 0 && $permissiontoaddline && is_object($commande)) {
1206 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1207 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1210 $buyprice = $result;
1213 $result = $commande->addline(
1240 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode((
string) ($commande->id)));
1244 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1245 } elseif (
GETPOST(
'factureid') > 0 && $permissiontoaddline && is_object($facture)) {
1248 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1249 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1252 $buyprice = $result;
1255 $result = $facture->addline(
1287 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1291 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1295 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1306$form =
new Form($db);
1310if (isModEnabled(
'accounting')) {
1313$sellOrEatByMandatoryList =
null;
1314if (isModEnabled(
'productbatch')) {
1318$title = $langs->trans(
'ProductServiceCard');
1323 if ($action ==
'create') {
1324 $title = $langs->trans(
"NewProduct");
1326 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1327 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1331 if ($action ==
'create') {
1332 $title = $langs->trans(
"NewService");
1334 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1335 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1339llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-card');
1343$modBarCodeProduct =
null;
1346 $dirbarcode = array_merge(array(
'/core/modules/barcode/'),
$conf->modules_parts[
'barcode']);
1347 foreach ($dirbarcode as $dirroot) {
1354 $modBarCodeProduct =
new $module();
1355 '@phan-var-force ModeleNumRefBarCode $modBarCodeProduct';
1359$canvasdisplayaction = $action;
1360if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
1361 $canvasdisplayaction =
'view';
1364if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
1368 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
1369 $objcanvas->display_canvas($canvasdisplayaction);
1374 if ($action ==
'create' && $usercancreate) {
1376 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1378 if (!empty(
$conf->use_javascript_ajax)) {
1379 print
'<script type="text/javascript">';
1380 print
'$(document).ready(function () {
1381 $("#selectcountry_id").change(function() {
1382 console.log("selectcountry_id change");
1383 document.formprod.action.value="create";
1384 document.formprod.submit();
1387 print
'</script>'.
"\n";
1391 $module =
getDolGlobalString(
'PRODUCT_CODEPRODUCT_ADDON',
'mod_codeproduct_leopard');
1392 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1393 $module = substr($module, 0,
dol_strlen($module) - 4);
1397 $modCodeProduct =
new $module();
1402 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1403 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1404 print
'<input type="hidden" name="action" value="add">';
1405 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1406 if (!empty($modCodeProduct->code_auto)) {
1407 print
'<input type="hidden" name="code_auto" value="1">';
1409 if (!empty($modBarCodeProduct->code_auto)) {
1410 print
'<input type="hidden" name="barcode_auto" value="1">';
1412 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1416 $title = $langs->trans(
"NewService");
1419 $title = $langs->trans(
"NewProduct");
1425 $object->country_id = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : null;
1426 if (
$object->country_id > 0) {
1428 $object->country_code = $tmparray[
'code'];
1429 $object->country = $tmparray[
'label'];
1435 $parameters = array();
1437 $reshook = $hookmanager->executeHooks(
'tabContentCreateProduct', $parameters,
$object, $action);
1438 if (empty($reshook)) {
1439 print
'<table class="border centpercent">';
1444 if (!empty($modCodeProduct->code_auto)) {
1445 $tmpcode = $modCodeProduct->getNextValue(
$object, $type);
1447 print
'<td class="titlefieldcreate fieldrequired">'.$langs->trans(
"ProductRef").
'</td><td><input id="ref" name="ref" class="maxwidth200" maxlength="128" value="'.
dol_escape_htmltag(GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alphanohtml') : $tmpcode).
'">';
1448 if ($refalreadyexists) {
1449 print $langs->trans(
"RefAlreadyExists");
1455 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>';
1458 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1459 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1460 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1464 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1465 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1466 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1470 if (isModEnabled(
'productbatch')) {
1471 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1472 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1473 print $form->selectarray(
'status_batch', $statutarray,
GETPOSTINT(
'status_batch'));
1477 if ($status_batch !==
'0') {
1478 $langs->load(
"admin");
1479 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1480 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1481 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1482 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1483 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1488 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1491 print
'<td id="field_mask">';
1492 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1493 print
'<script type="text/javascript">
1494 $(document).ready(function() {
1495 $("#field_mask, #mask_option").addClass("hideobject");
1496 $("#status_batch").on("change", function () {
1497 console.log("We change batch status");
1498 var optionSelected = $("option:selected", this);
1499 var valueSelected = this.value;
1500 $("#field_mask, #mask_option").addClass("hideobject");
1504 if (this.value == 1) {
1505 $("#field_mask, #mask_option").toggleClass("hideobject");
1506 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1512 if (this.value == 2) {
1513 $("#field_mask, #mask_option").toggleClass("hideobject");
1514 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1527 if (!empty($sellOrEatByMandatoryList)) {
1528 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
1529 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList,
GETPOSTINT(
'sell_or_eat_by_mandatory'));
1534 $showbarcode = isModEnabled(
'barcode');
1535 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
1539 if ($showbarcode && is_object($modBarCodeProduct)) {
1540 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1541 if (GETPOSTISSET(
'fk_barcode_type')) {
1542 $fk_barcode_type =
GETPOST(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type') : 0;
1547 $fk_barcode_type = 0;
1550 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1552 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1555 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1556 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
1557 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1558 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
1560 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1561 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1566 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1567 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1568 $doleditor->Create();
1573 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1574 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1575 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1579 if (($type != 1 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
1581 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1582 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1583 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1584 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOSTINT(
'type')).
'">';
1585 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1593 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1594 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1599 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1600 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1605 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1606 print
'<input name="desiredstock" type="hidden" value="0">';
1610 if ($type == $object::TYPE_SERVICE && isModEnabled(
"workstation")) {
1612 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1613 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1614 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
1620 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1621 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1622 print
'<input name="duration_value" size="4" value="'.GETPOSTINT(
'duration_value').
'">';
1623 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (GETPOSTISSET(
'duration_unit') ?
GETPOST(
'duration_unit',
'alpha') :
'h'), 0, 1);
1626 print
' ';
1627 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
1628 print
'<label for="mandatoryperiod">';
1629 $htmltooltip = $langs->trans(
"mandatoryHelper");
1631 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
1633 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1642 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1643 print $formproduct->selectProductNature(
'finished',
$object->finished);
1651 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1652 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1653 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1654 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);
1660 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1661 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1662 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1663 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1664 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1665 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') : (
GETPOST(
'size_units',
'alpha') ?:
'0'), 0, 2);
1670 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1671 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1672 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') : (
GETPOST(
'surface_units',
'alpha') ?:
'0'), 0, 2);
1677 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1678 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1679 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') : (
GETPOST(
'volume_units',
'alpha') ?:
'0'), 0, 2);
1685 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1686 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1687 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);
1694 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1696 print $form->selectUnits(empty($line->fk_unit) ?
getDolGlobalString(
'PRODUCT_USE_UNITS') : $line->fk_unit,
'units');
1702 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1705 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1707 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1708 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1710 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1718 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1720 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1723 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1724 print $formcompany->select_state(
$object->state_id,
$object->country_code);
1731 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1732 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1736 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
1737 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1738 print $hookmanager->resPrint;
1739 if (empty($reshook)) {
1740 print
$object->showOptionals($extrafields,
'create', $parameters);
1744 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1747 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1748 $doleditor->Create();
1753 if (isModEnabled(
'category')) {
1755 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1756 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
1757 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'), 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1769 print
'<table class="border centpercent">';
1771 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1773 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1780 print
'<table class="border centpercent">';
1783 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1784 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1785 print $form->selectPriceBaseType(
getDolGlobalString(
'PRODUCT_PRICE_BASE_TYPE'),
"price_base_type");
1789 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1790 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1794 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1796 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1806 print
'<!-- accountancy codes -->'.
"\n";
1807 print
'<table class="border centpercent">';
1810 if (isModEnabled(
'accounting')) {
1813 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1816 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_ACCOUNT"));
1818 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
1820 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1824 if ($mysoc->isInEEC()) {
1825 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1828 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1830 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1832 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1837 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1840 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1842 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1844 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1848 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1851 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1853 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1855 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1859 if ($mysoc->isInEEC()) {
1860 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1863 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1865 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1867 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1872 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1875 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1877 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1879 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1, array(), 1, 1,
'minwidth150 maxwidth300', 1);
1882 if (!empty($accountancy_code_sell)) {
1883 $object->accountancy_code_sell = $accountancy_code_sell;
1885 if (!empty($accountancy_code_sell_intra)) {
1886 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1888 if (!empty($accountancy_code_sell_export)) {
1889 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1891 if (!empty($accountancy_code_buy)) {
1892 $object->accountancy_code_buy = $accountancy_code_buy;
1894 if (!empty($accountancy_code_buy_intra)) {
1895 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1897 if (!empty($accountancy_code_buy_export)) {
1898 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1902 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1903 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1907 if ($mysoc->isInEEC()) {
1908 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1909 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1914 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1915 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1919 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1920 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1924 if ($mysoc->isInEEC()) {
1925 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1926 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1931 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1932 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1941 print $form->buttonsSaveCancel(
"Create");
1950 if ($action ==
'edit' && $usercancreate) {
1952 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1954 if (!empty(
$conf->use_javascript_ajax)) {
1955 print
'<script type="text/javascript">';
1956 print
'$(document).ready(function () {
1957 $("#selectcountry_id").change(function () {
1958 document.formprod.action.value="edit";
1959 document.formprod.submit();
1962 print
'</script>'.
"\n";
1969 $object->country_code = $tmparray[
'code'];
1970 $object->country = $tmparray[
'label'];
1973 $type = $langs->trans(
'Product');
1975 $type = $langs->trans(
'Service');
1980 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="formprod">'.
"\n";
1981 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1982 print
'<input type="hidden" name="action" value="update">';
1983 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1984 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1987 $titre = $langs->trans(
"CardProduct".
$object->type);
1989 print
dol_get_fiche_head($head,
'card', $titre, 0, $picto, 0,
'',
'', 0,
'', 1);
1992 $parameters = array();
1994 $reshook = $hookmanager->executeHooks(
'tabContentEditProduct', $parameters,
$object, $action);
1996 if (empty($reshook)) {
1997 print
'<table class="border allwidth">';
2001 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>';
2003 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>';
2007 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>';
2010 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
2011 print
'<select class="flat" name="statut">';
2012 if ((GETPOSTISSET(
'statut') &&
GETPOST(
'statut')) || (!GETPOSTISSET(
'statut') &&
$object->status)) {
2013 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
2014 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
2016 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
2017 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
2023 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
2024 print
'<select class="flat" name="statut_buy">';
2025 if ((GETPOSTISSET(
'statut_buy') &&
GETPOST(
'statut_buy')) || (!GETPOSTISSET(
'statut_buy') &&
$object->status_buy)) {
2026 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2027 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2029 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2030 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2036 if (isModEnabled(
'productbatch')) {
2038 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2039 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
2041 print $form->selectarray(
'status_batch', $statutarray, GETPOSTISSET(
'status_batch') ?
GETPOSTINT(
'status_batch') :
$object->status_batch);
2043 print
'<span id="statusBatchWarning" class="warning" style="display: none;">';
2044 print
img_warning().
' '.$langs->trans(
"WarningConvertFromBatchToSerial").
'</span>';
2046 print
'<span id="statusBatchMouvToGlobal" class="warning" style="display: none;">';
2047 print
img_warning().
' '.$langs->trans(
"WarningTransferBatchStockMouvToGlobal").
'</span>';
2051 print
'<script type="text/javascript">
2052 $(document).ready(function() {
2053 console.log($("#statusBatchWarning"))
2054 $("#status_batch").on("change", function() {
2055 if ($("#status_batch")[0].value == 0){
2056 $("#statusBatchMouvToGlobal").show()
2058 $("#statusBatchMouvToGlobal").hide()
2064 if (
$object->status_batch == 1) {
2065 print
'<script type="text/javascript">
2066 $(document).ready(function() {
2067 console.log($("#statusBatchWarning"))
2068 $("#status_batch").on("change", function() {
2069 if ($("#status_batch")[0].value == 2){
2070 $("#statusBatchWarning").show()
2072 $("#statusBatchWarning").hide()
2080 if (!empty(
$object->status_batch) || !empty(
$conf->use_javascript_ajax)) {
2081 $langs->load(
"admin");
2082 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2083 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
2084 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
2085 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2086 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
2089 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
2099 print
'<td id="field_mask">';
2100 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
2102 if (!empty(
$conf->use_javascript_ajax)) {
2103 print
'<script type="text/javascript">
2104 $(document).ready(function() {
2105 $("#field_mask").parent().addClass("hideobject");
2106 var preselect = document.getElementById("status_batch");';
2108 print
'if (preselect.value == "2") {
2109 $("#field_mask").parent().removeClass("hideobject");
2113 print
'if (preselect.value == "1") {
2114 $("#field_mask").parent().removeClass("hideobject");
2117 print
'$("#status_batch").on("change", function () {
2118 var optionSelected = $("option:selected", this);
2119 var valueSelected = this.value;
2120 $("#field_mask").parent().addClass("hideobject");
2124 if (this.value == 1) {
2125 $("#field_mask").parent().removeClass("hideobject");
2126 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
2132 if (this.value == 2) {
2133 $("#field_mask").parent().removeClass("hideobject");
2134 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2148 if (!empty($sellOrEatByMandatoryList)) {
2149 if (GETPOSTISSET(
'sell_or_eat_by_mandatory')) {
2150 $sellOrEatByMandatorySelectedId =
GETPOSTINT(
'sell_or_eat_by_mandatory');
2152 $sellOrEatByMandatorySelectedId =
$object->sell_or_eat_by_mandatory;
2154 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2155 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList, $sellOrEatByMandatorySelectedId);
2161 $showbarcode = isModEnabled(
'barcode');
2162 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2167 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2168 if (GETPOSTISSET(
'fk_barcode_type')) {
2169 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2171 $fk_barcode_type =
$object->barcode_type;
2176 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2178 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2180 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2181 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2182 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2183 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2185 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2190 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2193 $doleditor =
new DolEditor(
'desc', GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') :
$object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2194 $doleditor->Create();
2201 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2202 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2203 print
'<input type="text" name="url" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') :
$object->url).
'">';
2210 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2211 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2212 print $formproduct->selectWarehouses((GETPOSTISSET(
'fk_default_warehouse') ?
GETPOST(
'fk_default_warehouse') :
$object->fk_default_warehouse),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'maxwidth500 widthcentpercentminusxx');
2213 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int)
$object->id)).
'">';
2214 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2227 if (
$object->isService() && isModEnabled(
'workstation')) {
2229 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2230 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2231 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
2244 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2245 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
2246 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time",
$object->duration_unit, 0, 1);
2249 print
' ';
2250 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2251 print
'<label for="mandatoryperiod">';
2252 $htmltooltip = $langs->trans(
"mandatoryHelper");
2254 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2256 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2263 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2264 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') :
$object->finished));
2269 if (!
$object->isService() && isModEnabled(
'bom')) {
2270 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2271 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int)
$object->id).
')';
2272 print $form->selectForForms($bomkey,
'fk_default_bom', (GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') :
$object->fk_default_bom), 1);
2279 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2280 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') :
$object->weight).
'"> ';
2281 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') :
$object->weight_units, 0, 2);
2287 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2288 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') :
$object->length).
'">x';
2289 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') :
$object->width).
'">x';
2290 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') :
$object->height).
'"> ';
2291 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') :
$object->length_units, 0, 2);
2296 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2297 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') :
$object->surface).
'"> ';
2298 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') :
$object->surface_units, 0, 2);
2303 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2304 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') :
$object->volume).
'"> ';
2305 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') :
$object->volume_units, 0, 2);
2311 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2312 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') :
$object->net_measure).
'"> ';
2313 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') :
$object->net_measure_units, 0, 0);
2319 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2321 print $form->selectUnits(
$object->fk_unit,
'units');
2327 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') :
$object->customcode).
'"></td></tr>';
2329 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2331 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2332 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2334 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2342 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2344 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2347 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2348 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOSTINT(
'state_id') :
$object->state_id,
$object->country_code);
2356 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.
$object->lifetime.
'"></td></tr>';
2357 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.
$object->qc_frequency.
'"></td></tr>';
2361 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2362 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2363 print $hookmanager->resPrint;
2364 if (empty($reshook)) {
2365 print
$object->showOptionals($extrafields,
'edit', $parameters);
2369 if (isModEnabled(
'category')) {
2370 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2371 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
2373 $cats = $c->containing(
$object->id, Categorie::TYPE_PRODUCT);
2374 $arrayselected = array();
2375 if (is_array($cats)) {
2376 foreach ($cats as $cat) {
2377 $arrayselected[] = $cat->id;
2381 foreach (
GETPOST(
'categories',
'array') as $cat) {
2382 $arrayselected[] = $cat;
2385 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected, 0, 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2391 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2393 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2394 $doleditor->Create();
2403 print
'<table class="border centpercent">';
2406 if (isModEnabled(
'accounting')) {
2409 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2411 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');
2415 if ($mysoc->isInEEC()) {
2416 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2418 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');
2423 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2425 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');
2429 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2431 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');
2435 if ($mysoc->isInEEC()) {
2436 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2438 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');
2443 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2445 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');
2450 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2451 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell).
'">';
2455 if ($mysoc->isInEEC()) {
2456 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2457 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).
'">';
2462 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2463 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).
'">';
2467 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2468 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy).
'">';
2472 if ($mysoc->isInEEC()) {
2473 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2474 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).
'">';
2479 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2480 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).
'">';
2489 print $form->buttonsSaveCancel();
2495 $showbarcode = isModEnabled(
'barcode');
2496 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2501 $titre = $langs->trans(
"CardProduct".
$object->type);
2506 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2507 $object->next_prev_filter =
"fk_product_type:=:".((int)
$object->type);
2510 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
2514 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref');
2517 $parameters = array();
2519 $reshook = $hookmanager->executeHooks(
'tabContentViewProduct', $parameters,
$object, $action);
2520 if (empty($reshook)) {
2521 print
'<div class="fichecenter">';
2522 print
'<div class="fichehalfleft">';
2524 print
'<div class="underbanner clearboth"></div>';
2525 print
'<table class="border tableforfield centpercent">';
2528 if (isModEnabled(
"product") && isModEnabled(
"service")) {
2529 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2530 print
'<tr><td class="titlefield">';
2531 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2533 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat);
2539 print
'<tr><td class="nowrap">';
2540 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2541 print $langs->trans(
"BarcodeType");
2543 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2544 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>';
2546 print
'</tr></table>';
2548 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2549 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2553 $fk_barcode_type =
'';
2554 if ($action ==
'editbarcodetype' && is_object($formbarcode)) {
2555 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->barcode_type,
'fk_barcode_type');
2556 $fk_barcode_type =
$object->barcode_type;
2559 $fk_barcode_type =
$object->barcode_type;
2560 print
$object->barcode_type_label ?
$object->barcode_type_label : (
$object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2562 print
'</td></tr>'.
"\n";
2565 print
'<tr><td class="nowrap">';
2566 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2567 print $langs->trans(
"BarcodeValue");
2569 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2570 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>';
2572 print
'</tr></table>';
2573 print
'</td><td class="wordbreak">';
2574 if ($action ==
'editbarcode') {
2575 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2576 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2577 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2580 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
2581 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2582 print
'<input type="hidden" name="action" value="setbarcode">';
2583 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2584 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2585 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2590 print
'</td></tr>'.
"\n";
2594 if (isModEnabled(
'productbatch')) {
2596 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2597 print
$object->getLibStatut(0, 2);
2601 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2607 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->transnoentities(
'SellByDate'), $langs->transnoentities(
'EatByDate')).
'</td><td>';
2608 print
$object->getSellOrEatByMandatoryLabel();
2614 print
'<tr><td class="nowrap">';
2615 print $langs->trans(
"ProductAccountancySellCode");
2617 if (isModEnabled(
'accounting')) {
2618 if (!empty(
$object->accountancy_code_sell)) {
2620 $accountingaccount->fetch(0,
$object->accountancy_code_sell, 1);
2622 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2625 print
$object->accountancy_code_sell;
2630 if ($mysoc->isInEEC()) {
2631 print
'<tr><td class="nowrap">';
2632 print $langs->trans(
"ProductAccountancySellIntraCode");
2634 if (isModEnabled(
'accounting')) {
2635 if (!empty(
$object->accountancy_code_sell_intra)) {
2637 $accountingaccount2->fetch(0,
$object->accountancy_code_sell_intra, 1);
2639 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2642 print
$object->accountancy_code_sell_intra;
2648 print
'<tr><td class="nowrap">';
2649 print $langs->trans(
"ProductAccountancySellExportCode");
2651 if (isModEnabled(
'accounting')) {
2652 if (!empty(
$object->accountancy_code_sell_export)) {
2654 $accountingaccount3->fetch(0,
$object->accountancy_code_sell_export, 1);
2656 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2659 print
$object->accountancy_code_sell_export;
2664 print
'<tr><td class="nowrap">';
2665 print $langs->trans(
"ProductAccountancyBuyCode");
2667 if (isModEnabled(
'accounting')) {
2668 if (!empty(
$object->accountancy_code_buy)) {
2670 $accountingaccount4->fetch(0,
$object->accountancy_code_buy, 1);
2672 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2675 print
$object->accountancy_code_buy;
2680 if ($mysoc->isInEEC()) {
2681 print
'<tr><td class="nowrap">';
2682 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2684 if (isModEnabled(
'accounting')) {
2685 if (!empty(
$object->accountancy_code_buy_intra)) {
2687 $accountingaccount5->fetch(0,
$object->accountancy_code_buy_intra, 1);
2689 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2692 print
$object->accountancy_code_buy_intra;
2698 print
'<tr><td class="nowrap">';
2699 print $langs->trans(
"ProductAccountancyBuyExportCode");
2701 if (isModEnabled(
'accounting')) {
2702 if (!empty(
$object->accountancy_code_buy_export)) {
2704 $accountingaccount6->fetch(0,
$object->accountancy_code_buy_export, 1);
2706 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2709 print
$object->accountancy_code_buy_export;
2715 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
2716 print
'<td class="wordbreakimp wrapimp"><div class="longmessagecut">'.(dol_textishtml(
$object->description) ?
$object->description :
dol_nl2br(
$object->description, 1,
true)).
'</div></td></tr>';
2720 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2728 $warehouse->fetch(
$object->fk_default_warehouse);
2730 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2731 print(!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2735 if (
$object->isService() && isModEnabled(
'workstation')) {
2737 $res = $workstation->fetch(
$object->fk_default_workstation);
2739 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2740 print(!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2745 if (isModEnabled(
'variants') && (
$object->isProduct() ||
$object->isService())) {
2748 if ($combination->fetchByFkProductChild(
$object->id) > 0) {
2749 $prodstatic =
new Product($db);
2750 $prodstatic->fetch($combination->fk_product_parent);
2753 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2754 print $prodstatic->getNomUrl(1);
2761 print
'<div class="fichehalfright">';
2763 print
'<div class="underbanner clearboth"></div>';
2764 print
'<table class="border tableforfield centpercent">';
2768 require_once DOL_DOCUMENT_ROOT.
'/core/class/cunits.class.php';
2769 $measuringUnits =
new CUnits($db);
2772 if (
$object->duration_value > 1) {
2775 $result = $measuringUnits->fetchAll(
'',
'scale', 0, 0, [
't.active' => 1,
't.unit_type' =>
'time']);
2776 if ($result !== -1) {
2777 foreach ($measuringUnits->records as $record) {
2778 $durations[$record->short_label] =
dol_ucfirst($record->label) . $plural;
2781 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Duration").
'</td><td>';
2782 print
$object->duration_value;
2783 print (!empty(
$object->duration_unit) && isset($durations[
$object->duration_unit]) ?
" ".$langs->trans($durations[
$object->duration_unit]).
" " :
'');
2786 if (
$object->duration_value > 0) {
2787 print
' ';
2789 $htmltooltip = $langs->trans(
"mandatoryHelper");
2791 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2793 print
'<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2794 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2800 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2801 print
$object->getLibFinished();
2806 if (!
$object->isService() && isModEnabled(
'bom') &&
$object->finished) {
2807 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2808 if (
$object->fk_default_bom) {
2809 $bom_static =
new BOM($db);
2810 $bom_static->fetch(
$object->fk_default_bom);
2811 print $bom_static->getNomUrl(1);
2819 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Weight").
'</td><td>';
2825 print
"</td></tr>\n";
2830 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2834 print
" x ".$object->width;
2837 print
" x ".$object->height;
2839 print
' '.measuringUnitString(0,
"size",
$object->length_units);
2843 print
"</td></tr>\n";
2847 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2853 print
"</td></tr>\n";
2857 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2863 print
"</td></tr>\n";
2868 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"NetMeasure").
'</td><td>';
2869 if (
$object->net_measure !=
'') {
2880 $unit =
$object->getLabelOfUnit();
2882 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2884 print $langs->trans($unit);
2891 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.
$object->customcode.
'</td></tr>';
2894 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry(
$object->country_id,
'', $db);
2895 if (!empty(
$object->state_id)) {
2896 print
' - '.getState(
$object->state_id,
'0', $db);
2903 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.
$object->lifetime.
'</td></tr>';
2904 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.
$object->qc_frequency.
'</td></tr>';
2908 $parameters = array();
2909 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2912 if (isModEnabled(
'category')) {
2913 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2914 print $form->showCategories(
$object->id, Categorie::TYPE_PRODUCT, 1);
2920 print
'<!-- show Note --> '.
"\n";
2922 print
'<!-- End show Note --> '.
"\n";
2929 print
'<div class="clearboth"></div>';
2934 } elseif ($action !=
'create') {
2940if (!empty($modCodeProduct->code_auto)) {
2941 $tmpcode = $modCodeProduct->getNextValue(
$object,
$object->type);
2947if (($action ==
'delete' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
2948 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
2949 $formconfirm = $form->formconfirm(
"card.php?id=".
$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2951if ($action ==
'merge') {
2952 $formquestion = array(
2954 'name' =>
'product_origin',
2955 'label' => $langs->trans(
'MergeOriginProduct'),
2957 'value' => $form->select_produits(0,
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2960 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
2964if (($action ==
'clone' && (empty(
$conf->use_javascript_ajax) || !empty(
$conf->dol_use_jmobile)))
2965 || (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile))) {
2967 $formquestionclone = array(
2968 'text' => $langs->trans(
"ConfirmClone"),
2969 0 => array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->ref : $tmpcode,
'morecss' =>
'width150'),
2970 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2971 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2974 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2977 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2979 if (isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
2980 if (
$object->fk_default_bom > 0) {
2981 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_defbom',
'label' => $langs->trans(
"CloneDefBomProduct"),
'value' =>
getDolGlobalInt(
'BOM_CLONE_DEFBOM'));
2983 $bomstatic =
new BOM($db);
2984 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
2985 if (is_array($bomlist) && count($bomlist) > 0) {
2986 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_otherboms',
'label' => $langs->trans(
"CloneOtherBomsProduct"),
'value' => 0);
2989 $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);
2993$parameters = array(
'formConfirm' => $formconfirm,
'object' =>
$object);
2994$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2995if (empty($reshook)) {
2996 $formconfirm .= $hookmanager->resPrint;
2997} elseif ($reshook > 0) {
2998 $formconfirm = $hookmanager->resPrint;
3007if ($action !=
'create' && $action !=
'edit') {
3008 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
3009 $cloneButtonId =
'action-clone-no-ajax';
3011 print
"\n".
'<div class="tabsAction">'.
"\n";
3013 $parameters = array();
3014 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
3015 if (empty($reshook)) {
3016 if ($usercancreate) {
3017 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
3021 if (!isset($hookmanager->resArray[
'no_button_copy']) || $hookmanager->resArray[
'no_button_copy'] != 1) {
3022 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3023 $cloneProductUrl =
'';
3024 $cloneButtonId =
'action-clone';
3026 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
3031 if ($usercandelete) {
3032 if (empty($object_is_used)) {
3033 if (!isset($hookmanager->resArray[
'no_button_delete']) || $hookmanager->resArray[
'no_button_delete'] != 1) {
3034 if (!empty(
$conf->use_javascript_ajax) && empty(
$conf->dol_use_jmobile)) {
3035 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
3041 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3044 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
3047 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3065 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
3066 $propal =
new Propal($db);
3068 $langs->load(
"propal");
3070 $otherprop = $propal->liste_array(2, 1, 0);
3072 if (is_array($otherprop) && count($otherprop)) {
3073 $html .=
'<tr><td style="width: 200px;">';
3074 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3075 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
3076 $html .=
'</td></tr>';
3078 $html .=
'<tr><td style="width: 200px;">';
3079 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3080 $html .= $langs->trans(
"NoDraftProposals");
3081 $html .=
'</td></tr>';
3086 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
3089 $langs->load(
"orders");
3091 $othercom = $commande->liste_array(2, 1,
null);
3092 if (is_array($othercom) && count($othercom)) {
3093 $html .=
'<tr><td style="width: 200px;">';
3094 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3095 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
3096 $html .=
'</td></tr>';
3098 $html .=
'<tr><td style="width: 200px;">';
3099 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3100 $html .= $langs->trans(
"NoDraftOrders");
3101 $html .=
'</td></tr>';
3106 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
3109 $langs->load(
"bills");
3111 $otherinvoice = $invoice->liste_array(2, 1,
null);
3112 if (is_array($otherinvoice) && count($otherinvoice)) {
3113 $html .=
'<tr><td style="width: 200px;">';
3114 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3115 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
3116 $html .=
'</td></tr>';
3118 $html .=
'<tr><td style="width: 200px;">';
3119 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3120 $html .= $langs->trans(
"NoDraftInvoices");
3121 $html .=
'</td></tr>';
3126 if (!empty($html)) {
3127 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
3128 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3129 print
'<input type="hidden" name="action" value="addin">';
3135 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
3136 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
3137 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
3138 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
3139 $html .=
'</td></tr>';
3141 print
'<table class="centpercent border">';
3145 print
'<div class="center">';
3146 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
3160if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
3161 print
'<div class="fichecenter"><div class="fichehalfleft">';
3162 print
'<a name="builddoc"></a>';
3166 if (!empty(
$conf->product->multidir_output[
$object->entity])) {
3167 $filedir =
$conf->product->multidir_output[
$object->entity].
'/'.$objectref;
3169 $filedir =
$conf->product->dir_output.
'/'.$objectref;
3171 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3172 $genallowed = $usercanread;
3173 $delallowed = $usercancreate;
3175 print $formfile->showdocuments($modulepart,
$object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'',
$object);
3176 $somethingshown = $formfile->numoffiles;
3178 print
'</div><div class="fichehalfright">';
3181 $morehtmlcenter =
'<div class="nowraponall">';
3182 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/product/messaging.php?id='.
$object->id);
3183 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
3184 $morehtmlcenter .=
'</div>';
3187 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3189 $somethingshown = $formactions->showactions(
$object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3191 print
'</div></div>';
if( $user->socid > 0) if(! $user->hasRight('accounting', 'chartofaccount')) $object
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 sell or eat by mandatory list.
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.
load_fiche_titre($title, $morehtmlright='', $picto='generic', $pictoisfullpath=0, $id='', $morecssontable='', $morehtmlcenter='')
Load a title with picto.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_ucfirst($string, $encoding="UTF-8")
Convert first character of the first word of a string to upper.
showValueWithClipboardCPButton($valuetocopy, $showonlyonhover=1, $texttoshow='')
Create a button to copy $valuetocopy in the clipboard (for copy and paste feature).
img_warning($titlealt='default', $moreatt='', $morecss='pictowarning')
Show warning logo.
img_picto($titlealt, $picto, $moreatt='', $pictoisfullpath=0, $srconly=0, $notitle=0, $alt='', $morecss='', $marginleftonlyshort=2)
Show picto whatever it's its name (generic function)
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0)
Show tabs of a record.
price2num($amount, $rounding='', $option=0)
Function that return a number with universal decimal format (decimal separator is '.
dolGetButtonTitle($label, $helpText='', $iconClass='fa fa-file', $url='', $id='', $status=1, $params=array())
Function dolGetButtonTitle : this kind of buttons are used in title in list.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
dol_nl2br($stringtoencode, $nl2brmode=0, $forxml=false)
Replace CRLF in string with a HTML BR tag.
dol_print_url($url, $target='_blank', $max=32, $withpicto=0, $morecss='')
Show Url link.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
Function to format a value into an amount for visual output Function used into PDF and HTML pages.
GETPOSTISARRAY($paramname, $method=0)
Return true if the parameter $paramname is submit from a POST OR GET as an array.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
if(!function_exists( 'dol_getprefix')) dol_include_once($relpath, $classname='')
Make an include_once using default root and alternate root if it fails.
dol_set_focus($selector)
Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
newToken()
Return the value of token currently saved into session with name 'newtoken'.
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
GETPOSTFLOAT($paramname, $rounding='')
Return the value of a $_GET or $_POST supervariable, converted into float.
dol_clone($object, $native=2)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dol_sanitizeFileName($str, $newstr='_', $unaccent=1)
Clean a string to use it as a file name.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
dol_trunc($string, $size=40, $trunc='right', $stringencoding='UTF-8', $nodot=0, $display=0)
Truncate a string to a particular length adding '…' if string larger than length.
getDolGlobalString($key, $default='')
Return a Dolibarr global constant string value.
info_admin($text, $infoonimgalt=0, $nodiv=0, $admin='1', $morecss='hideonsmartphone', $textfordropdown='', $picto='')
Show information in HTML for admin users or standard users.
img_edit($titlealt='default', $float=0, $other='')
Show logo edit/modify fiche.
get_default_tva(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that return vat rate of a product line (according to seller, buyer and product vat rate) VAT...
get_localtax($vatrate, $local, $thirdparty_buyer=null, $thirdparty_seller=null, $vatnpr=0)
Return localtax rate for a particular vat, when selling a product with vat $vatrate,...
get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart='')
Return a path to have a the directory according to object where files are stored.
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...
global $conf
The following vars must be defined: $type2label $form $conf, $lang, The following vars may also be de...
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unitid, $measuring_style='', $unitscale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.