Merge remote-tracking branch 'origin/3.5' into develop

Conflicts:
	htdocs/projet/index.php
	test/phpunit/FunctionsTest.php
This commit is contained in:
Laurent Destailleur
2014-03-13 09:20:05 +01:00
20 changed files with 286 additions and 72 deletions

View File

@@ -91,11 +91,11 @@ Fix: Enable extrafields for customer order, proposal and invoice lines. This fea
Fix: user right on Holiday for month report nor working.
Fix: [ bug #1250 ] "Supplier Ref. product" sidebar search box does not work
Fix: Bad space in predefined messages.
Fix: Signature was not added for email sent from thirdparty page.
Fix: [ bug #1256 ] Signature was not added for email sent from thirdparty page.
Fix: Action event SHIPPING_VALIDATE is not implemented
Fix: The customer code was set to uppercase when using numbering module leopard. We
must keep data safe of any change.
Fix: Loading actions extrafields fails.
Fix: [ bug #1291 ] Loading actions extrafields fails.
Fix: [ bug #1123 ] Paid deposit invoices are always shown as partially paid when fully paid
Fix: Corrected project contact types translation.
Fix: [ bug #1206 ] PMP price is bad calculated.
@@ -103,6 +103,7 @@ Fix: [ bug #520 ] Product statistics and detailed lists are wrong.
Fix: [ bug #1240 ] traduction.
Fix: [ bug #1238 ] When creating accompte with a %, free product are used for calculation.
Fix: [ bug #1280 ] service with not end of date was tagged as expired.
Fix: [ bug #1295 ] Error when creating an agenda extrafield with a number as reference
***** ChangeLog for 3.5 compared to 3.4.* *****
For users:

View File

@@ -261,7 +261,7 @@ if ($object->id > 0)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}
$db->close();

View File

@@ -137,7 +137,7 @@ if ($object->id > 0)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}
llxFooter();

View File

@@ -128,7 +128,7 @@ if ($object->id)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}
llxFooter();

View File

@@ -160,7 +160,7 @@ if ($id > 0 || ! empty($ref))
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}
$db->close();

View File

@@ -167,7 +167,7 @@ if ($object->id)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}

View File

@@ -130,7 +130,7 @@ if ($object->id)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}

View File

@@ -957,7 +957,7 @@ class DoliDBMysql extends DoliDB
{
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql= "ALTER TABLE ".$table." ADD `".$field_name."` ";
$sql.= $field_desc['type'];
if(preg_match("/^[^\s]/i",$field_desc['value']))
if (! in_array($field_desc['type'],array('date','datetime')))

View File

@@ -960,7 +960,7 @@ class DoliDBMysqli extends DoliDB
{
// cles recherchees dans le tableau des descriptions (field_desc) : type,value,attribute,null,default,extra
// ex. : $field_desc = array('type'=>'int','value'=>'11','null'=>'not null','extra'=> 'auto_increment');
$sql= "ALTER TABLE ".$table." ADD ".$field_name." ";
$sql= "ALTER TABLE ".$table." ADD `".$field_name."` ";
$sql.= $field_desc['type'];
if(preg_match("/^[^\s]/i",$field_desc['value']))
if (! in_array($field_desc['type'],array('date','datetime')))

View File

@@ -390,7 +390,7 @@ function ajax_constantonoff($code, $input=array(), $entity=null, $revertonoff=0)
$out= "\n<!-- Ajax code to switch constant ".$code." -->".'
<script type="text/javascript">
$(function() {
$(document).ready(function() {
var input = '.json_encode($input).';
var url = \''.DOL_URL_ROOT.'/core/ajax/constantonoff.php\';
var code = \''.$code.'\';

View File

@@ -128,7 +128,7 @@ if ($object->id)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}
llxFooter();

View File

@@ -183,7 +183,7 @@ if ($object->id > 0)
}
else
{
print $langs->trans('UnkownError');
print $langs->trans('ErrorUnknown');
}

View File

@@ -34,7 +34,7 @@ ErrorFailedToOpenFile=Failed to open file %s
ErrorCanNotCreateDir=Can not create dir %s
ErrorCanNotReadDir=Can not read dir %s
ErrorConstantNotDefined=Parameter %s not defined
ErrorUnknown=Unkown error
ErrorUnknown=Unknown error
ErrorSQL=SQL Error
ErrorLogoFileNotFound=Logo file '%s' was not found
ErrorGoToGlobalSetup=Go to 'Company/Foundation' setup to fix this

View File

@@ -147,7 +147,7 @@ if ($object->id)
}
else
{
print $langs->trans("UnkownError");
print $langs->trans("ErrorUnknown");
}

View File

@@ -26,6 +26,7 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
$langs->load("projects");
@@ -81,7 +82,7 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print_liste_field_titre($langs->trans("ThirdParties"),"index.php","s.nom","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("ThirdParties"),$_SERVER["PHP_SELF"],"s.nom","","","",$sortfield,$sortorder);
print_liste_field_titre($langs->trans("NbOfProjects"),"","","","",'align="right"',$sortfield,$sortorder);
print "</tr>\n";
@@ -132,25 +133,14 @@ else
}
print "</table>";
print '</td></tr></table>';
print '</div></div></div>';
// Tasks for all resources of all opened projects and time spent for each task/resource
print '<div class="fichecenter">';
print '<BR>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
print '<th>'.$langs->trans('Projects').'</th>';
print '<th>'.$langs->trans('Task').'</th>';
print '<th>'.$langs->trans('DateStart').'</th>';
print '<th>'.$langs->trans('DateEnd').'</th>';
print '<th>'.$langs->trans('WorkloadOccupation').'</th>';
print '</tr>';
$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, tasktime.task_duration";
$sql = "SELECT p.title, p.rowid as projectid, t.label, t.rowid as taskid, u.rowid as userid, t.planned_workload, t.dateo, t.datee, SUM(tasktime.task_duration) as timespent";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe as s on p.fk_soc = s.rowid";
$sql.= " INNER JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
@@ -160,6 +150,7 @@ $sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || ! $user->rights->projet->all->lire) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid) $sql.= " AND (p.fk_soc IS NULL OR p.fk_soc = 0 OR p.fk_soc = ".$socid.")";
$sql.= " AND p.fk_statut=1";
$sql.= " GROUP BY p.title, p.rowid, t.label, t.rowid, u.rowid, t.planned_workload, t.dateo, t.datee";
$sql.= " ORDER BY u.rowid, t.dateo, t.datee";
$userstatic=new User($db);
@@ -171,32 +162,66 @@ if ( $resql )
$num = $db->num_rows($resql);
$i = 0;
while ($i < $num)
if ($num > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
{
$obj = $db->fetch_object($resql);
$var=!$var;
/* print '<tr '.$bc[0].'>';
print '<td colspan="9">';
print $langs->trans("TooManyDataPleaseUseMoreFilters");
print '</td></tr>';*/
}
else
{
print '<br>';
$username='';
$userstatic->fetch($obj->userid);
if (!empty($userstatic->id)) {
$username = $userstatic->getNomUrl(0,0);
print_fiche_titre($langs->trans("TimeSpent"),'','').'<br>';
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<th>'.$langs->trans('TaskRessourceLinks').'</th>';
print '<th>'.$langs->trans('Projects').'</th>';
print '<th>'.$langs->trans('Task').'</th>';
print '<th>'.$langs->trans('DateStart').'</th>';
print '<th>'.$langs->trans('DateEnd').'</th>';
print '<th>'.$langs->trans('TimeSpent').'</th>';
print '</tr>';
while ($i < $num)
{
$obj = $db->fetch_object($resql);
$var=!$var;
$username='';
if ($obj->userid && $userstatic->id != $obj->userid) // We have a user and it is not last loaded user
{
$result=$userstatic->fetch($obj->userid);
if (! $result) $userstatic->id=0;
}
if ($userstatic->id) $username = $userstatic->getNomUrl(0,0);
print "<tr ".$bc[$var].">";
print '<td>'.$username.'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
/* I disable this because information is wrong. This percent has no meaning for a particular resource. What do we want ?
* Percent of completion ?
* If we want to show completion, we must remove "user" into list,
if (empty($obj->planned_workload)) {
$percentcompletion = $langs->trans("Unknown");
} else {
$percentcompletion = intval($obj->task_duration*100/$obj->planned_workload);
}*/
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">';
//print $percentcompletion.' %';
print convertSecondToTime($obj->timespent, 'all');
print '</a></td>';
print "</tr>\n";
$i++;
}
print "<tr ".$bc[$var].">";
print '<td>'.$username.'</td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/fiche.php?id='.$obj->projectid.'">'.$obj->title.'</a></td>';
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/task.php?id='.$obj->taskid.'&withproject=1">'.$obj->label.'</a></td>';
print '<td>'.dol_print_date($db->jdate($obj->dateo)).'</td>';
print '<td>'.dol_print_date($db->jdate($obj->datee)).'</td>';
if (empty($obj->planned_workload)) {
$percentcompletion = '0';
} else {
$percentcompletion = intval(($obj->task_duration*100)/$obj->planned_workload);
}
print '<td><a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$obj->taskid.'&withproject=1">'.$percentcompletion.' %</a></td>';
print "</tr>\n";
$i++;
print "</table>";
}
$db->free($resql);
@@ -205,12 +230,12 @@ else
{
dol_print_error($db);
}
print "</table></div>";
print '</div>';
llxFooter();
$db->close();
?>
?>

View File

@@ -178,9 +178,10 @@ class UserGroup extends CommonObject
* Return array of users id for group this->id (or all if this->id not defined)
*
* @param string $excludefilter Filter to exclude
* @param int $mode 0=Return array of user instance, 1=Return array of users id only
* @return array Array of users
*/
function listUsersForGroup($excludefilter='')
function listUsersForGroup($excludefilter='', $mode=0)
{
global $conf, $user;
@@ -211,11 +212,15 @@ class UserGroup extends CommonObject
{
if (! array_key_exists($obj->rowid, $ret))
{
$newuser=new User($this->db);
$newuser->fetch($obj->rowid);
$ret[$obj->rowid]=$newuser;
if ($mode != 1)
{
$newuser=new User($this->db);
$newuser->fetch($obj->rowid);
$ret[$obj->rowid]=$newuser;
}
else $ret[$obj->rowid]=$obj->rowid;
}
if (! empty($obj->usergroup_entity))
if ($mode != 1 && ! empty($obj->usergroup_entity))
{
$ret[$obj->rowid]->usergroup_entity[]=$obj->usergroup_entity;
}
@@ -744,4 +749,4 @@ class UserGroup extends CommonObject
}
}
?>
?>

View File

@@ -76,13 +76,16 @@ class AllTests
$suite->addTestSuite('JsonLibTest');
require_once dirname(__FILE__).'/ImagesLibTest.php';
$suite->addTestSuite('ImagesLibTest');
require_once dirname(__FILE__).'/FunctionsTest.php';
$suite->addTestSuite('FunctionsTest');
require_once dirname(__FILE__).'/Functions2Test.php';
$suite->addTestSuite('Functions2Test');
require_once dirname(__FILE__).'/FunctionsLibTest.php';
$suite->addTestSuite('FunctionsLibTest');
require_once dirname(__FILE__).'/Functions2LibTest.php';
$suite->addTestSuite('Functions2LibTest');
require_once dirname(__FILE__).'/XCalLibTest.php';
$suite->addTestSuite('XCalLibTest');
require_once dirname(__FILE__).'/LangTest.php';
$suite->addTestSuite('LangTest');
require_once dirname(__FILE__).'/SecurityTest.php';
$suite->addTestSuite('SecurityTest');
@@ -168,6 +171,9 @@ class AllTests
require_once dirname(__FILE__).'/ScriptsTest.php';
$suite->addTestSuite('ScriptsTest');
require_once dirname(__FILE__).'/FormAdminTest.php';
$suite->addTestSuite('FormAdminTest');
require_once dirname(__FILE__).'/ModulesTest.php'; // At end because it's the longer
$suite->addTestSuite('ModulesTest');

View File

@@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/FunctionsTest.php
* \file test/phpunit/Functions2LibTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
@@ -48,7 +48,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class Functions2Test extends PHPUnit_Framework_TestCase
class Functions2LibTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
@@ -128,20 +128,20 @@ class Functions2Test extends PHPUnit_Framework_TestCase
print __METHOD__." result=".$result."\n";
$this->assertEquals('νεο',$result);
}
/**
* isValidMailDomain
*
*
* @return void
*/
public function testIsValidMailDomain()
{
}
/**
* isValidURL
*
*
* @return void
*/
public function testIsValidUrl()

View File

@@ -1,5 +1,5 @@
<?php
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010-2014 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
@@ -17,7 +17,7 @@
*/
/**
* \file test/phpunit/FunctionsTest.php
* \file test/phpunit/FunctionsLibTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
@@ -48,7 +48,7 @@ if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class FunctionsTest extends PHPUnit_Framework_TestCase
class FunctionsLibTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;

177
test/phpunit/LangTest.php Executable file
View File

@@ -0,0 +1,177 @@
<?php
/* Copyright (C) 2013 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 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/>.
* or see http://www.gnu.org/
*/
/**
* \file test/phpunit/LangTest.php
* \ingroup test
* \brief PHPUnit test
* \remarks To run this script as CLI: phpunit filename.php
*/
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/core/lib/security.lib.php';
require_once dirname(__FILE__).'/../../htdocs/core/lib/security2.lib.php';
if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1');
if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1');
if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show
if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
if (empty($user->id))
{
print "Load permissions for admin user nb 1\n";
$user->fetch(1);
$user->getrights();
}
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
/**
* Class for PHPUnit tests
*
* @backupGlobals disabled
* @backupStaticAttributes enabled
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
*/
class LangTest extends PHPUnit_Framework_TestCase
{
protected $savconf;
protected $savuser;
protected $savlangs;
protected $savdb;
/**
* Constructor
* We save global variables into local variables
*
* @return SecurityTest
*/
function __construct()
{
//$this->sharedFixture
global $conf,$user,$langs,$db;
$this->savconf=$conf;
$this->savuser=$user;
$this->savlangs=$langs;
$this->savdb=$db;
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
//print " - db ".$db->db;
print "\n";
}
// Static methods
public static function setUpBeforeClass()
{
global $conf,$user,$langs,$db;
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
print __METHOD__."\n";
}
public static function tearDownAfterClass()
{
global $conf,$user,$langs,$db;
$db->rollback();
print __METHOD__."\n";
}
/**
* Init phpunit tests
*
* @return void
*/
protected function setUp()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
print __METHOD__."\n";
}
/**
* End phpunit tests
*
* @return void
*/
protected function tearDown()
{
print __METHOD__."\n";
}
/**
* testBank
*
* @return string
*/
public function testLang()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php';
$filesarray = scandir(DOL_DOCUMENT_ROOT.'/langs');
foreach($filesarray as $key => $code)
{
if (! preg_match('/^[a-z]+_[A-Z]+$/',$code)) continue;
print 'Check language file for code='.$code."\n";
$tmplangs=new Translate('',$conf);
$langcode=$code;
$tmplangs->setDefaultLang($langcode);
$tmplangs->load("main");
$result=$tmplangs->trans("SeparatorDecimal");
print __METHOD__." SeparatorDecimal=".$result."\n";
$this->assertContains($result,array('.',',','/',' ','','None'));
$result=$tmplangs->trans("SeparatorThousand");
print __METHOD__." SeparatorThousand=".$result."\n";
$this->assertContains($result,array('.',',','/',' ','','None','SeparatorThousand')); // SeparatorThousand is returned when SeparatorThousand=Space
// Test java string contains only d,M,y,/,-,. and not m,...
$result=$tmplangs->trans("FormatDateShortJava");
print __METHOD__." FormatDateShortJava=".$result."\n";
$this->assertRegExp('/^[dMy\/\-\.]+$/',$result);
$result=$tmplangs->trans("FormatDateShortJavaInput");
print __METHOD__." FormatDateShortJavaInput=".$result."\n";
$this->assertRegExp('/^[dMy\/\-\.]+$/',$result);
unset($tmplangs);
}
return $result;
}
}
?>