diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 913da57ac39..e00ac9dcc71 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -18,7 +18,7 @@ */ /** - * \file htdocs/cron/cron/list.php + * \file htdocs/cron/list.php * \ingroup cron * \brief Lists Jobs */ @@ -356,11 +356,7 @@ if ($num > 0) if (! verifCond($obj->test)) continue; // Discard line with test = false - // title profil - if ($style=='pair') {$style='impair';} - else {$style='pair';} - - print ''; + print ''; print ''; print ''; diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 8eb03114c64..0186ffd1317 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -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 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 +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 EnabledAndDisabled=Enabled and disabled # Page list @@ -53,6 +55,7 @@ CronSaveSucess=Save successfully CronNote=Comment CronFieldMandatory=Fields %s is mandatory CronErrEndDateStartDt=End date cannot be before start date +StatusAtInstall=Status at installation CronStatusActiveBtn=Enable CronStatusInactiveBtn=Disable CronTaskInactive=This job is disabled diff --git a/htdocs/modulebuilder/index.php b/htdocs/modulebuilder/index.php index 4298505a18b..9b804e03cab 100644 --- a/htdocs/modulebuilder/index.php +++ b/htdocs/modulebuilder/index.php @@ -690,43 +690,24 @@ print load_fiche_titre($text, '', 'title_setup'); $listofmodules=array(); -/* -if (!empty($conf->modulebuilder->enabled) && $mainmenu == 'modulebuilder') // Entry for Module builder -{ - 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']; - if (dol_is_file($fullname.'/'.$FILEFLAG)) - { - // Get real name of module (MyModule instead of mymodule) - $descriptorfiles = dol_dir_list($fullname.'/core/modules/', 'files', 0, 'mod.*\.class\.php$'); - $modulenamewithcase=''; - foreach($descriptorfiles as $descriptorcursor) - { - $modulenamewithcase=preg_replace('/^mod/', '', $descriptorcursor['name']); - $modulenamewithcase=preg_replace('/\.class\.php$/', '', $modulenamewithcase); - } - if ($modulenamewithcase) $listofmodules[$dircustomcursor['name']]=$modulenamewithcase; - //var_dump($listofmodules); - } - } - } -/* } - } - else - { - $newmenu->add('', 'NoGeneratedModuleFound', 0, 0); - }*/ - +$dirsincustom=dol_dir_list($dirins, 'directories'); +if (is_array($dirsincustom) && count($dirsincustom) > 0) { + foreach ($dirsincustom as $dircustomcursor) { + $fullname = $dircustomcursor['fullname']; + if (dol_is_file($fullname . '/' . $FILEFLAG)) { + // Get real name of module (MyModule instead of mymodule) + $descriptorfiles = dol_dir_list($fullname . '/core/modules/', 'files', 0, 'mod.*\.class\.php$'); + $modulenamewithcase = ''; + foreach ($descriptorfiles as $descriptorcursor) { + $modulenamewithcase = preg_replace('/^mod/', '', $descriptorcursor['name']); + $modulenamewithcase = preg_replace('/\.class\.php$/', '', $modulenamewithcase); + } + if ($modulenamewithcase) + $listofmodules[$dircustomcursor['name']] = $modulenamewithcase; + // var_dump($listofmodules); + } + } +} // Show description of content $newdircustom=$dirins; @@ -764,7 +745,6 @@ if ($message) } print $langs->trans("ModuleBuilderDesc3", count($listofmodules), $FILEFLAG).'
'; -//print '
'; // Load module descriptor @@ -930,6 +910,11 @@ elseif (! empty($module)) $head2[$h][2] = 'widgets'; $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][1] = $langs->trans("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", '
'.$langs->trans('CronList').'').'
'; + print '
'; + + print ' '.$langs->trans("DescriptorFile").' : '.$pathtofile.''; + print ' '.img_picto($langs->trans("Edit"), 'edit').''; + print '
'; + + print '
'; + print load_fiche_titre($langs->trans("CronJobProfiles"), '', ''); + + print '
'; + print ''; + print ''; + print ''; + print ''; + print ''; + + print '
'; + print ''; + + print ''; + 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 "\n"; + + foreach ($cronjobs as $cron) + { + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } + + print '
'; + print $cron['label']; + print ''; + if ($cron['jobtype']=='method') + { + $text=$langs->trans("CronClass"); + $texttoshow=$langs->trans('CronModule').': '.$module.'
'; + $texttoshow.=$langs->trans('CronClass').': '. $cron['class'].'
'; + $texttoshow.=$langs->trans('CronObject').': '. $cron['objectname'].'
'; + $texttoshow.=$langs->trans('CronMethod').': '. $cron['method']; + $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + elseif ($cron['jobtype']=='command') + { + $text=$langs->trans('CronCommand'); + $texttoshow=$langs->trans('CronCommand').': '.dol_trunc($cron['command']); + $texttoshow.='
'.$langs->trans('CronArgs').': '. $cron['parameters']; + $texttoshow.='
'.$langs->trans('Comment').': '. $langs->trans($cron['comment']); + } + print $form->textwithpicto($text, $texttoshow, 1); + print '
'; + 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 ''; + print $cron['status']; + print ''; + if (!empty($cron['comment'])) {print $cron['comment'];} + print '
'; + print '
'; + } + else + { + $fullpathoffile=dol_buildpath($file, 0); + + $content = file_get_contents($fullpathoffile); + + // New module + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + $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 '
'; + print '
'; + print ''; + print '   '; + print ''; + print '
'; + + print '
'; + } + } + if ($tab == 'buildpackage') { if (! class_exists('ZipArchive') && ! defined('ODTPHP_PATHTOPCLZIP'))