diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php
index 285fe5df739..2417a61ba8d 100644
--- a/htdocs/contrat/class/contrat.class.php
+++ b/htdocs/contrat/class/contrat.class.php
@@ -1676,10 +1676,10 @@ class Contrat extends CommonObject
}
/**
- * Mets a jour une ligne de contrat
+ * Update a contract line
*
- * @param int $rowid Id de la ligne de facture
- * @param string $desc Description de la ligne
+ * @param int $rowid Id of contract line
+ * @param string $desc Description of line
* @param float $pu Prix unitaire
* @param float $qty Quantite
* @param float $remise_percent Percentage discount of the line
@@ -1701,7 +1701,7 @@ class Contrat extends CommonObject
*/
public function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx, $localtax1tx = 0.0, $localtax2tx = 0.0, $date_start_real = '', $date_end_real = '', $price_base_type = 'HT', $info_bits = 0, $fk_fournprice = null, $pa_ht = 0, $array_options = array(), $fk_unit = null, $rang = 0)
{
- global $user, $conf, $langs, $mysoc;
+ global $user, $langs, $mysoc;
$error = 0;
@@ -1822,7 +1822,16 @@ class Contrat extends CommonObject
}
}
- // TODO Update column llx_contrat.denormalized_lower_panned_end_date
+ // Update column llx_contrat.denormalized_lower_panned_end_date with next expiration date of an open contract
+ $sqltoupdatecontract = "UPDATE ".MAIN_DB_PREFIX."contrat as c";
+ $sqltoupdatecontract .= " SET c.denormalized_lower_planned_end_date = (SELECT MIN(date_fin_validite) FROM ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = ".((int) $this->id)." AND cd.statut = ".ContratLigne::STATUS_OPEN.")";
+ $sqltoupdatecontract .= " WHERE c.rowid = ".((int) $this->id);
+ $resqltoupdatecontract = $this->db->query($sqltoupdatecontract);
+ if (!$resqltoupdatecontract) {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -1;
+ }
if (empty($error)) {
// Call trigger
@@ -2763,7 +2772,6 @@ class Contrat extends CommonObject
// Load contract
$object = new Contrat($this->db);
$object->fetch($obj->rowid); // fetch also lines
- //$object->fetch_thirdparty();
if ($object->id <= 0) {
$error++;
@@ -2832,8 +2840,16 @@ class Contrat extends CommonObject
if ($resqlupdate) {
$contractlineprocessed[$obj->lid] = $object->ref;
- // TODO Update column llx_contrat.denormalized_lower_panned_end_date
-
+ // Update column llx_contrat.denormalized_lower_panned_end_date with next expiration date of an open contract
+ $sqltoupdatecontract = "UPDATE ".MAIN_DB_PREFIX."contrat as c";
+ $sqltoupdatecontract .= " SET c.denormalized_lower_planned_end_date = (SELECT MIN(date_fin_validite) FROM ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = ".((int) $object->id)." AND cd.statut = ".ContratLigne::STATUS_OPEN.")";
+ $sqltoupdatecontract .= " WHERE c.rowid = ".((int) $object->id);
+ $resqltoupdatecontract = $this->db->query($sqltoupdatecontract);
+ if (!$resqltoupdatecontract) {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -1;
+ }
$actioncode = 'RENEW_CONTRACT';
$now = dol_now();
diff --git a/htdocs/contrat/class/contratligne.class.php b/htdocs/contrat/class/contratligne.class.php
index e24726cc116..18c36bcc622 100644
--- a/htdocs/contrat/class/contratligne.class.php
+++ b/htdocs/contrat/class/contratligne.class.php
@@ -915,13 +915,14 @@ class ContratLigne extends CommonObjectLine
$this->db->begin();
$this->statut = ContratLigne::STATUS_OPEN;
+ $this->status = ContratLigne::STATUS_OPEN;
$this->date_start_real = $date;
$this->date_end = $date_end;
$this->fk_user_ouverture = $user->id;
$this->date_end_real = null;
$this->commentaire = $comment;
- $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".((int) $this->statut).",";
+ $sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = ".((int) $this->status).",";
$sql .= " date_ouverture = ".(dol_strlen((string) $this->date_start_real) != 0 ? "'".$this->db->idate($this->date_start_real)."'" : "null").",";
if ($date_end >= 0) {
$sql .= " date_fin_validite = ".(dol_strlen($this->date_end) != 0 ? "'".$this->db->idate($this->date_end)."'" : "null").",";
@@ -935,7 +936,16 @@ class ContratLigne extends CommonObjectLine
$resql = $this->db->query($sql);
if ($resql) {
if ($date_end >= 0) {
- // TODO Update column llx_contrat.denormalized_lower_panned_end_date
+ // Update column llx_contrat.denormalized_lower_panned_end_date with next expiration date of an open contract
+ $sqltoupdatecontract = "UPDATE ".MAIN_DB_PREFIX."contrat as c";
+ $sqltoupdatecontract .= " SET c.denormalized_lower_planned_end_date = (SELECT MIN(date_fin_validite) FROM ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = ".((int) $this->fk_contrat)." AND cd.statut = ".ContratLigne::STATUS_OPEN.")";
+ $sqltoupdatecontract .= " WHERE c.rowid = ".((int) $this->fk_contrat);
+ $resqltoupdatecontract = $this->db->query($sqltoupdatecontract);
+ if (!$resqltoupdatecontract) {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -1;
+ }
}
// Call trigger
@@ -991,6 +1001,17 @@ class ContratLigne extends CommonObjectLine
$resql = $this->db->query($sql);
if ($resql) {
+ // Update column llx_contrat.denormalized_lower_panned_end_date with next expiration date of an open contract
+ $sqltoupdatecontract = "UPDATE ".MAIN_DB_PREFIX."contrat as c";
+ $sqltoupdatecontract .= " SET c.denormalized_lower_planned_end_date = (SELECT MIN(date_fin_validite) FROM ".MAIN_DB_PREFIX."contratdet as cd WHERE cd.fk_contrat = ".((int) $this->fk_contrat)." AND cd.statut = ".ContratLigne::STATUS_OPEN.")";
+ $sqltoupdatecontract .= " WHERE c.rowid = ".((int) $this->fk_contrat);
+ $resqltoupdatecontract = $this->db->query($sqltoupdatecontract);
+ if (!$resqltoupdatecontract) {
+ $this->error = $this->db->lasterror();
+ $this->db->rollback();
+ return -1;
+ }
+
if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('LINECONTRACT_CLOSE', $user);
diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php
index 3596c294d67..82b3802e680 100644
--- a/htdocs/core/class/commonobjectline.class.php
+++ b/htdocs/core/class/commonobjectline.class.php
@@ -24,6 +24,8 @@
* \brief File of the superclass of classes of lines of business objects (invoice, contract, proposal, orders, etc. ...)
*/
+require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
+
/**
* Parent class for class inheritance lines of business objects
diff --git a/htdocs/install/repair.php b/htdocs/install/repair.php
index 3c4cc83700d..5ad0d3577aa 100644
--- a/htdocs/install/repair.php
+++ b/htdocs/install/repair.php
@@ -56,6 +56,7 @@ if (file_exists($conffile)) {
require_once $dolibarr_main_document_root.'/core/lib/admin.lib.php';
include_once $dolibarr_main_document_root.'/core/lib/images.lib.php';
require_once $dolibarr_main_document_root.'/core/class/extrafields.class.php';
+require_once $dolibarr_main_document_root.'/core/class/html.form.class.php';
require_once 'lib/repair.lib.php';
$ok = 0;
@@ -94,6 +95,8 @@ if (!is_object($conf)) {
* View
*/
+$form = new Form($db);
+
pHeader($langs->trans("Repair"), "upgrade2", GETPOST('action', 'aZ09'));
// Action to launch the repair script
@@ -219,7 +222,8 @@ $sections = [
],
[
'name' => 'repair_mailing_path',
- 'info' => 'Repair path of mailing files.
Should be applied when using emailing module with > 99 mailings.
In that case, please also set MAILING_USE_NEW_PATH_FOR_FILES.'
+ 'info' => 'Repair path of mailing files',
+ 'tooltip' => 'Should be applied when using emailing module with > 99 mailings. In that case, please also set MAILING_USE_NEW_PATH_FOR_FILES.'
]
],
'Clean tables and data' => [
@@ -280,18 +284,27 @@ $sections = [
]
];
+$conf->use_javascript_ajax = 1;
+
foreach ($sections as $section => $options) {
print '
| '.$langs->trans("PleaseBePatient").' |
*** Update denormalized_lower_planned_end_date. | |
*** Check fields into extra table structure match table of definition. If not add column into table | |
*** Check that fields into the extra table structure match the table of definition. If not, add column into table |