From f1f7ff315f3e40b680767f0e18dbfbc908c6e707 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 16 Jan 2013 15:54:07 +0100 Subject: [PATCH] Fix: CRLF --- dev/skeletons/build_class_from_table.php | 8 +- dev/skeletons/skeleton_page.php | 6 +- htdocs/admin/boxes.php | 10 +- htdocs/admin/tools/index.php | 4 +- htdocs/core/boxes/box_activity.php | 2 +- htdocs/core/boxes/box_comptes.php | 2 +- htdocs/core/boxes/box_members.php | 2 +- htdocs/core/class/html.formother.class.php | 10 +- htdocs/core/lib/invoice2.lib.php | 56 +-- .../menus/standard/auguria_backoffice.php | 4 +- htdocs/core/menus/standard/empty.php | 174 ++++---- htdocs/index.php | 2 +- .../mysql/tables/llx_c_availability.sql | 52 +-- scripts/invoices/rebuild_merge_pdf.php | 2 +- .../members/sync_members_ldap2dolibarr.php | 72 ++-- scripts/user/sync_users_ldap2dolibarr.php | 60 +-- test/phpunit/CommandeFournisseurTest.php | 46 +- test/phpunit/FilesLibTest.php | 124 +++--- test/phpunit/FunctionsTest.php | 156 +++---- test/phpunit/JsonLibTest.php | 8 +- test/phpunit/NumberingModulesTest.php | 400 +++++++++--------- test/phpunit/PricesTest.php | 6 +- 22 files changed, 603 insertions(+), 603 deletions(-) diff --git a/dev/skeletons/build_class_from_table.php b/dev/skeletons/build_class_from_table.php index 1b566afa5ee..cc6d557c58c 100755 --- a/dev/skeletons/build_class_from_table.php +++ b/dev/skeletons/build_class_from_table.php @@ -177,7 +177,7 @@ $targetcontent=preg_replace('/\s*\/\/\.\.\./', '', $targetcontent); $targetcontent=preg_replace('/Put here some comments/','Initialy built by build_class_from_table on '.strftime('%Y-%m-%d %H:%M',mktime()), $targetcontent); // Substitute table name -$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); +$targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); // Substitute declaration parameters $varprop="\n"; @@ -445,9 +445,9 @@ $targetcontent=preg_replace('/Put here some comments/','Initialy built by build_ // Substitute table name $targetcontent=preg_replace('/MAIN_DB_PREFIX."mytable/', 'MAIN_DB_PREFIX."'.$tablenoprefix, $targetcontent); -// Substitute fetch/select parameters -$targetcontent=preg_replace('/\$sql\.= " t\.field1,";/', $varpropselect, $targetcontent); -$targetcontent=preg_replace('/\$sql\.= " t\.field2";/', '', $targetcontent); +// Substitute fetch/select parameters +$targetcontent=preg_replace('/\$sql\.= " t\.field1,";/', $varpropselect, $targetcontent); +$targetcontent=preg_replace('/\$sql\.= " t\.field2";/', '', $targetcontent); // Build file $fp=fopen($outfile,"w"); diff --git a/dev/skeletons/skeleton_page.php b/dev/skeletons/skeleton_page.php index 983d0faab23..7c6208289eb 100644 --- a/dev/skeletons/skeleton_page.php +++ b/dev/skeletons/skeleton_page.php @@ -127,8 +127,8 @@ jQuery(document).ready(function() { if ($action == 'list') { $sql = "SELECT"; - $sql.= " t.rowid,"; - $sql.= " t.field1,"; + $sql.= " t.rowid,"; + $sql.= " t.field1,"; $sql.= " t.field2"; $sql.= " FROM ".MAIN_DB_PREFIX."mytable as t"; $sql.= " WHERE field3 = 'xxx'"; @@ -169,7 +169,7 @@ if ($action == 'list') dol_print_error($db); } - print ''."\n"; + print ''."\n"; } diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index c71ffd69290..5d9c4f998c2 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; include_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; $langs->load("admin"); -$langs->load("boxes"); +$langs->load("boxes"); if (! $user->admin) accessforbidden(); @@ -347,10 +347,10 @@ foreach($boxtoadd as $box) print ''; print ''.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).''; print ''; - if ($box->note == '(WarningUsingThisBoxSlowDown)') - { - $langs->load("errors"); - print $langs->trans("WarningUsingThisBoxSlowDown"); + if ($box->note == '(WarningUsingThisBoxSlowDown)') + { + $langs->load("errors"); + print $langs->trans("WarningUsingThisBoxSlowDown"); } else print ($box->note?$box->note:' '); print ''; diff --git a/htdocs/admin/tools/index.php b/htdocs/admin/tools/index.php index f2fa18a10be..9dc1aef46b2 100644 --- a/htdocs/admin/tools/index.php +++ b/htdocs/admin/tools/index.php @@ -52,8 +52,8 @@ print info_admin($langs->trans("SystemAreaForAdminOnly")).'
'; print '

