From 603c28dcdd619b39c85ea0ae95b97fe581c98afa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 02:04:02 +0200 Subject: [PATCH 01/20] [ bug #1397 ] Filter by supplier orders with status Draft does not filter --- ChangeLog | 1 + htdocs/fourn/commande/liste.php | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3bb088b99f3..ef71bc6c28e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ Fix: [ bug #1381 ] PHP Warning when listing stock transactions page. Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. Fix: TCPDF error file not found in member card generation. Fix: [ bug #1380 ] Customer invoices are not grouped in company results report. +Fix: [ bug #1397 ] Filter by supplier orders with status Draft does not filter ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** Fix: Can't add user for a task. diff --git a/htdocs/fourn/commande/liste.php b/htdocs/fourn/commande/liste.php index ef6e839dd09..2c5cab19531 100644 --- a/htdocs/fourn/commande/liste.php +++ b/htdocs/fourn/commande/liste.php @@ -3,6 +3,7 @@ * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2014 Marcos García * * 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 @@ -113,7 +114,8 @@ if ($sall) } if ($socid) $sql.= " AND s.rowid = ".$socid; -if (GETPOST('statut')) +//Required triple check because statut=0 means draft filter +if (GETPOST('statut', 'int') !== '') { $sql .= " AND fk_statut =".GETPOST('statut','int'); } From b2f299f5e450934d838e287f5e63f887631ce7c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 02:22:38 +0200 Subject: [PATCH 02/20] Fix: [ bug #1411 ] Unable to set an expedition note if invoices module is not enabled --- ChangeLog | 1 + htdocs/expedition/note.php | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bb088b99f3..8f2d5ef5914 100644 --- a/ChangeLog +++ b/ChangeLog @@ -113,6 +113,7 @@ Fix: [ bug #1306 ] Fatal error when adding an external calendar. New: Added es_CL language Fix: Margin tabs bad data show Fix: [ bug #1318 ] Problem with enter key when adding an existing product to a customer invoice. +Fix: [ bug #1411 ] Unable to set an expedition note if invoices module is not enabled ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/expedition/note.php b/htdocs/expedition/note.php index 252e6f922bf..077d28c0620 100644 --- a/htdocs/expedition/note.php +++ b/htdocs/expedition/note.php @@ -77,14 +77,14 @@ if ($id > 0 || ! empty($ref)) /* Actions */ /******************************************************************************/ -if ($action == 'setnote_public' && $user->rights->facture->creer) +if ($action == 'setnote_public') { $object->fetch($id); $result=$object->update_note(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES),'_public'); if ($result < 0) dol_print_error($db,$object->error); } -else if ($action == 'setnote_private' && $user->rights->facture->creer) +else if ($action == 'setnote_private') { $object->fetch($id); $result=$object->update_note(dol_html_entity_decode(GETPOST('note_private'), ENT_QUOTES),'_private'); From 77c09d887acf2ffd3bb1cbd182fa69ed8442d573 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 02:41:39 +0200 Subject: [PATCH 03/20] Fix: [ bug #1407 ] Rouget pdf overlapped when using tracking number and public notes --- ChangeLog | 1 + htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bb088b99f3..b0a55558eae 100644 --- a/ChangeLog +++ b/ChangeLog @@ -113,6 +113,7 @@ Fix: [ bug #1306 ] Fatal error when adding an external calendar. New: Added es_CL language Fix: Margin tabs bad data show Fix: [ bug #1318 ] Problem with enter key when adding an existing product to a customer invoice. +Fix: [ bug #1407 ] Rouget pdf overlapped when using tracking number and public notes ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d924da16785..2c2a3ab768c 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -182,6 +182,7 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($object->note_public) || ! empty($object->tracking_number)) { $tab_top = 88; + $tab_top_alt = $tab_top; // Tracking number if (! empty($object->tracking_number)) @@ -196,7 +197,9 @@ class pdf_rouget extends ModelePdfExpedition $label=$outputlangs->trans("LinkToTrackYourPackage")."
"; $label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; $pdf->SetFont('','B', $default_font_size - 2); - $pdf->writeHTMLCell(60, 4, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L'); + $pdf->writeHTMLCell(60, 7, $this->posxdesc-1, $tab_top-1, $label." ".$object->tracking_url, 0, 1, false, true, 'L'); + + $tab_top_alt += 7; } } } @@ -205,7 +208,7 @@ class pdf_rouget extends ModelePdfExpedition if (! empty($object->note_public)) { $pdf->SetFont('','', $default_font_size - 1); // Dans boucle pour gerer multi-page - $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top, dol_htmlentitiesbr($object->note_public), 0, 1); + $pdf->writeHTMLCell(190, 3, $this->posxdesc-1, $tab_top_alt, dol_htmlentitiesbr($object->note_public), 0, 1); } $nexY = $pdf->GetY(); From 9cc74c36d272391e90bf566779ca3ba22812a822 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 02:45:15 +0200 Subject: [PATCH 04/20] Missing copyright info --- htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index 2c2a3ab768c..412f34b84be 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -2,6 +2,7 @@ /* Copyright (C) 2005 Rodolphe Quiedeville * Copyright (C) 2005-2012 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2014 Marcos García * * 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 From a705d4e3336c5b3b38bd51d30c3f67daaed7f288 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 03:00:46 +0200 Subject: [PATCH 05/20] Fix: [ bug #1410 ] Add customer order line asks for required Unit Price but doesn't interrupt the creation of the line --- ChangeLog | 1 + htdocs/commande/fiche.php | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3bb088b99f3..ed85d409840 100644 --- a/ChangeLog +++ b/ChangeLog @@ -113,6 +113,7 @@ Fix: [ bug #1306 ] Fatal error when adding an external calendar. New: Added es_CL language Fix: Margin tabs bad data show Fix: [ bug #1318 ] Problem with enter key when adding an existing product to a customer invoice. +Fix: [ bug #1410 ] Add customer order line asks for required Unit Price but doesn't interrupt the creation of the line ***** ChangeLog for 3.5 compared to 3.4.* ***** For users: diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 10856f27c5e..4a00c1a661b 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -617,27 +617,27 @@ else if ($action == 'addline' && $user->rights->commande->creer) if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error++; + $error = true; } if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error++; + $error = true; } if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error++; + $error = true; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error++; + $error = true; } if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error++; + $error = true; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) From fa733c8ba4f7d58e2461101e6a4178bc1acef18c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Fri, 23 May 2014 11:42:14 +0200 Subject: [PATCH 06/20] Fix: [ bug #1405 ] Rouget PDF expedition incorrect when two expeditions under the same commande --- ChangeLog | 1 + htdocs/core/modules/expedition/doc/pdf_rouget.modules.php | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 3bb088b99f3..e339b627184 100644 --- a/ChangeLog +++ b/ChangeLog @@ -26,6 +26,7 @@ Fix: [ bug #1381 ] PHP Warning when listing stock transactions page. Fix: [ bug #1367 ] "Show invoice" link after a POS sell throws an error. Fix: TCPDF error file not found in member card generation. Fix: [ bug #1380 ] Customer invoices are not grouped in company results report. +Fix: [ bug #1405 ] Rouget PDF expedition incorrect when two expeditions under the same commande ***** ChangeLog for 3.5.2 compared to 3.5.1 ***** Fix: Can't add user for a task. diff --git a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php index d924da16785..c8ade6dbb94 100644 --- a/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_rouget.modules.php @@ -179,7 +179,7 @@ class pdf_rouget extends ModelePdfExpedition $tab_height = 130; $tab_height_newpage = 150; - if (! empty($object->note_public) || ! empty($object->tracking_number)) + if (! empty($object->note_public) || (! empty($object->tracking_number) && ! empty($object->shipping_method_id))) { $tab_top = 88; From 20ec1e6ac8c8b51bc133288e704efba7c8eaedff Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 May 2014 19:55:40 +0200 Subject: [PATCH 07/20] Fix: Suppliers invoices must be visible if module supplier is on. --- htdocs/core/menus/standard/eldy.lib.php | 15 ++++++--------- htdocs/fourn/facture/impayees.php | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 3f059d7dc76..2b84f51cb0d 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -758,16 +758,13 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu // Suppliers if (! empty($conf->societe->enabled) && ! empty($conf->fournisseur->enabled)) { - if (! empty($conf->facture->enabled)) - { - $langs->load("bills"); - $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); - $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); - $newmenu->add("/fourn/facture/impayees.php", $langs->trans("Unpaid"),1,$user->rights->fournisseur->facture->lire); - $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"),1,$user->rights->fournisseur->facture->lire); + $langs->load("bills"); + $newmenu->add("/fourn/facture/list.php?leftmenu=suppliers_bills", $langs->trans("BillsSuppliers"),0,$user->rights->fournisseur->facture->lire, '', $mainmenu, 'suppliers_bills'); + $newmenu->add("/fourn/facture/fiche.php?action=create",$langs->trans("NewBill"),1,$user->rights->fournisseur->facture->creer); + $newmenu->add("/fourn/facture/impayees.php", $langs->trans("Unpaid"),1,$user->rights->fournisseur->facture->lire); + $newmenu->add("/fourn/facture/paiement.php", $langs->trans("Payments"),1,$user->rights->fournisseur->facture->lire); - $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"),1,$user->rights->fournisseur->facture->lire); - } + $newmenu->add("/compta/facture/stats/index.php?leftmenu=suppliers_bills&mode=supplier", $langs->trans("Statistics"),1,$user->rights->fournisseur->facture->lire); } // Orders diff --git a/htdocs/fourn/facture/impayees.php b/htdocs/fourn/facture/impayees.php index 1d81ae01230..d6a24b01ec6 100644 --- a/htdocs/fourn/facture/impayees.php +++ b/htdocs/fourn/facture/impayees.php @@ -31,7 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php'; -if (! $user->rights->facture->lire) accessforbidden(); +if (! $user->rights->fournisseur->facture->lire) accessforbidden(); $langs->load("companies"); $langs->load("bills"); From 23e951ff2a37bc5b8f004777d744ad4ae7abbde2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 May 2014 20:54:23 +0200 Subject: [PATCH 08/20] Fix: select_date accepts -1 or '' but not 0 --- htdocs/comm/propal.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 361ccf13c22..33365889d48 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1407,7 +1407,7 @@ if ($action == 'create') } else { - $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $form->select_date($datepropal,'liv_','','','',"addprop"); } print ''; From f34aadef3df57794de74006bc2c2c9fc4da6be12 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 23 May 2014 21:06:53 +0200 Subject: [PATCH 09/20] Fix: css --- htdocs/comm/propal.php | 2 +- htdocs/theme/eldy/style.css.php | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 33365889d48..5463bf7a69d 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1368,7 +1368,7 @@ if ($action == 'create') // Date print ''.$langs->trans('Date').''; - $form->select_date('','','','','',"addprop"); + $form->select_date('','','','','',"addprop",1,1); print ''; // Validaty duration diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php index d6d5199b3c6..fd2c8a17252 100644 --- a/htdocs/theme/eldy/style.css.php +++ b/htdocs/theme/eldy/style.css.php @@ -2269,6 +2269,8 @@ li.cal_event { border: none; list-style-type: none; } /* Ajax - Liste deroulante de l'autocompletion */ /* ============================================================================== */ +.ui-widget-content { border: solid 1px rgba(0,0,0,.3); background: #fff; } + .ui-autocomplete-loading { background: white url() right center no-repeat; } .ui-autocomplete { position:absolute; @@ -2482,7 +2484,7 @@ A.none, A.none:active, A.none:visited, A.none:hover { { line-height: 1em !important; } -.ui-autocomplete-input { margin: 0; padding: 1px; } +.ui-autocomplete-input { margin: 0; padding: 2px; } /* ============================================================================== */ From 1df758320de0fc201f358d3ab955be820f10ddd3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 12:55:39 +0200 Subject: [PATCH 10/20] Fix: the delivery date must not be set with date of proposal. --- htdocs/comm/propal.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 5463bf7a69d..513e7cb5032 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1407,8 +1407,7 @@ if ($action == 'create') } else { - $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; - $form->select_date($datepropal,'liv_','','','',"addprop"); + $form->select_date(-1,'liv_','','','',"addprop",1,1); } print ''; From b11ef37c5882f3c9713f47a6f7dd3efe1c9a85b0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 12:59:44 +0200 Subject: [PATCH 11/20] Fix: Bad balance of table --- htdocs/comm/propal.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 513e7cb5032..f57778a42a4 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1461,7 +1461,7 @@ if ($action == 'create') print ''; } - print ''; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
'; if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) { // For backward compatibility @@ -1532,14 +1532,11 @@ if ($action == 'create') print ''; print ''; } - print "
%
"; - } print ''; } - print ''; - print '
'; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE) || ! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print '
'; $langs->load("bills"); print '
'; From 2a6b2a454075b31f43e356a8af4f3795070d12ae Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 14:00:58 +0200 Subject: [PATCH 12/20] Fix: Stat page show no cache when there is, if user was using apc. --- htdocs/admin/system/perf.php | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php index ce74d128a7a..124fc7d35bd 100644 --- a/htdocs/admin/system/perf.php +++ b/htdocs/admin/system/perf.php @@ -85,18 +85,35 @@ print '
'; // OPCode cache print '
'; print ''.$langs->trans("OPCodeCache").': '; -$test1=function_exists('xcache_info'); -if ($test1) +$foundcache=0; +$test=function_exists('xcache_info'); +if (! $foundcache && $test) { + $foundcache++; print img_picto('','tick.png').' '.$langs->trans("XCacheInstalled"); print ' '.$langs->trans("MoreInformation").' Xcache admin page'; } -else +$test=function_exists('eaccelerator_info'); +if (! $foundcache && $test) { - $test2=function_exists('eaccelerator_info'); - if ($test2) print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled"); - else print $langs->trans("NoOPCodeCacheFound"); + $foundcache++; + print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled"); } +$test=function_exists('apc_cache_info'); +if (! $foundcache && $test) +{ + //var_dump(apc_cache_info()); + if (ini_get('apc.enabled')) + { + $foundcache++; + print img_picto('','tick.png').' '.$langs->trans("APCInstalled"); + } + else + { + print img_picto('','warning').' '.$langs->trans("APCCacheInstalledButDisabled"); + } +} +if (! $foundcache) print $langs->trans("NoOPCodeCacheFound"); print '
'; // HTTPCacheStaticResources From 872e764c94ab5970eee8c89efdf4cf46d30792a0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 14:57:41 +0200 Subject: [PATCH 13/20] Fix: html detection was not working with hx tags. --- htdocs/core/lib/functions.lib.php | 3 ++- test/phpunit/FunctionsLibTest.php | 11 +++++++---- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index e37045ef88b..db5de85015d 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3673,6 +3673,7 @@ function dol_textishtml($msg,$option=0) elseif (preg_match('/<(br|div|font|img|li|span|strong|table)>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*>/i',$msg)) return true; elseif (preg_match('/<(br|div|font|img|li|span|strong|table)\s+[^<>\/]*\/>/i',$msg)) return true; + elseif (preg_match('//i',$msg)) return true; elseif (preg_match('/&[A-Z0-9]{1,6};/i',$msg)) return true; // Html entities names (http://www.w3schools.com/tags/ref_entities.asp) elseif (preg_match('/&#[0-9]{2,3};/i',$msg)) return true; // Html entities numbers (http://www.w3schools.com/tags/ref_entities.asp) return false; @@ -4532,4 +4533,4 @@ function natural_search($fields, $value) return " AND " . ($end > 1? '(' : '') . $res; } -?> +?> \ No newline at end of file diff --git a/test/phpunit/FunctionsLibTest.php b/test/phpunit/FunctionsLibTest.php index b8414dd170e..342a7074ce9 100755 --- a/test/phpunit/FunctionsLibTest.php +++ b/test/phpunit/FunctionsLibTest.php @@ -186,6 +186,9 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase $input='xxx
'; $after=dol_textishtml($input); $this->assertTrue($after); + $input='

