Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
eee0037a5b
@ -48,60 +48,10 @@ if (! empty($conf->syslog->enabled))
|
||||
*/
|
||||
if ($action=='purge' && ! preg_match('/^confirm/i',$choice) && ($choice != 'allfiles' || $confirm == 'yes') )
|
||||
{
|
||||
$filesarray=array();
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/utils.class.php';
|
||||
$utils = new Utils($db);
|
||||
$count = $utils->purgeFiles($choice);
|
||||
|
||||
if ($choice=='tempfiles')
|
||||
{
|
||||
// Delete temporary files
|
||||
if ($dolibarr_main_data_root)
|
||||
{
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$');
|
||||
}
|
||||
}
|
||||
|
||||
if ($choice=='allfiles')
|
||||
{
|
||||
// Delete all files
|
||||
if ($dolibarr_main_data_root)
|
||||
{
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root,"all",0,'','install\.lock$');
|
||||
}
|
||||
}
|
||||
|
||||
if ($choice=='logfile')
|
||||
{
|
||||
$filesarray[]=array('fullname'=>$filelog,'type'=>'file');
|
||||
}
|
||||
|
||||
$count=0;
|
||||
if (count($filesarray))
|
||||
{
|
||||
foreach($filesarray as $key => $value)
|
||||
{
|
||||
//print "x ".$filesarray[$key]['fullname']."<br>\n";
|
||||
if ($filesarray[$key]['type'] == 'dir')
|
||||
{
|
||||
$count+=dol_delete_dir_recursive($filesarray[$key]['fullname']);
|
||||
}
|
||||
elseif ($filesarray[$key]['type'] == 'file')
|
||||
{
|
||||
// If (file that is not logfile) or (if logfile with option logfile)
|
||||
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
|
||||
{
|
||||
$count+=(dol_delete_file($filesarray[$key]['fullname'])?1:0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update cachenbofdoc
|
||||
if (! empty($conf->ecm->enabled) && $choice=='allfiles')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||
$ecmdirstatic = new EcmDirectory($db);
|
||||
$result = $ecmdirstatic->refreshcachenboffile(1);
|
||||
}
|
||||
}
|
||||
|
||||
if ($count) $mesg=$langs->trans("PurgeNDirectoriesDeleted", $count);
|
||||
else $mesg=$langs->trans("PurgeNothingToDelete");
|
||||
setEventMessages($mesg, null, 'mesgs');
|
||||
@ -159,7 +109,7 @@ if (preg_match('/^confirm/i',$choice))
|
||||
{
|
||||
print '<br>';
|
||||
$formquestion=array();
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').' '.img_warning(), 'purge', $formquestion, 'no', 2);
|
||||
print $form->formconfirm($_SERVER["PHP_SELF"].'?choice=allfiles', $langs->trans('Purge'), $langs->trans('ConfirmPurge').img_warning().' ', 'purge', $formquestion, 'no', 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -535,7 +535,7 @@ if ($result)
|
||||
if ($user->rights->banque->modifier)
|
||||
{
|
||||
print '<td colspan="3">';
|
||||
print '<input name="amount" class="flat" size="10" '.($objp->rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$conf->currency);
|
||||
print '<input name="amount" class="flat" size="10" '.($objp->rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code);
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -154,6 +154,7 @@ $acct->fetch($id);
|
||||
$now=dol_now();
|
||||
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv, b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type as type";
|
||||
$sql.= ", b.fk_bordereau";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||
$sql.= " WHERE rappro=0 AND fk_account=".$acct->id;
|
||||
$sql.= " ORDER BY dateo ASC";
|
||||
@ -291,7 +292,7 @@ if ($resql)
|
||||
// Type + Number
|
||||
$label=($langs->trans("PaymentType".$objp->type)!="PaymentType".$objp->type)?$langs->trans("PaymentType".$objp->type):$objp->type; // $objp->type is a code
|
||||
if ($label=='SOLD') $label='';
|
||||
print '<td class="nowrap">'.$label.($objp->num_chq?' '.$objp->num_chq:'').'</td>';
|
||||
print '<td class="nowrap">'.$label.($objp->num_chq?' '.$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').'</td>';
|
||||
|
||||
// Description
|
||||
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$acct->id.'">';
|
||||
|
||||
@ -327,6 +327,7 @@ else
|
||||
// Recherche les ecritures pour le releve
|
||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
||||
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||
$sql.= " b.fk_bordereau,";
|
||||
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||
@ -373,7 +374,7 @@ else
|
||||
} else {
|
||||
$type_label=($langs->trans("PaymentTypeShort".$objp->fk_type)!="PaymentTypeShort".$objp->fk_type)?$langs->trans("PaymentTypeShort".$objp->fk_type):$objp->fk_type;
|
||||
}
|
||||
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq?$objp->num_chq:'').'</td>';
|
||||
print '<td class="nowrap">'.$type_label.' '.($objp->num_chq?$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').'</td>';
|
||||
|
||||
// Description
|
||||
print '<td valign="center"><a href="'.DOL_URL_ROOT.'/compta/bank/ligne.php?rowid='.$objp->rowid.'&account='.$object->id.'">';
|
||||
|
||||
@ -2992,7 +2992,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('Date');
|
||||
print '</td>';
|
||||
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer)
|
||||
if ($object->type != Facture::TYPE_CREDIT_NOTE && $action != 'editinvoicedate' && ! empty($object->brouillon) && $user->rights->facture->creer && empty($conf->global->FAC_FORCE_DATE_VALIDATION))
|
||||
print '<td align="right"><a href="' . $_SERVER["PHP_SELF"] . '?action=editinvoicedate&facid=' . $object->id . '">' . img_edit($langs->trans('SetDate'), 1) . '</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
|
||||
129
htdocs/core/class/utils.class.php
Normal file
129
htdocs/core/class/utils.class.php
Normal file
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Destailleur Laurent <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/class/utils.class.php
|
||||
* \ingroup core
|
||||
* \brief File for Utils class
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Class to manage utility methods
|
||||
*/
|
||||
class Utils
|
||||
{
|
||||
var $db;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Purge files into directory of data files.
|
||||
*
|
||||
* @param string $choice Choice of purge mode ('tempfiles', 'tempfilesold' to purge temp older than 24h, 'allfiles', 'logfiles')
|
||||
* @return int Nb of files deleted
|
||||
*/
|
||||
function purgeFiles($choice='tempfilesold')
|
||||
{
|
||||
global $conf, $dolibarr_main_data_root;
|
||||
|
||||
dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG);
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
|
||||
$filesarray=array();
|
||||
if (empty($choice)) $choice='tempfilesold';
|
||||
|
||||
if ($choice=='tempfiles' || $choice=='tempfilesold')
|
||||
{
|
||||
// Delete temporary files
|
||||
if ($dolibarr_main_data_root)
|
||||
{
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root,"directories",1,'^temp$','','','',2);
|
||||
if ($choice == 'tempfilesold')
|
||||
{
|
||||
$now = dol_now();
|
||||
foreach($filesarray as $key => $val)
|
||||
{
|
||||
if ($val['date'] > ($now - (24 * 3600))) unset($filesarray[$key]); // Discard files not older than 24h
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($choice=='allfiles')
|
||||
{
|
||||
// Delete all files
|
||||
if ($dolibarr_main_data_root)
|
||||
{
|
||||
$filesarray=dol_dir_list($dolibarr_main_data_root,"all",0,'','install\.lock$');
|
||||
}
|
||||
}
|
||||
|
||||
if ($choice=='logfile')
|
||||
{
|
||||
// Define filelog to discard it from purge
|
||||
$filelog='';
|
||||
if (! empty($conf->syslog->enabled))
|
||||
{
|
||||
$filelog=SYSLOG_FILE;
|
||||
$filelog=preg_replace('/DOL_DATA_ROOT/i',DOL_DATA_ROOT,$filelog);
|
||||
}
|
||||
|
||||
$filesarray[]=array('fullname'=>$filelog,'type'=>'file');
|
||||
}
|
||||
|
||||
$count=0;
|
||||
if (count($filesarray))
|
||||
{
|
||||
foreach($filesarray as $key => $value)
|
||||
{
|
||||
//print "x ".$filesarray[$key]['fullname']."<br>\n";
|
||||
if ($filesarray[$key]['type'] == 'dir')
|
||||
{
|
||||
$count+=dol_delete_dir_recursive($filesarray[$key]['fullname']);
|
||||
}
|
||||
elseif ($filesarray[$key]['type'] == 'file')
|
||||
{
|
||||
// If (file that is not logfile) or (if logfile with option logfile)
|
||||
if ($filesarray[$key]['fullname'] != $filelog || $choice=='logfile')
|
||||
{
|
||||
$count+=(dol_delete_file($filesarray[$key]['fullname'])?1:0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Update cachenbofdoc
|
||||
if (! empty($conf->ecm->enabled) && $choice=='allfiles')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/ecm/class/ecmdirectory.class.php';
|
||||
$ecmdirstatic = new EcmDirectory($this->db);
|
||||
$result = $ecmdirstatic->refreshcachenboffile(1);
|
||||
}
|
||||
}
|
||||
|
||||
return $count;
|
||||
}
|
||||
}
|
||||
@ -110,7 +110,7 @@ function vat_by_thirdparty($db, $y, $date_start, $date_end, $modetax, $direction
|
||||
if ($modetax == 1)
|
||||
{
|
||||
// If vat paid on due invoices (non draft)
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.siren as tva_intra, s.tva_assuj as assuj,";
|
||||
$sql = "SELECT s.rowid as socid, s.nom as name, s.tva_intra as tva_intra, s.tva_assuj as assuj,";
|
||||
$sql.= " sum(f.$total_ht) as amount, sum(f.".$total_tva.") as tva,";
|
||||
$sql.= " sum(f.localtax1) as localtax1,";
|
||||
$sql.= " sum(f.localtax2) as localtax2";
|
||||
|
||||
@ -936,10 +936,11 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
|
||||
if (! $err)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, label, jobtype, classesname, objectname, methodename, command, params, note, frequency, unitfrequency, entity)";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob (module_name, datec, datestart, label, jobtype, classesname, objectname, methodename, command, params, note, frequency, unitfrequency, entity)";
|
||||
$sql.= " VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->rights_class)."', ";
|
||||
$sql.= "'".$this->db->idate($now)."', ";
|
||||
$sql.= "'".$this->db->idate($now)."', ";
|
||||
$sql.= "'".$this->db->escape($label)."', ";
|
||||
$sql.= "'".$this->db->escape($jobtype)."', ";
|
||||
$sql.= ($class?"'".$this->db->escape($class)."'":"null").",";
|
||||
|
||||
@ -99,6 +99,12 @@ class modCron extends DolibarrModules
|
||||
$this->rights_class = 'cron';
|
||||
$r=0;
|
||||
|
||||
// Cronjobs
|
||||
$this->cronjobs = array(
|
||||
0=>array('label'=>'PurgeDeleteTemporaryFilesShort', 'jobtype'=>'method', 'class'=>'core/class/utils.class.php', 'objectname'=>'Utils', 'method'=>'purgeFiles', 'parameters'=>'', 'comment'=>'PurgeDeleteTemporaryFiles', 'frequency'=>1, 'unitfrequency'=>3600 * 24 * 7),
|
||||
// 1=>array('label'=>'My label', 'jobtype'=>'command', 'command'=>'', 'parameters'=>'', 'comment'=>'Comment', 'frequency'=>1, 'unitfrequency'=>3600*24)
|
||||
);
|
||||
|
||||
$this->rights[$r][0] = 23001;
|
||||
$this->rights[$r][1] = 'Read cron jobs';
|
||||
$this->rights[$r][3] = 1;
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concpt.pro>
|
||||
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
@ -539,7 +539,7 @@ else
|
||||
|
||||
print '<tr><td>';
|
||||
print $langs->trans('CronLabel')."</td>";
|
||||
print "<td>".$object->label;
|
||||
print "<td>".$langs->trans($object->label);
|
||||
print "</td></tr>";
|
||||
|
||||
print "<tr><td>";
|
||||
@ -579,7 +579,7 @@ else
|
||||
|
||||
print '<tr><td>';
|
||||
print $langs->trans('CronNote')."</td><td>";
|
||||
print $object->note;
|
||||
print $langs->trans($object->note);
|
||||
print "</td></tr>";
|
||||
|
||||
print '<tr><td>';
|
||||
|
||||
@ -500,7 +500,6 @@ class Cronjob extends CommonObject
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
|
||||
if (isset($this->label)) $this->label=trim($this->label);
|
||||
if (isset($this->jobtype)) $this->jobtype=trim($this->jobtype);
|
||||
if (isset($this->command)) $this->command=trim($this->command);
|
||||
@ -524,7 +523,7 @@ class Cronjob extends CommonObject
|
||||
// Check parameters
|
||||
// Put here code to add a control on parameters values
|
||||
if (dol_strlen($this->datestart)==0) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronDtStart'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronDtStart'));
|
||||
$error++;
|
||||
}
|
||||
if ((dol_strlen($this->datestart)!=0) && (dol_strlen($this->dateend)!=0) && ($this->dateend<$this->datestart)) {
|
||||
@ -532,32 +531,32 @@ class Cronjob extends CommonObject
|
||||
$error++;
|
||||
}
|
||||
if (empty($this->label)) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLabel'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronLabel'));
|
||||
$error++;
|
||||
}
|
||||
if (empty($this->unitfrequency)) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronFrequency'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronFrequency'));
|
||||
$error++;
|
||||
}
|
||||
if (($this->jobtype=='command') && (empty($this->command))) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronCommand'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronCommand'));
|
||||
$error++;
|
||||
}
|
||||
if (($this->jobtype=='method') && (empty($this->classesname))) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronClass'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronClass'));
|
||||
$error++;
|
||||
}
|
||||
if (($this->jobtype=='method' || $this->jobtype == 'function') && (empty($this->methodename))) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronMethod'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronMethod'));
|
||||
$error++;
|
||||
}
|
||||
if (($this->jobtype=='method') && (empty($this->objectname))) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronObject'));
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (($this->jobtype=='function') && (empty($this->libname))) {
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLib'));
|
||||
$this->errors[]=$langs->trans('CronFieldMandatory',$langs->transnoentitiesnoconv('CronLib'));
|
||||
$error++;
|
||||
}
|
||||
|
||||
@ -592,7 +591,7 @@ class Cronjob extends CommonObject
|
||||
$sql.= " libname=".(isset($this->libname)?"'".$this->db->escape($this->libname)."'":"null");
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
@ -841,6 +840,8 @@ class Cronjob extends CommonObject
|
||||
global $langs, $conf;
|
||||
|
||||
$now=dol_now();
|
||||
$error = 0;
|
||||
$retval = '';
|
||||
|
||||
$langs->load('cron');
|
||||
|
||||
@ -889,7 +890,7 @@ class Cronjob extends CommonObject
|
||||
}
|
||||
|
||||
|
||||
// Update last run date (to track launch)
|
||||
// Update last run date (to track running jobs)
|
||||
$this->datelastrun=$now;
|
||||
$this->lastoutput='';
|
||||
$this->lastresult='';
|
||||
@ -904,49 +905,63 @@ class Cronjob extends CommonObject
|
||||
if ($this->jobtype=='method')
|
||||
{
|
||||
// load classes
|
||||
$file = "/".$this->module_name."/class/".$this->classesname;
|
||||
$ret=dol_include_once($file,$this->objectname);
|
||||
if ($ret===false)
|
||||
$ret=dol_include_once($this->classesname,$this->objectname);
|
||||
if (! $error && $ret===false)
|
||||
{
|
||||
$this->error=$langs->trans('CronCannotLoadClass',$file,$this->objectname);
|
||||
$this->error=$langs->trans('CronCannotLoadClass',$this->classesname,$this->objectname);
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR);
|
||||
return -1;
|
||||
$this->lastoutput = $this->error;
|
||||
$this->lastresult = -1;
|
||||
$retval = $this->lastresult;
|
||||
$error++;
|
||||
}
|
||||
|
||||
// Load langs
|
||||
$result=$langs->load($this->module_name.'@'.$this->module_name);
|
||||
if ($result<0)
|
||||
if (! $error)
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR);
|
||||
return -1;
|
||||
$result=$langs->load($this->module_name.'@'.$this->module_name);
|
||||
if ($result<0)
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_jobs Cannot load module lang file - ".$langs->error, LOG_ERR);
|
||||
$this->lastoutput = $langs->error;
|
||||
$this->lastresult = -1;
|
||||
$retval = $this->lastresult;
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
|
||||
|
||||
// Create Object for the call module
|
||||
$object = new $this->objectname($this->db);
|
||||
|
||||
$params_arr = explode(", ",$this->params);
|
||||
if (!is_array($params_arr))
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$result = call_user_func(array($object, $this->methodename), $this->params);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = call_user_func_array(array($object, $this->methodename), $params_arr);
|
||||
}
|
||||
|
||||
if ($result===false)
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_jobs ".$object->error, LOG_ERR);
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lastoutput=var_export($result,true);
|
||||
$this->lastresult=var_export($result,true);
|
||||
}
|
||||
|
||||
dol_syslog(get_class($this)."::run_jobs ".$this->objectname."->".$this->methodename."(".$this->params.");", LOG_DEBUG);
|
||||
|
||||
// Create Object for the call module
|
||||
$object = new $this->objectname($this->db);
|
||||
|
||||
$params_arr = explode(", ",$this->params);
|
||||
if (!is_array($params_arr))
|
||||
{
|
||||
$result = call_user_func(array($object, $this->methodename), $this->params);
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = call_user_func_array(array($object, $this->methodename), $params_arr);
|
||||
}
|
||||
|
||||
if ($result===false)
|
||||
{
|
||||
dol_syslog(get_class($this)."::run_jobs ".$object->error, LOG_ERR);
|
||||
$this->lastoutput = $object->error;
|
||||
$this->lastresult = -1;
|
||||
$retval = $this->lastresult;
|
||||
$error++;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lastoutput='NA';
|
||||
$this->lastresult=var_export($result,true);
|
||||
$retval = $this->lastresult;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if($this->jobtype == 'function')
|
||||
@ -981,12 +996,16 @@ class Cronjob extends CommonObject
|
||||
if ($result === false)
|
||||
{
|
||||
dol_syslog(get_class($this) . "::run_jobs " . $object->error, LOG_ERR);
|
||||
return -1;
|
||||
|
||||
$this->lastoutput = $object->error;
|
||||
$this->lastresult = -1;
|
||||
$retval = $this->lastresult;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->lastoutput=var_export($result,true);
|
||||
$this->lastresult=var_export($result,true);
|
||||
$this->lastresult=var_export($result,true); // Return code
|
||||
$retval = $this->lastresult;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1029,9 +1048,7 @@ class Cronjob extends CommonObject
|
||||
|
||||
dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG);
|
||||
|
||||
|
||||
// Update with result
|
||||
$this->lastoutput='';
|
||||
if (is_array($output_arr) && count($output_arr)>0)
|
||||
{
|
||||
foreach($output_arr as $val)
|
||||
@ -1049,7 +1066,7 @@ class Cronjob extends CommonObject
|
||||
}
|
||||
else
|
||||
{
|
||||
return 1;
|
||||
return $error?-1:1;
|
||||
}
|
||||
|
||||
}
|
||||
@ -1089,26 +1106,26 @@ class Cronjob extends CommonObject
|
||||
|
||||
if (empty($this->datenextrun))
|
||||
{
|
||||
$this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
|
||||
if (empty($this->datestart)) $this->datenextrun = $now + ($this->frequency * $this->unitfrequency);
|
||||
else $this->datenextrun = $this->datestart + ($this->frequency * $this->unitfrequency);
|
||||
}
|
||||
|
||||
if ($this->datenextrun < $now && $this->frequency > 0 && $this->unitfrequency > 0)
|
||||
{
|
||||
// Loop until date is after future
|
||||
while ($this->datenextrun < $now)
|
||||
{
|
||||
$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
|
||||
{
|
||||
if ($this->datenextrun < $now && $this->frequency > 0)
|
||||
{
|
||||
// Loop until date is after future
|
||||
while ($this->datenextrun < $now)
|
||||
{
|
||||
$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->unitfrequency);
|
||||
}
|
||||
//$this->datenextrun=$this->datenextrun + ($this->frequency * $this->unitfrequency);
|
||||
}
|
||||
|
||||
|
||||
// Archive job
|
||||
if ($this->autodelete == 2)
|
||||
{
|
||||
@ -1116,7 +1133,7 @@ class Cronjob extends CommonObject
|
||||
|| ($this->dateend && ($this->datenextrun > $this->dateend)))
|
||||
{
|
||||
$this->status = 2;
|
||||
dol_syslog(get_class($this)."::reprogram_jobs Job must be set to archived", LOG_ERR);
|
||||
dol_syslog(get_class($this)."::reprogram_jobs Job will be set to archived", LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -54,7 +54,7 @@ if ($status == '') $status=-2;
|
||||
$search_label=GETPOST("search_label",'alpha');
|
||||
|
||||
if (empty($sortorder)) $sortorder="DESC";
|
||||
if (empty($sortfield)) $sortfield="t.datenextrun";
|
||||
if (empty($sortfield)) $sortfield="t.status";
|
||||
if (empty($arch)) $arch = 0;
|
||||
if ($page == -1) {
|
||||
$page = 0 ;
|
||||
@ -99,24 +99,26 @@ if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->ex
|
||||
|
||||
$now = dol_now(); // Date we start
|
||||
|
||||
$result = $object->run_jobs($user->login);
|
||||
if ($result < 0) {
|
||||
$resrunjob = $object->run_jobs($user->login);
|
||||
if ($resrunjob < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
|
||||
// Programm next run
|
||||
$res = $object->reprogram_jobs($user->login, $now);
|
||||
if ($res > 0)
|
||||
{
|
||||
$res = $object->reprogram_jobs($user->login, $now);
|
||||
if ($res > 0)
|
||||
if ($resrunjob >= 0) // We add result of reprogram ony if no error message already reported
|
||||
{
|
||||
if ($object->lastresult > 0) setEventMessages($langs->trans("JobFinished"), null, 'warnings');
|
||||
else setEventMessages($langs->trans("JobFinished"), null, 'mesgs');
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
$action='';
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
$action='';
|
||||
}
|
||||
|
||||
header("Location: ".DOL_URL_ROOT.'/cron/list.php?status=-2'); // Make a call to avoid to run twice job when using back
|
||||
@ -246,21 +248,19 @@ if ($num > 0)
|
||||
if ($line->jobtype=='method')
|
||||
{
|
||||
$text=$langs->trans("CronClass");
|
||||
$texttoshow=$langs->trans('CronModule').':'.$line->module_name.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').':'. $line->classesname.'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').':'. $line->objectname.'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').':'. $line->methodename;
|
||||
if(!empty($line->params)) {
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').':'. $line->params;
|
||||
}
|
||||
$texttoshow=$langs->trans('CronModule').': '.$line->module_name.'<br>';
|
||||
$texttoshow.=$langs->trans('CronClass').': '. $line->classesname.'<br>';
|
||||
$texttoshow.=$langs->trans('CronObject').': '. $line->objectname.'<br>';
|
||||
$texttoshow.=$langs->trans('CronMethod').': '. $line->methodename;
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').':'. $line->params;
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').':'. $line->note;
|
||||
}
|
||||
elseif ($line->jobtype=='command')
|
||||
{
|
||||
$text=$langs->trans('CronCommand');
|
||||
$texttoshow=$langs->trans('CronCommand').': '.dol_trunc($line->command);
|
||||
if(!empty($line->params)) {
|
||||
$texttoshow='<br>'.$langs->trans('CronArgs').':'. $line->params;
|
||||
}
|
||||
$texttoshow.='<br>'.$langs->trans('CronArgs').':'. $line->params;
|
||||
$texttoshow.='<br>'.$langs->trans('Comment').':'. $line->note;
|
||||
}
|
||||
print $form->textwithpicto($text, $texttoshow, 1);
|
||||
print '</td>';
|
||||
@ -297,7 +297,7 @@ if ($num > 0)
|
||||
print '</td>';
|
||||
|
||||
print '<td class="center">';
|
||||
if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);}
|
||||
if ($line->lastresult != '') {print dol_trunc($line->lastresult);}
|
||||
print '</td>';
|
||||
|
||||
print '<td>';
|
||||
|
||||
@ -154,6 +154,7 @@ Purge=Purge
|
||||
PurgeAreaDesc=This page allows you to delete all files built or stored by Dolibarr (temporary files or all files in <b>%s</b> directory). Using this feature is not necessary. It is provided for users whose Dolibarr is hosted by a provider that does not offer permissions to delete files built by the web server.
|
||||
PurgeDeleteLogFile=Delete log file <b>%s</b> defined for Syslog module (no risk to loose data)
|
||||
PurgeDeleteTemporaryFiles=Delete all temporary files (no risk to loose data)
|
||||
PurgeDeleteTemporaryFilesShort=Delete temporary files
|
||||
PurgeDeleteAllFilesInDocumentsDir=Delete all files in directory <b>%s</b>. Temporary files but also database backup dumps, files attached to elements (third parties, invoices, ...) and uploaded into the ECM module will be deleted.
|
||||
PurgeRunNow=Purge now
|
||||
PurgeNothingToDelete=No directory or file to delete.
|
||||
|
||||
@ -685,9 +685,9 @@ function getListOfThirdParties($authentication,$filterthirdparty)
|
||||
foreach($filterthirdparty as $key => $val)
|
||||
{
|
||||
if ($key == 'name' && $val != '') $sql.=" AND s.name LIKE '%".$db->escape($val)."%'";
|
||||
if ($key == 'client' && $val != '') $sql.=" AND s.client = ".$db->escape($val);
|
||||
if ($key == 'supplier' && $val != '') $sql.=" AND s.fournisseur = ".$db->escape($val);
|
||||
if ($key == 'category' && $val != '') $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
|
||||
if ($key == 'client' && (int) $val > 0) $sql.=" AND s.client = ".$db->escape($val);
|
||||
if ($key == 'supplier' && (int) $val > 0) $sql.=" AND s.fournisseur = ".$db->escape($val);
|
||||
if ($key == 'category' && (int) $val > 0) $sql.=" AND s.rowid IN (SELECT fk_soc FROM ".MAIN_DB_PREFIX."categorie_societe WHERE fk_categorie=".$db->escape($val).") ";
|
||||
}
|
||||
dol_syslog("Function: getListOfThirdParties", LOG_DEBUG);
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user