From 7b542731a11e3e5bcf135a6c499281c217932780 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Mon, 3 Mar 2014 15:59:11 +0100 Subject: [PATCH 01/18] Made test pessimistic by default The test result was wrong if, for example, the path was wrong. The unlink() function being never called, it returned the default true value even if it didn't remove a file. --- htdocs/core/lib/files.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 0af5e917cc5..553d275c466 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -832,7 +832,7 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n $error=0; //print "x".$file." ".$disableglob;exit; - $ok=true; + $ok=false; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && ! empty($file_osencoded)) { From b91d1fa0cac09fa9192e6d7e2674eb3054909ad3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Tue, 25 Mar 2014 10:58:35 +0100 Subject: [PATCH 02/18] dol_delete_files(): removed unused variables --- htdocs/core/lib/files.lib.php | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 553d275c466..c45dbf96927 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -802,7 +802,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable */ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null) { - global $db, $conf, $user, $langs; + global $langs; global $hookmanager; $langs->load("other"); @@ -829,8 +829,6 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n } else { - $error=0; - //print "x".$file." ".$disableglob;exit; $ok=false; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset From 7d08c95fcc54fbcb2845ef860c2c9e34b4417ba8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Wed, 17 Sep 2014 15:59:34 +0200 Subject: [PATCH 03/18] Updated unit test to reflect dol_delete_file changes --- test/phpunit/FilesLibTest.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 4477784ae7d..409816d5f90 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -339,10 +339,9 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertTrue($result,'delete file'); - // Again to test no error when deleteing a non existing file $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); print __METHOD__." result=".$result."\n"; - $this->assertTrue($result,'delete file that does not exists'); + $this->assertFalse($result,'delete file that does not exists'); // Test copy with special char / delete with blob $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1); From e24a8b45052b2a92ea7ca3ab26f46a22aeed0a8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 20 May 2015 16:43:44 +0200 Subject: [PATCH 04/18] Closed bug #2843 Wrong SQL table called --- htdocs/categories/class/categorie.class.php | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 96949371bae..4ebf6126deb 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -472,7 +472,7 @@ class Categorie extends CommonObject * Link an object to the category * * @param Object $obj Object to link to category - * @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact') + * @param string $type Type of category ('societe', 'member', 'customer', 'supplier', 'product', 'contact') * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) @@ -488,9 +488,20 @@ class Categorie extends CommonObject if ($type == 'customer') $type='societe'; if ($type == 'supplier') $type='fournisseur'; - $column_name=$type; - if ($type=='contact') $column_name='socpeople'; - if ($type=='fournisseur') $column_name='societe'; + /** + * llx_categorie_contact => fk_socpeople + * llx_categorie_fournisseur, llx_categorie_societe => fk_soc + * llx_categorie_member => fk_member + * llx_categorie_product => fk_product + * llx_categories_extrafields => fk_object + */ + if ($type == 'contact') { + $column_name = 'socpeople'; + } elseif ($type == 'supplier' || ($type == 'societe')) { + $column_name = 'soc'; + } else { + $column_name = 'type'; + } $this->db->begin(); From 9ebae9520a72805b88aa91898d0081ccdc56b6b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Wed, 20 May 2015 16:46:12 +0200 Subject: [PATCH 05/18] Extrafields does not form part of this class --- htdocs/categories/class/categorie.class.php | 1 - 1 file changed, 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 4ebf6126deb..b5e46cc475a 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -493,7 +493,6 @@ class Categorie extends CommonObject * llx_categorie_fournisseur, llx_categorie_societe => fk_soc * llx_categorie_member => fk_member * llx_categorie_product => fk_product - * llx_categories_extrafields => fk_object */ if ($type == 'contact') { $column_name = 'socpeople'; From ba68598ec75814dfa57133f593a01f1558d08fd9 Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 23 May 2015 15:06:18 +0100 Subject: [PATCH 06/18] added new trigger for supplier invoice unvalidation in Agenda --- htdocs/core/modules/modAgenda.class.php | 2 ++ .../interface_50_modAgenda_ActionsAuto.class.php | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/htdocs/core/modules/modAgenda.class.php b/htdocs/core/modules/modAgenda.class.php index 73a8390c9e6..c6492ab5161 100644 --- a/htdocs/core/modules/modAgenda.class.php +++ b/htdocs/core/modules/modAgenda.class.php @@ -6,6 +6,7 @@ * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2009-2011 Regis Houssin * Copyright (C) 2013 Cedric Gross + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -90,6 +91,7 @@ class modAgenda extends DolibarrModules $this->const[12] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_VALIDATE","chaine","1"); $this->const[13] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_SENTBYMAIL","chaine","1"); $this->const[14] = array("MAIN_AGENDA_ACTIONAUTO_BILL_UNVALIDATE","chaine","1"); + $this->const[15] = array("MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_UNVALIDATE","chaine","1"); // New pages on tabs // ----------------- diff --git a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php index 46a6cd0daa6..8a77bf86b4f 100644 --- a/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php +++ b/htdocs/core/triggers/interface_50_modAgenda_ActionsAuto.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2011-2014 Juanjo Menent * Copyright (C) 2013 Cedric GROSS * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -493,6 +494,18 @@ class InterfaceActionsAuto extends DolibarrTriggers $object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref)); $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; + } + elseif ($action == 'BILL_SUPPLIER_UNVALIDATE') + { + $langs->load("other"); + $langs->load("bills"); + + $object->actiontypecode='AC_OTH_AUTO'; + if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); + $object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref); + $object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login; + $object->sendtoid=0; } elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL') From 4e48f245073e4e1bda18690d48dffb42ea0d8302 Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 23 May 2015 15:12:24 +0100 Subject: [PATCH 07/18] added new trigger for supplier invoice unvalidation "BILL_SUPPLIER_UNVALIDATE" in Database --- htdocs/install/mysql/data/llx_c_action_trigger.sql | 2 ++ htdocs/install/mysql/migration/3.7.0-3.8.0.sql | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/htdocs/install/mysql/data/llx_c_action_trigger.sql b/htdocs/install/mysql/data/llx_c_action_trigger.sql index 1dde6d5d37c..408c7a36ff6 100644 --- a/htdocs/install/mysql/data/llx_c_action_trigger.sql +++ b/htdocs/install/mysql/data/llx_c_action_trigger.sql @@ -8,6 +8,7 @@ -- Copyright (C) 2010-2013 Juanjo Menent -- Copyright (C) 2013 Cedric Gross -- Copyright (C) 2014 Raphaël Doursenaud +-- Copyright (C) 2015 Bahfir Abbes -- -- 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 @@ -74,3 +75,4 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',35); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',36); insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',37); +insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_UNVALIDATE', 'Supplier invoice unvalidated', 'Executed when a supplier invoice status is set back to draft', 'invoice_supplier',15); diff --git a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql index aabca14f5a1..c44fa88c49c 100755 --- a/htdocs/install/mysql/migration/3.7.0-3.8.0.sql +++ b/htdocs/install/mysql/migration/3.7.0-3.8.0.sql @@ -644,4 +644,5 @@ ALTER TABLE llx_actioncomm ADD COLUMN recurdateend datetime; ALTER TABLE llx_stcomm ADD COLUMN picto varchar(128); - +-- New trigger for Supplier invoice unvalidation +INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) VALUES ('BILL_SUPPLIER_UNVALIDATE','Supplier invoice unvalidated','Executed when a supplier invoice status is set back to draft','invoice_supplier',15); From 879c82ee0a736ec4f3686537e560f6f0b50726f9 Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 23 May 2015 15:27:12 +0100 Subject: [PATCH 08/18] added new trigger for supplier invoice unvalidation "BILL_SUPPLIER_UNVALIDATE" in trigger demo file --- htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN index 8da8c6e3e00..99a8a152384 100644 --- a/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN +++ b/htdocs/core/triggers/interface_90_all_Demo.class.php-NORUN @@ -2,6 +2,7 @@ /* Copyright (C) 2005-2014 Laurent Destailleur * Copyright (C) 2005-2014 Regis Houssin * Copyright (C) 2014 Marcos García + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -197,6 +198,7 @@ class InterfaceDemo extends DolibarrTriggers case 'BILL_SUPPLIER_PAYED': case 'BILL_SUPPLIER_UNPAYED': case 'BILL_SUPPLIER_VALIDATE': + case 'BILL_SUPPLIER_UNVALIDATE': case 'LINEBILL_SUPPLIER_CREATE': case 'LINEBILL_SUPPLIER_UPDATE': case 'LINEBILL_SUPPLIER_DELETE': From ebf2edf019057b73e7a816d1fdc64478f4749236 Mon Sep 17 00:00:00 2001 From: abb Date: Sat, 23 May 2015 15:35:19 +0100 Subject: [PATCH 09/18] added new trigger for supplier invoice unvalidation "BILL_SUPPLIER_UNVALIDATE" in set_draft class function --- htdocs/fourn/class/fournisseur.facture.class.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/htdocs/fourn/class/fournisseur.facture.class.php b/htdocs/fourn/class/fournisseur.facture.class.php index 994ddb28310..1cfbe941d9a 100644 --- a/htdocs/fourn/class/fournisseur.facture.class.php +++ b/htdocs/fourn/class/fournisseur.facture.class.php @@ -8,6 +8,7 @@ * Copyright (C) 2013 Philippe Grand * Copyright (C) 2013 Florian Henry * Copyright (C) 2014-2015 Marcos García + * Copyright (C) 2015 Bahfir Abbes * * 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 @@ -1073,7 +1074,14 @@ class FactureFournisseur extends CommonInvoice } } } - + // Triggers call + if (! $error && empty($notrigger)) + { + // Call trigger + $result=$this->call_trigger('BILL_SUPPLIER_VALIDATE',$user); + if ($result < 0) $error++; + // End call triggers + } if ($error == 0) { $this->db->commit(); From c018858e91b6cf28ac0e027602d030cdd5829445 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Doursenaud?= Date: Sat, 23 May 2015 20:43:01 +0200 Subject: [PATCH 10/18] Deprecation of the mysql driver Fix #2886 --- htdocs/core/db/mysql.class.php | 2 ++ htdocs/install/fileconf.php | 5 +++-- htdocs/langs/en_US/install.lang | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/htdocs/core/db/mysql.class.php b/htdocs/core/db/mysql.class.php index 30a7780afdf..bca6d0798b8 100644 --- a/htdocs/core/db/mysql.class.php +++ b/htdocs/core/db/mysql.class.php @@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php'; /** * Class to manage Dolibarr database access for a MySQL database using the mysql extension + * + * @deprecated Use DoliDBMysqli */ class DoliDBMysql extends DoliDB { diff --git a/htdocs/install/fileconf.php b/htdocs/install/fileconf.php index 97a52ff6c34..04f8a3caf4c 100644 --- a/htdocs/install/fileconf.php +++ b/htdocs/install/fileconf.php @@ -328,8 +328,9 @@ if (! empty($force_install_message)) $option.='>'; $option.=$type.'   '; if ($note) $option.=' '.$note; - // Experimental - if ($type=='mssql') $option.=' '.$langs->trans("Experimental"); + // Deprecated and experimental + if ($type=='mysql') $option.=' ' . $langs->trans("Deprecated"); + elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental"); elseif ($type=='sqlite') $option.=' '.$langs->trans("Experimental"); elseif ($type=='sqlite3') $option.=' '.$langs->trans("Experimental"); // No available diff --git a/htdocs/langs/en_US/install.lang b/htdocs/langs/en_US/install.lang index 7de123d5ea3..0c61ce35e2e 100644 --- a/htdocs/langs/en_US/install.lang +++ b/htdocs/langs/en_US/install.lang @@ -64,6 +64,7 @@ DatabaseSuperUserAccess=Database server - Superuser access CheckToCreateDatabase=Check box if database does not exist and must be created.
In this case, you must fill the login/password for superuser account at the bottom of this page. CheckToCreateUser=Check box if database owner does not exist and must be created.
In this case, you must choose its login and password and also fill the login/password for the superuser account at the bottom of this page. If this box is unchecked, owner database and its passwords must exists. Experimental=(experimental) +Deprecated=(deprecated) DatabaseRootLoginDescription=Login of the user allowed to create new databases or new users, mandatory if your database or its owner does not already exists. KeepEmptyIfNoPassword=Leave empty if user has no password (avoid this) SaveConfigurationFile=Save values @@ -211,4 +212,4 @@ MigrationCategorieAssociation=Migration of categories MigrationEvents=Migration of events to add event owner into assignement table ShowNotAvailableOptions=Show not available options -HideNotAvailableOptions=Hide not available options \ No newline at end of file +HideNotAvailableOptions=Hide not available options From 8627f2f19b5551beb1de040e0c7f4f7ba7487e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 May 2015 14:01:15 +0200 Subject: [PATCH 11/18] Removed innecesary test --- htdocs/categories/class/categorie.class.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index b5e46cc475a..67d821578dd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -472,7 +472,7 @@ class Categorie extends CommonObject * Link an object to the category * * @param Object $obj Object to link to category - * @param string $type Type of category ('societe', 'member', 'customer', 'supplier', 'product', 'contact') + * @param string $type Type of category ('societe', 'member', 'product', 'contact', 'fournisseur) * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ function add_type($obj,$type) @@ -485,8 +485,8 @@ class Categorie extends CommonObject // For backward compatibility if ($type == 'company') $type='societe'; - if ($type == 'customer') $type='societe'; - if ($type == 'supplier') $type='fournisseur'; + elseif ($type == 'customer') $type='societe'; + elseif ($type == 'supplier') $type='fournisseur'; /** * llx_categorie_contact => fk_socpeople @@ -496,7 +496,7 @@ class Categorie extends CommonObject */ if ($type == 'contact') { $column_name = 'socpeople'; - } elseif ($type == 'supplier' || ($type == 'societe')) { + } elseif ($type == 'fournisseur' || ($type == 'societe')) { $column_name = 'soc'; } else { $column_name = 'type'; From d1c7c9489e017adc33ae07d96b3c2c5421598fae Mon Sep 17 00:00:00 2001 From: Steve Braun Date: Mon, 25 May 2015 14:56:37 +0200 Subject: [PATCH 12/18] fixes #2847 --- htdocs/core/lib/functions2.lib.php | 46 ++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 6 deletions(-) diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 1a1fd706e0a..e06577cf8f5 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -637,10 +637,21 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m //$date=dol_mktime(12, 0, 0, 1, 1, 1900); //$date=dol_stringtotime('20130101'); + $hasglobalcounter=false; // Extract value for mask counter, mask raz and mask offset - if (! preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) return 'ErrorBadMask'; - $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); - $maskcounter=$reg[1]; + if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) + { + $masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:''); + $maskcounter=$reg[1]; + $hasglobalcounter=true; + } + else + { + // setting some defaults so the rest of the code won't fail if there is a third party counter + $masktri='00000'; + $maskcounter='00000'; + } + $maskraz=-1; $maskoffset=0; $resetEveryMonth=false; @@ -659,6 +670,12 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; } else $maskrefclient=''; + + // fail if there is neither a global nor a third party counter + if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) + { + return 'ErrorBadMask'; + } // Extract value for third party type if (preg_match('/\{(t+)\}/i',$mask,$regType)) @@ -993,10 +1010,21 @@ function check_value($mask,$value) { $result=0; + $hasglobalcounter=false; // Extract value for mask counter, mask raz and mask offset - if (! preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) return 'ErrorBadMask'; - $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); - $maskcounter=$reg[1]; + if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) + { + $masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:''); + $maskcounter=$reg[1]; + $hasglobalcounter=true; + } + else + { + // setting some defaults so the rest of the code won't fail if there is a third party counter + $masktri='00000'; + $maskcounter='00000'; + } + $maskraz=-1; $maskoffset=0; if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits'; @@ -1015,6 +1043,12 @@ function check_value($mask,$value) } else $maskrefclient=''; + // fail if there is neither a global nor a third party counter + if (! $hasglobalcounter && ($maskrefclient_maskcounter == '')) + { + return 'ErrorBadMask'; + } + $maskwithonlyymcode=$mask; $maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$maskcounter,$maskwithonlyymcode); $maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode); From c0346bcba43a94e4e26b7962fe9355e886cdbe1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcos=20Garci=CC=81a=20de=20La=20Fuente?= Date: Mon, 25 May 2015 14:59:34 +0200 Subject: [PATCH 13/18] Fixed typo --- htdocs/categories/class/categorie.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 67d821578dd..cd248d45744 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -499,7 +499,7 @@ class Categorie extends CommonObject } elseif ($type == 'fournisseur' || ($type == 'societe')) { $column_name = 'soc'; } else { - $column_name = 'type'; + $column_name = $type; } $this->db->begin(); From a30d4d4be6b9bc8a2462b71c0752e2cc5a69f831 Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Mon, 25 May 2015 18:14:49 +0200 Subject: [PATCH 14/18] Tabs collector better identification Tabs collector goes wrong with 2 tabs in the same page (like projet and task), so we use picto name to identify the 2 tabscollect We need to substract the @ if the tabs is from a module... eg : factory@factory --- htdocs/core/lib/functions.lib.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 63ab76dcb2f..8b6dfa38657 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -789,14 +789,15 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p if ($displaytab > $limittoshow) { - $out.='
'; + $tabsname=str_replace ("@", "", $picto); + $out.='
'; $out.=''.$langs->trans("More").'...'; - $out.='
'.$outmore.'
'; + $out.='
'.$outmore.'
'; $out.="
\n"; $out.=""; } From 47045e074623776307f72a7d849afdf5a3f69e0f Mon Sep 17 00:00:00 2001 From: aspangaro Date: Thu, 28 May 2015 21:34:35 +0200 Subject: [PATCH 15/18] Accountancy: Review presentation --- htdocs/accountancy/bookkeeping/card.php | 26 +++++++++++++--------- htdocs/accountancy/customer/index.php | 8 +++---- htdocs/accountancy/journal/bankjournal.php | 4 ++-- htdocs/accountancy/supplier/index.php | 6 ++--- htdocs/projet/card.php | 2 +- 5 files changed, 26 insertions(+), 20 deletions(-) diff --git a/htdocs/accountancy/bookkeeping/card.php b/htdocs/accountancy/bookkeeping/card.php index a24ed34e052..e25ceb976ff 100644 --- a/htdocs/accountancy/bookkeeping/card.php +++ b/htdocs/accountancy/bookkeeping/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 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 @@ -205,36 +205,42 @@ if ($action == 'create') { print '
'; print '' . "\n"; print '' . "\n"; - + + dol_fiche_head(); + print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; - print ''; + print ''; print ''; print ''; print ''; print '
' . $langs->trans("NumMvts") . '' . $next_num_mvt . '
' . $langs->trans("Docdate") . ''; print $html->select_date('', 'doc_date', '', '', '', "create_mvt", 1, 1); print '
' . $langs->trans("Codejournal") . '' . $html->selectarray('code_journal', $code_journal_array) . '
' . $langs->trans("Docref") . '
' . $langs->trans("Doctype") . '
'; - print '
'; - print ''; - + + dol_fiche_end(); + + print '
'; + print '     '; + print '
'; + print '
'; } else diff --git a/htdocs/accountancy/customer/index.php b/htdocs/accountancy/customer/index.php index df635155416..5a1ffc30bb7 100644 --- a/htdocs/accountancy/customer/index.php +++ b/htdocs/accountancy/customer/index.php @@ -1,9 +1,9 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -172,8 +172,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - - print '' . length_accountg($row[0]) . ''; + $var=!$var; + print '' . length_accountg($row[0]) . ''; print '' . $row[1] . ''; print '' . price($row[2]) . ''; print '' . price($row[3]) . ''; diff --git a/htdocs/accountancy/journal/bankjournal.php b/htdocs/accountancy/journal/bankjournal.php index fc3157c318a..75e54b2a590 100644 --- a/htdocs/accountancy/journal/bankjournal.php +++ b/htdocs/accountancy/journal/bankjournal.php @@ -555,9 +555,9 @@ else $h=0; $head[$h][0] = $_SERVER["PHP_SELF"].'?id_account='.$id_accountancy_journal; $head[$h][1] = $langs->trans("Report"); - $head[$h][2] = 'report'; + $head[$h][2] = 'card'; - dol_fiche_head($head, $hselected); + dol_fiche_head($head, 'card', $langs->trans("BankJournal"), 0, 'payment'); print '
'; print ''; diff --git a/htdocs/accountancy/supplier/index.php b/htdocs/accountancy/supplier/index.php index 3bdf2f45a7c..2c2392bfa27 100644 --- a/htdocs/accountancy/supplier/index.php +++ b/htdocs/accountancy/supplier/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 Florian Henry - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2014 Juanjo Menent * * This program is free software; you can redistribute it and/or modify @@ -158,8 +158,8 @@ if ($resql) { while ( $i < $num ) { $row = $db->fetch_row($resql); - - print ''; + $var=!$var; + print ''; print ''; print ''; print ''; diff --git a/htdocs/projet/card.php b/htdocs/projet/card.php index 60384a29da0..b7ea6bd798b 100644 --- a/htdocs/projet/card.php +++ b/htdocs/projet/card.php @@ -698,7 +698,7 @@ else if ($action == 'edit' && $userWrite > 0) { print '
'; - print '     '; + print '     '; print ''; print '
'; } From fd988ab1f3db4454690552c929314ecc208d6da3 Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 29 May 2015 06:43:40 +0200 Subject: [PATCH 16/18] Review card of supplier/customer ventilation --- htdocs/accountancy/customer/card.php | 17 +++++--- htdocs/accountancy/supplier/card.php | 64 +++++++++++++++++----------- 2 files changed, 49 insertions(+), 32 deletions(-) diff --git a/htdocs/accountancy/customer/card.php b/htdocs/accountancy/customer/card.php index 487f4dc2719..d3d6ff8a945 100644 --- a/htdocs/accountancy/customer/card.php +++ b/htdocs/accountancy/customer/card.php @@ -1,7 +1,7 @@ * Copyright (C) 2013-2014 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 @@ -44,7 +44,6 @@ if ($user->societe_id > 0) /* * Actions */ - if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { if (! GETPOST('cancel', 'alpha')) { @@ -63,6 +62,10 @@ if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { } } +/* + * View + */ + llxHeader("", "", "FicheVentilation"); if ($cancel == $langs->trans("Cancel")) { @@ -108,6 +111,8 @@ if (! empty($id)) { $linkback=''.$langs->trans("Back").''; print_fiche_titre($langs->trans('CustomersVentilation'),$linkback,'title_setup'); + dol_fiche_head(); + print '
' . length_accountg($row[0]) . '
' . length_accountg($row[0]) . '' . $row[1] . '' . price($row[2]) . '' . price($row[3]) . '
'; // Ref facture @@ -120,13 +125,13 @@ if (! empty($id)) { print ''; print ''; print ''; print '
' . $langs->trans("Line") . '' . nl2br($objp->description) . '
' . $langs->trans("Account") . ''; - print $objp->account_number . '-' . $objp->label; - print '
' . $langs->trans("NewAccount") . ''; print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
'; + + dol_fiche_end(); - print '
'; + print '
'; print ''; print '     '; print ''; @@ -144,4 +149,4 @@ if (! empty($id)) { } llxFooter(); -$db->close(); +$db->close(); \ No newline at end of file diff --git a/htdocs/accountancy/supplier/card.php b/htdocs/accountancy/supplier/card.php index 51d09428c25..42837680428 100644 --- a/htdocs/accountancy/supplier/card.php +++ b/htdocs/accountancy/supplier/card.php @@ -1,11 +1,11 @@ * Copyright (C) 2005 Simon TOSSER - * Copyright (C) 2013-2014 Alexandre Spangaro + * Copyright (C) 2013-2015 Alexandre Spangaro * Copyright (C) 2013-2014 Olivier Geffroy * Copyright (C) 2013-2014 Florian Henry * Copyright (C) 2014 Juanjo Menent - * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2015 Jean-François Ferry * * 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 @@ -34,31 +34,32 @@ require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/accountancy/class/html.formventilation.class.php'; // Langs -$langs->load("compta"); $langs->load("bills"); -$langs->load("other"); -$langs->load("main"); $langs->load("accountancy"); -$action = GETPOST('action'); -$id = GETPOST('id', 'int'); +$action = GETPOST('action', 'alpha'); $codeventil = GETPOST('codeventil'); +$id = GETPOST('id'); // Security check if ($user->societe_id > 0) accessforbidden(); -if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) -{ - $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; - $sql .= " SET fk_code_ventilation = " . $codeventil; - $sql .= " WHERE rowid = " . $id; - - dol_syslog('accountancy/journal/sellsjournal.php:: $sql=' . $sql); - - $resql = $db->query($sql); - if (! $resql) { - setEventMessage($db->lasterror(), 'errors'); +if ($action == 'ventil' && $user->rights->accounting->ventilation->dispatch) { + if (! GETPOST('cancel', 'alpha')) + { + $sql = " UPDATE " . MAIN_DB_PREFIX . "facture_fourn_det"; + $sql .= " SET fk_code_ventilation = " . $codeventil; + $sql .= " WHERE rowid = " . $id; + + dol_syslog('accountancy/supplier/card.php:: $sql=' . $sql); + $resql = $db->query($sql); + if (! $resql) { + setEventMessage($db->lasterror(), 'errors'); + } + } else { + header("Location: ./lines.php"); + exit(); } } @@ -78,7 +79,7 @@ $form = new Form($db); $facturefournisseur_static = new FactureFournisseur($db); $formventilation = new FormVentilation($db); -if ($_GET["id"]) { +if (! empty($id)) { $sql = "SELECT f.ref as facnumber, f.rowid as facid, l.fk_product, l.description, l.rowid, l.fk_code_ventilation, "; $sql .= " p.rowid as product_id, p.ref as product_ref, p.label as product_label"; $sql .= ", aa.account_number, aa.label"; @@ -87,11 +88,14 @@ if ($_GET["id"]) { $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "accountingaccount as aa ON l.fk_code_ventilation = aa.rowid"; $sql .= " INNER JOIN " . MAIN_DB_PREFIX . "facture_fourn as f ON f.rowid = l.fk_facture_fourn "; $sql .= " WHERE f.fk_statut > 0 AND l.rowid = " . $id; + if (! empty($conf->multicompany->enabled)) { $sql .= " AND f.entity IN (" . getEntity("facture_fourn", 1) . ")"; } + dol_syslog("/accounting/supplier/card.php sql=" . $sql, LOG_DEBUG); $result = $db->query($sql); + if ($result) { $num_lines = $db->num_rows($result); $i = 0; @@ -103,7 +107,10 @@ if ($_GET["id"]) { print ''; print ''; - print_fiche_titre($langs->trans("SuppliersVentilation")); + $linkback=''.$langs->trans("Back").''; + print_fiche_titre($langs->trans('SuppliersVentilation'),$linkback,'title_setup'); + + dol_fiche_head(); print ''; @@ -119,19 +126,24 @@ if ($_GET["id"]) { print ''; print ''; print ''; - print ''; - print '
' . $langs->trans("ProductLabel") . '' . dol_trunc($objp->product_label, 24) . '
' . $langs->trans("Account") . ''; - print $objp->account_number . '-' . $objp->label; - print '
' . $langs->trans("NewAccount") . ''; print $formventilation->select_account($objp->fk_code_ventilation, 'codeventil', 1); print '
 
