Skip to content
Snippets Groups Projects
Commit f89a5cfa authored by Tyler Lemburg's avatar Tyler Lemburg
Browse files

Merge branch 'develop'

parents e31e1cfd 5e96efb9
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -25,7 +25,7 @@ $router->map('GET', '/logout/?', function() {
\Auth::logout();
});
$router->map('GET', '/[a:controller]/[a:action]/?', function($controller, $action) {
\Core::callController($controller, $action);
\Core::callController($controller, $action, array_merge(array(), $_GET));
});
$router->map('GET', '/[a:controller]/[a:action]/[**:trailing]', function($controller, $action, $trailing) {
# convert "trailing" into an array of params
......@@ -43,7 +43,7 @@ $router->map('GET', '/[a:controller]/[a:action]/[**:trailing]', function($contro
$even = !$even;
}
\Core::callController($controller, $action, $params);
\Core::callController($controller, $action, array_merge($_GET, $params));
});
$router->map('POST', '/[a:controller]/[a:action]/?', function($controller, $action) {
\Core::callController($controller, 'post' . ucfirst($action), $_POST);
......
......@@ -601,11 +601,98 @@ UNL Lockup Factory';
self::requireAuth();
\Core::$breadcrumbs[] = array('text' => 'Manage Lockups');
$page_size = 10;
$all_page = 1;
$all_offset = 0;
$my_page = 1;
$my_offset = 0;
$approver_page = 1;
$approver_offset = 0;
$creative_page = 1;
$creative_offset = 0;
if (array_key_exists('all_page', $get_params)) {
if ((int)($get_params['all_page']) >= 1) {
$all_page = (int)($get_params['all_page']);
$all_offset = ($all_page - 1) * $page_size;
}
}
if (array_key_exists('page', $get_params)) {
if ((int)($get_params['page']) >= 1) {
$my_page = (int)($get_params['page']);
$my_offset = ($my_page - 1) * $page_size;
}
}
if (array_key_exists('approver_page', $get_params)) {
if ((int)($get_params['approver_page']) >= 1) {
$approver_page = (int)($get_params['approver_page']);
$approver_offset = ($approver_page - 1) * $page_size;
}
}
if (array_key_exists('creative_page', $get_params)) {
if ((int)($get_params['creative_page']) >= 1) {
$creative_page = (int)($get_params['creative_page']);
$creative_offset = ($creative_page - 1) * $page_size;
}
}
$all_options = array('include' => array('user'), 'offset' => $all_offset, 'limit' => $page_size);
$my_options = array('include' => array('user'), 'offset' => $my_offset, 'limit' => $page_size,
'conditions' => array('user_id = ?', \Auth::$current_user->id));
$approver_options = array('offset' => $approver_offset, 'limit' => $page_size,
'conditions' => array('approver_id = ? AND status in (?)', \Auth::$current_user->id, array('awaiting_approval', 'feedback_given')));
$creative_options = array('offset' => $creative_offset, 'limit' => $page_size,
'conditions' => array('creative_status in (?)', array('awaiting_approval', 'feedback_given')));
$search_term = array_key_exists('search_term', $get_params) ? $get_params['search_term'] : NULL;
$search_sql_string = '(organization LIKE ? OR subject LIKE ? OR organization_second_line LIKE ? OR subject_second_line LIKE ? OR
acronym LIKE ? OR acronym_second_line LIKE ? OR acronym_subject LIKE ? OR extension_county LIKE ?)';
$search_array = array('%'.$search_term.'%','%'.$search_term.'%','%'.$search_term.'%','%'.$search_term.'%','%'.$search_term.'%',
'%'.$search_term.'%','%'.$search_term.'%','%'.$search_term.'%');
if (!empty($search_term)) {
$all_options['conditions'] = array_merge(array($search_sql_string), $search_array);
$my_options['conditions'][0] = $my_options['conditions'][0] . ' AND ' . $search_sql_string;
$my_options['conditions'] = array_merge($my_options['conditions'], $search_array);
$approver_options['conditions'][0] = $approver_options['conditions'][0] . ' AND ' . $search_sql_string;
$approver_options['conditions'] = array_merge($approver_options['conditions'], $search_array);
$creative_options['conditions'][0] = $creative_options['conditions'][0] . ' AND ' . $search_sql_string;
$creative_options['conditions'] = array_merge($creative_options['conditions'], $search_array);
}
$context = new \stdClass;
$context->all_lockups = Lockup::all(array('include' => array('user')));
$context->my_lockups = \Auth::$current_user->lockups;
$context->approver_lockups = Lockup::all(array('conditions' => array('approver_id = ? AND status in (?)', \Auth::$current_user->id, array('awaiting_approval', 'feedback_given'))));
$context->creative_approval_lockups = Lockup::all(array('conditions' => array('creative_status in (?)', array('awaiting_approval', 'feedback_given'))));
$context->all_lockups = Lockup::all($all_options);
unset($all_options['offset']);
unset($all_options['limit']);
unset($all_options['include']);
$context->all_count = Lockup::count($all_options);
$context->all_page = $all_page;
$context->my_lockups = Lockup::all($my_options);
unset($my_options['offset']);
unset($my_options['limit']);
unset($my_options['include']);
$context->my_count = Lockup::count($my_options);
$context->my_page = $my_page;
$context->approver_lockups = Lockup::all($approver_options);
unset($approver_options['offset']);
unset($approver_options['limit']);
unset($approver_options['include']);
$context->approver_count = Lockup::count($approver_options);
$context->approver_page = $approver_page;
$context->creative_approval_lockups = Lockup::all($creative_options);
unset($creative_options['offset']);
unset($creative_options['limit']);
unset($creative_options['include']);
$context->creative_count = Lockup::count($creative_options);
$context->creative_page = $creative_page;
$context->page_size = $page_size;
$context->search_term = $search_term;
return self::renderView('manage_lockups', $context);
}
......
......@@ -84,7 +84,7 @@ class Lockup extends \ActiveRecord\Model {
} else if ($this->isFullyApproved()) {
return 'Fully Approved';
} else {
return 'Communicator: ' . ucwords(join(explode('_', $this->status), ' ')) . '; Creative: ' . ucwords(join(explode('_', $this->creative_status), ' '));
return 'Communicator: ' . ucwords(join(explode('_', $this->status), ' ')) . ';<br>Creative: ' . ucwords(join(explode('_', $this->creative_status), ' '));
}
}
......
<?php
$all_pages = ceil($context->all_count / $context->page_size);
$my_pages = ceil($context->my_count / $context->page_size);
$approver_pages = ceil($context->approver_count / $context->page_size);
$creative_pages = ceil($context->creative_count / $context->page_size);
$page_array = array();
if ($context->all_page != 1) {
$page_array['all_page'] = $context->all_page;
}
if ($context->my_page != 1) {
$page_array['page'] = $context->my_page;
}
if ($context->approver_page != 1) {
$page_array['approver_page'] = $context->approver_page;
}
if ($context->creative_page != 1) {
$page_array['creative_page'] = $context->creative_page;
}
if (!empty($context->search_term)) {
$page_array['search_term'] = $context->search_term;
}
function outputParam($key, $val) {
return $key . '=' . $val;
}
function outputPages($array) {
$str = '?';
return $str . implode('&', array_map('outputParam', array_keys($array), $array));
}
?>
<script type="text/javascript">
WDN.loadCSS(WDN.getTemplateFilePath('css/modules/pagination.css'));
</script>
<div class="wdn-band">
<div class="wdn-inner-wrapper">
<h3 class="page-title">Manage Lockups</h3>
<form>
<input style="width: auto;" value="<?php echo $context->search_term ?>" type="text" placeholder="Search..." name="search_term">
<button type="submit" class="wdn-button wdn-button-triad">Search</button>
<?php if (!empty($context->search_term)): ?>
<button id="clear-search" class="wdn-button wdn-button" type="button">&times;</button>
<?php endif; ?>
</form>
<?php if (\Auth::$current_user->isAdmin()): ?>
<h4 class="wdn-brand">All Lockups</h4>
<table>
<thead>
<tr>
<th>ID</th>
<th>All Lockups</th>
<th>Title</th>
<th>Submitter</th>
<th>Submitted</th>
<th>Approver</th>
<th>Status</th>
<th>Version</th>
......@@ -17,9 +60,10 @@
<tbody>
<?php foreach ($context->all_lockups as $lockup): ?>
<tr>
<td><?php echo $lockup->id ?></td>
<td><?php echo $lockup->id; ?></td>
<td><a href="<?php echo $lockup->getPreviewURL(); ?>"><?php echo $lockup->getName(); ?></a></td>
<td><?php echo $lockup->user->username ?></td>
<td><?php echo $lockup->user->username; ?></td>
<td><?php echo $lockup->date_created;?></td>
<td><?php echo $lockup->getApproverName(); ?></td>
<td><?php echo $lockup->getFullStatusText(); ?></td>
<td><?php echo $lockup->version; ?></td>
......@@ -36,77 +80,211 @@
<?php endforeach; ?>
</tbody>
</table>
<?php if ($all_pages > 1): ?>
<div style="text-align: center;">
<div style="display: inline-block;">
<ul id="pending-pagination" class="wdn_pagination" data-tab="pending" style="padding-left: 0;">
<?php if($context->all_page != 1): ?>
<li class="arrow prev"><a href="<?php echo outputPages(array_merge($page_array, array('all_page' => $context->all_page - 1))); ?>" title="Go to the previous page">← prev</a></li>
<?php endif; ?>
<?php $before_ellipsis_shown = FALSE; $after_ellipsis_shown = FALSE; ?>
<?php for ($i = 1; $i <= $all_pages; $i++): ?>
<?php if ($i == $context->all_page): ?>
<li class="selected"><span><?php echo $i; ?></span></li>
<?php elseif ($i <= 3 || $i >= $all_pages - 2 || $i == $context->all_page - 1 ||
$i == $context->all_page - 2 || $i == $context->all_page + 1 || $i == $context->all_page + 2): ?>
<li><a href="<?php echo outputPages(array_merge($page_array, array('all_page' => $i))); ?>" title="Go to page <?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php elseif ($i < $context->all_page && !$before_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $before_ellipsis_shown = TRUE; ?>
<?php elseif ($i > $context->all_page && !$after_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $after_ellipsis_shown = TRUE; ?>
<?php endif; ?>
<?php endfor; ?>
<?php if($context->all_page != $all_pages): ?>
<li class="arrow next"><a href="<?php echo outputPages(array_merge($page_array, array('all_page' => $context->all_page + 1))); ?>" title="Go to the next page">next →</a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
<?php else: ?>
<?php if (\Auth::$current_user->isApprover()): ?>
<h4 class="wdn-brand">Lockups Needing Communicator Approval</h4>
<table>
<thead>
<tr>
<th>My Lockups</th>
<th>Approver</th>
<th>Title</th>
<th>Submitter</th>
<th>Submitted</th>
<th>Status</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($context->my_lockups as $lockup): ?>
<?php foreach ($context->approver_lockups as $lockup): ?>
<tr>
<td><a href="<?php echo $lockup->getPreviewURL(); ?>"><?php echo $lockup->getName(); ?></a></td>
<td><?php echo $lockup->getApproverName(); ?></td>
<td><?php echo $lockup->user->username ?></td>
<td><?php echo date('M j, Y', strtotime($lockup->date_created)) ?></td>
<td><?php echo $lockup->getFullStatusText(); ?></td>
<td class="table-actions right" style="min-width: 200px;">
<?php if ($lockup->isEditable()): ?>
<a class="wdn-button wdn-button-triad" href="<?php echo $lockup->getEditURL(); ?>">Edit</a>
<?php endif; ?>
<form action="<?php echo $lockup->getDeleteURL(); ?>" method="POST">
<button type="submit" class="wdn-button wdn-button-brand">Delete</button>
<input type="hidden" name="id" value="<?php echo $lockup->id ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($approver_pages > 1): ?>
<div style="text-align: center;">
<div style="display: inline-block;">
<ul id="pending-pagination" class="wdn_pagination" data-tab="pending" style="padding-left: 0;">
<?php if($context->approver_page != 1): ?>
<li class="arrow prev"><a href="<?php echo outputPages(array_merge($page_array, array('approver_page' => $context->approver_page - 1))); ?>" title="Go to the previous page">← prev</a></li>
<?php endif; ?>
<?php $before_ellipsis_shown = FALSE; $after_ellipsis_shown = FALSE; ?>
<?php for ($i = 1; $i <= $approver_pages; $i++): ?>
<?php if ($i == $context->approver_page): ?>
<li class="selected"><span><?php echo $i; ?></span></li>
<?php elseif ($i <= 3 || $i >= $approver_page - 2 || $i == $context->approver_page - 1 ||
$i == $context->approver_page - 2 || $i == $context->approver_page + 1 || $i == $context->approver_page + 2): ?>
<li><a href="<?php echo outputPages(array_merge($page_array, array('approver_page' => $i))); ?>" title="Go to page <?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php elseif ($i < $context->approver_page && !$before_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $before_ellipsis_shown = TRUE; ?>
<?php elseif ($i > $context->approver_page && !$after_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $after_ellipsis_shown = TRUE; ?>
<?php endif; ?>
<?php endfor; ?>
<?php if($context->approver_page != $approver_pages): ?>
<li class="arrow next"><a href="<?php echo outputPages(array_merge($page_array, array('approver_page' => $context->approver_page + 1))); ?>" title="Go to the next page">next →</a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
<br>
<?php if (\Auth::$current_user->isApprover()): ?>
<?php endif; ?>
<?php if (\Auth::$current_user->isCreative()): ?>
<h4 class="wdn-brand">Lockups Needing Creative Approval</h4>
<table>
<thead>
<tr>
<th>Lockups Needing Communicator Approval</th>
<th>Title</th>
<th>Submitter</th>
<th>Submitted</th>
<th>Status</th>
</tr>
</thead>
<tbody>
<?php foreach ($context->approver_lockups as $lockup): ?>
<?php foreach ($context->creative_approval_lockups as $lockup): ?>
<tr>
<td><a href="<?php echo $lockup->getPreviewURL(); ?>"><?php echo $lockup->getName(); ?></a></td>
<td><?php echo $lockup->user->username ?></td>
<td><?php echo date('M j, Y', strtotime($lockup->date_created)) ?></td>
<td><?php echo $lockup->getFullStatusText(); ?></td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($creative_pages > 1): ?>
<div style="text-align: center;">
<div style="display: inline-block;">
<ul id="pending-pagination" class="wdn_pagination" data-tab="pending" style="padding-left: 0;">
<?php if($context->creative_page != 1): ?>
<li class="arrow prev"><a href="<?php echo outputPages(array_merge($page_array, array('creative_page' => $context->creative_page - 1))); ?>" title="Go to the previous page">← prev</a></li>
<?php endif; ?>
<?php $before_ellipsis_shown = FALSE; $after_ellipsis_shown = FALSE; ?>
<?php for ($i = 1; $i <= $creative_pages; $i++): ?>
<?php if ($i == $context->creative_page): ?>
<li class="selected"><span><?php echo $i; ?></span></li>
<?php elseif ($i <= 3 || $i >= $context->creative_page - 2 || $i == $context->creative_page - 1 ||
$i == $context->creative_page - 2 || $i == $context->creative_page + 1 || $i == $context->creative_page + 2): ?>
<li><a href="<?php echo outputPages(array_merge($page_array, array('creative_page' => $i))); ?>" title="Go to page <?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php elseif ($i < $context->creative_page && !$before_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $before_ellipsis_shown = TRUE; ?>
<?php elseif ($i > $context->creative_page && !$after_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $after_ellipsis_shown = TRUE; ?>
<?php endif; ?>
<?php endfor; ?>
<?php if($context->creative_page != $creative_pages): ?>
<li class="arrow next"><a href="<?php echo outputPages(array_merge($page_array, array('creative_page' => $context->creative_page + 1))); ?>" title="Go to the next page">next →</a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
<br>
<?php if (\Auth::$current_user->isCreative()): ?>
<?php endif; ?>
<h4 class="wdn-brand">My Lockups</h4>
<table>
<thead>
<tr>
<th>Lockups Needing Creative Approval</th>
<th>Submitter</th>
<th>Title</th>
<th>Approver</th>
<th>Status</th>
<th class="right">Actions</th>
</tr>
</thead>
<tbody>
<?php foreach ($context->creative_approval_lockups as $lockup): ?>
<?php foreach ($context->my_lockups as $lockup): ?>
<tr>
<td><a href="<?php echo $lockup->getPreviewURL(); ?>"><?php echo $lockup->getName(); ?></a></td>
<td><?php echo $lockup->user->username ?></td>
<td><?php echo $lockup->getApproverName(); ?></td>
<td><?php echo $lockup->getFullStatusText(); ?></td>
<td class="table-actions right" style="min-width: 200px;">
<?php if ($lockup->isEditable()): ?>
<a class="wdn-button wdn-button-triad" href="<?php echo $lockup->getEditURL(); ?>">Edit</a>
<?php endif; ?>
<form action="<?php echo $lockup->getDeleteURL(); ?>" method="POST" class="delete-form">
<button type="submit" class="wdn-button wdn-button-brand">Delete</button>
<input type="hidden" name="id" value="<?php echo $lockup->id ?>">
</form>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?php if ($my_pages > 1): ?>
<div style="text-align: center;">
<div style="display: inline-block;">
<ul id="pending-pagination" class="wdn_pagination" data-tab="pending" style="padding-left: 0;">
<?php if($context->my_page != 1): ?>
<li class="arrow prev"><a href="<?php echo outputPages(array_merge($page_array, array('page' => $context->my_page - 1))); ?>" title="Go to the previous page">← prev</a></li>
<?php endif; ?>
<?php $before_ellipsis_shown = FALSE; $after_ellipsis_shown = FALSE; ?>
<?php for ($i = 1; $i <= $my_pages; $i++): ?>
<?php if ($i == $context->my_page): ?>
<li class="selected"><span><?php echo $i; ?></span></li>
<?php elseif ($i <= 3 || $i >= $my_pages - 2 || $i == $context->my_page - 1 ||
$i == $context->my_page - 2 || $i == $context->my_page + 1 || $i == $context->my_page + 2): ?>
<li><a href="<?php echo outputPages(array_merge($page_array, array('page' => $i))); ?>" title="Go to page <?php echo $i; ?>"><?php echo $i; ?></a></li>
<?php elseif ($i < $context->my_page && !$before_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $before_ellipsis_shown = TRUE; ?>
<?php elseif ($i > $context->my_page && !$after_ellipsis_shown): ?>
<li><span class="ellipsis">...</span></li>
<?php $after_ellipsis_shown = TRUE; ?>
<?php endif; ?>
<?php endfor; ?>
<?php if($context->my_page != $my_pages): ?>
<li class="arrow next"><a href="<?php echo outputPages(array_merge($page_array, array('page' => $context->my_page + 1))); ?>" title="Go to the next page">next →</a></li>
<?php endif; ?>
</ul>
</div>
</div>
<?php endif; ?>
<br>
<?php endif; ?>
</div>
</div>
<script type="text/javascript">
require(['jquery'], function ($) {
$(document).ready(function () {
$('#clear-search').click(function (click) {
window.location = window.location.href.split('?')[0];
});
});
});
</script>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment