diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 2734bacea2a..5617ecc1dfb 100755 --- a/htdocs/admin/pdf.php +++ b/htdocs/admin/pdf.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2005 Rodolphe Quiedeville * Copyright (C) 2004-2012 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin - * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2012-2103 Juanjo Menent * * 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 @@ -57,12 +57,12 @@ if ($action == 'update') dolibarr_set_const($db, "MAIN_PROFID4_IN_ADDRESS", $_POST["MAIN_PROFID4_IN_ADDRESS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT", $_POST["MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT"],'chaine',0,'',$conf->entity); - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_DESC", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_DESC"],'chaine',0,'',$conf->entity); dolibarr_set_const($db, "MAIN_GENERATE_DOCUMENTS_HIDE_REF", $_POST["MAIN_GENERATE_DOCUMENTS_HIDE_REF"],'chaine',0,'',$conf->entity); - } +// } header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); exit; @@ -224,8 +224,8 @@ if ($action == 'edit') // Edit print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT))?$conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT:0,1); print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { //Desc $var=!$var; print ''.$langs->trans("HideDescOnPDF").''; @@ -243,7 +243,7 @@ if ($action == 'edit') // Edit print ''.$langs->trans("HideDetailsOnPDF").''; print $form->selectyesno('MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS',(! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS))?$conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS:0,1); print ''; - } +// } print ''; @@ -418,8 +418,8 @@ else // Show print ""; print ''; - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { +// if ($conf->global->MAIN_FEATURES_LEVEL > 1) +// { //Desc $var=!$var; print ''.$langs->trans("HideDescOnPDF").''; @@ -437,7 +437,7 @@ else // Show print ''.$langs->trans("HideDetailsOnPDF").''; print yn($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS,1); print ''; - } +// } print ''; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 9058350747f..975765d12b4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1012,13 +1012,13 @@ abstract class CommonObject /** * Save a new position (field rang) for details lines. * You can choose to set position for lines with already a position or lines without any position defined. - * Call this function only for table that contains a field fk_parent_line. * - * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines. - * @param string $rowidorder ASC or DESC + * @param boolean $renum true to renum all already ordered lines, false to renum only not already ordered lines. + * @param string $rowidorder ASC or DESC + * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_order($renum=false, $rowidorder='ASC') + function line_order($renum=false, $rowidorder='ASC', $fk_parent_line=true) { if (! $this->table_element_line) { @@ -1055,7 +1055,8 @@ abstract class CommonObject // We first search all lines that are parent lines (for multilevel details lines) $sql = 'SELECT rowid FROM '.MAIN_DB_PREFIX.$this->table_element_line; $sql.= ' WHERE '.$this->fk_element.' = '.$this->id; - $sql.= ' AND fk_parent_line IS NULL'; + if ($fk_parent_line) + $sql.= ' AND fk_parent_line IS NULL'; $sql.= ' ORDER BY rang ASC, rowid '.$rowidorder; dol_syslog(get_class($this)."::line_order search all parent lines sql=".$sql, LOG_DEBUG); @@ -1130,12 +1131,13 @@ abstract class CommonObject /** * Update a line to have a lower rank * - * @param int $rowid Id of line + * @param int $rowid Id of line + * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_up($rowid) + function line_up($rowid, $fk_parent_line=true) { - $this->line_order(); + $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line $rang = $this->getRangOfLine($rowid); @@ -1147,12 +1149,13 @@ abstract class CommonObject /** * Update a line to have a higher rank * - * @param int $rowid Id of line + * @param int $rowid Id of line + * @param boolean $fk_parent_line Table with fk_parent_line field or not * @return void */ - function line_down($rowid) + function line_down($rowid, $fk_parent_line=true) { - $this->line_order(); + $this->line_order(false, 'ASC', $fk_parent_line); // Get rang of line $rang = $this->getRangOfLine($rowid); diff --git a/htdocs/core/class/html.formcron.class.php b/htdocs/core/class/html.formcron.class.php new file mode 100644 index 00000000000..2acb83e3f05 --- /dev/null +++ b/htdocs/core/class/html.formcron.class.php @@ -0,0 +1,93 @@ + +* +* 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 2 of the License, or +* (at your option) 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 cron/class/html.formcron.class.php +* \brief Fichier de la classe des fonctions predefinie de composants html cron +*/ + + +/** + * Class to manage building of HTML components +*/ +class FormCron extends Form +{ + var $db; + var $error; + + /** + * Constructor + * + * @param DoliDB $db Database handler + */ + function __construct($db) + { + $this->db = $db; + return 1; + } + + + /** + * Display On Off selector + * + * @param string $htmlname Html control name + * @param string $selected selected value + * @param string $readonly Select is read only or not + * @return string HTML select field + */ + function select_typejob($htmlname,$selected=0,$readonly=0) + { + global $langs; + + $langs->load('cron@cron'); + if (!empty($readonly)) { + if ($selected=='command') { + $out= $langs->trans('CronType_command'); + $out.=''; + } elseif ($selected=='method') { + $out= $langs->trans('CronType_method'); + $out.=''; + } + }else { + + $out=''; + } + + return $out; + } +} diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php new file mode 100644 index 00000000000..abd85131e29 --- /dev/null +++ b/htdocs/core/lib/cron.lib.php @@ -0,0 +1,71 @@ + + * + * 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 + * (at your option) 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 cron/lib/cron.lib.php + * \brief Ensemble de fonctions de base pour le module jobs + * \ingroup jobs + */ + +/** + * Return array of tabs to used on pages for third parties cards. + * + * @param Object $object Object company shown + * @return array Array of tabs + */ + +function cronadmin_prepare_head() +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath('/cron/admin/cron.php', 1); + $head[$h][1] = $langs->trans("CronSetup"); + $head[$h][2] = 'setup'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cronadmin', 'remove'); + + + return $head; +} + +function cron_prepare_head($object) +{ + global $langs, $conf, $user; + $h = 0; + $head = array(); + + $head[$h][0] = dol_buildpath('/cron/card.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("CronTask"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("CronInfoPage"); + $head[$h][2] = 'info'; + $h++; + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron'); + + complete_head_from_modules($conf, $langs, $object, $head, $h, 'cron', 'remove'); + + return $head; +} diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9dee5c7bee6..64f415ac085 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -33,9 +33,10 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/menubase.class.php'; * @param int $type_user 0=Menu for backoffice, 1=Menu for front office * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param array &$menu Object Menu to return back list of menu entries + * @param int $noout Disable output (Initialise &$menu only). * @return void */ -function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) +function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) { global $user,$conf,$langs,$dolibarr_main_db_name; @@ -45,18 +46,19 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) $id='mainmenu'; $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); - print_start_menu_array(); + if (empty($noout)) print_start_menu_array(); // Home + $showmode=1; $classname=""; if ($_SESSION["mainmenu"] && $_SESSION["mainmenu"] == "home") { $classname='class="tmenusel"'; $_SESSION['idmenu']=''; } else $classname = 'class="tmenu"'; $idsel='home'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $langs->trans("Home"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("Home"), 1, DOL_URL_ROOT.'/index.php?mainmenu=home&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/index.php?mainmenu=home&leftmenu=', $langs->trans("Home"), 0, $showmode, $atarget, "home", ''); // Third parties $tmpentry=array('enabled'=>(! empty($conf->societe->enabled) || ! empty($conf->fournisseur->enabled)), 'perms'=>(! empty($user->rights->societe->lire) || ! empty($user->rights->fournisseur->lire)), 'module'=>'societe|fournisseur'); @@ -71,10 +73,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='companies'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("ThirdParties"), $showmode, DOL_URL_ROOT.'/societe/index.php?mainmenu=companies&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/societe/index.php?mainmenu=companies&leftmenu=', $langs->trans("ThirdParties"), 0, $showmode, $atarget, "companies", ''); } // Products-Services @@ -100,10 +102,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) $chaine.=$langs->trans("Services"); } - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($chaine, $showmode, DOL_URL_ROOT.'/product/index.php?mainmenu=products&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/product/index.php?mainmenu=products&leftmenu=', $chaine, 0, $showmode, $atarget, "products", ''); } // Commercial @@ -124,10 +126,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='commercial'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("Commercial"), $showmode, DOL_URL_ROOT.'/comm/index.php?mainmenu=commercial&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/comm/index.php?mainmenu=commercial&leftmenu=', $langs->trans("Commercial"), 0, $showmode, $atarget, "commercial", ""); } // Financial @@ -144,10 +146,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='accountancy'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("MenuFinancial"), $showmode, DOL_URL_ROOT.'/compta/index.php?mainmenu=accountancy&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/compta/index.php?mainmenu=accountancy&leftmenu=', $langs->trans("MenuFinancial"), 0, $showmode, $atarget, "accountancy", ''); } // Bank @@ -165,10 +167,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='bank'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("MenuBankCash"), $showmode, DOL_URL_ROOT.'/compta/bank/index.php?mainmenu=bank&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/compta/bank/index.php?mainmenu=bank&leftmenu=', $langs->trans("MenuBankCash"), 0, $showmode, $atarget, "bank", ''); } // Projects @@ -185,10 +187,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='project'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("Projects"), $showmode, DOL_URL_ROOT.'/projet/index.php?mainmenu=project&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/projet/index.php?mainmenu=project&leftmenu=', $langs->trans("Projects"), 0, $showmode, $atarget, "project", ''); } // Tools @@ -205,10 +207,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='tools'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("Tools"), $showmode, DOL_URL_ROOT.'/core/tools.php?mainmenu=tools&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/core/tools.php?mainmenu=tools&leftmenu=', $langs->trans("Tools"), 0, $showmode, $atarget, "tools", ''); } // OSCommerce 1 @@ -225,10 +227,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='shop'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("OSCommerce"), $showmode, DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu=', $langs->trans("OSCommerce"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("OSCommerce"), $showmode, DOL_URL_ROOT.'/boutique/index.php?mainmenu=shop&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/boutique/index.php?mainmenu=shop&leftmenu=', $langs->trans("OSCommerce"), 0, $showmode, $atarget, "shop", ''); } // Members @@ -243,10 +245,10 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) else $classname = 'class="tmenu"'; $idsel='members'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $id, $idsel, $classname, $atarget); - print_end_menu_entry(); - $menu->add(DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($langs->trans("MenuMembers"), $showmode, DOL_URL_ROOT.'/adherents/index.php?mainmenu=members&leftmenu=', $id, $idsel, $classname, $atarget); + if (empty($noout)) print_end_menu_entry(); + $menu->add('/adherents/index.php?mainmenu=members&leftmenu=', $langs->trans("MenuMembers"), 0, $showmode, $atarget, "members", ''); } @@ -262,23 +264,24 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) $showmode=dol_eldy_showmenu($type_user,$newTabMenu[$i],$listofmodulesforexternal); if ($showmode == 1) { - if (preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) + $url = $newTabMenu[$i]['url']; + if (! preg_match("/^(http:\/\/|https:\/\/)/i",$newTabMenu[$i]['url'])) { $url = $newTabMenu[$i]['url']; - } - else - { - $url=dol_buildpath($newTabMenu[$i]['url'],1); + $param=''; if (! preg_match('/mainmenu/i',$url) || ! preg_match('/leftmenu/i',$url)) { - if (! preg_match('/\?/',$url)) $url.='?'; - else $url.='&'; - $url.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; + if (! preg_match('/\?/',$url)) $param.='?'; + else $param.='&'; + $param.='mainmenu='.$newTabMenu[$i]['mainmenu'].'&leftmenu='; } //$url.="idmenu=".$newTabMenu[$i]['rowid']; // Already done by menuLoad + $url = dol_buildpath($url,1).$param; + $shorturl = $newTabMenu[$i]['url'].$param; } $url=preg_replace('/__LOGIN__/',$user->login,$url); - + $shorturl=preg_replace('/__LOGIN__/',$user->login,$shorturl); + // Define the class (top menu selected or not) if (! empty($_SESSION['idmenu']) && $newTabMenu[$i]['rowid'] == $_SESSION['idmenu']) $classname='class="tmenusel"'; else if (! empty($_SESSION["mainmenu"]) && $newTabMenu[$i]['mainmenu'] == $_SESSION["mainmenu"]) $classname='class="tmenusel"'; @@ -286,13 +289,13 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) } else if ($showmode == 2) $classname='class="tmenu"'; - print_start_menu_entry($idsel,$classname); - print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); - print_end_menu_entry(); - $menu->add($url, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), $mainmenu, $leftmenu); + if (empty($noout)) print_start_menu_entry($idsel,$classname); + if (empty($noout)) print_text_menu_entry($newTabMenu[$i]['titre'], $showmode, $url, $id, $idsel, $classname, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget)); + if (empty($noout)) print_end_menu_entry(); + $menu->add($shorturl, $newTabMenu[$i]['titre'], 0, $showmode, ($newTabMenu[$i]['target']?$newTabMenu[$i]['target']:$atarget), ($newTabMenu[$i]['mainmenu']?$newTabMenu[$i]['mainmenu']:$newTabMenu[$i]['rowid']), ''); } - print_end_menu_array(); + if (empty($noout)) print_end_menu_array(); } @@ -391,19 +394,22 @@ function print_end_menu_array() * @param array $menu_array_after Table of menu entries to show after entries of menu handler * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) * @param array &$menu Object Menu to return back list of menu entries + * @param int $noout Disable output (Initialise &$menu only). + * @param string $forcemainmenu 'x'=Force mainmenu to mainmenu='x' + * @param string $forceleftmenu 'all'=Force leftmenu to '' (= all) * @return void */ -function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu) +function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu,&$menu,$noout=0,$forcemainmenu='',$forceleftmenu='') { global $user,$conf,$langs,$dolibarr_main_db_name,$mysoc; $newmenu = $menu; - $mainmenu=$_SESSION["mainmenu"]; - $leftmenu=$_SESSION["leftmenu"]; + $mainmenu=($forcemainmenu?$forcemainmenu:$_SESSION["mainmenu"]); + $leftmenu=($forceleftmenu?'':$_SESSION["leftmenu"]); // Show logo company - if (! empty($conf->global->MAIN_SHOW_LOGO)) + if (empty($noout) && ! empty($conf->global->MAIN_SHOW_LOGO)) { $mysoc->logo_mini=$conf->global->MAIN_INFO_SOCIETE_LOGO_MINI; if (! empty($mysoc->logo_mini) && is_readable($conf->mycompany->dir_output.'/logos/thumbs/'.$mysoc->logo_mini)) @@ -1158,107 +1164,91 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu if (! is_array($menu_array)) return 0; // Show menu - $alt=0; - $num=count($menu_array); - for ($i = 0; $i < $num; $i++) + if (empty($noout)) { - $showmenu=true; - if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false; - - $alt++; - if (empty($menu_array[$i]['level']) && $showmenu) + $alt=0; + $num=count($menu_array); + for ($i = 0; $i < $num; $i++) { - if (($alt%2==0)) + $showmenu=true; + if (! empty($conf->global->MAIN_MENU_HIDE_UNAUTHORIZED) && empty($menu_array[$i]['enabled'])) $showmenu=false; + + $alt++; + if (empty($menu_array[$i]['level']) && $showmenu) { - print '
'."\n"; + if (($alt%2==0)) + { + print '
'."\n"; + } + else + { + print '
'."\n"; + } } - else + + // Place tabulation + $tabstring=''; + $tabul=($menu_array[$i]['level'] - 1); + if ($tabul > 0) { - print '
'."\n"; + for ($j=0; $j < $tabul; $j++) + { + $tabstring.='   '; + } } - } - - // Place tabulation - $tabstring=''; - $tabul=($menu_array[$i]['level'] - 1); - if ($tabul > 0) - { - for ($j=0; $j < $tabul; $j++) + + // For external modules + $url = dol_buildpath($menu_array[$i]['url'], 1); + + print ''."\n"; + + // Menu niveau 0 + if ($menu_array[$i]['level'] == 0) { - $tabstring.='   '; + if ($menu_array[$i]['enabled']) + { + print ''."\n"; + } + else if ($showmenu) + { + print ''."\n"; + } + if ($showmenu) + print ''."\n"; } - } - - // For external modules - $url = dol_buildpath($menu_array[$i]['url'], 1); - - print ''."\n"; - - // Menu niveau 0 - if ($menu_array[$i]['level'] == 0) - { - if ($menu_array[$i]['enabled']) + // Menu niveau > 0 + if ($menu_array[$i]['level'] > 0) { - print ''."\n"; + if ($menu_array[$i]['enabled']) + { + print ''."\n"; + } + else if ($showmenu) + { + print ''."\n"; + } } - else if ($showmenu) + + // If next is a new block or end + if (empty($menu_array[$i+1]['level'])) { - print ''."\n"; + if ($showmenu) + print ''."\n"; + print "
\n"; } - if ($showmenu) - print ''."\n"; - } - // Menu niveau > 0 - if ($menu_array[$i]['level'] > 0) - { - if ($menu_array[$i]['enabled']) - { - print ''."\n"; - } - else if ($showmenu) - { - print ''."\n"; - } - } - - // If next is a new block or end - if (empty($menu_array[$i+1]['level'])) - { - if ($showmenu) - print ''."\n"; - print "
\n"; } } - + return count($menu_array); } -/** - * Core function to output top menu eldy - * - * @param DoliDB $db Database handler - * @param string $atarget Target - * @param int $type_user 0=Menu for backoffice, 1=Menu for front office - * @param array &$tabMenu If array with menu entries already loaded, we put this array here (in most cases, it's empty) - * @return void - */ -function print_jmobile_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu) -{ - print '
    '; - foreach ($tabMenu as $key => $val) - { - print '
  • '.$key.'
  • '; - } - print '
