';
print $langs->trans('CronModule')." ";
print $object->module_name;
@@ -601,6 +592,53 @@ else
print ' ';
+ print '';
+
+ print "";
+ print $langs->trans('CronEvery')." ";
+ print "";
+ if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Minutes');
+ if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Hours');
+ if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Days');
+ if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency)." ".$langs->trans('Weeks');
+ print " ";
+
+ print '';
+ print $langs->trans('CronDtStart')." ";
+ if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');}
+ print " ";
+
+ print "";
+ print $langs->trans('CronDtEnd')." ";
+ if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');}
+ print " ";
+
+ print "";
+ print $langs->trans('CronPriority')." ";
+ print "".$object->priority;
+ print " ";
+
+ print "";
+ print $langs->trans('CronMaxRun')." ";
+ print "".$object->maxrun;
+ print " ";
+
+ print "";
+ print $langs->trans('CronNbRun')." ";
+ print "".$object->nbrun;
+ print " ";
+
+ print '';
+ print $langs->trans('CronDtNextLaunch');
+ print ' ('.$langs->trans('CronFrom').')';
+ print " ";
+ if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhoursec');} else {print $langs->trans('CronNone');}
+ print " ";
+
+ print '
';
+
+ print ' ';
+
print '';
print '';
diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php
index 39eaacd303f..a66fcd9597c 100644
--- a/htdocs/cron/class/cronjob.class.php
+++ b/htdocs/cron/class/cronjob.class.php
@@ -175,8 +175,9 @@ class Cronjob extends CommonObject
$sql.= "fk_user_author,";
$sql.= "fk_user_mod,";
$sql.= "note,";
- $sql.= "nbrun";
- $sql .= ",libname";
+ $sql.= "nbrun,";
+ $sql.= "maxrun,";
+ $sql.= "libname";
$sql.= ") VALUES (";
@@ -206,12 +207,10 @@ class Cronjob extends CommonObject
$sql.= " ".$user->id.",";
$sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").",";
$sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").",";
+ $sql.= " ".(empty($this->maxrun)?'null':"'".$this->db->escape($this->maxrun)."'").",";
$sql.= " ".(! isset($this->libname)?'NULL':"'".$this->db->escape($this->libname)."'")."";
-
-
$sql.= ")";
-
$this->db->begin();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
@@ -291,8 +290,9 @@ class Cronjob extends CommonObject
$sql.= " t.fk_user_author,";
$sql.= " t.fk_user_mod,";
$sql.= " t.note,";
- $sql.= " t.nbrun";
- $sql .= ", t.libname";
+ $sql.= " t.nbrun,";
+ $sql.= " t.maxrun,";
+ $sql.= " t.libname";
$sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t";
@@ -335,6 +335,7 @@ class Cronjob extends CommonObject
$this->fk_user_mod = $obj->fk_user_mod;
$this->note = $obj->note;
$this->nbrun = $obj->nbrun;
+ $this->maxrun = $obj->maxrun;
$this->libname = $obj->libname;
}
@@ -517,6 +518,7 @@ class Cronjob extends CommonObject
if (isset($this->status)) $this->status=trim($this->status);
if (isset($this->note)) $this->note=trim($this->note);
if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun);
+ if (isset($this->maxrun)) $this->maxrun=trim($this->maxrun);
if (isset($this->libname)) $this->libname = trim($this->libname);
// Check parameters
@@ -585,10 +587,9 @@ class Cronjob extends CommonObject
$sql.= " status=".(isset($this->status)?$this->status:"null").",";
$sql.= " fk_user_mod=".$user->id.",";
$sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").",";
- $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null");
- $sql.= ", libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null");
-
-
+ $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null").",";
+ $sql.= " maxrun=".(isset($this->maxrun)?$this->maxrun:"null").",";
+ $sql.= " libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null");
$sql.= " WHERE rowid=".$this->id;
$this->db->begin();
@@ -786,6 +787,7 @@ class Cronjob extends CommonObject
$this->fk_user_mod='';
$this->note='';
$this->nbrun='';
+ $this->maxrun=100;
$this->libname = '';
}
@@ -1087,7 +1089,7 @@ class Cronjob extends CommonObject
if (empty($this->datenextrun))
{
- $this->datenextrun = $now + $this->frequency;
+ $this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
}
else
{
@@ -1096,12 +1098,14 @@ class Cronjob extends CommonObject
// Loop until date is after future
while ($this->datenextrun < $now)
{
- $this->datenextrun += $this->frequency;
+ $this->datenextrun += ($this->frequency * $this->unitfrequency);
+
+ // TODO For exact frequency (every month, every year, ...), use instead a dol_time_plus_duree($time, $duration_value, $duration_unit)
}
}
else
{
- //$this->datenextrun=$this->datenextrun+$this->frequency;
+ //$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency);
}
}
diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php
index 9645d42261b..867695cade6 100644
--- a/htdocs/cron/list.php
+++ b/htdocs/cron/list.php
@@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
$langs->load("admin");
$langs->load("cron");
+$langs->load("bills");
if (!$user->rights->cron->read) accessforbidden();
@@ -174,12 +175,12 @@ print ' ';
print_liste_field_titre($langs->trans("ID"),$_SERVER["PHP_SELF"],"t.rowid","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"t.label","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronTask"),'','',"",$param,'',$sortfield,$sortorder);
+print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtStart"),$_SERVER["PHP_SELF"],"t.datestart","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVER["PHP_SELF"],"t.dateend","",$param,'align="center"',$sortfield,$sortorder);
-print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
-print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$param,'',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronMaxRun"),$_SERVER["PHP_SELF"],"t.maxrun","",$param,'align="right"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronNbRun"),$_SERVER["PHP_SELF"],"t.nbrun","",$param,'align="right"',$sortfield,$sortorder);
+print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVER["PHP_SELF"],"t.datenextrun","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVER["PHP_SELF"],"t.datelastrun","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVER["PHP_SELF"],"t.lastresult","",$param,'align="center"',$sortfield,$sortorder);
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVER["PHP_SELF"],"t.lastoutput","",$param,'',$sortfield,$sortorder);
@@ -233,7 +234,7 @@ if ($num > 0)
print '';
if (! empty($line->label))
{
- print ''.$line->label.' ';
+ print ''.$langs->trans($line->label).' ';
}
else
{
@@ -244,20 +245,31 @@ if ($num > 0)
print ' ';
if ($line->jobtype=='method')
{
- print $langs->trans('CronModule').':'.$line->module_name.' ';
- print $langs->trans('CronClass').':'. $line->classesname.' ';
- print $langs->trans('CronObject').':'. $line->objectname.' ';
- print $langs->trans('CronMethod').':'. $line->methodename;
+ $text=$langs->trans("CronClass");
+ $texttoshow=$langs->trans('CronModule').':'.$line->module_name.' ';
+ $texttoshow.=$langs->trans('CronClass').':'. $line->classesname.' ';
+ $texttoshow.=$langs->trans('CronObject').':'. $line->objectname.' ';
+ $texttoshow.=$langs->trans('CronMethod').':'. $line->methodename;
if(!empty($line->params)) {
- print ' '.$langs->trans('CronArgs').':'. $line->params;
- }
-
- }elseif ($line->jobtype=='command') {
- print $langs->trans('CronCommand').':'. dol_trunc($line->command);
- if(!empty($line->params)) {
- print ' '.$langs->trans('CronArgs').':'. $line->params;
+ $texttoshow.=' '.$langs->trans('CronArgs').':'. $line->params;
}
}
+ elseif ($line->jobtype=='command')
+ {
+ $text=$langs->trans('CronCommand');
+ $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($line->command);
+ if(!empty($line->params)) {
+ $texttoshow=' '.$langs->trans('CronArgs').':'. $line->params;
+ }
+ }
+ print $form->textwithpicto($text, $texttoshow, 1);
+ print ' ';
+
+ print '';
+ if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Minutes');
+ if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Hours');
+ if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Days');
+ if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency)." ".$langs->trans('Weeks');
print ' ';
print '';
@@ -268,17 +280,6 @@ if ($num > 0)
if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhour');}
print ' ';
- print '';
- if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');}
- print ' ';
-
- print '';
- if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Minutes');
- if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Hours');
- if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Days');
- if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Weeks');
- print ' ';
-
print '';
if (!empty($line->maxrun)) {print $line->maxrun;}
print ' ';
@@ -287,6 +288,10 @@ if ($num > 0)
if (!empty($line->nbrun)) {print $line->nbrun;} else {print '0';}
print '';
+ print '';
+ if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhour');}
+ print ' ';
+
print '';
if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhour');}
print ' ';
@@ -307,6 +312,10 @@ if ($num > 0)
print '';
print '';
+ if ($user->rights->cron->create)
+ {
+ print "id."&action=edit&backtourl=".urlencode($_SERVER["PHP_SELF"])."\" title=\"".dol_escape_htmltag($langs->trans('Edit'))."\">".img_picto($langs->trans('Edit'),'edit')." ";
+ }
if ($user->rights->cron->delete)
{
print "id."&status=".$status."&action=delete\" title=\"".dol_escape_htmltag($langs->trans('CronDelete'))."\">".img_picto($langs->trans('CronDelete'),'delete')." ";
diff --git a/htdocs/langs/en_US/bills.lang b/htdocs/langs/en_US/bills.lang
index bc8062a5f9d..23f9ba4b532 100644
--- a/htdocs/langs/en_US/bills.lang
+++ b/htdocs/langs/en_US/bills.lang
@@ -224,6 +224,7 @@ NonPercuRecuperable=Non-recoverable
SetConditions=Set payment terms
SetMode=Set payment mode
Billed=Billed
+RecurringInvoices=Recurring invoices
RepeatableInvoice=Template invoice
RepeatableInvoices=Template invoices
Repeatable=Template
diff --git a/htdocs/projet/list.php b/htdocs/projet/list.php
index a644e9663bb..d503c6093ad 100644
--- a/htdocs/projet/list.php
+++ b/htdocs/projet/list.php
@@ -78,12 +78,12 @@ $optioncss = GETPOST('optioncss','alpha');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
if ($mine) $search_user = $user->id;
-$day = GETPOST('day','int');
-$month = GETPOST('month','int');
-$year = GETPOST('year','int');
$sday = GETPOST('sday','int');
$smonth = GETPOST('smonth','int');
$syear = GETPOST('syear','int');
+$day = GETPOST('day','int');
+$month = GETPOST('month','int');
+$year = GETPOST('year','int');
if ($search_status == '') $search_status=-1; // -1 or 1
@@ -150,12 +150,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_public="";
$search_sale="";
$search_user='';
- $day="";
- $month="";
- $year="";
$sday="";
$smonth="";
$syear="";
+ $day="";
+ $month="";
+ $year="";
$search_array_options=array();
}
diff --git a/htdocs/projet/tasks/list.php b/htdocs/projet/tasks/list.php
index 48cbcb86a1a..2a89ef45ae6 100644
--- a/htdocs/projet/tasks/list.php
+++ b/htdocs/projet/tasks/list.php
@@ -28,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
+require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
$langs->load('projects');
$langs->load('users');
@@ -46,6 +47,13 @@ $search_task_user=GETPOST('search_task_user');
$mine = $_REQUEST['mode']=='mine' ? 1 : 0;
if ($mine) $search_task_user = $user->id;
+$sday = GETPOST('sday','int');
+$smonth = GETPOST('smonth','int');
+$syear = GETPOST('syear','int');
+$day = GETPOST('day','int');
+$month = GETPOST('month','int');
+$year = GETPOST('year','int');
+
// Security check
$socid=0;
if ($user->societe_id > 0) $socid = $user->societe_id;
@@ -67,6 +75,12 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP
$search_task_label="";
$search_task_user=-1;
$search_project_user=-1;
+ $sday='';
+ $smonth='';
+ $syear='';
+ $day='';
+ $month='';
+ $year='';
}
if (empty($search_projectstatus) && $search_projectstatus == '') $search_projectstatus=1;
@@ -74,7 +88,35 @@ if (empty($search_projectstatus) && $search_projectstatus == '') $search_project
$fieldstosearchall = array(
't.ref'=>"Ref",
't.label'=>"Label",
+ 't.note_public'=>"NotePublic",
);
+if (empty($user->socid)) $fieldstosearchall['t.note_private']="NotePrivate";
+
+$arrayfields=array(
+ 'p.ref'=>array('label'=>$langs->trans("Project"), 'checked'=>1),
+ 'p.title'=>array('label'=>$langs->trans("ProjectLabel"), 'checked'=>1),
+ 'p.fk_statut'=>array('label'=>$langs->trans("ProjectStatus"), 'checked'=>1),
+ //'s.nom'=>array('label'=>$langs->trans("ThirdParty"), 'checked'=>1),
+ 't.title'=>array('label'=>$langs->trans("TaskLabel"), 'checked'=>1, 'position'=>80),
+ 't.dateo'=>array('label'=>$langs->trans("DateStart"), 'checked'=>1, 'position'=>100),
+ 't.datee'=>array('label'=>$langs->trans("DateEnd"), 'checked'=>1, 'position'=>101),
+ 't.planned_workload'=>array('label'=>$langs->trans("Workload"), 'checked'=>1, 'position'=>102),
+ 't.duration_effective'=>array('label'=>$langs->trans("TimeConsumed"), 'checked'=>1, 'position'=>103),
+ // Calculated progression
+ 't.progress'=>array('label'=>$langs->trans("TimeDeclared"), 'checked'=>1, 'position'=>105),
+
+ 't.datec'=>array('label'=>$langs->trans("DateCreation"), 'checked'=>0, 'position'=>500),
+ 't.tms'=>array('label'=>$langs->trans("DateModificationShort"), 'checked'=>0, 'position'=>500),
+ 't.fk_statut'=>array('label'=>$langs->trans("Status"), 'checked'=>1, 'position'=>1000),
+);
+// Extra fields
+if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
+{
+ foreach($extrafields->attribute_label as $key => $val)
+ {
+ $arrayfields["ef.".$key]=array('label'=>$extrafields->attribute_label[$key], 'checked'=>$extrafields->attribute_list[$key], 'position'=>$extrafields->attribute_pos[$key], 'enabled'=>$extrafields->attribute_perms[$key]);
+ }
+}
/*
@@ -89,6 +131,7 @@ $fieldstosearchall = array(
*/
$form=new Form($db);
+$formother=new FormOther($db);
$projectstatic = new Project($db);
$taskstatic = new Task($db);
$puser=new User($db);
@@ -121,15 +164,43 @@ else
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,$mine,1,$socid);
//var_dump($projectsListId);
+
+
// Get list of tasks in tasksarray and taskarrayfiltered
// We need all tasks (even not limited to a user because a task assigned to a user can have a parent that is not assigned to him and we need such parents).
$morewherefilter='';
if ($search_all) $morewherefilter.=natural_search(array_keys($fieldstosearchall), $search_all);
if ($search_task_ref) $morewherefilter.=natural_search('t.ref', $search_task_ref);
if ($search_task_label) $morewherefilter.=natural_search('t.label', $search_task_label);
+if ($smonth > 0)
+{
+ if ($syear > 0 && empty($sday))
+ $morewherefilter.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($syear,$smonth,false))."' AND '".$db->idate(dol_get_last_day($syear,$smonth,false))."'";
+ else if ($syear > 0 && ! empty($sday))
+ $morewherefilter.= " AND t.dateo BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $smonth, $sday, $syear))."' AND '".$db->idate(dol_mktime(23, 59, 59, $smonth, $sday, $syear))."'";
+ else
+ $morewherefilter.= " AND date_format(t.dateo, '%m') = '".$smonth."'";
+}
+else if ($syear > 0)
+{
+ $morewherefilter.= " AND t.dateo BETWEEN '".$db->idate(dol_get_first_day($syear,1,false))."' AND '".$db->idate(dol_get_last_day($syear,12,false))."'";
+}
+if ($month > 0)
+{
+ if ($year > 0 && empty($day))
+ $morewherefilter.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($year,$month,false))."' AND '".$db->idate(dol_get_last_day($year,$month,false))."'";
+ else if ($year > 0 && ! empty($day))
+ $morewherefilter.= " AND t.datee BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $month, $day, $year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $month, $day, $year))."'";
+ else
+ $morewherefilter.= " AND date_format(t.datee, '%m') = '".$month."'";
+}
+else if ($year > 0)
+{
+ $morewherefilter.= " AND t.datee BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
+}
-$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_projectstatus, $morewherefilter, $search_project_user, 0); // We don't use filter on task user. Because sometimes a task is assigned but not the parent one and we want to show also parent, so filtering is done during output
-$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, ($tuser->id?$tuser:null), $projectstatic->id, 0, $search_projectstatus); // We load also tasks limited to a particular user
+//$tasksarray=$taskstatic->getTasksArray(0, 0, $projectstatic->id, $socid, 0, $search_project, $search_projectstatus, $morewherefilter, $search_project_user, 0); // We don't use filter on task user. Because sometimes a task is assigned but not the parent one and we want to show also parent, so filtering is done during output
+//$tasksrole=$taskstatic->getUserRolesForProjectsOrTasks(0, ($tuser->id?$tuser:null), $projectstatic->id, 0, $search_projectstatus); // We load also tasks limited to a particular user
print ' ';
print '';
print ' ';
print ' ';
-print '';
+// Start date
+if (! empty($arrayfields['t.dateo']['checked']))
+{
+ print ' ';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($syear?$syear:-1,'syear',1, 20, 5);
+ print ' ';
+}
+// End date
+if (! empty($arrayfields['t.datee']['checked']))
+{
+ print '';
+ if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print ' ';
+ print ' ';
+ $formother->select_year($year?$year:-1,'year',1, 20, 5);
+ print ' ';
+}
+print '';
print ' ';
print ' ';
print ' ';
print ' ';
print ' ';
+print ' ';
+/*
$max=10000;
-
if (count($tasksarray) > (empty($conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA)?$max:$conf->global->PROJECT_LIMIT_TASK_PROJECT_AREA))
{
$langs->load("errors");
@@ -226,9 +316,14 @@ else
{
// Show all lines in taskarray (recursive function to go down on tree)
$j=0; $level=0;
+ if ($morewherefilter) $level=-1; // No recursive output when there is search criteria
//var_dump($tasksarray);
$nboftaskshown=projectLinesa($j, 0, $tasksarray, $level, true, 1, $tasksrole, $projectsListId, 0);
}
+*/
+
+
+
print "
";