From 2036f17df5140a5e11560bf1f2de8618aa8ec7cb Mon Sep 17 00:00:00 2001 From: BENKE Charlie Date: Tue, 19 Jan 2016 21:45:44 +0100 Subject: [PATCH 1/8] if FAC_FORCE_DATE_VALIDATION can't change the billing date --- htdocs/compta/facture.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index c933482f98e..5893a065475 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -2992,7 +2992,7 @@ else if ($id > 0 || ! empty($ref)) print ''; - 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 ''; print '
'; print $langs->trans('Date'); print 'id . '">' . img_edit($langs->trans('SetDate'), 1) . '
'; print ''; From 4d842d91d7668bd27ba111ec86825f2392c58ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Jan 2016 12:20:03 +0100 Subject: [PATCH 2/8] Add fk_bordereau in account statements --- htdocs/compta/bank/releve.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/releve.php b/htdocs/compta/bank/releve.php index 84c2edde0dd..0025fb62fd8 100644 --- a/htdocs/compta/bank/releve.php +++ b/htdocs/compta/bank/releve.php @@ -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 ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').''; + print ''.$type_label.' '.($objp->num_chq?$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').''; // Description print ''; From 4ed28311127be49e34e87509707ed1be9144c880 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Fri, 22 Jan 2016 12:23:13 +0100 Subject: [PATCH 3/8] Add fk_bordereau in account statement conciliation --- htdocs/compta/bank/rappro.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/htdocs/compta/bank/rappro.php b/htdocs/compta/bank/rappro.php index a2d7cb832b5..6e91a180e50 100644 --- a/htdocs/compta/bank/rappro.php +++ b/htdocs/compta/bank/rappro.php @@ -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 ''.$label.($objp->num_chq?' '.$objp->num_chq:'').''; + print ''.$label.($objp->num_chq?' '.$objp->num_chq:'').($objp->fk_bordereau>0?' ('.$objp->fk_bordereau.')':'').''; // Description print ''; From 6313f64c93c985c1f7121bebf840b5b3f95e46d8 Mon Sep 17 00:00:00 2001 From: Maxime Kohlhaas Date: Tue, 26 Jan 2016 18:09:52 +0100 Subject: [PATCH 4/8] Fix : amount in bank line is necessarily in the account currency --- htdocs/compta/bank/ligne.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index 0f73e5cb6cf..13b65f0baf1 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -535,7 +535,7 @@ if ($result) if ($user->rights->banque->modifier) { print ''; - print 'rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$conf->currency); + print 'rappro?' disabled':'').' value="'.price($objp->amount).'"> '.$langs->trans("Currency".$acct->currency_code); print ''; } else From f341c7fedde802baf2b0f1c12fc1480466f95bef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Wed, 27 Jan 2016 23:09:05 +0100 Subject: [PATCH 5/8] Avoid errors with bad parameters --- htdocs/webservices/server_thirdparty.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/webservices/server_thirdparty.php b/htdocs/webservices/server_thirdparty.php index 542e2980c45..50b8e80e363 100644 --- a/htdocs/webservices/server_thirdparty.php +++ b/htdocs/webservices/server_thirdparty.php @@ -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); From 1854f07e5c585af108e53b01efad29ae5e35fc02 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2016 00:12:58 +0100 Subject: [PATCH 6/8] Move code to purge files into a dedicated utils class (cron job need class) --- htdocs/admin/tools/purge.php | 58 +-------------- htdocs/core/class/utils.class.php | 117 ++++++++++++++++++++++++++++++ 2 files changed, 121 insertions(+), 54 deletions(-) create mode 100644 htdocs/core/class/utils.class.php diff --git a/htdocs/admin/tools/purge.php b/htdocs/admin/tools/purge.php index 9249186f574..1bc3fea3909 100644 --- a/htdocs/admin/tools/purge.php +++ b/htdocs/admin/tools/purge.php @@ -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']."
\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 '
'; $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); } diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php new file mode 100644 index 00000000000..23827a31b94 --- /dev/null +++ b/htdocs/core/class/utils.class.php @@ -0,0 +1,117 @@ + + * + * 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 . + */ + +/** + * \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', 'allfiles', 'logfiles') + * @return int Nb of files deleted + */ + function purgeFiles($choice) + { + global $conf, $dolibarr_main_data_root; + + $filesarray=array(); + + 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') + { + // 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']."
\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; + } +} From 19d119d3a41407bd6b26d7f49e4294bd02f8323d Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 30 Jan 2016 02:51:26 +0100 Subject: [PATCH 7/8] Debug cron module. Task to delete temporary files older than 24 is on by default. --- htdocs/core/class/utils.class.php | 22 ++- htdocs/core/modules/DolibarrModules.class.php | 3 +- htdocs/core/modules/modCron.class.php | 6 + htdocs/cron/card.php | 6 +- htdocs/cron/class/cronjob.class.php | 151 ++++++++++-------- htdocs/cron/list.php | 46 +++--- htdocs/langs/en_US/admin.lang | 1 + 7 files changed, 136 insertions(+), 99 deletions(-) diff --git a/htdocs/core/class/utils.class.php b/htdocs/core/class/utils.class.php index 23827a31b94..3132423d614 100644 --- a/htdocs/core/class/utils.class.php +++ b/htdocs/core/class/utils.class.php @@ -43,21 +43,33 @@ class Utils /** * Purge files into directory of data files. * - * @param string $choice Choice of purge mode ('tempfiles', 'allfiles', 'logfiles') + * @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) + function purgeFiles($choice='tempfilesold') { global $conf, $dolibarr_main_data_root; - $filesarray=array(); + dol_syslog("Utils::purgeFiles choice=".$choice, LOG_DEBUG); + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - if ($choice=='tempfiles') + $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$'); + $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 + } + } } } diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 11d904f58d4..06b3bc89860 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -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").","; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index aefb599a9b7..4981eeb0089 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -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; diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php index e91b359ed98..76781d6645e 100644 --- a/htdocs/cron/card.php +++ b/htdocs/cron/card.php @@ -1,7 +1,7 @@ - * Copyright (C) 2013-2015 Laurent Destailleur + * Copyright (C) 2013-2016 Laurent Destailleur * * 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 ''; print $langs->trans('CronLabel').""; - print "".$object->label; + print "".$langs->trans($object->label); print ""; print ""; @@ -579,7 +579,7 @@ else print ''; print $langs->trans('CronNote').""; - print $object->note; + print $langs->trans($object->note); print ""; print ''; diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index a66fcd9597c..a22b4aa21c0 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -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); } } diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 867695cade6..3ff7e974408 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -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.'
'; - $texttoshow.=$langs->trans('CronClass').':'. $line->classesname.'
'; - $texttoshow.=$langs->trans('CronObject').':'. $line->objectname.'
'; - $texttoshow.=$langs->trans('CronMethod').':'. $line->methodename; - if(!empty($line->params)) { - $texttoshow.='
'.$langs->trans('CronArgs').':'. $line->params; - } + $texttoshow=$langs->trans('CronModule').': '.$line->module_name.'
'; + $texttoshow.=$langs->trans('CronClass').': '. $line->classesname.'
'; + $texttoshow.=$langs->trans('CronObject').': '. $line->objectname.'
'; + $texttoshow.=$langs->trans('CronMethod').': '. $line->methodename; + $texttoshow.='
'.$langs->trans('CronArgs').':'. $line->params; + $texttoshow.='
'.$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='
'.$langs->trans('CronArgs').':'. $line->params; - } + $texttoshow.='
'.$langs->trans('CronArgs').':'. $line->params; + $texttoshow.='
'.$langs->trans('Comment').':'. $line->note; } print $form->textwithpicto($text, $texttoshow, 1); print ''; @@ -297,7 +297,7 @@ if ($num > 0) print ''; print ''; - if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);} + if ($line->lastresult != '') {print dol_trunc($line->lastresult);} print ''; print ''; diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 13368cbfc06..55eb22f0aee 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -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 %s 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 %s 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 %s. 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. From 827fd396581498600bd815f40ed24bc4d491ac9f Mon Sep 17 00:00:00 2001 From: mic9p Date: Sat, 30 Jan 2016 10:35:57 +0100 Subject: [PATCH 8/8] Do not select siren but tva_intra from societe VAT report by customer shows an empty field. --- htdocs/core/lib/tax.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/tax.lib.php b/htdocs/core/lib/tax.lib.php index cd128cec817..758301c9171 100644 --- a/htdocs/core/lib/tax.lib.php +++ b/htdocs/core/lib/tax.lib.php @@ -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";