From 82f69c68b15db7c719c254231b73f58b6eca30b3 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 20:23:58 +0200 Subject: [PATCH 01/22] Fix bad var --- .../interface_20_modWorkflow_WorkflowManager.class.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php index 15c00af5bac..993cbc8206d 100644 --- a/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php +++ b/htdocs/core/triggers/interface_20_modWorkflow_WorkflowManager.class.php @@ -262,8 +262,8 @@ class InterfaceWorkflowManager extends DolibarrTriggers } } - // Then set reception to "Billed" if WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE is set - if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_EXPEDITION_CLASSIFY_CLOSED_INVOICE)) { + // Then set reception to "Billed" if WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE is set + if (isModEnabled("reception") && !empty($conf->workflow->enabled) && !empty($conf->global->WORKFLOW_RECEPTION_CLASSIFY_CLOSED_INVOICE)) { $object->fetchObjectLinked('', 'reception', $object->id, $object->element); if (!empty($object->linkedObjects)) { $totalonlinkedelements = 0; From 4cb97704ccf5928460ee2fe298cd145f30a32384 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 3 Sep 2023 22:12:34 +0200 Subject: [PATCH 02/22] Fix look and feel on shipment/reception --- htdocs/expedition/card.php | 8 ++++---- htdocs/expedition/dispatch.php | 2 +- htdocs/reception/card.php | 10 ++++++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/htdocs/expedition/card.php b/htdocs/expedition/card.php index 7f948153e10..7e8feeed6af 100644 --- a/htdocs/expedition/card.php +++ b/htdocs/expedition/card.php @@ -862,7 +862,7 @@ if (empty($reshook)) { * View */ -$title = $langs->trans("Shipment"); +$title = $object->ref.' - '.$langs->trans("Shipment"); if ($action == 'create2') { $title = $langs->trans("CreateShipment"); } @@ -1370,7 +1370,7 @@ if ($action == 'create') { //var_dump($dbatch); $batchStock = + $dbatch->qty; // To get a numeric $deliverableQty = min($quantityToBeDelivered, $batchStock); - print ''; + print ''; print ''; print ''; print ''; @@ -1442,7 +1442,7 @@ if ($action == 'create') { $deliverableQty = min($quantityToBeDelivered, $stock); $deliverableQty = max(0, $deliverableQty); // Quantity to send - print ''; + print ''; print ''; if ($line->product_type == Product::TYPE_PRODUCT || !empty($conf->global->STOCK_SUPPORTS_SERVICES)) { if (isset($alreadyQtySetted[$line->fk_product][intval($warehouse_id)])) { @@ -1582,7 +1582,7 @@ if ($action == 'create') { } $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)] = $deliverableQty + $alreadyQtyBatchSetted[$line->fk_product][$dbatch->batch][intval($warehouse_id)]; - print ''; + print ''; print ''; print ''; diff --git a/htdocs/expedition/dispatch.php b/htdocs/expedition/dispatch.php index 5707b3474ef..33036499c1e 100644 --- a/htdocs/expedition/dispatch.php +++ b/htdocs/expedition/dispatch.php @@ -48,7 +48,7 @@ if (isModEnabled('project')) { } // Load translation files required by the page -$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal')); +$langs->loadLangs(array("sendings", "companies", "bills", 'deliveries', 'orders', 'stocks', 'other', 'propal', 'receptions')); if (isModEnabled('productbatch')) { $langs->load('productbatch'); diff --git a/htdocs/reception/card.php b/htdocs/reception/card.php index 5c58c71f8e1..7c2a17cea85 100644 --- a/htdocs/reception/card.php +++ b/htdocs/reception/card.php @@ -1037,14 +1037,16 @@ if ($action == 'create') { print ''."\n"; + $tplcontent .= ''."\n"; // Add headers $tplcontent .= ''."\n"; $tplcontent .= ''."\n"; diff --git a/htdocs/public/website/javascript.js.php b/htdocs/public/website/javascript.js.php new file mode 100644 index 00000000000..51cecf8c699 --- /dev/null +++ b/htdocs/public/website/javascript.js.php @@ -0,0 +1,171 @@ + + * + * 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/public/website/javascript.js.php + * \ingroup website + * \brief Page to output style page. Called with + */ + +if (!defined('NOTOKENRENEWAL')) { + define('NOTOKENRENEWAL', 1); // Disables token renewal +} +if (!defined('NOLOGIN')) { + define("NOLOGIN", 1); +} +if (!defined('NOCSRFCHECK')) { + define("NOCSRFCHECK", 1); // We accept to go on this page from external web site. +} +if (!defined('NOREQUIREMENU')) { + define('NOREQUIREMENU', '1'); +} +if (!defined('NOREQUIREHTML')) { + define('NOREQUIREHTML', '1'); +} +if (!defined('NOREQUIREAJAX')) { + define('NOREQUIREAJAX', '1'); +} +if (!defined('NOIPCHECK')) { + define('NOIPCHECK', '1'); // Do not check IP defined into conf $dolibarr_main_restrict_ip +} +if (!defined('NOBROWSERNOTIF')) { + define('NOBROWSERNOTIF', '1'); +} + +/** + * Header empty + * + * @return void + */ +function llxHeader() +{ +} +/** + * Footer empty + * + * @return void + */ +function llxFooter() +{ +} + +require '../../master.inc.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php'; + + +$error = 0; +$website = GETPOST('website', 'alpha'); +$websiteid = GETPOST('websiteid', 'int'); +$pageid = GETPOST('page', 'alpha') ?GETPOST('page', 'alpha') : GETPOST('pageid', 'alpha'); + +$accessallowed = 1; +$type = ''; + + +/* + * View + */ + +$appli = constant('DOL_APPLICATION_TITLE'); +if (!empty($conf->global->MAIN_APPLICATION_TITLE)) { + $appli = $conf->global->MAIN_APPLICATION_TITLE; +} + +//print 'Directory with '.$appli.' websites.
'; + +if (empty($pageid)) { + require_once DOL_DOCUMENT_ROOT.'/website/class/website.class.php'; + require_once DOL_DOCUMENT_ROOT.'/website/class/websitepage.class.php'; + + $object = new Website($db); + if ($websiteid) { + $object->fetch($websiteid); + $website = $object->ref; + } else { + $object->fetch(0, $website); + } + + $objectpage = new WebsitePage($db); + /* Not required for CSS file + $array=$objectpage->fetchAll($object->id); + + if (is_array($array) && count($array) > 0) + { + $firstrep=reset($array); + $pageid=$firstrep->id; + } + */ +} +/* Not required for CSS file +if (empty($pageid)) +{ + $langs->load("website"); + print $langs->trans("PreviewOfSiteNotYetAvailable"); + exit; +} +*/ + +// Security: Delete string ../ into $original_file +global $dolibarr_main_data_root; + +$original_file = $dolibarr_main_data_root.($conf->entity > 1 ? '/'.$conf->entity : '').'/website/'.$website.'/javascript.js.php'; + +// Find the subdirectory name as the reference +$refname = basename(dirname($original_file)."/"); + +// Security: +// Limite acces si droits non corrects +if (!$accessallowed) { + accessforbidden(); +} + +// Security: +// On interdit les remontees de repertoire ainsi que les pipe dans +// les noms de fichiers. +if (preg_match('/\.\./', $original_file) || preg_match('/[<>|]/', $original_file)) { + dol_syslog("Refused to deliver file ".$original_file); + $file = basename($original_file); // Do no show plain path of original_file in shown error message + dol_print_error(0, $langs->trans("ErrorFileNameInvalid", $file)); + exit; +} + +clearstatcache(); + +$filename = basename($original_file); + +// Output file on browser +dol_syslog("javascript.js.css.php include $original_file $filename content-type=$type"); +$original_file_osencoded = dol_osencode($original_file); // New file name encoded in OS encoding charset + +// This test if file exists should be useless. We keep it to find bug more easily +if (!file_exists($original_file_osencoded)) { + $langs->load("website"); + print $langs->trans("RequestedPageHasNoContentYet", $pageid); + //dol_print_error(0,$langs->trans("ErrorFileDoesNotExists",$original_file)); + exit; +} + + +// Output page content +define('USEDOLIBARRSERVER', 1); +print '/* Page content '.$original_file.' : JS content that was saved into tpl dir */'."\n"; +require_once $original_file_osencoded; + + +if (is_object($db)) { + $db->close(); +} From 2701f8a2a8d9b0c888247c8b37840008fcf75ce5 Mon Sep 17 00:00:00 2001 From: Hystepik Date: Tue, 5 Sep 2023 16:32:02 +0200 Subject: [PATCH 20/22] New : Bookcal dev 2 --- htdocs/bookcal/class/availabilities.class.php | 2 +- htdocs/comm/action/class/actioncomm.class.php | 7 ++ htdocs/comm/action/index.php | 73 +++++++++++++-- htdocs/core/ajax/bookcalAjax.php | 10 +-- htdocs/core/modules/modBookCal.class.php | 47 ++++++---- htdocs/langs/en_US/agenda.lang | 3 +- htdocs/public/bookcal/booking.php | 88 ++++++++++++++++--- htdocs/public/bookcal/index.php | 4 +- 8 files changed, 187 insertions(+), 47 deletions(-) diff --git a/htdocs/bookcal/class/availabilities.class.php b/htdocs/bookcal/class/availabilities.class.php index 40e07b821c5..6da76ad4a80 100644 --- a/htdocs/bookcal/class/availabilities.class.php +++ b/htdocs/bookcal/class/availabilities.class.php @@ -102,7 +102,7 @@ class Availabilities extends CommonObject * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor. */ public $fields=array( - 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>0, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), + 'rowid' => array('type'=>'integer', 'label'=>'TechnicalID', 'enabled'=>'1', 'position'=>1, 'notnull'=>1, 'visible'=>2, 'noteditable'=>'1', 'index'=>1, 'css'=>'left', 'comment'=>"Id"), 'label' => array('type'=>'varchar(255)', 'label'=>'Label', 'enabled'=>'1', 'position'=>30, 'notnull'=>0, 'visible'=>1, 'searchall'=>1, 'css'=>'minwidth300', 'cssview'=>'wordbreak', 'help'=>"Help text", 'showoncombobox'=>'2', 'validate'=>'1',), 'description' => array('type'=>'text', 'label'=>'Description', 'enabled'=>'1', 'position'=>60, 'notnull'=>0, 'visible'=>3, 'validate'=>'1',), 'note_public' => array('type'=>'html', 'label'=>'NotePublic', 'enabled'=>'1', 'position'=>61, 'notnull'=>0, 'visible'=>0, 'cssview'=>'wordbreak', 'validate'=>'1',), diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index 2de8736b39f..836562067f8 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -300,6 +300,11 @@ class ActionComm extends CommonObject */ public $elementtype; + /** + * @var int id of availability + */ + public $fk_bookcal_availability; + /** * @var string Ical name */ @@ -539,6 +544,7 @@ class ActionComm extends CommonObject $sql .= "transparency,"; $sql .= "fk_element,"; $sql .= "elementtype,"; + $sql .= "fk_bookcal_availability,"; $sql .= "entity,"; $sql .= "extraparams,"; // Fields emails @@ -581,6 +587,7 @@ class ActionComm extends CommonObject $sql .= "'".$this->db->escape($this->transparency)."', "; $sql .= (!empty($this->fk_element) ? ((int) $this->fk_element) : "null").", "; $sql .= (!empty($this->elementtype) ? "'".$this->db->escape($this->elementtype)."'" : "null").", "; + $sql .= (!empty($this->fk_bookcal_availability) ? "'".$this->db->escape($this->fk_bookcal_availability)."'" : "null").", "; $sql .= ((int) $conf->entity).","; $sql .= (!empty($this->extraparams) ? "'".$this->db->escape($this->extraparams)."'" : "null").", "; // Fields emails diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php index 7316ee3daaf..e03b4bd1473 100644 --- a/htdocs/comm/action/index.php +++ b/htdocs/comm/action/index.php @@ -557,6 +557,34 @@ if ($user->rights->agenda->myactions->create || $user->hasRight('agenda', 'allac $s = ''; $link = ''; $showextcals = $listofextcals; +$bookcalcalendars = array(); + +// Load Bookcal Calendars +if (isModEnabled("bookcal")) { + $sql = "SELECT ba.rowid, bc.label, bc.ref, bc.rowid as id_cal"; + $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as ba"; + $sql .= " JOIN ".MAIN_DB_PREFIX."bookcal_calendar as bc"; + $sql .= " ON bc.rowid = ba.fk_bookcal_calendar"; + $sql .= " WHERE bc.status = 1"; + $sql .= " AND ba.status = 1"; + if (!empty($filtert) && $filtert != -1) { + $sql .= " AND bc.visibility = ".(int) $filtert ; + } + $resql = $db->query($sql); + if ($resql) { + $num = $db->num_rows($resql); + $i = 0; + while ($i < $num) { + $objp = $db->fetch_object($resql); + $label = !empty($objp->label) ? $objp->label : $objp->ref; + $bookcalcalendars["calendars"][] = array("id" => $objp->id_cal, "label" => $label); + $bookcalcalendars["availabilitieslink"][$objp->rowid] = $objp->id_cal; + $i++; + } + } else { + dol_print_error($db); + } +} if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= "\n".''."\n"; @@ -564,6 +592,11 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on $s .= 'jQuery(document).ready(function () {'."\n"; $s .= 'jQuery(".check_birthday").click(function() { console.log("Toggle birthdays"); jQuery(".family_birthday").toggle(); });'."\n"; $s .= 'jQuery(".check_holiday").click(function() { console.log("Toggle holidays"); jQuery(".family_holiday").toggle(); });'."\n"; + if (isModEnabled("bookcal")) { + foreach ($bookcalcalendars["calendars"] as $key => $value) { + $s .= 'jQuery(".check_bookcal_calendar_'.$value['id'].'").click(function() { console.log("Toggle Bookcal Calendar '.$value['id'].'"); jQuery(".family_bookcal_calendar_'.$value['id'].'").toggle(); });'."\n"; + } + } if ($mode == "show_week" || $mode == "show_month" || empty($mode)) { // Code to enable drag and drop $s .= 'jQuery( "div.sortable" ).sortable({connectWith: ".sortable", placeholder: "ui-state-highlight", items: "div.movable", receive: function( event, ui ) {'."\n"; @@ -631,6 +664,14 @@ if (!empty($conf->use_javascript_ajax)) { // If javascript on // Birthdays $s .= '
 