'; -} - /** * Function to test if an entry is enabled or not * diff --git a/htdocs/core/menus/standard/eldy_menu.php b/htdocs/core/menus/standard/eldy_menu.php index 2b4ad8c97a7..f920a905983 100644 --- a/htdocs/core/menus/standard/eldy_menu.php +++ b/htdocs/core/menus/standard/eldy_menu.php @@ -112,7 +112,7 @@ class MenuManager */ function showmenu($mode) { - global $conf; + global $conf, $langs; require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; @@ -129,12 +129,53 @@ class MenuManager if ($mode == 'top') $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu); if ($mode == 'left') $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu); - if ($mode == 'jmobile') $res=print_jmobile_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$this->menu); + if ($mode == 'jmobile') + { + $res=print_eldy_menu($this->db,$this->atarget,$this->type_user,$this->tabMenu,$this->menu,1); + + foreach($this->menu->liste as $key => $val) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + { + print '
    '; + print '
  • '; + if ($val['enabled'] == 1) + { + $relurl=dol_buildpath($val['url'],1); + + print ''.$val['titre'].''."\n"; + + $submenu=new Menu(); + $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after,$this->tabMenu,$submenu,1,$val['mainmenu'],$val['leftmenu']); + $nexturl=dol_buildpath($submenu->liste[0]['url'],1); + $canonrelurl=preg_replace('/\?.*$/','',$relurl); + $canonnexturl=preg_replace('/\?.*$/','',$nexturl); + //var_dump($canonrelurl); + //var_dump($canonnexturl); + if ($canonrelurl != $canonnexturl && $val['mainmenu'] != 'home') + { + // We add sub entry + print '
  • '.$langs->trans("MainArea").'-'.$val['titre'].'
  • '."\n"; + } + var_dump($val['titre']); + foreach($submenu->liste as $key2 => $val2) // $val['url','titre','level','enabled'=0|1|2,'target','mainmenu','leftmenu' + { + $relurl2=dol_buildpath($val2['url'],1); + print '
  • '.$val2['titre'].'
  • '."\n"; + } + //var_dump($submenu); + } + if ($val['enabled'] == 2) + { + print ''.$val['titre'].''; + } + print ''; + print '
'."\n"; + print 'wwwwwww'; + } + } unset($this->menu); //print 'xx'.$mode; - //var_dump($this->menu); return $res; } diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index fbc14945f02..53d9afabf30 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry * * 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 @@ -16,11 +17,11 @@ */ /** - * \defgroup webservices Module webservices - * \brief Module to enable the Dolibarr server of web services - * \file htdocs/core/modules/modCron.class.php - * \ingroup cron - * \brief File to describe cron module + * \defgroup cron Module cron + * \brief cron module descriptor. + * \file cron/core/modules/modCron.class.php + * \ingroup cron + * \brief Description and activation file for module Jobs */ include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; @@ -65,11 +66,20 @@ class modCron extends DolibarrModules //------------- $this->depends = array(); $this->requiredby = array(); - $this->langfiles = array("cron"); + $this->langfiles = array("cron@cron"); // Constantes //----------- - $this->const = array(); + $this->const = array( + 0=>array( + 'MAIN_CRON_KEY', + 'chaine', + '', + 'CRON KEY', + 0, + 'main', + 0 + ),); // New pages on tabs // ----------------- @@ -79,25 +89,60 @@ class modCron extends DolibarrModules //------ $this->boxes = array(); - // Permissions - //------------ - $this->rights = array(); - $this->rights_class = 'cron'; - $r=0; + // Permissions + $this->rights = array(); // Permission array used by this module + $this->rights_class = 'cron'; + $r=0; + + $this->rights[$r][0] = 23001; + $this->rights[$r][1] = 'Read cron jobs'; + $this->rights[$r][3] = 1; + $this->rights[$r][4] = 'read'; + $r++; + + $this->rights[$r][0] = 23002; + $this->rights[$r][1] = 'Create cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'create'; + $r++; + + $this->rights[$r][0] = 23003; + $this->rights[$r][1] = 'Delete cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'delete'; + $r++; + + $this->rights[$r][0] = 23004; + $this->rights[$r][1] = 'Execute cron Jobs'; + $this->rights[$r][3] = 0; + $this->rights[$r][4] = 'execute'; + $r++; // Main menu entries $r=0; $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'left', // This is a Left menu entry - 'titre'=>'CronJobs', - 'url'=>'/cron/index.php', - 'langs'=>'cron@cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>100, + 'titre'=>'CronListActive', + 'url'=>'/cron/list.php?status=1', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>200, 'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. - 'perms'=>'$user->admin', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules 'target'=>'', 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both $r++; + + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', // Use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode + 'type'=>'left', // This is a Left menu entry + 'titre'=>'CronListInactive', + 'url'=>'/cron/list.php?status=0', + 'langs'=>'cron', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. + 'position'=>201, + 'enabled'=>'$leftmenu==\'modulesadmintools\'', // Define condition to show or hide menu entry. Use '$conf->mymodule->enabled' if entry must be visible if module is enabled. Use '$leftmenu==\'system\'' to show if leftmenu system is selected. + 'perms'=>'$user->rights->cron->read', // Use 'perms'=>'$user->rights->mymodule->level1->level2' if you want your menu with a permission rules + 'target'=>'', + 'user'=>2); // 0=Menu for internal users, 1=external users, 2=both + $r++; } @@ -114,8 +159,6 @@ class modCron extends DolibarrModules // Prevent pb of modules not correctly disabled //$this->remove($options); - $sql = array(); - return $this->_init($sql,$options); } diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index fd77bcc6851..894e9dc4457 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -1,34 +1,36 @@ * Copyright (C) 2005-2013 Laurent Destailleur - * Copyright (C) 2011 Juanjo Menent - * Copyright (C) 2012 Regis Houssin - * - * 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 - * (at your option) 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 . - */ +* Copyright (C) 2011 Juanjo Menent +* Copyright (C) 2012 Regis Houssin +* Copyright (C) 2013 Florian Henry +* +* 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 +* (at your option) 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/cron/admin/cron.php - * \ingroup cron - * \brief Page to setup cron module - */ + * \file cron/admin/cron.php +* \ingroup cron +*/ -require '../../main.inc.php'; +// Dolibarr environment +$res = @include("../../main.inc.php"); // From htdocs directory require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; -$langs->load("admin"); -$langs->load("cron"); +$langs->load("admin"); +$langs->load("cron"); if (! $user->admin) accessforbidden(); @@ -36,37 +38,40 @@ if (! $user->admin) $actionsave=GETPOST("save"); // Sauvegardes parametres -if ($actionsave) +if (!empty($actionsave)) { - $i=0; + $i=0; - $db->begin(); + $db->begin(); - $i+=dolibarr_set_const($db,'CRON_KEY',trim(GETPOST("CRON_KEY")),'chaine',0,'',$conf->entity); + $i+=dolibarr_set_const($db,'MAIN_CRON_KEY',trim(GETPOST("MAIN_CRON_KEY")),'chaine',0,'',0); - if ($i >= 1) - { - $db->commit(); - setEventMessage($langs->trans("SetupSaved")); - } - else - { - $db->rollback(); - setEventMessage($langs->trans("Error"), 'errors'); - } + if ($i >= 1) + { + $db->commit(); + setEventMessage($langs->trans("SetupSaved")); + } + else + { + $db->rollback(); + setEventMessage($langs->trans("Error"), 'errors'); + } } /* * View - */ +*/ llxHeader(); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("CronSetup"),$linkback,'setup'); -print $langs->trans("CronDesc")."
\n"; +// Configuration header +$head = cronadmin_prepare_head(); +dol_fiche_head($head,'setup',$langs->trans("Module2300Name"),0,'cron'); + print "
\n"; print '
'; @@ -76,13 +81,12 @@ print ''; print ''; print ""; print ""; -//print ""; print ""; print ""; print ''; print ''; -print ''; @@ -102,12 +106,35 @@ print '

'; // Cron launch print ''.$langs->trans("URLToLaunchCronJobs").':
'; -$url=DOL_MAIN_URL_ROOT.'/public/cron/cron_run_jobs.php'.(empty($conf->global->CRON_KEY)?'':'?securitykey='.$conf->global->CRON_KEY); +$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login; print img_picto('','object_globe.png').' '.$url."
\n"; print ' '.$langs->trans("OrToLaunchASpecificJob").'
'; -$url=DOL_MAIN_URL_ROOT.'/public/cron/cron_run_jobs.php?'.(empty($conf->global->CRON_KEY)?'':'securitykey='.$conf->global->CRON_KEY.'&').'id=cronjobid'; -print img_picto('','object_globe.png').' '.$url."
\n"; +$url=dol_buildpath('/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; +print img_picto('','object_globe.png').' '.$url."
\n"; print '
'; +print '
'; + + +$linuxlike=1; +if (preg_match('/^win/i',PHP_OS)) $linuxlike=0; +if (preg_match('/^mac/i',PHP_OS)) $linuxlike=0; + +if ($linuxlike) { + print $langs->trans("CronExplainHowToRunUnix"); +} else { + print $langs->trans("CronExplainHowToRunWin"); +} +print '
'; +print ''.$langs->trans("FileToLaunchCronJobs").':
'; +$file='/scripts/cron/cron_run_jobs.php'.' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)'; +if ($linuxlike) { + print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."
\n"; +} else { + print DOL_DOCUMENT_ROOT.'> php ..'.$file."
\n"; +} +print '
'; + + print '
'; @@ -116,20 +143,18 @@ if (! empty($conf->use_javascript_ajax)) { print "\n".''; } - llxFooter(); -$db->close(); -?> +$db->close(); \ No newline at end of file diff --git a/htdocs/cron/card.php b/htdocs/cron/card.php new file mode 100644 index 00000000000..bd6ffb0e5c9 --- /dev/null +++ b/htdocs/cron/card.php @@ -0,0 +1,596 @@ + + * +* 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 +* (at your option) 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 cron/card.php + * \ingroup cron + * \brief Cron Jobs Card + */ + +require '../main.inc.php'; + +require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + +// 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_buildpath('/cron/cron/list.php',1).'?status=1'); + } + +} + +// Delete jobs +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){ + + + $result = $object->delete($user); + + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + }else { + Header ( "Location: ".dol_buildpath('/cron/cron/list.php',1).'?status=1'); + } +} + +// Execute jobs +if ($action == 'confirm_execute' && $confirm == "yes" && $user->rights->cron->execute){ + + $result=$object->run_jobs($user->login); + + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action=''; + }else { + $action=''; + } + +} + + +if ($action=='add') { + + $object->jobtype=GETPOST('jobtype','alpha'); + $object->label=GETPOST('label','alpha'); + $object->command=GETPOST('command','alpha'); + $object->priority=GETPOST('priority','int'); + $object->classesname=GETPOST('classesname','alpha'); + $object->objectname=GETPOST('objectname','alpha'); + $object->methodename=GETPOST('methodename','alpha'); + $object->params=GETPOST('params'); + $object->md5params=GETPOST('md5params'); + $object->module_name=GETPOST('module_name','alpha'); + $object->note=GETPOST('note'); + $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); + $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); + $object->unitfrequency=GETPOST('unitfrequency','int'); + $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); + + //Ajout de la tache cron + $result = $object->create($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='create'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +// Save parameters +if ($action=='update') { + $object->id=$id; + $object->jobtype=GETPOST('jobtype','alpha'); + $object->label=GETPOST('label','alpha'); + $object->command=GETPOST('command','alpha'); + $object->classesname=GETPOST('classesname','alpha'); + $object->priority=GETPOST('priority','int'); + $object->objectname=GETPOST('objectname','alpha'); + $object->methodename=GETPOST('methodename','alpha'); + $object->params=GETPOST('params'); + $object->md5params=GETPOST('md5params'); + $object->module_name=GETPOST('module_name','alpha'); + $object->note=GETPOST('note'); + $object->datestart=dol_mktime(GETPOST('datestarthour','int'), GETPOST('datestartmin','int'), 0, GETPOST('datestartmonth','int'), GETPOST('datestartday','int'), GETPOST('datestartyear','int')); + $object->dateend=dol_mktime(GETPOST('dateendhour','int'), GETPOST('dateendmin','int'), 0, GETPOST('dateendmonth','int'), GETPOST('dateendday','int'), GETPOST('dateendyear','int')); + $object->unitfrequency=GETPOST('unitfrequency','int'); + $object->frequency=$object->unitfrequency * GETPOST('nbfrequency','int'); + + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +if ($action=='activate') { + $object->status=1; + + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + +if ($action=='inactive') { + $object->status=0; + //Ajout de la tache cron + $result = $object->update($user); + + // test du Resultat de la requete + if ($result < 0) { + setEventMessage($object->error,'errors'); + $action='edit'; + } + else { + setEventMessage($langs->trans('CronSaveSucess'),'mesgs'); + $action=''; + } +} + + +/* + * View +*/ + +llxHeader('',$langs->trans("CronAdd")); + +if ($action=='edit' || empty($action) || $action=='delete' || $action=='execute') { + $head=cron_prepare_head($object); + dol_fiche_head($head, 'card', $langs->trans("CronTask"), 0, 'bill'); +} elseif ($action=='create') { + print_fiche_titre($langs->trans("CronTask"),'','setup'); +} + +if ($conf->use_javascript_ajax) +{ + print "\n".''."\n"; +} + +$form = new Form($db); +$formCron = new FormCron($db); + +if ($action == 'delete') +{ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1); + if ($ret == 'html') print '
'; + $action=''; +} + +if ($action == 'execute'){ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$object->id,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); + if ($ret == 'html') print '
'; + $action=''; +} + + + +/* + * Create Template +*/ + +if (empty($object->status)) { + dol_htmloutput_mesg($langs->trans("CronTaskInactive"),'','warning',1); +} + +if (($action=="create") || ($action=="edit")) { + + print ''; + print ''."\n"; + if (!empty($object->id)) { + print ''."\n"; + print ''."\n"; + } else { + print ''."\n"; + } + + print '
".$langs->trans("Parameter")."".$langs->trans("Value")."".$langs->trans("Examples")." 
'.$langs->trans("KeyForCronAccess").''; +print ''; if (! empty($conf->use_javascript_ajax)) print ' '.img_picto($langs->trans('Generate'), 'refresh', 'id="generate_token" class="linkobject"'); print '
'; + + print '"; + print ""; + print ""; + print "\n"; + + print ""; + print ""; + print "\n"; + + print ""; + print ""; + print "\n"; + + print ""; + print ""; + print "\n"; + + print ""; + $priority=0; + if (!empty($object->priority)) { + $priority=$object->priority; + } + print ""; + print ""; + print "\n"; + + print ""; + print ""; + print ""; + print "\n"; + + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + print '"; + print ""; + print "\n"; + + + print '"; + print ""; + print "\n"; + + print '
'; + print $langs->trans('CronLabel')."label."\" /> "; + print ""; + print "
"; + print $langs->trans('CronType').""; + print $formCron->select_typejob('jobtype',$object->jobtype); + print ""; + print "
"; + print $langs->trans('CronHourStart').""; + if(!empty($object->datestart)){ + $form->select_date($object->datestart,'datestart',1,1,'',"cronform"); + } + else{ + $form->select_date(dol_now(),'datestart',1,1,'',"cronform"); + } + print ""; + print "
"; + print $langs->trans('CronDtEnd').""; + if(!empty($object->dateend)){ + $form->select_date($object->dateend,'dateend',1,1,'',"cronform"); + } + else{ + $form->select_date('','dateend',1,1,1,"cronform"); + } + print ""; + print "
"; + print $langs->trans('CronPriority')." "; + print ""; + print "
"; + print $langs->trans('CronEvery')."unitfrequency=="60"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = "unitfrequency=="3600"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = "unitfrequency=="86400"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + + $input = "unitfrequency=="604800"){ + $input .= ' checked="checked" />'; + } + else{ + $input .= ' />'; + } + $input .= ""; + print $input; + print ""; + print "
'; + print $langs->trans('CronModule').""; + print "module_name."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronModuleHelp"),1,'help'); + print "
'; + print $langs->trans('CronClassFile').""; + print "classesname."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronClassFileHelp"),1,'help'); + print "
'; + print $langs->trans('CronObject').""; + print "objectname."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronObjectHelp"),1,'help'); + print "
'; + print $langs->trans('CronMethod').""; + print "methodename."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronMethodHelp"),1,'help'); + print "
'; + print $langs->trans('CronArgs').""; + print "params."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronArgsHelp"),1,'help'); + print "
'; + print $langs->trans('CronCommand').""; + print "command."\" /> "; + print ""; + print $form->textwithpicto('',$langs->trans("CronCommandHelp"),1,'help'); + print "
'; + print $langs->trans('CronNote').""; + $doleditor = new DolEditor('note', $object->note, '', 160, 'dolibarr_notes', 'In', true, false, 0, 4, 90); + $doleditor->Create(); + print ""; + print "
'; + print "trans("Save")."\">"; + print "trans("Cancel")."\">"; + print ""; + print "
'; + + print "
\n"; + +}else { + + /* + * view Template + */ + + // box add_jobs_box + print ''; + + print '"; + print "\n"; + + print '"; + print ""; + + print ""; + + print ""; + + print ""; + + print ""; + print ""; + + print ""; + print ""; + + print ""; + print ""; + + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '"; + + print '
'; + print $langs->trans('CronId')."".$form->showrefnav($object, 'id', $linkback, 1, 'rowid', 'id'); + print "
'; + print $langs->trans('CronLabel')."".$object->label; + print "
"; + print $langs->trans('CronType').""; + print $formCron->select_typejob('jobtype',$object->jobtype,1); + print "
"; + print $langs->trans('CronHourStart').""; + if(!empty($object->datestart)) {print dol_print_date($object->datestart,'dayhourtext');} else {print $langs->trans('CronNone');} + print "
"; + print $langs->trans('CronDtEnd').""; + if(!empty($object->dateend)) {print dol_print_date($object->dateend,'dayhourtext');} else {print $langs->trans('CronNone');} + print "
"; + print $langs->trans('CronPriority')."".$object->priority; + print "
"; + print $langs->trans('CronNbRun')."".$object->nbrun; + print "
"; + print $langs->trans('CronEvery').""; + if($object->unitfrequency == "60") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Minutes'); + if($object->unitfrequency == "3600") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Hours'); + if($object->unitfrequency == "86400") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Days'); + if($object->unitfrequency == "604800") print $langs->trans('CronEach')." ".($object->frequency/$object->unitfrequency)." ".$langs->trans('Weeks'); + print "
'; + print $langs->trans('CronModule').""; + print $object->module_name; + print "
'; + print $langs->trans('CronClassFile').""; + print $object->classesname; + print "
'; + print $langs->trans('CronObject').""; + print $object->objectname; + print "
'; + print $langs->trans('CronMethod').""; + print $object->methodename; + print "
'; + print $langs->trans('CronArgs').""; + print $object->params; + print "
'; + print $langs->trans('CronCommand').""; + print $object->command; + print "
'; + print $langs->trans('CronNote').""; + print $object->note; + print "
'; + print $langs->trans('CronDtLastLaunch').""; + if(!empty($object->datelastrun)) {print dol_print_date($object->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print "
'; + print $langs->trans('CronDtNextLaunch').""; + if(!empty($object->datenextrun)) {print dol_print_date($object->datenextrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print "
'; + print $langs->trans('CronDtLastResult').""; + if(!empty($object->datelastresult)) {print dol_print_date($object->datelastresult,'dayhourtext');} else {print $langs->trans('CronNone');} + print "
'; + print $langs->trans('CronLastResult').""; + print $object->lastresult; + print "
'; + print $langs->trans('CronLastOutput').""; + print nl2br($object->lastoutput); + print "
'; + + print "\n\n
\n"; + if (! $user->rights->cron->create) { + print ''.$langs->trans("Edit").''; + } else { + print ''.$langs->trans("Edit").''; + } + if (! $user->rights->cron->delete) { + print ''.$langs->trans("Delete").''; + } else { + print ''.$langs->trans("Delete").''; + } + if (! $user->rights->cron->create) { + print ''.$langs->trans("CronStatusActiveBtn").'/'.$langs->trans("CronStatusInactiveBtn").''; + } else { + if (empty($object->status)) { + print ''.$langs->trans("CronStatusActiveBtn").''; + } else { + print ''.$langs->trans("CronStatusInactiveBtn").''; + } + } + if ((! $user->rights->cron->execute) || (empty($object->status))) { + print ''.$langs->trans("CronExecute").''; + } else { + print ''.$langs->trans("CronExecute").''; + } + print '

