diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index e03b4bd1473..3e00699f5fb 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -1866,7 +1866,7 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa } elseif ($event->type == 'bookcal_calendar') { $numbirthday++; $colorindex = 3; - $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray[$fk_bookcal_availability]) ? $bookcalcalendarsarray[$fk_bookcal_availability][$event->fk_bookcal_availability] : ""); + $cssclass = 'family_bookcal_calendar_'.(!empty($bookcalcalendarsarray["availabilitieslink"]) ? $bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_availability] : ""); $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; diff --git a/htdocs/core/modules/bookcal/mod_booking_advanced.php b/htdocs/core/modules/bookcal/mod_booking_advanced.php deleted file mode 100644 index e1b8e2ad3fe..00000000000 --- a/htdocs/core/modules/bookcal/mod_booking_advanced.php +++ /dev/null @@ -1,147 +0,0 @@ - - * Copyright (C) 2004-2007 Laurent Destailleur - * Copyright (C) 2005-2009 Regis Houssin - * Copyright (C) 2008 Raphael Bertrand (Resultic) - * Copyright (C) 2019 Frédéric France - * - * 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 https://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/booking/mod_booking_advanced.php - * \ingroup bookcal - * \brief File containing class for advanced numbering model of Booking - */ - -dol_include_once('/core/modules/bookcal/modules_booking.php'); - - -/** - * Class to manage the Advanced numbering rule for Booking - */ -class mod_booking_advanced extends ModeleNumRefBooking -{ - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - - /** - * @var string Error message - */ - public $error = ''; - - /** - * @var string name - */ - public $name = 'advanced'; - - - /** - * Returns the description of the numbering model - * - * @param Translate $langs Lang object to use for output - * @return string Descriptive text - */ - public function info($langs) - { - global $langs, $db; - - $langs->load("bills"); - - $form = new Form($db); - - $texte = $langs->trans('GenericNumRefModelDesc')."
\n"; - $texte .= '
'; - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - - $tooltip = $langs->trans("GenericMaskCodes", $langs->transnoentities("Booking"), $langs->transnoentities("Booking")); - $tooltip .= $langs->trans("GenericMaskCodes2"); - $tooltip .= $langs->trans("GenericMaskCodes3"); - $tooltip .= $langs->trans("GenericMaskCodes4a", $langs->transnoentities("Booking"), $langs->transnoentities("Booking")); - $tooltip .= $langs->trans("GenericMaskCodes5"); - - // Parametrage du prefix - $texte .= ''; - $texte .= ''; - $texte .= ''; - $texte .= ''; - - $texte .= '
'.$langs->trans("Mask").':'.$form->textwithpicto('', $tooltip, 1, 1).' 
'; - $texte .= '
'; - - return $texte; - } - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - global $conf, $db, $langs, $mysoc; - - $object = new Booking($db); - $object->initAsSpecimen(); - - /*$old_code_client = $mysoc->code_client; - $old_code_type = $mysoc->typent_code; - $mysoc->code_client = 'CCCCCCCCCC'; - $mysoc->typent_code = 'TTTTTTTTTT';*/ - - $numExample = $this->getNextValue($object); - - /*$mysoc->code_client = $old_code_client; - $mysoc->typent_code = $old_code_type;*/ - - if (!$numExample) { - $numExample = $langs->trans('NotConfigured'); - } - return $numExample; - } - - /** - * Return next free value - * - * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO - */ - public function getNextValue($object) - { - global $db, $conf; - - require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - - // We get cursor rule - $mask = getDolGlobalString('BOOKCAL_BOOKING_ADVANCED_MASK'); - - if (!$mask) { - $this->error = 'NotConfigured'; - return 0; - } - - $date = $object->date; - - $numFinal = get_next_value($db, $mask, 'bookcal_booking', 'ref', '', null, $date); - - return $numFinal; - } -} diff --git a/htdocs/core/modules/bookcal/mod_booking_standard.php b/htdocs/core/modules/bookcal/mod_booking_standard.php deleted file mode 100644 index ba077860ddf..00000000000 --- a/htdocs/core/modules/bookcal/mod_booking_standard.php +++ /dev/null @@ -1,162 +0,0 @@ - - * Copyright (C) 2005-2009 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 . - * or see https://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/bookcal/mod_booking_standard.php - * \ingroup bookcal - * \brief File of class to manage booking numbering rules standard - */ -dol_include_once('/core/modules/bookcal/modules_booking.php'); - - -/** - * Class to manage the Standard numbering rule for booking - */ -class mod_booking_standard extends ModeleNumRefBooking -{ - /** - * Dolibarr version of the loaded document - * @var string - */ - public $version = 'dolibarr'; // 'development', 'experimental', 'dolibarr' - - public $prefix = 'BK'; - - /** - * @var string Error code (or message) - */ - public $error = ''; - - /** - * @var string name - */ - public $name = 'standard'; - - - /** - * Return description of numbering module - * - * @param Translate $langs Lang object to use for output - * @return string Descriptive text - */ - public function info($langs) - { - global $langs; - return $langs->trans("SimpleNumRefModelDesc", $this->prefix); - } - - - /** - * Return an example of numbering - * - * @return string Example - */ - public function getExample() - { - return $this->prefix."0501-0001"; - } - - - /** - * Checks if the numbers already in the database do not - * cause conflicts that would prevent this numbering working. - * - * @param Object $object Object we need next value for - * @return boolean false if conflict, true if ok - */ - public function canBeActivated($object) - { - global $conf, $langs, $db; - - $coyymm = ''; $max = ''; - - $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_booking"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - if ($object->ismultientitymanaged == 1) { - $sql .= " AND entity = ".$conf->entity; - } elseif ($object->ismultientitymanaged == 2) { - // TODO - } - - $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 free value - * - * @param Object $object Object we need next value for - * @return string Value if KO, <0 if KO - */ - public function getNextValue($object) - { - global $db, $conf; - - // first we get the max value - $posindice = strlen($this->prefix) + 6; - $sql = "SELECT MAX(CAST(SUBSTRING(ref FROM ".$posindice.") AS SIGNED)) as max"; - $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_booking"; - $sql .= " WHERE ref LIKE '".$db->escape($this->prefix)."____-%'"; - if ($object->ismultientitymanaged == 1) { - $sql .= " AND entity = ".$conf->entity; - } elseif ($object->ismultientitymanaged == 2) { - // TODO - } - - $resql = $db->query($sql); - if ($resql) { - $obj = $db->fetch_object($resql); - if ($obj) { - $max = intval($obj->max); - } else { - $max = 0; - } - } else { - dol_syslog("mod_booking_standard::getNextValue", LOG_DEBUG); - return -1; - } - - //$date=time(); - $date = $object->date_creation; - $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_booking_standard::getNextValue return ".$this->prefix.$yymm."-".$num); - return $this->prefix.$yymm."-".$num; - } -} diff --git a/htdocs/core/modules/bookcal/modules_booking.php b/htdocs/core/modules/bookcal/modules_booking.php deleted file mode 100644 index 6025515954e..00000000000 --- a/htdocs/core/modules/bookcal/modules_booking.php +++ /dev/null @@ -1,72 +0,0 @@ - - * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2004 Eric Seigne - * Copyright (C) 2005-2012 Regis Houssin - * Copyright (C) 2006 Andre Cianfarani - * Copyright (C) 2012 Juanjo Menent - * Copyright (C) 2014 Marcos García - * - * 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 https://www.gnu.org/ - */ - -/** - * \file htdocs/core/modules/mymodule/modules_myobject.php - * \ingroup mymodule - * \brief File that contains parent class for myobjects document models and parent class for myobjects numbering models - */ - -require_once DOL_DOCUMENT_ROOT.'/core/class/commondocgenerator.class.php'; -require_once DOL_DOCUMENT_ROOT.'/core/class/commonnumrefgenerator.class.php'; -require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // required for use by classes that inherit - - -/** - * Parent class for documents models - */ -abstract class ModelePDFBooking extends CommonDocGenerator -{ - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * 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 - */ - public static function liste_modeles($db, $maxfilenamelength = 0) - { - // phpcs:enable - global $conf; - - $type = 'myobject'; - $list = array(); - - include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; - $list = getListOfModels($db, $type, $maxfilenamelength); - - return $list; - } -} - - - -/** - * Parent class to manage numbering of MyObject - */ -abstract class ModeleNumRefBooking extends CommonNumRefGenerator -{ - // No overload code -}