From f45239c2a9be312a9581d97ff567e8ebb19a7a79 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Mar 2019 12:03:00 +0100 Subject: [PATCH 1/6] memorize line before delete (for triggers) --- htdocs/commande/class/commande.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 07b7a907150..64cd763a43d 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1367,7 +1367,7 @@ class Commande extends CommonOrder // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2947,7 +2947,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($remise_percent)) $remise_percent=0; if (empty($special_code) || $special_code == 3) $special_code=0; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2962,7 +2962,7 @@ class Commande extends CommonOrder $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - + $this->db->begin(); // Calcul du total TTC et de la TVA pour la ligne a partir de From 00dfa86d74dc0658156496a4328b5d4fb54e9964 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Wed, 27 Mar 2019 12:09:28 +0100 Subject: [PATCH 2/6] Revert "memorize line before delete (for triggers)" This reverts commit f45239c2a9be312a9581d97ff567e8ebb19a7a79. --- htdocs/commande/class/commande.class.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 64cd763a43d..07b7a907150 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -1367,7 +1367,7 @@ class Commande extends CommonOrder // Check parameters if ($type < 0) return -1; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2947,7 +2947,7 @@ class Commande extends CommonOrder if (empty($txlocaltax2)) $txlocaltax2=0; if (empty($remise_percent)) $remise_percent=0; if (empty($special_code) || $special_code == 3) $special_code=0; - + if ($date_start && $date_end && $date_start > $date_end) { $langs->load("errors"); $this->error=$langs->trans('ErrorStartDateGreaterEnd'); @@ -2962,7 +2962,7 @@ class Commande extends CommonOrder $txtva=price2num($txtva); $txlocaltax1=price2num($txlocaltax1); $txlocaltax2=price2num($txlocaltax2); - + $this->db->begin(); // Calcul du total TTC et de la TVA pour la ligne a partir de From 5382ad207f3ebfe86506ac43d993cf05429dd9f4 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 9 Apr 2019 18:26:00 +0200 Subject: [PATCH 3/6] NEW : add payment terms to invoices list --- htdocs/compta/facture/list.php | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 749a0b28cfb..a2ea79e44dc 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -82,6 +82,7 @@ $search_montant_localtax2=GETPOST('search_montant_localtax2', 'alpha'); $search_montant_ttc=GETPOST('search_montant_ttc', 'alpha'); $search_status=GETPOST('search_status', 'intcomma'); $search_paymentmode=GETPOST('search_paymentmode', 'int'); +$search_paymentterms=GETPOST('search_paymentterms', 'int'); $search_town=GETPOST('search_town', 'alpha'); $search_zip=GETPOST('search_zip', 'alpha'); $search_state=trim(GETPOST("search_state")); @@ -162,6 +163,7 @@ $arrayfields=array( 'country.code_iso'=>array('label'=>"Country", 'checked'=>0), 'typent.code'=>array('label'=>"ThirdPartyType", 'checked'=>$checkedtypetiers), 'f.fk_mode_reglement'=>array('label'=>"PaymentMode", 'checked'=>1), + 'f.fk_cond_reglement'=>array('label'=>"PaymentConditionsShort", 'checked'=>1), 'f.total_ht'=>array('label'=>"AmountHT", 'checked'=>1), 'f.total_vat'=>array('label'=>"AmountVAT", 'checked'=>0), 'f.total_localtax1'=>array('label'=>$langs->transcountry("AmountLT1", $mysoc->country_code), 'checked'=>0, 'enabled'=>($mysoc->localtax1_assuj=="1")), @@ -214,6 +216,7 @@ if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter', $search_montant_ttc=''; $search_status=''; $search_paymentmode=''; + $search_paymentterms=''; $search_town=''; $search_zip=""; $search_state=""; @@ -359,7 +362,7 @@ $thirdpartystatic=new Societe($db); $sql = 'SELECT'; if ($sall || $search_product_category > 0) $sql = 'SELECT DISTINCT'; -$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; +$sql.= ' f.rowid as id, f.ref, f.ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total as total_ht, f.tva as total_vat, f.total_ttc,'; $sql.= ' f.localtax1 as total_localtax1, f.localtax2 as total_localtax2,'; $sql.= ' f.datef as df, f.date_lim_reglement as datelimite,'; $sql.= ' f.paye as paye, f.fk_statut,'; @@ -451,6 +454,7 @@ if ($search_status != '-1' && $search_status != '') } } if ($search_paymentmode > 0) $sql .= " AND f.fk_mode_reglement = ".$db->escape($search_paymentmode); +if ($search_paymentterms > 0) $sql .= " AND f.fk_cond_reglement = ".$db->escape($search_paymentterms); $sql.= dolSqlDateFilter("f.datef", $search_day, $search_month, $search_year); $sql.= dolSqlDateFilter("f.date_lim_reglement", $search_day_lim, $search_month_lim, $search_year_lim); if ($option == 'late') $sql.=" AND f.date_lim_reglement < '".$db->idate(dol_now() - $conf->facture->client->warning_delay)."'"; @@ -468,7 +472,7 @@ $sql.=$hookmanager->resPrint; if (! $sall) { - $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.total, f.tva, f.total_ttc,'; + $sql.= ' GROUP BY f.rowid, f.ref, ref_client, f.type, f.note_private, f.note_public, f.increment, f.fk_mode_reglement, f.fk_cond_reglement, f.total, f.tva, f.total_ttc,'; $sql.= ' f.localtax1, f.localtax2,'; $sql.= ' f.datef, f.date_lim_reglement,'; $sql.= ' f.paye, f.fk_statut,'; @@ -562,6 +566,7 @@ if ($resql) if ($search_montant_ttc != '') $param.='&search_montant_ttc='.urlencode($search_montant_ttc); if ($search_status != '') $param.='&search_status='.urlencode($search_status); if ($search_paymentmode > 0) $param.='&search_paymentmode='.urlencode($search_paymentmode); + if ($search_paymentterms > 0) $param.='&search_paymentterms='.urlencode($search_paymentterms); if ($show_files) $param.='&show_files='.urlencode($show_files); if ($option) $param.="&search_option=".urlencode($option); if ($optioncss != '') $param.='&optioncss='.urlencode($optioncss); @@ -776,6 +781,13 @@ if ($resql) $form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 1, 1, 10); print ''; } + // Payment terms + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + { + print ''; + $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', '', 0, 1, 1, 10); + print ''; + } if (! empty($arrayfields['f.total_ht']['checked'])) { // Amount @@ -869,6 +881,7 @@ if ($resql) if (! empty($arrayfields['country.code_iso']['checked'])) print_liste_field_titre($arrayfields['country.code_iso']['label'], $_SERVER["PHP_SELF"], "country.code_iso", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['typent.code']['checked'])) print_liste_field_titre($arrayfields['typent.code']['label'], $_SERVER["PHP_SELF"], "typent.code", "", $param, 'align="center"', $sortfield, $sortorder); if (! empty($arrayfields['f.fk_mode_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_mode_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_mode_reglement", "", $param, "", $sortfield, $sortorder); + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) print_liste_field_titre($arrayfields['f.fk_cond_reglement']['label'], $_SERVER["PHP_SELF"], "f.fk_cond_reglement", "", $param, "", $sortfield, $sortorder); if (! empty($arrayfields['f.total_ht']['checked'])) print_liste_field_titre($arrayfields['f.total_ht']['label'], $_SERVER['PHP_SELF'], 'f.total', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_vat']['checked'])) print_liste_field_titre($arrayfields['f.total_vat']['label'], $_SERVER['PHP_SELF'], 'f.tva', '', $param, 'class="right"', $sortfield, $sortorder); if (! empty($arrayfields['f.total_localtax1']['checked'])) print_liste_field_titre($arrayfields['f.total_localtax1']['label'], $_SERVER['PHP_SELF'], 'f.localtax1', '', $param, 'class="right"', $sortfield, $sortorder); @@ -1081,6 +1094,15 @@ if ($resql) if (! $i) $totalarray['nbfield']++; } + // Payment terms + if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) + { + print ''; + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1); + print ''; + if (! $i) $totalarray['nbfield']++; + } + // Amount HT if (! empty($arrayfields['f.total_ht']['checked'])) { From 01255602d87fd2a7389dcb8cd1b5a4a6082fb10a Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 9 Apr 2019 18:30:58 +0200 Subject: [PATCH 4/6] fix select_conditions parameters --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index a2ea79e44dc..10dfcd18ba9 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -785,7 +785,7 @@ if ($resql) if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; - $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', '', 0, 1, 1, 10); + $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1); print ''; } if (! empty($arrayfields['f.total_ht']['checked'])) From 790c5f493a4fb73053740df41906f37c7d897f11 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 9 Apr 2019 18:32:00 +0200 Subject: [PATCH 5/6] fix select_conditions parameters --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 10dfcd18ba9..474be867aab 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -785,7 +785,7 @@ if ($resql) if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; - $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1); + $form->select_conditions_paiements($search_paymentterms, 'search_paymentterms', -1, 1, 1); print ''; } if (! empty($arrayfields['f.total_ht']['checked'])) From 5f9f615e11f717f7c40c8a6bd5d4668ac83c6bc7 Mon Sep 17 00:00:00 2001 From: Christophe Battarel Date: Tue, 9 Apr 2019 18:37:36 +0200 Subject: [PATCH 6/6] fix form_conditions_reglement parameters --- htdocs/compta/facture/list.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 474be867aab..d978ddb62e5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -1098,7 +1098,7 @@ if ($resql) if (! empty($arrayfields['f.fk_cond_reglement']['checked'])) { print ''; - $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none', '', -1); + $form->form_conditions_reglement($_SERVER['PHP_SELF'], $obj->fk_cond_reglement, 'none'); print ''; if (! $i) $totalarray['nbfield']++; }