Merge remote-tracking branch 'origin/3.8' into 3.9

Conflicts:
	htdocs/comm/prospect/list.php
	htdocs/commande/list.php
	htdocs/compta/facture/list.php
This commit is contained in:
Laurent Destailleur 2016-02-27 18:33:39 +01:00
commit 5453f99e2e
5 changed files with 142 additions and 76 deletions

View File

@ -9,6 +9,7 @@
* Copyright (C) 2015 Frederic France <frederic.france@free.fr>
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -46,8 +47,10 @@ $langs->load('bills');
$orderyear=GETPOST("orderyear","int");
$ordermonth=GETPOST("ordermonth","int");
$orderday=GETPOST("orderday","int");
$deliveryyear=GETPOST("deliveryyear","int");
$deliverymonth=GETPOST("deliverymonth","int");
$deliveryday=GETPOST("deliveryday","int");
$search_product_category=GETPOST('search_product_category','int');
$search_ref=GETPOST('search_ref','alpha')!=''?GETPOST('search_ref','alpha'):GETPOST('sref','alpha');
$search_ref_customer=GETPOST('search_ref_customer','alpha');
@ -91,7 +94,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_total_ht='';
$orderyear='';
$ordermonth='';
$deliverymonth='';
$orderday='';
$deliveryday='';
$deliverymonth='';
$deliveryyear='';
$viewstatut='';
$billed='';
@ -182,10 +187,10 @@ if ($viewstatut <> '')
}
if ($ordermonth > 0)
{
if ($orderyear > 0 && empty($day))
if ($orderyear > 0 && empty($orderday))
$sql.= " AND c.date_commande BETWEEN '".$db->idate(dol_get_first_day($orderyear,$ordermonth,false))."' AND '".$db->idate(dol_get_last_day($orderyear,$ordermonth,false))."'";
else if ($orderyear > 0 && ! empty($day))
$sql.= " AND c.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $ordermonth, $day, $orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $ordermonth, $day, $orderyear))."'";
else if ($orderyear > 0 && ! empty($orderday))
$sql.= " AND c.date_commande BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $ordermonth, $orderday, $orderyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $ordermonth, $orderday, $orderyear))."'";
else
$sql.= " AND date_format(c.date_commande, '%m') = '".$ordermonth."'";
}
@ -195,10 +200,10 @@ else if ($orderyear > 0)
}
if ($deliverymonth > 0)
{
if ($deliveryyear > 0 && empty($day))
if ($deliveryyear > 0 && empty($deliveryday))
$sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_get_first_day($deliveryyear,$deliverymonth,false))."' AND '".$db->idate(dol_get_last_day($deliveryyear,$deliverymonth,false))."'";
else if ($deliveryyear > 0 && ! empty($day))
$sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $deliverymonth, $day, $deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $deliverymonth, $day, $deliveryyear))."'";
else if ($deliveryyear > 0 && ! empty($deliveryday))
$sql.= " AND c.date_livraison BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $deliverymonth, $deliveryday, $deliveryyear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $deliverymonth, $deliveryday, $deliveryyear))."'";
else
$sql.= " AND date_format(c.date_livraison, '%m') = '".$deliverymonth."'";
}
@ -256,8 +261,10 @@ if ($resql)
$param='';
if ($socid > 0) $param.='&socid='.$socid;
if ($viewstatut != '') $param.='&viewstatut='.$viewstatut;
if ($orderday) $param.='&orderday='.$orderday;
if ($ordermonth) $param.='&ordermonth='.$ordermonth;
if ($orderyear) $param.='&orderyear='.$orderyear;
if ($deliveryday) $param.='&deliveryday='.$deliveryday;
if ($deliverymonth) $param.='&deliverymonth='.$deliverymonth;
if ($deliveryyear) $param.='&deliveryyear='.$deliveryyear;
if ($search_ref) $param.='&search_ref='.$search_ref;

View File

