Add cronjobs view in modulebuilder
This commit is contained in:
parent
760d2617a0
commit
9ca874fde4
@ -18,7 +18,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/cron/cron/list.php
|
* \file htdocs/cron/list.php
|
||||||
* \ingroup cron
|
* \ingroup cron
|
||||||
* \brief Lists Jobs
|
* \brief Lists Jobs
|
||||||
*/
|
*/
|
||||||
@ -356,11 +356,7 @@ if ($num > 0)
|
|||||||
|
|
||||||
if (! verifCond($obj->test)) continue; // Discard line with test = false
|
if (! verifCond($obj->test)) continue; // Discard line with test = false
|
||||||
|
|
||||||
// title profil
|
print '<tr class="oddeven">';
|
||||||
if ($style=='pair') {$style='impair';}
|
|
||||||
else {$style='pair';}
|
|
||||||
|
|
||||||
print '<tr class="'.$style.'">';
|
|
||||||
|
|
||||||
print '<td class="nowrap">';
|
print '<td class="nowrap">';
|
||||||
print '<a href="'.DOL_URL_ROOT.'/cron/card.php?id='.$obj->rowid.'">';
|
print '<a href="'.DOL_URL_ROOT.'/cron/card.php?id='.$obj->rowid.'">';
|
||||||
|
|||||||
@ -14,6 +14,8 @@ FileToLaunchCronJobs=Command line to launch cron jobs
|
|||||||
CronExplainHowToRunUnix=On Unix environment you should use the following crontab entry to run the command line each 5 minutes
|
CronExplainHowToRunUnix=On Unix environment you should use the following crontab entry to run the command line each 5 minutes
|
||||||
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run the command line each 5 minutes
|
CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run the command line each 5 minutes
|
||||||
CronMethodDoesNotExists=Class %s does not contains any method %s
|
CronMethodDoesNotExists=Class %s does not contains any method %s
|
||||||
|
CronJobDefDesc=Cron job profiles are defined into the module descriptor file. When module is activated, they are loaded and available so you can administer the jobs from the admin tools menu %s.
|
||||||
|
CronJobProfiles=List of predefined cron job profiles
|
||||||
# Menu
|
# Menu
|
||||||
EnabledAndDisabled=Enabled and disabled
|
EnabledAndDisabled=Enabled and disabled
|
||||||
# Page list
|
# Page list
|
||||||
@ -53,6 +55,7 @@ CronSaveSucess=Save successfully
|
|||||||
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
|
||||||
|
StatusAtInstall=Status at installation
|
||||||
CronStatusActiveBtn=Enable
|
CronStatusActiveBtn=Enable
|
||||||
CronStatusInactiveBtn=Disable
|
CronStatusInactiveBtn=Disable
|
||||||
CronTaskInactive=This job is disabled
|
CronTaskInactive=This job is disabled
|
||||||
|
|||||||
@ -690,43 +690,24 @@ print load_fiche_titre($text, '', 'title_setup');
|
|||||||
|
|
||||||
$listofmodules=array();
|
$listofmodules=array();
|
||||||
|
|
||||||
/*
|
$dirsincustom=dol_dir_list($dirins, 'directories');
|
||||||
if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder
|
if (is_array($dirsincustom) && count($dirsincustom) > 0) {
|
||||||
{
|
foreach ($dirsincustom as $dircustomcursor) {
|
||||||
global $dolibarr_main_document_root_alt;
|
|
||||||
if (! empty($dolibarr_main_document_root_alt) && is_array($dolibarr_main_document_root_alt))
|
|
||||||
{
|
|
||||||
foreach ($dolibarr_main_document_root_alt as $diralt)
|
|
||||||
{*/
|
|
||||||
$dirsincustom=dol_dir_list($dirins, 'directories');
|
|
||||||
|
|
||||||
if (is_array($dirsincustom) && count($dirsincustom) > 0)
|
|
||||||
{
|
|
||||||
foreach ($dirsincustom as $dircustomcursor)
|
|
||||||
{
|
|
||||||
$fullname = $dircustomcursor['fullname'];
|
$fullname = $dircustomcursor['fullname'];
|
||||||
if (dol_is_file($fullname.'/'.$FILEFLAG))
|
if (dol_is_file($fullname . '/' . $FILEFLAG)) {
|
||||||
{
|
|
||||||
// Get real name of module (MyModule instead of mymodule)
|
// Get real name of module (MyModule instead of mymodule)
|
||||||
$descriptorfiles = dol_dir_list($fullname.'/core/modules/', 'files', 0, 'mod.*\.class\.php$');
|
$descriptorfiles = dol_dir_list($fullname . '/core/modules/', 'files', 0, 'mod.*\.class\.php$');
|
||||||
$modulenamewithcase='';
|
$modulenamewithcase = '';
|
||||||
foreach($descriptorfiles as $descriptorcursor)
|
foreach ($descriptorfiles as $descriptorcursor) {
|
||||||
{
|
$modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']);
|
||||||
$modulenamewithcase=preg_replace('/^mod/', '', $descriptorcursor['name']);
|
$modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase);
|
||||||
$modulenamewithcase=preg_replace('/\.class\.php$/', '', $modulenamewithcase);
|
|
||||||
}
|
}
|
||||||
if ($modulenamewithcase) $listofmodules[$dircustomcursor['name']]=$modulenamewithcase;
|
if ($modulenamewithcase)
|
||||||
//var_dump($listofmodules);
|
$listofmodules[$dircustomcursor['name']] = $modulenamewithcase;
|
||||||
|
// var_dump($listofmodules);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* }
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$newmenu->add('', 'NoGeneratedModuleFound', 0, 0);
|
|
||||||
}*/
|
|
||||||
|
|
||||||
|
|
||||||
// Show description of content
|
// Show description of content
|
||||||
$newdircustom=$dirins;
|
$newdircustom=$dirins;
|
||||||
@ -764,7 +745,6 @@ if ($message)
|
|||||||
}
|
}
|
||||||
|
|
||||||
print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
|
print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'<br>';
|
||||||
//print '<br>';
|
|
||||||
|
|
||||||
|
|
||||||
// Load module descriptor
|
// Load module descriptor
|
||||||
@ -930,6 +910,11 @@ elseif (! empty($module))
|
|||||||
$head2[$h][2] = 'widgets';
|
$head2[$h][2] = 'widgets';
|
||||||
$h++;
|
$h++;
|
||||||
|
|
||||||
|
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=cron&module='.$module;
|
||||||
|
$head2[$h][1] = $langs->trans("CronList");
|
||||||
|
$head2[$h][2] = 'cron';
|
||||||
|
$h++;
|
||||||
|
|
||||||
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module;
|
$head2[$h][0] = $_SERVER["PHP_SELF"].'?tab=buildpackage&module='.$module;
|
||||||
$head2[$h][1] = $langs->trans("BuildPackage");
|
$head2[$h][1] = $langs->trans("BuildPackage");
|
||||||
$head2[$h][2] = 'buildpackage';
|
$head2[$h][2] = 'buildpackage';
|
||||||
@ -1560,6 +1545,119 @@ elseif (! empty($module))
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($tab == 'cron')
|
||||||
|
{
|
||||||
|
$pathtofile = $modulelowercase.'/core/modules/mod'.$module.'.class.php';
|
||||||
|
|
||||||
|
$cronjobs = $moduleobj->cronjobs;
|
||||||
|
|
||||||
|
if ($action != 'editfile' || empty($file))
|
||||||
|
{
|
||||||
|
print $langs->trans("CronJobDefDesc", '<a href="'.DOL_URL_ROOT.'/cron/list.php?status=-2">'.$langs->trans('CronList').'</a>').'<br>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print '<span class="fa fa-file"></span> '.$langs->trans("DescriptorFile").' : <strong>'.$pathtofile.'</strong>';
|
||||||
|
print ' <a href="'.$_SERVER['PHP_SELF'].'?tab='.$tab.'&module='.$module.'&action=editfile&format=php&file='.urlencode($pathtofile).'">'.img_picto($langs->trans("Edit"), 'edit').'</a>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
print '<br>';
|
||||||
|
print load_fiche_titre($langs->trans("CronJobProfiles"), '', '');
|
||||||
|
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="addproperty">';
|
||||||
|
print '<input type="hidden" name="tab" value="objects">';
|
||||||
|
print '<input type="hidden" name="module" value="'.dol_escape_htmltag($module).'">';
|
||||||
|
print '<input type="hidden" name="tabobj" value="'.dol_escape_htmltag($tabobj).'">';
|
||||||
|
|
||||||
|
print '<div class="div-table-responsive">';
|
||||||
|
print '<table class="noborder">';
|
||||||
|
|
||||||
|
print '<tr class="liste_titre">';
|
||||||
|
print_liste_field_titre($langs->trans("CronLabel"),$_SERVER["PHP_SELF"],"","",$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("StatusAtInstall"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||||
|
print_liste_field_titre($langs->trans("Comment"),$_SERVER["PHP_SELF"],"","",$param,'',$sortfield,$sortorder);
|
||||||
|
print "</tr>\n";
|
||||||
|
|
||||||
|
foreach ($cronjobs as $cron)
|
||||||
|
{
|
||||||
|
print '<tr class="oddeven">';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print $cron['label'];
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
if ($cron['jobtype']=='method')
|
||||||
|
{
|
||||||
|
$text=$langs->trans("CronClass");
|
||||||
|
$texttoshow=$langs->trans('CronModule').': '.$module.'<br>';
|
||||||
|
$texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'<br>';
|
||||||
|
$texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'<br>';
|
||||||
|
$texttoshow.=$langs->trans('CronMethod').': '. $cron['method'];
|
||||||
|
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||||
|
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||||
|
}
|
||||||
|
elseif ($cron['jobtype']=='command')
|
||||||
|
{
|
||||||
|
$text=$langs->trans('CronCommand');
|
||||||
|
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']);
|
||||||
|
$texttoshow.='<br>'.$langs->trans('CronArgs').': '. $cron['parameters'];
|
||||||
|
$texttoshow.='<br>'.$langs->trans('Comment').': '. $langs->trans($cron['comment']);
|
||||||
|
}
|
||||||
|
print $form->textwithpicto($text, $texttoshow, 1);
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
if($cron['unitfrequency'] == "60") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Minutes');
|
||||||
|
if($cron['unitfrequency'] == "3600") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Hours');
|
||||||
|
if($cron['unitfrequency'] == "86400") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Days');
|
||||||
|
if($cron['unitfrequency'] == "604800") print $langs->trans('CronEach')." ".($cron['frequency'])." ".$langs->trans('Weeks');
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
print $cron['status'];
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '<td>';
|
||||||
|
if (!empty($cron['comment'])) {print $cron['comment'];}
|
||||||
|
print '</td>';
|
||||||
|
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</table>';
|
||||||
|
print '</div>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$fullpathoffile=dol_buildpath($file, 0);
|
||||||
|
|
||||||
|
$content = file_get_contents($fullpathoffile);
|
||||||
|
|
||||||
|
// New module
|
||||||
|
print '<form action="'.$_SERVER["PHP_SELF"].'" method="POST">';
|
||||||
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||||
|
print '<input type="hidden" name="action" value="savefile">';
|
||||||
|
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||||
|
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||||
|
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||||
|
|
||||||
|
$doleditor=new DolEditor('editfilecontent', $content, '', '300', 'Full', 'In', true, false, 'ace', 0, '99%');
|
||||||
|
print $doleditor->Create(1, '', false, $langs->trans("File").' : '.$file, (GETPOST('format','aZ09')?GETPOST('format','aZ09'):'html'));
|
||||||
|
print '<br>';
|
||||||
|
print '<center>';
|
||||||
|
print '<input type="submit" class="button" id="savefile" name="savefile" value="'.dol_escape_htmltag($langs->trans("Save")).'">';
|
||||||
|
print ' ';
|
||||||
|
print '<input type="submit" class="button" name="cancel" value="'.dol_escape_htmltag($langs->trans("Cancel")).'">';
|
||||||
|
print '</center>';
|
||||||
|
|
||||||
|
print '</form>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ($tab == 'buildpackage')
|
if ($tab == 'buildpackage')
|
||||||
{
|
{
|
||||||
if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))
|
if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user