New: Switch cron module to status stable. Thanks to everybody to test
this new module and debug it.
This commit is contained in:
parent
949565dde4
commit
ec2e3db450
13
ChangeLog
13
ChangeLog
@ -19,14 +19,15 @@ For users:
|
|||||||
- New: Add object_hour as substitution tag for opendocument generation.
|
- New: Add object_hour as substitution tag for opendocument generation.
|
||||||
- New: Add option MEMBER_PAYONLINE_SENDEMAIL to send email when paypal or paybox payment is done.
|
- New: Add option MEMBER_PAYONLINE_SENDEMAIL to send email when paypal or paybox payment is done.
|
||||||
- New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
- New: Implement same rule for return value of all command line scripts (0 when success, <>0 if error).
|
||||||
- New: Clone product/service composition
|
- New: Clone product/service composition.
|
||||||
- New: [ task #926 ] Add extrafield feature on order lines
|
- New: [ task #926 ] Add extrafield feature on order lines.
|
||||||
- New: [ task #927 ] Add extrafield feature on Proposal lines
|
- New: [ task #927 ] Add extrafield feature on Proposal lines.
|
||||||
- New: [ task #928 ] Add extrafield feature on invoice lines
|
- New: [ task #928 ] Add extrafield feature on invoice lines.
|
||||||
- New: Add option ADHERENT_LOGIN_NOT_REQUIRED
|
- New: Add option ADHERENT_LOGIN_NOT_REQUIRED.
|
||||||
|
- New: Add a cron module.
|
||||||
|
|
||||||
For translators:
|
For translators:
|
||||||
- Normalized sort order of all languages files with english ref file.
|
- Normalized sort order of all languages files with english reference files.
|
||||||
|
|
||||||
For developers:
|
For developers:
|
||||||
- New: DolGraph can build graph with three lines.
|
- New: DolGraph can build graph with three lines.
|
||||||
|
|||||||
@ -22,6 +22,7 @@
|
|||||||
* \ingroup cron
|
* \ingroup cron
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return array of tabs to used on pages to setup cron module.
|
* Return array of tabs to used on pages to setup cron module.
|
||||||
*
|
*
|
||||||
@ -74,3 +75,53 @@ function cron_prepare_head($object)
|
|||||||
|
|
||||||
return $head;
|
return $head;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show information with URLs to launch jobs
|
||||||
|
*
|
||||||
|
* @return int 0
|
||||||
|
*/
|
||||||
|
function dol_print_cron_urls()
|
||||||
|
{
|
||||||
|
global $conf, $langs, $user;
|
||||||
|
global $dolibarr_main_url_root;
|
||||||
|
|
||||||
|
// Define $urlwithroot
|
||||||
|
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||||
|
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||||
|
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||||
|
|
||||||
|
// Cron launch
|
||||||
|
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
||||||
|
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
|
||||||
|
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||||
|
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
||||||
|
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
||||||
|
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
||||||
|
|
||||||
|
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$user->login.' [cronjobid]';
|
||||||
|
print '<textarea rows="'.ROWS_2.'" cols="120">..'.$file."</textarea><br>\n";
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
// Add note
|
||||||
|
$linuxlike=1;
|
||||||
|
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
|
||||||
|
if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
|
||||||
|
print $langs->trans("Note").': ';
|
||||||
|
if ($linuxlike)
|
||||||
|
{
|
||||||
|
print $langs->trans("CronExplainHowToRunUnix");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print $langs->trans("CronExplainHowToRunWin");
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -48,7 +48,7 @@ class modCron extends DolibarrModules
|
|||||||
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
// Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module)
|
||||||
$this->name = preg_replace('/^mod/i','',get_class($this));
|
$this->name = preg_replace('/^mod/i','',get_class($this));
|
||||||
$this->description = "Enable the Dolibarr cron service";
|
$this->description = "Enable the Dolibarr cron service";
|
||||||
$this->version = 'experimental'; // 'experimental' or 'dolibarr' or version
|
$this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version
|
||||||
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
// Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase)
|
||||||
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
$this->const_name = 'MAIN_MODULE_'.strtoupper($this->name);
|
||||||
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
// Where to store the module in setup page (0=common,1=interface,2=others,3=very specific)
|
||||||
|
|||||||
@ -107,39 +107,7 @@ dol_fiche_end();
|
|||||||
print '<br><br>';
|
print '<br><br>';
|
||||||
|
|
||||||
|
|
||||||
// Define $urlwithroot
|
dol_print_cron_urls();
|
||||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
|
||||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
|
||||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
|
||||||
|
|
||||||
// Cron launch
|
|
||||||
print '<u>'.$langs->trans("URLToLaunchCronJobs").':</u><br>';
|
|
||||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login;
|
|
||||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
|
||||||
print ' '.$langs->trans("OrToLaunchASpecificJob").'<br>';
|
|
||||||
$url=$urlwithroot.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid';
|
|
||||||
print img_picto('','object_globe.png').' <a href="'.$url.'" target="_blank">'.$url."</a><br>\n";
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
|
|
||||||
$linuxlike=1;
|
|
||||||
if (preg_match('/^win/i',PHP_OS)) $linuxlike=0;
|
|
||||||
if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0;
|
|
||||||
|
|
||||||
print '<br>';
|
|
||||||
print '<u>'.$langs->trans("FileToLaunchCronJobs").':</u><br>';
|
|
||||||
|
|
||||||
$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->CRON_KEY)?'securitykey':''.$conf->global->CRON_KEY.'').' '.$user->login.' [cronjobid]';
|
|
||||||
print '<textarea rows="'.ROWS_2.'" cols="120">..'.$file."</textarea><br>\n";
|
|
||||||
print '<br>';
|
|
||||||
print $langs->trans("Note").': ';
|
|
||||||
if ($linuxlike) {
|
|
||||||
print $langs->trans("CronExplainHowToRunUnix");
|
|
||||||
} else {
|
|
||||||
print $langs->trans("CronExplainHowToRunWin");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
||||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro>
|
* Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro>
|
||||||
|
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -43,55 +44,66 @@ $confirm=GETPOST('confirm','alpha');
|
|||||||
$cancel=GETPOST('cancel');
|
$cancel=GETPOST('cancel');
|
||||||
|
|
||||||
$object = new Cronjob($db);
|
$object = new Cronjob($db);
|
||||||
if (!empty($id)) {
|
if (!empty($id))
|
||||||
|
{
|
||||||
$result=$object->fetch($id);
|
$result=$object->fetch($id);
|
||||||
if ($result < 0) {
|
if ($result < 0)
|
||||||
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!empty($cancel)) {
|
if(!empty($cancel))
|
||||||
if (!empty($id)) {
|
{
|
||||||
|
if (!empty($id))
|
||||||
|
{
|
||||||
$action='';
|
$action='';
|
||||||
}else {
|
|
||||||
Header("Location: ".dol_buildpath('/cron/cron/list.php',1).'?status=1');
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=1');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Delete jobs
|
// Delete jobs
|
||||||
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){
|
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete)
|
||||||
|
{
|
||||||
|
|
||||||
$result = $object->delete($user);
|
$result = $object->delete($user);
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0)
|
||||||
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
$action='edit';
|
$action='edit';
|
||||||
}else {
|
}
|
||||||
Header("Location: ".dol_buildpath('/cron/cron/list.php',1).'?status=1');
|
else
|
||||||
|
{
|
||||||
|
Header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=1');
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Execute jobs
|
// Execute jobs
|
||||||
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){
|
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute)
|
||||||
|
{
|
||||||
$result=$object->run_jobs($user->login);
|
$result=$object->run_jobs($user->login);
|
||||||
|
|
||||||
if ($result < 0) {
|
if ($result < 0)
|
||||||
|
{
|
||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
$action='';
|
$action='';
|
||||||
}else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings');
|
if ($object->lastresult > 0) setEventMessage($langs->trans("JobFinished"),'warnings');
|
||||||
else setEventMessage($langs->trans("JobFinished"),'mesgs');
|
else setEventMessage($langs->trans("JobFinished"),'mesgs');
|
||||||
$action='';
|
$action='';
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($action=='add') {
|
if ($action=='add')
|
||||||
|
{
|
||||||
$object->jobtype=GETPOST('jobtype','alpha');
|
$object->jobtype=GETPOST('jobtype','alpha');
|
||||||
$object->label=GETPOST('label','alpha');
|
$object->label=GETPOST('label','alpha');
|
||||||
$object->command=GETPOST('command','alpha');
|
$object->command=GETPOST('command','alpha');
|
||||||
@ -123,7 +135,8 @@ if ($action=='add') {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Save parameters
|
// Save parameters
|
||||||
if ($action=='update') {
|
if ($action=='update')
|
||||||
|
{
|
||||||
$object->id=$id;
|
$object->id=$id;
|
||||||
$object->jobtype=GETPOST('jobtype');
|
$object->jobtype=GETPOST('jobtype');
|
||||||
$object->label=GETPOST('label');
|
$object->label=GETPOST('label');
|
||||||
@ -155,7 +168,8 @@ if ($action=='update') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=='activate') {
|
if ($action=='activate')
|
||||||
|
{
|
||||||
$object->status=1;
|
$object->status=1;
|
||||||
|
|
||||||
//Ajout de la tache cron
|
//Ajout de la tache cron
|
||||||
@ -172,7 +186,8 @@ if ($action=='activate') {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($action=='inactive') {
|
if ($action=='inactive')
|
||||||
|
{
|
||||||
$object->status=0;
|
$object->status=0;
|
||||||
//Ajout de la tache cron
|
//Ajout de la tache cron
|
||||||
$result = $object->update($user);
|
$result = $object->update($user);
|
||||||
@ -199,7 +214,7 @@ llxHeader('',$langs->trans("CronAdd"));
|
|||||||
if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute')
|
if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute')
|
||||||
{
|
{
|
||||||
$head=cron_prepare_head($object);
|
$head=cron_prepare_head($object);
|
||||||
dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'bill');
|
print dol_get_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'bill');
|
||||||
}
|
}
|
||||||
elseif ($action=='create')
|
elseif ($action=='create')
|
||||||
{
|
{
|
||||||
@ -441,16 +456,12 @@ if (($action=="create") || ($action=="edit"))
|
|||||||
print "</td>";
|
print "</td>";
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
|
||||||
print '<tr><td colspan="2" align="center">';
|
print '<div align="center"><br>';
|
||||||
print "<input type=\"submit\" name=\"save\" class=\"button\" value=\"".$langs->trans("Save")."\">";
|
print '<input type="submit" name="save" class="button" value="'.$langs->trans("Save").'">';
|
||||||
print "<input type=\"submit\" name=\"cancel\" class=\"button\" value=\"".$langs->trans("Cancel")."\">";
|
print '<input type="submit" name="cancel" class="button" value="'.$langs->trans("Cancel").'">';
|
||||||
print "</td>";
|
print "</center>";
|
||||||
print "<td>";
|
|
||||||
print "</td>";
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
|
|
||||||
@ -608,5 +619,8 @@ if (($action=="create") || ($action=="edit"))
|
|||||||
print '<br><br></div>';
|
print '<br><br></div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
llxFooter();
|
?>
|
||||||
@ -25,8 +25,6 @@
|
|||||||
|
|
||||||
require '../main.inc.php';
|
require '../main.inc.php';
|
||||||
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php");
|
||||||
|
|
||||||
// librairie jobs
|
|
||||||
require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php";
|
require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php";
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php';
|
||||||
|
|
||||||
@ -99,6 +97,8 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
|
|||||||
setEventMessage($object->error,'errors');
|
setEventMessage($object->error,'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-1'); // Make a call to avoid to run twice job when using back
|
||||||
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -141,8 +141,8 @@ if ($result < 0) {
|
|||||||
|
|
||||||
print "<br><br>";
|
print "<br><br>";
|
||||||
|
|
||||||
if (count($object->lines)>0) {
|
if (count($object->lines)>0)
|
||||||
|
{
|
||||||
print '<table class="noborder">';
|
print '<table class="noborder">';
|
||||||
print '<tr class="liste_titre">';
|
print '<tr class="liste_titre">';
|
||||||
$arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label;
|
$arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label;
|
||||||
@ -156,7 +156,7 @@ if (count($object->lines)>0) {
|
|||||||
print_liste_field_titre($langs->trans("CronNbRun"),$_SERVEUR['PHP_SELF'],"t.nbrun","",$arg_url,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("CronNbRun"),$_SERVEUR['PHP_SELF'],"t.nbrun","",$arg_url,'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVEUR['PHP_SELF'],"t.lastresult","",$arg_url,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("CronLastResult"),$_SERVEUR['PHP_SELF'],"t.lastresult","",$arg_url,'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVEUR['PHP_SELF'],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVEUR['PHP_SELF'],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder);
|
||||||
print_liste_field_titre($langs->trans("Active"),$_SERVEUR['PHP_SELF'],"t.status","",$arg_url,'align="center"',$sortfield,$sortorder);
|
print_liste_field_titre($langs->trans("Enabled"),$_SERVEUR['PHP_SELF'],"t.status","",$arg_url,'align="center"',$sortfield,$sortorder);
|
||||||
print '<td></td>';
|
print '<td></td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
@ -303,6 +303,10 @@ print '</div>';
|
|||||||
|
|
||||||
print '<br>';
|
print '<br>';
|
||||||
|
|
||||||
|
|
||||||
|
dol_print_cron_urls();
|
||||||
|
|
||||||
|
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|||||||
@ -21,12 +21,12 @@ Permission23104 = Execute Scheduled task
|
|||||||
#
|
#
|
||||||
# Admin
|
# Admin
|
||||||
#
|
#
|
||||||
CronSetup= Configuration Scheduled task management
|
CronSetup= Scheduled job management setup
|
||||||
URLToLaunchCronJobs=URL to launch cron jobs
|
URLToLaunchCronJobs=URL to launch cron jobs
|
||||||
OrToLaunchASpecificJob=Or to launch a specific job
|
OrToLaunchASpecificJob=Or to launch a specific job
|
||||||
KeyForCronAccess=Security key for URL to launch cron jobs
|
KeyForCronAccess=Security key for URL to launch cron jobs
|
||||||
FileToLaunchCronJobs=Command to launch cron jobs
|
FileToLaunchCronJobs=Command line to launch cron jobs
|
||||||
CronExplainHowToRunUnix=On Unix environement you should use crontab to run Command line each minutes
|
CronExplainHowToRunUnix=On Unix environment you should use crontab to run Command line each minutes
|
||||||
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run Command line each minutes
|
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run Command line each minutes
|
||||||
|
|
||||||
|
|
||||||
@ -48,15 +48,15 @@ CronListOfCronJobs=List of scheduled jobs
|
|||||||
CronCommand=Command
|
CronCommand=Command
|
||||||
CronList= Job list
|
CronList= Job list
|
||||||
CronDelete= Delete cron jobs
|
CronDelete= Delete cron jobs
|
||||||
CronConfirmDelete= Are you sure to delete this cron jobs ?
|
CronConfirmDelete= Are you sure you want to delete this cron job ?
|
||||||
CronExecute=Launch task
|
CronExecute=Launch job
|
||||||
CronConfirmExecute= Are you sure to execute this job now
|
CronConfirmExecute= Are you sure to execute this job now
|
||||||
CronInfo= Jobs allow to execute task that have been planned
|
CronInfo= Jobs allow to execute task that have been planned
|
||||||
CronWaitingJobs=Wainting jobs
|
CronWaitingJobs=Wainting jobs
|
||||||
CronTask=Task
|
CronTask=Job
|
||||||
CronNone= None
|
CronNone= None
|
||||||
CronDtStart=Start date
|
CronDtStart=Start date
|
||||||
CronDtEnd=End fin
|
CronDtEnd=End date
|
||||||
CronDtNextLaunch=Next execution
|
CronDtNextLaunch=Next execution
|
||||||
CronDtLastLaunch=Last execution
|
CronDtLastLaunch=Last execution
|
||||||
CronFrequency=Frequancy
|
CronFrequency=Frequancy
|
||||||
@ -65,12 +65,14 @@ CronMethod=Method
|
|||||||
CronModule=Module
|
CronModule=Module
|
||||||
CronAction=Action
|
CronAction=Action
|
||||||
CronStatus=Status
|
CronStatus=Status
|
||||||
CronStatusActive=Active
|
CronStatusActive=Enabled
|
||||||
CronStatusInactive=Inactive
|
CronStatusInactive=Disabled
|
||||||
CronNoJobs=No jobs registered
|
CronNoJobs=No jobs registered
|
||||||
CronPriority=Priority
|
CronPriority=Priority
|
||||||
CronLabel=Description
|
CronLabel=Description
|
||||||
CronNbRun=Nb. launch
|
CronNbRun=Nb. launch
|
||||||
|
CronEach=Every
|
||||||
|
JobFinished=Job launched and finished
|
||||||
|
|
||||||
#
|
#
|
||||||
#Page card
|
#Page card
|
||||||
@ -84,12 +86,12 @@ CronSaveSucess=Save succesfully
|
|||||||
CronNote=Comment
|
CronNote=Comment
|
||||||
CronFieldMandatory=Fields %s is mandatory
|
CronFieldMandatory=Fields %s is mandatory
|
||||||
CronErrEndDateStartDt=End date cannot be before start date
|
CronErrEndDateStartDt=End date cannot be before start date
|
||||||
CronStatusActiveBtn=Active
|
CronStatusActiveBtn=Enable
|
||||||
CronStatusInactiveBtn=Inactive
|
CronStatusInactiveBtn=Disable
|
||||||
CronTaskInactive=This task is inactive
|
CronTaskInactive=This job is disabled
|
||||||
CronDtLastResult=Last result date
|
CronDtLastResult=Last result date
|
||||||
CronId=Id
|
CronId=Id
|
||||||
CronClassFile=Classes (file name)
|
CronClassFile=Classes (filename.class.php)
|
||||||
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value of module is <i>product</i>
|
CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module). <BR> For exemple to fetch method of Dolibarr Product object /htdocs/<u>product</u>/class/product.class.php, the value of module is <i>product</i>
|
||||||
CronClassFileHelp=The file name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/<u>product.class.php</u>, the value of class file name is <i>product.class.php</i>
|
CronClassFileHelp=The file name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/<u>product.class.php</u>, the value of class file name is <i>product.class.php</i>
|
||||||
CronObjectHelp=The object name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is <i>Product</i>
|
CronObjectHelp=The object name to load. <BR> For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is <i>Product</i>
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
# Dolibarr language file - en_US - cron
|
# Dolibarr language file - en_US - cron
|
||||||
CHARSET=UTF-8
|
CHARSET=UTF-8
|
||||||
Module2310Name=Cron
|
Module2310Name=Cron
|
||||||
Module2310Desc=Gestion des tâches programmées
|
Module2310Desc=Gestion des travaux programmées
|
||||||
|
|
||||||
#
|
#
|
||||||
# About page
|
# About page
|
||||||
@ -13,20 +13,20 @@ CronAboutPage = Page à propos de Cron
|
|||||||
#
|
#
|
||||||
# Right
|
# Right
|
||||||
#
|
#
|
||||||
Permission23101 = Voir la tâche planifiée
|
Permission23101 = Voir les travaux planifiés
|
||||||
Permission23102 = Créer/modifier la tâche planifiée
|
Permission23102 = Créer/modifier des travaux planifiés
|
||||||
Permission23103 = Supprimer la tâche planifiée
|
Permission23103 = Supprimer un travail planifiée
|
||||||
Permission23104 = Lancer la tâche planifiée
|
Permission23104 = Lancer un travail planifié
|
||||||
|
|
||||||
#
|
#
|
||||||
# Admin
|
# Admin
|
||||||
#
|
#
|
||||||
CronSetup= Page de configuration du module - Gestion des tâches planifiées
|
CronSetup= Page de configuration du module - Gestion des travaux planifiées
|
||||||
URLToLaunchCronJobs=URL pour lancer les travaux cron
|
URLToLaunchCronJobs=URL pour lancer les travaux planifiés actifs
|
||||||
OrToLaunchASpecificJob=Ou pour lancer un travail spécifique
|
OrToLaunchASpecificJob=Ou pour lancer un travail planifié spécifique
|
||||||
KeyForCronAccess=Clé de sécurité pour l'URL de lancement des travaux cron
|
KeyForCronAccess=Clé de sécurité pour l'URL de lancement des travaux planifiés
|
||||||
FileToLaunchCronJobs=Commande pour lancer les travaux cron
|
FileToLaunchCronJobs=Commande pour lancer les travaux planifiés actifs
|
||||||
CronExplainHowToRunUnix=Sur un environnement Unix vous devez utiliser crontab pour exécuter une commande toute les minutes
|
CronExplainHowToRunUnix=Sur un environnement Unix vous pouvez utiliser 'crontab' pour exécuter une commande toute les minutes
|
||||||
CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utiliser le planificateur de tâche pour lancer une commande toute les minutes
|
CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utiliser le planificateur de tâche pour lancer une commande toute les minutes
|
||||||
|
|
||||||
|
|
||||||
@ -71,6 +71,8 @@ CronNoJobs=Aucun travail enregistré
|
|||||||
CronPriority=Priorité
|
CronPriority=Priorité
|
||||||
CronLabel=Description
|
CronLabel=Description
|
||||||
CronNbRun=Nb. exec.
|
CronNbRun=Nb. exec.
|
||||||
|
CronEach=Tous les
|
||||||
|
JobFinished=Tache lancée et terminée
|
||||||
|
|
||||||
#
|
#
|
||||||
#Page card
|
#Page card
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
||||||
* Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro
|
* Copyright (C) 2013 Florian Henry <forian.henry@open-cocnept.pro>
|
||||||
|
* Copyright (C) 2013 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -40,9 +41,20 @@ if (! $res) die("Include of master.inc.php fails");
|
|||||||
// librarie jobs
|
// librarie jobs
|
||||||
dol_include_once("/cron/class/cronjob.class.php");
|
dol_include_once("/cron/class/cronjob.class.php");
|
||||||
|
|
||||||
|
|
||||||
global $langs, $conf;
|
global $langs, $conf;
|
||||||
|
|
||||||
|
// Language Management
|
||||||
|
$langs->load("admin");
|
||||||
|
$langs->load("cron");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
// Check the key, avoid that a stranger starts cron
|
// Check the key, avoid that a stranger starts cron
|
||||||
$key = $_GET['securitykey'];
|
$key = $_GET['securitykey'];
|
||||||
if (empty($key)) {
|
if (empty($key)) {
|
||||||
@ -55,80 +67,101 @@ if($key != $conf->global->CRON_KEY)
|
|||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// Check the key, avoid that a stranger starts cron
|
// Check the key, avoid that a stranger starts cron
|
||||||
$userlogin = $_GET['userlogin'];
|
$userlogin = GETPOST('userlogin');
|
||||||
if (empty($userlogin)) {
|
if (empty($userlogin))
|
||||||
|
{
|
||||||
echo 'userlogin is require';
|
echo 'userlogin is require';
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
$user=new User($db);
|
$user=new User($db);
|
||||||
$result=$user->fetch('',$userlogin);
|
$result=$user->fetch('',$userlogin);
|
||||||
if ($result<0) {
|
if ($result < 0)
|
||||||
|
{
|
||||||
echo "User Error:".$user->error;
|
echo "User Error:".$user->error;
|
||||||
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_WARNING);
|
||||||
exit;
|
exit;
|
||||||
}else {
|
}
|
||||||
if (empty($user->id)) {
|
else
|
||||||
|
{
|
||||||
|
if (empty($user->id))
|
||||||
|
{
|
||||||
echo " User user login:".$userlogin." do not exists";
|
echo " User user login:".$userlogin." do not exists";
|
||||||
dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR);
|
dol_syslog(" User user login:".$userlogin." do not exists", LOG_WARNING);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$id = $_GET['id'];
|
$id = GETPOST('id');
|
||||||
|
|
||||||
// Language Management
|
|
||||||
$langs->load("admin");
|
|
||||||
$langs->load("cron@cron");
|
|
||||||
|
|
||||||
// create a jobs object
|
// create a jobs object
|
||||||
$object = new Cronjob($db);
|
$object = new Cronjob($db);
|
||||||
|
|
||||||
$filter=array();
|
$filter=array();
|
||||||
if (empty($id)) {
|
if (! empty($id))
|
||||||
|
{
|
||||||
|
if (! is_numeric($id))
|
||||||
|
{
|
||||||
|
echo "Error: Bad value for parameter job id";
|
||||||
|
dol_syslog("cron_run_jobs.php Bad value for parameter job id", LOG_WARNING);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
$filter=array();
|
$filter=array();
|
||||||
$filter['t.rowid']=$id;
|
$filter['t.rowid']=$id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
|
$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter);
|
||||||
if ($result<0) {
|
if ($result<0)
|
||||||
echo "Error:".$cronjob->error;
|
{
|
||||||
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
|
echo "Error: ".$cronjob->error;
|
||||||
|
dol_syslog("cron_run_jobs.php fetch Error".$cronjob->error, LOG_WARNING);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
// current date
|
// current date
|
||||||
$now=dol_now();
|
$now=dol_now();
|
||||||
|
$nbofjobs=count($object->lines);
|
||||||
|
$nbofjobslaunchedok=0;
|
||||||
|
$nbofjobslaunchedko=0;
|
||||||
|
|
||||||
if(is_array($object->lines) && (count($object->lines)>0)){
|
if (is_array($object->lines) && (count($object->lines)>0))
|
||||||
|
{
|
||||||
// Loop over job
|
// Loop over job
|
||||||
foreach($object->lines as $line){
|
foreach($object->lines as $line)
|
||||||
|
{
|
||||||
dol_syslog("cron_run_jobs.php:: fetch cronjobid:".$line->id, LOG_ERR);
|
dol_syslog("cron_run_jobs.php fetch cronjobid: ".$line->id, LOG_WARNING);
|
||||||
|
|
||||||
//If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
|
//If date_next_jobs is less of current dat, execute the program, and store the execution time of the next execution in database
|
||||||
if ((($line->datenextrun <= $now) && $line->dateend < $now)
|
if ((($line->datenextrun <= $now) && $line->dateend < $now)
|
||||||
|| ((empty($line->datenextrun)) && (empty($line->dateend)))){
|
|| ((empty($line->datenextrun)) && (empty($line->dateend))))
|
||||||
|
{
|
||||||
|
|
||||||
dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext'), LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: torun line->datenextrun:".dol_print_date($line->datenextrun,'dayhourtext')." line->dateend:".dol_print_date($line->dateend,'dayhourtext')." now:".dol_print_date($now,'dayhourtext'));
|
||||||
|
|
||||||
$cronjob=new Cronjob($db);
|
$cronjob=new Cronjob($db);
|
||||||
$result=$cronjob->fetch($line->id);
|
$result=$cronjob->fetch($line->id);
|
||||||
if ($result<0) {
|
if ($result<0)
|
||||||
|
{
|
||||||
echo "Error:".$cronjob->error;
|
echo "Error:".$cronjob->error;
|
||||||
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
// execute methode
|
// Execut job
|
||||||
$result=$cronjob->run_jobs($userlogin);
|
$result=$cronjob->run_jobs($userlogin);
|
||||||
if ($result<0) {
|
if ($result<0)
|
||||||
|
{
|
||||||
echo "Error:".$cronjob->error;
|
echo "Error:".$cronjob->error;
|
||||||
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: run_jobs Error".$cronjob->error, LOG_ERR);
|
||||||
exit;
|
$nbofjobslaunchedko++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$nbofjobslaunchedok++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// we re-program the next execution and stores the last execution time for this job
|
// We re-program the next execution and stores the last execution time for this job
|
||||||
$result=$cronjob->reprogram_jobs($userlogin);
|
$result=$cronjob->reprogram_jobs($userlogin);
|
||||||
if ($result<0) {
|
if ($result<0)
|
||||||
|
{
|
||||||
echo "Error:".$cronjob->error;
|
echo "Error:".$cronjob->error;
|
||||||
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
|
dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR);
|
||||||
exit;
|
exit;
|
||||||
@ -136,7 +169,12 @@ if(is_array($object->lines) && (count($object->lines)>0)){
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo "OK";
|
echo "Result: ".($nbofjobs)." jobs - ".($nbofjobslaunchedok+$nbofjobslaunchedko)." launched = ".$nbofjobslaunchedok." OK + ".$nbofjobslaunchedko." KO";
|
||||||
} else {
|
|
||||||
echo "No Jobs to run";
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
echo "No active jobs found";
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->close();
|
||||||
|
?>
|
||||||
Loading…
Reference in New Issue
Block a user