@ -10,7 +10,7 @@
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
* Copyright (C) 2013 Cédric Salvador <csalvador@gpcsolutions.fr>
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -413,7 +413,6 @@ if (empty($reshook))
// Do we click on purge search criteria ?
if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both test are required to be compatible with all browsers
{
$search_categ='';
$search_user='';
$search_sale='';
$search_product_category='';
@ -430,6 +429,9 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$toselect='';
$option='';
$filter='';
$day_lim='';
$year_lim='';
$month_lim='';
}
@ -565,13 +567,18 @@ if ($resql)
}
$param='&socid='.$socid;
if ($day) $param.='&day='.$day;
if ($month) $param.='&month='.$month;
if ($year) $param.='&year=' .$year;
if ($day_lim) $param.='&day_lim='.$day_lim;
if ($month_lim) $param.='&month_lim='.$month_lim;
if ($year_lim) $param.='&year_lim=' .$year_lim;
if ($search_ref) $param.='&search_ref=' .$search_ref;
if ($search_refcustomer) $param.='&search_refcustomer=' .$search_refcustomer;
if ($search_societe) $param.='&search_societe=' .$search_societe;
if ($search_sale > 0) $param.='&search_sale=' .$search_sale;
if ($search_user > 0) $param.='&search_user=' .$search_user;
if ($search_product_category > 0) $param.='$search_product_category=' .$search_product_category;
if ($search_montant_ht != '') $param.='&search_montant_ht='.$search_montant_ht;
if ($search_montant_ttc != '') $param.='&search_montant_ttc='.$search_montant_ttc;
if ($search_status != '') $param.='&search_status='.$search_status;

View File

@ -8,7 +8,7 @@
* Copyright (C) 2015 Marcos García <marcosgdf@gmail.com>
* Copyright (C) 2015 juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2015 Abbes Bahfir <bafbes@gmail.com>
* Copyright (C) 2015 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2015-2016 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -97,6 +97,10 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter")) // Both
$search_status="";
$year="";
$month="";
$day="";
$year_lim="";
$month_lim="";
$day_lim="";
}
// List of fields to search into when doing a "search in all"
@ -249,8 +253,12 @@ if ($resql)
}
$param='&socid='.$socid;
if ($day) $param.='&day='.urlencode($day);
if ($month) $param.='&month='.urlencode($month);
if ($year) $param.='&year=' .urlencode($year);
if ($day_lim) $param.='&day_lim='.urlencode($day_lim);
if ($month_lim) $param.='&month_lim='.urlencode($month_lim);
if ($year_lim) $param.='&year_lim=' .urlencode($year_lim);
if ($search_ref) $param.='&search_ref='.urlencode($search_ref);
if ($search_ref_supplier) $param.='&search_ref_supplier'.urlencode($search_ref_supplier);
if ($search_label) $param.='&search_label='.urlencode($search_label);

View File

