diff --git a/htdocs/accountancy/admin/account.php b/htdocs/accountancy/admin/account.php index b4bf5cc7f2c..bc8fff8395c 100644 --- a/htdocs/accountancy/admin/account.php +++ b/htdocs/accountancy/admin/account.php @@ -36,6 +36,7 @@ $action = GETPOST('action', 'aZ09'); $cancel = GETPOST('cancel', 'alpha'); $id = GETPOST('id', 'int'); $rowid = GETPOST('rowid', 'int'); +$massaction = GETPOST('massaction', 'aZ09'); $contextpage=GETPOST('contextpage', 'aZ')?GETPOST('contextpage', 'aZ'):'accountingaccountlist'; // To manage different context of search $search_account = GETPOST('search_account', 'alpha'); @@ -100,7 +101,7 @@ if (empty($reshook)) $search_array_options=array(); } - if (GETPOST('change_chart', 'alpha')) + if (GETPOST('change_chart', 'alpha') && (GETPOST('valid_change_chart', 'int') || empty($conf->use_javascript_ajax))) { $chartofaccounts = GETPOST('chartofaccounts', 'int'); @@ -236,6 +237,24 @@ if ($resql) if ($search_pcgsubtype) $param.= '&search_pcgsubtype='.urlencode($search_pcgsubtype); if ($optioncss != '') $param.='&optioncss='.$optioncss; + if (! empty($conf->use_javascript_ajax)) + { + print ' + '; + } print '
'; if ($optioncss != '') print ''; @@ -278,7 +297,8 @@ if ($resql) else dol_print_error($db); print ""; print ajax_combobox("chartofaccounts"); - print ''; + print ''; + print ''; print '
'; print '
'; @@ -286,6 +306,9 @@ if ($resql) $varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage; $selectedfields=$form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields + $moreforfilter = ''; + $massactionbutton = ''; + print '
'; print ''."\n"; diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php index 2b482ea81a0..3c04548d7c6 100644 --- a/htdocs/accountancy/bookkeeping/balance.php +++ b/htdocs/accountancy/bookkeeping/balance.php @@ -265,7 +265,7 @@ if ($action != 'export_csv') $description = $object->get_compte_desc($line->numero_compte); // Search description of the account $root_account_description = $object->get_compte_racine($line->numero_compte); if (empty($description)) { - $link = '' . img_edit_add() . ''; + $link = '' . img_edit_add() . ''; } print ''; diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index d446c7b82eb..5f9ba37d341 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -439,7 +439,7 @@ if ($action == 'create') print $langs->trans('Docdate'); print ''; if ($action != 'editdate') - print ''; + print ''; print '
piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'piece_num .'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('SetDate'), 1).'
'; print ''; if ($action == 'editdate') { @@ -463,7 +463,7 @@ if ($action == 'create') print $langs->trans('Codejournal'); print ''; if ($action != 'editjournal') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editjournal') { @@ -487,7 +487,7 @@ if ($action == 'create') print $langs->trans('Piece'); print ''; if ($action != 'editdocref') - print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; + print 'piece_num.'&mode='. $mode .'">'.img_edit($langs->transnoentitiesnoconv('Edit'), 1).''; print ''; print ''; if ($action == 'editdocref') { diff --git a/htdocs/adherents/card.php b/htdocs/adherents/card.php index 4653ed43714..20da8ffd2f7 100644 --- a/htdocs/adherents/card.php +++ b/htdocs/adherents/card.php @@ -68,7 +68,7 @@ $object = new Adherent($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); @@ -320,7 +320,7 @@ if (empty($reshook)) $object->public = GETPOST("public", 'alpha'); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; // Check if we need to also synchronize user information @@ -497,7 +497,7 @@ if (empty($reshook)) $object->public = $public; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; // Check parameters @@ -1362,15 +1362,8 @@ else else print $langs->trans("NoDolibarrAccess"); print ''; - // Other attributes + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php'; - //Hooks here - $reshook=$hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook - print $hookmanager->resPrint; - if (empty($reshook)) - { - print $object->showOptionals($extrafields, 'edit'); - } print ''; dol_fiche_end(); diff --git a/htdocs/adherents/cartes/carte.php b/htdocs/adherents/cartes/carte.php index d7e0e9215a9..177e2eef18f 100644 --- a/htdocs/adherents/cartes/carte.php +++ b/htdocs/adherents/cartes/carte.php @@ -48,7 +48,7 @@ $object=new Adherent($db); $extrafields = new ExtraFields($db); // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); /* diff --git a/htdocs/adherents/list.php b/htdocs/adherents/list.php index 57d99a387e2..877dde34af0 100644 --- a/htdocs/adherents/list.php +++ b/htdocs/adherents/list.php @@ -89,7 +89,7 @@ $hookmanager->initHooks(array('memberlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/adherents/subscription.php b/htdocs/adherents/subscription.php index 97f259b53de..415efdc8570 100644 --- a/htdocs/adherents/subscription.php +++ b/htdocs/adherents/subscription.php @@ -68,7 +68,7 @@ $extrafields = new ExtraFields($db); $adht = new AdherentType($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $errmsg=''; $errmsgs=array(); @@ -571,7 +571,7 @@ if ($rowid > 0) print ''; - if ($action != 'editthirdparty' && $user->rights->adherent->creer) print ''; + if ($action != 'editthirdparty' && $user->rights->adherent->creer) print ''; print '
'; print $langs->trans("LinkedToDolibarrThirdParty"); print 'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'id.'">'.img_edit($langs->trans('SetLinkToThirdParty'), 1).'
'; print ''; if ($action == 'editthirdparty') @@ -614,7 +614,7 @@ if ($rowid > 0) print ''; if ($user->rights->user->user->creer) { - print 'id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).''; + print 'id.'">'.img_edit($langs->trans('SetLinkToUser'), 1).''; } print ''; } diff --git a/htdocs/adherents/subscription/list.php b/htdocs/adherents/subscription/list.php index 5d8bbdad08d..dbc14e2999e 100644 --- a/htdocs/adherents/subscription/list.php +++ b/htdocs/adherents/subscription/list.php @@ -68,7 +68,7 @@ $hookmanager->initHooks(array('subscriptionlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/adherents/type.php b/htdocs/adherents/type.php index ac15e8d28ae..b24e3361d16 100644 --- a/htdocs/adherents/type.php +++ b/htdocs/adherents/type.php @@ -73,7 +73,7 @@ $object = new AdherentType($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { @@ -113,7 +113,7 @@ if ($action == 'add' && $user->rights->adherent->configurer) { $object->vote = (int) $vote; // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (empty($object->label)) { @@ -168,7 +168,7 @@ if ($action == 'update' && $user->rights->adherent->configurer) $object->vote = (boolean) trim($vote); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; $ret=$object->update($user); @@ -713,7 +713,7 @@ if ($rowid > 0) print ''; if ($user->rights->adherent->creer) { - print ''.img_edit().''; + print ''.img_edit().''; } print ' '; if ($user->rights->adherent->supprimer) diff --git a/htdocs/admin/emailcollector_card.php b/htdocs/admin/emailcollector_card.php index 24aa836a038..255fdb68a0d 100644 --- a/htdocs/admin/emailcollector_card.php +++ b/htdocs/admin/emailcollector_card.php @@ -57,7 +57,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration $hookmanager->initHooks(array('emailcollectorcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -378,7 +378,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea { if ($action != 'classify') { - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/admin/emailcollector_list.php b/htdocs/admin/emailcollector_list.php index b9804e57f03..09ba5f7224f 100644 --- a/htdocs/admin/emailcollector_list.php +++ b/htdocs/admin/emailcollector_list.php @@ -68,7 +68,7 @@ $diroutputmassaction = $conf->emailcollector->dir_output . '/temp/massgeneration $hookmanager->initHooks(array('emailcollectorlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/admin/fckeditor.php b/htdocs/admin/fckeditor.php index d046d206fbf..c2c49eb4943 100644 --- a/htdocs/admin/fckeditor.php +++ b/htdocs/admin/fckeditor.php @@ -1,7 +1,8 @@ * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2012-20113 Juanjo Menent + * Copyright (C) 2012-2013 Juanjo Menent + * Copyright (C) 2019 Christophe Battarel * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -49,7 +50,8 @@ $modules = array( 'DETAILS' => 'FCKeditorForProductDetails', 'USERSIGN' => 'FCKeditorForUserSignature', 'MAILING' => 'FCKeditorForMailing', -'MAIL' => 'FCKeditorForMail' +'MAIL' => 'FCKeditorForMail', +'TICKET' => 'FCKeditorForTicket' ); // Conditions pour que l'option soit proposee $conditions = array( @@ -58,7 +60,8 @@ $conditions = array( 'DETAILS' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled) || ! empty($conf->supplier_proposal->enabled) || ! empty($conf->fournisseur->enabled)), 'USERSIGN' => 1, 'MAILING' => ! empty($conf->mailing->enabled), -'MAIL' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)) +'MAIL' => (! empty($conf->facture->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)), +'TICKET' => ! empty($conf->ticket->enabled) ); // Picto $picto = array( @@ -67,7 +70,8 @@ $picto = array( 'DETAILS' => 'product', 'USERSIGN' => 'user', 'MAILING' => 'email', -'MAIL' => 'email' +'MAIL' => 'email', +'TICKET' => 'ticket' ); diff --git a/htdocs/admin/mails_senderprofile_list.php b/htdocs/admin/mails_senderprofile_list.php index 2250980a98d..0aa53b11b8d 100644 --- a/htdocs/admin/mails_senderprofile_list.php +++ b/htdocs/admin/mails_senderprofile_list.php @@ -61,7 +61,7 @@ $diroutputmassaction=$conf->admin->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('emailsenderprofilelist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/admin/system/about.php b/htdocs/admin/system/about.php index 0ed0a2179ff..64f8fba72ad 100644 --- a/htdocs/admin/system/about.php +++ b/htdocs/admin/system/about.php @@ -160,7 +160,6 @@ print ''; diff --git a/htdocs/admin/ticket.php b/htdocs/admin/ticket.php index 277d6927e9b..d97252dc53b 100644 --- a/htdocs/admin/ticket.php +++ b/htdocs/admin/ticket.php @@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; +$error = 0; + +/* + * Actions + */ + if ($action == 'updateMask') { $maskconstticket = GETPOST('maskconstticket', 'alpha'); $maskticket = GETPOST('maskticket', 'alpha'); @@ -91,7 +97,7 @@ if ($action == 'updateMask') { $error++; } - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); + $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'restricthtml'); if (!empty($mail_intro)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); } else { @@ -101,7 +107,7 @@ if ($action == 'updateMask') { $error++; } - $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); + $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'restricthtml'); if (!empty($mail_signature)) { $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); } else { @@ -110,16 +116,6 @@ if ($action == 'updateMask') { if (!$res > 0) { $error++; } - - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); - if (!empty($text_help)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } } if ($action == 'setvarother') { diff --git a/htdocs/admin/ticket_public.php b/htdocs/admin/ticket_public.php index 81119b37ce9..c5cadac11c1 100644 --- a/htdocs/admin/ticket_public.php +++ b/htdocs/admin/ticket_public.php @@ -42,6 +42,12 @@ $label = GETPOST('label', 'alpha'); $scandir = GETPOST('scandir', 'alpha'); $type = 'ticket'; +$error = 0; + +/* + * Actions + */ + if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') { if (GETPOST('value')) dolibarr_set_const($db, 'TICKET_ENABLE_PUBLIC_INTERFACE', 1, 'chaine', 0, '', $conf->entity); @@ -51,95 +57,54 @@ if ($action == 'setTICKET_ENABLE_PUBLIC_INTERFACE') if ($action == 'setvar') { include_once DOL_DOCUMENT_ROOT . "/core/lib/files.lib.php"; - $notification_email = GETPOST('TICKET_NOTIFICATION_EMAIL_FROM', 'alpha'); - if (!empty($notification_email)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', $notification_email, 'chaine', 0, '', $conf->entity); + $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'nohtml'); + if (!empty($topic_interface)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_FROM', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; + $error++; } - // altairis : differentiate notification email FROM and TO - $notification_email_to = GETPOST('TICKET_NOTIFICATION_EMAIL_TO', 'alpha'); - if (!empty($notification_email_to)) { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', $notification_email_to, 'chaine', 0, '', $conf->entity); + $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'restricthtml'); + if (!empty($text_home)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_NOTIFICATION_EMAIL_TO', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; + $error++; } - $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'alpha'); + $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'restricthtml'); + if (!empty($text_help)) { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); + } else { + $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); + } + if (!$res > 0) { + $error++; + } + + $mail_new_ticket = GETPOST('TICKET_MESSAGE_MAIL_NEW', 'restricthtml'); if (!empty($mail_new_ticket)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $mail_new_ticket, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_NEW', $langs->trans('TicketMessageMailNewText'), 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; - } - - $mail_intro = GETPOST('TICKET_MESSAGE_MAIL_INTRO', 'alpha'); - if (!empty($mail_intro)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $mail_intro, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_INTRO', $langs->trans('TicketMessageMailIntroText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $mail_signature = GETPOST('TICKET_MESSAGE_MAIL_SIGNATURE', 'alpha'); - if (!empty($mail_signature)) { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $mail_signature, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_MESSAGE_MAIL_SIGNATURE', $langs->trans('TicketMessageMailSignatureText'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; + $error++; } $url_interface = GETPOST('TICKET_URL_PUBLIC_INTERFACE', 'alpha'); if (!empty($url_interface)) { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', $url_interface, 'chaine', 0, '', $conf->entity); } else { - $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); + $res = dolibarr_set_const($db, 'TICKET_URL_PUBLIC_INTERFACE', '', 'chaine', 0, '', $conf->entity); } if (!$res > 0) { - $error++; - } - - $topic_interface = GETPOST('TICKET_PUBLIC_INTERFACE_TOPIC', 'alpha'); - if (!empty($topic_interface)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', $topic_interface, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_INTERFACE_TOPIC', '', 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $text_home = GETPOST('TICKET_PUBLIC_TEXT_HOME', 'alpha'); - if (!empty($text_home)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $text_home, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HOME', $langs->trans('TicketPublicInterfaceTextHome'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; - } - - $text_help = GETPOST('TICKET_PUBLIC_TEXT_HELP_MESSAGE', 'alpha'); - if (!empty($text_help)) { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $text_help, 'chaine', 0, '', $conf->entity); - } else { - $res = dolibarr_set_const($db, 'TICKET_PUBLIC_TEXT_HELP_MESSAGE', $langs->trans('TicketPublicPleaseBeAccuratelyDescribe'), 'chaine', 0, '', $conf->entity); - } - if (!$res > 0) { - $error++; + $error++; } } @@ -162,14 +127,11 @@ if ($action == 'setvarother') { $error++; } - if ($conf->global->MAIN_FEATURES_LEVEL >= 2) - { - $param_show_module_logo = GETPOST('TICKET_SHOW_MODULE_LOGO', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_SHOW_MODULE_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } - } + $param_show_module_logo = GETPOST('TICKET_SHOW_COMPANY_LOGO', 'alpha'); + $res = dolibarr_set_const($db, 'TICKET_SHOW_COMPANY_LOGO', $param_show_module_logo, 'chaine', 0, '', $conf->entity); + if (!$res > 0) { + $error++; + } if ($conf->global->MAIN_FEATURES_LEVEL >= 2) { @@ -179,12 +141,6 @@ if ($action == 'setvarother') { $error++; } } - - $param_limit_view = GETPOST('TICKET_LIMIT_VIEW_ASSIGNED_ONLY', 'alpha'); - $res = dolibarr_set_const($db, 'TICKET_LIMIT_VIEW_ASSIGNED_ONLY', $param_limit_view, 'chaine', 0, '', $conf->entity); - if (!$res > 0) { - $error++; - } } @@ -238,8 +194,7 @@ print '

