diff --git a/.travis.yml b/.travis.yml
index dfeb209bfc3..7b8fa4546b2 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -403,8 +403,9 @@ script:
php step5.php 12.0.0 13.0.0 > $TRAVIS_BUILD_DIR/upgrade12001300-3.log
# Enable modules not enabled into original dump
- php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP > $TRAVIS_BUILD_DIR/enablemodule.log
- php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT > $TRAVIS_BUILD_DIR/enablemodule.log
+ php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_API,MAIN_MODULE_PRODUCTBATCH,MAIN_MODULE_SUPPLIERPROPOSAL,MAIN_MODULE_STRIPE > $TRAVIS_BUILD_DIR/enablemodule.log
+ php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_WEBSITE,MAIN_MODULE_TICKET,MAIN_MODULE_ACCOUNTING,MAIN_MODULE_MRP >> $TRAVIS_BUILD_DIR/enablemodule.log
+ php upgrade2.php 0.0.0 0.0.0 MAIN_MODULE_RECEPTION,MAIN_MODULE_RECRUITMENT >> $TRAVIS_BUILD_DIR/enablemodule.log
echo $?
cd -
set +e
diff --git a/ChangeLog b/ChangeLog
index 8b3b3c97157..322372ab8a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -16,7 +16,7 @@ NEW: Accountancy - add options to disable binding on sales, purchases & expense
NEW: Accountancy balance - add a menu entry to show subtotal by group
NEW: Accountancy - change menu disposition
NEW: Accountancy - on transfers, select the periodicity by default
-NEW: Accountancy - Add export for Gestinum (v3 & v5)
+NEW: Accountancy - Add export for Gestinum (v3 & v5) #15180
NEW: new currency rate editor
NEW: Solve blocking feature. Can increase stock of a Kit without changing subproduct stock.
NEW: add a widget to show the customers with outstanding limits reached
@@ -163,7 +163,7 @@ NEW: Support for Samba4 AD
NEW: TakePOS connector compatibility with RECEIPT PRINTERS module
NEW: TakePOS Gift Receipt
NEW: TakePOS Multicurrency compatibility
-NEW: the global header of a website can also have dynamic content
+NEW: TakePOS Weighing Scale compatibility with TakePOS connector #14725
NEW: Third-Party Import new fields: mother company,outstanding debt limit,bank account,incoterms
NEW: Thirdparty module : box on customer/supplier tab for invoice outsantding amount late
NEW: ticket classification on create from email collector
@@ -173,11 +173,11 @@ NEW: VAT rate for Angola #15606
NEW: VAT and juridical status for Algeria
NEW: VAT report - Invert constant to show by default zero VAT in reports
NEW: website page fields selection
-NEW: Weighing Scale compatibility with TakePOS connector
+NEW: website - global header of a website can also have dynamic content
NEW: when creating a user from a member linked to a thirdparty, you can choose to create it as external or internal user
-NEW: add clone button on miscellaneous payment
-NEW: #15065 Add option to put the product label in bold in the PDF templates if configured
-NEW: Add option "If the feature to manage kits of module Stock is used, show details of subproducts of a kit on PDF."
+NEW: add clone button on miscellaneous payment
+NEW: add option to put the product label in bold in the PDF templates if configured #15065
+NEW: add option "If the feature to manage kits of module Stock is used, show details of subproducts of a kit on PDF."
For developers:
diff --git a/htdocs/accountancy/bookkeeping/balance.php b/htdocs/accountancy/bookkeeping/balance.php
index 7ac795b784b..b049abb7652 100644
--- a/htdocs/accountancy/bookkeeping/balance.php
+++ b/htdocs/accountancy/bookkeeping/balance.php
@@ -88,6 +88,7 @@ if (empty($search_date_start) && !GETPOSTISSET('formfilteraction'))
} else {
$month_start = ($conf->global->SOCIETE_FISCAL_MONTH_START ? ($conf->global->SOCIETE_FISCAL_MONTH_START) : 1);
$year_start = dol_print_date(dol_now(), '%Y');
+ if (dol_print_date(dol_now(), '%m') < $month_start) $year_start--; // If current month is lower that starting fiscal month, we start last year
$year_end = $year_start + 1;
$month_end = $month_start - 1;
if ($month_end < 1)
diff --git a/htdocs/admin/dict.php b/htdocs/admin/dict.php
index d06f8a2ce31..62e95b2c001 100644
--- a/htdocs/admin/dict.php
+++ b/htdocs/admin/dict.php
@@ -621,6 +621,7 @@ if ($id == 11)
// 'contract' => $langs->trans('Contract'),
'project' => $langs->trans('Project'),
'project_task' => $langs->trans('Task'),
+ 'ticket' => $langs->trans('Ticket'),
'agenda' => $langs->trans('Agenda'),
'dolresource' => $langs->trans('Resource'),
// old deprecated
@@ -692,7 +693,7 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($value == 'sortorder') continue; // For a column name 'sortorder', we use the field name 'position'
if ((!GETPOSTISSET($value) || GETPOST($value) == '')
&& (!in_array($listfield[$f], array('decalage', 'module', 'accountancy_code', 'accountancy_code_sell', 'accountancy_code_buy', 'tracking', 'picto')) // Fields that are not mandatory
- && (!($id == 10 && $listfield[$f] == 'code')) // Code is mandatory fir table 10
+ && ($id != 10 || ($listfield[$f] != 'code' && $listfield[$f] != 'note')) // Field code and note is not mandatory for dictionary table 10
)
) {
$ok = 0;
@@ -757,9 +758,9 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
if ($_POST["accountancy_code"] <= 0) $_POST["accountancy_code"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_sell"] <= 0) $_POST["accountancy_code_sell"] = ''; // If empty, we force to null
if ($_POST["accountancy_code_buy"] <= 0) $_POST["accountancy_code_buy"] = ''; // If empty, we force to null
- if ($id == 10 && GETPOSTISSET("code")) // Spaces are not allowed into code
+ if ($id == 10 && GETPOSTISSET("code")) // Spaces are not allowed into code for tax dictionary
{
- $_POST["code"] = preg_replace('/\s/', '', $_POST["code"]);
+ $_POST["code"] = preg_replace('/[^a-zA-Z0-9\-\+]/', '', $_POST["code"]);
}
// If check ok and action add, add the line
@@ -826,8 +827,13 @@ if (GETPOST('actionadd') || GETPOST('actionmodify'))
$result = $db->query($sql);
if ($result) // Add is ok
{
- setEventMessages($langs->transnoentities("RecordSaved"), null, 'mesgs');
- $_POST = array('id'=>$id); // Clean $_POST array, we keep only
+ setEventMessages($langs->transnoentities("RecordCreatedSuccessfully"), null, 'mesgs');
+
+ // Clean $_POST array, we keep only id of dictionary
+ if ($id == 10 && GETPOST('country', 'int') > 0) {
+ $search_country_id = GETPOST('country', 'int');
+ }
+ $_POST = array('id'=>$id);
} else {
if ($db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
setEventMessages($langs->transnoentities("ErrorRecordAlreadyExists"), null, 'errors');
@@ -1487,11 +1493,9 @@ if ($id)
continue;
}
- if ($value == 'element')
- {
+ if ($value == 'element') {
$valuetoshow = isset($elementList[$valuetoshow]) ? $elementList[$valuetoshow] : $valuetoshow;
- } elseif ($value == 'source')
- {
+ } elseif ($value == 'source') {
$valuetoshow = isset($sourceList[$valuetoshow]) ? $sourceList[$valuetoshow] : $valuetoshow;
} elseif ($valuetoshow == 'all') {
$valuetoshow = $langs->trans('All');
diff --git a/htdocs/bom/bom_card.php b/htdocs/bom/bom_card.php
index 5c170d0aa72..38e8b601cf6 100644
--- a/htdocs/bom/bom_card.php
+++ b/htdocs/bom/bom_card.php
@@ -181,8 +181,10 @@ if (empty($reshook))
unset($_POST['qty_frozen']);
unset($_POST['disable_stock_change']);
- $object->fetchLines();
- }
+ $object->fetchLines();
+
+ $object->calculateCosts();
+ }
}
}
@@ -221,7 +223,9 @@ if (empty($reshook))
unset($_POST['qty_frozen']);
unset($_POST['disable_stock_change']);
- $object->fetchLines();
+ $object->fetchLines();
+
+ $object->calculateCosts();
}
}
}
diff --git a/htdocs/bom/tpl/objectline_create.tpl.php b/htdocs/bom/tpl/objectline_create.tpl.php
index d29cdb7c6bb..1f0a00cb4b8 100644
--- a/htdocs/bom/tpl/objectline_create.tpl.php
+++ b/htdocs/bom/tpl/objectline_create.tpl.php
@@ -113,7 +113,6 @@ if (!empty($conf->global->PRODUCT_USE_UNITS))
{
$coldisplay++;
print '
';
}
diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php
index 33f7f3a0352..467f6b7b78b 100644
--- a/htdocs/compta/bank/line.php
+++ b/htdocs/compta/bank/line.php
@@ -58,11 +58,15 @@ if ($user->socid) $socid = $user->socid;
$result = restrictedArea($user, 'banque', $fieldvalue, 'bank_account', '', '', $fieldtype);
if (!$user->rights->banque->lire && !$user->rights->banque->consolidate) accessforbidden();
+$hookmanager->initHooks(array('bankline'));
+
/*
* Actions
*/
-
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($cancel)
{
if ($backtopage)
diff --git a/htdocs/compta/bank/transfer.php b/htdocs/compta/bank/transfer.php
index 7e1b7fd0567..5aeec4f444c 100644
--- a/htdocs/compta/bank/transfer.php
+++ b/htdocs/compta/bank/transfer.php
@@ -40,11 +40,14 @@ if (!$user->rights->banque->transfer)
$action = GETPOST('action', 'aZ09');
$error = 0;
+$hookmanager->initHooks(array('banktransfer'));
/*
* Actions
*/
-
+$parameters = array('socid' => $socid);
+$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
+if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if ($action == 'add')
{
$langs->load("errors");
diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php
index a03fd03ffef..83393a52cb6 100644
--- a/htdocs/compta/paiement.php
+++ b/htdocs/compta/paiement.php
@@ -710,10 +710,10 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie
// Price
print '
'.price($sign * $objp->total_ttc).'
';
- // Received or paid back
+ // Received + already paid
print '
'.price($sign * $paiement);
- if ($creditnotes) print '+'.price($creditnotes);
- if ($deposits) print '+'.price($deposits);
+ if ($creditnotes) print '+'.price($creditnotes).'';
+ if ($deposits) print '+'.price($deposits).'';
print '
';
// Remain to take or to pay back
diff --git a/htdocs/contact/card.php b/htdocs/contact/card.php
index 752bdc4d642..0726e2c33e2 100644
--- a/htdocs/contact/card.php
+++ b/htdocs/contact/card.php
@@ -638,7 +638,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action))
print '
";
}
diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php
index 64f8fd92477..9ec2e04ee5c 100644
--- a/htdocs/contrat/card.php
+++ b/htdocs/contrat/card.php
@@ -374,8 +374,7 @@ if (empty($reshook))
$action = 'create';
}
}
- } elseif ($action == 'classin' && $user->rights->contrat->creer)
- {
+ } elseif ($action == 'classin' && $user->rights->contrat->creer) {
$object->setProject(GETPOST('projectid'));
}
diff --git a/htdocs/core/boxes/box_fournisseurs.php b/htdocs/core/boxes/box_fournisseurs.php
index 44e2682585e..7d1c72b3036 100644
--- a/htdocs/core/boxes/box_fournisseurs.php
+++ b/htdocs/core/boxes/box_fournisseurs.php
@@ -137,10 +137,13 @@ class box_fournisseurs extends ModeleBoxes
$line++;
}
- if ($num == 0) $this->info_box_contents[$line][0] = array(
- 'td' => 'class="center opacitymedium"',
- 'text'=>$langs->trans("NoRecordedSuppliers"),
- );
+ if ($num == 0) {
+ $langs->load("suppliers");
+ $this->info_box_contents[$line][0] = array(
+ 'td' => 'class="center opacitymedium"',
+ 'text'=>$langs->trans("NoRecordedSuppliers"),
+ );
+ }
$this->db->free($result);
} else {
diff --git a/htdocs/core/boxes/box_shipments.php b/htdocs/core/boxes/box_shipments.php
index 5a1f093ce87..22b28d42761 100644
--- a/htdocs/core/boxes/box_shipments.php
+++ b/htdocs/core/boxes/box_shipments.php
@@ -105,6 +105,7 @@ class box_shipments extends ModeleBoxes
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON e.fk_soc = sc.fk_soc";
$sql .= " WHERE e.entity IN (".getEntity('expedition').")";
if (!empty($conf->global->ORDER_BOX_LAST_SHIPMENTS_VALIDATED_ONLY)) $sql .= " AND e.fk_statut = 1";
+ if ($user->socid > 0) $sql.= " AND s.rowid = ".$user->socid;
if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND sc.fk_user = ".$user->id;
else $sql .= " ORDER BY e.date_delivery, e.ref DESC ";
$sql .= $this->db->plimit($max, 0);
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 47c025b0c0a..af0a625875f 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -6845,6 +6845,7 @@ abstract class CommonObject
break;
}
+ // Output value of the current field
if ($extrafields->attributes[$this->table_element]['type'][$key] == 'separate')
{
$extrafields_collapse_num = '';
diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php
index a1800e03980..3191e5edd47 100644
--- a/htdocs/core/class/conf.class.php
+++ b/htdocs/core/class/conf.class.php
@@ -102,6 +102,8 @@ class Conf
public $liste_limit;
+ public $tzuserinputkey = 'tzserver'; // Use 'tzuserrel' to always store date in GMT and show date in time zone of user.
+
/**
* Constructor
@@ -693,6 +695,8 @@ class Conf
if (defined('MAIN_ANTIVIRUS_COMMAND')) $this->global->MAIN_ANTIVIRUS_COMMAND = constant('MAIN_ANTIVIRUS_COMMAND');
if (defined('MAIN_ANTIVIRUS_PARAM')) $this->global->MAIN_ANTIVIRUS_PARAM = constant('MAIN_ANTIVIRUS_PARAM');
+ if (!empty($this->global->MAIN_TZUSERINPUTKEY)) $this->tzuserinputkey = $this->global->MAIN_TZUSERINPUTKEY; // 'tzserver' or 'tzuserrel'
+
// For backward compatibility
if (isset($this->product)) $this->produit = $this->product;
if (isset($this->facture)) $this->invoice = $this->facture;
diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php
index 4ed39694720..ed0511a8e1d 100644
--- a/htdocs/core/class/html.form.class.php
+++ b/htdocs/core/class/html.form.class.php
@@ -5531,13 +5531,18 @@ class Form
* @param int $stepminutes Specify step for minutes between 1 and 30
* @param string $labeladddateof Label to use for the $adddateof parameter.
* @param string $placeholder Placeholder
+ * @param mixed $gm 'auto', 'gmt' or 'tzserver' or 'tzuserrel'
* @return string Html for selectDate
* @see form_date(), select_month(), select_year(), select_dayofweek()
*/
- public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '')
+ public function selectDate($set_time = '', $prefix = 're', $h = 0, $m = 0, $empty = 0, $form_name = "", $d = 1, $addnowlink = 0, $disabled = 0, $fullday = '', $addplusone = '', $adddateof = '', $openinghours = '', $stepminutes = 1, $labeladddateof = '', $placeholder = '', $gm = 'auto')
{
global $conf, $langs;
+ if ($gm == 'auto') {
+ $gm = $conf->tzuserinputkey;
+ }
+
$retstring = '';
if ($prefix == '') $prefix = 're';
@@ -5553,7 +5558,11 @@ class Form
if ($set_time === '' && $emptydate == 0)
{
include_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
- $set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone
+ if ($gm == 'tzuser' || $gm == 'tzuserrel') {
+ $set_time = dol_now($gm);
+ } else {
+ $set_time = dol_now('tzuser') - (getServerTimeZoneInt('now') * 3600); // set_time must be relative to PHP server timezone
+ }
}
// Analysis of the pre-selection date
@@ -5569,14 +5578,14 @@ class Form
} elseif (strval($set_time) != '' && $set_time != -1)
{
// set_time est un timestamps (0 possible)
- $syear = dol_print_date($set_time, "%Y");
- $smonth = dol_print_date($set_time, "%m");
- $sday = dol_print_date($set_time, "%d");
+ $syear = dol_print_date($set_time, "%Y", $gm);
+ $smonth = dol_print_date($set_time, "%m", $gm);
+ $sday = dol_print_date($set_time, "%d", $gm);
if ($orig_set_time != '')
{
- $shour = dol_print_date($set_time, "%H");
- $smin = dol_print_date($set_time, "%M");
- $ssec = dol_print_date($set_time, "%S");
+ $shour = dol_print_date($set_time, "%H", $gm);
+ $smin = dol_print_date($set_time, "%M", $gm);
+ $ssec = dol_print_date($set_time, "%S", $gm);
} else {
$shour = '';
$smin = '';
diff --git a/htdocs/core/db/DoliDB.class.php b/htdocs/core/db/DoliDB.class.php
index 48bcbab6f3e..e900af925f4 100644
--- a/htdocs/core/db/DoliDB.class.php
+++ b/htdocs/core/db/DoliDB.class.php
@@ -84,13 +84,14 @@ abstract class DoliDB implements Database
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica
*
- * @param int $param Date TMS to convert
- * @return string Date in a string YYYY-MM-DD HH:MM:SS
+ * @param int $param Date TMS to convert
+ * @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ
+ * @return string Date in a string YYYY-MM-DD HH:MM:SS
*/
- public function idate($param)
+ public function idate($param, $gm = 'tzserver')
{
- // TODO GMT $param should be gmt, so we should add tzouptut to 'gmt'
- return dol_print_date($param, "%Y-%m-%d %H:%M:%S", 'tzserver');
+ // TODO $param should be gmt, so we should add $gm to 'gmt' instead of default 'tzserver'
+ return dol_print_date($param, "%Y-%m-%d %H:%M:%S", $gm);
}
/**
@@ -285,12 +286,12 @@ abstract class DoliDB implements Database
* 19700101020000 -> 7200 whaterver is TZ if gmt=1
*
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
- * @param bool $gm 1=Input informations are GMT values, otherwise local to server TZ
+ * @param mixed $gm 'gmt'=Input informations are GMT values, 'tzserver'=Local to server TZ
* @return int|string Date TMS or ''
*/
- public function jdate($string, $gm = false)
+ public function jdate($string, $gm = 'tzserver')
{
- // TODO GMT must set param gm to true by default
+ // TODO $string should be converted into a GMT timestamp, so param gm should be set to true by default instead of false
if ($string == 0 || $string == "0000-00-00 00:00:00") return '';
$string = preg_replace('/([^0-9])/i', '', $string);
$tmp = $string.'000000';
diff --git a/htdocs/core/db/pgsql.class.php b/htdocs/core/db/pgsql.class.php
index b393945eeb3..fe80f1ad28e 100644
--- a/htdocs/core/db/pgsql.class.php
+++ b/htdocs/core/db/pgsql.class.php
@@ -685,18 +685,6 @@ class DoliDBPgsql extends DoliDB
return pg_escape_string($stringtoencode);
}
- /**
- * Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field.
- * Function to use to build INSERT, UPDATE or WHERE predica
- *
- * @param string $param Date TMS to convert
- * @return string Date in a string YYYY-MM-DD HH:MM:SS
- */
- public function idate($param)
- {
- return dol_print_date($param, "%Y-%m-%d %H:%M:%S");
- }
-
/**
* Format a SQL IF
*
diff --git a/htdocs/core/lib/admin.lib.php b/htdocs/core/lib/admin.lib.php
index 13f59c45ba8..f3faeda4b3a 100644
--- a/htdocs/core/lib/admin.lib.php
+++ b/htdocs/core/lib/admin.lib.php
@@ -1438,9 +1438,15 @@ function complete_elementList_with_modules(&$elementList)
$dirmod[$i] = $dir;
//print "x".$modName." ".$orders[$i]."\n ";
- if (!empty($objMod->module_parts['contactelement'])) {
- $elementList[$objMod->name] = $langs->trans($objMod->name);
- }
+ if (!empty($objMod->module_parts['contactelement'])) {
+ if (is_array($objMod->module_parts['contactelement'])) {
+ foreach ($objMod->module_parts['contactelement'] as $elem => $title) {
+ $elementList[$elem] = $langs->trans($title);
+ }
+ } else {
+ $elementList[$objMod->name] = $langs->trans($objMod->name);
+ }
+ }
$j++;
$i++;
diff --git a/htdocs/core/lib/date.lib.php b/htdocs/core/lib/date.lib.php
index 163f6d85b6d..3a889367dc1 100644
--- a/htdocs/core/lib/date.lib.php
+++ b/htdocs/core/lib/date.lib.php
@@ -465,9 +465,10 @@ function dol_get_next_week($day, $week, $month, $year)
*
* @param int $year Year
* @param int $month Month
- * @param mixed $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
- * Exemple: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00
- * Exemple: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00
+ * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
+ * True or 1 or 'gmt' to compare with GMT date.
+ * Example: dol_get_first_day(1970,1,false) will return -3600 with TZ+1, a dol_print_date on it will return 1970-01-01 00:00:00
+ * Example: dol_get_first_day(1970,1,true) will return 0 whatever is TZ, a dol_print_date on it will return 1970-01-01 00:00:00
* @return int Date for first day, '' if error
*/
function dol_get_first_day($year, $month = 1, $gm = false)
@@ -481,7 +482,8 @@ function dol_get_first_day($year, $month = 1, $gm = false)
*
* @param int $year Year
* @param int $month Month
- * @param boolean $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
+ * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
+ * True or 1 or 'gmt' to compare with GMT date.
* @return int Date for first day, '' if error
*/
function dol_get_last_day($year, $month = 12, $gm = false)
@@ -529,7 +531,8 @@ function dol_get_first_hour($date)
* @param int $day Day
* @param int $month Month
* @param int $year Year
- * @param int $gm False or 0 or 'server' = Return date to compare with server TZ, True or 1 to compare with GM date.
+ * @param mixed $gm False or 0 or 'tzserver' = Return date to compare with server TZ,
+ * True or 1 or 'gmt' to compare with GMT date.
* @return array year,month,week,first_day,first_month,first_year,prev_day,prev_month,prev_year
*/
function dol_get_first_day_week($day, $month, $year, $gm = false)
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 8c1765620ec..4ded311f7ed 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -680,7 +680,8 @@ function checkVal($out = '', $check = 'alphanohtml', $filter = null, $options =
if (!is_array($out)) {
// '"' 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 = str_replace(array('"', '"'), "''", trim($out));
+ $out = str_replace(array('../'), '', $out);
// keep lines feed
$out = dol_string_nohtmltag($out, 0);
}
@@ -1971,10 +1972,14 @@ function dol_strftime($fmt, $ts = false, $is_gmt = false)
*
* @see dol_mktime(), dol_stringtotime(), dol_getdate()
*/
-function dol_print_date($time, $format = '', $tzoutput = 'tzserver', $outputlangs = '', $encodetooutput = false)
+function dol_print_date($time, $format = '', $tzoutput = 'auto', $outputlangs = '', $encodetooutput = false)
{
global $conf, $langs;
+ if ($tzoutput == 'auto') {
+ $tzoutput = $conf->tzuserinputkey;
+ }
+
// Clean parameters
$to_gmt = false;
$offsettz = $offsetdst = 0;
@@ -2183,18 +2188,24 @@ function dol_getdate($timestamp, $fast = false, $forcetimezone = '')
* @param int $day Day (1 to 31)
* @param int $year Year
* @param mixed $gm True or 1 or 'gmt'=Input informations are GMT values
- * False or 0 or 'server' = local to server TZ
- * 'user' = local to user TZ
+ * False or 0 or 'tzserver' = local to server TZ
+ * 'auto'
+ * 'tzuser' = local to user TZ taking dst into account at the current date. Not yet implemented.
+ * 'tzuserrel' = local to user TZ taking dst into account at the given date. Use this one to convert date input from user.
* 'tz,TimeZone' = use specified timezone
* @param int $check 0=No check on parameters (Can use day 32, etc...)
* @return int|string Date as a timestamp, '' or false if error
* @see dol_print_date(), dol_stringtotime(), dol_getdate()
*/
-function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $check = 1)
+function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = 'auto', $check = 1)
{
global $conf;
//print "- ".$hour.",".$minute.",".$second.",".$month.",".$day.",".$year.",".$_SERVER["WINDIR"]." -";
+ if ($gm == 'auto') {
+ $gm = $conf->tzuserinputkey;
+ }
+
// Clean parameters
if ($hour == -1 || empty($hour)) $hour = 0;
if ($minute == -1 || empty($minute)) $minute = 0;
@@ -2211,11 +2222,11 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $
if ($second < 0 || $second > 60) return '';
}
- if (empty($gm) || $gm === 'server')
+ if (empty($gm) || ($gm === 'server' || $gm === 'tzserver'))
{
$default_timezone = @date_default_timezone_get(); // Example 'Europe/Berlin'
$localtz = new DateTimeZone($default_timezone);
- } elseif ($gm === 'user')
+ } elseif ($gm === 'user' || $gm === 'tzuser' || $gm === 'tzuserrel')
{
// We use dol_tz_string first because it is more reliable.
$default_timezone = (empty($_SESSION["dol_tz_string"]) ? @date_default_timezone_get() : $_SESSION["dol_tz_string"]); // Example 'Europe/Berlin'
@@ -2254,16 +2265,21 @@ function dol_mktime($hour, $minute, $second, $month, $day, $year, $gm = false, $
/**
* Return date for now. In most cases, we use this function without parameters (that means GMT time).
*
- * @param string $mode 'gmt' => we return GMT timestamp,
+ * @param string $mode 'auto'
+ * 'gmt' => we return GMT timestamp,
* 'tzserver' => we add the PHP server timezone
- * 'tzref' => we add the company timezone
- * 'tzuser' => we add the user timezone
+ * 'tzref' => we add the company timezone. Not implemented.
+ * 'tzuser' or 'tzuserrel' => we add the user timezone
* @return int $date Timestamp
*/
-function dol_now($mode = 'gmt')
+function dol_now($mode = 'auto')
{
$ret = 0;
+ if ($mode == 'auto') {
+ $mode = 'tzserver';
+ }
+
if ($mode == 'gmt') $ret = time(); // Time for now at greenwich.
elseif ($mode == 'tzserver') // Time for now with PHP server timezone added
{
@@ -2276,7 +2292,7 @@ function dol_now($mode = 'gmt')
$tzsecond=getParentCompanyTimeZoneInt(); // Contains tz+dayling saving time
$ret=dol_now('gmt')+($tzsecond*3600);
}*/
- elseif ($mode == 'tzuser') // Time for now with user timezone added
+ elseif ($mode == 'tzuser' || $mode == 'tzuserrel') // Time for now with user timezone added
{
//print 'time: '.time();
$offsettz = (empty($_SESSION['dol_tz']) ? 0 : $_SESSION['dol_tz']) * 60 * 60;
@@ -4600,7 +4616,7 @@ function print_fleche_navigation($page, $file, $options = '', $nextpage = 0, $be
}
if ((int) $limit > 0 && empty($hideselectlimit))
{
- $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000';
+ $pagesizechoices = '10:10,15:15,20:20,30:30,40:40,50:50,100:100,250:250,500:500,1000:1000,5000:5000,25000:25000';
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
//$pagesizechoices.=',2:2';
if (!empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices = $conf->global->MAIN_PAGESIZE_CHOICES;
diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php
index a77f38f8f66..ffc79b8f4b4 100644
--- a/htdocs/core/lib/functions2.lib.php
+++ b/htdocs/core/lib/functions2.lib.php
@@ -246,8 +246,8 @@ function dol_print_object_info($object, $usetable = 0)
print $langs->trans("DateCreation");
if ($usetable) print '