Fix: CRLF

This commit is contained in:
Laurent Destailleur 2013-01-16 15:54:07 +01:00
parent d11cee399a
commit f1f7ff315f
22 changed files with 603 additions and 603 deletions

View File

@ -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");

View File

@ -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 '</table>'."\n";
print '</table>'."\n";
}

View File

@ -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 '<tr '.$bc[$var].'>';
print '<td>'.img_object("",$logo).' '.$langs->transnoentitiesnoconv($box->boxlabel).'</td>';
print '<td>';
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:'&nbsp;');
print '</td>';

View File

@ -52,8 +52,8 @@ print info_admin($langs->trans("SystemAreaForAdminOnly")).'<br>';
print '<br><br>';
// Show logo
print '<center><div class="logo_setup"></div></center>';
// Show logo
print '<center><div class="logo_setup"></div></center>';
llxFooter();
$db->close();

View File

@ -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();

View File

@ -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();

View File

@ -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();

View File

@ -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 '<table width="100%" class="notopnoleftnoright">';
print '<tr><td class="notopnoleftnoright">'."\n";

View File

@ -1,30 +1,30 @@
#!/usr/bin/php
<?php
/*
* Copyright (C) 2009-2012 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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 <eldy@users.sourceforge.net>
*
* 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 <http://www.gnu.org/licenses/>.
*/
/**
* \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

View File

@ -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;
/**

View File

@ -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 '<div class="blockvmenuimpair">'."\n";
}
else
{
print '<div class="blockvmenupair">'."\n";
}
}
// Place tabulation
$tabstring='';
$tabul=($this->menu_array[$i]['level'] - 1);
if ($tabul > 0)
{
for ($j=0; $j < $tabul; $j++)
{
$tabstring.='&nbsp; &nbsp;';
}
}
if ($this->menu_array[$i]['level'] == 0) {
if ($this->menu_array[$i]['enabled'])
{
print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'"'.($this->menu_array[$i]['target']?' target="'.$this->menu_array[$i]['target'].'"':'').'>'.$this->menu_array[$i]['titre'].'</a></div>'."\n";
}
else
{
print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu_array[$i]['titre'].'</font></div>'."\n";
}
print '<div class="menu_top"></div>'."\n";
}
if ($this->menu_array[$i]['level'] > 0) {
print '<div class="menu_contenu">';
if ($this->menu_array[$i]['enabled'])
print $tabstring.'<a class="vsmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'">'.$this->menu_array[$i]['titre'].'</a><br>';
else
print $tabstring.'<font class="vsmenudisabled">'.$this->menu_array[$i]['titre'].'</font><br>';
print '</div>'."\n";
}
// If next is a new block or end
if (empty($this->menu_array[$i+1]['level']))
{
print '<div class="menu_end"></div>'."\n";
print "</div>\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 '<div class="blockvmenuimpair">'."\n";
}
else
{
print '<div class="blockvmenupair">'."\n";
}
}
// Place tabulation
$tabstring='';
$tabul=($this->menu_array[$i]['level'] - 1);
if ($tabul > 0)
{
for ($j=0; $j < $tabul; $j++)
{
$tabstring.='&nbsp; &nbsp;';
}
}
if ($this->menu_array[$i]['level'] == 0) {
if ($this->menu_array[$i]['enabled'])
{
print '<div class="menu_titre">'.$tabstring.'<a class="vmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'"'.($this->menu_array[$i]['target']?' target="'.$this->menu_array[$i]['target'].'"':'').'>'.$this->menu_array[$i]['titre'].'</a></div>'."\n";
}
else
{
print '<div class="menu_titre">'.$tabstring.'<font class="vmenudisabled">'.$this->menu_array[$i]['titre'].'</font></div>'."\n";
}
print '<div class="menu_top"></div>'."\n";
}
if ($this->menu_array[$i]['level'] > 0) {
print '<div class="menu_contenu">';
if ($this->menu_array[$i]['enabled'])
print $tabstring.'<a class="vsmenu" href="'.dol_buildpath($this->menu_array[$i]['url'],1).'">'.$this->menu_array[$i]['titre'].'</a><br>';
else
print $tabstring.'<font class="vsmenudisabled">'.$this->menu_array[$i]['titre'].'</font><br>';
print '</div>'."\n";
}
// If next is a new block or end
if (empty($this->menu_array[$i+1]['level']))
{
print '<div class="menu_end"></div>'."\n";
print "</div>\n";
}
}
}
}

View File

@ -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();

View File

@ -1,26 +1,26 @@
-- ========================================================================
-- Copyright (C) 2011 Philippe GRAND <philippe.grand@atoo-net.com>
--
-- 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 <http://www.gnu.org/licenses/>.
--
-- ========================================================================
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 <philippe.grand@atoo-net.com>
--
-- 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 <http://www.gnu.org/licenses/>.
--
-- ========================================================================
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;

View File

@ -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

View File

@ -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

View File

@ -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]))

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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';