';
- print $ligne->LibStatut($row[1], 1);
+ print $line->LibStatut($row[1], 1);
print ' ';
print price($row[0]);
diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php
index 781daacd030..843a894a0fd 100644
--- a/htdocs/contact/list.php
+++ b/htdocs/contact/list.php
@@ -143,7 +143,7 @@ $hookmanager->initHooks(array('contactlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('contact');
+$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
@@ -200,7 +200,13 @@ if (is_array($extrafields->attributes[$object->table_element]['label']) && count
foreach ($extrafields->attributes[$object->table_element]['label'] as $key => $val)
{
if (!empty($extrafields->attributes[$object->table_element]['list'][$key]))
- $arrayfields["ef.".$key] = array('label'=>$extrafields->attributes[$object->table_element]['label'][$key], 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1), 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key], 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]));
+ $arrayfields["ef.".$key] = array(
+ 'label'=>$extrafields->attributes[$object->table_element]['label'][$key],
+ 'checked'=>(($extrafields->attributes[$object->table_element]['list'][$key] < 0) ? 0 : 1),
+ 'position'=>$extrafields->attributes[$object->table_element]['pos'][$key],
+ 'enabled'=>(abs($extrafields->attributes[$object->table_element]['list'][$key]) != 3 && $extrafields->attributes[$object->table_element]['perms'][$key]),
+ 'langfile'=>$extrafields->attributes[$object->table_element]['langfile'][$key],
+ );
}
}
$object->fields = dol_sort_array($object->fields, 'position');
@@ -412,8 +418,8 @@ else
$nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
{
- $result = $db->query($sql);
- $nbtotalofrecords = $db->num_rows($result);
+ $resql = $db->query($sql);
+ $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total resultset is smaller then paging size (filtering), goto and load page 0
{
$page = 0;
@@ -423,14 +429,14 @@ if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
$sql .= $db->plimit($limit + 1, $offset);
-$result = $db->query($sql);
-if (!$result)
+$resql = $db->query($sql);
+if (! $resql)
{
dol_print_error($db);
exit;
}
-$num = $db->num_rows($result);
+$num = $db->num_rows($resql);
$arrayofselected = is_array($toselect) ? $toselect : array();
@@ -786,7 +792,7 @@ $i = 0;
$totalarray = array();
while ($i < min($num, $limit))
{
- $obj = $db->fetch_object($result);
+ $obj = $db->fetch_object($resql);
$arraysocialnetworks = (array) json_decode($obj->socialnetworks, true);
$contactstatic->lastname = $obj->lastname;
@@ -986,7 +992,7 @@ while ($i < min($num, $limit))
$i++;
}
-$db->free($result);
+$db->free($resql);
$parameters = array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $object may have been modified by hook
diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 1dec473edac..1153f89689d 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2468,6 +2468,7 @@ class Contrat extends CommonObject
global $conf, $langs;
$langs->load("contracts");
+ $outputlangs->load("products");
if (!dol_strlen($modele)) {
$modele = 'strato';
diff --git a/htdocs/contrat/list.php b/htdocs/contrat/list.php
index a7205730817..37fd99a771e 100644
--- a/htdocs/contrat/list.php
+++ b/htdocs/contrat/list.php
@@ -100,7 +100,7 @@ $hookmanager->initHooks(array('contractlist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('contrat');
+$extrafields->fetch_name_optionals_label($object->table_element);
$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/contrat/services_list.php b/htdocs/contrat/services_list.php
index 2b81ceff5fa..90f6516a499 100644
--- a/htdocs/contrat/services_list.php
+++ b/htdocs/contrat/services_list.php
@@ -84,7 +84,7 @@ $hookmanager->initHooks(array('contractservicelist'));
$extrafields = new ExtraFields($db);
// fetch optionals attributes and labels
-$extrafields->fetch_name_optionals_label('contratdet');
+$extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php
index 912c9953229..ec35ec4061d 100644
--- a/htdocs/core/actions_addupdatedelete.inc.php
+++ b/htdocs/core/actions_addupdatedelete.inc.php
@@ -165,7 +165,7 @@ if ($action == 'update' && !empty($permissiontoadd))
} elseif (preg_match('/^(integer|price|real|double)/', $object->fields[$key]['type'])) {
$value = price2num(GETPOST($key, 'none')); // To fix decimal separator according to lang setup
} elseif ($object->fields[$key]['type'] == 'boolean') {
- $value = (GETPOST($key) == 'on' ? 1 : 0);
+ $value = ((GETPOST($key, 'aZ09') == 'on' || GETPOST($key, 'aZ09') == '1') ? 1 : 0);
} else {
$value = GETPOST($key, 'alpha');
}
@@ -219,7 +219,7 @@ if ($action == "update_extras" && !empty($permissiontoadd))
$object->array_options['options_'.$attributekey] = dol_mktime(GETPOST($attributekeylong.'hour', 'int'), GETPOST($attributekeylong.'min', 'int'), GETPOST($attributekeylong.'sec', 'int'), GETPOST($attributekeylong.'month', 'int'), GETPOST($attributekeylong.'day', 'int'), GETPOST($attributekeylong.'year', 'int'));
//var_dump(dol_print_date($object->array_options['options_'.$attributekey]));exit;
} else {
- $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, ' alpha');
+ $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong, 'alpha');
}
$result = $object->insertExtraFields(empty($triggermodname) ? '' : $triggermodname, $user);
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 5c7251c40e2..5ac114cfa69 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -270,6 +270,26 @@ class CMailFile
}
}
+ // Add autocopy to (Note: Adding bcc for specific modules are also done from pages)
+ if (! empty($conf->global->MAIN_MAIL_AUTOCOPY_TO)) $addr_bcc.=($addr_bcc?', ':'').$conf->global->MAIN_MAIL_AUTOCOPY_TO;
+
+ $this->addr_to = $to;
+ $this->addr_cc = $addr_cc;
+ $this->addr_bcc = $addr_bcc;
+ $this->reply_to = $replyto;
+ $this->addr_from = $from;
+ $this->subject = $subject;
+ $this->errors_to = $errors_to;
+ $this->deliveryreceipt = $deliveryreceipt;
+ $this->trackid = $trackid;
+
+ if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
+ {
+ $this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
+ $this->addr_cc = '';
+ $this->addr_bcc = '';
+ }
+
// We set all data according to choosed sending method.
// We also set a value for ->msgid
if ($this->sendmode == 'mail')
@@ -330,16 +350,16 @@ class CMailFile
$smtps->setCharSet($conf->file->character_set_client);
// Encode subject if required.
- $subjecttouse = $subject;
+ $subjecttouse = $this->subject;
if (!ascii_check($subjecttouse)) {
$subjecttouse = $this->encodetorfc2822($subjecttouse);
}
$smtps->setSubject($subjecttouse);
- $smtps->setTO($this->getValidAddress($to, 0, 1));
- $smtps->setFrom($this->getValidAddress($from, 0, 1));
- $smtps->setTrackId($trackid);
- $smtps->setReplyTo($this->getValidAddress($replyto, 0, 1));
+ $smtps->setTO($this->getValidAddress($this->addr_to, 0, 1));
+ $smtps->setFrom($this->getValidAddress($this->addr_from, 0, 1));
+ $smtps->setTrackId($this->trackid);
+ $smtps->setReplyTo($this->getValidAddress($this->replyto, 0, 1));
if (!empty($moreinheader)) $smtps->setMoreInHeader($moreinheader);
@@ -377,13 +397,13 @@ class CMailFile
}
}
- $smtps->setCC($addr_cc);
- $smtps->setBCC($addr_bcc);
- $smtps->setErrorsTo($errors_to);
- $smtps->setDeliveryReceipt($deliveryreceipt);
+ $smtps->setCC($this->addr_cc);
+ $smtps->setBCC($this->addr_bcc);
+ $smtps->setErrorsTo($this->errors_to);
+ $smtps->setDeliveryReceipt($this->deliveryreceipt);
$host = dol_getprefix('email');
- $this->msgid = time().'.SMTPs-dolibarr-'.$trackid.'@'.$host;
+ $this->msgid = time().'.SMTPs-dolibarr-'.$this->trackid.'@'.$host;
$this->smtps = $smtps;
}
@@ -405,8 +425,8 @@ class CMailFile
//$this->message = new Swift_SignedMessage();
// Adding a trackid header to a message
$headers = $this->message->getHeaders();
- $headers->addTextHeader('X-Dolibarr-TRACKID', $trackid.'@'.$host);
- $this->msgid = time().'.swiftmailer-dolibarr-'.$trackid.'@'.$host;
+ $headers->addTextHeader('X-Dolibarr-TRACKID', $this->trackid.'@'.$host);
+ $this->msgid = time().'.swiftmailer-dolibarr-'.$this->trackid.'@'.$host;
$headerID = $this->msgid;
$msgid = $headers->get('Message-ID');
$msgid->setId($headerID);
@@ -415,33 +435,33 @@ class CMailFile
// Give the message a subject
try {
- $result = $this->message->setSubject($subject);
+ $result = $this->message->setSubject($this->subject);
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
// Set the From address with an associative array
//$this->message->setFrom(array('john@doe.com' => 'John Doe'));
- if (!empty($from)) {
+ if (! empty($this->addr_from)) {
try {
- $result = $this->message->setFrom($this->getArrayAddress($from));
+ $result = $this->message->setFrom($this->getArrayAddress($this->addr_from));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
// Set the To addresses with an associative array
- if (!empty($to)) {
+ if (! empty($this->addr_to)) {
try {
- $result = $this->message->setTo($this->getArrayAddress($to));
+ $result = $this->message->setTo($this->getArrayAddress($this->addr_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
}
- if (!empty($replyto)) {
+ if (! empty($this->reply_to)) {
try {
- $result = $this->message->SetReplyTo($this->getArrayAddress($replyto));
+ $result = $this->message->SetReplyTo($this->getArrayAddress($this->reply_to));
} catch (Exception $e) {
$this->errors[] = $e->getMessage();
}
@@ -495,10 +515,10 @@ class CMailFile
}
}
- if (!empty($addr_cc)) $this->message->setCc($this->getArrayAddress($addr_cc));
- if (!empty($addr_bcc)) $this->message->setBcc($this->getArrayAddress($addr_bcc));
+ if (! empty($this->addr_cc)) $this->message->setCc($this->getArrayAddress($this->addr_cc));
+ if (! empty($this->addr_bcc)) $this->message->setBcc($this->getArrayAddress($this->addr_bcc));
//if (! empty($errors_to)) $this->message->setErrorsTo($this->getArrayAddress($errors_to);
- if (isset($deliveryreceipt) && $deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($from));
+ if (isset($this->deliveryreceipt) && $this->deliveryreceipt == 1) $this->message->setReadReceiptTo($this->getArrayAddress($this->addr_from));
}
else
{
@@ -617,13 +637,6 @@ class CMailFile
$keyforstarttls = 'MAIN_MAIL_EMAIL_STARTTLS_EMAILING';
}
- if (!empty($conf->global->MAIN_MAIL_FORCE_SENDTO))
- {
- $this->addr_to = $conf->global->MAIN_MAIL_FORCE_SENDTO;
- $this->addr_cc = '';
- $this->addr_bcc = '';
- }
-
// Action according to choosed sending method
if ($this->sendmode == 'mail')
{
@@ -768,14 +781,14 @@ class CMailFile
$from = $this->smtps->getFrom('org');
if ($res && !$from)
{
- $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Sender address '$from' invalid";
+ $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - Sender address '$from' invalid";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;
}
$dest = $this->smtps->getTo();
if ($res && !$dest)
{
- $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." Recipient address '$dest' invalid";
+ $this->error = "Failed to send mail with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - Recipient address '$dest' invalid";
dol_syslog("CMailFile::sendfile: mail end error=".$this->error, LOG_ERR);
$res = false;
}
@@ -798,7 +811,7 @@ class CMailFile
else
{
if (empty($this->error)) $this->error = $result;
- dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." ".$this->error, LOG_ERR);
+ dol_syslog("CMailFile::sendfile: mail end error with smtps lib to HOST=".$server.", PORT=".$conf->global->$keyforsmtpport." - ".$this->error, LOG_ERR);
$res = false;
}
}
diff --git a/htdocs/core/class/commondocgenerator.class.php b/htdocs/core/class/commondocgenerator.class.php
index be23895fe7f..544cc105416 100644
--- a/htdocs/core/class/commondocgenerator.class.php
+++ b/htdocs/core/class/commondocgenerator.class.php
@@ -1082,7 +1082,8 @@ abstract class CommonDocGenerator
$parameters = array(
'curY' => &$curY,
'columnText' => $columnText,
- 'colKey' => $colKey
+ 'colKey' => $colKey,
+ 'pdf' => &$pdf,
);
$reshook = $hookmanager->executeHooks('printStdColumnContent', $parameters, $this); // Note that $action and $object may have been modified by hook
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 9601320af49..9894d2e6c64 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1899,14 +1899,15 @@ abstract class CommonObject
$row = $this->db->fetch_row($result);
$this->ref_previous = $row[0];
-
$sql = "SELECT MIN(te.".$fieldid.")";
$sql .= " FROM ".(empty($nodbprefix) ?MAIN_DB_PREFIX:'').$this->table_element." as te";
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
$sql .= ",".MAIN_DB_PREFIX."usergroup_user as ug";
}
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 'fk_soc@societe') $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity
- elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
+ if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
+ $tmparray = explode('@', $this->ismultientitymanaged);
+ $sql .= ", ".MAIN_DB_PREFIX.$tmparray[1]." as ".($tmparray[1] == 'societe' ? 's' : 'parenttable'); // If we need to link to this table to limit select to entity
+ } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to socid
elseif ($this->restrictiononfksoc == 2 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON te.fk_soc = s.rowid"; // If we need to link to societe to limit select to socid
if ($this->restrictiononfksoc && !$user->rights->societe->client->voir && !$socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$aliastablesociete.".rowid = sc.fk_soc";
$sql .= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; // ->ref must always be defined (set to id if field does not exists)
@@ -1917,8 +1918,10 @@ abstract class CommonObject
if (!preg_match('/^\s*AND/i', $filter)) $sql .= " AND "; // For backward compatibility
$sql .= $filter;
}
- if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 'fk_soc@societe') $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity
- elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
+ if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged)) {
+ $tmparray = explode('@', $this->ismultientitymanaged);
+ $sql .= ' AND te.'.$tmparray[0].' = '.($tmparray[1] == 'societe' ? 's' : 'parenttable').'.rowid'; // If we need to link to this table to limit select to entity
+ } elseif ($this->restrictiononfksoc == 1 && $this->element != 'societe' && !$user->rights->societe->client->voir && !$socid) $sql .= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to socid
if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) {
if ($this->element == 'user' && !empty($conf->global->MULTICOMPANY_TRANSVERSE_MODE)) {
if (!empty($user->admin) && empty($user->entity) && $conf->entity == 1) {
@@ -1931,6 +1934,10 @@ abstract class CommonObject
$sql .= ' AND te.entity IN ('.getEntity($this->element).')';
}
}
+ if (isset($this->ismultientitymanaged) && !is_numeric($this->ismultientitymanaged) && $this->element != 'societe') {
+ $tmparray = explode('@', $this->ismultientitymanaged);
+ $sql .= ' AND parenttable.entity IN ('.getEntity($tmparray[1]).')';
+ }
if ($this->restrictiononfksoc == 1 && $socid && $this->element != 'societe') $sql .= ' AND te.fk_soc = '.$socid;
if ($this->restrictiononfksoc == 2 && $socid && $this->element != 'societe') $sql .= ' AND (te.fk_soc = '.$socid.' OR te.fk_soc IS NULL)';
if ($this->restrictiononfksoc && $socid && $this->element == 'societe') $sql .= ' AND te.rowid = '.$socid;
@@ -5524,11 +5531,12 @@ abstract class CommonObject
$new_array_options[$key] = null;
}
break;
- case 'double':
+ case 'price':
+ case 'double':
$value = price2num($value);
if (!is_numeric($value) && $value != '')
{
- dol_syslog($langs->trans("ExtraFieldHasWrongValue")." sur ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
+ dol_syslog($langs->trans("ExtraFieldHasWrongValue")." for ".$attributeLabel."(".$value."is not '".$attributeType."')", LOG_DEBUG);
$this->errors[] = $langs->trans("ExtraFieldHasWrongValue", $attributeLabel);
return -1;
}
@@ -5582,9 +5590,6 @@ abstract class CommonObject
$new_array_options[$key] = $this->array_options[$key];
}
break;
- case 'price':
- $new_array_options[$key] = price2num($this->array_options[$key]);
- break;
case 'date':
case 'datetime':
// If data is a string instead of a timestamp, we convert it
@@ -5682,7 +5687,7 @@ abstract class CommonObject
{
if (!isset($extrafields->attributes[$this->table_element]['type'][$tmpkey])) // If field not already added previously
{
- if (in_array($tmpval, array('int', 'double'))) $sql .= ", 0";
+ if (in_array($tmpval, array('int', 'double', 'price'))) $sql .= ", 0";
else $sql .= ", ''";
}
}
@@ -7043,7 +7048,7 @@ abstract class CommonObject
if (is_array($extrafields->attributes[$this->table_element]['label']) && count($extrafields->attributes[$this->table_element]['label']) > 0)
{
$out .= "\n";
- $out .= ' ';
+ $out .= ' ';
$out .= "\n";
$extrafields_collapse_num = '';
@@ -7181,7 +7186,7 @@ abstract class CommonObject
// HTML, select, integer and text add default value
if (in_array($extrafields->attributes[$this->table_element]['type'][$key], array('html', 'text', 'select', 'int')))
{
- if ($action == 'create') $value = $extrafields->attributes[$this->table_element]['default'][$key];
+ if ($action == 'create') $value = GETPOSTISSET($keyprefix.'options_'.$key.$keysuffix) ? GETPOST($keyprefix.'options_'.$key.$keysuffix, 'none', 3) : $extrafields->attributes[$this->table_element]['default'][$key];
else $value = $this->array_options['options_'.$key];
}
@@ -7265,7 +7270,7 @@ abstract class CommonObject
setListDependencies();
});
'."\n";
- $out .= ' '."\n";
+ $out .= ' '."\n";
}
}
return $out;
@@ -7963,11 +7968,11 @@ abstract class CommonObject
if (array_key_exists('ref', $fieldvalues)) $fieldvalues['ref'] = dol_string_nospecial($fieldvalues['ref']); // If field is a ref, we sanitize data
$keys = array();
- $values = array();
+ $values = array(); // Array to store string forged for SQL syntax
foreach ($fieldvalues as $k => $v) {
$keys[$k] = $k;
$value = $this->fields[$k];
- $values[$k] = $this->quote($v, $value);
+ $values[$k] = $this->quote($v, $value); // May return string 'NULL' if $value is null
}
// Clean and check mandatory
@@ -7977,8 +7982,7 @@ abstract class CommonObject
if (preg_match('/^integer:/i', $this->fields[$key]['type']) && $values[$key] == '-1') $values[$key] = '';
if (!empty($this->fields[$key]['foreignkey']) && $values[$key] == '-1') $values[$key] = '';
- //var_dump($key.'-'.$values[$key].'-'.($this->fields[$key]['notnull'] == 1));
- if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && !isset($values[$key]) && is_null($this->fields[$key]['default']))
+ if (isset($this->fields[$key]['notnull']) && $this->fields[$key]['notnull'] == 1 && (!isset($values[$key]) || $values[$key] === 'NULL') && is_null($this->fields[$key]['default']))
{
$error++;
$this->errors[] = $langs->trans("ErrorFieldRequired", $this->fields[$key]['label']);
diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php
index f04e2da11ee..4874dded08d 100644
--- a/htdocs/core/class/commonobjectline.class.php
+++ b/htdocs/core/class/commonobjectline.class.php
@@ -74,12 +74,12 @@ abstract class CommonObjectLine extends CommonObject
$label_type = 'short_label';
}
- $sql = 'select '.$label_type.' from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
+ $sql = 'select '.$label_type.',code from '.MAIN_DB_PREFIX.'c_units where rowid='.$this->fk_unit;
$resql = $this->db->query($sql);
if ($resql && $this->db->num_rows($resql) > 0)
{
$res = $this->db->fetch_array($resql);
- $label = $res[$label_type];
+ $label = ($label_type == 'short' ? $res[$label_type] : 'unit'.$res['code']);
$this->db->free($resql);
return $label;
}
diff --git a/htdocs/core/class/dolreceiptprinter.class.php b/htdocs/core/class/dolreceiptprinter.class.php
index 8d9c449b972..09dcc3681b7 100644
--- a/htdocs/core/class/dolreceiptprinter.class.php
+++ b/htdocs/core/class/dolreceiptprinter.class.php
@@ -468,6 +468,26 @@ class dolReceiptPrinter extends Printer
return $error;
}
+ /**
+ * Function to delete a printer template in db
+ *
+ * @param int $templateid Template ID
+ * @return int 0 if OK; >0 if KO
+ */
+ public function deleteTemplate($templateid)
+ {
+ global $conf;
+ $error = 0;
+ $sql = 'DELETE FROM '.MAIN_DB_PREFIX.'printer_receipt_template';
+ $sql .= " WHERE rowid = ".((int) $this->db->escape($templateid));
+ $sql .= " AND entity = ".$conf->entity;
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ $error++;
+ $this->errors[] = $this->db->lasterror;
+ }
+ return $error;
+ }
/**
* Function to Update a printer template in db
diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php
index 90fc879bd17..5ac47f1a478 100644
--- a/htdocs/core/class/extrafields.class.php
+++ b/htdocs/core/class/extrafields.class.php
@@ -154,8 +154,8 @@ class ExtraFields
public static $type2label = array(
- 'varchar'=>'String',
- 'text'=>'TextLong',
+ 'varchar'=>'String1Line',
+ 'text'=>'TextLongNLines',
'html'=>'HtmlText',
'int'=>'Int',
'double'=>'Float',
@@ -842,7 +842,7 @@ class ExtraFields
/**
* Load array this->attributes, or old this->attribute_xxx like attribute_label, attribute_type, ...
*
- * @param string $elementtype Type of element ('' = all, 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
+ * @param string $elementtype Type of element ('' = all or $object->table_element like 'adherent', 'commande', 'thirdparty', 'facture', 'propal', 'product', ...).
* @param boolean $forceload Force load of extra fields whatever is status of cache.
* @return array Array of attributes keys+label for all extra fields.
*/
@@ -856,6 +856,7 @@ class ExtraFields
if ($elementtype == 'thirdparty') $elementtype = 'societe';
if ($elementtype == 'contact') $elementtype = 'socpeople';
if ($elementtype == 'order_supplier') $elementtype = 'commande_fournisseur';
+ if ($elementtype == 'stock_mouvement') $elementtype = 'movement';
$array_name_label = array();
@@ -2098,6 +2099,10 @@ class ExtraFields
{
$value_key = GETPOST("options_".$key, 'alpha');
}
+ elseif (in_array($key_type, array('text')))
+ {
+ $value_key = GETPOST("options_".$key, 'alphanohtml');
+ }
else
{
$value_key = GETPOST("options_".$key);
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 9c4e2526249..90efe26e1ca 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -2743,9 +2743,9 @@ class Form
$outval .= ' - '.$langs->transnoentities("VirtualStock").':';
if ($virtualstock > 0) {
- $outval .= ' - ';
+ $outval .= '';
}elseif ($virtualstock <= 0) {
- $outval .= ' - ';
+ $outval .= '';
}
$outval .= $virtualstock;
$outval .= ' ';
@@ -6744,7 +6744,7 @@ class Form
*/
public static function multiSelectArrayWithCheckbox($htmlname, &$array, $varpage)
{
- global $conf, $langs, $user;
+ global $conf, $langs, $user, $extrafields;
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
@@ -6776,6 +6776,10 @@ class Form
}
if ($val['label'])
{
+ if (! empty($val['langfile']) && is_object($langs)) {
+ $langs->load($val['langfile']);
+ }
+
$lis .= ''.dol_escape_htmltag($langs->trans($val['label'])).' ';
$listcheckedstring .= (empty($val['checked']) ? '' : $key.',');
}
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 3fc3151030a..f20fcbcd5b9 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -546,7 +546,10 @@ class Translate
{
global $conf, $db;
- if (!is_string($key)) return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
+ if (!is_string($key)) {
+ //xdebug_print_function_stack('ErrorBadValueForParamNotAString');
+ return 'ErrorBadValueForParamNotAString'; // Avoid multiple errors with code not using function correctly.
+ }
$newstr = $key;
if (preg_match('/^Civility([0-9A-Z]+)$/i', $key, $reg))
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index 6b71366c46c..08b23156f64 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -183,6 +183,8 @@ class DoliDBPgsql extends DoliDB
if ($type == 'dml')
{
+ $reg = array();
+
$line = preg_replace('/\s/', ' ', $line); // Replace tabulation with space
// we are inside create table statement so lets process datatypes
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 12fb15d3b2a..7b3d66f9003 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -721,16 +721,16 @@ function translation_prepare_head()
$h = 0;
$head = array();
- $head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=overwrite";
- $head[$h][1] = $langs->trans("TranslationOverwriteKey").' ';
- $head[$h][2] = 'overwrite';
- $h++;
-
$head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=searchkey";
$head[$h][1] = $langs->trans("TranslationKeySearch");
$head[$h][2] = 'searchkey';
$h++;
+ $head[$h][0] = DOL_URL_ROOT."/admin/translation.php?mode=overwrite";
+ $head[$h][1] = $langs->trans("TranslationOverwriteKey").' ';
+ $head[$h][2] = 'overwrite';
+ $h++;
+
complete_head_from_modules($conf, $langs, null, $head, $h, 'translation_admin');
complete_head_from_modules($conf, $langs, null, $head, $h, 'translation_admin', 'remove');
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index e102e0e155d..67611649142 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -1286,7 +1286,7 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param Conf $conf Object conf
* @param Translate $langs Object langs
* @param DoliDB $db Object db
- * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket|... to list events linked to an object
+ * @param mixed $filterobj Filter on object Adherent|Societe|Project|Product|CommandeFournisseur|Dolresource|Ticket... to list events linked to an object
* @param Contact $objcon Filter on object contact to filter events on a contact
* @param int $noprint Return string but does not output it
* @param string $actioncode Filter on actioncode
@@ -1294,9 +1294,10 @@ function show_actions_todo($conf, $langs, $db, $filterobj, $objcon = '', $noprin
* @param array $filters Filter on other fields
* @param string $sortfield Sort field
* @param string $sortorder Sort order
+ * @param string $module You can add module name here if elementtype in table llx_actioncomm is objectkey@module
* @return string|void Return html part or void if noprint is 1
*/
-function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC')
+function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprint = 0, $actioncode = '', $donetodo = 'done', $filters = array(), $sortfield = 'a.datep,a.id', $sortorder = 'DESC', $module = '')
{
global $user, $conf;
global $form;
@@ -1416,7 +1417,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon = '', $noprin
}
elseif (is_object($filterobj) && is_array($filterobj->fields) && is_array($filterobj->fields['rowid']) && is_array($filterobj->fields['ref']) && $filterobj->table_element && $filterobj->element)
{
- $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element)."'";
+ // Generic case
+ $sql .= " AND a.fk_element = o.rowid AND a.elementtype = '".$db->escape($filterobj->element).($module ? '@'.$module : '')."'";
if ($filterobj->id) $sql .= " AND a.fk_element = ".$filterobj->id;
}
}
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index a72d2057004..91a3061dd41 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -601,7 +601,7 @@ function GETPOST($paramname, $check = 'alphanohtml', $method = 0, $filter = null
// '"' is dangerous because param in url can close the href= or src= and add javascript functions.
// '../' is dangerous because it allows dir transversals
$out = str_replace(array('"', '../'), '', trim($out));
- $out = dol_string_nohtmltag($out, 1);
+ $out = dol_string_nohtmltag($out, 0);
}
break;
case 'restricthtml': // Recommended for most html textarea
@@ -3172,7 +3172,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'setup', 'sign-out', 'split', 'stripe-s', 'switch_off', 'switch_on', 'tools', 'unlink', 'uparrow', 'user', 'vcard', 'wrench',
'jabber', 'skype', 'twitter', 'facebook', 'linkedin', 'instagram', 'snapchat', 'youtube', 'google-plus-g', 'whatsapp',
'chevron-left', 'chevron-right', 'chevron-down', 'chevron-top',
- 'home', 'companies', 'products', 'commercial', 'invoicing', 'preview', 'project', 'projectpub', 'supplier_invoice', 'hrm', 'members', 'ticket', 'generic',
+ 'home', 'hrm', 'companies', 'products', 'commercial', 'invoicing', 'pencil-ruler', 'preview', 'project', 'projectpub', 'supplier_invoice', 'members', 'ticket', 'generic',
'error', 'warning', 'supplier_proposal', 'supplier_order', 'supplier_invoice',
'title_setup', 'title_accountancy', 'title_bank', 'title_hrm', 'title_agenda'
)
@@ -3195,7 +3195,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
'company'=>'building', 'contact'=>'address-book', 'contract'=>'suitcase', 'conversation'=>'comments', 'donation'=>'file-alt', 'dynamicprice'=>'hand-holding-usd',
'setup'=>'cog', 'companies'=>'building', 'products'=>'cube', 'commercial'=>'suitcase', 'invoicing'=>'coins',
'accounting'=>'chart-line', 'category'=>'tag', 'dollyrevert'=>'dolly',
- 'hrm'=>'umbrella-beach', 'margin'=>'calculator', 'members'=>'users', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
+ 'hrm'=>'user-tie', 'margin'=>'calculator', 'members'=>'users', 'ticket'=>'ticket-alt', 'globe'=>'external-link-alt', 'lot'=>'barcode',
'email'=>'at',
'edit'=>'pencil-alt', 'grip_title'=>'arrows-alt', 'grip'=>'arrows-alt', 'help'=>'info-circle',
'generic'=>'file', 'holiday'=>'umbrella-beach', 'label'=>'layer-group',
@@ -5694,8 +5694,7 @@ function dol_string_onlythesehtmltags($stringtoclean, $cleanalsosomestyles = 1)
{
$allowed_tags = array(
"html", "head", "meta", "body", "article", "a", "abbr", "b", "blockquote", "br", "cite", "div", "dl", "dd", "dt", "em", "font", "img", "ins", "hr", "i", "li", "link",
- "ol", "p", "q", "s", "section", "span", "strike", "strong", "title",
- "table", "tr", "th", "td", "u", "ul"
+ "ol", "p", "q", "s", "section", "span", "strike", "strong", "title", "table", "tr", "th", "td", "u", "ul", "sup", "sub", "blockquote", "pre", "h1", "h2", "h3", "h4", "h5", "h6"
);
$allowed_tags_string = join("><", $allowed_tags);
$allowed_tags_string = preg_replace('/^>/', '', $allowed_tags_string);
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index b50090ee2cf..84670de46d2 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -1809,18 +1809,19 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
$ret = '';
$regs = array();
- // If we ask an resource form external module (instead of default path)
+ // If we ask a resource form external module (instead of default path)
if (preg_match('/^([^@]+)@([^@]+)$/i', $objecttype, $regs)) {
$myobject = $regs[1];
$module = $regs[2];
}
-
- // Parse $objecttype (ex: project_task)
- $module = $myobject = $objecttype;
- if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
- {
- $module = $regs[1];
- $myobject = $regs[2];
+ else {
+ // Parse $objecttype (ex: project_task)
+ $module = $myobject = $objecttype;
+ if (preg_match('/^([^_]+)_([^_]+)/i', $objecttype, $regs))
+ {
+ $module = $regs[1];
+ $myobject = $regs[2];
+ }
}
// Generic case for $classpath
@@ -1896,7 +1897,7 @@ function dolGetElementUrl($objectid, $objecttype, $withpicto = 0, $option = '')
// Generic case for $classfile and $classname
$classfile = strtolower($myobject); $classname = ucfirst($myobject);
- //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname;
+ //print "objecttype=".$objecttype." module=".$module." subelement=".$subelement." classfile=".$classfile." classname=".$classname." classpath=".$classpath;
if ($objecttype == 'invoice_supplier') {
$classfile = 'fournisseur.facture';
diff --git a/htdocs/core/lib/functionsnumtoword.lib.php b/htdocs/core/lib/functionsnumtoword.lib.php
index 26db2bbec90..5e33c976f9c 100644
--- a/htdocs/core/lib/functionsnumtoword.lib.php
+++ b/htdocs/core/lib/functionsnumtoword.lib.php
@@ -24,23 +24,23 @@
/**
- * Function to return number in text.
+ * Function to return a number into a text.
* May use module NUMBERWORDS if found.
*
- * @param float $num Number to convert
+ * @param float $num Number to convert (must be a numeric value, like reported by price2num())
* @param Translate $langs Language
* @param boolean $currency 0=number to translate | 1=currency to translate
- * @param boolean $centimes 0=no centimes | 1=centimes to translate
+ * @param boolean $centimes 0=no cents/centimes | 1=there is cents/centimes to translate
* @return string|false Text of the number
*/
function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
{
global $conf;
- $num = str_replace(array(',', ' '), '', trim($num));
- if (!$num) {
- return false;
- }
+ //$num = str_replace(array(',', ' '), '', trim($num)); This should be useless since $num MUST be a php numeric value
+ if (!$num) {
+ return false;
+ }
if ($centimes && strlen($num) == 1) {
$num = $num * 10;
@@ -57,78 +57,79 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
return $concatWords;
} else {
$TNum = explode('.', $num);
- $num = (int) $TNum[0];
- $words = array();
- $list1 = array(
- '',
- $langs->transnoentitiesnoconv('one'),
- $langs->transnoentitiesnoconv('two'),
- $langs->transnoentitiesnoconv('three'),
- $langs->transnoentitiesnoconv('four'),
- $langs->transnoentitiesnoconv('five'),
- $langs->transnoentitiesnoconv('six'),
- $langs->transnoentitiesnoconv('seven'),
- $langs->transnoentitiesnoconv('eight'),
- $langs->transnoentitiesnoconv('nine'),
- $langs->transnoentitiesnoconv('ten'),
- $langs->transnoentitiesnoconv('eleven'),
- $langs->transnoentitiesnoconv('twelve'),
- $langs->transnoentitiesnoconv('thirteen'),
- $langs->transnoentitiesnoconv('fourteen'),
- $langs->transnoentitiesnoconv('fifteen'),
- $langs->transnoentitiesnoconv('sixteen'),
- $langs->transnoentitiesnoconv('seventeen'),
- $langs->transnoentitiesnoconv('eighteen'),
- $langs->transnoentitiesnoconv('nineteen')
- );
- $list2 = array(
- '',
- $langs->transnoentitiesnoconv('ten'),
- $langs->transnoentitiesnoconv('twenty'),
- $langs->transnoentitiesnoconv('thirty'),
- $langs->transnoentitiesnoconv('forty'),
- $langs->transnoentitiesnoconv('fifty'),
- $langs->transnoentitiesnoconv('sixty'),
- $langs->transnoentitiesnoconv('seventy'),
- $langs->transnoentitiesnoconv('eighty'),
- $langs->transnoentitiesnoconv('ninety'),
- $langs->transnoentitiesnoconv('hundred')
- );
- $list3 = array(
- '',
- $langs->transnoentitiesnoconv('thousand'),
- $langs->transnoentitiesnoconv('million'),
- $langs->transnoentitiesnoconv('billion'),
- $langs->transnoentitiesnoconv('trillion'),
- $langs->transnoentitiesnoconv('quadrillion')
- );
- $num_length = strlen($num);
- $levels = (int) (($num_length + 2) / 3);
- $max_length = $levels * 3;
- $num = substr('00'.$num, -$max_length);
- $num_levels = str_split($num, 3);
- $nboflevels = count($num_levels);
- for ($i = 0; $i < $nboflevels; $i++) {
- $levels--;
- $hundreds = (int) ($num_levels[$i] / 100);
- $hundreds = ($hundreds ? ' '.$list1[$hundreds].' '.$langs->transnoentities('hundred').($hundreds == 1 ? '' : 's').' ' : '');
- $tens = (int) ($num_levels[$i] % 100);
- $singles = '';
- if ($tens < 20) {
- $tens = ($tens ? ' '.$list1[$tens].' ' : '');
- } else {
- $tens = (int) ($tens / 10);
- $tens = ' '.$list2[$tens].' ';
- $singles = (int) ($num_levels[$i] % 10);
- $singles = ' '.$list1[$singles].' ';
- }
- $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ? ' '.$list3[$levels].' ' : '');
- } //end for loop
- $commas = count($words);
- if ($commas > 1) {
- $commas = $commas - 1;
- }
+ $num = (int) $TNum[0];
+ $words = array();
+ $list1 = array(
+ '',
+ $langs->transnoentitiesnoconv('one'),
+ $langs->transnoentitiesnoconv('two'),
+ $langs->transnoentitiesnoconv('three'),
+ $langs->transnoentitiesnoconv('four'),
+ $langs->transnoentitiesnoconv('five'),
+ $langs->transnoentitiesnoconv('six'),
+ $langs->transnoentitiesnoconv('seven'),
+ $langs->transnoentitiesnoconv('eight'),
+ $langs->transnoentitiesnoconv('nine'),
+ $langs->transnoentitiesnoconv('ten'),
+ $langs->transnoentitiesnoconv('eleven'),
+ $langs->transnoentitiesnoconv('twelve'),
+ $langs->transnoentitiesnoconv('thirteen'),
+ $langs->transnoentitiesnoconv('fourteen'),
+ $langs->transnoentitiesnoconv('fifteen'),
+ $langs->transnoentitiesnoconv('sixteen'),
+ $langs->transnoentitiesnoconv('seventeen'),
+ $langs->transnoentitiesnoconv('eighteen'),
+ $langs->transnoentitiesnoconv('nineteen')
+ );
+ $list2 = array(
+ '',
+ $langs->transnoentitiesnoconv('ten'),
+ $langs->transnoentitiesnoconv('twenty'),
+ $langs->transnoentitiesnoconv('thirty'),
+ $langs->transnoentitiesnoconv('forty'),
+ $langs->transnoentitiesnoconv('fifty'),
+ $langs->transnoentitiesnoconv('sixty'),
+ $langs->transnoentitiesnoconv('seventy'),
+ $langs->transnoentitiesnoconv('eighty'),
+ $langs->transnoentitiesnoconv('ninety'),
+ $langs->transnoentitiesnoconv('hundred')
+ );
+ $list3 = array(
+ '',
+ $langs->transnoentitiesnoconv('thousand'),
+ $langs->transnoentitiesnoconv('million'),
+ $langs->transnoentitiesnoconv('billion'),
+ $langs->transnoentitiesnoconv('trillion'),
+ $langs->transnoentitiesnoconv('quadrillion')
+ );
+
+ $num_length = strlen($num);
+ $levels = (int) (($num_length + 2) / 3);
+ $max_length = $levels * 3;
+ $num = substr('00'.$num, -$max_length);
+ $num_levels = str_split($num, 3);
+ $nboflevels = count($num_levels);
+ for ($i = 0; $i < $nboflevels; $i++) {
+ $levels--;
+ $hundreds = (int) ($num_levels[$i] / 100);
+ $hundreds = ($hundreds ? ' '.$list1[$hundreds].' '.$langs->transnoentities('hundred').($hundreds == 1 ? '' : 's').' ' : '');
+ $tens = (int) ($num_levels[$i] % 100);
+ $singles = '';
+ if ($tens < 20) {
+ $tens = ($tens ? ' '.$list1[$tens].' ' : '');
+ } else {
+ $tens = (int) ($tens / 10);
+ $tens = ' '.$list2[$tens].' ';
+ $singles = (int) ($num_levels[$i] % 10);
+ $singles = ' '.$list1[$singles].' ';
+ }
+ $words[] = $hundreds.$tens.$singles.(($levels && (int) ($num_levels[$i])) ? ' '.$list3[$levels].' ' : '');
+ } //end for loop
+ $commas = count($words);
+ if ($commas > 1) {
+ $commas = $commas - 1;
+ }
$concatWords = implode(' ', $words);
// Delete multi whitespaces
$concatWords = trim(preg_replace('/[ ]+/', ' ', $concatWords));
@@ -138,12 +139,16 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
}
// If we need to write cents call again this function for cents
- if (!empty($TNum[1])) {
+ $decimalpart = $TNum[1];
+ $decimalpart = preg_replace('/0+$/', '', $decimalpart);
+
+ if ($decimalpart) {
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('and');
- $concatWords .= ' '.dol_convertToWord($TNum[1], $langs, $currency, true);
+
+ $concatWords .= ' '.dol_convertToWord($decimalpart, $langs, '', true);
if (!empty($currency)) $concatWords .= ' '.$langs->transnoentities('centimes');
}
- return $concatWords;
+ return $concatWords;
}
}
@@ -159,10 +164,12 @@ function dol_convertToWord($num, $langs, $currency = false, $centimes = false)
*/
function dolNumberToWord($numero, $langs, $numorcurrency = 'number')
{
- // If the number is negative convert to positive and return -1 if is too long
+ // If the number is negative convert to positive and return -1 if it is too long
if ($numero < 0) $numero *= -1;
- if ($numero >= 1000000000001)
+ if ($numero >= 1000000000001) {
return -1;
+ }
+
// Get 2 decimals to cents, another functions round or truncate
$strnumber = number_format($numero, 10);
$len = strlen($strnumber);
diff --git a/htdocs/core/lib/images.lib.php b/htdocs/core/lib/images.lib.php
index b65ad51db86..0822d3edd4b 100644
--- a/htdocs/core/lib/images.lib.php
+++ b/htdocs/core/lib/images.lib.php
@@ -33,11 +33,17 @@ $quality = 80;
* Return if a filename is file name of a supported image format
*
* @param string $file Filename
+ * @param int $acceptsvg 0=Default (depends on setup), 1=Always accept SVG as image files
* @return int -1=Not image filename, 0=Image filename but format not supported for conversion by PHP, 1=Image filename with format supported by this PHP
*/
-function image_format_supported($file)
+function image_format_supported($file, $acceptsvg = 0)
{
- $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm|\.svg'; // See also into product.class.php
+ global $conf;
+
+ $regeximgext = '\.gif|\.jpg|\.jpeg|\.png|\.bmp|\.webp|\.xpm|\.xbm'; // See also into product.class.php
+ if ($acceptsvg || ! empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) {
+ $regeximgext .= '|\.svg'; // Not allowed by default. SVG can contains javascript
+ }
// Case filename is not a format image
$reg = array();
diff --git a/htdocs/core/lib/order.lib.php b/htdocs/core/lib/order.lib.php
index 3d2847e926b..96d66c3272a 100644
--- a/htdocs/core/lib/order.lib.php
+++ b/htdocs/core/lib/order.lib.php
@@ -65,10 +65,10 @@ function commande_prepare_head(Commande $object)
$head[$h][0] = DOL_URL_ROOT.'/expedition/shipment.php?id='.$object->id;
$text = '';
if ($conf->expedition_bon->enabled) $text .= $langs->trans("Shipments");
- if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= '/';
+ if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled) $text .= ' - ';
if ($conf->livraison_bon->enabled) $text .= $langs->trans("Receivings");
if ($nbShipments > 0 || $nbReceiption > 0) $text .= ''.($nbShipments ? $nbShipments : 0);
- if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= '/';
+ if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ' - ';
if ($conf->expedition_bon->enabled && $conf->livraison_bon->enabled && ($nbShipments > 0 || $nbReceiption > 0)) $text .= ($nbReceiption ? $nbReceiption : 0);
if ($nbShipments > 0 || $nbReceiption > 0) $text .= ' ';
$head[$h][1] = $text;
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 63789a18e62..2f41a7df6eb 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -1859,7 +1859,6 @@ function pdf_getlineunit($object, $i, $outputlangs, $hidedetails = 0, $hookmanag
}
if (empty($reshook))
{
- if ($object->lines[$i]->special_code == 3) return '';
if (empty($hidedetails) || $hidedetails > 1) $result .= $langs->transnoentitiesnoconv($object->lines[$i]->getLabelOfUnit('short'));
}
return $result;
diff --git a/htdocs/core/lib/prelevement.lib.php b/htdocs/core/lib/prelevement.lib.php
index a404e19184e..8008c9fd51f 100644
--- a/htdocs/core/lib/prelevement.lib.php
+++ b/htdocs/core/lib/prelevement.lib.php
@@ -39,8 +39,13 @@ function prelevement_prepare_head(BonPrelevement $object)
$h = 0;
$head = array();
+ $titleoftab = "WithdrawalsReceipts";
+ if ($object->type == 'bank-transfer') {
+ $titleoftab = "BankTransferReceipts";
+ }
+
$head[$h][0] = DOL_URL_ROOT.'/compta/prelevement/card.php?id='.$object->id;
- $head[$h][1] = $langs->trans("WithdrawalsReceipts");
+ $head[$h][1] = $langs->trans($titleoftab);
$head[$h][2] = 'prelevement';
$h++;
diff --git a/htdocs/core/lib/price.lib.php b/htdocs/core/lib/price.lib.php
index 81c62958418..2cb8d8e30f6 100644
--- a/htdocs/core/lib/price.lib.php
+++ b/htdocs/core/lib/price.lib.php
@@ -40,8 +40,8 @@
* @param float $pu Unit price (HT or TTC selon price_base_type)
* @param float $remise_percent_ligne Discount for line
* @param float $txtva 0=do not apply VAT tax, VAT rate=apply (this is VAT rate only without text code, we don't need text code because we alreaydy have all tax info into $localtaxes_array)
- * @param float $uselocaltax1_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
- * @param float $uselocaltax2_rate 0=do not use this localtax, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
+ * @param float $uselocaltax1_rate 0=do not use localtax1, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
+ * @param float $uselocaltax2_rate 0=do not use localtax2, >0=apply and get value from localtaxes_array (or database if empty), -1=autodetect according to seller if we must apply, get value from localtaxes_array (or database if empty). Try to always use -1.
* @param float $remise_percent_global 0
* @param string $price_base_type HT=Unit price parameter is HT, TTC=Unit price parameter is TTC
* @param int $info_bits Miscellaneous informations on line
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 0b07e96ab50..96a868c4599 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -22,7 +22,7 @@
/**
* \file htdocs/core/lib/usergroups.lib.php
- * \brief Ensemble de fonctions de base pour la gestion des utilisaterus et groupes
+ * \brief Set of function to manage users, groups and permissions
*/
/**
diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql
index 03f8951b0f8..ec75b35073c 100644
--- a/htdocs/core/menus/init_menu_auguria.sql
+++ b/htdocs/core/menus/init_menu_auguria.sql
@@ -29,6 +29,7 @@ insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, left
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 101__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/company.php?mainmenu=home&leftmenu=setup', 'MenuCompanySetup', 1, 'admin', '', '', 2, 1, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 102__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/ihm.php?mainmenu=home&leftmenu=setup', 'GUISetup', 1, 'admin', '', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 114__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/translation.php?mainmenu=home&leftmenu=setup', 'Translation', 1, 'admin', '', '', 2, 4, __ENTITY__);
+insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 115__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/defaultvalues.php?mainmenu=home&leftmenu=setup', 'DefaultValues', 1, 'admin', '', '', 2, 4, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 103__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/modules.php?mainmenu=home&leftmenu=setup', 'Modules', 1, 'admin', '', '', 2, 2, __ENTITY__);
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$leftmenu=="setup"', __HANDLER__, 'left', 104__+MAX_llx_menu__, 'home', '', 100__+MAX_llx_menu__, '/admin/boxes.php?mainmenu=home&leftmenu=setup', 'Boxes', 1, 'admin', '', '', 2, 6, __ENTITY__);
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index 99c9a1002a5..8b51df3368f 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -234,12 +234,14 @@ function print_eldy_menu($db, $atarget, $type_user, &$tabMenu, &$menu, $noout =
!empty($conf->ficheinter->enabled)
) ? 1 : 0,
'perms'=>(!empty($user->rights->propal->lire) ||
- !empty($user->rights->commande->lire) ||
- !empty($user->rights->fournisseur->lire) ||
- !empty($user->rights->supplier_proposal->lire) ||
- !empty($user->rights->supplier_order->lire) ||
- !empty($user->rights->contrat->lire) ||
- !empty($user->rights->ficheinter->lire)
+ !empty($user->rights->commande->lire) ||
+ !empty($user->rights->fournisseur->lire) ||
+ !empty($user->rights->supplier_proposal->lire) ||
+ !empty($user->rights->supplier_order->lire) ||
+ !empty($user->rights->contrat->lire) ||
+ !empty($user->rights->ficheinter->lire) ||
+ !empty($user->rights->supplier_order->lire) ||
+ !empty($user->rights->fournisseur->commande->lire)
),
'module'=>'propal|commande|supplier_proposal|supplier_order|contrat|ficheinter'
);
diff --git a/htdocs/core/modules/modPaymentByBankTransfer.class.php b/htdocs/core/modules/modPaymentByBankTransfer.class.php
index d68274e2dee..2a1686bd1c3 100644
--- a/htdocs/core/modules/modPaymentByBankTransfer.class.php
+++ b/htdocs/core/modules/modPaymentByBankTransfer.class.php
@@ -54,7 +54,7 @@ class modPaymentByBankTransfer extends DolibarrModules
$this->description = "Management of payment by bank transfer";
// Possible values for version are: 'development', 'experimental', 'dolibarr' or version
- $this->version = 'development';
+ $this->version = 'experimental';
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
// Name of png file (without png) used for this module
diff --git a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
index d0e9ba9d1e4..69af56d1e17 100644
--- a/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
+++ b/htdocs/core/modules/stock/doc/pdf_stdmovement.modules.php
@@ -183,7 +183,7 @@ class pdf_stdmovement extends ModelePDFMovement
/**
* Function to build a document on disk using the generic odt module.
*
- * @param StockMovements $object Object source to build document
+ * @param MouvementStock $object Object source to build document
* @param Translate $outputlangs Lang output object
* @param string $srctemplatepath Full path of source filename for generator using a template file
* @param int $hidedetails Do not show line details
diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
index 0ad8b391faf..58ef22172bf 100644
--- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php
@@ -223,7 +223,7 @@ class pdf_standard extends ModelePDFSuppliersPayments
}
}
- $total = $object->montant;
+ $total = $object->amount;
// Definition of $dir and $file
if ($object->specimen)
@@ -550,12 +550,12 @@ class pdf_standard extends ModelePDFSuppliersPayments
// Total payments
$pdf->SetXY($this->page_largeur - $this->marge_droite - 50, $posy);
- $pdf->MultiCell(50, 4, price($object->montant), 0, 'R', 1);
+ $pdf->MultiCell(50, 4, price($object->amount), 0, 'R', 1);
$posy += 20;
// translate amount
$currency = $conf->currency;
- $translateinletter = strtoupper(dol_convertToWord($object->montant, $outputlangs, $currency));
+ $translateinletter = strtoupper(dol_convertToWord($object->amount, $outputlangs, $currency));
$pdf->SetXY($this->marge_gauche + 50, $posy);
$pdf->MultiCell(90, 8, $translateinletter, 0, 'L', 1);
$posy += 8;
@@ -565,10 +565,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->MultiCell(150, 4, $object->thirdparty->nom, 0, 'L', 1);
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
- $pdf->MultiCell(35, 4, str_pad(price($object->montant).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
+ $pdf->MultiCell(35, 4, str_pad(price($object->amount).' '.$currency, 18, '*', STR_PAD_LEFT), 0, 'R', 1);
$posy += 10;
-
// City
$pdf->SetXY($this->page_largeur - $this->marge_droite - 30, $posy);
$pdf->MultiCell(150, 4, $mysoc->town, 0, 'L', 1);
@@ -608,9 +607,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
$pdf->SetTextColor(0, 0, 0);
$pdf->SetFont('', '', $default_font_size - 2);
- $titre = strtoupper($mysoc->town).', le '.date("d").' '.$outputlangs->transnoentitiesnoconv(date("F")).' '.date("Y");
+ /*$titre = strtoupper($mysoc->town).' - '.dol_print_date(dol_now(), 'day', 'tzserver', $outputlangs);
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3) - 60, $tab_top - 6);
- $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);
+ $pdf->MultiCell(($pdf->GetStringWidth($titre) + 3), 2, $titre);*/
$titre = $outputlangs->transnoentities("AmountInCurrency", $outputlangs->transnoentitiesnoconv("Currency".$currency));
$pdf->SetXY($this->page_largeur - $this->marge_droite - ($pdf->GetStringWidth($titre) + 3), $tab_top);
@@ -774,7 +773,9 @@ class pdf_standard extends ModelePDFSuppliersPayments
$carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs);
- $carac_client = pdf_build_address($outputlangs, $this->emetteur, $mysoc, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object);
+ $usecontact = 0;
+
+ $carac_client = pdf_build_address($outputlangs, $this->emetteur, $object->thirdparty, ((!empty($object->contact)) ? $object->contact : null), $usecontact, 'target', $object);
// Show recipient
$widthrecbox = 90;
diff --git a/htdocs/core/tpl/admin_extrafields_edit.tpl.php b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
index 80a7cac7de3..191b4cf40c8 100644
--- a/htdocs/core/tpl/admin_extrafields_edit.tpl.php
+++ b/htdocs/core/tpl/admin_extrafields_edit.tpl.php
@@ -186,8 +186,10 @@ elseif (($type == 'sellist') || ($type == 'chkbxlst') || ($type == 'link') || ($
?>
trans("LabelOrTranslationKey"); ?>
+
trans("AttributeCode"); ?>
+
trans("Type"); ?>
array('varchar', 'phone', 'mail', 'url', 'select'),
'select'=>array('varchar', 'phone', 'mail', 'url', 'select')
);
+/* Disabled because text is text on several lines, when varchar is text on 1 line, we should not be able to convert
+if ($size <= 255 && in_array($type, array('text', 'html'))) {
+ $typewecanchangeinto['text'][] = 'varchar';
+}*/
if (in_array($type, array_keys($typewecanchangeinto)))
{
@@ -225,8 +231,10 @@ else
}
?>
+
+
@@ -247,33 +255,44 @@ else