From 79023cddb0031afb69b3d4cf621735cd8239d619 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2015 17:34:50 +0100 Subject: [PATCH 01/10] Fix external calendar for users were not visible if no global calendar was set. --- htdocs/admin/agenda_extsites.php | 2 +- htdocs/comm/action/index.php | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php index 6b683c8b52b..b49c82c5b84 100644 --- a/htdocs/admin/agenda_extsites.php +++ b/htdocs/admin/agenda_extsites.php @@ -41,7 +41,7 @@ $actiontest=GETPOST('test','alpha'); $actionsave=GETPOST('save','alpha'); if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; -$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB; +$MAXAGENDA=$conf->global->AGENDA_EXT_NB; // List of aviable colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index f41dbc50d3a..6baa03ba87e 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Eric Seigne - * Copyright (C) 2004-2014 Laurent Destailleur + * Copyright (C) 2004-2015 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2011 Juanjo Menent * Copyright (C) 2014 Cedric GROSS @@ -39,6 +39,9 @@ if (! empty($conf->projet->enabled)) { if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3; +if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5; +$MAXAGENDA=$conf->global->AGENDA_EXT_NB; + $filter=GETPOST("filter",'',3); $filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3); $usergroup = GETPOST("usergroup","int",3); @@ -170,7 +173,7 @@ $listofextcals=array(); if (empty($conf->global->AGENDA_DISABLE_EXT)) { $i=0; - while($i < $conf->global->AGENDA_EXT_NB) + while($i < $MAXAGENDA) { $i++; $source='AGENDA_EXT_SRC'.$i; @@ -188,7 +191,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT)) if (empty($user->conf->AGENDA_DISABLE_EXT)) { $i=0; - while($i < $conf->global->AGENDA_EXT_NB) + while($i < $MAXAGENDA) { $i++; $source='AGENDA_EXT_SRC_'.$user->id.'_'.$i; From 7050ef6176055ce851d4c98ad1242b8975bec3d2 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 2 Mar 2015 17:56:37 +0100 Subject: [PATCH 02/10] Fix parameter notolderthan was not effective --- htdocs/public/agenda/agendaexport.php | 29 +++++++++++++++++---------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php index 2b1d02ef493..3d5492dd62c 100644 --- a/htdocs/public/agenda/agendaexport.php +++ b/htdocs/public/agenda/agendaexport.php @@ -22,6 +22,10 @@ * http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=vcal&exportkey=cle * http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=ical&type=event&exportkey=cle * http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=rss&exportkey=cle + * Other parameters into url are: + * ¬olderthan=99 + * &year=2015 + * &id=..., &idfrom=..., &idto=... */ //if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); @@ -55,23 +59,26 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; // Security check if (empty($conf->agenda->enabled)) accessforbidden('',1,1,1); +// Not older than +if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; // default limit + // Define format, type and filter $format='ical'; $type='event'; if (! empty($_GET["format"])) $format=$_GET["format"]; if (! empty($_GET["type"])) $type=$_GET["type"]; + $filters=array(); -if (! empty($_GET["year"])) $filters['year']=$_GET["year"]; -if (! empty($_GET["id"])) $filters['id']=$_GET["id"]; -if (! empty($_GET["idfrom"])) $filters['idfrom']=$_GET["idfrom"]; -if (! empty($_GET["idto"])) $filters['idto']=$_GET["idto"]; -if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; -if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; -if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; -if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; -// Not older than -if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100; -$filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; +if (! empty($_GET["year"])) $filters['year']=$_GET["year"]; +if (! empty($_GET["id"])) $filters['id']=$_GET["id"]; +if (! empty($_GET["idfrom"])) $filters['idfrom']=$_GET["idfrom"]; +if (! empty($_GET["idto"])) $filters['idto']=$_GET["idto"]; +if (! empty($_GET["project"])) $filters['project']=$_GET["project"]; +if (! empty($_GET["login"])) $filters['login']=$_GET["login"]; +if (! empty($_GET["logina"])) $filters['logina']=$_GET["logina"]; +if (! empty($_GET["logint"])) $filters['logint']=$_GET["logint"]; +if (GETPOST("notolderthan")) $filters['notolderthan']=GETPOST("notolderthan","int"); +else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY; // Check config if (empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY)) From 35733c4c0872af7b579b607f5f725ea1fa0d4ce0 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Mar 2015 17:47:17 +0100 Subject: [PATCH 03/10] More comments --- htdocs/core/lib/functions.lib.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 129510194bb..5ecafde1a03 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -3759,8 +3759,8 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) /** * This function is called to encode a string into a HTML string but differs from htmlentities because - * all entities but &,<,> are converted. This permits to encode special chars to entities with no double - * encoding for already encoded HTML strings. + * a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted. + * This permits to encode special chars to entities with no double encoding for already encoded HTML strings. * This function also remove last EOL or BR if $removelasteolbr=1 (default). * For PDF usage, you can show text by 2 ways: * - writeHTMLCell -> param must be encoded into HTML. @@ -3777,7 +3777,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false) function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1) { $newstring=$stringtoencode; - if (dol_textishtml($stringtoencode)) + if (dol_textishtml($stringtoencode)) // Check if text is already HTML or not { $newstring=preg_replace('//i','
',$newstring); // Replace "
" by "
". It's same and avoid pb with FPDF. if ($removelasteolbr) $newstring=preg_replace('/
$/i','',$newstring); // Remove last
(remove only last one) From fddbca50b12f6288b80b9cadbf420e589b54d557 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 3 Mar 2015 18:33:53 +0100 Subject: [PATCH 04/10] Start to introduce MAIN_EMAIL_ADD_TRACK_ID option to test inclusion of tracking id into email. --- htdocs/core/class/CMailFile.class.php | 12 ++++++------ htdocs/core/lib/functions2.lib.php | 15 +++++++++++++++ htdocs/societe/soc.php | 9 +++++++-- 3 files changed, 28 insertions(+), 8 deletions(-) diff --git a/htdocs/core/class/CMailFile.class.php b/htdocs/core/class/CMailFile.class.php index 5288dc635cb..573e768fb4b 100644 --- a/htdocs/core/class/CMailFile.class.php +++ b/htdocs/core/class/CMailFile.class.php @@ -36,12 +36,12 @@ */ class CMailFile { - var $subject; // Topic: Subject of email - var $addr_from; // From: Label of sender (name but can contains an email inside <>) - // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). - // Use it with an email from a sending host from is a SPF protected domain and sending host is not this domain. - // Return-Path: Email where to send bounds. - var $errors_to; // Errors-To: Email where to send errors. + var $subject; // Topic: Subject of email + var $addr_from; // From: Label and EMail of sender (must include '<>'). For example '' or 'John Doe ' or '') + // Sender: Who send the email ("Sender" has sent emails on behalf of "From"). + // Use it when the "From" is an email of a domain that is a SPF protected domain, and sending smtp server is not this domain. In such case, use for Sender an email of the protected domain. + // Return-Path: Email where to send bounds. + var $errors_to; // Errors-To: Email where to send errors. var $addr_to; var $addr_cc; var $addr_bcc; diff --git a/htdocs/core/lib/functions2.lib.php b/htdocs/core/lib/functions2.lib.php index 9a26c727bd4..5faf1c1c470 100644 --- a/htdocs/core/lib/functions2.lib.php +++ b/htdocs/core/lib/functions2.lib.php @@ -371,6 +371,21 @@ function dol_print_object_info($object) } } + +/** + * Return an email formatted to include a tracking id + * For example myemail@mydomain.com becom myemail+trackingid@mydomain.com + * + * @param string $email Email address (Ex: "toto@titi.com", "John Do ") + * @param string $trackingid Tracking id (Ex: thi123 for thirdparty with id 123) + * @return boolean True if domain email is OK, False if KO + */ +function dolAddEmailTrackId($email, $trackingid) +{ + $tmp=explode('@',$email); + return $tmp[0].'+'.$trackingid.'@'.(isset($tmp[1])?$tmp[1]:''); +} + /** * Return true if email has a domain name that can't be resolved * diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index 04f749dc32a..72dfc8931b8 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -259,9 +259,9 @@ if (empty($reshook)) $action = (($action=='add'||$action=='create')?'create':'edit'); } } - + $idprof_mandatory ='SOCIETE_IDPROF'.($i).'_MANDATORY'; - + if (! $vallabel && ! empty($conf->global->$idprof_mandatory)) { $langs->load("errors"); @@ -2129,6 +2129,11 @@ else $formmail->fromid = $user->id; $formmail->fromname = $user->getFullName($langs); $formmail->frommail = $user->email; + if (! empty($conf->global->MAIN_EMAIL_ADD_TRACK_ID)) + { + include DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $formmail->frommail=dolAddEmailTrackId($formmail->frommail, 'thi'.$object->id); + } $formmail->withfrom=1; $formmail->withtopic=1; $liste=array(); From 107a16ed75cb874b4609016ee4e27c0037fed294 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 00:53:35 +0100 Subject: [PATCH 05/10] Work on timesheet module --- htdocs/core/js/timesheet.js | 176 ++++++++++++++++++++++++++ htdocs/core/lib/agenda.lib.php | 26 ++-- htdocs/core/lib/project.lib.php | 48 +++---- htdocs/langs/en_US/commercial.lang | 2 +- htdocs/projet/activity/perday.php | 35 ++++- htdocs/projet/class/project.class.php | 46 +++++++ 6 files changed, 290 insertions(+), 43 deletions(-) create mode 100644 htdocs/core/js/timesheet.js diff --git a/htdocs/core/js/timesheet.js b/htdocs/core/js/timesheet.js new file mode 100644 index 00000000000..7c85cb1afd0 --- /dev/null +++ b/htdocs/core/js/timesheet.js @@ -0,0 +1,176 @@ +//FIXME total not working +/* Copyright (C) 2014 delcroip + * Laurent Destailleur 2015 + * + * 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 . + */ + + +/* Parse en input data for time entry into timesheet */ +function regexEvent(objet,evt,type) +{ + console.log('regexEvent type='+type); + switch(type) + { + case 'days': + var regex= /^[0-9]{1}([.,]{1}[0-9]{1})?$/; + + if(regex.test(objet.value) ) + { + var tmp=objet.value.replace(',','.'); + if(tmp<=1.5){ + var tmpint=parseInt(tmp); + if(tmp-tmpint>=0.5){ + objet.value= tmpint+0.5; + }else{ + objet.value= tmpint; + } + }else{ + objet.value= '1.5'; + } + }else{ + objet.value= '0'; + } + break; + case 'hours': + var regex= /^[0-9]{1,2}:[0-9]{2}$/; + var regex2=/^[0-9]{1,2}$/; + if(!regex.test(objet.value)) + { + if(regex2.test(objet.value)) + objet.value=objet.value+':00'; + else + objet.value=''; + } + /* alert(jQuery("#"+id).val()); */ + break; + case 'timeChar': + //var regex= /^[0-9:]{1}$/; + //alert(event.charCode); + var charCode = (evt.which) ? evt.which : event.keyCode; + + if(((charCode >= 48) && (charCode <= 57)) || //num + (charCode===46) || (charCode===8)||// comma & periode + (charCode === 58) || (charCode==44) )// : & all charcode + { + // ((charCode>=96) && (charCode<=105)) || //numpad + return true; + + }else + { + return false; + } + + break; + default: + break; + } +} + + +function pad(n) { + return (n < 10) ? ("0" + n) : n; +} + + + +/* function from http://www.timlabonne.com/2013/07/parsing-a-time-string-with-javascript/ */ +function parseTime(timeStr, dt) +{ + if (!dt) { + dt = new Date(); + } + + var time = timeStr.match(/(\d+)(?::(\d\d))?\s*(p?)/i); + if (!time) { + return -1; + } + var hours = parseInt(time[1], 10); + if (hours == 12 && !time[3]) { + hours = 0; + } + else { + hours += (hours < 12 && time[3]) ? 12 : 0; + } + + dt.setHours(hours); + dt.setMinutes(parseInt(time[2], 10) || 0); + dt.setSeconds(0, 0); + return 0; +} + +/* Update total. days = column nb staring from 0 */ +function updateTotal(days,mode) +{ + console.log('updateTotal days='+days+' mode='+mode); + if(mode=="hours") + { + var total = new Date(0); + total.setHours(0); + total.setMinutes(0); + var nbline = document.getElementById('numberOfLines').value; + for (var i=0;i= 0) + { + total.setHours(total.getHours()+taskTime.getHours()); + total.setMinutes(total.getMinutes()+taskTime.getMinutes()); + } + } + } + document.getElementById('totalDay['+days+']').innerHTML = pad(total.getHours())+':'+pad(total.getMinutes()); + //addText(,total.getHours()+':'+total.getMinutes()); + } + else + { + var total =0; + var nbline = document.getElementById('numberOfLines').value; + for (var i=0;i'; - print ''; + print ''; print $langs->trans("ActionsToDoBy").'   '; - print ''; + print ''; print $form->select_dolusers($filtert, 'usertodo', 1, '', ! $canedit); if (empty($conf->dol_optimize_smallscreen)) print '   '.$langs->trans("or") . ' '.$langs->trans("Group").'   '; print $form->select_dolgroups($usergroupid, 'usergroup', 1, '', ! $canedit); @@ -83,16 +83,16 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $formactions=new FormActions($db); print ''; - print ''; + print ''; print $langs->trans("Type"); - print '  '; + print '  '; print $formactions->select_type_actions($actioncode, "actioncode", '', (empty($conf->global->AGENDA_USE_EVENT_TYPE) ? 1 : 0)); print ''; print ''; - print ''; + print ''; print $langs->trans("Status"); - print '  '; + print '  '; $formactions->form_select_status_action('formaction',$status,1,'status',1,2); print ''; } @@ -100,9 +100,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if (! empty($conf->societe->enabled) && $user->rights->societe->lire) { print ''; - print ''; + print ''; print $langs->trans("ThirdParty").'   '; - print ''; + print ''; print $form->select_thirdparty($socid, 'socid'); print ''; } @@ -113,9 +113,9 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh $formproject=new FormProjets($db); print ''; - print ''; + print ''; print $langs->trans("Project").'   '; - print ''; + print ''; $formproject->select_projects($socid?$socid:-1, $pid, 'projectid', 0); print ''; } @@ -124,7 +124,7 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh { // Filter on hours print ''; - print ''.$langs->trans("WorkingTimeRange").''; + print ''.$langs->trans("WorkingTimeRange").''; print ""; print ''; if (empty($conf->dol_use_jmobile)) print ' - '; @@ -140,10 +140,6 @@ function print_actions_filter($form, $canedit, $status, $year, $month, $day, $sh if (empty($conf->dol_use_jmobile)) print ' - '; print ''; print ''; - - print ''.$langs->trans("AgendaShowBirthdayEvents").' '; - print ''; - print ''; } // Hooks diff --git a/htdocs/core/lib/project.lib.php b/htdocs/core/lib/project.lib.php index 2320b0ca556..eb7617b5c7e 100644 --- a/htdocs/core/lib/project.lib.php +++ b/htdocs/core/lib/project.lib.php @@ -550,7 +550,7 @@ function projectLinesPerTime(&$inc, $parent, $lines, &$level, &$projectsrole, &$ print $taskstatic->getNomUrl(0); print "
"; for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end); + print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload @@ -665,6 +665,9 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t { $var = !$var; $lastprojectid=$lines[$i]->fk_project; + + $projectstatic->id = $lines[$i]->fk_project; + $projectstatic->loadTimeSpent($datestart, $lines[$i]->id, $fuser->id); } // If we want all or we have a role on task, we show it @@ -673,7 +676,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t print "\n"; // Project - print ""; + print ''; $projectstatic->id=$lines[$i]->fk_project; $projectstatic->ref=$lines[$i]->projectref; $projectstatic->public=$lines[$i]->public; @@ -682,7 +685,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t print ""; // Ref - print ''; + print ''; $taskstatic->id=$lines[$i]->id; $taskstatic->ref=($lines[$i]->ref?$lines[$i]->ref:$lines[$i]->id); print $taskstatic->getNomUrl(1); @@ -696,7 +699,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t print $taskstatic->getNomUrl(0); print "
"; for ($k = 0 ; $k < $level ; $k++) print "   "; - print get_date_range($lines[$i]->date_start,$lines[$i]->date_end); + print get_date_range($lines[$i]->date_start,$lines[$i]->date_end,'',$langs,0); print "\n"; // Planned Workload @@ -711,6 +714,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t print ''; // Time spent + /* print ''; if ($lines[$i]->duration) { @@ -720,6 +724,7 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t } else print '--:--'; print "\n"; + */ $disabledproject=1;$disabledtask=1; //print "x".$lines[$i]->fk_project; @@ -737,27 +742,22 @@ function projectLinesPerDay(&$inc, $parent, $lines, &$level, &$projectsrole, &$t $disabledtask=1; } - // Fields to add new time - print ''; - print $langs->trans("FeatureNotYetAvailable"); - /* - print ''; - $s=''; - $s.=$form->select_date('',$lines[$i]->id,0,0,2,"addtime",1,0,1,$disabledtask); - $s.='   '; - $s.=$form->select_duration($lines[$i]->id,'',$disabledtask,'text',0,1); - $s.=' '; - print $s; - print ''; + //var_dump($projectstatic->weekWorkLoad); - print ''; - if ((! $lines[$i]->public) && $disabledproject) print $form->textwithpicto('',$langs->trans("YouAreNotContactOfProject")); - else if ($disabledtask) print $form->textwithpicto('',$langs->trans("TaskIsNotAffectedToYou")); - print ''; - */ - - print ''; - print "\n"; + // Fields to show current time + $tableCell=''; $modeinput='hours'; + for ($idw = 0; $idw < 7; $idw++) + { + $dayWorkLoad = 0; + $tableCell =''; + $tableCell.='+'; + $tableCell.=''; + $tableCell.=''; + print $tableCell; + } + print "\n"; } $inc++; diff --git a/htdocs/langs/en_US/commercial.lang b/htdocs/langs/en_US/commercial.lang index 390a7f837e8..7acdc7bd7e6 100644 --- a/htdocs/langs/en_US/commercial.lang +++ b/htdocs/langs/en_US/commercial.lang @@ -62,7 +62,7 @@ LastProspectContactDone=Contact done DateActionPlanned=Date event planned for DateActionDone=Date event done ActionAskedBy=Event reported by -ActionAffectedTo=Event owned by +ActionAffectedTo=Event assigned to ActionDoneBy=Event done by ActionUserAsk=Reported by ErrorStatusCantBeZeroIfStarted=If field 'Date done' is filled, action is started (or finished), so field 'Status' can't be 0%%. diff --git a/htdocs/projet/activity/perday.php b/htdocs/projet/activity/perday.php index 6c4acb57334..f7b37ca1ca0 100644 --- a/htdocs/projet/activity/perday.php +++ b/htdocs/projet/activity/perday.php @@ -48,6 +48,8 @@ $socid=0; if ($user->societe_id > 0) $socid=$user->societe_id; $result = restrictedArea($user, 'projet', $projectid); +$now=dol_now(); + /* * Actions @@ -94,7 +96,7 @@ $tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0,$user,($project->id?$pr //var_dump($taskrole); -llxHeader("",$title,""); +llxHeader("",$title,"",'','','',array('/core/js/timesheet.js')); print_barre_liste($title, $page, $_SERVER["PHP_SELF"], "", $sortfield, $sortorder, "", $num); @@ -143,8 +145,17 @@ print ''.$langs->trans("RefTask").''; print ''.$langs->trans("LabelTask").''; print ''.$langs->trans("PlannedWorkload").''; print ''.$langs->trans("ProgressDeclared").''; -print ''.$langs->trans("TimeSpent").''; -print ''.$langs->trans("xxx").''; +//print ''.$langs->trans("TimeSpent").''; + +$tmp=dol_getdate($now); +$startdayarray=dol_get_first_day_week($tmp['mday'], $tmp['mon'], $tmp['year']); +$startday=dol_mktime(12, 0, 0, $startdayarray['first_month'], $startdayarray['first_day'], $startdayarray['first_year']); + +for($i=0;$i<7;$i++) +{ + print ''.dol_print_date($startday + ($i * 3600 * 24), '%a').'
'.dol_print_date($startday + ($i * 3600 * 24), 'day').''; +} + print "\n"; // By default, we can edit only tasks we are assigned to @@ -154,6 +165,17 @@ if (count($tasksarray) > 0) { $j=0; projectLinesPerDay($j, 0, $tasksarray, $level, $projectsrole, $tasksrole, $mine, $restricteditformytask); + + print ' + '.$langs->trans("Total").' +
 
+
 
+
 
+
 
+
 
+
 
+
 
+ '; } else { @@ -161,8 +183,15 @@ else } print ""; +print ''."\n"; +print ''."\n"; + dol_fiche_end(); +print '
'; +print ''; +print '
'; + print ''; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 8db1313904d..12750e00c6f 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1432,5 +1432,51 @@ class Project extends CommonObject return $this->commonGenerateDocument($modelpath, $modele, $outputlangs, $hidedetails, $hidedesc, $hideref); } + + /** + * load time spent into this->weekWorkLoad for all day of a week and task id + * + * @param int $datestart First day of week (use dol_get_first_day to find this date) + * @param int $userid Time consumed per a particular user + * @return int <0 if OK, >0 if KO + */ + public function loadTimeSpent($datestart,$taskid,$userid=0) + { + $error=0; + + $sql = "SELECT ptt.rowid, ptt.task_duration, ptt.task_date"; + $sql.= " FROM ".MAIN_DB_PREFIX."projet_task_time AS ptt"; + $sql.= " WHERE ptt.fk_task='".$taskid."'"; + $sql.= " AND ptt.fk_user='".$userid."'"; + $sql .= "AND (ptt.task_date >= '".$this->db->idate($datestart)."' "; + $sql .= "AND (ptt.task_date < '".$this->db->idate($datestart + 7 * 24 * 3600)."' "; + $resql=$this->db->query($sql); + if ($resql) + { + + $num = $this->db->num_rows($resql); + $i = 0; + // Loop on each record found, so each couple (project id, task id) + while ($i < $num) + { + $obj=$this->db->fetch_object($resql); + $day=$this->db->jdate($obj->task_date); + //$day=(intval(date('w',strtotime($obj->task_date)))+1)%6; + // if several tasktime in one day then only the last is used + $this->weekWorkLoad[$day] += $obj->task_duration; + $this->taskTimeId[$day]= ($obj->rowid)?($obj->rowid):0; + $i++; + } + $this->db->free($resql); + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + } From fa2e57eaa32698d6d00edf758fab6bf8b6df936f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 01:10:23 +0100 Subject: [PATCH 06/10] pcpcs --- htdocs/compta/prelevement/class/bonprelevement.class.php | 2 +- htdocs/install/mysql/migration/3.6.0-3.7.0.sql | 4 ++-- htdocs/product/stock/lib/replenishment.lib.php | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 24414c513e6..2c07baba5a0 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -1300,7 +1300,7 @@ class BonPrelevement extends CommonObject while ($i < $num) { $obj = $this->db->fetch_object($resql); - $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures , $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); + $fileDebiteurSection .= $this->EnregDestinataireSEPA($obj->code, $obj->nom, $obj->address, $obj->zip, $obj->town, $obj->country_code, $obj->cb, $obj->cg, $obj->cc, $obj->somme, $ListOfFactures, $obj->idfac, $obj->iban, $obj->bic, $obj->datec, $obj->drum); $this->total = $this->total + $obj->somme; $i++; } diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql index d9d972cc25c..7a432a1109e 100755 --- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql +++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql @@ -1095,8 +1095,8 @@ ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task); ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date); ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour); -ALTER TABLE llx_projet_task CHANGE COLUMN duration_effective real DEFAULT 0 NULL; -ALTER TABLE llx_projet_task CHANGE COLUMN planned_workload real DEFAULT 0 NULL; +ALTER TABLE llx_projet_task MODIFY COLUMN duration_effective real DEFAULT 0 NULL; +ALTER TABLE llx_projet_task MODIFY COLUMN planned_workload real DEFAULT 0 NULL; -- add extrafield on ficheinter lines diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php index 1ef993c479d..486e8373255 100644 --- a/htdocs/product/stock/lib/replenishment.lib.php +++ b/htdocs/product/stock/lib/replenishment.lib.php @@ -37,7 +37,7 @@ function dolDispatchToDo($order_id) $dispatched = array(); $ordered = array(); - # Count nb of quantity dispatched per product + // Count nb of quantity dispatched per product $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch'; $sql.= ' WHERE fk_commande = ' . $order_id; $sql.= ' GROUP BY fk_product'; @@ -49,7 +49,7 @@ function dolDispatchToDo($order_id) $dispatched[$obj->fk_product] = $obj; } - # Count nb of quantity to dispatch per product + // Count nb of quantity to dispatch per product $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet'; $sql.= ' WHERE fk_commande = ' . $order_id; $sql.= ' AND fk_product > 0'; From 52425648bf37c66a15d0b933cd54b1ce0f80467a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 01:54:26 +0100 Subject: [PATCH 07/10] NEW: When using transfer or correct stock from warehouse, after recording we go back to the warehouse page. --- htdocs/core/lib/functions.lib.php | 1 + htdocs/product/stock/card.php | 4 ++-- htdocs/product/stock/product.php | 29 ++++++++++++++++++++++++----- 3 files changed, 27 insertions(+), 7 deletions(-) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f2c00e2cf75..438f0ee22ca 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -4725,6 +4725,7 @@ function picto_from_langcode($codelang) * 'member' to add a tab in fundation member view * 'categories_x' to add a tab in category view ('x': type of category (0=product, 1=supplier, 2=customer, 3=member) * 'ecm' to add a tab for another ecm view + * 'stock' to add a tab for warehouse view * @param string $mode 'add' to complete head, 'remove' to remove entries * @return void */ diff --git a/htdocs/product/stock/card.php b/htdocs/product/stock/card.php index 0bd061b4a0c..8d9ee5b6d64 100644 --- a/htdocs/product/stock/card.php +++ b/htdocs/product/stock/card.php @@ -467,14 +467,14 @@ else if ($user->rights->stock->mouvement->creer) { - print ''; + print ''; print img_picto($langs->trans("StockMovement"),'uparrow.png','class="hideonsmartphone"').' '.$langs->trans("StockMovement"); print ""; } if ($user->rights->stock->creer) { - print ''; + print ''; print $langs->trans("StockCorrection"); print ""; } diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 57e4c2e7d98..044da6c9aa4 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -43,7 +43,7 @@ $langs->load("stocks"); $langs->load("sendings"); if (! empty($conf->productbatch->enabled)) $langs->load("productbatch"); - +$backtopage=GETPOST('backtopage'); $action=GETPOST("action"); $cancel=GETPOST('cancel'); @@ -160,8 +160,16 @@ if ($action == "correct_stock" && ! $cancel) if ($result > 0) { - header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); - exit; + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: ".$_SERVER["PHP_SELF"]."?id=".$product->id); + exit; + } } else { @@ -292,8 +300,17 @@ if ($action == "transfert_stock" && ! $cancel) if (! $error && $result1 >= 0 && $result2 >= 0) { $db->commit(); - header("Location: product.php?id=".$product->id); - exit; + + if ($backtopage) + { + header("Location: ".$backtopage); + exit; + } + else + { + header("Location: product.php?id=".$product->id); + exit; + } } else { @@ -594,6 +611,7 @@ if ($id > 0 || $ref) print '
'."\n"; print ''; print ''; + print ''; print ''; // Warehouse @@ -681,6 +699,7 @@ if ($id > 0 || $ref) print ''."\n"; print ''; print ''; + print ''; if ($pdluoid) { print ''; From 2c3a412c3a76917e43dd8cde35562a7e4b636536 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 02:08:51 +0100 Subject: [PATCH 08/10] Fix export extrafield on supplier orders --- htdocs/core/modules/modFournisseur.class.php | 167 +++++++++++-------- 1 file changed, 102 insertions(+), 65 deletions(-) diff --git a/htdocs/core/modules/modFournisseur.class.php b/htdocs/core/modules/modFournisseur.class.php index 1f8b3af3ed6..45cb61b04fd 100644 --- a/htdocs/core/modules/modFournisseur.class.php +++ b/htdocs/core/modules/modFournisseur.class.php @@ -255,40 +255,40 @@ class modFournisseur extends DolibarrModules $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Text",'fd.qty'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'fd.rowid'=>'invoice_line','fd.description'=>"invoice_line",'fd.tva_tx'=>"invoice_line",'fd.qty'=>"invoice_line",'fd.remise_percent'=>"invoice_line",'fd.total_ht'=>"invoice_line",'fd.total_ttc'=>"invoice_line",'fd.tva'=>"invoice_line",'fd.product_type'=>'invoice_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product','p.accountancy_code_buy'=>'product'); $this->export_dependencies_array[$r]=array('invoice_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) + // Add extra fields + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) + while ($obj=$this->db->fetch_object($resql)) { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $typeFilter="List:".$obj->param; - break; + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='invoice'; } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='facture_fourn'; } - } - // End add axtra fields + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; @@ -309,40 +309,40 @@ class modFournisseur extends DolibarrModules $this->export_TypeFields_array[$r]=array('s.nom'=>'Text','s.address'=>'Text','s.zip'=>'Text','s.town'=>'Text','c.code'=>'Text','s.phone'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.datec'=>"Date",'f.datef'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.total_tva'=>"Number",'f.paye'=>"Boolean",'f.fk_statut'=>'Status','f.note_public'=>"Text",'pf.amount'=>'Number','p.datep'=>'Date','p.num_paiement'=>'Number'); $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"invoice",'f.ref'=>"invoice",'f.ref_supplier'=>"invoice",'f.datec'=>"invoice",'f.datef'=>"invoice",'f.total_ht'=>"invoice",'f.total_ttc'=>"invoice",'f.total_tva'=>"invoice",'f.paye'=>"invoice",'f.fk_statut'=>'invoice','f.note_public'=>"invoice",'p.rowid'=>'payment','pf.amount'=>'payment','p.datep'=>'payment','p.num_paiement'=>'payment'); $this->export_dependencies_array[$r]=array('payment'=>'p.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - // Add extra fields - $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; - $resql=$this->db->query($sql); - if ($resql) // This can fail when class is used on old database (during migration for example) - { - while ($obj=$this->db->fetch_object($resql)) + // Add extra fields + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'facture_fourn'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) { - $fieldname='extra.'.$obj->name; - $fieldlabel=ucfirst($obj->label); - $typeFilter="Text"; - switch($obj->type) + while ($obj=$this->db->fetch_object($resql)) { - case 'int': - case 'double': - case 'price': - $typeFilter="Numeric"; - break; - case 'date': - case 'datetime': - $typeFilter="Date"; - break; - case 'boolean': - $typeFilter="Boolean"; - break; - case 'sellist': - $typeFilter="List:".$obj->param; - break; + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='invoice'; } - $this->export_fields_array[$r][$fieldname]=$fieldlabel; - $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; - $this->export_entities_array[$r][$fieldname]='facture_fourn'; } - } - // End add axtra fields + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; @@ -353,20 +353,57 @@ class modFournisseur extends DolibarrModules $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_invoice',1).')'; + + $r++; $this->export_code[$r]=$this->rights_class.'_'.$r; $this->export_label[$r]='Commandes fournisseurs et lignes de commandes'; $this->export_icon[$r]='order'; $this->export_permission[$r]=array(array("fournisseur","commande","export")); - $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); - $this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); - $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); + $this->export_fields_array[$r]=array('s.rowid'=>"IdCompany",'s.nom'=>'CompanyName','s.address'=>'Address','s.zip'=>'Zip','s.town'=>'Town','c.code'=>'CountryCode','s.phone'=>'Phone','s.siren'=>'ProfId1','s.siret'=>'ProfId2','s.ape'=>'ProfId3','s.idprof4'=>'ProfId4','s.idprof5'=>'ProfId5','s.idprof6'=>'ProfId6','s.tva_intra'=>'VATIntra','f.rowid'=>"OrderId",'f.ref'=>"Ref",'f.ref_supplier'=>"RefSupplier",'f.date_creation'=>"DateCreation",'f.date_commande'=>"OrderDate",'f.total_ht'=>"TotalHT",'f.total_ttc'=>"TotalTTC",'f.tva'=>"TotalVAT",'f.fk_statut'=>'Status','f.note_public'=>"NotePublic",'f.note_private'=>"NotePrivate",'fd.rowid'=>'LineId','fd.description'=>"LineDescription",'fd.tva_tx'=>"LineVATRate",'fd.qty'=>"LineQty",'fd.remise_percent'=>"Discount",'fd.total_ht'=>"LineTotalHT",'fd.total_ttc'=>"LineTotalTTC",'fd.total_tva'=>"LineTotalVAT",'fd.product_type'=>'TypeOfLineServiceOrProduct','fd.fk_product'=>'ProductId','p.ref'=>'ProductRef','p.label'=>'ProductLabel'); + $this->export_TypeFields_array[$r]=array('s.rowid'=>"company",'s.nom'=>'Text','s.address'=>'Text','s.cp'=>'Text','s.ville'=>'Text','c.code'=>'Text','s.tel'=>'Text','s.siren'=>'Text','s.siret'=>'Text','s.ape'=>'Text','s.idprof4'=>'Text','s.idprof5'=>'Text','s.idprof6'=>'Text','s.tva_intra'=>'Text','f.ref'=>"Text",'f.ref_supplier'=>"Text",'f.date_creation'=>"Date",'f.date_commande'=>"Date",'f.total_ht'=>"Number",'f.total_ttc'=>"Number",'f.tva'=>"Number",'f.fk_statut'=>'Status','f.note_public'=>"Text",'f.note_private'=>"Text",'fd.description'=>"Text",'fd.tva_tx'=>"Number",'fd.qty'=>"Number",'fd.remise_percent'=>"Number",'fd.total_ht'=>"Number",'fd.total_ttc'=>"Number",'fd.total_tva'=>"Number",'fd.product_type'=>'Boolean','fd.fk_product'=>'List:Product:label','p.ref'=>'Text','p.label'=>'Text'); + $this->export_entities_array[$r]=array('s.rowid'=>"company",'s.nom'=>'company','s.address'=>'company','s.zip'=>'company','s.town'=>'company','c.code'=>'company','s.phone'=>'company','s.siren'=>'company','s.siret'=>'company','s.ape'=>'company','s.idprof4'=>'company','s.idprof5'=>'company','s.idprof6'=>'company','s.tva_intra'=>'company','f.rowid'=>"order",'f.ref'=>"order",'f.ref_supplier'=>"order",'f.date_creation'=>"order",'f.date_commande'=>"order",'f.total_ht'=>"order",'f.total_ttc'=>"order",'f.tva'=>"order",'f.fk_statut'=>'order','f.note_public'=>"order",'f.note_private'=>"order",'fd.rowid'=>'order_line','fd.description'=>"order_line",'fd.tva_tx'=>"order_line",'fd.qty'=>"order_line",'fd.remise_percent'=>"order_line",'fd.total_ht'=>"order_line",'fd.total_ttc'=>"order_line",'fd.total_tva'=>"order_line",'fd.product_type'=>'order_line','fd.fk_product'=>'product','p.ref'=>'product','p.label'=>'product'); $this->export_dependencies_array[$r]=array('order_line'=>'fd.rowid','product'=>'fd.rowid'); // To add unique key if we ask a field of a child to avoid the DISTINCT to discard them - + // Add extra fields + $sql="SELECT name, label, type, param FROM ".MAIN_DB_PREFIX."extrafields WHERE elementtype = 'commande_fournisseur'"; + $resql=$this->db->query($sql); + if ($resql) // This can fail when class is used on old database (during migration for example) + { + while ($obj=$this->db->fetch_object($resql)) + { + $fieldname='extra.'.$obj->name; + $fieldlabel=ucfirst($obj->label); + $typeFilter="Text"; + switch($obj->type) + { + case 'int': + case 'double': + case 'price': + $typeFilter="Numeric"; + break; + case 'date': + case 'datetime': + $typeFilter="Date"; + break; + case 'boolean': + $typeFilter="Boolean"; + break; + case 'sellist': + $typeFilter="List:".$obj->param; + break; + } + $this->export_fields_array[$r][$fieldname]=$fieldlabel; + $this->export_TypeFields_array[$r][$fieldname]=$typeFilter; + $this->export_entities_array[$r][$fieldname]='order'; + } + } + // End add axtra fields $this->export_sql_start[$r]='SELECT DISTINCT '; $this->export_sql_end[$r] =' FROM '.MAIN_DB_PREFIX.'societe as s'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'c_country as c ON s.fk_pays = c.rowid,'; - $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f, '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseur as f'; + $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'commande_fournisseur_extrafields as extra ON f.rowid = extra.fk_object,'; + $this->export_sql_end[$r] .=' '.MAIN_DB_PREFIX.'commande_fournisseurdet as fd'; $this->export_sql_end[$r] .=' LEFT JOIN '.MAIN_DB_PREFIX.'product as p on (fd.fk_product = p.rowid)'; $this->export_sql_end[$r] .=' WHERE f.fk_soc = s.rowid AND f.rowid = fd.fk_commande'; $this->export_sql_end[$r] .=' AND f.entity IN ('.getEntity('supplier_order',1).')'; From 6f96d4cd5ca4bb9ea017dd991a3808c44bd85645 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 02:18:20 +0100 Subject: [PATCH 09/10] Minimum style --- htdocs/core/class/html.formother.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 88a5a7522fe..d418a32fd77 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -330,7 +330,7 @@ class FormOther } // Print a select with each of them - $moreforfilter.=''; $moreforfilter.=''; // Should use -1 to say nothing if (is_array($tab_categs)) From 4c1d51bd393c8e3ac7477463c77171fc895bb3c3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Wed, 4 Mar 2015 02:28:16 +0100 Subject: [PATCH 10/10] phpcs --- htdocs/core/class/commonobject.class.php | 2 +- htdocs/projet/class/project.class.php | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 1134d3f0945..c4b2902113a 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2575,7 +2575,7 @@ abstract class CommonObject { global $conf, $hookmanager, $inputalsopricewithtax, $usemargins, $langs, $user; - # Define usemargins + // Define usemargins $usemargins=0; if (! empty($conf->margin->enabled) && ! empty($this->element) && in_array($this->element,array('facture','propal','commande'))) $usemargins=1; diff --git a/htdocs/projet/class/project.class.php b/htdocs/projet/class/project.class.php index 12750e00c6f..1d5daf2110a 100644 --- a/htdocs/projet/class/project.class.php +++ b/htdocs/projet/class/project.class.php @@ -1437,6 +1437,7 @@ class Project extends CommonObject * load time spent into this->weekWorkLoad for all day of a week and task id * * @param int $datestart First day of week (use dol_get_first_day to find this date) + * @param int $taskid Task id * @param int $userid Time consumed per a particular user * @return int <0 if OK, >0 if KO */