From 383281e5f3029bf3b3a519e51e4cb3af6e6dc68b Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Mon, 18 Jan 2021 11:32:02 +0100 Subject: [PATCH 001/200] New update of funnel of prospection --- .../core/boxes/box_funnel_of_prospection.php | 26 ++- htdocs/core/class/dolgraph.class.php | 194 ++++++++++++------ 2 files changed, 148 insertions(+), 72 deletions(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 5b6130d8eb2..6d8acdb52bd 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -96,6 +96,7 @@ class box_funnel_of_prospection extends ModeleBoxes $listofopplabel = array(); $listofoppcode = array(); $colorseriesstat = array(); + $bordercolorseries = array(); $sql = "SELECT cls.rowid, cls.code, cls.percent, cls.label"; $sql .= " FROM " . MAIN_DB_PREFIX . "c_lead_status as cls"; $sql .= " WHERE active=1"; @@ -113,19 +114,24 @@ class box_funnel_of_prospection extends ModeleBoxes $listofoppcode[$objp->rowid] = $objp->code; switch ($objp->code) { case 'PROSP': - $colorseriesstat[$objp->rowid] = "-" . $badgeStatus0; + $colorseriesstat[$objp->rowid] = '#FFFFFF'; + $bordercolorseries[$objp->rowid] = $badgeStatus0; break; case 'QUAL': - $colorseriesstat[$objp->rowid] = "-" . $badgeStatus1; + $colorseriesstat[$objp->rowid] = '#FFFFFF'; + $bordercolorseries[$objp->rowid] = $badgeStatus1; break; case 'PROPO': $colorseriesstat[$objp->rowid] = $badgeStatus1; + $bordercolorseries[$objp->rowid] = $badgeStatus1; break; case 'NEGO': $colorseriesstat[$objp->rowid] = $badgeStatus4; + $bordercolorseries[$objp->rowid] = $badgeStatus4; break; case 'WON': $colorseriesstat[$objp->rowid] = $badgeStatus6; + $bordercolorseries[$objp->rowid] = $badgeStatus6; break; default: break; @@ -191,7 +197,10 @@ class box_funnel_of_prospection extends ModeleBoxes $listofstatus = array_keys($listofoppstatus); $liststatus = array(); $data = array(''); + $customlabels = array(); + $total=0; foreach ($listofstatus as $status) { + $customlabel = ''; $labelStatus = ''; if ($status != 7) { $code = dol_getIdFromCode($this->db, $status, 'c_lead_status', 'rowid', 'code'); @@ -201,8 +210,9 @@ class box_funnel_of_prospection extends ModeleBoxes if (empty($labelStatus)) { $labelStatus = $listofopplabel[$status]; } - - $data[] = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0); + $amount = (isset($valsamount[$status]) ? (float) $valsamount[$status] : 0); + $data[] = $amount; + $customlabel = $amount; $liststatus[] = $labelStatus; if (!$conf->use_javascript_ajax) { $stringtoprint .= ''; @@ -211,6 +221,7 @@ class box_funnel_of_prospection extends ModeleBoxes $stringtoprint .= "\n"; } } + $customlabels[]=$customlabel; } $dataseries[] = $data; if ($conf->use_javascript_ajax) { @@ -219,13 +230,18 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph->SetMinValue(0); $dolgraph->SetData($dataseries); $dolgraph->SetLegend($liststatus); + $dolgraph->SetHideXValues(true); $dolgraph->SetDataColor(array_values($colorseriesstat)); + $dolgraph->SetBorderColor(array_values($bordercolorseries)); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); - $dolgraph->setTitle(''); + $dolgraph->SetMirrorGraphValues(true); + $dolgraph->SetBorderWidth(2); $dolgraph->SetType(array('horizontalbars')); $dolgraph->SetHeight('200'); $dolgraph->SetWidth('600'); + $dolgraph->SetTooltipsTitles($liststatus); + $dolgraph->SetTooltipsLabels($customlabels); $dolgraph->mode = 'depth'; $dolgraph->draw('idgraphleadfunnel'); $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index e880e186e5b..1bc9f175171 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -66,6 +66,7 @@ class DolGraph public $labelInterval = -1; public $hideXGrid = false; + public $hideXValues = false; public $hideYGrid = false; public $Legend = array(); @@ -75,6 +76,12 @@ class DolGraph public $showpercent = 0; public $combine = 0; // 0.05 if you want to combine records < 5% into "other" public $graph; // Objet Graph (Artichow, Phplot...) + /** + * @var boolean Mirrors graph values + */ + public $mirrorGraphValues = false; + public $tooltipsTitles = null; + public $tooltipsLabels = null; /** * @var string Error code (or message) @@ -85,6 +92,7 @@ class DolGraph public $bgcolor; // array(R,G,B) public $bgcolorgrid = array(255, 255, 255); // array(R,G,B) public $datacolor; // array(array(R,G,B),...) + public $borderwidth = 1; private $stringtoshow; // To store string to output graph into HTML page @@ -175,6 +183,20 @@ class DolGraph return true; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Hide X Values + * + * @param boolean $bool XValues or not + * @return boolean true + */ + public function SetHideXValues($bool) + { + // phpcs:enable + $this->hideXValues = $bool; + return true; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide Y grid @@ -244,9 +266,9 @@ class DolGraph // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Set data + * Set data color * - * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) + * @param array $datacolor Data color array(array(R,G,B),array(R,G,B)...) or array('#......','#......'...) * @return void */ public function SetDataColor($datacolor) @@ -255,6 +277,56 @@ class DolGraph $this->datacolor = $datacolor; } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set border color + * + * @param array $bordercolor Border Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...) + * @return void + */ + public function SetBorderColor($bordercolor) + { + $this->bordercolor = $bordercolor; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set border width + * + * @param int $borderwidth Border Width + * @return void + */ + public function SetBorderWidth($borderwidth) + { + $this->borderwidth = $borderwidth; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set tooltips labels of the graph + * + * @param array $tooltipsLabels Tooltips Labels array('...','...'...) + * @return void + */ + public function SetTooltipsLabels($tooltipsLabels) + { + // phpcs:enable + $this->tooltipsLabels = $tooltipsLabels; + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Set tooltips titles of the graph + * + * @param array $tooltipsTitles Tooltips Titles array('...','...'...) + * @return void + */ + public function SetTooltipsTitles($tooltipsTitles) + { + // phpcs:enable + $this->tooltipsTitles = $tooltipsTitles; + } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set type @@ -408,6 +480,18 @@ class DolGraph unset($this->bgcolorgrid); } + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Mirror Values of the graph + * + * @param boolean $mirrorGraphValues Mirror Values if true and doesn't if false + * @return void + */ + public function SetMirrorGraphValues($mirrorGraphValues) + { + $this->mirrorGraphValues = $mirrorGraphValues; + } + /** * Is graph ko * @@ -1129,9 +1213,6 @@ class DolGraph else { $type = 'bar'; - $isfunnel = false; - if ($file == 'idgraphleadfunnel') $isfunnel = true; - if (!isset($this->type[$firstlot]) || $this->type[$firstlot] == 'bars') $type = 'bar'; if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'horizontalbars') $type = 'horizontalBar'; if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'lines' || $this->type[$firstlot] == 'linesnopoint')) $type = 'line'; @@ -1141,7 +1222,7 @@ class DolGraph $this->stringtoshow .= 'legend: { display: false }, '; } $this->stringtoshow .= 'scales: { xAxes: [{ '; - if ($isfunnel) { // FIXME Remove isfunnel by introducing a method hideXValues() on dolgraph + if ($this->hideXValues) { $this->stringtoshow .= ' ticks: { display: false }, display: true,'; } //$this->stringtoshow .= 'type: \'time\', '; // Need Moment.js @@ -1156,17 +1237,23 @@ class DolGraph } $this->stringtoshow .= ' }] }'; // Add a callback to change label to show only positive value - if ($isfunnel) { + if (is_array($this->tooltipsLabels) || is_array($this->tooltipsTitles)) { $this->stringtoshow .= ', tooltips: { mode: \'nearest\', - callbacks: { - title: function(tooltipItem, data) { - return data.datasets[tooltipItem[0].datasetIndex].label; - }, - label: function(tooltipItem, data) { - return data.datasets[tooltipItem.datasetIndex].data[0][1]; - } - } - },'; + callbacks: {'; + if (is_array($this->tooltipsTitles)) { + $this->stringtoshow .=' + title: function(tooltipItem, data) { + var tooltipsTitle ='.json_encode($this->tooltipsTitles).' + return tooltipsTitle[tooltipItem[0].datasetIndex]; + },'; + } + if (is_array($this->tooltipsLabels)) { + $this->stringtoshow .= 'label: function(tooltipItem, data) { + var tooltipslabels ='.json_encode($this->tooltipsLabels).' + return tooltipslabels[tooltipItem.datasetIndex] + }'; + } + $this->stringtoshow .='}},'; } $this->stringtoshow .= '};'; $this->stringtoshow .= ' @@ -1180,13 +1267,11 @@ class DolGraph labels: ['; $i = 0; - if (!$isfunnel) { - foreach ($legends as $val) // Loop on each serie - { - if ($i > 0) $this->stringtoshow .= ', '; - $this->stringtoshow .= "'".dol_escape_js(dol_trunc($val, 32))."'"; - $i++; - } + foreach ($legends as $val) // Loop on each serie + { + if ($i > 0) $this->stringtoshow .= ', '; + $this->stringtoshow .= "'" . dol_escape_js(dol_trunc($val, 32)) . "'"; + $i++; } //var_dump($arrayofgroupslegend); @@ -1196,7 +1281,8 @@ class DolGraph global $theme_datacolor; //var_dump($arrayofgroupslegend); - $i = 0; $iinstack = 0; + $i = 0; + $iinstack = 0; $oldstacknum = -1; while ($i < $nblot) // Loop on each serie { @@ -1242,34 +1328,15 @@ class DolGraph $color = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ', 0.9)'; $bordercolor = 'rgb(' . $newcolor[0] . ', ' . $newcolor[1] . ', ' . $newcolor[2] . ')'; } else { // We do not use a 'group by' - if ($isfunnel) { - $bordercolor == 'null'; - if (is_array($this->datacolor[$i])) { - $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; // If datacolor is array(R, G, B) - } else { - // TODO FIXME This logic must be in the caller that set $this->datacolor - $tmp = str_replace('#', '', $this->datacolor[$i]); - if (strpos($tmp, '-') !== false) { - $foundnegativecolor++; - $color = '#FFFFFF'; // If $val is '-123' - } else { - $color = "#" . $tmp; // If $val is '123' or '#123' - $bordercolor = $color; - } - if ($foundnegativecolor) { - if (is_array($this->datacolor[$i])) $color = 'null'; // If datacolor is array(R, G, B) - else { - $tmp = str_replace('#', '', $this->datacolor[$i]); - if (strpos($tmp, '-') !== false) $bordercolor = '#' . str_replace('-', '', $tmp); // If $val is '-123' - else $bordercolor = 'null'; // If $val is '123' or '#123' - } - } - } - $bordercolor == 'null' ? "'rgba(0,0,0,0.2)'" : "'" . $bordercolor . "'"; + if (is_array($this->datacolor[$i])) { + $color = 'rgb(' . $this->datacolor[$i][0] . ', ' . $this->datacolor[$i][1] . ', ' . $this->datacolor[$i][2] . ', 0.9)'; } else { - $color = 'rgb('.$this->datacolor[$i][0].', '.$this->datacolor[$i][1].', '.$this->datacolor[$i][2].', 0.9)'; + $color = $this->datacolor[$i]; + } + if (is_array($this->bordercolor[$i])) { $bordercolor = $color; - //$color = (!empty($data['seriescolor']) ? json_encode($data['seriescolor']) : json_encode($datacolor)); + } else { + $bordercolor = $this->bordercolor[$i]; } } @@ -1280,21 +1347,16 @@ class DolGraph $this->stringtoshow .= 'label: \'' . dol_escape_js(dol_string_nohtmltag($textoflegend)) . '\', '; $this->stringtoshow .= 'pointStyle: \'' . ((!empty($this->type[$i]) && $this->type[$i] == 'linesnopoint') ? 'line' : 'circle') . '\', '; $this->stringtoshow .= 'fill: ' . ($type == 'bar' ? 'true' : 'false') . ', '; - if ($isfunnel) { - $this->stringtoshow .= 'borderWidth: \'2\', '; - } elseif ($type == 'bar' || $type == 'horizontalBar') { - $this->stringtoshow .= 'borderWidth: \'1\', '; + if ($type == 'bar' || $type == 'horizontalBar') { + $this->stringtoshow .= 'borderWidth: \''.$this->borderwidth.'\', '; } $this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', '; $this->stringtoshow .= 'backgroundColor: \'' . $color . '\', '; - if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; - $this->stringtoshow .='data: ['; - if ($isfunnel) { - $this->stringtoshow .= '['.-$serie[$i].','.$serie[$i].']'; - } else { - $this->stringtoshow .= $serie[$i]; - } - $this->stringtoshow .=']'; + if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; + $this->stringtoshow .= 'data: ['; + + $this->stringtoshow .= $this->mirrorGraphValues ? '[' . -$serie[$i] . ',' . $serie[$i] . ']' : $serie[$i]; + $this->stringtoshow .= ']'; $this->stringtoshow .= '}' . "\n"; $i++; @@ -1318,7 +1380,7 @@ class DolGraph { $value = 0; foreach ($this->data as $valarray) // Loop on each x - { + { $value += $valarray[1]; } return $value; @@ -1361,13 +1423,11 @@ class DolGraph { global $conf; - if ($direction == 'width') - { + if ($direction == 'width') { if (empty($conf->dol_optimize_smallscreen)) return ($defaultsize ? $defaultsize : '500'); else return (empty($_SESSION['dol_screen_width']) ? '280' : ($_SESSION['dol_screen_width'] - 40)); } - if ($direction == 'height') - { + if ($direction == 'height') { return (empty($conf->dol_optimize_smallscreen) ? ($defaultsize ? $defaultsize : '200') : '160'); } return 0; From fe01f352070629574dd74c74af580276da6a6aef Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Mon, 18 Jan 2021 10:33:46 +0000 Subject: [PATCH 002/200] Fixing style errors. --- htdocs/core/class/dolgraph.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 1bc9f175171..417f00ce81b 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -483,7 +483,7 @@ class DolGraph // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mirror Values of the graph - * + * * @param boolean $mirrorGraphValues Mirror Values if true and doesn't if false * @return void */ @@ -1354,7 +1354,7 @@ class DolGraph $this->stringtoshow .= 'backgroundColor: \'' . $color . '\', '; if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; $this->stringtoshow .= 'data: ['; - + $this->stringtoshow .= $this->mirrorGraphValues ? '[' . -$serie[$i] . ',' . $serie[$i] . ']' : $serie[$i]; $this->stringtoshow .= ']'; $this->stringtoshow .= '}' . "\n"; From 2cfaf5fbd606ba0acf7ee7afea134c22c71f7a3f Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 18 Jan 2021 17:08:17 +0100 Subject: [PATCH 003/200] NEW : add real payments on vat objects --- htdocs/compta/bank/bankentries_list.php | 10 +- htdocs/compta/bank/line.php | 23 +- htdocs/compta/paiement_vat.php | 348 +++++++++ htdocs/compta/payment_vat/card.php | 334 ++++++++ htdocs/compta/tva/card.php | 522 +++++++++++-- htdocs/compta/tva/class/paymentvat.class.php | 719 ++++++++++++++++++ htdocs/compta/tva/class/tva.class.php | 124 ++- htdocs/compta/tva/index.php | 24 +- htdocs/compta/tva/list.php | 70 +- htdocs/compta/tva/payments.php | 502 ++++++++++++ htdocs/core/class/commonobject.class.php | 2 + htdocs/core/lib/functions.lib.php | 3 +- htdocs/core/lib/vat.lib.php | 3 +- htdocs/core/menus/standard/eldy.lib.php | 2 + .../install/mysql/tables/llx_paiementtva.sql | 35 + htdocs/langs/en_US/bills.lang | 2 + htdocs/langs/en_US/compta.lang | 16 +- 17 files changed, 2607 insertions(+), 132 deletions(-) create mode 100644 htdocs/compta/paiement_vat.php create mode 100644 htdocs/compta/payment_vat/card.php create mode 100644 htdocs/compta/tva/class/paymentvat.class.php create mode 100644 htdocs/compta/tva/payments.php create mode 100644 htdocs/install/mysql/tables/llx_paiementtva.sql diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 7d059734126..3bd1e16b27d 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -382,7 +382,6 @@ $loanstatic = new Loan($db); $memberstatic = new Adherent($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); -$paymentvatstatic = new TVA($db); $paymentsalstatic = new PaymentSalary($db); $paymentvariousstatic = new PaymentVarious($db); $donstatic = new Don($db); @@ -1229,9 +1228,9 @@ if ($resql) } elseif ($links[$key]['type'] == 'payment_vat') { - $paymentvatstatic->id = $links[$key]['url_id']; - $paymentvatstatic->ref = $links[$key]['url_id']; - print ' '.$paymentvatstatic->getNomUrl(2); + print ''; + print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; + print ''; } elseif ($links[$key]['type'] == 'payment_salary') { @@ -1306,6 +1305,9 @@ if ($resql) elseif ($links[$key]['type'] == 'sc') { } + elseif ($links[$key]['type'] == 'vat') + { + } else { // Show link with label $links[$key]['label'] diff --git a/htdocs/compta/bank/line.php b/htdocs/compta/bank/line.php index bf8dc6f5649..affde235ebd 100644 --- a/htdocs/compta/bank/line.php +++ b/htdocs/compta/bank/line.php @@ -8,6 +8,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2016 Marcos García * Copyright (C) 2018 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -367,12 +368,18 @@ if ($result) $societe->fetch($links[$key]['url_id']); print $societe->getNomUrl(1); } - elseif ($links[$key]['type'] == 'sc') { - print ''; - print img_object($langs->trans('SocialContribution'), 'bill').' '; - print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); - print ''; - } + elseif ($links[$key]['type'] == 'sc') { + print ''; + print img_object($langs->trans('SocialContribution'), 'bill').' '; + print $langs->trans("SocialContribution").($links[$key]['label'] ? ' - '.$links[$key]['label'] : ''); + print ''; + } + elseif ($links[$key]['type'] == 'vat') { + print ''; + print img_object($langs->trans('VATDeclaration'), 'bill').' '; + print $langs->trans("VATDeclaration").($links[$key]['label'] ? ' '.$links[$key]['label'] : ''); + print ''; + } elseif ($links[$key]['type'] == 'payment_sc') { print ''; print img_object($langs->trans('Payment'), 'payment').' '; @@ -380,8 +387,8 @@ if ($result) print ''; } elseif ($links[$key]['type'] == 'payment_vat') { - print ''; - print img_object($langs->trans('VAT'), 'payment').' '; + print ''; + print img_object($langs->trans('VATPayment'), 'payment').' '; print $langs->trans("VATPayment"); print ''; } diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php new file mode 100644 index 00000000000..cc5f6b858c8 --- /dev/null +++ b/htdocs/compta/paiement_vat.php @@ -0,0 +1,348 @@ + + * Copyright (C) 2016-2018 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/paiement_charge.php + * \ingroup tax + * \brief Page to add payment of a tax + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +// Load translation files required by the page +$langs->load("bills"); + +$chid = GETPOST("id", 'int'); +$action = GETPOST('action', 'alpha'); +$amounts = array(); + +// Security check +$socid = 0; +if ($user->socid > 0) +{ + $socid = $user->socid; +} + + +/* + * Actions + */ + +if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'yes')) +{ + $error = 0; + + if ($_POST["cancel"]) + { + $loc = DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid; + header("Location: ".$loc); + exit; + } + + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + + if (!$_POST["paiementtype"] > 0) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode")), null, 'errors'); + $error++; + $action = 'create'; + } + if ($datepaye == '') + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Date")), null, 'errors'); + $error++; + $action = 'create'; + } + if (!empty($conf->banque->enabled) && !($_POST["accountid"] > 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("AccountToCredit")), null, 'errors'); + $error++; + $action = 'create'; + } + + if (!$error) + { + $paymentid = 0; + + // Read possible payments + foreach ($_POST as $key => $value) + { + if (substr($key, 0, 7) == 'amount_') + { + $other_chid = substr($key, 7); + $amounts[$other_chid] = price2num($_POST[$key]); + } + } + + if (count($amounts) <= 0) + { + $error++; + setEventMessages($langs->trans("ErrorNoPaymentDefined"), null, 'errors'); + $action = 'create'; + } + + if (!$error) + { + $db->begin(); + + // Create a line of payments + $paiement = new PaymentVAT($db); + $paiement->chid = $chid; + $paiement->datepaye = $datepaye; + $paiement->amounts = $amounts; // Tableau de montant + $paiement->paiementtype = GETPOST("paiementtype", 'alphanohtml'); + $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); + $paiement->note = GETPOST("note", 'none'); + $paiement->note_private = GETPOST("note", 'none'); + + if (!$error) + { + $paymentid = $paiement->create($user, (GETPOST('closepaidvat') == 'on' ? 1 : 0)); + if ($paymentid < 0) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } + } + + if (!$error) + { + $result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } + } + + if (!$error) + { + $db->commit(); + $loc = DOL_URL_ROOT.'/compta/tva/card.php?id='.$chid; + header('Location: '.$loc); + exit; + } + else + { + $db->rollback(); + } + } + } +} + + +/* + * View + */ + +llxHeader(); + +$form = new Form($db); + + +// Formulaire de creation d'un paiement de charge +if ($action == 'create') +{ + $tva = new Tva($db); + $tva->fetch($chid); + $tva->accountid = $tva->fk_account ? $tva->fk_account : $tva->accountid; + $tva->paiementtype = $tva->type_payment; + + $total = $tva->amount; + if (!empty($conf->use_javascript_ajax)) + { + print "\n".''."\n"; + } + + print load_fiche_titre($langs->trans("DoPayment")); + print "
\n"; + + if ($mesg) + { + print "
$mesg
"; + } + + print '
'; + print ''; + print ''; + print ''; + print ''; + + dol_fiche_head('', ''); + + print ''; + + print ''; + //print '\n"; + print '\n"; + print '\n"; + /*print '\n"; + print '';*/ + + $sql = "SELECT sum(p.amount) as total"; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as p"; + $sql .= " WHERE p.fk_tva = ".$chid; + $resql = $db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + $sumpaid = $obj->total; + $db->free(); + } + /*print ''; + print '';*/ + + print '"; + print ''; + + print '\n"; + print ''; + + print ''; + print ''; + print ''; + + // Number + print ''; + print ''."\n"; + + print ''; + print ''; + print ''; + print ''; + + print '
'.$langs->trans("Ref").''.$chid.'
'.$langs->trans("Type")."".$tva->type_label."
'.$langs->trans("Period")."".dol_print_date($tva->datev, 'day')."
'.$langs->trans("Label").''.$tva->label."
'.$langs->trans("DateDue")."".dol_print_date($tva->date_ech,'day')."
'.$langs->trans("Amount")."".price($tva->amount,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("AlreadyPaid").''.price($sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("RemainderToPay").''.price($total-$sumpaid,0,$outputlangs,1,-1,-1,$conf->currency).'
'.$langs->trans("Date").''; + $datepaye = dol_mktime(12, 0, 0, $_POST["remonth"], $_POST["reday"], $_POST["reyear"]); + $datepayment = empty($conf->global->MAIN_AUTOFILL_DATE) ? (empty($_POST["remonth"]) ?-1 : $datepaye) : 0; + print $form->selectDate($datepayment, '', '', '', '', "add_payment", 1, 1); + print "
'.$langs->trans("PaymentMode").''; + $form->select_types_paiements(isset($_POST["paiementtype"]) ? $_POST["paiementtype"] : $tva->paiementtype, "paiementtype"); + print "
'.$langs->trans('AccountToDebit').''; + $form->select_comptes(isset($_POST["accountid"]) ? $_POST["accountid"] : $tva->accountid, "accountid", 0, '', 1); // Show opend bank account list + print '
'.$langs->trans('Numero'); + print ' ('.$langs->trans("ChequeOrTransferNumber").')'; + print '
'.$langs->trans("Comments").'
'; + + dol_fiche_end(); + + /* + * Autres charges impayees + */ + $num = 1; + $i = 0; + + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + $total = 0; + $totalrecu = 0; + + while ($i < $num) + { + $objp = $tva; + + print ''; + + if ($objp->datev > 0) + { + print ''."\n"; + } + else + { + print "\n"; + } + + print '"; + + print '"; + + print '"; + + print '"; + + print "\n"; + $total += $objp->total; + $total_ttc += $objp->total_ttc; + $totalrecu += $objp->am; + $i++; + } + if ($i > 1) + { + // Print total + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + } + + print "
'.$langs->trans("SocialContribution").''.$langs->trans("DateDue").''.$langs->trans("Amount").''.$langs->trans("AlreadyPaid").''.$langs->trans("RemainderToPay").''.$langs->trans("Amount").'
'.dol_print_date($objp->datev, 'day').'!!!'.price($objp->amount)."'.price($sumpaid)."'.price($objp->amount - $sumpaid)."'; + + if ($sumpaid <> $objp->amount) + { + $namef = "amount_".$objp->id; + $nameRemain = "remain_".$objp->id; + if (!empty($conf->use_javascript_ajax)) + print img_picto("Auto fill", 'rightarrow', "class='AutoFillAmount' data-rowid='".$namef."' data-value='".($objp->amount - $sumpaid)."'"); + $remaintopay = $objp->amount - $sumpaid; + print ''; + print ''; + } + else + { + print '-'; + } + print "
'.$langs->trans("Total").':'.price($total_ttc).''.price($totalrecu).''.price($total_ttc - $totalrecu).' 
"; + + // Bouton Save payment + print '
'.$langs->trans("ClosePaidVATAutomatically"); + print '
'; + print '     '; + print ''; + print '
'; + + print "
\n"; +} + +llxFooter(); +$db->close(); diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php new file mode 100644 index 00000000000..30bd6844b71 --- /dev/null +++ b/htdocs/compta/payment_vat/card.php @@ -0,0 +1,334 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2021 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/payment_vat/card.php + * \ingroup facture + * \brief Onglet payment of a social contribution + * \remarks Fichier presque identique a fournisseur/paiement/card.php + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/facture/modules_facture.php'; +if (!empty($conf->banque->enabled)) require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + +// Load translation files required by the page +$langs->loadLangs(array('bills', 'banks', 'companies')); + +// Security check +$id = GETPOST("id", 'int'); +$action = GETPOST('action', 'aZ09'); +$confirm = GETPOST('confirm'); +if ($user->socid) $socid = $user->socid; +// TODO ajouter regle pour restreindre acces paiement +//$result = restrictedArea($user, 'facture', $id,''); + +$object = new PaymentVAT($db); +if ($id > 0) +{ + $result = $object->fetch($id); + if (!$result) dol_print_error($db, 'Failed to get payment id '.$id); +} + + +/* + * Actions + */ + +// Delete payment +if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->charges->supprimer) +{ + $db->begin(); + + $result = $object->delete($user); + if ($result > 0) + { + $db->commit(); + header("Location: ".DOL_URL_ROOT."/compta/tva/payments.php?mode=tvaonly"); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } +} + +// Validate social contribution +/* +if ($action == 'confirm_valide' && $confirm == 'yes' && $user->rights->tax->charges->creer) +{ + $db->begin(); + + $result=$object->valide(); + + if ($result > 0) + { + $db->commit(); + + $factures=array(); // TODO Get all id of invoices linked to this payment + foreach($factures as $id) + { + $fac = new Facture($db); + $fac->fetch($id); + + $outputlangs = $langs; + if (! empty($_REQUEST['lang_id'])) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($_REQUEST['lang_id']); + } + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) { + $fac->generateDocument($fac->modelpdf, $outputlangs); + } + } + + header('Location: card.php?id='.$object->id); + exit; + } + else + { + setEventMessages($object->error, $object->errors, 'errors'); + $db->rollback(); + } +} +*/ + + +/* + * View + */ + +llxHeader(); + +$tva = new TVA($db); + +$form = new Form($db); + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='.$id; +$head[$h][1] = $langs->trans("VATPayment"); +$hselected = $h; +$h++; + +/*$head[$h][0] = DOL_URL_ROOT.'/compta/payment_sc/info.php?id='.$id; +$head[$h][1] = $langs->trans("Info"); +$h++; +*/ + + +dol_fiche_head($head, $hselected, $langs->trans("VATPayment"), -1, 'payment'); + +/* + * Deletion confirmation of payment + */ +if ($action == 'delete') +{ + print $form->formconfirm('card.php?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete', '', 0, 2); +} + +/* + * Validation confirmation of payment + */ +/* +if ($action == 'valide') +{ + $facid = $_GET['facid']; + print $form->formconfirm('card.php?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2); + +} +*/ + + +$linkback = ''.$langs->trans("BackToList").''; + +dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'id', ''); + + +print '
'; +print '
'; + +print ''; + +// Ref +/*print ''; +print '';*/ + +// Date +print ''; + +// Mode +print ''; + +// Numero +print ''; + +// Montant +print ''; + +// Note +print ''; + +// Bank account +if (!empty($conf->banque->enabled)) +{ + if ($object->bank_account) + { + $bankline = new AccountLine($db); + $bankline->fetch($object->bank_line); + + print ''; + print ''; + print ''; + print ''; + } +} + +print '
'.$langs->trans('Ref').''; +print $form->showrefnav($object,'id','',1,'rowid','id'); +print '
'.$langs->trans('Date').''.dol_print_date($object->datep, 'day').'
'.$langs->trans('Mode').''.$langs->trans("PaymentType".$object->type_code).'
'.$langs->trans('Numero').''.$object->num_paiement.'
'.$langs->trans('Amount').''.price($object->amount, 0, $outputlangs, 1, -1, -1, $conf->currency).'
'.$langs->trans('Note').''.nl2br($object->note).'
'.$langs->trans('BankTransactionLine').''; + print $bankline->getNomUrl(1, 0, 'showall'); + print '
'; + +print '
'; + +dol_fiche_end(); + + +/* + * List of social contributions payed + */ + +$disable_delete = 0; +$sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount'; +//$sql .= ', pc.libelle as sc_type'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementtva as pf,'.MAIN_DB_PREFIX.'tva as f'; +//$sql .= ', '.MAIN_DB_PREFIX.'c_chargesociales as pc'; +$sql .= ' WHERE pf.fk_tva = f.rowid'; +//$sql .= ' AND f.fk_type = pc.id'; +$sql .= ' AND f.entity = '.$conf->entity; +$sql .= ' AND pf.rowid = '.$object->id; + +dol_syslog("compta/payment_vat/card.php", LOG_DEBUG); +$resql = $db->query($sql); +if ($resql) +{ + $num = $db->num_rows($resql); + + $i = 0; + $total = 0; + print '
'; + print ''; + print ''; + //print ''; + print ''; + print ''; + print ''; + print ''; + print "\n"; + + if ($num > 0) + { + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + print ''; + // Ref + print '\n"; + // Type + /* print '\n";*/ + // Label + print ''; + // Expected to pay + print ''; + // Status + print ''; + // Amount payed + print ''; + print "\n"; + if ($objp->paye == 1) // If at least one invoice is paid, disable delete + { + $disable_delete = 1; + } + $total = $total + $objp->amount; + $i++; + } + } + + + print "
'.$langs->trans('VATDeclaration').''.$langs->trans('Type').''.$langs->trans('Label').''.$langs->trans('ExpectedToPay').''.$langs->trans('Status').''.$langs->trans('PayedByThisPayment').'
'; + $tva->fetch($objp->scid); + print $tva->getNomUrl(1); + print "'; + print $tva->type_label;4 + print "'.$objp->label.''.price($objp->tva_amount).''.$tva->getLibStatut(4, $objp->amount).''.price($objp->amount).'
\n"; + $db->free($resql); +} +else +{ + dol_print_error($db); +} + + + +/* + * Boutons Actions + */ +print '
'; + +/* +if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION)) +{ + if ($user->socid == 0 && $object->statut == 0 && $_GET['action'] == '') + { + if ($user->rights->facture->paiement) + { + print ''.$langs->trans('Valid').''; + } + } +} +*/ + +if ($action == '') +{ + if ($user->rights->tax->charges->supprimer) + { + if (!$disable_delete) + { + print ''.$langs->trans('Delete').''; + } + else + { + print ''.$langs->trans('Delete').''; + } + } +} + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 6d7c5935418..aec96c88caa 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2013 Regis Houssin * Copyright (C) 2015-2017 Alexandre Spangaro * Copyright (C) 2018 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -27,15 +28,23 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/vat.lib.php'; +if (!empty($conf->accounting->enabled)) { + include_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php'; +} + // Load translation files required by the page $langs->loadLangs(array('compta', 'banks', 'bills')); $id = GETPOST("id", 'int'); $action = GETPOST("action", "alpha"); +$confirm = GETPOST('confirm'); $refund = GETPOST("refund", "int"); +$auto_create_payment = GETPOST("auto_create_paiement", "int"); + if (empty($refund)) $refund = 0; $datev = dol_mktime(12, 0, 0, GETPOST("datevmonth", 'int'), GETPOST("datevday", 'int'), GETPOST("datevyear", 'int')); @@ -81,11 +90,50 @@ if ($action == 'setdatev' && $user->rights->tax->charges->creer) $action = ''; } +// payment mode +if ($action == 'setmode' && $user->rights->tax->charges->creer) { + $object->fetch($id); + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id', 'int')); + if ($result < 0) + setEventMessages($object->error, $object->errors, 'errors'); +} + +// Bank account +if ($action == 'setbankaccount' && $user->rights->tax->charges->creer) { + $object->fetch($id); + $result = $object->setBankAccount(GETPOST('fk_account', 'int')); + if ($result < 0) { + setEventMessages($object->error, $object->errors, 'errors'); + } +} + +// Classify paid +if ($action == 'confirm_paid' && $user->rights->tax->charges->creer && $confirm == 'yes') +{ + $object->fetch($id); + $result = $object->set_paid($user); +} + +if ($action == 'reopen' && $user->rights->tax->charges->creer) { + $result = $object->fetch($id); + if ($object->paye) + { + $result = $object->set_unpaid($user); + if ($result > 0) + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit(); + } else { + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} + if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $error = 0; - $object->accountid = GETPOST("accountid", 'int'); + $object->fk_account = GETPOST("accountid", 'int'); $object->type_payment = GETPOST("type_payment", 'alphanohtml'); $object->num_payment = GETPOST("num_payment", 'alphanohtml'); @@ -110,7 +158,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PeriodEndDate")), null, 'errors'); $error++; } - if (empty($object->type_payment) || $object->type_payment < 0) + if (!empty($auto_create_payment) && (empty($object->type_payment) || $object->type_payment < 0)) { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("PaymentMode")), null, 'errors'); $error++; @@ -120,34 +168,76 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Amount")), null, 'errors'); $error++; } + if (!empty($auto_create_payment) && ($object->fk_account <= 0)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("AccountToCredit")), null, 'errors'); + $error++; + } if (!$error) { - $db->begin(); + $ret = $object->create($user); + if($ret < 0) $error++; - $ret = $object->addPayment($user); - if ($ret > 0) + // Auto create payment + if (!empty($auto_create_payment) && !$error) { - $db->commit(); - header("Location: list.php"); - exit; + $db->begin(); + + // Create a line of payments + $paiement = new PaymentVAT($db); + $paiement->chid = $object->id; + $paiement->datepaye = $datep; + $paiement->amounts = array($object->id=>$amount); // Tableau de montant + $paiement->paiementtype = GETPOST("type_payment", 'alphanohtml'); + $paiement->num_payment = GETPOST("num_payment", 'alphanohtml'); + $paiement->note = GETPOST("note", 'none'); + + if (!$error) + { + $paymentid = $paiement->create($user, (int)GETPOST('closepaidtva')); + if ($paymentid < 0) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + $action = 'create'; + } + } + + if (!$error) + { + $result = $paiement->addPaymentToBank($user, 'payment_vat', '(VATPayment)', GETPOST('accountid', 'int'), '', ''); + if (!($result > 0)) + { + $error++; + setEventMessages($paiement->error, null, 'errors'); + } + } + + if (!$error) + { + $db->commit(); + } + else + { + $db->rollback(); + } } - else - { - $db->rollback(); - setEventMessages($object->error, $object->errors, 'errors'); - $action = "create"; + if(empty($error)) { + header("Location: card.php?id=" . $object->id); + exit; } } $action = 'create'; } -if ($action == 'delete') +if ($action == 'confirm_delete' && $confirm == 'yes') { $result = $object->fetch($id); + $totalpaye = $object->getSommePaiement(); - if ($object->rappro == 0) + if (empty($totalpaye)) { $db->begin(); @@ -182,11 +272,89 @@ if ($action == 'delete') } else { - $mesg = 'Error try do delete a line linked to a conciliated bank transaction'; - setEventMessages($mesg, null, 'errors'); + setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors'); } } +if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->creer) +{ + $amount = price2num(GETPOST('amount')); + + if (empty($amount)) + { + setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")), null, 'errors'); + $action = 'edit'; + } + elseif (!is_numeric($amount)) + { + setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); + $action = 'create'; + } + else + { + $result = $object->fetch($id); + + $object->amount = price2num($amount); + + $result = $object->update($user); + if ($result <= 0) + { + setEventMessages($object->error, $object->errors, 'errors'); + } + } +} + +// Action clone object +if ($action == 'confirm_clone' && $confirm != 'yes') { $action = ''; } + +if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->charges->creer)) +{ + $db->begin(); + + $originalId = $id; + + $object->fetch($id); + + if ($object->id > 0) + { + $object->paye = 0; + $object->id = $object->ref = null; + + if (GETPOST('clone_label', 'alphanohtml')) { + $object->label = GETPOST('clone_label', 'alphanohtml'); + } + else { + $object->label = $langs->trans("CopyOf").' '.$object->label; + } + + $newdateperiod = dol_mktime(0, 0, 0, GETPOST('clone_periodmonth', 'int'), GETPOST('clone_periodday', 'int'), GETPOST('clone_periodyear', 'int')); + if ($newdateperiod) $object->datev = $newdateperiod; + + //if ($object->check()) { + $id = $object->create($user); + if ($id > 0) + { + $db->commit(); + $db->close(); + + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); + exit; + } + else + { + $id = $originalId; + $db->rollback(); + + setEventMessages($object->error, $object->errors, 'errors'); + } + //} + } + else + { + $db->rollback(); + dol_print_error($db, $object->error); + } +} /* * View @@ -213,7 +381,6 @@ if ($id) if ($action == 'create') { print load_fiche_titre($langs->trans("VAT").' - '.$langs->trans("New")); - if (!empty($conf->use_javascript_ajax)) { print "\n".''."\n"; } @@ -256,12 +447,12 @@ if ($action == 'create') print ''; - print ""; - print ''; + print ''; - print ''; @@ -276,29 +467,44 @@ if ($action == 'create') // Amount print ''; - if (!empty($conf->banque->enabled)) - { - print ''; - } - // Type payment - print '\n"; print ""; + if (!empty($conf->banque->enabled)) + { + print ''; + } + + // Auto create payment + print ''; + print ''."\n"; + // Number - print ''."\n"; + // Comments + print ''; + print ''; + print ''; + print ''; + // Other attributes $parameters = array(); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $object, $action); // Note that $action and $object may have been modified by hook print $hookmanager->resPrint; + // Bouton Save payment + print ''; + print '
'.$langs->trans("DatePayment").''; + print '
'.$langs->trans("DatePayment").''; print $form->selectDate($datep, "datep", '', '', '', 'add', 1, 1); print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; + print '
'.$form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")).''; print $form->selectDate((GETPOST("datevmonth", 'int') ? $datev : -1), "datev", '', '', '', 'add', 1, 1); print '
'.$langs->trans("Amount").'
'.$langs->trans("BankAccount").''; - $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 2); // List of bank account available - print '
'.$langs->trans("PaymentMode").''; + print '
'.$langs->trans("PaymentMode").''; $form->select_types_paiements(GETPOST("type_payment"), "type_payment"); print "
'.$langs->trans("BankAccount").''; + $form->select_comptes(GETPOST("accountid", 'int'), "accountid", 0, "courant=1", 1); // List of bank account available + print '
'.$langs->trans('AutomaticCreationPayment').'
'.$langs->trans('Numero'); + print '
'.$langs->trans('Numero'); print ' ('.$langs->trans("ChequeOrTransferNumber").')'; print '
'.$langs->trans("Comments").'
'; + print $langs->trans("ClosePaidVATAutomatically"); + print '
'; dol_fiche_end(); @@ -317,6 +523,39 @@ if ($id) { $head = vat_prepare_head($object); + $totalpaye = $object->getSommePaiement(); + + // Clone confirmation + if ($action === 'clone') + { + $formquestion = array( + array('type' => 'text', 'name' => 'clone_label', 'label' => $langs->trans("Label"), 'value' => $langs->trans("CopyOf").' '.$object->label), + ); + + //$formquestion[] = array('type' => 'date', 'name' => 'clone_date_ech', 'label' => $langs->trans("Date"), 'value' => -1); + $formquestion[] = array('type' => 'date', 'name' => 'clone_period', 'label' => $langs->trans("PeriodEndDate"), 'value' => -1); + + print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ToClone'), $langs->trans('ConfirmCloneVAT', $object->ref), 'confirm_clone', $formquestion, 'yes', 1, 240); + } + + if ($action == 'paid') + { + $text = $langs->trans('ConfirmPayVAT'); + print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id, $langs->trans('PayVAT'), $text, "confirm_paid", '', '', 2); + } + + if ($action == 'delete') + { + $text = $langs->trans('ConfirmDeleteVAT'); + print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans('DeleteVAT'), $text, 'confirm_delete', '', '', 2); + } + + if ($action == 'edit') + { + print "
id&action=update\" method=\"post\">"; + print ''; + } + dol_fiche_head($head, 'card', $langs->trans("VATPayment"), -1, 'payment'); $morehtmlref = '
'; @@ -328,9 +567,12 @@ if ($id) $linkback = ''.$langs->trans("BackToList").''; + $object->totalpaye = $totalpaye; // To give a chance to dol_banner_tab to use already paid amount to show correct status + dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, '', ''); print '
'; + print '
'; print '
'; print ''; @@ -338,10 +580,10 @@ if ($id) // Label //print ''; - print ""; + /*print ""; print ''; + print '';*/ print ''; - print ''; + if ($action == 'edit') { + print ''; + } else { + print ''; + } + // Mode of payment + print ''; + + // Bank account if (!empty($conf->banque->enabled)) { - if ($object->fk_account > 0) - { - $bankline = new AccountLine($db); - $bankline->fetch($object->fk_bank); - - print ''; - print ''; - print ''; - print ''; + print ''; + print ''; } // Other attributes @@ -377,27 +643,179 @@ if ($id) print ''; + print '
'; + print '
'; + + $nbcols = 3; + if (!empty($conf->banque->enabled)) { + $nbcols++; + } + + /* + * Payments + */ + $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,"; + $sql .= " c.code as type_code,c.libelle as paiement_type,"; + $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as p"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; + $sql .= ", ".MAIN_DB_PREFIX."tva as tva"; + $sql .= " WHERE p.fk_tva = ".$id; + $sql .= " AND p.fk_tva = tva.rowid"; + $sql .= " AND tva.entity IN (".getEntity('tax').")"; + $sql .= " ORDER BY dp DESC"; + + //print $sql; + $resql = $db->query($sql); + if ($resql) + { + $totalpaye = 0; + + $num = $db->num_rows($resql); + $i = 0; $total = 0; + + print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table + print '
'.$langs->trans("Label").''.$object->label.'
'.$langs->trans("DatePayment").''; print dol_print_date($object->datep, 'day'); - print '
'; print $form->editfieldkey($form->textwithpicto($langs->trans("PeriodEndDate"), $langs->trans("LastDayTaxIsRelatedTo")), 'datev', $object->datev, $object, $user->rights->tax->charges->creer, 'day'); @@ -350,22 +592,46 @@ if ($id) //print dol_print_date($object->datev,'day'); print '
'.$langs->trans("Amount").''.price($object->amount).'
' . $langs->trans("Amount") . '
' . $langs->trans("Amount") . '' . price($object->amount) . '
'; + print ''; + if ($action != 'editmode') + print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->trans('SetMode'), 1).'
'; + print '
'; + if ($action == 'editmode') { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'mode_reglement_id'); + } else { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id, $object->type_payment, 'none'); + } + print '
'.$langs->trans('BankTransactionLine').''; - print $bankline->getNomUrl(1, 0, 'showall'); - print '
'; + print ''; + print '
'; + print $langs->trans('BankAccount'); + print ''; + if ($action != 'editbankaccount' && $user->rights->tax->charges->creer) + print 'id.'">'.img_edit($langs->trans('SetBankAccount'), 1).'
'; + print '
'; + if ($action == 'editbankaccount') { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'fk_account', 1); + } else { + $form->formSelectAccount($_SERVER['PHP_SELF'].'?id='.$object->id, $object->fk_account, 'none'); } + print '
'; + print ''; + print ''; + print ''; + print ''; + if (!empty($conf->banque->enabled)) { + print ''; + } + print ''; + print ''; + + if ($num > 0) + { + $bankaccountstatic = new Account($db); + while ($i < $num) + { + $objp = $db->fetch_object($resql); + + print ''; + print '\n"; + $labeltype = $langs->trans("PaymentType".$objp->type_code) != ("PaymentType".$objp->type_code) ? $langs->trans("PaymentType".$objp->type_code) : $objp->paiement_type; + print "\n"; + if (!empty($conf->banque->enabled)) + { + $bankaccountstatic->id = $objp->baid; + $bankaccountstatic->ref = $objp->baref; + $bankaccountstatic->label = $objp->baref; + $bankaccountstatic->number = $objp->banumber; + $bankaccountstatic->currency_code = $objp->bacurrency_code; + + if (!empty($conf->accounting->enabled)) { + $bankaccountstatic->account_number = $objp->account_number; + + $accountingjournal = new AccountingJournal($db); + $accountingjournal->fetch($objp->fk_accountancy_journal); + $bankaccountstatic->accountancy_journal = $accountingjournal->getNomUrl(0, 1, 1, '', 1); + } + + print ''; + } + print '\n"; + print ""; + $totalpaye += $objp->amount; + $i++; + } + } + else + { + print ''; + print ''; + print ''; + } + + print '\n"; + print '\n"; + + $resteapayer = $object->amount - $totalpaye; + $cssforamountpaymentcomplete = 'amountpaymentcomplete'; + + print '"; + print '\n"; + + print "
'.$langs->trans("RefPayment").''.$langs->trans("Date").''.$langs->trans("Type").''.$langs->trans('BankAccount').''.$langs->trans("Amount").'
'; + print ''.img_object($langs->trans("Payment"), "payment").' '.$objp->rowid.''.dol_print_date($db->jdate($objp->dp), 'day')."".$labeltype.' '.$objp->num_payment."'; + if ($bankaccountstatic->id) + print $bankaccountstatic->getNomUrl(1, 'transactions'); + print ''.price($objp->amount)."
'.$langs->trans("None").'
'.$langs->trans("AlreadyPaid")." :".price($totalpaye)."
'.$langs->trans("AmountExpected")." :".price($object->amount)."
'.$langs->trans("RemainderToPay")." :'.price($resteapayer)."
"; + print '
'; + + $db->free($resql); + } + else + { + dol_print_error($db); + } + + print '
'; + print '
'; + print ''; + + print '
'; + dol_fiche_end(); + if ($action == 'edit') + { + print '
'; + print ''; + print '   '; + print ''; + print '
'; + print "
\n"; + } + /* * Action buttons */ print "
\n"; - if ($object->rappro == 0) + if ($action != 'edit') { - if (!empty($user->rights->tax->charges->supprimer)) + // Reopen + if ($object->paye && $user->rights->tax->charges->creer) + { + print ""; + } + + // Edit + if ($object->paye == 0 && $user->rights->tax->charges->creer) + { + print ""; + } + + // Emit payment + if ($object->paye == 0 && ((price2num($object->amount) < 0 && price2num($resteapayer, 'MT') < 0) || (price2num($object->amount) > 0 && price2num($resteapayer, 'MT') > 0)) && $user->rights->tax->charges->creer) + { + print ""; + } + + // Classify 'paid' + if ($object->paye == 0 && round($resteapayer) <= 0 && $user->rights->tax->charges->creer) + { + print ""; + } + + // Clone + if ($user->rights->tax->charges->creer) + { + print ""; + } + + if (!empty($user->rights->tax->charges->supprimer) && empty($totalpaye)) { print ''; } else { - print ''; + print ''; } } - else - { - print ''; - } print "
"; } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php new file mode 100644 index 00000000000..f5a34decebc --- /dev/null +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -0,0 +1,719 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2021 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/sociales/class/paymentsocialcontribution.class.php + * \ingroup facture + * \brief File of class to manage payment of social contributions + */ + +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; + + +/** + * Class to manage payments of social contributions + */ +class PaymentVAT extends CommonObject +{ + /** + * @var string ID to identify managed object + */ + public $element = 'paiementtva'; + + /** + * @var string Name of table without prefix where object is stored + */ + public $table_element = 'paiementtva'; + + /** + * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png + */ + public $picto = 'payment'; + + /** + * @var int ID + */ + public $fk_tva; + + public $datec = ''; + public $tms = ''; + public $datep = ''; + + /** + * @deprecated + * @see $amount + */ + public $total; + + public $amount; // Total amount of payment + public $amounts = array(); // Array of amounts + + /** + * @var int ID + */ + public $fk_typepaiement; + + /** + * @var string + * @deprecated + */ + public $num_paiement; + + /** + * @var string + */ + public $num_payment; + + /** + * @var int ID + */ + public $fk_bank; + + /** + * @var int ID + */ + public $fk_user_creat; + + /** + * @var int ID + */ + public $fk_user_modif; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + public function __construct($db) + { + $this->db = $db; + } + + /** + * Create payment of social contribution into database. + * Use this->amounts to have list of lines for the payment + * + * @param User $user User making payment + * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more + * @return int <0 if KO, id of payment if OK + */ + public function create($user, $closepaidcontrib = 0) + { + global $conf, $langs; + + $error = 0; + + $now = dol_now(); + + dol_syslog(get_class($this)."::create", LOG_DEBUG); + + // Validate parametres + if (!$this->datepaye) + { + $this->error = 'ErrorBadValueForParameterCreatePaymentVAT'; + return -1; + } + + // Clean parameters + if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; + + $totalamount = 0; + foreach ($this->amounts as $key => $value) // How payment is dispatch + { + $newvalue = price2num($value, 'MT'); + $this->amounts[$key] = $newvalue; + $totalamount += $newvalue; + } + $totalamount = price2num($totalamount); + + // Check parameters + if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null + + + $this->db->begin(); + + if ($totalamount != 0) + { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementtva (fk_tva, datec, datep, amount,"; + $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; + $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; + $sql .= " '".$this->db->idate($this->datepaye)."',"; + $sql .= " ".$totalamount.","; + $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; + $sql .= " 0)"; + + $resql = $this->db->query($sql); + if ($resql) + { + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementtva"); + + // Insere tableau des montants / factures + foreach ($this->amounts as $key => $amount) + { + $contribid = $key; + if (is_numeric($amount) && $amount <> 0) + { + $amount = price2num($amount); + + // If we want to closed payed invoices + if ($closepaidcontrib) + { + $contrib = new Tva($this->db); + $contrib->fetch($contribid); + $paiement = $contrib->getSommePaiement(); + //$creditnotes=$contrib->getSumCreditNotesUsed(); + $creditnotes = 0; + //$deposits=$contrib->getSumDepositsUsed(); + $deposits = 0; + $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); + $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); + if ($remaintopay == 0) + { + $result = $contrib->set_paid($user); + } + else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); + } + } + } + } + else + { + $error++; + } + } + + $result = $this->call_trigger('PAYMENTVAT_CREATE', $user); + if ($result < 0) $error++; + + if ($totalamount != 0 && !$error) + { + $this->amount = $totalamount; + $this->total = $totalamount; // deprecated + $this->db->commit(); + return $this->id; + } + else + { + $this->error = $this->db->error(); + $this->db->rollback(); + return -1; + } + } + + /** + * Load object in memory from database + * + * @param int $id Id object + * @return int <0 if KO, >0 if OK + */ + public function fetch($id) + { + global $langs; + $sql = "SELECT"; + $sql .= " t.rowid,"; + $sql .= " t.fk_tva,"; + $sql .= " t.datec,"; + $sql .= " t.tms,"; + $sql .= " t.datep,"; + $sql .= " t.amount,"; + $sql .= " t.fk_typepaiement,"; + $sql .= " t.num_paiement as num_payment,"; + $sql .= " t.note,"; + $sql .= " t.fk_bank,"; + $sql .= " t.fk_user_creat,"; + $sql .= " t.fk_user_modif,"; + $sql .= " pt.code as type_code, pt.libelle as type_label,"; + $sql .= ' b.fk_account'; + $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id"; + $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; + $sql .= " WHERE t.rowid = ".$id; + // TODO link on entity of tax; + + dol_syslog(get_class($this)."::fetch", LOG_DEBUG); + $resql = $this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + + $this->id = $obj->rowid; + $this->ref = $obj->rowid; + + $this->fk_tva = $obj->fk_tva; + $this->datec = $this->db->jdate($obj->datec); + $this->tms = $this->db->jdate($obj->tms); + $this->datep = $this->db->jdate($obj->datep); + $this->amount = $obj->amount; + $this->fk_typepaiement = $obj->fk_typepaiement; + $this->num_paiement = $obj->num_payment; + $this->num_payment = $obj->num_payment; + $this->note = $obj->note; + $this->fk_bank = $obj->fk_bank; + $this->fk_user_creat = $obj->fk_user_creat; + $this->fk_user_modif = $obj->fk_user_modif; + + $this->type_code = $obj->type_code; + $this->type_label = $obj->type_label; + + $this->bank_account = $obj->fk_account; + $this->bank_line = $obj->fk_bank; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error = "Error ".$this->db->lasterror(); + return -1; + } + } + + + /** + * Update database + * + * @param User $user User that modify + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function update($user = null, $notrigger = 0) + { + global $conf, $langs; + $error = 0; + + // Clean parameters + + if (isset($this->fk_tva)) $this->fk_tva = (int) $this->fk_tva; + if (isset($this->amount)) $this->amount = trim($this->amount); + if (isset($this->fk_typepaiement)) $this->fk_typepaiement = (int) $this->fk_typepaiement; + if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated + if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); + if (isset($this->note)) $this->note = trim($this->note); + if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; + if (isset($this->fk_user_creat)) $this->fk_user_creat = (int) $this->fk_user_creat; + if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; + + + + // Check parameters + // Put here code to add control on parameters values + + // Update request + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementtva SET"; + + $sql .= " fk_tva=".(isset($this->fk_tva) ? $this->fk_tva : "null").","; + $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; + $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; + $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; + $sql .= " fk_typepaiement=".(isset($this->fk_typepaiement) ? $this->fk_typepaiement : "null").","; + $sql .= " num_paiement=".(isset($this->num_paiement) ? "'".$this->db->escape($this->num_paiement)."'" : "null").","; + $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; + $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; + $sql .= " fk_user_creat=".(isset($this->fk_user_creat) ? $this->fk_user_creat : "null").","; + $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; + + + $sql .= " WHERE rowid=".$this->id; + + $this->db->begin(); + + dol_syslog(get_class($this)."::update", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + /** + * Delete object in database + * + * @param User $user User that delete + * @param int $notrigger 0=launch triggers after, 1=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete($user, $notrigger = 0) + { + global $conf, $langs; + $error = 0; + + dol_syslog(get_class($this)."::delete"); + + $this->db->begin(); + + if ($this->bank_line > 0) + { + $accline = new AccountLine($this->db); + $accline->fetch($this->bank_line); + $result = $accline->delete(); + if ($result < 0) { + $this->errors[] = $accline->error; + $error++; + } + } + + if (!$error) + { + $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementtva"; + $sql .= " WHERE rowid=".$this->id; + + dol_syslog(get_class($this)."::delete", LOG_DEBUG); + $resql = $this->db->query($sql); + if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } + } + + // Commit or rollback + if ($error) + { + foreach ($this->errors as $errmsg) + { + dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); + $this->error .= ($this->error ? ', '.$errmsg : $errmsg); + } + $this->db->rollback(); + return -1 * $error; + } + else + { + $this->db->commit(); + return 1; + } + } + + + + /** + * Load an object from its id and create a new one in database + * + * @param User $user User making the clone + * @param int $fromid Id of object to clone + * @return int New id of clone + */ + public function createFromClone(User $user, $fromid) + { + $error = 0; + + $object = new PaymentSocialContribution($this->db); + + $this->db->begin(); + + // Load source object + $object->fetch($fromid); + $object->id = 0; + $object->statut = 0; + + // Clear fields + // ... + + // Create clone + $object->context['createfromclone'] = 'createfromclone'; + $result = $object->create($user); + + // Other options + if ($result < 0) + { + $this->error = $object->error; + $error++; + } + + unset($object->context['createfromclone']); + + // End + if (!$error) + { + $this->db->commit(); + return $object->id; + } + else + { + $this->db->rollback(); + return -1; + } + } + + + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + public function initAsSpecimen() + { + $this->id = 0; + + $this->fk_tva = ''; + $this->datec = ''; + $this->tms = ''; + $this->datep = ''; + $this->amount = ''; + $this->fk_typepaiement = ''; + $this->num_payment = ''; + $this->note_private = ''; + $this->note_public = ''; + $this->fk_bank = ''; + $this->fk_user_creat = ''; + $this->fk_user_modif = ''; + } + + + /** + * Add record into bank for payment with links between this bank record and invoices of payment. + * All payment properties must have been set first like after a call to create(). + * + * @param User $user Object of user making payment + * @param string $mode 'payment_sc' + * @param string $label Label to use in bank record + * @param int $accountid Id of bank account to do link with + * @param string $emetteur_nom Name of transmitter + * @param string $emetteur_banque Name of bank + * @return int <0 if KO, >0 if OK + */ + public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) + { + global $conf; + + // Clean data + $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); + + $error = 0; + + if (!empty($conf->banque->enabled)) + { + include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; + + $acc = new Account($this->db); + $acc->fetch($accountid); + + $total = $this->total; + if ($mode == 'payment_vat') $total = -$total; + + // Insert payment into llx_bank + $bank_line_id = $acc->addline( + $this->datepaye, + $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") + $label, + $total, + $this->num_payment, + '', + $user, + $emetteur_nom, + $emetteur_banque + ); + + // Mise a jour fk_bank dans llx_paiement. + // On connait ainsi le paiement qui a genere l'ecriture bancaire + if ($bank_line_id > 0) + { + $result = $this->update_fk_bank($bank_line_id); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + + // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction + $url = ''; + if ($mode == 'payment_vat') $url = DOL_URL_ROOT.'/compta/payment_vat/card.php?id='; + if ($url) + { + $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); + if ($result <= 0) + { + $error++; + dol_print_error($this->db); + } + } + + // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) + $linkaddedforthirdparty = array(); + foreach ($this->amounts as $key => $value) + { + if ($mode == 'payment_vat') + { + $tva = new Tva($this->db); + $tva->fetch($key); + $result = $acc->add_url_line($bank_line_id, $tva->id, DOL_URL_ROOT.'/compta/tva/card.php?id=', '('.$tva->label.')', 'vat'); + if ($result <= 0) dol_print_error($this->db); + } + } + } + else + { + $this->error = $acc->error; + $error++; + } + } + + if (!$error) + { + return 1; + } + else + { + return -1; + } + } + + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Mise a jour du lien entre le paiement de tva et la ligne dans llx_bank generee + * + * @param int $id_bank Id if bank + * @return int >0 if OK, <=0 if KO + */ + public function update_fk_bank($id_bank) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."paiementtva SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + + dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); + $result = $this->db->query($sql); + if ($result) + { + return 1; + } + else + { + $this->error = $this->db->error(); + return 0; + } + } + + + /** + * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle + */ + public function getLibStatut($mode = 0) + { + return $this->LibStatut($this->statut, $mode); + } + + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + /** + * Renvoi le libelle d'un statut donne + * + * @param int $status Statut + * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto + * @return string Libelle du statut + */ + public function LibStatut($status, $mode = 0) + { + // phpcs:enable + global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + + $langs->load('compta'); + /*if ($mode == 0) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 1) + { + if ($status == 0) return $langs->trans('ToValidate'); + if ($status == 1) return $langs->trans('Validated'); + } + if ($mode == 2) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 3) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 4) + { + if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); + if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); + } + if ($mode == 5) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + } + if ($mode == 6) + { + if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); + if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); + }*/ + return ''; + } + + /** + * Return clicable name (with picto eventually) + * + * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto + * @param int $maxlen Longueur max libelle + * @return string Chaine avec URL + */ + public function getNomUrl($withpicto = 0, $maxlen = 0) + { + global $langs; + + $result = ''; + + if (empty($this->ref)) $this->ref = $this->lib; + $label = $langs->trans("ShowPayment").': '.$this->ref; + + if (!empty($this->id)) { + $link = ''; + $linkend = ''; + + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; + } + + return $result; + } +} diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 668a58c4f77..c9ed4bd5671 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2011-2017 Alexandre Spangaro * Copyright (C) 2018 Philippe Grand * Copyright (C) 2018 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,6 +76,10 @@ class Tva extends CommonObject */ public $fk_user_modif; + + const STATUS_UNPAID = 0; + const STATUS_PAID = 1; + /** * Constructor * @@ -102,8 +107,10 @@ class Tva extends CommonObject // Clean parameters $this->amount = trim($this->amount); $this->label = trim($this->label); + $this->type_payment = (int) $this->type_payment; $this->note = trim($this->note); - $this->fk_bank = (int) $this->fk_bank; + //$this->fk_bank = (int) $this->fk_bank; + $this->fk_account = (int) $this->fk_account; $this->fk_user_creat = (int) $this->fk_user_creat; $this->fk_user_modif = (int) $this->fk_user_modif; @@ -120,7 +127,8 @@ class Tva extends CommonObject $sql .= "amount,"; $sql .= "label,"; $sql .= "note,"; - $sql .= "fk_bank,"; + $sql .= "fk_account,"; + $sql .= "fk_typepayment,"; $sql .= "fk_user_creat,"; $sql .= "fk_user_modif"; $sql .= ") VALUES ("; @@ -130,7 +138,8 @@ class Tva extends CommonObject $sql .= " '".$this->db->escape($this->amount)."',"; $sql .= " '".$this->db->escape($this->label)."',"; $sql .= " '".$this->db->escape($this->note)."',"; - $sql .= " ".($this->fk_bank <= 0 ? "NULL" : "'".$this->db->escape($this->fk_bank)."'").","; + $sql .= " '".$this->db->escape($this->fk_account)."',"; + $sql .= " '".$this->db->escape($this->type_payment)."',"; $sql .= " '".$this->db->escape($this->fk_user_creat)."',"; $sql .= " '".$this->db->escape($this->fk_user_modif)."'"; $sql .= ")"; @@ -182,7 +191,6 @@ class Tva extends CommonObject $this->amount = trim($this->amount); $this->label = trim($this->label); $this->note = trim($this->note); - $this->fk_bank = (int) $this->fk_bank; $this->fk_user_creat = (int) $this->fk_user_creat; $this->fk_user_modif = (int) $this->fk_user_modif; @@ -199,7 +207,6 @@ class Tva extends CommonObject $sql .= " amount=".price2num($this->amount).","; $sql .= " label='".$this->db->escape($this->label)."',"; $sql .= " note='".$this->db->escape($this->note)."',"; - $sql .= " fk_bank=".$this->fk_bank.","; $sql .= " fk_user_creat=".$this->fk_user_creat.","; $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? $this->fk_user_modif : $user->id).""; $sql .= " WHERE rowid=".$this->id; @@ -232,6 +239,40 @@ class Tva extends CommonObject } } + /** + * Tag TVA as payed completely + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_paid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql .= " paye = 1"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } + + /** + * Remove tag payed on TVA + * + * @param User $user Object user making change + * @return int <0 if KO, >0 if OK + */ + public function set_unpaid($user) + { + // phpcs:enable + $sql = "UPDATE ".MAIN_DB_PREFIX."tva SET"; + $sql .= " paye = 0"; + $sql .= " WHERE rowid = ".$this->id; + $return = $this->db->query($sql); + if ($return) return 1; + else return -1; + } + /** * Load object in memory from database @@ -254,15 +295,15 @@ class Tva extends CommonObject $sql .= " t.num_payment,"; $sql .= " t.label,"; $sql .= " t.note,"; - $sql .= " t.fk_bank,"; + $sql .= " t.paye,"; $sql .= " t.fk_user_creat,"; $sql .= " t.fk_user_modif,"; - $sql .= " b.fk_account,"; - $sql .= " b.fk_type,"; - $sql .= " b.rappro"; + $sql .= " t.fk_account"; + //$sql .= " b.fk_type,"; + //$sql .= " b.rappro"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; - $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; + //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; $sql .= " WHERE t.rowid = ".$id; dol_syslog(get_class($this)."::fetch", LOG_DEBUG); @@ -282,8 +323,8 @@ class Tva extends CommonObject $this->type_payment = $obj->fk_typepayment; $this->num_payment = $obj->num_payment; $this->label = $obj->label; + $this->paye = $obj->paye; $this->note = $obj->note; - $this->fk_bank = $obj->fk_bank; $this->fk_user_creat = $obj->fk_user_creat; $this->fk_user_modif = $obj->fk_user_modif; $this->fk_account = $obj->fk_account; @@ -735,8 +776,8 @@ class Tva extends CommonObject */ public function getSommePaiement() { - $table = 'paiementcharge'; - $field = 'fk_charge'; + $table = 'paiementtva'; + $field = 'fk_tva'; $sql = 'SELECT sum(amount) as amount'; $sql .= ' FROM '.MAIN_DB_PREFIX.$table; @@ -808,29 +849,54 @@ class Tva extends CommonObject } /** - * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) + * Retourne le libelle du statut d'une TVA (impaye, payee) * - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label */ - public function getLibStatut($mode = 0) + public function getLibStatut($mode = 0, $alreadypaid = -1) { - return $this->LibStatut($this->statut, $mode); + return $this->LibStatut($this->paye, $mode, $alreadypaid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps + // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Renvoi le libelle d'un statut donne + * Renvoi le libelle d'un statut donne * - * @param int $status Statut - * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto - * @return string Libelle du statut + * @param int $status Id status + * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @return string Label */ - public function LibStatut($status, $mode = 0) - { - // phpcs:enable - global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage + public function LibStatut($status, $mode = 0, $alreadypaid = -1) + { + // phpcs:enable + global $langs; - return ''; - } + // Load translation files required by the page + $langs->loadLangs(array("customers", "bills")); + + // We reinit status array to force to redefine them because label may change according to properties values. + $this->labelStatus = array(); + $this->labelStatusShort = array(); + + if (empty($this->labelStatus) || empty($this->labelStatusShort)) + { + global $langs; + //$langs->load("mymodule"); + $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid'); + $this->labelStatus[self::STATUS_PAID] = $langs->trans('BillStatusPaid'); + if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatus[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid'); + $this->labelStatusShort[self::STATUS_PAID] = $langs->trans('BillStatusPaid'); + if ($status == self::STATUS_UNPAID && $alreadypaid <> 0) $this->labelStatusShort[self::STATUS_UNPAID] = $langs->trans("BillStatusStarted"); + } + + $statusType = 'status1'; + if ($status == 0 && $alreadypaid <> 0) $statusType = 'status3'; + if ($status == 1) $statusType = 'status6'; + + return dolGetStatus($this->labelStatus[$status], $this->labelStatusShort[$status], '', $statusType, $mode); + } } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 0a785aa78cd..15f03979b8a 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -5,6 +5,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2014 Ferran Marcet * Copyright (C) 2018 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -35,6 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/localtax/class/localtax.class.php'; // Load translation files required by the page $langs->loadLangs(array("other", "compta", "banks", "bills", "companies", "product", "trips", "admin")); +$form = new Form($db); $now = dol_now(); $current_date = dol_getdate($now); if (empty($conf->global->SOCIETE_FISCAL_MONTH_START)) $conf->global->SOCIETE_FISCAL_MONTH_START = 1; @@ -114,7 +116,7 @@ $result = restrictedArea($user, 'tax', '', '', 'charges'); */ function pt($db, $sql, $date) { - global $conf, $bc, $langs; + global $conf, $bc, $langs, $form; $result = $db->query($sql); if ($result) { @@ -126,7 +128,7 @@ function pt($db, $sql, $date) print ''; print ''.$date.''; print ''.$langs->trans("ClaimedForThisPeriod").''; - print ''.$langs->trans("PaidDuringThisPeriod").''; + print ''.$langs->trans("PaidDuringThisPeriod").$form->textwithpicto('', $langs->trans('PaidDuringThisPeriodDesc'), 1).''; print "\n"; $totalclaimed = 0; @@ -218,7 +220,6 @@ function pt($db, $sql, $date) * View */ -$form = new Form($db); $company_static = new Societe($db); $tva = new Tva($db); @@ -561,18 +562,19 @@ print load_fiche_titre($langs->trans("VATPaid"), '', ''); $sql = ''; -$sql .= "SELECT SUM(amount) as mm, date_format(f.datev,'%Y-%m') as dm, 'claimed' as mode"; -$sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; -$sql .= " WHERE f.entity = ".$conf->entity; -$sql .= " AND (f.datev >= '".$db->idate($date_start)."' AND f.datev <= '".$db->idate($date_end)."')"; +$sql .= "SELECT SUM(amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'claimed' as mode"; +$sql .= " FROM ".MAIN_DB_PREFIX."tva as tva"; +$sql .= " WHERE tva.entity = ".$conf->entity; +$sql .= " AND (tva.datev >= '".$db->idate($date_start)."' AND tva.datev <= '".$db->idate($date_end)."')"; $sql .= " GROUP BY dm"; $sql .= " UNION "; -$sql .= "SELECT SUM(amount) as mm, date_format(f.datep,'%Y-%m') as dm, 'paid' as mode"; -$sql .= " FROM ".MAIN_DB_PREFIX."tva as f"; -$sql .= " WHERE f.entity = ".$conf->entity; -$sql .= " AND (f.datep >= '".$db->idate($date_start)."' AND f.datep <= '".$db->idate($date_end)."')"; +$sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode"; +$sql .= " FROM ".MAIN_DB_PREFIX."tva as tva"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementtva as ptva ON (tva.rowid = ptva.fk_tva)"; +$sql .= " WHERE tva.entity = ".$conf->entity; +$sql .= " AND (tva.datev >= '".$db->idate($date_start)."' AND tva.datev <= '".$db->idate($date_end)."')"; $sql .= " GROUP BY dm"; $sql .= " ORDER BY dm ASC, mode ASC"; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 003a7eabcad..e2dca56dddc 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2020 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011-2019 Alexandre Spangaro + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -47,6 +48,7 @@ $search_dateend_end = dol_mktime(23, 59, 59, GETPOST('search_dateend_endmonth', $search_datepayment_start = dol_mktime(0, 0, 0, GETPOST('search_datepayment_startmonth', 'int'), GETPOST('search_datepayment_startday', 'int'), GETPOST('search_datepayment_startyear', 'int')); $search_datepayment_end = dol_mktime(23, 59, 59, GETPOST('search_datepayment_endmonth', 'int'), GETPOST('search_datepayment_endday', 'int'), GETPOST('search_datepayment_endyear', 'int')); $search_amount = GETPOST('search_amount', 'alpha'); +$search_status = GETPOST('search_status', 'int'); $month = GETPOST("month", "int"); $year = GETPOST("year", "int"); @@ -88,6 +90,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' $search_datepayment_end = ''; $search_account = ''; $search_amount = ""; + $search_status = ''; $year = ""; $month = ""; $typeid = ""; @@ -98,24 +101,26 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x' * View */ -llxHeader('', $langs->trans("VATPayments")); +llxHeader('', $langs->trans("VATDeclarations")); $form = new Form($db); $formother = new FormOther($db); $tva_static = new Tva($db); $bankstatic = new Account($db); -$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank, pst.code as payment_code,"; -$sql .= " ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel"; +$sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.num_payment, pst.code as payment_code, "; +$sql .= " SUM(ptva.amount) as alreadypayed"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementtva as ptva ON ptva.fk_tva = t.rowid"; +//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; +//$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql .= " WHERE t.entity IN (".getEntity('tax').")"; if ($search_ref) $sql .= natural_search("t.rowid", $search_ref); if ($search_label) $sql .= natural_search("t.label", $search_label); if ($search_account > 0) $sql .= " AND b.fk_account=".$search_account; if ($search_amount) $sql .= natural_search("t.amount", price2num(trim($search_amount)), 1); +if ($search_status != '' && $search_status >= 0) $sql .= " AND t.paye = ".$db->escape($search_status); if ($search_dateend_start) $sql .= " AND t.datev >= '".$db->idate($search_dateend_start)."'"; if ($search_dateend_end) $sql .= " AND t.datev <= '".$db->idate($search_dateend_end)."'"; if ($search_datepayment_start) $sql .= " AND t.datep >= '".$db->idate($search_datepayment_start)."'"; @@ -127,6 +132,7 @@ if ($filtre) { if ($typeid) { $sql .= " AND t.fk_typepayment=".$typeid; } +$sql .= " GROUP BY t.rowid, t.amount, t.datev, t.label, t.paye"; $sql .= $db->order($sortfield, $sortorder); $totalnboflines = 0; $result = $db->query($sql); @@ -144,9 +150,15 @@ if ($result) $total = 0; $param = ''; - if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; - if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; if ($typeid) $param .= '&typeid='.$typeid; + if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage); + if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit); + if ($search_ref) $param .= '&search_ref='.urlencode($search_ref); + if ($search_label) $param .= '&search_label='.urlencode($search_label); + if ($search_project_ref >= 0) $param .= "&search_project_ref=".urlencode($search_project_ref); + if ($search_amount) $param .= '&search_amount='.urlencode($search_amount); + if ($search_typeid) $param .= '&search_typeid='.urlencode($search_typeid); + if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); $newcardbutton = ''; if ($user->rights->tax->charges->creer) @@ -161,7 +173,7 @@ if ($result) print ''; print ''; - print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); + print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $totalnboflines, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); print '
'; print ''."\n"; @@ -182,7 +194,7 @@ if ($result) print $form->selectDate($search_dateend_end ? $search_dateend_end : -1, 'search_dateend_end', 0, 0, 1); print ''; // Date payment - print ''; // Account - if (!empty($conf->banque->enabled)) + /*if (!empty($conf->banque->enabled)) { print ''; - } + }*/ // Amount print ''; + + // Status + print ''; + print ''; + print "\n"; print ''; print_liste_field_titre("Ref", $_SERVER["PHP_SELF"], "t.rowid", "", $param, "", $sortfield, $sortorder); print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "t.label", "", $param, 'align="left"', $sortfield, $sortorder); print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "t.datev", "", $param, 'align="center"', $sortfield, $sortorder); - print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "t.datep", "", $param, 'align="center"', $sortfield, $sortorder); + //print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "t.datep", "", $param, 'align="center"', $sortfield, $sortorder); print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "type", "", $param, '', $sortfield, $sortorder, 'left '); - if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); - print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "t.amount", "", $param, '', $sortfield, $sortorder, 'right '); + //if (!empty($conf->banque->enabled)) print_liste_field_titre("Account", $_SERVER["PHP_SELF"], "ba.label", "", $param, "", $sortfield, $sortorder); + print_liste_field_titre("Amount", $_SERVER["PHP_SELF"], "t.amount", "", $param, '', $sortfield, $sortorder, 'right '); + print_liste_field_titre("Status", $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder); print_liste_field_titre('', $_SERVER["PHP_SELF"], "", '', '', '', $sortfield, $sortorder, 'maxwidthsearch '); print "\n"; @@ -246,11 +267,11 @@ if ($result) // Date end period print '\n"; // Date payment - print '\n"; + //print '\n"; // Type print $type; // Account - if (!empty($conf->banque->enabled)) + /*if (!empty($conf->banque->enabled)) { print ''; - } + }*/ // Amount $total = $total + $obj->amount; print '"; - print ""; - print "\n"; + + print ''; + if (!$i) $totalarray['nbfield']++; + + print ""; $i++; } - $colspan = 5; + $colspan = 4; if (!empty($conf->banque->enabled)) $colspan++; - print ''; + print ''; print ''; - print ""; + print ""; print "
'; + /*print ''; print '
'; print $langs->trans('From').' '; print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1); @@ -190,34 +202,43 @@ if ($result) print '
'; print $langs->trans('to').' '; print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1); - print '
'; + print '
';*/ // Type print '
'; $form->select_types_paiements($typeid, 'typeid', '', 0, 1, 1, 16); print ''; $form->select_comptes($search_account, 'search_account', 0, '', 1); print ''; + $liststatus = array('0'=>$langs->trans("Unpaid"), '1'=>$langs->trans("Paid")); + print $form->selectarray('search_status', $liststatus, $search_status, 1); + print ''; $searchpicto = $form->showFilterAndCheckAddButtons(0); print $searchpicto; print '
'.dol_print_date($db->jdate($obj->datev), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'.dol_print_date($db->jdate($obj->datep), 'day')."'; if ($obj->fk_bank > 0) @@ -269,21 +290,24 @@ if ($result) } else print ' '; print ''.price($obj->amount)." 
'.$tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed).' 
'.$langs->trans("Total").'
'.$langs->trans("Total").''.price($total).' 
  
"; print '
'; diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php new file mode 100644 index 00000000000..b6910610454 --- /dev/null +++ b/htdocs/compta/tva/payments.php @@ -0,0 +1,502 @@ + + * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2005-2010 Regis Houssin + * Copyright (C) 2011-2016 Alexandre Spangaro + * Copyright (C) 2011-2014 Juanjo Menent + * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2021 Gauthier VERDOL + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ + +/** + * \file htdocs/compta/tva/payments.php + * \ingroup compta + * \brief Page to list payments of special expenses + */ + +require '../../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; +require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; + +// Load translation files required by the page +$langs->loadLangs(array('compta', 'bills')); + +// Security check +if ($user->socid) $socid = $user->socid; +$result = restrictedArea($user, 'tax|salaries', '', '', 'charges|'); + +$mode = GETPOST("mode", 'alpha'); +$year = GETPOST("year", 'int'); +$filtre = GETPOST("filtre", 'alpha'); +if (!$year && $mode != 'tvaonly') { $year = date("Y", time()); } + +$limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit; +$sortfield = GETPOST("sortfield", 'alpha'); +$sortorder = GETPOST("sortorder", 'alpha'); +$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int'); +if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1 +$offset = $limit * $page; +$pageprev = $page - 1; +$pagenext = $page + 1; +if (!$sortfield) $sortfield = "ptva.datep"; +if (!$sortorder) $sortorder = "DESC"; + + +/* + * View + */ + +$tva_static = new Tva($db); +$tva = new Tva($db); +$payment_vat_static = new PaymentVAT($db); +$sal_static = new PaymentSalary($db); + +llxHeader('', $langs->trans("VATExpensesArea")); + +$title = $langs->trans("VATArea"); +if ($mode == 'tvaonly') $title = $langs->trans("VATPayments"); + +$param = ''; +if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.$contextpage; +if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.$limit; +if ($mode == 'tvaonly') $param = '&mode=tvaonly'; +if ($sortfield) $param .= '&sortfield='.$sortfield; +if ($sortorder) $param .= '&sortorder='.$sortorder; + + +print '
'; +if ($optioncss != '') print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if ($mode != 'tvaonly') +{ + $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); +} +else +{ + print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); +} + +if ($year) $param .= '&year='.$year; + +if ($mode != 'tvaonly') +{ + print $langs->trans("DescTaxAndDividendsArea").'
'; + print "
"; +} + +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + // Social contributions only + if ($mode != 'tvaonly') + { + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + } + + print ''; + print ''; + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "ptva.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "ptva.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("Type", $_SERVER["PHP_SELF"], "pct.code", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("BankAccount", $_SERVER["PHP_SELF"], "bank.ref", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("LabelContrib", $_SERVER["PHP_SELF"], "tva.label", "", $param, '', $sortfield, $sortorder); + //print_liste_field_titre("TypeContrib", $_SERVER["PHP_SELF"], "tva.fk_type", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "tva.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "tva.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "ptva.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + $sql = "SELECT tva.rowid, tva.label as label, b.fk_account"; + $sql .= ", tva.datev"; + $sql .= ", tva.amount as total,"; + $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; + $sql .= " pct.code as payment_code"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,"; + $sql .= " ".MAIN_DB_PREFIX."paiementtva as ptva"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = ptva.fk_bank)"; + $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank_account as bank ON (bank.rowid = b.fk_account)"; + $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id"; + $sql .= " WHERE ptva.fk_tva = tva.rowid"; + $sql .= " AND tva.entity = ".$conf->entity; + if ($year > 0) + { + $sql .= " AND ("; + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " (tva.datev IS NOT NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= " OR (tva.datev IS NULL AND tva.datev between '".$db->idate(dol_get_first_day($year))."' AND '".$db->idate(dol_get_last_day($year))."')"; + $sql .= ")"; + } + if (preg_match('/^cs\./', $sortfield) + || preg_match('/^tva\./', $sortfield) + || preg_match('/^ptva\./', $sortfield) + || preg_match('/^pct\./', $sortfield) + || preg_match('/^bank\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + //$sql.= $db->plimit($limit+1,$offset); + //print $sql; + + dol_syslog("compta/tva/payments.php: select payment", LOG_DEBUG); + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + $total = 0; + $totalnb = 0; + $totalpaye = 0; + + while ($i < min($num, $limit)) + { + $obj = $db->fetch_object($resql); + + $payment_vat_static->id = $obj->pid; + $payment_vat_static->ref = $obj->pid; + + print ''; + // Ref payment + print '\n"; + // Date payment + print ''; + // Type payment + print ''; + // Account + print ''; + // Label + print ''; + // Type + //print ''; + // Date + $date = $obj->datev; + print ''; + // Expected to pay + print ''; + // Paid + print ''; + print ''; + + $total = $total + $obj->total; + $totalnb = $totalnb + $obj->nb; + $totalpaye = $totalpaye + $obj->totalpaye; + $i++; + } + print ''; + print ''; // A total here has no sense + //print ''; + print ''; + print ''; + print ''; + print '"; + print ""; + } + else + { + dol_print_error($db); + } + print '
'.$payment_vat_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day').''; + if ($obj->payment_code) print $langs->trans("PaymentTypeShort".$obj->payment_code).' '; + print $obj->num_payment.''; + $account = new Account($db); + $account->fetch($obj->fk_account); + print $account->getNomUrl(1); + print ''; + $tva->id = $obj->rowid; + $tva->ref = $obj->rowid; + $tva->label = $obj->label; + print $tva->getNomUrl(1, '20'); + print ''.$obj->type_label.''.dol_print_date($date, 'day').''.price($obj->total).''; + if ($obj->totalpaye) print price($obj->totalpaye); + print '
'.$langs->trans("Total").'    '.price($totalpaye)."
'; +} + +// VAT +if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) +{ + if (!$mode || $mode != 'tvaonly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->trans("VATPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm"; + $sql .= " FROM ".MAIN_DB_PREFIX."tva as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dm), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total).'  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } +} + +// Localtax +if ($mysoc->localtax1_assuj == "1" && $mysoc->localtax2_assuj == "1") +{ + $j = 1; + $numlt = 3; +} +elseif ($mysoc->localtax1_assuj == "1") +{ + $j = 1; + $numlt = 2; +} +elseif ($mysoc->localtax2_assuj == "1") +{ + $j = 2; + $numlt = 3; +} +else +{ + $j = 0; + $numlt = 0; +} + +while ($j < $numlt) +{ + if (!$mode || $mode != 'tvaonly') + { + print "
"; + + $tva = new Tva($db); + + print load_fiche_titre($langs->transcountry(($j == 1 ? "LT1Payments" : "LT2Payments"), $mysoc->country_code).($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + + $sql = "SELECT pv.rowid, pv.amount, pv.label, pv.datev as dm, pv.datep as dp"; + $sql .= " FROM ".MAIN_DB_PREFIX."localtax as pv"; + $sql .= " WHERE pv.entity = ".$conf->entity." AND localtaxtype = ".$j; + if ($year > 0) + { + // Si period renseignee on l'utilise comme critere de date, sinon on prend date echeance, + // ceci afin d'etre compatible avec les cas ou la periode n'etait pas obligatoire + $sql .= " AND pv.datev between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + } + if (preg_match('/^pv/', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "pv.datev", "", $param, 'width="120"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "pv.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "pv.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "pv.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "pv.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $tva_static->id = $obj->rowid; + $tva_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print '"; + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dm), 'day').'".$obj->label."'.price($obj->amount)."'.$tva_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->dp), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").''.price($total)."  '.price($total)."
"; + $db->free($result); + } + else + { + dol_print_error($db); + } + } + $j++; +} + + +// Payment Salary +if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) +{ + if (!$mode || $mode != 'tvaonly') + { + $sal = new PaymentSalary($db); + + print "
"; + + print load_fiche_titre($langs->trans("SalariesPayments").($year ? ' ('.$langs->trans("Year").' '.$year.')' : ''), '', ''); + + $sql = "SELECT s.rowid, s.amount, s.label, s.datep as datep, s.datev as datev, s.datesp, s.dateep, s.salary, u.salary as current_salary"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_salary as s, ".MAIN_DB_PREFIX."user as u"; + $sql .= " WHERE s.entity IN (".getEntity('user').")"; + $sql .= " AND u.rowid = s.fk_user"; + if ($year > 0) + { + $sql .= " AND (s.datesp between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."'"; + $sql .= " OR s.dateep between '".$db->idate(dol_get_first_day($year, 1, false))."' AND '".$db->idate(dol_get_last_day($year, 12, false))."')"; + } + if (preg_match('/^s\./', $sortfield)) $sql .= $db->order($sortfield, $sortorder); + + $result = $db->query($sql); + if ($result) + { + $num = $db->num_rows($result); + $i = 0; + $total = 0; + print ''; + print ''; + print_liste_field_titre("PeriodEndDate", $_SERVER["PHP_SELF"], "s.dateep", "", $param, 'width="140px"', $sortfield, $sortorder); + print_liste_field_titre("Label", $_SERVER["PHP_SELF"], "s.label", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("ExpectedToPay", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print_liste_field_titre("RefPayment", $_SERVER["PHP_SELF"], "s.rowid", "", $param, '', $sortfield, $sortorder); + print_liste_field_titre("DatePayment", $_SERVER["PHP_SELF"], "s.datep", "", $param, 'align="center"', $sortfield, $sortorder); + print_liste_field_titre("PayedByThisPayment", $_SERVER["PHP_SELF"], "s.amount", "", $param, 'class="right"', $sortfield, $sortorder); + print "\n"; + + while ($i < $num) + { + $obj = $db->fetch_object($result); + + $total = $total + $obj->amount; + + print ''; + + print ''."\n"; + + print "\n"; + + print '"; + + // Ref payment + $sal_static->id = $obj->rowid; + $sal_static->ref = $obj->rowid; + print '\n"; + + print '\n"; + print '"; + print "\n"; + + $i++; + } + print ''; + print ''; // A total here has no sense + print ''; + print ''; + print '"; + print ""; + + print "
'.dol_print_date($db->jdate($obj->dateep), 'day').'".$obj->label."'.($obj->salary ?price($obj->salary) : '')."'.$sal_static->getNomUrl(1)."'.dol_print_date($db->jdate($obj->datep), 'day')."'.price($obj->amount)."
'.$langs->trans("Total").'  '.price($total)."
"; + $db->free($result); + + print "
"; + } + else + { + dol_print_error($db); + } + } +} + +print '
'; + +// End of page +llxFooter(); +$db->close(); diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index dea6bdf60ad..3228f299790 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -14,6 +14,7 @@ * Copyright (C) 2017 Rui Strecht * Copyright (C) 2018-2019 Frédéric France * Copyright (C) 2018 Josep Lluís Amador + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -2042,6 +2043,7 @@ abstract class CommonObject $fieldname = 'fk_mode_reglement'; if ($this->element == 'societe') $fieldname = 'mode_reglement'; if (get_class($this) == 'Fournisseur') $fieldname = 'mode_reglement_supplier'; + if (get_class($this) == 'Tva') $fieldname = 'fk_typepayment'; $sql = 'UPDATE '.MAIN_DB_PREFIX.$this->table_element; $sql .= ' SET '.$fieldname.' = '.(($id > 0 || $id == '0') ? $id : 'NULL'); diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 023ade28052..74510327967 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -15,6 +15,7 @@ * Copyright (C) 2015 Jean-François Ferry * Copyright (C) 2018-2020 Frédéric France * Copyright (C) 2019 Thibault Foucart + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1611,7 +1612,7 @@ function dol_banner_tab($object, $paramid, $morehtml = '', $shownav = 1, $fieldi $morehtmlstatus .= ''.$object->getLibStatut(6, 1).''; } } - elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan'))) + elseif (in_array($object->element, array('facture', 'invoice', 'invoice_supplier', 'chargesociales', 'loan', 'tva'))) { $tmptxt = $object->getLibStatut(6, $object->totalpaye); if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3)) $tmptxt = $object->getLibStatut(5, $object->totalpaye); diff --git a/htdocs/core/lib/vat.lib.php b/htdocs/core/lib/vat.lib.php index 68e52a142a3..8f5f6941645 100644 --- a/htdocs/core/lib/vat.lib.php +++ b/htdocs/core/lib/vat.lib.php @@ -1,6 +1,7 @@ * Copyright (C) 2018 Philippe Grand + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,7 +38,7 @@ function vat_prepare_head($object) $head = array(); $head[$tab][0] = DOL_URL_ROOT.'/compta/tva/card.php?id='.$object->id; - $head[$tab][1] = $langs->trans('VATPayment'); + $head[$tab][1] = $langs->trans('VATDeclaration'); $head[$tab][2] = 'card'; $tab++; diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 0f85d824ca2..9b54deb6afd 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -6,6 +6,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2018 Ferran Marcet * Copyright (C) 2018-2019 Frédéric France + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -1116,6 +1117,7 @@ function print_left_eldy_menu($db, $menu_array_before, $menu_array_after, &$tabM if ($usemenuhider || empty($leftmenu) || preg_match('/^tax_vat/i', $leftmenu)) { $newmenu->add("/compta/tva/card.php?leftmenu=tax_vat&action=create", $langs->trans("New"), 2, $user->rights->tax->charges->creer); $newmenu->add("/compta/tva/list.php?leftmenu=tax_vat", $langs->trans("List"), 2, $user->rights->tax->charges->lire); + $newmenu->add("/compta/tva/payments.php?mode=tvaonly&leftmenu=tax_vat", $langs->trans("Payments"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/index.php?leftmenu=tax_vat", $langs->trans("ReportByMonth"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/clients.php?leftmenu=tax_vat", $langs->trans("ReportByCustomers"), 2, $user->rights->tax->charges->lire); $newmenu->add("/compta/tva/quadri_detail.php?leftmenu=tax_vat", $langs->trans("ReportByQuarter"), 2, $user->rights->tax->charges->lire); diff --git a/htdocs/install/mysql/tables/llx_paiementtva.sql b/htdocs/install/mysql/tables/llx_paiementtva.sql new file mode 100644 index 00000000000..c73f1a90c6d --- /dev/null +++ b/htdocs/install/mysql/tables/llx_paiementtva.sql @@ -0,0 +1,35 @@ +-- =================================================================== +-- Copyright (C) 2004 Laurent Destailleur +-- Copyright (C) 2021 Gauthier VERDOL +-- +-- This program is free software; you can redistribute it and/or modify +-- it under the terms of the GNU General Public License as published by +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- =================================================================== + +create table llx_paiementtva +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_tva integer, + datec datetime, -- date de creation + tms timestamp, + datep datetime, -- payment date + amount double(24,8) DEFAULT 0, + fk_typepaiement integer NOT NULL, + num_paiement varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, -- creation user + fk_user_modif integer -- last modification user + +)ENGINE=innodb; diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang index a4ac01774f3..0b97213b5d5 100644 --- a/htdocs/langs/en_US/bills.lang +++ b/htdocs/langs/en_US/bills.lang @@ -493,12 +493,14 @@ Cash=Cash Reported=Delayed DisabledBecausePayments=Not possible since there are some payments CantRemovePaymentWithOneInvoicePaid=Can't remove payment since there is at least one invoice classified paid +CantRemovePaymentVATPaid=Can't remove payment since VAT declaration is classified paid ExpectedToPay=Expected payment CantRemoveConciliatedPayment=Can't remove reconciled payment PayedByThisPayment=Paid by this payment ClosePaidInvoicesAutomatically=Classify automatically all standard, down payment or replacement invoices as "Paid" when payment is done entirely. ClosePaidCreditNotesAutomatically=Classify automatically all credit notes as "Paid" when refund is done entirely. ClosePaidContributionsAutomatically=Classify automatically all social or fiscal contributions as "Paid" when payment is done entirely. +ClosePaidVATAutomatically=Classify automatically VAT declaration as "Paid" when payment is done entirely. AllCompletelyPayedInvoiceWillBeClosed=All invoices with no remainder to pay will be automatically closed with status "Paid". ToMakePayment=Pay ToMakePaymentBack=Pay back diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index 8a8c837ac87..7b1514f1835 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -65,6 +65,7 @@ LT2SupplierIN=SGST purchases VATCollected=VAT collected StatusToPay=To pay SpecialExpensesArea=Area for all special payments +VATExpensesArea=Area for all TVA payments SocialContribution=Social or fiscal tax SocialContributions=Social or fiscal taxes SocialContributionsDeductibles=Deductible social or fiscal taxes @@ -84,6 +85,7 @@ PaymentCustomerInvoice=Customer invoice payment PaymentSupplierInvoice=vendor invoice payment PaymentSocialContribution=Social/fiscal tax payment PaymentVat=VAT payment +AutomaticCreationPayment=Automatically create a total payment ListPayment=List of payments ListOfCustomerPayments=List of customer payments ListOfSupplierPayments=List of vendor payments @@ -103,6 +105,8 @@ LT2PaymentES=IRPF Payment LT2PaymentsES=IRPF Payments VATPayment=Sales tax payment VATPayments=Sales tax payments +VATDeclarations=VAT declarations +VATDeclaration=VAT declaration VATRefund=Sales tax refund NewVATPayment=New sales tax payment NewLocalTaxPayment=New tax %s payment @@ -133,9 +137,13 @@ NoWaitingChecks=No checks awaiting deposit. DateChequeReceived=Check reception date NbOfCheques=No. of checks PaySocialContribution=Pay a social/fiscal tax -ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid? +PayVAT=Pay a VAT declaration +ConfirmPaySocialContribution=Are you sure you want to classify this social or fiscal tax as paid ? +ConfirmPayVAT=Are you sure you want to classify this VAT declaration as paid ? DeleteSocialContribution=Delete a social or fiscal tax payment -ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment? +DeleteVAT=Delete a VAT declaration +ConfirmDeleteSocialContribution=Are you sure you want to delete this social/fiscal tax payment ? +ConfirmDeleteVAT=Are you sure you want to delete this VAT declaration ? ExportDataset_tax_1=Social and fiscal taxes and payments CalcModeVATDebt=Mode %sVAT on commitment accounting%s. CalcModeVATEngagement=Mode %sVAT on incomes-expenses%s. @@ -231,6 +239,7 @@ ACCOUNTING_ACCOUNT_CUSTOMER_Desc=The dedicated accounting account defined on thi ACCOUNTING_ACCOUNT_SUPPLIER=Accounting account used for vendor third parties ACCOUNTING_ACCOUNT_SUPPLIER_Desc=The dedicated accounting account defined on third party card will be used for Subledger accounting only. This one will be used for General Ledger and as default value of Subledger accounting if dedicated vendor accounting account on third party is not defined. ConfirmCloneTax=Confirm the clone of a social/fiscal tax +ConfirmCloneVAT=Confirm the clone of a VAT declaration CloneTaxForNextMonth=Clone it for next month SimpleReport=Simple report AddExtraReport=Extra reports (add foreign and national customer report) @@ -249,7 +258,8 @@ AccountingAffectation=Accounting assignment LastDayTaxIsRelatedTo=Last day of period the tax is related to VATDue=Sale tax claimed ClaimedForThisPeriod=Claimed for the period -PaidDuringThisPeriod=Paid during this period +PaidDuringThisPeriod=Paid for this period +PaidDuringThisPeriodDesc=This is the sum of all payments linked to VAT declarations which have an end-of-period date in the selected date range ByVatRate=By sale tax rate TurnoverbyVatrate=Turnover invoiced by sale tax rate TurnoverCollectedbyVatrate=Turnover collected by sale tax rate From 82b688a2b0be1c3b9f8b94f300c0e90b24b309cd Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 19 Jan 2021 09:10:15 +0100 Subject: [PATCH 004/200] dolgrap.class.php with frederic34 advices --- htdocs/core/class/dolgraph.class.php | 6 ------ 1 file changed, 6 deletions(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 1bc9f175171..a06bda53f07 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -183,7 +183,6 @@ class DolGraph return true; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Hide X Values * @@ -277,7 +276,6 @@ class DolGraph $this->datacolor = $datacolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set border color * @@ -289,7 +287,6 @@ class DolGraph $this->bordercolor = $bordercolor; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set border width * @@ -301,7 +298,6 @@ class DolGraph $this->borderwidth = $borderwidth; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set tooltips labels of the graph * @@ -314,7 +310,6 @@ class DolGraph $this->tooltipsLabels = $tooltipsLabels; } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Set tooltips titles of the graph * @@ -480,7 +475,6 @@ class DolGraph unset($this->bgcolorgrid); } - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** * Mirror Values of the graph * From afab5a977a0b579ef97cbe469c5c5f54c353945a Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Tue, 19 Jan 2021 09:43:06 +0100 Subject: [PATCH 005/200] dolgrap.class.php with frederic34 advices 2 --- htdocs/core/boxes/box_funnel_of_prospection.php | 12 ++++++------ htdocs/core/class/dolgraph.class.php | 15 ++++++--------- 2 files changed, 12 insertions(+), 15 deletions(-) diff --git a/htdocs/core/boxes/box_funnel_of_prospection.php b/htdocs/core/boxes/box_funnel_of_prospection.php index 6d8acdb52bd..519cb2cd306 100644 --- a/htdocs/core/boxes/box_funnel_of_prospection.php +++ b/htdocs/core/boxes/box_funnel_of_prospection.php @@ -230,18 +230,18 @@ class box_funnel_of_prospection extends ModeleBoxes $dolgraph->SetMinValue(0); $dolgraph->SetData($dataseries); $dolgraph->SetLegend($liststatus); - $dolgraph->SetHideXValues(true); + $dolgraph->setHideXValues(true); $dolgraph->SetDataColor(array_values($colorseriesstat)); - $dolgraph->SetBorderColor(array_values($bordercolorseries)); + $dolgraph->setBorderColor(array_values($bordercolorseries)); $dolgraph->setShowLegend(2); $dolgraph->setShowPercent(1); - $dolgraph->SetMirrorGraphValues(true); - $dolgraph->SetBorderWidth(2); + $dolgraph->setMirrorGraphValues(true); + $dolgraph->setBorderWidth(2); $dolgraph->SetType(array('horizontalbars')); $dolgraph->SetHeight('200'); $dolgraph->SetWidth('600'); - $dolgraph->SetTooltipsTitles($liststatus); - $dolgraph->SetTooltipsLabels($customlabels); + $dolgraph->setTooltipsTitles($liststatus); + $dolgraph->setTooltipsLabels($customlabels); $dolgraph->mode = 'depth'; $dolgraph->draw('idgraphleadfunnel'); $stringtoprint .= $dolgraph->show($totaloppnb ? 0 : 1); diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 03d6efd8740..0e5e42331db 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -189,9 +189,8 @@ class DolGraph * @param boolean $bool XValues or not * @return boolean true */ - public function SetHideXValues($bool) + public function setHideXValues($bool) { - // phpcs:enable $this->hideXValues = $bool; return true; } @@ -282,7 +281,7 @@ class DolGraph * @param array $bordercolor Border Color array(array(R,G,B),array(R,G,B)...) or array('#FFFFFF','#......'...) * @return void */ - public function SetBorderColor($bordercolor) + public function setBorderColor($bordercolor) { $this->bordercolor = $bordercolor; } @@ -293,7 +292,7 @@ class DolGraph * @param int $borderwidth Border Width * @return void */ - public function SetBorderWidth($borderwidth) + public function setBorderWidth($borderwidth) { $this->borderwidth = $borderwidth; } @@ -304,9 +303,8 @@ class DolGraph * @param array $tooltipsLabels Tooltips Labels array('...','...'...) * @return void */ - public function SetTooltipsLabels($tooltipsLabels) + public function setTooltipsLabels($tooltipsLabels) { - // phpcs:enable $this->tooltipsLabels = $tooltipsLabels; } @@ -316,9 +314,8 @@ class DolGraph * @param array $tooltipsTitles Tooltips Titles array('...','...'...) * @return void */ - public function SetTooltipsTitles($tooltipsTitles) + public function setTooltipsTitles($tooltipsTitles) { - // phpcs:enable $this->tooltipsTitles = $tooltipsTitles; } @@ -481,7 +478,7 @@ class DolGraph * @param boolean $mirrorGraphValues Mirror Values if true and doesn't if false * @return void */ - public function SetMirrorGraphValues($mirrorGraphValues) + public function setMirrorGraphValues($mirrorGraphValues) { $this->mirrorGraphValues = $mirrorGraphValues; } From b2eca0a3148b5ada5418afbea03abbdaa017a5da Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 19 Jan 2021 12:02:05 +0100 Subject: [PATCH 006/200] FIX : VAT declaration list + migration script --- htdocs/compta/tva/list.php | 102 +++++++----------- .../install/mysql/migration/13.0.0-14.0.0.sql | 33 ++++++ 2 files changed, 74 insertions(+), 61 deletions(-) diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index a142518279f..13cb2ad7386 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2011-2019 Alexandre Spangaro * Copyright (C) 2020 Tobias Sekan + * Copyright (C) 2021 Gauthier VERDOL * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -57,6 +58,7 @@ $search_type = GETPOST('search_type', 'int'); $search_cheque = GETPOST('search_cheque', 'alpha'); $search_account = GETPOST('search_account', 'int'); $search_amount = GETPOST('search_amount', 'alpha'); +$search_status = GETPOST('search_status', 'int'); $limit = GETPOST('limit', 'int') ? GETPOST('limit', 'int') : $conf->liste_limit; $sortfield = GETPOST('sortfield', 'alpha'); @@ -75,12 +77,9 @@ $arrayfields = array( 't.rowid' =>array('checked'=>1, 'position'=>10, 'label'=>"Ref",), 't.label' =>array('checked'=>1, 'position'=>20, 'label'=>"Label"), 't.datev' =>array('checked'=>1, 'position'=>30, 'label'=>"PeriodEndDate"), - 't.datep' =>array('checked'=>1, 'position'=>40, 'label'=>"DatePayment"), 't.fk_typepayment' =>array('checked'=>1, 'position'=>50, 'label'=>"Type"), - 't.num_payment' =>array('checked'=>1, 'position'=>60, 'label'=>"Numero", 'tooltip'=>"ChequeOrTransferNumber"), - 'transaction' =>array('checked'=>1, 'position'=>70, 'label'=>"BankTransactionLine", 'enabled'=>(!empty($conf->banque->enabled))), - 'ba.label' =>array('checked'=>1, 'position'=>80, 'label'=>"Account", 'enable'=>(!empty($conf->banque->enabled))), - 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"PayedByThisPayment"), + 't.amount' =>array('checked'=>1, 'position'=>90, 'label'=>"Amount"), + 't.status' =>array('checked'=>1, 'position'=>90, 'label'=>"Status"), ); $arrayfields = dol_sort_array($arrayfields, 'position'); @@ -113,6 +112,7 @@ if (empty($reshook)) { $search_cheque = ''; $search_account = ''; $search_amount = ''; + $search_status = ''; } } @@ -128,15 +128,13 @@ $bankstatic = new Account($db); $accountingjournal = new AccountingJournal($db); $bankline = new AccountLine($db); -llxHeader('', $langs->trans("VATPayments")); +llxHeader('', $langs->trans("VATDeclarations")); -$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.fk_typepayment as type, t.num_payment, t.fk_bank'; -$sql .= ', ba.rowid as bid, ba.ref as bref, ba.number as bnumber, ba.account_number, ba.fk_accountancy_journal, ba.label as blabel'; -$sql .= ', pst.code as payment_code'; +$sql = 'SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepayment as type, t.num_payment, pst.code as payment_code,'; +$sql .= ' SUM(ptva.amount) as alreadypayed'; $sql .= ' FROM '.MAIN_DB_PREFIX.'tva as t'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'c_paiement as pst ON t.fk_typepayment = pst.id'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; -$sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementtva as ptva ON ptva.fk_tva = t.rowid"; $sql .= ' WHERE t.entity IN ('.getEntity($object->element).')'; if (!empty($search_ref)) $sql .= natural_search('t.rowid', $search_ref); @@ -146,10 +144,11 @@ if (!empty($search_dateend_end)) $sql .= ' AND t.datev <= "'.$db->idate($sea if (!empty($search_datepayment_start)) $sql .= ' AND t.datep >= "'.$db->idate($search_datepayment_start).'"'; if (!empty($search_datepayment_end)) $sql .= ' AND t.datep <= "'.$db->idate($search_datepayment_end).'"'; if (!empty($search_type) && $search_type > 0) $sql .= ' AND t.fk_typepayment='.$search_type; -if (!empty($search_cheque)) $sql .= natural_search('t.num_payment', $search_cheque); if (!empty($search_account) && $search_account > 0) $sql .= ' AND b.fk_account='.$search_account; if (!empty($search_amount)) $sql .= natural_search('t.amount', price2num(trim($search_amount)), 1); +if ($search_status != '' && $search_status >= 0) $sql .= " AND t.paye = ".$db->escape($search_status); +$sql .= " GROUP BY t.rowid, t.amount, t.datev, t.label, t.paye"; $sql .= $db->order($sortfield, $sortorder); $nbtotalofrecords = ''; @@ -200,6 +199,7 @@ if (!empty($search_type) && $search_type > 0) $param .= '&search_type='.$search if (!empty($search_cheque)) $param .= '&search_cheque="'.$search_cheque.'"'; if (!empty($search_account) && $search_account > 0) $param .= '&search_account='.$search_account; if (!empty($search_amount)) $param .= '&search_amount="'.$search_amount.'"'; +if ($search_status != '' && $search_status != '-1') $param .= '&search_status='.urlencode($search_status); print '
'; if ($optioncss != '') print ''; @@ -213,7 +213,7 @@ print ''; $url = DOL_URL_ROOT.'/compta/tva/card.php?action=create'; if (!empty($socid)) $url .= '&socid='.$socid; $newcardbutton = dolGetButtonTitle($langs->trans('NewVATPayment', ($ltt + 1)), '', 'fa fa-plus-circle', $url, '', $user->rights->tax->charges->creer); -print_barre_liste($langs->trans("VATPayments"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); +print_barre_liste($langs->trans("VATDeclarations"), $page, $_SERVER['PHP_SELF'], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_accountancy', 0, $newcardbutton, '', $limit, 0, 0, 1); $varpage = empty($contextpage) ? $_SERVER['PHP_SELF'] : $contextpage; $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields @@ -257,7 +257,7 @@ if (!empty($arrayfields['t.datev']['checked'])) { } // Filter: Date payment -if (!empty($arrayfields['t.datep']['checked'])) { +/*if (!empty($arrayfields['t.datep']['checked'])) { print ''; print '
'; print $form->selectDate($search_datepayment_start ? $search_datepayment_start : -1, 'search_datepayment_start', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("From")); @@ -266,7 +266,7 @@ if (!empty($arrayfields['t.datep']['checked'])) { print $form->selectDate($search_datepayment_end ? $search_datepayment_end : -1, 'search_datepayment_end', 0, 0, 1, '', 1, 0, 0, '', '', '', '', 1, '', $langs->trans("to")); print '
'; print ''; -} +}*/ // Filter: Type if (!empty($arrayfields['t.fk_typepayment']['checked'])) { @@ -275,26 +275,6 @@ if (!empty($arrayfields['t.fk_typepayment']['checked'])) { print ''; } -// Filter: Cheque number -if (!empty($arrayfields['t.num_payment']['checked'])) { - print ''; - print ''; - print ''; -} - -// Filter: Bank transaction number (placeholder) -if (!empty($arrayfields['transaction']['checked'])) { - print ''; - print ''; -} - -// Filter: Bank account -if (!empty($arrayfields['ba.label']['checked'])) { - print ''; - $form->select_comptes($search_account, 'search_account', 0, '', 1); - print ''; -} - // Filter: Amount if (!empty($arrayfields['t.amount']['checked'])) { print ''; @@ -302,6 +282,14 @@ if (!empty($arrayfields['t.amount']['checked'])) { print ''; } +// Status +if (!empty($arrayfields['t.status']['checked'])) { + print ''; + $liststatus = array('0' => $langs->trans("Unpaid"), '1' => $langs->trans("Paid")); + print $form->selectarray('search_status', $liststatus, $search_status, 1); + print ''; +} + // Fields from hook $parameters = array('arrayfields'=>$arrayfields); $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $object may have been modified by hook @@ -319,12 +307,9 @@ if (!empty($conf->global->MAIN_VIEW_LINE_NUMBER_IN_LIST)) print_liste_field_titr if (!empty($arrayfields['t.rowid']['checked'])) print_liste_field_titre($arrayfields['t.rowid']['label'], $_SERVER['PHP_SELF'], 't.rowid', '', $param, '', $sortfield, $sortorder); if (!empty($arrayfields['t.label']['checked'])) print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, 'align="left"', $sortfield, $sortorder); if (!empty($arrayfields['t.datev']['checked'])) print_liste_field_titre($arrayfields['t.datev']['label'], $_SERVER['PHP_SELF'], 't.datev', '', $param, 'align="center"', $sortfield, $sortorder); -if (!empty($arrayfields['t.datep']['checked'])) print_liste_field_titre($arrayfields['t.datep']['label'], $_SERVER['PHP_SELF'], 't.datep', '', $param, 'align="center"', $sortfield, $sortorder); if (!empty($arrayfields['t.fk_typepayment']['checked'])) print_liste_field_titre($arrayfields['t.fk_typepayment']['label'], $_SERVER['PHP_SELF'], 't.fk_typepayment', '', $param, '', $sortfield, $sortorder, 'left '); -if (!empty($arrayfields['t.num_payment']['checked'])) print_liste_field_titre($arrayfields['t.num_payment']['label'], $_SERVER['PHP_SELF'], 't.num_payment', '', $param, '', $sortfield, $sortorder, '', $arrayfields['t.num_payment']['tooltip']); -if (!empty($arrayfields['transaction']['checked'])) print_liste_field_titre($arrayfields['transaction']['label'], $_SERVER['PHP_SELF'], '', '', $param, '', $sortfield, $sortorder); -if (!empty($arrayfields['ba.label']['checked'])) print_liste_field_titre($arrayfields['ba.label']['label'], $_SERVER['PHP_SELF'], 'ba.label', '', $param, '', $sortfield, $sortorder, 'left '); if (!empty($arrayfields['t.amount']['checked'])) print_liste_field_titre($arrayfields['t.amount']['label'], $_SERVER['PHP_SELF'], 't.amount', '', $param, '', $sortfield, $sortorder, 'right '); +if (!empty($arrayfields['t.status']['checked'])) print_liste_field_titre($arrayfields['t.status']['label'], $_SERVER["PHP_SELF"], "t.paye", "", $param, 'class="right"', $sortfield, $sortorder); // Hook fields $parameters = array('arrayfields'=>$arrayfields, 'param'=>$param, 'sortfield'=>$sortfield, 'sortorder'=>$sortorder); @@ -369,10 +354,10 @@ while ($i < min($num, $limit)) { } // Date payment - if (!empty($arrayfields['t.datep']['checked'])) { + /*if (!empty($arrayfields['t.datep']['checked'])) { print ''.dol_print_date($db->jdate($obj->datep), 'day').''; if (!$i) $totalarray['nbfield']++; - } + }*/ // Type if (!empty($arrayfields['t.fk_typepayment']['checked'])) @@ -381,21 +366,8 @@ while ($i < min($num, $limit)) { if (!$i) $totalarray['nbfield']++; } - // Cheque number - if (!empty($arrayfields['t.num_payment']['checked'])) { - print ''.$obj->num_payment.''; - if (!$i) $totalarray['nbfield']++; - } - - // Bank transaction - if (!empty($arrayfields['transaction']['checked'])) { - $bankline->fetch($obj->fk_bank); - print ''.$bankline->getNomUrl(1, 0).''; - if (!$i) $totalarray['nbfield']++; - } - // Account - if (!empty($arrayfields['ba.label']['checked'])) { + /*if (!empty($arrayfields['ba.label']['checked'])) { print ''; if ($obj->fk_bank > 0) { $bankstatic->id = $obj->bid; @@ -411,14 +383,22 @@ while ($i < min($num, $limit)) { } print ''; if (!$i) $totalarray['nbfield']++; - } + }*/ // Amount - $total = $total + $obj->amount; - print ''.price($obj->amount).''; - if (!$i) $totalarray['nbfield']++; - $totalarray['pos'][$totalarray['nbfield']] = 'amount'; - $totalarray['val']['amount'] += $objp->amount; + if (!empty($arrayfields['t.amount']['checked'])) { + $total = $total + $obj->amount; + print '' . price($obj->amount) . ''; + if (!$i) $totalarray['nbfield']++; + $totalarray['pos'][$totalarray['nbfield']] = 'amount'; + $totalarray['val']['amount'] += $obj->amount; + } + + if (!empty($arrayfields['t.status']['checked'])) { + print '' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . ''; + if (!$i) $totalarray['nbfield']++; + if(!empty($arrayfields['t.amount']['checked'])) $totalarray['pos'][$totalarray['nbfield']] = ''; + } // Buttons print ''; diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 90839fe6e95..910ea92d5d1 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -105,3 +105,36 @@ ALTER TABLE llx_propal ADD INDEX idx_propal_fk_warehouse(fk_warehouse); ALTER TABLE llx_product_customer_price ADD COLUMN ref_customer varchar(30); ALTER TABLE llx_product_customer_price_log ADD COLUMN ref_customer varchar(30); + +create table llx_paiementtva +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + fk_tva integer, + datec datetime, -- date de creation + tms timestamp, + datep datetime, -- payment date + amount double(24,8) DEFAULT 0, + fk_typepaiement integer NOT NULL, + num_paiement varchar(50), + note text, + fk_bank integer NOT NULL, + fk_user_creat integer, -- creation user + fk_user_modif integer -- last modification user + +)ENGINE=innodb; + +ALTER TABLE llx_tva ADD paye smallint default 0 NOT NULL; +ALTER TABLE llx_tva ADD fk_account integer; + +INSERT INTO `llx_paiementtva` (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) +SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva; + +UPDATE llx_bank_url url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat'; + +INSERT INTO `llx_bank_url` (fk_bank, url_id, url, label, type) +SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' +FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_paiementtva ptva on (ptva.fk_bank = b.fk_bank) +WHERE type = "vat"; + +ALTER TABLE llx_tva DROP COLUMN fk_bank; +UPDATE llx_tva SET paye = 1; From c35a13bad0c83355abb4969cec1de2fa7021544c Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 19 Jan 2021 12:12:05 +0100 Subject: [PATCH 007/200] FIX : set paid button display test --- htdocs/compta/tva/card.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index aec96c88caa..08b942bf9a2 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -796,7 +796,12 @@ if ($id) } // Classify 'paid' - if ($object->paye == 0 && round($resteapayer) <= 0 && $user->rights->tax->charges->creer) + if ($object->paye == 0 + && ( + (round($resteapayer) <= 0 && $object->amount > 0) + || (round($resteapayer) >= 0 && $object->amount < 0) + ) + && $user->rights->tax->charges->creer) { print ""; } From 694f65082fb3cff426be3b4de7f16d98240e7c15 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Tue, 19 Jan 2021 11:25:45 +0000 Subject: [PATCH 008/200] Fixing style errors. --- htdocs/compta/paiement_vat.php | 9 ++-- htdocs/compta/payment_vat/card.php | 11 ++--- htdocs/compta/tva/card.php | 40 ++++++--------- htdocs/compta/tva/class/paymentvat.class.php | 27 ++++------- htdocs/compta/tva/class/tva.class.php | 51 +++++++------------- htdocs/compta/tva/index.php | 12 ++--- htdocs/compta/tva/list.php | 2 +- htdocs/compta/tva/payments.php | 18 +++---- 8 files changed, 59 insertions(+), 111 deletions(-) diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index cc5f6b858c8..7feb8fb6477 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -143,8 +143,7 @@ if ($action == 'add_payment' || ($action == 'confirm_paiement' && $confirm == 'y header('Location: '.$loc); exit; } - else - { + else { $db->rollback(); } } @@ -285,8 +284,7 @@ if ($action == 'create') { print ''.dol_print_date($objp->datev, 'day').''."\n"; } - else - { + else { print "!!!\n"; } @@ -308,8 +306,7 @@ if ($action == 'create') print ''; print ''; } - else - { + else { print '-'; } print ""; diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 30bd6844b71..976d2d761a1 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -68,8 +68,7 @@ if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->tax->char header("Location: ".DOL_URL_ROOT."/compta/tva/payments.php?mode=tvaonly"); exit; } - else - { + else { setEventMessages($object->error, $object->errors, 'errors'); $db->rollback(); } @@ -262,7 +261,7 @@ if ($resql) print $tva->getNomUrl(1); print "\n"; // Type - /* print ''; + /* print ''; print $tva->type_label;4 print "\n";*/ // Label @@ -287,8 +286,7 @@ if ($resql) print "\n"; $db->free($resql); } -else -{ +else { dol_print_error($db); } @@ -320,8 +318,7 @@ if ($action == '') { print ''.$langs->trans('Delete').''; } - else - { + else { print ''.$langs->trans('Delete').''; } } diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 9e7b8862c82..7f6cc454af1 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -177,7 +177,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) if (!$error) { $ret = $object->create($user); - if($ret < 0) $error++; + if ($ret < 0) $error++; // Auto create payment if (!empty($auto_create_payment) && !$error) @@ -195,7 +195,7 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) if (!$error) { - $paymentid = $paiement->create($user, (int)GETPOST('closepaidtva')); + $paymentid = $paiement->create($user, (int) GETPOST('closepaidtva')); if ($paymentid < 0) { $error++; @@ -218,12 +218,11 @@ if ($action == 'add' && $_POST["cancel"] <> $langs->trans("Cancel")) { $db->commit(); } - else - { + else { $db->rollback(); } } - if(empty($error)) { + if (empty($error)) { header("Location: card.php?id=" . $object->id); exit; } @@ -257,21 +256,18 @@ if ($action == 'confirm_delete' && $confirm == 'yes') header("Location: ".DOL_URL_ROOT.'/compta/tva/list.php'); exit; } - else - { + else { $object->error = $accountline->error; $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } - else - { + else { $db->rollback(); setEventMessages($object->error, $object->errors, 'errors'); } } - else - { + else { setEventMessages($langs->trans('DisabledBecausePayments'), null, 'errors'); } } @@ -290,8 +286,7 @@ if ($action == 'update' && !$_POST["cancel"] && $user->rights->tax->charges->cre setEventMessages($langs->trans("ErrorFieldMustBeANumeric", $langs->transnoentities("Amount")), null, 'errors'); $action = 'create'; } - else - { + else { $result = $object->fetch($id); $object->amount = price2num($amount); @@ -340,8 +335,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char header("Location: ".$_SERVER["PHP_SELF"]."?id=".$id); exit; } - else - { + else { $id = $originalId; $db->rollback(); @@ -349,8 +343,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes' && ($user->rights->tax->char } //} } - else - { + else { $db->rollback(); dol_print_error($db, $object->error); } @@ -405,8 +398,8 @@ if ($action == 'create') } });'; - if($_REQUEST['action'] === 'add') { // form has been send but there is at least one error - if(empty($auto_create_payment)) { + if ($_REQUEST['action'] === 'add') { // form has been send but there is at least one error + if (empty($auto_create_payment)) { print '$("#label_fk_account").removeClass("fieldrequired"); $("#label_type_payment").removeClass("fieldrequired"); $(".hide_if_no_auto_create_payment").hide();'; @@ -727,8 +720,7 @@ if ($id) $i++; } } - else - { + else { print ''.$langs->trans("None").''; print ''; print ''; @@ -748,8 +740,7 @@ if ($id) $db->free($resql); } - else - { + else { dol_print_error($db); } @@ -816,8 +807,7 @@ if ($id) { print ''; } - else - { + else { print ''; } } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index f5a34decebc..4e13a890b80 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -201,8 +201,7 @@ class PaymentVAT extends CommonObject } } } - else - { + else { $error++; } } @@ -217,8 +216,7 @@ class PaymentVAT extends CommonObject $this->db->commit(); return $this->id; } - else - { + else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -288,8 +286,7 @@ class PaymentVAT extends CommonObject return 1; } - else - { + else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -360,8 +357,7 @@ class PaymentVAT extends CommonObject $this->db->rollback(); return -1 * $error; } - else - { + else { $this->db->commit(); return 1; } @@ -416,8 +412,7 @@ class PaymentVAT extends CommonObject $this->db->rollback(); return -1 * $error; } - else - { + else { $this->db->commit(); return 1; } @@ -467,8 +462,7 @@ class PaymentVAT extends CommonObject $this->db->commit(); return $object->id; } - else - { + else { $this->db->rollback(); return -1; } @@ -582,8 +576,7 @@ class PaymentVAT extends CommonObject } } } - else - { + else { $this->error = $acc->error; $error++; } @@ -593,8 +586,7 @@ class PaymentVAT extends CommonObject { return 1; } - else - { + else { return -1; } } @@ -618,8 +610,7 @@ class PaymentVAT extends CommonObject { return 1; } - else - { + else { $this->error = $this->db->error(); return 0; } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 3dfdc8be38c..8609b2a39e2 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -164,14 +164,12 @@ class Tva extends CommonObject $this->db->commit(); return $this->id; } - else - { + else { $this->db->rollback(); return -1; } } - else - { + else { $this->error = "Error ".$this->db->lasterror(); $this->db->rollback(); return -1; @@ -236,8 +234,7 @@ class Tva extends CommonObject $this->db->commit(); return 1; } - else - { + else { $this->db->rollback(); return -1; } @@ -337,8 +334,7 @@ class Tva extends CommonObject return 1; } - else - { + else { $this->error = "Error ".$this->db->lasterror(); return -1; } @@ -448,14 +444,12 @@ class Tva extends CommonObject $this->db->free($result); return $ret; } - else - { + else { $this->db->free($result); return 0; } } - else - { + else { print $this->db->lasterror(); return -1; } @@ -489,14 +483,12 @@ class Tva extends CommonObject $this->db->free($result); return $ret; } - else - { + else { $this->db->free($result); return 0; } } - else - { + else { print $this->db->lasterror(); return -1; } @@ -532,14 +524,12 @@ class Tva extends CommonObject $this->db->free($result); return $ret; } - else - { + else { $this->db->free($result); return 0; } } - else - { + else { print $this->db->lasterror(); return -1; } @@ -657,8 +647,7 @@ class Tva extends CommonObject { $this->update_fk_bank($bank_line_id); } - else - { + else { $this->error = $acc->error; $ok = 0; } @@ -677,20 +666,17 @@ class Tva extends CommonObject $this->db->commit(); return $this->id; } - else - { + else { $this->db->rollback(); return -3; } } - else - { + else { $this->db->rollback(); return -2; } } - else - { + else { $this->error = $this->db->error(); $this->db->rollback(); return -1; @@ -714,8 +700,7 @@ class Tva extends CommonObject { return 1; } - else - { + else { dol_print_error($this->db); return -1; } @@ -797,8 +782,7 @@ class Tva extends CommonObject $this->db->free($resql); return $amount; } - else - { + else { return -1; } } @@ -844,8 +828,7 @@ class Tva extends CommonObject $this->db->free($result); } - else - { + else { dol_print_error($this->db); } } diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index e5ea2fd6471..fd03b678711 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -60,8 +60,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end if (empty($q)) { if (GETPOST("month", "int")) { $date_start = dol_get_first_day($year_start, GETPOST("month", "int"), false); $date_end = dol_get_last_day($year_start, GETPOST("month", "int"), false); } - else - { + else { if (empty($conf->global->MAIN_INFO_VAT_RETURN) || $conf->global->MAIN_INFO_VAT_RETURN == 2) { // quaterly vat, we take last past complete quarter $date_start = dol_time_plus_duree(dol_get_first_day($year_start, $current_date['mon'], false), -3 - (($current_date['mon'] - $conf->global->SOCIETE_FISCAL_MONTH_START) % 3), 'm'); $date_end = dol_time_plus_duree($date_start, 3, 'm') - 1; @@ -85,8 +84,7 @@ if (empty($date_start) || empty($date_end)) // We define date_start and date_end } } } - else - { + else { if ($q == 1) { $date_start = dol_get_first_day($year_start, 1, false); $date_end = dol_get_last_day($year_start, 3, false); } if ($q == 2) { $date_start = dol_get_first_day($year_start, 4, false); $date_end = dol_get_last_day($year_start, 6, false); } if ($q == 3) { $date_start = dol_get_first_day($year_start, 7, false); $date_end = dol_get_last_day($year_start, 9, false); } @@ -179,8 +177,7 @@ function pt($db, $sql, $date) $previousmode = ''; $previousmonth = ''; } - else - { + else { $previousmode = $obj->mode; $previousmonth = $obj->dm; } @@ -373,8 +370,7 @@ while ((($y < $yend) || ($y == $yend && $m <= $mend)) && $mcursor < 1000) // $mc //'link' =>$expensereport->getNomUrl(1) ); } - else - { + else { //$invoice_supplier->id=$x_paye[$my_paye_rate]['facid'][$id]; //$invoice_supplier->ref=$x_paye[$my_paye_rate]['facnum'][$id]; //$invoice_supplier->type=$x_paye[$my_paye_rate]['type'][$id]; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 13cb2ad7386..10d902697f5 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -397,7 +397,7 @@ while ($i < min($num, $limit)) { if (!empty($arrayfields['t.status']['checked'])) { print '' . $tva_static->LibStatut($obj->paye, 5, $obj->alreadypayed) . ''; if (!$i) $totalarray['nbfield']++; - if(!empty($arrayfields['t.amount']['checked'])) $totalarray['pos'][$totalarray['nbfield']] = ''; + if (!empty($arrayfields['t.amount']['checked'])) $totalarray['pos'][$totalarray['nbfield']] = ''; } // Buttons diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index b6910610454..66a8a087216 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -95,8 +95,7 @@ if ($mode != 'tvaonly') $center = ($year ? ''.img_previous($langs->trans("Previous"), 'class="valignbottom"')." ".$langs->trans("Year").' '.$year.' '.img_next($langs->trans("Next"), 'class="valignbottom"')."" : ""); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit, 1); } -else -{ +else { print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, $center, $num, $totalnboflines, 'title_accountancy', 0, '', '', $limit); } @@ -224,8 +223,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ''.price($totalpaye).""; print ""; } - else - { + else { dol_print_error($db); } print ''; @@ -303,8 +301,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) print ""; $db->free($result); } - else - { + else { dol_print_error($db); } } @@ -326,8 +323,7 @@ elseif ($mysoc->localtax2_assuj == "1") $j = 2; $numlt = 3; } -else -{ +else { $j = 0; $numlt = 0; } @@ -404,8 +400,7 @@ while ($j < $numlt) print ""; $db->free($result); } - else - { + else { dol_print_error($db); } } @@ -488,8 +483,7 @@ if (!empty($conf->salaries->enabled) && !empty($user->rights->salaries->read)) print "
"; } - else - { + else { dol_print_error($db); } } From ae6e1db6522643d376d2c0fc56ad9098ca19a776 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 19 Jan 2021 13:32:08 +0100 Subject: [PATCH 009/200] FIX : getNomUrl() --- htdocs/compta/bank/bankentries_list.php | 18 ++++++---- .../class/paymentsocialcontribution.class.php | 34 +++++++++++++------ htdocs/compta/tva/class/paymentvat.class.php | 34 +++++++++++++------ htdocs/compta/tva/class/tva.class.php | 2 ++ htdocs/compta/tva/list.php | 1 + 5 files changed, 62 insertions(+), 27 deletions(-) diff --git a/htdocs/compta/bank/bankentries_list.php b/htdocs/compta/bank/bankentries_list.php index 3bd1e16b27d..149eef20bee 100644 --- a/htdocs/compta/bank/bankentries_list.php +++ b/htdocs/compta/bank/bankentries_list.php @@ -41,6 +41,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/html.formaccounting.class.php'; require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/paymentvat.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php'; require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php'; @@ -382,6 +384,8 @@ $loanstatic = new Loan($db); $memberstatic = new Adherent($db); $paymentstatic = new Paiement($db); $paymentsupplierstatic = new PaiementFourn($db); +$paymentscstatic = new PaymentSocialContribution($db); +$paymentvatstatic = new PaymentVAT($db); $paymentsalstatic = new PaymentSalary($db); $paymentvariousstatic = new PaymentVarious($db); $donstatic = new Don($db); @@ -1221,16 +1225,16 @@ if ($resql) } elseif ($links[$key]['type'] == 'payment_sc') { - print ''; - print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; - //print $langs->trans("SocialContributionPayment"); - print ''; + $paymentscstatic->id = $links[$key]['url_id']; + $paymentscstatic->ref = $links[$key]['url_id']; + $paymentscstatic->label = $links[$key]['label']; + print ' '.$paymentscstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_vat') { - print ''; - print ' '.img_object($langs->trans('ShowPayment'), 'payment').' '; - print ''; + $paymentvatstatic->id = $links[$key]['url_id']; + $paymentvatstatic->ref = $links[$key]['url_id']; + print ' '.$paymentvatstatic->getNomUrl(2); } elseif ($links[$key]['type'] == 'payment_salary') { diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index c771a664d5f..2f4fb89e7de 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -702,17 +702,31 @@ class PaymentSocialContribution extends CommonObject $result = ''; if (empty($this->ref)) $this->ref = $this->lib; - $label = $langs->trans("ShowPayment").': '.$this->ref; - if (!empty($this->id)) { - $link = ''; - $linkend = ''; + $label = img_picto('', $this->picto).' '.$langs->trans("SocialContributionPayment").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) { + $labeltoshow = $this->label; + $reg = array(); + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + $labeltoshow = $langs->trans($reg[1]); + } + $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + } + if ($this->datep) $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->datep, 'day'); - if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; - } + if (!empty($this->id)) { + $link = ''; + $linkend = ''; - return $result; - } + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; + } + + return $result; + } } diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index f5a34decebc..7165fef7f4c 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -703,17 +703,31 @@ class PaymentVAT extends CommonObject $result = ''; if (empty($this->ref)) $this->ref = $this->lib; - $label = $langs->trans("ShowPayment").': '.$this->ref; - if (!empty($this->id)) { - $link = ''; - $linkend = ''; + $label = img_picto('', $this->picto).' '.$langs->trans("VATPayment").''; + $label .= '
'.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) { + $labeltoshow = $this->label; + $reg = array(); + if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) + { + // Label generique car entre parentheses. On l'affiche en le traduisant + if ($reg[1] == 'paiement') $reg[1] = 'Payment'; + $labeltoshow = $langs->trans($reg[1]); + } + $label .= '
'.$langs->trans('Label').': '.$labeltoshow; + } + if ($this->datep) $label .= '
'.$langs->trans('Date').': '.dol_print_date($this->datep, 'day'); - if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); - if ($withpicto && $withpicto != 2) $result .= ' '; - if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; - } + if (!empty($this->id)) { + $link = ''; + $linkend = ''; - return $result; - } + if ($withpicto) $result .= ($link.img_object($label, 'payment', 'class="classfortooltip"').$linkend.' '); + if ($withpicto && $withpicto != 2) $result .= ' '; + if ($withpicto != 2) $result .= $link.($maxlen ?dol_trunc($this->ref, $maxlen) : $this->ref).$linkend; + } + + return $result; + } } diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index c9ed4bd5671..e1f25d992a8 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -739,6 +739,8 @@ class Tva extends CommonObject $label = ''.$langs->trans("ShowVatPayment").''; $label .= '
'; $label .= ''.$langs->trans('Ref').': '.$this->ref; + if (!empty($this->label)) + $label .= '
'.$langs->trans('Label').': '.$this->label; $url = DOL_URL_ROOT.'/compta/tva/card.php?id='.$this->id; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index e2dca56dddc..7616b0b53a6 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -259,6 +259,7 @@ if ($result) $tva_static->id = $obj->rowid; $tva_static->ref = $obj->rowid; + $tva_static->label = $obj->label; // Ref print "".$tva_static->getNomUrl(1)."\n"; From 8b0a5d270b6722215bfa1ffa70fcbaa12fb0c56d Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Tue, 19 Jan 2021 17:18:22 +0100 Subject: [PATCH 010/200] FIX : group by --- htdocs/compta/tva/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 7616b0b53a6..2164524a16b 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -132,7 +132,7 @@ if ($filtre) { if ($typeid) { $sql .= " AND t.fk_typepayment=".$typeid; } -$sql .= " GROUP BY t.rowid, t.amount, t.datev, t.label, t.paye"; +$sql .= " GROUP BY t.rowid, t.amount, t.datev, t.label, t.paye, pst.code"; $sql .= $db->order($sortfield, $sortorder); $totalnboflines = 0; $result = $db->query($sql); From 60d6de86f1e86667d2986f3c2a7df007f942b812 Mon Sep 17 00:00:00 2001 From: lmarcouiller Date: Thu, 21 Jan 2021 14:31:18 +0100 Subject: [PATCH 011/200] change of line 1346 because miss remove --- htdocs/core/class/dolgraph.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 0e5e42331db..033ddd8afe3 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1343,7 +1343,7 @@ class DolGraph } $this->stringtoshow .= 'borderColor: \'' . $bordercolor . '\', '; $this->stringtoshow .= 'backgroundColor: \'' . $color . '\', '; - if ($arrayofgroupslegend[$i]) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; + if (!empty($arrayofgroupslegend) && !empty($arrayofgroupslegend[$i])) $this->stringtoshow .= 'stack: \'' . $arrayofgroupslegend[$i]['stacknum'] . '\', '; $this->stringtoshow .= 'data: ['; $this->stringtoshow .= $this->mirrorGraphValues ? '[' . -$serie[$i] . ',' . $serie[$i] . ']' : $serie[$i]; From 0b981743aa921fb86dde8f28059154a604a49001 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 22 Jan 2021 09:15:45 +0100 Subject: [PATCH 012/200] FIX : remove backquotes --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 910ea92d5d1..4f466e09d9d 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -126,12 +126,12 @@ create table llx_paiementtva ALTER TABLE llx_tva ADD paye smallint default 0 NOT NULL; ALTER TABLE llx_tva ADD fk_account integer; -INSERT INTO `llx_paiementtva` (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) +INSERT INTO llx_paiementtva (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva; UPDATE llx_bank_url url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat'; -INSERT INTO `llx_bank_url` (fk_bank, url_id, url, label, type) +INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_paiementtva ptva on (ptva.fk_bank = b.fk_bank) WHERE type = "vat"; From f3e7adad18e8becfff10df108347b2b12e051c49 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Fri, 22 Jan 2021 16:08:46 +0100 Subject: [PATCH 013/200] FIX : double quotes on sql file --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 4f466e09d9d..ac91b01858c 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -134,7 +134,7 @@ UPDATE llx_bank_url url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET typ INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_paiementtva ptva on (ptva.fk_bank = b.fk_bank) -WHERE type = "vat"; +WHERE type = 'vat'; ALTER TABLE llx_tva DROP COLUMN fk_bank; UPDATE llx_tva SET paye = 1; From 42e28941d03f8436f314c6f1d261eeaa35bfb1a0 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 25 Jan 2021 10:22:31 +0100 Subject: [PATCH 014/200] FIX : sql db escape missing --- htdocs/compta/tva/class/tva.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 76a4001d1b4..2db413cbf9d 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -470,7 +470,7 @@ class Tva extends CommonObject $sql .= " FROM ".MAIN_DB_PREFIX."facture_fourn as f"; if ($year) { - $sql .= " WHERE f.datef >= '".$year."-01-01' AND f.datef <= '".$year."-12-31' "; + $sql .= " WHERE f.datef >= '".$this->db->escape($year)."-01-01' AND f.datef <= '".$this->db->escape($year)."-12-31' "; } $result = $this->db->query($sql); From 509e9d597e76a95ee5d21ddd99ab4187aed094a4 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 1 Feb 2021 11:47:43 +0100 Subject: [PATCH 015/200] FIX : table name for VAT payments must be llx_payment_vat --- htdocs/compta/paiement_vat.php | 2 +- htdocs/compta/payment_vat/card.php | 2 +- htdocs/compta/tva/card.php | 2 +- htdocs/compta/tva/class/paymentvat.class.php | 16 ++++++++-------- htdocs/compta/tva/class/tva.class.php | 2 +- htdocs/compta/tva/index.php | 2 +- htdocs/compta/tva/list.php | 2 +- htdocs/compta/tva/payments.php | 2 +- .../{llx_paiementtva.sql => llx_payment_vat.sql} | 2 +- htdocs/install/mysql/tables/llx_tva.sql | 3 ++- 10 files changed, 18 insertions(+), 17 deletions(-) rename htdocs/install/mysql/tables/{llx_paiementtva.sql => llx_payment_vat.sql} (98%) diff --git a/htdocs/compta/paiement_vat.php b/htdocs/compta/paiement_vat.php index cc5f6b858c8..b31e60e76a5 100644 --- a/htdocs/compta/paiement_vat.php +++ b/htdocs/compta/paiement_vat.php @@ -211,7 +211,7 @@ if ($action == 'create') print ''.$langs->trans("Amount")."".price($tva->amount,0,$outputlangs,1,-1,-1,$conf->currency).'';*/ $sql = "SELECT sum(p.amount) as total"; - $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p"; $sql .= " WHERE p.fk_tva = ".$chid; $resql = $db->query($sql); if ($resql) diff --git a/htdocs/compta/payment_vat/card.php b/htdocs/compta/payment_vat/card.php index 30bd6844b71..6c5103d8d28 100644 --- a/htdocs/compta/payment_vat/card.php +++ b/htdocs/compta/payment_vat/card.php @@ -224,7 +224,7 @@ dol_fiche_end(); $disable_delete = 0; $sql = 'SELECT f.rowid as scid, f.label as label, f.paye, f.amount as tva_amount, pf.amount'; //$sql .= ', pc.libelle as sc_type'; -$sql .= ' FROM '.MAIN_DB_PREFIX.'paiementtva as pf,'.MAIN_DB_PREFIX.'tva as f'; +$sql .= ' FROM '.MAIN_DB_PREFIX.'payment_vat as pf,'.MAIN_DB_PREFIX.'tva as f'; //$sql .= ', '.MAIN_DB_PREFIX.'c_chargesociales as pc'; $sql .= ' WHERE pf.fk_tva = f.rowid'; //$sql .= ' AND f.fk_type = pc.id'; diff --git a/htdocs/compta/tva/card.php b/htdocs/compta/tva/card.php index 08b942bf9a2..c5cd4d7f0e2 100644 --- a/htdocs/compta/tva/card.php +++ b/htdocs/compta/tva/card.php @@ -657,7 +657,7 @@ if ($id) $sql = "SELECT p.rowid, p.num_paiement as num_payment, p.datep as dp, p.amount,"; $sql .= " c.code as type_code,c.libelle as paiement_type,"; $sql .= ' ba.rowid as baid, ba.ref as baref, ba.label, ba.number as banumber, ba.account_number, ba.currency_code as bacurrency_code, ba.fk_accountancy_journal'; - $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as p"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as p"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON p.fk_bank = b.rowid'; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank_account as ba ON b.fk_account = ba.rowid'; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as c ON p.fk_typepaiement = c.id"; diff --git a/htdocs/compta/tva/class/paymentvat.class.php b/htdocs/compta/tva/class/paymentvat.class.php index 7165fef7f4c..db05c7895d3 100644 --- a/htdocs/compta/tva/class/paymentvat.class.php +++ b/htdocs/compta/tva/class/paymentvat.class.php @@ -35,12 +35,12 @@ class PaymentVAT extends CommonObject /** * @var string ID to identify managed object */ - public $element = 'paiementtva'; + public $element = 'payment_vat'; /** * @var string Name of table without prefix where object is stored */ - public $table_element = 'paiementtva'; + public $table_element = 'payment_vat'; /** * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png @@ -159,7 +159,7 @@ class PaymentVAT extends CommonObject if ($totalamount != 0) { - $sql = "INSERT INTO ".MAIN_DB_PREFIX."paiementtva (fk_tva, datec, datep, amount,"; + $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_vat (fk_tva, datec, datep, amount,"; $sql .= " fk_typepaiement, num_paiement, note, fk_user_creat, fk_bank)"; $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; $sql .= " '".$this->db->idate($this->datepaye)."',"; @@ -170,7 +170,7 @@ class PaymentVAT extends CommonObject $resql = $this->db->query($sql); if ($resql) { - $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."paiementtva"); + $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_vat"); // Insere tableau des montants / factures foreach ($this->amounts as $key => $amount) @@ -249,7 +249,7 @@ class PaymentVAT extends CommonObject $sql .= " t.fk_user_modif,"; $sql .= " pt.code as type_code, pt.libelle as type_label,"; $sql .= ' b.fk_account'; - $sql .= " FROM ".MAIN_DB_PREFIX."paiementtva as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id"; + $sql .= " FROM ".MAIN_DB_PREFIX."payment_vat as t LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pt ON t.fk_typepaiement = pt.id"; $sql .= ' LEFT JOIN '.MAIN_DB_PREFIX.'bank as b ON t.fk_bank = b.rowid'; $sql .= " WHERE t.rowid = ".$id; // TODO link on entity of tax; @@ -326,7 +326,7 @@ class PaymentVAT extends CommonObject // Put here code to add control on parameters values // Update request - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementtva SET"; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET"; $sql .= " fk_tva=".(isset($this->fk_tva) ? $this->fk_tva : "null").","; $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; @@ -397,7 +397,7 @@ class PaymentVAT extends CommonObject if (!$error) { - $sql = "DELETE FROM ".MAIN_DB_PREFIX."paiementtva"; + $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_vat"; $sql .= " WHERE rowid=".$this->id; dol_syslog(get_class($this)."::delete", LOG_DEBUG); @@ -610,7 +610,7 @@ class PaymentVAT extends CommonObject public function update_fk_bank($id_bank) { // phpcs:enable - $sql = "UPDATE ".MAIN_DB_PREFIX."paiementtva SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; + $sql = "UPDATE ".MAIN_DB_PREFIX."payment_vat SET fk_bank = ".$id_bank." WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::update_fk_bank", LOG_DEBUG); $result = $this->db->query($sql); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index e1f25d992a8..ea522ca0eaf 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -778,7 +778,7 @@ class Tva extends CommonObject */ public function getSommePaiement() { - $table = 'paiementtva'; + $table = 'payment_vat'; $field = 'fk_tva'; $sql = 'SELECT sum(amount) as amount'; diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 15f03979b8a..98897d20ef7 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -572,7 +572,7 @@ $sql .= " UNION "; $sql .= "SELECT SUM(ptva.amount) as mm, date_format(tva.datev,'%Y-%m') as dm, 'paid' as mode"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva"; -$sql .= " INNER JOIN ".MAIN_DB_PREFIX."paiementtva as ptva ON (tva.rowid = ptva.fk_tva)"; +$sql .= " INNER JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON (tva.rowid = ptva.fk_tva)"; $sql .= " WHERE tva.entity = ".$conf->entity; $sql .= " AND (tva.datev >= '".$db->idate($date_start)."' AND tva.datev <= '".$db->idate($date_end)."')"; $sql .= " GROUP BY dm"; diff --git a/htdocs/compta/tva/list.php b/htdocs/compta/tva/list.php index 2164524a16b..81b5cd6d665 100644 --- a/htdocs/compta/tva/list.php +++ b/htdocs/compta/tva/list.php @@ -112,7 +112,7 @@ $sql = "SELECT t.rowid, t.amount, t.label, t.datev, t.datep, t.paye, t.fk_typepa $sql .= " SUM(ptva.amount) as alreadypayed"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as t"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pst ON t.fk_typepayment = pst.id"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."paiementtva as ptva ON ptva.fk_tva = t.rowid"; +$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."payment_vat as ptva ON ptva.fk_tva = t.rowid"; //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON t.fk_bank = b.rowid"; //$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.rowid"; $sql .= " WHERE t.entity IN (".getEntity('tax').")"; diff --git a/htdocs/compta/tva/payments.php b/htdocs/compta/tva/payments.php index b6910610454..3ac139a9524 100644 --- a/htdocs/compta/tva/payments.php +++ b/htdocs/compta/tva/payments.php @@ -135,7 +135,7 @@ if (!empty($conf->tax->enabled) && $user->rights->tax->charges->lire) $sql .= " ptva.rowid as pid, ptva.datep, ptva.amount as totalpaye, ptva.num_paiement as num_payment,"; $sql .= " pct.code as payment_code"; $sql .= " FROM ".MAIN_DB_PREFIX."tva as tva,"; - $sql .= " ".MAIN_DB_PREFIX."paiementtva as ptva"; + $sql .= " ".MAIN_DB_PREFIX."payment_vat as ptva"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank as b ON (b.rowid = ptva.fk_bank)"; $sql .= " INNER JOIN ".MAIN_DB_PREFIX."bank_account as bank ON (bank.rowid = b.fk_account)"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."c_paiement as pct ON ptva.fk_typepaiement = pct.id"; diff --git a/htdocs/install/mysql/tables/llx_paiementtva.sql b/htdocs/install/mysql/tables/llx_payment_vat.sql similarity index 98% rename from htdocs/install/mysql/tables/llx_paiementtva.sql rename to htdocs/install/mysql/tables/llx_payment_vat.sql index c73f1a90c6d..4ebb5bb4af3 100644 --- a/htdocs/install/mysql/tables/llx_paiementtva.sql +++ b/htdocs/install/mysql/tables/llx_payment_vat.sql @@ -17,7 +17,7 @@ -- -- =================================================================== -create table llx_paiementtva +create table llx_payment_vat ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_tva integer, diff --git a/htdocs/install/mysql/tables/llx_tva.sql b/htdocs/install/mysql/tables/llx_tva.sql index 2804d410e7d..4e9e3e4a9d3 100644 --- a/htdocs/install/mysql/tables/llx_tva.sql +++ b/htdocs/install/mysql/tables/llx_tva.sql @@ -30,7 +30,8 @@ create table llx_tva label varchar(255), entity integer DEFAULT 1 NOT NULL, -- multi company id note text, - fk_bank integer, + paye smallint default 0 NOT NULL, + fk_account integer, fk_user_creat integer, -- utilisateur who create record fk_user_modif integer, -- utilisateur who modify record import_key varchar(14) From f1352fba9725929d6241d02269355a4522af26a4 Mon Sep 17 00:00:00 2001 From: Gauthier PC portable 024 Date: Mon, 1 Feb 2021 11:56:28 +0100 Subject: [PATCH 016/200] FIX : migration script --- htdocs/install/mysql/migration/13.0.0-14.0.0.sql | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index f816d926f7c..0e15101b70e 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -122,7 +122,7 @@ ALTER TABLE llx_societe ADD INDEX idx_societe_warehouse(fk_warehouse); ALTER TABLE llx_socpeople MODIFY poste varchar(255); -create table llx_paiementtva +create table llx_payment_vat ( rowid integer AUTO_INCREMENT PRIMARY KEY, fk_tva integer, @@ -139,18 +139,18 @@ create table llx_paiementtva )ENGINE=innodb; -ALTER TABLE llx_tva ADD paye smallint default 0 NOT NULL; +ALTER TABLE llx_tva ADD paye smallint default 1 NOT NULL; ALTER TABLE llx_tva ADD fk_account integer; -INSERT INTO llx_paiementtva (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) +INSERT INTO llx_payment_vat (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva; UPDATE llx_bank_url url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat'; INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' -FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_paiementtva ptva on (ptva.fk_bank = b.fk_bank) +FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_payment_vat ptva on (ptva.fk_bank = b.fk_bank) WHERE type = 'vat'; ALTER TABLE llx_tva DROP COLUMN fk_bank; -UPDATE llx_tva SET paye = 1; +ALTER TABLE llx_tva ALTER paye SET DEFAULT 0; From 70d04900c1e8b29de10a961b128affef349e04e6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 1 Feb 2021 19:59:08 +0100 Subject: [PATCH 017/200] Several fixes in migration Fix we must not drop a field during migration. This must be done 2 or 3 versions later. Fix syntax of sql --- .../install/mysql/migration/13.0.0-14.0.0.sql | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql index 45fb4093975..ca6eeeb3940 100644 --- a/htdocs/install/mysql/migration/13.0.0-14.0.0.sql +++ b/htdocs/install/mysql/migration/13.0.0-14.0.0.sql @@ -140,18 +140,13 @@ create table llx_payment_vat )ENGINE=innodb; -ALTER TABLE llx_tva ADD paye smallint default 1 NOT NULL; -ALTER TABLE llx_tva ADD fk_account integer; +ALTER TABLE llx_tva ADD COLUMN paye smallint default 1 NOT NULL; +ALTER TABLE llx_tva ADD COLUMN fk_account integer; -INSERT INTO llx_payment_vat (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) -SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva; +--INSERT INTO llx_payment_vat (fk_tva, datec, datep, amount, fk_typepaiement, num_paiement, note, fk_bank, fk_user_creat, fk_user_modif) SELECT rowid, NOW(), datep, amount, COALESCE(fk_typepayment, 0), num_payment, '', fk_bank, fk_user_creat, fk_user_modif FROM llx_tva; +--UPDATE llx_bank_url as url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET url.type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat'; +--INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_payment_vat ptva on (ptva.fk_bank = b.fk_bank) WHERE type = 'vat'; -UPDATE llx_bank_url url INNER JOIN llx_tva tva ON tva.rowid = url.url_id SET type = 'vat', url.label = CONCAT('(', tva.label, ')') WHERE type = 'payment_vat'; +--ALTER TABLE llx_tva DROP COLUMN fk_bank; -INSERT INTO llx_bank_url (fk_bank, url_id, url, label, type) -SELECT b.fk_bank, ptva.rowid, REPLACE(b.url, 'tva/card.php', 'payment_vat/card.php'), '(paiement)', 'payment_vat' -FROM llx_bank_url b INNER JOIN llx_tva tva ON (tva.fk_bank = b.fk_bank) INNER JOIN llx_payment_vat ptva on (ptva.fk_bank = b.fk_bank) -WHERE type = 'vat'; - -ALTER TABLE llx_tva DROP COLUMN fk_bank; -ALTER TABLE llx_tva ALTER paye SET DEFAULT 0; +ALTER TABLE llx_tva ALTER COLUMN paye SET DEFAULT 0; From f4f9a7c461789881fed4c3d023090bf26ec73ce8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 09:44:51 +0100 Subject: [PATCH 018/200] Clean page of info tools --- htdocs/admin/system/dolibarr.php | 10 +-- htdocs/admin/system/phpinfo.php | 118 ++++++++----------------------- htdocs/admin/system/security.php | 29 +++++--- htdocs/langs/en_US/admin.lang | 1 + 4 files changed, 55 insertions(+), 103 deletions(-) diff --git a/htdocs/admin/system/dolibarr.php b/htdocs/admin/system/dolibarr.php index 2efb2a14a7d..5e89d8ae683 100644 --- a/htdocs/admin/system/dolibarr.php +++ b/htdocs/admin/system/dolibarr.php @@ -73,7 +73,7 @@ print load_fiche_titre($title, '', 'title_setup'); // Version print '
'; print ''; -print ''."\n"; +print ''."\n"; print '
'.$langs->trans("Version").''.$langs->trans("Value").'
'.$langs->trans("Version").''.$langs->trans("Value").'
'.$langs->trans("CurrentVersion").' ('.$langs->trans("Programs").')'.DOL_VERSION; // If current version differs from last upgrade if (empty($conf->global->MAIN_VERSION_LAST_UPGRADE)) @@ -139,7 +139,7 @@ print '
'; // Session print '
'; print ''; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; @@ -180,7 +180,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S print '
'; print '
'.$langs->trans("Session").''.$langs->trans("Value").'
'.$langs->trans("Session").''.$langs->trans("Value").'
'.$langs->trans("SessionSavePath").''.session_save_path().'
'.$langs->trans("SessionName").''.session_name().'
'.$langs->trans("SessionId").''.session_id().'
'; print ''; - print ''; + print ''; print ''; print ''; print ''."\n"; @@ -202,7 +202,7 @@ if (isset($conf->global->MAIN_OPTIMIZE_SPEED) && ($conf->global->MAIN_OPTIMIZE_S // Localisation print '
'; print '
'.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").''.$langs->trans("LanguageFilesCachedIntoShmopSharedMemory").''.$langs->trans("NbOfEntries").''.$langs->trans("Address").'
'; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; // Thousands @@ -342,7 +342,7 @@ $configfileparameters = array( print '
'; print '
'.$langs->trans("LocalisationDolibarrParameters").''.$langs->trans("Value").'
'.$langs->trans("LocalisationDolibarrParameters").''.$langs->trans("Value").'
'.$langs->trans("LanguageBrowserParameter", "HTTP_ACCEPT_LANGUAGE").''.$_SERVER["HTTP_ACCEPT_LANGUAGE"].'
'.$langs->trans("CurrentUserLanguage").''.$langs->getDefaultLang().'
'; print ''; -print ''; print ''; diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index cf38687f66f..a7bce7a3025 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -69,13 +69,13 @@ if ($maxphp > 0 && $maxphp2 > 0 && $maxphp > $maxphp2) print '
'.$langs->trans("Parameters").' '; +print ''.$langs->trans("Parameters").' '; print $langs->trans("ConfigurationFile").' ('.$conffiletoshowshort.')'; print ''.$langs->trans("Parameter").'
'; -print ''; +print ''; $ErrorPicturePath = "../../theme/eldy/img/error.png"; $WarningPicturePath = "../../theme/eldy/img/warning.png"; $OkayPicturePath = "../../theme/eldy/img/tick.png"; -print ''; // Status print ''; - // Amount payed + // Amount paid print ''; print "\n"; if ($objp->paye == 1) // If at least one invoice is paid, disable delete diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index fb2f114b579..721d7c10111 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -370,7 +370,7 @@ class BonPrelevement extends CommonObject $num = count($facs); for ($i = 0; $i < $num; $i++) { - /* Tag invoice as payed */ + /* Tag invoice as paid */ dol_syslog(get_class($this)."::set_credite set_paid fac ".$facs[$i]); $fac = new Facture($this->db); $fac->fetch($facs[$i]); diff --git a/htdocs/compta/sociales/class/chargesociales.class.php b/htdocs/compta/sociales/class/chargesociales.class.php index ffb2d04e155..a281aeb2198 100644 --- a/htdocs/compta/sociales/class/chargesociales.class.php +++ b/htdocs/compta/sociales/class/chargesociales.class.php @@ -421,7 +421,7 @@ class ChargeSociales extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag social contribution as payed completely + * Tag social contribution as paid completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK @@ -439,7 +439,7 @@ class ChargeSociales extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Remove tag payed on social contribution + * Remove tag paid on social contribution * * @param User $user Object user making change * @return int <0 if KO, >0 if OK @@ -459,7 +459,7 @@ class ChargeSociales extends CommonObject * Retourne le libelle du statut d'une charge (impaye, payee) * * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto - * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount paid if you have it, 1 otherwise) * @return string Label */ public function getLibStatut($mode = 0, $alreadypaid = -1) @@ -473,7 +473,7 @@ class ChargeSociales extends CommonObject * * @param int $status Id status * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto - * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount paid if you have it, 1 otherwise) * @return string Label */ public function LibStatut($status, $mode = 0, $alreadypaid = -1) diff --git a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php index 2f4f772fca0..ca46bdadfea 100644 --- a/htdocs/compta/sociales/class/paymentsocialcontribution.class.php +++ b/htdocs/compta/sociales/class/paymentsocialcontribution.class.php @@ -110,7 +110,7 @@ class PaymentSocialContribution extends CommonObject * Use this->amounts to have list of lines for the payment * * @param User $user User making payment - * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more + * @param int $closepaidcontrib 1=Also close paid contributions to paid, 0=Do nothing more * @return int <0 if KO, id of payment if OK */ public function create($user, $closepaidcontrib = 0) @@ -178,7 +178,7 @@ class PaymentSocialContribution extends CommonObject { $amount = price2num($amount); - // If we want to closed payed invoices + // If we want to closed paid invoices if ($closepaidcontrib) { $contrib = new ChargeSociales($this->db); diff --git a/htdocs/compta/tva/class/tva.class.php b/htdocs/compta/tva/class/tva.class.php index 51cac4c7394..4b97070cce6 100644 --- a/htdocs/compta/tva/class/tva.class.php +++ b/htdocs/compta/tva/class/tva.class.php @@ -413,7 +413,7 @@ class Tva extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * VAT payed + * Total of VAT paid into invoice * * @param int $year Year * @return double Amount @@ -451,7 +451,7 @@ class Tva extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Total of the VAT payed + * Total of the VAT paid * * @param int $year Year * @return double Amount diff --git a/htdocs/compta/tva/index.php b/htdocs/compta/tva/index.php index 4a16d996ab8..576a9038165 100644 --- a/htdocs/compta/tva/index.php +++ b/htdocs/compta/tva/index.php @@ -543,7 +543,7 @@ print '
'; /* - * Payed + * Paid */ print load_fiche_titre($langs->trans("VATPaid"), '', ''); diff --git a/htdocs/core/boxes/box_factures_fourn_imp.php b/htdocs/core/boxes/box_factures_fourn_imp.php index d345f3d33b0..99848d916f4 100644 --- a/htdocs/core/boxes/box_factures_fourn_imp.php +++ b/htdocs/core/boxes/box_factures_fourn_imp.php @@ -26,7 +26,7 @@ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; /** - * Class to manage the box to show not payed suppliers invoices + * Class to manage the box to show not paid suppliers invoices */ class box_factures_fourn_imp extends ModeleBoxes { diff --git a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php index 19e78eb4ff9..bcb90df2bb1 100644 --- a/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php +++ b/htdocs/core/modules/supplier_payment/doc/pdf_standard.modules.php @@ -748,7 +748,7 @@ class pdf_standard extends ModelePDFSuppliersPayments $pdf->SetFont('', '', $default_font_size - 1); $pdf->MultiCell(80, 4, $carac_emetteur, 0, 'L'); - // Payed + // Paid $thirdparty = $object->thirdparty; $carac_client_name = pdfBuildThirdpartyName($thirdparty, $outputlangs); diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index c7c16ee970b..e827bca338d 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -184,7 +184,7 @@ if ($resql) print '
'; // Status print ''; - // Amount payed + // Amount paid print ''; print "\n"; if ($objp->paid == 1) { diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index babe69206ce..ad55ec4b537 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -66,14 +66,14 @@ class ExpenseReport extends CommonObject public $date_fin; /** - * 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + * 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=paid, 99=denied * * @var int Status */ public $status; /** - * 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=payed, 99=denied + * 0=draft, 2=validated (attente approb), 4=canceled, 5=approved, 6=paid, 99=denied * * @var int Status * @deprecated diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index c8ae31398c0..83408d9ba6c 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -1248,7 +1248,7 @@ class FactureFournisseur extends CommonInvoice // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag invoice as a payed invoice + * Tag invoice as a paid invoice * * @param User $user Object user * @param string $close_code Code indicates whether the class has paid in full while payment is incomplete. Not implementd yet. diff --git a/htdocs/fourn/class/paiementfourn.class.php b/htdocs/fourn/class/paiementfourn.class.php index 56d4af045f4..bb0ecbcfa7c 100644 --- a/htdocs/fourn/class/paiementfourn.class.php +++ b/htdocs/fourn/class/paiementfourn.class.php @@ -229,7 +229,7 @@ class PaiementFourn extends Paiement $invoice = new FactureFournisseur($this->db); $invoice->fetch($facid); - // If we want to closed payed invoices + // If we want to closed paid invoices if ($closepaidinvoices) { $paiement = $invoice->getSommePaiement(); diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 00e0e33ea1e..ac8b7b75dbf 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -489,7 +489,7 @@ if (empty($reshook)) $result = $discountcheck->fetch(0, 0, $object->id); $canconvert = 0; - if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is payed (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) + if ($object->type == FactureFournisseur::TYPE_DEPOSIT && empty($discountcheck->id)) $canconvert = 1; // we can convert deposit into discount if deposit is paid (completely, partially or not at all) and not already converted (see real condition into condition used to show button converttoreduc) if (($object->type == FactureFournisseur::TYPE_CREDIT_NOTE || $object->type == FactureFournisseur::TYPE_STANDARD) && $object->paye == 0 && empty($discountcheck->id)) $canconvert = 1; // we can convert credit note into discount if credit note is not refunded completely and not already converted and amount of payment is 0 (see also the real condition used as the condition to show button converttoreduc) if ($canconvert) { diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 8a7e0cc8054..a7619cd84ac 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -511,7 +511,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie if (empty($reshook)) { /* - * All unpayed supplier invoices + * All unpaid supplier invoices */ $sql = 'SELECT f.rowid as facid, f.ref, f.ref_supplier, f.type, f.total_ht, f.total_ttc,'; $sql .= ' f.multicurrency_code, f.multicurrency_tx, f.multicurrency_total_ht, f.multicurrency_total_tva, f.multicurrency_total_ttc,'; diff --git a/htdocs/fourn/paiement/card.php b/htdocs/fourn/paiement/card.php index 06cff4b5c9e..355b84796f2 100644 --- a/htdocs/fourn/paiement/card.php +++ b/htdocs/fourn/paiement/card.php @@ -305,7 +305,7 @@ if ($result > 0) print ''; // Expected to pay print ''; - // Payed + // Paid print ''; // Status print ''; diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index eeca137dbc0..7390c3234a5 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -101,7 +101,7 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_CREATE','Expense report created','Executed when an expense report is created','expensereport',201); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',202); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',203); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAYED','Expense report billed','Executed when an expense report is set as billed','expensereport',204); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_REPORT_PAID','Expense report billed','Executed when an expense report is set as billed','expensereport',204); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('EXPENSE_DELETE','Expense report deleted','Executed when an expense report is deleted','expensereport',205); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_VALIDATE','Expense report validated','Executed when an expense report is validated','expensereport',211); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('HOLIDAY_APPROVE','Expense report approved','Executed when an expense report is approved','expensereport',212); diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 96a681d4c56..2af0c3373c4 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -563,3 +563,6 @@ INSERT INTO llx_c_socialnetworks (entity, code, label, url, icon, active) VALUES ALTER TABLE llx_product_fournisseur_price ADD COLUMN packaging varchar(64); ALTER TABLE llx_projet ADD COLUMN fk_opp_status_end integer DEFAULT NULL; + + +UPDATE llx_c_action_trigger SET code = 'EXPENSE_REPORT_PAID' where code = 'EXPENSE_REPORT_PAYED'; diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index 00bf30f6672..c6325454b86 100644 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -248,7 +248,7 @@ CREATE TABLE llx_expensereport ( fk_user_approve integer DEFAULT NULL, fk_user_refuse integer DEFAULT NULL, fk_user_cancel integer DEFAULT NULL, - fk_statut integer NOT NULL, -- 1=brouillon, 2=validé (attente approb), 4=annulé, 5=approuvé, 6=payed, 99=refusé + fk_statut integer NOT NULL, -- 1=draft, 2=validate (waiting approbation), 4=cancel, 5=approved, 6=paid, 99=refused fk_c_paiement integer DEFAULT NULL, paid smallint DEFAULT 0 NOT NULL, note_public text, @@ -524,13 +524,13 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('CONTRACT_VALIDATE','Contract validated','Executed when a contract is validated','contrat',18); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPAL_SENTBYMAIL','Commercial proposal sent by mail','Executed when a commercial proposal is sent by mail','propal',3); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SENTBYMAIL','Customer order sent by mail','Executed when a customer order is sent by mail ','commande',5); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_PAYED','Customer invoice payed','Executed when a customer invoice is payed','facture',7); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_PAYED','Customer invoice paid','Executed when a customer invoice is paid','facture',7); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_CANCEL','Customer invoice canceled','Executed when a customer invoice is conceled','facture',8); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SENTBYMAIL','Customer invoice sent by mail','Executed when a customer invoice is sent by mail','facture',9); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_VALIDATE','Supplier order validated','Executed when a supplier order is validated','order_supplier',11); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('ORDER_SUPPLIER_SENTBYMAIL','Supplier order sent by mail','Executed when a supplier order is sent by mail','order_supplier',14); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_VALIDATE','Supplier invoice validated','Executed when a supplier invoice is validated','invoice_supplier',15); -insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_PAYED','Supplier invoice payed','Executed when a supplier invoice is payed','invoice_supplier',16); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_PAYED','Supplier invoice paid','Executed when a supplier invoice is paid','invoice_supplier',16); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_SENTBYMAIL','Supplier invoice sent by mail','Executed when a supplier invoice is sent by mail','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_CANCELED','Supplier invoice cancelled','Executed when a supplier invoice is cancelled','invoice_supplier',17); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('SHIPPING_VALIDATE','Shipping validated','Executed when a shipping is validated','shipping',20); diff --git a/htdocs/install/mysql/migration/repair.sql b/htdocs/install/mysql/migration/repair.sql index 6d662e64893..6e9ea4601f8 100644 --- a/htdocs/install/mysql/migration/repair.sql +++ b/htdocs/install/mysql/migration/repair.sql @@ -509,7 +509,7 @@ UPDATE llx_facturedet SET situation_percent = 100 WHERE situation_percent IS NUL -- from llx_facturedet as fd, llx_facture as f where fd.fk_facture = f.rowid AND (total_ht - situation_percent / 100 * subprice * qty * (1 - (fd.remise_percent / 100))) > 0.01 and f.type = 5; --- Note to make all deposit as payed when there is already a discount generated from it. +-- Note to make all deposit as paid when there is already a discount generated from it. --drop table tmp_invoice_deposit_mark_as_available; --create table tmp_invoice_deposit_mark_as_available as select * from llx_facture as f where f.type = 3 and f.paye = 0 and f.rowid in (select fk_facture_source from llx_societe_remise_except); --update llx_facture set paye = 1, fk_statut = 2 where rowid in (select rowid from tmp_invoice_deposit_mark_as_available); diff --git a/htdocs/install/mysql/tables/llx_expensereport.sql b/htdocs/install/mysql/tables/llx_expensereport.sql index 772888620fb..d591de78436 100644 --- a/htdocs/install/mysql/tables/llx_expensereport.sql +++ b/htdocs/install/mysql/tables/llx_expensereport.sql @@ -43,7 +43,7 @@ CREATE TABLE llx_expensereport ( fk_user_approve integer DEFAULT NULL, fk_user_refuse integer DEFAULT NULL, fk_user_cancel integer DEFAULT NULL, - fk_statut integer NOT NULL, -- 1=brouillon, 2=validated (waiting approval), 4=canceled, 5=approved, 6=payed, 99=refused + fk_statut integer NOT NULL, -- 1=brouillon, 2=validated (waiting approval), 4=canceled, 5=approved, 6=paid, 99=refused fk_c_paiement integer DEFAULT NULL, -- deprecated paid smallint default 0 NOT NULL, -- deprecated (status is used instead) note_public text, diff --git a/htdocs/loan/class/loan.class.php b/htdocs/loan/class/loan.class.php index ae683c829a5..1a888375bf3 100644 --- a/htdocs/loan/class/loan.class.php +++ b/htdocs/loan/class/loan.class.php @@ -377,7 +377,7 @@ class Loan extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * Tag loan as payed completely + * Tag loan as paid completely * * @param User $user Object user making change * @return int <0 if KO, >0 if OK @@ -445,7 +445,7 @@ class Loan extends CommonObject * Return label of loan status (unpaid, paid) * * @param int $mode 0=label, 1=short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount paid if you have it, 1 otherwise) * @return string Label */ public function getLibStatut($mode = 0, $alreadypaid = -1) @@ -459,7 +459,7 @@ class Loan extends CommonObject * * @param int $status Id status * @param int $mode 0=Label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Label, 5=Short label + Picto - * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise) + * @param integer $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount paid if you have it, 1 otherwise) * @return string Label */ public function LibStatut($status, $mode = 0, $alreadypaid = -1) diff --git a/htdocs/loan/list.php b/htdocs/loan/list.php index 79e38dbdeb1..744a6929fc8 100644 --- a/htdocs/loan/list.php +++ b/htdocs/loan/list.php @@ -93,7 +93,7 @@ $help_url = ''; $title = $langs->trans('Loans'); $sql = "SELECT l.rowid, l.label, l.capital, l.datestart, l.dateend, l.paid,"; -$sql .= " SUM(pl.amount_capital) as alreadypayed"; +$sql .= " SUM(pl.amount_capital) as alreadypaid"; $sql .= " FROM ".MAIN_DB_PREFIX."loan as l LEFT JOIN ".MAIN_DB_PREFIX."payment_loan AS pl"; $sql .= " ON l.rowid = pl.fk_loan"; $sql .= " WHERE l.entity = ".$conf->entity; @@ -229,7 +229,7 @@ if ($resql) print ''; print ''; print ''; diff --git a/htdocs/loan/payment/card.php b/htdocs/loan/payment/card.php index 6aebd9fb33d..ac76dbf9053 100644 --- a/htdocs/loan/payment/card.php +++ b/htdocs/loan/payment/card.php @@ -149,7 +149,7 @@ print ''; /* - * List of loans payed + * List of loans paid */ $disable_delete = 0; @@ -194,7 +194,7 @@ if ($resql) // print ''; // Status print ''; - // Amount payed + // Amount paid $amount_payed = $objp->amount_capital + $objp->amount_insurance + $objp->amount_interest; print ''; diff --git a/htdocs/public/payment/newpayment.php b/htdocs/public/payment/newpayment.php index 1a643323dce..8672fa1c2bf 100644 --- a/htdocs/public/payment/newpayment.php +++ b/htdocs/public/payment/newpayment.php @@ -1855,7 +1855,7 @@ if (preg_match('/^dopayment/', $action)) // If we choosed/click on the payment { $noidempotency_key = (GETPOSTISSET('noidempotency') ? GETPOST('noidempotency', 'int') : 0); // By default noidempotency is unset, so we must use a different tag/ref for each payment. If set, we can pay several times the same tag/ref. $paymentintent = $stripe->getPaymentIntent($amount, $currency, $tag, 'Stripe payment: '.$fulltag.(is_object($object) ? ' ref='.$object->ref : ''), $object, $stripecu, $stripeacc, $servicestatus, 0, 'automatic', false, null, 0, $noidempotency_key); - // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already payed) + // The paymentintnent has status 'requires_payment_method' (even if paymentintent was already paid) //var_dump($paymentintent); if ($stripe->error) setEventMessages($stripe->error, null, 'errors'); } diff --git a/htdocs/public/payment/paymentok.php b/htdocs/public/payment/paymentok.php index 346e4003e4c..f4b9f0feb5b 100644 --- a/htdocs/public/payment/paymentok.php +++ b/htdocs/public/payment/paymentok.php @@ -614,7 +614,7 @@ if ($ispaymentok) $ispostactionok = -1; } } else { - $postactionmessages[] = 'Member '.$tmptag['MEM'].' for subscription payed was not found'; + $postactionmessages[] = 'Member '.$tmptag['MEM'].' for subscription paid was not found'; $ispostactionok = -1; } } elseif (array_key_exists('INV', $tmptag) && $tmptag['INV'] > 0) @@ -718,7 +718,7 @@ if ($ispaymentok) $ispostactionok = -1; } } else { - $postactionmessages[] = 'Invoice payed '.$tmptag['INV'].' was not found'; + $postactionmessages[] = 'Invoice paid '.$tmptag['INV'].' was not found'; $ispostactionok = -1; } } else { diff --git a/htdocs/societe/class/api_thirdparties.class.php b/htdocs/societe/class/api_thirdparties.class.php index 81a1c167a02..3e8a6c91f92 100644 --- a/htdocs/societe/class/api_thirdparties.class.php +++ b/htdocs/societe/class/api_thirdparties.class.php @@ -1068,7 +1068,7 @@ class Thirdparties extends DolibarrApi /** * Return list of invoices qualified to be corrected by a credit note. * Invoices matching the following rules are returned - * (validated + payment on process) or classified (payed completely or payed partialy) + not already replaced + not already a credit note + * (validated + payment on process) or classified (paid completely or paid partialy) + not already replaced + not already a credit note * * @param int $id Id of thirdparty * From 3798892fd3348ec66b555a089240af5a45e643b7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 19:53:28 +0100 Subject: [PATCH 047/200] FIX Hide/Unhide external ICSS calendars --- htdocs/comm/action/index.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 016201be0f3..a603010f46a 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -514,7 +514,7 @@ if (!empty($conf->use_javascript_ajax)) // If javascript on { $s .= '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("Version").''; +print '
'.$langs->trans("Version").''; $arrayphpminversionerror = array(5, 5, 0); $arrayphpminversionwarning = array(5, 6, 0); @@ -129,11 +129,8 @@ $loadedExtensions = array_map('strtolower', get_loaded_extensions(false)); print ''; print ''; -print ''; -//print ''; -print ''; -print ''; -print ''; +print ''; +print ''; print ''; $functions = ["mb_check_encoding"]; @@ -141,9 +138,6 @@ $name = "MBString"; print ""; print ""; -//print getTableColumn($name, $activatedExtensions); -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -152,9 +146,6 @@ $name = "JSON"; print ""; print ""; -//print getTableColumn($name, $activatedExtensions); -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -163,8 +154,6 @@ $name = "GD"; print ""; print ""; -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -173,8 +162,6 @@ $name = "Curl"; print ""; print ""; -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -185,8 +172,6 @@ if (empty($_SERVER["SERVER_ADMIN"]) || $_SERVER["SERVER_ADMIN"] != 'doliwamp@loc print ""; print ""; - print getTableColumn($name, $loadedExtensions); - print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; } @@ -196,8 +181,6 @@ $name = "IMAP"; print ""; print ""; -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -206,8 +189,6 @@ $name = "xDebug"; print ""; print ""; -print getTableColumn($name, $loadedExtensions); -print getTableColumnFunction($functions); print getResultColumn($name, $activatedExtensions, $loadedExtensions, $functions); print ""; @@ -222,7 +203,7 @@ foreach ($phparray as $key => $value) print '
'; print '
'.$langs->trans("Extension").''.$langs->trans("EnabledInSetup").''.$langs->trans("Loaded").''.$langs->trans("FunctionTest").''.$langs->trans("Result").''.$langs->trans("Extension").''.$langs->trans("Test").'
".$name."
".$name."
".$name."
".$name."
".$name."
".$name."
".$name."
'; print ''; - print ''; + print ''; print ''; print "\n"; @@ -269,69 +250,6 @@ llxFooter(); $db->close(); -/** - * Return a table column with a indicator (okay or warning), based on the given name and list - * - * @param string $name The name to check inside the given list - * @param array $list A list that should contains the given name - * - * @return string - */ -function getTableColumn($name, array $list) -{ - global $langs; - - $name = strtolower($name); - $html = ""; - - return $html; -} - -/** - * Return a table column with a indicator (okay or warning), based on the given functions to check - * - * @param array $functions A list with functions to check - * - * @return string - */ -function getTableColumnFunction(array $functions) -{ - if (count($functions) < 1) - { - return ""; - } - - $result = true; - $html = ""; - - return $html; -} - /** * Return a result column with a translated result text * @@ -339,7 +257,6 @@ function getTableColumnFunction(array $functions) * @param array $activated A list with all activated PHP extensions. Deprecated. * @param array $loaded A list with all loaded PHP extensions * @param array $functions A list with all PHP functions to check - * * @return string */ function getResultColumn($name, array $activated, array $loaded, array $functions) @@ -347,6 +264,7 @@ function getResultColumn($name, array $activated, array $loaded, array $function global $langs; $result = true; + //$result = $result && in_array(strtolower($name), $activated); $result = $result && in_array(strtolower($name), $loaded); @@ -356,7 +274,29 @@ function getResultColumn($name, array $activated, array $loaded, array $function } $html = ""; return $html; diff --git a/htdocs/admin/system/security.php b/htdocs/admin/system/security.php index f978c0dcd81..f0ada86a393 100644 --- a/htdocs/admin/system/security.php +++ b/htdocs/admin/system/security.php @@ -43,9 +43,6 @@ if (GETPOST('action', 'aZ09') == 'donothing') * View */ -$form = new Form($db); -$nowstring = dol_print_date(dol_now(), 'dayhourlog'); - llxHeader(); print load_fiche_titre($langs->trans("Security"), '', 'title_setup'); @@ -78,7 +75,7 @@ else { print '
'; print '
'; -print load_fiche_titre($langs->trans("ConfigFile"), '', 'folder'); +print load_fiche_titre($langs->trans("ConfigurationFile"), '', 'folder'); print ''.$langs->trans("dolibarr_main_prod").': '.$dolibarr_main_prod; if (empty($dolibarr_main_prod)) { @@ -90,7 +87,12 @@ print ''.$langs->trans("dolibarr_nocsrfcheck").': '.$dolibarr_n if (!empty($dolibarr_nocsrfcheck)) { print img_picto('', 'warning').'   '.$langs->trans("IfYouAreOnAProductionSetThis", 0); } +print '
'; +print ''.$langs->trans("dolibarr_main_restrict_ip").': '.$dolibarr_main_restrict_ip; +/*if (empty($dolibarr_main_restrict_ip)) { + print '   '.img_picto('', 'warning').' '.$langs->trans("IfYouAreOnAProductionSetThis", 1); +}*/ print '
'; print '
'; @@ -102,9 +104,17 @@ print ''.$langs->trans("PermissionsOnFilesInWebRoot").': '; print 'TODO'; print '
'; -print ''.$langs->trans("PermissionsOnFile", 'conf.php').': '; -// TODO Check permission on file conf.php (read only for the web user) -print 'TODO'; +print ''.$langs->trans("PermissionsOnFile", $conffile).': '; // $conffile is defined into filefunc.inc.php +$perms = fileperms($dolibarr_main_document_root.'/'.$conffile); +if ($perms) { + if (($perms & 0x0004) || ($perms & 0x0002)) { + print img_warning().' '.$langs->trans("ConfFileIsReadableOrWritableByAnyUsers"); + } else { + print img_picto('', 'tick'); + } +} else { + print img_warning().' '.$langs->trans("FailedToReadFile", $conffile); +} print '
'; print '
'; @@ -137,14 +147,15 @@ print '
'; print load_fiche_titre($langs->trans("Menu").' '.$langs->trans("SecuritySetup"), '', 'folder'); //print ''.$langs->trans("PasswordEncryption").': '; -print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? 'unset' : '')."   "; +print 'MAIN_SECURITY_HASH_ALGO = '.(empty($conf->global->MAIN_SECURITY_HASH_ALGO) ? $langs->trans("Undefined") : '')."   "; print '   If unset: \'md5\' '; print ' - Recommanded value: \'password_hash\'
'; -print 'MAIN_SECURITY_SALT = '.$conf->global->MAIN_SECURITY_SALT.'
'; +print 'MAIN_SECURITY_SALT = '.(empty($conf->global->MAIN_SECURITY_SALT) ? $langs->trans("Undefined") : '').'
'; print '
'; // TODO print ''.$langs->trans("AntivirusEnabledOnUpload").': '; +print empty($conf->global->MAIN_ANTIVIRUS_COMMAND) ? '' : img_picto('', 'tick').' '; print yn($conf->global->MAIN_ANTIVIRUS_COMMAND ? 1 : 0); if (!empty($conf->global->MAIN_ANTIVIRUS_COMMAND)) { print '   - '.$conf->global->MAIN_ANTIVIRUS_COMMAND; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index bba6966fa45..cc10b054606 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -2095,3 +2095,4 @@ SeeLinkToOnlineDocumentation=See link to online documention on top menu for exam SHOW_SUBPRODUCT_REF_IN_PDF=If the feature "%s" of module %s is used, show details of subproducts of a kit on PDF. AskThisIDToYourBank=Contact your bank to get this ID AdvancedModeOnly=Permision available in Advanced permission mode only +ConfFileIsReadableOrWritableByAnyUsers=The conf file is reabable or writable by any users. Give permission to web server user and group only. From fc1d8a2c5bf134ed04f9d26b7f2abaa73dfc8251 Mon Sep 17 00:00:00 2001 From: ibuiv <50403308+ibuiv@users.noreply.github.com> Date: Tue, 2 Feb 2021 10:01:54 +0100 Subject: [PATCH 019/200] FIX(path) htdocs removed --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index d7af9b46470..14589374e3d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3234,7 +3234,7 @@ class CommandeFournisseur extends CommonOrder { if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines) > 0) { - require_once DOL_DOCUMENT_ROOT.'/htdocs/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $date_liv = dol_now(); // Build array with quantity deliverd by product From 2f6a8c85c21b3a13976080140f0b6adcf9a1d53d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 10:25:57 +0100 Subject: [PATCH 020/200] Doc --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index e1ee0138287..9722de167f9 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -317,7 +317,7 @@ class Stripe extends CommonObject * @param int $mode automatic=automatic confirmation/payment when conditions are ok, manual=need to call confirm() on intent * @param boolean $confirmnow false=default, true=try to confirm immediatly after create (if conditions are ok) * @param string $payment_method 'pm_....' (if known) - * @param string $off_session If we use an already known payment method to pay off line. + * @param string $off_session If we use an already known payment method to pay when customer is not available during the checkout flow. * @param string $noidempotency_key Do not use the idempotency_key when creating the PaymentIntent * @return \Stripe\PaymentIntent|null Stripe PaymentIntent or null if not found and failed to create */ From 3b050c34520fd072a95c529a920af50373ce0eca Mon Sep 17 00:00:00 2001 From: lvessiller Date: Tue, 2 Feb 2021 10:34:33 +0100 Subject: [PATCH 021/200] FIX select default mail template --- htdocs/core/class/html.formmail.class.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formmail.class.php b/htdocs/core/class/html.formmail.class.php index 855ce1ed7ad..d19269ffd5f 100644 --- a/htdocs/core/class/html.formmail.class.php +++ b/htdocs/core/class/html.formmail.class.php @@ -455,9 +455,11 @@ class FormMail extends Form // Zone to select email template if (count($modelmail_array) > 0) { + $model_mail_selected_id = GETPOSTISSET('modelmailselected') ? GETPOST('modelmailselected', 'int') : $arraydefaultmessage->id; + // If list of template is filled $out .= '
'."\n"; - $out .= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, 0, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); + $out .= ''.$langs->trans('SelectMailModel').': '.$this->selectarray('modelmailselected', $modelmail_array, $model_mail_selected_id, 1, 0, 0, '', 0, 0, 0, '', 'minwidth100'); if ($user->admin) $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFrom", $langs->transnoentitiesnoconv('Setup').' - '.$langs->transnoentitiesnoconv('EMails')), 1); $out .= '   '; $out .= ''; From 95e255747fa0b79e54f1ee96105c96d4fcce4427 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 10:53:59 +0100 Subject: [PATCH 022/200] Fix accent on graph of expense report --- htdocs/expensereport/class/expensereport.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index 8d5cbd3c2cc..babe69206ce 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -2319,7 +2319,7 @@ class ExpenseReport extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($result); - $ret[$obj->code] = (($langs->trans($obj->code) != $obj->code) ? $langs->trans($obj->code) : $obj->label); + $ret[$obj->code] = (($langs->transnoentitiesnoconv($obj->code) != $obj->code) ? $langs->transnoentitiesnoconv($obj->code) : $obj->label); $i++; } } else { From 506ba822e97969b7e1c018df5c39e179962b6402 Mon Sep 17 00:00:00 2001 From: kamel Date: Tue, 2 Feb 2021 11:06:01 +0100 Subject: [PATCH 023/200] FIX: Select transport mode function when create a supplier invoice and add unique key to the table llx_c_transport_mode in migrate sql --- htdocs/fourn/facture/card.php | 2 +- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/facture/card.php b/htdocs/fourn/facture/card.php index 00e0e33ea1e..3ff3d72e810 100644 --- a/htdocs/fourn/facture/card.php +++ b/htdocs/fourn/facture/card.php @@ -2095,7 +2095,7 @@ if ($action == 'create') { $langs->loadLangs(array("intracommreport")); print '
'; } diff --git a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql index 96a681d4c56..ae9f1f901b7 100644 --- a/htdocs/install/mysql/migration/12.0.0-13.0.0.sql +++ b/htdocs/install/mysql/migration/12.0.0-13.0.0.sql @@ -123,6 +123,7 @@ CREATE TABLE llx_c_transport_mode ( label varchar(255) NOT NULL, active tinyint DEFAULT 1 NOT NULL ) ENGINE=innodb; +ALTER TABLE llx_c_transport_mode ADD UNIQUE INDEX uk_c_transport_mode (code, entity); INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('MAR', 'Transport maritime (y compris camions ou wagons sur bateau)', 1); INSERT INTO llx_c_transport_mode (code, label, active) VALUES ('TRA', 'Transport par chemin de fer (y compris camions sur wagon)', 1); From 218a76ee637f011a519cbb6f4c057e7000e0e618 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:06:58 +0100 Subject: [PATCH 024/200] FIX SQL Error with postgres or mysql strict mode --- htdocs/core/boxes/box_factures_imp.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/boxes/box_factures_imp.php b/htdocs/core/boxes/box_factures_imp.php index 08233ff754c..b47f948f4ca 100644 --- a/htdocs/core/boxes/box_factures_imp.php +++ b/htdocs/core/boxes/box_factures_imp.php @@ -110,7 +110,8 @@ class box_factures_imp extends ModeleBoxes $sql .= " AND fk_statut = 1"; if (!$user->rights->societe->client->voir && !$user->socid) $sql .= " AND s.rowid = sc.fk_soc AND sc.fk_user = ".$user->id; if ($user->socid) $sql .= " AND s.rowid = ".$user->socid; - $sql .= " GROUP BY s.nom, s.rowid, s.email, s.code_client, s.logo, f.ref, f.date_lim_reglement,"; + $sql .= " GROUP BY s.rowid, s.nom, s.name_alias, s.code_client, s.code_compta, s.client, s.logo, s.email, s.entity, s.tva_intra, s.siren, s.siret, s.ape, s.idprof4, s.idprof5, s.idprof6,"; + $sql .= " f.ref, f.date_lim_reglement,"; $sql .= " f.type, f.datef, f.total, f.tva, f.total_ttc, f.paye, f.fk_statut, f.rowid"; //$sql.= " ORDER BY f.datef DESC, f.ref DESC "; $sql .= " ORDER BY datelimite ASC, f.ref ASC "; From 1fd2f126731960b96fd50aed0da5a3de1115575b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:15:16 +0100 Subject: [PATCH 025/200] Fix responsive --- htdocs/core/boxes/box_last_ticket.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/core/boxes/box_last_ticket.php b/htdocs/core/boxes/box_last_ticket.php index 268a6861524..dbc453eced6 100644 --- a/htdocs/core/boxes/box_last_ticket.php +++ b/htdocs/core/boxes/box_last_ticket.php @@ -134,7 +134,7 @@ class box_last_ticket extends ModeleBoxes $thirdparty->name = $objp->company_name; $link = $thirdparty->getNomUrl(1); } else { - $link = dol_print_email($objp->origin_email); + $link = ''.dol_print_email($objp->origin_email).''; } $r = 0; @@ -149,15 +149,15 @@ class box_last_ticket extends ModeleBoxes // Subject $this->info_box_contents[$i][$r] = array( - 'td' => '', - 'text' => $objp->subject, // Some event have no ref + 'td' => 'class="tdoverflowmax200"', + 'text' => ''.$objp->subject.'', // Some event have no ref 'url' => DOL_URL_ROOT."/ticket/card.php?track_id=".$objp->track_id, ); $r++; // Customer $this->info_box_contents[$i][$r] = array( - 'td' => '', + 'td' => 'class="tdoverflowmax100"', 'text' => $link, 'asis' => 1, ); From 7ff5cd50c322f41557a2d76a0275959f6dbd1e16 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 11:41:32 +0100 Subject: [PATCH 026/200] Fix responsive --- htdocs/compta/bank/various_payment/list.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/bank/various_payment/list.php b/htdocs/compta/bank/various_payment/list.php index 9c936c1d943..0d91eb38e7d 100644 --- a/htdocs/compta/bank/various_payment/list.php +++ b/htdocs/compta/bank/various_payment/list.php @@ -424,6 +424,10 @@ if ($result) { $obj = $db->fetch_object($result); + $variousstatic->id = $obj->rowid; + $variousstatic->ref = $obj->rowid; + $variousstatic->label = $obj->label; + print ''; // No @@ -433,15 +437,13 @@ if ($result) // Ref if ($arrayfields['ref']['checked']) { - $variousstatic->id = $obj->rowid; - $variousstatic->ref = $obj->rowid; - print ""; + print '"; if (!$i) $totalarray['nbfield']++; } // Label payment if ($arrayfields['label']['checked']) { - print ""; + print '"; if (!$i) $totalarray['nbfield']++; } @@ -460,7 +462,13 @@ if ($result) // Type if ($arrayfields['type']['checked']) { - print ''; + print ''; if (!$i) $totalarray['nbfield']++; } From b80de4aeaf2f28c17769611951e05a4d659bb164 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 13:04:41 +0100 Subject: [PATCH 027/200] FIX CSRF errors on margin forms --- htdocs/core/class/html.form.class.php | 13 ++++++---- htdocs/core/lib/ajax.lib.php | 9 ++++--- htdocs/core/tpl/objectline_create.tpl.php | 3 +-- htdocs/margin/agentMargins.php | 11 ++------- htdocs/margin/customerMargins.php | 16 +++++-------- htdocs/margin/productMargins.php | 29 +++++++---------------- htdocs/variants/combinations.php | 8 ++++--- 7 files changed, 37 insertions(+), 52 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 448bdad3cd9..bc33692e2fc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -1927,7 +1927,7 @@ class Form * Return list of products for customer in Ajax if Ajax activated or go to select_produits_list * * @param int $selected Preselected products - * @param string $htmlname Name of HTML select field (must be unique in page) + * @param string $htmlname Name of HTML select field (must be unique in page). * @param int $filtertype Filter on product type (''=nofilter, 0=product, 1=service) * @param int $limit Limit on number of returned lines * @param int $price_level Level of price to show @@ -1949,7 +1949,7 @@ class Form * @param string $nooutput No print, return the output into a string * @return void|string */ - public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = array(), $nooutput = 0) + public function select_produits($selected = '', $htmlname = 'productid', $filtertype = '', $limit = 0, $price_level = 0, $status = 1, $finished = 2, $selected_input_value = '', $hidelabel = 0, $ajaxoptions = array(), $socid = 0, $showempty = '1', $forcecombo = 0, $morecss = '', $hidepriceinlabel = 0, $warehouseStatus = '', $selected_combinations = null, $nooutput = 0) { // phpcs:enable global $langs, $conf; @@ -1997,10 +1997,13 @@ class Form } $out .= ajax_autocompleter($selected, $htmlname, DOL_URL_ROOT.'/product/ajax/products.php', $urloption, $conf->global->PRODUIT_USE_SEARCH_TO_SELECT, 1, $ajaxoptions); - if (!empty($conf->variants->enabled)) { + if (!empty($conf->variants->enabled) && is_array($selected_combinations)) { + // Code to automatically insert with javascript the select of attributes under the select of product + // when a parent of variant has been selected. $out .= ' + '."\n"; - // End of page llxFooter(); $db->close(); diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 0a015f0f73d..468d633875d 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -87,6 +87,7 @@ $picto = 'margin'; print ''; +print ''; print dol_get_fiche_head($head, 'customerMargins', $titre, 0, $picto); @@ -101,7 +102,7 @@ if ($socid > 0) { { print ''; print ''; $client = true; @@ -111,7 +112,7 @@ if ($socid > 0) { } else { print ''; print ''; } @@ -138,16 +139,16 @@ foreach ($TRes as $prod) { $TProducts[$prod['key']] = $prod['label']; } -print ''; +print ''; print ''; // Categories $TCats = $form->select_all_categories(0, array(), '', 64, 0, 1); print ''; -print ''; +print ''; print ''; @@ -365,11 +366,6 @@ $db->free($result); print ' '; diff --git a/htdocs/variants/combinations.php b/htdocs/variants/combinations.php index 24da596f3c2..933d379e48a 100644 --- a/htdocs/variants/combinations.php +++ b/htdocs/variants/combinations.php @@ -107,7 +107,9 @@ if (($action == 'add' || $action == 'create') && empty($massaction) && !GETPOST( $features = $_SESSION['addvariant_'.$object->id]; if (!$features) { - setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); + if ($action == 'create') { + setEventMessages($langs->trans('ErrorFieldsRequired'), null, 'errors'); + } } else { $reference = trim($reference); if (empty($reference)) { @@ -763,11 +765,11 @@ if (!empty($id) || !empty($ref)) print '
'; - print ''.$langs->trans('NewProductCombination').''; // NewVariant + print ''.$langs->trans('NewProductCombination').''; // NewVariant if ($productCombinations) { - print ''.$langs->trans('PropagateVariant').''; + print ''.$langs->trans('PropagateVariant').''; } print '
'; From 85357a34c8b58d91b2997f2612a6b4ad832a34b8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 13:12:12 +0100 Subject: [PATCH 028/200] Fix style of injected combo to select variant --- htdocs/core/class/html.form.class.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index bc33692e2fc..2482795147a 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2022,7 +2022,7 @@ class Form return; } - console.log("After change we get variants"); + console.log("A change has started. We get variants fields to inject html select"); jQuery.getJSON("'.DOL_URL_ROOT.'/variants/ajax/getCombinations.php", { id: jQuery(this).val() @@ -2040,8 +2040,7 @@ class Form span.append( jQuery(document.createElement(\'div\')).text(val.label).css({ \'font-weight\': \'bold\', - \'display\': \'table-cell\', - \'text-align\': \'right\' + \'display\': \'table-cell\' }) ); From 6b32fd33fd2b6e857d832a650867b3fee649218f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 13:33:44 +0100 Subject: [PATCH 029/200] Fix export with excell --- ...el2007new.modules.php => export_excel2007.modules.php} | 8 ++++---- htdocs/install/upgrade2.php | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) rename htdocs/core/modules/export/{export_excel2007new.modules.php => export_excel2007.modules.php} (98%) diff --git a/htdocs/core/modules/export/export_excel2007new.modules.php b/htdocs/core/modules/export/export_excel2007.modules.php similarity index 98% rename from htdocs/core/modules/export/export_excel2007new.modules.php rename to htdocs/core/modules/export/export_excel2007.modules.php index eb111ebb985..b93a0a0c8de 100644 --- a/htdocs/core/modules/export/export_excel2007new.modules.php +++ b/htdocs/core/modules/export/export_excel2007.modules.php @@ -17,7 +17,7 @@ */ /** - * \file htdocs/core/modules/export/export_excel2007new.modules.php + * \file htdocs/core/modules/export/export_excel2007.modules.php * \ingroup export * \brief File of class to generate export file with Excel format */ @@ -32,7 +32,7 @@ use PhpOffice\PhpSpreadsheet\Cell\Coordinate; /** * Class to build export files with Excel format */ -class ExportExcel2007new extends ModeleExports +class ExportExcel2007 extends ModeleExports { /** * @var string ID @@ -79,7 +79,7 @@ class ExportExcel2007new extends ModeleExports global $conf, $langs; $this->db = $db; - $this->id = 'excel2007new'; // Same value then xxx in file name export_xxx.modules.php + $this->id = 'excel2007'; // Same value then xxx in file name export_xxx.modules.php $this->label = 'Excel 2007'; // Label of driver $this->desc = $langs->trans('Excel2007FormatDesc'); $this->extension = 'xlsx'; // Extension for generated file by this driver @@ -199,7 +199,7 @@ class ExportExcel2007new extends ModeleExports require_once DOL_DOCUMENT_ROOT.'/includes/Psr/autoloader.php'; require_once PHPEXCELNEW_PATH.'Spreadsheet.php'; - if ($this->id == 'excel2007new') + if ($this->id == 'excel2007') { if (!class_exists('ZipArchive')) // For Excel2007, PHPSpreadSheet may need ZipArchive { diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index dabb826149c..c588959ae90 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4205,6 +4205,7 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/kiwi.modules.php', '/core/modules/facture/pdf_crabe.modules.php', '/core/modules/facture/pdf_oursin.modules.php', + '/core/modules/export/export_excel2007new.modules.php', '/api/class/api_generic.class.php', '/categories/class/api_category.class.php', From f11037c6bfa6d637ab0b73c3c978cf7cf20622e0 Mon Sep 17 00:00:00 2001 From: JC Prieto Date: Tue, 2 Feb 2021 13:40:09 +0100 Subject: [PATCH 030/200] Update bonprelevement.class.php Bad sender ICS_transfer --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 89687997a59..37fe6520eeb 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1704,7 +1704,7 @@ class BonPrelevement extends CommonObject fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); - fputs($this->file, ' '.$conf->global->PAYMENTBYBANKTRANSFER_ICS.''.$CrLf); + fputs($this->file, ' '.$this->emetteur_ics.''.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); fputs($this->file, ' '.$CrLf); From 31aebf34574a13d2f4d19ed0f862a5786f8cb03d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 13:44:54 +0100 Subject: [PATCH 031/200] Fix log --- build/generate_filelist_xml.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/generate_filelist_xml.php b/build/generate_filelist_xml.php index 41c20740d78..50eb6c84def 100755 --- a/build/generate_filelist_xml.php +++ b/build/generate_filelist_xml.php @@ -105,8 +105,8 @@ if (empty($includecustom)) { } } -print "Release : ".$release."\n"; print "Working on files into : ".DOL_DOCUMENT_ROOT."\n"; +print "Release : ".$release."\n"; print "Include custom in signature : ".$includecustom."\n"; print "Include constants in signature : "; foreach ($includeconstants as $countrycode => $tmp) { From 3021c221983eb4ef3176581a304d70bed74b5c5b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 13:49:03 +0100 Subject: [PATCH 032/200] Clean files --- htdocs/install/upgrade2.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/upgrade2.php b/htdocs/install/upgrade2.php index c588959ae90..708d8834123 100644 --- a/htdocs/install/upgrade2.php +++ b/htdocs/install/upgrade2.php @@ -4205,6 +4205,7 @@ function migrate_delete_old_files($db, $langs, $conf) '/core/modules/mailings/kiwi.modules.php', '/core/modules/facture/pdf_crabe.modules.php', '/core/modules/facture/pdf_oursin.modules.php', + '/core/modules/export/export_excel.modules.php', '/core/modules/export/export_excel2007new.modules.php', '/api/class/api_generic.class.php', From fed99aa3bbbf1e0cd9b4cc7c22985a5ea1951b70 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 15:35:40 +0100 Subject: [PATCH 033/200] FIX Assignement of actors on tasks --- htdocs/core/class/commonobject.class.php | 1 - htdocs/projet/tasks/contact.php | 56 ++++++++++++------------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 47bfab139d1..684f5d65948 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1055,7 +1055,6 @@ abstract class CommonObject { $this->error = $this->db->errno(); $this->db->rollback(); - echo 'err rollback'; return -2; } else { $this->error = $this->db->error(); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 253c2c787e4..eff772dfce9 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -57,11 +57,22 @@ $projectstatic = new Project($db); // Add new contact if ($action == 'addcontact' && $user->rights->projet->creer) { + $source = 'internal'; + if (GETPOST("addsourceexternal")) { + $source ='external'; + } + $result = $object->fetch($id, $ref); if ($result > 0 && $id > 0) { - $idfortaskuser = (GETPOST("contactid") != 0) ?GETPOST("contactid") : GETPOST("userid"); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + if ($source == 'internal') { + $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('type'); + } else { + $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('typecontact'); + } if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); @@ -72,13 +83,11 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $contactsofproject = $projectstatic->getListContactId('internal'); foreach ($contactsofproject as $key => $val) { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($val, $type, GETPOST("source", 'aZ09')); + $result = $object->add_contact($val, $typeid, $source); } } } else { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($idfortaskuser, $typeid, GETPOST("source", 'aZ09')); + $result = $object->add_contact($idfortaskuser, $typeid, $source); } } @@ -353,6 +362,12 @@ if ($id > 0 || !empty($ref)) /* * Add a new contact line */ + print ''; + print ''; + print ''; + print ''; + if ($withproject) print ''; + print '
'.$key.''.$key.''.$langs->trans("Value").'
"; - - if (in_array($name, $list)) - { - if ($name == 'xdebug') $html .= ''; - else $html .= ''; - } else { - if ($name == 'xdebug') $html .= yn(0); - else $html .= ''; - } - - $html .= "-"; - - foreach ($functions as $function) - { - $result = $result && function_exists($function); - } - - if ($result) - { - $html .= 'Ok'; - } else { - $html .= 'Warning'; - } - - $html .= ""; - $html .= $result ? $langs->trans("PHPSupport", $name) : $langs->trans("ErrorPHPDoesNotSupport", $name); + if ($result) { + if (strtolower($name) == 'xdebug') $html .= img_warning($langs->trans("ModuleActivated", "xdebug")); + else $html .= img_picto($langs->trans("Ok"), 'tick'); + if (in_array(strtolower($name), $loaded)) { + $html .= ' '.$langs->trans("Loaded").' - '; + } else { + //$html .= ' '.$langs->trans("NotLoaded").' - '; + } + if (strtolower($name) == 'xdebug') { + $html .= ' '.$langs->trans("ModuleActivated", "xdebug"); + } else { + $html .= ' '.$langs->trans("PHPSupport", $name); + } + } else { + if (strtolower($name) == 'xdebug') $html .= yn(0); + else $html .= img_warning($langs->trans("ModuleActivated", "xdebug")); + if (in_array(strtolower($name), $loaded)) { + $html .= ' '.$langs->trans("Loaded").' - '; + } else { + //$html .= ' '.$langs->trans("NotLoaded").' - '; + } + $html .= ' '.$langs->trans("ErrorPHPDoesNotSupport", $name); + } $html .= "
'.$langs->trans('IntracommReportTransportMode').''; - $form->selectModeTransport(isset($_POST['transport_mode_id']) ? $_POST['transport_mode_id'] : $transport_mode_id, 'transport_mode_id'); + $form->selectTransportMode(isset($_POST['transport_mode_id']) ? $_POST['transport_mode_id'] : $transport_mode_id, 'transport_mode_id'); print '
".$variousstatic->getNomUrl(1)."'.$variousstatic->getNomUrl(1)."".dol_trunc($obj->label, 40)."'.$variousstatic->label."'.$langs->trans("PaymentTypeShort".$obj->payment_code).' '.$obj->num_payment.''; + if ($obj->payment_code) { + print $langs->trans("PaymentTypeShort".$obj->payment_code); + print ' '; + } + print $obj->num_payment; + print '
'.$langs->trans('ThirdPartyName').''; - print $form->select_company($socid, 'socid', '(client=1 OR client=3)', 1, 0, 0); + print img_picto('', 'company').$form->select_company($socid, 'socid', '(client=1 OR client=3)', 1, 0, 0); print '
'.$langs->trans('ThirdPartyName').''; - print $form->select_company(null, 'socid', '(client=1 OR client=3)', 1, 0, 0); + print img_picto('', 'company').$form->select_company(null, 'socid', '(client=1 OR client=3)', 1, 0, 0); print '
'.$langs->trans('ChooseProduct/Service').'
'.$langs->trans('ProductOrService').''; -print $form->multiselectarray('products', $TProducts, $TSelectedProducts, 0, 0, 'minwidth500'); +print img_picto('', 'product').$form->multiselectarray('products', $TProducts, $TSelectedProducts, 0, 0, 'minwidth500'); print '
'.$langs->trans('ChooseCategory').''.$langs->trans('Category').''; print img_picto('', 'category').$form->multiselectarray('categories', $TCats, $TSelectedCats, 0, 0, 'quatrevingtpercent widthcentpercentminusx'); print '
'; if ($action != 'editline' && $user->rights->projet->creer) @@ -365,13 +380,6 @@ if ($id > 0 || !empty($ref)) print ''; print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - // Ligne ajout pour contact interne print ''; @@ -387,26 +395,17 @@ if ($id > 0 || !empty($ref)) // On recupere les id des users deja selectionnes if ($object->project->public) $contactsofproject = ''; // Everybody else $contactsofproject = $projectstatic->getListContactId('internal'); - print $form->select_dolusers((GETPOST('contactid') ?GETPOST('contactid') : $user->id), 'contactid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); + print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); print ''; print ''; - print ''; + print ''; print ''; - print ''; - // Line to add an external contact. Only if project linked to a third party. if ($projectstatic->socid) { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - print ''; print ''; print ''; - print ''; print ''; - - print ""; } } @@ -535,6 +532,9 @@ if ($id > 0 || !empty($ref)) } } print "
 
