mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-16 02:49:03 +01:00
Fix resource participant search conflict checking
This commit is contained in:
parent
4612519199
commit
8c86b4b41f
@ -1466,21 +1466,17 @@ class calendar_uiforms extends calendar_ui
|
|||||||
}
|
}
|
||||||
// adding extra content for the resource link-entry widget to
|
// adding extra content for the resource link-entry widget to
|
||||||
// * select resources or addressbook as a default selection on the app selectbox based on prefs
|
// * select resources or addressbook as a default selection on the app selectbox based on prefs
|
||||||
$content['participants']['resource']['default_sel'] = $this->cal_prefs['defaultresource_sel'];
|
$content['participants']['resource']['app'] = $this->cal_prefs['defaultresource_sel'];
|
||||||
// * get informations from the event on the ajax callback
|
// * get informations from the event on the ajax callback
|
||||||
if (in_array($content['participants']['resource']['default_sel'],array('resources_conflict','resources_without_conflict')))
|
if (in_array($content['participants']['resource']['app'],array('resources_conflict','resources_without_conflict')))
|
||||||
{
|
{
|
||||||
// fix real app string
|
// fix real app string
|
||||||
$content['participants']['resource']['default_sel'] = 'resources';
|
$content['participants']['resource']['app'] = 'resources';
|
||||||
// this will be used to get reservation information on the resource select list
|
|
||||||
$content['participants']['resource']['extra'] = "values2url(this.form,'start,end,duration,participants,recur_type,whole_day')".
|
|
||||||
"+'&exec[event_id]=".$content['id']."'"."+'&exec[show_conflict]=".
|
|
||||||
(($this->cal_prefs['defaultresource_sel'] == 'resources_without_conflict')? '0':'1')."'";
|
|
||||||
}
|
}
|
||||||
// check if current pref. is an allowed application for the user
|
// check if current pref. is an allowed application for the user
|
||||||
if (!isset($GLOBALS['egw_info']['user']['apps'][$content['participants']['resource']['default_sel']]))
|
if (!isset($GLOBALS['egw_info']['user']['apps'][$content['participants']['resource']['app']]))
|
||||||
{
|
{
|
||||||
$content['participants']['resource']['default_sel'] = 'home-accounts';
|
$content['participants']['resource']['app'] = 'home-accounts';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$content['participants']['status_date'] = $preserv['actual_date'];
|
$content['participants']['status_date'] = $preserv['actual_date'];
|
||||||
|
@ -939,6 +939,43 @@ app.classes.calendar = AppJS.extend(
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/**
|
||||||
|
* In edit popup, search for calendar participants.
|
||||||
|
* Resources need to have the start & duration (etc.)
|
||||||
|
* passed along in the query.
|
||||||
|
*
|
||||||
|
* @param {Object} request
|
||||||
|
* @param {et2_link_entry} widget
|
||||||
|
*
|
||||||
|
* @returns {boolean} True to continue with the search
|
||||||
|
*/
|
||||||
|
edit_participant_search: function(request, widget)
|
||||||
|
{
|
||||||
|
if(widget.app_select.val() == 'resources')
|
||||||
|
{
|
||||||
|
// Resources search is expecting exec
|
||||||
|
var values = widget.getInstanceManager().getValues(widget.getRoot());
|
||||||
|
if(typeof request.options != 'object' || request.options == null)
|
||||||
|
{
|
||||||
|
request.options = {};
|
||||||
|
}
|
||||||
|
request.options.exec = {
|
||||||
|
start: values.start,
|
||||||
|
end: values.end,
|
||||||
|
duration: values.duration,
|
||||||
|
participants: values.participants,
|
||||||
|
recur_type: values.recur_type,
|
||||||
|
event_id: values.link_to.to_id, // cal_id, if available
|
||||||
|
show_conflict: (egw.preference('defaultresource_sel','calendar') == 'resources_without_conflict') ? '0' : '1'
|
||||||
|
};
|
||||||
|
if(values.whole_day)
|
||||||
|
{
|
||||||
|
request.options.exec.whole_date = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Handles to select freetime, and replace the selected one on Start,
|
* Handles to select freetime, and replace the selected one on Start,
|
||||||
* and End date&time in edit calendar entry popup.
|
* and End date&time in edit calendar entry popup.
|
||||||
|
@ -112,7 +112,7 @@
|
|||||||
<menulist>
|
<menulist>
|
||||||
<menupopup type="select-account" statustext="User or group" id="account" multiple="true" no_lang="true" tags="true" account_type="both" empty_label="User or group" class="et2_fullWidth" width="99%"/>
|
<menupopup type="select-account" statustext="User or group" id="account" multiple="true" no_lang="true" tags="true" account_type="both" empty_label="User or group" class="et2_fullWidth" width="99%"/>
|
||||||
</menulist>
|
</menulist>
|
||||||
<link-entry id="resource" options="@cal_resources"/>
|
<link-entry id="resource" options="@cal_resources" query="app.calendar.edit_participant_search"/>
|
||||||
</vbox>
|
</vbox>
|
||||||
<vbox span="2" valign="middle">
|
<vbox span="2" valign="middle">
|
||||||
<textbox type="integer" align="center" id="quantity" min="1" size="3"/>
|
<textbox type="integer" align="center" id="quantity" min="1" size="3"/>
|
||||||
|
@ -588,11 +588,11 @@ class resources_bo
|
|||||||
$data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter);
|
$data = $this->so->search($criteria,$only_keys,$order_by='name',$extra_cols='',$wildcard='%',$empty,$op='OR',$limit,$filter);
|
||||||
// maybe we need to check disponibility of the searched resources in the calendar if $pattern ['exec'] contains some extra args
|
// maybe we need to check disponibility of the searched resources in the calendar if $pattern ['exec'] contains some extra args
|
||||||
$show_conflict=False;
|
$show_conflict=False;
|
||||||
if (is_array($pattern) && isset($pattern['exec']) )
|
if ($options['exec'])
|
||||||
{
|
{
|
||||||
// we'll use a cache for resources info taken from database
|
// we'll use a cache for resources info taken from database
|
||||||
static $res_info_cache = array();
|
static $res_info_cache = array();
|
||||||
$cal_info=$pattern['exec'];
|
$cal_info=$options['exec'];
|
||||||
if ( isset($cal_info['start']) && isset($cal_info['duration']))
|
if ( isset($cal_info['start']) && isset($cal_info['duration']))
|
||||||
{
|
{
|
||||||
//get a calendar objet for reservations
|
//get a calendar objet for reservations
|
||||||
@ -601,22 +601,14 @@ class resources_bo
|
|||||||
require_once(EGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_bo.inc.php');
|
require_once(EGW_INCLUDE_ROOT.'/calendar/inc/class.calendar_bo.inc.php');
|
||||||
$this->bocal =& CreateObject('calendar.calendar_bo');
|
$this->bocal =& CreateObject('calendar.calendar_bo');
|
||||||
}
|
}
|
||||||
|
$start = new egw_time($cal_info['start']);
|
||||||
//get the real timestamps from infos we have on the event
|
$startarr= getdate($start->format('ts'));
|
||||||
//use etemplate date widget to handle date values
|
|
||||||
require_once(EGW_INCLUDE_ROOT.'/phpgwapi/inc/class.jscalendar.inc.php');
|
|
||||||
$jscal=& CreateObject('phpgwapi.jscalendar');
|
|
||||||
$startarr= $jscal->input2date($cal_info['start']['str'],$raw='raw',$day='day',$month='month',$year='year');
|
|
||||||
if (isset($cal_info['whole_day'])) {
|
if (isset($cal_info['whole_day'])) {
|
||||||
$startarr['hour'] = $startarr['minute'] = 0;
|
$startarr['hour'] = $startarr['minute'] = 0;
|
||||||
unset($startarr['raw']);
|
$start = new egw_time($startarr);
|
||||||
$start = $this->bocal->date2ts($startarr);
|
$end = $start->format('ts') + 86399;
|
||||||
$end = $start + 86399;
|
|
||||||
} else {
|
} else {
|
||||||
$startarr['hour'] = $cal_info['start']['H'];
|
$start = $start->format('ts');
|
||||||
$startarr['minute'] = $cal_info['start']['i'];
|
|
||||||
unset($startarr['raw']);
|
|
||||||
$start = $this->bocal->date2ts($startarr);
|
|
||||||
$end = $start + ($cal_info['duration']);
|
$end = $start + ($cal_info['duration']);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,7 +665,7 @@ class resources_bo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isset($res_info_cache)) {
|
if (isset($res_info_cache)) {
|
||||||
$show_conflict= (isset($pattern['exec']['show_conflict'])&& ($pattern['exec']['show_conflict']=='0'))? False:True;
|
$show_conflict= (isset($options['exec']['show_conflict'])&& ($options['exec']['show_conflict']=='0'))? False:True;
|
||||||
// if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar
|
// if we have this array indexed on resource id it means non-bookable resource are removed and we are working for calendar
|
||||||
// so we'll loop on this one and not $data
|
// so we'll loop on this one and not $data
|
||||||
foreach($res_info_cache as $id => $resource) {
|
foreach($res_info_cache as $id => $resource) {
|
||||||
|
Loading…
Reference in New Issue
Block a user