';
@@ -216,7 +229,7 @@ print '| ';
if (! empty($conf->fournisseur->enabled))
{
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL');
+ print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_BILL', array(), null, 0, 0, 1);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_BILL", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL);
@@ -237,7 +250,7 @@ print ' | ';
if (! empty($conf->fournisseur->enabled))
{
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER');
+ print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER', array(), null, 0, 0, 1);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_VALIDATE_ORDER);
@@ -257,7 +270,7 @@ if (!empty($conf->reception->enabled))
print ' | ';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION');
+ print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION', array(), null, 0, 0, 1);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION);
@@ -272,7 +285,7 @@ if (!empty($conf->reception->enabled))
print ' | ';
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE');
+ print ajax_constantonoff('STOCK_CALCULATE_ON_RECEPTION_CLOSE', array(), null, 0, 0, 1);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_RECEPTION_CLOSE", $arrval, $conf->global->STOCK_CALCULATE_ON_RECEPTION_CLOSE);
@@ -288,7 +301,7 @@ else
if (! empty($conf->fournisseur->enabled))
{
if ($conf->use_javascript_ajax) {
- print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER');
+ print ajax_constantonoff('STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER', array(), null, 0, 0, 1);
} else {
$arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
print $form->selectarray("STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER", $arrval, $conf->global->STOCK_CALCULATE_ON_SUPPLIER_DISPATCH_ORDER);
diff --git a/htdocs/api/class/api.class.php b/htdocs/api/class/api.class.php
index 46431cdb510..89450c57366 100644
--- a/htdocs/api/class/api.class.php
+++ b/htdocs/api/class/api.class.php
@@ -32,7 +32,7 @@ class DolibarrApi
/**
* @var DoliDb $db Database object
*/
- protected static $db;
+ protected $db;
/**
* @var Restler $r Restler object
diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php
index 77d6718ed17..75ab4cd8414 100644
--- a/htdocs/categories/class/categorie.class.php
+++ b/htdocs/categories/class/categorie.class.php
@@ -781,8 +781,8 @@ class Categorie extends CommonObject
$objs = array();
- $tmpclass = $this->MAP_OBJ_CLASS[$type];
- $obj = new $tmpclass($this->db);
+ $classnameforobj = $this->MAP_OBJ_CLASS[$type];
+ $obj = new $classnameforobj($this->db);
$sql = "SELECT c.fk_".$this->MAP_CAT_FK[$type];
$sql .= " FROM ".MAIN_DB_PREFIX."categorie_".$this->MAP_CAT_TABLE[$type]." as c";
@@ -810,8 +810,11 @@ class Categorie extends CommonObject
}
else
{
- $obj = new $this->MAP_OBJ_CLASS[$type]($this->db);
- $obj->fetch($rec['fk_'.$this->MAP_CAT_FK[$type]]);
+ $classnameforobj = $this->MAP_OBJ_CLASS[$type];
+
+ $obj = new $classnameforobj($this->db);
+ $obj->fetch($rec['fk_' . $this->MAP_CAT_FK[$type]]);
+
$objs[] = $obj;
}
}
diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php
index 0962fcd63b6..938775d726d 100644
--- a/htdocs/comm/propal/class/propal.class.php
+++ b/htdocs/comm/propal/class/propal.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2008 Raphael Bertrand
- * Copyright (C) 2010-2019 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2010-2017 Philippe Grand
* Copyright (C) 2012-2014 Christophe Battarel
* Copyright (C) 2012 Cedric Salvador
@@ -2992,9 +2992,9 @@ class Propal extends CommonObject
if (!$error)
{
- $main = MAIN_DB_PREFIX . 'propaldet';
- $ef = $main . "_extrafields";
- $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = " . $this->id . ")";
+ $main = MAIN_DB_PREFIX . 'propaldet';
+ $ef = $main . "_extrafields";
+ $sqlef = "DELETE FROM $ef WHERE fk_object IN (SELECT rowid FROM $main WHERE fk_propal = " . $this->id . ")";
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
if ($this->db->query($sqlef) && $this->db->query($sql))
{
@@ -3011,6 +3011,9 @@ class Propal extends CommonObject
if (!$error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->propal->multidir_output[$this->entity] && !empty($this->ref))
diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php
index e356a4d5936..cc104261010 100644
--- a/htdocs/commande/class/commande.class.php
+++ b/htdocs/commande/class/commande.class.php
@@ -3,7 +3,7 @@
* Copyright (C) 2004-2012 Laurent Destailleur
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
- * Copyright (C) 2010-2016 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2011 Jean Heimburger
* Copyright (C) 2012-2014 Christophe Battarel
* Copyright (C) 2012 Cedric Salvador
@@ -3461,6 +3461,9 @@ class Commande extends CommonOrder
if (! $error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// Remove directory with files
$comref = dol_sanitizeFileName($this->ref);
if ($conf->commande->multidir_output[$this->entity] && !empty($this->ref))
diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php
index a9267201858..b41d2eaa9b9 100644
--- a/htdocs/compta/facture/class/facture.class.php
+++ b/htdocs/compta/facture/class/facture.class.php
@@ -7,7 +7,7 @@
* Copyright (C) 2005-2014 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2010-2016 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2012-2014 Christophe Battarel
* Copyright (C) 2012-2015 Marcos García
* Copyright (C) 2012 Cédric Salvador
@@ -2185,6 +2185,9 @@ class Facture extends CommonInvoice
$resql = $this->db->query($sql);
if ($resql)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// On efface le repertoire de pdf provisoire
$ref = dol_sanitizeFileName($this->ref);
if ($conf->facture->dir_output && !empty($this->ref))
diff --git a/htdocs/compta/prelevement/index.php b/htdocs/compta/prelevement/index.php
index 936fbebcf6e..9b9e8e08ce5 100644
--- a/htdocs/compta/prelevement/index.php
+++ b/htdocs/compta/prelevement/index.php
@@ -180,6 +180,7 @@ print '';
$limit=5;
$sql = "SELECT p.rowid, p.ref, p.amount, p.datec, p.statut";
$sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons as p";
+$sql.= " WHERE entity IN (" . getEntity('prelevement') . ")";
$sql.= " ORDER BY datec DESC";
$sql.= $db->plimit($limit);
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index f0f65071207..d555c50372a 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -1254,6 +1254,11 @@ else
}
}
+ // Select mail models is same action as presend
+ if (GETPOST('modelselected', 'alpha')) {
+ $action = 'presend';
+ }
+
if (!empty($id) && $action != 'edit' && $action != 'create')
{
$objsoc = new Societe($db);
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index caea252c571..7141728c23d 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -94,7 +94,7 @@ class box_contacts extends ModeleBoxes
$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s ON sp.fk_soc = s.rowid";
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql .= " WHERE sp.entity IN (".getEntity('socpeople').")";
- if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sp.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
+ if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id;
if ($user->socid) $sql .= " AND sp.fk_soc = ".$user->socid;
$sql .= " ORDER BY sp.tms DESC";
$sql .= $this->db->plimit($max, 0);
diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php
index 454673fe55b..76a9fc09a38 100644
--- a/htdocs/core/class/CMailFile.class.php
+++ b/htdocs/core/class/CMailFile.class.php
@@ -486,6 +486,9 @@ class CMailFile
{
//$this->message->attach(Swift_Attachment::fromPath($filename_list[$i],$mimetype_list[$i]));
$attachment = Swift_Attachment::fromPath($filename_list[$i], $mimetype_list[$i]);
+ if (!empty($mimefilename_list[$i])) {
+ $attachment->setFilename($mimefilename_list[$i]);
+ }
$this->message->attach($attachment);
}
}
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 4786b5817fe..e933c9d82f7 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -1,7 +1,7 @@
* Copyright (C) 2005-2013 Regis Houssin
- * Copyright (C) 2010-2015 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2012-2013 Christophe Battarel
* Copyright (C) 2011-2019 Philippe Grand
* Copyright (C) 2012-2015 Marcos García
@@ -8250,4 +8250,49 @@ abstract class CommonObject
$this->db->commit();
return 1;
}
+
+ /**
+ * Delete related files of object in database
+ *
+ * @return bool
+ */
+ public function deleteEcmFiles()
+ {
+ global $conf;
+
+ $this->db->begin();
+
+ switch ($this->element){
+ case 'propal':
+ $element = 'propale';
+ break;
+ case 'product':
+ $element = 'produit';
+ break;
+ case 'order_supplier':
+ $element ='fournisseur/commande';
+ break;
+ case 'invoice_supplier':
+ $element = 'fournisseur/facture/' . get_exdir($this->id, 2, 0, 1, $this, 'invoice_supplier');
+ break;
+ case 'shipping':
+ $element = 'expedition/sending';
+ break;
+ default:
+ $element = $this->element;
+ }
+
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."ecm_files";
+ $sql.= " WHERE filename LIKE '".$this->db->escape($this->ref)."%'";
+ $sql.= " AND filepath = '".$element."/".$this->db->escape($this->ref)."' AND entity = ".$conf->entity;
+
+ if (!$this->db->query($sql)) {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return false;
+ }
+
+ $this->db->commit();
+ return true;
+ }
}
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index 97a4bdf1948..6da413368dc 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -354,7 +354,7 @@ class FormFile
// Add entity in $param if not already exists
if (!preg_match('/entity\=[0-9]+/', $param)) {
- $param .= 'entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
+ $param .= ($param ? '&' : '').'entity='.(!empty($object->entity) ? $object->entity : $conf->entity);
}
$printer = 0;
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index b7e9c53a845..855ce1ed7ad 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -1248,7 +1248,7 @@ class FormMail extends Form
elseif ($type_template == 'fichinter_send') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentSendFichInter"); }
elseif ($type_template == 'thirdparty') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentThirdparty"); }
elseif ($type_template == 'user') { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentUser"); }
- elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContent".ucfirst($type_template)); }
+ elseif (!empty($type_template)) { $defaultmessage = $outputlangs->transnoentities("PredefinedMailContentGeneric"); }
$ret->label = 'default';
$ret->lang = $outputlangs->defaultlang;
diff --git a/htdocs/core/class/translate.class.php b/htdocs/core/class/translate.class.php
index 22ae1787ee4..06d8432f3e1 100644
--- a/htdocs/core/class/translate.class.php
+++ b/htdocs/core/class/translate.class.php
@@ -163,18 +163,19 @@ class Translate
*
* Value for hash are: 1:Loaded from disk, 2:Not found, 3:Loaded from cache
*
- * @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files:
- * If $domain is "file@module" instead of "file" then we look for module lang file
- * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang
- * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang
- * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US)
- * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed)
- * @param int $forcelangdir To force a different lang directory
- * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf.
- * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK
+ * @param string $domain File name to load (.lang file). Must be "file" or "file@module" for module language files:
+ * If $domain is "file@module" instead of "file" then we look for module lang file
+ * in htdocs/custom/modules/mymodule/langs/code_CODE/file.lang
+ * then in htdocs/module/langs/code_CODE/file.lang instead of htdocs/langs/code_CODE/file.lang
+ * @param integer $alt 0 (try xx_ZZ then 1), 1 (try xx_XX then 2), 2 (try en_US)
+ * @param int $stopafterdirection Stop when the DIRECTION tag is found (optimize speed)
+ * @param int $forcelangdir To force a different lang directory
+ * @param int $loadfromfileonly 1=Do not load overwritten translation from file or old conf.
+ * @param int $forceloadifalreadynotfound Force attempt to reload lang file if it was previously not found
+ * @return int <0 if KO, 0 if already loaded or loading not required, >0 if OK
* @see loadLangs()
*/
- public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0)
+ public function load($domain, $alt = 0, $stopafterdirection = 0, $forcelangdir = '', $loadfromfileonly = 0, $forceloadifalreadynotfound = 0)
{
global $conf,$db;
@@ -205,7 +206,8 @@ class Translate
}
// Check cache
- if (! empty($this->_tab_loaded[$newdomain])) // File already loaded for this domain
+ if (! empty($this->_tab_loaded[$newdomain])
+ && ($this->_tab_loaded[$newdomain] != 2 || empty($forceloadifalreadynotfound)) ) // File already loaded and found and not forced for this domain
{
//dol_syslog("Translate::Load already loaded for newdomain=".$newdomain);
return 0;
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index 4018d20aee5..0ef444422f0 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -479,16 +479,17 @@ function ajax_combobox($htmlname, $events = array(), $minLengthToAutocomplete =
* @param array $input Array of type->list of CSS element to switch. Example: array('disabled'=>array(0=>'cssid'))
* @param int $entity Entity to set
* @param int $revertonoff Revert on/off
- * @param bool $strict Use only "disabled" with delConstant and "enabled" with setConstant
+ * @param int $strict Use only "disabled" with delConstant and "enabled" with setConstant
+ * @param int $forcenoajax 1=Force to use a ahref link instead of ajax code.
* @return string
*/
-function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0)
+function ajax_constantonoff($code, $input = array(), $entity = null, $revertonoff = 0, $strict = 0, $forcenoajax = 0)
{
global $conf, $langs;
$entity = ((isset($entity) && is_numeric($entity) && $entity >= 0) ? $entity : $conf->entity);
- if (empty($conf->use_javascript_ajax))
+ if (empty($conf->use_javascript_ajax) || $forcenoajax)
{
if (empty($conf->global->$code)) print ''.img_picto($langs->trans("Disabled"), 'off').'';
else print ''.img_picto($langs->trans("Enabled"), 'on').'';
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 69a31d73d31..c6fd80f72d0 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -7928,19 +7928,16 @@ function getAdvancedPreviewUrl($modulepart, $relativepath, $alldata = 0, $param
if (empty($conf->use_javascript_ajax)) return '';
- $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'svg+xml');
- //$mime_preview[]='vnd.oasis.opendocument.presentation';
- //$mime_preview[]='archive';
- $num_mime = array_search(dol_mimetype($relativepath, '', 1), $mime_preview);
+ $isAllowedForPreview = dolIsAllowedForPreview($relativepath);
if ($alldata == 1)
{
- if ($num_mime !== false) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime'=>dol_mimetype($relativepath),);
+ if ($isAllowedForPreview) return array('target'=>'_blank', 'css'=>'documentpreview', 'url'=>DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : ''), 'mime'=>dol_mimetype($relativepath));
else return array();
}
- // old behavior
- if ($num_mime !== false) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')';
+ // old behavior, return a string
+ if ($isAllowedForPreview) return 'javascript:document_preview(\''.dol_escape_js(DOL_URL_ROOT.'/document.php?modulepart='.$modulepart.'&attachment=0&file='.urlencode($relativepath).($param ? '&'.$param : '')).'\', \''.dol_mimetype($relativepath).'\', \''.dol_escape_js($langs->trans('Preview')).'\')';
else return '';
}
@@ -7964,6 +7961,31 @@ function ajax_autoselect($htmlname, $addlink = '')
return $out;
}
+/**
+ * Return if a file is qualified for preview
+ *
+ * @param string $file Filename we looking for information
+ * @return int 1 If allowed, 0 otherwise
+ * @see dol_mimetype(), image_format_supported() from images.lib.php
+ */
+function dolIsAllowedForPreview($file)
+{
+ global $conf;
+
+ // Check .noexe extension in filename
+ if (preg_match('/\.noexe$/i', $file)) return 0;
+
+ // Check mime types
+ $mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css', 'webp');
+ if (!empty($conf->global->MAIN_ALLOW_SVG_FILES_AS_IMAGES)) $mime_preview[] = 'svg+xml';
+ //$mime_preview[]='vnd.oasis.opendocument.presentation';
+ //$mime_preview[]='archive';
+ $num_mime = array_search(dol_mimetype($file, '', 1), $mime_preview);
+ if ($num_mime !== false) return 1;
+
+ // By default, not allowed for preview
+ return 0;
+}
/**
* Return mime type of a file
@@ -7972,7 +7994,7 @@ function ajax_autoselect($htmlname, $addlink = '')
* @param string $default Default mime type if extension not found in known list
* @param int $mode 0=Return full mime, 1=otherwise short mime string, 2=image for mime type, 3=source language, 4=css of font fa
* @return string Return a mime type family (text/xxx, application/xxx, image/xxx, audio, video, archive)
- * @see image_format_supported() from images.lib.php
+ * @see dolIsAllowedForPreview(), image_format_supported() from images.lib.php
*/
function dol_mimetype($file, $default = 'application/octet-stream', $mode = 0)
{
@@ -8507,7 +8529,7 @@ function dolGetButtonTitle($label, $helpText = '', $iconClass = 'fa fa-file', $u
$attr['class'] .= ' classfortooltip';
}
- if (empty($id)) {
+ if (!empty($id)) {
$attr['id'] = $id;
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index eda6930ab7e..ec61ecab2e2 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -2107,7 +2107,7 @@ function pdf_getTotalQty($object, $type, $outputlangs)
*/
function pdf_getLinkedObjects($object, $outputlangs)
{
- global $hookmanager;
+ global $db, $hookmanager;
$linkedobjects = array();
@@ -2174,8 +2174,13 @@ function pdf_getLinkedObjects($object, $outputlangs)
// We concat this record info into fields xxx_value. title is overwrote.
if (empty($object->linkedObjects['commande']) && $object->element != 'commande') // There is not already a link to order and object is not the order, so we show also info with order
{
- $elementobject->fetchObjectLinked();
- if (!empty($elementobject->linkedObjects['commande'])) $order = reset($elementobject->linkedObjects['commande']);
+ $elementobject->fetchObjectLinked(null, '', null, '', 'OR', 1, 'sourcetype', 0);
+ if (! empty($elementobject->linkedObjectsIds['commande'])){
+ include_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
+ $order = new Commande($db);
+ $ret = $order->fetch(reset($elementobject->linkedObjectsIds['commande']));
+ if ($ret < 1) { $order=null; }
+ }
}
if (!is_object($order))
{
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 225dab1332c..afe5437b0d5 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -1,6 +1,7 @@
* Copyright (C) 2008-2017 Regis Houssin
+ * Copyright (C) 2020 Ferran Marcet
*
* 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
@@ -575,6 +576,18 @@ function checkUserAccessToObject($user, $featuresarray, $objectid = 0, $tableand
$sql .= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
$sql .= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
}
+
+ if ($feature == 'agenda')// Also check myactions rights
+ {
+ if ($objectid > 0 && empty($user->rights->agenda->allactions->read)) {
+ require_once DOL_DOCUMENT_ROOT . '/comm/action/class/actioncomm.class.php';
+ $action = new ActionComm($db);
+ $action->fetch($objectid);
+ if ($action->authorid != $user->id && $action->userownerid != $user->id && !(array_key_exists($user->id, $action->userassigned))) {
+ return false;
+ }
+ }
+ }
}
elseif (in_array($feature, $checkproject))
{
diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php
index f6d8aa401a5..ca7220037a5 100644
--- a/htdocs/core/menus/standard/eldy.lib.php
+++ b/htdocs/core/menus/standard/eldy.lib.php
@@ -1706,7 +1706,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
// Project affected to user
- $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire);
+ $newmenu->add("/projet/activity/index.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("Activities"), 0, $user->rights->projet->lire, '', 'project', 'tasks');
$newmenu->add("/projet/tasks.php?leftmenu=tasks&action=create", $langs->trans("NewTask"), 1, $user->rights->projet->creer);
$newmenu->add("/projet/tasks/list.php?leftmenu=tasks".($search_project_user ? '&search_project_user='.$search_project_user : ''), $langs->trans("List"), 1, $user->rights->projet->lire);
$newmenu->add("/projet/tasks/stats/index.php?leftmenu=projects", $langs->trans("Statistics"), 1, $user->rights->projet->lire);
diff --git a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
index 32a8714cf12..1b578da172f 100644
--- a/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
+++ b/htdocs/core/modules/expensereport/doc/pdf_standard.modules.php
@@ -358,7 +358,7 @@ class pdf_standard extends ModeleExpenseReport
while ($i < $nblines) {
$pdf->SetFont('', '', $default_font_size - 2); // Into loop to work with multipage
$pdf->SetTextColor(0, 0, 0);
- if (empty($showpricebeforepagebreak)) {
+ if (empty($showpricebeforepagebreak) && ($i !== ($nblines - 1))) {
$pdf->setPageOrientation('', 1, $heightforfooter); // The only function to edit the bottom margin of current page to set it.
} else {
$pdf->setPageOrientation('', 1, $heightforfooter + $heightforfreetext + $heightforinfotot); // The only function to edit the bottom margin of current page to set it.
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 6139f157f8a..f0cee68a01f 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -1057,7 +1057,8 @@ class Cronjob extends CommonObject
if (!$error)
{
$result = $langs->load($this->module_name);
- $result = $langs->load($this->module_name.'@'.$this->module_name); // If this->module_name was an existing language file, this will make nothing
+ $result = $langs->load($this->module_name.'@'.$this->module_name, 0, 0, '', 0, 1);
+
if ($result < 0) // If technical error
{
dol_syslog(get_class($this)."::run_jobs Cannot load module lang file - ".$langs->error, LOG_ERR);
diff --git a/htdocs/document.php b/htdocs/document.php
index c1ed149649e..2e088d6378c 100644
--- a/htdocs/document.php
+++ b/htdocs/document.php
@@ -159,11 +159,13 @@ if (isset($_GET["attachment"])) $attachment = GETPOST("attachment", 'alpha') ?tr
if (!empty($conf->global->MAIN_DISABLE_FORCE_SAVEAS)) $attachment = false;
// Define mime type
-$type = 'application/octet-stream';
+$type = 'application/octet-stream'; // By default
if (GETPOST('type', 'alpha')) $type = GETPOST('type', 'alpha');
-else $type = dol_mimetype($original_file);
-// Security: Force to octet-stream if file is a dangerous file
-if (preg_match('/\.noexe$/i', $original_file)) $type = 'application/octet-stream';
+else $type=dol_mimetype($original_file);
+// Security: Force to octet-stream if file is a dangerous file. For example when it is a .noexe file
+if (!in_array($type, array('text/x-javascript')) && !dolIsAllowedForPreview($original_file)) {
+ $type = 'application/octet-stream';
+}
// Security: Delete string ../ into $original_file
$original_file = str_replace("../", "/", $original_file);
diff --git a/htdocs/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php
index a4bdfd1fb64..4193c9bf020 100644
--- a/htdocs/expedition/class/expedition.class.php
+++ b/htdocs/expedition/class/expedition.class.php
@@ -3,7 +3,7 @@
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2007 Franky Van Liedekerke
* Copyright (C) 2006-2012 Laurent Destailleur
- * Copyright (C) 2011-2017 Juanjo Menent
+ * Copyright (C) 2011-2020 Juanjo Menent
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014 Cedric GROSS
* Copyright (C) 2014-2015 Marcos García
@@ -1325,6 +1325,9 @@ class Expedition extends CommonObject
{
$this->db->commit();
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// We delete PDFs
$ref = dol_sanitizeFileName($this->ref);
if (!empty($conf->expedition->dir_output))
diff --git a/htdocs/fichinter/class/fichinter.class.php b/htdocs/fichinter/class/fichinter.class.php
index 025a2e13a88..97dfe98b517 100644
--- a/htdocs/fichinter/class/fichinter.class.php
+++ b/htdocs/fichinter/class/fichinter.class.php
@@ -2,7 +2,7 @@
/* Copyright (C) 2002-2003 Rodolphe Quiedeville
* Copyright (C) 2004-2014 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2011-2013 Juanjo Menent
+ * Copyright (C) 2011-2020 Juanjo Menent
* Copyright (C) 2015 Marcos García
* Copyright (C) 2015 Charlie Benke
* Copyright (C) 2018 Nicolas ZABOURI
@@ -1000,6 +1000,9 @@ class Fichinter extends CommonObject
if (!$error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// Remove directory with files
$fichinterref = dol_sanitizeFileName($this->ref);
if ($conf->ficheinter->dir_output)
diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php
index dd34555dd79..d669ccffd11 100644
--- a/htdocs/fourn/class/fournisseur.commande.class.php
+++ b/htdocs/fourn/class/fournisseur.commande.class.php
@@ -3,7 +3,7 @@
* Copyright (C) 2004-2017 Laurent Destailleur
* Copyright (C) 2005-2012 Regis Houssin
* Copyright (C) 2007 Franky Van Liedekerke
- * Copyright (C) 2010-2014 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2010-2018 Philippe Grand
* Copyright (C) 2012-2015 Marcos García
* Copyright (C) 2013 Florian Henry
@@ -2062,6 +2062,9 @@ class CommandeFournisseur extends CommonOrder
if (!$error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->fournisseur->commande->dir_output)
diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php
index 46c2c032786..78615fc2cf6 100644
--- a/htdocs/fourn/class/fournisseur.facture.class.php
+++ b/htdocs/fourn/class/fournisseur.facture.class.php
@@ -4,7 +4,7 @@
* Copyright (C) 2004 Christophe Combelles
* Copyright (C) 2005 Marc Barilley
* Copyright (C) 2005-2012 Regis Houssin
- * Copyright (C) 2010-2017 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2013-2019 Philippe Grand
* Copyright (C) 2013 Florian Henry
* Copyright (C) 2014-2016 Marcos García
@@ -1217,6 +1217,9 @@ class FactureFournisseur extends CommonInvoice
if (!$error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// We remove directory
if ($conf->fournisseur->facture->dir_output)
{
diff --git a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php
index 74d3356faeb..b2a79dc4751 100644
--- a/htdocs/includes/OAuth/Common/Storage/DoliStorage.php
+++ b/htdocs/includes/OAuth/Common/Storage/DoliStorage.php
@@ -242,7 +242,7 @@ class DoliStorage implements TokenStorageInterface
$sql.= " WHERE service='".$this->db->escape($service)."'";
$resql = $this->db->query($sql);
$result = $this->db->fetch_array($resql);
- $states[$service] = $result[state];
+ $states[$service] = $result['state'];
$this->states[$service] = $states[$service];
return is_array($states)
diff --git a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
index 7055898ada6..37bb2962724 100644
--- a/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
+++ b/htdocs/install/mysql/migration/10.0.0-11.0.0.sql
@@ -98,7 +98,8 @@ ALTER TABLE llx_bom_bomline ADD COLUMN position integer NOT NULL DEFAULT 0;
ALTER TABLE llx_bom_bomline ADD COLUMN qty_frozen smallint DEFAULT 0;
ALTER TABLE llx_bom_bomline ADD COLUMN disable_stock_change smallint DEFAULT 0;
-ALTER TABLE llx_bom_bomline DROP COLUMN `rank`;
+-- VMYSQL4.1 ALTER TABLE llx_bom_bomline DROP COLUMN `rank`;
+-- VPGSQL8.2 ALTER TABLE llx_bom_bomline DROP COLUMN rank;
create table llx_categorie_warehouse
(
diff --git a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
index 91c155d3d84..c0efe6d68b3 100644
--- a/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
+++ b/htdocs/install/mysql/migration/3.2.0-3.3.0.sql
@@ -315,6 +315,7 @@ ALTER TABLE llx_c_chargesociales ADD COLUMN accountancy_code varchar(15) DEFAULT
-- Tables for accountancy expert
DROP TABLE llx_accountingaccount;
+DROP TABLE llx_accounting_account;
DROP TABLE llx_accountingsystem;
DROP TABLE llx_accounting_system;
diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
index 0f84c92ef22..88d9ae1b685 100644
--- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
+++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql
@@ -102,6 +102,10 @@ ALTER TABLE llx_expedition DROP FOREIGN KEY fk_expedition_fk_shipping_method;
ALTER TABLE llx_expedition DROP INDEX idx_expedition_fk_expedition_methode;
ALTER TABLE llx_expedition CHANGE COLUMN fk_expedition_methode fk_shipping_method integer;
+-- This table and constraint should not exists as it appears in more recent version, but we may have it if we load an old dump
+-- on a newly created database and we want to be sure upgrade of rowid into autoincrement done later will works.
+ALTER TABLE llx_reception DROP FOREIGN KEY fk_reception_fk_shipping_method;
+
ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(255) NOT NULL DEFAULT '' AFTER description;
--ALTER TABLE llx_c_shipment_mode DROP COLUMN CASCADE;
diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang
index 051dde11ff7..e7c35f6d9f7 100644
--- a/htdocs/langs/en_US/main.lang
+++ b/htdocs/langs/en_US/main.lang
@@ -353,8 +353,8 @@ PriceUTTC=U.P. (inc. tax)
Amount=Amount
AmountInvoice=Invoice amount
AmountInvoiced=Amount invoiced
-AmountInvoicedHT=Amount invoiced (incl. tax)
-AmountInvoicedTTC=Amount invoiced (excl. tax)
+AmountInvoicedHT=Amount invoiced (excl. tax)
+AmountInvoicedTTC=Amount invoiced (inc. tax)
AmountPayment=Payment amount
AmountHTShort=Amount (excl.)
AmountTTCShort=Amount (inc. tax)
diff --git a/htdocs/langs/en_US/other.lang b/htdocs/langs/en_US/other.lang
index 3a15443b961..f23e0399ee3 100644
--- a/htdocs/langs/en_US/other.lang
+++ b/htdocs/langs/en_US/other.lang
@@ -97,6 +97,7 @@ PredefinedMailContentThirdparty=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNA
PredefinedMailContentContact=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentUser=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
PredefinedMailContentLink=You can click on the link below to make your payment if it is not already done.\n\n%s\n\n
+PredefinedMailContentGeneric=__(Hello)__\n\n\n__(Sincerely)__\n\n__USER_SIGNATURE__
DemoDesc=Dolibarr is a compact ERP/CRM supporting several business modules. A demo showcasing all modules makes no sense as this scenario never occurs (several hundred available). So, several demo profiles are available.
ChooseYourDemoProfil=Choose the demo profile that best suits your needs...
ChooseYourDemoProfilMore=...or build your own profile (manual module selection)
diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang
index 611d27d7723..ff74af2ad5c 100644
--- a/htdocs/langs/fr_FR/main.lang
+++ b/htdocs/langs/fr_FR/main.lang
@@ -353,8 +353,8 @@ PriceUTTC=P.U TTC
Amount=Montant
AmountInvoice=Montant facture
AmountInvoiced=Montant facturé
-AmountInvoicedHT=Montant facturé (TTC)
-AmountInvoicedTTC=Montant facturé (HT)
+AmountInvoicedHT=Montant facturé (HT)
+AmountInvoicedTTC=Montant facturé (TTC)
AmountPayment=Montant paiement
AmountHTShort=Montant HT
AmountTTCShort=Montant TTC
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index fa0507ca190..238726b0919 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -366,7 +366,7 @@ if ($num == 1 && !empty($conf->global->MAIN_SEARCH_DIRECT_OPEN_IF_ONLY_ONE) && $
{
$obj = $db->fetch_object($resql);
$id = $obj->id;
- header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withprojet=1');
+ header("Location: ".DOL_URL_ROOT.'/projet/tasks/task.php?id='.$id.'&withproject=1');
exit;
}
diff --git a/htdocs/societe/card.php b/htdocs/societe/card.php
index a5fca19e99d..ee252677bf2 100644
--- a/htdocs/societe/card.php
+++ b/htdocs/societe/card.php
@@ -552,7 +552,7 @@ if (empty($reshook))
// Links with users
$salesreps = GETPOST('commercial', 'array');
- $result = $object->setSalesRep($salesreps);
+ $result = $object->setSalesRep($salesreps, true);
if ($result < 0)
{
$error++;
diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php
index a37830b0ed9..f10cead50fd 100644
--- a/htdocs/societe/class/societe.class.php
+++ b/htdocs/societe/class/societe.class.php
@@ -2412,7 +2412,15 @@ class Societe extends CommonObject
global $action;
$hookmanager->initHooks(array('thirdpartydao'));
- $parameters = array('id'=>$this->id, 'getnomurl'=>$result);
+ $parameters = array(
+ 'id'=>$this->id,
+ 'getnomurl'=>$result,
+ 'withpicto '=> $withpicto,
+ 'option'=> $option,
+ 'maxlen'=> $maxlen,
+ 'notooltip'=> $notooltip,
+ 'save_lastsearch_value'=> $save_lastsearch_value
+ );
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $result = $hookmanager->resPrint;
else $result .= $hookmanager->resPrint;
@@ -4270,9 +4278,10 @@ class Societe extends CommonObject
* Sets sales representatives of the thirdparty
*
* @param int[]|int $salesrep User ID or array of user IDs
+ * @param bool $onlyAdd Only add (no delete before)
* @return int <0 if KO, >0 if OK
*/
- public function setSalesRep($salesrep)
+ public function setSalesRep($salesrep, $onlyAdd = false)
{
global $user;
@@ -4281,16 +4290,18 @@ class Societe extends CommonObject
$salesrep = array($salesrep);
}
- // Get current users
- $existing = $this->getSalesRepresentatives($user, 1);
- // Diff
- if (is_array($existing)) {
- $to_del = array_diff($existing, $salesrep);
- $to_add = array_diff($salesrep, $existing);
- } else {
- $to_del = array(); // Nothing to delete
- $to_add = $salesrep;
+ $to_del = array(); // Nothing to delete
+ $to_add = $salesrep;
+ if ($onlyAdd === false) {
+ // Get current users
+ $existing = $this->getSalesRepresentatives($user, 1);
+
+ // Diff
+ if (is_array($existing)) {
+ $to_del = array_diff($existing, $salesrep);
+ $to_add = array_diff($salesrep, $existing);
+ }
}
$error = 0;
diff --git a/htdocs/supplier_proposal/class/supplier_proposal.class.php b/htdocs/supplier_proposal/class/supplier_proposal.class.php
index 1801bf16d71..5b03f5e8c82 100644
--- a/htdocs/supplier_proposal/class/supplier_proposal.class.php
+++ b/htdocs/supplier_proposal/class/supplier_proposal.class.php
@@ -6,7 +6,7 @@
* Copyright (C) 2005-2013 Regis Houssin
* Copyright (C) 2006 Andre Cianfarani
* Copyright (C) 2008 Raphael Bertrand
- * Copyright (C) 2010-2015 Juanjo Menent
+ * Copyright (C) 2010-2020 Juanjo Menent
* Copyright (C) 2010-2018 Philippe Grand
* Copyright (C) 2012-2014 Christophe Battarel
* Copyright (C) 2013 Florian Henry
@@ -1818,7 +1818,7 @@ class SupplierProposal extends CommonObject
if(!empty($conf->multicurrency->enabled) && !empty($product->multicurrency_code)) list($fk_multicurrency, $multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $product->multicurrency_code);
$productsupplier->id = $product->fk_product;
- $productsupplier->update_buyprice($product->qty, $product->subprice, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_subprice, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', '');
+ $productsupplier->update_buyprice($product->qty, $product->total_ht, $user, 'HT', $this->thirdparty, '', $ref_fourn, $product->tva_tx, 0, 0, 0, $product->info_bits, '', '', array(), '', $product->multicurrency_total_ht, 'HT', $multicurrency_tx, $product->multicurrency_code, '', '', '');
}
return 1;
@@ -2076,6 +2076,9 @@ class SupplierProposal extends CommonObject
if (! $error)
{
+ // Delete record into ECM index (Note that delete is also done when deleting files with the dol_delete_dir_recursive
+ $this->deleteEcmFiles();
+
// We remove directory
$ref = dol_sanitizeFileName($this->ref);
if ($conf->supplier_proposal->dir_output && !empty($this->ref))
|