'; +} + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/cron/class/cronjob.class.php b/htdocs/cron/class/cronjob.class.php index b2b5fcddd1a..b24055c6f3d 100644 --- a/htdocs/cron/class/cronjob.class.php +++ b/htdocs/cron/class/cronjob.class.php @@ -1,6 +1,6 @@ - * Copyright (C) ---Put here your own copyright and developer email--- + * Copyright (C) 2013 Florian Henry * * 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 @@ -17,42 +17,58 @@ */ /** - * \file dev/skeletons/cronjob.class.php + * \file cron/class/cronjob.class.php * \ingroup cron - * \brief CRUD class file (Create/Read/Update/Delete) for cronjob table - * Initialy built by build_class_from_table on 2013-03-17 18:50 */ // Put here all includes required by your class file require_once(DOL_DOCUMENT_ROOT."/core/class/commonobject.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/societe/class/societe.class.php"); -//require_once(DOL_DOCUMENT_ROOT."/product/class/product.class.php"); /** - * Put here description of your class + * Crob Job class */ class Cronjob extends CommonObject { var $db; //!< To store db handler var $error; //!< To return error code (or message) var $errors=array(); //!< To return several error codes (or messages) - var $element='cronjob'; //!< Id that identify managed objects + var $element='cronjob'; //!< Id that identify managed objects var $table_element='cronjob'; //!< Name of table without prefix where object is stored var $id; - + + var $ref; //Use for prevnext_ref + var $jobtype; var $tms=''; var $datec=''; + var $label; var $command; + var $classesname; + var $objectname; + var $methodename; var $params; + var $md5params; + var $module_name; + var $priority; var $datelastrun=''; - var $lastresult=''; + var $datenextrun=''; + var $dateend=''; + var $datestart=''; + var $datelastresult=''; + var $lastresult; var $lastoutput; - var $fk_user; + var $unitfrequency; + var $frequency; + var $status; + var $fk_user_author; + var $fk_user_mod; var $note; + var $nbrun; + + var $lines; - + /** @@ -80,51 +96,128 @@ 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); + if (isset($this->classesname)) $this->classesname=trim($this->classesname); + if (isset($this->objectname)) $this->objectname=trim($this->objectname); + if (isset($this->methodename)) $this->methodename=trim($this->methodename); if (isset($this->params)) $this->params=trim($this->params); + if (isset($this->md5params)) $this->md5params=trim($this->md5params); + if (isset($this->module_name)) $this->module_name=trim($this->module_name); + if (isset($this->priority)) $this->priority=trim($this->priority); if (isset($this->lastoutput)) $this->lastoutput=trim($this->lastoutput); - if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user); + if (isset($this->lastresult)) $this->lastresult=trim($this->lastresult); + if (isset($this->unitfrequency)) $this->unitfrequency=trim($this->unitfrequency); + if (isset($this->frequency)) $this->frequency=trim($this->frequency); + if (isset($this->status)) $this->status=trim($this->status); if (isset($this->note)) $this->note=trim($this->note); - - + if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); // Check parameters - // Put here code to add control on parameters values + // Put here code to add a control on parameters values + if (dol_strlen($this->datestart)==0) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronDtStart')); + $error++; + } + if (empty($this->label)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLabel')); + $error++; + } + if ((dol_strlen($this->datestart)!=0) && (dol_strlen($this->dateend)!=0) && ($this->dateend<$this->datestart)) { + $this->errors[]=$langs->trans('CronErrEndDateStartDt'); + $error++; + } + if (empty($this->unitfrequency)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronFrequency')); + $error++; + } + if (($this->jobtype=='command') && (empty($this->command))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronCommand')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->classesname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronClass')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->methodename))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronMethod')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->objectname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject')); + $error++; + } // Insert request $sql = "INSERT INTO ".MAIN_DB_PREFIX."cronjob("; - + $sql.= "datec,"; + $sql.= "jobtype,"; + $sql.= "label,"; $sql.= "command,"; + $sql.= "classesname,"; + $sql.= "objectname,"; + $sql.= "methodename,"; $sql.= "params,"; + $sql.= "md5params,"; + $sql.= "module_name,"; + $sql.= "priority,"; $sql.= "datelastrun,"; + $sql.= "datenextrun,"; + $sql.= "dateend,"; + $sql.= "datestart,"; $sql.= "lastresult,"; + $sql.= "datelastresult,"; $sql.= "lastoutput,"; - $sql.= "fk_user,"; - $sql.= "note"; - + $sql.= "unitfrequency,"; + $sql.= "frequency,"; + $sql.= "status,"; + $sql.= "fk_user_author,"; + $sql.= "fk_user_mod,"; + $sql.= "note,"; + $sql.= "nbrun"; + $sql.= ") VALUES ("; - - $sql.= " ".(! isset($this->datec) || dol_strlen($this->datec)==0?'NULL':$this->db->idate($this->datec)).","; + + $sql.= " ".$this->db->idate(dol_now()).","; + $sql.= " ".(! isset($this->jobtype)?'NULL':"'".$this->db->escape($this->jobtype)."'").","; + $sql.= " ".(! isset($this->label)?'NULL':"'".$this->db->escape($this->label)."'").","; $sql.= " ".(! isset($this->command)?'NULL':"'".$this->db->escape($this->command)."'").","; + $sql.= " ".(! isset($this->classesname)?'NULL':"'".$this->db->escape($this->classesname)."'").","; + $sql.= " ".(! isset($this->objectname)?'NULL':"'".$this->db->escape($this->objectname)."'").","; + $sql.= " ".(! isset($this->methodename)?'NULL':"'".$this->db->escape($this->methodename)."'").","; $sql.= " ".(! isset($this->params)?'NULL':"'".$this->db->escape($this->params)."'").","; + $sql.= " ".(! isset($this->md5params)?'NULL':"'".$this->db->escape($this->md5params)."'").","; + $sql.= " ".(! isset($this->module_name)?'NULL':"'".$this->db->escape($this->module_name)."'").","; + $sql.= " ".(! isset($this->priority)?'NULL':"'".$this->priority."'").","; $sql.= " ".(! isset($this->datelastrun) || dol_strlen($this->datelastrun)==0?'NULL':$this->db->idate($this->datelastrun)).","; - $sql.= " ".(! isset($this->lastresult) || dol_strlen($this->lastresult)==0?'NULL':$this->db->idate($this->lastresult)).","; + $sql.= " ".(! isset($this->datenextrun) || dol_strlen($this->datenextrun)==0?'NULL':$this->db->idate($this->datenextrun)).","; + $sql.= " ".(! isset($this->dateend) || dol_strlen($this->dateend)==0?'NULL':$this->db->idate($this->dateend)).","; + $sql.= " ".(! isset($this->datestart) || dol_strlen($this->datestart)==0?'NULL':$this->db->idate($this->datestart)).","; + $sql.= " ".(! isset($this->lastresult)?'NULL':"'".$this->db->escape($this->lastresult)."'").","; + $sql.= " ".(! isset($this->datelastresult) || dol_strlen($this->datelastresult)==0?'NULL':$this->db->idate($this->datelastresult)).","; $sql.= " ".(! isset($this->lastoutput)?'NULL':"'".$this->db->escape($this->lastoutput)."'").","; - $sql.= " ".(! isset($this->fk_user)?'NULL':"'".$this->fk_user."'").","; - $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").""; - + $sql.= " ".(! isset($this->unitfrequency)?'NULL':"'".$this->unitfrequency."'").","; + $sql.= " ".(! isset($this->frequency)?'NULL':"'".$this->frequency."'").","; + $sql.= " ".(! isset($this->status)?'0':"'".$this->status."'").","; + $sql.= " ".$user->id.","; + $sql.= " ".$user->id.","; + $sql.= " ".(! isset($this->note)?'NULL':"'".$this->db->escape($this->note)."'").","; + $sql.= " ".(! isset($this->nbrun)?'0':"'".$this->db->escape($this->nbrun)."'").""; + $sql.= ")"; + $this->db->begin(); dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."cronjob"); @@ -173,18 +266,35 @@ class Cronjob extends CommonObject global $langs; $sql = "SELECT"; $sql.= " t.rowid,"; - + $sql.= " t.tms,"; $sql.= " t.datec,"; + $sql.= " t.jobtype,"; + $sql.= " t.label,"; $sql.= " t.command,"; + $sql.= " t.classesname,"; + $sql.= " t.objectname,"; + $sql.= " t.methodename,"; $sql.= " t.params,"; + $sql.= " t.md5params,"; + $sql.= " t.module_name,"; + $sql.= " t.priority,"; $sql.= " t.datelastrun,"; + $sql.= " t.datenextrun,"; + $sql.= " t.dateend,"; + $sql.= " t.datestart,"; $sql.= " t.lastresult,"; + $sql.= " t.datelastresult,"; $sql.= " t.lastoutput,"; - $sql.= " t.fk_user,"; - $sql.= " t.note"; - + $sql.= " t.unitfrequency,"; + $sql.= " t.frequency,"; + $sql.= " t.status,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.note,"; + $sql.= " t.nbrun"; + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; $sql.= " WHERE t.rowid = ".$id; @@ -197,18 +307,36 @@ class Cronjob extends CommonObject $obj = $this->db->fetch_object($resql); $this->id = $obj->rowid; - + $this->ref = $obj->rowid; + $this->tms = $this->db->jdate($obj->tms); $this->datec = $this->db->jdate($obj->datec); + $this->label = $obj->label; + $this->jobtype = $obj->jobtype; $this->command = $obj->command; + $this->classesname = $obj->classesname; + $this->objectname = $obj->objectname; + $this->methodename = $obj->methodename; $this->params = $obj->params; + $this->md5params = $obj->md5params; + $this->module_name = $obj->module_name; + $this->priority = $obj->priority; $this->datelastrun = $this->db->jdate($obj->datelastrun); - $this->lastresult = $this->db->jdate($obj->lastresult); + $this->datenextrun = $this->db->jdate($obj->datenextrun); + $this->dateend = $this->db->jdate($obj->dateend); + $this->datestart = $this->db->jdate($obj->datestart); + $this->lastresult = $obj->lastresult; $this->lastoutput = $obj->lastoutput; - $this->fk_user = $obj->fk_user; + $this->datelastresult = $this->db->jdate($obj->datelastresult); + $this->unitfrequency = $obj->unitfrequency; + $this->frequency = $obj->frequency; + $this->status = $obj->status; + $this->fk_user_author = $obj->fk_user_author; + $this->fk_user_mod = $obj->fk_user_mod; $this->note = $obj->note; + $this->nbrun = $obj->nbrun; - + } $this->db->free($resql); @@ -221,6 +349,141 @@ class Cronjob extends CommonObject return -1; } } + + /** + * Load object in memory from the database + * + * @param string $sortorder sort order + * @param string $sortfield sort field + * @param int $limit limit page + * @param int $offset page + * @param int $status display active or not + * @param array $filter filter output + * @return int <0 if KO, >0 if OK + */ + function fetch_all($sortorder='DESC', $sortfield='t.rowid', $limit=0, $offset=0, $status=1, $filter='') + { + global $langs; + $sql = "SELECT"; + $sql.= " t.rowid,"; + $sql.= " t.tms,"; + $sql.= " t.datec,"; + $sql.= " t.jobtype,"; + $sql.= " t.label,"; + $sql.= " t.command,"; + $sql.= " t.classesname,"; + $sql.= " t.objectname,"; + $sql.= " t.methodename,"; + $sql.= " t.params,"; + $sql.= " t.md5params,"; + $sql.= " t.module_name,"; + $sql.= " t.priority,"; + $sql.= " t.datelastrun,"; + $sql.= " t.datenextrun,"; + $sql.= " t.dateend,"; + $sql.= " t.datestart,"; + $sql.= " t.lastresult,"; + $sql.= " t.datelastresult,"; + $sql.= " t.lastoutput,"; + $sql.= " t.unitfrequency,"; + $sql.= " t.frequency,"; + $sql.= " t.status,"; + $sql.= " t.fk_user_author,"; + $sql.= " t.fk_user_mod,"; + $sql.= " t.note,"; + $sql.= " t.nbrun"; + + + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; + $status = (empty($status))?'0':'1'; + $sql.= " WHERE t.status=".$status; + //Manage filter + if (is_array($filter) && count($filter)>0) { + foreach($filter as $key => $value) { + $sql.= ' AND '.$key.' LIKE \'%'.$value.'%\''; + } + } + + + $sql.= " ORDER BY $sortfield $sortorder "; + if (!empty($limit) && !empty($offset)) { + $sql.= $this->db->plimit( $limit + 1 ,$offset); + } + + $sqlwhere = array(); + + if (!empty($module_name)) { + $sqlwhere[]='(t.module_name='.$module_name.')'; + } + if (count($sqlwhere)>0) { + $sql.= " WHERE ".implode(' AND ',$sqlwhere); + } + + dol_syslog(get_class($this)."::fetch_all sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + $num=$this->db->num_rows($resql); + $i=0; + + if ($num) + { + $this->lines=array(); + + while ($i < $num) + { + + $line = new Cronjobline(); + + $obj = $this->db->fetch_object($resql); + + $line->id = $obj->rowid; + $line->ref = $obj->rowid; + + $line->tms = $this->db->jdate($obj->tms); + $line->datec = $this->db->jdate($obj->datec); + $line->label = $obj->label; + $line->jobtype = $obj->jobtype; + $line->command = $obj->command; + $line->classesname = $obj->classesname; + $line->objectname = $obj->objectname; + $line->methodename = $obj->methodename; + $line->params = $obj->params; + $line->md5params = $obj->md5params; + $line->module_name = $obj->module_name; + $line->priority = $obj->priority; + $line->datelastrun = $this->db->jdate($obj->datelastrun); + $line->datenextrun = $this->db->jdate($obj->datenextrun); + $line->dateend = $this->db->jdate($obj->dateend); + $line->datestart = $this->db->jdate($obj->datestart); + $line->lastresult = $obj->lastresult; + $line->datelastresult = $this->db->jdate($obj->datelastresult); + $line->lastoutput = $obj->lastoutput; + $line->unitfrequency = $obj->unitfrequency; + $line->frequency = $obj->frequency; + $line->status = $obj->status; + $line->fk_user_author = $obj->fk_user_author; + $line->fk_user_mod = $obj->fk_user_mod; + $line->note = $obj->note; + $line->nbrun = $obj->nbrun; + + $this->lines[]=$line; + + $i++; + + } + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } /** @@ -233,35 +496,98 @@ class Cronjob extends CommonObject function update($user=0, $notrigger=0) { global $conf, $langs; + + $langs->load('cron'); + $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); + if (isset($this->classesname)) $this->classesname=trim($this->classesname); + if (isset($this->objectname)) $this->objectname=trim($this->objectname); + if (isset($this->methodename)) $this->methodename=trim($this->methodename); if (isset($this->params)) $this->params=trim($this->params); + if (isset($this->md5params)) $this->md5params=trim($this->md5params); + if (isset($this->module_name)) $this->module_name=trim($this->module_name); + if (isset($this->priority)) $this->priority=trim($this->priority); if (isset($this->lastoutput)) $this->lastoutput=trim($this->lastoutput); - if (isset($this->fk_user)) $this->fk_user=trim($this->fk_user); + if (isset($this->lastresult)) $this->lastresult=trim($this->lastresult); + if (isset($this->unitfrequency)) $this->unitfrequency=trim($this->unitfrequency); + if (isset($this->frequency)) $this->frequency=trim($this->frequency); + if (isset($this->status)) $this->status=trim($this->status); if (isset($this->note)) $this->note=trim($this->note); - - + if (isset($this->nbrun)) $this->nbrun=trim($this->nbrun); // Check parameters // Put here code to add a control on parameters values + if (empty($this->status)) { + $this->dateend=dol_now(); + } + if (dol_strlen($this->datestart)==0) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronDtStart')); + $error++; + } + if ((dol_strlen($this->datestart)!=0) && (dol_strlen($this->dateend)!=0) && ($this->dateend<$this->datestart)) { + $this->errors[]=$langs->trans('CronErrEndDateStartDt'); + $error++; + } + if (empty($this->label)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronLabel')); + $error++; + } + if (empty($this->unitfrequency)) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronFrequency')); + $error++; + } + if (($this->jobtype=='command') && (empty($this->command))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronCommand')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->classesname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronClass')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->methodename))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronMethod')); + $error++; + } + if (($this->jobtype=='method') && (empty($this->objectname))) { + $this->errors[]=$langs->trans('CronFieldMandatory',$langs->trans('CronObject')); + $error++; + } + // Update request $sql = "UPDATE ".MAIN_DB_PREFIX."cronjob SET"; - - $sql.= " tms=".(dol_strlen($this->tms)!=0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; - $sql.= " datec=".(dol_strlen($this->datec)!=0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; + + $sql.= " label=".(isset($this->label)?"'".$this->db->escape($this->label)."'":"null").","; + $sql.= " jobtype=".(isset($this->jobtype)?"'".$this->db->escape($this->jobtype)."'":"null").","; $sql.= " command=".(isset($this->command)?"'".$this->db->escape($this->command)."'":"null").","; + $sql.= " classesname=".(isset($this->classesname)?"'".$this->db->escape($this->classesname)."'":"null").","; + $sql.= " objectname=".(isset($this->objectname)?"'".$this->db->escape($this->objectname)."'":"null").","; + $sql.= " methodename=".(isset($this->methodename)?"'".$this->db->escape($this->methodename)."'":"null").","; $sql.= " params=".(isset($this->params)?"'".$this->db->escape($this->params)."'":"null").","; + $sql.= " md5params=".(isset($this->md5params)?"'".$this->db->escape($this->md5params)."'":"null").","; + $sql.= " module_name=".(isset($this->module_name)?"'".$this->db->escape($this->module_name)."'":"null").","; + $sql.= " priority=".(isset($this->priority)?$this->priority:"null").","; $sql.= " datelastrun=".(dol_strlen($this->datelastrun)!=0 ? "'".$this->db->idate($this->datelastrun)."'" : 'null').","; - $sql.= " lastresult=".(dol_strlen($this->lastresult)!=0 ? "'".$this->db->idate($this->lastresult)."'" : 'null').","; + $sql.= " datenextrun=".(dol_strlen($this->datenextrun)!=0 ? "'".$this->db->idate($this->datenextrun)."'" : 'null').","; + $sql.= " dateend=".(dol_strlen($this->dateend)!=0 ? "'".$this->db->idate($this->dateend)."'" : 'null').","; + $sql.= " datestart=".(dol_strlen($this->datestart)!=0 ? "'".$this->db->idate($this->datestart)."'" : 'null').","; + $sql.= " datelastresult=".(dol_strlen($this->datelastresult)!=0 ? "'".$this->db->idate($this->datelastresult)."'" : 'null').","; + $sql.= " lastresult=".(isset($this->lastresult)?"'".$this->db->escape($this->lastresult)."'":"null").","; $sql.= " lastoutput=".(isset($this->lastoutput)?"'".$this->db->escape($this->lastoutput)."'":"null").","; - $sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").","; - $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").""; - + $sql.= " unitfrequency=".(isset($this->unitfrequency)?$this->unitfrequency:"null").","; + $sql.= " frequency=".(isset($this->frequency)?$this->frequency:"null").","; + $sql.= " status=".(isset($this->status)?$this->status:"null").","; + $sql.= " fk_user_mod=".$user->id.","; + $sql.= " note=".(isset($this->note)?"'".$this->db->escape($this->note)."'":"null").","; + $sql.= " nbrun=".(isset($this->nbrun)?$this->nbrun:"null"); + $sql.= " WHERE rowid=".$this->id; $this->db->begin(); @@ -269,7 +595,7 @@ class Cronjob extends CommonObject dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); } - + if (! $error) { if (! $notrigger) @@ -377,7 +703,7 @@ class Cronjob extends CommonObject $error=0; - $object=new Cronjobs($this->db); + $object=new Cronjob($this->db); $this->db->begin(); @@ -428,19 +754,277 @@ class Cronjob extends CommonObject function initAsSpecimen() { $this->id=0; - + $this->ref=0; + $this->tms=''; $this->datec=''; + $this->label=''; + $this->jobtype=''; $this->command=''; + $this->classesname=''; + $this->objectname=''; + $this->methodename=''; $this->params=''; + $this->md5params=''; + $this->module_name=''; + $this->priority=''; $this->datelastrun=''; - $this->lastresult=''; + $this->datenextrun=''; + $this->dateend=''; + $this->datestart=''; + $this->datelastresult=''; $this->lastoutput=''; - $this->fk_user=''; - $this->note=''; - - + $this->lastresult=''; + $this->unitfrequency=''; + $this->frequency=''; + $this->status=''; + $this->fk_user_author=''; + $this->fk_user_mod=''; + $this->note=''; + $this->nbrun=''; } + + /** + * Load object information + * + * @return void + */ + function info() + { + global $langs; + + $sql = "SELECT"; + $sql.= " f.rowid, f.datec, f.tms, f.fk_user_mod, f.fk_user_author"; + $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as f"; + $sql.= " WHERE f.rowid = ".$this->id; + + dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG); + $resql=$this->db->query($sql); + if ($resql) + { + if ($this->db->num_rows($resql)) + { + $obj = $this->db->fetch_object($resql); + $this->id = $obj->rowid; + $this->date_creation = $this->db->jdate($obj->datec); + $this->date_modification = $this->db->jdate($obj->tms); + $this->user_modification = $obj->fk_user_mod; + $this->user_creation = $obj->fk_user_author; + } + $this->db->free($resql); + + return 1; + } + else + { + $this->error="Error ".$this->db->lasterror(); + dol_syslog(get_class($this)."::fetch ".$this->error, LOG_ERR); + return -1; + } + } + + /** + * Run a job + * + * @param string $userlogin User login + * @return int <0 if KO, >0 if OK + */ + function run_jobs($userlogin) + { + global $langs, $conf; + + $langs->load('cron'); + + if (empty($userlogin)) { + $this->error="User login is mandatory"; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user=new User($this->db); + $result=$user->fetch('',$userlogin); + if ($result<0) { + $this->error="User Error:".$user->error; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + }else { + if (empty($user->id)) { + $this->error=" User user login:".$userlogin." do not exists"; + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + } + + dol_syslog(get_class($this)."::run_jobs userlogin:$userlogin", LOG_DEBUG); + + $error=0; + $now=dol_now(); + + $this->db->begin(); + + if ($this->jobtype=='method') { + // load classes + $ret=dol_include_once("/".$this->module_name."/class/".$this->classesname,$this->objectname); + if ($ret===false) { + $this->error=$langs->trans('CronCannotLoadClass',$file,$this->objectname); + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + return -1; + } + + // Load langs + $result=$langs->load($this->module_name.'@'.$this->module_name); + if ($result<0) { + dol_syslog(get_class($this)."::run_jobs Cannot load module langs".$langs->error, LOG_ERR); + return -1; + } + + 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 = array(); + $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); + return -1; + }else { + $this->lastoutput=var_export($result,true); + $this->lastresult=var_export($result,true); + } + + } elseif ($this->jobtype=='command') { + dol_syslog(get_class($this)."::run_jobs system:".$this->command, LOG_DEBUG); + $output_arr=array(); + + exec($this->command, $output_arr,$retval); + + dol_syslog(get_class($this)."::run_jobs output_arr:".var_export($output_arr,true), LOG_DEBUG); + + $this->lastoutput=''; + if (is_array($output_arr) && count($output_arr)>0) { + foreach($output_arr as $val) { + $this->lastoutput.=$val."\n"; + } + } + $this->lastresult=$retval; + } + + $this->datelastresult=$now; + $this->datelastrun=$now; + $this->nbrun=$this->nbrun+1; + $result = $this->update($user); + if ($result<0) { + dol_syslog(get_class($this)."::run_jobs ".$this->error, LOG_ERR); + $this->db->rollback(); + return -1; + }else { + $this->db->commit(); + return 1; + } + + + } + + /** + * Reprogram a job + * + * @param string $userlogin User login + * @return int <0 if KO, >0 if OK + * + */ + function reprogram_jobs($userlogin) + { + global $langs, $conf; + + dol_syslog(get_class($this)."::reprogram_jobs userlogin:$userlogin", LOG_DEBUG); + + require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; + $user=new User($this->db); + $result=$user->fetch('',$userlogin); + if ($result<0) { + $this->error="User Error:".$user->error; + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + }else { + if (empty($user->id)) { + $this->error=" User user login:".$userlogin." do not exists"; + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + } + } + + dol_syslog(get_class($this)."::reprogram_jobs ", LOG_DEBUG); + + if (empty($this->datenextrun)) { + $this->datenextrun=dol_now()+$this->frequency; + } else { + if ($this->datenextrundatenextrun=dol_now()+$this->frequency; + } else { + $this->datenextrun=$this->datenextrun+$this->frequency; + } + } + $result = $this->update($user); + if ($result<0) { + dol_syslog(get_class($this)."::reprogram_jobs ".$this->error, LOG_ERR); + return -1; + } + + return 1; + + } } -?> + + +/** + * Crob Job line class + */ +class Cronjobline{ + + var $id; + var $ref; + + var $tms=''; + var $datec=''; + var $label; + var $jobtype; + var $command; + var $classesname; + var $objectname; + var $methodename; + var $params; + var $md5params; + var $module_name; + var $priority; + var $datelastrun=''; + var $datenextrun=''; + var $dateend=''; + var $datestart=''; + var $lastresult=''; + var $lastoutput; + var $unitfrequency; + var $frequency; + var $status; + var $fk_user_author; + var $fk_user_mod; + var $note; + var $nbrun; + + /** + * Constructor + * + */ + function __construct() + { + return 1; + } +} \ No newline at end of file diff --git a/htdocs/cron/functions_cron.lib.php b/htdocs/cron/functions_cron.lib.php deleted file mode 100644 index 31cc8ebefad..00000000000 --- a/htdocs/cron/functions_cron.lib.php +++ /dev/null @@ -1,27 +0,0 @@ - - * Copyright (C) 2007-2009 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 - * the Free Software Foundation; either version 3 of the License, or - * (at your option) 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 cron/functions_cron.lib.php - * \ingroup core - * \brief Functions for miscellaneous cron tasks - */ - - - -?> diff --git a/htdocs/cron/index.php b/htdocs/cron/index.php deleted file mode 100644 index 3d7ef46ad77..00000000000 --- a/htdocs/cron/index.php +++ /dev/null @@ -1,219 +0,0 @@ - - * - * 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 - * (at your option) 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 dev/Cronjobss/Cronjobs_page.php - * \ingroup mymodule othermodule1 othermodule2 - * \brief This file is an example of a php page - * Initialy built by build_class_from_table on 2013-03-17 18:50 - */ - -//if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1'); -//if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1'); -//if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); -//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); -//if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); -//if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); -//if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no menu to show -//if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php -//if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); -//if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session) - -// Change this following line to use the correct relative path (../, ../../, etc) -$res=0; -if (! $res && file_exists("../main.inc.php")) $res=@include '../main.inc.php'; -if (! $res && file_exists("../../main.inc.php")) $res=@include '../../main.inc.php'; -if (! $res && file_exists("../../../main.inc.php")) $res=@include '../../../main.inc.php'; -if (! $res && file_exists("../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res && file_exists("../../../../../dolibarr/htdocs/main.inc.php")) $res=@include '../../../../../dolibarr/htdocs/main.inc.php'; // Used on dev env only -if (! $res) die("Include of main fails"); -// Change this following line to use the correct relative path from htdocs -dol_include_once('/module/class/cronjob.class.php'); - -// Load traductions files requiredby by page -$langs->load("companies"); -$langs->load("other"); -$langs->load("cron"); - -// Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); -$myparam = GETPOST('myparam','alpha'); -$action='list'; - -// Protection if external user -if ($user->societe_id > 0) accessforbidden(); -if (! $user->admin) accessforbidden(); - - -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ - -if ($action == 'add') -{ - $object=new Cronjobs($db); - $object->prop1=$_POST["field1"]; - $object->prop2=$_POST["field2"]; - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - } - { - // Creation KO - $mesg=$object->error; - } -} - - - - - -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ - -llxHeader('','MyPageName',''); - -$form=new Form($db); - - -//print ''; -//print '
'; -print '
'; - - - - - -//print '
'; -print '
'; - - - -// Example 1 : Adding jquery code -print ''; - - -// Example 2 : Adding links to objects -// The class must extends CommonObject class to have this method available -//$somethingshown=$object->showLinkedObjectBlock(); - - -// Example 3 : List of data -if ($action == 'list') -{ - $sql = "SELECT"; - $sql.= " t.rowid,"; - - $sql.= " t.tms,"; - $sql.= " t.datec,"; - $sql.= " t.command,"; - $sql.= " t.params,"; - $sql.= " t.datelastrun,"; - $sql.= " t.lastresult,"; - $sql.= " t.lastoutput,"; - $sql.= " t.fk_user,"; - $sql.= " t.note"; - - - $sql.= " FROM ".MAIN_DB_PREFIX."cronjob as t"; - //$sql.= " WHERE field3 = 'xxx'"; - //$sql.= " ORDER BY field1 ASC"; - - - print_fiche_titre($langs->trans("ListOfCronJobs"),'','').'
'; - - - print ''."\n"; - print ''; - print_liste_field_titre($langs->trans('Id'),$_SERVER['PHP_SELF'],'t.rowid','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('Command'),$_SERVER['PHP_SELF'],'t.command','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DateCreation'),$_SERVER['PHP_SELF'],'t.datec','align="center"',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('LastOutput'),$_SERVER['PHP_SELF'],'','',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('DateLastRun'),$_SERVER['PHP_SELF'],'t.datelastrun','align="center"',$param,'',$sortfield,$sortorder); - print_liste_field_titre($langs->trans('LastResult'),$_SERVER['PHP_SELF'],'t.lastresult','align="right"',$param,'',$sortfield,$sortorder); - print ''; - - dol_syslog($script_file." sql=".$sql, LOG_DEBUG); - $resql=$db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - if ($num) - { - while ($i < $num) - { - $obj = $db->fetch_object($resql); - if ($obj) - { - // You can use here results - print ''; - } - $i++; - } - } - } - else - { - $error++; - dol_print_error($db); - } - - print '
'; - print $obj->rowid; - print ''; - print $obj->command; - print ''; - print $db->jdate($obj->datec); - print ''; - print ''; - print ''; - print $db->jdate($obj->datelastrun); - print ''; - print $obj->lastresult; - print '
'."\n"; -} - - -//print '
'; -print '
'; - - -// End of page -llxFooter(); -$db->close(); -?> diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php new file mode 100644 index 00000000000..55c294d54ed --- /dev/null +++ b/htdocs/cron/info.php @@ -0,0 +1,59 @@ + +* +* 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 +* (at your option) 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, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/** + * \file /cron/cron/info.php + * \brief Page fiche d'une operation + */ + +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, 'bill'); + +print '
'; +dol_print_object_info($object); +print '
'; +print '
'; + + +$db->close(); +llxFooter(); \ No newline at end of file diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php new file mode 100644 index 00000000000..5e972f0e55b --- /dev/null +++ b/htdocs/cron/list.php @@ -0,0 +1,295 @@ + + * + * 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 + * (at your option) 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 cron/cron/list.php + * \ingroup cron + * \brief Lists Jobs + */ + + +require '../main.inc.php'; +require_once(DOL_DOCUMENT_ROOT."/core/lib/admin.lib.php"); + +// librairie jobs +require_once DOL_DOCUMENT_ROOT."/cron/class/cronjob.class.php"; +require_once DOL_DOCUMENT_ROOT.'/core/lib/cron.lib.php'; + +$langs->load("admin"); +$langs->load("cron"); + +if (!$user->rights->cron->read) accessforbidden(); + +/* + * Actions + */ +$action=GETPOST('action','alpha'); +$confirm=GETPOST('confirm','alpha'); +$id=GETPOST('id','int'); + +$sortorder=GETPOST('sortorder','alpha'); +$sortfield=GETPOST('sortfield','alpha'); +$page=GETPOST('page','int'); +$status=GETPOST('status','int'); + +//Search criteria +$search_label=GETPOST("search_label",'alpha'); + +if (empty($sortorder)) $sortorder="DESC"; +if (empty($sortfield)) $sortfield="t.datenextrun"; +if (empty($arch)) $arch = 0; + +if ($page == -1) { + $page = 0 ; +} + +$limit = $conf->global->MAIN_SIZE_LISTE_LIMIT; +$offset = $limit * $page ; +$pageprev = $page - 1; +$pagenext = $page + 1; + +// Do we click on purge search criteria ? +if (GETPOST("button_removefilter_x")) +{ + $search_label=''; +} + +$filter=array(); +if (!empty($search_label)) { + $filter['t.label']=$search_label; +} + +// Delete jobs +if ($action == 'confirm_delete' && $confirm == "yes" && $user->rights->cron->delete){ + + //Delete de la tache cron + $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'); + } + +} + + +/* + * View + */ +if (!empty($status)) { + $pagetitle=$langs->trans("CronListActive"); +}else { + $pagetitle=$langs->trans("CronListInactive"); +} + +llxHeader('',$pagetitle); + + +// Form object for popup +$form = new Form($db); + +if ($action == 'delete') +{ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronDelete"),$langs->trans("CronConfirmDelete"),"confirm_delete",'','',1); + if ($ret == 'html') print '
'; +} + +if ($action == 'execute'){ + $ret=$form->form_confirm($_SERVER['PHP_SELF']."?id=".$id.'&status='.$status,$langs->trans("CronExecute"),$langs->trans("CronConfirmExecute"),"confirm_execute",'','',1); + if ($ret == 'html') print '
'; +} + + +print_fiche_titre($pagetitle,'','setup'); + +print $langs->trans('CronInfo'); + +// liste des jobs creer +$object = new Cronjob($db); +$result=$object->fetch_all($sortorder, $sortfield, $limit, $offset, $status, $filter); +if ($result < 0) { + setEventMessage($object->error,'errors'); +} + + +print "

