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';
61if (isModEnabled(
'propal')) {
62 require_once DOL_DOCUMENT_ROOT.
'/comm/propal/class/propal.class.php';
64if (isModEnabled(
'invoice')) {
65 require_once DOL_DOCUMENT_ROOT.
'/compta/facture/class/facture.class.php';
67if (isModEnabled(
'order')) {
68 require_once DOL_DOCUMENT_ROOT.
'/commande/class/commande.class.php';
70if (isModEnabled(
'accounting')) {
71 require_once DOL_DOCUMENT_ROOT.
'/core/lib/accounting.lib.php';
72 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formaccounting.class.php';
73 require_once DOL_DOCUMENT_ROOT.
'/accountancy/class/accountingaccount.class.php';
75if (isModEnabled(
'bom')) {
76 require_once DOL_DOCUMENT_ROOT.
'/bom/class/bom.class.php';
79if (isModEnabled(
'workstation')) {
80 require_once DOL_DOCUMENT_ROOT.
'/workstation/class/workstation.class.php';
84$langs->loadLangs(array(
'products',
'other'));
85if (isModEnabled(
'stock')) {
86 $langs->load(
"stocks");
88if (isModEnabled(
'invoice')) {
89 $langs->load(
"bills");
91if (isModEnabled(
'productbatch')) {
92 $langs->load(
"productbatch");
104 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'nohtml') : null);
106 $ref = (GETPOSTISSET(
'ref') ?
GETPOST(
'ref',
'alpha') : null);
109$action = (
GETPOST(
'action',
'alpha') ?
GETPOST(
'action',
'alpha') :
'view');
110$cancel =
GETPOST(
'cancel',
'alpha');
111$backtopage =
GETPOST(
'backtopage',
'alpha');
112$confirm =
GETPOST(
'confirm',
'alpha');
114$duration_value =
GETPOSTINT(
'duration_value');
115$duration_unit =
GETPOST(
'duration_unit',
'alpha');
117$accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
118$accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
119$accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
120$accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
121$accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
122$accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
124$checkmandatory =
GETPOST(
'accountancy_code_buy_export',
'alpha');
128 $label_security_check =
'nohtml';
130 $label_security_check = !
getDolGlobalString(
'MAIN_SECURITY_ALLOW_UNSECURED_LABELS_WITH_HTML') ?
'alphanohtml' :
'restricthtml';
133if (!empty($user->socid)) {
134 $socid = $user->socid;
139if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
140 $module = substr($module, 0,
dol_strlen($module) - 4);
144 $modCodeProduct =
new $module();
152$extrafields->fetch_name_optionals_label(
$object->table_element);
154if ($id > 0 || !empty($ref)) {
155 $result =
$object->fetch($id, $ref);
159 $entity = (empty(
$object->entity) ? $conf->entity :
$object->entity);
160 if (isModEnabled(
"product")) {
161 $upload_dir = $conf->product->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
162 } elseif (isModEnabled(
"service")) {
163 $upload_dir = $conf->service->multidir_output[$entity].
'/'.
get_exdir(0, 0, 0, 0,
$object,
'product').dol_sanitizeFileName(
$object->ref);
167 if (isModEnabled(
"product")) {
168 $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";
170 $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";
175$modulepart =
'product';
180if (!empty($canvas)) {
181 require_once DOL_DOCUMENT_ROOT.
'/core/class/canvas.class.php';
182 $objcanvas =
new Canvas($db, $action);
183 $objcanvas->getCanvas(
'product',
'card', $canvas);
187$fieldvalue = (!empty($id) ?
$id : (!empty($ref) ? $ref :
''));
188$fieldtype = (!empty($id) ?
'rowid' :
'ref');
191$hookmanager->initHooks(array(
'productcard',
'globalcard'));
194 if (
$object->type == $object::TYPE_PRODUCT) {
197 if (
$object->type == $object::TYPE_SERVICE) {
201 restrictedArea($user,
'produit|service', 0,
'product&product',
'',
'', $fieldtype);
218$createbarcode = isModEnabled(
'barcode');
219if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'creer_advance')) {
223$parameters = array(
'id' => $id,
'ref' => $ref,
'objcanvas' => $objcanvas);
224$reshook = $hookmanager->executeHooks(
'doActions', $parameters,
$object, $action);
229if (empty($reshook)) {
230 $backurlforlist = DOL_URL_ROOT.
'/product/list.php?type='.$type;
232 if (empty($backtopage) || ($cancel && empty($id))) {
233 if (empty($backtopage) || ($cancel && strpos($backtopage,
'__ID__'))) {
234 if (empty($id) && (($action !=
'add' && $action !=
'create') || $cancel)) {
235 $backtopage = $backurlforlist;
237 $backtopage = DOL_URL_ROOT.
'/product/card.php?id='.((!empty($id) &&
$id > 0) ? $id :
'__ID__');
243 if (!empty($backtopageforcancel)) {
244 header(
"Location: ".$backtopageforcancel);
246 } elseif (!empty($backtopage)) {
247 header(
"Location: ".$backtopage);
253 if ($action ==
'confirm_merge' && $confirm ==
'yes' && $user->hasRight(
'societe',
'creer')) {
255 $productOriginId =
GETPOSTINT(
'product_origin');
256 $productOrigin =
new Product($db);
258 if ($productOriginId <= 0) {
259 $langs->load(
'errors');
260 setEventMessages($langs->trans(
'ErrorProductIdIsMandatory', $langs->transnoentitiesnoconv(
'MergeOriginProduct')),
null,
'errors');
262 if (!$error && $productOrigin->fetch($productOriginId) < 1) {
272 $listofproperties = array(
282 'accountancy_code_buy',
283 'accountancy_code_buy_intra',
284 'accountancy_code_buy_export',
285 'accountancy_code_sell',
286 'accountancy_code_sell_intra',
287 'accountancy_code_sell_export'
289 foreach ($listofproperties as $property) {
290 if (empty(
$object->$property)) {
291 $object->$property = $productOrigin->$property;
295 $listofproperties = array(
296 'note_public',
'note_private'
298 foreach ($listofproperties as $property) {
303 if (is_array($productOrigin->array_options)) {
304 foreach ($productOrigin->array_options as $key => $val) {
305 if (empty(
$object->array_options[$key])) {
306 $object->array_options[$key] = $val;
313 $custcats_ori = $static_cat->containing($productOrigin->id,
'product',
'id');
314 $custcats = $static_cat->containing(
$object->id,
'product',
'id');
315 $custcats = array_merge($custcats, $custcats_ori);
316 $object->setCategories($custcats);
319 if ($productOrigin->barcode ==
$object->barcode) {
320 dol_syslog(
"We clean customer and supplier code so we will be able to make the update of target");
321 $productOrigin->barcode =
'';
337 'ActionComm' =>
'/comm/action/class/actioncomm.class.php',
338 'Bom' =>
'/bom/class/bom.class.php',
341 'Commande' =>
'/commande/class/commande.class.php',
342 'CommandeFournisseur' =>
'/fourn/class/fournisseur.commande.class.php',
343 'Contrat' =>
'/contrat/class/contrat.class.php',
344 'Delivery' =>
'/delivery/class/delivery.class.php',
345 'Facture' =>
'/compta/facture/class/facture.class.php',
346 'FactureFournisseur' =>
'/fourn/class/fournisseur.facture.class.php',
347 'FactureRec' =>
'/compta/facture/class/facture-rec.class.php',
348 'FichinterRec' =>
'/fichinter/class/fichinterrec.class.php',
349 'ProductFournisseur' =>
'/fourn/class/fournisseur.product.class.php',
350 'Propal' =>
'/comm/propal/class/propal.class.php',
351 'Reception' =>
'/reception/class/reception.class.php',
352 'SupplierProposal' =>
'/supplier_proposal/class/supplier_proposal.class.php',
356 foreach ($objects as $object_name => $object_file) {
357 require_once DOL_DOCUMENT_ROOT.$object_file;
359 if (!$error && !$object_name::replaceProduct($db, $productOrigin->id,
$object->id)) {
369 $parameters = array(
'soc_origin' => $productOrigin->id,
'soc_dest' =>
$object->id);
370 $reshook = $hookmanager->executeHooks(
387 'mergefromid' => $productOrigin->id,
391 $result =
$object->call_trigger(
'PRODUCT_MODIFY', $user);
402 if ($productOrigin->delete($user) < 1) {
411 $langs->load(
"errors");
420 if ($action ==
'setfk_product_type' && $usercancreate) {
421 $result =
$object->setValueFrom(
'fk_product_type',
GETPOST(
'fk_product_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
422 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
427 $upload_dir = $conf->product->dir_output;
428 $permissiontoadd = $usercancreate;
429 include DOL_DOCUMENT_ROOT.
'/core/actions_builddoc.inc.php';
431 include DOL_DOCUMENT_ROOT.
'/core/actions_printing.inc.php';
434 if ($action ==
'setfk_barcode_type' && $usercancreate) {
435 $result =
$object->setValueFrom(
'fk_barcode_type',
GETPOST(
'fk_barcode_type'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
436 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
441 if ($action ==
'setbarcode' && $usercancreate) {
445 $result =
$object->setValueFrom(
'barcode',
GETPOST(
'barcode'),
'',
null,
'text',
'', $user,
'PRODUCT_MODIFY');
446 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".
$object->id);
449 $langs->load(
"errors");
451 $errors[] =
'ErrorBadBarCodeSyntax';
452 } elseif ($result == -2) {
453 $errors[] =
'ErrorBarCodeRequired';
454 } elseif ($result == -3) {
455 $errors[] =
'ErrorBarCodeAlreadyUsed';
457 $errors[] =
'FailedToValidateBarCode';
466 if ($action ==
'update_extras' && $usercancreate) {
470 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
GETPOST(
'attribute',
'restricthtml'));
477 $result =
$object->insertExtraFields(
'PRODUCT_MODIFY');
485 $action =
'edit_extras';
490 if ($action ==
'add' && $usercancreate) {
493 if (!
GETPOST(
'label', $label_security_check)) {
494 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Label')),
null,
'errors');
500 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'ProductRef')),
null,
'errors');
505 if (!empty($duration_value) && empty($duration_unit)) {
506 setEventMessages($langs->trans(
'ErrorFieldRequired', $langs->transnoentities(
'Unit')),
null,
'errors');
514 $object->entity = $conf->entity;
518 $object->mandatory_period = !empty(
GETPOST(
"mandatoryperiod",
'alpha')) ? 1 : 0;
519 if (
$object->price_base_type ==
'TTC') {
524 if (
$object->price_base_type ==
'TTC') {
530 $tva_tx_txt =
GETPOST(
'tva_tx',
'alpha');
534 $tva_tx = preg_replace(
'/[^0-9\.].*$/',
'', $tva_tx_txt);
535 $npr = preg_match(
'/\*/', $tva_tx_txt) ? 1 : 0;
538 $localtax1_type =
'0';
539 $localtax2_type =
'0';
542 if (preg_match(
'/\((.*)\)/', $tva_tx_txt, $reg)) {
544 $vatratecode = $reg[1];
546 $sql =
"SELECT t.rowid, t.code, t.recuperableonly, t.localtax1, t.localtax2, t.localtax1_type, t.localtax2_type";
547 $sql .=
" FROM ".MAIN_DB_PREFIX.
"c_tva as t, ".MAIN_DB_PREFIX.
"c_country as c";
548 $sql .=
" WHERE t.fk_pays = c.rowid AND c.code = '".$db->escape($mysoc->country_code).
"'";
549 $sql .=
" AND t.taux = ".((float) $tva_tx).
" AND t.active = 1";
550 $sql .=
" AND t.code = '".$db->escape($vatratecode).
"'";
551 $sql .=
" AND t.entity IN (".getEntity(
'c_tva').
")";
552 $resql = $db->query($sql);
554 $obj = $db->fetch_object($resql);
555 $npr = $obj->recuperableonly;
556 $localtax1 = $obj->localtax1;
557 $localtax2 = $obj->localtax2;
558 $localtax1_type = $obj->localtax1_type;
559 $localtax2_type = $obj->localtax2_type;
563 $object->default_vat_code = $vatratecode;
566 $object->localtax1_tx = $localtax1;
567 $object->localtax2_tx = $localtax2;
568 $object->localtax1_type = $localtax1_type;
569 $object->localtax2_type = $localtax2_type;
582 $stdobject->element =
'product';
583 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
584 $result = $stdobject->fetch_barcode();
587 $mesg =
'Failed to get bar code type information ';
590 $object->barcode_type_code = $stdobject->barcode_type_code;
591 $object->barcode_type_coder = $stdobject->barcode_type_coder;
592 $object->barcode_type_label = $stdobject->barcode_type_label;
603 $object->duration_value = $duration_value;
604 $object->duration_unit = $duration_unit;
623 if ($finished >= 0) {
636 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
637 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
638 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
639 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
640 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
641 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
643 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
644 $object->accountancy_code_sell =
'';
646 $object->accountancy_code_sell = $accountancy_code_sell;
648 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
649 $object->accountancy_code_sell_intra =
'';
651 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
653 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
654 $object->accountancy_code_sell_export =
'';
656 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
658 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
659 $object->accountancy_code_buy =
'';
661 $object->accountancy_code_buy = $accountancy_code_buy;
663 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
664 $object->accountancy_code_buy_intra =
'';
666 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
668 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
669 $object->accountancy_code_buy_export =
'';
671 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
677 for ($i = 2; $i <= $produit_multiprices_limit; $i++) {
678 if (GETPOSTISSET(
"price_".$i)) {
680 $object->multiprices_base_type[
"$i"] =
GETPOST(
"multiprices_base_type_".$i);
682 $object->multiprices[
"$i"] =
"";
688 $ret = $extrafields->setOptionalsFromPost(
null,
$object);
695 '@phan-var ModeleProductCode $modCodeProduct';
696 $ref = $modCodeProduct->getNextValue(
$object, $type);
705 $categories =
GETPOST(
'categories',
'array');
706 $object->setCategories($categories);
708 if (!empty($backtopage)) {
709 $backtopage = preg_replace(
'/__ID__/', (
string)
$object->id, $backtopage);
710 $backtopage = preg_replace(
'/--IDFORBACKTOPAGE--/', (
string)
$object->id, $backtopage);
711 if (preg_match(
'/\?/', $backtopage)) {
712 $backtopage .=
'&productid='.$object->id;
715 header(
"Location: ".$backtopage);
718 header(
"Location: ".$_SERVER[
'PHP_SELF'].
"?id=".$id);
725 if (
$object->error ==
'ErrorProductAlreadyExists') {
727 $reshook = $hookmanager->executeHooks(
'onProductAlreadyExists', $parameters,
$object, $action);
746 if ($action ==
'update' && $usercancreate) {
747 if (
GETPOST(
'cancel',
'alpha')) {
803 if ($finished >= 0) {
809 $fk_default_bom =
GETPOSTINT(
'fk_default_bom');
810 if ($fk_default_bom >= 0) {
811 $object->fk_default_bom = $fk_default_bom;
827 $stdobject->element =
'product';
828 $stdobject->barcode_type =
GETPOSTINT(
'fk_barcode_type');
829 $result = $stdobject->fetch_barcode();
832 $mesg =
'Failed to get bar code type information ';
835 $object->barcode_type_code = $stdobject->barcode_type_code;
836 $object->barcode_type_coder = $stdobject->barcode_type_coder;
837 $object->barcode_type_label = $stdobject->barcode_type_label;
839 $accountancy_code_sell =
GETPOST(
'accountancy_code_sell',
'alpha');
840 $accountancy_code_sell_intra =
GETPOST(
'accountancy_code_sell_intra',
'alpha');
841 $accountancy_code_sell_export =
GETPOST(
'accountancy_code_sell_export',
'alpha');
842 $accountancy_code_buy =
GETPOST(
'accountancy_code_buy',
'alpha');
843 $accountancy_code_buy_intra =
GETPOST(
'accountancy_code_buy_intra',
'alpha');
844 $accountancy_code_buy_export =
GETPOST(
'accountancy_code_buy_export',
'alpha');
845 $checkmandatory =
GETPOST(
'mandatoryperiod',
'alpha');
846 if (empty($accountancy_code_sell) || $accountancy_code_sell ==
'-1') {
847 $object->accountancy_code_sell =
'';
849 $object->accountancy_code_sell = $accountancy_code_sell;
851 if (empty($accountancy_code_sell_intra) || $accountancy_code_sell_intra ==
'-1') {
852 $object->accountancy_code_sell_intra =
'';
854 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
856 if (empty($accountancy_code_sell_export) || $accountancy_code_sell_export ==
'-1') {
857 $object->accountancy_code_sell_export =
'';
859 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
861 if (empty($accountancy_code_buy) || $accountancy_code_buy ==
'-1') {
862 $object->accountancy_code_buy =
'';
864 $object->accountancy_code_buy = $accountancy_code_buy;
866 if (empty($accountancy_code_buy_intra) || $accountancy_code_buy_intra ==
'-1') {
867 $object->accountancy_code_buy_intra =
'';
869 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
871 if (empty($accountancy_code_buy_export) || $accountancy_code_buy_export ==
'-1') {
872 $object->accountancy_code_buy_export =
'';
874 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
877 $object->mandatory_period = (!empty($checkmandatory)) ? 1 : 0 ;
883 $ret = $extrafields->setOptionalsFromPost(
null,
$object,
'@GETPOSTISSET');
888 if (!$error &&
$object->check()) {
891 $categories =
GETPOST(
'categories',
'array');
892 $object->setCategories($categories);
907 setEventMessages($langs->trans(
"ErrorProductBadRefOrLabel"),
null,
'errors');
916 if ($action ==
'confirm_clone' && $confirm !=
'yes') {
919 if ($action ==
'confirm_clone' && $confirm ==
'yes' && $usercancreate) {
930 $clone->ref =
GETPOST(
'clone_ref',
'alphanohtml');
932 $clone->status_buy = 0;
933 $clone->barcode = -1;
935 if ($clone->check()) {
938 $clone->context[
'createfromclone'] =
'createfromclone';
939 $id = $clone->create($user);
941 if (
GETPOST(
'clone_composition')) {
942 $result = $clone->clone_associations(
$object->id, $id);
950 if (!$error &&
GETPOST(
'clone_categories')) {
951 $result = $clone->cloneCategories(
$object->id, $id);
959 if (!$error &&
GETPOST(
'clone_prices')) {
960 $result = $clone->clone_price(
$object->id, $id);
968 if (!$error && isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
971 $bomstatic =
new BOM($db);
972 $bomclone = $bomstatic->createFromClone($user,
$object->fk_default_bom);
973 if ((
int) $bomclone < 0) {
974 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
976 $defbomidac =
$object->fk_default_bom;
977 $clone->fk_default_bom = $bomclone->id;
978 $clone->update($id, $user);
979 $bomclone->fk_product =
$id;
980 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
981 $bomclone->update($user);
982 $bomclone->validate($user);
985 if (
GETPOST(
'clone_otherboms')) {
986 $bomstatic =
new BOM($db);
987 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
988 if (is_array($bomlist)) {
989 foreach ($bomlist as $bom2clone) {
990 if ($bom2clone->id != $defbomidac) {
991 $bomclone = $bomstatic->createFromClone($user, $bom2clone->id);
992 if ((
int) $bomclone < 0) {
993 setEventMessages($langs->trans(
'ErrorProductClone').
' : '.$langs->trans(
'ErrorProductCloneBom'),
null,
'warnings');
995 $bomclone->fk_product =
$id;
996 $bomclone->label = $langs->trans(
'BOMofRef', $clone->ref);
997 $bomclone->update($user);
998 $bomclone->validate($user);
1007 if ($clone->error ==
'ErrorProductAlreadyExists') {
1008 $refalreadyexists++;
1011 $mesg = $langs->trans(
"ErrorProductAlreadyExists", $clone->ref);
1012 $mesg .=
' <a href="' . $_SERVER[
"PHP_SELF"] .
'?ref=' . $clone->ref .
'">' . $langs->trans(
"ShowCardHere") .
'</a>.';
1015 setEventMessages(empty($clone->error) ?
'' : $langs->trans($clone->error), $clone->errors,
'errors');
1020 unset($clone->context[
'createfromclone']);
1027 header(
"Location: " . $_SERVER[
"PHP_SELF"] .
"?id=" . $id);
1031 setEventMessages($langs->trans(
"ErrorFieldRequired", $langs->transnoentitiesnoconv(
"NewRefForClone")),
null,
'errors');
1041 if ($action ==
'confirm_delete' && $confirm !=
'yes') {
1044 if ($action ==
'confirm_delete' && $confirm ==
'yes' && $usercandelete) {
1045 $result =
$object->delete($user);
1048 header(
'Location: '.DOL_URL_ROOT.
'/product/list.php?type='.
$object->type.
'&delprod='.urlencode(
$object->ref));
1059 if (
$object->id > 0 && $action ==
'addin') {
1061 $permissiontoaddline =
false;
1064 if (
GETPOST(
'propalid') > 0) {
1065 $propal =
new Propal($db);
1066 $result = $propal->fetch(
GETPOST(
'propalid'));
1071 $thirpdartyid = $propal->socid;
1072 $permissiontoaddline = $user->hasRight(
'propal',
'creer');
1073 } elseif (
GETPOST(
'commandeid') > 0) {
1075 $result = $commande->fetch(
GETPOST(
'commandeid'));
1080 $thirpdartyid = $commande->socid;
1081 $permissiontoaddline = $user->hasRight(
'commande',
'creer');
1082 } elseif (
GETPOST(
'factureid') > 0) {
1084 $result = $facture->fetch(
GETPOST(
'factureid'));
1089 $thirpdartyid = $facture->socid;
1090 $permissiontoaddline = $user->hasRight(
'facture',
'creer');
1093 if ($thirpdartyid > 0) {
1095 $result = $soc->fetch($thirpdartyid);
1105 if (empty($tva_tx)) {
1108 $localtax1_tx =
get_localtax($tva_tx, 1, $soc, $mysoc, $tva_npr);
1109 $localtax2_tx =
get_localtax($tva_tx, 2, $soc, $mysoc, $tva_npr);
1113 $price_base_type =
$object->price_base_type;
1117 $pu_ht =
$object->multiprices[$soc->price_level];
1118 $pu_ttc =
$object->multiprices_ttc[$soc->price_level];
1119 $price_base_type =
$object->multiprices_base_type[$soc->price_level];
1121 require_once DOL_DOCUMENT_ROOT.
'/product/class/productcustomerprice.class.php';
1125 $filter = array(
't.fk_product' =>
$object->id,
't.fk_soc' => $soc->id);
1127 $result = $prodcustprice->fetchAll(
'',
'', 0, 0, $filter);
1129 if (count($prodcustprice->lines) > 0) {
1130 $pu_ht =
price($prodcustprice->lines [0]->price);
1131 $pu_ttc =
price($prodcustprice->lines [0]->price_ttc);
1132 $price_base_type = $prodcustprice->lines [0]->price_base_type;
1133 $tva_tx = $prodcustprice->lines [0]->tva_tx;
1138 $tmpvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $tva_tx));
1139 $tmpprodvat =
price2num(preg_replace(
'/\s*\(.*\)/',
'', $prod->tva_tx));
1143 if ($tmpvat != $tmpprodvat) {
1144 if ($price_base_type !=
'HT') {
1145 $pu_ht =
price2num($pu_ttc / (1 + ((
float) $tmpvat / 100)),
'MU');
1147 $pu_ttc =
price2num($pu_ht * (1 + ((
float) $tmpvat / 100)),
'MU');
1151 if (
GETPOST(
'propalid') > 0 && $permissiontoaddline) {
1154 if (($result = $propal->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1155 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1158 $buyprice = $result;
1161 $result = $propal->addline(
1186 header(
"Location: ".DOL_URL_ROOT.
"/comm/propal/card.php?id=".$propal->id);
1190 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1191 } elseif (
GETPOST(
'commandeid') > 0 && $permissiontoaddline) {
1194 if (($result = $commande->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1195 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1198 $buyprice = $result;
1201 $result = $commande->addline(
1228 header(
"Location: ".DOL_URL_ROOT.
"/commande/card.php?id=".urlencode((
string) ($commande->id)));
1232 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1233 } elseif (
GETPOST(
'factureid') > 0 && $permissiontoaddline) {
1236 if (($result = $facture->defineBuyPrice($pu_ht,
price2num(
GETPOST(
'remise_percent'),
'', 2),
$object->id)) < 0) {
1237 dol_syslog($langs->trans(
'FailedToGetCostPrice'));
1240 $buyprice = $result;
1243 $result = $facture->addline(
1275 header(
"Location: ".DOL_URL_ROOT.
"/compta/facture/card.php?facid=".$facture->id);
1279 setEventMessages($langs->trans(
"ErrorUnknown").
": $result",
null,
'errors');
1283 setEventMessages($langs->trans(
"WarningSelectOneDocument"),
null,
'warnings');
1294$form =
new Form($db);
1298if (isModEnabled(
'accounting')) {
1301$sellOrEatByMandatoryList =
null;
1302if (isModEnabled(
'productbatch')) {
1306$title = $langs->trans(
'ProductServiceCard');
1311 if ($action ==
'create') {
1312 $title = $langs->trans(
"NewProduct");
1314 $title = $langs->trans(
'Product').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1315 $help_url =
'EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos|DE:Modul_Produkte';
1319 if ($action ==
'create') {
1320 $title = $langs->trans(
"NewService");
1322 $title = $langs->trans(
'Service').
" ".$shortlabel.
" - ".$langs->trans(
'Card');
1323 $help_url =
'EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios|DE:Modul_Leistungen';
1327llxHeader(
'', $title, $help_url,
'', 0, 0,
'',
'',
'',
'mod-product page-card');
1333 $dirbarcode = array_merge(array(
'/core/modules/barcode/'), $conf->modules_parts[
'barcode']);
1334 foreach ($dirbarcode as $dirroot) {
1341 $modBarCodeProduct =
new $module();
1345$canvasdisplayaction = $action;
1346if (in_array($canvasdisplayaction, array(
'merge',
'confirm_merge'))) {
1347 $canvasdisplayaction =
'view';
1350if (is_object($objcanvas) && $objcanvas->displayCanvasExists($canvasdisplayaction)) {
1354 $objcanvas->assign_values($canvasdisplayaction,
$object->id,
$object->ref);
1355 $objcanvas->display_canvas($canvasdisplayaction);
1360 if ($action ==
'create' && $usercancreate) {
1362 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1364 if (!empty($conf->use_javascript_ajax)) {
1365 print
'<script type="text/javascript">';
1366 print
'$(document).ready(function () {
1367 $("#selectcountry_id").change(function() {
1368 document.formprod.action.value="create";
1369 document.formprod.submit();
1372 print
'</script>'.
"\n";
1376 $module =
getDolGlobalString(
'PRODUCT_CODEPRODUCT_ADDON',
'mod_codeproduct_leopard');
1377 if (substr($module, 0, 16) ==
'mod_codeproduct_' && substr($module, -3) ==
'php') {
1378 $module = substr($module, 0,
dol_strlen($module) - 4);
1382 $modCodeProduct =
new $module();
1387 print
'<form action="'.$_SERVER[
"PHP_SELF"].
'" method="POST" name="formprod">';
1388 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1389 print
'<input type="hidden" name="action" value="add">';
1390 print
'<input type="hidden" name="type" value="'.$type.
'">'.
"\n";
1391 if (!empty($modCodeProduct->code_auto)) {
1392 print
'<input type="hidden" name="code_auto" value="1">';
1394 if (!empty($modBarCodeProduct->code_auto)) {
1395 print
'<input type="hidden" name="barcode_auto" value="1">';
1397 print
'<input type="hidden" name="backtopage" value="'.$backtopage.
'">';
1401 $title = $langs->trans(
"NewService");
1404 $title = $langs->trans(
"NewProduct");
1410 $object->country_id = GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') : null;
1411 if (
$object->country_id > 0) {
1413 $object->country_code = $tmparray[
'code'];
1414 $object->country = $tmparray[
'label'];
1420 $parameters = array();
1422 $reshook = $hookmanager->executeHooks(
'tabContentCreateProduct', $parameters,
$object, $action);
1423 if (empty($reshook)) {
1424 print
'<table class="border centpercent">';
1429 if (!empty($modCodeProduct->code_auto)) {
1430 $tmpcode = $modCodeProduct->getNextValue(
$object, $type);
1432 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).
'">';
1433 if ($refalreadyexists) {
1434 print $langs->trans(
"RefAlreadyExists");
1440 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>';
1443 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td>';
1444 $statutarray = array(
'1' => $langs->trans(
"OnSell"),
'0' => $langs->trans(
"NotOnSell"));
1445 print $form->selectarray(
'statut', $statutarray,
GETPOST(
'statut'));
1449 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td>';
1450 $statutarray = array(
'1' => $langs->trans(
"ProductStatusOnBuy"),
'0' => $langs->trans(
"ProductStatusNotOnBuy"));
1451 print $form->selectarray(
'statut_buy', $statutarray,
GETPOST(
'statut_buy'));
1455 if (isModEnabled(
'productbatch')) {
1456 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
1457 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
1458 print $form->selectarray(
'status_batch', $statutarray,
GETPOST(
'status_batch'));
1461 $status_batch =
GETPOST(
'status_batch');
1462 if ($status_batch !==
'0') {
1463 $langs->load(
"admin");
1464 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1465 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
1466 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
1467 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
1468 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
1473 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
1476 print
'<td id="field_mask">';
1477 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input">', $tooltip, 1, 1);
1478 print
'<script type="text/javascript">
1479 $(document).ready(function() {
1480 $("#field_mask, #mask_option").addClass("hideobject");
1481 $("#status_batch").on("change", function () {
1482 console.log("We change batch status");
1483 var optionSelected = $("option:selected", this);
1484 var valueSelected = this.value;
1485 $("#field_mask, #mask_option").addClass("hideobject");
1489 if (this.value == 1) {
1490 $("#field_mask, #mask_option").toggleClass("hideobject");
1491 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
1497 if (this.value == 2) {
1498 $("#field_mask, #mask_option").toggleClass("hideobject");
1499 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
1512 if (!empty($sellOrEatByMandatoryList)) {
1513 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->trans(
'SellByDate'), $langs->trans(
'EatByDate')).
'</td><td>';
1514 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList,
GETPOSTINT(
'sell_or_eat_by_mandatory'));
1519 $showbarcode = isModEnabled(
'barcode');
1520 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
1525 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
1526 if (GETPOSTISSET(
'fk_barcode_type')) {
1527 $fk_barcode_type =
GETPOST(
'fk_barcode_type') ?
GETPOST(
'fk_barcode_type') : 0;
1532 $fk_barcode_type = 0;
1535 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
1537 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
1540 print
'<td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
1541 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
1542 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
1543 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
1545 print
img_picto(
'',
'barcode',
'class="pictofixedwidth"');
1546 print
'<input class="maxwidth100" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
1551 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
1552 $doleditor =
new DolEditor(
'desc',
GETPOST(
'desc',
'restricthtml'),
'', 160,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
1553 $doleditor->Create();
1558 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
1559 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
1560 print
'<input type="text" name="url" class="quatrevingtpercent" value="'.GETPOST(
'url').
'">';
1564 if (($type != 1 ||
getDolGlobalInt(
'STOCK_SUPPORTS_SERVICES')) && isModEnabled(
'stock')) {
1566 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
1567 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
1568 print $formproduct->selectWarehouses(
GETPOSTINT(
'fk_default_warehouse'),
'fk_default_warehouse',
'warehouseopen', 1, 0, 0,
'', 0, 0, array(),
'minwidth300 widthcentpercentminusxx maxwidth500');
1569 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&token='.
newToken().
'&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?&action=create&type='.
GETPOSTINT(
'type')).
'">';
1570 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span>';
1578 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"StockLimit"), $langs->trans(
"StockLimitDesc"), 1).
'</td><td>';
1579 print
'<input name="seuil_stock_alerte" class="maxwidth50" value="'.GETPOST(
'seuil_stock_alerte').
'">';
1584 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DesiredStock"), $langs->trans(
"DesiredStockDesc"), 1).
'</td><td>';
1585 print
'<input name="desiredstock" class="maxwidth50" value="'.GETPOST(
'desiredstock').
'">';
1590 print
'<input name="seuil_stock_alerte" type="hidden" value="0">';
1591 print
'<input name="desiredstock" type="hidden" value="0">';
1595 if ($type == $object::TYPE_SERVICE && isModEnabled(
"workstation")) {
1597 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
1598 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
1599 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
1605 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
1606 print
img_picto(
'',
'clock',
'class="pictofixedwidth"');
1607 print
'<input name="duration_value" size="4" value="'.GETPOSTINT(
'duration_value').
'">';
1608 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time", (GETPOSTISSET(
'duration_unit') ?
GETPOST(
'duration_unit',
'alpha') :
'h'), 0, 1);
1611 print
' ';
1612 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
1613 print
'<label for="mandatoryperiod">';
1614 $htmltooltip = $langs->trans(
"mandatoryHelper");
1616 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
1618 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
1627 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
1628 print $formproduct->selectProductNature(
'finished',
$object->finished);
1636 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
1637 print
img_picto(
'',
'fa-balance-scale',
'class="pictofixedwidth"');
1638 print
'<input name="weight" size="4" value="'.GETPOST(
'weight').
'">';
1639 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units',
'alpha') : (!
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT') ? 0 :
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT')), 0, 2);
1645 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
1646 print
img_picto(
'',
'fa-ruler',
'class="pictofixedwidth"');
1647 print
'<input name="size" class="width50" value="'.GETPOST(
'size').
'"> x ';
1648 print
'<input name="sizewidth" class="width50" value="'.GETPOST(
'sizewidth').
'"> x ';
1649 print
'<input name="sizeheight" class="width50" value="'.GETPOST(
'sizeheight').
'">';
1650 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units',
'alpha') :
'0', 0, 2);
1655 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
1656 print
'<input name="surface" size="4" value="'.GETPOST(
'surface').
'">';
1657 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units',
'alpha') :
'0', 0, 2);
1662 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
1663 print
'<input name="volume" size="4" value="'.GETPOST(
'volume').
'">';
1664 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units',
'alpha') :
'0', 0, 2);
1670 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
1671 print
'<input name="net_measure" size="4" value="'.GETPOST(
'net_measure').
'">';
1672 print $formproduct->selectMeasuringUnits(
"net_measure_units",
'', GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units',
'alpha') : (!
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT') ? 0 :
getDolGlobalString(
'MAIN_WEIGHT_DEFAULT_UNIT')), 0, 0);
1679 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
1681 print $form->selectUnits(empty($line->fk_unit) ?
getDolGlobalString(
'PRODUCT_USE_UNITS') : $line->fk_unit,
'units');
1687 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.
GETPOST(
'customcode').
'"></td></tr>';
1690 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
1692 print
img_picto(
'',
'globe-americas',
'class="pictofixedwidth"');
1693 print $form->select_country((GETPOSTISSET(
'country_id') ?
GETPOST(
'country_id') :
$object->country_id),
'country_id',
'', 0,
'minwidth300 widthcentpercentminusx maxwidth500');
1695 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
1703 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1705 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
1708 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
1709 print $formcompany->select_state(
$object->state_id,
$object->country_code);
1716 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth50" value="'.
GETPOST(
'lifetime').
'"></td></tr>';
1717 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth50" value="'.
GETPOST(
'qc_frequency').
'"></td></tr>';
1721 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
1722 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
1723 print $hookmanager->resPrint;
1724 if (empty($reshook)) {
1725 print
$object->showOptionals($extrafields,
'create', $parameters);
1729 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
1732 $doleditor =
new DolEditor(
'note_private',
GETPOST(
'note_private',
'restricthtml'),
'', 140,
'dolibarr_details',
'',
false,
true,
getDolGlobalString(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_8,
'90%');
1733 $doleditor->Create();
1738 if (isModEnabled(
'category')) {
1740 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
1741 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
1742 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo,
GETPOST(
'categories',
'array'),
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
1754 print
'<table class="border centpercent">';
1756 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"VATRate").
'</td><td>';
1758 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1765 print
'<table class="border centpercent">';
1768 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"SellingPrice").
'</td>';
1769 print
'<td><input name="price" class="maxwidth50" value="'.$object->price.
'">';
1770 print $form->selectPriceBaseType(
getDolGlobalString(
'PRODUCT_PRICE_BASE_TYPE'),
"price_base_type");
1774 print
'<tr><td>'.$langs->trans(
"MinPrice").
'</td>';
1775 print
'<td><input name="price_min" class="maxwidth50" value="'.$object->price_min.
'">';
1779 print
'<tr><td>'.$langs->trans(
"VATRate").
'</td><td>';
1781 print $form->load_tva(
"tva_tx", $defaultva, $mysoc, $mysoc, 0, 0,
'',
false, 1);
1791 print
'<!-- accountancy codes -->'.
"\n";
1792 print
'<table class="border centpercent">';
1795 if (isModEnabled(
'accounting')) {
1797 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1800 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_ACCOUNT"));
1802 $accountancy_code_sell = (GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_ACCOUNT"));
1804 print $formaccounting->select_account($accountancy_code_sell,
'accountancy_code_sell', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1808 if ($mysoc->isInEEC()) {
1809 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1812 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_INTRA_ACCOUNT"));
1814 $accountancy_code_sell_intra = (GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_INTRA_ACCOUNT"));
1816 print $formaccounting->select_account($accountancy_code_sell_intra,
'accountancy_code_sell_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1821 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1824 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_SOLD_EXPORT_ACCOUNT"));
1826 $accountancy_code_sell_export = (
GETPOST(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_SOLD_EXPORT_ACCOUNT"));
1828 print $formaccounting->select_account($accountancy_code_sell_export,
'accountancy_code_sell_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1832 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1835 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_ACCOUNT"));
1837 $accountancy_code_buy = (
GETPOST(
'accountancy_code_buy',
'alpha') ? (
GETPOST(
'accountancy_code_buy',
'alpha')) :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_ACCOUNT"));
1839 print $formaccounting->select_account($accountancy_code_buy,
'accountancy_code_buy', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1843 if ($mysoc->isInEEC()) {
1844 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1847 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_INTRA_ACCOUNT"));
1849 $accountancy_code_buy_intra = (GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_INTRA_ACCOUNT"));
1851 print $formaccounting->select_account($accountancy_code_buy_intra,
'accountancy_code_buy_intra', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1856 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1859 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_PRODUCT_BUY_EXPORT_ACCOUNT"));
1861 $accountancy_code_buy_export = (
GETPOST(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export',
'alpha') :
getDolGlobalString(
"ACCOUNTING_SERVICE_BUY_EXPORT_ACCOUNT"));
1863 print $formaccounting->select_account($accountancy_code_buy_export,
'accountancy_code_buy_export', 1,
null, 1, 1,
'minwidth150 maxwidth300', 1);
1866 if (!empty($accountancy_code_sell)) {
1867 $object->accountancy_code_sell = $accountancy_code_sell;
1869 if (!empty($accountancy_code_sell_intra)) {
1870 $object->accountancy_code_sell_intra = $accountancy_code_sell_intra;
1872 if (!empty($accountancy_code_sell_export)) {
1873 $object->accountancy_code_sell_export = $accountancy_code_sell_export;
1875 if (!empty($accountancy_code_buy)) {
1876 $object->accountancy_code_buy = $accountancy_code_buy;
1878 if (!empty($accountancy_code_buy_intra)) {
1879 $object->accountancy_code_buy_intra = $accountancy_code_buy_intra;
1881 if (!empty($accountancy_code_buy_export)) {
1882 $object->accountancy_code_buy_export = $accountancy_code_buy_export;
1886 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
1887 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell" value="'.$object->accountancy_code_sell.
'">';
1891 if ($mysoc->isInEEC()) {
1892 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
1893 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_intra" value="'.$object->accountancy_code_sell_intra.
'">';
1898 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
1899 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_sell_export" value="'.$object->accountancy_code_sell_export.
'">';
1903 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
1904 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy" value="'.$object->accountancy_code_buy.
'">';
1908 if ($mysoc->isInEEC()) {
1909 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
1910 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_intra" value="'.$object->accountancy_code_buy_intra.
'">';
1915 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
1916 print
'<td class="maxwidthonsmartphone"><input class="minwidth150" name="accountancy_code_buy_export" value="'.$object->accountancy_code_buy_export.
'">';
1925 print $form->buttonsSaveCancel(
"Create");
1934 if ($action ==
'edit' && $usercancreate) {
1936 require_once DOL_DOCUMENT_ROOT.
'/core/class/doleditor.class.php';
1938 if (!empty($conf->use_javascript_ajax)) {
1939 print
'<script type="text/javascript">';
1940 print
'$(document).ready(function () {
1941 $("#selectcountry_id").change(function () {
1942 document.formprod.action.value="edit";
1943 document.formprod.submit();
1946 print
'</script>'.
"\n";
1953 $object->country_code = $tmparray[
'code'];
1954 $object->country = $tmparray[
'label'];
1957 $type = $langs->trans(
'Product');
1959 $type = $langs->trans(
'Service');
1964 print
'<form action="'.$_SERVER[
'PHP_SELF'].
'?id='.
$object->id.
'" method="POST" name="formprod">'.
"\n";
1965 print
'<input type="hidden" name="token" value="'.newToken().
'">';
1966 print
'<input type="hidden" name="action" value="update">';
1967 print
'<input type="hidden" name="id" value="'.$object->id.
'">';
1968 print
'<input type="hidden" name="canvas" value="'.$object->canvas.
'">';
1971 $titre = $langs->trans(
"CardProduct".
$object->type);
1973 print
dol_get_fiche_head($head,
'card', $titre, 0, $picto, 0,
'',
'', 0,
'', 1);
1976 $parameters = array();
1978 $reshook = $hookmanager->executeHooks(
'tabContentEditProduct', $parameters,
$object, $action);
1980 if (empty($reshook)) {
1981 print
'<table class="border allwidth">';
1985 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>';
1987 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>';
1991 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>';
1994 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Sell").
')</td><td colspan="3">';
1995 print
'<select class="flat" name="statut">';
1996 if ((GETPOSTISSET(
'statut') &&
GETPOST(
'statut')) || (!GETPOSTISSET(
'statut') &&
$object->status)) {
1997 print
'<option value="1" selected>'.$langs->trans(
"OnSell").
'</option>';
1998 print
'<option value="0">'.$langs->trans(
"NotOnSell").
'</option>';
2000 print
'<option value="1">'.$langs->trans(
"OnSell").
'</option>';
2001 print
'<option value="0" selected>'.$langs->trans(
"NotOnSell").
'</option>';
2007 print
'<tr><td class="fieldrequired">'.$langs->trans(
"Status").
' ('.$langs->trans(
"Buy").
')</td><td colspan="3">';
2008 print
'<select class="flat" name="statut_buy">';
2009 if ((GETPOSTISSET(
'statut_buy') &&
GETPOST(
'statut_buy')) || (!GETPOSTISSET(
'statut_buy') &&
$object->status_buy)) {
2010 print
'<option value="1" selected>'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2011 print
'<option value="0">'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2013 print
'<option value="1">'.$langs->trans(
"ProductStatusOnBuy").
'</option>';
2014 print
'<option value="0" selected>'.$langs->trans(
"ProductStatusNotOnBuy").
'</option>';
2020 if (isModEnabled(
'productbatch')) {
2022 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2023 $statutarray = array(
'0' => $langs->trans(
"ProductStatusNotOnBatch"),
'1' => $langs->trans(
"ProductStatusOnBatch"),
'2' => $langs->trans(
"ProductStatusOnSerial"));
2025 print $form->selectarray(
'status_batch', $statutarray, GETPOSTISSET(
'status_batch') ?
GETPOST(
'status_batch') :
$object->status_batch);
2027 print
'<span id="statusBatchWarning" class="warning" style="display: none;">';
2028 print
img_warning().
' '.$langs->trans(
"WarningConvertFromBatchToSerial").
'</span>';
2030 print
'<span id="statusBatchMouvToGlobal" class="warning" style="display: none;">';
2031 print
img_warning().
' '.$langs->trans(
"WarningTransferBatchStockMouvToGlobal").
'</span>';
2035 print
'<script type="text/javascript">
2036 $(document).ready(function() {
2037 console.log($("#statusBatchWarning"))
2038 $("#status_batch").on("change", function() {
2039 if ($("#status_batch")[0].value == 0){
2040 $("#statusBatchMouvToGlobal").show()
2042 $("#statusBatchMouvToGlobal").hide()
2048 if (
$object->status_batch == 1) {
2049 print
'<script type="text/javascript">
2050 $(document).ready(function() {
2051 console.log($("#statusBatchWarning"))
2052 $("#status_batch").on("change", function() {
2053 if ($("#status_batch")[0].value == 2){
2054 $("#statusBatchWarning").show()
2056 $("#statusBatchWarning").hide()
2064 if (!empty(
$object->status_batch) || !empty($conf->use_javascript_ajax)) {
2065 $langs->load(
"admin");
2066 $tooltip = $langs->trans(
"GenericMaskCodes", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2067 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes2");
2068 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes3");
2069 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes4a", $langs->transnoentities(
"Batch"), $langs->transnoentities(
"Batch"));
2070 $tooltip .=
'<br>'.$langs->trans(
"GenericMaskCodes5");
2073 print
'<tr><td id="mask_option">'.$langs->trans(
"ManageLotMask").
'</td>';
2083 print
'<td id="field_mask">';
2084 print $form->textwithpicto(
'<input type="text" class="flat minwidth175" name="batch_mask" id="batch_mask_input" value="'.$mask.
'">', $tooltip, 1, 1);
2086 if (!empty($conf->use_javascript_ajax)) {
2087 print
'<script type="text/javascript">
2088 $(document).ready(function() {
2089 $("#field_mask").parent().addClass("hideobject");
2090 var preselect = document.getElementById("status_batch");';
2092 print
'if (preselect.value == "2") {
2093 $("#field_mask").parent().removeClass("hideobject");
2097 print
'if (preselect.value == "1") {
2098 $("#field_mask").parent().removeClass("hideobject");
2101 print
'$("#status_batch").on("change", function () {
2102 var optionSelected = $("option:selected", this);
2103 var valueSelected = this.value;
2104 $("#field_mask").parent().addClass("hideobject");
2108 if (this.value == 1) {
2109 $("#field_mask").parent().removeClass("hideobject");
2110 $("#batch_mask_input").val("'.$inherited_mask_lot.
'");
2116 if (this.value == 2) {
2117 $("#field_mask").parent().removeClass("hideobject");
2118 $("#batch_mask_input").val("'.$inherited_mask_sn.
'");
2132 if (!empty($sellOrEatByMandatoryList)) {
2133 if (GETPOSTISSET(
'sell_or_eat_by_mandatory')) {
2134 $sellOrEatByMandatorySelectedId =
GETPOSTINT(
'sell_or_eat_by_mandatory');
2136 $sellOrEatByMandatorySelectedId =
$object->sell_or_eat_by_mandatory;
2138 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->trans(
'SellByDate'), $langs->trans(
'EatByDate')).
'</td><td>';
2139 print $form->selectarray(
'sell_or_eat_by_mandatory', $sellOrEatByMandatoryList, $sellOrEatByMandatorySelectedId);
2145 $showbarcode = isModEnabled(
'barcode');
2146 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2151 print
'<tr><td>'.$langs->trans(
'BarcodeType').
'</td><td>';
2152 if (GETPOSTISSET(
'fk_barcode_type')) {
2153 $fk_barcode_type =
GETPOST(
'fk_barcode_type');
2155 $fk_barcode_type =
$object->barcode_type;
2160 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2162 print $formbarcode->selectBarcodeType($fk_barcode_type,
'fk_barcode_type', 1);
2164 print
'<tr><td>'.$langs->trans(
"BarcodeValue").
'</td><td>';
2165 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2166 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2167 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2169 print
'<input class="maxwidth150 maxwidthonsmartphone" type="text" name="barcode" value="'.dol_escape_htmltag($tmpcode).
'">';
2174 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td><td>';
2177 $doleditor =
new DolEditor(
'desc', GETPOSTISSET(
'desc') ?
GETPOST(
'desc',
'restricthtml') :
$object->
description,
'', 160,
'dolibarr_details',
'', false, true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_DETAILS'), ROWS_4,
'90%');
2178 $doleditor->Create();
2185 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2186 print
img_picto(
'',
'globe',
'class="pictofixedwidth"');
2187 print
'<input type="text" name="url" class="maxwidth500 widthcentpercentminusx" value="'.(GETPOSTISSET(
'url') ?
GETPOST(
'url') :
$object->url).
'">';
2194 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2195 print
img_picto($langs->trans(
"DefaultWarehouse"),
'stock',
'class="pictofixedwidth"');
2196 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');
2197 print
' <a href="'.DOL_URL_ROOT.
'/product/stock/card.php?action=create&backtopage='.urlencode($_SERVER[
'PHP_SELF'].
'?action=edit&id='.((
int)
$object->id)).
'">';
2198 print
'<span class="fa fa-plus-circle valignmiddle paddingleft" title="'.$langs->trans(
"AddWarehouse").
'"></span></a>';
2211 if (
$object->isService() && isModEnabled(
'workstation')) {
2213 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2214 print
img_picto($langs->trans(
"DefaultWorkstation"),
'workstation',
'class="pictofixedwidth"');
2215 print $formproduct->selectWorkstations(
$object->fk_default_workstation,
'fk_default_workstation', 1);
2228 print
'<tr><td>'.$langs->trans(
"Duration").
'</td><td>';
2229 print
'<input name="duration_value" size="5" value="'.$object->duration_value.
'"> ';
2230 print $formproduct->selectMeasuringUnits(
"duration_unit",
"time",
$object->duration_unit, 0, 1);
2233 print
' ';
2234 print
'<input type="checkbox" id="mandatoryperiod" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
'>';
2235 print
'<label for="mandatoryperiod">';
2236 $htmltooltip = $langs->trans(
"mandatoryHelper");
2238 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2240 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2247 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2248 print $formproduct->selectProductNature(
'finished', (GETPOSTISSET(
'finished') ?
GETPOST(
'finished') :
$object->finished));
2253 if (!
$object->isService() && isModEnabled(
'bom')) {
2254 print
'<tr><td>'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2255 $bomkey =
"Bom:bom/class/bom.class.php:0:(t.status:=:1) AND (t.fk_product:=:".((int)
$object->id).
')';
2256 print $form->selectForForms($bomkey,
'fk_default_bom', (GETPOSTISSET(
'fk_default_bom') ?
GETPOST(
'fk_default_bom') :
$object->fk_default_bom), 1);
2263 print
'<tr><td>'.$langs->trans(
"Weight").
'</td><td>';
2264 print
'<input name="weight" size="5" value="'.(GETPOSTISSET(
'weight') ?
GETPOST(
'weight') :
$object->weight).
'"> ';
2265 print $formproduct->selectMeasuringUnits(
"weight_units",
"weight", GETPOSTISSET(
'weight_units') ?
GETPOST(
'weight_units') :
$object->weight_units, 0, 2);
2271 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2272 print
'<input name="size" size="5" value="'.(GETPOSTISSET(
'size') ?
GETPOST(
'size') :
$object->length).
'">x';
2273 print
'<input name="sizewidth" size="5" value="'.(GETPOSTISSET(
'sizewidth') ?
GETPOST(
'sizewidth') :
$object->width).
'">x';
2274 print
'<input name="sizeheight" size="5" value="'.(GETPOSTISSET(
'sizeheight') ?
GETPOST(
'sizeheight') :
$object->height).
'"> ';
2275 print $formproduct->selectMeasuringUnits(
"size_units",
"size", GETPOSTISSET(
'size_units') ?
GETPOST(
'size_units') :
$object->length_units, 0, 2);
2280 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2281 print
'<input name="surface" size="5" value="'.(GETPOSTISSET(
'surface') ?
GETPOST(
'surface') :
$object->surface).
'"> ';
2282 print $formproduct->selectMeasuringUnits(
"surface_units",
"surface", GETPOSTISSET(
'surface_units') ?
GETPOST(
'surface_units') :
$object->surface_units, 0, 2);
2287 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2288 print
'<input name="volume" size="5" value="'.(GETPOSTISSET(
'volume') ?
GETPOST(
'volume') :
$object->volume).
'"> ';
2289 print $formproduct->selectMeasuringUnits(
"volume_units",
"volume", GETPOSTISSET(
'volume_units') ?
GETPOST(
'volume_units') :
$object->volume_units, 0, 2);
2295 print
'<tr><td>'.$langs->trans(
"NetMeasure").
'</td><td>';
2296 print
'<input name="net_measure" size="5" value="'.(GETPOSTISSET(
'net_measure') ?
GETPOST(
'net_measure') :
$object->net_measure).
'"> ';
2297 print $formproduct->selectMeasuringUnits(
"net_measure_units",
"", GETPOSTISSET(
'net_measure_units') ?
GETPOST(
'net_measure_units') :
$object->net_measure_units, 0, 0);
2303 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td>';
2305 print $form->selectUnits(
$object->fk_unit,
'units');
2311 print
'<tr><td class="wordbreak">'.$langs->trans(
"CustomCode").
'</td><td><input name="customcode" class="maxwidth100onsmartphone" value="'.(GETPOSTISSET(
'customcode') ?
GETPOST(
'customcode') :
$object->customcode).
'"></td></tr>';
2313 print
'<tr><td>'.$langs->trans(
"CountryOrigin").
'</td>';
2315 print
img_picto(
'',
'globe-americas',
'class="paddingrightonly"');
2316 print $form->select_country(GETPOSTISSET(
'country_id') ?
GETPOSTINT(
'country_id') :
$object->country_id,
'country_id',
'', 0,
'minwidth100 maxwidthonsmartphone');
2318 print
info_admin($langs->trans(
"YouCanChangeValuesForThisListFromDictionarySetup"), 1);
2326 print
'<td>'.$form->editfieldkey(
'RegionStateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2328 print
'<td>'.$form->editfieldkey(
'StateOrigin',
'state_id',
'',
$object, 0).
'</td><td>';
2331 print
img_picto(
'',
'state',
'class="pictofixedwidth"');
2332 print $formcompany->select_state(GETPOSTISSET(
'state_id') ?
GETPOSTINT(
'state_id') :
$object->state_id,
$object->country_code);
2340 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td><input name="lifetime" class="maxwidth100onsmartphone" value="'.
$object->lifetime.
'"></td></tr>';
2341 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td><input name="qc_frequency" class="maxwidth100onsmartphone" value="'.
$object->qc_frequency.
'"></td></tr>';
2345 $parameters = array(
'colspan' =>
' colspan="2"',
'cols' => 2);
2346 $reshook = $hookmanager->executeHooks(
'formObjectOptions', $parameters,
$object, $action);
2347 print $hookmanager->resPrint;
2348 if (empty($reshook)) {
2349 print
$object->showOptionals($extrafields,
'edit', $parameters);
2353 if (isModEnabled(
'category')) {
2354 print
'<tr><td>'.$langs->trans(
"Categories").
'</td><td>';
2355 $cate_arbo = $form->select_all_categories(Categorie::TYPE_PRODUCT,
'',
'parent', 64, 0, 3);
2357 $cats = $c->containing(
$object->id, Categorie::TYPE_PRODUCT);
2358 $arrayselected = array();
2359 if (is_array($cats)) {
2360 foreach ($cats as $cat) {
2361 $arrayselected[] = $cat->id;
2365 foreach (
GETPOST(
'categories',
'array') as $cat) {
2366 $arrayselected[] = $cat;
2369 print
img_picto(
'',
'category',
'class="pictofixedwidth"').$form->multiselectarray(
'categories', $cate_arbo, $arrayselected,
'', 0,
'quatrevingtpercent widthcentpercentminusx', 0, 0);
2375 print
'<tr><td class="tdtop">'.$langs->trans(
"NoteNotVisibleOnBill").
'</td><td>';
2377 $doleditor =
new DolEditor(
'note_private',
$object->note_private,
'', 140,
'dolibarr_notes',
'',
false,
true,
getDolGlobalInt(
'FCKEDITOR_ENABLE_NOTE_PRIVATE'), ROWS_4,
'90%');
2378 $doleditor->Create();
2387 print
'<table class="border centpercent">';
2390 if (isModEnabled(
'accounting')) {
2392 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2394 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell),
'accountancy_code_sell', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2398 if ($mysoc->isInEEC()) {
2399 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2401 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_intra') ?
GETPOST(
'accountancy_code_sell_intra') :
$object->accountancy_code_sell_intra),
'accountancy_code_sell_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2406 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2408 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_sell_export') ?
GETPOST(
'accountancy_code_sell_export') :
$object->accountancy_code_sell_export),
'accountancy_code_sell_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2412 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2414 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy),
'accountancy_code_buy', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2418 if ($mysoc->isInEEC()) {
2419 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2421 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_intra') ?
GETPOST(
'accountancy_code_buy_intra') :
$object->accountancy_code_buy_intra),
'accountancy_code_buy_intra', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2426 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2428 print $formaccounting->select_account((GETPOSTISSET(
'accountancy_code_buy_export') ?
GETPOST(
'accountancy_code_buy_export') :
$object->accountancy_code_buy_export),
'accountancy_code_buy_export', 1,
'', 1, 1,
'minwidth150 maxwidth300');
2433 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellCode").
'</td>';
2434 print
'<td><input name="accountancy_code_sell" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_sell') ?
GETPOST(
'accountancy_code_sell') :
$object->accountancy_code_sell).
'">';
2438 if ($mysoc->isInEEC()) {
2439 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellIntraCode").
'</td>';
2440 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).
'">';
2445 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancySellExportCode").
'</td>';
2446 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).
'">';
2450 print
'<tr><td>'.$langs->trans(
"ProductAccountancyBuyCode").
'</td>';
2451 print
'<td><input name="accountancy_code_buy" class="maxwidth200" value="'.(GETPOSTISSET(
'accountancy_code_buy') ?
GETPOST(
'accountancy_code_buy') :
$object->accountancy_code_buy).
'">';
2455 if ($mysoc->isInEEC()) {
2456 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyIntraCode").
'</td>';
2457 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).
'">';
2462 print
'<tr><td class="titlefieldcreate">'.$langs->trans(
"ProductAccountancyBuyExportCode").
'</td>';
2463 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).
'">';
2472 print $form->buttonsSaveCancel();
2478 $showbarcode = isModEnabled(
'barcode');
2479 if (
getDolGlobalString(
'MAIN_USE_ADVANCED_PERMS') && !$user->hasRight(
'barcode',
'lire_advance')) {
2484 $titre = $langs->trans(
"CardProduct".
$object->type);
2489 $linkback =
'<a href="'.DOL_URL_ROOT.
'/product/list.php?restore_lastsearch_values=1&type='.
$object->type.
'">'.$langs->trans(
"BackToList").
'</a>';
2490 $object->next_prev_filter =
"fk_product_type:=:".((int)
$object->type);
2493 if ($user->socid && !in_array(
'product', explode(
',',
getDolGlobalString(
'MAIN_MODULES_FOR_EXTERNAL')))) {
2497 dol_banner_tab(
$object,
'ref', $linkback, $shownav,
'ref');
2500 $parameters = array();
2502 $reshook = $hookmanager->executeHooks(
'tabContentViewProduct', $parameters,
$object, $action);
2503 if (empty($reshook)) {
2504 print
'<div class="fichecenter">';
2505 print
'<div class="fichehalfleft">';
2507 print
'<div class="underbanner clearboth"></div>';
2508 print
'<table class="border tableforfield centpercent">';
2511 if (isModEnabled(
"product") && isModEnabled(
"service")) {
2512 $typeformat =
'select;0:'.$langs->trans(
"Product").
',1:'.$langs->trans(
"Service");
2513 print
'<tr><td class="titlefield">';
2514 print (!
getDolGlobalString(
'PRODUCT_DENY_CHANGE_PRODUCT_TYPE')) ? $form->editfieldkey(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat) : $langs->trans(
'Type');
2516 print $form->editfieldval(
"Type",
'fk_product_type',
$object->type,
$object, $usercancreate, $typeformat);
2522 print
'<tr><td class="nowrap">';
2523 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2524 print $langs->trans(
"BarcodeType");
2526 if (($action !=
'editbarcodetype') && $usercancreate && $createbarcode) {
2527 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>';
2529 print
'</tr></table>';
2531 if ($action ==
'editbarcodetype' || $action ==
'editbarcode') {
2532 require_once DOL_DOCUMENT_ROOT.
'/core/class/html.formbarcode.class.php';
2536 $fk_barcode_type =
'';
2537 if ($action ==
'editbarcodetype') {
2538 print $formbarcode->formBarcodeType($_SERVER[
'PHP_SELF'].
'?id='.
$object->id,
$object->barcode_type,
'fk_barcode_type');
2539 $fk_barcode_type =
$object->barcode_type;
2542 $fk_barcode_type =
$object->barcode_type;
2543 print
$object->barcode_type_label ?
$object->barcode_type_label : (
$object->barcode ?
'<div class="warning">'.$langs->trans(
"SetDefaultBarcodeType").
'<div>' :
'');
2545 print
'</td></tr>'.
"\n";
2548 print
'<tr><td class="nowrap">';
2549 print
'<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
2550 print $langs->trans(
"BarcodeValue");
2552 if (($action !=
'editbarcode') && $usercancreate && $createbarcode) {
2553 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>';
2555 print
'</tr></table>';
2556 print
'</td><td class="wordbreak">';
2557 if ($action ==
'editbarcode') {
2558 $tmpcode = GETPOSTISSET(
'barcode') ?
GETPOST(
'barcode') :
$object->barcode;
2559 if (empty($tmpcode) && !empty($modBarCodeProduct->code_auto)) {
2560 $tmpcode = $modBarCodeProduct->getNextValue(
$object, $fk_barcode_type);
2563 print
'<form method="post" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
2564 print
'<input type="hidden" name="token" value="'.newToken().
'">';
2565 print
'<input type="hidden" name="action" value="setbarcode">';
2566 print
'<input type="hidden" name="barcode_type_code" value="'.$object->barcode_type_code.
'">';
2567 print
'<input class="width300" class="maxwidthonsmartphone" type="text" name="barcode" value="'.$tmpcode.
'">';
2568 print
' <input type="submit" class="button smallpaddingimp" value="'.$langs->trans(
"Modify").
'">';
2573 print
'</td></tr>'.
"\n";
2577 if (isModEnabled(
'productbatch')) {
2579 print
'<tr><td>'.$langs->trans(
"ManageLotSerial").
'</td><td>';
2580 print
$object->getLibStatut(0, 2);
2584 print
'<tr><td>'.$langs->trans(
"ManageLotMask").
'</td><td>';
2590 print
'<tr><td>'.$langs->trans(
'BatchSellOrEatByMandatoryList', $langs->trans(
'SellByDate'), $langs->trans(
'EatByDate')).
'</td><td>';
2591 print
$object->getSellOrEatByMandatoryLabel();
2597 print
'<tr><td class="nowrap">';
2598 print $langs->trans(
"ProductAccountancySellCode");
2600 if (isModEnabled(
'accounting')) {
2601 if (!empty(
$object->accountancy_code_sell)) {
2603 $accountingaccount->fetch(
'',
$object->accountancy_code_sell, 1);
2605 print $accountingaccount->getNomUrl(0, 1, 1,
'', 1);
2608 print
$object->accountancy_code_sell;
2613 if ($mysoc->isInEEC()) {
2614 print
'<tr><td class="nowrap">';
2615 print $langs->trans(
"ProductAccountancySellIntraCode");
2617 if (isModEnabled(
'accounting')) {
2618 if (!empty(
$object->accountancy_code_sell_intra)) {
2620 $accountingaccount2->fetch(
'',
$object->accountancy_code_sell_intra, 1);
2622 print $accountingaccount2->getNomUrl(0, 1, 1,
'', 1);
2625 print
$object->accountancy_code_sell_intra;
2631 print
'<tr><td class="nowrap">';
2632 print $langs->trans(
"ProductAccountancySellExportCode");
2634 if (isModEnabled(
'accounting')) {
2635 if (!empty(
$object->accountancy_code_sell_export)) {
2637 $accountingaccount3->fetch(
'',
$object->accountancy_code_sell_export, 1);
2639 print $accountingaccount3->getNomUrl(0, 1, 1,
'', 1);
2642 print
$object->accountancy_code_sell_export;
2647 print
'<tr><td class="nowrap">';
2648 print $langs->trans(
"ProductAccountancyBuyCode");
2650 if (isModEnabled(
'accounting')) {
2651 if (!empty(
$object->accountancy_code_buy)) {
2653 $accountingaccount4->fetch(
'',
$object->accountancy_code_buy, 1);
2655 print $accountingaccount4->getNomUrl(0, 1, 1,
'', 1);
2658 print
$object->accountancy_code_buy;
2663 if ($mysoc->isInEEC()) {
2664 print
'<tr><td class="nowrap">';
2665 print $langs->trans(
"ProductAccountancyBuyIntraCode");
2667 if (isModEnabled(
'accounting')) {
2668 if (!empty(
$object->accountancy_code_buy_intra)) {
2670 $accountingaccount5->fetch(
'',
$object->accountancy_code_buy_intra, 1);
2672 print $accountingaccount5->getNomUrl(0, 1, 1,
'', 1);
2675 print
$object->accountancy_code_buy_intra;
2681 print
'<tr><td class="nowrap">';
2682 print $langs->trans(
"ProductAccountancyBuyExportCode");
2684 if (isModEnabled(
'accounting')) {
2685 if (!empty(
$object->accountancy_code_buy_export)) {
2687 $accountingaccount6->fetch(
'',
$object->accountancy_code_buy_export, 1);
2689 print $accountingaccount6->getNomUrl(0, 1, 1,
'', 1);
2692 print
$object->accountancy_code_buy_export;
2698 print
'<tr><td class="tdtop">'.$langs->trans(
"Description").
'</td>';
2699 print
'<td class="wordbreakimp wrapimp"><div class="longmessagecut">'.(dol_textishtml(
$object->description) ?
$object->description :
dol_nl2br(
$object->description, 1,
true)).
'</div></td></tr>';
2703 print
'<tr><td>'.$langs->trans(
"PublicUrl").
'</td><td>';
2711 $warehouse->fetch(
$object->fk_default_warehouse);
2713 print
'<tr><td>'.$langs->trans(
"DefaultWarehouse").
'</td><td>';
2714 print(!empty($warehouse->id) ? $warehouse->getNomUrl(1) :
'');
2718 if (
$object->isService() && isModEnabled(
'workstation')) {
2720 $res = $workstation->fetch(
$object->fk_default_workstation);
2722 print
'<tr><td>'.$langs->trans(
"DefaultWorkstation").
'</td><td>';
2723 print(!empty($workstation->id) ? $workstation->getNomUrl(1) :
'');
2728 if (isModEnabled(
'variants') && (
$object->isProduct() ||
$object->isService())) {
2731 if ($combination->fetchByFkProductChild(
$object->id) > 0) {
2732 $prodstatic =
new Product($db);
2733 $prodstatic->fetch($combination->fk_product_parent);
2736 print
'<tr><td>'.$langs->trans(
"ParentProduct").
'</td><td>';
2737 print $prodstatic->getNomUrl(1);
2744 print
'<div class="fichehalfright">';
2746 print
'<div class="underbanner clearboth"></div>';
2747 print
'<table class="border tableforfield centpercent">';
2751 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Duration").
'</td><td>';
2752 print
$object->duration_value;
2753 if (
$object->duration_value > 1) {
2754 $dur = array(
"i" => $langs->trans(
"Minute"),
"h" => $langs->trans(
"Hours"),
"d" => $langs->trans(
"Days"),
"w" => $langs->trans(
"Weeks"),
"m" => $langs->trans(
"Months"),
"y" => $langs->trans(
"Years"));
2755 } elseif (
$object->duration_value > 0) {
2756 $dur = array(
"i" => $langs->trans(
"Minute"),
"h" => $langs->trans(
"Hour"),
"d" => $langs->trans(
"Day"),
"w" => $langs->trans(
"Week"),
"m" => $langs->trans(
"Month"),
"y" => $langs->trans(
"Year"));
2758 print(!empty(
$object->duration_unit) && isset($dur[
$object->duration_unit]) ?
" ".$langs->trans($dur[
$object->duration_unit]).
" " :
'');
2761 if (
$object->duration_value > 0) {
2762 print
' ';
2764 $htmltooltip = $langs->trans(
"mandatoryHelper");
2766 $htmltooltip .=
'<br>'.$langs->trans(
"mandatoryHelper2");
2768 print
'<input type="checkbox" class="" name="mandatoryperiod"'.($object->mandatory_period == 1 ?
' checked="checked"' :
'').
' disabled>';
2769 print $form->textwithpicto($langs->trans(
"mandatoryperiod"), $htmltooltip, 1, 0);
2775 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"NatureOfProductShort"), $langs->trans(
"NatureOfProductDesc")).
'</td><td>';
2776 print
$object->getLibFinished();
2781 if (!
$object->isService() && isModEnabled(
'bom') &&
$object->finished) {
2782 print
'<tr><td class="titlefieldmiddle">'.$form->textwithpicto($langs->trans(
"DefaultBOM"), $langs->trans(
"DefaultBOMDesc", $langs->transnoentitiesnoconv(
"Finished"))).
'</td><td>';
2783 if (
$object->fk_default_bom) {
2784 $bom_static =
new BOM($db);
2785 $bom_static->fetch(
$object->fk_default_bom);
2786 print $bom_static->getNomUrl(1);
2794 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"Weight").
'</td><td>';
2800 print
"</td></tr>\n";
2805 print
'<tr><td>'.$langs->trans(
"Length").
' x '.$langs->trans(
"Width").
' x '.$langs->trans(
"Height").
'</td><td>';
2809 print
" x ".$object->width;
2812 print
" x ".$object->height;
2814 print
' '.measuringUnitString(0,
"size",
$object->length_units);
2818 print
"</td></tr>\n";
2822 print
'<tr><td>'.$langs->trans(
"Surface").
'</td><td>';
2828 print
"</td></tr>\n";
2832 print
'<tr><td>'.$langs->trans(
"Volume").
'</td><td>';
2838 print
"</td></tr>\n";
2843 print
'<tr><td class="titlefieldmiddle">'.$langs->trans(
"NetMeasure").
'</td><td>';
2844 if (
$object->net_measure !=
'') {
2855 $unit =
$object->getLabelOfUnit();
2857 print
'<tr><td>'.$langs->trans(
'DefaultUnitToShow').
'</td><td>';
2859 print $langs->trans($unit);
2866 print
'<tr><td>'.$langs->trans(
"CustomCode").
'</td><td>'.
$object->customcode.
'</td></tr>';
2869 print
'<tr><td>'.$langs->trans(
"Origin").
'</td><td>'.
getCountry(
$object->country_id,
'', $db);
2870 if (!empty(
$object->state_id)) {
2871 print
' - '.getState(
$object->state_id,
'0', $db);
2878 print
'<tr><td>'.$langs->trans(
"LifeTime").
'</td><td>'.
$object->lifetime.
'</td></tr>';
2879 print
'<tr><td>'.$langs->trans(
"QCFrequency").
'</td><td>'.
$object->qc_frequency.
'</td></tr>';
2883 $parameters = array();
2884 include DOL_DOCUMENT_ROOT.
'/core/tpl/extrafields_view.tpl.php';
2887 if (isModEnabled(
'category')) {
2888 print
'<tr><td class="valignmiddle">'.$langs->trans(
"Categories").
'</td><td>';
2889 print $form->showCategories(
$object->id, Categorie::TYPE_PRODUCT, 1);
2895 print
'<!-- show Note --> '.
"\n";
2897 print
'<!-- End show Note --> '.
"\n";
2904 print
'<div class="clearboth"></div>';
2909 } elseif ($action !=
'create') {
2915if (!empty($modCodeProduct->code_auto)) {
2916 $tmpcode = $modCodeProduct->getNextValue(
$object,
$object->type);
2922if (($action ==
'delete' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2923 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2924 $formconfirm = $form->formconfirm(
"card.php?id=".
$object->id, $langs->trans(
"DeleteProduct"), $langs->trans(
"ConfirmDeleteProduct"),
"confirm_delete",
'', 0,
"action-delete");
2926if ($action ==
'merge') {
2927 $formquestion = array(
2929 'name' =>
'product_origin',
2930 'label' => $langs->trans(
'MergeOriginProduct'),
2932 'value' => $form->select_produits(
'',
'product_origin',
'', 0, 0, 1, 2,
'', 1, array(), 0, 1, 0,
'minwidth200', 0,
'',
null, 1),
2935 $formconfirm = $form->formconfirm($_SERVER[
"PHP_SELF"].
"?id=".
$object->id, $langs->trans(
"MergeProducts"), $langs->trans(
"ConfirmMergeProducts"),
"confirm_merge", $formquestion,
'no', 1, 250);
2939if (($action ==
'clone' && (empty($conf->use_javascript_ajax) || !empty($conf->dol_use_jmobile)))
2940 || (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile))) {
2942 $formquestionclone = array(
2943 'text' => $langs->trans(
"ConfirmClone"),
2944 0 => array(
'type' =>
'text',
'name' =>
'clone_ref',
'label' => $langs->trans(
"NewRefForClone"),
'value' => empty($tmpcode) ? $langs->trans(
"CopyOf").
' '.
$object->ref : $tmpcode,
'morecss' =>
'width150'),
2945 1 => array(
'type' =>
'checkbox',
'name' =>
'clone_content',
'label' => $langs->trans(
"CloneContentProduct"),
'value' => 1),
2946 2 => array(
'type' =>
'checkbox',
'name' =>
'clone_categories',
'label' => $langs->trans(
"CloneCategoriesProduct"),
'value' => 1),
2949 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_prices',
'label' => $langs->trans(
"ClonePricesProduct").
' ('.$langs->trans(
"CustomerPrices").
')',
'value' => 0);
2952 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_composition',
'label' => $langs->trans(
'CloneCompositionProduct'),
'value' => 1);
2954 if (isModEnabled(
'bom') && $user->hasRight(
'bom',
'write')) {
2955 if (
$object->fk_default_bom > 0) {
2956 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_defbom',
'label' => $langs->trans(
"CloneDefBomProduct"),
'value' =>
getDolGlobalInt(
'BOM_CLONE_DEFBOM'));
2958 $bomstatic =
new BOM($db);
2959 $bomlist = $bomstatic->fetchAll(
"",
"", 0, 0,
'fk_product:=:'.(
int)
$object->id);
2960 if (is_array($bomlist) && count($bomlist) > 0) {
2961 $formquestionclone[] = array(
'type' =>
'checkbox',
'name' =>
'clone_otherboms',
'label' => $langs->trans(
"CloneOtherBomsProduct"),
'value' => 0);
2964 $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);
2968$parameters = array(
'formConfirm' => $formconfirm,
'object' =>
$object);
2969$reshook = $hookmanager->executeHooks(
'formConfirm', $parameters,
$object, $action);
2970if (empty($reshook)) {
2971 $formconfirm .= $hookmanager->resPrint;
2972} elseif ($reshook > 0) {
2973 $formconfirm = $hookmanager->resPrint;
2982if ($action !=
'create' && $action !=
'edit') {
2983 $cloneProductUrl = $_SERVER[
"PHP_SELF"].
'?action=clone&token='.
newToken();
2984 $cloneButtonId =
'action-clone-no-ajax';
2986 print
"\n".
'<div class="tabsAction">'.
"\n";
2988 $parameters = array();
2989 $reshook = $hookmanager->executeHooks(
'addMoreActionsButtons', $parameters,
$object, $action);
2990 if (empty($reshook)) {
2991 if ($usercancreate) {
2992 if (!isset($hookmanager->resArray[
'no_button_edit']) || $hookmanager->resArray[
'no_button_edit'] != 1) {
2996 if (!isset($hookmanager->resArray[
'no_button_copy']) || $hookmanager->resArray[
'no_button_copy'] != 1) {
2997 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
2998 $cloneProductUrl =
'';
2999 $cloneButtonId =
'action-clone';
3001 print
dolGetButtonAction($langs->trans(
'ToClone'),
'',
'default', $cloneProductUrl, $cloneButtonId, $usercancreate);
3006 if ($usercandelete) {
3007 if (empty($object_is_used)) {
3008 if (!isset($hookmanager->resArray[
'no_button_delete']) || $hookmanager->resArray[
'no_button_delete'] != 1) {
3009 if (!empty($conf->use_javascript_ajax) && empty($conf->dol_use_jmobile)) {
3010 print
dolGetButtonAction($langs->trans(
'Delete'),
'',
'delete',
'#',
'action-delete',
true);
3016 print
dolGetButtonAction($langs->trans(
"ProductIsUsed"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3019 print
'<a class="butActionDelete" href="card.php?action=merge&id='.$object->id.
'" title="'.
dol_escape_htmltag($langs->trans(
"MergeProducts")).
'">'.$langs->trans(
'Merge').
'</a>'.
"\n";
3022 print
dolGetButtonAction($langs->trans(
"NotEnoughPermissions"), $langs->trans(
'Delete'),
'delete',
'#',
'',
false);
3040 if (isModEnabled(
"propal") && $user->hasRight(
'propal',
'creer')) {
3041 $propal =
new Propal($db);
3043 $langs->load(
"propal");
3045 $otherprop = $propal->liste_array(2, 1, 0);
3047 if (is_array($otherprop) && count($otherprop)) {
3048 $html .=
'<tr><td style="width: 200px;">';
3049 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3050 $html .= $form->selectarray(
"propalid", $otherprop, 0, 1);
3051 $html .=
'</td></tr>';
3053 $html .=
'<tr><td style="width: 200px;">';
3054 $html .= $langs->trans(
"AddToDraftProposals").
'</td><td>';
3055 $html .= $langs->trans(
"NoDraftProposals");
3056 $html .=
'</td></tr>';
3061 if (isModEnabled(
'order') && $user->hasRight(
'commande',
'creer')) {
3064 $langs->load(
"orders");
3066 $othercom = $commande->liste_array(2, 1,
null);
3067 if (is_array($othercom) && count($othercom)) {
3068 $html .=
'<tr><td style="width: 200px;">';
3069 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3070 $html .= $form->selectarray(
"commandeid", $othercom, 0, 1);
3071 $html .=
'</td></tr>';
3073 $html .=
'<tr><td style="width: 200px;">';
3074 $html .= $langs->trans(
"AddToDraftOrders").
'</td><td>';
3075 $html .= $langs->trans(
"NoDraftOrders");
3076 $html .=
'</td></tr>';
3081 if (isModEnabled(
'invoice') && $user->hasRight(
'facture',
'creer')) {
3084 $langs->load(
"bills");
3086 $otherinvoice = $invoice->liste_array(2, 1,
null);
3087 if (is_array($otherinvoice) && count($otherinvoice)) {
3088 $html .=
'<tr><td style="width: 200px;">';
3089 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3090 $html .= $form->selectarray(
"factureid", $otherinvoice, 0, 1);
3091 $html .=
'</td></tr>';
3093 $html .=
'<tr><td style="width: 200px;">';
3094 $html .= $langs->trans(
"AddToDraftInvoices").
'</td><td>';
3095 $html .= $langs->trans(
"NoDraftInvoices");
3096 $html .=
'</td></tr>';
3101 if (!empty($html)) {
3102 print
'<form method="POST" action="'.$_SERVER[
"PHP_SELF"].
'?id='.
$object->id.
'">';
3103 print
'<input type="hidden" name="token" value="'.newToken().
'">';
3104 print
'<input type="hidden" name="action" value="addin">';
3110 $html .=
'<tr><td class="nowrap">'.$langs->trans(
"Quantity").
' ';
3111 $html .=
'<input type="text" class="flat" name="qty" size="1" value="1"></td>';
3112 $html .=
'<td class="nowrap">'.$langs->trans(
"ReductionShort").
'(%) ';
3113 $html .=
'<input type="text" class="flat" name="remise_percent" size="1" value="0">';
3114 $html .=
'</td></tr>';
3116 print
'<table class="centpercent border">';
3120 print
'<div class="center">';
3121 print
'<input type="submit" class="button button-add" value="'.$langs->trans(
"Add").
'">';
3135if ($action !=
'create' && $action !=
'edit' && $action !=
'delete') {
3136 print
'<div class="fichecenter"><div class="fichehalfleft">';
3137 print
'<a name="builddoc"></a>';
3141 if (!empty($conf->product->multidir_output[
$object->entity])) {
3142 $filedir = $conf->product->multidir_output[
$object->entity].
'/'.$objectref;
3144 $filedir = $conf->product->dir_output.
'/'.$objectref;
3146 $urlsource = $_SERVER[
"PHP_SELF"].
"?id=".
$object->id;
3147 $genallowed = $usercanread;
3148 $delallowed = $usercancreate;
3150 print $formfile->showdocuments($modulepart,
$object->ref, $filedir, $urlsource, $genallowed, $delallowed,
'', 0, 0, 0, 28, 0,
'', 0,
'', $langs->getDefaultLang(),
'',
$object);
3151 $somethingshown = $formfile->numoffiles;
3153 print
'</div><div class="fichehalfright">';
3156 $morehtmlcenter =
'<div class="nowraponall">';
3157 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'FullConversation'),
'',
'fa fa-comments imgforviewmode', DOL_URL_ROOT.
'/product/messaging.php?id='.
$object->id);
3158 $morehtmlcenter .=
dolGetButtonTitle($langs->trans(
'SeeAll'),
'',
'fa fa-bars imgforviewmode', DOL_URL_ROOT.
'/product/agenda.php?id='.
$object->id);
3159 $morehtmlcenter .=
'</div>';
3162 include_once DOL_DOCUMENT_ROOT.
'/core/class/html.formactions.class.php';
3164 $somethingshown = $formactions->showactions(
$object,
'product', 0, 1,
'', $MAXEVENT,
'', $morehtmlcenter);
3166 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 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.
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'.
dol_clone($object, $native=0)
Create a clone of instance of object (new instance with same value for each properties) With native =...
dolGetButtonAction($label, $text='', $actionType='default', $url='', $id='', $userRight=1, $params=array())
Function dolGetButtonAction.
dol_htmlcleanlastbr($stringtodecode)
This function remove all ending and br at end.
get_default_npr(Societe $thirdparty_seller, Societe $thirdparty_buyer, $idprod=0, $idprodfournprice=0)
Function that returns whether VAT must be recoverable collected VAT (e.g.: VAT NPR in France)
dol_concatdesc($text1, $text2, $forxml=false, $invert=false)
Concat 2 descriptions with a new line between them (second operand after first one with appropriate n...
dol_textishtml($msg, $option=0)
Return if a text is a html content.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_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...
product_prepare_head($object)
Prepare array with list of tabs.
measuringUnitString($unit, $measuring_style='', $scale='', $use_short_label=0, $outputlangs=null)
Return translation label of a unit key.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.