'; + + dol_fiche_end(); + + print '
'; + print ''; + print '     '; + print ''; + print '
'; + print ''; } else { - print "Error 1"; + print "Error"; } } else { - print "Error 2"; + print "Error"; } } else { print "Error ID incorrect"; From 27c0b84a136633f31b1a485a851f57ca462ba36d Mon Sep 17 00:00:00 2001 From: aspangaro Date: Fri, 29 May 2015 06:54:16 +0200 Subject: [PATCH 17/18] Typo on search --- htdocs/accountancy/customer/lines.php | 2 +- htdocs/accountancy/supplier/lines.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/accountancy/customer/lines.php b/htdocs/accountancy/customer/lines.php index 3a368f8d3ad..7941a7df4a8 100644 --- a/htdocs/accountancy/customer/lines.php +++ b/htdocs/accountancy/customer/lines.php @@ -43,7 +43,7 @@ $search_facture = GETPOST('search_facture','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); -$search_acount = GETPOST('search_account','alpha'); +$search_account = GETPOST('search_account','alpha'); // Security check if ($user->societe_id > 0) diff --git a/htdocs/accountancy/supplier/lines.php b/htdocs/accountancy/supplier/lines.php index 9cf77779bf4..0edc9e1142f 100644 --- a/htdocs/accountancy/supplier/lines.php +++ b/htdocs/accountancy/supplier/lines.php @@ -44,7 +44,7 @@ $search_facture = GETPOST('search_facture','alpha'); $search_label = GETPOST('search_label','alpha'); $search_desc = GETPOST('search_desc','alpha'); $search_amount = GETPOST('search_amount','alpha'); -$search_acount = GETPOST('search_account','alpha'); +$search_account = GETPOST('search_account','alpha'); // Security check if ($user->societe_id > 0) From d925ecb4f1359a094c889ce9a8d0d0911407e34e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 29 May 2015 17:09:35 +0200 Subject: [PATCH 18/18] Revert "Made test pessimistic by default" --- htdocs/core/lib/files.lib.php | 6 ++++-- test/phpunit/FilesLibTest.php | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php index 85429d96ac7..daae392cd39 100644 --- a/htdocs/core/lib/files.lib.php +++ b/htdocs/core/lib/files.lib.php @@ -802,7 +802,7 @@ function dol_move_uploaded_file($src_file, $dest_file, $allowoverwrite, $disable */ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=null) { - global $langs; + global $db, $conf, $user, $langs; global $hookmanager; $langs->load("other"); @@ -829,8 +829,10 @@ function dol_delete_file($file,$disableglob=0,$nophperrors=0,$nohook=0,$object=n } else { + $error=0; + //print "x".$file." ".$disableglob;exit; - $ok=false; + $ok=true; $file_osencoded=dol_osencode($file); // New filename encoded in OS filesystem encoding charset if (empty($disableglob) && ! empty($file_osencoded)) { diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 409816d5f90..4477784ae7d 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -339,9 +339,10 @@ class FilesLibTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertTrue($result,'delete file'); + // Again to test no error when deleteing a non existing file $result=dol_delete_file($conf->admin->dir_temp.'/file2.csv'); print __METHOD__." result=".$result."\n"; - $this->assertFalse($result,'delete file that does not exists'); + $this->assertTrue($result,'delete file that does not exists'); // Test copy with special char / delete with blob $result=dol_copy($file, $conf->admin->dir_temp.'/file with [x] and é.csv',0,1);