From 199bbe90a8130e0fe880e5cf823e7f6ab995e285 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 19 Mar 2013 15:28:40 +0100 Subject: [PATCH 01/11] Add missing style --- htdocs/theme/amarok/style.css.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 3607c8c4edd..cb7d355ef9a 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -494,6 +494,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 */ From 0215031632bfc0cbe3ced261463818f9aa434345 Mon Sep 17 00:00:00 2001 From: fhenry Date: Fri, 22 Mar 2013 14:45:20 +0100 Subject: [PATCH 02/11] [ task #122 ] Create a scheduled cron module --- htdocs/core/class/html.formcron.class.php | 93 +++ htdocs/core/lib/cron.lib.php | 70 ++ htdocs/core/modules/modCron.class.php | 102 ++- htdocs/cron/admin/cron.php | 139 ++-- htdocs/cron/card.php | 596 +++++++++++++++ htdocs/cron/class/cronjob.class.php | 696 ++++++++++++++++-- htdocs/cron/functions_cron.lib.php | 27 - htdocs/cron/index.php | 219 ------ htdocs/cron/info.php | 59 ++ htdocs/cron/list.php | 289 ++++++++ .../install/mysql/migration/3.3.0-3.4.0.sql | 33 + htdocs/install/mysql/tables/llx_cronjob.sql | 84 ++- htdocs/install/pgsql/functions/functions.sql | 1 + htdocs/langs/en_US/admin.lang | 4 + htdocs/langs/en_US/cron.lang | 90 ++- htdocs/langs/fr_FR/admin.lang | 4 + htdocs/langs/fr_FR/cron.lang | 96 ++- htdocs/public/cron/cron_run_jobs.php | 243 +++--- htdocs/theme/amarok/img/cron.png | Bin 0 -> 2165 bytes htdocs/theme/amarok/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/auguria/img/cron.png | Bin 0 -> 2165 bytes htdocs/theme/auguria/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/bureau2crea/img/cron.png | Bin 0 -> 2165 bytes htdocs/theme/bureau2crea/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/cameleo/img/cron.png | Bin 0 -> 2165 bytes htdocs/theme/cameleo/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/eldy/img/menus/cron.png | Bin 0 -> 2165 bytes htdocs/theme/eldy/img/menus/object_cron.png | Bin 0 -> 655 bytes scripts/cron/cron_run_jobs.php | 146 ++++ 29 files changed, 2432 insertions(+), 559 deletions(-) create mode 100644 htdocs/core/class/html.formcron.class.php create mode 100644 htdocs/core/lib/cron.lib.php create mode 100644 htdocs/cron/card.php delete mode 100644 htdocs/cron/functions_cron.lib.php delete mode 100644 htdocs/cron/index.php create mode 100644 htdocs/cron/info.php create mode 100644 htdocs/cron/list.php create mode 100644 htdocs/theme/amarok/img/cron.png create mode 100644 htdocs/theme/amarok/img/object_cron.png create mode 100644 htdocs/theme/auguria/img/cron.png create mode 100644 htdocs/theme/auguria/img/object_cron.png create mode 100644 htdocs/theme/bureau2crea/img/cron.png create mode 100644 htdocs/theme/bureau2crea/img/object_cron.png create mode 100644 htdocs/theme/cameleo/img/cron.png create mode 100644 htdocs/theme/cameleo/img/object_cron.png create mode 100644 htdocs/theme/eldy/img/menus/cron.png create mode 100644 htdocs/theme/eldy/img/menus/object_cron.png create mode 100644 scripts/cron/cron_run_jobs.php 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..5d388c35a16 --- /dev/null +++ b/htdocs/core/lib/cron.lib.php @@ -0,0 +1,70 @@ +. + */ +/** + * \file htdocs/jobs/lib/jobs.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/cron/card.php', 1).'?id='.$object->id; + $head[$h][1] = $langs->trans("CronTask"); + $head[$h][2] = 'card'; + $h++; + + $head[$h][0] = dol_buildpath('/cron/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/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index fbc14945f02..2cf4e9cd9e4 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'; @@ -46,7 +47,7 @@ class modCron extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the Dolibarr cron service"; - $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version + $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) @@ -59,7 +60,7 @@ class modCron extends DolibarrModules // Config pages //------------- - $this->config_page_url = array("cron.php@cron"); + $this->config_page_url = array("cron"); // Dependancies //------------- @@ -69,7 +70,16 @@ class modCron extends DolibarrModules // Constantes //----------- - $this->const = array(); + $this->const = array( + 0=>array( + 'MAIN_CRON_KEY', + 'chaine', + '', + 'CRON KEY', + 0, + 'main', + 0 + ),); // New pages on tabs // ----------------- @@ -79,11 +89,34 @@ 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; @@ -92,12 +125,49 @@ class modCron extends DolibarrModules '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, + 'position'=>100, + 'leftmenu'=>'cron', '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 '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', + 'type'=>'left', + 'titre'=>'CronListActive', + 'url'=>'/cron/cron/list.php?status=1', + 'langs'=>'cron@cron', + 'position'=>201, + 'enabled'=>'$user->rights->cron->read', + 'perms'=>'$user->rights->cron->read', + 'target'=>'', + 'user'=>2); + $r++; + + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', + 'type'=>'left', + 'titre'=>'CronListInactive', + 'url'=>'/cron/cron/list.php?status=0', + 'langs'=>'cron@cron', + 'position'=>201, + 'enabled'=>'$user->rights->cron->read', + 'perms'=>'$user->rights->cron->read', + 'target'=>'', + 'user'=>2); + $r++; + + $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', + 'type'=>'left', + 'titre'=>'CronAdd', + 'url'=>'/cron/cron/card.php?action=create', + 'langs'=>'cron@cron', + 'position'=>202, + 'enabled'=>'$user->rights->cron->create', + 'perms'=>'$user->rights->cron->create', + 'target'=>'', + 'user'=>2); + $r++; } @@ -114,8 +184,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..238208035f3 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('/cron/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('/cron/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=dol_buildpath('/cron/script/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..b5b9c6d29dc --- /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("CronInfo"), 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..2d472add564 --- /dev/null +++ b/htdocs/cron/list.php @@ -0,0 +1,289 @@ + + * + * 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 '
'; + +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..0394764a5a7 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,36 @@ 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; + + diff --git a/htdocs/install/mysql/tables/llx_cronjob.sql b/htdocs/install/mysql/tables/llx_cronjob.sql index 5a8e33ef38f..959a3a1705d 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 IF NOT EXISTS 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/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/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/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 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/amarok/img/object_cron.png b/htdocs/theme/amarok/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/auguria/img/cron.png b/htdocs/theme/auguria/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/auguria/img/object_cron.png b/htdocs/theme/auguria/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/bureau2crea/img/cron.png b/htdocs/theme/bureau2crea/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/bureau2crea/img/object_cron.png b/htdocs/theme/bureau2crea/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/cameleo/img/cron.png b/htdocs/theme/cameleo/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/cameleo/img/object_cron.png b/htdocs/theme/cameleo/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/img/menus/cron.png b/htdocs/theme/eldy/img/menus/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 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 From 52573cad89b58bbbdd7d95ea80cb25203b099d38 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 22 Mar 2013 15:12:57 +0100 Subject: [PATCH 03/11] New: Remove FEATURE_LEVEL>1 for PDF options hide details, desc and ref --- htdocs/admin/pdf.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 2734bacea2a..80c42edba0c 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-213 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 ''; From d2875d4e6d426b2c825aa947d2c4451d1c73de9a Mon Sep 17 00:00:00 2001 From: fhenry Date: Fri, 22 Mar 2013 15:14:43 +0100 Subject: [PATCH 04/11] [ task #122 ] Create a scheduled cron module --- htdocs/core/lib/cron.lib.php | 7 ++- htdocs/core/modules/modCron.class.php | 63 +++++++-------------- htdocs/cron/admin/cron.php | 10 ++-- htdocs/cron/info.php | 2 +- htdocs/cron/list.php | 8 ++- htdocs/install/mysql/tables/llx_cronjob.sql | 2 +- 6 files changed, 37 insertions(+), 55 deletions(-) diff --git a/htdocs/core/lib/cron.lib.php b/htdocs/core/lib/cron.lib.php index 5d388c35a16..abd85131e29 100644 --- a/htdocs/core/lib/cron.lib.php +++ b/htdocs/core/lib/cron.lib.php @@ -1,5 +1,6 @@ * * 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 @@ -15,7 +16,7 @@ * along with this program. If not, see . */ /** - * \file htdocs/jobs/lib/jobs.lib.php + * \file cron/lib/cron.lib.php * \brief Ensemble de fonctions de base pour le module jobs * \ingroup jobs */ @@ -52,12 +53,12 @@ function cron_prepare_head($object) $h = 0; $head = array(); - $head[$h][0] = dol_buildpath('/cron/cron/card.php', 1).'?id='.$object->id; + $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/cron/info.php', 1).'?id='.$object->id; + $head[$h][0] = dol_buildpath('/cron/info.php', 1).'?id='.$object->id; $head[$h][1] = $langs->trans("CronInfoPage"); $head[$h][2] = 'info'; $h++; diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index 2cf4e9cd9e4..b7bcafc12be 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -60,13 +60,13 @@ class modCron extends DolibarrModules // Config pages //------------- - $this->config_page_url = array("cron"); + $this->config_page_url = array("cron.php@cron"); // Dependancies //------------- $this->depends = array(); $this->requiredby = array(); - $this->langfiles = array("cron"); + $this->langfiles = array("cron@cron"); // Constantes //----------- @@ -122,52 +122,27 @@ class modCron extends DolibarrModules $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, - 'leftmenu'=>'cron', + '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', - 'type'=>'left', - 'titre'=>'CronListActive', - 'url'=>'/cron/cron/list.php?status=1', - 'langs'=>'cron@cron', - 'position'=>201, - 'enabled'=>'$user->rights->cron->read', - 'perms'=>'$user->rights->cron->read', - 'target'=>'', - 'user'=>2); - $r++; - - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', - 'type'=>'left', - 'titre'=>'CronListInactive', - 'url'=>'/cron/cron/list.php?status=0', - 'langs'=>'cron@cron', - 'position'=>201, - 'enabled'=>'$user->rights->cron->read', - 'perms'=>'$user->rights->cron->read', - 'target'=>'', - 'user'=>2); - $r++; - - $this->menu[$r]=array( 'fk_menu'=>'fk_mainmenu=home,fk_leftmenu=modulesadmintools', - 'type'=>'left', - 'titre'=>'CronAdd', - 'url'=>'/cron/cron/card.php?action=create', - 'langs'=>'cron@cron', - 'position'=>202, - 'enabled'=>'$user->rights->cron->create', - 'perms'=>'$user->rights->cron->create', - 'target'=>'', - 'user'=>2); - $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++; } diff --git a/htdocs/cron/admin/cron.php b/htdocs/cron/admin/cron.php index 238208035f3..894e9dc4457 100644 --- a/htdocs/cron/admin/cron.php +++ b/htdocs/cron/admin/cron.php @@ -106,10 +106,10 @@ print '

'; // Cron launch print ''.$langs->trans("URLToLaunchCronJobs").':
'; -$url=dol_buildpath('/cron/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login; +$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_buildpath('/cron/public/cron/cron_run_jobs.php',1).(empty($conf->global->MAIN_CRON_KEY)?'':'?securitykey='.$conf->global->MAIN_CRON_KEY.'&').'userlogin='.$user->login.'&id=cronjobid'; +$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 '
'; @@ -126,11 +126,11 @@ if ($linuxlike) { } print '
'; print ''.$langs->trans("FileToLaunchCronJobs").':
'; -$file=dol_buildpath('/cron/script/cron/cron_run_jobs.php').' '.(empty($conf->global->MAIN_CRON_KEY)?'securitykey':''.$conf->global->MAIN_CRON_KEY.'').' '.$user->login.' cronjobid(optionnal)'; +$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"; + print 'user@host:'.DOL_DOCUMENT_ROOT.'$ php ..'.$file."
\n"; } else { - print DOL_DOCUMENT_ROOT.'> php '.$file."
\n"; + print DOL_DOCUMENT_ROOT.'> php ..'.$file."
\n"; } print '
'; diff --git a/htdocs/cron/info.php b/htdocs/cron/info.php index b5b9c6d29dc..55c294d54ed 100644 --- a/htdocs/cron/info.php +++ b/htdocs/cron/info.php @@ -47,7 +47,7 @@ $object->info($id); $head = cron_prepare_head($object); -dol_fiche_head($head, 'info', $langs->trans("CronInfo"), 0, 'bill'); +dol_fiche_head($head, 'info', $langs->trans("CronTask"), 0, 'bill'); print ''; print ''; - print ''; + print ''; + print ''; print ''; print ''; if (! empty($conf->banque->enabled)) @@ -701,6 +703,7 @@ if ($rowid) $cotisationstatic->ref=$objp->crowid; $cotisationstatic->id=$objp->crowid; print ''; + print '\n"; print '\n"; print '\n"; print ''; @@ -899,16 +902,18 @@ if ($rowid) // Title payments //print ''; - // Define a way to write payment + // No more action print ''; print ''; @@ -1029,4 +1037,4 @@ else llxFooter(); $db->close(); -?> +?> \ No newline at end of file diff --git a/htdocs/compta/bank/admin/bank.php b/htdocs/admin/bank.php similarity index 93% rename from htdocs/compta/bank/admin/bank.php rename to htdocs/admin/bank.php index a45fa29c912..98a08708dff 100644 --- a/htdocs/compta/bank/admin/bank.php +++ b/htdocs/admin/bank.php @@ -1,6 +1,7 @@ * Copyright (C) 2010-2012 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -18,12 +19,12 @@ /** - * \file htdocs/compta/bank/admin/bank.php + * \file htdocs/admin/bank.php * \ingroup bank * \brief Page to setup the bank module */ -require '../../../main.inc.php'; +require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; @@ -87,6 +88,16 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("BankSetupModule"),$linkback,'setup'); print '
'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/bank.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + print '
'; dol_print_object_info($object); diff --git a/htdocs/cron/list.php b/htdocs/cron/list.php index 2d472add564..5e972f0e55b 100644 --- a/htdocs/cron/list.php +++ b/htdocs/cron/list.php @@ -283,7 +283,13 @@ if (count($object->lines)>0) { print $langs->trans('CronNoJobs'); } -print '
'; +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/tables/llx_cronjob.sql b/htdocs/install/mysql/tables/llx_cronjob.sql index 959a3a1705d..a5bb3c10f59 100644 --- a/htdocs/install/mysql/tables/llx_cronjob.sql +++ b/htdocs/install/mysql/tables/llx_cronjob.sql @@ -18,7 +18,7 @@ -- =================================================================== -CREATE TABLE IF NOT EXISTS llx_cronjob +CREATE TABLE llx_cronjob ( rowid integer AUTO_INCREMENT PRIMARY KEY, tms timestamp, From ab0354f14f6dc68982e48279a7df90ce823dff62 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 22 Mar 2013 15:15:13 +0100 Subject: [PATCH 05/11] New: Remove FEATURE_LEVEL>1 for PDF options hide details, desc and ref --- htdocs/admin/pdf.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/admin/pdf.php b/htdocs/admin/pdf.php index 80c42edba0c..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-213 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 From 49702ce5788ffe5b88b5f920762bed44fa6e4de3 Mon Sep 17 00:00:00 2001 From: fhenry Date: Fri, 22 Mar 2013 15:18:33 +0100 Subject: [PATCH 06/11] Change module to experimantal --- htdocs/core/modules/modCron.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/modules/modCron.class.php b/htdocs/core/modules/modCron.class.php index b7bcafc12be..53d9afabf30 100644 --- a/htdocs/core/modules/modCron.class.php +++ b/htdocs/core/modules/modCron.class.php @@ -47,7 +47,7 @@ class modCron extends DolibarrModules // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) $this->name = preg_replace('/^mod/i','',get_class($this)); $this->description = "Enable the Dolibarr cron service"; - $this->version = 'dolibarr'; // 'experimental' or 'dolibarr' or version + $this->version = 'experimental'; // 'experimental' or 'dolibarr' or version // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); // Where to store the module in setup page (0=common,1=interface,2=others,3=very specific) From 708f0472cd7aba69a5a8d1bf1cb73e377b16fe9b Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Mar 2013 16:40:35 +0100 Subject: [PATCH 07/11] Qual: Prepare menu handler to be able to output content into a list. --- htdocs/core/menus/standard/eldy.lib.php | 276 +++++++++++------------ htdocs/core/menus/standard/eldy_menu.php | 47 +++- htdocs/theme/amarok/style.css.php | 2 +- 3 files changed, 178 insertions(+), 147 deletions(-) diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 7e459f07f20..c07360abd10 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)) @@ -1164,107 +1170,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/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index cb7d355ef9a..8c92d9e561b 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -388,7 +388,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 --- */ From 2ec462dcf4814b5ea9e805faf72435d8e37dc469 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Mar 2013 17:00:55 +0100 Subject: [PATCH 08/11] Fix: [ task #771 ] harmonize length of zipcode New: Add personal address for users. --- htdocs/install/mysql/migration/3.3.0-3.4.0.sql | 12 +++++++++++- htdocs/install/mysql/tables/llx_societe.sql | 2 +- htdocs/install/mysql/tables/llx_user.sql | 5 +++++ 3 files changed, 17 insertions(+), 2 deletions(-) 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 a8a57e7750d..d5fb257cead 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 @@ -153,4 +153,14 @@ ALTER TABLE llx_holiday ADD COLUMN note_public text; -- Add new trigger on Invoice BILL_UNVALIDATE + Index INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (28,'BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10); -ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang) +ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang) + +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_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), From 350bcea1833485e9e953bb7953d960c237e94ea9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Fri, 22 Mar 2013 17:10:17 +0100 Subject: [PATCH 09/11] Merge --- ChangeLog | 1 + htdocs/adherents/card_subscriptions.php | 18 +- htdocs/{compta/bank => }/admin/bank.php | 15 +- htdocs/admin/commande.php | 99 +- htdocs/admin/compta.php | 20 +- htdocs/admin/contract.php | 18 +- htdocs/admin/dons.php | 88 +- htdocs/admin/ecm.php | 11 + htdocs/admin/fichinter.php | 123 +- htdocs/admin/mailing.php | 10 + htdocs/admin/pdf.php | 20 +- htdocs/admin/prelevement.php | 11 + htdocs/admin/project.php | 38 +- htdocs/admin/stock.php | 20 +- htdocs/admin/taxes.php | 11 + htdocs/comm/action/fiche.php | 2 +- htdocs/comm/propal.php | 4491 +++++++++-------- htdocs/commande/class/commande.class.php | 6 + htdocs/commissions/admin/commissions.php | 192 - htdocs/commissions/index.php | 329 -- htdocs/commissions/lib/commissions.lib.php | 52 - .../facture/class/facture-rec.class.php | 1 - htdocs/compta/facture/class/facture.class.php | 22 +- htdocs/compta/recap-compta.php | 23 +- .../compta/ventilation/fournisseur/index.php | 8 +- htdocs/compta/ventilation/lignes.php | 6 +- htdocs/compta/ventilation/liste.php | 2 +- htdocs/contrat/class/contrat.class.php | 12 +- htdocs/contrat/fiche.php | 214 +- htdocs/core/class/commonobject.class.php | 27 +- htdocs/core/class/html.formcron.class.php | 93 + htdocs/core/lib/company.lib.php | 5 + htdocs/core/lib/cron.lib.php | 71 + htdocs/core/menus/standard/eldy.lib.php | 8 +- .../doc/pdf_expedition_merou.modules.php | 4 +- .../doc/pdf_expedition_rouget.modules.php | 4 +- htdocs/core/modules/modBanque.class.php | 2 +- htdocs/core/modules/modCommissions.class.php | 169 - htdocs/core/modules/modCron.class.php | 83 +- htdocs/core/tpl/objectline_view.tpl.php | 90 +- htdocs/cron/admin/cron.php | 139 +- htdocs/cron/card.php | 596 +++ htdocs/cron/class/cronjob.class.php | 696 ++- htdocs/cron/functions_cron.lib.php | 27 - htdocs/cron/index.php | 219 - htdocs/cron/info.php | 59 + htdocs/cron/list.php | 295 ++ htdocs/expedition/class/expedition.class.php | 12 +- htdocs/expedition/fiche.php | 22 +- .../install/mysql/migration/3.3.0-3.4.0.sql | 39 +- htdocs/install/mysql/tables/llx_cronjob.sql | 84 +- .../mysql/tables/llx_facture_fourn_det.sql | 1 + .../install/mysql/tables/llx_facturedet.sql | 1 - htdocs/install/mysql/tables/llx_paiement.sql | 9 +- htdocs/install/pgsql/functions/functions.sql | 1 + htdocs/langs/ar_SA/main.lang | 2 - htdocs/langs/ar_SA/members.lang | 2 +- htdocs/langs/bg_BG/members.lang | 2 +- htdocs/langs/ca_ES/commissions.lang | 41 - htdocs/langs/ca_ES/orders.lang | 4 +- htdocs/langs/da_DK/members.lang | 2 +- htdocs/langs/el_GR/members.lang | 2 +- htdocs/langs/en_US/admin.lang | 6 +- htdocs/langs/en_US/commissions.lang | 44 - htdocs/langs/en_US/companies.lang | 1 + htdocs/langs/en_US/compta.lang | 4 +- htdocs/langs/en_US/cron.lang | 90 +- htdocs/langs/en_US/main.lang | 2 +- htdocs/langs/en_US/members.lang | 2 +- htdocs/langs/es_ES/commissions.lang | 41 - htdocs/langs/es_ES/orders.lang | 4 +- htdocs/langs/et_EE/members.lang | 2 +- htdocs/langs/fa_IR/members.lang | 2 +- htdocs/langs/fi_FI/members.lang | 2 +- htdocs/langs/fr_FR/admin.lang | 6 +- htdocs/langs/fr_FR/commissions.lang | 44 - htdocs/langs/fr_FR/companies.lang | 1 + htdocs/langs/fr_FR/compta.lang | 2 + htdocs/langs/fr_FR/cron.lang | 96 +- htdocs/langs/fr_FR/main.lang | 2 +- htdocs/langs/he_IL/members.lang | 2 +- htdocs/langs/hu_HU/members.lang | 2 +- htdocs/langs/is_IS/members.lang | 2 +- htdocs/langs/it_IT/members.lang | 2 +- htdocs/langs/ja_JP/members.lang | 2 +- htdocs/langs/nb_NO/members.lang | 2 +- htdocs/langs/pl_PL/members.lang | 2 +- htdocs/langs/pt_PT/members.lang | 2 +- htdocs/langs/ro_RO/members.lang | 2 +- htdocs/langs/sv_SE/members.lang | 2 +- htdocs/langs/zh_TW/members.lang | 2 +- htdocs/margin/agentMargins.php | 35 +- htdocs/margin/customerMargins.php | 37 +- htdocs/margin/productMargins.php | 31 +- htdocs/margin/tabs/productMargins.php | 14 +- htdocs/margin/tabs/thirdpartyMargins.php | 14 +- htdocs/public/cron/cron_run_jobs.php | 243 +- htdocs/societe/consumption.php | 439 ++ htdocs/theme/amarok/img/cron.png | Bin 0 -> 2165 bytes htdocs/theme/amarok/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/amarok/style.css.php | 17 +- htdocs/theme/auguria/img/cron.png | Bin 0 -> 2165 bytes .../theme/auguria/img/object_commissions.png | Bin 651 -> 0 bytes htdocs/theme/auguria/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/bureau2crea/img/cron.png | Bin 0 -> 2165 bytes .../bureau2crea/img/object_commissions.png | Bin 651 -> 0 bytes htdocs/theme/bureau2crea/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/cameleo/img/cron.png | Bin 0 -> 2165 bytes .../theme/cameleo/img/object_commissions.png | Bin 651 -> 0 bytes htdocs/theme/cameleo/img/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/eldy/img/menus/cron.png | Bin 0 -> 2165 bytes htdocs/theme/eldy/img/menus/object_cron.png | Bin 0 -> 655 bytes htdocs/theme/eldy/img/object_commissions.png | Bin 651 -> 0 bytes scripts/cron/cron_run_jobs.php | 146 + 114 files changed, 5882 insertions(+), 4141 deletions(-) rename htdocs/{compta/bank => }/admin/bank.php (93%) delete mode 100644 htdocs/commissions/admin/commissions.php delete mode 100644 htdocs/commissions/index.php delete mode 100644 htdocs/commissions/lib/commissions.lib.php create mode 100644 htdocs/core/class/html.formcron.class.php create mode 100644 htdocs/core/lib/cron.lib.php delete mode 100644 htdocs/core/modules/modCommissions.class.php create mode 100644 htdocs/cron/card.php delete mode 100644 htdocs/cron/functions_cron.lib.php delete mode 100644 htdocs/cron/index.php create mode 100644 htdocs/cron/info.php create mode 100644 htdocs/cron/list.php delete mode 100644 htdocs/langs/ca_ES/commissions.lang delete mode 100644 htdocs/langs/en_US/commissions.lang delete mode 100644 htdocs/langs/es_ES/commissions.lang delete mode 100644 htdocs/langs/fr_FR/commissions.lang create mode 100644 htdocs/societe/consumption.php create mode 100644 htdocs/theme/amarok/img/cron.png create mode 100644 htdocs/theme/amarok/img/object_cron.png create mode 100644 htdocs/theme/auguria/img/cron.png delete mode 100644 htdocs/theme/auguria/img/object_commissions.png create mode 100644 htdocs/theme/auguria/img/object_cron.png create mode 100644 htdocs/theme/bureau2crea/img/cron.png delete mode 100644 htdocs/theme/bureau2crea/img/object_commissions.png create mode 100644 htdocs/theme/bureau2crea/img/object_cron.png create mode 100644 htdocs/theme/cameleo/img/cron.png delete mode 100644 htdocs/theme/cameleo/img/object_commissions.png create mode 100644 htdocs/theme/cameleo/img/object_cron.png create mode 100644 htdocs/theme/eldy/img/menus/cron.png create mode 100644 htdocs/theme/eldy/img/menus/object_cron.png delete mode 100644 htdocs/theme/eldy/img/object_commissions.png create mode 100644 scripts/cron/cron_run_jobs.php diff --git a/ChangeLog b/ChangeLog index f7eedaf2369..66e4a8cfd89 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ English Dolibarr ChangeLog ***** ChangeLog for 3.4 compared to 3.3 ***** For users: +- New: Add a tab "consumption" on thirdparties to list products bought/sells. - New: Some performance enhancements. - New: Can attach files onto trip and expenses modules. - New: Add option MAIN_PDF_TITLE_BACKGROUND_COLOR. diff --git a/htdocs/adherents/card_subscriptions.php b/htdocs/adherents/card_subscriptions.php index 25767e8f5b2..279669497ec 100644 --- a/htdocs/adherents/card_subscriptions.php +++ b/htdocs/adherents/card_subscriptions.php @@ -660,6 +660,7 @@ if ($rowid) { $sql = "SELECT d.rowid, d.firstname, d.lastname, d.societe,"; $sql.= " c.rowid as crowid, c.cotisation,"; + $sql.= " c.datec,"; $sql.= " c.dateadh,"; $sql.= " c.datef,"; $sql.= " c.fk_bank,"; @@ -683,7 +684,8 @@ if ($rowid) print '
'.$langs->trans("Ref").''.$langs->trans("DateSubscription").''.$langs->trans("DateCreation").''.$langs->trans("DateStart").''.$langs->trans("DateEnd").''.$langs->trans("Amount").''.$cotisationstatic->getNomUrl(1).''.dol_print_date($db->jdate($objp->datec),'dayhour')."'.dol_print_date($db->jdate($objp->dateadh),'day')."'.dol_print_date($db->jdate($objp->datef),'day')."'.price($objp->cotisation).'
'.$langs->trans("Payment").'
'.$langs->trans('MoreActions'); print ''; print ' '.$langs->trans("None").'
'; + // Add entry into bank accoun if (! empty($conf->banque->enabled)) { print ' '.$langs->trans("MoreActionBankDirect").'
'; } + // Add invoice with no payments if (! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print ' '.$langs->trans("MoreActionInvoiceOnly"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else - { + { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0).'.'; print '
'; } + // Add invoice with payments if (! empty($conf->banque->enabled) && ! empty($conf->societe->enabled) && ! empty($conf->facture->enabled)) { print ' '.$langs->trans("MoreActionBankViaInvoice"); if ($object->fk_soc) print ' ('.$langs->trans("ThirdParty").': '.$company->getNomUrl(1).')'; else - { + { print ' ('.$langs->trans("NoThirdPartyAssociatedToMember"); print ' - '; print $langs->trans("CreateDolibarrThirdParty"); print ')'; } + if (empty($conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS) || $conf->global->ADHERENT_VAT_FOR_SUBSCRIPTIONS != 'defaultforfoundationcountry') print '. '.$langs->trans("NoVatOnSubscription",0).'.'; print '
'; } print '
'; print ''; print ''; diff --git a/htdocs/admin/commande.php b/htdocs/admin/commande.php index 7dda6ded0e4..2a225234af6 100644 --- a/htdocs/admin/commande.php +++ b/htdocs/admin/commande.php @@ -7,7 +7,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011 Philippe Grand + * Copyright (C) 2011-2013 Philippe Grand * * 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 @@ -66,7 +66,7 @@ if ($action == 'updateMask') } } -if ($action == 'specimen') +else if ($action == 'specimen') { $modele=GETPOST('module','alpha'); @@ -111,74 +111,36 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $type='order'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - if ($db->query($sql)) - { - - } + $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { - $type='order'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql.= " WHERE nom = '".$db->escape($value)."'"; - $sql.= " AND type = '".$type."'"; - $sql.= " AND entity = ".$conf->entity; - - if ($db->query($sql)) + $ret = delDocumentModel($value, $type); + if ($ret > 0) { if ($conf->global->COMMANDE_ADDON_PDF == "$value") dolibarr_del_const($db, 'COMMANDE_ADDON_PDF',$conf->entity); } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $db->begin(); - if (dolibarr_set_const($db, "COMMANDE_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent $conf->global->COMMANDE_ADDON_PDF = $value; } // On active le modele - $type='order'; - - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($value)."'"; - $sql_del.= " AND type = '".$type."'"; - $sql_del.= " AND entity = ".$conf->entity; - dol_syslog("Delete from model table ".$sql_del); - $result1=$db->query($sql_del); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$value."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$scandir."'":"null"); - $sql.= ")"; - dol_syslog("Insert into model table ".$sql); - $result2=$db->query($sql); - if ($result1 && $result2) + $ret = delDocumentModel($value, $type); + if ($ret > 0) { - $db->commit(); - } - else - { - dol_syslog("Error ".$db->lasterror(), LOG_ERR); - $db->rollback(); + $ret = addDocumentModel($value, $type, $label, $scandir); } } @@ -240,10 +202,18 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("OrdersSetup"),$linkback,'setup'); print '
'; +$h = 0; +$head[$h][0] = DOL_URL_ROOT."/admin/commande.php"; +$head[$h][1] = $langs->trans("Orders"); +$head[$h][2] = 'Order'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); /* - * Numbering module + * Orders Numbering model */ print_titre($langs->trans("OrdersNumberingModules")); @@ -276,22 +246,22 @@ foreach ($dirmodels as $reldir) { $file = substr($file, 0, dol_strlen($file)-4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/commande/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - if ($module->isEnabled()) { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print '
'; - // Show example of numbering module + // Show example of numbering model print '
'.$langs->trans("Parameters").'
'.$module->nom."\n"; print $module->info(); print ''; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; @@ -508,11 +478,14 @@ foreach ($dirmodels as $reldir) } print '
'; - -//Autres Options print "
"; -print_titre($langs->trans("OtherOptions")); +/* + * Other options + * + */ + +print_titre($langs->trans("OtherOptions")); print ''; print ''; print ''; diff --git a/htdocs/admin/compta.php b/htdocs/admin/compta.php index e45a316858f..a5213413d54 100644 --- a/htdocs/admin/compta.php +++ b/htdocs/admin/compta.php @@ -2,7 +2,8 @@ /* Copyright (C) 2004 Rodolphe Quiedeville * Copyright (C) 2004-2008 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2011-2012 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -35,6 +36,10 @@ accessforbidden(); $action = GETPOST('action','alpha'); +/* + * Actions + */ + $compta_mode = defined('COMPTA_MODE')?COMPTA_MODE:'RECETTES-DEPENSES'; if ($action == 'setcomptamode') @@ -87,7 +92,7 @@ if ($action == 'update' || $action == 'add') }*/ /* - * Affichage page + * View */ llxHeader(); @@ -97,9 +102,18 @@ $form=new Form($db); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans('ComptaSetup'),$linkback,'setup'); - print '
'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/compta.php"; +$head[$h][1] = $langs->trans("Compta"); +$head[$h][2] = 'Compta'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + print '
'.$langs->trans("Parameter").'
'; // Cas du parametre COMPTA_MODE diff --git a/htdocs/admin/contract.php b/htdocs/admin/contract.php index 80e1547b33f..5e32dd097d0 100644 --- a/htdocs/admin/contract.php +++ b/htdocs/admin/contract.php @@ -1,5 +1,6 @@ + * Copyright (C) 2011-2013 Philippe Grand * * 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 @@ -27,6 +28,7 @@ require_once DOL_DOCUMENT_ROOT.'/contrat/class/contrat.class.php'; $langs->load("admin"); $langs->load("errors"); +$langs->load("contracts"); if (!$user->admin) accessforbidden(); @@ -88,6 +90,20 @@ print_fiche_titre($langs->trans("ContractsSetup"),$linkback,'setup'); print "
"; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/contract.php"; +$head[$h][1] = $langs->trans("Contracts"); +$head[$h][2] = 'Contract'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +/* + * Contracts Numbering model + */ + print_titre($langs->trans("ContractsNumberingModules")); print '
'; @@ -129,7 +145,7 @@ if (is_resource($handle)) print $module->info(); print ''; - // Show example of numbering module + // Show example of numbering model print '"; } - // Defaut + // Default print "
'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } diff --git a/htdocs/admin/dons.php b/htdocs/admin/dons.php index 21c2b3a1a59..0176436c928 100644 --- a/htdocs/admin/dons.php +++ b/htdocs/admin/dons.php @@ -1,6 +1,7 @@ * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -47,7 +48,7 @@ if ($action == 'specimen') $don = new Don($db); $don->initAsSpecimen(); - // Charge le modele + // Search template files $dir = DOL_DOCUMENT_ROOT . "/core/modules/dons/"; $file = $modele.".modules.php"; if (file_exists($dir.$file)) @@ -75,67 +76,39 @@ if ($action == 'specimen') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $db->begin(); + if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity)) + { + // La constante qui a ete lue en avant du nouveau set + // on passe donc par une variable pour avoir un affichage coherent + $conf->global->DON_ADDON_MODEL = $value; + } - if (dolibarr_set_const($db, "DON_ADDON_MODEL",$value,'chaine',0,'',$conf->entity)) - { - $conf->global->DON_ADDON_MODEL = $value; - } - - // On active le modele - $type='donation'; - $sql_del = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql_del.= " WHERE nom = '".$db->escape($value)."' AND type = '".$type."'"; - $result1=$db->query($sql_del); - - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."', '".$type."', ".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $result2=$db->query($sql); - if ($result1 && $result2) - { - $db->commit(); - } - else - { - $db->rollback(); - } + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { - $value = GETPOST('value','alpha'); - $label = GETPOST('label','alpha'); - $scandir = GETPOST('scandir','alpha'); - - $type='donation'; - $sql = "INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity, libelle, description)"; - $sql.= " VALUES ('".$db->escape($value)."','".$type."',".$conf->entity.", "; - $sql.= ($label?"'".$db->escape($label)."'":'null').", "; - $sql.= (! empty($scandir)?"'".$db->escape($scandir)."'":"null"); - $sql.= ")"; - $resql=$db->query($sql); + $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { - $value = GETPOST('value','alpha'); - - $type='donation'; - $sql = "DELETE FROM ".MAIN_DB_PREFIX."document_model"; - $sql .= " WHERE nom = '".$value."' AND type = '".$type."'"; - $resql=$db->query($sql); + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->DON_ADDON_MODEL == "$value") dolibarr_del_const($db, 'DON_ADDON_MODEL',$conf->entity); + } } - /* * View */ @@ -147,6 +120,17 @@ llxHeader('',$langs->trans("DonationsSetup"),'DonConfiguration'); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("DonationsSetup"),$linkback,'setup'); +print '
'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/dons.php"; +$head[$h][1] = $langs->trans("Donations"); +$head[$h][2] = 'Donation'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); // Document templates diff --git a/htdocs/admin/ecm.php b/htdocs/admin/ecm.php index 908b36dbabb..45a142d8190 100644 --- a/htdocs/admin/ecm.php +++ b/htdocs/admin/ecm.php @@ -70,6 +70,17 @@ llxHeader('',$langs->trans("ECMSetup"),$help_url); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("ECMSetup"),$linkback,'setup'); +print '
'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/ecm.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print ''; print ''; diff --git a/htdocs/admin/fichinter.php b/htdocs/admin/fichinter.php index 708acf6bc86..023593ea2a7 100644 --- a/htdocs/admin/fichinter.php +++ b/htdocs/admin/fichinter.php @@ -6,7 +6,7 @@ * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2008 Raphael Bertrand (Resultic) * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2011-2013 Philippe Grand * * 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 @@ -67,42 +67,7 @@ if ($action == 'updateMask') } } -if ($action == 'set_FICHINTER_FREE_TEXT') -{ - $freetext= GETPOST('FICHINTER_FREE_TEXT','alpha'); - $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - $mesg = "".$langs->trans("SetupSaved").""; - } - else - { - $mesg = "".$langs->trans("Error").""; - } -} - -if ($action == 'set_FICHINTER_DRAFT_WATERMARK') -{ - $draft= GETPOST('FICHINTER_DRAFT_WATERMARK','alpha'); - - $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; - - if (! $error) - { - $mesg = "".$langs->trans("SetupSaved").""; - } - else - { - $mesg = "".$langs->trans("Error").""; - } -} - -if ($action == 'specimen') +else if ($action == 'specimen') // For fiche inter { $modele= GETPOST('module','alpha'); @@ -147,12 +112,13 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) @@ -161,7 +127,8 @@ if ($action == 'del') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { if (dolibarr_set_const($db, "FICHEINTER_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { @@ -178,7 +145,7 @@ if ($action == 'setdoc') } } -if ($action == 'setmod') +else if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -186,6 +153,41 @@ if ($action == 'setmod') dolibarr_set_const($db, "FICHEINTER_ADDON",$value,'chaine',0,'',$conf->entity); } +else if ($action == 'set_FICHINTER_FREE_TEXT') +{ + $freetext= GETPOST('FICHINTER_FREE_TEXT','alpha'); + $res = dolibarr_set_const($db, "FICHINTER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } +} + +else if ($action == 'set_FICHINTER_DRAFT_WATERMARK') +{ + $draft= GETPOST('FICHINTER_DRAFT_WATERMARK','alpha'); + + $res = dolibarr_set_const($db, "FICHINTER_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + $mesg = "".$langs->trans("SetupSaved").""; + } + else + { + $mesg = "".$langs->trans("Error").""; + } +} + /* * View @@ -202,6 +204,17 @@ print_fiche_titre($langs->trans("InterventionsSetup"),$linkback,'setup'); print "
"; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/fichinter.php"; +$head[$h][1] = $langs->trans("Interventions"); +$head[$h][2] = 'Ficheinter'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +// Interventions numbering model print_titre($langs->trans("FicheinterNumberingModules")); @@ -234,22 +247,22 @@ foreach ($dirmodels as $reldir) $file = $reg[1]; $classname = substr($file,4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/fichinter/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; - - // Show modules according to features level - if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; - if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; - + if ($module->isEnabled()) { + // Show modules according to features level + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) continue; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) continue; + $var=!$var; print '
'; - // Show example of numbering module + // Show example of numbering model print '
'.$module->nom."\n"; print $module->info(); print ''; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; @@ -295,6 +308,9 @@ foreach ($dirmodels as $reldir) print '