'; $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid'); print '
'; @@ -421,18 +420,16 @@ if ($id > 0 || !empty($ref)) print ''; $contactofproject = $projectstatic->getListContactId('external'); - print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject); + print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject, 0, '', false, 0, 0); $nbofcontacts = $form->num; print ''; - $formcompany->selectTypeContact($object, '', 'type', 'external', 'rowid'); + $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'rowid'); print '
"; + + print ""; + } else { print "ErrorRecordNotFound"; } From bd9eb4c9499cfef62b7ec10cf56edf6eb9d5112a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 15:35:40 +0100 Subject: [PATCH 034/200] FIX Assignement of actors on tasks --- htdocs/core/class/commonobject.class.php | 1 - htdocs/projet/tasks/contact.php | 56 ++++++++++++------------ 2 files changed, 28 insertions(+), 29 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index d8fac5e8e41..23924814d04 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1054,7 +1054,6 @@ abstract class CommonObject { $this->error = $this->db->errno(); $this->db->rollback(); - echo 'err rollback'; return -2; } else { $this->error = $this->db->error(); diff --git a/htdocs/projet/tasks/contact.php b/htdocs/projet/tasks/contact.php index 253c2c787e4..eff772dfce9 100644 --- a/htdocs/projet/tasks/contact.php +++ b/htdocs/projet/tasks/contact.php @@ -57,11 +57,22 @@ $projectstatic = new Project($db); // Add new contact if ($action == 'addcontact' && $user->rights->projet->creer) { + $source = 'internal'; + if (GETPOST("addsourceexternal")) { + $source ='external'; + } + $result = $object->fetch($id, $ref); if ($result > 0 && $id > 0) { - $idfortaskuser = (GETPOST("contactid") != 0) ?GETPOST("contactid") : GETPOST("userid"); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + if ($source == 'internal') { + $idfortaskuser = ((GETPOST("userid") != 0 && GETPOST('userid') != -1) ? GETPOST("userid") : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('type'); + } else { + $idfortaskuser = ((GETPOST("contactid") > 0) ? GETPOST("contactid", 'int') : 0); // GETPOST('contactid') may val -1 to mean empty or -2 to means "everybody" + $typeid = GETPOST('typecontact'); + } if ($idfortaskuser == -2) { $result = $projectstatic->fetch($object->fk_project); @@ -72,13 +83,11 @@ if ($action == 'addcontact' && $user->rights->projet->creer) $contactsofproject = $projectstatic->getListContactId('internal'); foreach ($contactsofproject as $key => $val) { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($val, $type, GETPOST("source", 'aZ09')); + $result = $object->add_contact($val, $typeid, $source); } } } else { - $typeid = (GETPOST('typecontact') ? GETPOST('typecontact') : GETPOST('type')); - $result = $object->add_contact($idfortaskuser, $typeid, GETPOST("source", 'aZ09')); + $result = $object->add_contact($idfortaskuser, $typeid, $source); } } @@ -353,6 +362,12 @@ if ($id > 0 || !empty($ref)) /* * Add a new contact line */ + print '
'; + print ''; + print ''; + print ''; + if ($withproject) print ''; + print ''; if ($action != 'editline' && $user->rights->projet->creer) @@ -365,13 +380,6 @@ if ($id > 0 || !empty($ref)) print ''; print "\n"; - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - // Ligne ajout pour contact interne print ''; @@ -387,26 +395,17 @@ if ($id > 0 || !empty($ref)) // On recupere les id des users deja selectionnes if ($object->project->public) $contactsofproject = ''; // Everybody else $contactsofproject = $projectstatic->getListContactId('internal'); - print $form->select_dolusers((GETPOST('contactid') ?GETPOST('contactid') : $user->id), 'contactid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); + print $form->select_dolusers((GETPOSTISSET('userid') ? GETPOST('userid', 'int') : $user->id), 'userid', 0, '', 0, '', $contactsofproject, 0, 0, 0, '', 1, $langs->trans("ResourceNotAssignedToProject")); print ''; print ''; - print ''; + print ''; print ''; - print ''; - // Line to add an external contact. Only if project linked to a third party. if ($projectstatic->socid) { - print ''; - print ''; - print ''; - print ''; - print ''; - if ($withproject) print ''; - print ''; print ''; print ''; - print ''; print ''; - - print ""; } } @@ -535,6 +532,9 @@ if ($id > 0 || !empty($ref)) } } print "
 
