diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index 9de719a9e9d..d26c5dea5dd 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -9,6 +9,7 @@ * Copyright (C) 2015 Frederic France * Copyright (C) 2015 Marcos García * Copyright (C) 2015 Jean-François Ferry + * Copyright (C) 2016 Ferran Marcet * * 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; diff --git a/htdocs/compta/facture/list.php b/htdocs/compta/facture/list.php index 3855e2525c4..8f7b805f4d5 100644 --- a/htdocs/compta/facture/list.php +++ b/htdocs/compta/facture/list.php @@ -10,7 +10,7 @@ * Copyright (C) 2013 Florian Henry * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2015 Jean-François Ferry - * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2015-2016 Ferran Marcet * * 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; diff --git a/htdocs/fourn/facture/list.php b/htdocs/fourn/facture/list.php index 6731c70d328..f5ac8c9e74f 100644 --- a/htdocs/fourn/facture/list.php +++ b/htdocs/fourn/facture/list.php @@ -8,7 +8,7 @@ * Copyright (C) 2015 Marcos García * Copyright (C) 2015 juanjo Menent * Copyright (C) 2015 Abbes Bahfir - * Copyright (C) 2015 Ferran Marcet + * Copyright (C) 2015-2016 Ferran Marcet * * 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); diff --git a/htdocs/projet/activity/index.php b/htdocs/projet/activity/index.php index 9dec7555ae0..358792bafd8 100644 --- a/htdocs/projet/activity/index.php +++ b/htdocs/projet/activity/index.php @@ -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 ''; - print ''.convertSecondToTime($row->nb).''; + print ''.convertSecondToTime($row->nb, 'allhourmin').''; print "\n"; $total += $row->nb; } @@ -143,7 +144,7 @@ else } print ''; print ''.$langs->trans('Total').''; -print ''.convertSecondToTime($total).''; +print ''.convertSecondToTime($total, 'allhourmin').''; print "\n"; print ""; @@ -186,7 +187,7 @@ if ($db->type != 'pgsql') $projectstatic->title=$row->title; print $projectstatic->getNomUrl(1, '', 1); print ''; - print ''.convertSecondToTime($row->nb).''; + print ''.convertSecondToTime($row->nb, 'allhourmin').''; print "\n"; $total += $row->nb; } @@ -199,71 +200,74 @@ if ($db->type != 'pgsql') } print ''; print ''.$langs->trans('Total').''; - print ''.convertSecondToTime($total).''; + print ''.convertSecondToTime($total, 'allhourmin').''; print "\n"; print ""; } -// TODO Do not use week function to be compatible with all database +/* if ($db->type != 'pgsql') { + print '
'; + + // Affichage de la liste des projets de la semaine + print ''; + print ''; + print ''; + print ''; + print "\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 ""; + print ''; + print ''; + print "\n"; + $total += $row->nb; + } + + $db->free($resql); + } + else + { + dol_print_error($db); + } + print ''; + print ''; + print ''; + print "\n"; + print "
'.$langs->trans("ActivityOnProjectThisWeek").''.$langs->trans("Time").'
'; + $projectstatic->id=$row->rowid; + $projectstatic->ref=$row->ref; + $projectstatic->title=$row->title; + print $projectstatic->getNomUrl(1, '', 1); + print ''.convertSecondToTime($row->nb, 'allhourmin').'
'.$langs->trans('Total').''.convertSecondToTime($total, 'allhourmin').'

"; + +} +*/ + print '
'; -/* Affichage de la liste des projets de la semaine */ -print ''; -print ''; -print ''; -print ''; -print "\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 ""; - print ''; - print ''; - print "\n"; - $total += $row->nb; - } - - $db->free($resql); -} -else -{ - dol_print_error($db); -} -print ''; -print ''; -print ''; -print "\n"; -print "
'.$langs->trans("ActivityOnProjectThisWeek").''.$langs->trans("Time").'
'; - $projectstatic->id=$row->rowid; - $projectstatic->ref=$row->ref; - $projectstatic->title=$row->title; - print $projectstatic->getNomUrl(1, '', 1); - print ''.convertSecondToTime($row->nb).'
'.$langs->trans('Total').''.convertSecondToTime($total).'

"; - -} - /* Affichage de la liste des projets du mois */ print ''; print ''; @@ -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 ''; - print ''; + print ''; print "\n"; $var=!$var; } @@ -309,7 +313,7 @@ else } print ''; print ''; -print ''; +print ''; print "\n"; print "
'.convertSecondToTime($row->nb).''.convertSecondToTime($row->nb, 'allhourmin').'
'.$langs->trans('Total').''.convertSecondToTime($total).''.convertSecondToTime($total, 'allhourmin').'
"; @@ -347,7 +351,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) $projectstatic->title=$row->title; print $projectstatic->getNomUrl(1, '', 1); print ''; - print ''.convertSecondToTime($row->nb).''; + print ''.convertSecondToTime($row->nb, 'allhourmin').''; print "\n"; $var=!$var; } @@ -359,7 +363,7 @@ if (! empty($conf->global->PROJECT_TASK_TIME_YEAR)) } print ''; print ''.$langs->trans('Total').''; - print ''.convertSecondToTime($total).''; + print ''.convertSecondToTime($total, 'allhourmin').''; print "\n"; print ""; } @@ -371,6 +375,38 @@ print '
'; 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"; diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index ffb587fcc53..dc2d6b6a516 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -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