Beispiel #1
0
    exit;
}
// current date
$now = dol_now();
$nbofjobs = count($object->lines);
$nbofjobslaunchedok = 0;
$nbofjobslaunchedko = 0;
if (is_array($object->lines) && count($object->lines) > 0) {
    // Loop over job
    foreach ($object->lines as $line) {
        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 ($line->datenextrun <= $now && $line->dateend < $now || 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'));
            $cronjob = new Cronjob($db);
            $result = $cronjob->fetch($line->id);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: fetch Error" . $cronjob->error, LOG_ERR);
                exit;
            }
            // Execut job
            $result = $cronjob->run_jobs($userlogin);
            if ($result < 0) {
                echo "Error:" . $cronjob->error;
                dol_syslog("cron_run_jobs.php:: run_jobs Error" . $cronjob->error, LOG_ERR);
                $nbofjobslaunchedko++;
            } else {
                $nbofjobslaunchedok++;
            }
            // We re-program the next execution and stores the last execution time for this job
}
// Delete jobs
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) {
    //Delete cron task
    $object = new Cronjob($db);
    $object->id = $id;
    $result = $object->delete($user);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    }
}
// Execute jobs
if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute) {
    //Execute jobs
    $object = new Cronjob($db);
    $job = $object->fetch($id);
    $result = $object->run_jobs($user->login);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    } else {
        $res = $object->reprogram_jobs($user->login);
        if ($res > 0) {
            if ($object->lastresult > 0) {
                setEventMessage($langs->trans("JobFinished"), 'warnings');
            } else {
                setEventMessage($langs->trans("JobFinished"), 'mesgs');
            }
            $action = '';
        } else {
            setEventMessage($object->error, 'errors');
            $action = '';
 /**
  *	Load an object from its id and create a new one in database
  *
  *	@param	int		$fromid     Id of object to clone
  * 	@return	int					New id of clone
  */
 function createFromClone($fromid)
 {
     global $user, $langs;
     $error = 0;
     $object = new Cronjob($this->db);
     $object->context['createfromclone'] = 'createfromclone';
     $this->db->begin();
     // Load source object
     $object->fetch($fromid);
     $object->id = 0;
     $object->statut = 0;
     // Clear fields
     // ...
     // Create clone
     $result = $object->create($user);
     // Other options
     if ($result < 0) {
         $this->error = $object->error;
         $error++;
     }
     if (!$error) {
     }
     unset($this->context['createfromclone']);
     // End
     if (!$error) {
         $this->db->commit();
         return $object->id;
     } else {
         $this->db->rollback();
         return -1;
     }
 }
Beispiel #4
0
// librairie jobs
require_once DOL_DOCUMENT_ROOT . "/cron/class/cronjob.class.php";
require_once DOL_DOCUMENT_ROOT . "/core/class/html.formcron.class.php";
require_once DOL_DOCUMENT_ROOT . '/core/lib/cron.lib.php';
$langs->load("admin");
$langs->load("cron");
if (!$user->rights->cron->create) {
    accessforbidden();
}
$id = GETPOST('id', 'int');
$action = GETPOST('action', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$cancel = GETPOST('cancel');
$object = new Cronjob($db);
if (!empty($id)) {
    $result = $object->fetch($id);
    if ($result < 0) {
        setEventMessage($object->error, 'errors');
    }
}
if (!empty($cancel)) {
    if (!empty($id)) {
        $action = '';
    } else {
        Header("Location: " . DOL_URL_ROOT . '/cron/list.php?status=1');
        exit;
    }
}
// Delete jobs
if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete) {
    $result = $object->delete($user);
Beispiel #5
0
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 */
/**
 *  \file       	htdocs/cron/info.php
 *  \brief      	Page of info of a cron job
 */
require '../main.inc.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/functions2.lib.php';
// Security check
if (!$user->rights->cron->read) {
    accessforbidden();
}
$id = GETPOST('id', 'int');
$mesg = '';
/*
 * View
*/
llxHeader('', $langs->trans("CronInfo"));
$object = new Cronjob($db);
$object->fetch($id);
$object->info($id);
$head = cron_prepare_head($object);
dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'cron');
print '<table width="100%"><tr><td>';
dol_print_object_info($object);
print '</td></tr></table>';
print '</div>';
$db->close();
llxFooter();