Merge remote-tracking branch 'upstream/develop' into develop

This commit is contained in:
Marcos García de La Fuente
2015-03-15 17:52:07 +01:00
198 changed files with 13982 additions and 1942 deletions

View File

@@ -0,0 +1,122 @@
<?php
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@capnetworks.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/>.
* or see http://www.gnu.org/
*/
/**
* \file htdocs/core/lib/propal.lib.php
* \brief Ensemble de fonctions de base pour le module propal
* \ingroup propal
*/
/**
* Prepare array with list of tabs
*
* @param object $object Object related to tabs
* @return array Array of tabs to show
*/
function askpricesupplier_prepare_head($object)
{
global $langs, $conf, $user;
$langs->load("askpricesupplier");
$langs->load("compta");
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/card.php?id='.$object->id;
$head[$h][1] = $langs->trans('AskPriceSupplierCard');
$head[$h][2] = 'comm';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname); to remove a tab
complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier');
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
{
$nbNote = 0;
if(!empty($object->note_private)) $nbNote++;
if(!empty($object->note_public)) $nbNote++;
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/note.php?id='.$object->id;
$head[$h][1] = $langs->trans('Notes');
if ($nbNote > 0) $head[$h][1].= ' <span class="badge">'.$nbNote.'</span>';
$head[$h][2] = 'note';
$h++;
}
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
$upload_dir = $conf->askpricesupplier->dir_output . "/" . dol_sanitizeFileName($object->ref);
$nbFiles = count(dol_dir_list($upload_dir,'files',0,'','(\.meta|_preview\.png)$'));
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/document.php?id='.$object->id;
$head[$h][1] = $langs->trans('Documents');
if($nbFiles > 0) $head[$h][1].= ' <span class="badge">'.$nbFiles.'</span>';
$head[$h][2] = 'document';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/askpricesupplier/info.php?id='.$object->id;
$head[$h][1] = $langs->trans('Info');
$head[$h][2] = 'info';
$h++;
complete_head_from_modules($conf,$langs,$object,$head,$h,'askpricesupplier','remove');
return $head;
}
/**
* Return array head with list of tabs to view object informations.
*
* @return array head array with tabs
*/
function askpricesupplier_admin_prepare_head()
{
global $langs, $conf, $user;
$h = 0;
$head = array();
$head[$h][0] = DOL_URL_ROOT.'/admin/askpricesupplier.php';
$head[$h][1] = $langs->trans("Miscellaneous");
$head[$h][2] = 'general';
$h++;
// Show more tabs from modules
// Entries must be declared in modules descriptor with line
// $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab
// $this->tabs = array('entity:-tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to remove a tab
complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin');
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplier_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFields");
$head[$h][2] = 'attributes';
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/admin/askpricesupplierdet_extrafields.php';
$head[$h][1] = $langs->trans("ExtraFieldsLines");
$head[$h][2] = 'attributeslines';
$h++;
complete_head_from_modules($conf,$langs,null,$head,$h,'askpricesupplier_admin','remove');
return $head;
}

View File

