1<?php 2if(!defined('OSTADMININC') || !$thisstaff || !$thisstaff->isAdmin()) die('Access Denied'); 3 4$qs = array(); 5$sortOptions=array( 6 'name' => 'name', 7 'status' => 'isenabled', 8 'members' => 'members_count', 9 'lead' => 'lead__lastname', 10 'created' => 'created', 11 'updated' => 'updated', 12 ); 13 14$orderWays = array('DESC'=>'DESC', 'ASC'=>'ASC'); 15$sort = ($_REQUEST['sort'] && $sortOptions[strtolower($_REQUEST['sort'])]) ? strtolower($_REQUEST['sort']) : 'name'; 16 17//Sorting options... 18if ($sort && $sortOptions[$sort]) { 19 $order_column = $sortOptions[$sort]; 20} 21 22$order_column = $order_column ? $order_column : 'name'; 23 24if ($_REQUEST['order'] && isset($orderWays[strtoupper($_REQUEST['order'])])) { 25 $order = $orderWays[strtoupper($_REQUEST['order'])]; 26} else { 27 $order = 'ASC'; 28} 29 30if ($order_column && strpos($order_column,',')) { 31 $order_column=str_replace(','," $order,",$order_column); 32} 33$x=$sort.'_sort'; 34$$x=' class="'.strtolower($order).'" '; 35$page = ($_GET['p'] && is_numeric($_GET['p'])) ? $_GET['p'] : 1; 36$count = Team::objects()->count(); 37$pageNav = new Pagenate($count, $page, PAGE_LIMIT); 38$qstr = '&'. Http::build_query($qs); 39$qs += array('sort' => $_REQUEST['sort'], 'order' => $_REQUEST['order']); 40$pageNav->setURL('teams.php', $qs); 41$showing = $pageNav->showing().' '._N('team', 'teams', $count); 42$qstr .= '&order='.urlencode($order=='DESC' ? 'ASC' : 'DESC'); 43 44 45?> 46<form action="teams.php" method="POST" name="teams"> 47<div class="sticky bar"> 48 <div class="content"> 49 <div class="pull-left"> 50 <h2><?php echo __('Teams');?> 51 <i class="help-tip icon-question-sign notsticky" href="#teams"></i> 52 </h2> 53 </div> 54 <div class="pull-right flush-right"> 55 <a href="teams.php?a=add" class="green button action-button"><i class="icon-plus-sign"></i> <?php echo __('Add New Team');?></a> 56 <span class="action-button" data-dropdown="#action-dropdown-more"> 57 <i class="icon-caret-down pull-right"></i> 58 <span ><i class="icon-cog"></i> <?php echo __('More');?></span> 59 </span> 60 <div id="action-dropdown-more" class="action-dropdown anchor-right"> 61 <ul id="actions"> 62 <li><a class="confirm" data-name="enable" href="teams.php?a=enable"> 63 <i class="icon-ok-sign icon-fixed-width"></i> 64 <?php echo __('Enable'); ?></a></li> 65 <li><a class="confirm" data-name="disable" href="teams.php?a=disable"> 66 <i class="icon-ban-circle icon-fixed-width"></i> 67 <?php echo __('Disable'); ?></a></li> 68 <li class="danger"><a class="confirm" data-name="delete" href="teams.php?a=delete"> 69 <i class="icon-trash icon-fixed-width"></i> 70 <?php echo __('Delete'); ?></a></li> 71 </ul> 72 </div> 73 </div> 74 <div class="clear"></div> 75 </div> 76</div> 77 <?php csrf_token(); ?> 78 <input type="hidden" name="do" value="mass_process" > 79 <input type="hidden" id="action" name="a" value="" > 80 <table class="list" border="0" cellspacing="1" cellpadding="0" width="940"> 81 <thead> 82 <tr> 83 <th width="4%"> </th> 84 <th width="25%"><a <?php echo $name_sort; ?> href="teams.php?<?php echo $qstr; ?>&sort=name"><?php echo __('Team Name');?></a></th> 85 <th width="8%"><a <?php echo $status_sort; ?> href="teams.php?<?php echo $qstr; ?>&sort=status"><?php echo __('Status');?></a></th> 86 <th width="8%"><a <?php echo $members_sort; ?>href="teams.php?<?php echo $qstr; ?>&sort=members"><?php echo __('Members');?></a></th> 87 <th width="20%"><a <?php echo $lead_sort; ?> href="teams.php?<?php echo $qstr; ?>&sort=lead"><?php echo __('Team Lead');?></a></th> 88 <th width="15%"><a <?php echo $created_sort; ?> href="teams.php?<?php echo $qstr; ?>&sort=created"><?php echo __('Created');?></a></th> 89 <th width="20%"><a <?php echo $updated_sort; ?> href="teams.php?<?php echo $qstr; ?>&sort=updated"><?php echo __('Last Updated');?></a></th> 90 </tr> 91 </thead> 92 <tbody> 93 <?php 94 $ids= ($errors && is_array($_POST['ids'])) ? $_POST['ids'] : null; 95 if ($count) { 96 $teams = Team::objects() 97 ->annotate(array( 98 'members_count'=>SqlAggregate::COUNT('members__staff', true), 99 )) 100 ->order_by(sprintf('%s%s', 101 strcasecmp($order, 'DESC') ? '' : '-', 102 $order_column)) 103 ->limit($pageNav->getLimit()) 104 ->offset($pageNav->getStart()); 105 106 foreach ($teams as $team) { 107 $id = $team->getId(); 108 $sel=false; 109 if ($ids && in_array($id, $ids)) 110 $sel=true; 111 ?> 112 <tr id="<?php echo $id; ?>"> 113 <td align="center"> 114 <input type="checkbox" class="ckb" name="ids[]" 115 value="<?php echo $id; ?>" 116 <?php echo $sel ? 'checked="checked"' : ''; ?>> </td> 117 <td><a href="teams.php?id=<?php echo $id; ?>"><?php echo 118 $team->getName(); ?></a> </td> 119 <td> <?php echo $team->isActive() ? __('Active') : '<b>'.__('Disabled').'</b>'; ?></td> 120 <td style="text-align:right;padding-right:25px"> 121 <?php if ($team->members_count > 0) { ?> 122 <a href="staff.php?tid=<?php echo $id; ?>"><?php 123 echo $team->members_count; ?></a> 124 <?php } else { ?> 0 125 <?php } ?> 126 127 </td> 128 <td><a href="staff.php?id=<?php 129 echo $team->getLeadId(); ?>"><?php echo $team->lead ?: ''; ?> </a></td> 130 <td><?php echo Format::date($team->created); ?> </td> 131 <td><?php echo Format::datetime($team->updated); ?> </td> 132 </tr> 133 <?php 134 } //end of foreach 135 }?> 136 <tfoot> 137 <tr> 138 <td colspan="7"> 139 <?php if ($count){ ?> 140 <?php echo __('Select');?>: 141 <a id="selectAll" href="#ckb"><?php echo __('All');?></a> 142 <a id="selectNone" href="#ckb"><?php echo __('None');?></a> 143 <a id="selectToggle" href="#ckb"><?php echo __('Toggle');?></a> 144 <?php }else{ 145 echo __('No teams found!'); 146 } ?> 147 </td> 148 </tr> 149 </tfoot> 150</table> 151<?php 152if ($count): //Show options.. 153 echo '<div> '.__('Page').':'.$pageNav->getPageLinks().' </div>'; 154?> 155 156<?php 157endif; 158?> 159</form> 160<div style="display:none;" class="dialog" id="confirm-action"> 161 <h3><?php echo __('Please Confirm');?></h3> 162 <a class="close" href=""><i class="icon-remove-circle"></i></a> 163 <hr/> 164 <p class="confirm-action" style="display:none;" id="enable-confirm"> 165 <?php echo sprintf(__('Are you sure you want to <b>enable</b> %s?'), 166 _N('selected team', 'selected teams', 2));?> 167 </p> 168 <p class="confirm-action" style="display:none;" id="disable-confirm"> 169 <?php echo sprintf(__('Are you sure you want to <b>disable</b> %s?'), 170 _N('selected team', 'selected teams', 2));?> 171 </p> 172 <p class="confirm-action" style="display:none;" id="delete-confirm"> 173 <font color="red"><strong><?php echo sprintf(__('Are you sure you want to DELETE %s?'), 174 _N('selected team', 'selected teams', 2));?></strong></font> 175 <br><br><?php echo __('Deleted data CANNOT be recovered.'); ?> 176 </p> 177 <div><?php echo __('Please confirm to continue.');?></div> 178 <hr style="margin-top:1em"/> 179 <p class="full-width"> 180 <span class="buttons pull-left"> 181 <input type="button" value="<?php echo __('No, Cancel');?>" class="close"> 182 </span> 183 <span class="buttons pull-right"> 184 <input type="button" value="<?php echo __('Yes, Do it!');?>" class="confirm"> 185 </span> 186 </p> 187 <div class="clear"></div> 188</div> 189