'; +/* + * Documents models for Interventions + */ print_titre($langs->trans("TemplatePDFInterventions")); @@ -377,7 +393,7 @@ foreach ($dirmodels as $reldir) print "
"; if ($conf->global->FICHEINTER_ADDON_PDF == "$name") { @@ -413,11 +429,14 @@ foreach ($dirmodels as $reldir) } print '
'; - -//Autres Options print "
"; -print_titre($langs->trans("OtherOptions")); +/* + * Other options + * + */ + +print_titre($langs->trans("OtherOptions")); print ''; print ''; print ''; diff --git a/htdocs/admin/mailing.php b/htdocs/admin/mailing.php index ea5c9b7bbb4..87252252d65 100644 --- a/htdocs/admin/mailing.php +++ b/htdocs/admin/mailing.php @@ -103,6 +103,16 @@ llxHeader('',$langs->trans("MailingSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("MailingSetup"),$linkback,'setup'); +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/mailing.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + dol_htmloutput_mesg($mesg); 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 ''; - } +// } print '
'.$langs->trans("Parameter").'
'.$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 '
'; @@ -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/admin/prelevement.php b/htdocs/admin/prelevement.php index f5dfb2bc8fb..2e21c3cfb4c 100644 --- a/htdocs/admin/prelevement.php +++ b/htdocs/admin/prelevement.php @@ -117,6 +117,17 @@ llxHeader('',$langs->trans("WithdrawalsSetup")); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("WithdrawalsSetup"),$linkback,'setup'); +print '
'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/prelevement.php"; +$head[$h][1] = $langs->trans("Withdrawals"); +$head[$h][2] = 'Withdrawal'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print ''; print ''; diff --git a/htdocs/admin/project.php b/htdocs/admin/project.php index 8ea4910541c..f2f216d7b52 100644 --- a/htdocs/admin/project.php +++ b/htdocs/admin/project.php @@ -2,7 +2,7 @@ /* Copyright (C) 2010 Regis Houssin * Copyright (C) 2011 Laurent Destailleur * Copyright (C) 2011-2012 Juanjo Menent - * Copyright (C) 2011-2012 Philippe Grand + * Copyright (C) 2011-2013 Philippe Grand * * 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 @@ -66,7 +66,7 @@ if ($action == 'updateMask') } } -if ($action == 'specimen') +else if ($action == 'specimen') { $modele=GETPOST('module','alpha'); @@ -111,12 +111,13 @@ if ($action == 'specimen') } } -if ($action == 'set') +// Activate a model +else if ($action == 'set') { $ret = addDocumentModel($value, $type, $label, $scandir); } -if ($action == 'del') +else if ($action == 'del') { $ret = delDocumentModel($value, $type); if ($ret > 0) @@ -125,7 +126,8 @@ if ($action == 'del') } } -if ($action == 'setdoc') +// Set default model +else if ($action == 'setdoc') { if (dolibarr_set_const($db, "PROJECT_ADDON_PDF",$value,'chaine',0,'',$conf->entity)) { @@ -142,7 +144,7 @@ if ($action == 'setdoc') } } -if ($action == 'setmod') +else if ($action == 'setmod') { // TODO Verifier si module numerotation choisi peut etre active // par appel methode canBeActivated @@ -156,7 +158,7 @@ if ($action == 'setmod') $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); -llxHeader(); +llxHeader("",$langs->trans("ProjectsSetup")); $form=new Form($db); @@ -165,8 +167,20 @@ print_fiche_titre($langs->trans("ProjectsSetup"),$linkback,'setup'); print "
"; +$h = 0; -// Project numbering module +$head[$h][0] = DOL_URL_ROOT."/admin/project.php"; +$head[$h][1] = $langs->trans("Projects"); +$head[$h][2] = 'Project'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + +/* + * Projects Numbering model + */ + print_titre($langs->trans("ProjectsNumberingModules")); print ''; @@ -198,7 +212,7 @@ foreach ($dirmodels as $reldir) $file = $reg[1]; $classname = substr($file,4); - require_once DOL_DOCUMENT_ROOT ."/core/modules/project/".$file.'.php'; + require_once $dir.$file.'.php'; $module = new $file; @@ -213,7 +227,7 @@ foreach ($dirmodels as $reldir) print $module->info(); print ''; - // Show example of numbering module + // Show example of numbering model print '
'; $tmp=$module->getExample(); if (preg_match('/^Error/',$tmp)) print '
'.$langs->trans($tmp).'
'; @@ -269,7 +283,7 @@ print '