'; $formcompany->selectTypeContact($object, '', 'type', 'internal', 'rowid'); print '
'; @@ -421,18 +420,16 @@ if ($id > 0 || !empty($ref)) print ''; $contactofproject = $projectstatic->getListContactId('external'); - print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject); + print $form->selectcontacts($selectedCompany, '', 'contactid', 0, '', $contactofproject, 0, '', false, 0, 0); $nbofcontacts = $form->num; print ''; - $formcompany->selectTypeContact($object, '', 'type', 'external', 'rowid'); + $formcompany->selectTypeContact($object, '', 'typecontact', 'external', 'rowid'); print '
"; + + print ""; + } else { print "ErrorRecordNotFound"; } From c5201b95bb9c6f26a09a4dd8df65e1b420c5b4b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 16:12:03 +0100 Subject: [PATCH 035/200] FIX Must not be able to edit vat of all lines if not draft --- htdocs/commande/card.php | 2 +- htdocs/commande/class/commande.class.php | 2 ++ htdocs/compta/facture/class/facture.class.php | 2 ++ htdocs/core/class/commonobject.class.php | 6 ++++++ htdocs/core/tpl/objectline_title.tpl.php | 1 + 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 42ad4ac6af6..27dd6b2308e 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -615,7 +615,7 @@ if (empty($reshook)) $result = $object->set_remise($user, GETPOST('remise_percent')); } elseif ($action == 'setremiseabsolue' && $usercancreate) { $result = $object->set_remise_absolue($user, GETPOST('remise_absolue')); - } elseif ($action == 'addline' && GETPOST('submitforalllines', 'aZ09') && GETPOST('vatforalllines', 'alpha')) { + } elseif ($action == 'addline' && GETPOST('submitforalllines', 'alpha') && GETPOST('vatforalllines', 'alpha')) { // Define vat_rate $vat_rate = (GETPOST('vatforalllines') ? GETPOST('vatforalllines') : 0); $vat_rate = str_replace('*', '', $vat_rate); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 7ed6d5e7199..fae2fefefaa 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1824,6 +1824,8 @@ class Commande extends CommonOrder $this->project = null; // Clear if another value was already set by fetch_projet $this->statut = $obj->fk_statut; + $this->status = $obj->fk_statut; + $this->user_author_id = $obj->fk_user_author; $this->user_valid = $obj->fk_user_valid; $this->total_ht = $obj->total_ht; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index f036145161d..1ce1ea84f93 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -1594,6 +1594,8 @@ class Facture extends CommonInvoice $this->project = null; // Clear if another value was already set by fetch_projet $this->statut = $obj->fk_statut; + $this->status = $obj->fk_statut; + $this->date_lim_reglement = $this->db->jdate($obj->dlr); $this->mode_reglement_id = $obj->fk_mode_reglement; $this->mode_reglement_code = $obj->mode_reglement_code; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 23924814d04..9e6204bd364 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -221,6 +221,12 @@ abstract class CommonObject */ public $statut; + /** + * @var int The object's status + * @see setStatut() + */ + public $status; + /** * @var string * @see getFullAddress() diff --git a/htdocs/core/tpl/objectline_title.tpl.php b/htdocs/core/tpl/objectline_title.tpl.php index bfced08e5c8..8a7c38f8ada 100644 --- a/htdocs/core/tpl/objectline_title.tpl.php +++ b/htdocs/core/tpl/objectline_title.tpl.php @@ -65,6 +65,7 @@ if (!empty($conf->global->FACTURE_LOCAL_TAX1_OPTION) || !empty($conf->global->FA } else { print $langs->trans('VAT'); } + if (in_array($object->element, array('propal', 'commande', 'facture')) && $object->status == $object::STATUS_DRAFT) { global $mysoc; From c7a4baf7c5c77f1a853f8fb94eab0cb2e95eb304 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 16:14:40 +0100 Subject: [PATCH 036/200] Fix phpunit export excel2007 --- test/phpunit/ExportTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/phpunit/ExportTest.php b/test/phpunit/ExportTest.php index 0f5b0bd82e3..92d08e81101 100644 --- a/test/phpunit/ExportTest.php +++ b/test/phpunit/ExportTest.php @@ -259,14 +259,14 @@ class ExportTest extends PHPUnit\Framework\TestCase $expectedresult=1; $this->assertEquals($expectedresult, $result, 'Error in TSV export'); - $model='excel2007new'; + $model='excel2007'; // Build export file /* ko on php 7.4 on travis (zip not available) */ print "Process build_file for model = ".$model."\n"; $result=$objexport->build_file($user, $model, $datatoexport, $array_selected, array(), $sql); $expectedresult=1; - $this->assertEquals($expectedresult, $result, 'Error in Excel2007new export'); + $this->assertEquals($expectedresult, $result, 'Error in Excel2007 export'); return true; From 29410cac6f8d7f8afcf53f38493586033013c89a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 2 Feb 2021 16:22:16 +0100 Subject: [PATCH 037/200] Fix phpcs --- htdocs/compta/tva/info.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/compta/tva/info.php b/htdocs/compta/tva/info.php index ddabf6e2b49..45799c8e1f5 100644 --- a/htdocs/compta/tva/info.php +++ b/htdocs/compta/tva/info.php @@ -83,6 +83,8 @@ dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref', $morehtmlref, '', 0, print '
'; print '
'; +print '
'; + print '
'; dol_print_object_info($object); print '
'; From 3132877349a342e0d52a7834b822cc647e7f76e1 Mon Sep 17 00:00:00 2001 From: ptibogxiv Date: Tue, 2 Feb 2021 23:09:23 +0100 Subject: [PATCH 038/200] FIX cash fence for takepos with multientity --- htdocs/takepos/index.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/takepos/index.php b/htdocs/takepos/index.php index 51b6334a2c9..2182973a219 100644 --- a/htdocs/takepos/index.php +++ b/htdocs/takepos/index.php @@ -730,10 +730,9 @@ $( document ).ready(function() { else print "TerminalsDialog();"; } if ($conf->global->TAKEPOS_CONTROL_CASH_OPENING) - { - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE "; - $sql .= "date(date_creation) = CURDATE() "; - $sql .= ""; + $sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; + $sql .= " entity = ".$conf->entity." AND "; + $sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { $obj = $db->fetch_object($resql); @@ -917,8 +916,9 @@ if ($conf->global->TAKEPOS_PRINT_METHOD == "receiptprinter") { ); } -$sql = "SELECT rowid, status FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE "; -$sql .= "date(date_creation) = CURDATE() "; +$sql = "SELECT rowid, status, entity FROM ".MAIN_DB_PREFIX."pos_cash_fence WHERE"; +$sql .= " entity = ".$conf->entity." AND "; +$sql .= " date(date_creation) = CURDATE()"; $resql = $db->query($sql); if ($resql) { From eb15c4d800857d2421b2583d7a88b3348da5db9b Mon Sep 17 00:00:00 2001 From: Anthony Berton <34568357+bb2a@users.noreply.github.com> Date: Wed, 3 Feb 2021 11:29:54 +0100 Subject: [PATCH 039/200] 20200203 --- htdocs/comm/propal/list.php | 159 ++++++++++++++++++++------------- htdocs/langs/fr_FR/propal.lang | 5 ++ 2 files changed, 103 insertions(+), 61 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 07ff1c64dbb..16e6214cc98 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -271,6 +271,98 @@ if (empty($reshook)) include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; } +if ($action == 'validate') { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 0) { + if ($tmpproposal->valid($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); + } else { + setEventMessage($langs->trans('CantBeValidated'), 'errors'); + $error++; + } + } else { + setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; + } + } + dol_print_error($db); + $error++; + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } + } + + if ($action == "sign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 2; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); + } else { + dol_print_error($db); + $error++; + } + } else { + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); + $error++; + } + } else { + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } + } + if ($action == "nosign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 3; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); + } else { + dol_print_error($db); + $error++; + } + } else { + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); + $error++; + } + } else { + dol_print_error($db); + $error++; + } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } + } /* @@ -493,6 +585,7 @@ if ($resql) 'presend'=>$langs->trans("SendByMail"), 'prevalidate'=>$langs->trans("Validate"), 'presign'=>$langs->trans("Sign"), + 'nopresign'=>$langs->trans("NoSign"), ); if ($user->rights->propal->supprimer) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete"); if ($user->rights->propal->cloturer) $arrayofmassactions['closed'] = $langs->trans("Close"); @@ -531,6 +624,11 @@ if ($resql) print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassSignature"), $langs->trans("ConfirmMassSignatureQuestion"), "sign", null, '', 0, 200, 500, 1); } + if ($massaction == 'nopresign') + { + print $form->formconfirm($_SERVER["PHP_SELF"], $langs->trans("ConfirmMassNoSignature"), $langs->trans("ConfirmMassNoSignatureQuestion"), "nosign", null, '', 0, 200, 500, 1); + } + if ($sall) { foreach ($fieldstosearchall as $key => $val) $fieldstosearchall[$key] = $langs->trans($val); @@ -1389,67 +1487,6 @@ if ($resql) print $formfile->showdocuments('massfilesarea_proposals', '', $filedir, $urlsource, 0, $delallowed, '', 1, 1, 0, 48, 1, $param, $title, '', '', '', null, $hidegeneratedfilelistifempty); - if ($action == 'validate') { - if (GETPOST('confirm') == 'yes') { - $tmpproposal = new Propal($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 0) { - if ($tmpproposal->valid($user)) { - setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); - } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); - $error++; - } - } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors'); - $error++; - } - } - dol_print_error($db); - $error++; - } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } - } - - if ($action == "sign") { - if (GETPOST('confirm') == 'yes') { - $tmpproposal = new Propal($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 1) { - $tmpproposal->statut = 2; - if ($tmpproposal->update($user)) { - setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); - } else { - dol_print_error($db); - $error++; - } - } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); - $error++; - } - } else { - dol_print_error($db); - $error++; - } - } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } - } - } } else { dol_print_error($db); } diff --git a/htdocs/langs/fr_FR/propal.lang b/htdocs/langs/fr_FR/propal.lang index 64199c5248d..aaff4579427 100644 --- a/htdocs/langs/fr_FR/propal.lang +++ b/htdocs/langs/fr_FR/propal.lang @@ -90,12 +90,17 @@ PassedInOpenStatus = passé au statut "ouvert" CantBeSign = ne peut pas être signée Sign = Signer Signed = signé +NoSign = Non signer +NoSigned = Non signé CantBeSign = ne peut pas être signé +CantBeSign = ne peut pas être non signé CantBeValidated = Ne peut pas être validé ConfirmMassValidation = Confirmer la validation ? ConfirmMassSignature = Confirmer la signature ? +ConfirmMassNoSignature = Confirmer la non signature ? ConfirmMassValidationQuestion = Voulez-vous confirmer la validation des devis brouillons selectionnés ? ConfirmMassSignatureQuestion = Voulez-vous confirmer la signature des devis ouvert selectionnés ? +ConfirmMassNoSignatureQuestion = Voulez-vous confirmer la non signature des devis ouvert selectionnés ? PropNoProductOrService = devis ne contient pas de produits ni de services PropsNoProductOrService = devis ne contiennent pas de produits ni de services IdProposal=ID de proposition From 609428bc093343279c7b0a2c3cd99f041e6e6532 Mon Sep 17 00:00:00 2001 From: stickler-ci Date: Wed, 3 Feb 2021 10:37:15 +0000 Subject: [PATCH 040/200] Fixing style errors. --- htdocs/comm/propal/list.php | 142 ++++++++++++++++++------------------ 1 file changed, 71 insertions(+), 71 deletions(-) diff --git a/htdocs/comm/propal/list.php b/htdocs/comm/propal/list.php index 16e6214cc98..f7b42fae261 100644 --- a/htdocs/comm/propal/list.php +++ b/htdocs/comm/propal/list.php @@ -272,97 +272,97 @@ if (empty($reshook)) } if ($action == 'validate') { - if (GETPOST('confirm') == 'yes') { - $tmpproposal = new Propal($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 0) { - if ($tmpproposal->valid($user)) { - setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); - } else { - setEventMessage($langs->trans('CantBeValidated'), 'errors'); - $error++; - } + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 0) { + if ($tmpproposal->valid($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('PassedInOpenStatus'), 'mesgs'); } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors'); + setEventMessage($langs->trans('CantBeValidated'), 'errors'); $error++; } + } else { + setEventMessage($tmpproposal->ref." ".$langs->trans('IsNotADraft'), 'errors'); + $error++; } + } + dol_print_error($db); + $error++; + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); + } + } +} + +if ($action == "sign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 2; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); + } else { + dol_print_error($db); + $error++; + } + } else { + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); + $error++; + } + } else { dol_print_error($db); $error++; } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } + } + if ($error) { + $db->rollback(); + } else { + $db->commit(); } } - - if ($action == "sign") { - if (GETPOST('confirm') == 'yes') { - $tmpproposal = new Propal($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 1) { - $tmpproposal->statut = 2; - if ($tmpproposal->update($user)) { - setEventMessage($tmpproposal->ref." ".$langs->trans('Signed'), 'mesgs'); - } else { - dol_print_error($db); - $error++; - } +} +if ($action == "nosign") { + if (GETPOST('confirm') == 'yes') { + $tmpproposal = new Propal($db); + $db->begin(); + $error = 0; + foreach ($toselect as $checked) { + if ($tmpproposal->fetch($checked)) { + if ($tmpproposal->statut == 1) { + $tmpproposal->statut = 3; + if ($tmpproposal->update($user)) { + setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); + dol_print_error($db); $error++; } } else { - dol_print_error($db); + setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); $error++; } - } - if ($error) { - $db->rollback(); } else { - $db->commit(); + dol_print_error($db); + $error++; } } - } - if ($action == "nosign") { - if (GETPOST('confirm') == 'yes') { - $tmpproposal = new Propal($db); - $db->begin(); - $error = 0; - foreach ($toselect as $checked) { - if ($tmpproposal->fetch($checked)) { - if ($tmpproposal->statut == 1) { - $tmpproposal->statut = 3; - if ($tmpproposal->update($user)) { - setEventMessage($tmpproposal->ref." ".$langs->trans('NoSigned'), 'mesgs'); - } else { - dol_print_error($db); - $error++; - } - } else { - setEventMessage($tmpproposal->ref." ".$langs->trans('CantBeSign'), 'errors'); - $error++; - } - } else { - dol_print_error($db); - $error++; - } - } - if ($error) { - $db->rollback(); - } else { - $db->commit(); - } + if ($error) { + $db->rollback(); + } else { + $db->commit(); } } +} /* From bf2defbef4a83292f103ba49b2ec2e5047127134 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 12:04:28 +0100 Subject: [PATCH 041/200] More complete log --- htdocs/stripe/class/stripe.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 9722de167f9..c2029c7133d 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -923,7 +923,7 @@ class Stripe extends CommonObject dol_syslog("* createPaymentStripe get stripeacc", LOG_DEBUG); $stripeacc = $stripe->getStripeAccount($service); // Get Stripe OAuth connect account if it exists (no network access here) - dol_syslog("* createPaymentStripe Create payment on card ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); + dol_syslog("* createPaymentStripe Create payment for customer ".$customer->id." on source card ".$stripecard->id.", amounttopay=".$amounttopay.", amountstripe=".$amountstripe.", FULLTAG=".$FULLTAG, LOG_DEBUG); // Create payment intent and charge payment (confirmnow = true) $paymentintent = $stripe->getPaymentIntent($amounttopay, $currency, $FULLTAG, $description, $invoice, $customer->id, $stripeacc, $servicestatus, 0, 'automatic', true, $stripecard->id, 1); From e9b5a52a4fc134b6ef12baf8682581855e5c863d Mon Sep 17 00:00:00 2001 From: atm-lena Date: Wed, 3 Feb 2021 15:22:04 +0100 Subject: [PATCH 042/200] Add hidden conf to display supplier in object lines --- htdocs/core/tpl/objectline_view.tpl.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index 0e705f4f844..9e9da40c23a 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -166,7 +166,7 @@ else } } -if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0) +if ($user->rights->fournisseur->lire && $line->fk_fournprice > 0 && !empty($conf->global->DISPLAY_SUPPLIER_OBJECTLINES)) { require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.product.class.php'; $productfourn = new ProductFournisseur($this->db); From 6ab723e85caf920cc8c2ce0924057094f1002644 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 17:09:26 +0100 Subject: [PATCH 043/200] Fix bad path of include --- htdocs/fourn/class/fournisseur.commande.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.commande.class.php b/htdocs/fourn/class/fournisseur.commande.class.php index defd0fe7ef0..ab605e38e8d 100644 --- a/htdocs/fourn/class/fournisseur.commande.class.php +++ b/htdocs/fourn/class/fournisseur.commande.class.php @@ -3173,7 +3173,7 @@ class CommandeFournisseur extends CommonOrder { if (is_array($supplierorderdispatch->lines) && count($supplierorderdispatch->lines) > 0) { - require_once DOL_DOCUMENT_ROOT.'/htdocs/product/class/product.class.php'; + require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; $date_liv = dol_now(); // Build array with quantity deliverd by product From 5a969539d235c2d0102929ba0b55975356cecb2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 17:20:05 +0100 Subject: [PATCH 044/200] Better log --- htdocs/stripe/class/stripe.class.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/htdocs/stripe/class/stripe.class.php b/htdocs/stripe/class/stripe.class.php index 3effbb4b9cb..ff816dd2a88 100644 --- a/htdocs/stripe/class/stripe.class.php +++ b/htdocs/stripe/class/stripe.class.php @@ -325,7 +325,7 @@ class Stripe extends CommonObject { global $conf, $user; - dol_syslog("getPaymentIntent", LOG_INFO, 1); + dol_syslog(get_class($this)."::getPaymentIntent", LOG_INFO, 1); $error = 0; @@ -534,10 +534,9 @@ class Stripe extends CommonObject } } - dol_syslog("getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); + dol_syslog(get_class($this)."::getPaymentIntent return error=".$error." this->error=".$this->error, LOG_INFO, -1); - if (!$error) - { + if (!$error) { return $paymentintent; } else { return null; From c9e232f2ffb43bc475aa41601546836216ab0e24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 18:00:27 +0100 Subject: [PATCH 045/200] Try to fix import/export timeout by dynamic increase --- htdocs/admin/system/phpinfo.php | 2 +- htdocs/exports/export.php | 7 ++++--- htdocs/imports/import.php | 8 ++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/system/phpinfo.php b/htdocs/admin/system/phpinfo.php index a7bce7a3025..b6160d2d2e9 100644 --- a/htdocs/admin/system/phpinfo.php +++ b/htdocs/admin/system/phpinfo.php @@ -288,7 +288,7 @@ function getResultColumn($name, array $activated, array $loaded, array $function $html .= ' '.$langs->trans("PHPSupport", $name); } } else { - if (strtolower($name) == 'xdebug') $html .= yn(0); + if (strtolower($name) == 'xdebug') $html .= yn(0).' - '; else $html .= img_warning($langs->trans("ModuleActivated", "xdebug")); if (in_array(strtolower($name), $loaded)) { $html .= ' '.$langs->trans("Loaded").' - '; diff --git a/htdocs/exports/export.php b/htdocs/exports/export.php index c9db970cd0b..c80ee4d248f 100644 --- a/htdocs/exports/export.php +++ b/htdocs/exports/export.php @@ -270,11 +270,12 @@ if ($step == 1 || $action == 'cleanselect') if ($action == 'builddoc') { - $max_execution_time_for_export = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined + $max_execution_time_for_importexport = (empty($conf->global->EXPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->EXPORT_MAX_EXECUTION_TIME); // 5mn if not defined $max_time = @ini_get("max_execution_time"); - if ($max_time && $max_time < $max_execution_time_for_export) + if ($max_time && $max_time < $max_execution_time_for_importexport) { - @ini_set("max_execution_time", $max_execution_time_for_export); // This work only if safe mode is off. also web servers has timeout of 300 + dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); + @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 } // Build export file diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index fbb17e15280..8814fa584fa 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -1518,6 +1518,14 @@ if ($step == 5 && $datatoimport) } print '
'; } else { + $max_execution_time_for_importexport = (empty($conf->global->IMPORT_MAX_EXECUTION_TIME) ? 300 : $conf->global->IMPORT_MAX_EXECUTION_TIME); // 5mn if not defined + $max_time = @ini_get("max_execution_time"); + if ($max_time && $max_time < $max_execution_time_for_importexport) + { + dol_syslog("max_execution_time=".$max_time." is lower than max_execution_time_for_importexport=".$max_execution_time_for_importexport.". We try to increase it dynamically."); + @ini_set("max_execution_time", $max_execution_time_for_importexport); // This work only if safe mode is off. also web servers has timeout of 300 + } + // Launch import $arrayoferrors = array(); $arrayofwarnings = array(); From 348fd0fcb5ff8a2403240a9dadb0a9762d7e2ac7 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 3 Feb 2021 19:36:02 +0100 Subject: [PATCH 046/200] FIX #16160 --- htdocs/cashdesk/validation_verif.php | 2 +- htdocs/compta/facture/class/api_invoices.class.php | 2 +- htdocs/compta/index.php | 2 +- htdocs/compta/localtax/class/localtax.class.php | 5 ++--- htdocs/compta/localtax/index.php | 2 +- htdocs/compta/payment_sc/card.php | 4 ++-- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- htdocs/compta/sociales/class/chargesociales.class.php | 8 ++++---- .../sociales/class/paymentsocialcontribution.class.php | 4 ++-- htdocs/compta/tva/class/tva.class.php | 4 ++-- htdocs/compta/tva/index.php | 2 +- htdocs/core/boxes/box_factures_fourn_imp.php | 2 +- .../modules/supplier_payment/doc/pdf_standard.modules.php | 2 +- htdocs/don/payment/card.php | 2 +- htdocs/expensereport/class/expensereport.class.php | 4 ++-- htdocs/fourn/class/fournisseur.facture.class.php | 2 +- htdocs/fourn/class/paiementfourn.class.php | 2 +- htdocs/fourn/facture/card.php | 2 +- htdocs/fourn/facture/paiement.php | 2 +- htdocs/fourn/paiement/card.php | 2 +- htdocs/install/mysql/data/llx_c_action_trigger.sql | 2 +- htdocs/install/mysql/migration/12.0.0-13.0.0.sql | 3 +++ htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 6 +++--- htdocs/install/mysql/migration/repair.sql | 2 +- htdocs/install/mysql/tables/llx_expensereport.sql | 2 +- htdocs/loan/class/loan.class.php | 6 +++--- htdocs/loan/list.php | 4 ++-- htdocs/loan/payment/card.php | 4 ++-- htdocs/public/payment/newpayment.php | 2 +- htdocs/public/payment/paymentok.php | 4 ++-- htdocs/societe/class/api_thirdparties.class.php | 2 +- 31 files changed, 48 insertions(+), 46 deletions(-) diff --git a/htdocs/cashdesk/validation_verif.php b/htdocs/cashdesk/validation_verif.php index 9468c395756..1df6f805ff6 100644 --- a/htdocs/cashdesk/validation_verif.php +++ b/htdocs/cashdesk/validation_verif.php @@ -318,7 +318,7 @@ switch ($action) if ($invoice->total_ttc == $obj_facturation->amountWithTax() && $obj_facturation->getSetPaymentMode() != 'DIFF') { - // We set status to payed + // We set status to paid $result = $invoice->set_paid($user); //print 'set paid';exit; } diff --git a/htdocs/compta/facture/class/api_invoices.class.php b/htdocs/compta/facture/class/api_invoices.class.php index 19a5c8c287b..316f43bc011 100644 --- a/htdocs/compta/facture/class/api_invoices.class.php +++ b/htdocs/compta/facture/class/api_invoices.class.php @@ -1051,7 +1051,7 @@ class Invoices extends DolibarrApi } if ($this->invoice->paye) { - throw new RestException(500, 'Alreay payed'); + throw new RestException(500, 'Alreay paid'); } $this->invoice->fetch($id); diff --git a/htdocs/compta/index.php b/htdocs/compta/index.php index 1d4d1a37354..e161ab82e23 100644 --- a/htdocs/compta/index.php +++ b/htdocs/compta/index.php @@ -1090,7 +1090,7 @@ if (!empty($conf->facture->enabled) && $user->rights->facture->lire) } /* - * Unpayed supplier invoices + * Unpaid supplier invoices */ if ((!empty($conf->fournisseur->enabled) && empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) || !empty($conf->supplier_invoice->enabled)) && $user->rights->fournisseur->facture->lire) { diff --git a/htdocs/compta/localtax/class/localtax.class.php b/htdocs/compta/localtax/class/localtax.class.php index b14c567a01d..18367a04a46 100644 --- a/htdocs/compta/localtax/class/localtax.class.php +++ b/htdocs/compta/localtax/class/localtax.class.php @@ -381,7 +381,7 @@ class Localtax extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * localtax payed + * Total of localtax paid in invoice * * @param int $year Year * @return int ??? @@ -419,8 +419,7 @@ class Localtax extends CommonObject // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps /** - * localtax payed - * Total de la localtax payed + * Total of localtax paid * * @param int $year Year * @return int ??? diff --git a/htdocs/compta/localtax/index.php b/htdocs/compta/localtax/index.php index 7d48d6e1f2d..bedb7259184 100644 --- a/htdocs/compta/localtax/index.php +++ b/htdocs/compta/localtax/index.php @@ -565,7 +565,7 @@ print '
'; /* - * Payed + * Paid */ print load_fiche_titre($langs->transcountry($LTPaid, $mysoc->country_code), '', ''); diff --git a/htdocs/compta/payment_sc/card.php b/htdocs/compta/payment_sc/card.php index 11c8512a265..78fa11fc70b 100644 --- a/htdocs/compta/payment_sc/card.php +++ b/htdocs/compta/payment_sc/card.php @@ -162,7 +162,7 @@ print dol_get_fiche_end(); /* - * List of social contributions payed + * List of social contributions paid */ $disable_delete = 0; @@ -213,7 +213,7 @@ if ($resql) print '
'.price($objp->sc_amount).''.$socialcontrib->getLibStatut(4, $objp->amount).''.price($objp->amount).'
'.price($objp->d_amount).''.$don->getLibStatut(4, $objp->amount).''.price($objp->amount).'
'.img_object($langs->trans('ShowCompany'), 'company').' '.$objp->name.''.price($objp->total_ttc).''.price($objp->amount).''.$facturestatic->LibStatut($objp->paye, $objp->status, 6, 1).''.dol_print_date($db->jdate($obj->dateend), 'day').''; - print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypayed); + print $loan_static->LibStatut($obj->paid, 5, $obj->alreadypaid); print ''.price($objp->capital).''.$loan->getLibStatut(4, $objp->amount_capital).''.price($amount_payed).'