From bd2e2c5c75288b28388e7b146e7ed177eccf4533 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 6 Dec 2023 16:18:28 +0100 Subject: [PATCH] FIX #26944 --- htdocs/compta/sociales/card.php | 5 + .../sociales/class/chargesociales.class.php | 12 ++- htdocs/intracommreport/card.php | 97 +------------------ .../class/intracommreport.class.php | 6 +- 4 files changed, 20 insertions(+), 100 deletions(-) diff --git a/htdocs/compta/sociales/card.php b/htdocs/compta/sociales/card.php index 70b39fde0fb..564de96b4f4 100644 --- a/htdocs/compta/sociales/card.php +++ b/htdocs/compta/sociales/card.php @@ -201,6 +201,7 @@ if (empty($reshook)) { $object->label = GETPOST('label', 'alpha'); $object->date_ech = $dateech; $object->periode = $dateperiod; + $object->period = $dateperiod; $object->amount = $amount; $object->fk_user = $fk_user; $object->mode_reglement_id = (int) GETPOST('mode_reglement_id', 'int'); @@ -236,6 +237,7 @@ if (empty($reshook)) { $object->date_ech = $dateech; $object->periode = $dateperiod; + $object->period = $dateperiod; $object->amount = $amount; $object->fk_user = $fk_user; @@ -271,6 +273,7 @@ if (empty($reshook)) { if (GETPOST('clone_for_next_month', 'int')) { // This can be true only if TAX_ADD_CLONE_FOR_NEXT_MONTH_CHECKBOX has been set $object->periode = dol_time_plus_duree($object->periode, 1, 'm'); + $object->period = dol_time_plus_duree($object->periode, 1, 'm'); $object->date_ech = dol_time_plus_duree($object->date_ech, 1, 'm'); } else { // Note date_ech is often a little bit higher than dateperiod @@ -278,6 +281,7 @@ if (empty($reshook)) { $newdateech = dol_mktime(0, 0, 0, GETPOST('clone_date_echmonth', 'int'), GETPOST('clone_date_echday', 'int'), GETPOST('clone_date_echyear', 'int')); if ($newdateperiod) { $object->periode = $newdateperiod; + $object->period = $newdateperiod; if (empty($newdateech)) { $object->date_ech = $object->periode; } @@ -288,6 +292,7 @@ if (empty($reshook)) { // TODO We can here get dol_get_last_day of previous month: // $object->periode = dol_get_last_day(year of $object->date_ech - 1m, month or $object->date_ech -1m) $object->periode = $object->date_ech; + $object->period = $object->date_ech; } } } diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index 909072fb459..246e92e0031 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -66,7 +66,11 @@ class ChargeSociales extends CommonObject public $type_label; public $amount; public $paye; + /** + * @deprecated + */ public $periode; + public $period; /** * @var integer|string date_creation @@ -149,7 +153,7 @@ class ChargeSociales extends CommonObject public function fetch($id, $ref = '') { $sql = "SELECT cs.rowid, cs.date_ech"; - $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode, cs.import_key"; + $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key"; $sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user, note_public, note_private"; $sql .= ", c.libelle as type_label"; $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; @@ -186,7 +190,8 @@ class ChargeSociales extends CommonObject $this->note_public = $obj->note_public; $this->note_private = $obj->note_private; $this->paye = $obj->paye; - $this->periode = $this->db->jdate($obj->periode); + $this->periode = $this->db->jdate($obj->period); + $this->period = $this->db->jdate($obj->period); $this->import_key = $this->import_key; $this->db->free($resql); @@ -211,7 +216,7 @@ class ChargeSociales extends CommonObject $newamount = price2num($this->amount, 'MT'); // Validation of parameters - if ($newamount == 0 || empty($this->date_ech) || empty($this->periode)) { + if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) { return false; } @@ -744,6 +749,7 @@ class ChargeSociales extends CommonObject $this->date_creation = dol_now(); $this->date_ech = $this->date_creation + 3600 * 24 * 30; $this->periode = $this->date_creation + 3600 * 24 * 30; + $this->period = $this->date_creation + 3600 * 24 * 30; $this->amount = 100; $this->label = 'Social contribution label'; $this->type = 1; diff --git a/htdocs/intracommreport/card.php b/htdocs/intracommreport/card.php index 554be07eb97..9409ae0d40f 100644 --- a/htdocs/intracommreport/card.php +++ b/htdocs/intracommreport/card.php @@ -267,7 +267,7 @@ if ($id > 0 && $action != 'edit') { // Type print ''.$langs->trans("Type").''.$object->declaration."\n"; - // Analysis Period + // Analysis period print ''.$langs->trans("AnalysisPeriod").''.$object->period.''; print ''; @@ -283,101 +283,6 @@ if ($id > 0 && $action != 'edit') { print dol_get_fiche_end(); } - /* - switch($action) { - case 'generateXML': - $obj = new TDebProdouane($PDOdb); - $obj->load($PDOdb, GETPOST('id_declaration')); - $obj->generateXMLFile(); - break; - case 'list': - _liste($exporttype); - break; - case 'export': - if ($exporttype == 'deb') _export_xml_deb($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); - else _export_xml_des($type_declaration, $year, str_pad($month, 2, 0, STR_PAD_LEFT)); - default: - if ($exporttype == 'deb') _print_form_deb(); - else _print_form_des(); - break; - } - - function _print_form_des() - { - global $langs, $formother, $year, $month, $type_declaration; - - print load_fiche_titre($langs->trans("IntracommReportDESTitle")); - - print dol_get_fiche_head(); - - print '
'; - print ''; - print ''; - print ''; - print ''; // Permet d'utiliser le bon select de la requête sql - - print ''; - - print ''; - - print ''; - print ''; - print ''; - print ''; - - print '
'; - print 'Paramètres de l\'export'; - print '
Période d\'analyse'; - $TabMonth = array(); - for($i=1;$i<=12;$i++) $TabMonth[$i] = $langs->trans('Month'.str_pad($i, 2, 0, STR_PAD_LEFT)); - //print $ATMform->combo('','month', $TabMonth, empty($month) ? date('m') : $month); - print $formother->selectyear(empty($year) ? date('Y') : $year,'year',0, 20, 5); - print '
'; - - print '
'; - print ''; - print '
'; - - print '
'; - } - - function _export_xml_deb($type_declaration, $period_year, $period_month) { - - global $db, $conf; - - $obj = new TDebProdouane($db); - $obj->entity = $conf->entity; - $obj->mode = 'O'; - $obj->periode = $period_year.'-'.$period_month; - $obj->type_declaration = $type_declaration; - $obj->numero_declaration = $obj->getNextNumeroDeclaration(); - $obj->content_xml = $obj->getXML('O', $type_declaration, $period_year.'-'.$period_month); - if(empty($obj->errors)) { - $obj->save($PDOdb); - $obj->generateXMLFile(); - } - else setEventMessage($obj->errors, 'warnings'); - } - - function _export_xml_des($type_declaration, $period_year, $period_month) { - - global $PDOdb, $conf; - - $obj = new TDebProdouane($PDOdb); - $obj->entity = $conf->entity; - $obj->periode = $period_year.'-'.$period_month; - $obj->type_declaration = $type_declaration; - $obj->exporttype = 'des'; - $obj->numero_declaration = $obj->getNextNumeroDeclaration(); - $obj->content_xml = $obj->getXMLDes($period_year, $period_month, $type_declaration); - if(empty($obj->errors)) { - $obj->save($PDOdb); - $obj->generateXMLFile(); - } - else setEventMessage($obj->errors, 'warnings'); - } - */ - // End of page llxFooter(); $db->close(); diff --git a/htdocs/intracommreport/class/intracommreport.class.php b/htdocs/intracommreport/class/intracommreport.class.php index 28efdbf08fd..7512813ebae 100644 --- a/htdocs/intracommreport/class/intracommreport.class.php +++ b/htdocs/intracommreport/class/intracommreport.class.php @@ -482,8 +482,11 @@ class IntracommReport extends CommonObject */ public function generateXMLFile() { - $name = $this->periode.'.xml'; + $name = $this->period.'.xml'; + + // TODO Must be stored into a dolibarr temp directory $fname = sys_get_temp_dir().'/'.$name; + $f = fopen($fname, 'w+'); fwrite($f, $this->content_xml); fclose($f); @@ -495,6 +498,7 @@ class IntracommReport extends CommonObject header('Cache-Control: must-revalidate'); header('Pragma: public'); header('Content-Length: '.filesize($fname)); + readfile($fname); exit; }