'; /* - * Modeles documents for projects + * Document templates generators */ print_titre($langs->trans("ProjectsModelModule")); @@ -352,7 +366,7 @@ foreach ($dirmodels as $reldir) print ""; } - // Defaut + // Default print ""; if ($conf->global->PROJECT_ADDON_PDF == "$name") { diff --git a/htdocs/admin/stock.php b/htdocs/admin/stock.php index 1f40461ca0f..ba28ea15635 100644 --- a/htdocs/admin/stock.php +++ b/htdocs/admin/stock.php @@ -3,6 +3,7 @@ * Copyright (C) 2008-2010 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * Copyright (C) 2012 Juanjo Menent + * Copyright (C) 2013 Philippe Grand * * 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 @@ -97,6 +98,16 @@ $linkback=''.$langs->trans("BackToM print_fiche_titre($langs->trans("StockSetup"),$linkback,'setup'); print '
'; +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/stock.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); + $form=new Form($db); $var=true; print ''; @@ -124,9 +135,12 @@ print '' print ''; print "\n"; print "\n"; - +print '
'; +print '
'; +print '
'; // Title rule for stock decrease +print ''; print ''; print " \n"; print " \n"; @@ -174,9 +188,11 @@ if (! empty($conf->expedition->enabled)) print ''; print "\n\n\n"; } - +print '
".$langs->trans("RuleForStockManagementDecrease")." 
'; +print '
'; // Title rule for stock increase +print ''; print ''; print " \n"; print " \n"; diff --git a/htdocs/admin/taxes.php b/htdocs/admin/taxes.php index bf5e0db26a6..8e547bd4e21 100644 --- a/htdocs/admin/taxes.php +++ b/htdocs/admin/taxes.php @@ -121,6 +121,17 @@ $form=new Form($db); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans('TaxSetup'),$linkback,'setup'); +print '
'; + +$h = 0; + +$head[$h][0] = DOL_URL_ROOT."/admin/taxes.php"; +$head[$h][1] = $langs->trans("Miscellanous"); +$head[$h][2] = 'general'; +$hselected=$h; +$h++; + +dol_fiche_head($head, $hselected, $langs->trans("ModuleSetup")); print '
'; diff --git a/htdocs/comm/action/fiche.php b/htdocs/comm/action/fiche.php index c7ac95111b1..07a6647f4bb 100644 --- a/htdocs/comm/action/fiche.php +++ b/htdocs/comm/action/fiche.php @@ -575,7 +575,7 @@ if ($action == 'create') $numproject=select_projects((! empty($societe->id)?$societe->id:0),GETPOST("projectid")?GETPOST("projectid"):'','projectid'); if ($numproject==0) { - print '   '.$langs->trans("AddProject").''; + print '   '.$langs->trans("AddProject").''; } print ''; } diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index eb4278cb528..b74ebd11938 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -1,747 +1,747 @@ - - * Copyright (C) 2004-2013 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005 Marc Barilley / Ocebo - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2010-2013 Juanjo Menent - * Copyright (C) 2010-2011 Philippe Grand - * Copyright (C) 2012 Christophe Battarel -* - * 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/comm/propal.php - * \ingroup propale - * \brief Page of commercial proposals card and list - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; -require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; -if (! empty($conf->projet->enabled)) -{ - require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; - require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; -} - -$langs->load('companies'); -$langs->load('propal'); -$langs->load('compta'); -$langs->load('bills'); -$langs->load('orders'); -$langs->load('products'); -$langs->load("deliveries"); -if (! empty($conf->margin->enabled)) - $langs->load('margins'); - -$error=0; - -$id=GETPOST('id','int'); -$ref=GETPOST('ref','alpha'); -$socid=GETPOST('socid','int'); -$action=GETPOST('action','alpha'); -$origin=GETPOST('origin','alpha'); -$originid=GETPOST('originid','int'); -$confirm=GETPOST('confirm','alpha'); -$lineid=GETPOST('lineid','int'); - -//PDF -$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); -$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); -$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); - -// Nombre de ligne pour choix de produit/service predefinis -$NBLINES=4; - -// Security check -if (! empty($user->societe_id)) $socid=$user->societe_id; -$result = restrictedArea($user, 'propal', $id); - -$object = new Propal($db); -$extrafields = new ExtraFields($db); - -// Load object -if ($id > 0 || ! empty($ref)) -{ - $ret=$object->fetch($id, $ref); - if ($ret > 0) $ret=$object->fetch_thirdparty(); - if ($ret < 0) dol_print_error('',$object->error); -} - -// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array -$hookmanager->initHooks(array('propalcard')); - - - -/* - * Actions - */ - -$parameters=array('socid'=>$socid); -$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - -// Action clone object -if ($action == 'confirm_clone' && $confirm == 'yes') -{ - if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) - { - setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); - } - else - { - if ($object->id > 0) - { - $result=$object->createFromClone($socid); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); - exit; - } - else - { - setEventMessage($object->error, 'errors'); - $action=''; - } - } - } -} - -// Suppression de la propale -else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) -{ - $result=$object->delete($user); - if ($result > 0) - { - header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); - exit; - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -// Remove line -else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) -{ - $result = $object->deleteline($lineid); - // reorder lines - if ($result) $object->line_order(true); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; -} - -// Validation -else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) -{ - $result=$object->valid($user); - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - } - else - { - $langs->load("errors"); - setEventMessage($langs->trans($object->error), 'errors'); - } -} - -else if ($action == 'setdate' && $user->rights->propal->creer) -{ - $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); - - if (empty($datep)) - { - $error++; - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); - } - - if (! $error) - { - $result=$object->set_date($user,$datep); - if ($result < 0) dol_print_error($db,$object->error); - } -} -else if ($action == 'setecheance' && $user->rights->propal->creer) -{ - $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); - if ($result < 0) dol_print_error($db,$object->error); -} -else if ($action == 'setdate_livraison' && $user->rights->propal->creer) -{ - $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); - if ($result < 0) dol_print_error($db,$object->error); -} - -// Positionne ref client -else if ($action == 'set_ref_client' && $user->rights->propal->creer) -{ - $object->set_ref_client($user, $_POST['ref_client']); -} - -else if ($action == 'setnote_public' && $user->rights->propal->creer) -{ - $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -else if ($action == 'setnote' && $user->rights->propal->creer) -{ - $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); - if ($result < 0) dol_print_error($db,$object->error); -} - -// Create proposal -else if ($action == 'add' && $user->rights->propal->creer) -{ - $object->socid=$socid; - $object->fetch_thirdparty(); - - $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); - $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); - $duration=GETPOST('duree_validite'); - - if (empty($datep)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); - $action='create'; - $error++; - } - if (empty($duration)) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); - $action='create'; - $error++; - } - - if ($socid<1) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); - $action='create'; - $error++; - } - - if (! $error) - { - $db->begin(); - - // Si on a selectionne une propal a copier, on realise la copie - if (GETPOST('createmode')=='copy' && GETPOST('copie_propal')) - { - if ($object->fetch(GETPOST('copie_propal')) > 0) - { - $object->ref = GETPOST('ref'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = $duration; - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - $object->remise_percent = GETPOST('remise_percent'); - $object->remise_absolue = GETPOST('remise_absolue'); - $object->socid = GETPOST('socid'); - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - $object->statut = 0; - - $id = $object->create_from($user); - } - else - { - setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors'); - } - } - else - { - $object->ref = GETPOST('ref'); - $object->ref_client = GETPOST('ref_client'); - $object->datep = $datep; - $object->date_livraison = $date_delivery; - $object->availability_id = GETPOST('availability_id'); - $object->demand_reason_id = GETPOST('demand_reason_id'); - $object->fk_delivery_address = GETPOST('fk_address'); - $object->duree_validite = GETPOST('duree_validite'); - $object->cond_reglement_id = GETPOST('cond_reglement_id'); - $object->mode_reglement_id = GETPOST('mode_reglement_id'); - - $object->contactid = GETPOST('contactidp'); - $object->fk_project = GETPOST('projectid'); - $object->modelpdf = GETPOST('model'); - $object->author = $user->id; // deprecated - $object->note = GETPOST('note'); - - $object->origin = GETPOST('origin'); - $object->origin_id = GETPOST('originid'); - - for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) - { - if ($_POST['idprod'.$i]) - { - $xid = 'idprod'.$i; - $xqty = 'qty'.$i; - $xremise = 'remise'.$i; - $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); - } - } - - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=GETPOST($key); - } - } - - $id = $object->create($user); - } - - if ($id > 0) - { - // Insertion contact par defaut si defini - if (GETPOST('contactidp')) - { - $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); - if ($result < 0) - { - $error++; - setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); - } - } - - if (! $error) - { - $db->commit(); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); - exit; - } - else - { - $db->rollback(); - } - } - else - { - dol_print_error($db,$object->error); - $db->rollback(); - exit; - } - } -} - -// Classify billed -else if ($action == 'classifybilled' && $user->rights->propal->cloturer) -{ - $object->cloture($user, 4, ''); -} - -// Reopen proposal -else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) -{ - // prevent browser refresh from reopening proposal several times - if ($object->statut==2 || $object->statut==3) - { - $object->setStatut(1); - } -} - -// Close proposal -else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) -{ - if (! GETPOST('statut')) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors'); - $action='statut'; - } - else - { - // prevent browser refresh from closing proposal several times - if ($object->statut==1) - { - $object->cloture($user, GETPOST('statut'), GETPOST('note')); - } - } -} - -/* - * Add file in email form - */ -if (GETPOST('addfile')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory TODO Use a dedicated directory for temp mails files - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - dol_add_file_process($upload_dir_tmp,0,0); - $action='presend'; -} - -/* - * Remove file in email form - */ -if (GETPOST('removedfile')) -{ - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - // Set tmp user directory - $vardir=$conf->user->dir_output."/".$user->id; - $upload_dir_tmp = $vardir.'/temp'; - - // TODO Delete only files that was uploaded from email form - dol_remove_file_process($_POST['removedfile'],0); - $action='presend'; -} - -/* - * Send mail - */ -if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) -{ - $langs->load('mails'); - - if ($object->id > 0) - { - if ($_POST['sendto']) - { - // Le destinataire a ete fourni via le champ libre - $sendto = $_POST['sendto']; - $sendtoid = 0; - } - elseif ($_POST['receiver'] != '-1') - { - // Recipient was provided from combo list - if ($_POST['receiver'] == 'thirdparty') // Id of third party - { - $sendto = $object->client->email; - $sendtoid = 0; - } - else // Id du contact - { - $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); - $sendtoid = $_POST['receiver']; - } - } - - if (dol_strlen($sendto)) - { - $langs->load("commercial"); - - $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; - $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; - $message = $_POST['message']; - $sendtocc = $_POST['sendtocc']; - $deliveryreceipt = $_POST['deliveryreceipt']; - - if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; - else $subject = $langs->transnoentities('Propal').' '.$object->ref; - $actiontypecode='AC_PROP'; - $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; - if ($message) - { - $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; - $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; - $actionmsg.=$message; - } - $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - - $attachedfiles=$formmail->get_attached_files(); - $filepath = $attachedfiles['paths']; - $filename = $attachedfiles['names']; - $mimetype = $attachedfiles['mimes']; - - // Envoi de la propal - require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; - $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); - if ($mailfile->error) - { - setEventMessage($mailfile->error, 'errors'); - } - else - { - $result=$mailfile->sendfile(); - if ($result) - { - // Initialisation donnees - $object->sendtoid = $sendtoid; - $object->actiontypecode = $actiontypecode; - $object->actionmsg = $actionmsg; - $object->actionmsg2 = $actionmsg2; - $object->fk_element = $object->id; - $object->elementtype = $object->element; - - // Appel des triggers - include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; - $interface=new Interfaces($db); - $result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf); - if ($result < 0) { - $error++; $this->errors=$interface->errors; - } - // Fin appel triggers - - if (! $error) - { - // Redirect here - // This avoid sending mail twice if going out and then back to page - $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); - setEventMessage($mesg); - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); - exit; - } - else - { - dol_print_error($db); - } - } - else - { - $langs->load("other"); - if ($mailfile->error) - { - $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); - $mesg.='
'.$mailfile->error; - } - else - { - $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; - } - setEventMessage($mesg, 'errors'); - } - } - } - else - { - $langs->load("other"); - setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors'); - dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); - } - } - else - { - $langs->load("other"); - setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors'); - dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal"))); - } -} - -// Go back to draft -if ($action == 'modif' && $user->rights->propal->creer) -{ - $object->set_draft($user); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } -} - -else if ($action == "setabsolutediscount" && $user->rights->propal->creer) -{ - if ($_POST["remise_id"]) - { - if ($object->id > 0) - { - $result=$object->insert_discount($_POST["remise_id"]); - if ($result < 0) - { - setEventMessage($object->error, 'errors'); - } - } - } -} - -//Ajout d'une ligne produit dans la propale -else if ($action == "addline" && $user->rights->propal->creer) -{ - $idprod=GETPOST('idprod', 'int'); - $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); - $price_ht = GETPOST('price_ht'); - $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); - - if (empty($idprod) && GETPOST('type') < 0) - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); - $error++; - } - if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht != 0) || $price_ht == '')) // Unit price can be 0 but not ''. Also price can be negative for proposal. - { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); - $error++; - } - if (empty($idprod) && empty($product_desc)) - { - setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); - $error++; - } - - if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) - { - $pu_ht=0; - $pu_ttc=0; - $price_min=0; - $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); - - // Ecrase $pu par celui du produit - // Ecrase $desc par celui du produit - // Ecrase $txtva par celui du produit - if (! empty($idprod)) - { - $prod = new Product($db); - $prod->fetch($idprod); - - $label = ((GETPOST('product_label') && GETPOST('product_label')!=$prod->label)?GETPOST('product_label'):''); - - // If prices fields are update - if (GETPOST('usenewaddlineform')) - { - $pu_ht=price2num($price_ht, 'MU'); - $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); - $tva_tx=str_replace('*','', $tva_tx); - $desc = $product_desc; - } - else - { - $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); - $tva_npr = get_default_npr($mysoc,$object->client,$prod->id); - - // On defini prix unitaire - if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) - { - $pu_ht = $prod->multiprices[$object->client->price_level]; - $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; - $price_min = $prod->multiprices_min[$object->client->price_level]; - $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; - } - else - { - $pu_ht = $prod->price; - $pu_ttc = $prod->price_ttc; - $price_min = $prod->price_min; - $price_base_type = $prod->price_base_type; - } - - // On reevalue prix selon taux tva car taux tva transaction peut etre different - // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). - if ($tva_tx != $prod->tva_tx) - { - if ($price_base_type != 'HT') - { - $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); - } - else - { - $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); - } - } - - $desc=''; - - // Define output language - if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) - { - $outputlangs = $langs; - $newlang=''; - if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); - if (empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; - } - else - { - $desc = $prod->description; - } - - $desc=dol_concatdesc($desc,$product_desc); - + + * Copyright (C) 2004-2013 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005 Marc Barilley / Ocebo + * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2010-2013 Juanjo Menent + * Copyright (C) 2010-2011 Philippe Grand + * Copyright (C) 2012 Christophe Battarel +* + * 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/comm/propal.php + * \ingroup propale + * \brief Page of commercial proposals card and list + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formpropal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/modules/propale/modules_propale.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/propal.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php'; +if (! empty($conf->projet->enabled)) +{ + require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php'; + require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php'; +} + +$langs->load('companies'); +$langs->load('propal'); +$langs->load('compta'); +$langs->load('bills'); +$langs->load('orders'); +$langs->load('products'); +$langs->load("deliveries"); +if (! empty($conf->margin->enabled)) + $langs->load('margins'); + +$error=0; + +$id=GETPOST('id','int'); +$ref=GETPOST('ref','alpha'); +$socid=GETPOST('socid','int'); +$action=GETPOST('action','alpha'); +$origin=GETPOST('origin','alpha'); +$originid=GETPOST('originid','int'); +$confirm=GETPOST('confirm','alpha'); +$lineid=GETPOST('lineid','int'); + +//PDF +$hidedetails = (GETPOST('hidedetails','int') ? GETPOST('hidedetails','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 1 : 0)); +$hidedesc = (GETPOST('hidedesc','int') ? GETPOST('hidedesc','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 1 : 0)); +$hideref = (GETPOST('hideref','int') ? GETPOST('hideref','int') : (! empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 1 : 0)); + +// Nombre de ligne pour choix de produit/service predefinis +$NBLINES=4; + +// Security check +if (! empty($user->societe_id)) $socid=$user->societe_id; +$result = restrictedArea($user, 'propal', $id); + +$object = new Propal($db); +$extrafields = new ExtraFields($db); + +// Load object +if ($id > 0 || ! empty($ref)) +{ + $ret=$object->fetch($id, $ref); + if ($ret > 0) $ret=$object->fetch_thirdparty(); + if ($ret < 0) dol_print_error('',$object->error); +} + +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('propalcard')); + + + +/* + * Actions + */ + +$parameters=array('socid'=>$socid); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + +// Action clone object +if ($action == 'confirm_clone' && $confirm == 'yes') +{ + if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers')) + { + setEventMessage($langs->trans("NoCloneOptionsSpecified"), 'errors'); + } + else + { + if ($object->id > 0) + { + $result=$object->createFromClone($socid); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); + exit; + } + else + { + setEventMessage($object->error, 'errors'); + $action=''; + } + } + } +} + +// Suppression de la propale +else if ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->propal->supprimer) +{ + $result=$object->delete($user); + if ($result > 0) + { + header('Location: '.DOL_URL_ROOT.'/comm/propal/list.php'); + exit; + } + else + { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); + } +} + +// Remove line +else if ($action == 'confirm_deleteline' && $confirm == 'yes' && $user->rights->propal->creer) +{ + $result = $object->deleteline($lineid); + // reorder lines + if ($result) $object->line_order(true); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; +} + +// Validation +else if ($action == 'confirm_validate' && $confirm == 'yes' && $user->rights->propal->valider) +{ + $result=$object->valid($user); + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + } + else + { + $langs->load("errors"); + setEventMessage($langs->trans($object->error), 'errors'); + } +} + +else if ($action == 'setdate' && $user->rights->propal->creer) +{ + $datep=dol_mktime(12, 0, 0, $_POST['remonth'], $_POST['reday'], $_POST['reyear']); + + if (empty($datep)) + { + $error++; + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); + } + + if (! $error) + { + $result=$object->set_date($user,$datep); + if ($result < 0) dol_print_error($db,$object->error); + } +} +else if ($action == 'setecheance' && $user->rights->propal->creer) +{ + $result=$object->set_echeance($user,dol_mktime(12, 0, 0, $_POST['echmonth'], $_POST['echday'], $_POST['echyear'])); + if ($result < 0) dol_print_error($db,$object->error); +} +else if ($action == 'setdate_livraison' && $user->rights->propal->creer) +{ + $result=$object->set_date_livraison($user,dol_mktime(12, 0, 0, $_POST['liv_month'], $_POST['liv_day'], $_POST['liv_year'])); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Positionne ref client +else if ($action == 'set_ref_client' && $user->rights->propal->creer) +{ + $object->set_ref_client($user, $_POST['ref_client']); +} + +else if ($action == 'setnote_public' && $user->rights->propal->creer) +{ + $result=$object->update_note_public(dol_html_entity_decode(GETPOST('note_public'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +else if ($action == 'setnote' && $user->rights->propal->creer) +{ + $result=$object->update_note(dol_html_entity_decode(GETPOST('note'), ENT_QUOTES)); + if ($result < 0) dol_print_error($db,$object->error); +} + +// Create proposal +else if ($action == 'add' && $user->rights->propal->creer) +{ + $object->socid=$socid; + $object->fetch_thirdparty(); + + $datep=dol_mktime(12, 0, 0, GETPOST('remonth'), GETPOST('reday'), GETPOST('reyear')); + $date_delivery=dol_mktime(12, 0, 0, GETPOST('liv_month'), GETPOST('liv_day'), GETPOST('liv_year')); + $duration=GETPOST('duree_validite'); + + if (empty($datep)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Date")), 'errors'); + $action='create'; + $error++; + } + if (empty($duration)) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("ValidityDuration")), 'errors'); + $action='create'; + $error++; + } + + if ($socid<1) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Customer")),'errors'); + $action='create'; + $error++; + } + + if (! $error) + { + $db->begin(); + + // Si on a selectionne une propal a copier, on realise la copie + if (GETPOST('createmode')=='copy' && GETPOST('copie_propal')) + { + if ($object->fetch(GETPOST('copie_propal')) > 0) + { + $object->ref = GETPOST('ref'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = $duration; + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + $object->remise_percent = GETPOST('remise_percent'); + $object->remise_absolue = GETPOST('remise_absolue'); + $object->socid = GETPOST('socid'); + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + $object->statut = 0; + + $id = $object->create_from($user); + } + else + { + setEventMessage($langs->trans("ErrorFailedToCopyProposal",GETPOST('copie_propal')), 'errors'); + } + } + else + { + $object->ref = GETPOST('ref'); + $object->ref_client = GETPOST('ref_client'); + $object->datep = $datep; + $object->date_livraison = $date_delivery; + $object->availability_id = GETPOST('availability_id'); + $object->demand_reason_id = GETPOST('demand_reason_id'); + $object->fk_delivery_address = GETPOST('fk_address'); + $object->duree_validite = GETPOST('duree_validite'); + $object->cond_reglement_id = GETPOST('cond_reglement_id'); + $object->mode_reglement_id = GETPOST('mode_reglement_id'); + + $object->contactid = GETPOST('contactidp'); + $object->fk_project = GETPOST('projectid'); + $object->modelpdf = GETPOST('model'); + $object->author = $user->id; // deprecated + $object->note = GETPOST('note'); + + $object->origin = GETPOST('origin'); + $object->origin_id = GETPOST('originid'); + + for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) + { + if ($_POST['idprod'.$i]) + { + $xid = 'idprod'.$i; + $xqty = 'qty'.$i; + $xremise = 'remise'.$i; + $object->add_product($_POST[$xid],$_POST[$xqty],$_POST[$xremise]); + } + } + + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=GETPOST($key); + } + } + + $id = $object->create($user); + } + + if ($id > 0) + { + // Insertion contact par defaut si defini + if (GETPOST('contactidp')) + { + $result=$object->add_contact(GETPOST('contactidp'),'CUSTOMER','external'); + if ($result < 0) + { + $error++; + setEventMessage($langs->trans("ErrorFailedToAddContact"), 'errors'); + } + } + + if (! $error) + { + $db->commit(); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id); + exit; + } + else + { + $db->rollback(); + } + } + else + { + dol_print_error($db,$object->error); + $db->rollback(); + exit; + } + } +} + +// Classify billed +else if ($action == 'classifybilled' && $user->rights->propal->cloturer) +{ + $object->cloture($user, 4, ''); +} + +// Reopen proposal +else if ($action == 'confirm_reopen' && $user->rights->propal->cloturer && ! GETPOST('cancel')) +{ + // prevent browser refresh from reopening proposal several times + if ($object->statut==2 || $object->statut==3) + { + $object->setStatut(1); + } +} + +// Close proposal +else if ($action == 'setstatut' && $user->rights->propal->cloturer && ! GETPOST('cancel')) +{ + if (! GETPOST('statut')) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("CloseAs")), 'errors'); + $action='statut'; + } + else + { + // prevent browser refresh from closing proposal several times + if ($object->statut==1) + { + $object->cloture($user, GETPOST('statut'), GETPOST('note')); + } + } +} + +/* + * Add file in email form + */ +if (GETPOST('addfile')) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory TODO Use a dedicated directory for temp mails files + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + dol_add_file_process($upload_dir_tmp,0,0); + $action='presend'; +} + +/* + * Remove file in email form + */ +if (GETPOST('removedfile')) +{ + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + // Set tmp user directory + $vardir=$conf->user->dir_output."/".$user->id; + $upload_dir_tmp = $vardir.'/temp'; + + // TODO Delete only files that was uploaded from email form + dol_remove_file_process($_POST['removedfile'],0); + $action='presend'; +} + +/* + * Send mail + */ +if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! GETPOST('cancel')) +{ + $langs->load('mails'); + + if ($object->id > 0) + { + if ($_POST['sendto']) + { + // Le destinataire a ete fourni via le champ libre + $sendto = $_POST['sendto']; + $sendtoid = 0; + } + elseif ($_POST['receiver'] != '-1') + { + // Recipient was provided from combo list + if ($_POST['receiver'] == 'thirdparty') // Id of third party + { + $sendto = $object->client->email; + $sendtoid = 0; + } + else // Id du contact + { + $sendto = $object->client->contact_get_property($_POST['receiver'],'email'); + $sendtoid = $_POST['receiver']; + } + } + + if (dol_strlen($sendto)) + { + $langs->load("commercial"); + + $from = $_POST['fromname'] . ' <' . $_POST['frommail'] .'>'; + $replyto = $_POST['replytoname']. ' <' . $_POST['replytomail'].'>'; + $message = $_POST['message']; + $sendtocc = $_POST['sendtocc']; + $deliveryreceipt = $_POST['deliveryreceipt']; + + if (dol_strlen($_POST['subject'])) $subject = $_POST['subject']; + else $subject = $langs->transnoentities('Propal').' '.$object->ref; + $actiontypecode='AC_PROP'; + $actionmsg = $langs->transnoentities('MailSentBy').' '.$from.' '.$langs->transnoentities('To').' '.$sendto.".\n"; + if ($message) + { + $actionmsg.=$langs->transnoentities('MailTopic').": ".$subject."\n"; + $actionmsg.=$langs->transnoentities('TextUsedInTheMessageBody').":\n"; + $actionmsg.=$message; + } + $actionmsg2=$langs->transnoentities('Action'.$actiontypecode); + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + + $attachedfiles=$formmail->get_attached_files(); + $filepath = $attachedfiles['paths']; + $filename = $attachedfiles['names']; + $mimetype = $attachedfiles['mimes']; + + // Envoi de la propal + require_once DOL_DOCUMENT_ROOT.'/core/class/CMailFile.class.php'; + $mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc,'',$deliveryreceipt); + if ($mailfile->error) + { + setEventMessage($mailfile->error, 'errors'); + } + else + { + $result=$mailfile->sendfile(); + if ($result) + { + // Initialisation donnees + $object->sendtoid = $sendtoid; + $object->actiontypecode = $actiontypecode; + $object->actionmsg = $actionmsg; + $object->actionmsg2 = $actionmsg2; + $object->fk_element = $object->id; + $object->elementtype = $object->element; + + // Appel des triggers + include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; + $interface=new Interfaces($db); + $result=$interface->run_triggers('PROPAL_SENTBYMAIL',$object,$user,$langs,$conf); + if ($result < 0) { + $error++; $this->errors=$interface->errors; + } + // Fin appel triggers + + if (! $error) + { + // Redirect here + // This avoid sending mail twice if going out and then back to page + $mesg=$langs->trans('MailSuccessfulySent',$mailfile->getValidAddress($from,2),$mailfile->getValidAddress($sendto,2)); + setEventMessage($mesg); + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id); + exit; + } + else + { + dol_print_error($db); + } + } + else + { + $langs->load("other"); + if ($mailfile->error) + { + $mesg.=$langs->trans('ErrorFailedToSendMail',$from,$sendto); + $mesg.='
'.$mailfile->error; + } + else + { + $mesg.='No mail sent. Feature is disabled by option MAIN_DISABLE_ALL_MAILS'; + } + setEventMessage($mesg, 'errors'); + } + } + } + else + { + $langs->load("other"); + setEventMessage($langs->trans('ErrorMailRecipientIsEmpty').'!', 'errors'); + dol_syslog($langs->trans('ErrorMailRecipientIsEmpty')); + } + } + else + { + $langs->load("other"); + setEventMessage($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal")), 'errors'); + dol_syslog($langs->trans('ErrorFailedToReadEntity',$langs->trans("Proposal"))); + } +} + +// Go back to draft +if ($action == 'modif' && $user->rights->propal->creer) +{ + $object->set_draft($user); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } +} + +else if ($action == "setabsolutediscount" && $user->rights->propal->creer) +{ + if ($_POST["remise_id"]) + { + if ($object->id > 0) + { + $result=$object->insert_discount($_POST["remise_id"]); + if ($result < 0) + { + setEventMessage($object->error, 'errors'); + } + } + } +} + +//Ajout d'une ligne produit dans la propale +else if ($action == "addline" && $user->rights->propal->creer) +{ + $idprod=GETPOST('idprod', 'int'); + $product_desc = (GETPOST('product_desc')?GETPOST('product_desc'):(GETPOST('np_desc')?GETPOST('np_desc'):(GETPOST('dp_desc')?GETPOST('dp_desc'):''))); + $price_ht = GETPOST('price_ht'); + $tva_tx = (GETPOST('tva_tx')?GETPOST('tva_tx'):0); + + if (empty($idprod) && GETPOST('type') < 0) + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); + $error++; + } + if ((empty($idprod) || GETPOST('usenewaddlineform')) && (!($price_ht != 0) || $price_ht == '')) // Unit price can be 0 but not ''. Also price can be negative for proposal. + { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("UnitPriceHT")), 'errors'); + $error++; + } + if (empty($idprod) && empty($product_desc)) + { + setEventMessage($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Description")), 'errors'); + $error++; + } + + if (! $error && (GETPOST('qty') >= 0) && (! empty($product_desc) || ! empty($idprod))) + { + $pu_ht=0; + $pu_ttc=0; + $price_min=0; + $price_base_type = (GETPOST('price_base_type', 'alpha')?GETPOST('price_base_type', 'alpha'):'HT'); + + // Ecrase $pu par celui du produit + // Ecrase $desc par celui du produit + // Ecrase $txtva par celui du produit + if (! empty($idprod)) + { + $prod = new Product($db); + $prod->fetch($idprod); + + $label = ((GETPOST('product_label') && GETPOST('product_label')!=$prod->label)?GETPOST('product_label'):''); + + // If prices fields are update + if (GETPOST('usenewaddlineform')) + { + $pu_ht=price2num($price_ht, 'MU'); + $pu_ttc=price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr=(preg_match('/\*/', $tva_tx)?1:0); + $tva_tx=str_replace('*','', $tva_tx); + $desc = $product_desc; + } + else + { + $tva_tx = get_default_tva($mysoc,$object->client,$prod->id); + $tva_npr = get_default_npr($mysoc,$object->client,$prod->id); + + // On defini prix unitaire + if (! empty($conf->global->PRODUIT_MULTIPRICES) && $object->client->price_level) + { + $pu_ht = $prod->multiprices[$object->client->price_level]; + $pu_ttc = $prod->multiprices_ttc[$object->client->price_level]; + $price_min = $prod->multiprices_min[$object->client->price_level]; + $price_base_type = $prod->multiprices_base_type[$object->client->price_level]; + } + else + { + $pu_ht = $prod->price; + $pu_ttc = $prod->price_ttc; + $price_min = $prod->price_min; + $price_base_type = $prod->price_base_type; + } + + // On reevalue prix selon taux tva car taux tva transaction peut etre different + // de ceux du produit par defaut (par exemple si pays different entre vendeur et acheteur). + if ($tva_tx != $prod->tva_tx) + { + if ($price_base_type != 'HT') + { + $pu_ht = price2num($pu_ttc / (1 + ($tva_tx/100)), 'MU'); + } + else + { + $pu_ttc = price2num($pu_ht * (1 + ($tva_tx/100)), 'MU'); + } + } + + $desc=''; + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $desc = (! empty($prod->multilangs[$outputlangs->defaultlang]["description"])) ? $prod->multilangs[$outputlangs->defaultlang]["description"] : $prod->description; + } + else + { + $desc = $prod->description; + } + + $desc=dol_concatdesc($desc,$product_desc); + // Add custom code and origin country into description if (empty($conf->global->MAIN_PRODUCT_DISABLE_CUSTOMCOUNTRYCODE) && (! empty($prod->customcode) || ! empty($prod->country_code))) { @@ -752,1501 +752,1512 @@ else if ($action == "addline" && $user->rights->propal->creer) $tmptxt.=')'; $desc= dol_concatdesc($desc, $tmptxt); } - } - - $type = $prod->type; - } - else - { - $pu_ht = price2num($price_ht, 'MU'); - $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); - $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); - $tva_tx = str_replace('*', '', $tva_tx); - $label = (GETPOST('product_label')?GETPOST('product_label'):''); - $desc = $product_desc; - $type = GETPOST('type'); - } - - // Margin - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); - - // Local Taxes - $localtax1_tx= get_localtax($tva_tx, 1, $object->client); - $localtax2_tx= get_localtax($tva_tx, 2, $object->client); - - $info_bits=0; - if ($tva_npr) $info_bits |= 0x01; - - if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) - { - $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency)); - setEventMessage($mesg, 'errors'); - } - else - { - // Insert line - $result=$object->addline( - $id, - $desc, - $pu_ht, - GETPOST('qty'), - $tva_tx, - $localtax1_tx, - $localtax2_tx, - $idprod, - GETPOST('remise_percent'), - $price_base_type, - $pu_ttc, - $info_bits, - $type, - -1, - 0, - GETPOST('fk_parent_line'), - $fournprice, - $buyingprice, - $label - ); - - if ($result > 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['idprod']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - - // old method - unset($_POST['np_desc']); - unset($_POST['dp_desc']); - } - else - { - setEventMessage($object->error, 'errors'); - } - } - } -} - -// Mise a jour d'une ligne dans la propale -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) -{ - // Define info_bits - $info_bits=0; - if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; - - // Clean parameters - $description=dol_htmlcleanlastbr(GETPOST('product_desc')); - - // Define vat_rate - $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); - $vat_rate=str_replace('*','',$vat_rate); - $localtax1_rate=get_localtax($vat_rate,1,$object->client); - $localtax2_rate=get_localtax($vat_rate,2,$object->client); - $pu_ht=GETPOST('price_ht'); - - // Add buying price - $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); - $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); - - // Define special_code for special lines - $special_code=0; - if (! GETPOST('qty')) $special_code=3; - - // Check minimum price - $productid = GETPOST('productid', 'int'); - if (! empty($productid)) - { - $product = new Product($db); - $res=$product->fetch($productid); - - $type=$product->type; - - $price_min = $product->price_min; - if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) - $price_min = $product->multiprices_min[$object->client->price_level]; - - $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); - - if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) - { - setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors'); - $error++; - } - } - else - { - $type = GETPOST('type'); - $label = (GETPOST('product_label') ? GETPOST('product_label'):''); - - // Check parameters - if (GETPOST('type') < 0) { - setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); - $error++; - } - } - - if (! $error) - { - $result = $object->updateline( - GETPOST('lineid'), - $pu_ht, - GETPOST('qty'), - GETPOST('remise_percent'), - $vat_rate, - $localtax1_rate, - $localtax2_rate, - $description, - 'HT', - $info_bits, - $special_code, - GETPOST('fk_parent_line'), - 0, - $fournprice, - $buyingprice, - $label, - $type - ); - - if ($result >= 0) - { - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - unset($_POST['qty']); - unset($_POST['type']); - unset($_POST['productid']); - unset($_POST['remise_percent']); - unset($_POST['price_ht']); - unset($_POST['price_ttc']); - unset($_POST['tva_tx']); - unset($_POST['product_ref']); - unset($_POST['product_label']); - unset($_POST['product_desc']); - unset($_POST['fournprice']); - unset($_POST['buying_price']); - } - else - { - setEventMessage($object->error, 'errors'); - } - } -} - -else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) -{ - header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition - exit; -} - -// Generation doc (depuis lien ou depuis cartouche doc) -else if ($action == 'builddoc' && $user->rights->propal->creer) -{ - if (GETPOST('model')) - { - $object->setDocModel($user, GETPOST('model')); - } - - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - else - { - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); - exit; - } -} - -// Remove file in doc form -else if ($action == 'remove_file' && $user->rights->propal->creer) -{ - if ($object->id > 0) - { - require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - - $langs->load("other"); - $upload_dir = $conf->propal->dir_output; - $file = $upload_dir . '/' . GETPOST('file'); - $ret=dol_delete_file($file,0,0,0,$object); - if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); - else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); - } -} - -// Set project -else if ($action == 'classin' && $user->rights->propal->creer) -{ - $object->setProject($_POST['projectid']); -} - -// Delai de livraison -else if ($action == 'setavailability' && $user->rights->propal->creer) -{ - $result = $object->availability($_POST['availability_id']); -} - -// Origine de la propale -else if ($action == 'setdemandreason' && $user->rights->propal->creer) -{ - $result = $object->demand_reason($_POST['demand_reason_id']); -} - -// Conditions de reglement -else if ($action == 'setconditions' && $user->rights->propal->creer) -{ - $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); -} - -else if ($action == 'setremisepercent' && $user->rights->propal->creer) -{ - $result = $object->set_remise_percent($user, $_POST['remise_percent']); -} - -else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) -{ - $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); -} - -// Mode de reglement -else if ($action == 'setmode' && $user->rights->propal->creer) -{ - $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); -} - -/* - * Ordonnancement des lignes - */ - -else if ($action == 'up' && $user->rights->propal->creer) -{ - $object->line_up(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); - exit; -} - -else if ($action == 'down' && $user->rights->propal->creer) -{ - $object->line_down(GETPOST('rowid')); - - if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) - { - // Define output language - $outputlangs = $langs; - if (! empty($conf->global->MAIN_MULTILANGS)) - { - $outputlangs = new Translate("",$conf); - $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); - $outputlangs->setDefaultLang($newlang); - } - $ret=$object->fetch($id); // Reload to get new records - propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - } - - header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); - exit; -} -else if ($action == 'update_extras') -{ - // Get extra fields - foreach($_POST as $key => $value) - { - if (preg_match("/^options_/",$key)) - { - $object->array_options[$key]=$_POST[$key]; - } - } - // Actions on extra fields (by external module or standard code) - // FIXME le hook fait double emploi avec le trigger !! - $hookmanager->initHooks(array('propaldao')); - $parameters=array('id'=>$object->id); - $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks - if (empty($reshook)) - { - if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used - { - $result=$object->insertExtraFields(); - if ($result < 0) - { - $error++; - } - } - } - else if ($reshook < 0) $error++; - -} - -if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) -{ - if ($action == 'addcontact') - { - if ($object->id > 0) - { - $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); - $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); - } - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') - { - $langs->load("errors"); - setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); - } - else - { - setEventMessage($object->error, 'errors'); - } - } - } - - // Bascule du statut d'un contact - else if ($action == 'swapstatut') - { - if ($object->fetch($id) > 0) - { - $result=$object->swapContactStatus(GETPOST('ligne')); - } - else - { - dol_print_error($db); - } - } - - // Efface un contact - else if ($action == 'deletecontact') - { - $object->fetch($id); - $result = $object->delete_contact($lineid); - - if ($result >= 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else - { - dol_print_error($db); - } - } -} - - -/* - * View - */ - -llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); - -$form = new Form($db); -$formother = new FormOther($db); -$formfile = new FormFile($db); -$formpropal = new FormPropal($db); -$companystatic=new Societe($db); - -// fetch optionals attributes and labels -$extralabels=$extrafields->fetch_name_optionals_label('propal'); - -$now=dol_now(); - -// Add new proposal -if ($action == 'create') -{ - print_fiche_titre($langs->trans("NewProp")); - - $soc = new Societe($db); - if ($socid>0) $res=$soc->fetch($socid); - - $object = new Propal($db); - - print '
'; - print ''; - print ''; - - if ($origin != 'project' && $originid) - { - print ''; - print ''; - } - - print '
".$langs->trans("RuleForStockManagementIncrease")." 
'; - - // Reference - print ''; - - // Ref customer - print ''; - print ''; - - // Third party - print ''; - print ''; - if($socid>0) - { - print ''; - } - else - { - print ''; - } - print ''."\n"; - - // Contacts - if($socid>0) - { - print "'; - - // Ligne info remises tiers - print ''; - } - - // Date - print ''; - - // Validaty duration - print ''; - - // Terms of payment - print ''; - - // Mode of payment - print ''; - - // What trigger creation - print ''; - - // Delivery delay - print ''; - - // Delivery date (or manufacturing) - print ''; - print ''; - - // Model - print ''; - print ''; - print '"; - - // Project - if (! empty($conf->projet->enabled) && $socid>0) - { - $projectid = 0; - if ($origin == 'project') $projectid = ($originid?$originid:0); - - print ''; - print ''; - print ''; - } - - // Other attributes - $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - - // Show separator only - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''."\n"; - } - } - } - - print "
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; - print '
'.$langs->trans('Customer').''; - print $soc->getNomUrl(1); - print ''; - print ''; - print $form->select_company('','socid','s.client = 1 OR s.client = 2 OR s.client = 3',1); - print '
".$langs->trans("DefaultContact").''; - $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); - print '
'.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - $absolute_discount=$soc->getAvailableDiscounts(); - print '. '; - if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); - else print $langs->trans("CompanyHasNoAbsoluteDiscount"); - print '.'; - print '
'.$langs->trans('Date').''; - $form->select_date('','','','','',"addprop"); - print '
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans('PaymentConditionsShort').''; - $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); - print '
'.$langs->trans('PaymentMode').''; - $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); - print '
'.$langs->trans('Source').''; - $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1); - print '
'.$langs->trans('AvailabilityPeriod').''; - $form->select_availability('','availability_id','',1); - print '
'.$langs->trans("DeliveryDate").''; - if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") - { - $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); - $syear = date("Y", $tmpdte); - $smonth = date("m", $tmpdte); - $sday = date("d", $tmpdte); - $form->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); - } - else - { - $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; - $form->select_date($datepropal,'liv_','','','',"addprop"); - } - print '
'.$langs->trans("DefaultModel").''; - $liste=ModelePDFPropales::liste_modeles($db); - print $form->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); - print "
'.$langs->trans("Project").''; - - $numprojet=select_projects($soc->id,$projectid); - if ($numprojet==0) - { - print '   '.$langs->trans("AddProject").''; - } - print '
'; - print $extrafields->showInputField($key,$value); - print '
"; - print '
'; - - /* - * Combobox pour la fonction de copie - */ - - if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) - { - print ''; - } - - print ''; - if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) - { - // For backward compatibility - print ''; - print ''; - print ''; - print ''; - - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print ''; - - print ''; - print ''; - } - - if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) - { - print ''; - } - print '
'.$langs->trans("CopyPropalFrom").' '; - $liste_propal = array(); - $liste_propal[0] = ''; - - $sql ="SELECT p.rowid as id, p.ref, s.nom"; - $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; - $sql.= ", ".MAIN_DB_PREFIX."societe s"; - $sql.= " WHERE s.rowid = p.fk_soc"; - $sql.= " AND p.entity = ".$conf->entity; - $sql.= " AND p.fk_statut <> 0"; - $sql.= " ORDER BY Id"; - - $resql = $db->query($sql); - if ($resql) - { - $num = $db->num_rows($resql); - $i = 0; - while ($i < $num) - { - $row = $db->fetch_row($resql); - $propalRefAndSocName = $row[1]." - ".$row[2]; - $liste_propal[$row[0]]=$propalRefAndSocName; - $i++; - } - print $form->selectarray("copie_propal",$liste_propal, 0); - } - else - { - dol_print_error($db); - } - print '
 
