From ce247432eec3324ae2eb72cc07bdd4f0bcc0150f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Feb 2015 08:05:23 +0100 Subject: [PATCH 01/18] FIXED: Remove condition to show accountancy field on user. --- htdocs/user/card.php | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 429bcc91130..67407bd6d39 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -1319,12 +1319,9 @@ else print "\n"; // Accountancy code - if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared. - { - $rowspan++; - print ''.$langs->trans("AccountancyCode").''; - print ''.$object->accountancy_code.''; - } + $rowspan++; + print ''.$langs->trans("AccountancyCode").''; + print ''.$object->accountancy_code.''; // Color user if (! empty($conf->agenda->enabled)) From 4bb524d55d75af966bf7462e9132c223722d8326 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Feb 2015 08:12:40 +0100 Subject: [PATCH 02/18] Also for edit user. --- htdocs/user/card.php | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index 67407bd6d39..fde96bcc21c 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -2018,23 +2018,20 @@ else print "\n"; // Accountancy code - if (! empty($conf->global->USER_ENABLE_ACCOUNTANCY_CODE)) // For the moment field is not used so must not appeared. - { - print ""; - print ''.$langs->trans("AccountancyCode").''; - print ''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->accountancy_code; - } - print ''; - print ""; - } + print ""; + print ''.$langs->trans("AccountancyCode").''; + print ''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->accountancy_code; + } + print ''; + print ""; // User color if (! empty($conf->agenda->enabled)) From 067af47955e92d257dc3fda13d2a5278d41c6557 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Sun, 22 Feb 2015 08:35:25 +0100 Subject: [PATCH 03/18] Add accountancy field on creation mode and correct rowspan. --- htdocs/user/card.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index fde96bcc21c..b8e70dcd12f 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -8,7 +8,7 @@ * Copyright (C) 2011 Herve Prot * Copyright (C) 2012 Juanjo Menent * Copyright (C) 2013 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * * 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 @@ -980,6 +980,12 @@ if (($action == 'create') || ($action == 'adduserldap')) print ''; print ''; print "\n"; + + // Accountancy code + print ''.$langs->trans("AccountancyCode").''; + print ''; + print ''; + print ''; // User color if (! empty($conf->agenda->enabled)) @@ -1123,7 +1129,7 @@ else */ if ($action != 'edit') { - $rowspan=17; + $rowspan=19; print ''; @@ -1319,7 +1325,6 @@ else print "\n"; // Accountancy code - $rowspan++; print ''; print ''; @@ -1651,7 +1656,7 @@ else */ if ($action == 'edit' && ($canedituser || $caneditfield || $caneditpassword || ($user->id == $object->id))) { - $rowspan=15; + $rowspan=16; if (isset($conf->file->main_authentication) && preg_match('/openid/',$conf->file->main_authentication) && ! empty($conf->global->MAIN_OPENIDURL_PERUSER)) $rowspan++; if (! empty($conf->societe->enabled)) $rowspan++; if (! empty($conf->adherent->enabled)) $rowspan++; From 47c41f6a85b4e43cbf208ebef74a51e42b5a0ff8 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 26 Feb 2015 20:47:06 +0100 Subject: [PATCH 04/18] Add a test to enable field only when module salary is used --- htdocs/user/card.php | 51 ++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 21 deletions(-) diff --git a/htdocs/user/card.php b/htdocs/user/card.php index b8e70dcd12f..cf10d93fe4e 100644 --- a/htdocs/user/card.php +++ b/htdocs/user/card.php @@ -982,10 +982,13 @@ if (($action == 'create') || ($action == 'adduserldap')) print "\n"; // Accountancy code - print ''; - print ''; + if ($conf->salaries->enabled) + { + print ''; + print ''; + } // User color if (! empty($conf->agenda->enabled)) @@ -1325,9 +1328,12 @@ else print "\n"; // Accountancy code - print ''; - print ''; - + if ($conf->salaries->enabled) + { + print ''; + print ''; + } + // Color user if (! empty($conf->agenda->enabled)) { @@ -2023,20 +2029,23 @@ else print "\n"; // Accountancy code - print ""; - print ''; - print ''; - print ""; + if ($conf->salaries->enabled) + { + print ""; + print ''; + print ''; + print ""; + } // User color if (! empty($conf->agenda->enabled)) From a421564b8453b5b5fa6e80b247943bf179aa53b6 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 1 Mar 2015 13:52:58 +0100 Subject: [PATCH 05/18] Fix phpcs --- .../prelevement/class/bonprelevement.class.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index b90b0dc6c25..25236ee3ebb 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -891,13 +891,13 @@ class BonPrelevement extends CommonObject if (!$error) { $ref = substr($year,-2).$month; - + $sql = "SELECT substring(ref from char_length(ref) - 1)"; $sql.= " FROM ".MAIN_DB_PREFIX."prelevement_bons"; $sql.= " WHERE ref LIKE '%".$ref."%'"; $sql.= " AND entity = ".$conf->entity; $sql.= " ORDER BY ref DESC LIMIT 1"; - + dol_syslog(get_class($this)."::Create sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); @@ -914,7 +914,7 @@ class BonPrelevement extends CommonObject $ref = "T".$ref.str_pad(dol_substr("00".intval($row[0])+1),2,"0",STR_PAD_LEFT); $filebonprev = $ref; - + // Create withdraw receipt in database $sql = "INSERT INTO ".MAIN_DB_PREFIX."prelevement_bons ("; $sql.= " ref, entity, datec"; @@ -1326,7 +1326,7 @@ class BonPrelevement extends CommonObject $dateTime_ECMA = dol_print_date($date_actu, '%Y-%m-%dT%H:%M:%S'); $fileDebiteurSection = ''; $fileEmetteurSection = ''; - $i = 0; + $i = 0; $j = 0; $this->total = 0; @@ -1337,7 +1337,7 @@ class BonPrelevement extends CommonObject $sql = "SELECT f.facnumber as fac FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."prelevement_facture as pf, ".MAIN_DB_PREFIX."societe as soc, ".MAIN_DB_PREFIX."c_pays as p, ".MAIN_DB_PREFIX."societe_rib as rib WHERE pl.fk_prelevement_bons = ".$this->id." AND pl.rowid = pf.fk_prelevement_lignes AND pf.fk_facture = f.rowid AND soc.fk_pays = p.rowid AND soc.rowid = f.fk_soc AND rib.fk_soc = f.fk_soc AND rib.default_rib = 1"; $resql=$this->db->query($sql); if ($resql) - { + { $num = $this->db->num_rows($resql); while ($j < $num) { @@ -1372,7 +1372,7 @@ class BonPrelevement extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures , $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); $this->total = $this->total + $obj->somme; $i++; } From 787623882312d836daa11a499bc9b8efbaf44151 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 2 Mar 2015 01:36:27 +0100 Subject: [PATCH 06/18] Fixed bug with hide/show checkboxes reported by Ruben Almeida (aruben) When an external calendar was called "mytasks", Dolibarr events were also hidden too. --- htdocs/comm/action/index.php | 2 +- htdocs/core/lib/agenda.lib.php | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 38e8ab24bb1..82e6818a250 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1038,7 +1038,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $numicals[dol_string_nospecial($event->icalname)]++; } $color=$event->icalcolor; - $cssclass=(! empty($event->icalname)?'family_'.dol_string_nospecial($event->icalname):'family_other'); + $cssclass=(! empty($event->icalname)?'family_ext'.dol_string_nospecial($event->icalname):'family_other'); } else if ($event->type_code == 'BIRTHDAY') { $numbirthday++; $colorindex=2; $cssclass='family_birthday'; } else { $numother++; $cssclass='family_other'; } diff --git a/htdocs/core/lib/agenda.lib.php b/htdocs/core/lib/agenda.lib.php index 5bd0bc5ee95..219b69015a0 100644 --- a/htdocs/core/lib/agenda.lib.php +++ b/htdocs/core/lib/agenda.lib.php @@ -130,7 +130,6 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh print ''; foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); + $htmlname = md5($val['name']); print 'service->enabled) && $dateSelector && GETPOST('type') != '0') +if ((! empty($conf->service->enabled) || ($object->element == 'contrat')) && $dateSelector && GETPOST('type') != '0') // We show date field if required { if(! empty($conf->global->MAIN_VIEW_LINE_NUMBER)) $colspan = 10; else $colspan = 9; @@ -493,6 +486,11 @@ jQuery(document).ready(function() { if (jQuery('#idprod').val() > 0) jQuery('#dp_desc').focus(); if (jQuery('#idprodfournprice').val() > 0) jQuery('#dp_desc').focus(); }); + + + setforpredef(); + + }); /* Function to set fields from choice */ diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index 7750250b00b..eefd5c961e2 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -251,7 +251,7 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $idprod=0; $productsupplier = new ProductFournisseur($db); - if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-2; // Same behaviour than with combolist. When not select idprodfournprice is now -2 (to avoid conflict with next action that may return -1) + if (GETPOST('idprodfournprice') == -1 || GETPOST('idprodfournprice') == '') $idprod=-99; // Same behaviour than with combolist. When not select idprodfournprice is now -99 (to avoid conflict with next action that may return -1, -2, ...) if (GETPOST('idprodfournprice') > 0) { @@ -294,12 +294,12 @@ if ($action == 'addline' && $user->rights->fournisseur->commande->creer) $date_end ); } - if ($idprod == -2 || $idprod == 0) + if ($idprod == 0 || $idprod == -99) { // Product not selected $error++; $langs->load("errors"); - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")), 'errors'); + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ProductOrService")).' '.$langs->trans("or").' '.$langs->trans("NoPriceDefinedForThisSupplier"), 'errors'); } if ($idprod == -1) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 653925701ad..ac3d8e967a2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -1229,14 +1229,14 @@ class Product extends CommonObject } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -3; } } } else { - $this->error=$this->db->error(); + $this->error=$this->db->lasterror(); return -2; } }
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'.$langs->trans("AccountancyCode").''; - print ''; - print '
'.$langs->trans("AccountancyCode").''; + print ''; + print '
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'.$langs->trans("AccountancyCode").''.$object->accountancy_code.'
'.$langs->trans("AccountancyCode").''; - if ($caneditfield) - { - print ''; - } - else - { - print ''; - print $object->accountancy_code; - } - print '
'.$langs->trans("AccountancyCode").''; + if ($caneditfield) + { + print ''; + } + else + { + print ''; + print $object->accountancy_code; + } + print '
'; print ''; print ' ' . $langs->trans("LocalAgenda") . '
'; print ' ' . $val ['name']; From 1a02f6aa806b811129edb58f2e5d10cad0f5590b Mon Sep 17 00:00:00 2001 From: fmarcet Date: Wed, 4 Mar 2015 18:18:55 +0100 Subject: [PATCH 13/18] Fix: Masks works with thirdparty type --- htdocs/contrat/card.php | 2 +- htdocs/core/modules/commande/mod_commande_saphir.php | 2 +- htdocs/core/modules/contract/mod_contract_magre.php | 2 +- htdocs/core/modules/fichinter/mod_arctic.php | 2 +- htdocs/core/modules/livraison/mod_livraison_saphir.php | 2 +- htdocs/core/modules/propale/mod_propale_saphir.php | 2 +- .../modules/supplier_invoice/mod_facture_fournisseur_tulip.php | 2 +- .../supplier_order/mod_commande_fournisseur_orchidee.php | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/htdocs/contrat/card.php b/htdocs/contrat/card.php index 6d10442caf7..edb20d91d35 100644 --- a/htdocs/contrat/card.php +++ b/htdocs/contrat/card.php @@ -1097,7 +1097,7 @@ else $ref = substr($object->ref, 1, 4); if ($ref == 'PROV' && !empty($modCodeContract->code_auto)) { - $numref = $object->getNextNumRef($soc); + $numref = $object->getNextNumRef($object->thirdparty); } else { diff --git a/htdocs/core/modules/commande/mod_commande_saphir.php b/htdocs/core/modules/commande/mod_commande_saphir.php index 87ba0d57c98..1996717e506 100644 --- a/htdocs/core/modules/commande/mod_commande_saphir.php +++ b/htdocs/core/modules/commande/mod_commande_saphir.php @@ -121,7 +121,7 @@ class mod_commande_saphir extends ModeleNumRefCommandes return 0; } - $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc->code_client,$object->date); + $numFinal=get_next_value($db,$mask,'commande','ref','',$objsoc,$object->date); return $numFinal; } diff --git a/htdocs/core/modules/contract/mod_contract_magre.php b/htdocs/core/modules/contract/mod_contract_magre.php index 289b474de5e..54da8fc55c4 100644 --- a/htdocs/core/modules/contract/mod_contract_magre.php +++ b/htdocs/core/modules/contract/mod_contract_magre.php @@ -112,7 +112,7 @@ class mod_contract_magre extends ModelNumRefContracts return 0; } - $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc->code_client,$contract->date_contrat); + $numFinal=get_next_value($db,$mask,'contrat','ref','',$objsoc,$contract->date_contrat); return $numFinal; } diff --git a/htdocs/core/modules/fichinter/mod_arctic.php b/htdocs/core/modules/fichinter/mod_arctic.php index ab06d1417e6..278e20ae7de 100644 --- a/htdocs/core/modules/fichinter/mod_arctic.php +++ b/htdocs/core/modules/fichinter/mod_arctic.php @@ -120,7 +120,7 @@ class mod_arctic extends ModeleNumRefFicheinter return 0; } - $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc->code_client,$object->datec); + $numFinal=get_next_value($db,$mask,'fichinter','ref','',$objsoc,$object->datec); return $numFinal; } diff --git a/htdocs/core/modules/livraison/mod_livraison_saphir.php b/htdocs/core/modules/livraison/mod_livraison_saphir.php index 5f8a6b93686..1192656bf8d 100644 --- a/htdocs/core/modules/livraison/mod_livraison_saphir.php +++ b/htdocs/core/modules/livraison/mod_livraison_saphir.php @@ -120,7 +120,7 @@ class mod_livraison_saphir extends ModeleNumRefDeliveryOrder return 0; } - $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc->code_client,$object->date_livraison); + $numFinal=get_next_value($db,$mask,'livraison','ref','',$objsoc,$object->date_livraison); return $numFinal; } diff --git a/htdocs/core/modules/propale/mod_propale_saphir.php b/htdocs/core/modules/propale/mod_propale_saphir.php index 503d8754684..25ccecb253c 100644 --- a/htdocs/core/modules/propale/mod_propale_saphir.php +++ b/htdocs/core/modules/propale/mod_propale_saphir.php @@ -123,7 +123,7 @@ class mod_propale_saphir extends ModeleNumRefPropales $date=$propal->datep; $customercode=$objsoc->code_client; - $numFinal=get_next_value($db,$mask,'propal','ref','',$customercode,$date); + $numFinal=get_next_value($db,$mask,'propal','ref','',$objsoc,$date); return $numFinal; } diff --git a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php index 15bef66bf8f..ba31d979864 100644 --- a/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php +++ b/htdocs/core/modules/supplier_invoice/mod_facture_fournisseur_tulip.php @@ -126,7 +126,7 @@ class mod_facture_fournisseur_tulip extends ModeleNumRefSuppliersInvoices } //Supplier invoices take invoice date instead of creation date for the mask - $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc->code_fournisseur,$object->date); + $numFinal=get_next_value($db,$mask,'facture_fourn','ref','',$objsoc,$object->date); return $numFinal; } diff --git a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php index 7f74ce095c0..37b8adab22e 100644 --- a/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php +++ b/htdocs/core/modules/supplier_order/mod_commande_fournisseur_orchidee.php @@ -121,7 +121,7 @@ class mod_commande_fournisseur_orchidee extends ModeleNumRefSuppliersOrders return 0; } - $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc->code_fournisseur,$object->date_commande); + $numFinal=get_next_value($db,$mask,'commande_fournisseur','ref','',$objsoc,$object->date_commande); return $numFinal; } From dc15eee533b85c5856d9508ad6ffb7f13c348198 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 11:21:58 +0100 Subject: [PATCH 14/18] Fix: missing dependcy on project to check before deleting --- htdocs/societe/class/societe.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 510e184e521..a18aedfcc1b 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2004 Eric Seigne * Copyright (C) 2003 Brian Fraval * Copyright (C) 2006 Andre Cianfarani @@ -42,7 +42,7 @@ class Societe extends CommonObject public $element='societe'; public $table_element = 'societe'; public $fk_element='fk_soc'; - protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur"); // To test if we can delete object + protected $childtables=array("propal","commande","facture","contrat","facture_fourn","commande_fournisseur","projet"); // To test if we can delete object /** * 0=No test on entity, 1=Test with field entity, 2=Test with link by societe From 9c12c325dbf60a450c6b23b8f57424f3999a2b57 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 11:46:03 +0100 Subject: [PATCH 15/18] Fix regression into enable/disable external calendars --- htdocs/comm/action/index.php | 9 ++++----- htdocs/comm/action/peruser.php | 8 ++++---- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 1565bf79cac..f2e945cf83d 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -363,17 +363,16 @@ if (! empty($conf->use_javascript_ajax)) { foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); - $htmlname = dol_string_nospecial($htmlname,'_',array("\.","#")); + $htmlname = md5($val['name']); $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s.='
' . $val ['name'] . '  
'; } } $s.='
'.$langs->trans("AgendaShowBirthdayEvents").'  
'; diff --git a/htdocs/comm/action/peruser.php b/htdocs/comm/action/peruser.php index 599bc32ceba..0f281a91af4 100644 --- a/htdocs/comm/action/peruser.php +++ b/htdocs/comm/action/peruser.php @@ -305,16 +305,16 @@ if ($conf->use_javascript_ajax) { foreach ($showextcals as $val) { - $htmlname = dol_string_nospecial($val['name']); + $htmlname = md5($val['name']); $s.='' . "\n"; - $s.='
' . $val ['name'] . '  
'; + $s.='
' . $val ['name'] . '  
'; } } } From 22045603b744134fa4c75066b97ff1adca623d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 5 Mar 2015 13:51:29 +0100 Subject: [PATCH 16/18] Fix bad update of denormalized field --- htdocs/projet/class/task.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/projet/class/task.class.php b/htdocs/projet/class/task.class.php index 017e2b782ec..b01a9644cb1 100644 --- a/htdocs/projet/class/task.class.php +++ b/htdocs/projet/class/task.class.php @@ -807,7 +807,7 @@ class Task extends CommonObject if ($ret >= 0) { $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".price2num($this->timespent_duration)."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; if (isset($this->progress)) $sql.= ", progress = " . $this->progress; // Do not overwrite value if not provided $sql.= " WHERE rowid = ".$this->id; @@ -980,7 +980,7 @@ class Task extends CommonObject $newDuration = $this->timespent_duration - $this->timespent_old_duration; $sql = "UPDATE ".MAIN_DB_PREFIX."projet_task"; - $sql.= " SET duration_effective = duration_effective + '".$newDuration."'"; + $sql.= " SET duration_effective = (SELECT SUM(task_duration) FROM ".MAIN_DB_PREFIX."projet_task_time as ptt where ptt.fk_task = ".$this->id.")"; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::updateTimeSpent", LOG_DEBUG); From 77dd07c846e335869800b6e1e0f01ed6c7086e3c Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 13:12:33 +0100 Subject: [PATCH 17/18] Fix thumbs generation --- htdocs/categories/class/categorie.class.php | 16 +++++++++----- htdocs/product/class/product.class.php | 24 +++++++++++++-------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index f5828ecdea7..b9876bb8382 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -1330,17 +1330,23 @@ class Categorie extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... if (file_exists($file)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index e26f9102544..653925701ad 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3100,11 +3100,9 @@ class Product extends CommonObject * * @param string $sdir Target directory * @param string $file Array of file info of file to upload: array('name'=>..., 'tmp_name'=>...) - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 by defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 by defaut) * @return int <0 if KO, >0 if OK */ - function add_photo($sdir, $file, $maxWidth = 160, $maxHeight = 120) + function add_photo($sdir, $file) { global $conf; @@ -3114,10 +3112,12 @@ class Product extends CommonObject $dir = $sdir; if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $dir .= '/'. get_exdir($this->id,2) . $this->id ."/photos"; + else $dir .= '/'.dol_sanitizeFileName($this->ref); dol_mkdir($dir); $dir_osencoded=$dir; + if (is_dir($dir_osencoded)) { $originImage = $dir . '/' . $file['name']; @@ -3128,7 +3128,7 @@ class Product extends CommonObject if (file_exists(dol_osencode($originImage))) { // Cree fichier en taille vignette - $this->add_thumb($originImage,$maxWidth,$maxHeight); + $this->add_thumb($originImage); } } @@ -3140,18 +3140,24 @@ class Product extends CommonObject * Build thumb * * @param string $file Chemin du fichier d'origine - * @param int $maxWidth Largeur maximum que dois faire la miniature (160 par defaut) - * @param int $maxHeight Hauteur maximum que dois faire la miniature (120 par defaut) * @return void */ - function add_thumb($file, $maxWidth = 160, $maxHeight = 120) + function add_thumb($file) { - require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; + global $maxwidthsmall, $maxheightsmall, $maxwidthmini, $maxheightmini, $quality; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/images.lib.php'; // This define also $maxwidthsmall, $quality, ... $file_osencoded=dol_osencode($file); if (file_exists($file_osencoded)) { - vignette($file,$maxWidth,$maxHeight); + // Create small thumbs for company (Ratio is near 16/9) + // Used on logon for example + $imgThumbSmall = vignette($file, $maxwidthsmall, $maxheightsmall, '_small', $quality); + + // Create mini thumbs for company (Ratio is near 16/9) + // Used on menu or for setup page for example + $imgThumbMini = vignette($file, $maxwidthmini, $maxheightmini, '_mini', $quality); } } From a169b3348ee2d5249baccc0fadc8adeffd747c75 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 6 Mar 2015 14:36:22 +0100 Subject: [PATCH 18/18] Fix show alays date fields for contract module. Fix select of product were lost. --- htdocs/commande/card.php | 32 +++++++++++------------ htdocs/core/tpl/objectline_create.tpl.php | 22 +++++++--------- htdocs/fourn/commande/card.php | 6 ++--- htdocs/product/class/product.class.php | 4 +-- 4 files changed, 31 insertions(+), 33 deletions(-) diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index 12150f9a61e..27c333eec21 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -207,13 +207,13 @@ if (empty($reshook)) if ($datecommande == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentities('Date')), 'errors'); $action = 'create'; - $error ++; + $error++; } if ($socid < 1) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Customer")), 'errors'); $action = 'create'; - $error ++; + $error++; } if (! $error) { @@ -334,7 +334,7 @@ if (empty($reshook)) $result = $object->addline($desc, $lines [$i]->subprice, $lines [$i]->qty, $lines [$i]->tva_tx, $lines [$i]->localtax1_tx, $lines [$i]->localtax2_tx, $lines [$i]->fk_product, $lines [$i]->remise_percent, $lines [$i]->info_bits, $lines [$i]->fk_remise_except, 'HT', 0, $date_start, $date_end, $product_type, $lines [$i]->rang, $lines [$i]->special_code, $fk_parent_line, $lines [$i]->fk_fournprice, $lines [$i]->pa_ht, $label, $array_option); if ($result < 0) { - $error ++; + $error++; break; } @@ -349,14 +349,14 @@ if (empty($reshook)) $reshook = $hookmanager->executeHooks('createFrom', $parameters, $object, $action); // Note that $action and $object may have been // modified by hook if ($reshook < 0) - $error ++; + $error++; } else { setEventMessage($srcobject->error, 'errors'); - $error ++; + $error++; } } else { setEventMessage($object->error, 'errors'); - $error ++; + $error++; } } else { // Required extrafield left blank, error message already defined by setOptionalsFromPost() @@ -390,7 +390,7 @@ if (empty($reshook)) $result = $object->add_contact(GETPOST('contactid'), 'CUSTOMER', 'external'); if ($result < 0) { setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - $error ++; + $error++; } } @@ -554,24 +554,24 @@ if (empty($reshook)) if (empty($idprod) && ($price_ht < 0) && ($qty < 0)) { setEventMessage($langs->trans('ErrorBothFieldCantBeNegative', $langs->transnoentitiesnoconv('UnitPriceHT'), $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && GETPOST('type') < 0) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Type')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && (! ($price_ht >= 0) || $price_ht == '')) // Unit price can be 0 but not '' { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error ++; + $error++; } if ($qty == '') { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Qty')), 'errors'); - $error ++; + $error++; } if (GETPOST('prod_entry_mode') == 'free' && empty($idprod) && empty($product_desc)) { setEventMessage($langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv('Description')), 'errors'); - $error ++; + $error++; } if (! $error && ($qty >= 0) && (! empty($product_desc) || ! empty($idprod))) { @@ -826,7 +826,7 @@ if (empty($reshook)) if ($price_min && (price2num($pu_ht) * (1 - price2num(GETPOST('remise_percent')) / 100) < price2num($price_min))) { setEventMessage($langs->trans("CantBeLessThanMinPrice", price(price2num($price_min, 'MU'), 0, $langs, 0, 0, - 1, $conf->currency)), 'errors'); - $error ++; + $error++; } } else { $type = GETPOST('type'); @@ -835,7 +835,7 @@ if (empty($reshook)) // Check parameters if (GETPOST('type') < 0) { setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Type")), 'errors'); - $error ++; + $error++; } } @@ -1137,10 +1137,10 @@ if (empty($reshook)) if (empty($reshook)) { $result = $object->insertExtraFields(); if ($result < 0) { - $error ++; + $error++; } } else if ($reshook < 0) - $error ++; + $error++; } if ($error) diff --git a/htdocs/core/tpl/objectline_create.tpl.php b/htdocs/core/tpl/objectline_create.tpl.php index 6037f6c77c9..e3f2431783f 100644 --- a/htdocs/core/tpl/objectline_create.tpl.php +++ b/htdocs/core/tpl/objectline_create.tpl.php @@ -153,12 +153,12 @@ else { if (empty($senderissupplier)) { - $form->select_produits('', 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); + $form->select_produits(GETPOST('idprod'), 'idprod', $filtertype, $conf->product->limit_size, $buyer->price_level, 1, 2, '', 1, array(),$buyer->id); } else { $ajaxoptions=array( - 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tag will be edited with which ajax json response key + 'update' => array('qty'=>'qty','remise_percent' => 'discount'), // html id tags that will be edited with which ajax json response key 'option_disabled' => 'addPredefinedProductButton', // html id to disable once select is done 'warning' => $langs->trans("NoPriceDefinedForThisSupplier") // translation of an error saved into var 'error' ); @@ -192,23 +192,16 @@ else {
tva_assuj == "0") echo '0'; - else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); - } + if ($seller->tva_assuj == "0") echo '0'; + else echo $form->load_tva('tva_tx', (isset($_POST["tva_tx"])?$_POST["tva_tx"]:-1), $seller, $buyer); ?> - "> - - "> - "> @@ -273,7 +266,7 @@ else {