"; +print $langs->trans('CronWaitingJobs'); +print "

"; + +if (count($object->lines)>0) { + + print ''; + print ''; + $arg_url='&page='.$page.'&status='.$status.'&search_label='.$search_label; + print_liste_field_titre($langs->trans("CronLabel"),$_SERVEUR['PHP_SELF'],"t.label","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronTask"),'','',"",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtStart"),$_SERVEUR['PHP_SELF'],"t.datestart","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtEnd"),$_SERVEUR['PHP_SELF'],"t.dateend","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtLastLaunch"),$_SERVEUR['PHP_SELF'],"t.datelastrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronDtNextLaunch"),$_SERVEUR['PHP_SELF'],"t.datenextrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronFrequency"),'',"","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronNbRun"),$_SERVEUR['PHP_SELF'],"t.nbrun","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronLastResult"),$_SERVEUR['PHP_SELF'],"t.lastresult","",$arg_url,'',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CronLastOutput"),$_SERVEUR['PHP_SELF'],"t.lastoutput","",$arg_url,'',$sortfield,$sortorder); + print ''; + + print ''; + + print ''."\n"; + print ''; + print ''; + + + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + + print ''; + print ''; + + + + // Boucler sur chaque job + $style='impair'; + foreach($object->lines as $line){ + // title profil + if ($style=='pair') {$style='impair';} + else {$style='pair';} + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + + print ''; + } + print '
'; + print ''; + print '         '; + print '  '; + print ''; + print '
'; + if(!empty($line->label)) { + print ''.$line->label.''; + } + else { + print $langs->trans('CronNone'); + } + print ''; + if ($line->jobtype=='method') { + print $langs->trans('CronModule').':'.$line->module_name.'
'; + print $langs->trans('CronClass').':'. $line->classesname.'
'; + print $langs->trans('CronObject').':'. $line->objectname.'
'; + print $langs->trans('CronMethod').':'. $line->methodename; + if(!empty($line->params)) { + print '
'.$langs->trans('CronArgs').':'. $line->params; + } + + }elseif ($line->jobtype=='command') { + print $langs->trans('CronCommand').':'. dol_trunc($line->command); + if(!empty($line->params)) { + print '
'.$langs->trans('CronArgs').':'. $line->params; + } + } + print '
'; + if(!empty($line->datestart)) {print dol_print_date($line->datestart,'dayhourtext');} else {print $langs->trans('CronNone');} + print ''; + if(!empty($line->dateend)) {print dol_print_date($line->dateend,'dayhourtext');} else {print $langs->trans('CronNone');} + print ''; + if(!empty($line->datelastrun)) {print dol_print_date($line->datelastrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print ''; + if(!empty($line->datenextrun)) {print dol_print_date($line->datenextrun,'dayhourtext');} else {print $langs->trans('CronNone');} + print ''; + if($line->unitfrequency == "60") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Minutes'); + if($line->unitfrequency == "3600") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Hours'); + if($line->unitfrequency == "86400") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Days'); + if($line->unitfrequency == "604800") print $langs->trans('CronEach')." ".($line->frequency/$line->unitfrequency)." ".$langs->trans('Weeks'); + print ''; + if(!empty($line->nbrun)) {print $line->nbrun;} else {print '0';} + print ''; + if(!empty($line->lastresult)) {print dol_trunc($line->lastresult);} else {print $langs->trans('CronNone');} + print ''; + if(!empty($line->lastoutput)) {print dol_trunc(nl2br($line->lastoutput),100);} else {print $langs->trans('CronNone');} + print ''; + if ($user->rights->cron->delete) { + print "id."&status=".$status."&action=delete\" title=\"".$langs->trans('CronDelete')."\">\"".$langs-trans('CronDelete')."\" />"; + } else { + print "trans('NotEnoughPermissions')."\">\"".$langs-trans('NotEnoughPermissions')."\" />"; + } + if ($user->rights->cron->execute) { + print "id."&status=".$status."&action=execute\" title=\"".$langs->trans('CronExecute')."\">\"".$langs-trans('CronExecute')."\" />"; + } else { + print "trans('NotEnoughPermissions')."\">\"".$langs-trans('NotEnoughPermissions')."\" />"; + } + print '
'; +} else { + print $langs->trans('CronNoJobs'); +} + +print "\n\n
\n"; +if (! $user->rights->cron->create) { + print ''.$langs->trans("New").''; +} else { + print ''.$langs->trans("New").''; +} +print '