'.$langs->trans("CreateEmptyPropal").'
'; - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - $lib=$langs->trans("ProductsAndServices"); - - print ''; - print ''; - print ''; - print ''; - print ''; - print ''; - for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) - { - print ''; - print ''; - print ''; - print ''; - } - - print "
'.$lib.''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'
'; - // multiprix - if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) - $form->select_produits('',"idprod".$i,'',$conf->product->limit_size,$soc->price_level); - else - $form->select_produits('',"idprod".$i,'',$conf->product->limit_size); - print '%
"; - - } - print '
'; - print '
'; - - $langs->load("bills"); - print '
'; - print ''; - print ' '; - print '
'; - - print ""; -} -else -{ - /* - * Show object in view mode - */ - - $soc = new Societe($db); - $soc->fetch($object->socid); - - $head = propal_prepare_head($object); - dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); - - $formconfirm=''; - - // Clone confirmation - if ($action == 'clone') - { - // Create an array for form - $formquestion=array( - //'text' => $langs->trans("ConfirmClone"), - //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), - //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), - array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=2 OR s.client=3)')) - ); - // Paiement incomplet. On demande si motif = escompte ou autre - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); - } - - // Confirm delete - else if ($action == 'delete') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); - } - - // Confirm reopen - else if ($action == 'reopen') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); - } - - // Confirmation delete product/service line - else if ($action == 'ask_deleteline') - { - $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); - } - - // Confirm validate proposal - else if ($action == 'validate') - { - $error=0; - - // on verifie si l'objet est en numerotation provisoire - $ref = substr($object->ref, 1, 4); - if ($ref == 'PROV') - { - $numref = $object->getNextNumRef($soc); - if (empty($numref)) - { - $error++; - dol_htmloutput_errors($object->error); - } - } - else - { - $numref = $object->ref; - } - - $text=$langs->trans('ConfirmValidateProp',$numref); - if (! empty($conf->notification->enabled)) - { - require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; - $notify=new Notify($db); - $text.='
'; - $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); - } - - if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); - } - - if (! $formconfirm) - { - $parameters=array('lineid'=>$lineid); - $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - - // Print form confirm - print $formconfirm; - - - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - - // Ref client - print ''; - print ''; - - // Company - print ''; - print ''; - - // Ligne info remises tiers - print ''; - - // Date of proposal - print ''; - print ''; - - // Date end proposal - print ''; - print ''; - print ''; - - // Payment term - print ''; - print ''; - - // Delivery date - $langs->load('deliveries'); - print ''; - print ''; - - // Delivery delay - print ''; - print ''; - - // Origin of demand - print ''; - print ''; - - // Payment mode - print ''; - print ''; - - // Project - if (! empty($conf->projet->enabled)) - { - $langs->load("projects"); - print ''; - } - else - { - print '
'.$langs->trans('Ref').''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); - print '
'; - print ''; - if ($action != 'refclient' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('RefCustomer').''; - print ''.img_edit($langs->trans('Modify')).'
'; - print '
'; - if ($user->rights->propal->creer && $action == 'refclient') - { - print '
'; - print ''; - print ''; - print ''; - print ' '; - print '
'; - } - else - { - print $object->ref_client; - } - print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Discounts').''; - if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); - else print $langs->trans("CompanyHasNoRelativeDiscount"); - print '. '; - $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); - $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); - $absolute_discount=price2num($absolute_discount,'MT'); - $absolute_creditnote=price2num($absolute_creditnote,'MT'); - if ($absolute_discount) - { - if ($object->statut > 0) - { - print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); - } - else - { - // Remise dispo de type non avoir - $filter='fk_facture_source IS NULL'; - print '
'; - $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); - } - } - if ($absolute_creditnote) - { - print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; - } - if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; - print '
'; - print ''; - if ($action != 'editdate' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('Date'); - print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; - print '
'; - if (! empty($object->brouillon) && $action == 'editdate') - { - print '
'; - print ''; - print ''; - $form->select_date($object->date,'re','','',0,"editdate"); - print ''; - print '
'; - } - else - { - if ($object->date) - { - print dol_print_date($object->date,'daytext'); - } - else - { - print ' '; - } - } - print '
'; - print ''; - if ($action != 'editecheance' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('DateEndPropal'); - print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; - print '
'; - if (! empty($object->brouillon) && $action == 'editecheance') - { - print '
'; - print ''; - print ''; - $form->select_date($object->fin_validite,'ech','','','',"editecheance"); - print ''; - print '
'; - } - else - { - if (! empty($object->fin_validite)) - { - print dol_print_date($object->fin_validite,'daytext'); - if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); - } - else - { - print ' '; - } - } - print '
'; - print ''; - if ($action != 'editconditions' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('PaymentConditionsShort'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'
'; - print '
'; - if ($action == 'editconditions') - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); - } - else - { - $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); - } - print '
'; - print ''; - if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('DeliveryDate'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'
'; - print '
'; - if ($action == 'editdate_livraison') - { - print '
'; - print ''; - print ''; - $form->select_date($object->date_livraison,'liv_','','','',"editdate_livraison"); - print ''; - print '
'; - } - else - { - print dol_print_date($object->date_livraison,'daytext'); - } - print '
'; - print ''; - if ($action != 'editavailability' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('AvailabilityPeriod'); - if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'
'; - print '
'; - if ($action == 'editavailability') - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); - } - else - { - $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); - } - - print '
'; - print ''; - if ($action != 'editdemandreason' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('Source'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'
'; - print '
'; - //print $object->demand_reason_id; - if ($action == 'editdemandreason') - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); - } - else - { - $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); - } - - print '
'; - print ''; - if ($action != 'editmode' && ! empty($object->brouillon)) print ''; - print '
'; - print $langs->trans('PaymentMode'); - print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'
'; - print '
'; - if ($action == 'editmode') - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); - } - else - { - $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); - } - print '
'; - print ''; - if ($user->rights->propal->creer) - { - if ($action != 'classify') print ''; - print '
'; - print $langs->trans('Project').''.img_edit($langs->transnoentitiesnoconv('SetProject')).'
'; - print '
'; - if ($action == 'classify') - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); - } - else - { - $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); - } - print '
'; - if (! empty($object->fk_project)) - { - print ''; - $proj = new Project($db); - $proj->fetch($object->fk_project); - print ''; - print $proj->ref; - print ''; - print ''; - } - else { - print ' '; - } - } - print ''; - } - - // Other attributes - $res=$object->fetch_optionals($object->id,$extralabels); - $parameters=array('colspan' => ' colspan="3"'); - $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - if (empty($reshook) && ! empty($extrafields->attribute_label)) - { - - if ($action == 'edit_extras') - { - print '
'; - print ''; - print ''; - print ''; - } - - - foreach($extrafields->attribute_label as $key=>$label) - { - $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); - if ($extrafields->attribute_type[$key] == 'separate') - { - print $extrafields->showSeparator($key); - } - else - { - print 'attribute_required[$key])) print ' class="fieldrequired"'; - print '>'.$label.''; - if ($action == 'edit_extras' && $user->rights->propal->creer) - { - print $extrafields->showInputField($key,$value); - } - else - { - print $extrafields->showOutputField($key,$value); - } - print ''."\n"; - } - } - - if(count($extrafields->attribute_label) > 0) { - - if ($action == 'edit_extras' && $user->rights->propal->creer) - { - print ''; - print ''; - print ''; - print ''; - - } - else { - if ($object->statut == 0 && $user->rights->propal->creer) - { - print ''.img_picto('','edit').' '.$langs->trans('Modify').''; - } - } - } - } - - // Amount HT - print ''.$langs->trans('AmountHT').''; - print ''.price($object->total_ht).''; - print ''.$langs->trans("Currency".$conf->currency).''; - - // Margin Infos - if (! empty($conf->margin->enabled)) { - print ''; - $object->displayMarginInfos(); - print ''; - } - print ''; - - // Amount VAT - print ''.$langs->trans('AmountVAT').''; - print ''.price($object->total_tva).''; - print ''.$langs->trans("Currency".$conf->currency).''; - - // Amount Local Taxes - if ($mysoc->localtax1_assuj=="1") //Localtax1 - { - print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).''; - print ''.price($object->total_localtax1).''; - print ''.$langs->trans("Currency".$conf->currency).''; - } - if ($mysoc->localtax2_assuj=="1") //Localtax2 - { - print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).''; - print ''.price($object->total_localtax2).''; - print ''.$langs->trans("Currency".$conf->currency).''; - } - - - // Amount TTC - print ''.$langs->trans('AmountTTC').''; - print ''.price($object->total_ttc).''; - print ''.$langs->trans("Currency".$conf->currency).''; - - // Statut - print ''.$langs->trans('Status').''.$object->getLibStatut(4).''; - - print '
'; - - if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) - { - $blocname = 'contacts'; - $title = $langs->trans('ContactsAddresses'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) - { - $blocname = 'notes'; - $title = $langs->trans('Notes'); - include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; - } - - /* - * Lines - */ - - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) - { - include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; - } - - print ''; - - // Show object lines - $result = $object->getLinesArray(); - if (! empty($object->lines)) - $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); - - // Form to add new line - if ($object->statut == 0 && $user->rights->propal->creer) - { - if ($action != 'editline') - { - $var=true; - - if ($conf->global->MAIN_FEATURES_LEVEL > 1) - { - // Add free or predefined products/services - $object->formAddObjectLine(0,$mysoc,$soc); - } - else - { - // Add free products/services - $object->formAddFreeProduct(0,$mysoc,$soc); - - // Add predefined products/services - if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) - { - $var=!$var; - $object->formAddPredefinedProduct(0,$mysoc,$soc); - } - } - - $parameters=array(); - $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook - } - } - - print '
'; - - print ''; - print "\n"; - - if ($action == 'statut') - { - /* - * Formulaire cloture (signe ou non) - */ - $form_close = '
'; - $form_close.= ''; - $form_close.= ''; - $form_close.= ''; - $form_close.= ''; - $form_close.= ''; - $form_close.= '
'.$langs->trans("CloseAs").''; - $form_close.= ''; - $form_close.= ''; - $form_close.= '
'.$langs->trans('Note').'
'; - $form_close.= ''; - $form_close.= '   '; - $form_close.= ' '; - $form_close.= '
'; - - print $form_close; - } - - - /* - * Boutons Actions - */ - if ($action != 'presend') - { - print '
'; - - if ($action != 'statut' && $action <> 'editline') - { - // Validate - if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) - { - if (count($object->lines) > 0) print ''.$langs->trans('Validate').''; - //else print ''.$langs->trans('Validate').''; - } - - // Edit - if ($object->statut == 1 && $user->rights->propal->creer) - { - print ''.$langs->trans('Modify').''; - } - - // ReOpen - if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) - { - print 'global->MAIN_JUMP_TAG)?'':'#reopen').'"'; - print '>'.$langs->trans('ReOpen').''; - } - - // Send - if ($object->statut == 1 || $object->statut == 2) - { - if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) - { - print ''.$langs->trans('SendByMail').''; - } - else print ''.$langs->trans('SendByMail').''; - } - - // Create an order - if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) - { - if ($user->rights->commande->creer) - { - print ''.$langs->trans("AddOrder").''; - } - } - - // Create an invoice and classify billed - if ($object->statut == 2 && $user->societe_id == 0) - { - if (! empty($conf->facture->enabled) && $user->rights->facture->creer) - { - print ''.$langs->trans("AddBill").''; - } - - $arraypropal=$object->getInvoiceArrayList(); - if (is_array($arraypropal) && count($arraypropal) > 0) - { - print 'socid.'">'.$langs->trans("ClassifyBilled").''; - } - } - - // Close - if ($object->statut == 1 && $user->rights->propal->cloturer) - { - print 'global->MAIN_JUMP_TAG)?'':'#close').'"'; - print '>'.$langs->trans('Close').''; - } - - // Clone - if ($user->rights->propal->creer) - { - print ''.$langs->trans("ToClone").''; - } - - // Delete - if ($user->rights->propal->supprimer) - { - print ''.$langs->trans('Delete').''; - } - - } - - print '
'; - print "
\n"; - } - - if ($action != 'presend') - { - print '
'; - print ''; // ancre - - - /* - * Documents generes - */ - $filename=dol_sanitizeFileName($object->ref); - $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); - $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; - $genallowed=$user->rights->propal->creer; - $delallowed=$user->rights->propal->supprimer; - - $var=true; - - $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); - - - /* - * Linked object block - */ - $somethingshown=$object->showLinkedObjectBlock(); - - print ''; - - // List of actions on element - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; - $formactions=new FormActions($db); - $somethingshown=$formactions->showactions($object,'propal',$socid); - - print '
'; - } - - - /* - * Action presend - * - */ - if ($action == 'presend') - { - $ref = dol_sanitizeFileName($object->ref); - include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); - $file=$fileparams['fullname']; - - // Build document if it not exists - if (! $file || ! is_readable($file)) - { - // Define output language - $outputlangs = $langs; - $newlang=''; - if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; - if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; - if (! empty($newlang)) - { - $outputlangs = new Translate("",$conf); - $outputlangs->setDefaultLang($newlang); - } - - $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); - if ($result <= 0) - { - dol_print_error($db,$result); - exit; - } - $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); - $file=$fileparams['fullname']; - } - - print '
'; - print_titre($langs->trans('SendPropalByMail')); - - // Create form object - include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; - $formmail = new FormMail($db); - $formmail->fromtype = 'user'; - $formmail->fromid = $user->id; - $formmail->fromname = $user->getFullName($langs); - $formmail->frommail = $user->email; - $formmail->withfrom=1; + } + + $type = $prod->type; + } + else + { + $pu_ht = price2num($price_ht, 'MU'); + $pu_ttc = price2num(GETPOST('price_ttc'), 'MU'); + $tva_npr = (preg_match('/\*/', $tva_tx)?1:0); + $tva_tx = str_replace('*', '', $tva_tx); + $label = (GETPOST('product_label')?GETPOST('product_label'):''); + $desc = $product_desc; + $type = GETPOST('type'); + } + + // Margin + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + + // Local Taxes + $localtax1_tx= get_localtax($tva_tx, 1, $object->client); + $localtax2_tx= get_localtax($tva_tx, 2, $object->client); + + $info_bits=0; + if ($tva_npr) $info_bits |= 0x01; + + if (! empty($price_min) && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + $mesg = $langs->trans("CantBeLessThanMinPrice",price2num($price_min,'MU').$langs->getCurrencySymbol($conf->currency)); + setEventMessage($mesg, 'errors'); + } + else + { + // Insert line + $result=$object->addline( + $id, + $desc, + $pu_ht, + GETPOST('qty'), + $tva_tx, + $localtax1_tx, + $localtax2_tx, + $idprod, + GETPOST('remise_percent'), + $price_base_type, + $pu_ttc, + $info_bits, + $type, + -1, + 0, + GETPOST('fk_parent_line'), + $fournprice, + $buyingprice, + $label + ); + + if ($result > 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['idprod']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + + // old method + unset($_POST['np_desc']); + unset($_POST['dp_desc']); + } + else + { + setEventMessage($object->error, 'errors'); + } + } + } +} + +// Mise a jour d'une ligne dans la propale +else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('save') == $langs->trans("Save")) +{ + // Define info_bits + $info_bits=0; + if (preg_match('/\*/', GETPOST('tva_tx'))) $info_bits |= 0x01; + + // Clean parameters + $description=dol_htmlcleanlastbr(GETPOST('product_desc')); + + // Define vat_rate + $vat_rate=(GETPOST('tva_tx')?GETPOST('tva_tx'):0); + $vat_rate=str_replace('*','',$vat_rate); + $localtax1_rate=get_localtax($vat_rate,1,$object->client); + $localtax2_rate=get_localtax($vat_rate,2,$object->client); + $pu_ht=GETPOST('price_ht'); + + // Add buying price + $fournprice=(GETPOST('fournprice')?GETPOST('fournprice'):''); + $buyingprice=(GETPOST('buying_price')?GETPOST('buying_price'):''); + + // Define special_code for special lines + $special_code=0; + if (! GETPOST('qty')) $special_code=3; + + // Check minimum price + $productid = GETPOST('productid', 'int'); + if (! empty($productid)) + { + $product = new Product($db); + $res=$product->fetch($productid); + + $type=$product->type; + + $price_min = $product->price_min; + if (! empty($conf->global->PRODUIT_MULTIPRICES) && ! empty($object->client->price_level)) + $price_min = $product->multiprices_min[$object->client->price_level]; + + $label = ((GETPOST('update_label') && GETPOST('product_label')) ? GETPOST('product_label'):''); + + if ($price_min && (price2num($pu_ht)*(1-price2num(GETPOST('remise_percent'))/100) < price2num($price_min))) + { + setEventMessage($langs->trans("CantBeLessThanMinPrice", price2num($price_min,'MU')).$langs->getCurrencySymbol($conf->currency), 'errors'); + $error++; + } + } + else + { + $type = GETPOST('type'); + $label = (GETPOST('product_label') ? GETPOST('product_label'):''); + + // Check parameters + if (GETPOST('type') < 0) { + setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentitiesnoconv("Type")), 'errors'); + $error++; + } + } + + if (! $error) + { + $result = $object->updateline( + GETPOST('lineid'), + $pu_ht, + GETPOST('qty'), + GETPOST('remise_percent'), + $vat_rate, + $localtax1_rate, + $localtax2_rate, + $description, + 'HT', + $info_bits, + $special_code, + GETPOST('fk_parent_line'), + 0, + $fournprice, + $buyingprice, + $label, + $type + ); + + if ($result >= 0) + { + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + unset($_POST['qty']); + unset($_POST['type']); + unset($_POST['productid']); + unset($_POST['remise_percent']); + unset($_POST['price_ht']); + unset($_POST['price_ttc']); + unset($_POST['tva_tx']); + unset($_POST['product_ref']); + unset($_POST['product_label']); + unset($_POST['product_desc']); + unset($_POST['fournprice']); + unset($_POST['buying_price']); + } + else + { + setEventMessage($object->error, 'errors'); + } + } +} + +else if ($action == 'updateligne' && $user->rights->propal->creer && GETPOST('cancel') == $langs->trans('Cancel')) +{ + header('Location: '.$_SERVER['PHP_SELF'].'?id='.$object->id); // Pour reaffichage de la fiche en cours d'edition + exit; +} + +// Generation doc (depuis lien ou depuis cartouche doc) +else if ($action == 'builddoc' && $user->rights->propal->creer) +{ + if (GETPOST('model')) + { + $object->setDocModel($user, GETPOST('model')); + } + + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + $result=propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + else + { + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id.(empty($conf->global->MAIN_JUMP_TAG)?'':'#builddoc')); + exit; + } +} + +// Remove file in doc form +else if ($action == 'remove_file' && $user->rights->propal->creer) +{ + if ($object->id > 0) + { + require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + $langs->load("other"); + $upload_dir = $conf->propal->dir_output; + $file = $upload_dir . '/' . GETPOST('file'); + $ret=dol_delete_file($file,0,0,0,$object); + if ($ret) setEventMessage($langs->trans("FileWasRemoved", GETPOST('file'))); + else setEventMessage($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), 'errors'); + } +} + +// Set project +else if ($action == 'classin' && $user->rights->propal->creer) +{ + $object->setProject($_POST['projectid']); +} + +// Delai de livraison +else if ($action == 'setavailability' && $user->rights->propal->creer) +{ + $result = $object->availability($_POST['availability_id']); +} + +// Origine de la propale +else if ($action == 'setdemandreason' && $user->rights->propal->creer) +{ + $result = $object->demand_reason($_POST['demand_reason_id']); +} + +// Conditions de reglement +else if ($action == 'setconditions' && $user->rights->propal->creer) +{ + $result = $object->setPaymentTerms(GETPOST('cond_reglement_id','int')); +} + +else if ($action == 'setremisepercent' && $user->rights->propal->creer) +{ + $result = $object->set_remise_percent($user, $_POST['remise_percent']); +} + +else if ($action == 'setremiseabsolue' && $user->rights->propal->creer) +{ + $result = $object->set_remise_absolue($user, $_POST['remise_absolue']); +} + +// Mode de reglement +else if ($action == 'setmode' && $user->rights->propal->creer) +{ + $result = $object->setPaymentMethods(GETPOST('mode_reglement_id','int')); +} + +/* + * Ordonnancement des lignes + */ + +else if ($action == 'up' && $user->rights->propal->creer) +{ + $object->line_up(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); + exit; +} + +else if ($action == 'down' && $user->rights->propal->creer) +{ + $object->line_down(GETPOST('rowid')); + + if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE)) + { + // Define output language + $outputlangs = $langs; + if (! empty($conf->global->MAIN_MULTILANGS)) + { + $outputlangs = new Translate("",$conf); + $newlang=(GETPOST('lang_id') ? GETPOST('lang_id') : $object->client->default_lang); + $outputlangs->setDefaultLang($newlang); + } + $ret=$object->fetch($id); // Reload to get new records + propale_pdf_create($db, $object, $object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + } + + header('Location: '.$_SERVER["PHP_SELF"].'?id='.$id.'#'.GETPOST('rowid')); + exit; +} +else if ($action == 'update_extras') +{ + // Get extra fields + foreach($_POST as $key => $value) + { + if (preg_match("/^options_/",$key)) + { + $object->array_options[$key]=$_POST[$key]; + } + } + // Actions on extra fields (by external module or standard code) + // FIXME le hook fait double emploi avec le trigger !! + $hookmanager->initHooks(array('propaldao')); + $parameters=array('id'=>$object->id); + $reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks + if (empty($reshook)) + { + if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used + { + $result=$object->insertExtraFields(); + if ($result < 0) + { + $error++; + } + } + } + else if ($reshook < 0) $error++; + +} + +if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB) && $user->rights->propal->creer) +{ + if ($action == 'addcontact') + { + if ($object->id > 0) + { + $contactid = (GETPOST('userid') ? GETPOST('userid') : GETPOST('contactid')); + $result = $object->add_contact($contactid, $_POST["type"], $_POST["source"]); + } + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') + { + $langs->load("errors"); + setEventMessage($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), 'errors'); + } + else + { + setEventMessage($object->error, 'errors'); + } + } + } + + // Bascule du statut d'un contact + else if ($action == 'swapstatut') + { + if ($object->fetch($id) > 0) + { + $result=$object->swapContactStatus(GETPOST('ligne')); + } + else + { + dol_print_error($db); + } + } + + // Efface un contact + else if ($action == 'deletecontact') + { + $object->fetch($id); + $result = $object->delete_contact($lineid); + + if ($result >= 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else + { + dol_print_error($db); + } + } +} + + +/* + * View + */ + +llxHeader('',$langs->trans('Proposal'),'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos'); + +$form = new Form($db); +$formother = new FormOther($db); +$formfile = new FormFile($db); +$formpropal = new FormPropal($db); +$companystatic=new Societe($db); + +// fetch optionals attributes and labels +$extralabels=$extrafields->fetch_name_optionals_label('propal'); + +$now=dol_now(); + +// Add new proposal +if ($action == 'create') +{ + print_fiche_titre($langs->trans("NewProp")); + + $soc = new Societe($db); + if ($socid>0) $res=$soc->fetch($socid); + + $object = new Propal($db); + + print '
'; + print ''; + print ''; + + if ($origin != 'project' && $originid) + { + print ''; + print ''; + } + + print ''; + + // Reference + print ''; + + // Ref customer + print ''; + print ''; + + // Third party + print ''; + print ''; + if($socid>0) + { + print ''; + } + else + { + print ''; + } + print ''."\n"; + + // Contacts + if($socid>0) + { + print "'; + + // Ligne info remises tiers + print ''; + } + + // Date + print ''; + + // Validaty duration + print ''; + + // Terms of payment + print ''; + + // Mode of payment + print ''; + + // What trigger creation + print ''; + + // Delivery delay + print ''; + + // Delivery date (or manufacturing) + print ''; + print ''; + + // Model + print ''; + print ''; + print '"; + + // Project + if (! empty($conf->projet->enabled) && $socid>0) + { + $projectid = 0; + if ($origin == 'project') $projectid = ($originid?$originid:0); + + print ''; + print ''; + print ''; + } + + // Other attributes + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + + // Show separator only + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''."\n"; + } + } + } + + print "
'.$langs->trans('Ref').''.$langs->trans("Draft").'
'.$langs->trans('RefCustomer').''; + print '
'.$langs->trans('Customer').''; + print $soc->getNomUrl(1); + print ''; + print ''; + print $form->select_company('','socid','s.client = 1 OR s.client = 2 OR s.client = 3',1); + print '
".$langs->trans("DefaultContact").''; + $form->select_contacts($soc->id,$setcontact,'contactidp',1,$srccontactslist); + print '
'.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + $absolute_discount=$soc->getAvailableDiscounts(); + print '. '; + if ($absolute_discount) print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->trans("Currency".$conf->currency)); + else print $langs->trans("CompanyHasNoAbsoluteDiscount"); + print '.'; + print '
'.$langs->trans('Date').''; + $form->select_date('','','','','',"addprop"); + print '
'.$langs->trans("ValidityDuration").' '.$langs->trans("days").'
'.$langs->trans('PaymentConditionsShort').''; + $form->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id'); + print '
'.$langs->trans('PaymentMode').''; + $form->select_types_paiements($soc->mode_reglement,'mode_reglement_id'); + print '
'.$langs->trans('Source').''; + $form->select_demand_reason('','demand_reason_id',"SRC_PROP",1); + print '
'.$langs->trans('AvailabilityPeriod').''; + $form->select_availability('','availability_id','',1); + print '
'.$langs->trans("DeliveryDate").''; + if ($conf->global->DATE_LIVRAISON_WEEK_DELAY != "") + { + $tmpdte = time() + ((7 * $conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60); + $syear = date("Y", $tmpdte); + $smonth = date("m", $tmpdte); + $sday = date("d", $tmpdte); + $form->select_date($syear."-".$smonth."-".$sday,'liv_','','','',"addprop"); + } + else + { + $datepropal=empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0; + $form->select_date($datepropal,'liv_','','','',"addprop"); + } + print '
'.$langs->trans("DefaultModel").''; + $liste=ModelePDFPropales::liste_modeles($db); + print $form->selectarray('model',$liste,$conf->global->PROPALE_ADDON_PDF); + print "
'.$langs->trans("Project").''; + + $numprojet=select_projects($soc->id,$projectid); + if ($numprojet==0) + { + print '   '.$langs->trans("AddProject").''; + } + print '
'; + print $extrafields->showInputField($key,$value); + print '
"; + print '
'; + + /* + * Combobox pour la fonction de copie + */ + + if (empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + { + print ''; + } + + print ''; + if (! empty($conf->global->PROPAL_CLONE_ON_CREATE_PAGE)) + { + // For backward compatibility + print ''; + print ''; + print ''; + print ''; + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) print ''; + + print ''; + print ''; + } + + if (! empty($conf->global->PRODUCT_SHOW_WHEN_CREATE)) + { + print ''; + } + print '
'.$langs->trans("CopyPropalFrom").' '; + $liste_propal = array(); + $liste_propal[0] = ''; + + $sql ="SELECT p.rowid as id, p.ref, s.nom"; + $sql.=" FROM ".MAIN_DB_PREFIX."propal p"; + $sql.= ", ".MAIN_DB_PREFIX."societe s"; + $sql.= " WHERE s.rowid = p.fk_soc"; + $sql.= " AND p.entity = ".$conf->entity; + $sql.= " AND p.fk_statut <> 0"; + $sql.= " ORDER BY Id"; + + $resql = $db->query($sql); + if ($resql) + { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) + { + $row = $db->fetch_row($resql); + $propalRefAndSocName = $row[1]." - ".$row[2]; + $liste_propal[$row[0]]=$propalRefAndSocName; + $i++; + } + print $form->selectarray("copie_propal",$liste_propal, 0); + } + else + { + dol_print_error($db); + } + print '
 
