From 8dc6110c459b080b43476552ef96275d79111912 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 15 Sep 2020 11:33:22 +0200 Subject: [PATCH 1/6] Fixed a bug where a price equal zero would be replaced with the product price --- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f275f16ee03..6ee54218adc 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -825,7 +825,7 @@ if (empty($reshook)) $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht === '' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; @@ -966,7 +966,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) { + if (isset($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } // On reevalue prix selon taux tva car taux tva transaction peut etre different diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8cc3fd48aca..01db6a68fb9 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -820,7 +820,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) { + if (isset($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3d06f665e22..79936020cb4 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2016,7 +2016,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) + if (isset($price_ht)) { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); From 0adca0a66036f3ef1edea969dfdfdc4bfb5445c4 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 21 Sep 2020 11:43:08 +0200 Subject: [PATCH 2/6] fix event creation same on all page --- htdocs/contact/agenda.php | 9 +++------ htdocs/core/class/html.formactions.class.php | 2 +- htdocs/societe/agenda.php | 9 +++------ 3 files changed, 7 insertions(+), 13 deletions(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 7ac512bd32f..386847abe38 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -240,12 +240,9 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $permok = $user->rights->agenda->myactions->create; if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); } diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 8614d4ee433..1c359914bf0 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -202,7 +202,7 @@ class FormActions $newcardbutton = ''; if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) { - $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 61d473f5c43..0108ba0a607 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -139,12 +139,9 @@ if ($socid > 0) $permok = $user->rights->agenda->myactions->create; if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - //$out.='trans("AddAnAction"),'filenew'); - //$out.=""; + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&percentage=-1'; + $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); } From 1efec17228ef6739d1af0b8a67b2ff7c45d65106 Mon Sep 17 00:00:00 2001 From: Florian HENRY Date: Mon, 21 Sep 2020 11:53:09 +0200 Subject: [PATCH 3/6] remove commented code since 3 years --- htdocs/contact/agenda.php | 4 ---- htdocs/societe/agenda.php | 9 ++------- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 386847abe38..1984097d3cb 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -245,10 +245,6 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); } - - //print '
'; - //print '
'; - $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { diff --git a/htdocs/societe/agenda.php b/htdocs/societe/agenda.php index 0108ba0a607..77953f73d7c 100644 --- a/htdocs/societe/agenda.php +++ b/htdocs/societe/agenda.php @@ -139,16 +139,11 @@ if ($socid > 0) $permok = $user->rights->agenda->myactions->create; if ((!empty($objthirdparty->id) || !empty($objcon->id)) && $permok) { - if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); - $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&percentage=-1'; + if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : '').'&backtopage='.urlencode($_SERVER['PHP_SELF'].($objthirdparty->id > 0 ? '?socid='.$objthirdparty->id : '')); + $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&percentage=-1'; $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); } - - //print '
'; - //print '
'; - - $newcardbutton = ''; if (!empty($conf->agenda->enabled)) { From e373de91d96f666e78a9cc9f84abe531fbd1ea23 Mon Sep 17 00:00:00 2001 From: Tim Otte Date: Tue, 22 Sep 2020 14:43:09 +0200 Subject: [PATCH 4/6] Fixed a bug where a price equal zero would be replaced with the product price --- htdocs/comm/propal/card.php | 4 ++-- htdocs/commande/card.php | 2 +- htdocs/compta/facture/card.php | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/comm/propal/card.php b/htdocs/comm/propal/card.php index f275f16ee03..e824e365528 100644 --- a/htdocs/comm/propal/card.php +++ b/htdocs/comm/propal/card.php @@ -825,7 +825,7 @@ if (empty($reshook)) $error++; } - if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht == '' && $price_ht_devise == '') // Unit price can be 0 but not ''. Also price can be negative for proposal. + if ($prod_entry_mode == 'free' && empty($idprod) && $price_ht === '' && $price_ht_devise === '') // Unit price can be 0 but not ''. Also price can be negative for proposal. { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), null, 'errors'); $error++; @@ -966,7 +966,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) { + if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } // On reevalue prix selon taux tva car taux tva transaction peut etre different diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 8cc3fd48aca..4cb01a030f4 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -820,7 +820,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht is forced (ie: calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) { + if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); } diff --git a/htdocs/compta/facture/card.php b/htdocs/compta/facture/card.php index 3d06f665e22..bac45f0f486 100644 --- a/htdocs/compta/facture/card.php +++ b/htdocs/compta/facture/card.php @@ -2016,7 +2016,7 @@ if (empty($reshook)) $tmpprodvat = price2num(preg_replace('/\s*\(.*\)/', '', $prod->tva_tx)); // if price ht was forced (ie: from gui when calculated by margin rate and cost price). TODO Why this ? - if (!empty($price_ht)) + if (!empty($price_ht) || $price_ht === '0') { $pu_ht = price2num($price_ht, 'MU'); $pu_ttc = price2num($pu_ht * (1 + ($tmpvat / 100)), 'MU'); From 8e59d0528e3d39c0210b5db79b9aaa42bb542eba Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Sep 2020 18:33:13 +0200 Subject: [PATCH 5/6] Update html.formactions.class.php --- htdocs/core/class/html.formactions.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formactions.class.php b/htdocs/core/class/html.formactions.class.php index 1c359914bf0..54406b1075b 100644 --- a/htdocs/core/class/html.formactions.class.php +++ b/htdocs/core/class/html.formactions.class.php @@ -202,7 +202,7 @@ class FormActions $newcardbutton = ''; if (!empty($conf->agenda->enabled) && !empty($user->rights->agenda->myactions->create)) { - $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.dol_print_date(dol_now(), 'dayhourlog').'&origin='.$typeelement.'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); + $newcardbutton .= dolGetButtonTitle($langs->trans("AddEvent"), '', 'fa fa-plus-circle', DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')).'&origin='.urlencode($typeelement).'&originid='.$object->id.($object->socid > 0 ? '&socid='.$object->socid : ($socid > 0 ? '&socid='.$socid : '')).($projectid > 0 ? '&projectid='.$projectid : '').'&backtopage='.urlencode($urlbacktopage)); } From d53e7266d21a35eb302c3cfe6a12db4659e3564c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 27 Sep 2020 18:34:35 +0200 Subject: [PATCH 6/6] Update agenda.php --- htdocs/contact/agenda.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/contact/agenda.php b/htdocs/contact/agenda.php index 1984097d3cb..23a6042fbf9 100644 --- a/htdocs/contact/agenda.php +++ b/htdocs/contact/agenda.php @@ -242,7 +242,7 @@ if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { if (is_object($objthirdparty) && get_class($objthirdparty) == 'Societe') $out .= '&originid='.$objthirdparty->id.($objthirdparty->id > 0 ? '&socid='.$objthirdparty->id : ''); $out .= (!empty($objcon->id) ? '&contactid='.$objcon->id : '').'&origin=contact&originid='.$object->id.'&percentage=-1&backtopage='.urlencode($_SERVER['PHP_SELF'].($objcon->id > 0 ? '?id='.$objcon->id : '')); - $out .= '&datep='.dol_print_date(dol_now(), 'dayhourlog'); + $out .= '&datep='.urlencode(dol_print_date(dol_now(), 'dayhourlog')); } $newcardbutton = '';