mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-02-24 22:21:34 +01:00
* check quantity of resource to book against maximum, as conflict check only fails if other events are involved
This commit is contained in:
parent
b19c4b3030
commit
c115d73cfb
@ -156,6 +156,7 @@ class calendar_uiforms extends calendar_ui
|
||||
* Process the edited event and evtl. call edit to redisplay it
|
||||
*
|
||||
* @param array $content posted eTemplate content
|
||||
* @ToDo add conflict check / available quantity of resources when adding participants
|
||||
*/
|
||||
function process_edit($content)
|
||||
{
|
||||
@ -317,8 +318,21 @@ class calendar_uiforms extends calendar_ui
|
||||
$status = isset($this->bo->resources[$type]['new_status']) ? ExecMethod($this->bo->resources[$type]['new_status'],$id) : 'U';
|
||||
if ($status)
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types'][$type][$id] =
|
||||
calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
|
||||
$res_info = $this->bo->resource_info($uid);
|
||||
// todo check real availability = maximum - already booked quantity
|
||||
if (isset($res_info['useable']) && $content['participants']['quantity'] > $res_info['useable'])
|
||||
{
|
||||
$msg .= lang('Maximum available quantity of %1 exceeded!',$res_info['useable']);
|
||||
foreach(array('quantity','resource','role') as $n)
|
||||
{
|
||||
$event['participants'][$n] = $content['participants'][$n];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types'][$type][$id] =
|
||||
calendar_so::combine_status($status,$content['participants']['quantity'],$content['participants']['role']);
|
||||
}
|
||||
}
|
||||
elseif(!$msg_permission_denied_added)
|
||||
{
|
||||
@ -332,79 +346,79 @@ class calendar_uiforms extends calendar_ui
|
||||
case 'account':
|
||||
foreach(is_array($data) ? $data : explode(',',$data) as $uid)
|
||||
{
|
||||
if ($uid && $this->bo->check_acl_invite($uid))
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types']['u'][$uid] =
|
||||
calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U',1,$content['participants']['role']);
|
||||
}
|
||||
elseif($uid && !$msg_permission_denied_added)
|
||||
{
|
||||
$msg .= lang('Permission denied!');
|
||||
$msg_permission_denied_added = true;
|
||||
}
|
||||
if ($uid && $this->bo->check_acl_invite($uid))
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types']['u'][$uid] =
|
||||
calendar_so::combine_status($uid == $this->bo->user ? 'A' : 'U',1,$content['participants']['role']);
|
||||
}
|
||||
elseif($uid && !$msg_permission_denied_added)
|
||||
{
|
||||
$msg .= lang('Permission denied!');
|
||||
$msg_permission_denied_added = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
default: // existing participant row
|
||||
foreach(array('uid','status','quantity','role') as $name)
|
||||
{
|
||||
$$name = $data[$name];
|
||||
$$name = $data[$name];
|
||||
}
|
||||
if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
|
||||
{
|
||||
$uid = false; // entry has been deleted
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_numeric($uid))
|
||||
if ($content['participants']['delete'][$uid] || $content['participants']['delete'][md5($uid)])
|
||||
{
|
||||
$id = $uid;
|
||||
$type = 'u';
|
||||
$uid = false; // entry has been deleted
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = substr($uid,1);
|
||||
$type = $uid[0];
|
||||
}
|
||||
if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
|
||||
{
|
||||
//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
|
||||
$new_status = calendar_so::combine_status($status, $quantity, $role);
|
||||
if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0))
|
||||
if (is_numeric($uid))
|
||||
{
|
||||
// refreshing the calendar-view with the changed participant-status
|
||||
if($event['recur_type'] != MCAL_RECUR_NONE)
|
||||
$id = $uid;
|
||||
$type = 'u';
|
||||
}
|
||||
else
|
||||
{
|
||||
$id = substr($uid,1);
|
||||
$type = $uid[0];
|
||||
}
|
||||
if ($data['old_status'] != $status && !(!$data['old_status'] && $status == 'G'))
|
||||
{
|
||||
//echo "<p>$uid: status changed '$data[old_status]' --> '$status<'/p>\n";
|
||||
$new_status = calendar_so::combine_status($status, $quantity, $role);
|
||||
if ($this->bo->set_status($event['id'],$uid,$new_status,isset($content['edit_single']) ? $content['participants']['status_date'] : 0))
|
||||
{
|
||||
$msg = lang('Status for all future scheduled days changed');
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isset($content['edit_single']))
|
||||
// refreshing the calendar-view with the changed participant-status
|
||||
if($event['recur_type'] != MCAL_RECUR_NONE)
|
||||
{
|
||||
$msg = lang('Status for this particular day changed');
|
||||
// prevent accidentally creating a real exception afterwards
|
||||
$view = true;
|
||||
$hide_delete = true;
|
||||
$msg = lang('Status for all future scheduled days changed');
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = lang('Status changed');
|
||||
if(isset($content['edit_single']))
|
||||
{
|
||||
$msg = lang('Status for this particular day changed');
|
||||
// prevent accidentally creating a real exception afterwards
|
||||
$view = true;
|
||||
$hide_delete = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = lang('Status changed');
|
||||
}
|
||||
}
|
||||
if (!$content['no_popup'])
|
||||
{
|
||||
$js = "opener.location.search += (opener.location.search?'&msg=':'?msg=')+'".
|
||||
addslashes($msg)."';";
|
||||
}
|
||||
}
|
||||
if (!$content['no_popup'])
|
||||
{
|
||||
$js = "opener.location.search += (opener.location.search?'&msg=':'?msg=')+'".
|
||||
addslashes($msg)."';";
|
||||
}
|
||||
}
|
||||
if ($uid && $status != 'G')
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types'][$type][$id] =
|
||||
calendar_so::combine_status($status,$quantity,$role);
|
||||
}
|
||||
}
|
||||
if ($uid && $status != 'G')
|
||||
{
|
||||
$event['participants'][$uid] = $event['participant_types'][$type][$id] =
|
||||
calendar_so::combine_status($status,$quantity,$role);
|
||||
}
|
||||
}
|
||||
break;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1195,6 +1209,11 @@ function replace_eTemplate_onsubmit()
|
||||
|
||||
$row = 2;
|
||||
$readonlys = $content['participants'] = $preserv['participants'] = array();
|
||||
// preserve some ui elements, if set eg. under error-conditions
|
||||
foreach(array('quantity','resource','role') as $n)
|
||||
{
|
||||
if (isset($event['participants'][$n])) $content['participants'][$n] = $event['participants'][$n];
|
||||
}
|
||||
foreach($event['participant_types'] as $type => $participants)
|
||||
{
|
||||
$name = 'accounts';
|
||||
|
Loading…
Reference in New Issue
Block a user