@@ -6528,7 +6541,9 @@ class Form
$linktoelem='';
}
- print '
+ if (! empty($conf->use_javascript_ajax))
+ {
+ print '
- ';
+ ';
+ }
return $linktoelem;
}
diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php
index 0eba0a51e1d..066c2a25a23 100644
--- a/htdocs/core/class/html.formactions.class.php
+++ b/htdocs/core/class/html.formactions.class.php
@@ -243,7 +243,7 @@ class FormActions
print '
';
// Ref
- print '| '.$ref.' | ';
+ print ''.$ref.' | ';
// Onwer
print '';
if (! empty($action->userownerid))
diff --git a/htdocs/core/class/html.formcompany.class.php b/htdocs/core/class/html.formcompany.class.php
index 60017d82570..9d0bded74b6 100644
--- a/htdocs/core/class/html.formcompany.class.php
+++ b/htdocs/core/class/html.formcompany.class.php
@@ -622,8 +622,8 @@ class FormCompany
runJsCodeForEvent'.$htmlname.'(values);
}
});
- /* Clean contact */
- $("div#s2id_contactid>a>span").html(\'\');
+
+ $(this).trigger("blur");
});
// Function used to execute events when search_htmlname change
diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php
index be9993a74b5..da2f697d5d4 100644
--- a/htdocs/core/class/html.formfile.class.php
+++ b/htdocs/core/class/html.formfile.class.php
@@ -307,8 +307,10 @@ class FormFile
return $this->getDocumentsLink($modulepart, $modulesubdir, $filedir);
}
- // Add entity in $param
- $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity);
+ // Add entity in $param if not already exists
+ if (!preg_match('/entity\=[0-9]+/', $param)) {
+ $param.= 'entity='.(!empty($object->entity)?$object->entity:$conf->entity);
+ }
$printer=0;
if (in_array($modulepart,array('facture','supplier_proposal','propal','proposal','order','commande','expedition', 'commande_fournisseur', 'expensereport','livraison'))) // The direct print feature is implemented only for such elements
diff --git a/htdocs/core/class/html.formprojet.class.php b/htdocs/core/class/html.formprojet.class.php
index 1b6efe56820..35b3e52d154 100644
--- a/htdocs/core/class/html.formprojet.class.php
+++ b/htdocs/core/class/html.formprojet.class.php
@@ -334,7 +334,7 @@ class FormProjets
$out='';
$hideunselectables = false;
- if (! empty($conf->global->CONTRACT_HIDE_UNSELECTABLES)) $hideunselectables = true;
+ if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
if (empty($projectsListId))
{
@@ -346,11 +346,11 @@ class FormProjets
}
// Search all projects
- $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,';
+ $sql = 'SELECT t.rowid, t.ref as tref, t.label as tlabel, p.rowid as pid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public,';
$sql.= ' s.nom as name';
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
- $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc';
- $sql.= ', '.MAIN_DB_PREFIX.'projet_task as t';
+ $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'societe as s ON s.rowid = p.fk_soc,';
+ $sql.= ' '.MAIN_DB_PREFIX.'projet_task as t';
$sql.= " WHERE p.entity IN (".getEntity('project').")";
$sql.= " AND t.fk_projet = p.rowid";
if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")";
@@ -393,7 +393,7 @@ class FormProjets
}
else
{
- if ($discard_closed == 1 && $obj->fk_statut == 2)
+ if ($discard_closed == 1 && $obj->fk_statut == Project::STATUS_CLOSED)
{
$i++;
continue;
@@ -411,12 +411,12 @@ class FormProjets
if ($obj->name) $labeltoshow.=' ('.$obj->name.')';
$disabled=0;
- if ($obj->fk_statut == 0)
+ if ($obj->fk_statut == Project::STATUS_DRAFT)
{
$disabled=1;
$labeltoshow.=' - '.$langs->trans("Draft");
}
- else if ($obj->fk_statut == 2)
+ else if ($obj->fk_statut == Project::STATUS_CLOSED)
{
if ($discard_closed == 2) $disabled=1;
$labeltoshow.=' - '.$langs->trans("Closed");
diff --git a/htdocs/core/class/interfaces.class.php b/htdocs/core/class/interfaces.class.php
index abcf2132efa..6f43643eeb7 100644
--- a/htdocs/core/class/interfaces.class.php
+++ b/htdocs/core/class/interfaces.class.php
@@ -61,7 +61,7 @@ class Interfaces
* @param string $action Trigger event code
* @param object $object Objet concerned. Some context information may also be provided into array property object->context.
* @param User $user Objet user
- * @param Lang $langs Objet lang
+ * @param Translate $langs Objet lang
* @param Conf $conf Objet conf
* @return int Nb of triggers ran if no error, -Nb of triggers with errors otherwise.
*/
@@ -86,6 +86,7 @@ class Interfaces
global $db;
$user = new User($db);
}
+ //dol_syslog(get_class($this)."::run_triggers action=".$action." Launch run_triggers", LOG_DEBUG);
$nbfile = $nbtotal = $nbok = $nbko = 0;
@@ -94,6 +95,7 @@ class Interfaces
$orders = array();
$i=0;
+
$dirtriggers=array_merge(array('/core/triggers'),$conf->modules_parts['triggers']);
foreach($dirtriggers as $reldir)
{
diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php
index 7f4ab7c6d4a..86b27948389 100644
--- a/htdocs/core/class/menubase.class.php
+++ b/htdocs/core/class/menubase.class.php
@@ -589,7 +589,6 @@ class Menubase
$a = 0;
$b = 0;
- $oldrowid=0;
while ($a < $numa)
{
//$objm = $this->db->fetch_object($resql);
diff --git a/htdocs/core/class/stats.class.php b/htdocs/core/class/stats.class.php
index 1a58e14796a..90986e7b6da 100644
--- a/htdocs/core/class/stats.class.php
+++ b/htdocs/core/class/stats.class.php
@@ -384,16 +384,16 @@ abstract class Stats
$row = $this->db->fetch_object($resql);
$result[$i]['year'] = $row->year;
$result[$i]['nb'] = $row->nb;
- if($i>0 && $row->nb) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100;
+ if($i>0 && $row->nb>0) $result[$i-1]['nb_diff'] = ($result[$i-1]['nb'] - $row->nb) / $row->nb * 100;
$result[$i]['total'] = $row->total;
- if($i>0 && $row->total) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100;
+ if($i>0 && $row->total>0) $result[$i-1]['total_diff'] = ($result[$i-1]['total'] - $row->total) / $row->total * 100;
$result[$i]['avg'] = $row->avg;
- if($i>0 && $row->avg) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100;
+ if($i>0 && $row->avg>0) $result[$i-1]['avg_diff'] = ($result[$i-1]['avg'] - $row->avg) / $row->avg * 100;
// For some $sql only
if (isset($row->weighted))
{
$result[$i]['weighted'] = $row->weighted;
- if($i>0 && $row->weighted) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
+ if($i>0 && $row->weighted>0) $result[$i-1]['avg_weighted'] = ($result[$i-1]['weighted'] - $row->weighted) / $row->weighted * 100;
}
$i++;
}
diff --git a/htdocs/core/js/lib_foot.js.php b/htdocs/core/js/lib_foot.js.php
index cc08af7431f..cfa05289f4b 100644
--- a/htdocs/core/js/lib_foot.js.php
+++ b/htdocs/core/js/lib_foot.js.php
@@ -29,14 +29,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-session_cache_limiter(false);
+session_cache_limiter('public');
require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
else header('Cache-Control: no-cache');
//var_dump($conf);
diff --git a/htdocs/core/js/lib_gravatar.js.php b/htdocs/core/js/lib_gravatar.js.php
index 485a57ede88..dad6482460a 100644
--- a/htdocs/core/js/lib_gravatar.js.php
+++ b/htdocs/core/js/lib_gravatar.js.php
@@ -33,14 +33,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-session_cache_limiter(false);
+session_cache_limiter('public');
require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
else header('Cache-Control: no-cache');
?>
diff --git a/htdocs/core/js/lib_head.js.php b/htdocs/core/js/lib_head.js.php
index f2aa6fc521f..5b909c6e148 100644
--- a/htdocs/core/js/lib_head.js.php
+++ b/htdocs/core/js/lib_head.js.php
@@ -32,14 +32,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-session_cache_limiter(false);
+session_cache_limiter('public');
require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
else header('Cache-Control: no-cache');
diff --git a/htdocs/core/js/lib_notification.js.php b/htdocs/core/js/lib_notification.js.php
index 6900e9b03e7..fa7095c65ac 100644
--- a/htdocs/core/js/lib_notification.js.php
+++ b/htdocs/core/js/lib_notification.js.php
@@ -40,7 +40,7 @@ if (! ($_SERVER['HTTP_REFERER'] === $dolibarr_main_url_root . '/' || $_SERVER['H
// TODO Try to make a solution with only a javascript timer that is easier. Difficulty is to avoid notification twice when.
/* session already started into main
- session_cache_limiter(false);
+ session_cache_limiter('public');
header('Cache-Control: no-cache');
session_set_cookie_params(0, '/', null, false, true); // Add tag httponly on session cookie
session_start();*/
diff --git a/htdocs/core/js/timepicker.js.php b/htdocs/core/js/timepicker.js.php
index 8e67f517b44..38c450b8e23 100644
--- a/htdocs/core/js/timepicker.js.php
+++ b/htdocs/core/js/timepicker.js.php
@@ -29,14 +29,14 @@ if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU',1);
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML',1);
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
-session_cache_limiter(false);
+session_cache_limiter('public');
require_once '../../main.inc.php';
// Define javascript type
top_httphead('text/javascript; charset=UTF-8');
// Important: Following code is to avoid page request by browser and PHP CPU at each Dolibarr page access.
-if (empty($dolibarr_nocache)) header('Cache-Control: max-age=3600, public, must-revalidate');
+if (empty($dolibarr_nocache)) header('Cache-Control: max-age=10800, public, must-revalidate');
else header('Cache-Control: no-cache');
?>
diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php
index e3a0f44c9ac..1fcda0e34d2 100644
--- a/htdocs/core/lib/ajax.lib.php
+++ b/htdocs/core/lib/ajax.lib.php
@@ -382,6 +382,7 @@ function ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $
if (! empty($conf->global->MAIN_DISABLE_AJAX_COMBOX)) return '';
if (empty($conf->use_javascript_ajax)) return '';
if (empty($conf->global->MAIN_USE_JQUERY_MULTISELECT) && ! defined('REQUIRE_JQUERY_MULTISELECT')) return '';
+ if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) return '';
if (empty($minLengthToAutocomplete)) $minLengthToAutocomplete=0;
diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php
index e06e071ee89..3f1efad3bce 100644
--- a/htdocs/core/lib/company.lib.php
+++ b/htdocs/core/lib/company.lib.php
@@ -1341,6 +1341,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
if (is_object($objcon) && $objcon->id) {
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."actioncomm_resources as r ON a.id = r.fk_actioncomm";
+ $sql.= " AND r.element_type = '" . $db->escape($objcon->table_element) . "' AND r.fk_element = " . $objcon->id;
}
if (is_object($filterobj) && get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid";
@@ -1373,13 +1374,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
}
- // Work with new table actioncomm_resources and multiple contact affectation.
- if (is_object($objcon) && $objcon->id)
- {
- $sql.= " AND r.element_type = '" . $objcon->table_element . "'" .
- " AND r.fk_element = " . $objcon->id;
- }
-
// Condition on actioncode
if (! empty($actioncode))
{
@@ -1403,7 +1397,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
elseif ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
if (is_array($filters) && $filters['search_agenda_label']) $sql.= natural_search('a.label', $filters['search_agenda_label']);
-
+
//TODO Add limit for thirdparty in contexte very all result
$sql.= $db->order($sortfield, $sortorder);
dol_syslog("company.lib::show_actions_done", LOG_DEBUG);
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 1bca14827e6..964e368c4e3 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -2119,6 +2119,9 @@ function dol_check_secure_access_document($modulepart, $original_file, $entity,
if (empty($conf->multicompany->enabled)) $entity=1;
else $entity=0;
}
+ // Fix modulepart
+ if ($modulepart == 'users') $modulepart='user';
+
dol_syslog('modulepart='.$modulepart.' original_file='.$original_file.' entity='.$entity);
// We define $accessallowed and $sqlprotectagainstexternals
$accessallowed=0;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 9cc9f315e82..fffe95cbb0c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -321,13 +321,18 @@ function GETPOST($paramname, $check='none', $method=0, $filter=null, $options=nu
}
}
}
- if (! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring])) // If there is saved contextpage
+ // If there is saved contextpage, page or limit
+ if ($paramname == 'contextpage' && ! empty($_SESSION['lastsearch_contextpage_'.$relativepathstring]))
{
- if ($paramname == 'contextpage')
- {
- $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
- //var_dump($paramname.' '.$out);
- }
+ $out = $_SESSION['lastsearch_contextpage_'.$relativepathstring];
+ }
+ elseif ($paramname == 'page' && ! empty($_SESSION['lastsearch_page_'.$relativepathstring]))
+ {
+ $out = $_SESSION['lastsearch_page_'.$relativepathstring];
+ }
+ elseif ($paramname == 'limit' && ! empty($_SESSION['lastsearch_limit_'.$relativepathstring]))
+ {
+ $out = $_SESSION['lastsearch_limit_'.$relativepathstring];
}
}
// Else, retreive default values if we are not doing a sort
@@ -611,7 +616,7 @@ if (! function_exists('dol_getprefix'))
/**
* Return a prefix to use for this Dolibarr instance, for session/cookie names or email id.
* The prefix for session is unique in a web context only and is unique for instance and avoid conflict
- * between multi-instances, even when having two instances with one root dir or two instances in virtual servers.
+ * between multi-instances, even when having two instances with same root dir or two instances in same virtual servers.
* The prefix for email is unique if MAIL_PREFIX_FOR_EMAIL_ID is set to a value, otherwise value may be same than other instance.
*
* @param string $mode '' (prefix for session name) or 'email' (prefix for email id)
@@ -629,16 +634,16 @@ if (! function_exists('dol_getprefix'))
if ($conf->global->MAIL_PREFIX_FOR_EMAIL_ID != 'SERVER_NAME') return $conf->global->MAIL_PREFIX_FOR_EMAIL_ID;
else if (isset($_SERVER["SERVER_NAME"])) return $_SERVER["SERVER_NAME"];
}
- return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
+ return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
}
if (isset($_SERVER["SERVER_NAME"]) && isset($_SERVER["DOCUMENT_ROOT"]))
{
- return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
- // Use this for a "readable" cookie name
+ return dol_hash($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
+ // Use this for a "readable" key
//return dol_sanitizeFileName($_SERVER["SERVER_NAME"].$_SERVER["DOCUMENT_ROOT"].DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
}
- return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT);
+ return dol_hash(DOL_DOCUMENT_ROOT.DOL_URL_ROOT, '3');
}
}
@@ -1437,6 +1442,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
{
if (empty($conf->global->MAIN_DISABLE_PDF_THUMBS)) // If you experienc trouble with pdf thumb generation and imagick, you can disable here.
{
+ include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$ret = dol_convert_file($file, 'png', $fileimage);
if ($ret < 0) $error++;
}
@@ -3009,8 +3015,8 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
//if (in_array($picto, array('switch_off', 'switch_on', 'off', 'on')))
if (empty($srconly) && in_array($pictowithoutext, array(
'bank', 'close_title', 'delete', 'edit', 'ellipsis-h', 'filter', 'grip', 'grip_title', 'list', 'listlight', 'off', 'on', 'play', 'playdisabled', 'printer', 'resize',
- 'note','switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow',
- 'skype','twitter','facebook'
+ 'note', 'split', 'switch_off', 'switch_on', 'unlink', 'uparrow', '1downarrow', '1uparrow',
+ 'jabber','skype','twitter','facebook'
)
)) {
$fakey = $pictowithoutext;
@@ -3097,16 +3103,23 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$fakey = 'fa-play';
$facolor = '#444';
}
+ elseif ($pictowithoutext == 'jabber') {
+ $fakey = 'fa-comment-o';
+ }
+ elseif ($pictowithoutext == 'split') {
+ $fakey = 'fa-code-fork';
+ }
else {
$fakey = 'fa-'.$pictowithoutext;
$facolor = '#444';
$marginleftonlyshort=0;
}
+ $reg=array();
if (preg_match('/class="([^"]+)"/', $moreatt, $reg)) {
$morecss.= ($morecss?' ':'').$reg[1];
}
- $enabledisablehtml = '';
+ $enabledisablehtml = '';
if (! empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$enabledisablehtml.= $titlealt;
}
@@ -3122,11 +3135,11 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
$path = $conf->global->MAIN_OVERWRITE_THEME_RES.'/theme/'.$conf->global->MAIN_OVERWRITE_THEME_RES; // To allow an external module to overwrite image resources whatever is activated theme
}
else if (! empty($conf->modules_parts['theme']) && array_key_exists($theme, $conf->modules_parts['theme'])) {
- $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module
+ $path = $theme.'/theme/'.$theme; // If the theme have the same name as the module
}
// If we ask an image into $url/$mymodule/img (instead of default path)
- if (preg_match('/^([^@]+)@([^@]+)$/i',$picto,$regs)) {
+ if (preg_match('/^([^@]+)@([^@]+)$/i', $picto, $regs)) {
$picto = $regs[1];
$path = $regs[2]; // $path is $mymodule
}
@@ -4337,7 +4350,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
* @param string $currency_code To add currency symbol (''=add nothing, 'auto'=Use default currency, 'XXX'=add currency symbols for XXX currency)
* @return string Chaine avec montant formate
*
- * @see price2num Revert function of price
+ * @see price2num() Revert function of price
*/
function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerounding=-1, $currency_code='')
{
@@ -4400,7 +4413,11 @@ function price($amount, $form=0, $outlangs='', $trunc=1, $rounding=-1, $forcerou
if ($currency_code == 'auto') $currency_code=$conf->currency;
$listofcurrenciesbefore=array('USD','GBP','AUD','MXN','PEN','CNY');
- if (in_array($currency_code,$listofcurrenciesbefore)) $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code);
+ $listoflanguagesbefore=array('nl_NL');
+ if (in_array($currency_code, $listofcurrenciesbefore) || in_array($outlangs->defaultlang, $listoflanguagesbefore))
+ {
+ $cursymbolbefore.=$outlangs->getCurrencySymbol($currency_code);
+ }
else
{
$tmpcur=$outlangs->getCurrencySymbol($currency_code);
@@ -4506,37 +4523,49 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
* Output a dimension with best unit
*
* @param float $dimension Dimension
- * @param int $unit Unit of dimension (0, -3, ...)
+ * @param int $unit Unit of dimension (Example: 0=kg, -3=g, 98=ounce, 99=pound, ...)
* @param string $type 'weight', 'volume', ...
* @param Translate $outputlangs Translate language object
* @param int $round -1 = non rounding, x = number of decimal
- * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit
+ * @param string $forceunitoutput 'no' or numeric (-3, -6, ...) compared to $unit (In most case, this value is value defined into $conf->global->MAIN_WEIGHT_DEFAULT_UNIT)
* @return string String to show dimensions
*/
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
{
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
- if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
+ if (($forceunitoutput == 'no' && $dimension < 1/10000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
{
$dimension = $dimension * 1000000;
$unit = $unit - 6;
}
- elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
+ elseif (($forceunitoutput == 'no' && $dimension < 1/10 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
{
$dimension = $dimension * 1000;
$unit = $unit - 3;
}
- elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
+ elseif (($forceunitoutput == 'no' && $dimension > 100000000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
{
$dimension = $dimension / 1000000;
$unit = $unit + 6;
}
- elseif (($forceunitoutput == 'no' && $dimension > 100000) || (is_numeric($forceunitoutput) && $forceunitoutput == 3))
+ elseif (($forceunitoutput == 'no' && $dimension > 100000 && $unit < 90) || (is_numeric($forceunitoutput) && $forceunitoutput == 3))
{
$dimension = $dimension / 1000;
$unit = $unit + 3;
}
+ // Special case when we want output unit into pound or ounce
+ /* TODO
+ if ($unit < 90 && $type == 'weight' && is_numeric($forceunitoutput) && (($forceunitoutput == 98) || ($forceunitoutput == 99))
+ {
+ $dimension = // convert dimension from standard unit into ounce or pound
+ $unit = $forceunitoutput;
+ }
+ if ($unit > 90 && $type == 'weight' && is_numeric($forceunitoutput) && $forceunitoutput < 90)
+ {
+ $dimension = // convert dimension from standard unit into ounce or pound
+ $unit = $forceunitoutput;
+ }*/
$ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
@@ -5838,7 +5867,7 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__THIRDPARTY_NAME_ALIAS__'] = '__THIRDPARTY_NAME_ALIAS__';
$substitutionarray['__THIRDPARTY_EMAIL__'] = '__THIRDPARTY_EMAIL__';
- if (is_object($object) && $object->element == 'member')
+ if (! empty($conf->adherent->enabled))
{
$substitutionarray['__MEMBER_ID__'] = '__MEMBER_ID__';
$substitutionarray['__MEMBER_CIVILITY__'] = '__MEMBER_CIVILITY__';
@@ -5866,9 +5895,9 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = 'Direct download url of an order';
$substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = 'Direct download url of an invoice';
- if (is_object($object) && $object->element == 'shipping')
+ if (! empty($conf->expedition->enabled))
{
- $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number';
+ $substitutionarray['__SHIPPINGTRACKNUM__']='Shipping tacking number';
$substitutionarray['__SHIPPINGTRACKNUMURL__']='Shipping tracking url';
}
}
@@ -5876,38 +5905,41 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
{
$substitutionarray['__ID__'] = $object->id;
$substitutionarray['__REF__'] = $object->ref;
- $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : ''));
- $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : '');
+ $substitutionarray['__REFCLIENT__'] = (isset($object->ref_client) ? $object->ref_client : (isset($object->ref_customer) ? $object->ref_customer : null));
+ $substitutionarray['__REFSUPPLIER__'] = (isset($object->ref_supplier) ? $object->ref_supplier : null);
// TODO Remove this
$msgishtml = 0;
$birthday = dol_print_date($object->birth,'day');
- $substitutionarray['__MEMBER_ID__']=$object->id;
- if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
- $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname;
- $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname;
- if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs);
- $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe;
- $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address;
- $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip;
- $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town;
- $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country;
- $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email;
- $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday;
- $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo;
- $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login;
- $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass;
- $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone;
- $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso;
- $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile;
- $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc');
- $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc');
- $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc');
- $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc');
- $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc');
- $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc');
+ if ($object->id > 0)
+ {
+ $substitutionarray['__MEMBER_ID__']=$object->id;
+ if (method_exists($object, 'getCivilityLabel')) $substitutionarray['__MEMBER_CIVILITY__'] = $object->getCivilityLabel();
+ $substitutionarray['__MEMBER_FIRSTNAME__']=$msgishtml?dol_htmlentitiesbr($object->firstname):$object->firstname;
+ $substitutionarray['__MEMBER_LASTNAME__']=$msgishtml?dol_htmlentitiesbr($object->lastname):$object->lastname;
+ if (method_exists($object, 'getFullName')) $substitutionarray['__MEMBER_FULLNAME__']=$msgishtml?dol_htmlentitiesbr($object->getFullName($outputlangs)):$object->getFullName($outputlangs);
+ $substitutionarray['__MEMBER_COMPANY__']=$msgishtml?dol_htmlentitiesbr($object->societe):$object->societe;
+ $substitutionarray['__MEMBER_ADDRESS__']=$msgishtml?dol_htmlentitiesbr($object->address):$object->address;
+ $substitutionarray['__MEMBER_ZIP__']=$msgishtml?dol_htmlentitiesbr($object->zip):$object->zip;
+ $substitutionarray['__MEMBER_TOWN__']=$msgishtml?dol_htmlentitiesbr($object->town):$object->town;
+ $substitutionarray['__MEMBER_COUNTRY__']=$msgishtml?dol_htmlentitiesbr($object->country):$object->country;
+ $substitutionarray['__MEMBER_EMAIL__']=$msgishtml?dol_htmlentitiesbr($object->email):$object->email;
+ $substitutionarray['__MEMBER_BIRTH__']=$msgishtml?dol_htmlentitiesbr($birthday):$birthday;
+ $substitutionarray['__MEMBER_PHOTO__']=$msgishtml?dol_htmlentitiesbr($object->photo):$object->photo;
+ $substitutionarray['__MEMBER_LOGIN__']=$msgishtml?dol_htmlentitiesbr($object->login):$object->login;
+ $substitutionarray['__MEMBER_PASSWORD__']=$msgishtml?dol_htmlentitiesbr($object->pass):$object->pass;
+ $substitutionarray['__MEMBER_PHONE__']=$msgishtml?dol_htmlentitiesbr($object->phone):$object->phone;
+ $substitutionarray['__MEMBER_PHONEPRO__']=$msgishtml?dol_htmlentitiesbr($object->phone_perso):$object->phone_perso;
+ $substitutionarray['__MEMBER_PHONEMOBILE__']=$msgishtml?dol_htmlentitiesbr($object->phone_mobile):$object->phone_mobile;
+ $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE__'] = dol_print_date($object->first_subscription_date, 'dayrfc');
+ $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->first_subscription_date_start, 'dayrfc');
+ $substitutionarray['__MEMBER_FIRST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->first_subscription_date_end, 'dayrfc');
+ $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE__'] = dol_print_date($object->last_subscription_date, 'dayrfc');
+ $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_START__'] = dol_print_date($object->last_subscription_date_start, 'dayrfc');
+ $substitutionarray['__MEMBER_LAST_SUBSCRIPTION_DATE_END__'] = dol_print_date($object->last_subscription_date_end, 'dayrfc');
+ }
if (is_object($object) && $object->element == 'societe')
{
@@ -5939,17 +5971,20 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
if (is_object($object) && $object->element == 'contrat' && is_array($object->lines))
{
- $dateplannedstart='';
- $datenextexpiration='';
- foreach($object->lines as $line)
+ if ($object->id > 0)
{
- if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
- if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
+ $dateplannedstart='';
+ $datenextexpiration='';
+ foreach($object->lines as $line)
+ {
+ if ($line->date_ouverture_prevue > $dateplannedstart) $dateplannedstart = $line->date_ouverture_prevue;
+ if ($line->statut == 4 && $line->date_fin_prevue && (! $datenextexpiration || $line->date_fin_prevue < $datenextexpiration)) $datenextexpiration = $line->date_fin_prevue;
+ }
+ $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
+ $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
+ $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
+ $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
- $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATE__'] = dol_print_date($dateplannedstart, 'dayrfc');
- $substitutionarray['__CONTRACT_HIGHEST_PLANNED_START_DATETIME__'] = dol_print_date($dateplannedstart, 'standard');
- $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATE__'] = dol_print_date($datenextexpiration, 'dayrfc');
- $substitutionarray['__CONTRACT_LOWEST_EXPIRATION_DATETIME__'] = dol_print_date($datenextexpiration, 'standard');
}
// Create dynamic tags for __EXTRAFIELD_FIELD__
@@ -5988,30 +6023,33 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
$paymenturl=$url;
}
- $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):'');
- $substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl;
+ if ($object->id > 0)
+ {
+ $substitutionarray['__ONLINE_PAYMENT_TEXT_AND_URL__']=($paymenturl?str_replace('\n', "\n", $outputlangs->trans("PredefinedMailContentLink", $paymenturl)):'');
+ $substitutionarray['__ONLINE_PAYMENT_URL__']=$paymenturl;
- if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal')
- {
- $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
+ if (! empty($conf->global->PROPOSAL_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'propal')
+ {
+ $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = $object->getLastMainDocLink($object->element);
+ }
+ else $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
+ if (! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande')
+ {
+ $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
+ }
+ else $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
+ if (! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture')
+ {
+ $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
+ }
+ else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
}
- else $substitutionarray['__DIRECTDOWNLOAD_URL_PROPOSAL__'] = '';
- if (! empty($conf->global->ORDER_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'commande')
- {
- $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = $object->getLastMainDocLink($object->element);
- }
- else $substitutionarray['__DIRECTDOWNLOAD_URL_ORDER__'] = '';
- if (! empty($conf->global->INVOICE_ALLOW_EXTERNAL_DOWNLOAD) && is_object($object) && $object->element == 'facture')
- {
- $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = $object->getLastMainDocLink($object->element);
- }
- else $substitutionarray['__DIRECTDOWNLOAD_URL_INVOICE__'] = '';
}
}
if (empty($exclude) || ! in_array('objectamount', $exclude))
{
- $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : '') : '';
- $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement)? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : '') : '';
+ $substitutionarray['__DATE_YMD__'] = is_object($object)?(isset($object->date) ? dol_print_date($object->date, 'day', 0, $outputlangs) : null) : '';
+ $substitutionarray['__DATE_DUE_YMD__'] = is_object($object)?(isset($object->date_lim_reglement) ? dol_print_date($object->date_lim_reglement, 'day', 0, $outputlangs) : null) : '';
$substitutionarray['__AMOUNT__'] = is_object($object)?$object->total_ttc:'';
$substitutionarray['__AMOUNT_EXCL_TAX__'] = is_object($object)?$object->total_ht:'';
@@ -6019,11 +6057,11 @@ function getCommonSubstitutionArray($outputlangs, $onlykey=0, $exclude=null, $ob
if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2__'] = is_object($object)?$object->total_localtax1:'';
if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3__'] = is_object($object)?$object->total_localtax2:'';
- $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency):'';
- $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency):'';
- $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat?price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency):price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency)):'';
- if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)?price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency):'';
- if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)?price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency):'';
+ $substitutionarray['__AMOUNT_FORMATED__'] = is_object($object)?($object->total_ttc ? price($object->total_ttc, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):'';
+ $substitutionarray['__AMOUNT_EXCL_TAX_FORMATED__'] = is_object($object)?($object->total_ht ? price($object->total_ht, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):'';
+ $substitutionarray['__AMOUNT_VAT_FORMATED__'] = is_object($object)?($object->total_vat ? price($object->total_vat, 0, $outputlangs, 0, 0, -1, $conf->currency): ($object->total_tva ? price($object->total_tva, 0, $outputlangs, 0, 0, -1, $conf->currency) : null)):'';
+ if ($onlykey != 2 || $mysoc->useLocalTax(1)) $substitutionarray['__AMOUNT_TAX2_FORMATED__'] = is_object($object)? ($object->total_localtax1 ? price($object->total_localtax1, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):'';
+ if ($onlykey != 2 || $mysoc->useLocalTax(2)) $substitutionarray['__AMOUNT_TAX3_FORMATED__'] = is_object($object)? ($object->total_localtax2 ? price($object->total_localtax2, 0, $outputlangs, 0, 0, -1, $conf->currency) : null):'';
// TODO Add keys for foreign multicurrency
@@ -6134,10 +6172,12 @@ function make_substitutions($text, $substitutionarray, $outputlangs=null)
// Make substitition for array $substitutionarray
foreach ($substitutionarray as $key => $value)
{
+ if (! isset($value)) continue; // If value is null, it same than not having substitution key at all into array, we do not replace.
+
if ($key == '__SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection
if ($key == '__USER_SIGNATURE__' && (! empty($conf->global->MAIN_MAIL_DO_NOT_USE_SIGN))) $value=''; // Protection
- $text=str_replace("$key","$value",$text); // We must keep the " to work when value is 123.5 for example
+ $text=str_replace("$key", "$value", $text); // We must keep the " to work when value is 123.5 for example
}
return $text;
@@ -7145,7 +7185,7 @@ function printCommonFooter($zone='private')
if ($zone == 'private' && empty($conf->dol_use_jmobile))
{
print "\n";
- print '/* JS CODE TO ENABLE to enable handler to switch left menu page (menuhider) */'."\n";
+ print '/* JS CODE TO ENABLE to manage handler to switch left menu page (menuhider) */'."\n";
print 'jQuery(".menuhider").click(function() {';
print ' console.log("We click on .menuhider");'."\n";
//print " $('.side-nav').animate({width:'toggle'},200);\n"; // OK with eldy theme but not with md
@@ -7155,9 +7195,9 @@ function printCommonFooter($zone='private')
}
// Management of focus and mandatory for fields
- if ($action == 'create' || $action == 'edit')
+ if ($action == 'create' || $action == 'edit' || (empty($action) && (preg_match('/new\.php/', $_SERVER["PHP_SELF"]))))
{
- print '/* Code js to manage focus and mandatory form fields */'."\n";
+ print '/* JS CODE TO ENABLE to manage focus and mandatory form fields */'."\n";
$relativepathstring = $_SERVER["PHP_SELF"];
// Clean $relativepathstring
if (constant('DOL_URL_ROOT')) $relativepathstring = preg_replace('/^'.preg_quote(constant('DOL_URL_ROOT'),'/').'/', '', $relativepathstring);
@@ -7186,8 +7226,10 @@ function printCommonFooter($zone='private')
{
foreach($defval as $paramkey => $paramval)
{
- // Add property 'required' on input
+ // Set focus on field
print 'jQuery("input[name=\''.$paramkey.'\']").focus();'."\n";
+ print 'jQuery("textarea[name=\''.$paramkey.'\']").focus();'."\n";
+ print 'jQuery("select[name=\''.$paramkey.'\']").focus();'."\n"; // Not really usefull, but we keep it in case of.
}
}
}
@@ -7216,6 +7258,7 @@ function printCommonFooter($zone='private')
{
// Add property 'required' on input
print 'jQuery("input[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
+ print 'jQuery("textarea[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n";
print 'jQuery("select[name=\''.$paramkey.'\']").prop(\'required\',true);'."\n"; // required on a select works only if key is "", this does not happen in Dolibarr
}
}
diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php
index 247fbb20c14..4490a59d055 100644
--- a/htdocs/core/lib/pdf.lib.php
+++ b/htdocs/core/lib/pdf.lib.php
@@ -728,7 +728,7 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$cury+=3;
}
- if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enought for them
+ if (empty($conf->global->PDF_BANK_HIDE_NUMBER_SHOW_ONLY_BICIBAN)) // Note that some countries still need bank number, BIC/IBAN not enougth for them
{
// Note:
// bank = code_banque (FR), sort code (GB, IR. Example: 12-34-56)
diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php
index 84d32725682..8b6ca6a5ca3 100644
--- a/htdocs/core/lib/project.lib.php
+++ b/htdocs/core/lib/project.lib.php
@@ -52,9 +52,44 @@ function project_prepare_head($object)
$head[$h][2] = 'contact';
$h++;
+ if (empty($conf->global->PROJECT_HIDE_TASKS))
+ {
+ // Then tab for sub level of projet, i mean tasks
+ $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id;
+ $head[$h][1] = $langs->trans("Tasks");
+
+ require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
+ $taskstatic=new Task($db);
+ $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
+ if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).'';
+ $head[$h][2] = 'tasks';
+ $h++;
+
+ $nbTimeSpent=0;
+ $sql = "SELECT t.rowid";
+ //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
+ //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
+ $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt";
+ $sql .= " WHERE t.fk_task = pt.rowid";
+ $sql .= " AND pt.fk_projet =".$object->id;
+ $resql = $db->query($sql);
+ if ($resql)
+ {
+ $obj = $db->fetch_object($resql);
+ if ($obj) $nbTimeSpent=1;
+ }
+ else dol_print_error($db);
+
+ $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id;
+ $head[$h][1] = $langs->trans("TimeSpent");
+ if ($nbTimeSpent > 0) $head[$h][1].= ' ...';
+ $head[$h][2] = 'timespent';
+ $h++;
+ }
+
if (! empty($conf->fournisseur->enabled) || ! empty($conf->propal->enabled) || ! empty($conf->commande->enabled)
- || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled)
- || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled))
+ || ! empty($conf->facture->enabled) || ! empty($conf->contrat->enabled)
+ || ! empty($conf->ficheinter->enabled) || ! empty($conf->agenda->enabled) || ! empty($conf->deplacement->enabled))
{
$head[$h][0] = DOL_URL_ROOT.'/projet/element.php?id='.$object->id;
$head[$h][1] = $langs->trans("ProjectOverview");
@@ -92,41 +127,6 @@ function project_prepare_head($object)
$head[$h][2] = 'document';
$h++;
- if (empty($conf->global->PROJECT_HIDE_TASKS))
- {
- // Then tab for sub level of projet, i mean tasks
- $head[$h][0] = DOL_URL_ROOT.'/projet/tasks.php?id='.$object->id;
- $head[$h][1] = $langs->trans("Tasks");
-
- require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
- $taskstatic=new Task($db);
- $nbTasks=count($taskstatic->getTasksArray(0, 0, $object->id, 0, 0));
- if ($nbTasks > 0) $head[$h][1].= ' '.($nbTasks).'';
- $head[$h][2] = 'tasks';
- $h++;
-
- $nbTimeSpent=0;
- $sql = "SELECT t.rowid";
- //$sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt, ".MAIN_DB_PREFIX."user as u";
- //$sql .= " WHERE t.fk_user = u.rowid AND t.fk_task = pt.rowid";
- $sql .= " FROM ".MAIN_DB_PREFIX."projet_task_time as t, ".MAIN_DB_PREFIX."projet_task as pt";
- $sql .= " WHERE t.fk_task = pt.rowid";
- $sql .= " AND pt.fk_projet =".$object->id;
- $resql = $db->query($sql);
- if ($resql)
- {
- $obj = $db->fetch_object($resql);
- if ($obj) $nbTimeSpent=1;
- }
- else dol_print_error($db);
-
- $head[$h][0] = DOL_URL_ROOT.'/projet/tasks/time.php?withproject=1&projectid='.$object->id;
- $head[$h][1] = $langs->trans("TimeSpent");
- if ($nbTimeSpent > 0) $head[$h][1].= ' ...';
- $head[$h][2] = 'timespent';
- $h++;
- }
-
// Manage discussion
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
{
@@ -1205,7 +1205,7 @@ function projectLinesPerWeek(&$inc, $firstdaytoshow, $fuser, $parent, $lines, &$
{
continue;
}
-
+
// Break on a new project
if ($parent == 0 && $lines[$i]->fk_project != $lastprojectid)
{
diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php
index 83e90114bb6..e98484707c0 100644
--- a/htdocs/core/lib/security.lib.php
+++ b/htdocs/core/lib/security.lib.php
@@ -483,9 +483,9 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
{
$sql.= ",".MAIN_DB_PREFIX."usergroup_user as ug";
$sql.= " WHERE dbt.".$dbt_select." IN (".$objectid.")";
- $sql.= " AND (ug.fk_user = dbt.rowid";
- $sql.= " AND ug.entity IN (".getEntity('user')."))";
- $sql.= " OR dbt.entity = 0"; // Show always superadmin
+ $sql.= " AND ((ug.fk_user = dbt.rowid";
+ $sql.= " AND ug.entity IN (".getEntity('usergroup')."))";
+ $sql.= " OR dbt.entity = 0)"; // Show always superadmin
}
}
else {
diff --git a/htdocs/core/lib/usergroups.lib.php b/htdocs/core/lib/usergroups.lib.php
index 033d4eb37fe..5747c0a5c0e 100644
--- a/htdocs/core/lib/usergroups.lib.php
+++ b/htdocs/core/lib/usergroups.lib.php
@@ -467,6 +467,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '';
print ' | ';
+ print '
';
}
// Background color THEME_ELDY_BACKBODY
@@ -513,6 +514,7 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $form->textwithpicto('', $langs->trans("NotSupportedByAllThemes").', '.$langs->trans("PressF5AfterChangingThis"));
print '';
print '';
+ print '