\n";
$i++;
}
- $db->free();
+ $db->free($resql);
print "";
} else {
@@ -532,7 +537,8 @@ if ($resql) {
print "\n";
$i++;
}
- $db->free();
+
+ $db->free($resql);
print "";
} else {
@@ -614,7 +620,7 @@ if ($resql) {
print "\n";
$i++;
}
- $db->free();
+ $db->free($resql);
print "";
} else {
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index f97d4aa94ee..cec127eeac4 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -121,7 +121,7 @@ if ($action == 'add' && !empty($permissiontoadd)) {
// Fill array 'array_options' with data from add form
if (!$error) {
- $ret = $extrafields->setOptionalsFromPost(null, $object);
+ $ret = $extrafields->setOptionalsFromPost(null, $object, '', 1);
if ($ret < 0) {
$error++;
}
diff --git a/htdocs/core/boxes/box_boms.php b/htdocs/core/boxes/box_boms.php
index d96fac8bc76..a9a4f8746da 100644
--- a/htdocs/core/boxes/box_boms.php
+++ b/htdocs/core/boxes/box_boms.php
@@ -147,7 +147,7 @@ class box_boms extends ModeleBoxes
}
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datem, 'day', 'tzuserrel'),
);
diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php
index 2afa630860b..4a7ea965006 100644
--- a/htdocs/core/boxes/box_clients.php
+++ b/htdocs/core/boxes/box_clients.php
@@ -140,7 +140,7 @@ class box_clients extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="center nowraponall"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datem, "day", 'tzuserrel')
);
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index b2ba608d689..ea35a080d0e 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -177,7 +177,7 @@ class box_contacts extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datem, "day", 'tzuserrel'),
);
diff --git a/htdocs/core/boxes/box_contracts.php b/htdocs/core/boxes/box_contracts.php
index 8eeb1b93323..dddafffdc02 100644
--- a/htdocs/core/boxes/box_contracts.php
+++ b/htdocs/core/boxes/box_contracts.php
@@ -83,8 +83,8 @@ class box_contracts extends ModeleBoxes
$thirdpartytmp = new Societe($this->db);
$sql = "SELECT s.nom as name, s.rowid as socid, s.email, s.client, s.fournisseur, s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur,";
- $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.fin_validite, c.date_cloture";
- $sql .= ", c.ref_customer, c.ref_supplier";
+ $sql .= " c.rowid, c.ref, c.statut as fk_statut, c.date_contrat, c.datec, c.tms as date_modification, c.fin_validite, c.date_cloture,";
+ $sql .= " c.ref_customer, c.ref_supplier";
$sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."contrat as c";
if (empty($user->rights->societe->client->voir) && !$user->socid) {
$sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
@@ -117,6 +117,7 @@ class box_contracts extends ModeleBoxes
$objp = $this->db->fetch_object($resql);
$datec = $this->db->jdate($objp->datec);
+ $datem = $this->db->jdate($objp->date_modification);
$dateterm = $this->db->jdate($objp->fin_validite);
$dateclose = $this->db->jdate($objp->date_cloture);
$late = '';
@@ -155,8 +156,8 @@ class box_contracts extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="right"',
- 'text' => dol_print_date($datec, 'day', 'tzuserrel'),
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
+ 'text' => dol_print_date($datem, 'day', 'tzuserrel'),
);
$this->info_box_contents[$line][] = array(
diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php
index 5865cba2530..e091d58643b 100644
--- a/htdocs/core/boxes/box_members.php
+++ b/htdocs/core/boxes/box_members.php
@@ -145,7 +145,7 @@ class box_members extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="center nowraponall"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datem, "day", 'tzuserrel'),
);
diff --git a/htdocs/core/boxes/box_mos.php b/htdocs/core/boxes/box_mos.php
index 6436fb8e34e..cff19388c17 100644
--- a/htdocs/core/boxes/box_mos.php
+++ b/htdocs/core/boxes/box_mos.php
@@ -144,7 +144,7 @@ class box_mos extends ModeleBoxes
}
$this->info_box_contents[$line][] = array(
- 'td' => 'class="center nowraponall"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("DateModification").': '.dol_print_date($datem, 'dayhour', 'tzuserrel')).'"',
'text' => dol_print_date($datem, 'day', 'tzuserrel'),
);
diff --git a/htdocs/core/boxes/box_propales.php b/htdocs/core/boxes/box_propales.php
index f3f9496325f..97b7bd5fd51 100644
--- a/htdocs/core/boxes/box_propales.php
+++ b/htdocs/core/boxes/box_propales.php
@@ -165,7 +165,7 @@ class box_propales extends ModeleBoxes
);
$this->info_box_contents[$line][] = array(
- 'td' => 'class="center nowraponall"',
+ 'td' => 'class="center nowraponall" title="'.dol_escape_htmltag($langs->trans("Date").': '.dol_print_date($datem, 'day', 'tzuserrel')).'"',
'text' => dol_print_date($date, 'day', 'tzuserrel'),
);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index e1ed8855378..6466754f241 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -7805,7 +7805,7 @@ abstract class CommonObject
* @param string $keyprefix Prefix string to add before name and id of field (can be used to avoid duplicate names)
* @param string $onetrtd All fields in same tr td. Used by objectline_create.tpl.php for example.
* @param string $display_type "card" for form display, "line" for document line display (extrafields on propal line, order line, etc...)
- * @return string
+ * @return string String with html content to show
*/
public function showOptionals($extrafields, $mode = 'view', $params = null, $keysuffix = '', $keyprefix = '', $onetrtd = 0, $display_type = 'card')
{
@@ -7814,13 +7814,20 @@ abstract class CommonObject
if (!is_object($form)) {
$form = new Form($db);
}
+ if (!is_object($extrafields)) {
+ dol_syslog('Bad parameter extrafields for showOptionals', LOG_ERR);
+ return 'Bad parameter extrafields for showOptionals';
+ }
+ if (!is_array($extrafields->attributes[$this->table_element])) {
+ dol_syslog("extrafields->attributes was not loaded with extrafields->fetch_name_optionals_label(table_element);", LOG_WARNING);
+ }
$out = '';
$parameters = array();
$reshook = $hookmanager->executeHooks('showOptionals', $parameters, $this, $action); // Note that $action and $object may have been modified by hook
if (empty($reshook)) {
- if (key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) {
+ if (is_array($extrafields->attributes[$this->table_element]) && key_exists('label', $extrafields->attributes[$this->table_element]) && is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0) {
$out .= "\n";
$out .= ' ';
$out .= "\n";
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 3a396e365d7..768031467bc 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -1948,14 +1948,15 @@ class ExtraFields
/**
* Fill array_options property of object by extrafields value (using for data sent by forms)
*
- * @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
- * @param object $object Object
- * @param string $onlykey Only some keys are filled:
- * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
- * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
- * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
+ * @param array $extralabels Deprecated (old $array of extrafields, now set this to null)
+ * @param object $object Object
+ * @param string $onlykey Only some keys are filled:
+ * 'string' => When we make update of only one extrafield ($action = 'update_extras'), calling page can set this to avoid to have other extrafields being reset.
+ * '@GETPOSTISSET' => When we make update of several extrafields ($action = 'update'), calling page can set this to avoid to have fields not into POST being reset.
+ * @param int $todefaultifmissing 1=Set value to the default value in database if value is mandatory and missing
+ * @return int 1 if array_options set, 0 if no value, -1 if error (field required missing for example)
*/
- public function setOptionalsFromPost($extralabels, &$object, $onlykey = '')
+ public function setOptionalsFromPost($extralabels, &$object, $onlykey = '', $todefaultifmissing = 0)
{
global $_POST, $langs;
@@ -2015,8 +2016,10 @@ class ExtraFields
|| (!is_array($_POST["options_".$key]) && isset($_POST["options_".$key]) && $this->attributes[$object->table_element]['type'][$key] == 'sellist' && $_POST['options_'.$key] == '0')
|| (is_array($_POST["options_".$key]) && empty($_POST["options_".$key]))) {
//print 'ccc'.$value.'-'.$this->attributes[$object->table_element]['required'][$key];
+
+ // Field is not defined. We mark this as a problem. We may fix it later if there is a default value and $todefaultifmissing is set.
$nofillrequired++;
- $error_field_required[] = $langs->transnoentitiesnoconv($value);
+ $error_field_required[$key] = $langs->transnoentitiesnoconv($value);
}
}
@@ -2047,12 +2050,22 @@ class ExtraFields
}
}
+ if (!empty($error_field_required[$key]) && $todefaultifmissing) {
+ // Value is required but we have a default value and we asked to set empty value to the default value
+ if (!empty($this->attributes[$object->table_element]['default']) && !is_null($this->attributes[$object->table_element]['default'][$key])) {
+ $value_key = $this->attributes[$object->table_element]['default'][$key];
+ unset($error_field_required[$key]);
+ $nofillrequired--;
+ }
+ }
+
$object->array_options["options_".$key] = $value_key;
}
if ($nofillrequired) {
$langs->load('errors');
- setEventMessages($langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required), null, 'errors');
+ $this->error = $langs->trans('ErrorFieldsRequired').' : '.implode(', ', $error_field_required);
+ setEventMessages($this->error, null, 'errors');
return -1;
} else {
return 1;
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 244da59b5ff..19ea745c8e1 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -1533,10 +1533,12 @@ class FormMail extends Form
if (!is_object($extrafields)) {
$extrafields = new ExtraFields($this->db);
}
- $extrafields->fetch_name_optionals_label('product', true);
$product = new Product($this->db);
$product->fetch($line->fk_product, '', '', 1);
$product->fetch_optionals();
+
+ $extrafields->fetch_name_optionals_label($product->table_element, true);
+
if (is_array($extrafields->attributes[$product->table_element]['label']) && count($extrafields->attributes[$product->table_element]['label']) > 0) {
foreach ($extrafields->attributes[$product->table_element]['label'] as $key => $label) {
$substit_line['__PRODUCT_EXTRAFIELD_'.strtoupper($key).'__'] = $product->array_options['options_'.$key];
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 8776381b922..8772cd55714 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -2257,7 +2257,7 @@ function dol_format_address($object, $withcountry = 0, $sep = "\n", $outputlangs
$ret = '';
$countriesusingstate = array('AU', 'CA', 'US', 'IN', 'GB', 'ES', 'UK', 'TR', 'CN'); // See also MAIN_FORCE_STATE_INTO_ADDRESS
- $sep = "\n";
+
// See format of addresses on https://en.wikipedia.org/wiki/Address
// Address
if (empty($mode)) {
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 15162c8b273..56aa24a8523 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -509,7 +509,7 @@ function project_admin_prepare_head()
$head[$h][2] = 'attributes_task';
$h++;
- if (getDolGlobalInt('MAIN_FEATURES_LEVEL') >= 2) {
+ if (!empty($conf->global->PROJECT_USE_OPPORTUNITIES)) {
$langs->load("members");
$head[$h][0] = DOL_URL_ROOT.'/projet/admin/website.php';
@@ -2819,7 +2819,7 @@ function getTaskProgressView($task, $label = true, $progressNumber = true, $hide
$out .= ' ';
} else {
// bad
- $out .= '
';
+ $out .= '
';
$out .= ' ';
$out .= '
';
}
diff --git a/htdocs/core/tpl/extrafields_add.tpl.php b/htdocs/core/tpl/extrafields_add.tpl.php
index 2f44bbe9c48..fa150d6a27b 100644
--- a/htdocs/core/tpl/extrafields_add.tpl.php
+++ b/htdocs/core/tpl/extrafields_add.tpl.php
@@ -41,6 +41,7 @@ if (!isset($parameters)) {
}
$reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
+
print $hookmanager->resPrint;
if (empty($reshook)) {
$params = array();
@@ -48,6 +49,7 @@ if (empty($reshook)) {
$params['tpl_context'] = $tpl_context;
}
$params['cols'] = key_exists('colspanvalue', $parameters) ? $parameters['colspanvalue'] : '';
+
print $object->showOptionals($extrafields, 'create', $params);
}
diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
index 187e3f5a156..0e018514353 100644
--- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
+++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php
@@ -924,7 +924,8 @@ class InterfaceActionsAuto extends DolibarrTriggers
}
}
- // If trackid is not defined, we set it
+ // If trackid is not defined, we set it.
+ // Note that it should be set by caller. This is for compatibility purpose only.
if (empty($object->trackid)) {
// See also similar list into emailcollector.class.php
if (preg_match('/^COMPANY_/', $action)) {
@@ -1039,15 +1040,17 @@ class InterfaceActionsAuto extends DolibarrTriggers
$actioncomm->contact_id = $contactforaction->id; // deprecated, use ->socpeopleassigned instead
$actioncomm->authorid = $user->id; // User saving action
$actioncomm->userownerid = $user->id; // Owner of action
- // Fields defined when action is an email (content should be into object->actionmsg to be added into note, subject into object->actionms2 to be added into label)
- $actioncomm->email_msgid = empty($object->email_msgid) ? null : $object->email_msgid;
- $actioncomm->email_from = empty($object->email_from) ? null : $object->email_from;
- $actioncomm->email_sender = empty($object->email_sender) ? null : $object->email_sender;
- $actioncomm->email_to = empty($object->email_to) ? null : $object->email_to;
- $actioncomm->email_tocc = empty($object->email_tocc) ? null : $object->email_tocc;
- $actioncomm->email_tobcc = empty($object->email_tobcc) ? null : $object->email_tobcc;
- $actioncomm->email_subject = empty($object->email_subject) ? null : $object->email_subject;
- $actioncomm->errors_to = empty($object->errors_to) ? null : $object->errors_to;
+ // Fields defined when action is an email (content should be into object->actionmsg to be added into event note, subject should be into object->actionms2 to be added into event label)
+ if (!property_exists($object, 'email_fields_no_propagate_in_actioncomm') || empty($object->email_fields_no_propagate_in_actioncomm)) {
+ $actioncomm->email_msgid = empty($object->email_msgid) ? null : $object->email_msgid;
+ $actioncomm->email_from = empty($object->email_from) ? null : $object->email_from;
+ $actioncomm->email_sender = empty($object->email_sender) ? null : $object->email_sender;
+ $actioncomm->email_to = empty($object->email_to) ? null : $object->email_to;
+ $actioncomm->email_tocc = empty($object->email_tocc) ? null : $object->email_tocc;
+ $actioncomm->email_tobcc = empty($object->email_tobcc) ? null : $object->email_tobcc;
+ $actioncomm->email_subject = empty($object->email_subject) ? null : $object->email_subject;
+ $actioncomm->errors_to = empty($object->errors_to) ? null : $object->errors_to;
+ }
// Object linked (if link is for thirdparty, contact, project it is a recording error. We should not have links in link table
// for such objects because there is already a dedicated field into table llx_actioncomm or llx_actioncomm_resources.
diff --git a/htdocs/don/payment/payment.php b/htdocs/don/payment/payment.php
index 5128509c88c..6cc37303346 100644
--- a/htdocs/don/payment/payment.php
+++ b/htdocs/don/payment/payment.php
@@ -149,7 +149,7 @@ $resql = $db->query($sql);
if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
- $db->free();
+ $db->free($resql);
}
diff --git a/htdocs/expensereport/payment/payment.php b/htdocs/expensereport/payment/payment.php
index ee80c9bc24a..185b3cdc139 100644
--- a/htdocs/expensereport/payment/payment.php
+++ b/htdocs/expensereport/payment/payment.php
@@ -212,7 +212,7 @@ if ($action == 'create' || empty($action)) {
if ($resql) {
$obj = $db->fetch_object($resql);
$sumpaid = $obj->total;
- $db->free();
+ $db->free($resql);
}
print '
';
if (!in_array($year, $arrayyears)) {
$arrayyears[$year] = $year;
}
diff --git a/htdocs/public/members/new.php b/htdocs/public/members/new.php
index 055ffec56f9..7a27ae14b62 100644
--- a/htdocs/public/members/new.php
+++ b/htdocs/public/members/new.php
@@ -57,7 +57,6 @@ if (!defined('NOIPCHECK')) {
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
-// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
@@ -430,7 +429,7 @@ if (empty($reshook) && $action == 'added') {
llxHeaderVierge($langs->trans("NewMemberForm"));
// Si on a pas ete redirige
- print ' ';
+ print '
';
print '
';
print $langs->trans("NewMemberbyWeb");
print '
';
@@ -448,7 +447,7 @@ if (empty($reshook) && $action == 'added') {
$form = new Form($db);
$formcompany = new FormCompany($db);
$adht = new AdherentType($db);
-$extrafields->fetch_name_optionals_label('adherent'); // fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($object->table_element); // fetch optionals attributes and labels
llxHeaderVierge($langs->trans("NewSubscription"));
diff --git a/htdocs/public/partnership/new.php b/htdocs/public/partnership/new.php
index cbc1b849115..f6f0efc4fb2 100644
--- a/htdocs/public/partnership/new.php
+++ b/htdocs/public/partnership/new.php
@@ -419,7 +419,7 @@ if (empty($reshook) && $action == 'added') {
llxHeaderVierge($langs->trans("NewPartnershipForm"));
// Si on a pas ete redirige
- print ' ';
+ print '
';
@@ -437,7 +437,7 @@ if (empty($reshook) && $action == 'added') {
$form = new Form($db);
$formcompany = new FormCompany($db);
-$extrafields->fetch_name_optionals_label('partnership'); // fetch optionals attributes and labels
+$extrafields->fetch_name_optionals_label($partnership->table_element); // fetch optionals attributes and labels
llxHeaderVierge($langs->trans("NewPartnershipRequest"));
diff --git a/htdocs/public/project/new.php b/htdocs/public/project/new.php
index 971031e7a80..4838c88c5a1 100644
--- a/htdocs/public/project/new.php
+++ b/htdocs/public/project/new.php
@@ -45,7 +45,6 @@ if (!defined('NOIPCHECK')) {
// For MultiCompany module.
// Do not use GETPOST here, function is not defined and define must be done before including main.inc.php
-// TODO This should be useless. Because entity must be retrieve from object ref and not from url.
$entity = (!empty($_GET['entity']) ? (int) $_GET['entity'] : (!empty($_POST['entity']) ? (int) $_POST['entity'] : 1));
if (is_numeric($entity)) {
define("DOLENTITY", $entity);
@@ -132,9 +131,9 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $
print '';
}
- if (!empty($conf->global->PROJECT_IMAGE_PUBLIC_ORGANIZEDEVENT)) {
- print '
'."\n";
+
// Other attributes
$tpl_context = 'public'; // define template context to public
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_add.tpl.php';
// Comments
print '