'; if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) { - - if (!$conf->use_javascript_ajax) { + if (empty($conf->use_javascript_ajax)) { print ''; print ''; print ''; @@ -349,16 +304,6 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print "\n"; } - // Url public interface - $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; - print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; - print ''; - print ''; - print ''; - print ''; - print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); - print ''; - // Interface topic $url_interface = $conf->global->TICKET_PUBLIC_INTERFACE_TOPIC; print '' . $langs->trans("TicketPublicInterfaceTopicLabelAdmin") . ''; @@ -420,6 +365,16 @@ if (! empty($conf->global->TICKET_ENABLE_PUBLIC_INTERFACE)) print $form->textwithpicto('', $langs->trans("TicketNewEmailBodyHelp"), 1, 'help'); print ''; + // Url public interface + $url_interface = $conf->global->TICKET_URL_PUBLIC_INTERFACE; + print '' . $langs->trans("TicketUrlPublicInterfaceLabelAdmin") . ''; + print ''; + print ''; + print ''; + print ''; + print $form->textwithpicto('', $langs->trans("TicketUrlPublicInterfaceHelpAdmin"), 1, 'help'); + print ''; + print ''; print '
'; diff --git a/htdocs/asset/card.php b/htdocs/asset/card.php index 77fb734be54..7c2f1b42f32 100644 --- a/htdocs/asset/card.php +++ b/htdocs/asset/card.php @@ -45,7 +45,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('assetcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); @@ -64,9 +64,6 @@ if (empty($action) && empty($id) && empty($ref)) $action='view'; //if ($user->societe_id > 0) $socid = $user->societe_id; //$result = restrictedArea($user, 'asset', $id); -// fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once. @@ -207,7 +204,7 @@ if (($id || $ref) && $action == 'edit') // Part to show record if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'create'))) { - $res = $object->fetch_optionals($object->id, $extralabels); + $res = $object->fetch_optionals($object->id); $head = asset_prepare_head($object); dol_fiche_head($head, 'card', $langs->trans("Asset"), -1, 'generic'); diff --git a/htdocs/asset/document.php b/htdocs/asset/document.php index 3fc0b1efe3d..d1fa8c1e04b 100644 --- a/htdocs/asset/document.php +++ b/htdocs/asset/document.php @@ -62,7 +62,7 @@ $diroutputmassaction=$conf->assets->dir_output . '/temp/massgeneration/'.$user-> $hookmanager->initHooks(array('assetdocument')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals diff --git a/htdocs/asset/list.php b/htdocs/asset/list.php index fb752b00087..6c4e5e92f20 100644 --- a/htdocs/asset/list.php +++ b/htdocs/asset/list.php @@ -62,7 +62,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('assetlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/asset/note.php b/htdocs/asset/note.php index b09ade8715b..0c03619d31c 100644 --- a/htdocs/asset/note.php +++ b/htdocs/asset/note.php @@ -43,7 +43,7 @@ $diroutputmassaction=$conf->asset->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('assetnote')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); @@ -102,7 +102,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->asset->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/asset/type.php b/htdocs/asset/type.php index 8be5cdc104e..6803f9d65e7 100644 --- a/htdocs/asset/type.php +++ b/htdocs/asset/type.php @@ -65,7 +65,7 @@ $object = new AssetType($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All tests are required to be compatible with all browsers { @@ -102,7 +102,7 @@ if ($action == 'add' && $user->rights->asset->write) $object->note = trim($comment); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (empty($object->label)) { @@ -155,7 +155,7 @@ if ($action == 'update' && $user->rights->asset->write) $object->note = trim($comment); // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; $ret=$object->update($user); diff --git a/htdocs/bom/bom_agenda.php b/htdocs/bom/bom_agenda.php index 3ef8c38f364..87fb55a6541 100644 --- a/htdocs/bom/bom_agenda.php +++ b/htdocs/bom/bom_agenda.php @@ -74,7 +74,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomagenda','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('bom'); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -149,7 +149,7 @@ if ($object->id > 0) if ($user->rights->bom->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php index 1496ba56851..5e24724b6f7 100644 --- a/htdocs/bom/bom_card.php +++ b/htdocs/bom/bom_card.php @@ -48,7 +48,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomcard', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias @@ -339,7 +339,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($user->rights->bom->write) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/bom/bom_document.php b/htdocs/bom/bom_document.php index dadf92ea6d0..826222af8b0 100644 --- a/htdocs/bom/bom_document.php +++ b/htdocs/bom/bom_document.php @@ -63,7 +63,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomdocument', 'globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals diff --git a/htdocs/bom/bom_list.php b/htdocs/bom/bom_list.php index d7fce692f07..4b0a6ff29be 100644 --- a/htdocs/bom/bom_list.php +++ b/htdocs/bom/bom_list.php @@ -62,7 +62,7 @@ $diroutputmassaction = $conf->bom->dir_output . '/temp/massgeneration/'.$user->i $hookmanager->initHooks(array('bomlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); // Load $extrafields->attributes['bom'] +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/bom/bom_note.php b/htdocs/bom/bom_note.php index 6e8d63ab851..481d8f1d799 100644 --- a/htdocs/bom/bom_note.php +++ b/htdocs/bom/bom_note.php @@ -44,7 +44,7 @@ $diroutputmassaction=$conf->bom->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('bomnote','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); @@ -104,7 +104,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->bom->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php index 5fbc0877927..b574efc81df 100644 --- a/htdocs/bom/tpl/objectline_create.tpl.php +++ b/htdocs/bom/tpl/objectline_create.tpl.php @@ -140,7 +140,7 @@ if ($nolinesbefore) { showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> diff --git a/htdocs/bom/tpl/objectline_edit.tpl.php b/htdocs/bom/tpl/objectline_edit.tpl.php index a650b585740..05b9094d10e 100644 --- a/htdocs/bom/tpl/objectline_edit.tpl.php +++ b/htdocs/bom/tpl/objectline_edit.tpl.php @@ -138,7 +138,7 @@ $coldisplay=0; showOptionals($extrafieldsline, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $objectline->showOptionals($extrafields, 'edit', array('style'=>$bcnd[$var], 'colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> diff --git a/htdocs/bom/tpl/objectline_view.tpl.php b/htdocs/bom/tpl/objectline_view.tpl.php index 49b6f0e6488..9582e69f967 100644 --- a/htdocs/bom/tpl/objectline_view.tpl.php +++ b/htdocs/bom/tpl/objectline_view.tpl.php @@ -149,9 +149,9 @@ $objectline = new BOMLine($object->db); showOptionals($extrafieldsline, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); + print $line->showOptionals($extrafields, 'view', array('style'=>'class="drag drop oddeven"','colspan'=>$coldisplay), '', '', empty($conf->global->MAIN_EXTRAFIELDS_IN_ONE_TD)?0:1); } ?> diff --git a/htdocs/bookmarks/bookmarks.lib.php b/htdocs/bookmarks/bookmarks.lib.php index 5ce2f782d39..1e54cc816fd 100644 --- a/htdocs/bookmarks/bookmarks.lib.php +++ b/htdocs/bookmarks/bookmarks.lib.php @@ -150,3 +150,140 @@ function printBookmarksList($aDb, $aLangs) return $ret; } + + + +/** + * Add area with bookmarks in top menu + * + * @param DoliDb $aDb Database handler + * @param Translate $aLangs Object lang + * @return string + */ +function printDropdownBookmarksList($aDb, $aLangs) +{ + global $conf, $user; + + $db = $aDb; + $langs = $aLangs; + + require_once DOL_DOCUMENT_ROOT.'/bookmarks/class/bookmark.class.php'; + if (! isset($conf->global->BOOKMARKS_SHOW_IN_MENU)) $conf->global->BOOKMARKS_SHOW_IN_MENU=5; + + $langs->load("bookmarks"); + + $url= $_SERVER["PHP_SELF"]; + + if (! empty($_SERVER["QUERY_STRING"])) + { + $url.=(dol_escape_htmltag($_SERVER["QUERY_STRING"])?'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]):''); + } + else + { + global $sortfield,$sortorder; + $tmpurl=''; + // No urlencode, all param $url will be urlencoded later + if ($sortfield) $tmpurl.=($tmpurl?'&':'').'sortfield='.$sortfield; + if ($sortorder) $tmpurl.=($tmpurl?'&':'').'sortorder='.$sortorder; + if (is_array($_POST)) + { + foreach($_POST as $key => $val) + { + if (preg_match('/^search_/', $key) && $val != '') $tmpurl.=($tmpurl?'&':'').$key.'='.$val; + } + } + $url.=($tmpurl?'?'.$tmpurl:''); + } + + $searchForm = ''."\n"; + $searchForm.= ''; + $searchForm.= ''; + $searchForm.= ''; + + // Url to list bookmark + $listbtn = ''; + $listbtn.= ' '.$langs->trans('Bookmarks').''; + + // Url to go on create new bookmark page + $newbtn = ''; + if (! empty($user->rights->bookmark->creer)) + { + //$urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&urlsource='.urlencode($url).'&url='.urlencode($url); + $urltoadd=DOL_URL_ROOT.'/bookmarks/card.php?action=create&url='.urlencode($url); + $newbtn.= ''; + $newbtn.= ' '.dol_escape_htmltag($langs->trans('AddThisPageToBookmarks')).''; + } + + + $bookmarkList=''; + + $html= ''; + if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU)) { + $html.= ' + + + '; + } + + $html.= ' + + + '; + + $html.= ' + + + '; + + if (! empty($conf->global->BOOKMARKS_SHOW_IN_MENU)) { + $html .= ''; + } + + return $html; +} diff --git a/htdocs/bookmarks/list.php b/htdocs/bookmarks/list.php index 020ca561d28..bdd4f0b5429 100644 --- a/htdocs/bookmarks/list.php +++ b/htdocs/bookmarks/list.php @@ -181,7 +181,7 @@ if ($resql) print ''; if ($user->rights->bookmark->creer) { - print "rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"])."\">".img_edit()." "; + print 'rowid."&backtopage=".urlencode($_SERVER["PHP_SELF"]).'">'.img_edit().""; } if ($user->rights->bookmark->supprimer) { diff --git a/htdocs/categories/card.php b/htdocs/categories/card.php index cf29dc38561..68e2ff5e1d0 100644 --- a/htdocs/categories/card.php +++ b/htdocs/categories/card.php @@ -68,7 +68,7 @@ if ($catorigin && $type == Categorie::TYPE_PRODUCT) $idCatOrigin = $catorigin; $object = new Categorie($db); $extrafields = new ExtraFields($db); -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); @@ -137,7 +137,7 @@ if ($action == 'add' && $user->rights->categorie->creer) if ($parent != "-1") $object->fk_parent = $parent; - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (! $object->label) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index 044d0c8c6d6..39db14a9613 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -62,7 +62,7 @@ if ($id > 0) } $extrafields = new ExtraFields($db); -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard')); @@ -102,7 +102,7 @@ if ($action == 'update' && $user->rights->categorie->creer) } if (! $error && empty($object->error)) { - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (! $error && $object->update($user) > 0) diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index ec4998b6ea3..737b488c090 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -84,7 +84,7 @@ $type=$object->type; if (is_numeric($type)) $type=Categorie::$MAP_ID_TO_CODE[$type]; // For backward compatibility $extrafields = new ExtraFields($db); -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array array $hookmanager->initHooks(array('categorycard','globalcard')); diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4bd5ceb4d8f..baf454fdf67 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -99,7 +99,7 @@ if ($id > 0 && $action!='add') { } // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); //var_dump($_POST); @@ -361,7 +361,7 @@ if (empty($reshook) && $action == 'add') } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (! $error) @@ -526,7 +526,7 @@ if (empty($reshook) && $action == 'update') } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (!$error) { @@ -1582,7 +1582,7 @@ if ($id > 0) (($object->authorid == $user->id || $object->userownerid == $user->id) && $user->rights->agenda->myactions->create)) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.='
'; @@ -1622,7 +1622,7 @@ if ($id > 0) // Type if (! empty($conf->global->AGENDA_USE_EVENT_TYPE)) { - print ''.$langs->trans("Type").''.$object->type.''; + print ''.$langs->trans("Type").''.$langs->trans($object->type).''; } // Full day event diff --git a/htdocs/comm/action/list.php b/htdocs/comm/action/list.php index 29a88111f17..efb11a7e22b 100644 --- a/htdocs/comm/action/list.php +++ b/htdocs/comm/action/list.php @@ -82,7 +82,7 @@ $hookmanager->initHooks(array('agendalist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // If not choice done on calendar owner, we filter on user. diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php index 49a52188df9..3f50c6ab6c8 100644 --- a/htdocs/comm/card.php +++ b/htdocs/comm/card.php @@ -80,7 +80,7 @@ $object = new Client($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('thirdpartycomm','globalcard')); @@ -194,8 +194,7 @@ if (empty($reshook)) $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) { @@ -324,7 +323,7 @@ if ($object->id > 0) print ''; + if (($action != 'editconditions') && $user->rights->societe->creer) print ''; print '
'; print $langs->trans('PaymentConditions'); print ''; - if (($action != 'editconditions') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetConditions'), 1).'id.'">'.img_edit($langs->trans('SetConditions'), 1).'
'; print ''; if ($action == 'editconditions') @@ -343,7 +342,7 @@ if ($object->id > 0) print ''; + if (($action != 'editmode') && $user->rights->societe->creer) print ''; print '
'; print $langs->trans('PaymentMode'); print ''; - if (($action != 'editmode') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; if ($action == 'editmode') @@ -364,7 +363,7 @@ if ($object->id > 0) print ''; + if (($action != 'editbankaccount') && $user->rights->societe->creer) print ''; print '
'; print $langs->trans('PaymentBankAccount'); print ''; - if (($action != 'editbankaccount') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; print ''; if ($action == 'editbankaccount') @@ -390,7 +389,7 @@ if ($object->id > 0) print ''; if ($user->rights->societe->creer && !$user->societe_id > 0) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''.($object->remise_percent?''.$object->remise_percent.'%':'').''; @@ -457,7 +456,7 @@ if ($object->id > 0) print ''; if ($user->rights->societe->creer) { - print ''.img_edit($langs->trans("Modify")).''; + print ''.img_edit($langs->trans("Modify")).''; } print ''; print ''; @@ -474,7 +473,7 @@ if ($object->id > 0) print ''; + if (($action != 'editshipping') && $user->rights->societe->creer) print ''; print '
'; print $langs->trans('SendingMethod'); print ''; - if (($action != 'editshipping') && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; print ''; if ($action == 'editshipping') @@ -542,7 +541,7 @@ if ($object->id > 0) print ''; + if ($action != 'editlevel' && $user->rights->societe->creer) print ''; print '
'; print $langs->trans('ProspectLevel'); print ''; - if ($action != 'editlevel' && $user->rights->societe->creer) print 'id.'">'.img_edit($langs->trans('Modify'), 1).'id.'">'.img_edit($langs->trans('Modify'), 1).'
'; print ''; if ($action == 'editlevel') diff --git a/htdocs/comm/mailing/card.php b/htdocs/comm/mailing/card.php index 9609038ca41..33de68f22a1 100644 --- a/htdocs/comm/mailing/card.php +++ b/htdocs/comm/mailing/card.php @@ -51,7 +51,7 @@ $result=$object->fetch($id); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('mailingcard','globalcard')); diff --git a/htdocs/comm/mailing/class/advtargetemailing.class.php b/htdocs/comm/mailing/class/advtargetemailing.class.php index 006e009c78d..7346bf87543 100644 --- a/htdocs/comm/mailing/class/advtargetemailing.class.php +++ b/htdocs/comm/mailing/class/advtargetemailing.class.php @@ -544,7 +544,7 @@ class AdvanceTargetingMailing extends CommonObject public function query_thirdparty($arrayquery) { // phpcs:enable - global $langs,$conf; + global $langs,$conf,$extrafields; $sql = "SELECT"; $sql.= " t.rowid"; @@ -617,29 +617,29 @@ class AdvanceTargetingMailing extends CommonObject //Standard Extrafield feature if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { - // fetch optionals attributes and labels - dol_include_once('/core/class/extrafields.class.php'); - $extrafields = new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label('societe'); - foreach($extralabels as $key=>$val) { + $elementtype = Societe::$table_element; - if (($extrafields->attribute_type[$key] == 'varchar') || - ($extrafields->attribute_type[$key] == 'text')) { + $extrafields->fetch_name_optionals_label($elementtype); + + foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { + + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key]."')"; } - } elseif (($extrafields->attribute_type[$key] == 'int') || - ($extrafields->attribute_type[$key] == 'double')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { if (!empty($arrayquery['options_'.$key.'_max'])) { $sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'].")"; } - } elseif (($extrafields->attribute_type[$key] == 'date') || - ($extrafields->attribute_type[$key] == 'datetime')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { if (!empty($arrayquery['options_'.$key.'_end_dt'])){ $sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')"; } - } elseif ($extrafields->attribute_type[$key] == 'boolean') { + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key].")"; } @@ -757,29 +757,33 @@ class AdvanceTargetingMailing extends CommonObject //Standard Extrafield feature if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementtype = Contact::$table_element; + // fetch optionals attributes and labels dol_include_once('/core/class/extrafields.class.php'); $extrafields = new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label('socpeople'); + $extrafields->fetch_name_optionals_label($elementtype); - foreach($extralabels as $key=>$val) { + $extrafields->fetch_name_optionals_label($elementtype); - if (($extrafields->attribute_type[$key] == 'varchar') || - ($extrafields->attribute_type[$key] == 'text')) { + foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { + + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key.'_cnct'])) { $sqlwhere[]= " (te.".$key." LIKE '".$arrayquery['options_'.$key.'_cnct']."')"; } - } elseif (($extrafields->attribute_type[$key] == 'int') || - ($extrafields->attribute_type[$key] == 'double')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { if (!empty($arrayquery['options_'.$key.'_max'.'_cnct'])) { $sqlwhere[]= " (te.".$key." >= ".$arrayquery['options_'.$key.'_max'.'_cnct']." AND te.".$key." <= ".$arrayquery['options_'.$key.'_min'.'_cnct'].")"; } - } elseif (($extrafields->attribute_type[$key] == 'date') || - ($extrafields->attribute_type[$key] == 'datetime')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { if (!empty($arrayquery['options_'.$key.'_end_dt'.'_cnct'])){ $sqlwhere[]= " (te.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'.'_cnct'])."' AND te.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'.'_cnct'])."')"; } - } elseif ($extrafields->attribute_type[$key] == 'boolean') { + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key.'_cnct']!=''){ if ($arrayquery['options_'.$key.'_cnct']==0) { $sqlwhere[]= " (te.".$key." = ".$arrayquery['options_'.$key.'_cnct']." OR ((te.".$key." IS NULL) AND (te.fk_object IS NOT NULL)))"; @@ -857,29 +861,32 @@ class AdvanceTargetingMailing extends CommonObject //Standard Extrafield feature if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) { + $elementtype = Societe::$table_element; + // fetch optionals attributes and labels dol_include_once('/core/class/extrafields.class.php'); $extrafields = new ExtraFields($this->db); - $extralabels=$extrafields->fetch_name_optionals_label('societe'); - foreach($extralabels as $key=>$val) { + $extrafields->fetch_name_optionals_label($elementtype); - if (($extrafields->attribute_type[$key] == 'varchar') || - ($extrafields->attribute_type[$key] == 'text')) { + foreach($extrafields->attributes[$elementtype]['label'] as $key=>$val) { + + if (($extrafields->attributes[$elementtype]['type'][$key] == 'varchar') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'text')) { if (!empty($arrayquery['options_'.$key])) { $sqlwhere[]= " (tse.".$key." LIKE '".$arrayquery['options_'.$key]."')"; } - } elseif (($extrafields->attribute_type[$key] == 'int') || - ($extrafields->attribute_type[$key] == 'double')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'int') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'double')) { if (!empty($arrayquery['options_'.$key.'_max'])) { $sqlwhere[]= " (tse.".$key." >= ".$arrayquery['options_'.$key.'_max']." AND tse.".$key." <= ".$arrayquery['options_'.$key.'_min'].")"; } - } elseif (($extrafields->attribute_type[$key] == 'date') || - ($extrafields->attribute_type[$key] == 'datetime')) { + } elseif (($extrafields->attributes[$elementtype]['type'][$key] == 'date') || + ($extrafields->attributes[$elementtype]['type'][$key] == 'datetime')) { if (!empty($arrayquery['options_'.$key.'_end_dt'])){ $sqlwhere[]= " (tse.".$key." >= '".$this->db->idate($arrayquery['options_'.$key.'_st_dt'])."' AND tse.".$key." <= '".$this->db->idate($arrayquery['options_'.$key.'_end_dt'])."')"; } - } elseif ($extrafields->attribute_type[$key] == 'boolean') { + } elseif ($extrafields->attributes[$elementtype]['type'][$key] == 'boolean') { if ($arrayquery['options_'.$key]!=''){ $sqlwhere[]= " (tse.".$key." = ".$arrayquery['options_'.$key].")"; } diff --git a/htdocs/comm/mailing/list.php b/htdocs/comm/mailing/list.php index 6e308100b5a..ff69bd00c0c 100644 --- a/htdocs/comm/mailing/list.php +++ b/htdocs/comm/mailing/list.php @@ -53,7 +53,7 @@ $hookmanager->initHooks(array('mailinglist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index 39c80269d8f..96aa12062d4 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -93,7 +93,7 @@ $object = new Propal($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object if ($id > 0 || ! empty($ref)) { @@ -410,7 +410,7 @@ if (empty($reshook)) } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) { $error ++; $action = 'create'; @@ -841,9 +841,8 @@ if (empty($reshook)) if (empty($remise_percent)) $remise_percent=0; // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1210,9 +1209,8 @@ if (empty($reshook)) $date_end = dol_mktime(GETPOST('date_endhour'), GETPOST('date_endmin'), GETPOST('date_endsec'), GETPOST('date_endmonth'), GETPOST('date_endday'), GETPOST('date_endyear')); // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1379,8 +1377,7 @@ if (empty($reshook)) $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) { @@ -1903,7 +1900,7 @@ if ($action == 'create') { require_once DOL_DOCUMENT_ROOT . '/core/class/notify.class.php'; $notify = new Notify($db); -$formquestion = array_merge($formquestion, array( + $formquestion = array_merge($formquestion, array( array('type' => 'onecolumn', 'value' => $notify->confirmMessage('PROPAL_CLOSE_SIGNED', $object->socid, $object)), )); } @@ -1983,7 +1980,7 @@ $formquestion = array_merge($formquestion, array( if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; @@ -2049,7 +2046,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('Date'); print ''; if ($action != 'editdate' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdate' && $usercancreate) { @@ -2075,7 +2072,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('DateEndPropal'); print ''; if ($action != 'editecheance' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; + print 'id . '">' . img_edit($langs->trans('SetConditions'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editecheance' && $usercancreate) { @@ -2103,7 +2100,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('PaymentConditionsShort'); print ''; if ($action != 'editconditions' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetConditions'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editconditions' && $usercancreate) { @@ -2131,7 +2128,7 @@ $formquestion = array_merge($formquestion, array( print ' (' . $langs->trans('AfterOrder') . ')'; print ''; if ($action != 'editavailability' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetAvailability'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editavailability' && $usercancreate) { @@ -2150,7 +2147,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('SendingMethod'); print ''; if ($action != 'editshippingmethod' && $usercancreate) - print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).''; + print 'id.'">'.img_edit($langs->trans('SetShippingMode'), 1).''; print ''; print ''; if ($action == 'editshippingmethod' && $usercancreate) { @@ -2168,7 +2165,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('Source'); print ''; if ($action != 'editdemandreason' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetDemandReason'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editdemandreason' && $usercancreate) { @@ -2186,7 +2183,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('PaymentMode'); print ''; if ($action != 'editmode' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMode'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmode' && $usercancreate) { @@ -2206,7 +2203,7 @@ $formquestion = array_merge($formquestion, array( print $form->editfieldkey('Currency', 'multicurrency_code', '', $object, 0); print ''; if ($action != 'editmulticurrencycode' && $object->statut == Propal::STATUS_DRAFT && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && $action == 'editmulticurrencycode' && $usercancreate) { @@ -2223,7 +2220,7 @@ $formquestion = array_merge($formquestion, array( print $form->editfieldkey('CurrencyRate', 'multicurrency_tx', '', $object, 0); print ''; if ($action != 'editmulticurrencyrate' && $object->statut == Propal::STATUS_DRAFT && $object->multicurrency_code && $object->multicurrency_code != $conf->currency && $usercancreate) - print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; + print 'id . '">' . img_edit($langs->transnoentitiesnoconv('SetMultiCurrencyCode'), 1) . ''; print ''; print ''; if ($object->statut == Propal::STATUS_DRAFT && ($action == 'editmulticurrencyrate' || $action == 'actualizemulticurrencyrate') && $usercancreate) { @@ -2263,7 +2260,7 @@ $formquestion = array_merge($formquestion, array( print $langs->trans('BankAccount'); print ''; if ($action != 'editbankaccount' && $usercancreate) - print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).''; print ''; print ''; if ($action == 'editbankaccount') { @@ -2298,7 +2295,7 @@ $formquestion = array_merge($formquestion, array( print '
'; print $langs->trans('IncotermLabel'); print ''; - if ($usercancreate) print ''.img_edit().''; + if ($usercancreate) print ''.img_edit().''; else print ' '; print '
'; print ''; diff --git a/htdocs/comm/propal/contact.php b/htdocs/comm/propal/contact.php index 9fad14fee54..96673084580 100644 --- a/htdocs/comm/propal/contact.php +++ b/htdocs/comm/propal/contact.php @@ -171,7 +171,7 @@ if ($object->id > 0) if ($user->rights->propal->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/comm/propal/document.php b/htdocs/comm/propal/document.php index ffd37b5b3ee..14b845a3e8a 100644 --- a/htdocs/comm/propal/document.php +++ b/htdocs/comm/propal/document.php @@ -122,7 +122,7 @@ if ($object->id > 0) if ($user->rights->propal->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/comm/propal/info.php b/htdocs/comm/propal/info.php index fec6d3bd906..108a09e7d07 100644 --- a/htdocs/comm/propal/info.php +++ b/htdocs/comm/propal/info.php @@ -87,7 +87,7 @@ if (! empty($conf->projet->enabled)) if ($user->rights->propal->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 112cc76527d..f81949fb11d 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -129,7 +129,7 @@ $hookmanager->initHooks(array('propallist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/comm/propal/note.php b/htdocs/comm/propal/note.php index d4354cce643..2a3f0438ad0 100644 --- a/htdocs/comm/propal/note.php +++ b/htdocs/comm/propal/note.php @@ -102,7 +102,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->propal->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ''; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index ff4606655a5..ed08c39d869 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -88,7 +88,7 @@ $object = new Commande($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once @@ -284,7 +284,7 @@ if (empty($reshook)) // Fill array 'array_options' with data from add form if (! $error) { - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; } @@ -673,9 +673,8 @@ if (empty($reshook)) $remise_percent = (GETPOST('remise_percent'.$predef) != '' ? GETPOST('remise_percent'.$predef) : 0); // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -1037,9 +1036,8 @@ if (empty($reshook)) $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields Lines - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); // Unset extrafield POST Data if (is_array($extralabelsline)) { foreach ($extralabelsline as $key => $value) { @@ -1297,8 +1295,7 @@ if (empty($reshook)) $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from update form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -2096,7 +2093,7 @@ if ($action == 'create' && $usercancreate) if ($usercancreate) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/commande/contact.php b/htdocs/commande/contact.php index c11f71f2133..82d24ad3646 100644 --- a/htdocs/commande/contact.php +++ b/htdocs/commande/contact.php @@ -165,7 +165,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->commande->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/commande/document.php b/htdocs/commande/document.php index d82441916af..4d784e299fb 100644 --- a/htdocs/commande/document.php +++ b/htdocs/commande/document.php @@ -124,7 +124,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->commande->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/commande/info.php b/htdocs/commande/info.php index 72fa1dc4e4d..f42a9fc5b60 100644 --- a/htdocs/commande/info.php +++ b/htdocs/commande/info.php @@ -85,7 +85,7 @@ if (! empty($conf->projet->enabled)) if ($user->rights->commande->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 6db881a656d..75304d34eb2 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -111,7 +111,7 @@ $hookmanager->initHooks(array('orderlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('commande'); +$extrafields->fetch_name_optionals_label('commande'); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" diff --git a/htdocs/commande/note.php b/htdocs/commande/note.php index f1248e9b746..0931067f155 100644 --- a/htdocs/commande/note.php +++ b/htdocs/commande/note.php @@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->commande->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index da9af8b3569..fae23fa8bcd 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -72,8 +72,10 @@ $date_endy = dol_mktime(23, 59, 59, $_REQUEST["date_end_delymonth"], $_REQUEST[" $extrafields = new ExtraFields($db); +$object=new Facture($db); + // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('facture'); +$extrafields->fetch_name_optionals_label($object->table_element); if ($action == 'create') { @@ -141,7 +143,6 @@ if (($action == 'create' || $action == 'add') && !$error) $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', $fieldid); $usehm=$conf->global->MAIN_USE_HOURMIN_IN_DATE_RANGE; - $object=new Facture($db); // Insert new invoice in database if ($action == 'add' && $user->rights->facture->creer) @@ -177,7 +178,7 @@ if (($action == 'create' || $action == 'add') && !$error) $object->remise_absolue = $_POST['remise_absolue']; $object->remise_percent = $_POST['remise_percent']; - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if ($_POST['origin'] && $_POST['originid']) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 3b2a63cd839..e0e0d77e89c 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -137,7 +137,7 @@ $hookmanager->initHooks(array('banktransactionlist', $contextpage)); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('banktransaction'); +$extrafields->fetch_name_optionals_label('banktransaction'); $search_array_options=$extrafields->getOptionalsFromPost('banktransaction', '', 'search_'); $arrayfields=array( @@ -909,7 +909,7 @@ if ($resql) } if (! empty($arrayfields['balance']['checked'])) { - print ''; + print ''; $htmltext=$langs->trans("BalanceVisibilityDependsOnSortAndFilters", $langs->transnoentitiesnoconv("DateValue")); print $form->textwithpicto('', $htmltext, 1); print ''; diff --git a/htdocs/compta/bank/card.php b/htdocs/compta/bank/card.php index 023a757ce73..fd5a2b42723 100644 --- a/htdocs/compta/bank/card.php +++ b/htdocs/compta/bank/card.php @@ -57,8 +57,9 @@ $result=restrictedArea($user, 'banque', $id, 'bank_account&bank_account', '', '' $object = new Account($db); $extrafields = new ExtraFields($db); + // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('bankcard','globalcard')); @@ -136,7 +137,7 @@ if ($action == 'add') } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if (! $error) { @@ -241,7 +242,7 @@ if ($action == 'update') if (! $error) { // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); } if (! $error) @@ -433,7 +434,7 @@ if ($action == 'create') print $hookmanager->resPrint; if (empty($reshook)) { - print $object->showOptionals($extrafields, 'edit', $parameters); + print $object->showOptionals($extrafields, 'edit'); } print ''; diff --git a/htdocs/compta/bank/categ.php b/htdocs/compta/bank/categ.php index c2cba78dbbc..c4b127d02c9 100644 --- a/htdocs/compta/bank/categ.php +++ b/htdocs/compta/bank/categ.php @@ -142,7 +142,8 @@ if ($result) print "".$objp->label.""; print ''; print ''.img_edit().'  '; - print ''.img_delete().''; + print ''.img_delete().''; + print ''; } print ""; $i++; diff --git a/htdocs/compta/bank/list.php b/htdocs/compta/bank/list.php index 2bdea48487e..77971439f75 100644 --- a/htdocs/compta/bank/list.php +++ b/htdocs/compta/bank/list.php @@ -73,7 +73,7 @@ $hookmanager->initHooks(array('bankaccountlist')); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('bank_account'); +$extrafields->fetch_name_optionals_label('bank_account'); $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // List of fields to search into when doing a "search in all" diff --git a/htdocs/compta/bank/various_payment/card.php b/htdocs/compta/bank/various_payment/card.php index 6defb112efa..9260ee3f1f9 100644 --- a/htdocs/compta/bank/various_payment/card.php +++ b/htdocs/compta/bank/various_payment/card.php @@ -428,7 +428,7 @@ if ($id) if ($user->rights->banque->modifier) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/compta/bank/various_payment/document.php b/htdocs/compta/bank/various_payment/document.php index 6f0ed439d0d..a196540d484 100644 --- a/htdocs/compta/bank/various_payment/document.php +++ b/htdocs/compta/bank/various_payment/document.php @@ -93,7 +93,7 @@ if ($object->id) if ($user->rights->banque->modifier && 0) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/compta/bank/various_payment/info.php b/htdocs/compta/bank/various_payment/info.php index 033074d2584..4cc64bb830e 100644 --- a/htdocs/compta/bank/various_payment/info.php +++ b/htdocs/compta/bank/various_payment/info.php @@ -62,7 +62,7 @@ if (! empty($conf->projet->enabled)) if ($user->rights->banque->modifier && 0) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.=''; diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index d27f915fe33..aef5c0573f9 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -72,7 +72,7 @@ $object= new CashControl($db); $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); // Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context $hookmanager->initHooks(array('cashcontrolcard','globalcard')); diff --git a/htdocs/compta/cashcontrol/cashcontrol_list.php b/htdocs/compta/cashcontrol/cashcontrol_list.php index 00ba378c3b4..6b767bc3949 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_list.php +++ b/htdocs/compta/cashcontrol/cashcontrol_list.php @@ -78,8 +78,10 @@ $object=new CashControl($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->monmodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('cashcontrol')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('cashcontrol'); // Load $extrafields->attributes['cashcontrol'] +$extrafields->fetch_name_optionals_label($object->table_element); + $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 171ba639efb..9467cebde59 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -902,8 +902,7 @@ if (empty($reshook)) $error = 0; $originentity = GETPOST('originentity'); // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; // Replacement invoice @@ -1679,8 +1678,8 @@ if (empty($reshook)) $nextSituationInvoice = new Facture($db); $nextSituationInvoice->fetch($id); // create extrafields with data from create form - $extralabels = $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $nextSituationInvoice); + $extrafields->fetch_name_optionals_label($nextSituationInvoice->table_element); + $ret = $extrafields->setOptionalsFromPost(null, $nextSituationInvoice); if ($ret > 0) { $nextSituationInvoice->insertExtraFields(); } @@ -1752,9 +1751,8 @@ if (empty($reshook)) $remise_percent = GETPOST('remise_percent' . $predef); // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line, $predef); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line, $predef); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -2075,9 +2073,8 @@ if (empty($reshook)) $buyingprice = price2num(GETPOST('buying_price') != '' ? GETPOST('buying_price') : ''); // If buying_price is '0', we muste keep this value // Extrafields - $extrafieldsline = new ExtraFields($db); - $extralabelsline = $extrafieldsline->fetch_name_optionals_label($object->table_element_line); - $array_options = $extrafieldsline->getOptionalsFromPost($object->table_element_line); + $extralabelsline = $extrafields->fetch_name_optionals_label($object->table_element_line); + $array_options = $extrafields->getOptionalsFromPost($object->table_element_line); // Unset extrafield if (is_array($extralabelsline)) { // Get extra fields @@ -2496,8 +2493,7 @@ if (empty($reshook)) $object->oldcopy = dol_clone($object); // Fill array 'array_options' with data from add form - $extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - $ret = $extrafields->setOptionalsFromPost($extralabels, $object, GETPOST('attribute', 'none')); + $ret = $extrafields->setOptionalsFromPost(null, $object, GETPOST('attribute', 'none')); if ($ret < 0) $error++; if (! $error) @@ -2585,7 +2581,7 @@ llxHeader('', $title, $helpurl); if ($action == 'create') { $facturestatic = new Facture($db); - $extralabels = $extrafields->fetch_name_optionals_label($facturestatic->table_element); + $extrafields->fetch_name_optionals_label($facturestatic->table_element); print load_fiche_titre($langs->trans('NewBill'), '', 'invoicing'); @@ -3050,7 +3046,7 @@ if ($action == 'create') print '
'; $tmp='global->INVOICE_CREDIT_NOTE_STANDALONE)) $tmp.=' disabled'; $tmp.= '> '; // Show credit note options only if we checked credit note print ' + '; + } + return $html; +} + +/** + * Build the tooltip on top menu tsearch + * + * @param user $user User object + * @param Translate $langs Language object + * @return string HTML content + */ +function top_menu_search(User $user, Translate $langs) +{ + global $langs, $conf, $db, $hookmanager, $user; + global $menumanager; + $html = ''; + + $usedbyinclude=1; + $arrayresult=null; + include DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult + + $defaultAction = ''; + $buttonList=''; + + + + $searchInput = ''; + + + $dropDownHtml = ''."\n"; + $dropDownHtml.= ''; + + $dropDownHtml.= ' + + + '; + + $dropDownHtml.= ' + + + '; + + $dropDownHtml.= ''; + + + $html.= ' + '; + + $html .= ' + + + '; + + + return $html; +} + /** * Show left menu bar * @@ -1930,55 +2136,47 @@ function left_menu($menu_array_before, $helppagename = '', $notused = '', $menu_ if (! is_object($form)) $form=new Form($db); $selected=-1; - $usedbyinclude=1; - $arrayresult=null; - include_once DOL_DOCUMENT_ROOT.'/core/ajax/selectsearchbox.php'; // This set $arrayresult + if(empty($conf->global->MAIN_USE_TOP_MENU_SEARCH_DROPDOWN)) { + $usedbyinclude = 1; + $arrayresult = null; + include DOL_DOCUMENT_ROOT . '/core/ajax/selectsearchbox.php'; // This set $arrayresult - if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) - { - $searchform.=$form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY)?1:0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); - } - else - { - if (is_array($arrayresult)) - { - foreach($arrayresult as $key => $val) - { - $searchform.=printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft'.$key, img_picto('', $val['img'], '', false, 1, 1)); - } - } - } + if ($conf->use_javascript_ajax && empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) { + $searchform .= $form->selectArrayFilter('searchselectcombo', $arrayresult, $selected, '', 1, 0, (empty($conf->global->MAIN_SEARCHBOX_CONTENT_LOADED_BEFORE_KEY) ? 1 : 0), 'vmenusearchselectcombo', 1, $langs->trans("Search"), 1); + } else { + if (is_array($arrayresult)) { + foreach ($arrayresult as $key => $val) { + $searchform .= printSearchForm($val['url'], $val['url'], $val['label'], 'maxwidth125', 'sall', $val['shortcut'], 'searchleft' . $key, img_picto('', $val['img'], '', false, 1, 1)); + } + } + } - // Execute hook printSearchForm - $parameters=array('searchform'=>$searchform); - $reshook=$hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - $searchform.=$hookmanager->resPrint; - } - else $searchform=$hookmanager->resPrint; + // Execute hook printSearchForm + $parameters = array('searchform' => $searchform); + $reshook = $hookmanager->executeHooks('printSearchForm', $parameters); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) { + $searchform .= $hookmanager->resPrint; + } else $searchform = $hookmanager->resPrint; - // Force special value for $searchform - if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER) || empty($conf->use_javascript_ajax)) - { - $urltosearch=DOL_URL_ROOT.'/core/search_page.php?showtitlebefore=1'; - $searchform=''; - } - elseif ($conf->use_javascript_ajax && ! empty($conf->global->MAIN_USE_OLD_SEARCH_FORM)) - { - $searchform='
'; - $searchform.='' . "\n"; - $searchform.='
'; - } + $searchform .= '
'; + } + } // Define $bookmarks - if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire) + if (! empty($conf->bookmark->enabled) && $user->rights->bookmark->lire && empty($conf->global->MAIN_USE_TOP_MENU_BOOKMARK_DROPDOWN)) { include_once DOL_DOCUMENT_ROOT.'/bookmarks/bookmarks.lib.php'; $langs->load("bookmarks"); diff --git a/htdocs/modulebuilder/template/myobject_agenda.php b/htdocs/modulebuilder/template/myobject_agenda.php index 02583e81260..8abb3623909 100644 --- a/htdocs/modulebuilder/template/myobject_agenda.php +++ b/htdocs/modulebuilder/template/myobject_agenda.php @@ -87,7 +87,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectagenda','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('myobject'); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals @@ -162,7 +162,7 @@ if ($object->id > 0) if ($user->rights->mymodule->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index 788a106dbbb..7f28794d51b 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -80,8 +80,10 @@ $object=new MyObject($db); $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectcard','globalcard')); // Note that conf->hooks_modules contains array + // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); + $search_array_options=$extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Initialize array of search criterias @@ -209,6 +211,8 @@ if ($action == 'create') print '
'; print ''; + + //dol_set_focus('input[name="ref"]'); } // Part to edit record @@ -316,7 +320,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea if ($user->rights->mymodule->write) { if ($action != 'classify') - $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); $morehtmlref.='
'; @@ -354,7 +358,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea //$keyforbreak='fieldkeytoswitchonsecondcolumn'; include DOL_DOCUMENT_ROOT . '/core/tpl/commonfields_view.tpl.php'; - // Other attributes + // Other attributes. Fields from hook formObjectOptions and Extrafields. include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php'; print ''; diff --git a/htdocs/modulebuilder/template/myobject_document.php b/htdocs/modulebuilder/template/myobject_document.php index 7f7b2f58db2..5e40b12a076 100644 --- a/htdocs/modulebuilder/template/myobject_document.php +++ b/htdocs/modulebuilder/template/myobject_document.php @@ -76,7 +76,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectdocument','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('myobject'); +$extrafields->fetch_name_optionals_label($object->table_element); // Load object include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be include, not include_once // Must be include, not include_once. Include fetch and fetch_thirdparty but not fetch_optionals diff --git a/htdocs/modulebuilder/template/myobject_list.php b/htdocs/modulebuilder/template/myobject_list.php index 9de7feb5650..396ab0119f7 100644 --- a/htdocs/modulebuilder/template/myobject_list.php +++ b/htdocs/modulebuilder/template/myobject_list.php @@ -100,11 +100,8 @@ $diroutputmassaction = $conf->mymodule->dir_output . '/temp/massgeneration/'.$us $hookmanager->initHooks(array('myobjectlist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label($object->table_element); - -// fetch optionals attributes lines and labels -//$extrafieldsline = new ExtraFields($db); -//$extralabelslines=$extrafieldsline->fetch_name_optionals_label($object->table_element_line); +$extrafields->fetch_name_optionals_label($object->table_element); +//$extrafields->fetch_name_optionals_label($object->table_element_line); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); diff --git a/htdocs/modulebuilder/template/myobject_note.php b/htdocs/modulebuilder/template/myobject_note.php index b87e87c9045..c8dbc5d3140 100644 --- a/htdocs/modulebuilder/template/myobject_note.php +++ b/htdocs/modulebuilder/template/myobject_note.php @@ -56,7 +56,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction=$conf->mymodule->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('myobjectnote','globalcard')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('myobject'); +$extrafields->fetch_name_optionals_label($object->table_element); // Security check - Protection if external user //if ($user->societe_id > 0) access_forbidden(); @@ -116,7 +116,7 @@ if ($id > 0 || ! empty($ref)) if ($user->rights->mymodule->creer) { if ($action != 'classify') - //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; $morehtmlref.=' : '; if ($action == 'classify') { //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); diff --git a/htdocs/opensurvey/list.php b/htdocs/opensurvey/list.php index 3616c4f094c..202c236abc2 100644 --- a/htdocs/opensurvey/list.php +++ b/htdocs/opensurvey/list.php @@ -63,7 +63,7 @@ $extrafields = new ExtraFields($db); $diroutputmassaction = $conf->opensurvey->dir_output . '/temp/massgeneration/'.$user->id; $hookmanager->initHooks(array('surveylist')); // Note that conf->hooks_modules contains array // Fetch optionals attributes and labels -$extralabels = $extrafields->fetch_name_optionals_label('survey'); // Load $extrafields->attributes['myobject'] +$extrafields->fetch_name_optionals_label($object->table_element); $search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_'); // Default sort order (if not yet defined by previous GETPOST) diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 482dbead2c5..ef144c10e0d 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -1,22 +1,22 @@ - * Copyright (C) 2004-2016 Laurent Destailleur - * Copyright (C) 2005 Eric Seigne - * Copyright (C) 2005-2015 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2006 Auguria SARL - * Copyright (C) 2010-2015 Juanjo Menent - * Copyright (C) 2013-2016 Marcos García - * Copyright (C) 2012-2013 Cédric Salvador - * Copyright (C) 2011-2017 Alexandre Spangaro - * Copyright (C) 2014 Cédric Gross - * Copyright (C) 2014-2015 Ferran Marcet - * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Raphaël Doursenaud - * Copyright (C) 2016 Charlie Benke - * Copyright (C) 2016 Meziane Sof - * Copyright (C) 2017 Josep Lluís Amador - * Copyright (C) 2019 Frédéric France +/* Copyright (C) 2001-2007 Rodolphe Quiedeville + * Copyright (C) 2004-2016 Laurent Destailleur + * Copyright (C) 2005 Eric Seigne + * Copyright (C) 2005-2015 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2006 Auguria SARL + * Copyright (C) 2010-2015 Juanjo Menent + * Copyright (C) 2013-2016 Marcos García + * Copyright (C) 2012-2013 Cédric Salvador + * Copyright (C) 2011-2017 Alexandre Spangaro + * Copyright (C) 2014 Cédric Gross + * Copyright (C) 2014-2015 Ferran Marcet + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Raphaël Doursenaud + * Copyright (C) 2016 Charlie Benke + * Copyright (C) 2016 Meziane Sof + * Copyright (C) 2017 Josep Lluís Amador + * Copyright (C) 2019 Frédéric France * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,7 +83,7 @@ $object->type = $type; // so test later to fill $usercancxxx is correct $extrafields = new ExtraFields($db); // fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label($object->table_element); +$extrafields->fetch_name_optionals_label($object->table_element); if ($id > 0 || ! empty($ref)) { @@ -300,17 +300,17 @@ if (empty($reshook)) $object->desiredstock = GETPOST('desiredstock')?GETPOST('desiredstock'):0; $object->canvas = GETPOST('canvas'); $object->weight = GETPOST('weight'); - $object->weight_units = GETPOST('weight_units'); + $object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit $object->length = GETPOST('size'); - $object->length_units = GETPOST('size_units'); + $object->length_units = GETPOST('size_units'); // This is not the fk_unit but the power of unit $object->width = GETPOST('sizewidth'); $object->height = GETPOST('sizeheight'); $object->surface = GETPOST('surface'); - $object->surface_units = GETPOST('surface_units'); + $object->surface_units = GETPOST('surface_units'); // This is not the fk_unit but the power of unit $object->volume = GETPOST('volume'); - $object->volume_units = GETPOST('volume_units'); + $object->volume_units = GETPOST('volume_units'); // This is not the fk_unit but the power of unit $object->finished = GETPOST('finished', 'alpha'); - $object->fk_unit = GETPOST('units', 'alpha'); + $object->fk_unit = GETPOST('units', 'alpha'); // This is the fk_unit of sale $accountancy_code_sell = GETPOST('accountancy_code_sell', 'alpha'); $accountancy_code_sell_intra = GETPOST('accountancy_code_sell_intra', 'alpha'); @@ -340,7 +340,7 @@ if (empty($reshook)) } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (! $error) @@ -404,16 +404,16 @@ if (empty($reshook)) $object->canvas = GETPOST('canvas'); $object->weight = GETPOST('weight'); - $object->weight_units = GETPOST('weight_units'); + $object->weight_units = GETPOST('weight_units'); // This is not the fk_unit but the power of unit $object->length = GETPOST('size'); - $object->length_units = GETPOST('size_units'); - $object->width = GETPOST('sizewidth'); - $object->height = GETPOST('sizeheight'); + $object->length_units = GETPOST('size_units'); // This is not the fk_unit but the power of unit + $object->width = GETPOST('sizewidth'); + $object->height = GETPOST('sizeheight'); $object->surface = GETPOST('surface'); - $object->surface_units = GETPOST('surface_units'); + $object->surface_units = GETPOST('surface_units'); // This is not the fk_unit but the power of unit $object->volume = GETPOST('volume'); - $object->volume_units = GETPOST('volume_units'); + $object->volume_units = GETPOST('volume_units'); // This is not the fk_unit but the power of unit $object->finished = GETPOST('finished', 'alpha'); $units = GETPOST('units', 'int'); @@ -452,7 +452,7 @@ if (empty($reshook)) if ($accountancy_code_buy <= 0) { $object->accountancy_code_buy = ''; } else { $object->accountancy_code_buy = $accountancy_code_buy; } // Fill array 'array_options' with data from add form - $ret = $extrafields->setOptionalsFromPost($extralabels, $object); + $ret = $extrafields->setOptionalsFromPost(null, $object); if ($ret < 0) $error++; if (! $error && $object->check()) @@ -1057,7 +1057,7 @@ else // Weight print ''.$langs->trans("Weight").''; print ''; - print $formproduct->selectMeasuringUnits("weight_units", "weight", (empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT)); + print $formproduct->selectMeasuringUnits("weight_units", "weight", GETPOSTISSET('weight_units')?GETPOST('weight_units', 'alpha'):(empty($conf->global->MAIN_WEIGHT_DEFAULT_UNIT)?0:$conf->global->MAIN_WEIGHT_DEFAULT_UNIT), 0, 2); print ''; // Length if (empty($conf->global->PRODUCT_DISABLE_SIZE)) @@ -1066,7 +1066,7 @@ else print ' x '; print ' x '; print ''; - print $formproduct->selectMeasuringUnits("size_units", "size"); + print $formproduct->selectMeasuringUnits("size_units", "size", GETPOSTISSET('size_units')?GETPOST('size_units', 'alpha'):'0', 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) @@ -1074,7 +1074,7 @@ else // Surface print ''.$langs->trans("Surface").''; print ''; - print $formproduct->selectMeasuringUnits("surface_units", "surface"); + print $formproduct->selectMeasuringUnits("surface_units", "surface", GETPOSTISSET('surface_units')?GETPOST('surface_units', 'alpha'):'0', 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) @@ -1082,7 +1082,7 @@ else // Volume print ''.$langs->trans("Volume").''; print ''; - print $formproduct->selectMeasuringUnits("volume_units", "volume"); + print $formproduct->selectMeasuringUnits("volume_units", "volume", GETPOSTISSET('volume_units')?GETPOST('volume_units', 'alpha'):'0', 0, 2); print ''; } } @@ -1430,7 +1430,7 @@ else // Weight print ''.$langs->trans("Weight").''; print ' '; - print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units); + print $formproduct->selectMeasuringUnits("weight_units", "weight", $object->weight_units, 0, 2); print ''; if (empty($conf->global->PRODUCT_DISABLE_SIZE)) { @@ -1439,7 +1439,7 @@ else print 'x'; print 'x'; print ' '; - print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units); + print $formproduct->selectMeasuringUnits("size_units", "size", $object->length_units, 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_SURFACE)) @@ -1447,7 +1447,7 @@ else // Surface print ''.$langs->trans("Surface").''; print ' '; - print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units); + print $formproduct->selectMeasuringUnits("surface_units", "surface", $object->surface_units, 0, 2); print ''; } if (empty($conf->global->PRODUCT_DISABLE_VOLUME)) @@ -1455,7 +1455,7 @@ else // Volume print ''.$langs->trans("Volume").''; print ' '; - print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units); + print $formproduct->selectMeasuringUnits("volume_units", "volume", $object->volume_units, 0, 2); print ''; } } @@ -1618,7 +1618,9 @@ else { // TODO change for compatibility with edit in place $typeformat='select;0:'.$langs->trans("Product").',1:'.$langs->trans("Service"); - print ''.$form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat).''; + print ''; + print (empty($conf->global->PRODUCT_DENY_CHANGE_PRODUCT_TYPE)) ? $form->editfieldkey("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat) : $langs->trans('Type'); + print ''; print $form->editfieldval("Type", 'fk_product_type', $object->type, $object, $usercancreate, $typeformat); print ''; } @@ -1630,7 +1632,7 @@ else print ''; - if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) print ''; + if (($action != 'editbarcodetype') && $usercancreate && $createbarcode) print ''; print '
'; print $langs->trans("BarcodeType"); print 'id.'">'.img_edit($langs->trans('Edit'), 1).'id.'">'.img_edit($langs->trans('Edit'), 1).'
'; print ''; if ($action == 'editbarcodetype' || $action == 'editbarcode') @@ -1654,7 +1656,7 @@ else print ''; - if (($action != 'editbarcode') && $usercancreate && $createbarcode) print ''; + if (($action != 'editbarcode') && $usercancreate && $createbarcode) print ''; print '
'; print $langs->trans("BarcodeValue"); print 'id.'">'.img_edit($langs->trans('Edit'), 1).'id.'">'.img_edit($langs->trans('Edit'), 1).'
'; print ''; if ($action == 'editbarcode') @@ -1831,11 +1833,12 @@ else print ''.$langs->trans("Nature").''; print $object->getLibFinished(); print ''; + // Weight print ''.$langs->trans("Weight").''; if ($object->weight != '') { - print $object->weight." ".measuring_units_string($object->weight_units, "weight"); + print $object->weight." ".measuring_units_string(0, "weight", $object->weight_units); } else { @@ -1851,7 +1854,7 @@ else print $object->length; if ($object->width) print " x ".$object->width; if ($object->height) print " x ".$object->height; - print ' '.measuring_units_string($object->length_units, "size"); + print ' '.measuring_units_string(0, "size", $object->length_units); } else { @@ -1865,7 +1868,7 @@ else print ''.$langs->trans("Surface").''; if ($object->surface != '') { - print $object->surface." ".measuring_units_string($object->surface_units, "surface"); + print $object->surface." ".measuring_units_string(0, "surface", $object->surface_units); } else { @@ -1879,7 +1882,7 @@ else print ''.$langs->trans("Volume").''; if ($object->volume != '') { - print $object->volume." ".measuring_units_string($object->volume_units, "volume"); + print $object->volume." ".measuring_units_string(0, "volume", $object->volume_units); } else { diff --git a/htdocs/product/class/api_products.class.php b/htdocs/product/class/api_products.class.php index 16cf12e422d..346aef06a91 100644 --- a/htdocs/product/class/api_products.class.php +++ b/htdocs/product/class/api_products.class.php @@ -15,10 +15,11 @@ * along with this program. If not, see . */ - use Luracast\Restler\RestException; +use Luracast\Restler\RestException; - require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; - require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; +require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; +require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php'; /** * API class for products @@ -41,6 +42,11 @@ class Products extends DolibarrApi */ public $product; + /** + * @var ProductFournisseur $productsupplier {@type ProductFournisseur} + */ + public $productsupplier; + /** * Constructor */ @@ -49,6 +55,7 @@ class Products extends DolibarrApi global $db, $conf; $this->db = $db; $this->product = new Product($this->db); + $this->productsupplier = new ProductFournisseur($this->db); } /** @@ -467,6 +474,41 @@ class Products extends DolibarrApi ); } + /** + * Delete purchase price for a product + * + * @param int $id Product ID + * @param int $priceid purchase price ID + * + * @url DELETE {id}/purchase_prices/{priceid} + * + * @return int + * + * @throws 401 + * @throws 404 + * + */ + public function deletePurchasePrice($id, $priceid) + { + if(! DolibarrApiAccess::$user->rights->produit->supprimer) { + throw new RestException(401); + } + $result = $this->product->fetch($id); + if(! $result ) { + throw new RestException(404, 'Product not found'); + } + + if(! DolibarrApi::_checkAccessToResource('product', $this->product->id)) { + throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login); + } + $resultsupplier = 0; + if ($result) { + $this->productsupplier->fetch($id); + $resultsupplier = $this->product->remove_product_fournisseur_price($priceid); + } + + return $resultsupplier; + } /** * List purchase prices @@ -597,16 +639,15 @@ class Products extends DolibarrApi } if ($includestockdata) { - $this->product->load_stock(); + $this->product->load_stock(); } - if($result) { - $this->product = new ProductFournisseur($this->db); - $this->product->fetch($id, $ref); - $this->product->list_product_fournisseur_price($id, '', '', 0, 0); + if ($result) { + $this->productsupplier->fetch($id, $ref); + $this->productsupplier->list_product_fournisseur_price($id, '', '', 0, 0); } - return $this->_cleanObjectDatas($this->product); + return $this->_cleanObjectDatas($this->productsupplier); } // phpcs:disable PEAR.NamingConventions.ValidFunctionName.PublicUnderscore diff --git a/htdocs/product/class/html.formproduct.class.php b/htdocs/product/class/html.formproduct.class.php index bbf6d642ad2..33bf1240c92 100644 --- a/htdocs/product/class/html.formproduct.class.php +++ b/htdocs/product/class/html.formproduct.class.php @@ -333,7 +333,7 @@ class FormProduct * @param string $measuring_style Unit to show: weight, size, surface, volume, time * @param string $default Preselected value * @param int $adddefault Add empty unit called "Default" - * @param int $mode 1=Use short label as value, 0=Use rowid + * @param int $mode 1=Use short label as value, 0=Use rowid, 2=Use scale (power) * @return string */ public function selectMeasuringUnits($name = 'measuring_units', $measuring_style = '', $default = '0', $adddefault = 0, $mode = 0) @@ -370,10 +370,12 @@ class FormProduct { $return .= '