From 85469438981f29cf13e2caa7bb641f04055d0d5e Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:30:40 +0200 Subject: [PATCH 1/6] Create index.html --- htdocs/core/modules/holiday/index.html | 1 + 1 file changed, 1 insertion(+) create mode 100644 htdocs/core/modules/holiday/index.html diff --git a/htdocs/core/modules/holiday/index.html b/htdocs/core/modules/holiday/index.html new file mode 100644 index 00000000000..8b137891791 --- /dev/null +++ b/htdocs/core/modules/holiday/index.html @@ -0,0 +1 @@ + From ffaff97af121e56f82b2da8096fadb930c8a2f12 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:33:14 +0200 Subject: [PATCH 2/6] Create modules_holiday.php --- .../core/modules/holiday/modules_holiday.php | 146 ++++++++++++++++++ 1 file changed, 146 insertions(+) create mode 100644 htdocs/core/modules/holiday/modules_holiday.php diff --git a/htdocs/core/modules/holiday/modules_holiday.php b/htdocs/core/modules/holiday/modules_holiday.php new file mode 100644 index 00000000000..7e7865c87e8 --- /dev/null +++ b/htdocs/core/modules/holiday/modules_holiday.php @@ -0,0 +1,146 @@ + + * Copyright (C) 2004-2007 Laurent Destailleur + * Copyright (C) 2004 Eric Seigne + * Copyright (C) 2005-2009 Regis Houssin + * Copyright (C) 2006 Andre Cianfarani + * Copyright (C) 2011 Juanjo Menent + * Copyright (C) 2013 Philippe Grand + * Copyright (C) 2014 Marcos García + * Copyright (C) 2018 Charlene Benke + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/modules_holiday.php + * \ingroup contract + * \brief File with parent class for generating holiday to PDF and File of class to manage contract numbering + */ + + require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; + + +/** + * Parent class to manage intervention document templates + */ +abstract class ModelePDFHoliday extends CommonDocGenerator +{ + var $error=''; + + + /** + * Return list of active generation modules + * + * @param DoliDB $db Database handler + * @param integer $maxfilenamelength Max length of value to show + * @return array List of templates + */ + static function liste_modeles($db,$maxfilenamelength=0) + { + global $conf; + + $type='contract'; + $liste=array(); + + include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; + $liste=getListOfModels($db,$type,$maxfilenamelength); + + return $liste; + } +} + + +/** + * Parent class for all contract numbering modules + */ +class ModelNumRefHolidays +{ + var $error=''; + + /** + * Return if a module can be used or not + * + * @return boolean true if module can be used + */ + function isEnabled() + { + return true; + } + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoDescription"); + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $langs; + $langs->load("holidays"); + return $langs->trans("NoExample"); + } + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflict, true if ok + */ + function canBeActivated() + { + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value + */ + function getNextValue($objsoc, $contract) + { + global $langs; + return $langs->trans("NotAvailable"); + } + + /** + * Return numbering version module + * + * @return string Value + */ + function getVersion() + { + global $langs; + $langs->load("admin"); + + if ($this->version == 'development') return $langs->trans("VersionDevelopment"); + if ($this->version == 'experimental') return $langs->trans("VersionExperimental"); + if ($this->version == 'dolibarr') return DOL_VERSION; + if ($this->version) return $this->version; + return $langs->trans("NotAvailable"); + } +} From a20632d31d401e3e346c441f1ff4fa64fa81c85b Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:34:26 +0200 Subject: [PATCH 3/6] Create mod_holiday_immaculate.php --- .../holiday/mod_holiday_immaculate.php | 132 ++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 htdocs/core/modules/holiday/mod_holiday_immaculate.php diff --git a/htdocs/core/modules/holiday/mod_holiday_immaculate.php b/htdocs/core/modules/holiday/mod_holiday_immaculate.php new file mode 100644 index 00000000000..1355ba90302 --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_immaculate.php @@ -0,0 +1,132 @@ + + * Copyright (C) 2018 Charlene Benke + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_immaculate.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Magre + */ + +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules Magre + */ +class mod_holiday_immaculate extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $error = ''; + var $nom = 'Immaculate'; + var $code_auto=1; + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $conf,$langs; + + $langs->load("bills"); + + $form = new Form($this->db); + + $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; + $texte.= '
'; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + + $tooltip=$langs->trans("GenericMaskCodes",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes2"); + $tooltip.=$langs->trans("GenericMaskCodes3"); + $tooltip.=$langs->trans("GenericMaskCodes4a",$langs->transnoentities("Holiday"),$langs->transnoentities("Holiday")); + $tooltip.=$langs->trans("GenericMaskCodes5"); + + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= ''; + $texte.= '
'.$langs->trans("Mask").':'.$form->textwithpicto('',$tooltip,1,1).' 
'; + $texte.= '
'; + + return $texte; + } + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + global $conf,$langs,$user; + + $old_login=$user->login; + $user->login='UUUUUUU'; + $numExample = $this->getNextValue($user, ''); + $user->login=$old_login; + + if (! $numExample) + { + $numExample = $langs->trans('NotConfigured'); + } + return $numExample; + } + + /** + * Return next value + * + * @param Societe $user user object + * @param Object $holiday holiday object + * @return string Value if OK, 0 if KO + */ + function getNextValue($user, $holiday) + { + global $db,$conf; + + require_once DOL_DOCUMENT_ROOT .'/core/lib/functions2.lib.php'; + + $mask=$conf->global->HOLIDAY_IMMACULATE_MASK; + + if (! $mask) + { + $this->error='NotConfigured'; + return 0; + } + + $numFinal=get_next_value($db,$mask,'holiday','ref','', $user, $holiday->date_create); + + return $numFinal; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($user, $objforref) + { + return $this->getNextValue($user, $objforref); + } +} From 3d268933a43f56929a72d9b139f6d9a1cf043202 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:35:19 +0200 Subject: [PATCH 4/6] Create mod_holiday_madonna.php --- .../modules/holiday/mod_holiday_madonna.php | 148 ++++++++++++++++++ 1 file changed, 148 insertions(+) create mode 100644 htdocs/core/modules/holiday/mod_holiday_madonna.php diff --git a/htdocs/core/modules/holiday/mod_holiday_madonna.php b/htdocs/core/modules/holiday/mod_holiday_madonna.php new file mode 100644 index 00000000000..b5848263c98 --- /dev/null +++ b/htdocs/core/modules/holiday/mod_holiday_madonna.php @@ -0,0 +1,148 @@ + + * Copyright (C) 2018 Charlene Benke + * + * 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 . + * or see http://www.gnu.org/ + */ + +/** + * \file htdocs/core/modules/holiday/mod_holiday_madonna.php + * \ingroup contract + * \brief File of class to manage contract numbering rules Serpis + */ +require_once DOL_DOCUMENT_ROOT .'/core/modules/holiday/modules_holiday.php'; + +/** + * Class to manage contract numbering rules madonna + */ +class mod_holiday_madonna extends ModelNumRefHolidays +{ + var $version='dolibarr'; + var $prefix='HL'; + var $error=''; + var $nom='Madonna'; + var $code_auto=1; + + + /** + * Return default description of numbering model + * + * @return string text description + */ + function info() + { + global $langs; + return $langs->trans("SimpleNumRefModelDesc",$this->prefix); + } + + + /** + * Return numbering example + * + * @return string Example + */ + function getExample() + { + return $this->prefix."0501-0001"; + } + + + /** + * Test if existing numbers make problems with numbering + * + * @return boolean false if conflit, true if ok + */ + function canBeActivated() + { + global $conf,$langs,$db; + + $coyymm=''; $max=''; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $row = $db->fetch_row($resql); + if ($row) { $coyymm = substr($row[0],0,6); $max=$row[0]; } + } + if ($coyymm && ! preg_match('/'.$this->prefix.'[0-9][0-9][0-9][0-9]/i',$coyymm)) + { + $langs->load("errors"); + $this->error=$langs->trans('ErrorNumRefModel', $max); + return false; + } + + return true; + } + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $contract contract object + * @return string Value if OK, 0 if KO + */ + function getNextValue($objsoc,$contract) + { + global $db,$conf; + + $posindice=8; + $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; + $sql.= " FROM ".MAIN_DB_PREFIX."holiday"; + $sql.= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; + $sql.= " AND entity = ".$conf->entity; + + $resql=$db->query($sql); + if ($resql) + { + $obj = $db->fetch_object($resql); + if ($obj) $max = intval($obj->max); + else $max=0; + } + else + { + dol_syslog("mod_holiday_madonna::getNextValue", LOG_DEBUG); + return -1; + } + + $date=$contract->date_contrat; + $yymm = strftime("%y%m",$date); + + if ($max >= (pow(10, 4) - 1)) $num=$max+1; // If counter > 9999, we do not format on 4 chars, we take number as it is + else $num = sprintf("%04s",$max+1); + + dol_syslog("mod_holiday_madonna::getNextValue return ".$this->prefix.$yymm."-".$num); + return $this->prefix.$yymm."-".$num; + } + + + /** + * Return next value + * + * @param Societe $objsoc third party object + * @param Object $objforref contract object + * @return string Value if OK, 0 if KO + */ + function holiday_get_num($objsoc,$objforref) + { + return $this->getNextValue($objsoc,$objforref); + } + +} From 79bb8ef6c7adbb37b1ee867e8014004b9107aff8 Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:47:24 +0200 Subject: [PATCH 5/6] Update modHoliday.class.php --- htdocs/core/modules/modHoliday.class.php | 31 ++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/htdocs/core/modules/modHoliday.class.php b/htdocs/core/modules/modHoliday.class.php index 3fd056b525e..4f41f2eae2d 100644 --- a/htdocs/core/modules/modHoliday.class.php +++ b/htdocs/core/modules/modHoliday.class.php @@ -4,6 +4,7 @@ * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2011 Dimitri Mouillard * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke * * 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 @@ -69,9 +70,13 @@ class modHoliday extends DolibarrModules // Data directories to create when module is enabled. // Example: this->dirs = array("/mymodule/temp"); - $this->dirs = array(); + $this->dirs = array("/holiday/temp"); $r=0; + // Config pages + $this->config_page_url = array("holiday.php"); + + // Config pages. Put here list of php page names stored in admmin directory used to setup module. // $this->config_page_url = array("holiday.php?leftmenu=setup@holiday"); @@ -87,7 +92,29 @@ class modHoliday extends DolibarrModules // 1=>array('MYMODULE_MYNEWCONST2','chaine','myvalue','This is another constant to add',0) ); // 2=>array('MAIN_MODULE_MYMODULE_NEEDSMARTY','chaine',1,'Constant to say module need smarty',0) $this->const = array(); // List of particular constants to add when module is enabled (key, 'chaine', value, desc, visible, 0 or 'allentities') - + $r=0; + + $this->const[$r][0] = "HOLIDAY_ADDON"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "mod_holiday_madonna"; + $this->const[$r][3] = 'Nom du gestionnaire de numerotation des congés'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "celebrate"; + $this->const[$r][3] = 'Name of PDF model of holiday'; + $this->const[$r][4] = 0; + $r++; + + $this->const[$r][0] = "HOLIDAY_ADDON_PDF_ODT_PATH"; + $this->const[$r][1] = "chaine"; + $this->const[$r][2] = "DOL_DATA_ROOT/doctemplates/holiday"; + $this->const[$r][3] = ""; + $this->const[$r][4] = 0; + $r++; + // Array to add new pages in new tabs $this->tabs[] = array('data'=>'user:+paidholidays:CPTitreMenu:holiday:$user->rights->holiday->read:/holiday/list.php?mainmenu=hrm&id=__ID__'); // To add a new tab identified by code tabname1 From e3963c3518cf87023d666b9a80992c95b136856c Mon Sep 17 00:00:00 2001 From: BENKE Charlene Date: Mon, 7 May 2018 22:48:43 +0200 Subject: [PATCH 6/6] Create holiday.php --- htdocs/admin/holiday.php | 521 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 521 insertions(+) create mode 100644 htdocs/admin/holiday.php diff --git a/htdocs/admin/holiday.php b/htdocs/admin/holiday.php new file mode 100644 index 00000000000..b199505d214 --- /dev/null +++ b/htdocs/admin/holiday.php @@ -0,0 +1,521 @@ + + * Copyright (C) 2011-2015 Philippe Grand + * Copyright (C) 2013 Juanjo Menent + * Copyright (C) 2018 Charlene Benke + * + * 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/contract.php + * \ingroup contract + * \brief Setup page of module Contracts + */ + +require '../main.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/pdf.lib.php'; +require_once DOL_DOCUMENT_ROOT.'/holiday/class/holiday.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/holiday.lib.php'; + +$langs->load("admin"); +$langs->load("errors"); +$langs->load("holiday"); + +if (!$user->admin) accessforbidden(); + +$action = GETPOST('action','alpha'); +$value = GETPOST('value','alpha'); +$label = GETPOST('label','alpha'); +$scandir = GETPOST('scan_dir','alpha'); +$type='contract'; + +if (empty($conf->global->HOLIDAY_ADDON)) +{ + $conf->global->HOLIDAY_ADDON='mod_holiday_madona'; +} + + +/* + * Actions + */ + +include DOL_DOCUMENT_ROOT.'/core/actions_setmoduleoptions.inc.php'; + +if ($action == 'updateMask') +{ + $maskconst = GETPOST('maskconstholidaty','alpha'); + $maskvalue = GETPOST('maskholiday','alpha'); + if ($maskconst) $res = dolibarr_set_const($db,$maskconst,$maskvalue,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + +else if ($action == 'specimen') // For contract +{ + $modele= GETPOST('module','alpha'); + + $contract = new Contrat($db); + $contract->initAsSpecimen(); + + // Search template files + $file=''; $classname=''; $filefound=0; + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + foreach($dirmodels as $reldir) + { + $file=dol_buildpath($reldir."core/modules/holiday/doc/pdf_".$modele.".modules.php",0); + if (file_exists($file)) + { + $filefound=1; + $classname = "pdf_".$modele; + break; + } + } + + if ($filefound) + { + require_once $file; + + $module = new $classname($db); + + if ($module->write_file($contract,$langs) > 0) + { + header("Location: ".DOL_URL_ROOT."/document.php?modulepart=holiday&file=SPECIMEN.pdf"); + return; + } + else + { + setEventMessages($obj->error, $obj->errors, 'errors'); + dol_syslog($obj->error, LOG_ERR); + } + } + else + { + setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors'); + dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR); + } +} + +// Activate a model +else if ($action == 'set') +{ + $ret = addDocumentModel($value, $type, $label, $scandir); +} + +else if ($action == 'del') +{ + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + if ($conf->global->HOLIDAY_ADDON_PDF == "$value") dolibarr_del_const($db, 'HOLIDAY_ADDON_PDF',$conf->entity); + } +} + +// Set default model +else if ($action == 'setdoc') +{ + if (dolibarr_set_const($db, "HOLIDAY_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->HOLIDAY_ADDON_PDF = $value; + } + + // On active le modele + $ret = delDocumentModel($value, $type); + if ($ret > 0) + { + $ret = addDocumentModel($value, $type, $label, $scandir); + } +} + +else if ($action == 'setmod') +{ + // TODO Verifier si module numerotation choisi peut etre active + // par appel methode canBeActivated + + dolibarr_set_const($db, "HOLIDAY_ADDON",$value,'chaine',0,'',$conf->entity); +} + +else if ($action == 'set_other') +{ + $freetext= GETPOST('HOLIDAY_FREE_TEXT','none'); // No alpha here, we want exact string + $res1 = dolibarr_set_const($db, "HOLIDAY_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + + $draft= GETPOST('HOLIDAY_DRAFT_WATERMARK','alpha'); + $res2 = dolibarr_set_const($db, "HOLIDAY_DRAFT_WATERMARK",trim($draft),'chaine',0,'',$conf->entity); + + if (! $res1 > 0 || ! $res2 > 0) $error++; + + if (! $error) + { + setEventMessages($langs->trans("SetupSaved"), null, 'mesgs'); + } + else + { + setEventMessages($langs->trans("Error"), null, 'errors'); + } +} + + +/* + * View + */ + +$dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); + +llxHeader(); + +$form=new Form($db); + +$linkback=''.$langs->trans("BackToModuleList").''; +print load_fiche_titre($langs->trans("HolidaySetup"),$linkback,'title_setup'); + +$head=holiday_admin_prepare_head(); + +dol_fiche_head($head, 'holiday', $langs->trans("Holidays"), -1, 'holiday'); + +/* + * Holiday Numbering model + */ + +print load_fiche_titre($langs->trans("HolidaysNumberingModules"),'',''); + +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +foreach ($dirmodels as $reldir) +{ + $dir = dol_buildpath($reldir."core/modules/holiday/"); + + if (is_dir($dir)) + { + $handle = opendir($dir); + if (is_resource($handle)) + { + $var=true; + + while (($file = readdir($handle))!==false) + { + if (substr($file, 0, 12) == 'mod_holiday_' && substr($file, dol_strlen($file)-3, 3) == 'php') + { + $file = substr($file, 0, dol_strlen($file)-4); + + require_once $dir.$file.'.php'; + + $module = new $file($db); + + // 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()) + { + + print ''; + + // Show example of numbering model + print ''."\n"; + + print ''; + + $holiday=new Holiday($db); + $holiday->initAsSpecimen(); + + // Info + $htmltooltip=''; + $htmltooltip.=''.$langs->trans("Version").': '.$module->getVersion().'
'; + $nextval=$module->getNextValue($mysoc,$contract); + if ("$nextval" != $langs->trans("NotAvailable")) { // Keep " on nextval + $htmltooltip.=''.$langs->trans("NextValue").': '; + if ($nextval) { + if (preg_match('/^Error/',$nextval) || $nextval=='NotConfigured') + $nextval = $langs->trans($nextval); + $htmltooltip.=$nextval.'
'; + } else { + $htmltooltip.=$langs->trans($module->error).'
'; + } + } + + print ''; + + print ''; + } + } + } + closedir($handle); + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Example").''.$langs->trans("Status").''.$langs->trans("ShortInfo").'
'.$module->nom."\n"; + print $module->info(); + print ''; + $tmp=$module->getExample(); + if (preg_match('/^Error/',$tmp)) { $langs->load("errors"); print '
'.$langs->trans($tmp).'
'; } + elseif ($tmp=='NotConfigured') print $langs->trans($tmp); + else print $tmp; + print '
'; + if ($conf->global->HOLIDAY_ADDON == "$file") + { + print img_picto($langs->trans("Activated"),'switch_on'); + } + else + { + print ''; + print img_picto($langs->trans("Disabled"),'switch_off'); + print ''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print '