'; + +llxFooter(); +$db->close(); \ No newline at end of file diff --git a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql index 9684651832c..e6b82dc565e 100755 --- a/htdocs/install/mysql/migration/3.3.0-3.4.0.sql +++ b/htdocs/install/mysql/migration/3.3.0-3.4.0.sql @@ -159,3 +159,43 @@ ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang); ALTER TABLE llx_facture_fourn_det ADD COLUMN fk_code_ventilation integer DEFAULT 0 NOT NULL; ALTER TABLE llx_facturedet DROP COLUMN fk_export_compta; + +CREATE TABLE llx_cronjob +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + datec datetime, + jobtype varchar(10) NOT NULL, + label text NOT NULL, + command varchar(255), + classesname varchar(255), + objectname varchar(255), + methodename varchar(255), + params text NOT NULL, + md5params varchar(32), + module_name varchar(255), + priority integer DEFAULT 0, + datelastrun datetime, + datenextrun datetime, + datestart datetime, + dateend datetime, + datelastresult datetime, + lastresult text, + lastoutput text, + unitfrequency integer NOT NULL DEFAULT 0, + frequency integer NOT NULL DEFAULT 0, + nbrun integer, + status integer NOT NULL DEFAULT 1, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer DEFAULT NULL, + note text +)ENGINE=innodb; + + +ALTER TABLE llx_societe MODIFY COLUMN zip varchar(25); + +ALTER TABLE llx_user ADD COLUMN address varchar(255); +ALTER TABLE llx_user ADD COLUMN zip varchar(25); +ALTER TABLE llx_user ADD COLUMN town varchar(50); +ALTER TABLE llx_user ADD COLUMN fk_state integer DEFAULT 0; -- +ALTER TABLE llx_user ADD COLUMN fk_country integer DEFAULT 0; diff --git a/htdocs/install/mysql/tables/llx_cronjob.sql b/htdocs/install/mysql/tables/llx_cronjob.sql index 5a8e33ef38f..a5bb3c10f59 100644 --- a/htdocs/install/mysql/tables/llx_cronjob.sql +++ b/htdocs/install/mysql/tables/llx_cronjob.sql @@ -1,32 +1,52 @@ --- =================================================================== --- Copyright (C) 2013 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 --- the Free Software Foundation; either version 3 of the License, or --- (at your option) 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 . --- --- =================================================================== - -create table llx_cronjob -( - rowid integer AUTO_INCREMENT PRIMARY KEY, - tms timestamp, - datec datetime, - command varchar(256), - params text, - frequency varchar(24), - datelastrun datetime, - lastresult date, - lastoutput text, - fk_user integer DEFAULT NULL, - note text -)ENGINE=innodb; +-- =================================================================== +-- Copyright (C) 2013 Laurent Destailleur +-- Copyright (C) 2013 Florian Henry +-- +-- 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 +-- (at your option) 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 . +-- +-- =================================================================== + + +CREATE TABLE llx_cronjob +( + rowid integer AUTO_INCREMENT PRIMARY KEY, + tms timestamp, + datec datetime, + jobtype varchar(10) NOT NULL, + label text NOT NULL, + command varchar(255), + classesname varchar(255), + objectname varchar(255), + methodename varchar(255), + params text NOT NULL, + md5params varchar(32), + module_name varchar(255), + priority integer DEFAULT 0, + datelastrun datetime, + datenextrun datetime, + datestart datetime, + dateend datetime, + datelastresult datetime, + lastresult text, + lastoutput text, + unitfrequency integer NOT NULL DEFAULT 0, + frequency integer NOT NULL DEFAULT 0, + nbrun integer, + status integer NOT NULL DEFAULT 1, + fk_user_author integer DEFAULT NULL, + fk_user_mod integer DEFAULT NULL, + note text +)ENGINE=innodb; + + diff --git a/htdocs/install/mysql/tables/llx_societe.sql b/htdocs/install/mysql/tables/llx_societe.sql index 2c09e7a60fb..786bfa92d38 100644 --- a/htdocs/install/mysql/tables/llx_societe.sql +++ b/htdocs/install/mysql/tables/llx_societe.sql @@ -41,7 +41,7 @@ create table llx_societe code_compta varchar(24), -- code compta client code_compta_fournisseur varchar(24), -- code compta founisseur address varchar(255), -- company address - zip varchar(10), -- zipcode + zip varchar(25), -- zipcode town varchar(50), -- town fk_departement integer DEFAULT 0, -- fk_pays integer DEFAULT 0, -- diff --git a/htdocs/install/mysql/tables/llx_user.sql b/htdocs/install/mysql/tables/llx_user.sql index 3974096085f..0a3f63d873d 100644 --- a/htdocs/install/mysql/tables/llx_user.sql +++ b/htdocs/install/mysql/tables/llx_user.sql @@ -35,6 +35,11 @@ create table llx_user civilite varchar(6), name varchar(50), firstname varchar(50), + address varchar(255), -- user personal address + zip varchar(25), -- zipcode + town varchar(50), -- town + fk_state integer DEFAULT 0, -- + fk_country integer DEFAULT 0, -- job varchar(128), office_phone varchar(20), office_fax varchar(20), diff --git a/htdocs/install/pgsql/functions/functions.sql b/htdocs/install/pgsql/functions/functions.sql index 0c7f39025f9..b1f9282b6bf 100644 --- a/htdocs/install/pgsql/functions/functions.sql +++ b/htdocs/install/pgsql/functions/functions.sql @@ -116,3 +116,4 @@ CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_tva FOR EACH ROW EXE CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_user_extrafields FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_usergroup FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); +CREATE TRIGGER update_customer_modtime BEFORE UPDATE ON llx_cronjob FOR EACH ROW EXECUTE PROCEDURE update_modified_column_tms(); diff --git a/htdocs/langs/ca_ES/admin.lang b/htdocs/langs/ca_ES/admin.lang index 89761b3eba5..de095a8ff62 100644 --- a/htdocs/langs/ca_ES/admin.lang +++ b/htdocs/langs/ca_ES/admin.lang @@ -348,16 +348,18 @@ TextLong=Text llarg Int=numèric enter Float=Decimal DateAndTime=Data i hora +Unique=Unic Boolean=Boleano (Checkbox) ExtrafieldPhone=Telèfon ExtrafieldPrice=Preu ExtrafieldMail=Correu ExtrafieldSelect=Llista de selecció +ExtrafieldSeparator= LibraryToBuildPDF=Llibreria usada per a la creació d'arxius PDF WarningUsingFPDF=Atenció: El seu arxiu conf.php conté la directiva dolibarr_pdf_force_fpdf=1. Això fa que s'usi la llibreria FPDF per generar els seus arxius PDF. Aquesta llibreria és antiga i no cobreix algunes funcionalitats (Unicode, transparència d'imatges, idiomes ciríl · lics, àrabs o asiàtics, etc.), Pel que pot tenir problemes en la generació dels PDF.
Per resoldre-ho, i disposar d'un suport complet de PDF, pot descarregar la llibreria TCPDF , i a continuació comentar o eliminar la línia $dolibarr_pdf_force_fpdf=1, i afegir al seu lloc $dolibarr_lib_TCPDF_PATH='ruta_a_TCPDF' LocalTaxDesc=Alguns països apliquen 2 o 3 taxes a cada línia de factura. Si és el cas, escolliu el tipus de la segona i tercera taxa i el seu valor. Els possibles tipus són:
1: taxa local aplicable a productes i serveis sense IVA (IVA no s'aplica a la taxa local)
2: taxa local s'aplica a productes i serveis abans de l'IVA (IVA es calcula sobre import + taxa local)
3: taxa local s'aplica a productes sense IVA (IVA no s'aplica a la taxa local)
4: taxa local s'aplica a productes abans de l'IVA (IVA es calcula sobre l'import + taxa local)
5: taxa local s'aplica a serveis sense IVA (IVA no s'aplica a la taxa local)
6: taxa local s'aplica a serveis abans de l'IVA (IVA es calcula sobre import + taxa local) SuhosinSessionEncrypt=Emmagatzematge de sessions xifrades per Suhosin -# Modules= = +# Modules Module0Name=Usuaris y grups Module0Desc=Gestió d'usuaris i grups Module1Name=Tercers @@ -365,7 +367,7 @@ Module1Desc=Gestió de tercers (empreses, particulars) i contactes Module2Name=Comercial Module2Desc=Gestió comercial Module10Name=Comptabilitat -Module10Desc=Gestió simple de la comptabilitat (desglossament de factures i pagaments) +Module10Desc=Activació d'informes simples de comptabilitat (diaris, vendes) basats en el contingut de la base de dades. Sense desglossaments. Module20Name=Pressupostos Module20Desc=Gestió de pressupostos/propostes comercials Module22Name=E-Mailings @@ -450,6 +452,8 @@ Module1780Name=Categories Module1780Desc=Gestió de categories (productes, proveïdors i clients) Module2000Name=Editor WYSIWYG Module2000Desc=Permet l'edició de certes zones de text mitjançant un editor avançat +Module2300Name=Cron +Module2300Desc=Gestor de tasques programades Module2400Name=Agenda Module2400Desc=Gestió de l'agenda i de les accions Module2500Name=Gestió Electrònica de Documents @@ -673,6 +677,10 @@ Permission1411=Llegir els moviments comptables Permission1412=Crear/modificar/anular moviments comptables Permission1415=Llegir Balanços, informes, diaris, llibres mestres Permission1421=Exporta comandes de clients i atributs +Permission23001=Veure les tasques programades +Permission23002=Crear/Modificar les tasques programades +Permission23003=Eliminar les tasques programades +Permission23004=Executar les tasques programades Permission2401=Llegir accions (esdeveniments o tasques) vinculades al seu compte Permission2402=Crear/modificar accions (esdeveniments o tasques) vinculades al seu compte Permission2403=Modificar accions (esdeveniments o tasques) vinculades al seu compte @@ -946,7 +954,7 @@ TranslationDesc=L'elecció de l'idioma mostrat en pantalla es modifica:
* A n ClassNotFoundIntoPathWarning=No s'ha trobat la classe %s en el seu path PHP YesInSummer=Sí a l'estiu OnlyFollowingModulesAreOpenedToExternalUsers=Recordeu que només els mòduls següents estan oberts a usuaris externs (siguin quins siguin els permisos dels usuaris): -##### Module password generation= = +##### Module password generation PasswordGenerationStandard=Retorna una contrasenya generada per l'algoritme intern Dolibarr: 8 caràcters, números i caràcters en minúscules barrejades. PasswordGenerationNone=No ofereix contrasenyes. La contrasenya s'introdueix manualment. ##### Users setup ##### @@ -1270,6 +1278,8 @@ FCKeditorForCompany=Creació/edició WYSIWIG de la descripció i notes dels terc FCKeditorForProduct=Creació/edició WYSIWIG de la descripció i notes dels productes/serveis FCKeditorForProductDetails=Creació/edició WYSIWIG de les línies de detall dels productes (en comandes, pressupostos, factures, etc.) FCKeditorForMailing=Creació/edició WYSIWIG dels E-Mails +FCKeditorForUserSignature=Creació/edició WYSIWIG dela firma dels usuaris +FCKeditorForMail=Creació/edició WYSIWIG de tots els E-mails (excepte Utilitats->E-Mailings) ##### OSCommerce 1 ##### OSCommerceErrorConnectOkButWrongDatabase=La connexió s'ha establert, però la base de dades no sembla de OSCommerce. OSCommerceTestOk=La connexió al servidor '%s' sobre la base '%s' per l'usuari '%s' és correcta. @@ -1378,6 +1388,7 @@ MultiCompanySetup=Configuració del mòdul Multi-empresa SuppliersSetup=Configuració del mòdul Proveïdors SuppliersCommandModel=Model de comandes a proveïdors complet (logo...) SuppliersInvoiceModel=Model de factures de proveïdors complet (logo...) +SuppliersInvoiceNumberingModel=Models de numeració de factures de proveïdor ##### GeoIPMaxmind ##### GeoIPMaxmindSetup=Configuració del mòdul GeoIP Maxmind PathToGeoIPMaxmindCountryDataFile=Ruta de l'arxiu Maxmind que conté les conversions IP-> País.
Exemple: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/ca_ES/bills.lang b/htdocs/langs/ca_ES/bills.lang index 8456f4518e4..3f923cb917d 100644 --- a/htdocs/langs/ca_ES/bills.lang +++ b/htdocs/langs/ca_ES/bills.lang @@ -385,6 +385,7 @@ ClosePaidCreditNotesAutomatically=Classificar automàticament com "Pagats" els a AllCompletelyPayedInvoiceWillBeClosed=Totes les factures amb una resta a pagar 0 seran automàticament tancades a l'estat "Pagada". ToMakePayment=Pagar ToMakePaymentBack=Reemborsar +ListOfYourUnpaidInvoices=Llistat de factures impagades ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Responsable seguiment factura a client TypeContact_facture_external_BILLING=Contacte client facturació diff --git a/htdocs/langs/ca_ES/companies.lang b/htdocs/langs/ca_ES/companies.lang index 1559fd7cf72..c474ac42f68 100644 --- a/htdocs/langs/ca_ES/companies.lang +++ b/htdocs/langs/ca_ES/companies.lang @@ -393,6 +393,8 @@ UniqueThirdParties=Total de tercers únics InActivity=Actiu ActivityCeased=Tancat ActivityStateFilter=Estat d'activitat +ProductsIntoElements=Llistat de productes en %s + # Monkey MonkeyNumRefModelDesc=Retorna un número sota el format %syymm-nnnn per als codis de clients i %syymm-nnnn per als codis dels proveïdors, on yy és l'any, mm el mes i nnnn un comptador seqüencial sense ruptura i sense tornar a 0. # Leopard diff --git a/htdocs/langs/ca_ES/compta.lang b/htdocs/langs/ca_ES/compta.lang index fb9d58e541d..eff4e5cd8ad 100644 --- a/htdocs/langs/ca_ES/compta.lang +++ b/htdocs/langs/ca_ES/compta.lang @@ -157,3 +157,9 @@ COMPTA_ACCOUNT_SUPPLIER=Codi comptable per defecte de proveïdors (si no està d AddRemind=Desglossar import disponible RemainToDivide=Resta a repartir : WarningDepositsNotIncluded=Les factures de bestreta encara no estan incloses en aquesta versió en el mòdul de comptabilitat. +DatePaymentTermCantBeLowerThanObjectDate=La data límit de pagament no pot ser inferior a la data de l'objecte +Pcg_version=Versió del pla +Pcg_type=Tipus de compte +Pcg_subtype=Subtipus de compte +InvoiceLinesToDispatch=Línies de factures a desglossar +InvoiceDispatched=Factures desglossades \ No newline at end of file diff --git a/htdocs/langs/ca_ES/cron.lang b/htdocs/langs/ca_ES/cron.lang new file mode 100644 index 00000000000..67833a6b65b --- /dev/null +++ b/htdocs/langs/ca_ES/cron.lang @@ -0,0 +1,92 @@ +# Dolibarr language file - ca_ES - cron +CHARSET=UTF-8 + +# +# Admin +# +CronSetup=Pàgina de configuració del mòdul - Gestió de tasques planificades +URLToLaunchCronJobs=URL per llançar les tasques automàtiques +OrToLaunchASpecificJob=O per llançar una tasca específica +KeyForCronAccess=Codi de seguretat per a la URL de llançament de tasques automàtiques +FileToLaunchCronJobs=Ordre per llançar les tasques automàtiques +CronExplainHowToRunUnix=En un entorn Unix pot parametritzar crontab per executar aquesta comanda cada minut +CronExplainHowToRunWin=En un entorn Microsoft (tm) Windows pot utilitzar el planificador de tasques per llançar aquesta comanda cada minut +# +# Menu +# +CronListActive=Llistat de tasques planificades actives +CronListInactive=Llistat de tasques planificades inactives + + +# +# Page list +# +CronDateLastRun=Últim llançament +CronLastOutput=Última sortida +CronLastResult=Últim codi tornat +CronCommand=Comando +CronList=Llistat de tasques planificades +CronDelete=Eliminar la tasca planificada +CronConfirmDelete=Està segur que voleu eliminar aquesta tasca planificada? +CronExecute=Executar aquesta tasca +CronConfirmExecute=Està segur que voleu executar ara aquesta tasca? +CronInfo=Els treballs permeten executar les tasques a intervals regulars +CronWaitingJobs=Els seus treballs en espera: +CronTask=Tasca +CronNone=Ningún +CronDtStart=Data inici +CronDtEnd=Data fi +CronDtNextLaunch=Propera execució +CronDtLastLaunch=Darrera execució +CronFrequency=Freqüència +CronClass=Clase +CronMethod=Mètod +CronModule=Mòdul +CronAction=Acció +CronStatus=Estat +CronStatusActive=Activa +CronStatusInactive=Inactiva +CronEach=Cada +CronNoJobs=Sense treballs actualment +CronPriority=Prioritat +CronLabel=Descripció +CronNbRun=Nº ejec. +CronDtLastResult=Data de l'últim resultat de l'última execució + +# +#Page card +# +CronAdd=Afegir una tasca +CronHourStart=Dia i hora d'inici de la tasca +CronEvery=Executar cada +CronObject=Instància/Objecte a crear +CronArgs=Argument +CronSaveSucess=Registre guardat +CronNote=Nota +CronFieldMandatory=El camp %s és obligatori +CronErrEndDateStartDt=La data de fi no pot ser anterior a la d'inici +CronStatusActiveBtn=Activar +CronStatusInactiveBtn=Desactivar +CronTaskInactive=Aquesta tasca es troba desactivada +CronId=Id +CronClassFile=Classe (arxiu) +CronModuleHelp=Nombre del directorio del módulo Dolibarr (funciona automáticamente con los módulos externos Dolibarr).
Por ejemplo para llamar al método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del módulo es product +CronClassFileHelp=El archivo archivo que contiene el objeto.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor de la clase es product.class.php +CronObjectHelp=El nombre del objeto a crear.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del objeto es Product +CronMethodHelp=El método a lanzar.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del método es fecth +CronArgsHelp=Los argumentos del método.
Por ejemplo para usar el método fetch del objeto Product deDolibarr /htdocs/product/class/product.class.php, el valor del parámetro podría ser 0, RefProduit +CronCommandHelp=El comando del sistema a executar + +# +# Info +# +CronInfoPage=Informació + +# +# Common +# +CronType=Tipus d'acció a executar +CronType_method=Mètode d'una classe d'un mòdul Dolibarr +CronType_command=Comando Shell +CronMenu=Cron +CronCannotLoadClass=impossible carregar la classe %s de l'objecte %s \ No newline at end of file diff --git a/htdocs/langs/ca_ES/main.lang b/htdocs/langs/ca_ES/main.lang index a3d51433d1a..35b4d437e4e 100644 --- a/htdocs/langs/ca_ES/main.lang +++ b/htdocs/langs/ca_ES/main.lang @@ -489,7 +489,7 @@ NbOfThirdParties=Número de tercers NbOfCustomers=Nombre de clients NbOfLines=Números de línies NbOfObjects=Nombre d'objectes -NbOfReferers=Nombre de referències +NbOfReferers=Consumició Referers=Referències TotalQuantity=Quantitat total DateFromTo=De %s a %s diff --git a/htdocs/langs/ca_ES/sendings.lang b/htdocs/langs/ca_ES/sendings.lang index 38462265059..fc53bde5f28 100644 --- a/htdocs/langs/ca_ES/sendings.lang +++ b/htdocs/langs/ca_ES/sendings.lang @@ -59,6 +59,7 @@ LinkToTrackYourPackage=Enllaç per al seguiment del seu paquet ShipmentCreationIsDoneFromOrder=De moment, la creació d'una nova expedició es realitza des de la fitxa de comanda. RelatedShippings=Expedició(ns) associades ShipmentLine=Línia d'expedició +CarrierList=Llistat de transportistes # Sending methods SendingMethodCATCH=Recollit pel client diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 671a00ddf16..a9aae951692 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -672,6 +672,10 @@ Permission1237=Export supplier orders and their details Permission1251=Run mass imports of external data into database (data load) Permission1321=Export customer invoices, attributes and payments Permission1421=Export customer orders and attributes +Permission23001 = Read Scheduled task +Permission23002 = Create/update Scheduled task +Permission23003 = Delete Scheduled task +Permission23004 = Execute Scheduled task Permission2401=Read actions (events or tasks) linked to his account Permission2402=Create/modify actions (events or tasks) linked to his account Permission2403=Delete actions (events or tasks) linked to his account diff --git a/htdocs/langs/en_US/cron.lang b/htdocs/langs/en_US/cron.lang index 4f504d34e59..c64c74f1f58 100644 --- a/htdocs/langs/en_US/cron.lang +++ b/htdocs/langs/en_US/cron.lang @@ -1,11 +1,87 @@ # Dolibarr language file - en_US - cron CHARSET=UTF-8 -CronSetup=Cron scheduler setup -CronDesc=This page can be used to setup options of the scheduler manager + +# +# Admin +# +CronSetup= Configuration Scheduled task management URLToLaunchCronJobs=URL to launch cron jobs +OrToLaunchASpecificJob=Or to launch a specific job KeyForCronAccess=Security key for URL to launch cron jobs -DateLastRun=Last run -LastOutput=Last run output -LastResult=Last result code -ListOfCronJobs=List of scheduled jobs -Command=Command \ No newline at end of file +FileToLaunchCronJobs=Command to launch cron jobs +CronExplainHowToRunUnix=On Unix environement you should use crontab to run Command line each minutes +CronExplainHowToRunWin=On Microsoft(tm) Windows environement you can use Scheduled task tools to run Command line each minutes + +# +# Page list +# +CronDateLastRun=Last run +CronLastOutput=Last run output +CronLastResult=Last result code +CronListOfCronJobs=List of scheduled jobs +CronCommand=Command +CronList= Job list +CronDelete= Delete cron jobs +CronConfirmDelete= Are you sure to delete this cron jobs ? +CronExecute=Launch task +CronConfirmExecute= Are you sure to execute this job now +CronInfo= Jobs allow to execute task that have been planned +CronWaitingJobs=Wainting jobs +CronTask=Task +CronNone= None +CronDtStart=Start date +CronDtEnd=End fin +CronDtNextLaunch=Next execution +CronDtLastLaunch=Last execution +CronFrequency=Frequancy +CronClass=Classe +CronMethod=Method +CronModule=Module +CronAction=Action +CronStatus=Status +CronStatusActive=Active +CronStatusInactive=Inactive +CronNoJobs=No jobs registered +CronPriority=Priority +CronLabel=Description +CronNbRun=Nb. launch + +# +#Page card +# +CronAdd= Add jobs +CronHourStart= Start Hour and date of task +CronEvery= And execute task each +CronObject= Instance/Object to create +CronArgs=Parameters +CronSaveSucess=Save succefully +CronNote=Comment +CronFieldMandatory=Fields %s is mandatory +CronErrEndDateStartDt=End date cannot be before start date +CronStatusActiveBtn=Active +CronStatusInactiveBtn=Inactive +CronTaskInactive=This task is inactive +CronDtLastResult=Last result date +CronId=Id +CronClassFile=Classes (file name) +CronModuleHelp=Name of Dolibarr module directory (also work with external Dolibarr module).
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of module is product +CronClassFileHelp=The file name to load.
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is product.class.php +CronObjectHelp=The object name to load.
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of class file name is Product +CronMethodHelp=The object method to launch.
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of method is is fecth +CronArgsHelp=The method arguments.
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, the value of paramters can be 0, ProductRef +CronCommandHelp=The system command line to execute. + +# +# Info +# +CronInfoPage=Information + + +# +# Common +# +CronType=Task type +CronType_method=Call method of a Dolibarr Class +CronType_command=Shell command +CronMenu=Cron +CronCannotLoadClass=Cannot load class %s or object %s \ No newline at end of file diff --git a/htdocs/langs/es_ES/admin.lang b/htdocs/langs/es_ES/admin.lang index 811d9166b57..88328c5cfac 100644 --- a/htdocs/langs/es_ES/admin.lang +++ b/htdocs/langs/es_ES/admin.lang @@ -354,11 +354,12 @@ ExtrafieldPhone=Teléfono ExtrafieldPrice=Precio ExtrafieldMail=Correo ExtrafieldSelect=Lista de selección +ExtrafieldSeparator= LibraryToBuildPDF=Librería usada para la creación de archivos PDF WarningUsingFPDF=Atención: Su archivo conf.php contiene la directiva dolibarr_pdf_force_fpdf=1. Esto hace que se use la librería FPDF para generar sus archivos PDF. Esta librería es antigua y no cubre algunas funcionalidades (Unicode, transparencia de imágenes, idiomas cirílicos, árabes o asiáticos, etc.), por lo que puede tener problemas en la generación de los PDF.
Para resolverlo, y disponer de un soporte completo de PDF, puede descargar la librería TCPDF , y a continuación comentar o eliminar la línea $dolibarr_pdf_force_fpdf=1, y añadir en su lugar $dolibarr_lib_TCPDF_PATH='ruta_a_TCPDF' LocalTaxDesc=Algunos países aplican 2 o 3 tasas a cada línea de factura. Si es el caso, escoja el tipo de la segunda y tercera tasa y su valor. Los posibles tipos son:
1 : tasa local aplicable a productos y servicios sin IVA (IVA no se aplica en la tasa local)
2 : tasa local se aplica a productos y servicios antes del IVA (IVA se calcula sobre importe+tasa local)
3 : tasa local se aplica a productos sin IVA (IVA no se aplica en la tasa local)
4 : tasa local se aplica a productos antes del IVA (IVA se calcula sobre el importe+tasa local)
5 : tasa local se aplica a servicios sin IVA (IVA no se aplica a la tasa local)
6 : tasa local se aplica a servicios antes del IVA (IVA se calcula sobre importe + tasa local) SuhosinSessionEncrypt=Almacenamiento de sesiones cifradas por Suhosin -# Modules= = +# Modules Module0Name=Usuarios y grupos Module0Desc=Gestión de usuarios y grupos Module1Name=Terceros @@ -366,7 +367,7 @@ Module1Desc=Gestión de terceros (empresas, particulares) y contactos Module2Name=Comercial Module2Desc=Gestión comercial Module10Name=Contabilidad -Module10Desc=Gestión simple de la contabilidad (desglose de facturas y pagos) +Module10Desc=Activación de informes simples de contabilidad (diarios, ventas) basados en el contenido de la base de datos. Sin desgloses. Module20Name=Presupuestos Module20Desc=Gestión de presupuestos/propuestas comerciales Module22Name=E-Mailings @@ -451,6 +452,8 @@ Module1780Name=Categorías Module1780Desc=Gestión de categorías (productos, proveedores y clientes) Module2000Name=Editor WYSIWYG Module2000Desc=Permite la edición de ciertas zonas de texto mediante un editor avanzado +Module2300Name=Cron +Module2300Desc=Gestor de tareas programadas Module2400Name=Agenda Module2400Desc=Gestión de la agenda y de las acciones Module2500Name=Gestión Electrónica de Documentos @@ -674,6 +677,10 @@ Permission1411=Leer los movimientos contables Permission1412=Crear/modificar/anular movimientos contables Permission1415=Leer Balances, informes, diarios, libros maestros Permission1421=Exportar pedidos de clientes y atributos +Permission23001=Ver las tareas programadas +Permission23002=Crear/Modificar las tareas programadas +Permission23003=Eliminar las tareas programadas +Permission23004=Ejecutar las tareas programadas Permission2401=Leer acciones (eventos o tareas) vinculadas a su cuenta Permission2402=Crear/eliminar acciones (eventos o tareas) vinculadas a su cuenta Permission2403=Modificar acciones (eventos o tareas) vinculadas a su cuenta @@ -947,7 +954,7 @@ TranslationDesc=La elección del idioma mostrado en pantalla se modifica:
* A ClassNotFoundIntoPathWarning=No se ha encontrado la clase %s en su path PHP YesInSummer=Sí en verano OnlyFollowingModulesAreOpenedToExternalUsers=Tenga en cuenta que sólo los módulos siguientes están abiertos a usuarios externos (sean cuales sean los permisos de los usuarios): -##### Module password generation= = +##### Module password generation PasswordGenerationStandard=Devuelve una contraseña generada por el algoritmo interno Dolibarr: 8 caracteres, números y caracteres en minúsculas mezcladas. PasswordGenerationNone=No ofrece contraseñas. La contraseña se introduce manualmente. ##### Users setup ##### @@ -1271,7 +1278,7 @@ FCKeditorForCompany=Creación/edición WYSIWIG de la descripción y notas de los FCKeditorForProduct=Creación/edición WYSIWIG de la descripción y notas de los productos/servicios FCKeditorForProductDetails=Creación/edición WYSIWIG de las líneas de detalle de los productos (en pedidos, presupuestos, facturas, etc.) FCKeditorForMailing=Creación/edición WYSIWIG de los E-Mails (Utilidades->E-Mailings) -FCKeditorForUserSignature=Creación/edición WYSIWIG de los usuario firma +FCKeditorForUserSignature=Creación/edición WYSIWIG de la firma de usuarios FCKeditorForMail=Creación/edición WYSIWIG de todos los E-Mails (excepto Utilidades->E-Mailings) ##### OSCommerce 1 ##### OSCommerceErrorConnectOkButWrongDatabase=La conexión se ha establecido, pero la base de datos no parece de OSCommerce. @@ -1381,6 +1388,7 @@ MultiCompanySetup=Configuración del módulo Multi-empresa SuppliersSetup=Configuración del módulo Proveedores SuppliersCommandModel=Modelo de pedidos a proveedores completo (logo...) SuppliersInvoiceModel=Modelo de facturas de proveedores completo (logo...) +SuppliersInvoiceNumberingModel=Modelos de numeración de facturas de proveedor ##### GeoIPMaxmind ##### GeoIPMaxmindSetup=Configuración del módulo GeoIP Maxmind PathToGeoIPMaxmindCountryDataFile=Ruta del archivo Maxmind que contiene las conversiones IP->País.
Ejemplo: /usr/local/share/GeoIP/GeoIP.dat diff --git a/htdocs/langs/es_ES/bills.lang b/htdocs/langs/es_ES/bills.lang index e72c4637fd4..4429143bacf 100644 --- a/htdocs/langs/es_ES/bills.lang +++ b/htdocs/langs/es_ES/bills.lang @@ -385,6 +385,7 @@ ClosePaidCreditNotesAutomatically=Clasificar automáticamente como "Pagados" los AllCompletelyPayedInvoiceWillBeClosed=Todas las facturas con un resto a pagar 0 serán automáticamente cerradas al estado "Pagada". ToMakePayment=Pagar ToMakePaymentBack=Reembolsar +ListOfYourUnpaidInvoices=Listado de facturas impagadas ##### Types de contacts ##### TypeContact_facture_internal_SALESREPFOLL=Responsable seguimiento factura a cliente TypeContact_facture_external_BILLING=Contacto cliente facturación diff --git a/htdocs/langs/es_ES/companies.lang b/htdocs/langs/es_ES/companies.lang index fedfabfbc2c..b86b0d5fffa 100644 --- a/htdocs/langs/es_ES/companies.lang +++ b/htdocs/langs/es_ES/companies.lang @@ -394,6 +394,8 @@ UniqueThirdParties=Total de terceros únicos InActivity=Activo ActivityCeased=Cerrado ActivityStateFilter=Estado de actividad +ProductsIntoElements=Listado de productos en %s + # Monkey MonkeyNumRefModelDesc=Devuelve un número bajo el formato %syymm-nnnn para los códigos de clientes y %syymm-nnnn para los códigos de los proveedores, donde yy es el año, mm el mes y nnnn un contador secuencial sin ruptura y sin volver a 0. # Leopard diff --git a/htdocs/langs/es_ES/compta.lang b/htdocs/langs/es_ES/compta.lang index 2f72861a920..f2e86e42739 100644 --- a/htdocs/langs/es_ES/compta.lang +++ b/htdocs/langs/es_ES/compta.lang @@ -158,4 +158,10 @@ COMPTA_ACCOUNT_CUSTOMER=Código contable por defecto de clientes (si no está de COMPTA_ACCOUNT_SUPPLIER=Código contable por defecto de proveedores (si no está definido en la pestaña terceros) AddRemind=Desglosar importe disponible RemainToDivide=Resto a repartir : -WarningDepositsNotIncluded=Las facturas de anticipo aún no están incluidas en esta versión en el módulo de contabilidad. \ No newline at end of file +WarningDepositsNotIncluded=Las facturas de anticipo aún no están incluidas en esta versión en el módulo de contabilidad. +DatePaymentTermCantBeLowerThanObjectDate=La fecha límite de pago no puede ser inferior a la fecha del objeto +Pcg_version=Versión del plan +Pcg_type=Tipo de cuenta +Pcg_subtype=Subtipo de cuenta +InvoiceLinesToDispatch=Líneas de facturas a desglosar +InvoiceDispatched=Facturas desglosadas \ No newline at end of file diff --git a/htdocs/langs/es_ES/cron.lang b/htdocs/langs/es_ES/cron.lang new file mode 100644 index 00000000000..37710fdd67d --- /dev/null +++ b/htdocs/langs/es_ES/cron.lang @@ -0,0 +1,92 @@ +# Dolibarr language file - es_ES - cron +CHARSET=UTF-8 + +# +# Admin +# +CronSetup=Página de configuración del módulo - Gestión de tareas planificadas +URLToLaunchCronJobs=URL para lanzar las tareas automáticas +OrToLaunchASpecificJob=O para lanzar una tarea específica +KeyForCronAccess=Código de seguridad para la URL de lanzamiento de tareas automáticas +FileToLaunchCronJobs=Comando para lanzar las tareas automáticas +CronExplainHowToRunUnix=En un entorno Unix puede parametrizar CronTab para ejecutar este comando cada minuto +CronExplainHowToRunWin=En un entorno Microsoft(tm) Windows puede usar el planificador de tareas para lanzar este comando cada minuto +# +# Menu +# +CronListActive=Listado de tareas planificadas activas +CronListInactive= Listado de tareas planificadas inactivas + + +# +# Page list +# +CronDateLastRun=Último lanzamiento +CronLastOutput=Última salida +CronLastResult=Último código devuelto +CronCommand=Comando +CronList=Listado de tareas planificadas +CronDelete=Eliminar la tarea planificada +CronConfirmDelete=¿Está seguro de querer eliminar esta tarea planificada? +CronExecute=Ejecutar esta tarea +CronConfirmExecute=¿Está seguro de querer ejecutar ahora esta tarea? +CronInfo=Los trabajos permiten ejecutar las tareas a intervalos regulares +CronWaitingJobs=Sus trabajos en espera: +CronTask=Tarea +CronNone=Ninguno +CronDtStart=Fecha inicio +CronDtEnd=Fecha fin +CronDtNextLaunch=Próxima ejecución +CronDtLastLaunch=Última ejecución +CronFrequency=Frecuencia +CronClass=Clase +CronMethod=Método +CronModule=Módulo +CronAction=Acción +CronStatus=Estado +CronStatusActive=Activa +CronStatusInactive=Inactiva +CronEach=Cada +CronNoJobs=Sin trabajos actualmente +CronPriority=Prioridad +CronLabel=Descripción +CronNbRun=Nº ejec. +CronDtLastResult=Fecha del último resultado de la última ejecución + +# +#Page card +# +CronAdd=Añadir una tarea +CronHourStart=Dia y hora de inicio de la tarea +CronEvery=Ejecutar cada +CronObject=Instancia/Objeto a crear +CronArgs=Argumento +CronSaveSucess=Registro guardado +CronNote=Nota +CronFieldMandatory=El campo %s es obligatorio +CronErrEndDateStartDt=La fecha de fin no puede ser anterior a la de inicio +CronStatusActiveBtn=Activar +CronStatusInactiveBtn=Desactivar +CronTaskInactive=Esta tarea se encuentra desactivada +CronId=Id +CronClassFile=Clase (archivo) +CronModuleHelp=Nombre del directorio del módulo Dolibarr (funciona automáticamente con los módulos externos Dolibarr).
Por ejemplo para llamar al método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del módulo es product +CronClassFileHelp=El archivo archivo que contiene el objeto.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor de la clase es product.class.php +CronObjectHelp=El nombre del objeto a crear.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del objeto es Product +CronMethodHelp=El método a lanzar.
Por ejemplo para llamar el método fetch del objeto Product de Dolibarr /htdocs/product/class/product.class.php, el valor del método es fecth +CronArgsHelp=Los argumentos del método.
Por ejemplo para usar el método fetch del objeto Product deDolibarr /htdocs/product/class/product.class.php, el valor del parámetro podría ser 0, RefProduit +CronCommandHelp=El comando del sistema a ejecutar + +# +# Info +# +CronInfoPage=Información + +# +# Common +# +CronType=Tipo de acción a ejecutar +CronType_method=Método de una clase de un módulo Dolibarr +CronType_command=Comando Shell +CronMenu=Cron +CronCannotLoadClass=imposible cargar la clase %s o el objeto %s \ No newline at end of file diff --git a/htdocs/langs/es_ES/main.lang b/htdocs/langs/es_ES/main.lang index ec308d590d5..b7ba4d9c578 100644 --- a/htdocs/langs/es_ES/main.lang +++ b/htdocs/langs/es_ES/main.lang @@ -489,7 +489,7 @@ NbOfThirdParties=Número de terceros NbOfCustomers=Numero de clientes NbOfLines=Números de líneas NbOfObjects=Número de objetos -NbOfReferers=Número de referencias +NbOfReferers=Consumición Referers=Referencias TotalQuantity=Cantidad total DateFromTo=De %s a %s diff --git a/htdocs/langs/es_ES/sendings.lang b/htdocs/langs/es_ES/sendings.lang index 7efaabc81cd..99dda507fa8 100644 --- a/htdocs/langs/es_ES/sendings.lang +++ b/htdocs/langs/es_ES/sendings.lang @@ -59,6 +59,7 @@ LinkToTrackYourPackage=Enlace para el seguimento de su paquete ShipmentCreationIsDoneFromOrder=De momento, la creación de una nueva expedición se realiza desde la ficha de pedido. RelatedShippings=Expedición(es) asociada(s) ShipmentLine=Línea de expedición +CarrierList=Listado de transportistas # Sending methods SendingMethodCATCH=Recogido por el cliente diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 095e1a63dc6..a20821cd61b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -678,6 +678,10 @@ Permission1411= Lire les mouvements comptables Permission1412= Créer/modifier/annuler les mouvements comptables Permission1415= Lire CA, bilans, résultats, journaux, grands livres Permission1421= Exporter les commandes clients et attributs +Permission23001 = Voir les taches planifiée +Permission23002 = Créer/Modifier les taches planifiée +Permission23003 = Supprimer les taches planifiée +Permission23004 = Executer les taches planifiée Permission2401= Lire les actions (événements ou tâches) liées à son compte Permission2402= Créer/modifier les actions (événements ou tâches) liées à son compte Permission2403= Supprimer les actions (événements ou tâches) liées à son compte diff --git a/htdocs/langs/fr_FR/cron.lang b/htdocs/langs/fr_FR/cron.lang index 1a9bf136e02..d0aaccfecf7 100644 --- a/htdocs/langs/fr_FR/cron.lang +++ b/htdocs/langs/fr_FR/cron.lang @@ -1,11 +1,93 @@ # Dolibarr language file - fr_FR - cron CHARSET=UTF-8 -CronSetup=Configuration du séquenceur de taches -CronDesc=Cette page permet de configurer certaines options du séquenceur de taches + +# +# Admin +# +CronSetup = Page de configuration du module - Gestion de tâches planifiées URLToLaunchCronJobs=URL pour lancer les taches automatiques +OrToLaunchASpecificJob=Ou pour lancer une tache spécifique KeyForCronAccess=Clé de sécurité pour l'URL de lancement des taches automatiques -DateLastRun=Dernier lancement -LastOutput=Dernière sortie -LastResult=Dernière code retour -ListOfCronJobs=Liste des taches programmées -Command=Commande \ No newline at end of file +FileToLaunchCronJobs=Commande pour lancer les taches automatiques +CronExplainHowToRunUnix=Sur un environement Unix vous pouvez paramétré CronTab pour executer cette commande toute les minutes +CronExplainHowToRunWin=Sur un environement Microsoft(tm) Windows vous pouvez utilisr le planificateur de tache pour lancer cette commande toute les minutes + +# +# Menu +# +CronListActive= Liste des tâches planifiées active +CronListInactive= Liste des tâches planifiées inactive + + +# +# Page list +# +CronDateLastRun=Dernier lancement +CronLastOutput=Dernière sortie +CronLastResult=Dernier code retour +CronCommand=Commande +CronList= Liste des tâches planifiées +CronDelete= Supprimer la tâche planifiée +CronConfirmDelete= Êtes-vous sûr de vouloir supprimer cette tâche planifiée ? +CronExecute=Exécuter cette tâche +CronConfirmExecute= Êtes-vous sûr de vouloir exécuter cette tâche maintenant? +CronInfo= Les jobs permettent d'exécuter des tâches à intervales réguliers +CronWaitingJobs= Vos jobs en attente: +CronTask= Tâche +CronNone=Aucun(e) +CronDtStart=Date début +CronDtEnd=Date fin +CronDtNextLaunch=Prochaine éxécution +CronDtLastLaunch=Dernière éxécution +CronFrequency=Fréquence +CronClass=Classes +CronMethod=Méthode +CronModule=Module +CronAction=Action +CronStatus=Status +CronStatusActive=Active +CronStatusInactive=Inactive +CronEach=Tou(te)s +CronNoJobs= Aucun jobs actuellement +CronPriority=Priorité +CronLabel=Description +CronNbRun=Nb. exec. +CronDtLastResult=Date du derniétre resulat de la dernière éxécution + +# +#Page card +# +CronAdd= Ajoutez une tâche +CronHourStart= Jour et Heure de début de la tâche +CronEvery= Puis execution toutes les +CronObject= Instance/Objet à créer +CronArgs= Argument +CronSaveSucess=Enregistrement effectué +CronNote=Note +CronFieldMandatory=Le champ %s est obligatoire +CronErrEndDateStartDt=La date de fin ne peux être avant la date de début +CronStatusActiveBtn=Activer +CronStatusInactiveBtn=Désactiver +CronTaskInactive=Cette tâche est désactivée +CronId=Id +CronClassFile=Classes (fichier) +CronModuleHelp=Nom du repertoire du module dolibarr (fonctionne automatiquement avec les modules externe Dolibarr).
Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de module est product +CronClassFileHelp=Le fichier qui contient l'objet .
Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de classe est product.class.php +CronObjectHelp=Le nom de l'object a crée.
Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de objet est Product +CronMethodHelp=La mèthode a lancer.
Par exemple pour appeler la mèthode fetch de l'object Product de Dolibarr /htdocs/product/class/product.class.php, la valeur de mèthode est fecth +CronArgsHelp=Les arguments de la mèthode.
For exemple to fetch method of Dolibarr Product object /htdocs/product/class/product.class.php, la valeur de paramétre pourrait être 0, RefProduit +CronCommandHelp=La commande système a éxecuter + +# +# Info +# +CronInfoPage=Suivie + +# +# Common +# +CronType=Type d'action a executer +CronType_method=Méthode d'une classe d'un module Dolibarr +CronType_command=Commande Shell +CronMenu=Cron +CronCannotLoadClass=impossible de charger la classe %s ou l'object %s \ No newline at end of file diff --git a/htdocs/public/cron/cron_run_jobs.php b/htdocs/public/cron/cron_run_jobs.php index 75e15a414a0..838c298212f 100644 --- a/htdocs/public/cron/cron_run_jobs.php +++ b/htdocs/public/cron/cron_run_jobs.php @@ -1,5 +1,6 @@ +/* Copyright (C) 2012 Nicolas Villa aka Boyquotes http://informetic.fr + * Copyright (C) 2013 Florian Henry Export agenda cal'; -} -/** - * Footer function - * - * @return void - */ -function llxFooterVierge() { - print ''; -} - - - -// Load traductions files requiredby by page -$langs->load("companies"); -$langs->load("other"); -$langs->load("cron@cron"); - -// Get parameters -$id = GETPOST('id','int'); -$action = GETPOST('action','alpha'); - -// Protection if external user -if ($user->societe_id > 0) -{ - //accessforbidden(); +// librarie core +// Dolibarr environment +$res = @include("../../main.inc.php"); // From htdocs directory +if (! $res) { + $res = @include("../../../main.inc.php"); // From "custom" directory } +if (! $res) die("Include of master.inc.php fails"); -// Security check -if (empty($conf->cron->enabled)) accessforbidden('',1,1,1); +// librarie jobs +dol_include_once("/cron/class/cronjob.class.php"); -// Check also security key -if (empty($_GET["securitykey"]) || $conf->global->CRON_KEY != $_GET["securitykey"]) -{ - $user->getrights(); - - llxHeaderVierge(); - print '
Bad value for key.
'; - llxFooterVierge(); - exit; + +global $langs, $conf; + +// Check the key, avoid that a stranger starts cron +$key = $_GET['securitykey']; +if (empty($key)) { + echo 'securitykey is require'; + exit; } - - -/******************************************************************* -* ACTIONS -* -* Put here all code to do according to value of "action" parameter -********************************************************************/ - -if ($action == 'add') +if($key != $conf->global->MAIN_CRON_KEY) { - $object=new Cronjobs($db); - $object->prop1=$_POST["field1"]; - $object->prop2=$_POST["field2"]; - $result=$object->create($user); - if ($result > 0) - { - // Creation OK - } - { - // Creation KO - $mesg=$object->error; + echo 'securitykey is wrong'; + exit; +} +// Check the key, avoid that a stranger starts cron +$userlogin = $_GET['userlogin']; +if (empty($userlogin)) { + echo 'userlogin is require'; + exit; +} +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +$user=new User($db); +$result=$user->fetch('',$userlogin); +if ($result<0) { + echo "User Error:".$user->error; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit; +}else { + if (empty($user->id)) { + echo " User user login:".$userlogin." do not exists"; + dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR); + exit; } } +$id = $_GET['id']; +// Language Management +$langs->load("admin"); +$langs->load("cron@cron"); +// create a jobs object +$object = new Cronjob($db); +$filter=array(); +if (empty($id)) { + $filter=array(); + $filter['t.rowid']=$id; +} +$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter); +if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; +} -/*************************************************** -* VIEW -* -* Put here all code to build page -****************************************************/ +// current date +$now=dol_now(); -llxHeader('',$langs->trans('CronList'),''); +if(is_array($object->lines) && (count($object->lines)>0)){ + // Loop over job + foreach($object->lines as $line){ -$form=new Form($db); - - -// Put here content of your page - -// Example 1 : Adding jquery code -print ''; - - -$cronjob=new CronJob($db); -$result=$cronjob->fetch($id); - -if ($result > 0) -{ - - + echo "OK"; +} else { + echo "No Jobs to run"; } -else -{ - $langs->load("errors"); - print $langs->trans("ErrorRecordNotFound"); -} - - -// End of page -llxFooter(); - -$db->close(); -?> diff --git a/htdocs/theme/amarok/img/cron.png b/htdocs/theme/amarok/img/cron.png new file mode 100644 index 00000000000..ddfe62e7b24 Binary files /dev/null and b/htdocs/theme/amarok/img/cron.png differ diff --git a/htdocs/theme/amarok/img/object_cron.png b/htdocs/theme/amarok/img/object_cron.png new file mode 100644 index 00000000000..b929050598d Binary files /dev/null and b/htdocs/theme/amarok/img/object_cron.png differ diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 53b5bc114a7..48fa2c8f5a3 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -391,7 +391,7 @@ div.tmenu ul li a.tmenusel {/* texte du menu principal sélectionné */ font-weight:bold; } -.tmenudisabled {color:#d0d0d0 !important;} +.tmenudisabled { color:#808080 !important; cursor: not-allowed; } /* --- end nav --- */ @@ -497,6 +497,8 @@ div.vmenu { text-align:center; } +a.help:link, a.help:visited, a.help:hover, a.help:active { font-size:px; font-family: ; text-align: ; font-weight: normal; color: #666666; } + /* ============================================================================== */ /* Panes for Main */ diff --git a/htdocs/theme/auguria/img/cron.png b/htdocs/theme/auguria/img/cron.png new file mode 100644 index 00000000000..ddfe62e7b24 Binary files /dev/null and b/htdocs/theme/auguria/img/cron.png differ diff --git a/htdocs/theme/auguria/img/object_cron.png b/htdocs/theme/auguria/img/object_cron.png new file mode 100644 index 00000000000..b929050598d Binary files /dev/null and b/htdocs/theme/auguria/img/object_cron.png differ diff --git a/htdocs/theme/bureau2crea/img/cron.png b/htdocs/theme/bureau2crea/img/cron.png new file mode 100644 index 00000000000..ddfe62e7b24 Binary files /dev/null and b/htdocs/theme/bureau2crea/img/cron.png differ diff --git a/htdocs/theme/bureau2crea/img/object_cron.png b/htdocs/theme/bureau2crea/img/object_cron.png new file mode 100644 index 00000000000..b929050598d Binary files /dev/null and b/htdocs/theme/bureau2crea/img/object_cron.png differ diff --git a/htdocs/theme/cameleo/img/cron.png b/htdocs/theme/cameleo/img/cron.png new file mode 100644 index 00000000000..ddfe62e7b24 Binary files /dev/null and b/htdocs/theme/cameleo/img/cron.png differ diff --git a/htdocs/theme/cameleo/img/object_cron.png b/htdocs/theme/cameleo/img/object_cron.png new file mode 100644 index 00000000000..b929050598d Binary files /dev/null and b/htdocs/theme/cameleo/img/object_cron.png differ diff --git a/htdocs/theme/eldy/img/menus/cron.png b/htdocs/theme/eldy/img/menus/cron.png new file mode 100644 index 00000000000..ddfe62e7b24 Binary files /dev/null and b/htdocs/theme/eldy/img/menus/cron.png differ diff --git a/htdocs/theme/eldy/img/menus/object_cron.png b/htdocs/theme/eldy/img/menus/object_cron.png new file mode 100644 index 00000000000..b929050598d Binary files /dev/null and b/htdocs/theme/eldy/img/menus/object_cron.png differ diff --git a/scripts/cron/cron_run_jobs.php b/scripts/cron/cron_run_jobs.php new file mode 100644 index 00000000000..0c22107bde6 --- /dev/null +++ b/scripts/cron/cron_run_jobs.php @@ -0,0 +1,146 @@ +#!/usr/bin/php +. + */ + +/** + * \file cron/script/cron/cron_run_jobs.php + * \ingroup cron + * \brief Execute pendings jobs + */ +if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Disables token renewal +if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); +if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); +if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1'); +if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1'); +if (! defined('NOLOGIN')) define('NOLOGIN','1'); +//if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1'); + +$sapi_type = php_sapi_name(); +$script_file = basename(__FILE__); +$path=dirname(__FILE__).'/'; + +// Test if batch mode +if (substr($sapi_type, 0, 3) == 'cgi') { + echo "Error: You are using PHP for CGI. To execute ".$script_file." from command line, you must use PHP for CLI mode.\n"; + exit; +} + +if (! isset($argv[1]) || ! $argv[1]) { + print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; + exit; +} +$key=$argv[1]; + +if (! isset($argv[2]) || ! $argv[2]) { + print "Usage: ".$script_file." securitykey userlogin cronjobid(optional)\n"; + exit; +} else { + $userlogin=$argv[2]; +} + + +$res=@include("../../master.inc.php"); // For root directory +if (! $res) $res=@include("../../../master.inc.php"); // For "custom" directory +if (! $res) die("Include of master.inc.php fails"); + + +// librarie jobs +require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php"); + + +//Check security key +if($key != $conf->global->MAIN_CRON_KEY) +{ + echo 'securitykey is wrong'; + exit; +} + +//Check user login +require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php'; +$user=new User($db); +$result=$user->fetch('',$userlogin); +if ($result<0) { + echo "User Error:".$user->error; + dol_syslog("cron_run_jobs.php:: User Error:".$user->error, LOG_ERR); + exit; +}else { + if (empty($user->id)) { + echo " User user login:".$userlogin." do not exists"; + dol_syslog(" User user login:".$userlogin." do not exists", LOG_ERR); + exit; + } +} + +if (isset($argv[3]) || $argv[3]) { + $id = $argv[3]; +} + +// librarie jobs +require_once (DOL_DOCUMENT_ROOT_ALT."/cron/class/cronjob.class.php"); + +// create a jobs object +$object = new Cronjob($db); + +$filter=array(); +if (empty($id)) { + $filter=array(); + $filter['t.rowid']=$id; +} + +$result = $object->fetch_all('DESC','t.rowid', 0, 0, 1, $filter); +if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: fetch Error".$cronjob->error, LOG_ERR); + exit; +} + +// current date +$now=dol_now(); + +if(is_array($object->lines) && (count($object->lines)>0)){ + // Loop over job + foreach($object->lines as $line){ + + //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){ + $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; + } + // execute methode + $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); + exit; + } + + // we re-program the next execution and stores the last execution time for this job + $result=$cronjob->reprogram_jobs($userlogin); + if ($result<0) { + echo "Error:".$cronjob->error; + dol_syslog("cron_run_jobs.php:: reprogram_jobs Error".$cronjob->error, LOG_ERR); + exit; + } + + } + } +} \ No newline at end of file