diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 87830593714..9bd2d022ace 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -2120,7 +2120,7 @@ class Contrat extends CommonObject
$this->from.= ", ".MAIN_DB_PREFIX."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $this->from.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
- if ($mode == 'inactives')
+ if ($mode == 'inactive')
{
$sql = "SELECT cd.rowid, cd.date_ouverture_prevue as datefin";
$sql.= $this->from;
@@ -2135,25 +2135,43 @@ class Contrat extends CommonObject
$sql.= " WHERE c.statut = 1";
$sql.= " AND c.rowid = cd.fk_contrat";
$sql.= " AND cd.statut = 4";
- $sql.= " AND cd.date_fin_validite < '".$this->db->idate(time())."'";
+ $sql.= " AND cd.date_fin_validite < '".$this->db->idate(dol_now())."'";
+ }
+ elseif ($mode == 'active')
+ {
+ $sql = "SELECT cd.rowid, cd.date_fin_validite as datefin";
+ $sql.= $this->from;
+ $sql.= " WHERE c.statut = 1";
+ $sql.= " AND c.rowid = cd.fk_contrat";
+ $sql.= " AND cd.statut = 4";
+ //$datetouse = dol_now();
+ //$sql.= " AND cd.date_fin_validite < '".$this->db->idate($datetouse)."'";
}
$sql.= " AND c.fk_soc = s.rowid";
$sql.= " AND c.entity = ".$conf->entity;
if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id;
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql.= " AND c.fk_soc = sc.fk_soc AND sc.fk_user = " .$user->id;
+
$resql=$this->db->query($sql);
if ($resql)
{
$langs->load("contracts");
$now=dol_now();
- if ($mode == 'inactives') {
+ if ($mode == 'inactive') {
$warning_delay = $conf->contrat->services->inactifs->warning_delay;
$label = $langs->trans("BoardNotActivatedServices");
- $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0';
+ $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=0&sortfield=cd.date_fin_validite&sortorder=asc';
+ }
+ elseif ($mode == 'expired') {
+ $warning_delay = $conf->contrat->services->expires->warning_delay;
+ $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired&sortfield=cd.date_fin_validite&sortorder=asc';
+ $label = $langs->trans("BoardExpiredServices");
} else {
$warning_delay = $conf->contrat->services->expires->warning_delay;
- $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&filter=expired';
+ $url = DOL_URL_ROOT.'/contrat/services_list.php?mainmenu=commercial&leftmenu=contracts&mode=4&sortfield=cd.date_fin_validite&sortorder=asc';
+ //$url.= '&op2day='.$arraydatetouse['mday'].'&op2month='.$arraydatetouse['mon'].'&op2year='.$arraydatetouse['year'];
+ //if ($warning_delay >= 0) $url.='&filter=expired';
$label = $langs->trans("BoardRunningServices");
}
diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php
index 22683ab0993..b39c3839c71 100644
--- a/htdocs/core/class/html.formmail.class.php
+++ b/htdocs/core/class/html.formmail.class.php
@@ -710,7 +710,7 @@ class FormMail extends Form
}
else
{
- $out.= 'withtocc) : (isset($_POST["sendtocc"])?$_POST["sendtocc"]:"") ).'" />';
+ $out.= 'withtocc) && ! is_numeric($this->withtocc)) ? $this->withtocc : '')).'" />';
if (! empty($this->withtocc) && is_array($this->withtocc))
{
$out.= " ".$langs->trans("and")."/".$langs->trans("or")." ";
@@ -1022,7 +1022,7 @@ class FormMail extends Form
if (! empty($this->withtocccreadonly)) {
$out.= (! is_array($this->withtoccc) && ! is_numeric($this->withtoccc))?$this->withtoccc:"";
} else {
- $out.= 'withtoccc) : (isset($_POST["sendtoccc"])?$_POST["sendtoccc"]:"") ).'" />';
+ $out.= 'withtoccc) && ! is_numeric($this->withtoccc)) ? $this->withtoccc : '')).'" />';
if (! empty($this->withtoccc) && is_array($this->withtoccc)) {
$out.= " ".$langs->trans("and")."/".$langs->trans("or")." ";
// multiselect array convert html entities into options tags, even if we dont want this, so we encode them a second time
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 3f5480ee455..80aeb83b064 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -307,7 +307,7 @@ function GETPOST($paramname, $check = 'none', $method = 0, $filter = null, $opti
}
if (! empty($conf->global->MAIN_ENABLE_DEFAULT_VALUES))
{
- if (! empty($_GET['action']) && preg_match('/^create/', $_GET['action']) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
+ if (! empty($_GET['action']) && (preg_match('/^create/', $_GET['action']) || preg_match('/^presend/', $_GET['action'])) && ! isset($_GET[$paramname]) && ! isset($_POST[$paramname]))
{
// Now search in setup to overwrite default values
if (! empty($user->default_values)) // $user->default_values defined from menu 'Setup - Default values'
diff --git a/htdocs/index.php b/htdocs/index.php
index 9c78693a68e..ce59ad4f476 100644
--- a/htdocs/index.php
+++ b/htdocs/index.php
@@ -433,9 +433,9 @@ if (! empty($conf->contrat->enabled) && $user->rights->contrat->lire)
{
include_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php';
$board=new Contrat($db);
- $dashboardlines[] = $board->load_board($user, "inactives");
+ $dashboardlines[] = $board->load_board($user, "inactive");
// Number of active services (expired)
- $dashboardlines[] = $board->load_board($user, "expired");
+ $dashboardlines[] = $board->load_board($user, "active");
}
// Number of invoices customers (has paid)
if (! empty($conf->facture->enabled) && $user->rights->facture->lire)
diff --git a/htdocs/langs/en_US/contracts.lang b/htdocs/langs/en_US/contracts.lang
index 51b73423fb0..129b7d8416a 100644
--- a/htdocs/langs/en_US/contracts.lang
+++ b/htdocs/langs/en_US/contracts.lang
@@ -64,7 +64,8 @@ DateStartRealShort=Real start date
DateEndReal=Real end date
DateEndRealShort=Real end date
CloseService=Close service
-BoardRunningServices=Expired running services
+BoardRunningServices=Services running
+BoardExpiredServices=Services expired
ServiceStatus=Status of service
DraftContracts=Drafts contracts
CloseRefusedBecauseOneServiceActive=Contract can't be closed as there is at least one open service on it