@ -49,6 +49,7 @@ $now = dol_now();
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); // Return all projects I have permission on because I want my tasks and some of my task may be on a public projet that is not my project
$taskstatic=new Task($db);
$tasktmp=new Task($db);
$title=$langs->trans("Activities");
@ -130,7 +131,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
@ -143,7 +144,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
@ -186,7 +187,7 @@ if ($db->type != 'pgsql')
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
@ -199,71 +200,74 @@ if ($db->type != 'pgsql')
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
}
// TODO Do not use week function to be compatible with all database
/*
if ($db->type != 'pgsql')
{
print '<br>';
// Affichage de la liste des projets de la semaine
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND task_date >= '".dol_get_first_day($year, $month).'" AND ...";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$resql = $db->query($sql);
if ( $resql )
{
$total = 0;
$var=true;
while ($row = $db->fetch_object($resql))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table><br>";
}
*/
print '<br>';
/* Affichage de la liste des projets de la semaine */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans("ActivityOnProjectThisWeek").'</td>';
print '<td align="right">'.$langs->trans("Time").'</td>';
print "</tr>\n";
$sql = "SELECT p.rowid, p.ref, p.title, SUM(tt.task_duration) as nb";
$sql.= " FROM ".MAIN_DB_PREFIX."projet as p";
$sql.= " , ".MAIN_DB_PREFIX."projet_task as t";
$sql.= " , ".MAIN_DB_PREFIX."projet_task_time as tt";
$sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND week(task_date) = '".strftime("%W",time())."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
$resql = $db->query($sql);
if ( $resql )
{
$total = 0;
$var=true;
while ($row = $db->fetch_object($resql))
{
$var=!$var;
print "<tr ".$bc[$var].">";
print '<td>';
$projectstatic->id=$row->rowid;
$projectstatic->ref=$row->ref;
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print "</tr>\n";
$total += $row->nb;
}
$db->free($resql);
}
else
{
dol_print_error($db);
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print "</tr>\n";
print "</table><br>";
}
/* Affichage de la liste des projets du mois */
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
@ -279,7 +283,7 @@ $sql.= " WHERE t.fk_projet = p.rowid";
$sql.= " AND p.entity = ".$conf->entity;
$sql.= " AND tt.fk_task = t.rowid";
$sql.= " AND tt.fk_user = ".$user->id;
$sql.= " AND date_format(task_date,'%y-%m') = '".strftime("%y-%m",$now)."'";
$sql.= " AND task_date BETWEEN '".dol_get_first_day($year, $month).'" AND "'.dol_get_last_day($year, $month)."'";
$sql.= " AND p.rowid in (".$projectsListId.")";
$sql.= " GROUP BY p.rowid, p.ref, p.title";
@ -297,7 +301,7 @@ if ( $resql )
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$var=!$var;
}
@ -309,7 +313,7 @@ else
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
@ -347,7 +351,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
$projectstatic->title=$row->title;
print $projectstatic->getNomUrl(1, '', 1);
print '</td>';
print '<td align="right">'.convertSecondToTime($row->nb).'</td>';
print '<td align="right">'.convertSecondToTime($row->nb, 'allhourmin').'</td>';
print "</tr>\n";
$var=!$var;
}
@ -359,7 +363,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR))
}
print '<tr class="liste_total">';
print '<td>'.$langs->trans('Total').'</td>';
print '<td align="right">'.convertSecondToTime($total).'</td>';
print '<td align="right">'.convertSecondToTime($total, 'allhourmin').'</td>';
print "</tr>\n";
print "</table>";
}
@ -371,6 +375,38 @@ print '</div><div class="fichetwothirdright"><div class="ficheaddleft">';
if (empty($conf->global->PROJECT_HIDE_TASKS))
{
// Get id of types of contacts for projects (This list never contains a lot of elements)
$listofprojectcontacttype=array();
$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE ctc.element = '" . $projectstatic->element . "'";
$sql.= " AND ctc.source = 'internal'";
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
{
$listofprojectcontacttype[$obj->rowid]=$obj->code;
}
}
else dol_print_error($db);
if (count($listofprojectcontacttype) == 0) $listofprojectcontacttype[0]='0'; // To avoid sql syntax error if not found
// Get id of types of contacts for tasks (This list never contains a lot of elements)
$listoftaskcontacttype=array();
$sql = "SELECT ctc.rowid, ctc.code FROM ".MAIN_DB_PREFIX."c_type_contact as ctc";
$sql.= " WHERE ctc.element = '" . $taskstatic->element . "'";
$sql.= " AND ctc.source = 'internal'";
$resql = $db->query($sql);
if ($resql)
{
while($obj = $db->fetch_object($resql))
{
$listoftaskcontacttype[$obj->rowid]=$obj->code;
}
}
else dol_print_error($db);
if (count($listoftaskcontacttype) == 0) $listoftaskcontacttype[0]='0'; // To avoid sql syntax error if not found
// Tasks for all resources of all opened projects and time spent for each task/resource
$max = (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?1000:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA);
@ -381,8 +417,16 @@ if (empty($conf->global->PROJECT_HIDE_TASKS))
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task as t on t.fk_projet = p.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."projet_task_time as tasktime on tasktime.fk_task = t.rowid";
$sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u on tasktime.fk_user = u.rowid";
if ($mine)
{
$sql.= ", " . MAIN_DB_PREFIX . "element_contact as ect";
}
$sql.= " WHERE p.entity = ".$conf->entity;
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($mine || empty($user->rights->projet->all->lire)) $sql.= " AND p.rowid IN (".$projectsListId.")"; // project i have permission on
if ($mine) // this may duplicate record if we are contact twice
{
$sql.= " AND ect.fk_c_type_contact IN (".join(',',array_keys($listoftaskcontacttype)).") AND ect.element_id = t.rowid AND ect.fk_socpeople = ".$user->id;
}
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.ref, p.title, p.rowid, t.label, t.rowid, t.planned_workload, t.duration_effective, t.progress, t.dateo, t.datee";

View File

@ -750,7 +750,7 @@ else
* Creation
*/
$private=GETPOST("private","int");
if (! empty($conf->global->MAIN_THIRPARTY_CREATION_INDIVIDUAL) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1;
if (! empty($conf->global->MAIN_THIRDPARTY_CREATION_INDIVIDUAL) && ! isset($_GET['private']) && ! isset($_POST['private'])) $private=1;
if (empty($private)) $private=0;
// Load object modCodeTiers