abc

'; + $after=dol_textishtml($input); + $this->assertTrue($after); // False $input='xxx < br>'; @@ -528,16 +531,16 @@ class FunctionsLibTest extends PHPUnit_Framework_TestCase public function testVerifCond() { $verifcond=verifCond('1==1'); - $this->assertTrue($verifcond); + $this->assertTrue($verifcond,'Test a true comparison'); $verifcond=verifCond('1==2'); - $this->assertFalse($verifcond); + $this->assertFalse($verifcond,'Test a false comparison'); $verifcond=verifCond('$conf->facture->enabled'); - $this->assertTrue($verifcond); + $this->assertTrue($verifcond,'Test that conf property of a module report true when enabled'); $verifcond=verifCond('$conf->moduledummy->enabled'); - $this->assertFalse($verifcond); + $this->assertFalse($verifcond,'Test that conf property of a module report false when disabled'); $verifcond=verifCond(''); $this->assertTrue($verifcond); From a51e18a5a7577d517c49a71fac8ccdf3f6fc18f4 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 15:20:26 +0200 Subject: [PATCH 14/20] Fix: $error var must use type int and be increased when error found. Using $error as boolean at some place was source of error. --- htdocs/commande/fiche.php | 12 ++++---- htdocs/holiday/admin/holiday.php | 50 +++++++++++++++++-------------- htdocs/holiday/define_holiday.php | 15 ++++++---- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 4a00c1a661b..43fe619bd1a 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -568,7 +568,7 @@ else if ($action == 'setnote_private' && $user->rights->commande->creer) else if ($action == 'addline' && $user->rights->commande->creer) { $langs->load('errors'); - $error = false; + $error = 0; // Set if we used free entry or predefined product if (GETPOST('addline_libre') @@ -617,27 +617,27 @@ else if ($action == 'addline' && $user->rights->commande->creer) if ((empty($idprod) || GETPOST('usenewaddlineform')) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error = true; + $error++; } if (empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error = true; + $error++; } if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error = true; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error = true; + $error++; } if (empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error = true; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) diff --git a/htdocs/holiday/admin/holiday.php b/htdocs/holiday/admin/holiday.php index 174adbdf725..2b265711fa1 100644 --- a/htdocs/holiday/admin/holiday.php +++ b/htdocs/holiday/admin/holiday.php @@ -60,18 +60,18 @@ $cp = new Holiday($db); if ($action == "add") { $message = ''; - $error = false; + $error = 0; // Option du groupe de validation /*if (!$cp->updateConfCP('userGroup',$_POST['userGroup'])) { - $error = true; + $error++; }*/ // Option du délai pour faire une demande de congés payés if (!$cp->updateConfCP('delayForRequest',$_POST['delayForRequest'])) { - $error = true; + $error++; } // Option du nombre de jours à ajouter chaque mois @@ -79,67 +79,69 @@ if ($action == "add") if(!$cp->updateConfCP('nbHolidayEveryMonth',$nbHolidayEveryMonth)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage $OptMariageCP = price2num($_POST['OptMariage'],5); if(!$cp->updateConfCP('OptMariage',$OptMariageCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un proche $OptDecesProcheCP = price2num($_POST['OptDecesProche'],5); if(!$cp->updateConfCP('OptDecesProche',$OptDecesProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un mariage d'un enfant $OptMariageProcheCP = price2num($_POST['OptMariageProche'],5); if(!$cp->updateConfCP('OptMariageProche',$OptMariageProcheCP)) { - $error = true; + $error++; } // Option du nombre de jours pour un décés d'un parent $OptDecesParentsCP = price2num($_POST['OptDecesParents'],5); if(!$cp->updateConfCP('OptDecesParents',$OptDecesParentsCP)) { - $error = true; + $error++; } // Option pour avertir le valideur si délai de demande incorrect if(isset($_POST['AlertValidatorDelay'])) { if(!$cp->updateConfCP('AlertValidatorDelay','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorDelay','0')) { - $error = true; + $error++; } } // Option pour avertir le valideur si solde des congés de l'utilisateur inccorect if(isset($_POST['AlertValidatorSolde'])) { if(!$cp->updateConfCP('AlertValidatorSolde','1')) { - $error = true; + $error++; } } else { if(!$cp->updateConfCP('AlertValidatorSolde','0')) { - $error = true; + $error++; } } // Option du nombre de jours à déduire pour 1 jour de congés $nbHolidayDeducted = price2num($_POST['nbHolidayDeducted'],2); - if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) { - $error = true; + if(!$cp->updateConfCP('nbHolidayDeducted',$nbHolidayDeducted)) + { + $error++; } - if ($error) { + if ($error) + { $message = '
'.$langs->trans('ErrorUpdateConfCP').'
'; } else { $message = '
'.$langs->trans('UpdateConfCPOK').'
'; @@ -151,8 +153,8 @@ if ($action == "add") $result = $db->query($sql); $num = $db->num_rows($sql); - - if($num < 1) { + if($num < 1) + { $cp->createCPusers(); $message.= '
'.$langs->trans('AddCPforUsers').'
'; } @@ -202,7 +204,7 @@ elseif ($action == 'create_event') } elseif($action == 'event' && isset($_POST['update_event'])) { - $error = false; + $error = 0; $eventId = array_keys($_POST['update_event']); $eventId = $eventId[0]; @@ -213,19 +215,21 @@ elseif($action == 'event' && isset($_POST['update_event'])) $eventValue = $optValue; $eventValue = $eventValue[$eventId]; - if(!empty($eventName)) { + if (!empty($eventName)) + { $eventName = trim($eventName); } else { - $error = true; + $error++; } - if(!empty($eventValue)) { + if (!empty($eventValue)) + { $eventValue = price2num($eventValue,2); } else { - $error = true; + $error++; } - if(!$error) + if (!$error) { // Mise à jour des congés de l'utilisateur $update = $cp->updateEventCP($eventId,$eventName,$eventValue); diff --git a/htdocs/holiday/define_holiday.php b/htdocs/holiday/define_holiday.php index 1cf37e77d6f..f167422f503 100644 --- a/htdocs/holiday/define_holiday.php +++ b/htdocs/holiday/define_holiday.php @@ -82,7 +82,7 @@ if ($action == 'update' && isset($_POST['update_cp'])) $sql.= " value = '".dol_print_date($now,'%Y%m%d%H%M%S')."'"; $sql.= " WHERE name = 'lastUpdate' and value IS NULL"; // Add value IS NULL to be sure to update only at init. dol_syslog('define_holiday update lastUpdate entry sql='.$sql); - $result = $db->query($sql); + $result = $db->query($sql); $mesg='
'.$langs->trans('UpdateConfCPOK').'
'; @@ -91,21 +91,24 @@ if ($action == 'update' && isset($_POST['update_cp'])) } elseif($action == 'add_event') { - $error = false; + $error = 0; if(!empty($_POST['list_event']) && $_POST['list_event'] > 0) { $event = $_POST['list_event']; - } else { $error = true; + } else { $error++; } if(!empty($_POST['userCP']) && $_POST['userCP'] > 0) { $userCP = $_POST['userCP']; - } else { $error = true; + } else { $erro++; } - if($error) { + if ($error) + { $message = '
'.$langs->trans('ErrorAddEventToUserCP').'
'; - } else { + } + else + { $nb_holiday = $holiday->getCPforUser($userCP); $add_holiday = $holiday->getValueEventCp($event); $new_holiday = $nb_holiday + $add_holiday; From 9bc1a6b4f56e34724cb62f9b7c1fd6bcbb072d19 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 24 May 2014 18:29:22 +0200 Subject: [PATCH 15/20] Fix: favicon must use dol_buildpath and not hardcoded path Conflicts: htdocs/core/lib/security2.lib.php --- htdocs/core/lib/security2.lib.php | 3 ++- htdocs/main.inc.php | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/htdocs/core/lib/security2.lib.php b/htdocs/core/lib/security2.lib.php index a33c1b5d443..a95d7a52356 100644 --- a/htdocs/core/lib/security2.lib.php +++ b/htdocs/core/lib/security2.lib.php @@ -286,7 +286,8 @@ function dol_loginfunction($langs,$conf,$mysoc) // Set jquery theme $dol_loginmesg = (! empty($_SESSION["dol_loginmesg"])?$_SESSION["dol_loginmesg"]:''); - $favicon=DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/favicon.ico'; + $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); + if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; $jquerytheme = 'smoothness'; if (! empty($conf->global->MAIN_USE_JQUERY_THEME)) $jquerytheme = $conf->global->MAIN_USE_JQUERY_THEME; diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 98adfca23e0..12dbfee552d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -959,6 +959,7 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs print ''."\n"; // Evite indexation par robots print ''."\n"; $favicon=dol_buildpath('/theme/'.$conf->theme.'/img/favicon.ico',1); + if (! empty($conf->global->MAIN_FAVICON_URL)) $favicon=$conf->global->MAIN_FAVICON_URL; print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; if (empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) print ''."\n"; From ae01c785c5dac1120dbe4b262d9f9468680ce7da Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 May 2014 03:57:13 +0200 Subject: [PATCH 16/20] Fix: Do not show ref supplier title if ref_supplier not set (currently always the case with 3.5). --- htdocs/core/lib/pdf.lib.php | 8 +++---- .../fourn/class/fournisseur.facture.class.php | 22 +++++++++---------- .../fourn/class/fournisseur.product.class.php | 9 ++++++-- htdocs/fourn/facture/fiche.php | 3 ++- htdocs/product/class/product.class.php | 14 +++++++----- 5 files changed, 32 insertions(+), 24 deletions(-) diff --git a/htdocs/core/lib/pdf.lib.php b/htdocs/core/lib/pdf.lib.php index 13047234834..d8723334328 100644 --- a/htdocs/core/lib/pdf.lib.php +++ b/htdocs/core/lib/pdf.lib.php @@ -128,7 +128,7 @@ function pdf_getInstance($format='',$metric='mm',$pagetype='P') // Protection and encryption of pdf if (empty($conf->global->MAIN_USE_FPDF) && ! empty($conf->global->PDF_SECURITY_ENCRYPTION)) - { + { /* Permission supported by TCPDF - print : Print the document; - modify : Modify the contents of the document by operations other than those controlled by 'fill-forms', 'extract' and 'assemble'; @@ -957,7 +957,7 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (! empty($conf->global->MAIN_MULTILANGS) && ($outputlangs->defaultlang != $langs->defaultlang)) { if (! empty($prodser->multilangs[$outputlangs->defaultlang]["label"]) && $label == $prodser->label) $label=$prodser->multilangs[$outputlangs->defaultlang]["label"]; - + //Manage HTML entities description test //Cause $prodser->description is store with htmlentities but $desc no $needdesctranslation=false; @@ -1032,10 +1032,10 @@ function pdf_getlinedesc($object,$i,$outputlangs,$hideref=0,$hidedesc=0,$issuppl if (empty($hideref)) { - if ($issupplierline) $ref_prodserv = $prodser->ref.' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')'; // Show local ref and supplier ref + if ($issupplierline) $ref_prodserv = $prodser->ref.($ref_supplier ? ' ('.$outputlangs->transnoentitiesnoconv("SupplierRef").' '.$ref_supplier.')' : ''); // Show local ref and supplier ref else $ref_prodserv = $prodser->ref; // Show local ref only - $ref_prodserv .= " - "; + if (! empty($libelleproduitservice)) $ref_prodserv .= " - "; } $libelleproduitservice=$prefix_prodserv.$ref_prodserv.$libelleproduitservice; diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d8f15c5b9b3..d8a1a1d824e 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -420,7 +420,7 @@ class FactureFournisseur extends CommonInvoice */ function fetch_lines() { - $sql = 'SELECT f.rowid, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; + $sql = 'SELECT f.rowid, f.ref as ref_supplier, f.description, f.pu_ht, f.pu_ttc, f.qty, f.remise_percent, f.tva_tx, f.tva'; $sql.= ', f.localtax1_tx, f.localtax2_tx, f.total_localtax1, f.total_localtax2 '; $sql.= ', f.total_ht, f.tva as total_tva, f.total_ttc, f.fk_product, f.product_type, f.info_bits'; $sql.= ', p.rowid as product_id, p.ref as product_ref, p.label as label, p.description as product_desc'; @@ -428,7 +428,7 @@ class FactureFournisseur extends CommonInvoice $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON f.fk_product = p.rowid'; $sql.= ' WHERE fk_facture_fourn='.$this->id; - dol_syslog("FactureFournisseur::fetch_lines sql=".$sql, LOG_DEBUG); + dol_syslog(get_class($this)."::fetch_lines sql=".$sql, LOG_DEBUG); $resql_rows = $this->db->query($sql); if ($resql_rows) { @@ -443,10 +443,10 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i] = new stdClass(); $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->description = $obj->description; - $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference - //$this->lines[$i]->ref_fourn = $obj->ref_fourn; // Reference fournisseur du produit - $this->lines[$i]->libelle = $obj->label; // Label du produit + $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated. Replace with next line + //$this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref into ref_supplier into table llx_facture_fourn_det and update it into updateline + $this->lines[$i]->libelle = $obj->label; // deprecated $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit $this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ttc = $obj->pu_ttc; @@ -474,7 +474,7 @@ class FactureFournisseur extends CommonInvoice else { $this->error=$this->db->error(); - dol_syslog('FactureFournisseur::fetch_lines: Error '.$this->error,LOG_ERR); + dol_syslog(get_class($this).'::fetch_lines: Error '.$this->error,LOG_ERR); return -3; } } @@ -1127,7 +1127,7 @@ class FactureFournisseur extends CommonInvoice * Update a line detail into database * * @param int $id Id of line invoice - * @param string $label Description of line + * @param string $desc Description of line * @param double $pu Prix unitaire (HT ou TTC selon price_base_type) * @param double $vatrate VAT Rate * @param double $txlocaltax1 LocalTax1 Rate @@ -1141,9 +1141,9 @@ class FactureFournisseur extends CommonInvoice * @param int $notrigger Disable triggers * @return int <0 if KO, >0 if OK */ - function updateline($id, $label, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) + function updateline($id, $desc, $pu, $vatrate, $txlocaltax1=0, $txlocaltax2=0, $qty=1, $idproduct=0, $price_base_type='HT', $info_bits=0, $type=0, $remise_percent=0, $notrigger=false) { - dol_syslog(get_class($this)."::updateline $id,$label,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); + dol_syslog(get_class($this)."::updateline $id,$desc,$pu,$vatrate,$qty,$idproduct,$price_base_type,$info_bits,$type,$remise_percent", LOG_DEBUG); include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php'; $pu = price2num($pu); @@ -1169,7 +1169,7 @@ class FactureFournisseur extends CommonInvoice $localtaxes_type=getLocalTaxesFromRate($vatrate,0,$this->thirdparty); - $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty,$localtaxes_type); + $tabprice = calcul_price_total($qty, $pu, $remise_percent, $vatrate, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type, $this->thirdparty, $localtaxes_type); $total_ht = $tabprice[0]; $total_tva = $tabprice[1]; $total_ttc = $tabprice[2]; @@ -1192,7 +1192,7 @@ class FactureFournisseur extends CommonInvoice } $sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn_det SET"; - $sql.= " description ='".$this->db->escape($label)."'"; + $sql.= " description ='".$this->db->escape($desc)."'"; $sql.= ", pu_ht = ".price2num($pu_ht); $sql.= ", pu_ttc = ".price2num($pu_ttc); $sql.= ", qty = ".price2num($qty); diff --git a/htdocs/fourn/class/fournisseur.product.class.php b/htdocs/fourn/class/fournisseur.product.class.php index 10bbd8b270b..5efef7b7c35 100644 --- a/htdocs/fourn/class/fournisseur.product.class.php +++ b/htdocs/fourn/class/fournisseur.product.class.php @@ -40,8 +40,13 @@ class ProductFournisseur extends Product var $product_fourn_price_id; // id of ligne product-supplier var $id; // product id - var $fourn_ref; // ref supplier - var $fourn_qty; // quantity for price + var $fourn_ref; // deprecated + var $ref_supplier; // ref supplier (can be set by get_buyprice) + var $vatrate_supplier; // default vat rate for this supplier/qty/product (can be set by get_buyprice) + + var $fourn_qty; // quantity for price (can be set by get_buyprice) + var $fourn_pu; // unit price for quantity (can be set by get_buyprice) + var $fourn_price; // price for quantity var $fourn_remise_percent; // discount for quantity (percent) var $fourn_remise; // discount for quantity (amount) diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 566ae26f640..0f15ff42885 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -542,7 +542,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) } if (GETPOST('addline_predefined') || (! GETPOST('dp_desc') && ! GETPOST('addline_predefined') && GETPOST('idprod', 'int')>0) // we push enter onto qty field - ) + ) { $predef=(($conf->global->MAIN_FEATURES_LEVEL < 2) ? '_predef' : ''); $idprod=GETPOST('idprod', 'int'); @@ -593,6 +593,7 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) $type = $productsupplier->type; + // TODO Save the product supplier ref into database into field ref_supplier (must rename field ref into ref_supplier first) $result=$object->addline($desc, $productsupplier->fourn_pu, $tvatx, $localtax1tx, $localtax2tx, $qty, $idprod, $remise_percent, '', '', 0, $npr); } if ($idprod == 0) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 308ca339303..934706a1c95 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -902,14 +902,14 @@ class Product extends CommonObject /** - * Lit le prix pratique par un fournisseur - * On renseigne le couple prodfournprice/qty ou le triplet qty/product_id/fourn_ref + * Read price used by a provider + * We enter as input couple prodfournprice/qty or triplet qty/product_id/fourn_ref * * @param int $prodfournprice Id du tarif = rowid table product_fournisseur_price * @param double $qty Quantity asked * @param int $product_id Filter on a particular product id * @param string $fourn_ref Filter on a supplier ref - * @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve + * @return int <-1 if KO, -1 if qty not enough, 0 si ok mais rien trouve, id_product si ok et trouve. May also initialize some properties like (->ref_supplier, buyprice, fourn_pu, vatrate_supplier...) */ function get_buyprice($prodfournprice,$qty,$product_id=0,$fourn_ref=0) { @@ -940,7 +940,7 @@ class Product extends CommonObject { // We do same select again but searching with qty, ref and id product $sql = "SELECT pfp.rowid, pfp.price as price, pfp.quantity as quantity, pfp.fk_soc,"; - $sql.= " pfp.fk_product, pfp.ref_fourn, pfp.tva_tx"; + $sql.= " pfp.fk_product, pfp.ref_fourn as ref_supplier, pfp.tva_tx"; $sql.= " FROM ".MAIN_DB_PREFIX."product_fournisseur_price as pfp"; $sql.= " WHERE pfp.ref_fourn = '".$fourn_ref."'"; $sql.= " AND pfp.fk_product = ".$product_id; @@ -955,9 +955,11 @@ class Product extends CommonObject $obj = $this->db->fetch_object($resql); if ($obj && $obj->quantity > 0) // If found { - $this->buyprice = $obj->price; // \deprecated + $this->buyprice = $obj->price; // deprecated + $this->fourn_qty = $obj->quantity; // min quantity for price $this->fourn_pu = $obj->price / $obj->quantity; // Prix unitaire du produit pour le fournisseur $fourn_id - $this->ref_fourn = $obj->ref_fourn; // Ref supplier + $this->ref_fourn = $obj->ref_supplier; // deprecated + $this->ref_supplier = $obj->ref_supplier; // Ref supplier $this->vatrate_supplier = $obj->tva_tx; // Vat ref supplier $result=$obj->fk_product; return $result; From 44ecd504bc718d6aa716c4b3fdc983517afce252 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 May 2014 04:12:08 +0200 Subject: [PATCH 17/20] Fix: Field ref_supplier and label not filled. Just add FIXME because fix is too heavy for a maintenance release. --- htdocs/fourn/class/fournisseur.facture.class.php | 10 ++++++---- htdocs/fourn/facture/fiche.php | 13 ++++++------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index d8a1a1d824e..63cf162e7e2 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -444,10 +444,10 @@ class FactureFournisseur extends CommonInvoice $this->lines[$i]->rowid = $obj->rowid; $this->lines[$i]->description = $obj->description; $this->lines[$i]->product_ref = $obj->product_ref; // Internal reference - $this->lines[$i]->ref = $obj->product_ref; // TODO deprecated. Replace with next line - //$this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref into ref_supplier into table llx_facture_fourn_det and update it into updateline - $this->lines[$i]->libelle = $obj->label; // deprecated - $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit + $this->lines[$i]->ref = $obj->product_ref; // deprecated. + $this->lines[$i]->ref_supplier = $obj->ref_supplier; // Reference product supplier TODO Rename field ref to ref_supplier into table llx_facture_fourn_det and llx_commande_fournisseurdet and update fields it into updateline + $this->lines[$i]->libelle = $obj->label; // This field may contains label of product (when invoice create from order) + $this->lines[$i]->product_desc = $obj->product_desc; // Description du produit $this->lines[$i]->pu_ht = $obj->pu_ht; $this->lines[$i]->pu_ttc = $obj->pu_ttc; $this->lines[$i]->tva_tx = $obj->tva_tx; @@ -1034,6 +1034,8 @@ class FactureFournisseur extends CommonInvoice * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,idprod) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue). * + * FIXME Add field ref (that should be named ref_supplier) and label into update. For example can be filled when product line created from order. + * * @param string $desc Description de la ligne * @param double $pu Prix unitaire (HT ou TTC selon price_base_type, > 0 even for credit note) * @param double $txtva Taux de tva force, sinon -1 diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 0f15ff42885..402be19f17a 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -373,6 +373,7 @@ elseif ($action == 'add' && $user->rights->fournisseur->facture->creer) if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel; if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end; + // FIXME Missing $lines[$i]->ref_supplier and $lines[$i]->label into addline and updateline methods. They are filled when coming from order for example. $result = $object->addline( $desc, $lines[$i]->subprice, @@ -632,19 +633,17 @@ elseif ($action == 'addline' && $user->rights->fournisseur->facture->creer) { $ht = price2num($_POST['amount']); $price_base_type = 'HT'; - - //print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0 - $result=$object->addline($product_desc, $ht, $tauxtva, $localtax1tx, $localtax2tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type); } else - { + { $ttc = price2num($_POST['amountttc']); $ht = $ttc / (1 + ($tauxtva / 100)); $price_base_type = 'HT'; - //print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0 - $result=$object->addline($product_desc, $ht, $tauxtva,$localtax1tx, $localtax2tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type); } - } + //print $product_desc, $pu, $txtva, $qty, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits='', $price_base_type='HT', $type=0 + // FIXME Must add $productsupplier->ref_supplier and $productsupplier->label if there were loaded by get_buyprice previously. + $result=$object->addline($product_desc, $ht, $tauxtva, $localtax1tx, $localtax2tx, $qty, 0, $remise_percent, $datestart, $dateend, 0, $npr, $price_base_type, $type); + } } //print "xx".$tva_tx; exit; From 4076a4a64303f6cce9c511e62a060de37e7454ee Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 25 May 2014 14:51:56 +0200 Subject: [PATCH 18/20] Fix: select_date accepts -1, '' or a date but not '0' --- htdocs/commande/fiche.php | 6 +++--- htdocs/commande/orderstoinvoice.php | 2 +- htdocs/compta/facture.php | 4 ++-- htdocs/compta/paiement.php | 2 +- htdocs/fourn/facture/fiche.php | 6 +++--- htdocs/fourn/facture/paiement.php | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/htdocs/commande/fiche.php b/htdocs/commande/fiche.php index 43fe619bd1a..c1a6d38a58a 100644 --- a/htdocs/commande/fiche.php +++ b/htdocs/commande/fiche.php @@ -1548,7 +1548,7 @@ if ($action == 'create' && $user->rights->commande->creer) $demand_reason_id = (!empty($objectsrc->demand_reason_id)?$objectsrc->demand_reason_id:(!empty($soc->demand_reason_id)?$soc->demand_reason_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $datedelivery = (!empty($objectsrc->date_livraison)?$objectsrc->date_livraison:''); @@ -1567,7 +1567,7 @@ if ($action == 'create' && $user->rights->commande->creer) $demand_reason_id = $soc->demand_reason_id; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $projectid = 0; } $absolute_discount=$soc->getAvailableDiscounts(); @@ -1643,7 +1643,7 @@ if ($action == 'create' && $user->rights->commande->creer) if (empty($datedelivery)) { if (! empty($conf->global->DATE_LIVRAISON_WEEK_DELAY)) $datedelivery = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + else $datedelivery=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; } $form->select_date($datedelivery,'liv_','','','',"crea_commande",1,1); print ""; diff --git a/htdocs/commande/orderstoinvoice.php b/htdocs/commande/orderstoinvoice.php index 7b79a16bec1..5ea4e5b72cb 100644 --- a/htdocs/commande/orderstoinvoice.php +++ b/htdocs/commande/orderstoinvoice.php @@ -373,7 +373,7 @@ if ($action == 'create' && empty($mesgs)) $remise_percent = $soc->remise_percent; } $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $absolute_discount=$soc->getAvailableDiscounts(); print '
'; diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 29f4e61c7c7..d685f9ad1ed 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2082,7 +2082,7 @@ if ($action == 'create') $mode_reglement_id = (! empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(! empty($soc->mode_reglement_id)?$soc->mode_reglement_id:0)); $remise_percent = (! empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(! empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (! empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(! empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; //Replicate extrafields $objectsrc->fetch_optionals($originid); @@ -2095,7 +2095,7 @@ if ($action == 'create') $mode_reglement_id = $soc->mode_reglement_id; $remise_percent = $soc->remise_percent; $remise_absolue = 0; - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; } $absolute_discount=$soc->getAvailableDiscounts(); diff --git a/htdocs/compta/paiement.php b/htdocs/compta/paiement.php index 3b9d257314e..7a149ed80fd 100644 --- a/htdocs/compta/paiement.php +++ b/htdocs/compta/paiement.php @@ -397,7 +397,7 @@ if ($action == 'create' || $action == 'confirm_paiement' || $action == 'add_paie // Date payment print ''.$langs->trans('Date').''; $datepayment = dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0) : $datepayment); + $datepayment= ($datepayment == '' ? (empty($conf->global->MAIN_AUTOFILL_DATE)?-1:'') : $datepayment); $form->select_date($datepayment,'','','',0,"add_paiement",1,1); print ''; print ''.$langs->trans('Comments').''; diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php index 402be19f17a..966ab630ade 100644 --- a/htdocs/fourn/facture/fiche.php +++ b/htdocs/fourn/facture/fiche.php @@ -1122,10 +1122,10 @@ if ($action == 'create') $mode_reglement_id = (!empty($objectsrc->mode_reglement_id)?$objectsrc->mode_reglement_id:(!empty($soc->mode_reglement_supplier_id)?$soc->mode_reglement_supplier_id:0)); $remise_percent = (!empty($objectsrc->remise_percent)?$objectsrc->remise_percent:(!empty($soc->remise_percent)?$soc->remise_percent:0)); $remise_absolue = (!empty($objectsrc->remise_absolue)?$objectsrc->remise_absolue:(!empty($soc->remise_absolue)?$soc->remise_absolue:0)); - $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=($datetmp==''?-1:$datetmp); } @@ -1135,7 +1135,7 @@ if ($action == 'create') $cond_reglement_id = $societe->cond_reglement_supplier_id; $mode_reglement_id = $societe->mode_reglement_supplier_id; $datetmp=dol_mktime(12,0,0,$_POST['remonth'],$_POST['reday'],$_POST['reyear']); - $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datetmp); + $dateinvoice=($datetmp==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datetmp); $datetmp=dol_mktime(12,0,0,$_POST['echmonth'],$_POST['echday'],$_POST['echyear']); $datedue=($datetmp==''?-1:$datetmp); } diff --git a/htdocs/fourn/facture/paiement.php b/htdocs/fourn/facture/paiement.php index 352c3150c52..6f8c3bc1920 100644 --- a/htdocs/fourn/facture/paiement.php +++ b/htdocs/fourn/facture/paiement.php @@ -191,7 +191,7 @@ if ($action == 'create' || $action == 'add_paiement') $object->fetch($facid); $datefacture=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0):$datefacture); + $dateinvoice=($datefacture==''?(empty($conf->global->MAIN_AUTOFILL_DATE)?-1:''):$datefacture); $sql = 'SELECT s.nom, s.rowid as socid,'; $sql.= ' f.rowid, f.ref, f.ref_supplier, f.amount, f.total_ttc as total'; From 5d9ec6807c453ec99cb7bf8eb1fe68f349edc58a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 May 2014 01:14:15 +0200 Subject: [PATCH 19/20] Fix: Show duration only if defined. --- htdocs/product/liste.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/product/liste.php b/htdocs/product/liste.php index 501e0c60794..923b19e3daa 100644 --- a/htdocs/product/liste.php +++ b/htdocs/product/liste.php @@ -437,11 +437,15 @@ else if (! empty($conf->service->enabled) && $type != 0) { print ''; - if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); - elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); - elseif (preg_match('/([0-9]+)w/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); - elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); - else print $objp->duration; + if (preg_match('/([0-9]+)[a-z]/i',$objp->duration)) + { + if (preg_match('/([0-9]+)y/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationYear"); + elseif (preg_match('/([0-9]+)m/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationMonth"); + elseif (preg_match('/([0-9]+)w/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationWeek"); + elseif (preg_match('/([0-9]+)d/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationDay"); + //elseif (preg_match('/([0-9]+)h/i',$objp->duration,$regs)) print $regs[1].' '.$langs->trans("DurationHour"); + else print $objp->duration; + } print ''; } From d41f87acabd4eb227a3e65642ef6e7b1d6db167f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 May 2014 01:27:22 +0200 Subject: [PATCH 20/20] Fix: Option to limit was not used everywhere. --- htdocs/projet/tasks/index.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/projet/tasks/index.php b/htdocs/projet/tasks/index.php index cf4d996487b..5483c41e411 100644 --- a/htdocs/projet/tasks/index.php +++ b/htdocs/projet/tasks/index.php @@ -119,7 +119,7 @@ print ''; print ''; print "\n"; -if (count($tasksarray) > 1000) +if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)) { print ''; print '';