From bfc476a118a40f4d05af7e6b5c5c1aa297c664ec Mon Sep 17 00:00:00 2001 From: Ferran Marcet Date: Thu, 7 Dec 2017 18:44:33 +0100 Subject: [PATCH 1/7] FIX #7379: Compatibility with PRODUCT_USE_OLD_PATH_FOR_PHOTO varieable --- htdocs/core/class/html.formfile.class.php | 6 +++--- htdocs/product/class/product.class.php | 4 ++-- htdocs/product/document.php | 5 +++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/htdocs/core/class/html.formfile.class.php b/htdocs/core/class/html.formfile.class.php index 824b13fd62f..a48ae7477fc 100644 --- a/htdocs/core/class/html.formfile.class.php +++ b/htdocs/core/class/html.formfile.class.php @@ -6,7 +6,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2014 Marcos García * Copyright (C) 2015 Bahfir Abbes - * Copyright (C) 2016 Ferran Marcet + * Copyright (C) 2016-2017 Ferran Marcet * 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 @@ -938,9 +938,9 @@ class FormFile if ($object->element == 'project_task') $relativepath='Call_not_supported_._Call_function_using_a_defined_relative_path_.'; } // For backward compatiblity, we detect file is stored into an old path - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $file['level1name'] == 'photos') + if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO) && $filearray[0]['level1name'] == 'photos') { - $relativepath=preg_replace('/^.*\/produit\//','',$file['path']).'/'; + $relativepath=preg_replace('/^.*\/produit\//','',$filearray[0]['path']).'/'; } // Defined relative dir to DOL_DATA_ROOT $relativedir = ''; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 05adfc1b5c5..2f8570d6883 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -3997,8 +3997,8 @@ class Product extends CommonObject if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) { - $dirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; - $pdirold .= get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; + $dir = $sdir . '/'. get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; + $pdir = '/' . get_exdir($this->id,2,0,0,$this,'product') . $this->id ."/photos/"; } // Defined relative dir to DOL_DATA_ROOT diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 53bbbfeeabb..814f708a99e 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -6,6 +6,7 @@ * Copyright (C) 2005 Simon TOSSER * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador + * Copyright (C) 2017 Ferran Marcet * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -75,8 +76,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; - else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + else $upload_dir = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } } $modulepart='produit'; From 95fa183fac33b7ea8432ae213534b70502e50702 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 08:49:03 +0100 Subject: [PATCH 2/7] Fix: Avoid warning "A non-numeric value encountered" --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 01787ca3372..a9810396e0c 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -53,7 +53,7 @@ $sortorder=GETPOST('sortorder', 'alpha'); $page=GETPOST('page', 'int'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="b.dateo,b.rowid"; -if ($page < 0) { $page = 0 ; } +if (empty($page) || $page == -1) { $page = 0; } $limit = GETPOST('limit')?GETPOST('limit','int'):$conf->liste_limit; $offset = $limit * $page ; From 8e1a9064cb053eebf4db0bacbc47d742c986f62f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:00:05 +0100 Subject: [PATCH 3/7] Fix: avoid warning again --- htdocs/compta/paiement/cheque/card.php | 87 +++++++++++++------------- 1 file changed, 44 insertions(+), 43 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index a9810396e0c..7029bd6ec72 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -490,53 +490,54 @@ if ($action == 'new') if (count($lines[$bid])) { - foreach ($lines[$bid] as $lid => $value) - { - $account_id = $bid; - if (! isset($accounts[$bid])) - $accounts[$bid]=0; - $accounts[$bid] += 1; + foreach ($lines[$bid] as $lid => $value) + { + $account_id = $bid; + if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + $accounts[$bid]=0; + } + $accounts[$bid] += 1; - print ''; - print ''.dol_print_date($value["date"],'day').''; - print ''.$value["numero"]."\n"; - print ''.$value["emetteur"]."\n"; - print ''.$value["banque"]."\n"; - print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; + print ''; + print ''.dol_print_date($value["date"],'day').''; + print ''.$value["numero"]."\n"; + print ''.$value["emetteur"]."\n"; + print ''.$value["banque"]."\n"; + print ''.price($value["amount"], 0, $langs, 1, -1, -1, $conf->currency).''; - // Link to payment - print ''; - $paymentstatic->id=$value["paymentid"]; - $paymentstatic->ref=$value["paymentid"]; - if ($paymentstatic->id) - { - print $paymentstatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; - // Link to bank transaction - print ''; - $accountlinestatic->rowid=$value["id"]; - if ($accountlinestatic->rowid) - { - print $accountlinestatic->getNomUrl(1); - } - else - { - print ' '; - } - print ''; + // Link to payment + print ''; + $paymentstatic->id=$value["paymentid"]; + $paymentstatic->ref=$value["paymentid"]; + if ($paymentstatic->id) + { + print $paymentstatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; + // Link to bank transaction + print ''; + $accountlinestatic->rowid=$value["id"]; + if ($accountlinestatic->rowid) + { + print $accountlinestatic->getNomUrl(1); + } + else + { + print ' '; + } + print ''; - print ''; - print ''; - print '' ; - print ''; + print ''; + print ''; + print '' ; + print ''; - $i++; - } + $i++; + } } print ""; print ''; From c4b2c3e6976f98f5f3700ebe3b886f26979e8a04 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:16:36 +0100 Subject: [PATCH 4/7] FIXME $accounts[$bid] is a label ! --- htdocs/compta/paiement/cheque/card.php | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index 7029bd6ec72..eb69a386719 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -492,11 +492,12 @@ if ($action == 'new') { foreach ($lines[$bid] as $lid => $value) { - $account_id = $bid; - if (! isset($accounts[$bid]) || $accounts[$bid] == '') { + //$account_id = $bid; FIXME not used + + // FIXME $accounts[$bid] is a label ! + /*if (! isset($accounts[$bid])) $accounts[$bid]=0; - } - $accounts[$bid] += 1; + $accounts[$bid] += 1;*/ print ''; print ''.dol_print_date($value["date"],'day').''; @@ -689,10 +690,12 @@ else { while ($objp = $db->fetch_object($resql)) { - $account_id = $objp->bid; - if (! isset($accounts[$objp->bid])) + //$account_id = $objp->bid; FIXME not used + + // FIXME $accounts[$objp->bid] is a label + /*if (! isset($accounts[$objp->bid])) $accounts[$objp->bid]=0; - $accounts[$objp->bid] += 1; + $accounts[$objp->bid] += 1;*/ print ''; print ''.$i.''; From 04327189f756d476157af50e684679c48507c04e Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 8 Dec 2017 09:41:33 +0100 Subject: [PATCH 5/7] Fix: access error when user not right to view all customers --- htdocs/compta/paiement/cheque/card.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/paiement/cheque/card.php b/htdocs/compta/paiement/cheque/card.php index eb69a386719..c684e041660 100644 --- a/htdocs/compta/paiement/cheque/card.php +++ b/htdocs/compta/paiement/cheque/card.php @@ -46,7 +46,7 @@ $confirm=GETPOST('confirm', 'alpha'); // Security check $fieldname = (! empty($ref)?'ref':'rowid'); if ($user->societe_id) $socid=$user->societe_id; -$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','',$fieldname); +$result = restrictedArea($user, 'cheque', $id, 'bordereau_cheque','','fk_user_author',$fieldname); $sortfield=GETPOST('sortfield', 'alpha'); $sortorder=GETPOST('sortorder', 'alpha'); From 08abb1490a3660fabd7dd632808a5ddd91b20359 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 12:54:08 +0100 Subject: [PATCH 6/7] Remove code using not defined var --- htdocs/product/class/product.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index 2f8570d6883..b533fad3ec2 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -4018,11 +4018,11 @@ class Product extends CommonObject $filearray=dol_dir_list($dir,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); - if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs + /*if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { $filearrayold=dol_dir_list($dirold,"files",0,'','(\.meta|_preview.*\.png)$',$sortfield,(strtolower($sortorder)=='desc'?SORT_DESC:SORT_ASC),1); $filearray=array_merge($filearray, $filearrayold); - } + }*/ $filearrayindatabase = dol_dir_list_in_database($relativedir, '', null, 'name', SORT_ASC); From 9b9b5adf660d47a07191d342e6066046acc3bfe9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 8 Dec 2017 13:01:45 +0100 Subject: [PATCH 7/7] Fix must be compatible with old and new storage location --- htdocs/product/document.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/product/document.php b/htdocs/product/document.php index 814f708a99e..a3ccbead70a 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -76,8 +76,8 @@ if ($id > 0 || ! empty($ref)) if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) // For backward compatiblity, we scan also old dirs { - if (! empty($conf->product->enabled)) $upload_dir = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; - else $upload_dir = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + if (! empty($conf->product->enabled)) $upload_dirold = $conf->product->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; + else $upload_dirold = $conf->service->multidir_output[$object->entity].'/'.substr(substr("000".$object->id, -2),1,1).'/'.substr(substr("000".$object->id, -2),0,1).'/'.$object->id."/photos"; } } $modulepart='produit';