'; + // Bookcal Calendar + if (isModEnabled("bookcal")) { + foreach ($bookcalcalendars["calendars"] as $key => $value) { + $label = $value['label']; + $s .= '
 
'; + } + } + // Calendars from hooks $parameters = array(); $reshook = $hookmanager->executeHooks('addCalendarChoice', $parameters, $object, $action); @@ -673,7 +714,7 @@ $sql .= ' a.datep2,'; $sql .= ' a.percent,'; $sql .= ' a.fk_user_author,a.fk_user_action,'; $sql .= ' a.transparency, a.priority, a.fulldayevent, a.location,'; -$sql .= ' a.fk_soc, a.fk_contact, a.fk_project,'; +$sql .= ' a.fk_soc, a.fk_contact, a.fk_project, a.fk_bookcal_availability,'; $sql .= ' a.fk_element, a.elementtype,'; $sql .= ' ca.code as type_code, ca.libelle as type_label, ca.color as type_color, ca.type as type_type, ca.picto as type_picto'; $sql .= ' FROM '.MAIN_DB_PREFIX.'c_actioncomm as ca, '.MAIN_DB_PREFIX."actioncomm as a"; @@ -862,6 +903,10 @@ if ($resql) { $event->socid = $obj->fk_soc; $event->contact_id = $obj->fk_contact; + $event->fk_bookcal_availability = $obj->fk_bookcal_availability; + if (!empty($event->fk_bookcal_availability)) { + $event->type = "bookcal_calendar"; + } // Defined date_start_in_calendar and date_end_in_calendar property // They are date start and end of action but modified to not be outside calendar view. @@ -1505,7 +1550,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month } //var_dump($todayarray['mday']."==".$tmpday." && ".$todayarray['mon']."==".$month." && ".$todayarray['year']."==".$year.' -> '.$style); echo ' '; - show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam); + show_day_events($db, $tmpday, $month, $year, $month, $style, $eventarray, $maxprint, $maxnbofchar, $newparam, 0, 60, 0, $bookcalcalendars); echo "\n"; } else { /* Show days after the current month (next month) */ @@ -1578,7 +1623,7 @@ if (empty($mode) || $mode == 'show_month') { // View by month } echo ' '; - show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300); + show_day_events($db, $tmpday, $tmpmonth, $tmpyear, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); echo " \n"; } echo " \n"; @@ -1668,13 +1713,13 @@ if (empty($mode) || $mode == 'show_month') { // View by month echo ''; - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 1, $bookcalcalendars); print ''; } else { print '
'; // You can use div-table-responsive-no-min if you dont need reserved height for your table - show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0); + show_day_events($db, $day, $month, $year, $month, $style, $eventarray, 0, $maxnbofchar, $newparam, 1, 300, 0, $bookcalcalendars); print '
'; } @@ -1703,9 +1748,10 @@ $db->close(); * @param int $showinfo Add extended information (used by day and week view) * @param int $minheight Minimum height for each event. 60px by default. * @param string $nonew 0=Add "new entry button", 1=No "new entry button", -1=Only "new entry button" + * @param string $bookcalcalendarsarray Used for Bookcal module array of calendar of bookcal * @return void */ -function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0) +function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventarray, $maxprint = 0, $maxnbofchar = 16, $newparam = '', $showinfo = 0, $minheight = 60, $nonew = 0, $bookcalcalendarsarray = array()) { global $user, $conf, $langs; global $action, $mode, $filter, $filtert, $status, $actioncode, $usergroup; // Filters used into search form @@ -1817,6 +1863,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $colorindex = 2; $cssclass = 'family_birthday '; $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); + } 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] : ""); + $color = sprintf("%02x%02x%02x", $theme_datacolor[$colorindex][0], $theme_datacolor[$colorindex][1], $theme_datacolor[$colorindex][2]); } else { $numother++; $color = ($event->icalcolor ? $event->icalcolor : -1); @@ -1904,6 +1955,9 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa if ($event->type == 'holiday' && !GETPOST('check_holiday')) { $morecss = 'hidden'; } + if ($event->type == 'bookcal_calendar' && !GETPOST('check_bookcal_calendar_'.$bookcalcalendarsarray["availabilitieslink"][$event->fk_bookcal_availability])) { + $morecss = 'hidden'; + } if ($morecss != 'hidden') { $itoshow++; } @@ -1911,8 +1965,11 @@ function show_day_events($db, $day, $month, $year, $monthshown, $style, &$eventa $ireallyshown++; } //var_dump($event->type.' - '.$morecss.' - '.$cssclass.' - '.$i.' - '.$ireallyshown.' - '.$itoshow); - - print '
type == 'bookcal_calendar') { + print '
fk_bookcal_availability].' '.$cssclass.($morecss ? ' '.$morecss : '').'"'; + } else { + print '
idate($datetocheckbooking)."'"; - $sql .= " AND b.start < '".$db->idate($datetocheckbooking_end)."'"; + $sql .= " AND b.datep >= '".$db->idate($datetocheckbooking)."'"; + $sql .= " AND b.datep < '".$db->idate($datetocheckbooking_end)."'"; $resql = $db->query($sql); if ($resql) { @@ -94,7 +94,7 @@ if ($action == 'verifyavailability') { $response["content"] = array(); while ($i < $num) { $obj = $db->fetch_object($resql); - $dateobject = $obj->start; + $dateobject = $obj->datep; $dateobject = explode(" ", $dateobject)[1]; $dateobject = explode(":", $dateobject); diff --git a/htdocs/core/modules/modBookCal.class.php b/htdocs/core/modules/modBookCal.class.php index fbbc4180423..07237b63d45 100644 --- a/htdocs/core/modules/modBookCal.class.php +++ b/htdocs/core/modules/modBookCal.class.php @@ -297,7 +297,7 @@ class modBookCal extends DolibarrModules $r = 0; // Add here entries to declare new menus /* BEGIN MODULEBUILDER TOPMENU */ - $this->menu[$r++] = array( + /*$this->menu[$r++] = array( 'fk_menu'=>'', // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode 'type'=>'top', // This is a Top menu entry 'titre'=>'ModuleBookCalName', @@ -311,18 +311,33 @@ class modBookCal extends DolibarrModules 'perms'=>'$user->rights->bookcal->availabilities->read', // Use 'perms'=>'$user->rights->bookcal->availabilities->read' if you want your menu with a permission rules 'target'=>'', 'user'=>2, // 0=Menu for internal users, 1=external users, 2=both - ); + );*/ /* END MODULEBUILDER TOPMENU */ /* BEGIN MODULEBUILDER LEFTMENU CALENDAR */ + $this->menu[$r++] = array( + 'fk_menu'=>'fk_mainmenu=agenda', + 'type'=>'left', + 'titre'=> 'MenuBookcalIndex', + 'prefix' => img_picto('', $this->picto, 'class="paddingright pictofixedwidth em92"'), + 'mainmenu'=>'agenda', + 'leftmenu'=> 'bookcal', + 'url'=> '/bookcal/bookcalindex.php', + 'langs'=> 'bookcal', + 'position'=> 1100+$r, + 'enabled'=> '1', + 'perms'=> '$user->rights->bookcal->calendar->read', + 'user'=> 0 + ); + $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', // This is a Left menu entry 'type'=>'left', - 'titre'=>'List Calendar', - 'mainmenu'=>'bookcal', - 'leftmenu'=>'bookcal_calendar', + 'titre'=>'Calendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_calendar_list', 'url'=>'/bookcal/calendar_list.php', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'bookcal', @@ -337,12 +352,12 @@ class modBookCal extends DolibarrModules ); $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_calendar', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_calendar_list', // This is a Left menu entry 'type'=>'left', - 'titre'=>'New Calendar', - 'mainmenu'=>'bookcal', - 'leftmenu'=>'bookcal_calendar', + 'titre'=>'NewCalendar', + 'mainmenu'=>'agenda', + 'leftmenu'=>'bookcal_new', 'url'=>'/bookcal/calendar_card.php?action=create', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. 'langs'=>'bookcal', @@ -405,11 +420,11 @@ class modBookCal extends DolibarrModules $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal', // This is a Left menu entry 'type'=>'left', - 'titre'=>'List Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'Availabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_list.php', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. @@ -425,11 +440,11 @@ class modBookCal extends DolibarrModules ); $this->menu[$r++]=array( // '' if this is a top menu. For left menu, use 'fk_mainmenu=xxx' or 'fk_mainmenu=xxx,fk_leftmenu=yyy' where xxx is mainmenucode and yyy is a leftmenucode - 'fk_menu'=>'fk_mainmenu=bookcal,fk_leftmenu=bookcal_availabilities', + 'fk_menu'=>'fk_mainmenu=agenda,fk_leftmenu=bookcal_availabilities', // This is a Left menu entry 'type'=>'left', - 'titre'=>'New Availabilities', - 'mainmenu'=>'bookcal', + 'titre'=>'NewAvailabilities', + 'mainmenu'=>'agenda', 'leftmenu'=>'bookcal_availabilities', 'url'=>'/bookcal/availabilities_card.php?action=create', // Lang file to use (without .lang) by module. File must be in langs/code_CODE/ directory. diff --git a/htdocs/langs/en_US/agenda.lang b/htdocs/langs/en_US/agenda.lang index abdbdbed6a1..07d97bb967f 100644 --- a/htdocs/langs/en_US/agenda.lang +++ b/htdocs/langs/en_US/agenda.lang @@ -180,4 +180,5 @@ BrowserPush=Browser Popup Notification Reminders=Reminders ActiveByDefault=Enabled by default Until=until -DataFromWasMerged=Data from %s was merged \ No newline at end of file +DataFromWasMerged=Data from %s was merged +AgendaShowBookcalCalendar=Booking calendar: %s \ No newline at end of file diff --git a/htdocs/public/bookcal/booking.php b/htdocs/public/bookcal/booking.php index 74972cfc8f0..0ddc53ebd6f 100644 --- a/htdocs/public/bookcal/booking.php +++ b/htdocs/public/bookcal/booking.php @@ -44,6 +44,8 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/calendar.class.php'; require_once DOL_DOCUMENT_ROOT.'/bookcal/class/availabilities.class.php'; +require_once DOL_DOCUMENT_ROOT.'/contact/class/contact.class.php'; +require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; $langs->loadLangs(array("main", "other", "dict", "agenda", "errors", "companies")); @@ -169,13 +171,21 @@ function llxHeaderVierge($title, $head = "", $disablejs = 0, $disablehead = 0, $ if ($action == 'add') { $error = 0; - $urlback = ''; + $idcontact = 0; + $calendar = new Calendar($db); + $contact = new Contact($db); + $actioncomm = new ActionComm($db); + + $res = $calendar->fetch($fk_calendar); + if ($res < 0) { + $error++; + $errmsg .= $calendar->error." ".join(',', $calendar->errors); + } + if (!is_object($user)) { $user = new User($db); } - $booking = new ActionComm($db); - $db->begin(); if (!GETPOST("lastname")) { $error++; @@ -191,21 +201,71 @@ if ($action == 'add') { } if (!$error) { - $booking->ref = $booking->getNextNumRef(); - $booking->lastname = GETPOST("lastname"); - $booking->firstname = GETPOST("firstname"); - $booking->email = GETPOST("email"); - $booking->description = GETPOST("description"); - $booking->duration = GETPOST("duration"); - $booking->start = GETPOST("datetimebooking", 'int'); - $booking->fk_bookcal_availability = GETPOST("id", 'int'); + $sql = "SELECT s.rowid"; + $sql .= " FROM ".MAIN_DB_PREFIX."socpeople as s"; + $sql .= " WHERE s.lastname = '".GETPOST("lastname")."'"; + $sql .= " AND s.firstname = '".GETPOST("firstname")."'"; + $sql .= " AND s.email = '".GETPOST("email")."'"; + $resql = $db->query($sql); - $result = $booking->create($user); - if ($result <= 0) { + if ($resql) { + $num = $db->num_rows($resql); + if ($num > 0) { + $obj = $db->fetch_object($resql); + $idcontact = $obj->rowid; + $contact->fetch($idcontact); + } else { + $contact->lastname = GETPOST("lastname"); + $contact->firstname = GETPOST("firstname"); + $contact->email = GETPOST("email"); + $result = $contact->create($user); + if ($result < 0) { + $error++; + $errmsg .= $contact->error." ".join(',', $contact->errors); + } + } + } else { $error++; - $errmsg = ($booking->error ? $booking->error.'
' : '').join('
', $booking->errors); + $errmsg .= $db->lasterror(); } } + + if (!$error) { + $dateend = dol_time_plus_duree(GETPOST("datetimebooking", 'int'), GETPOST("duration"), 'i'); + + $actioncomm->label = "test"; + $actioncomm->type = 'AC_RDV'; + $actioncomm->type_id = 5; + $actioncomm->datep = GETPOST("datetimebooking", 'int'); + $actioncomm->datef = $dateend; + $actioncomm->note_private = GETPOST("description"); + $actioncomm->percentage = -1; + $actioncomm->fk_bookcal_availability = GETPOST("id", 'int'); + $actioncomm->userownerid = $calendar->visibility; + $actioncomm->contact_id = $contact->id; + $actioncomm->socpeopleassigned = $contact->id; + $result = $actioncomm->create($user); + if ($result < 0) { + $error++; + $errmsg .= $actioncomm->error." ".join(',', $actioncomm->errors); + } + + if (!$error) { + $sql = "INSERT INTO ".MAIN_DB_PREFIX."actioncomm_resources"; + $sql .= "(fk_actioncomm, element_type, fk_element, answer_status, mandatory, transparency"; + $sql .= ") VALUES ("; + $sql .= (int) $actioncomm->id; + $sql .= ", 'socpeople'"; + $sql .= ", ". (int) $contact->id; + $sql .= ", 0, 0, 0)"; + $resql = $db->query($sql); + if (!$resql) { + $error++; + $errmsg .= $db->lasterror(); + } + } + } + if (!$error) { $db->commit(); $action = 'afteradd'; diff --git a/htdocs/public/bookcal/index.php b/htdocs/public/bookcal/index.php index cd4db57da4d..39d6b1f84da 100644 --- a/htdocs/public/bookcal/index.php +++ b/htdocs/public/bookcal/index.php @@ -180,7 +180,7 @@ print '
'; print '

'.(!empty($object->label) ? $object->label : $object->ref).'

'; -$sql = "SELECT b.rowid, b.ref, b.label, b.start, b.end, b.duration, b.startHour, b.endHour"; +$sql = "SELECT b.rowid, b.label, b.start, b.end, b.duration, b.startHour, b.endHour"; $sql .= " FROM ".MAIN_DB_PREFIX."bookcal_availabilities as b"; $sql .= " WHERE b.status = ".(int) $availabilities::STATUS_VALIDATED; $sql .= " AND b.fk_bookcal_calendar = ".(int) $id; @@ -193,7 +193,7 @@ if ($resql) { while ($i < $num) { $i++; $obj = $db->fetch_object($resql); - print ''; + print ''; } } print '
'; From 6459c862b883e1c3761893fda59b3751407dd8c9 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Sep 2023 16:50:23 +0200 Subject: [PATCH 21/22] Comment --- htdocs/core/lib/security.lib.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index d6bc0027da4..9d38e7fdb3d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -371,7 +371,7 @@ function restrictedArea(User $user, $features, $object = 0, $tableandshare = '', //dol_syslog("functions.lib:restrictedArea $feature, $objectid, $dbtablename, $feature2, $dbt_socfield, $dbt_select, $isdraft"); /*print "user_id=".$user->id.", features=".$features.", feature2=".$feature2.", objectid=".$objectid; print ", dbtablename=".$tableandshare.", dbt_socfield=".$dbt_keyfield.", dbt_select=".$dbt_select; - print ", perm: user->right->".$features.($feature2 ? "->".$feature2 : "")."=".($user->hasRight($features, $feature2, 'lire'))."
"; + print ", perm: user->hasRight(".$features.($feature2 ? ",".$feature2 : "").", lire) = ".($feature2 ? $user->hasRight($features, $feature2, 'lire') : $user->hasRight($features, 'lire'))."
"; */ $parentfortableentity = ''; From c95c006810e3ad76ff7a64a890c58d0a8bb29d37 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Sep 2023 17:01:04 +0200 Subject: [PATCH 22/22] Fix regression --- htdocs/product/list.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/htdocs/product/list.php b/htdocs/product/list.php index 4028726096a..9c9f3e5f274 100644 --- a/htdocs/product/list.php +++ b/htdocs/product/list.php @@ -413,7 +413,9 @@ if (empty($reshook)) { */ $product_static = new Product($db); -$static_ws = new Workstation($db); +if (isModEnabled('workstation')) { + $workstation_static = new Workstation($db); +} $product_fourn = new ProductFournisseur($db); $title = $langs->trans("ProductsAndServices"); @@ -1844,12 +1846,12 @@ while ($i < $imaxinloop) { // Default Workstation if (!empty($arrayfields['p.fk_default_workstation']['checked'])) { print ''; - if (!empty($obj->fk_default_workstation)) { - $static_ws->id = $obj->fk_default_workstation; - $static_ws->ref = $obj->ref_workstation; - $static_ws->status = $obj->status_workstation; + if (isModEnabled('workstation') && !empty($obj->fk_default_workstation)) { + $workstation_static->id = $obj->fk_default_workstation; + $workstation_static->ref = $obj->ref_workstation; + $workstation_static->status = $obj->status_workstation; - print $static_ws->getNomUrl(1); + print $workstation_static->getNomUrl(1); } print ''; if (!$i) {