@@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2006-2007 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2015 Alexandre Spangaro <alexandre.spangaro@gmail.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
@@ -20,8 +20,8 @@
/**
* \file htdocs/core/lib/bank.lib.php
* \ingroup bank
* \brief Ensemble de fonctions de base pour le module banque
* \ingroup banque
*/
/**
@@ -41,13 +41,6 @@ function bank_prepare_head(Account $object)
$head[$h][2] = 'bankname';
$h++;
if ($object->type == 0 || $object->type == 1) {
$head[$h][0] = DOL_URL_ROOT . '/compta/bank/bankid_fr.php?id=' . $object->id;
$head[$h][1] = $langs->trans("RIB");
$head[$h][2] = 'bankid';
$h++;
}
$head[$h][0] = DOL_URL_ROOT . "/compta/bank/account.php?id=" . $object->id;
$head[$h][1] = $langs->trans("Transactions");
$head[$h][2] = 'journal';

View File

@@ -4944,34 +4944,64 @@ function dol_getmypid()
/**
* Natural search
* Generate natural SQL search string
*
* @param mixed $fields String or array of strings filled with the fields names in the SQL query
* @param string $value The value to look for (example: "keyword1 keyword2")
* @return string $res The statement to append to the SQL query
* @param string|string[] $fields String or array of strings, filled with the name of fields in the SQL query
* @param string $value The value to look for.
* If param $numeric is 0, can contains several keywords separated with a space, like "keyword1 keyword2" = We want record field like keyword1 and field like keyword2
* If param $numeric is 1, can contains an operator <>= like "<10" or ">=100.5 < 1000"
* @param string $number 0=value is list of keywords, 1=value is a numeric test
* @return string $res The statement to append to the SQL query
*/
function natural_search($fields, $value)
function natural_search($fields, $value, $numeric=0)
{
global $db;
global $db,$langs;
if ($numeric)
{
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
}
$crits = explode(' ', $value);
$res = '';
if (! is_array($fields)) $fields = array($fields);
$end = count($fields);
$nboffields = count($fields);
$end2 = count($crits);
$j = 0;
foreach ($crits as $crit) {
$i = 0;
foreach ($fields as $field) {
if ( $i > 0 && $i < $end) $res .= " OR ";
$res .= $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
foreach ($crits as $crit)
{
$i = 0; $i2 = 0;
$newres = '';
foreach ($fields as $field)
{
if ($numeric)
{
$operator='=';
$newcrit = preg_replace('/([<>=]+)/','',trim($crit));
preg_match('/([<>=]+)/',trim($crit), $reg);
if ($reg[1])
{
$operator = $reg[1];
}
if ($newcrit != '')
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . ' '.$operator.' '.price2num($newcrit);
$i2++; // a criteria was added to string
}
}
else
{
$newres .= ($i2 > 0 ? ' OR ' : '') . $field . " LIKE '%" . $db->escape(trim($crit)) . "%'";
$i2++; // a criteria was added to string
}
$i++;
}
if ($end > 1) $res .= ')';
if ($j < $end2 - 1) $res .= " AND ";
if ($end > 1 && $j < $end2 - 1) $res .= '(';
if ($newres) $res = $res . ($res ? ' AND ' : '') . ($i2 > 1 ? '(' : '') .$newres . ($i2 > 1 ? ')' : '');
$j++;
}
return " AND " . ($end > 1? '(' : '') . $res;
$res = " AND (" . $res . ")";
//print 'xx'.$res.'yy';
return $res;
}

View File

@@ -1549,6 +1549,9 @@ function dolGetElementUrl($objectid,$objecttype,$withpicto=0,$option='')
if ($objecttype == 'propal') {
$classpath = 'comm/propal/class';
}
if ($objecttype == 'askpricesupplier') {
$classpath = 'comm/askpricesupplier/class';
}
if ($objecttype == 'shipping') {
$classpath = 'expedition/class';
$subelement = 'expedition';
@@ -1780,6 +1783,9 @@ function getElementProperties($element_type)
if ($element_type == 'propal') {
$classpath = 'comm/propal/class';
}
if ($element_type == 'askpricesupplier') {
$classpath = 'comm/askpricesupplier/class';
}
if ($element_type == 'shipping') {
$classpath = 'expedition/class';
$subelement = 'expedition';

View File

@@ -269,7 +269,7 @@ function dol_json_decode($json, $assoc=false)
/**
* Return text according to type
*
* @param mixed $val Value to decode
* @param string $val Value to decode
* @return string Formated value
*/
function _unval($val)

View File

@@ -615,12 +615,12 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$pdf->SetXY($curx, $cury);
$pdf->MultiCell(100, 3, $outputlangs->transnoentities("BankAccountNumber").': ' . $outputlangs->convToOutputCharset($account->number), 0, 'L', 0);
$cury+=3;
if ($diffsizecontent <= 2) $cury+=1;
}
$pdf->SetFont('','',$default_font_size - $diffsizecontent);
if (empty($onlynumber) && ! empty($account->domiciliation))
{
$pdf->SetXY($curx, $cury);
@@ -631,8 +631,18 @@ function pdf_bank(&$pdf,$outputlangs,$curx,$cury,$account,$onlynumber=0,$default
$tmpy=$pdf->getStringHeight(100, $val);
$cury+=$tmpy;
}
if (! empty($account->proprio))
{
$pdf->SetXY($curx, $cury);
$val=$outputlangs->transnoentities("BankAccountOwner").': ' . $outputlangs->convToOutputCharset($account->proprio);
$pdf->MultiCell(100, 3, $val, 0, 'L', 0);
$tmpy=$pdf->getStringHeight(100, $val);
$cury+=$tmpy;
}
else if (! $usedetailedbban) $cury+=1;
// Use correct name of bank id according to country
$ibankey="IBANNumber";
if ($account->getCountryCode() == 'IN') $ibankey="IFSC";

View File

@@ -177,15 +177,21 @@ function project_timesheet_prepare_head($mode)
$h = 0;
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERDAY))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/perday.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerDay");
$head[$h][2] = 'inputperday';
$h++;
}
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerTime");
$head[$h][2] = 'inputpertime';
$h++;
if (empty($conf->global->PROJECT_DISABLE_TIMESHEET_PERTIME))
{
$head[$h][0] = DOL_URL_ROOT."/projet/activity/pertime.php".($mode?'?mode='.$mode:'');
$head[$h][1] = $langs->trans("InputPerTime");
$head[$h][2] = 'inputpertime';
$h++;
}
complete_head_from_modules($conf,$langs,null,$head,$h,'project_timesheet');
@@ -234,10 +240,10 @@ function project_admin_prepare_head()
/**
* Show task lines with a particular parent
*
* @param string $inc Counter that count number of lines legitimate to show (for return)
* @param int $parent Id of parent task to start
* @param array $lines Array of all tasks
* @param int $level Level of task
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $var Color
* @param int $showproject Show project columns
* @param int $taskrole Array of roles of user for each tasks
@@ -482,12 +488,12 @@ function projectLinesa(&$inc, $parent, &$lines, &$level, $var, $showproject, &$t
/**
* Output a task line into a pertime intput mode
*
* @param string $inc ?
* @param string $parent ?
* @param Task[] $lines ?
* @param int $level ?
* @param string $projectsrole ?
* @param string $tasksrole ?
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $projectsrole Array of roles user has on project
* @param string $tasksrole Array of roles user has on task
* @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc
@@ -524,20 +530,22 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
// If we want all or we have a role on task, we show it
if (empty($mine) || ! empty($tasksrole[$lines[$i]->id]))
{
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
$projectstatic->id=$lines[$i]->fk_project;
$projectstatic->ref=$lines[$i]->projectref;
$projectstatic->public=$lines[$i]->public;
$projectstatic->label=$langs->transnoentitiesnoconv("YourRole").': '.$projectsrole[$lines[$i]->fk_project];
$taskstatic->id=$lines[$i]->id;
print "<tr ".$bc[$var].">\n";
// Project
print "<td>";
print $projectstatic->getNomUrl(1);
print "</td>";
// Ref
print '<td>';
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id);
print $taskstatic->getNomUrl(1);
print '</td>';
@@ -547,10 +555,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->label;
$taskstatic->date_start=$lines[$i]->date_start;
$taskstatic->date_end=$lines[$i]->date_end;
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
//print "<br>";
//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload
@@ -564,8 +574,9 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
print '</td>';
// Time spent
// Time spent by everybody
print '<td align="right">';
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
@@ -575,6 +586,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
else print '--:--';
print "</td>\n";
// Time spent by user
print '<td align="right">';
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
//var_dump($lines[$i]);
@@ -592,11 +610,13 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
}
// Form to add new time
print '<td class="nowrap" align="right">';
print '<td class="nowrap" align="center">';
$s='';
$s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask);
$s.='&nbsp;&nbsp;&nbsp;';
$s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1);
$s.=$form->select_date('',$lines[$i]->id,1,1,2,"addtime",1,0,1,$disabledtask);
print $s;
print '</td><td align="right">';
//$s.='&nbsp;&nbsp;&nbsp;';
$s=$form->select_duration($lines[$i]->id.'duration','',$disabledtask,'text',0,1);
$s.='&nbsp;<input type="submit" class="button"'.($disabledtask?' disabled="disabled"':'').' value="'.$langs->trans("Add").'">';
print $s;
print '</td>';
@@ -628,12 +648,12 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$
/**
* Output a task line into a perday intput mode
*
* @param string $inc ?
* @param string $parent ?
* @param Task[] $lines ?
* @param int $level ?
* @param string $projectsrole ?
* @param string $tasksrole ?
* @param string $inc Line number (start to 0, then increased by recursive call)
* @param string $parent Id of parent project to show (0 to show all)
* @param Task[] $lines Array of lines
* @param int $level Level (start to 0, then increased/decrease by recursive call)
* @param string $projectsrole Array of roles user has on project
* @param string $tasksrole Array of roles user has on task
* @param string $mine Show only task lines I am assigned to
* @param int $restricteditformytask 0=No restriction, 1=Enable add time only if task is a task i am affected to
* @return $inc
@@ -696,10 +716,12 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
$taskstatic->id=$lines[$i]->id;
$taskstatic->ref=$lines[$i]->label;
$taskstatic->date_start=$lines[$i]->date_start;
$taskstatic->date_end=$lines[$i]->date_end;
print $taskstatic->getNomUrl(0);
print "<br>";
for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
//print "<br>";
//for ($k = 0 ; $k < $level ; $k++) print "&nbsp;&nbsp;&nbsp;";
//print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0);
print "</td>\n";
// Planned Workload
@@ -713,9 +735,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
print $formother->select_percent($lines[$i]->progress, $lines[$i]->id . 'progress');
print '</td>';
// Time spent
/*
// Time spent by everybody
print '<td align="right">';
// $lines[$i]->duration is a denormalised field = summ of time spent by everybody for task. What we need is time consummed by user
if ($lines[$i]->duration)
{
print '<a href="'.DOL_URL_ROOT.'/projet/tasks/time.php?id='.$lines[$i]->id.'">';
@@ -724,7 +746,13 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
}
else print '--:--';
print "</td>\n";
*/
// Time spent by user
print '<td align="right">';
$tmptimespent=$taskstatic->getSummaryOfTimeSpent();
if ($tmptimespent['total_duration']) print convertSecondToTime($tmptimespent['total_duration'],'allhourmin');
else print '--:--';
print "</td>\n";
$disabledproject=1;$disabledtask=1;
//print "x".$lines[$i]->fk_project;
@@ -750,7 +778,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t
{
$dayWorkLoad = 0;
$tableCell ='<td align="center">';
$tableCell.='<input type="text" class="center" size="2" disabled="disabled" value="'.convertSecondToTime($dayWorkLoad,'allhourmin').'">+';
$tableCell.='<span class="timesheetalreadyrecorded"><input type="text" class="center" size="2" disabled="disabled" value="'.convertSecondToTime($dayWorkLoad,'allhourmin').'"></span>+';
$tableCell.='<input type="text" class="center" size="2" id="task['.$inc.']['.$idw.']" name="task['.$lines[$i]->id.']['.$idw.']" value="" cols="2" maxlength="5"';
$tableCell.=' onkeypress="return regexEvent(this,event,\'timeChar\')"';
$tableCell.= 'onblur="regexEvent(this,event,\''.$modeinput.'\');updateTotal('.$idw.',\''.$modeinput.'\')" />';
@@ -927,7 +955,8 @@ function print_projecttasks_array($db, $socid, $projectsListId, $mytasks=0, $sta
print "</table>";
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE)) {
if (!empty($conf->global->PROJECT_LIMIT_YEAR_RANGE))
{
//Add the year filter input
print '<table width="100%">';
print '<tr>';