'; + +/* + * Documents models for Contracts + */ + +print load_fiche_titre($langs->trans("TemplatePDFHolidays"),'',''); + +// Defini tableau def des modeles +$def = array(); +$sql = "SELECT nom"; +$sql.= " FROM ".MAIN_DB_PREFIX."document_model"; +$sql.= " WHERE type = '".$type."'"; +$sql.= " AND entity = ".$conf->entity; +$resql=$db->query($sql); +if ($resql) +{ + $i = 0; + $num_rows=$db->num_rows($resql); + while ($i < $num_rows) + { + $array = $db->fetch_array($resql); + array_push($def, $array[0]); + $i++; + } +} +else +{ + dol_print_error($db); +} + + +print ''; +print ''; +print ''; +print ''; +print '\n"; +print '\n"; +print ''; +print ''; +print "\n"; + +clearstatcache(); + +$var=true; +foreach ($dirmodels as $reldir) +{ + foreach (array('','/doc') as $valdir) + { + $dir = dol_buildpath($reldir."core/modules/holiday".$valdir); + + if (is_dir($dir)) + { + $handle=opendir($dir); + if (is_resource($handle)) + { + while (($file = readdir($handle))!==false) + { + $filelist[]=$file; + } + closedir($handle); + arsort($filelist); + + foreach($filelist as $file) + { + if (preg_match('/\.modules\.php$/i',$file) && preg_match('/^(pdf_|doc_)/',$file)) + { + + if (file_exists($dir.'/'.$file)) + { + $name = substr($file, 4, dol_strlen($file) -16); + $classname = substr($file, 0, dol_strlen($file) -12); + + require_once $dir.'/'.$file; + $module = new $classname($db); + + $modulequalified=1; + if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2) $modulequalified=0; + if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1) $modulequalified=0; + + if ($modulequalified) + { + $var = !$var; + print ''; + + // Active + if (in_array($name, $def)) + { + print ''; + } + else + { + print '"; + } + + // Defaut + print ''; + + // Info + $htmltooltip = ''.$langs->trans("Name").': '.$module->name; + $htmltooltip.='
'.$langs->trans("Type").': '.($module->type?$module->type:$langs->trans("Unknown")); + if ($module->type == 'pdf') + { + $htmltooltip.='
'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur; + } + $htmltooltip.='

'.$langs->trans("FeaturesSupported").':'; + $htmltooltip.='
'.$langs->trans("Logo").': '.yn($module->option_logo,1,1); + $htmltooltip.='
'.$langs->trans("PaymentMode").': '.yn($module->option_modereg,1,1); + $htmltooltip.='
'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg,1,1); + $htmltooltip.='
'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang,1,1); + $htmltooltip.='
'.$langs->trans("WatermarkOnDraftOrders").': '.yn($module->option_draft_watermark,1,1); + + + print ''; + + // Preview + print ''; + + print "\n"; + } + } + } + } + } + } + } +} + +print '
'.$langs->trans("Name").''.$langs->trans("Description").''.$langs->trans("Status")."'.$langs->trans("Default")."'.$langs->trans("ShortInfo").''.$langs->trans("Preview").'
'; + print (empty($module->name)?$name:$module->name); + print "\n"; + if (method_exists($module,'info')) print $module->info($langs); + else print $module->description; + print ''."\n"; + print ''; + print img_picto($langs->trans("Enabled"),'switch_on'); + print ''; + print ''."\n"; + print 'scandir.'&label='.urlencode($module->name).'">'.img_picto($langs->trans("Disabled"),'switch_off').''; + print "'; + if ($conf->global->HOLIDAY_ADDON_PDF == $name) + { + print img_picto($langs->trans("Default"),'on'); + } + else + { + print 'scandir.'&label='.urlencode($module->name).'" alt="'.$langs->trans("Default").'">'.img_picto($langs->trans("Disabled"),'off').''; + } + print ''; + print $form->textwithpicto('',$htmltooltip,1,0); + print ''; + if ($module->type == 'pdf') + { + print ''.img_object($langs->trans("Preview"),'contract').''; + } + else + { + print img_object($langs->trans("PreviewNotAvailable"),'generic'); + } + print '
'; +print "
"; + +/* + * Other options + * + */ + +print '
'; +print ''; +print ''; + +print load_fiche_titre($langs->trans("OtherOptions"),'',''); +print ''; +print ''; +print ''; +print ''; +print "\n"; +$var=true; + +$substitutionarray=pdf_getSubstitutionArray($langs, array('objectamount'), null, 2); +$substitutionarray['__(AnyTranslationKey)__']=$langs->trans("Translation"); +$htmltext = ''.$langs->trans("AvailableVariables").':
'; +foreach($substitutionarray as $key => $val) $htmltext.=$key.'
'; +$htmltext.='
'; + +$var=! $var; +print ''."\n"; + +//Use draft Watermark + +print ''."\n"; + +print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; +print $form->textwithpicto($langs->trans("FreeLegalTextOnHolidays"), $langs->trans("AddCRIfTooLong").'

'.$htmltext, 1, 'help', '', 0, 2, 'tooltiphelp'); +print '
'; +$variablename='HOLIDAY_FREE_TEXT'; +if (empty($conf->global->PDF_ALLOW_HTML_FOR_FREE_TEXT)) +{ + print ''; +} +else +{ + include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; + $doleditor=new DolEditor($variablename, $conf->global->$variablename,'',80,'dolibarr_notes'); + print $doleditor->Create(); +} +print '
'; +print $form->textwithpicto($langs->trans("WatermarkOnDraftHolidayCards"), $htmltext, 1, 'help', '', 0, 2, 'watermarktooltip').'
'; +print '
'; +print ''; +print '
'; + +print '
'; +print ''; +print '
'; + +print '
'; + +dol_fiche_end(); + +llxFooter(); +$db->close();