'.$langs->trans("CreateEmptyPropal").'
'; + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $lib=$langs->trans("ProductsAndServices"); + + print ''; + print ''; + print ''; + print ''; + print ''; + print ''; + for ($i = 1 ; $i <= $conf->global->PRODUCT_SHOW_WHEN_CREATE; $i++) + { + print ''; + print ''; + print ''; + print ''; + } + + print "
'.$lib.''.$langs->trans("Qty").''.$langs->trans("ReductionShort").'
'; + // multiprix + if($conf->global->PRODUIT_MULTIPRICES && $soc->price_level) + $form->select_produits('',"idprod".$i,'',$conf->product->limit_size,$soc->price_level); + else + $form->select_produits('',"idprod".$i,'',$conf->product->limit_size); + print '%
"; + + } + print '
'; + print '
'; + + $langs->load("bills"); + print '
'; + print ''; + print ' '; + print '
'; + + print "
"; +} +else +{ + /* + * Show object in view mode + */ + + $soc = new Societe($db); + $soc->fetch($object->socid); + + $head = propal_prepare_head($object); + dol_fiche_head($head, 'comm', $langs->trans('Proposal'), 0, 'propal'); + + $formconfirm=''; + + // Clone confirmation + if ($action == 'clone') + { + // Create an array for form + $formquestion=array( + //'text' => $langs->trans("ConfirmClone"), + //array('type' => 'checkbox', 'name' => 'clone_content', 'label' => $langs->trans("CloneMainAttributes"), 'value' => 1), + //array('type' => 'checkbox', 'name' => 'update_prices', 'label' => $langs->trans("PuttingPricesUpToDate"), 'value' => 1), + array('type' => 'other', 'name' => 'socid', 'label' => $langs->trans("SelectThirdParty"), 'value' => $form->select_company(GETPOST('socid','int'),'socid','(s.client=1 OR s.client=2 OR s.client=3)')) + ); + // Paiement incomplet. On demande si motif = escompte ou autre + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('ClonePropal'),$langs->trans('ConfirmClonePropal',$object->ref),'confirm_clone',$formquestion,'yes',1); + } + + // Confirm delete + else if ($action == 'delete') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp',$object->ref), 'confirm_delete','',0,1); + } + + // Confirm reopen + else if ($action == 'reopen') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ReOpen'), $langs->trans('ConfirmReOpenProp',$object->ref), 'confirm_reopen','',0,1); + } + + // Confirmation delete product/service line + else if ($action == 'ask_deleteline') + { + $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id.'&lineid='.$lineid, $langs->trans('DeleteProductLine'), $langs->trans('ConfirmDeleteProductLine'), 'confirm_deleteline','',0,1); + } + + // Confirm validate proposal + else if ($action == 'validate') + { + $error=0; + + // on verifie si l'objet est en numerotation provisoire + $ref = substr($object->ref, 1, 4); + if ($ref == 'PROV') + { + $numref = $object->getNextNumRef($soc); + if (empty($numref)) + { + $error++; + dol_htmloutput_errors($object->error); + } + } + else + { + $numref = $object->ref; + } + + $text=$langs->trans('ConfirmValidateProp',$numref); + if (! empty($conf->notification->enabled)) + { + require_once DOL_DOCUMENT_ROOT .'/core/class/notify.class.php'; + $notify=new Notify($db); + $text.='
'; + $text.=$notify->confirmMessage('NOTIFY_VAL_PROPAL',$object->socid); + } + + if (! $error) $formconfirm=$form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id, $langs->trans('ValidateProp'), $text, 'confirm_validate','',0,1); + } + + if (! $formconfirm) + { + $parameters=array('lineid'=>$lineid); + $formconfirm=$hookmanager->executeHooks('formConfirm',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + + // Print form confirm + print $formconfirm; + + + print ''; + + $linkback = ''.$langs->trans("BackToList").''; + + // Ref + print ''; + + // Ref client + print ''; + print ''; + + // Company + print ''; + print ''; + + // Ligne info remises tiers + print ''; + + // Date of proposal + print ''; + print ''; + + // Date end proposal + print ''; + print ''; + print ''; + + // Payment term + print ''; + print ''; + + // Delivery date + $langs->load('deliveries'); + print ''; + print ''; + + // Delivery delay + print ''; + print ''; + + // Origin of demand + print ''; + print ''; + + // Payment mode + print ''; + print ''; + + // Project + if (! empty($conf->projet->enabled)) + { + $langs->load("projects"); + print ''; + } + else + { + print '
'.$langs->trans('Ref').''; + print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref', ''); + print '
'; + print ''; + if ($action != 'refclient' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('RefCustomer').''; + print ''.img_edit($langs->trans('Modify')).'
'; + print '
'; + if ($user->rights->propal->creer && $action == 'refclient') + { + print '
'; + print ''; + print ''; + print ''; + print ' '; + print '
'; + } + else + { + print $object->ref_client; + } + print '
'.$langs->trans('Company').''.$soc->getNomUrl(1).'
'.$langs->trans('Discounts').''; + if ($soc->remise_client) print $langs->trans("CompanyHasRelativeDiscount",$soc->remise_client); + else print $langs->trans("CompanyHasNoRelativeDiscount"); + print '. '; + $absolute_discount=$soc->getAvailableDiscounts('','fk_facture_source IS NULL'); + $absolute_creditnote=$soc->getAvailableDiscounts('','fk_facture_source IS NOT NULL'); + $absolute_discount=price2num($absolute_discount,'MT'); + $absolute_creditnote=price2num($absolute_creditnote,'MT'); + if ($absolute_discount) + { + if ($object->statut > 0) + { + print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); + } + else + { + // Remise dispo de type non avoir + $filter='fk_facture_source IS NULL'; + print '
'; + $form->form_remise_dispo($_SERVER["PHP_SELF"].'?id='.$object->id,0,'remise_id',$soc->id,$absolute_discount,$filter); + } + } + if ($absolute_creditnote) + { + print $langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)).'. '; + } + if (! $absolute_discount && ! $absolute_creditnote) print $langs->trans("CompanyHasNoAbsoluteDiscount").'.'; + print '
'; + print ''; + if ($action != 'editdate' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('Date'); + print 'id.'">'.img_edit($langs->trans('SetDate'),1).'
'; + print '
'; + if (! empty($object->brouillon) && $action == 'editdate') + { + print '
'; + print ''; + print ''; + $form->select_date($object->date,'re','','',0,"editdate"); + print ''; + print '
'; + } + else + { + if ($object->date) + { + print dol_print_date($object->date,'daytext'); + } + else + { + print ' '; + } + } + print '
'; + print ''; + if ($action != 'editecheance' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('DateEndPropal'); + print 'id.'">'.img_edit($langs->trans('SetConditions'),1).'
'; + print '
'; + if (! empty($object->brouillon) && $action == 'editecheance') + { + print '
'; + print ''; + print ''; + $form->select_date($object->fin_validite,'ech','','','',"editecheance"); + print ''; + print '
'; + } + else + { + if (! empty($object->fin_validite)) + { + print dol_print_date($object->fin_validite,'daytext'); + if ($object->statut == 1 && $object->fin_validite < ($now - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late")); + } + else + { + print ' '; + } + } + print '
'; + print ''; + if ($action != 'editconditions' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('PaymentConditionsShort'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetConditions'),1).'
'; + print '
'; + if ($action == 'editconditions') + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'cond_reglement_id'); + } + else + { + $form->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->cond_reglement_id,'none'); + } + print '
'; + print ''; + if ($action != 'editdate_livraison' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('DeliveryDate'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDeliveryDate'),1).'
'; + print '
'; + if ($action == 'editdate_livraison') + { + print '
'; + print ''; + print ''; + $form->select_date($object->date_livraison,'liv_','','','',"editdate_livraison"); + print ''; + print '
'; + } + else + { + print dol_print_date($object->date_livraison,'daytext'); + } + print '
'; + print ''; + if ($action != 'editavailability' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('AvailabilityPeriod'); + if (! empty($conf->commande->enabled)) print ' ('.$langs->trans('AfterOrder').')'; + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetAvailability'),1).'
'; + print '
'; + if ($action == 'editavailability') + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'availability_id',1); + } + else + { + $form->form_availability($_SERVER['PHP_SELF'].'?id='.$object->id,$object->availability_id,'none',1); + } + + print '
'; + print ''; + if ($action != 'editdemandreason' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('Source'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetDemandReason'),1).'
'; + print '
'; + //print $object->demand_reason_id; + if ($action == 'editdemandreason') + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'demand_reason_id',1); + } + else + { + $form->form_demand_reason($_SERVER['PHP_SELF'].'?id='.$object->id,$object->demand_reason_id,'none'); + } + + print '
'; + print ''; + if ($action != 'editmode' && ! empty($object->brouillon)) print ''; + print '
'; + print $langs->trans('PaymentMode'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('SetMode'),1).'
'; + print '
'; + if ($action == 'editmode') + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'mode_reglement_id'); + } + else + { + $form->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$object->id,$object->mode_reglement_id,'none'); + } + print '
'; + print ''; + if ($user->rights->propal->creer) + { + if ($action != 'classify') print ''; + print '
'; + print $langs->trans('Project').''.img_edit($langs->transnoentitiesnoconv('SetProject')).'
'; + print '
'; + if ($action == 'classify') + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'projectid'); + } + else + { + $form->form_project($_SERVER['PHP_SELF'].'?id='.$object->id, $object->socid, $object->fk_project, 'none'); + } + print '
'; + if (! empty($object->fk_project)) + { + print ''; + $proj = new Project($db); + $proj->fetch($object->fk_project); + print ''; + print $proj->ref; + print ''; + print ''; + } + else { + print ' '; + } + } + print ''; + } + + // Other attributes + $res=$object->fetch_optionals($object->id,$extralabels); + $parameters=array('colspan' => ' colspan="3"'); + $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + if (empty($reshook) && ! empty($extrafields->attribute_label)) + { + + if ($action == 'edit_extras') + { + print '
'; + print ''; + print ''; + print ''; + } + + + foreach($extrafields->attribute_label as $key=>$label) + { + $value=(isset($_POST["options_".$key])?$_POST["options_".$key]:$object->array_options["options_".$key]); + if ($extrafields->attribute_type[$key] == 'separate') + { + print $extrafields->showSeparator($key); + } + else + { + print 'attribute_required[$key])) print ' class="fieldrequired"'; + print '>'.$label.''; + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print $extrafields->showInputField($key,$value); + } + else + { + print $extrafields->showOutputField($key,$value); + } + print ''."\n"; + } + } + + if(count($extrafields->attribute_label) > 0) { + + if ($action == 'edit_extras' && $user->rights->propal->creer) + { + print ''; + print ''; + print ''; + print ''; + + } + else { + if ($object->statut == 0 && $user->rights->propal->creer) + { + print ''.img_picto('','edit').' '.$langs->trans('Modify').''; + } + } + } + } + + // Amount HT + print ''.$langs->trans('AmountHT').''; + print ''.price($object->total_ht).''; + print ''.$langs->trans("Currency".$conf->currency).''; + + // Margin Infos + if (! empty($conf->margin->enabled)) { + print ''; + $object->displayMarginInfos(); + print ''; + } + print ''; + + // Amount VAT + print ''.$langs->trans('AmountVAT').''; + print ''.price($object->total_tva).''; + print ''.$langs->trans("Currency".$conf->currency).''; + + // Amount Local Taxes + if ($mysoc->localtax1_assuj=="1") //Localtax1 + { + print ''.$langs->transcountry("AmountLT1",$mysoc->country_code).''; + print ''.price($object->total_localtax1).''; + print ''.$langs->trans("Currency".$conf->currency).''; + } + if ($mysoc->localtax2_assuj=="1") //Localtax2 + { + print ''.$langs->transcountry("AmountLT2",$mysoc->country_code).''; + print ''.price($object->total_localtax2).''; + print ''.$langs->trans("Currency".$conf->currency).''; + } + + + // Amount TTC + print ''.$langs->trans('AmountTTC').''; + print ''.price($object->total_ttc).''; + print ''.$langs->trans("Currency".$conf->currency).''; + + // Statut + print ''.$langs->trans('Status').''.$object->getLibStatut(4).''; + + print '
'; + + if (! empty($conf->global->MAIN_DISABLE_CONTACTS_TAB)) + { + $blocname = 'contacts'; + $title = $langs->trans('ContactsAddresses'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + if (! empty($conf->global->MAIN_DISABLE_NOTES_TAB)) + { + $blocname = 'notes'; + $title = $langs->trans('Notes'); + include DOL_DOCUMENT_ROOT.'/core/tpl/bloc_showhide.tpl.php'; + } + + /* + * Lines + */ + + if (! empty($conf->use_javascript_ajax) && $object->statut == 0) + { + include DOL_DOCUMENT_ROOT.'/core/tpl/ajaxrow.tpl.php'; + } + + print ''; + + // Show object lines + $result = $object->getLinesArray(); + if (! empty($object->lines)) + $ret=$object->printObjectLines($action,$mysoc,$soc,$lineid); + + // Form to add new line + if ($object->statut == 0 && $user->rights->propal->creer) + { + if ($action != 'editline') + { + $var=true; + + if ($conf->global->MAIN_FEATURES_LEVEL > 1) + { + // Add free or predefined products/services + $object->formAddObjectLine(0,$mysoc,$soc); + } + else + { + // Add free products/services + $object->formAddFreeProduct(0,$mysoc,$soc); + + // Add predefined products/services + if (! empty($conf->product->enabled) || ! empty($conf->service->enabled)) + { + $var=!$var; + $object->formAddPredefinedProduct(0,$mysoc,$soc); + } + } + + $parameters=array(); + $reshook=$hookmanager->executeHooks('formAddObjectLine',$parameters,$object,$action); // Note that $action and $object may have been modified by hook + } + } + + print '
'; + + print ''; + print "\n"; + + if ($action == 'statut') + { + /* + * Formulaire cloture (signe ou non) + */ + $form_close = '
'; + $form_close.= ''; + $form_close.= ''; + $form_close.= ''; + $form_close.= ''; + $form_close.= ''; + $form_close.= '
'.$langs->trans("CloseAs").''; + $form_close.= ''; + $form_close.= ''; + $form_close.= '
'.$langs->trans('Note').'
'; + $form_close.= ''; + $form_close.= '   '; + $form_close.= ' '; + $form_close.= '
'; + + print $form_close; + } + + + /* + * Boutons Actions + */ + if ($action != 'presend') + { + print '
'; + + if ($action != 'statut' && $action <> 'editline') + { + // Validate + if ($object->statut == 0 && $object->total_ttc >= 0 && count($object->lines) > 0 && $user->rights->propal->valider) + { + if (count($object->lines) > 0) print ''.$langs->trans('Validate').''; + //else print ''.$langs->trans('Validate').''; + } + + // Edit + if ($object->statut == 1 && $user->rights->propal->creer) + { + print ''.$langs->trans('Modify').''; + } + + // ReOpen + if (($object->statut == 2 || $object->statut == 3) && $user->rights->propal->cloturer) + { + print 'global->MAIN_JUMP_TAG)?'':'#reopen').'"'; + print '>'.$langs->trans('ReOpen').''; + } + + // Send + if ($object->statut == 1 || $object->statut == 2) + { + if (empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->propal->propal_advance->send) + { + print ''.$langs->trans('SendByMail').''; + } + else print ''.$langs->trans('SendByMail').''; + } + + // Create an order + if (! empty($conf->commande->enabled) && $object->statut == 2 && $user->societe_id == 0) + { + if ($user->rights->commande->creer) + { + print ''.$langs->trans("AddOrder").''; + } + } + + // Create contract + if ($conf->contrat->enabled && $object->statut == 2 && $user->societe_id == 0) + { + $langs->load("contracts"); + + if ($user->rights->contrat->creer) + { + print ''.$langs->trans('AddContract').''; + } + } + + // Create an invoice and classify billed + if ($object->statut == 2 && $user->societe_id == 0) + { + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) + { + print ''.$langs->trans("AddBill").''; + } + + $arraypropal=$object->getInvoiceArrayList(); + if (is_array($arraypropal) && count($arraypropal) > 0) + { + print 'socid.'">'.$langs->trans("ClassifyBilled").''; + } + } + + // Close + if ($object->statut == 1 && $user->rights->propal->cloturer) + { + print 'global->MAIN_JUMP_TAG)?'':'#close').'"'; + print '>'.$langs->trans('Close').''; + } + + // Clone + if ($user->rights->propal->creer) + { + print ''.$langs->trans("ToClone").''; + } + + // Delete + if ($user->rights->propal->supprimer) + { + print ''.$langs->trans('Delete').''; + } + + } + + print '
'; + print "
\n"; + } + + if ($action != 'presend') + { + print '
'; + print ''; // ancre + + + /* + * Documents generes + */ + $filename=dol_sanitizeFileName($object->ref); + $filedir=$conf->propal->dir_output . "/" . dol_sanitizeFileName($object->ref); + $urlsource=$_SERVER["PHP_SELF"]."?id=".$object->id; + $genallowed=$user->rights->propal->creer; + $delallowed=$user->rights->propal->supprimer; + + $var=true; + + $somethingshown=$formfile->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf,1,0,0,28,0,'',0,'',$soc->default_lang); + + + /* + * Linked object block + */ + $somethingshown=$object->showLinkedObjectBlock(); + + print ''; + + // List of actions on element + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'propal',$socid); + + print '
'; + } + + + /* + * Action presend + * + */ + if ($action == 'presend') + { + $ref = dol_sanitizeFileName($object->ref); + include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); + $file=$fileparams['fullname']; + + // Build document if it not exists + if (! $file || ! is_readable($file)) + { + // Define output language + $outputlangs = $langs; + $newlang=''; + if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id'])) $newlang=$_REQUEST['lang_id']; + if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang=$object->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $result=propale_pdf_create($db, $object, GETPOST('model')?GETPOST('model'):$object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref); + if ($result <= 0) + { + dol_print_error($db,$result); + exit; + } + $fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/')); + $file=$fileparams['fullname']; + } + + print '
'; + print_titre($langs->trans('SendPropalByMail')); + + // Create form object + include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php'; + $formmail = new FormMail($db); + $formmail->fromtype = 'user'; + $formmail->fromid = $user->id; + $formmail->fromname = $user->getFullName($langs); + $formmail->frommail = $user->email; + $formmail->withfrom=1; $liste=array(); foreach ($object->thirdparty->thirdparty_and_contact_email_array(1) as $key=>$value) $liste[$key]=$value; - $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; - $formmail->withtocc=$liste; - $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); - $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); - $formmail->withfile=2; - $formmail->withbody=1; - $formmail->withdeliveryreceipt=1; - $formmail->withcancel=1; - - // Tableau des substitutions - $formmail->substit['__PROPREF__']=$object->ref; - $formmail->substit['__SIGNATURE__']=$user->signature; - $formmail->substit['__PERSONALIZED__']=''; - // Tableau des parametres complementaires - $formmail->param['action']='send'; - $formmail->param['models']='propal_send'; - $formmail->param['id']=$object->id; - $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; - - // Init list of files - if (GETPOST("mode")=='init') - { - $formmail->clear_attached_files(); - $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); - } - - $formmail->show_form(); - - print '
'; - } -} - -// End of page -llxFooter(); -$db->close(); -?> + $formmail->withto=GETPOST("sendto")?GETPOST("sendto"):$liste; + $formmail->withtocc=$liste; + $formmail->withtoccc=(! empty($conf->global->MAIN_EMAIL_USECCC)?$conf->global->MAIN_EMAIL_USECCC:false); + $formmail->withtopic=$langs->trans('SendPropalRef','__PROPREF__'); + $formmail->withfile=2; + $formmail->withbody=1; + $formmail->withdeliveryreceipt=1; + $formmail->withcancel=1; + + // Tableau des substitutions + $formmail->substit['__PROPREF__']=$object->ref; + $formmail->substit['__SIGNATURE__']=$user->signature; + $formmail->substit['__PERSONALIZED__']=''; + // Tableau des parametres complementaires + $formmail->param['action']='send'; + $formmail->param['models']='propal_send'; + $formmail->param['id']=$object->id; + $formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id; + + // Init list of files + if (GETPOST("mode")=='init') + { + $formmail->clear_attached_files(); + $formmail->add_attached_files($file,basename($file),dol_mimetype($file)); + } + + $formmail->show_form(); + + print '
'; + } +} + +// End of page +llxFooter(); +$db->close(); +?> diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 15a42841002..493f34c3962 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -912,6 +912,12 @@ class Commande extends CommonOrder $line->special_code = $object->lines[$i]->special_code; $line->fk_parent_line = $object->lines[$i]->fk_parent_line; + $line->fk_fournprice = $object->lines[$i]->fk_fournprice; + $marginInfos = getMarginInfos($object->lines[$i]->subprice, $object->lines[$i]->remise_percent, $object->lines[$i]->tva_tx, $object->lines[$i]->localtax1_tx, $object->lines[$i]->localtax2_tx, $object->lines[$i]->fk_fournprice, $object->lines[$i]->pa_ht); + $line->pa_ht = $marginInfos[0]; + $line->marge_tx = $marginInfos[1]; + $line->marque_tx = $marginInfos[2]; + $this->lines[$i] = $line; } diff --git a/htdocs/commissions/admin/commissions.php b/htdocs/commissions/admin/commissions.php deleted file mode 100644 index 015cab308ff..00000000000 --- a/htdocs/commissions/admin/commissions.php +++ /dev/null @@ -1,192 +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 /htdocs/admin/commissions.php - * \ingroup commissions - * \brief Page to setup advanced commissions module - */ - -include '../../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/commissions/lib/commissions.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; -require_once(DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'); -require_once(DOL_DOCUMENT_ROOT."/compta/facture/class/facture.class.php"); - -$langs->load("admin"); -$langs->load("bills"); -$langs->load("commissions"); - -if (! $user->admin) accessforbidden(); - - -/* - * Action - */ -if (GETPOST('commissionBase')) -{ - if (dolibarr_set_const($db, 'COMMISSION_BASE', GETPOST('commissionBase'), 'string', 0, '', $conf->entity) > 0) - { - $conf->global->COMMISSION_BASE = GETPOST('commissionBase'); - setEventMessage($langs->trans("RecordModifiedSuccessfully")); - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('productCommissionRate')) -{ - if (dolibarr_set_const($db, 'PRODUCT_COMMISSION_RATE', GETPOST('productCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('serviceCommissionRate')) -{ - if (dolibarr_set_const($db, 'SERVICE_COMMISSION_RATE', GETPOST('serviceCommissionRate'), 'rate', 0, '', $conf->entity) > 0) - { - } - else - { - dol_print_error($db); - } -} - -if (GETPOST('AGENT_CONTACT_TYPE')) -{ - if (dolibarr_set_const($db, 'AGENT_CONTACT_TYPE', GETPOST('AGENT_CONTACT_TYPE'), 'chaine', 0, '', $conf->entity) > 0) - { - $conf->global->AGENT_CONTACT_TYPE = GETPOST('AGENT_CONTACT_TYPE'); - } - else - { - dol_print_error($db); - } -} - -/* - * View - */ - -llxHeader('',$langs->trans("CommissionsSetup")); - - -$linkback=''.$langs->trans("BackToModuleList").''; -print_fiche_titre($langs->trans("commissionsSetup"),$linkback,'setup'); - - -$head = commissions_admin_prepare_head(); - -dol_fiche_head($head, 'parameters', $langs->trans("Commissions"), 0, 'commissions'); - -print "
"; - - -print_fiche_titre($langs->trans("MemberMainOptions"),'',''); -print ''; -print ''; -print ''; -print ''."\n"; -print ''."\n"; -print ''; - -$var=true; -$form = new Form($db); - -print ''; - -// COMMISSION BASE (TURNOVER / MARGIN) -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// PRODUCT COMMISSION RATE -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// SERVICE COMMISSION RATE -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -// INTERNAL CONTACT TYPE USED AS COMMERCIAL AGENT -$var=!$var; -print ''; -print ''; -print ''; -print ''; -print ''; - -$var=!$var; -print ''; -print ''; -print ''; - -print '
'.$langs->trans("Description").''.$langs->trans("Value").''.$langs->trans("Details").'
'.$langs->trans("CommissionBase").''; -print 'global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "TURNOVER") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnTurnover"); -print '
'; -print 'margin->enabled)) - print 'disabled'; -elseif (isset($conf->global->COMMISSION_BASE) && $conf->global->COMMISSION_BASE == "MARGIN") - print 'checked'; -print ' />'; -print $langs->trans("CommissionBasedOnMargins"); -print '
'.$langs->trans('CommissionBaseDetails'); -print '
'; -print $langs->trans('CommissionBasedOnMarginsDetails'); -print '
'.$langs->trans("ProductCommissionRate").''; -print '  %'; -print ''.$langs->trans('ProductCommissionRateDetails').'
'.$langs->trans("ServiceCommissionRate").''; -print '  %'; -print ''.$langs->trans('ServiceCommissionRateDetails').'
'.$langs->trans("AgentContactType").''; -$formcompany = new FormCompany($db); -$facture = new Facture($db); -print $formcompany->selectTypeContact($facture, $conf->global->AGENT_CONTACT_TYPE, "AGENT_CONTACT_TYPE","internal","code",1); -print ''.$langs->trans('AgentContactTypeDetails').'
'; -print ''; -print '
'; - -print ''; - -dol_fiche_end(); - -print '
'; - -llxFooter(); -$db->close(); -?> diff --git a/htdocs/commissions/index.php b/htdocs/commissions/index.php deleted file mode 100644 index cdc6329d858..00000000000 --- a/htdocs/commissions/index.php +++ /dev/null @@ -1,329 +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 htdocs/commissions/index.php - * \ingroup commissions - * \brief Page des commissions par agent commercial - */ - -require '../main.inc.php'; -require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; -require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php'; -if (! empty($conf->margin->enabled)) - require_once DOL_DOCUMENT_ROOT.'/margin/lib/margins.lib.php'; - -$langs->load("companies"); -$langs->load("bills"); -$langs->load("products"); -$langs->load("commissions"); -if (! empty($conf->margin->enabled)) - $langs->load("margins"); - -// Security check -$agentid = GETPOST('agentid','int'); - -$mesg = ''; - -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -$page = GETPOST("page",'int'); -if ($page == -1) { $page = 0; } -$offset = $conf->liste_limit * $page; -$pageprev = $page - 1; -$pagenext = $page + 1; - -$startdate=$enddate=''; - -if (!empty($_POST['startdatemonth'])) - $startdate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['startdatemonth'], $_POST['startdateday'], $_POST['startdateyear'])); -if (!empty($_POST['enddatemonth'])) - $enddate = date('Y-m-d', dol_mktime(12, 0, 0, $_POST['enddatemonth'], $_POST['enddateday'], $_POST['enddateyear'])); - -/* - * View - */ - -$userstatic = new User($db); -$companystatic = new Societe($db); -$invoicestatic=new Facture($db); - -$form = new Form($db); - -llxHeader('',$langs->trans("Commissions")); - -$text=$langs->trans("Commissions"); -print_fiche_titre($text); - -print '
'; -print ''; - -if ($agentid > 0) { - - print ''; - print ''; - - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="s.nom"; -} -else { - print ''; - print ''; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="u.login"; -} - -// Start date -print ''; -print ''; -print ''; -print ''; -print ''; - -// Include unpayed invoices -print ''; - - -// Total Margin -if ($conf->global->COMMISSION_BASE == "MARGIN") { - print ''; -} -elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { - print ''; -} - -// Total Commission -print ''; - -print "
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers($agentid,'agentid',1,'',0,'',''); - print '
'.$langs->trans('CommercialAgent').''; - print $form->select_dolusers('','agentid',1,'',0,'',''); - print '
'.$langs->trans('StartDate').''; -$form->select_date($startdate,'startdate','','',1,"sel",1,1); -print ''.$langs->trans('EndDate').''; -$form->select_date($enddate,'enddate','','',1,"sel",1,1); -print ''; -print ''; -print '
'.$langs->trans("IncludeUnpayedInvoices").''; -print ''; -print '
'.$langs->trans("TotalMargin").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TurnoverTotal").''; - print ''; // set by jquery (see below) - print '
'.$langs->trans("TotalCommission").''; -print ''; // set by jquery (see below) -print '
"; -print '
'; - -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -if ($conf->global->COMMISSION_BASE == "MARGIN") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) else 0 end) as serviceBase" ; -} -elseif ($conf->global->COMMISSION_BASE == "TURNOVER") { - $sql.= " sum(case d.product_type when 1 then 0 else (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) end) as productBase," ; - $sql.= " sum(case d.product_type when 1 then (((d.subprice * (1 - d.remise_percent / 100))) * d.qty) else 0 end) as serviceBase" ; -} -$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; -$sql.= ", ".MAIN_DB_PREFIX."facture as f"; -$sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); -$sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; -$sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; -$sql.= ", ".MAIN_DB_PREFIX."user as u"; -$sql.= " WHERE f.fk_soc = s.rowid"; -$sql.= " AND sc.fk_soc = f.fk_soc"; -if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = u.rowid) OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = u.rowid))"; -else - $sql .= " AND sc.fk_user = u.rowid"; -if (GETPOST('unpayed') == 'on') - $sql.= " AND f.fk_statut > 0"; -else - $sql.= " AND f.fk_statut > 1"; -$sql.= " AND s.entity = ".$conf->entity; -$sql.= " AND d.fk_facture = f.rowid"; -if ($agentid > 0) { - if (! empty($conf->global->AGENT_CONTACT_TYPE)) - $sql.= " AND ((e.fk_socpeople IS NULL AND sc.fk_user = ".$agentid.") OR (e.fk_socpeople IS NOT NULL AND e.fk_socpeople = ".$agentid."))"; - else - $sql .= " AND sc.fk_user = ".$agentid; -} -if (!empty($startdate)) - $sql.= " AND f.datef >= '".$startdate."'"; -if (!empty($enddate)) - $sql.= " AND f.datef <= '".$enddate."'"; -if ($conf->global->COMMISSION_BASE == "MARGIN") - $sql .= " AND d.buy_price_ht IS NOT NULL"; -if (($conf->global->COMMISSION_BASE == "MARGIN") && isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) - $sql .= " AND d.buy_price_ht <> 0"; -if ($agentid > 0) - $sql.= " GROUP BY s.rowid"; -else - $sql.= " GROUP BY u.rowid"; -$sql.= " ORDER BY $sortfield $sortorder "; -//$sql.= $db->plimit($conf->liste_limit +1, $offset); - -$result = $db->query($sql); -if ($result) -{ - $num = $db->num_rows($result); - - print '
'; - print_barre_liste($langs->trans("CommissionDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); - - $i = 0; - print ""; - - print ''; - if ($agentid > 0) - print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); - else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); - - // product commission - if ($conf->global->COMMISSION_BASE == "MARGIN") - print_liste_field_titre($langs->trans("ProductMargin"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "TURNOVER") - print_liste_field_titre($langs->trans("ProductTurnover"),$_SERVER["PHP_SELF"],"productBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ProductCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - // service commission - if ($conf->global->COMMISSION_BASE == "MARGIN") - print_liste_field_titre($langs->trans("ServiceMargin"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - elseif ($conf->global->COMMISSION_BASE == "TURNOVER") - print_liste_field_titre($langs->trans("ServiceTurnover"),$_SERVER["PHP_SELF"],"serviceBase","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print_liste_field_titre($langs->trans("CommissionRate"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - print_liste_field_titre($langs->trans("ServiceCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - // total commission - print_liste_field_titre($langs->trans("TotalCommission"),$_SERVER["PHP_SELF"],"","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); - - print "\n"; - - $cumul_base_produit = 0; - $cumul_base_service = 0; - $cumul_commission_produit = 0; - $cumul_commission_service = 0; - $rounding = min($conf->global->MAIN_MAX_DECIMALS_UNIT,$conf->global->MAIN_MAX_DECIMALS_TOT); - if ($num > 0) - { - $var=True; - while ($i < $num && $i < $conf->liste_limit) - { - $objp = $db->fetch_object($result); - - $var=!$var; - - print ""; - if ($agentid > 0) { - $companystatic->id=$objp->socid; - $companystatic->nom=$objp->nom; - $companystatic->client=$objp->client; - print "\n"; - } - else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; - } - - // product commission - $productCommissionRate=(! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0); - $productBase=(! empty($objp->productBase)?$objp->productBase:0); - $productCommission = (! empty($productBase)?($productCommissionRate * $productBase / 100):0); - print "\n"; - print "\n"; - print "\n"; - - // service commission - $serviceCommissionRate=(! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0); - $serviceBase=(! empty($objp->serviceBase)?$objp->serviceBase:0); - $serviceCommission = (! empty($serviceBase)?($serviceCommissionRate * $serviceBase / 100):0); - print "\n"; - print "\n"; - print "\n"; - - // total commission - print "\n"; - print "\n"; - - $i++; - - $cumul_base_produit += round($productBase, $rounding); - $cumul_base_service += round($serviceBase, $rounding); - $cumul_commission_produit += round($productCommission, $rounding); - $cumul_commission_service += round($serviceCommission, $rounding); - } - } - - // affichage totaux commission - $var=!$var; - print ''; - print '"; - // product commission - print "\n"; - print "\n"; - print "\n"; - // service commission - print "\n"; - print "\n"; - print "\n"; - // total commission - print "\n"; - - print "\n"; - - print ""; - print "
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".price($productBase)."".price($productCommissionRate)."".price($productCommission)."".price($serviceBase)."".price($serviceCommissionRate)."".price($serviceCommission)."".price($productCommission + $serviceCommission)."
'; - print $langs->trans('Total'); - print "".price($cumul_base_produit)."".price((! empty($conf->global->PRODUCT_COMMISSION_RATE)?$conf->global->PRODUCT_COMMISSION_RATE:0))."".price($cumul_commission_produit)."".price($cumul_base_service)."".price((! empty($conf->global->SERVICE_COMMISSION_RATE)?$conf->global->SERVICE_COMMISSION_RATE:0))."".price($cumul_commission_service)."".price($cumul_commission_produit + $cumul_commission_service)."
"; -} -else -{ - dol_print_error($db); -} -$db->free($result); - - -llxFooter(); -$db->close(); -?> - \ No newline at end of file diff --git a/htdocs/commissions/lib/commissions.lib.php b/htdocs/commissions/lib/commissions.lib.php deleted file mode 100644 index aa87720968c..00000000000 --- a/htdocs/commissions/lib/commissions.lib.php +++ /dev/null @@ -1,52 +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 /htdocs/commissions/lib/commissions.lib.php - * \ingroup commissions - * \brief Library for common commissions functions - */ - -/** - * Define head array for tabs of marges tools setup pages - * - * @return Array of head - */ -function commissions_admin_prepare_head() -{ - global $langs, $conf; - - $h = 0; - $head = array(); - - $head[$h][0] = DOL_URL_ROOT.'/commissions/admin/commissions.php'; - $head[$h][1] = $langs->trans("Parameters"); - $head[$h][2] = 'parameters'; - $h++; - - // Show more tabs from modules - // Entries must be declared in modules descriptor with line - // $this->tabs = array('entity:+tabname:Title:@mymodule:/mymodule/mypage.php?id=__ID__'); to add new tab - // $this->tabs = array('entity:-tabname); to remove a tab - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin'); - - complete_head_from_modules($conf,$langs,'',$head,$h,'commissionsadmin','remove'); - - return $head; -} - -?> diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index b41fa735e7c..4e168d0645f 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -336,7 +336,6 @@ class FactureRec extends Facture $line->total_ht = $objp->total_ht; $line->total_tva = $objp->total_tva; $line->total_ttc = $objp->total_ttc; - $line->export_compta = $objp->fk_export_compta; $line->code_ventilation = $objp->fk_code_ventilation; $line->rang = $objp->rang; $line->special_code = $objp->special_code; diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index ace5e15312c..f3427ee5d4b 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -455,7 +455,7 @@ class Facture extends CommonInvoice } } else if ($reshook < 0) $error++; - + // Appel des triggers include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); @@ -866,7 +866,7 @@ class Facture extends CommonInvoice $this->extraparams = (array) json_decode($obj->extraparams, true); if ($this->statut == 0) $this->brouillon = 1; - + // Retreive all extrafield for invoice // fetch optionals attributes and labels if(!class_exists('Extrafields')) @@ -925,7 +925,7 @@ class Facture extends CommonInvoice $sql.= ' l.localtax1_tx, l.localtax2_tx, l.remise, l.remise_percent, l.fk_remise_except, l.subprice,'; $sql.= ' l.rang, l.special_code,'; $sql.= ' l.date_start as date_start, l.date_end as date_end,'; - $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_export_compta, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; + $sql.= ' l.info_bits, l.total_ht, l.total_tva, l.total_localtax1, l.total_localtax2, l.total_ttc, l.fk_code_ventilation, l.fk_product_fournisseur_price as fk_fournprice, l.buy_price_ht as pa_ht,'; $sql.= ' p.ref as product_ref, p.fk_product_type as fk_product_type, p.label as product_label, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON l.fk_product = p.rowid'; @@ -970,7 +970,6 @@ class Facture extends CommonInvoice $line->total_localtax1 = $objp->total_localtax1; $line->total_localtax2 = $objp->total_localtax2; $line->total_ttc = $objp->total_ttc; - $line->export_compta = $objp->fk_export_compta; $line->code_ventilation = $objp->fk_code_ventilation; $line->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $line->fk_fournprice, $objp->pa_ht); @@ -1860,7 +1859,7 @@ class Facture extends CommonInvoice } } } - + if ($error == 0) { $old_statut=$this->statut; @@ -1870,8 +1869,8 @@ class Facture extends CommonInvoice include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php'; $interface=new Interfaces($this->db); $result=$interface->run_triggers('BILL_UNVALIDATE',$this,$user,$langs,$conf); - if ($result < 0) { - $error++; + if ($result < 0) { + $error++; $this->errors=$interface->errors; $this->statut=$old_statut; $this->brouillon=0; @@ -1881,7 +1880,7 @@ class Facture extends CommonInvoice $this->db->rollback(); return -1; } - + if ($error == 0) { $this->db->commit(); @@ -3196,7 +3195,6 @@ class FactureLigne var $total_ttc; var $fk_code_ventilation = 0; - var $fk_export_compta = 0; var $date_start; var $date_end; @@ -3237,7 +3235,7 @@ class FactureLigne $sql.= ' fd.localtax1_tx, fd. localtax2_tx, fd.remise, fd.remise_percent, fd.fk_remise_except, fd.subprice,'; $sql.= ' fd.date_start as date_start, fd.date_end as date_end, fd.fk_product_fournisseur_price as fk_fournprice, fd.buy_price_ht as pa_ht,'; $sql.= ' fd.info_bits, fd.total_ht, fd.total_tva, fd.total_ttc, fd.total_localtax1, fd.total_localtax2, fd.rang,'; - $sql.= ' fd.fk_code_ventilation, fd.fk_export_compta,'; + $sql.= ' fd.fk_code_ventilation,'; $sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc'; $sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as fd'; $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON fd.fk_product = p.rowid'; @@ -3271,7 +3269,6 @@ class FactureLigne $this->total_localtax2 = $objp->total_localtax2; $this->total_ttc = $objp->total_ttc; $this->fk_code_ventilation = $objp->fk_code_ventilation; - $this->fk_export_compta = $objp->fk_export_compta; $this->rang = $objp->rang; $this->fk_fournprice = $objp->fk_fournprice; $marginInfos = getMarginInfos($objp->subprice, $objp->remise_percent, $objp->tva_tx, $objp->localtax1_tx, $objp->localtax2_tx, $this->fk_fournprice, $objp->pa_ht); @@ -3338,7 +3335,7 @@ class FactureLigne $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet'; $sql.= ' (fk_facture, fk_parent_line, label, description, qty, tva_tx, localtax1_tx, localtax2_tx,'; $sql.= ' fk_product, product_type, remise_percent, subprice, fk_remise_except,'; - $sql.= ' date_start, date_end, fk_code_ventilation, fk_export_compta, '; + $sql.= ' date_start, date_end, fk_code_ventilation, '; $sql.= ' rang, special_code, fk_product_fournisseur_price, buy_price_ht,'; $sql.= ' info_bits, total_ht, total_tva, total_ttc, total_localtax1, total_localtax2)'; $sql.= " VALUES (".$this->fk_facture.","; @@ -3357,7 +3354,6 @@ class FactureLigne $sql.= " ".(! empty($this->date_start)?"'".$this->db->idate($this->date_start)."'":"null").","; $sql.= " ".(! empty($this->date_end)?"'".$this->db->idate($this->date_end)."'":"null").","; $sql.= ' '.$this->fk_code_ventilation.','; - $sql.= ' '.$this->fk_export_compta.','; $sql.= ' '.$this->rang.','; $sql.= ' '.$this->special_code.','; $sql.= ' '.(! empty($this->fk_fournprice)?$this->fk_fournprice:"null").','; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 553262a3b4b..bc89cf7de7e 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -43,6 +43,8 @@ if ($user->societe_id > 0) * View */ +$userstatic=new User($db); + llxHeader(); if ($socid > 0) @@ -135,7 +137,7 @@ if ($socid > 0) $var=!$var; print ""; - print "".dol_print_date($fac->date)."\n"; + print "".dol_print_date($fac->date,'day')."\n"; print ''.img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."\n"; print ''.$fac->getLibStatut(2,$totalpaye).''; @@ -146,8 +148,12 @@ if ($socid > 0) print ' '; print ''.price($solde)."\n"; - // Auteur - print ''.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.''; + // Author + $userstatic->id=$objf->userid; + $userstatic->login=$objf->login; + print ''; + print $userstatic->getLoginUrl(1); + print ''; print "\n"; @@ -172,7 +178,7 @@ if ($socid > 0) $objp = $db->fetch_object($resqlp); //$var=!$var; print ""; - print ''.dol_print_date($db->jdate($objp->dp))."\n"; + print ''.dol_print_date($db->jdate($objp->dp),'day')."\n"; print ''; print '      '; // Decalage print ''.img_object($langs->trans("ShowPayment"),"payment").' '.$langs->trans("Payment").' '.$objp->rowid.''; @@ -182,8 +188,12 @@ if ($socid > 0) $solde = $solde - $objp->amount; print ''.price($solde)."\n"; - // Auteur - print ''.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.''; + // Author + $userstatic->id=$objp->userid; + $userstatic->login=$objp->login; + print ''; + print $userstatic->getLoginUrl(1); + print ''; print ''; @@ -214,5 +224,4 @@ else llxFooter(); $db->close(); - ?> diff --git a/htdocs/compta/ventilation/fournisseur/index.php b/htdocs/compta/ventilation/fournisseur/index.php index c10bb23a056..636891e7c18 100644 --- a/htdocs/compta/ventilation/fournisseur/index.php +++ b/htdocs/compta/ventilation/fournisseur/index.php @@ -39,7 +39,7 @@ print ''; $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facturedet"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) { @@ -50,7 +50,7 @@ if ($result) } $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."paiement"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) @@ -62,7 +62,7 @@ if ($result) } $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."facture_fourn_det"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) { @@ -73,7 +73,7 @@ if ($result) } /*$sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."paiementfourn"; -$sql .= " WHERE fk_export_compta = 0"; +$sql .= " WHERE fk_code_ventilation = 0"; $result = $db->query($sql); if ($result) diff --git a/htdocs/compta/ventilation/lignes.php b/htdocs/compta/ventilation/lignes.php index e5cf6bc8edd..c938e9774c4 100644 --- a/htdocs/compta/ventilation/lignes.php +++ b/htdocs/compta/ventilation/lignes.php @@ -48,7 +48,7 @@ if ($page < 0) $page = 0; $limit = $conf->liste_limit; $offset = $limit * $page ; -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.fk_code_ventilation, c.intitule, c.numero,"; +$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total_ttc as price, l.qty, l.rowid, l.tva_tx, l.fk_code_ventilation, c.intitule, c.numero,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."compta_compte_generaux as c"; @@ -72,7 +72,7 @@ if ($result) $num_lignes = $db->num_rows($result); $i = 0; - print_barre_liste("Lignes de facture ventil�es",$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); + print_barre_liste($langs->trans("InvoiceDispatched"),$page,"lignes.php","",$sortfield,$sortorder,'',$num_lignes); print '
'; print ''; @@ -136,7 +136,7 @@ else print "
"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/compta/ventilation/liste.php b/htdocs/compta/ventilation/liste.php index 70679d3a381..81613640541 100644 --- a/htdocs/compta/ventilation/liste.php +++ b/htdocs/compta/ventilation/liste.php @@ -54,7 +54,7 @@ $pageprev = $page - 1; $pagenext = $page + 1; $limit = $conf->liste_limit; -$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, l.price, l.rowid, l.fk_code_ventilation,"; +$sql = "SELECT f.facnumber, f.rowid as facid, l.fk_product, l.description, f.total as price, l.rowid, l.fk_code_ventilation,"; $sql.= " p.rowid as product_id, p.ref as product_ref, p.label as product_label, p.fk_product_type as type"; $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " , ".MAIN_DB_PREFIX."facturedet as l"; diff --git a/htdocs/contrat/class/contrat.class.php b/htdocs/contrat/class/contrat.class.php index d005396d829..398f30dd100 100644 --- a/htdocs/contrat/class/contrat.class.php +++ b/htdocs/contrat/class/contrat.class.php @@ -649,14 +649,16 @@ class Contrat extends CommonObject // Insert contract $sql = "INSERT INTO ".MAIN_DB_PREFIX."contrat (datec, fk_soc, fk_user_author, date_contrat,"; $sql.= " fk_commercial_signature, fk_commercial_suivi, fk_projet,"; - $sql.= " ref, entity)"; + $sql.= " ref, entity, note, note_public)"; $sql.= " VALUES (".$this->db->idate($now).",".$this->socid.",".$user->id; $sql.= ",".$this->db->idate($this->date_contrat); $sql.= ",".($this->commercial_signature_id>0?$this->commercial_signature_id:"NULL"); $sql.= ",".($this->commercial_suivi_id>0?$this->commercial_suivi_id:"NULL"); - $sql.= ",".($this->fk_projet>0?$this->fk_projet:"NULL"); + $sql.= ",".($this->fk_project>0?$this->fk_project:"NULL"); $sql.= ", ".(dol_strlen($this->ref)<=0 ? "null" : "'".$this->ref."'"); $sql.= ", ".$conf->entity; + $sql.= ", ".(!empty($this->note)?("'".$this->db->escape($this->note)."'"):"NULL"); + $sql.= ", ".(!empty($this->note_public)?("'".$this->db->escape($this->note_public)."'"):"NULL"); $sql.= ")"; $resql=$this->db->query($sql); if ($resql) @@ -694,6 +696,12 @@ class Contrat extends CommonObject if (! $error) { + // Add linked object + if (! $error && $this->origin && $this->origin_id) + { + $ret = $this->add_object_linked(); + if (! $ret) dol_print_error($this->db); + } $this->db->commit(); return $this->id; } diff --git a/htdocs/contrat/fiche.php b/htdocs/contrat/fiche.php index ac56afab3ca..902dde79f17 100644 --- a/htdocs/contrat/fiche.php +++ b/htdocs/contrat/fiche.php @@ -176,27 +176,158 @@ if ($action == 'add' && $user->rights->contrat->creer) if (! $error) { - $object->socid = $socid; + $object->socid = $socid; $object->date_contrat = $datecontrat; $object->commercial_suivi_id = GETPOST('commercial_suivi_id','int'); $object->commercial_signature_id = GETPOST('commercial_signature_id','int'); $object->note = GETPOST('note','alpha'); + $object->note_public = GETPOST('note_public','alpha'); $object->fk_project = GETPOST('projectid','int'); $object->remise_percent = GETPOST('remise_percent','alpha'); $object->ref = GETPOST('ref','alpha'); - $result = $object->create($user,$langs,$conf); - if ($result > 0) - { - header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); - exit; - } - else { - $mesg='
'.$object->error.'
'; - } - $action='create'; + // If creation from another object of another module (Example: origin=propal, originid=1) + if ($_POST['origin'] && $_POST['originid']) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = $_POST['origin']; + if (preg_match('/^([^_]+)_([^_]+)/i',$_POST['origin'],$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + + // For compatibility + if ($element == 'order') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + + $object->origin = $_POST['origin']; + $object->origin_id = $_POST['originid']; + + // Possibility to add external linked objects with hooks + $object->linked_objects[$object->origin] = $object->origin_id; + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) + { + $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); + } + + $id = $object->create($user); + if ($id < 0) { + $mesg='
'.$object->error.'
'; + } + + if ($id > 0) + { + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $srcobject = new $classname($db); + + dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines"); + $result=$srcobject->fetch($object->origin_id); + if ($result > 0) + { + $srcobject->fetch_thirdparty(); + $lines = $srcobject->lines; + if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines(); + + $fk_parent_line=0; + $num=count($lines); + + for ($i=0;$i<$num;$i++) + { + $product_type=($lines[$i]->product_type?$lines[$i]->product_type:0); + + if ($product_type == 1) { //only services + // service prédéfini + if ($lines[$i]->fk_product > 0) + { + $product_static = new Product($db); + + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $prod = new Product($db, $lines[$i]->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$srcobject->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["libelle"])) ? $prod->multilangs[$outputlangs->defaultlang]["libelle"] : $lines[$i]->product_label; + } + else + { + $label = $lines[$i]->product_label; + } + + if ($conf->global->PRODUIT_DESC_IN_FORM) + $desc .= ($lines[$i]->desc && $lines[$i]->desc!=$lines[$i]->libelle)?dol_htmlentitiesbr($lines[$i]->desc):''; + } + else { + $desc = dol_htmlentitiesbr($lines[$i]->desc); + } + + $result = $object->addline( + $desc, + $lines[$i]->subprice, + $lines[$i]->qty, + $lines[$i]->tva_tx, + $lines[$i]->localtax1_tx, + $lines[$i]->localtax2_tx, + $lines[$i]->fk_product, + $lines[$i]->remise_percent, + $date_start =0, + $date_end =0, + 'HT', + 0, + $lines[$i]->info_bits, + $lines[$i]->fk_fournprice, + $lines[$i]->pa_ht + ); + + if ($result < 0) + { + $error++; + break; + } + + } + } + + } + else + { + $mesg=$srcobject->error; + $error++; + } + } + else + { + $mesg=$object->error; + $error++; + } + } + else + { + $result = $object->create($user,$langs,$conf); + if ($result > 0) + { + header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id); + exit; + } + else { + $mesg='
'.$object->error.'
'; + } + $action='create'; + } } } @@ -622,6 +753,51 @@ if ($action == 'create') $soc = new Societe($db); if ($socid>0) $soc->fetch($socid); + if (GETPOST('origin') && GETPOST('originid')) + { + // Parse element/subelement (ex: project_task) + $element = $subelement = GETPOST('origin'); + if (preg_match('/^([^_]+)_([^_]+)/i',GETPOST('origin'),$regs)) + { + $element = $regs[1]; + $subelement = $regs[2]; + } + + if ($element == 'project') + { + $projectid=GETPOST('originid'); + } + else + { + // For compatibility + if ($element == 'order' || $element == 'commande') { $element = $subelement = 'commande'; } + if ($element == 'propal') { $element = 'comm/propal'; $subelement = 'propal'; } + + dol_include_once('/'.$element.'/class/'.$subelement.'.class.php'); + + $classname = ucfirst($subelement); + $objectsrc = new $classname($db); + $objectsrc->fetch(GETPOST('originid')); + if (empty($objectsrc->lines) && method_exists($objectsrc,'fetch_lines')) $objectsrc->fetch_lines(); + $objectsrc->fetch_thirdparty(); + + $projectid = (!empty($objectsrc->fk_project)?$objectsrc->fk_project:''); + + $soc = $objectsrc->client; + + $note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : '')); + $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : ''); + + // Object source contacts list + $srccontactslist = $objectsrc->liste_contact(-1,'external',1); + } + } + else { + $projectid = GETPOST('projectid','int'); + $note_private = GETPOST("note"); + $note_public = GETPOST("note_public"); + } + $object->date_contrat = dol_now(); $numct = $object->getNextNumRef($soc); @@ -687,18 +863,18 @@ if ($action == 'create') if (! empty($conf->projet->enabled)) { print ''.$langs->trans("Project").''; - select_projects($soc->id,GETPOST("projectid"),"projectid"); + select_projects($soc->id,$projectid,"projectid"); print ""; } print ''.$langs->trans("NotePublic").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note_public', GETPOST('note_public'), '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); + $doleditor=new DolEditor('note_public', $note_public, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); print $doleditor->Create(1); /* print ''; */ @@ -706,11 +882,11 @@ if ($action == 'create') { print ''.$langs->trans("NotePrivate").''; require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; - $doleditor=new DolEditor('note', GETPOST('note'), '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); + $doleditor=new DolEditor('note', $note_private, '', '100', 'dolibarr_notes', 'In', 1, true, true, ROWS_3, 70); print $doleditor->Create(1); /* print '';*/ print ''; } @@ -721,6 +897,12 @@ if ($action == 'create') print "\n"; + if (is_object($objectsrc)) + { + print ''; + print ''; + } + print '
'; print "\n"; diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 26b8a0c5826..9058350747f 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -2141,7 +2141,7 @@ abstract class CommonObject $attributeKey = substr($key,8); // Remove 'options_' prefix // Add field of attribut if ($extrafields->attribute_type[$attributeKey] != 'separate') // Only for other type of separate - $sql.=",".$attributeKey; + $sql.=",".$attributeKey; } $sql .= ") VALUES (".$this->id; foreach($this->array_options as $key => $value) @@ -2695,7 +2695,8 @@ abstract class CommonObject global $form,$bc,$bcdd; $element=$this->element; - $text=''; + + $text=''; $description=''; $type=0; // Show product and description $type=(! empty($line->product_type)?$line->product_type:$line->fk_product_type); @@ -2703,27 +2704,25 @@ abstract class CommonObject if (! empty($line->date_start)) $type=1; // deprecated if (! empty($line->date_end)) $type=1; // deprecated - if ($line->fk_product > 0) - { - $product_static = new Product($this->db); - - $product_static->type=$line->fk_product_type; - $product_static->id=$line->fk_product; - $product_static->ref=$line->ref; - $text=$product_static->getNomUrl(1); - } - // Ligne en mode visu if ($action != 'editline' || $selected != $line->id) { - // Produit + // Product if ($line->fk_product > 0) { - // Define output language + $product_static = new Product($this->db); + + $product_static->type=$line->fk_product_type; + $product_static->id=$line->fk_product; + $product_static->ref=$line->ref; + $text=$product_static->getNomUrl(1); + + // Define output language (TODO Does this works ?) if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) { $this->fetch_thirdparty(); $prod = new Product($this->db); + $prod->fetch($line->fk_product); $outputlangs = $langs; $newlang=''; 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/company.lib.php b/htdocs/core/lib/company.lib.php index 8ba3a161712..f06e8027e5f 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -90,6 +90,11 @@ function societe_prepare_head($object) $head[$h][2] = 'note'; $h++; + $head[$h][0] = DOL_URL_ROOT.'/societe/consumption.php?socid='.$object->id; + $head[$h][1] = $langs->trans("Referers"); + $head[$h][2] = 'consumption'; + $h++; + // Attached files $head[$h][0] = DOL_URL_ROOT.'/societe/document.php?socid='.$object->id; $head[$h][1] = $langs->trans("Documents"); 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 c07360abd10..64f415ac085 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -805,17 +805,11 @@ function print_left_eldy_menu($db,$menu_array_before,$menu_array_after,&$tabMenu } // Compta simple - if (! empty($conf->comptabilite->enabled) && ! empty($conf->global->FACTURE_VENTILATION)) + if (! empty($conf->comptabilite->enabled) && ($conf->global->MAIN_FEATURES_LEVEL >= 2)) { $newmenu->add("/compta/ventilation/index.php?leftmenu=ventil",$langs->trans("Dispatch"),0,$user->rights->compta->ventilation->lire, '', $mainmenu, 'ventil'); if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/liste.php",$langs->trans("ToDispatch"),1,$user->rights->compta->ventilation->lire); if ($leftmenu=="ventil") $newmenu->add("/compta/ventilation/lignes.php",$langs->trans("Dispatched"),1,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/",$langs->trans("Setup"),1,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/fiche.php?action=create",$langs->trans("New"),2,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/param/comptes/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->parametrer); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/",$langs->trans("Export"),1,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/index.php?action=export",$langs->trans("New"),2,$user->rights->compta->ventilation->lire); - if ($leftmenu=="ventil") $newmenu->add("/compta/export/liste.php",$langs->trans("List"),2,$user->rights->compta->ventilation->lire); } // Compta expert diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php index 56e0d90fdb3..39c70faab79 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_merou.modules.php @@ -546,10 +546,10 @@ class pdf_expedition_merou extends ModelePdfExpedition $object->GetUrlTrackingStatus($object->tracking_number); if (! empty($object->tracking_url)) { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); $label=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; } else diff --git a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php index 172966b89cf..368527612f1 100644 --- a/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php +++ b/htdocs/core/modules/expedition/doc/pdf_expedition_rouget.modules.php @@ -189,10 +189,10 @@ class pdf_expedition_rouget extends ModelePdfExpedition $object->GetUrlTrackingStatus($object->tracking_number); if (! empty($object->tracking_url)) { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$outputlangs->getLabelFromKey($this->db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$outputlangs->getLabelFromKey($this->db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); $label=$outputlangs->trans("LinkToTrackYourPackage")."
"; $label.=$outputlangs->trans("SendingMethod".strtoupper($code))." :"; $pdf->SetFont('','B', $default_font_size - 2); diff --git a/htdocs/core/modules/modBanque.class.php b/htdocs/core/modules/modBanque.class.php index 1bae9f61129..832d96a194b 100644 --- a/htdocs/core/modules/modBanque.class.php +++ b/htdocs/core/modules/modBanque.class.php @@ -65,7 +65,7 @@ class modBanque extends DolibarrModules // Config pages //------------- - $this->config_page_url = array("bank.php@compta/bank"); + $this->config_page_url = array("bank.php"); // Dependancies $this->depends = array(); diff --git a/htdocs/core/modules/modCommissions.class.php b/htdocs/core/modules/modCommissions.class.php deleted file mode 100644 index 64908f5248c..00000000000 --- a/htdocs/core/modules/modCommissions.class.php +++ /dev/null @@ -1,169 +0,0 @@ - - * Copyright (C) 2012 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 . - */ - -/** - * \defgroup commissions Module commissions - * \brief Module commissions - * \file htdocs/core/modules/modCommissions.class.php - * \ingroup commissions - * \brief Description and activation file for module Commissions - */ -include_once DOL_DOCUMENT_ROOT .'/core/modules/DolibarrModules.class.php'; - - -/** - * Class to describe modude Commisions - */ -class modCommissions extends DolibarrModules -{ - /** - * Constructor - * - * @param DoliDB $db Database handler - */ - function __construct($db) - { - $this->db = $db; - - // Id for module (must be unique). - // Use here a free id (See in Home -> System information -> Dolibarr for list of used modules id). - $this->numero = 60000; - // Key text used to identify module (for permissions, menus, etc...) - $this->rights_class = 'Commissions'; - - // Family can be 'crm','financial','hr','projects','products','ecm','technic','other' - // It is used to group modules in module setup page - $this->family = "financial"; - // Module label (no space allowed), used if translation string 'ModuleXXXName' not found (where XXX is value of numeric property 'numero' of module) - $this->name = preg_replace('/^mod/i','',get_class($this)); - // Module description, used if translation string 'ModuleXXXDesc' not found (where XXX is value of numeric property 'numero' of module) - $this->description = "Commissions management"; - // Possible values for version are: 'development', 'experimental', 'dolibarr' or version - $this->version = 'experimental'; - // Key used in llx_const table to save module status enabled/disabled (where MYMODULE is value of property name of module in uppercase) - $this->const_name = 'MAIN_MODULE_'.strtoupper($this->name); - // Where to store the module in setup page (0=common,1=interface,2=other) - $this->special = 2; - // Name of png file (without png) used for this module. - // Png file must be in theme/yourtheme/img directory under name object_pictovalue.png. - $this->picto='commissions'; - - // Data directories to create when module is enabled. - $this->dirs = array(); - - // Config pages. Put here list of php page names stored in admmin directory used to setup module. - $this->config_page_url = array("commissions.php@commissions"); - - // Dependencies - $this->depends = array("modFacture", "modMargin"); // List of modules id that must be enabled if this module is enabled - $this->requiredby = array(); // List of modules id to disable if this one is disabled - $this->phpmin = array(5,1); // Minimum version of PHP required by module - $this->need_dolibarr_version = array(3,2); // Minimum version of Dolibarr required by module - $this->langfiles = array("commissions"); - - // Constants - $this->const = array(0=>array('COMMISSION_BASE',"chaine","TURNOVER",'Default commission base',0)); // List of particular constants to add when module is enabled - - // New pages on tabs - $this->tabs = array(); - - // Boxes - $this->boxes = array(); // List of boxes - $r=0; - - // Permissions - $this->rights = array(); // Permission array used by this module - $r=0; - - // Add here list of permission defined by an id, a label, a boolean and two constant strings. - // Example: - // $this->rights[$r][0] = 2000; // Permission id (must not be already used) - // $this->rights[$r][1] = 'Permision label'; // Permission label - // $this->rights[$r][3] = 1; // Permission by default for new user (0/1) - // $this->rights[$r][4] = 'level1'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $this->rights[$r][5] = 'level2'; // In php code, permission will be checked by test if ($user->rights->permkey->level1->level2) - // $r++; - - - // Main menu entries - $this->menu = array(); // List of menus to add - $r = 0; - - // left menu entry - $this->menu[$r]=array( - 'fk_menu'=>'fk_mainmenu=accountancy', // Put 0 if this is a top menu - 'type'=>'left', // This is a Top menu entry - 'titre'=>'Commissions', - 'mainmenu'=>'accountancy', - 'leftmenu'=>'commissions', // Use 1 if you also want to add left menu entries using this descriptor. Use 0 if left menu entries are defined in a file pre.inc.php (old school). - 'url'=>'/commissions/index.php', - 'langs'=>'commissions', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. - 'position'=>200, - 'enabled'=>'$conf->commissions->enabled', // Define condition to show or hide menu entry. Use '$conf->monmodule->enabled' if entry must be visible if module is enabled. - 'perms'=>'1', // Use 'perms'=>'$user->rights->monmodule->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++; - } - - /** - * Function called when module is enabled. - * The init function add constants, boxes, permissions and menus (defined in constructor) into Dolibarr database. - * It also creates data directories. - * - * @return int 1 if OK, 0 if KO - */ - function init() - { - $sql = array(); - - $result=$this->load_tables(); - - return $this->_init($sql); - } - - /** - * Function called when module is disabled. - * Remove from database constants, boxes and permissions from Dolibarr database. - * Data directories are not deleted. - * - * @return int 1 if OK, 0 if KO - */ - function remove() - { - $sql = array(); - - return $this->_remove($sql); - } - - - /** - * Create tables and keys required by module - * Files mymodule.sql and mymodule.key.sql with create table and create keys - * commands must be stored in directory /mymodule/sql/ - * This function is called by this->init. - * - * @return int <=0 if KO, >0 if OK - */ - function load_tables() - { - return; - } -} - -?> 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/core/tpl/objectline_view.tpl.php b/htdocs/core/tpl/objectline_view.tpl.php index abaef7a1910..051f4f98071 100644 --- a/htdocs/core/tpl/objectline_view.tpl.php +++ b/htdocs/core/tpl/objectline_view.tpl.php @@ -16,6 +16,8 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . * + * To use this template, the following var must be defined + * $type, $text, $description, $line */ ?> @@ -38,59 +40,59 @@ description) { - if ($line->description == '(CREDIT_NOTE)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); - } - elseif ($line->description == '(DEPOSIT)') - { - $discount=new DiscountAbsolute($this->db); - $discount->fetch($line->fk_remise_except); - echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); - // Add date of deposit - if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; - } - else - { - echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); - } + if ($line->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($line->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($this->db); + $discount->fetch($line->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($line->description); } } - else - { - if ($line->fk_product > 0) { + } + else + { + if ($line->fk_product > 0) { - echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); + echo $form->textwithtooltip($text,$description,3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); - // Show range - print_date_range($line->date_start, $line->date_end); + // Show range + echo get_date_range($line->date_start, $line->date_end); - // Add description in form - if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) - { - print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; - } + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($line->description) && $line->description!=$line->product_label)?'
'.dol_htmlentitiesbr($line->description):''; + } + } else { + + if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($line->label)) { + $text.= ' '.$line->label.''; + echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); } else { - - if (! empty($line->fk_parent_line)) echo img_picto('', 'rightarrow'); - if ($type==1) $text = img_object($langs->trans('Service'),'service'); - else $text = img_object($langs->trans('Product'),'product'); - - if (! empty($line->label)) { - $text.= ' '.$line->label.''; - echo $form->textwithtooltip($text,dol_htmlentitiesbr($line->description),3,'','',$i,0,($line->fk_parent_line?img_picto('', 'rightarrow'):'')); - } else { - echo $text.' '.dol_htmlentitiesbr($line->description); - } - - // Show range - print_date_range($line->date_start,$line->date_end); + echo $text.' '.dol_htmlentitiesbr($line->description); } + + // Show range + echo get_date_range($line->date_start,$line->date_end); } - ?> + } + ?> tva_tx,'%',$line->info_bits); ?> 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/expedition/class/expedition.class.php b/htdocs/expedition/class/expedition.class.php index cac81eda070..393a316df15 100644 --- a/htdocs/expedition/class/expedition.class.php +++ b/htdocs/expedition/class/expedition.class.php @@ -51,7 +51,6 @@ class Expedition extends CommonObject var $origin; var $origin_id; var $lines=array(); - var $expedition_method_id; // deprecated var $shipping_method_id; var $tracking_number; var $tracking_url; @@ -203,7 +202,7 @@ class Expedition extends CommonObject $sql.= ", ".($this->date_delivery>0?"'".$this->db->idate($this->date_delivery)."'":"null"); $sql.= ", ".$this->socid; $sql.= ", ".($this->fk_delivery_address>0?$this->fk_delivery_address:"null"); - $sql.= ", ".($this->expedition_method_id>0?$this->expedition_method_id:"null"); + $sql.= ", ".($this->shipping_method_id>0?$this->shipping_method_id:"null"); $sql.= ", '".$this->db->escape($this->tracking_number)."'"; $sql.= ", ".$this->weight; $sql.= ", ".$this->sizeS; // TODO Should use this->trueDepth @@ -373,7 +372,6 @@ class Expedition extends CommonObject $this->date_delivery = $this->db->jdate($obj->date_delivery); // Date planed $this->fk_delivery_address = $obj->fk_address; $this->modelpdf = $obj->model_pdf; - $this->expedition_method_id = $obj->fk_expedition_methode; // TODO deprecated $this->shipping_method_id = $obj->fk_expedition_methode; $this->tracking_number = $obj->tracking_number; $this->origin = ($obj->origin?$obj->origin:'commande'); // For compatibility @@ -683,7 +681,7 @@ class Expedition extends CommonObject if (isset($this->fk_user_author)) $this->fk_user_author=trim($this->fk_user_author); if (isset($this->fk_user_valid)) $this->fk_user_valid=trim($this->fk_user_valid); if (isset($this->fk_delivery_address)) $this->fk_delivery_address=trim($this->fk_delivery_address); - if (isset($this->expedition_method_id)) $this->expedition_method_id=trim($this->expedition_method_id); + if (isset($this->shipping_method_id)) $this->shipping_method_id=trim($this->shipping_method_id); if (isset($this->tracking_number)) $this->tracking_number=trim($this->tracking_number); if (isset($this->statut)) $this->statut=trim($this->statut); if (isset($this->trueDepth)) $this->trueDepth=trim($this->trueDepth); @@ -714,7 +712,7 @@ class Expedition extends CommonObject $sql.= " date_expedition=".(dol_strlen($this->date_expedition)!=0 ? "'".$this->db->idate($this->date_expedition)."'" : 'null').","; $sql.= " date_delivery=".(dol_strlen($this->date_delivery)!=0 ? "'".$this->db->idate($this->date_delivery)."'" : 'null').","; $sql.= " fk_address=".(isset($this->fk_delivery_address)?$this->fk_delivery_address:"null").","; - $sql.= " fk_expedition_methode=".((isset($this->expedition_method_id) && $this->expedition_method_id > 0)?$this->expedition_method_id:"null").","; + $sql.= " fk_shipping_method=".((isset($this->shipping_method_id) && $this->shipping_method_id > 0)?$this->shipping_method_id:"null").","; $sql.= " tracking_number=".(isset($this->tracking_number)?"'".$this->db->escape($this->tracking_number)."'":"null").","; $sql.= " fk_statut=".(isset($this->statut)?$this->statut:"null").","; $sql.= " height=".(($this->trueHeight != '')?$this->trueHeight:"null").","; @@ -1291,11 +1289,11 @@ class Expedition extends CommonObject { $code=''; - if (! empty($this->expedition_method_id)) + if (! empty($this->shipping_method_id)) { $sql = "SELECT em.code, em.tracking"; $sql.= " FROM ".MAIN_DB_PREFIX."c_shipment_mode as em"; - $sql.= " WHERE em.rowid = ".$this->expedition_method_id; + $sql.= " WHERE em.rowid = ".$this->shipping_method_id; $resql = $this->db->query($sql); if ($resql) diff --git a/htdocs/expedition/fiche.php b/htdocs/expedition/fiche.php index 21289f60864..bcb55bb3ef8 100644 --- a/htdocs/expedition/fiche.php +++ b/htdocs/expedition/fiche.php @@ -104,7 +104,7 @@ if ($action == 'add') $object->ref_customer = $objectsrc->ref_client; $object->date_delivery = $date_delivery; // Date delivery planed $object->fk_delivery_address = $objectsrc->fk_delivery_address; - $object->expedition_method_id = GETPOST('expedition_method_id','int'); + $object->shipping_method_id = GETPOST('shipping_method_id','int'); $object->tracking_number = GETPOST('tracking_number','alpha'); $object->ref_int = GETPOST('ref_int','alpha'); @@ -260,7 +260,7 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl' || $action == 'settrueWidth' || $action == 'settrueHeight' || $action == 'settrueDepth' -|| $action == 'setexpedition_method_id') +|| $action == 'setshipping_method_id') { $error=0; @@ -274,7 +274,7 @@ else if ($action == 'settrackingnumber' || $action == 'settrackingurl' if ($action == 'settrueWidth') $shipping->trueWidth = trim(GETPOST('trueWidth','int')); if ($action == 'settrueHeight') $shipping->trueHeight = trim(GETPOST('trueHeight','int')); if ($action == 'settrueDepth') $shipping->trueDepth = trim(GETPOST('trueDepth','int')); - if ($action == 'setexpedition_method_id') $shipping->expedition_method_id = trim(GETPOST('expedition_method_id','int')); + if ($action == 'setshipping_method_id') $shipping->shipping_method_id = trim(GETPOST('shipping_method_id','int')); if (! $error) { @@ -658,7 +658,7 @@ if ($action == 'create') print "".$langs->trans("DeliveryMethod").""; print ''; $expe->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$expe->meths,GETPOST('expedition_method_id','int'),1,0,0,"",1); + print $form->selectarray("shipping_method_id",$expe->meths,GETPOST('shipping_method_id','int'),1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print "\n"; @@ -1105,26 +1105,26 @@ else print $langs->trans('SendingMethod'); print ''; - if ($action != 'editexpedition_method_id') print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).''; + if ($action != 'editshipping_method_id') print 'id.'">'.img_edit($langs->trans('SetSendingMethod'),1).''; print ''; print ''; - if ($action == 'editexpedition_method_id') + if ($action == 'editshipping_method_id') { - print ''; + print ''; print ''; - print ''; + print ''; $object->fetch_delivery_methods(); - print $form->selectarray("expedition_method_id",$object->meths,$object->expedition_method_id,1,0,0,"",1); + print $form->selectarray("shipping_method_id",$object->meths,$object->shipping_method_id,1,0,0,"",1); if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1); print ''; print ''; } else { - if ($object->expedition_method_id > 0) + if ($object->shipping_method_id > 0) { // Get code using getLabelFromKey - $code=$langs->getLabelFromKey($db,$object->expedition_method_id,'c_shipment_mode','rowid','code'); + $code=$langs->getLabelFromKey($db,$object->shipping_method_id,'c_shipment_mode','rowid','code'); print $langs->trans("SendingMethod".strtoupper($code)); } } 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 d5fb257cead..9728e9d4a29 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 @@ -81,6 +81,7 @@ alter table llx_socpeople CHANGE COLUMN cp zip varchar(10); alter table llx_societe_rib CHANGE COLUMN adresse_proprio owner_address text; alter table llx_societe_address CHANGE COLUMN ville town text; alter table llx_societe_address CHANGE COLUMN cp zip varchar(10); +alter table llx_expedition CHANGE COLUMN fk_expedition_methode fk_shipping_method integer; ALTER TABLE llx_c_shipment_mode ADD COLUMN tracking VARCHAR(256) NOT NULL DEFAULT '' AFTER description; @@ -153,7 +154,43 @@ ALTER TABLE llx_holiday ADD COLUMN note_public text; -- Add new trigger on Invoice BILL_UNVALIDATE + Index INSERT INTO llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (28,'BILL_UNVALIDATE','Customer invoice unvalidated','Executed when a customer invoice status set back to draft','facture',10); -ALTER TABLE llx_c_action_trigger ADD INDEX idx_action_trigger_rang (rang) +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); 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_facture_fourn_det.sql b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql index 16dacbbb336..325950a4e46 100644 --- a/htdocs/install/mysql/tables/llx_facture_fourn_det.sql +++ b/htdocs/install/mysql/tables/llx_facture_fourn_det.sql @@ -43,5 +43,6 @@ create table llx_facture_fourn_det product_type integer DEFAULT 0, date_start datetime DEFAULT NULL, -- date debut si service date_end datetime DEFAULT NULL, -- date fin si service + fk_code_ventilation integer DEFAULT 0 NOT NULL, import_key varchar(14) )ENGINE=innodb; diff --git a/htdocs/install/mysql/tables/llx_facturedet.sql b/htdocs/install/mysql/tables/llx_facturedet.sql index 847178d8330..949dee1933c 100644 --- a/htdocs/install/mysql/tables/llx_facturedet.sql +++ b/htdocs/install/mysql/tables/llx_facturedet.sql @@ -51,7 +51,6 @@ create table llx_facturedet buy_price_ht double(24,8) DEFAULT 0, -- prix d'achat HT fk_product_fournisseur_price integer DEFAULT NULL, -- reference prix fournisseur fk_code_ventilation integer DEFAULT 0 NOT NULL, - fk_export_compta integer DEFAULT 0 NOT NULL, special_code integer UNSIGNED DEFAULT 0, -- code pour les lignes speciales rang integer DEFAULT 0, -- ordre d'affichage import_key varchar(14) diff --git a/htdocs/install/mysql/tables/llx_paiement.sql b/htdocs/install/mysql/tables/llx_paiement.sql index 6787aee87fd..00680f29d69 100644 --- a/htdocs/install/mysql/tables/llx_paiement.sql +++ b/htdocs/install/mysql/tables/llx_paiement.sql @@ -18,10 +18,6 @@ -- -- =================================================================== - --- Satut, 0 ou 1, 1 n'est plus supprimable --- fk_export_compta 0 pas exporte - create table llx_paiement ( rowid integer AUTO_INCREMENT PRIMARY KEY, @@ -36,7 +32,6 @@ create table llx_paiement fk_bank integer NOT NULL DEFAULT 0, fk_user_creat integer, -- utilisateur qui a cree l'info fk_user_modif integer, -- utilisateur qui a modifie l'info - statut smallint DEFAULT 0 NOT NULL, - fk_export_compta integer DEFAULT 0 NOT NULL - + statut smallint DEFAULT 0 NOT NULL, -- Satut, 0 ou 1, 1 n'est plus supprimable + fk_export_compta integer DEFAULT 0 NOT NULL -- fk_export_compta 0 pas exporte )ENGINE=innodb; 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/ar_SA/main.lang b/htdocs/langs/ar_SA/main.lang index 5befea18b77..f273f913d04 100644 --- a/htdocs/langs/ar_SA/main.lang +++ b/htdocs/langs/ar_SA/main.lang @@ -428,8 +428,6 @@ NbOfThirdParties=عدد من الأطراف الثالثة NbOfCustomers=عدد من العملاء NbOfLines=عدد الخطوط NbOfObjects=عدد الأجسام -NbOfReferers=عدد referers -Referers=Referers TotalQuantity=الكمية الإجمالية DateFromTo=ل٪ من ق ق ٪ DateFrom=من ق ٪ diff --git a/htdocs/langs/ar_SA/members.lang b/htdocs/langs/ar_SA/members.lang index 570dfab4069..6b16226f9e5 100644 --- a/htdocs/langs/ar_SA/members.lang +++ b/htdocs/langs/ar_SA/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=وتبين من نوع '٪ ق' HTPasswordExport=الملف htpassword جيل NoThirdPartyAssociatedToMember=لم يرتبط بها من طرف ثالث لهذا العضو ThirdPartyDolibarr=Dolibarr طرف ثالث -MembersAndSubscriptions=وأعضاء Suscriptions +MembersAndSubscriptions=وأعضاء Subscriptions // Date 2009-08-11 13:27:01 // STOP - Lines generated via parser diff --git a/htdocs/langs/bg_BG/members.lang b/htdocs/langs/bg_BG/members.lang index c2fabf1da50..88d614bb1ad 100644 --- a/htdocs/langs/bg_BG/members.lang +++ b/htdocs/langs/bg_BG/members.lang @@ -163,7 +163,7 @@ ShowTypeCard=Покажи тип "%s" HTPasswordExport=htpassword файл поколение NoThirdPartyAssociatedToMember=Никоя трета страна, свързана с този потребител ThirdPartyDolibarr=Dolibarr трета страна -MembersAndSubscriptions=Членове и Suscriptions +MembersAndSubscriptions=Членове и Subscriptions MoreActions=Допълнително действие на запис MoreActionBankDirect=Създаване на директен запис на сделката по сметка MoreActionBankViaInvoice=Създаване на фактура и плащане по сметка diff --git a/htdocs/langs/ca_ES/commissions.lang b/htdocs/langs/ca_ES/commissions.lang deleted file mode 100644 index da97a4066f2..00000000000 --- a/htdocs/langs/ca_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - ca_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestió de comissions -commissionsSetup=Configuració de la gestió de comissions - -ProductCommissionRate=Taxa de comissió sobre els productes -ServiceCommissionRate=Taxa de comissió sobre els serveis - -ProductCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de productes -ServiceCommissionRateDetails=Taxa usada per calcular les comissions sobre les vendes de serveis - -Commissions=Comissions -CommissionDetails=Detall de comissions - -IncludeUnpayedInvoices=Incloure les factures no cobrades -TotalCommission=Total comissions - -ProductMargin=Marge / productes -ServiceMargin=Marge / serveis - -CommissionRate=Taxes comissions - -ProductCommission=Comissió / productes -ServiceCommission=Comissió / serveis - -CommissionBase=Base de càlcul de comissions -CommissionBasedOnTurnover=Comissions calculades sobre el volum de venda -CommissionBasedOnMargins=Comissions calculades sobre els marges -CommissionBaseDetails=Estableix el mètode de càlcul de les comissions -CommissionBasedOnMarginsDetails=El càlcul basat en els marges requereix l'activació del mòdul marges - -TurnoverTotal = Volum de vendes sense IVA -ProductTurnover=Vendes sense IVA / productes -ServiceTurnover=Vendes sense IVA / serveis - -CommercialAgent=Agent comercial - -StartDate=Data d'inici -EndDate=Data de fi -Launch=Començar \ No newline at end of file diff --git a/htdocs/langs/ca_ES/orders.lang b/htdocs/langs/ca_ES/orders.lang index 39ee41a4ca9..a0a49bb243c 100644 --- a/htdocs/langs/ca_ES/orders.lang +++ b/htdocs/langs/ca_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Nombre de comandes per mes AmountOfOrdersByMonthHT=Import total de comandes per mes (Sense IVA) ListOfOrders=Llistat de comandes CloseOrder=Tancar comanda -ConfirmCloseOrder=Esteu segur de voler tancar aquesta comanda? Un cop tancat, haurà de facturar-se -ConfirmCloseOrderIfSending=Esteu segur de voler tancar aquesta comanda? No ha de tancar una comanda que encara no té els seus productes enviats +ConfirmCloseOrder=Esteu segur que voleu classificar aquesta comanda com a enviat? Un cop enviat una comanda, només podrà facturar-se +ConfirmCloseOrderIfSending=Esteu segur que voleu tancar aquesta comanda? Només hauria de tancar una comanda quan aquesta hagi estat enviada completament. ConfirmDeleteOrder=Esteu segur de voler eliminar aquest comanda? ConfirmValidateOrder=Esteu segur de voler validar aquesta comanda sota la referència %s ? ConfirmUnvalidateOrder=Esteu segur de voler restaurar la comanda %s a l'estat esborrany? diff --git a/htdocs/langs/da_DK/members.lang b/htdocs/langs/da_DK/members.lang index c2975ad715c..9492f48514a 100644 --- a/htdocs/langs/da_DK/members.lang +++ b/htdocs/langs/da_DK/members.lang @@ -161,7 +161,7 @@ MemberId=Medlem id PaymentSubscription=Nye bidrag betaling NoThirdPartyAssociatedToMember=Nr. tredjepart forbundet til dette medlem ThirdPartyDolibarr=Dolibarr tredjepart -MembersAndSubscriptions=Medlemmer og Suscriptions +MembersAndSubscriptions=Medlemmer og Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 20:39:59). diff --git a/htdocs/langs/el_GR/members.lang b/htdocs/langs/el_GR/members.lang index 8343aff155c..270e3cd1f1e 100644 --- a/htdocs/langs/el_GR/members.lang +++ b/htdocs/langs/el_GR/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=Show type '%s' HTPasswordExport=htpassword file generation NoThirdPartyAssociatedToMember=No third party associated to this member ThirdPartyDolibarr=Dolibarr third party -MembersAndSubscriptions= Members and Suscriptions +MembersAndSubscriptions= Members and Subscriptions MoreActions=Complementary action on recording MoreActionBankDirect=Create a direct transaction record on account MoreActionBankViaInvoice=Create an invoice and payment on account diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 5e632efbe1e..a9aae951692 100644 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -369,7 +369,7 @@ Module1Desc=Companies and contact management (customers, prospects...) Module2Name=Commercial Module2Desc=Commercial management Module10Name=Accounting -Module10Desc=Simple accounting management (invoice and payment dispatching) +Module10Desc=Simple accounting reports (journals, turnover) based onto database content. No dispatching. Module20Name=Proposals Module20Desc=Commercial proposal management Module22Name=Mass E-mailings @@ -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/commissions.lang b/htdocs/langs/en_US/commissions.lang deleted file mode 100644 index 776f4d0c1a1..00000000000 --- a/htdocs/langs/en_US/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Commissions management -commissionsSetup=Commissions management setup - -ProductCommissionRate=Commission rate on products -ServiceCommissionRate=Commission rate on services - -ProductCommissionRateDetails=Commission rate on product sales -ServiceCommissionRateDetails=Commission rate on service sales - -Commissions=Commissions -CommissionDetails=Commissions details - -IncludeUnpayedInvoices=Include overdue invoices -TotalCommission=Commissions subtotal - -ProductMargin=Margin / products -ServiceMargin=Margin / services - -CommissionRate=Commission rate - -ProductCommission=Commission / produics -ServiceCommission=Commission / services - -CommissionBase=Commissions base -CommissionBasedOnTurnover=Commissions based on turnover -CommissionBasedOnMargins=Commissions based on margins -CommissionBaseDetails=Define calculation method for commissions -CommissionBasedOnMarginsDetails=Commissions based on margins needs margin module activation. - -TurnoverTotal = Total turrnover -ProductTurnover=Product turnover -ServiceTurnover=Service turnover - -CommercialAgent=Commercial agent - -StartDate=Start date -EndDate=End date -Launch=Start - -AgentContactType=Contact type used for commissioning -AgentContactTypeDetails=Défine what contact type (linked on invoices) will be associated with commercial agents \ No newline at end of file diff --git a/htdocs/langs/en_US/companies.lang b/htdocs/langs/en_US/companies.lang index 1ce5db6ccd4..0ae15edba41 100644 --- a/htdocs/langs/en_US/companies.lang +++ b/htdocs/langs/en_US/companies.lang @@ -392,6 +392,7 @@ UniqueThirdParties=Total of unique third parties InActivity=Open ActivityCeased=Closed ActivityStateFilter=Activity status +ProductsIntoElements=List of products into # Monkey MonkeyNumRefModelDesc=Return numero with format %syymm-nnnn for customer code and %syymm-nnnn for supplier code where yy is year, mm is month and nnnn is a sequence with no break and no return to 0. diff --git a/htdocs/langs/en_US/compta.lang b/htdocs/langs/en_US/compta.lang index c38ccd07d68..538b4f1784a 100644 --- a/htdocs/langs/en_US/compta.lang +++ b/htdocs/langs/en_US/compta.lang @@ -149,4 +149,6 @@ WarningDepositsNotIncluded=Deposits invoices are not included in this version wi DatePaymentTermCantBeLowerThanObjectDate=Payment term date can't be lower than object date. Pcg_version=Pcg version Pcg_type=Pcg type -Pcg_subtype=Pcg subtype \ No newline at end of file +Pcg_subtype=Pcg subtype +InvoiceLinesToDispatch=Invoice lines to dispatch +InvoiceDispatched=Dispatched invoices \ No newline at end of file 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/en_US/main.lang b/htdocs/langs/en_US/main.lang index 0b82960dab2..99a60857e3d 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -487,7 +487,7 @@ NbOfCustomers=Number of customers NbOfLines=Number of lines NbOfObjects=Number of objects NbOfReferers=Number of referrers -Referers=Referrers +Referers=Consumption TotalQuantity=Total quantity DateFromTo=From %s to %s DateFrom=From %s diff --git a/htdocs/langs/en_US/members.lang b/htdocs/langs/en_US/members.lang index 77657563851..e1eda16c790 100644 --- a/htdocs/langs/en_US/members.lang +++ b/htdocs/langs/en_US/members.lang @@ -155,7 +155,7 @@ ShowTypeCard=Show type '%s' HTPasswordExport=htpassword file generation NoThirdPartyAssociatedToMember=No third party associated to this member ThirdPartyDolibarr=Dolibarr third party -MembersAndSubscriptions= Members and Suscriptions +MembersAndSubscriptions= Members and Subscriptions MoreActions=Complementary action on recording MoreActionsOnSubscription=Complementary action, suggested by default when recording a subscription MoreActionBankDirect=Create a direct transaction record on account diff --git a/htdocs/langs/es_ES/commissions.lang b/htdocs/langs/es_ES/commissions.lang deleted file mode 100644 index 2077ca5990c..00000000000 --- a/htdocs/langs/es_ES/commissions.lang +++ /dev/null @@ -1,41 +0,0 @@ -# Dolibarr language file - es_ES - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestión de comisiones -commissionsSetup=Configuración de la gestión de comisiones - -ProductCommissionRate=Tasa de comisión sobre los productos -ServiceCommissionRate=Tasa de comisión sobre los servicios - -ProductCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de productos -ServiceCommissionRateDetails=Tasa usada para calcular las comisiones sobre las ventas de servicios - -Commissions=Comisiones -CommissionDetails=Detalle de comisiones - -IncludeUnpayedInvoices=Incluir las facturas no cobradas -TotalCommission=Total comisiones - -ProductMargin=Margen / productos -ServiceMargin=Margen / servicios - -CommissionRate=Tasas comisiones - -ProductCommission=Comisión / productos -ServiceCommission=Comisión / servicios - -CommissionBase=Base de cálculo de comisiones -CommissionBasedOnTurnover=Comisiones calculadas sobre el volumen de venta -CommissionBasedOnMargins=Comisiones calculadas sobre los márgenes -CommissionBaseDetails=Establece el método de cálculo de las comisiones -CommissionBasedOnMarginsDetails=El cálculo basado en los márgenes requiere la activación del módulo márgenes - -TurnoverTotal = Volumen de ventas sin IVA -ProductTurnover=Ventas sin IVA / productos -ServiceTurnover=Ventas sin IVA / servicios - -CommercialAgent=Agente comercial - -StartDate=Fecha de inicio -EndDate=Fecha de fin -Launch=Comenzar \ No newline at end of file diff --git a/htdocs/langs/es_ES/orders.lang b/htdocs/langs/es_ES/orders.lang index 65044ab09a7..3b1069cf7a6 100644 --- a/htdocs/langs/es_ES/orders.lang +++ b/htdocs/langs/es_ES/orders.lang @@ -84,8 +84,8 @@ NumberOfOrdersByMonth=Número de pedidos por mes AmountOfOrdersByMonthHT=Importe total de pedidos por mes (sin IVA) ListOfOrders=Listado de pedidos CloseOrder=Cerrar pedido -ConfirmCloseOrder=¿Está seguro de querer cerrar este pedido? Una vez cerrado, deberá facturarse -ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? No debe cerrar un pedido que aún no tiene sus productos enviados +ConfirmCloseOrder=¿Está seguro de querer clasificar este pedido como enviado? Una vez enviado un pedido, solo podrá facturarse +ConfirmCloseOrderIfSending=¿Está seguro de querer cerrar este pedido? Solamente debería cerrar un pedido cuando este haya sido enviado completamente. ConfirmDeleteOrder=¿Está seguro de querer eliminar este pedido? ConfirmValidateOrder=¿Está seguro de querer validar este pedido bajo la referencia %s ? ConfirmUnvalidateOrder=¿Está seguro de querer restaurar el pedido %s al estado borrador? diff --git a/htdocs/langs/et_EE/members.lang b/htdocs/langs/et_EE/members.lang index b2d7eb1bc7a..ef7bcef6304 100644 --- a/htdocs/langs/et_EE/members.lang +++ b/htdocs/langs/et_EE/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=Näita tüüp "%s" HTPasswordExport=htpassword fail põlvkonna NoThirdPartyAssociatedToMember=Ükski kolmas isik on seotud selle liige ThirdPartyDolibarr=Dolibarr kolmanda osapoole -MembersAndSubscriptions=Liikmete ja Suscriptions +MembersAndSubscriptions=Liikmete ja Subscriptions MoreActions=Täiendav tegevus salvestus MoreActionBankDirect=Loo otseseid tehingukulusid rekord konto MoreActionBankViaInvoice=Loo arve ja ettemaks diff --git a/htdocs/langs/fa_IR/members.lang b/htdocs/langs/fa_IR/members.lang index e7ecd54bf5c..b0a46554eb6 100644 --- a/htdocs/langs/fa_IR/members.lang +++ b/htdocs/langs/fa_IR/members.lang @@ -152,7 +152,7 @@ ShowTypeCard=وتبين من نوع '٪ ق' HTPasswordExport=الملف htpassword جيل NoThirdPartyAssociatedToMember=لم يرتبط بها من طرف ثالث لهذا العضو ThirdPartyDolibarr=Dolibarr طرف ثالث -MembersAndSubscriptions=وأعضاء Suscriptions +MembersAndSubscriptions=وأعضاء Subscriptions // Date 2009-08-11 13:27:01 // STOP - Lines generated via parser diff --git a/htdocs/langs/fi_FI/members.lang b/htdocs/langs/fi_FI/members.lang index b4c5c52f2d4..cad773224bc 100644 --- a/htdocs/langs/fi_FI/members.lang +++ b/htdocs/langs/fi_FI/members.lang @@ -159,7 +159,7 @@ MemberId=Jäsen id PaymentSubscription=Uusi osuus maksu NoThirdPartyAssociatedToMember=Kolmansista osapuolista ei näihin jäsen ThirdPartyDolibarr=Dolibarr kolmannen osapuolen -MembersAndSubscriptions=Jäsenet ja Suscriptions +MembersAndSubscriptions=Jäsenet ja Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 20:45:19). diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang index 3834defebc8..a20821cd61b 100644 --- a/htdocs/langs/fr_FR/admin.lang +++ b/htdocs/langs/fr_FR/admin.lang @@ -368,7 +368,7 @@ Module1Desc= Gestion des tiers (sociétés, particuliers) et contacts Module2Name= Commercial Module2Desc= Gestion commerciale Module10Name= Comptabilité -Module10Desc= Gestion simpliste de comptabilité (ventilation de factures et paiements uniquement) +Module10Desc= Activation de rapports simplistes de comptabilité (ca, journaux) basé sur la base. Pas de ventilation. Module20Name= Propositions commerciales Module20Desc= Gestion des devis/propositions commerciales Module22Name= EMailings @@ -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/commissions.lang b/htdocs/langs/fr_FR/commissions.lang deleted file mode 100644 index 5fb83f32320..00000000000 --- a/htdocs/langs/fr_FR/commissions.lang +++ /dev/null @@ -1,44 +0,0 @@ -# Dolibarr language file - fr_FR - commissions -CHARSET=UTF-8 - -Module60000Desc=Gestion des commissions -commissionsSetup=Paramétrage de la gestion des commissions - -ProductCommissionRate=Taux de commissionnement sur les produits -ServiceCommissionRate=Taux de commissionnement sur les services - -ProductCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de produits -ServiceCommissionRateDetails=Taux utilisé pour calculer les commissions sur les ventes de services - -Commissions=Commissions -CommissionDetails=Détail des commissions - -IncludeUnpayedInvoices=Inclure les factures non réglées -TotalCommission=Total des commissions - -ProductMargin=Marge / produits -ServiceMargin=Marge / services - -CommissionRate=Taux de commissionnement - -ProductCommission=Commission / produits -ServiceCommission=Commission / services - -CommissionBase=Base de calcul des commissions -CommissionBasedOnTurnover=Commissions calculées sur le CA -CommissionBasedOnMargins=Commissions calculées sur les marges -CommissionBaseDetails=Définit le mode de calcul des commissions -CommissionBasedOnMarginsDetails=Le calcul basé sur les marges nécessite l'activation du module marges. - -TurnoverTotal = Chiffre d'affaire réalisé HT -ProductTurnover=CA HT / produits -ServiceTurnover=CA HT / services - -CommercialAgent=Agent commercial - -StartDate=Date de début -EndDate=Date de fin -Launch=Démarrer - -AgentContactType=Type de contact commissionné -AgentContactTypeDetails=Permet de définir le type de contact associé aux factures qui sera associé aux agents commerciaux \ No newline at end of file diff --git a/htdocs/langs/fr_FR/companies.lang b/htdocs/langs/fr_FR/companies.lang index 254d1e8af16..99612d8ec2d 100644 --- a/htdocs/langs/fr_FR/companies.lang +++ b/htdocs/langs/fr_FR/companies.lang @@ -394,6 +394,7 @@ UniqueThirdParties=Total de tiers uniques InActivity=En activité ActivityCeased=Clos ActivityStateFilter=Statut d'activité +ProductsIntoElements=Liste des produits dans les %s # Monkey MonkeyNumRefModelDesc=Renvoie le numéro sous la forme %syymm-nnnn pour les codes clients et %syymm-nnnn pour les codes fournisseurs où yy est l'année, mm le mois et nnnn un compteur séquentiel sans rupture et sans remise à 0. diff --git a/htdocs/langs/fr_FR/compta.lang b/htdocs/langs/fr_FR/compta.lang index 01ba085620b..12ea0024f63 100644 --- a/htdocs/langs/fr_FR/compta.lang +++ b/htdocs/langs/fr_FR/compta.lang @@ -161,3 +161,5 @@ DatePaymentTermCantBeLowerThanObjectDate=La date limite de règlement ne peut ê Pcg_version=Version du plan Pcg_type=Classe de compte Pcg_subtype=Sous classe de compte +InvoiceLinesToDispatch=Lignes de factures à ventiler +InvoiceDispatched=Factures ventilées \ No newline at end of file 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/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index a7093fd8b75..b31b711f3a3 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -490,7 +490,7 @@ NbOfCustomers=Nombre de clients NbOfLines=Nombre de lignes NbOfObjects=Nombre d'objets NbOfReferers=Nombre de références -Referers=Référents +Referers=Consommation TotalQuantity=Quantité totale DateFromTo=Du %s au %s DateFrom=A partir du %s diff --git a/htdocs/langs/he_IL/members.lang b/htdocs/langs/he_IL/members.lang index b8f1a2389d0..647559b284a 100644 --- a/htdocs/langs/he_IL/members.lang +++ b/htdocs/langs/he_IL/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=הצג מסוג "%s" HTPasswordExport=htpassword הדור הקובץ NoThirdPartyAssociatedToMember=אין צד שלישי הקשור משתמש זה ThirdPartyDolibarr=Dolibarr צד שלישי -MembersAndSubscriptions=משתמשים ו Suscriptions +MembersAndSubscriptions=משתמשים ו Subscriptions MoreActions=פעולה משלימה על ההקלטה MoreActionBankDirect=יצירת הרשומה העסקה ישירה על חשבון MoreActionBankViaInvoice=יצירת חשבונית התשלום על חשבון diff --git a/htdocs/langs/hu_HU/members.lang b/htdocs/langs/hu_HU/members.lang index a1baf95f0c6..ff2cbf8d7ec 100644 --- a/htdocs/langs/hu_HU/members.lang +++ b/htdocs/langs/hu_HU/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=Mutasd típusú "%s" HTPasswordExport=htpassword fájl létrehozása NoThirdPartyAssociatedToMember=Harmadik félnek nem társult a tag ThirdPartyDolibarr=Dolibarr harmadik fél -MembersAndSubscriptions=A tagok és Suscriptions +MembersAndSubscriptions=A tagok és Subscriptions MoreActions=Kiegészítő fellépés a felvételi MoreActionBankDirect=Hozzon létre egy közvetlen tranzakciós rekord miatt MoreActionBankViaInvoice=Hozzon létre egy számlát és előleg diff --git a/htdocs/langs/is_IS/members.lang b/htdocs/langs/is_IS/members.lang index d64fc0dbd55..20f211f24ef 100644 --- a/htdocs/langs/is_IS/members.lang +++ b/htdocs/langs/is_IS/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=Sýna tegund ' %s ' HTPasswordExport=htpassword skrá kynslóð NoThirdPartyAssociatedToMember=Engar þriðja aðila í tengslum við þennan ThirdPartyDolibarr=Dolibarr þriðja aðila -MembersAndSubscriptions=Aðilar og Suscriptions +MembersAndSubscriptions=Aðilar og Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-06-30 00:15:29). diff --git a/htdocs/langs/it_IT/members.lang b/htdocs/langs/it_IT/members.lang index 4000e50c514..e1645587088 100644 --- a/htdocs/langs/it_IT/members.lang +++ b/htdocs/langs/it_IT/members.lang @@ -88,7 +88,7 @@ MemberModifiedInDolibarr =Membri modificati su Dolibarr MEMBER_NEWFORM_PAYONLINE =Saltate sulla integrato pagina di pagamento online MemberNotOrNoMoreExpectedToSubscribe =Membri non iscritti o non più attesi per iscrizione MemberPublicLinks =Link/pagine pubbliche -MembersAndSubscriptions =Deputati e Suscriptions +MembersAndSubscriptions =Deputati e Subscriptions MembersArea =Sezione riservata membri MembersAttributes =Attributi dei membri MembersByCountryDesc =Questa schermata mostra le statistiche dei membri per paese. Il grafico dipende da servizi online di Google ed è disponibile solo se il server può connettersi ad internet. diff --git a/htdocs/langs/ja_JP/members.lang b/htdocs/langs/ja_JP/members.lang index 4fee5b42355..afc8a3f759b 100644 --- a/htdocs/langs/ja_JP/members.lang +++ b/htdocs/langs/ja_JP/members.lang @@ -162,7 +162,7 @@ ShowTypeCard=タイプ "%s"を表示 HTPasswordExport=htpasswordファイルの生成 NoThirdPartyAssociatedToMember=このメンバに関連付けられているサードパーティません ThirdPartyDolibarr=Dolibarrサードパーティ -MembersAndSubscriptions=メンバーとSuscriptions +MembersAndSubscriptions=メンバーとSubscriptions MoreActions=記録上の相補的なアクション MoreActionBankDirect=アカウントに直接トランザクション·レコードを作成します。 MoreActionBankViaInvoice=アカウントの請求書と支払いを作成します。 diff --git a/htdocs/langs/nb_NO/members.lang b/htdocs/langs/nb_NO/members.lang index 471b4e735a9..62c8faf8822 100644 --- a/htdocs/langs/nb_NO/members.lang +++ b/htdocs/langs/nb_NO/members.lang @@ -29,7 +29,7 @@ DescADHERENT_CARD_TEXT_RIGHT=Tekst trykt på kort medlem (justere på høyre) DescADHERENT_MAILMAN_LISTS=Liste (er) for automatisk insription av nye medlemmer (separert med komma) NoThirdPartyAssociatedToMember=Ingen tredjepart knyttet til dette medlemmet ThirdPartyDolibarr=Dolibarr tredjepart -MembersAndSubscriptions=Medlemmer og Suscriptions +MembersAndSubscriptions=Medlemmer og Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-07-17 11:48:27). diff --git a/htdocs/langs/pl_PL/members.lang b/htdocs/langs/pl_PL/members.lang index 4782007adfd..0810e643b43 100644 --- a/htdocs/langs/pl_PL/members.lang +++ b/htdocs/langs/pl_PL/members.lang @@ -162,7 +162,7 @@ MemberId=Państwa id PaymentSubscription=Nowy wkład płatności NoThirdPartyAssociatedToMember=Nr trzeciej związane do tego członka ThirdPartyDolibarr=Dolibarr trzeciej -MembersAndSubscriptions=Członkowie i Suscriptions +MembersAndSubscriptions=Członkowie i Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:07:31). diff --git a/htdocs/langs/pt_PT/members.lang b/htdocs/langs/pt_PT/members.lang index 0c42a9c3295..d82002190b5 100644 --- a/htdocs/langs/pt_PT/members.lang +++ b/htdocs/langs/pt_PT/members.lang @@ -149,7 +149,7 @@ SetLinkToThirdParty=Link para uma Dolibarr terceiro SubscriptionId=Assinaturas id MemberId=Estados-id PaymentSubscription=Nova contribuição pagamento -MembersAndSubscriptions=Deputados e Suscriptions +MembersAndSubscriptions=Deputados e Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:10:10). diff --git a/htdocs/langs/ro_RO/members.lang b/htdocs/langs/ro_RO/members.lang index 067614c8b30..d14d60ab82b 100644 --- a/htdocs/langs/ro_RO/members.lang +++ b/htdocs/langs/ro_RO/members.lang @@ -160,7 +160,7 @@ MemberId=Statele id PaymentSubscription=New plata contribuţiei NoThirdPartyAssociatedToMember=Nu părţi terţe asociate la prezenta membru ThirdPartyDolibarr=Dolibarr terţă parte -MembersAndSubscriptions=Membrii şi Suscriptions +MembersAndSubscriptions=Membrii şi Subscriptions // STOP - Lines generated via autotranslator.php tool (2009-08-13 21:12:07). diff --git a/htdocs/langs/sv_SE/members.lang b/htdocs/langs/sv_SE/members.lang index bf398731fe3..ded4d0542d6 100644 --- a/htdocs/langs/sv_SE/members.lang +++ b/htdocs/langs/sv_SE/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=Visa typ "%s" HTPasswordExport=htpassword fil generation NoThirdPartyAssociatedToMember=Ingen tredje part som är associerade till denna medlem ThirdPartyDolibarr=Dolibarr tredje part -MembersAndSubscriptions=Medlemmar och Suscriptions +MembersAndSubscriptions=Medlemmar och Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-08-27 08:51:26). diff --git a/htdocs/langs/zh_TW/members.lang b/htdocs/langs/zh_TW/members.lang index c08035af7a1..1b344cfd452 100644 --- a/htdocs/langs/zh_TW/members.lang +++ b/htdocs/langs/zh_TW/members.lang @@ -157,7 +157,7 @@ ShowTypeCard=顯示類型'%s' HTPasswordExport=htpassword文件生成 NoThirdPartyAssociatedToMember=無關聯的第三方該會員 ThirdPartyDolibarr=Dolibarr第三者 -MembersAndSubscriptions=議員和Suscriptions +MembersAndSubscriptions=議員和Subscriptions // STOP - Lines generated via autotranslator.php tool (2010-06-08 21:22:55). diff --git a/htdocs/margin/agentMargins.php b/htdocs/margin/agentMargins.php index a195ef6de04..6ca0879a88a 100644 --- a/htdocs/margin/agentMargins.php +++ b/htdocs/margin/agentMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 Christophe Battarel * * 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 @@ -40,7 +40,13 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; +if (! $sortfield) +{ + if ($agentid > 0) + $sortfield="s.nom"; + else + $sortfield="u.name"; +} $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -75,7 +81,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'agentMargins', $titre, 0, $picto); -print '
'; +print ''; print ''; print ''; @@ -118,10 +124,11 @@ if (! empty($conf->global->DISPLAY_MARK_RATES)) { print "
'.$langs->trans('CommercialAgent').'
"; print '
'; -$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, sc.fk_user as agent,"; -$sql.= " u.login,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge" ; +$sql = "SELECT s.nom, s.rowid as socid, s.code_client, s.client, u.rowid as agent,"; +$sql.= " u.login, u.name, u.firstname,"; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge" ; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."element_contact e ON e.element_id = f.rowid and e.statut = 4 and e.fk_c_type_contact = ".(empty($conf->global->AGENT_CONTACT_TYPE)?-1:$conf->global->AGENT_CONTACT_TYPE); @@ -155,7 +162,8 @@ if ($agentid > 0) else $sql.= " GROUP BY u.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -163,7 +171,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print ""; @@ -172,7 +180,7 @@ if ($result) if ($agentid > 0) print_liste_field_titre($langs->trans("Customer"),$_SERVER["PHP_SELF"],"s.nom","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); else - print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.login","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); + print_liste_field_titre($langs->trans("CommercialAgent"),$_SERVER["PHP_SELF"],"u.name","","&agentid=".$agentid,'align="center"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("SellingPrice"),$_SERVER["PHP_SELF"],"selling_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); print_liste_field_titre($langs->trans("BuyingPrice"),$_SERVER["PHP_SELF"],"buying_price","","&agentid=".$agentid,'align="right"',$sortfield,$sortorder); @@ -191,7 +199,7 @@ if ($result) if ($num > 0) { $var=true; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); @@ -208,9 +216,8 @@ if ($result) print "\n"; } else { - $userstatic->id=$objp->agent; - $userstatic->login=$objp->login; - print "\n"; + $userstatic->fetch($objp->agent); + print "\n"; } print "\n"; print "\n"; diff --git a/htdocs/margin/customerMargins.php b/htdocs/margin/customerMargins.php index 23fb49dab87..a07d3192e9b 100644 --- a/htdocs/margin/customerMargins.php +++ b/htdocs/margin/customerMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 Christophe Battarel * * 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 @@ -40,10 +40,6 @@ $result = restrictedArea($user, 'societe','',''); $mesg = ''; -$sortfield = GETPOST("sortfield",'alpha'); -$sortorder = GETPOST("sortorder",'alpha'); -if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="s.nom"; $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -77,7 +73,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'customerMargins', $titre, 0, $picto); -print '
'; +print ''; print '
".$companystatic->getNomUrl(1,'customer')."".$userstatic->getLoginUrl(1)."".$userstatic->getFullName($langs,0,0,0)."".price($objp->selling_price)."".price($objp->buying_price)."
'; $client = false; @@ -105,6 +101,23 @@ else { print ''; } +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +if (! $sortorder) $sortorder="ASC"; +if (! $sortfield) +{ + if ($client) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="s.nom"; + $sortorder="ASC"; + } +} + // Start date print ''; print '
'.$langs->trans('StartDate').''; @@ -142,8 +155,9 @@ print ''; $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client, s.client,"; $sql.= " f.facnumber, f.total as total_ht,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -166,7 +180,8 @@ if ($client) else $sql.= " GROUP BY s.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -174,7 +189,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"",$sortfield,$sortorder,'',0,0,''); $i = 0; print ""; @@ -203,7 +218,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/productMargins.php b/htdocs/margin/productMargins.php index 4f22ba5599e..3b709559f28 100644 --- a/htdocs/margin/productMargins.php +++ b/htdocs/margin/productMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 Christophe Battarel * * 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 @@ -48,7 +48,20 @@ $mesg = ''; $sortfield = GETPOST("sortfield",'alpha'); $sortorder = GETPOST("sortorder",'alpha'); if (! $sortorder) $sortorder="ASC"; -if (! $sortfield) $sortfield="p.ref"; +if (! $sortfield) +{ + if ($id > 0) + { + $sortfield="f.datef"; + $sortorder="DESC"; + } + else + { + $sortfield="p.ref"; + $sortorder="ASC"; + } +} + $page = GETPOST("page",'int'); if ($page == -1) { $page = 0; } $offset = $conf->liste_limit * $page; @@ -83,7 +96,7 @@ $titre=$langs->trans("Margins"); $picto='margin'; dol_fiche_head($head, 'productMargins', $titre, 0, $picto); -print '
'; +print ''; print '
'; if ($id > 0) { @@ -144,8 +157,9 @@ print ''; $sql = "SELECT DISTINCT d.fk_product, p.label, p.rowid, p.fk_product_type, p.ref,"; $sql.= " f.facnumber, f.total as total_ht,"; -$sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price,"; -$sql.= " sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; +$sql.= " sum(d.total_ht) as selling_price,"; +$sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; +$sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."product as p"; @@ -170,7 +184,8 @@ if ($id > 0) else $sql.= " GROUP BY d.fk_product"; $sql.= " ORDER BY $sortfield $sortorder "; -$sql.= $db->plimit($conf->liste_limit +1, $offset); +// TODO: calculate total to display then restore pagination +//$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) @@ -178,7 +193,7 @@ if ($result) $num = $db->num_rows($result); print '
'; - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=".$id,$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -207,7 +222,7 @@ if ($result) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index 407f3603d49..326efc526d2 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 Christophe Battarel * * 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 @@ -130,7 +130,10 @@ if ($id > 0 || ! empty($ref)) $sql = "SELECT DISTINCT s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " (d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, (d.buy_price_ht * d.qty) as buying_price, d.qty, ((d.subprice - d.buy_price_ht) * d.qty) as marge," ; + $sql.= " d.total_ht as selling_price,"; + $sql.= $db->ifsql('f.type =2','(d.buy_price_ht * d.qty *-1)','(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','d.qty *-1','d.qty')." as qty,"; + $sql.= $db->ifsql('f.type =2','((d.price + d.buy_price_ht) * d.qty)','((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user "; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; @@ -148,14 +151,15 @@ if ($id > 0 || ! empty($ref)) if (isset($conf->global->ForceBuyingPriceIfNull) && $conf->global->ForceBuyingPriceIfNull == 1) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&id=$object->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -184,7 +188,7 @@ if ($id > 0 || ! empty($ref)) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); $var=!$var; diff --git a/htdocs/margin/tabs/thirdpartyMargins.php b/htdocs/margin/tabs/thirdpartyMargins.php index cbb42401b5a..643d190d04d 100644 --- a/htdocs/margin/tabs/thirdpartyMargins.php +++ b/htdocs/margin/tabs/thirdpartyMargins.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2012-2013 Christophe Battarel * * 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 @@ -128,7 +128,10 @@ if ($socid > 0) $sql = "SELECT distinct s.nom, s.rowid as socid, s.code_client,"; $sql.= " f.facnumber, f.total as total_ht,"; - $sql.= " sum(d.subprice * d.qty * (1 - d.remise_percent / 100)) as selling_price, sum(d.buy_price_ht * d.qty) as buying_price, sum(((d.subprice * (1 - d.remise_percent / 100)) - d.buy_price_ht) * d.qty) as marge," ; + $sql.= " sum(d.total_ht) as selling_price,"; + + $sql.= $db->ifsql('f.type =2','sum(d.buy_price_ht * d.qty *-1)','sum(d.buy_price_ht * d.qty)')." as buying_price, "; + $sql.= $db->ifsql('f.type =2','sum((d.price + d.buy_price_ht) * d.qty)','sum((d.price - d.buy_price_ht) * d.qty)')." as marge," ; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.rowid as facid"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."facture as f"; @@ -143,14 +146,15 @@ if ($socid > 0) $sql .= " AND d.buy_price_ht <> 0"; $sql.= " GROUP BY f.rowid"; $sql.= " ORDER BY $sortfield $sortorder "; - $sql.= $db->plimit($conf->liste_limit +1, $offset); + // TODO: calculate total to display then restore pagination + //$sql.= $db->plimit($conf->liste_limit +1, $offset); $result = $db->query($sql); if ($result) { $num = $db->num_rows($result); - print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',$num,0,''); + print_barre_liste($langs->trans("MarginDetails"),$page,$_SERVER["PHP_SELF"],"&socid=$societe->id",$sortfield,$sortorder,'',0,0,''); $i = 0; print "
"; @@ -176,7 +180,7 @@ if ($socid > 0) if ($num > 0) { $var=True; - while ($i < $num && $i < $conf->liste_limit) + while ($i < $num /*&& $i < $conf->liste_limit*/) { $objp = $db->fetch_object($result); 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/societe/consumption.php b/htdocs/societe/consumption.php new file mode 100644 index 00000000000..4f61d24a4aa --- /dev/null +++ b/htdocs/societe/consumption.php @@ -0,0 +1,439 @@ + + * Copyright (C) 2004-2012 Laurent Destailleur + * + * Version V1.1 Initial version of Philippe Berthet + * Version V2 Change to be compatible with 3.4 and enhanced to be more generic + * + * 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/societe/consumption.php + * \ingroup societe + * \brief Add a tab on thirpdarty view to list all products/services bought or sells by thirdparty + */ + +require("../main.inc.php"); +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.class.php'; +require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; + +// Security check +$socid = GETPOST('socid','int'); +if ($user->societe_id) $socid=$user->societe_id; +$result = restrictedArea($user, 'societe', $socid, '&societe'); +$object = new Societe($db); +if ($socid > 0) $object->fetch($socid); + +// Sort & Order fields +$sortfield = GETPOST("sortfield",'alpha'); +$sortorder = GETPOST("sortorder",'alpha'); +$page = GETPOST("page",'int'); +if ($page == -1) { + $page = 0; +} +$offset = $conf->liste_limit * $page; +if (! $sortorder) $sortorder='DESC'; +if (! $sortfield) $sortfield='datePrint'; +$limit = $conf->liste_limit; + +// Search fields +$sref=GETPOST("sref"); +$sprod_fulldescr=GETPOST("sprod_fulldescr"); +$month = GETPOST('month','int'); +$year = GETPOST('year','int'); + +// Clean up on purge search criteria ? +if (GETPOST("button_removefilter")) +{ + $sref=''; + $sprod_fulldescr=''; + $year=''; + $month=''; +} +// Customer or supplier selected in drop box +$thirdTypeSelect = GETPOST("third_select_id"); +$type_element = GETPOST('type_element')?GETPOST('type_element'):'invoice'; + +$langs->load("bills"); +$langs->load("orders"); +$langs->load("suppliers"); + + +/* + * Actions + */ + + + +/* + * View + */ + +$form = new Form($db); +$formother = new FormOther($db); +$productstatic=new Product($db); + +$titre = $langs->trans("Referer",$object->name); +llxHeader('',$titre,''); + +if (empty($socid)) +{ + dol_print_error($db); + exit; +} + +$head = societe_prepare_head($object); +dol_fiche_head($head, 'consumption', $langs->trans("ThirdParty"),0,'company'); + +print '
'; +print ''; +print ''; + +print '
'; +print ''; +print ''; + +if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field +{ + print ''; +} + +if ($object->client) +{ + print ''; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."facture where fk_soc = ".$socid; + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); + + $obj = $db->fetch_object($resql); + $nbFactsClient = $obj->nb; + $thirdTypeArray['customer']=$langs->trans("customer"); + if ($conf->facture->enabled) $elementTypeArray['invoice']=$langs->trans('Invoices'); + if ($conf->commande->enabled) $elementTypeArray['order']=$langs->trans('Orders'); +} + +if ($object->fournisseur) +{ + print ''; + $sql = "SELECT count(*) as nb from ".MAIN_DB_PREFIX."commande_fournisseur where fk_soc = ".$socid; + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); + + $obj = $db->fetch_object($resql); + $nbCmdsFourn = $obj->nb; + $thirdTypeArray['supplier']=$langs->trans("supplier"); + if ($conf->fournisseur->enabled) $elementTypeArray['supplier_invoice']=$langs->trans('SuppliersInvoices'); + if ($conf->fournisseur->enabled) $elementTypeArray['supplier_order']=$langs->trans('SuppliersOrders'); +} +print '
'.$langs->trans('ThirdPartyName').''; +print $form->showrefnav($object,'socid','',($user->societe_id?0:1),'rowid','nom'); +print '
'.$langs->trans('Prefix').''.$object->prefix_comm.'
'; + print $langs->trans('CustomerCode').''; + print $object->code_client; + if ($object->check_codeclient() <> 0) print ' ('.$langs->trans("WrongCustomerCode").')'; + print '
'; + print $langs->trans('SupplierCode').''; + print $object->code_fournisseur; + if ($object->check_codefournisseur() <> 0) print ' ('.$langs->trans("WrongSupplierCode").')'; + print '
'; + +dol_fiche_end(); +print '
'; + + +$sql_select=''; +if ($type_element == 'invoice') +{ // Customer : show products from invoices +$documentstatic=new Facture($db); +$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, '; +$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d"; +$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid; +$where.= " AND d.fk_facture = f.rowid"; +$where.= " AND f.entity = ".$conf->entity; +$datePrint = 'f.datef'; +$doc_number='f.facnumber'; +$thirdTypeSelect='customer'; +} +if ($type_element == 'order') +{ + // TODO + +} +if ($type_element == 'supplier_order') +{ // Supplier : Show products from orders. +$documentstatic=new CommandeFournisseur($db); +$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, "1" as doc_type, c.date_valid as datePrint, '; +$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d"; +$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid; +$where.= " AND d.fk_commande = c.rowid"; +$datePrint = 'c.date_creation'; +$doc_number='c.ref'; +$thirdTypeSelect='supplier'; +} +if ($type_element == 'supplier_invoice') +{ + // TODO + +} + +$sql = $sql_select; +$sql.= ' d.fk_product as product_id, d.fk_product as fk_product, d.label, d.description as description, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,'; +$sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,'; +$sql.= " s.rowid as socid, p.ref as prod_ref, p.label as product_label"; +$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from; +$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid '; +$sql.= $where; +if ($month > 0) { + if ($year > 0) { + $start = dol_mktime(0, 0, 0, $month, 1, $year); + $end = dol_time_plus_duree($start, 1 , 'm') - 1; + $sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; + } else { + $sql.= " AND date_format(".$datePrint.", '%m') = '".sprintf('%02d',$month)."'"; + } +} else if ($year > 0) { + $start = dol_mktime(0, 0, 0, 1, 1, $year); + $end = dol_time_plus_duree($start, 1 , 'y') - 1; + $sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'"; +} +if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'"; +$sql.= $db->order($sortfield,$sortorder); +$sql.= $db->plimit($limit + 1, $offset); + + +// Define type of elements +$typeElementString = $form->selectarray("type_element",$elementTypeArray,GETPOST('type_element')); +$button = ''; +$param="&sref=".$sref."&month=".$month."&year=".$year."&sprod_fulldescr=".$sprod_fulldescr."&socid=".$socid; + +print_barre_liste($langs->trans('ProductsIntoElements', $typeElementString.' '.$button), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', ''); + +if ($sql_select) +{ + dol_syslog("sql=".$sql); + $resql=$db->query($sql); + if (!$resql) dol_print_error($db); +} + +print ''."\n"; +// Titles with sort buttons +print ''; +print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'datePrint','',$param,'align="center" width="150"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder); +print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder); +// Filters +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; + +if ($sql_select) +{ + $var=true; + $num = $db->num_rows($resql); + $i = 0; + while (($objp = $db->fetch_object($resql)) && $i < $conf->liste_limit ) + { + $var=!$var; + print ""; + print ''; + print ''; + + print ''; + + //print ''; + + print ''; + + print "\n"; + $i++; + } + if ($num > $conf->liste_limit) { + print_barre_liste('', $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num); + } + $db->free($resql); +} +else { + print ''; +} + +print "
'; +print ''; +print ''; // date +print $formother->select_month($month?$month:-1,'month',1); +$formother->select_year($year?$year:-1,'year',1, 20, 1); +print ''; +print ''; +print ''; +print ''; +print ''; +print '
'; + $documentstatic->id=$objp->doc_id; + $documentstatic->ref=$objp->doc_number; + $documentstatic->type=$objp->type; + print $documentstatic->getNomUrl(1); + print ''.dol_print_date($db->jdate($objp->datePrint),'day').''; + + // Define text, description and type + $text=''; $description=''; $type=0; + + // Code to show product duplicated from commonobject->printObjectLine + if ($objp->fk_product > 0) + { + $product_static = new Product($db); + + $product_static->type=$objp->fk_product_type; + $product_static->id=$objp->fk_product; + $product_static->ref=$objp->ref; + $text=$product_static->getNomUrl(1); + } + + // Product + if ($objp->fk_product > 0) + { + // Define output language + if (! empty($conf->global->MAIN_MULTILANGS) && ! empty($conf->global->PRODUIT_TEXTS_IN_THIRDPARTY_LANGUAGE)) + { + $this->fetch_thirdparty(); + $prod = new Product($db); + $prod->fetch($objp->fk_product); + + $outputlangs = $langs; + $newlang=''; + if (empty($newlang) && GETPOST('lang_id')) $newlang=GETPOST('lang_id'); + if (empty($newlang)) $newlang=$this->client->default_lang; + if (! empty($newlang)) + { + $outputlangs = new Translate("",$conf); + $outputlangs->setDefaultLang($newlang); + } + + $label = (! empty($prod->multilangs[$outputlangs->defaultlang]["label"])) ? $prod->multilangs[$outputlangs->defaultlang]["label"] : $objp->product_label; + } + else + { + $label = $objp->product_label; + } + + $text.= ' - '.(! empty($objp->label)?$objp->label:$label); + $description=(! empty($conf->global->PRODUIT_DESC_IN_FORM)?'':dol_htmlentitiesbr($objp->description)); + } + + if (($objp->info_bits & 2) == 2) { ?> + + trans("ShowReduc"),'reduc').' '; + if ($objp->description == '(DEPOSIT)') $txt=$langs->trans("Deposit"); + //else $txt=$langs->trans("Discount"); + print $txt; + ?> + + description) + { + if ($objp->description == '(CREDIT_NOTE)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromCreditNote",$discount->getNomUrl(0)); + } + elseif ($objp->description == '(DEPOSIT)' && $objp->fk_remise_except > 0) + { + $discount=new DiscountAbsolute($db); + $discount->fetch($objp->fk_remise_except); + echo ($txt?' - ':'').$langs->transnoentities("DiscountFromDeposit",$discount->getNomUrl(0)); + // Add date of deposit + if (! empty($conf->global->INVOICE_ADD_DEPOSIT_DATE)) echo ' ('.dol_print_date($discount->datec).')'; + } + else + { + echo ($txt?' - ':'').dol_htmlentitiesbr($objp->description); + } + } + } + else + { + if ($objp->fk_product > 0) { + + echo $form->textwithtooltip($text,$description,3,'','',$i,0,''); + + // Show range + echo get_date_range($objp->date_start, $objp->date_end); + + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + print (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + } + + } else { + + //if (! empty($objp->fk_parent_line)) echo img_picto('', 'rightarrow'); + if ($type==1) $text = img_object($langs->trans('Service'),'service'); + else $text = img_object($langs->trans('Product'),'product'); + + if (! empty($objp->label)) { + $text.= ' '.$objp->label.''; + echo $form->textwithtooltip($text,dol_htmlentitiesbr($objp->description),3,'','',$i,0,''); + } else { + echo $text.' '.dol_htmlentitiesbr($objp->description); + } + + // Show range + echo get_date_range($objp->date_start,$objp->date_end); + } + } + + /* + $prodreftxt=''; + if ($objp->prod_id > 0) + { + $productstatic->id = $objp->prod_id; + $productstatic->ref = $objp->prod_ref; + $productstatic->status = $objp->prod_type; + $prodreftxt = $productstatic->getNomUrl(0); + if(!empty($objp->product_label)) $prodreftxt .= ' - '.$objp->product_label; + } + // Show range + $prodreftxt .= get_date_range($objp->date_start, $objp->date_end); + // Add description in form + if (! empty($conf->global->PRODUIT_DESC_IN_FORM)) + { + $prodreftxt .= (! empty($objp->description) && $objp->description!=$objp->product_label)?'
'.dol_htmlentitiesbr($objp->description):''; + } + */ + print '
'.$prodreftxt.''.$objp->prod_qty.'
'.$langs->trans("FeatureNotYetAvailable").'
"; +print ""; + + +/* + * Errors + */ + +dol_htmloutput_errors($warning); +dol_htmloutput_errors($error,$errors); + +llxFooter(); + +$db->close(); +?> diff --git a/htdocs/theme/amarok/img/cron.png b/htdocs/theme/amarok/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/amarok/img/object_cron.png b/htdocs/theme/amarok/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php index 8c92d9e561b..48fa2c8f5a3 100755 --- a/htdocs/theme/amarok/style.css.php +++ b/htdocs/theme/amarok/style.css.php @@ -120,6 +120,9 @@ a:hover, a:active { color:rgba(0,0,0,.6); } +input, input.flat, textarea, textarea.flat, form.flat select, select.flat { + padding: 1px; +} input, textarea { font-size:px; font-family:; @@ -812,7 +815,7 @@ td.vmenu { } div.fiche { - padding:8px 12px 10px; + padding:8px 6px 10px; margin-: browser->phone) || empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT))?'16':'24'; ?>px; margin-: browser->phone)?'12':'6'; ?>px; } @@ -1140,21 +1143,21 @@ tr.fiche { .ok { color:#159e26; background:url() left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } .warning { color:#bca936; background:url() left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } .error { color:#a61111; background:#f58080 url() left center no-repeat !important; - padding-left:20px; + padding-left:20px !important; font-weight:bold; } @@ -1163,7 +1166,7 @@ td.highlights {background:#f9c5c6;} div.ok { background:#61e372; /* url() 3px center no-repeat; */ /*color:#ffffff;*/ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; font-weight:normal; } @@ -1171,7 +1174,7 @@ div.ok { div.warning, div.info { background:#fcf5b8; /* url() 3px center no-repeat; */ /*color:#232323; */ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; border:1px solid #bca936; font-weight:normal; @@ -1180,7 +1183,7 @@ div.warning, div.info { div.error { background:#f58080; /* url() 3px center no-repeat; */ /* color:#ffffff; */ - padding:2px 4px 2px 24px; + padding:2px 4px 2px 6px; margin:0.5em 0em; border:1px solid #a61111; font-weight:normal; diff --git a/htdocs/theme/auguria/img/cron.png b/htdocs/theme/auguria/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/auguria/img/object_commissions.png b/htdocs/theme/auguria/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/auguria/img/object_cron.png b/htdocs/theme/auguria/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/bureau2crea/img/cron.png b/htdocs/theme/bureau2crea/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/bureau2crea/img/object_commissions.png b/htdocs/theme/bureau2crea/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/bureau2crea/img/object_cron.png b/htdocs/theme/bureau2crea/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/cameleo/img/cron.png b/htdocs/theme/cameleo/img/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 diff --git a/htdocs/theme/cameleo/img/object_commissions.png b/htdocs/theme/cameleo/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h diff --git a/htdocs/theme/cameleo/img/object_cron.png b/htdocs/theme/cameleo/img/object_cron.png new file mode 100644 index 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/img/menus/cron.png b/htdocs/theme/eldy/img/menus/cron.png new file mode 100644 index 0000000000000000000000000000000000000000..ddfe62e7b24f19698ca3b7d8c308865ec2bd4088 GIT binary patch literal 2165 zcmV-*2#WWKP) zhGCk@X*r@*SrN^}8T{p|e17pGwrwpVn@vQrU5H$luS8AMV{XGORpb zia<)yT3w~STfYRIWd=0;{%-Yf%`SuQ$ zS5r7mg$i7fnnaT>kuUK`5$h?D$YhnS>0;vIg|w8x8^*@&?y;SB-$T9GBv`#pShV(T80uqfkUhX6HYl)S(k32M934HSMubtMHk68_QmH{B zoylb4ND;>h5yxmM!V)1e@`+-fFp7z9y$pn*Q63!P$);=L@T)AUPDTtLI3`62L4vm%Nn~Px>ZZZu6Y3B*;cC=7p$2E-DVtwTX z5`&Z$(!6>KBU>bW*F7W(MKnz#jza_rDFuzd#zQ9*HktrU6QaIerPXp4jn$QvPj4>H zZ|dqUt2kW}q~l~i#fx?y7$HX`F8+*Aiq zEYOPm7`j0mMa<3q3*Yyy7z+yvM<=g-{$y|eCS<0F%J<>ioI_U)GG>b~xK7ip5*tZ! zS%XMAc-2V)p(9Wv@+GWd52OpIAV5Q)SvJXZT3w%=5!2IC*G$u#(fuG;*x1$i<6ZZU znwn)RbW;S48X{<5MNLwcz}6+U5z>}TlTMr1R!mS|C-8hCrIX0!NaymTGFi-I3f(j@ zO-ua!gQFZj`nOjc$9Y$Oc+W%4h57kXce!VDaN7=IC4|xpR1A^tAf$s%fUU*YT8O0_ z%&-Ao6X~`Hf&e|8Cz)h=1fJ~cg!@B7y*)7-yh za9g3+wNb@ZMxfcq5Mrs*hz@?2NE{pMjl zIDYKq#f6186+}8fv)NqNG_e>(;S-y;Y&F`8C54?9qOFrC-Hq>sg!L6{TKKL{wXSGr zC8FGB?5>@pN@X-ViO>usr4%0?f0uWTymf5i;>DkbQM3kND5VfWsIzC!9?532Wy3Ij zHTLu~Mo(YA@)Jq)bU`?^WtuCqXmJve%@J?x!N~QX=Qd(wiil(e!?IPY)e;{beV4ah zKRkZ=^!Q7Gl(V-7+qgY=Kyc#3iQfl7;H+0GzxdAMPi?sOYrDv_<&~Sr2v4Mlu(8{B zknFpgL~aA7WrLz5Rv16xBjlbkL?pc8L_I4_j$}I}|FIq7N2e&-1 zedo}j`|sbqZ)Ep_?AUoX=}a0FO5H{$A%v8YndwQ+ojJwHe|%KAaN+##rluzU7zDSH z?B2bb@$vC5s~QUb4Js&TCG-#`9JzMs-p~SO~oP900000NkvXXu0mjf<>nx% literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..b929050598d10d851b4bca1299e8cd75514a41cc GIT binary patch literal 655 zcmV;A0&x9_P)`xW z!{Lw=MWM-LV$|#Pmq`9;;qnNIsj7Mri9{$I4ihKOW;3zbW*^@<9F8Eza*l!?Oi)_` zjT(&xt=DT>E|;PTFRt!#xd^~qk#@V?db{14ayp&9g7a-G7SmR%72N|=4a0Z?``co% z2mx5PSS;l6c&O9qJb}+D=W@Bbd_M0RkHcDqg8Zub>>`;LOYKzD-vUUY4gr?IeRVtMpKtCwByn)dj300vL!`?A$)U2-K|*F_7Q$bupE9awy3RV`Ml z)eWfy4I~KplgXr@*z5JUXL3571d&)(6(f=qa5r)I-S77ePziExqtS?(&8A3XrMWjw z#25@D)wo}&P$-C30>^Wx_6SZ^@na^F336h!TJ3}CYuveT`~!AnW+vV$8+b-P&d&^0 p!Vuy5Ug1vw`g)E#{|NsC7yzo}QT`99$FKkZ002ovPDHLkV1izUCSd>o literal 0 HcmV?d00001 diff --git a/htdocs/theme/eldy/img/object_commissions.png b/htdocs/theme/eldy/img/object_commissions.png deleted file mode 100644 index 39f09967046b32c8563a44af9da1b0b454175626..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 651 zcmV;60(AX}P)FVe>ug)pt&qqU8XGoQof21v4uoQYD?CsA}0 zssidqY_F|yu=I*@xyHEx^+UmKw1T|<5?3X`*77&zKgDqxZY=8(t+sU>aF!@Vk&Q+n zOOsb4wHhJ1U8baV;|mQ^Lt&ubCcdzMdXcEC*uv}@AYj$l%jCH`HAOPE@drWLeD<&r zyghzO6abFH^O+|MUu`B8PqMm_Ang=!8~O>t|A;C(Rk9Tg;r63>Tkv&to*)2XFPXMo z)pw9vKPAexJgmiw^o@*S1@n09X8fVh3Bu3UQ#O#(bT`cIO&1qR zG&EgMt40!e+0IDqBX!M+h^j8!rKUMaW>!^IjUEn<+O^G*N&002ovPDHLkV1jd4IY$5h 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 From e9cbf94e06831f366cdb21b0b123ca48867fc973 Mon Sep 17 00:00:00 2001 From: simnandez Date: Fri, 22 Mar 2013 17:31:43 +0100 Subject: [PATCH 10/11] Trad: Add es_ES and ca_ES missing translations --- htdocs/langs/ca_ES/admin.lang | 17 +++++- htdocs/langs/ca_ES/bills.lang | 1 + htdocs/langs/ca_ES/companies.lang | 2 + htdocs/langs/ca_ES/compta.lang | 6 ++ htdocs/langs/ca_ES/cron.lang | 92 +++++++++++++++++++++++++++++++ htdocs/langs/ca_ES/main.lang | 2 +- htdocs/langs/ca_ES/sendings.lang | 1 + htdocs/langs/es_ES/admin.lang | 16 ++++-- htdocs/langs/es_ES/bills.lang | 1 + htdocs/langs/es_ES/companies.lang | 2 + htdocs/langs/es_ES/compta.lang | 8 ++- htdocs/langs/es_ES/cron.lang | 92 +++++++++++++++++++++++++++++++ htdocs/langs/es_ES/main.lang | 2 +- htdocs/langs/es_ES/sendings.lang | 1 + 14 files changed, 233 insertions(+), 10 deletions(-) create mode 100644 htdocs/langs/ca_ES/cron.lang create mode 100644 htdocs/langs/es_ES/cron.lang 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/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 From 34bfdb18466de4df7eb872a2f4d6ad7b820c2af5 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Fri, 22 Mar 2013 19:21:46 +0100 Subject: [PATCH 11/11] Fix: broken feature if the table has no field fk_parent_line --- htdocs/core/class/commonobject.class.php | 25 +++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) 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);