Newer
Older
if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied');
$info = $members = $qs = array();
$submit_text=__('Save Changes');
$trans['name'] = $team->getTranslateTag('name');
$submit_text=__('Create Team');
if (!$team) {
$team = Team::create(array(
'flags' => Team::FLAG_ENABLED,
));
}
<form action="teams.php?<?php echo Http::build_query($qs); ?>" method="post" id="save">
<input type="hidden" name="do" value="<?php echo $action; ?>">
<input type="hidden" name="a" value="<?php echo Format::htmlchars($_REQUEST['a']); ?>">
<input type="hidden" name="id" value="<?php echo $team->getId(); ?>">
<i class="help-tip icon-question-sign" href="#teams"></i>
</h2>
<li class="active"><a href="#team">
<i class="icon-file"></i> <?php echo __('Team'); ?></a></li>
<li><a href="#members">
<i class="icon-group"></i> <?php echo __('Members'); ?></a></li>
</ul>
<table class="form_table" width="940" border="0" cellspacing="0" cellpadding="2">
<thead>
<tr>
<th colspan="2">
<h4><?php echo $title; ?></h4>
<em><strong><?php echo __('Team Information'); ?></strong>:</em>
</th>
</tr>
</thead>
<tbody>
<tr>
<td width="180" class="required">
<input type="text" size="30" name="name" value="<?php echo Format::htmlchars($team->name); ?>"
autofocus data-translate-tag="<?php echo $trans['name']; ?>"/>
<span class="error">* <?php echo $errors['name']; ?></span>
</td>
</tr>
<tr>
<td width="180" class="required">
<input type="radio" name="isenabled" value="1" <?php echo $team->isEnabled()?'checked="checked"':''; ?>><strong><?php echo __('Active');?></strong>
<input type="radio" name="isenabled" value="0" <?php echo !$team->isEnabled()?'checked="checked"':''; ?>><?php echo __('Disabled');?>
<i class="help-tip icon-question-sign" href="#status"></i>
</span>
<option value="0">— <?php echo __('None');?> —</option>
$selected=($team->lead_id && $staff->getId()==$team->lead_id)?'selected="selected"':'';
echo sprintf('<option value="%d" %s>%s</option>',$staff->getId(),$selected,$staff->getName());
}
}
?>
</select>
<span class="error"><?php echo $errors['lead_id']; ?></span>
<i class="help-tip icon-question-sign" href="#lead"></i>
</span>
<?php echo __('Assignment Alert');?>:
<input type="checkbox" name="noalerts" value="1" <?php echo !$team->alertsEnabled()?'checked="checked"':''; ?> >
<?php echo __('<strong>Disable</strong> for this Team'); ?>
<i class="help-tip icon-question-sign" href="#assignment_alert"></i>
<em><strong><?php echo __('Admin Notes');?></strong>: <?php echo __('Internal notes viewable by all admins.');?> </em>
<textarea class="richtext no-bar" name="notes" cols="21"
rows="8" style="width: 80%;"><?php echo Format::htmlchars($team->notes); ?></textarea>
$agents = Staff::getStaffMembers();
foreach ($members as $m)
unset($agents[$m->staff_id]);
?>
<div id="members" class="tab_content" style="display:none">
<table class="two-column table" width="100%">
<tbody>
<tr class="header">
<td colspan="2">
<?php echo __('Team Members'); ?>
<div><small>
<?php echo __('Agents who are members of this team'); ?>
<i class="help-tip icon-question-sign" href="#members"></i>
</small></div>
</td>
<tr id="add_member">
<td colspan="2">
<i class="icon-plus-sign"></i>
<select id="add_access" data-quick-add="staff">
<option value="0">— <?php echo __('Select Agent');?> —</option>
<?php
foreach ($agents as $id=>$name) {
echo sprintf('<option value="%d">%s</option>',$id,Format::htmlchars($name));
}
?>
<option value="0" data-quick-add>— <?php echo __('Add New');?> —</option>
</select>
<button type="button" class="action-button">
<?php echo __('Add'); ?>
</button>
</td>
</tr>
</tbody>
<tr id="member_template" class="hidden">
<td>
<input type="hidden" data-name="members[]" value="" />
</td>
<td>
<label>
<input type="checkbox" data-name="member_alerts" value="1" />
<?php echo __('Alerts'); ?>
</label>
<a href="#" class="pull-right drop-membership" title="<?php echo __('Delete');
?>"><i class="icon-trash"></i></a>
</td>
</tr>
<input type="submit" name="submit" value="<?php echo $submit_text; ?>">
<input type="reset" name="reset" value="<?php echo __('Reset');?>">
<input type="button" name="cancel" value="<?php echo __('Cancel');?>" onclick='window.location.href="?"'>
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
<script type="text/javascript">
var addMember = function(staffid, name, alerts, error) {
var copy = $('#member_template').clone();
copy.find('[data-name=members\\[\\]]')
.attr('name', 'members[]')
.val(staffid);
copy.find('[data-name^=member_alerts]')
.attr('name', 'member_alerts['+staffid+']')
.prop('checked', alerts);
copy.find('td:first').append(document.createTextNode(name));
copy.attr('id', '').show().insertBefore($('#add_member'));
copy.removeClass('hidden')
if (error)
$('<div class="error">').text(error).appendTo(copy.find('td:last'));
};
$('#add_member').find('button').on('click', function() {
var selected = $('#add_access').find(':selected');
addMember(selected.val(), selected.text(), true);
selected.remove();
return false;
});
$(document).on('click', 'a.drop-membership', function() {
var tr = $(this).closest('tr');
$('#add_access').append(
$('<option>')
.attr('value', tr.find('input[name^=members][type=hidden]').val())
.text(tr.find('td:first').text())
);
tr.fadeOut(function() { $(this).remove(); });
return false;
});
<?php
if ($team) {
foreach ($team->members->sort(function($a) { return $a->staff->getName(); }) as $member) {
echo sprintf('addMember(%d, %s, %d, %s);',
$member->staff_id,
JsonDataEncoder::encode((string) $member->staff->getName()),
$member->isAlertsEnabled(),
JsonDataEncoder::encode($errors['members'][$member->staff_id])
);
}
}
?>
</script>