'; -// Show logo -print '
'; +// Show logo +print '
'; llxFooter(); $db->close(); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index 75179e2742a..cbed2cb4e68 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -37,7 +37,7 @@ class box_activity extends ModeleBoxes var $db; var $param; var $enabled = 1; - var $enabled = 1; + var $enabled = 1; var $info_box_head = array(); var $info_box_contents = array(); diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 8cb14046cd3..4d9ec0e600c 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -38,7 +38,7 @@ class box_comptes extends ModeleBoxes var $db; var $param; - var $enabled = 1; + var $enabled = 1; var $info_box_head = array(); var $info_box_contents = array(); diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index d8a3cd2ed26..1692abffe0a 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -38,7 +38,7 @@ class box_members extends ModeleBoxes var $db; var $param; - var $enabled = 1; + var $enabled = 1; var $info_box_head = array(); var $info_box_contents = array(); diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 489ee328f8b..47cab7e5fd2 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -823,11 +823,11 @@ class FormOther if (! empty($user->conf->$confuserzone)) { $langs->load("boxes"); - foreach($boxactivated as $box) - { + foreach($boxactivated as $box) + { if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user - $arrayboxtoactivatelabel[$box->id]=$langs->transnoentitiesnoconv($box->boxlabel); // We keep only boxes not shown for user, to show into combo list - } + $arrayboxtoactivatelabel[$box->id]=$langs->transnoentitiesnoconv($box->boxlabel); // We keep only boxes not shown for user, to show into combo list + } $form=new Form($db); $selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1); @@ -862,7 +862,7 @@ class FormOther if ($nbboxactivated) { - $emptybox=new ModeleBoxes($db); + $emptybox=new ModeleBoxes($db); print ''; print '
'."\n"; diff --git a/htdocs/core/lib/invoice2.lib.php b/htdocs/core/lib/invoice2.lib.php index f2c6bd3599d..a73855accb4 100644 --- a/htdocs/core/lib/invoice2.lib.php +++ b/htdocs/core/lib/invoice2.lib.php @@ -1,30 +1,30 @@ #!/usr/bin/php -* -* 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 -* the Free Software Foundation; either version 2 of the License, or -* (at your option) any later version. -* -* This program is distributed in the hope that it will be useful, -* but WITHOUT ANY WARRANTY; without even the implied warranty of -* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -* GNU General Public License for more details. -* -* You should have received a copy of the GNU General Public License -* along with this program. If not, see . -*/ - -/** - * \file htdocs/core/lib/invoice2.lib.php - * \ingroup facture - * \brief Function to rebuild PDF and merge PDF files into one +/* + * Copyright (C) 2009-2012 Laurent Destailleur +* +* 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 +* the Free Software Foundation; either version 2 of the License, or +* (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program. If not, see . +*/ + +/** + * \file htdocs/core/lib/invoice2.lib.php + * \ingroup facture + * \brief Function to rebuild PDF and merge PDF files into one */ -require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); -require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'); /** @@ -174,13 +174,13 @@ function rebuild_merge_pdf($db, $langs, $conf, $diroutputpdf, $newlangid, $filte // Define format of output PDF - $formatarray=pdf_getFormat(); - $page_largeur = $formatarray['width']; - $page_hauteur = $formatarray['height']; + $formatarray=pdf_getFormat(); + $page_largeur = $formatarray['width']; + $page_hauteur = $formatarray['height']; $format = array($page_largeur,$page_hauteur); - if ($usestdout) print "Using output PDF format ".join('x',$format)."\n"; - else dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR); + if ($usestdout) print "Using output PDF format ".join('x',$format)."\n"; + else dol_syslog("Using output PDF format ".join('x',$format), LOG_ERR); // Now, build a merged files with all files in $files array diff --git a/htdocs/core/menus/standard/auguria_backoffice.php b/htdocs/core/menus/standard/auguria_backoffice.php index 2104ee3fe19..f4a9eaa4b3f 100644 --- a/htdocs/core/menus/standard/auguria_backoffice.php +++ b/htdocs/core/menus/standard/auguria_backoffice.php @@ -38,8 +38,8 @@ class MenuManager var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // Valeur du target a utiliser dans les liens - var $menu_array; - var $menu_array_after; + var $menu_array; + var $menu_array_after; /** diff --git a/htdocs/core/menus/standard/empty.php b/htdocs/core/menus/standard/empty.php index a46f6d6cd94..48496aee1fc 100644 --- a/htdocs/core/menus/standard/empty.php +++ b/htdocs/core/menus/standard/empty.php @@ -30,8 +30,8 @@ class MenuManager var $type_user=0; // Put 0 for internal users, 1 for external users var $atarget=""; // To store arget to use in menu links - var $menu_array; - var $menu_array_after; + var $menu_array; + var $menu_array_after; /** @@ -80,91 +80,91 @@ class MenuManager if ($mode == 'left') { - $newmenu = new Menu(); - - // Put here left menu entries - // ***** START ***** - - $langs->load("admin"); // Load translation file admin.lang - $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); - $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); - $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1); - $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1); - $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); - $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); - $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1); - $newmenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); - $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); - $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); - $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); - $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); - $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionnarySetup"),1); - $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); - - // ***** END ***** - - // do not change code after this - - // override menu_array by value array in $newmenu - $this->menu_array=$newmenu->liste; - - $alt=0; - $num=count($this->menu_array); - for ($i = 0; $i < $num; $i++) - { - $alt++; - if (empty($this->menu_array[$i]['level'])) - { - if (($alt%2==0)) - { - print '
'."\n"; - } - else - { - print '
'."\n"; - } - } - - // Place tabulation - $tabstring=''; - $tabul=($this->menu_array[$i]['level'] - 1); - if ($tabul > 0) - { - for ($j=0; $j < $tabul; $j++) - { - $tabstring.='   '; - } - } - - if ($this->menu_array[$i]['level'] == 0) { - if ($this->menu_array[$i]['enabled']) - { - print ''."\n"; - } - else - { - print ''."\n"; - } - print ''."\n"; - } - - if ($this->menu_array[$i]['level'] > 0) { - print ''."\n"; - } - - // If next is a new block or end - if (empty($this->menu_array[$i+1]['level'])) - { - print ''."\n"; - print "
\n"; - } + $newmenu = new Menu(); + + // Put here left menu entries + // ***** START ***** + + $langs->load("admin"); // Load translation file admin.lang + $newmenu->add("/admin/index.php?leftmenu=setup", $langs->trans("Setup"),0); + $newmenu->add("/admin/company.php", $langs->trans("MenuCompanySetup"),1); + $newmenu->add("/admin/modules.php", $langs->trans("Modules"),1); + $newmenu->add("/admin/menus.php", $langs->trans("Menus"),1); + $newmenu->add("/admin/ihm.php", $langs->trans("GUISetup"),1); + $newmenu->add("/admin/boxes.php", $langs->trans("Boxes"),1); + $newmenu->add("/admin/delais.php",$langs->trans("Alerts"),1); + $newmenu->add("/admin/proxy.php?mainmenu=home", $langs->trans("Security"),1); + $newmenu->add("/admin/limits.php?mainmenu=home", $langs->trans("MenuLimits"),1); + $newmenu->add("/admin/pdf.php?mainmenu=home", $langs->trans("PDF"),1); + $newmenu->add("/admin/mails.php?mainmenu=home", $langs->trans("Emails"),1); + $newmenu->add("/admin/sms.php?mainmenu=home", $langs->trans("SMS"),1); + $newmenu->add("/admin/dict.php?mainmenu=home", $langs->trans("DictionnarySetup"),1); + $newmenu->add("/admin/const.php?mainmenu=home", $langs->trans("OtherSetup"),1); + + // ***** END ***** + + // do not change code after this + + // override menu_array by value array in $newmenu + $this->menu_array=$newmenu->liste; + + $alt=0; + $num=count($this->menu_array); + for ($i = 0; $i < $num; $i++) + { + $alt++; + if (empty($this->menu_array[$i]['level'])) + { + if (($alt%2==0)) + { + print '
'."\n"; + } + else + { + print '
'."\n"; + } + } + + // Place tabulation + $tabstring=''; + $tabul=($this->menu_array[$i]['level'] - 1); + if ($tabul > 0) + { + for ($j=0; $j < $tabul; $j++) + { + $tabstring.='   '; + } + } + + if ($this->menu_array[$i]['level'] == 0) { + if ($this->menu_array[$i]['enabled']) + { + print ''."\n"; + } + else + { + print ''."\n"; + } + print ''."\n"; + } + + if ($this->menu_array[$i]['level'] > 0) { + print ''."\n"; + } + + // If next is a new block or end + if (empty($this->menu_array[$i+1]['level'])) + { + print ''."\n"; + print "
\n"; + } } } } diff --git a/htdocs/index.php b/htdocs/index.php index bd64d31ca7f..7d38cb67495 100644 --- a/htdocs/index.php +++ b/htdocs/index.php @@ -569,7 +569,7 @@ if ($user->admin && empty($conf->global->MAIN_REMOVE_INSTALL_WARNING)) } } -//print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); +//print 'mem='.memory_get_usage().' - '.memory_get_peak_usage(); llxFooter(); diff --git a/htdocs/install/mysql/tables/llx_c_availability.sql b/htdocs/install/mysql/tables/llx_c_availability.sql index a58daeb0059..0a6b7e18db0 100644 --- a/htdocs/install/mysql/tables/llx_c_availability.sql +++ b/htdocs/install/mysql/tables/llx_c_availability.sql @@ -1,26 +1,26 @@ --- ======================================================================== --- Copyright (C) 2011 Philippe GRAND --- --- 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 --- the Free Software Foundation; either version 3 of the License, or --- (at your option) any later version. --- --- This program is distributed in the hope that it will be useful, --- but WITHOUT ANY WARRANTY; without even the implied warranty of --- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --- GNU General Public License for more details. --- --- You should have received a copy of the GNU General Public License --- along with this program. If not, see . --- --- ======================================================================== - -create table llx_c_availability -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - code varchar(30) NOT NULL, - label varchar(60) NOT NULL, - active tinyint DEFAULT 1 NOT NULL - -)ENGINE=innodb; +-- ======================================================================== +-- Copyright (C) 2011 Philippe GRAND +-- +-- 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 +-- the Free Software Foundation; either version 3 of the License, or +-- (at your option) any later version. +-- +-- This program is distributed in the hope that it will be useful, +-- but WITHOUT ANY WARRANTY; without even the implied warranty of +-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +-- GNU General Public License for more details. +-- +-- You should have received a copy of the GNU General Public License +-- along with this program. If not, see . +-- +-- ======================================================================== + +create table llx_c_availability +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + code varchar(30) NOT NULL, + label varchar(60) NOT NULL, + active tinyint DEFAULT 1 NOT NULL + +)ENGINE=innodb; diff --git a/scripts/invoices/rebuild_merge_pdf.php b/scripts/invoices/rebuild_merge_pdf.php index df836183f45..f4984331a51 100644 --- a/scripts/invoices/rebuild_merge_pdf.php +++ b/scripts/invoices/rebuild_merge_pdf.php @@ -40,7 +40,7 @@ require_once(DOL_DOCUMENT_ROOT."/cron/functions_cron.lib.php"); require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/facture/modules_facture.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); -require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php'); +require_once(DOL_DOCUMENT_ROOT.'/core/lib/invoice2.lib.php'); // Load main language strings diff --git a/scripts/members/sync_members_ldap2dolibarr.php b/scripts/members/sync_members_ldap2dolibarr.php index 7b960b3a85d..bbe3f9ab100 100755 --- a/scripts/members/sync_members_ldap2dolibarr.php +++ b/scripts/members/sync_members_ldap2dolibarr.php @@ -48,42 +48,42 @@ require_once(DOL_DOCUMENT_ROOT."/adherents/class/adherent.class.php"); require_once(DOL_DOCUMENT_ROOT."/adherents/class/cotisation.class.php"); -$langs->load("main"); -$langs->load("errors"); +$langs->load("main"); +$langs->load("errors"); + +// List of fields to get from LDAP +$required_fields = array( + $conf->global->LDAP_KEY_MEMBERS, + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_PHONE_PERSO, + $conf->global->LDAP_FIELD_MOBILE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_ADDRESS, + $conf->global->LDAP_FIELD_ZIP, + $conf->global->LDAP_FIELD_TOWN, + $conf->global->LDAP_FIELD_COUNTRY, + $conf->global->LDAP_FIELD_DESCRIPTION, + $conf->global->LDAP_FIELD_BIRTHDATE, + $conf->global->LDAP_FIELD_MEMBER_STATUS, + $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION, + // Subscriptions + $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE, + $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT, + $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE, + $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT +); + +// Remove from required_fields all entries not configured in LDAP (empty) and duplicated +$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); -// List of fields to get from LDAP -$required_fields = array( - $conf->global->LDAP_KEY_MEMBERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_PHONE_PERSO, - $conf->global->LDAP_FIELD_MOBILE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_ADDRESS, - $conf->global->LDAP_FIELD_ZIP, - $conf->global->LDAP_FIELD_TOWN, - $conf->global->LDAP_FIELD_COUNTRY, - $conf->global->LDAP_FIELD_DESCRIPTION, - $conf->global->LDAP_FIELD_BIRTHDATE, - $conf->global->LDAP_FIELD_MEMBER_STATUS, - $conf->global->LDAP_FIELD_MEMBER_END_LASTSUBSCRIPTION, - // Subscriptions - $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_DATE, - $conf->global->LDAP_FIELD_MEMBER_FIRSTSUBSCRIPTION_AMOUNT, - $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_DATE, - $conf->global->LDAP_FIELD_MEMBER_LASTSUBSCRIPTION_AMOUNT -); - -// Remove from required_fields all entries not configured in LDAP (empty) and duplicated -$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); - if ($argv[3]) $conf->global->LDAP_SERVER_HOST=$argv[2]; @@ -94,7 +94,7 @@ if (! isset($argv[2]) || ! is_numeric($argv[2])) { exit; } $typeid=$argv[2]; -if ($argv[1] == 'commitiferror') $forcecommit=1; +if ($argv[1] == 'commitiferror') $forcecommit=1; print "Mails sending disabled (useless in batch mode)\n"; $conf->global->MAIN_DISABLE_ALL_MAILS=1; // On bloque les mails diff --git a/scripts/user/sync_users_ldap2dolibarr.php b/scripts/user/sync_users_ldap2dolibarr.php index 647a7266028..758440e201e 100755 --- a/scripts/user/sync_users_ldap2dolibarr.php +++ b/scripts/user/sync_users_ldap2dolibarr.php @@ -50,34 +50,34 @@ require_once(DOL_DOCUMENT_ROOT."/core/class/ldap.class.php"); require_once(DOL_DOCUMENT_ROOT."/user/class/user.class.php"); $langs->load("main"); -$langs->load("errors"); +$langs->load("errors"); -// List of fields to get from LDAP -$required_fields = array( - $conf->global->LDAP_KEY_USERS, - $conf->global->LDAP_FIELD_FULLNAME, - $conf->global->LDAP_FIELD_NAME, - $conf->global->LDAP_FIELD_FIRSTNAME, - $conf->global->LDAP_FIELD_LOGIN, - $conf->global->LDAP_FIELD_LOGIN_SAMBA, - $conf->global->LDAP_FIELD_PASSWORD, - $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, - $conf->global->LDAP_FIELD_PHONE, - $conf->global->LDAP_FIELD_FAX, - $conf->global->LDAP_FIELD_MOBILE, - //$conf->global->LDAP_FIELD_ADDRESS, - //$conf->global->LDAP_FIELD_ZIP, - //$conf->global->LDAP_FIELD_TOWN, - //$conf->global->LDAP_FIELD_COUNTRY, - $conf->global->LDAP_FIELD_MAIL, - $conf->global->LDAP_FIELD_TITLE, - $conf->global->LDAP_FIELD_DESCRIPTION, - $conf->global->LDAP_FIELD_SID -); +// List of fields to get from LDAP +$required_fields = array( + $conf->global->LDAP_KEY_USERS, + $conf->global->LDAP_FIELD_FULLNAME, + $conf->global->LDAP_FIELD_NAME, + $conf->global->LDAP_FIELD_FIRSTNAME, + $conf->global->LDAP_FIELD_LOGIN, + $conf->global->LDAP_FIELD_LOGIN_SAMBA, + $conf->global->LDAP_FIELD_PASSWORD, + $conf->global->LDAP_FIELD_PASSWORD_CRYPTED, + $conf->global->LDAP_FIELD_PHONE, + $conf->global->LDAP_FIELD_FAX, + $conf->global->LDAP_FIELD_MOBILE, + //$conf->global->LDAP_FIELD_ADDRESS, + //$conf->global->LDAP_FIELD_ZIP, + //$conf->global->LDAP_FIELD_TOWN, + //$conf->global->LDAP_FIELD_COUNTRY, + $conf->global->LDAP_FIELD_MAIL, + $conf->global->LDAP_FIELD_TITLE, + $conf->global->LDAP_FIELD_DESCRIPTION, + $conf->global->LDAP_FIELD_SID +); + +// Remove from required_fields all entries not configured in LDAP (empty) and duplicated +$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); -// Remove from required_fields all entries not configured in LDAP (empty) and duplicated -$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement"))); - if ($argv[2]) $conf->global->LDAP_SERVER_HOST=$argv[2]; print "***** $script_file ($version) *****\n"; @@ -184,7 +184,7 @@ if ($result >= 0) $fuser->lastname=$ldapuser[$conf->global->LDAP_FIELD_NAME]; $fuser->login=$ldapuser[$conf->global->LDAP_FIELD_LOGIN]; $fuser->pass=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD]; - $fuser->pass_indatabase_crypted=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; + $fuser->pass_indatabase_crypted=$ldapuser[$conf->global->LDAP_FIELD_PASSWORD_CRYPTED]; //$user->societe; /* @@ -204,9 +204,9 @@ if ($result >= 0) $fuser->job=$ldapuser[$conf->global->LDAP_FIELD_TITLE]; $fuser->note=$ldapuser[$conf->global->LDAP_FIELD_DESCRIPTION]; $fuser->admin=0; - $fuser->societe_id=0; - $fuser->contact_id=0; - $fuser->fk_member=0; + $fuser->societe_id=0; + $fuser->contact_id=0; + $fuser->fk_member=0; $fuser->statut=1; /*if (isset($ldapuser[$conf->global->LDAP_FIELD_MEMBER_STATUS])) diff --git a/test/phpunit/CommandeFournisseurTest.php b/test/phpunit/CommandeFournisseurTest.php index a3478b74110..10435972924 100644 --- a/test/phpunit/CommandeFournisseurTest.php +++ b/test/phpunit/CommandeFournisseurTest.php @@ -27,8 +27,8 @@ global $conf,$user,$langs,$db; //define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver require_once 'PHPUnit/Autoload.php'; require_once dirname(__FILE__).'/../../htdocs/master.inc.php'; -require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.commande.class.php'; -require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.product.class.php'; +require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.commande.class.php'; +require_once dirname(__FILE__).'/../../htdocs/fourn/class/fournisseur.product.class.php'; if (empty($user->id)) { @@ -143,18 +143,18 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase // Create supplier price $result=$product->add_fournisseur($user, $societe->id, $ref_fourn, $quantity); // This insert record with no value for price. Values are update later with update_buyprice - $this->assertGreaterThanOrEqual(1, $result); + $this->assertGreaterThanOrEqual(1, $result); $result=$product->update_buyprice($quantity, 10, $user, 'HT', $societe, '', $ref_fourn, $tva_tx, 0, 0); - $this->assertGreaterThanOrEqual(0, $result); + $this->assertGreaterThanOrEqual(0, $result); // Create supplier order with a too low quantity $localobject=new CommandeFournisseur($db); $localobject->initAsSpecimen(); $localobject->lines=array(); // Overwrite lines of order - $line=new CommandeFournisseurLigne($db); - $line->desc=$langs->trans("Description")." specimen line too low"; - $line->qty=1; // So lower than $quantity - $line->fk_product=$product->id; + $line=new CommandeFournisseurLigne($db); + $line->desc=$langs->trans("Description")." specimen line too low"; + $line->qty=1; // So lower than $quantity + $line->fk_product=$product->id; $line->ref_fourn=$ref_fourn; $localobject->lines[]=$line; @@ -165,22 +165,22 @@ class CommandeFournisseurTest extends PHPUnit_Framework_TestCase $sql="DELETE FROM ".MAIN_DB_PREFIX."commande_fournisseur where ref=''"; $db->query($sql); - // Create supplier order - $localobject2=new CommandeFournisseur($db); - $localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1 - $localobject2->lines=array(); // Overwrite lines of order - $line=new CommandeFournisseurLigne($db); - $line->desc=$langs->trans("Description")." specimen line ok"; - $line->qty=10; // So enough quantity + // Create supplier order + $localobject2=new CommandeFournisseur($db); + $localobject2->initAsSpecimen(); // This create 5 lines of first product found for socid 1 + $localobject2->lines=array(); // Overwrite lines of order + $line=new CommandeFournisseurLigne($db); + $line->desc=$langs->trans("Description")." specimen line ok"; + $line->qty=10; // So enough quantity $line->fk_product=$product->id; - $line->ref_fourn=$ref_fourn; - $localobject2->lines[]=$line; - - $result=$localobject2->create($user); - print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(0, $result); - - return $result; + $line->ref_fourn=$ref_fourn; + $localobject2->lines[]=$line; + + $result=$localobject2->create($user); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(0, $result); + + return $result; } diff --git a/test/phpunit/FilesLibTest.php b/test/phpunit/FilesLibTest.php index 7a3d0f10aa9..f87494c924d 100644 --- a/test/phpunit/FilesLibTest.php +++ b/test/phpunit/FilesLibTest.php @@ -224,71 +224,71 @@ class FilesLibTest extends PHPUnit_Framework_TestCase return $result; } - /** - * testDolMimeType - * - * @return string - */ - public function testDolMimeType() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; - $db=$this->savdb; - - // file.png - $result=dol_mimetype('file.png','',0); - $this->assertEquals('image/png',$result); - $result=dol_mimetype('file.png','',1); - $this->assertEquals('png',$result); - $result=dol_mimetype('file.png','',2); - $this->assertEquals('image.png',$result); - $result=dol_mimetype('file.png','',3); - $this->assertEquals('',$result); - // file.odt - $result=dol_mimetype('file.odt','',0); - $this->assertEquals('application/vnd.oasis.opendocument.text',$result); - $result=dol_mimetype('file.odt','',1); - $this->assertEquals('vnd.oasis.opendocument.text',$result); - $result=dol_mimetype('file.odt','',2); - $this->assertEquals('ooffice.png',$result); - $result=dol_mimetype('file.odt','',3); - $this->assertEquals('',$result); - // file.php - $result=dol_mimetype('file.php','',0); - $this->assertEquals('text/plain',$result); - $result=dol_mimetype('file.php','',1); - $this->assertEquals('plain',$result); - $result=dol_mimetype('file.php','',2); - $this->assertEquals('php.png',$result); - $result=dol_mimetype('file.php','',3); - $this->assertEquals('php',$result); - // file.php.noexe - $result=dol_mimetype('file.php.noexe','',0); - $this->assertEquals('text/plain',$result); - } - - - /** - * testDolDeleteDir - * - * @return int - */ - public function testDolDeleteDir() - { - global $conf,$user,$langs,$db; - $conf=$this->savconf; - $user=$this->savuser; - $langs=$this->savlangs; + /** + * testDolMimeType + * + * @return string + */ + public function testDolMimeType() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; $db=$this->savdb; - $dirout=$conf->admin->dir_temp.'/test'; - - $count=0; + // file.png + $result=dol_mimetype('file.png','',0); + $this->assertEquals('image/png',$result); + $result=dol_mimetype('file.png','',1); + $this->assertEquals('png',$result); + $result=dol_mimetype('file.png','',2); + $this->assertEquals('image.png',$result); + $result=dol_mimetype('file.png','',3); + $this->assertEquals('',$result); + // file.odt + $result=dol_mimetype('file.odt','',0); + $this->assertEquals('application/vnd.oasis.opendocument.text',$result); + $result=dol_mimetype('file.odt','',1); + $this->assertEquals('vnd.oasis.opendocument.text',$result); + $result=dol_mimetype('file.odt','',2); + $this->assertEquals('ooffice.png',$result); + $result=dol_mimetype('file.odt','',3); + $this->assertEquals('',$result); + // file.php + $result=dol_mimetype('file.php','',0); + $this->assertEquals('text/plain',$result); + $result=dol_mimetype('file.php','',1); + $this->assertEquals('plain',$result); + $result=dol_mimetype('file.php','',2); + $this->assertEquals('php.png',$result); + $result=dol_mimetype('file.php','',3); + $this->assertEquals('php',$result); + // file.php.noexe + $result=dol_mimetype('file.php.noexe','',0); + $this->assertEquals('text/plain',$result); + } + + + /** + * testDolDeleteDir + * + * @return int + */ + public function testDolDeleteDir() + { + global $conf,$user,$langs,$db; + $conf=$this->savconf; + $user=$this->savuser; + $langs=$this->savlangs; + $db=$this->savdb; + + $dirout=$conf->admin->dir_temp.'/test'; + + $count=0; $result=dol_delete_dir_recursive($dirout,$count,1); // If it has no permission to delete, it will fails as if dir does not exists, so we can't test it - print __METHOD__." result=".$result."\n"; - $this->assertGreaterThanOrEqual(0,$result); + print __METHOD__." result=".$result."\n"; + $this->assertGreaterThanOrEqual(0,$result); } diff --git a/test/phpunit/FunctionsTest.php b/test/phpunit/FunctionsTest.php index 8e26f896c2a..c6c80ae54f8 100755 --- a/test/phpunit/FunctionsTest.php +++ b/test/phpunit/FunctionsTest.php @@ -429,8 +429,8 @@ class FunctionsTest extends PHPUnit_Framework_TestCase $s=img_picto('alt','img.png','style="float: right"',0); print __METHOD__." s=".$s."\n"; - $this->assertContains('theme',$s,'testImgPicto2'); - $this->assertContains('style="float: right"',$s,'testImgPicto2'); + $this->assertContains('theme',$s,'testImgPicto2'); + $this->assertContains('style="float: right"',$s,'testImgPicto2'); $s=img_picto('alt','/fullpath/img.png','',1); print __METHOD__." s=".$s."\n"; @@ -546,90 +546,90 @@ class FunctionsTest extends PHPUnit_Framework_TestCase $this->assertEquals(0,$vat); } - /** - * testGetDefaultTva - * - * @return void - */ - public function testGetDefaultLocalTax() - { - global $conf,$user,$langs,$db; - $this->savconf=$conf; - $this->savuser=$user; - $this->savlangs=$langs; - $this->savdb=$db; - - $companyfrnovat=new Societe($db); - $companyfrnovat->country_code='FR'; - $companyfrnovat->tva_assuj=0; - $companyfrnovat->localtax1_assuj=0; + /** + * testGetDefaultTva + * + * @return void + */ + public function testGetDefaultLocalTax() + { + global $conf,$user,$langs,$db; + $this->savconf=$conf; + $this->savuser=$user; + $this->savlangs=$langs; + $this->savdb=$db; + + $companyfrnovat=new Societe($db); + $companyfrnovat->country_code='FR'; + $companyfrnovat->tva_assuj=0; + $companyfrnovat->localtax1_assuj=0; $companyfrnovat->localtax2_assuj=0; - - $companyes=new Societe($db); - $companyes->country_code='ES'; - $companyes->tva_assuj=1; - $companyes->localtax1_assuj=1; - $companyes->localtax2_assuj=1; - - $companymc=new Societe($db); - $companymc->country_code='MC'; - $companymc->tva_assuj=1; - $companymc->localtax1_assuj=0; - $companymc->localtax2_assuj=0; - - $companyit=new Societe($db); - $companyit->country_code='IT'; - $companyit->tva_assuj=1; - $companyit->tva_intra='IT99999'; - $companyit->localtax1_assuj=0; - $companyit->localtax2_assuj=0; - - $notcompanyit=new Societe($db); - $notcompanyit->country_code='IT'; - $notcompanyit->tva_assuj=1; - $notcompanyit->tva_intra=''; - $notcompanyit->typent_code='TE_PRIVATE'; - $notcompanyit->localtax1_assuj=0; - $notcompanyit->localtax2_assuj=0; - - $companyus=new Societe($db); - $companyus->country_code='US'; - $companyus->tva_assuj=1; - $companyus->tva_intra=''; - $companyus->localtax1_assuj=0; - $companyus->localtax2_assuj=0; - + + $companyes=new Societe($db); + $companyes->country_code='ES'; + $companyes->tva_assuj=1; + $companyes->localtax1_assuj=1; + $companyes->localtax2_assuj=1; + + $companymc=new Societe($db); + $companymc->country_code='MC'; + $companymc->tva_assuj=1; + $companymc->localtax1_assuj=0; + $companymc->localtax2_assuj=0; + + $companyit=new Societe($db); + $companyit->country_code='IT'; + $companyit->tva_assuj=1; + $companyit->tva_intra='IT99999'; + $companyit->localtax1_assuj=0; + $companyit->localtax2_assuj=0; + + $notcompanyit=new Societe($db); + $notcompanyit->country_code='IT'; + $notcompanyit->tva_assuj=1; + $notcompanyit->tva_intra=''; + $notcompanyit->typent_code='TE_PRIVATE'; + $notcompanyit->localtax1_assuj=0; + $notcompanyit->localtax2_assuj=0; + + $companyus=new Societe($db); + $companyus->country_code='US'; + $companyus->tva_assuj=1; + $companyus->tva_intra=''; + $companyus->localtax1_assuj=0; + $companyus->localtax2_assuj=0; + // Test RULE FR-MC - $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); + $vat1=get_default_localtax($companyfrnovat,$companymc,1,0); $vat2=get_default_localtax($companyfrnovat,$companymc,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); - - // Test RULE ES-ES + $this->assertEquals(0,$vat1); + $this->assertEquals(0,$vat2); + + // Test RULE ES-ES $vat1=get_default_localtax($companyes,$companyes,1,0); $vat2=get_default_localtax($companyes,$companyes,2,0); - $this->assertEquals(5.2,$vat1); - $this->assertEquals(-15,$vat2); - - // Test RULE ES-IT - $vat1=get_default_localtax($companyes,$companyit,1,0); + $this->assertEquals(5.2,$vat1); + $this->assertEquals(-15,$vat2); + + // Test RULE ES-IT + $vat1=get_default_localtax($companyes,$companyit,1,0); $vat2=get_default_localtax($companyes,$companyit,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); - - // Test RULE ES-IT - $vat1=get_default_localtax($companyes,$notcompanyit,1,0); + $this->assertEquals(0,$vat1); + $this->assertEquals(0,$vat2); + + // Test RULE ES-IT + $vat1=get_default_localtax($companyes,$notcompanyit,1,0); $vat2=get_default_localtax($companyes,$notcompanyit,2,0); - $this->assertEquals(0,$vat1); - $this->assertEquals(0,$vat2); - - // Test RULE FR-IT - // Not tested - - // Test RULE ES-US - $vat1=get_default_localtax($companyes,$companyus,1,0); + $this->assertEquals(0,$vat1); + $this->assertEquals(0,$vat2); + + // Test RULE FR-IT + // Not tested + + // Test RULE ES-US + $vat1=get_default_localtax($companyes,$companyus,1,0); $vat2=get_default_localtax($companyes,$companyus,2,0); - $this->assertEquals(0,$vat1); + $this->assertEquals(0,$vat1); $this->assertEquals(0,$vat2); } } diff --git a/test/phpunit/JsonLibTest.php b/test/phpunit/JsonLibTest.php index 330c4547eef..1ad4a29b1e8 100755 --- a/test/phpunit/JsonLibTest.php +++ b/test/phpunit/JsonLibTest.php @@ -148,11 +148,11 @@ class JsonLibTest extends PHPUnit_Framework_TestCase $now=gmmktime(12,0,0,1,1,1970); $objecttotest=new stdClass(); - $objecttotest->property1='abc'; - $objecttotest->property2=1234; + $objecttotest->property1='abc'; + $objecttotest->property2=1234; $objecttotest->property3=$now; - $encoded=dol_json_encode($objecttotest); - $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); + $encoded=dol_json_encode($objecttotest); + $this->assertEquals('{"property1":"abc","property2":1234,"property3":43200}',$encoded); } diff --git a/test/phpunit/NumberingModulesTest.php b/test/phpunit/NumberingModulesTest.php index 59d13c7606f..946826449ed 100644 --- a/test/phpunit/NumberingModulesTest.php +++ b/test/phpunit/NumberingModulesTest.php @@ -134,22 +134,22 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}-{0000}'; $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}-{0000}'; - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('1915-0001', $result); // counter must start to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1915); // we use year 1915 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('1915-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1916); // we use following year for second invoice + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; $this->assertEquals('1916-0002', $result); // counter must not be reset // Now we try with a reset @@ -162,7 +162,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; - $this->assertEquals('1910-0001', $result); // counter must start to 1 + $this->assertEquals('1910-0001', $result); // counter must start to 1 // Same mask but we add month $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@1}'; @@ -175,7 +175,7 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $result2=$localobject->create($user,1); $result3=$localobject->validate($user, $result); print __METHOD__." result=".$result."\n"; - $this->assertEquals('192001-0001', $result); // counter must start to 1 + $this->assertEquals('192001-0001', $result); // counter must start to 1 $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); @@ -183,23 +183,23 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase $numbering=new mod_facture_mercure(); $result=$numbering->getNextValue($mysoc, $localobject); print __METHOD__." result=".$result."\n"; - $this->assertEquals('192101-0001', $result); // counter must be resete to 1 + $this->assertEquals('192101-0001', $result); // counter must be resete to 1 // Now we try with a different fiscal month (forced by mask) - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('193001-0001', $result); // counter must start to 1 - + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@6}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@6}'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1930); // we use year 1930 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('193001-0001', $result); // counter must start to 1 + $localobject=new Facture($this->savdb); $localobject->initAsSpecimen(); $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1930); // we use same year but fiscal month after @@ -220,188 +220,188 @@ class NumberingModulesTest extends PHPUnit_Framework_TestCase print __METHOD__." result=".$result."\n"; $this->assertEquals('193101-0002', $result); // counter must be 2 - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different discal year but same year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1931); // we use different discal year but same year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; $this->assertEquals('193112-0001', $result); // counter must be reset to 1 - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) - $conf->global->SOCIETE_FISCAL_MONTH_START=6; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) + $conf->global->SOCIETE_FISCAL_MONTH_START=6; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@0}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@0}'; - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('194001-0001', $result); // counter must start to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('194012-0001', $result); // counter must be reset to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('194101-0002', $result); // counter must be 2 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('194112-0001', $result); // counter must be reset to 1 + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1940); // we use year 1940 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('194001-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1940); // we use same year but fiscal month after + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('194012-0001', $result); // counter must be reset to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1941); // we use same fiscal year but different year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('194101-0002', $result); // counter must be 2 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1941); // we use different discal year but same year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('194112-0001', $result); // counter must be reset to 1 // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want year of element - $conf->global->SOCIETE_FISCAL_MONTH_START=6; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('195001-0001', $result); // counter must start to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('195012-0001', $result); // counter must be reset to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('195101-0002', $result); // counter must be 2 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; + $conf->global->SOCIETE_FISCAL_MONTH_START=6; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@=}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@=}'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1950); // we use year 1950 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('195001-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1950); // we use same year but fiscal month after + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('195012-0001', $result); // counter must be reset to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1951); // we use same fiscal year but different year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('195101-0002', $result); // counter must be 2 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1951); // we use different discal year but same year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; $this->assertEquals('195112-0001', $result); // counter must be reset to 1 // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want start year - $conf->global->SOCIETE_FISCAL_MONTH_START=6; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('195901-0001', $result); // counter must start to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('196012-0001', $result); // counter must be reset to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('196001-0002', $result); // counter must be 2 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; + $conf->global->SOCIETE_FISCAL_MONTH_START=6; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@-}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@-}'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1960); // we use year 1960 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('195901-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1960); // we use same year but fiscal month after + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('196012-0001', $result); // counter must be reset to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1961); // we use same fiscal year but different year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('196001-0002', $result); // counter must be 2 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1961); // we use different discal year but same year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; $this->assertEquals('196112-0001', $result); // counter must be reset to 1 - // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year - $conf->global->SOCIETE_FISCAL_MONTH_START=6; - $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; - $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('197001-0001', $result); // counter must start to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('197112-0001', $result); // counter must be reset to 1 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - $result2=$localobject->create($user,1); - $result3=$localobject->validate($user, $result); - print __METHOD__." result=".$result."\n"; - $this->assertEquals('197101-0002', $result); // counter must be 2 - - $localobject=new Facture($this->savdb); - $localobject->initAsSpecimen(); - $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different discal year but same year - $numbering=new mod_facture_mercure(); - $result=$numbering->getNextValue($mysoc, $localobject); - print __METHOD__." result=".$result."\n"; + // Now we try with a different fiscal month (defined by SOCIETE_FISCAL_MONTH_START) and we always want end year + $conf->global->SOCIETE_FISCAL_MONTH_START=6; + $conf->global->FACTURE_MERCURE_MASK_CREDIT='{yyyy}{mm}-{0000@+}'; + $conf->global->FACTURE_MERCURE_MASK_INVOICE='{yyyy}{mm}-{0000@+}'; + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1970); // we use year 1970 to be sure to not have existing invoice for this year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('197001-0001', $result); // counter must start to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1970); // we use same year but fiscal month after + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('197112-0001', $result); // counter must be reset to 1 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 1, 1, 1971); // we use same fiscal year but different year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + $result2=$localobject->create($user,1); + $result3=$localobject->validate($user, $result); + print __METHOD__." result=".$result."\n"; + $this->assertEquals('197101-0002', $result); // counter must be 2 + + $localobject=new Facture($this->savdb); + $localobject->initAsSpecimen(); + $localobject->date=dol_mktime(12, 0, 0, 12, 1, 1971); // we use different discal year but same year + $numbering=new mod_facture_mercure(); + $result=$numbering->getNextValue($mysoc, $localobject); + print __METHOD__." result=".$result."\n"; $this->assertEquals('197212-0001', $result); // counter must be reset to 1 return $result; diff --git a/test/phpunit/PricesTest.php b/test/phpunit/PricesTest.php index c89901fb990..ecea4b517e1 100755 --- a/test/phpunit/PricesTest.php +++ b/test/phpunit/PricesTest.php @@ -130,8 +130,8 @@ class PricesTest extends PHPUnit_Framework_TestCase $this->savlangs=$langs; $this->savdb=$db; - global $mysoc; - $mysoc=new Societe($db); + global $mysoc; + $mysoc=new Societe($db); // qty=1, unit_price=1.24, discount_line=0, vat_rate=10, price_base_type='HT' $mysoc->country_code='FR'; @@ -139,7 +139,7 @@ class PricesTest extends PHPUnit_Framework_TestCase $result1=calcul_price_total(1, 1.24, 0, 10, 0, 0, 0, 'HT', 0, 0); print __METHOD__." result1=".join(', ',$result1)."\n"; // result[0,1,2,3,4,5,6,7,8] (total_ht, total_vat, total_ttc, pu_ht, pu_tva, pu_ttc, total_ht_without_discount, total_vat_without_discount, total_ttc_without_discount) - $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1'); + $this->assertEquals(array(1.24, 0.12, 1.36, 1.24, 0.124, 1.364, 1.24, 0.12, 1.36, 0, 0, 0, 0, 0, 0, 0),$result1,'Test1'); // 10 * 10 HT - 0% discount with 10% vat and 1.4% localtax1 type 1, 0% localtax2 type 0 (method we provide value) $mysoc->country_code='ES';