| 1 |
<?php |
| 2 |
/** |
| 3 |
* Archive project template |
| 4 |
* |
| 5 |
* WordPress Coding Standart (WCS) note: |
| 6 |
* All camelCase object properties on this file are not converted to snake_case, |
| 7 |
* because it was the data from the model file. |
| 8 |
* |
| 9 |
* @package UpStream |
| 10 |
*/ |
| 11 |
|
| 12 |
/* Prevent direct access. */ |
| 13 |
if ( ! defined( 'ABSPATH' ) ) { |
| 14 |
exit; |
| 15 |
} |
| 16 |
|
| 17 |
@define( 'OP_SCRIPT_DEBUG', '' ); |
| 18 |
|
| 19 |
|
| 20 |
/** |
| 21 |
* The Template for displaying all projects |
| 22 |
* |
| 23 |
* This template can be overridden by copying it to wp-content/themes/yourtheme/upstream/archive-project.php. |
| 24 |
*/ |
| 25 |
|
| 26 |
/* Some hosts disable this function, so let's make sure it is enabled before call it. */ |
| 27 |
if ( function_exists( 'set_time_limit' ) ) { |
| 28 |
set_time_limit( 1200 ); |
| 29 |
} |
| 30 |
|
| 31 |
$exception = null; |
| 32 |
$get_data = isset( $_GET ) ? wp_unslash( $_GET ) : array(); |
| 33 |
$post_data = isset( $_POST ) ? wp_unslash( $_POST ) : array(); |
| 34 |
$server_data = isset( $_SERVER ) ? wp_unslash( $_SERVER ) : array(); |
| 35 |
|
| 36 |
try { |
| 37 |
if ( ! session_id() ) { |
| 38 |
session_start(); |
| 39 |
} |
| 40 |
} catch ( \Exception $e ) { |
| 41 |
$exception = $e; |
| 42 |
} |
| 43 |
|
| 44 |
add_action( |
| 45 |
'init', |
| 46 |
function() { |
| 47 |
try { |
| 48 |
if ( ! session_id() ) { |
| 49 |
session_start(); |
| 50 |
} |
| 51 |
} catch ( \Exception $e ) { |
| 52 |
$exception = $e; |
| 53 |
} |
| 54 |
}, |
| 55 |
9 |
| 56 |
); |
| 57 |
|
| 58 |
if ( isset( $get_data['report'] ) ) { |
| 59 |
$nonce_passed = false; |
| 60 |
$nonce_keys = array( |
| 61 |
'nonce' => 'upstream-nonce', |
| 62 |
'upstream_report_form_nonce' => 'upstream_report_form', |
| 63 |
); |
| 64 |
|
| 65 |
// check multiple nonce possibility. |
| 66 |
foreach ( $nonce_keys as $key => $value ) { |
| 67 |
if ( ! isset( $post_data[ $key ] ) ) { |
| 68 |
continue; |
| 69 |
} |
| 70 |
|
| 71 |
if ( wp_verify_nonce( $post_data[ $key ], $value ) ) { |
| 72 |
$nonce_passed = true; |
| 73 |
} |
| 74 |
} |
| 75 |
|
| 76 |
// load report template. |
| 77 |
if ( isset( $post_data['submit'] ) && $nonce_passed ) { |
| 78 |
include 'report-display.php'; |
| 79 |
} else { |
| 80 |
include 'report-parameters.php'; |
| 81 |
} |
| 82 |
return; |
| 83 |
} elseif ( isset( $get_data['download'] ) ) { |
| 84 |
upstream_upfs_download( sanitize_text_field( $get_data['download'] ) ); |
| 85 |
return; |
| 86 |
} |
| 87 |
|
| 88 |
$plugin_options = get_option( 'upstream_projects' ); |
| 89 |
$option_name = 'project_number_per_page'; |
| 90 |
$total_per_page = isset( $plugin_options[ $option_name ] ) ? (int) $plugin_options[ $option_name ] : 1000; |
| 91 |
$up_page = isset( $get_data['page'] ) ? absint( $get_data['page'] ) : 1; |
| 92 |
$up_search = isset( $get_data['search'] ) ? sanitize_text_field( $get_data['search'] ) : ''; |
| 93 |
|
| 94 |
if ( $up_page <= 1 ) { |
| 95 |
$up_page = 1; |
| 96 |
} |
| 97 |
|
| 98 |
$display_start = ( $up_page - 1 ) * $total_per_page; |
| 99 |
$project_page_url = get_post_type_archive_link( 'project' ); |
| 100 |
$are_clients_enabled = ! upstream_is_clients_disabled(); |
| 101 |
$archive_closed_items = upstream_archive_closed_items(); |
| 102 |
|
| 103 |
$i18n = array( |
| 104 |
'LB_PROJECT' => upstream_project_label(), |
| 105 |
'LB_PROJECTS' => upstream_project_label_plural(), |
| 106 |
'LB_TASKS' => upstream_task_label_plural(), |
| 107 |
'LB_BUGS' => upstream_bug_label_plural(), |
| 108 |
'LB_LOGOUT' => __( 'Log Out', 'upstream' ), |
| 109 |
'LB_ENDS_AT' => __( 'Ends at', 'upstream' ), |
| 110 |
'MSG_SUPPORT' => upstream_admin_support_label( $plugin_options ), |
| 111 |
'LB_TITLE' => __( 'Title', 'upstream' ), |
| 112 |
'LB_TOGGLE_FILTERS' => __( 'Toggle Filters', 'upstream' ), |
| 113 |
'LB_EXPORT' => __( 'Export', 'upstream' ), |
| 114 |
'LB_PLAIN_TEXT' => __( 'Plain Text', 'upstream' ), |
| 115 |
'LB_CSV' => __( 'CSV', 'upstream' ), |
| 116 |
'LB_CLIENT' => upstream_client_label(), |
| 117 |
'LB_CLIENTS' => upstream_client_label_plural(), |
| 118 |
'LB_STATUS' => __( 'Status', 'upstream' ), |
| 119 |
'LB_STATUSES' => __( 'Statuses', 'upstream' ), |
| 120 |
'LB_CATEGORIES' => __( 'Categories' ), |
| 121 |
'LB_PROGRESS' => __( 'Progress', 'upstream' ), |
| 122 |
'LB_NONE_UCF' => __( 'None', 'upstream' ), |
| 123 |
'LB_NONE' => __( 'none', 'upstream' ), |
| 124 |
// translators: %s: Completed item label. |
| 125 |
'LB_COMPLETE' => __( '%s Complete', 'upstream' ), |
| 126 |
); |
| 127 |
|
| 128 |
$up_current_user = (object) upstream_user_data( @$_SESSION['upstream']['user_id'] ); |
| 129 |
$project_statuses = upstream_get_all_project_statuses(); |
| 130 |
$project_order = array(); |
| 131 |
$statuses = array(); |
| 132 |
$open_statuses = array(); |
| 133 |
|
| 134 |
/* We start from 1 instead of 0 because the 0 position is used for "__none__". */ |
| 135 |
$status_index = 1; |
| 136 |
|
| 137 |
foreach ( $project_statuses as $status_id => $up_status ) { |
| 138 |
$project_order[ $status_index++ ] = $status_id; |
| 139 |
|
| 140 |
/* If closed items will be archived, we do not need to display closed statuses. */ |
| 141 |
if ( $archive_closed_items && 'open' !== $up_status['type'] ) { |
| 142 |
continue; |
| 143 |
} |
| 144 |
|
| 145 |
$statuses[ $up_status['id'] ] = $up_status; |
| 146 |
|
| 147 |
if ( 'open' === $up_status['type'] ) { |
| 148 |
$open_statuses[] = $up_status['id']; |
| 149 |
} |
| 150 |
} |
| 151 |
|
| 152 |
$projects_list = array(); |
| 153 |
$count_pos = 0; |
| 154 |
$total_projects = 0; |
| 155 |
|
| 156 |
if ( isset( $up_current_user->projects ) ) { |
| 157 |
if ( is_array( $up_current_user->projects ) && count( $up_current_user->projects ) > 0 ) { |
| 158 |
|
| 159 |
$projects_list = $up_current_user->projects; |
| 160 |
uasort( |
| 161 |
$projects_list, |
| 162 |
function( $a, $b ) { |
| 163 |
if ( ! isset( $a->post_title ) || ! isset( $b->post_title ) ) { |
| 164 |
return 0; |
| 165 |
} |
| 166 |
return strcasecmp( $a->post_title, $b->post_title ); |
| 167 |
} |
| 168 |
); |
| 169 |
|
| 170 |
foreach ( $projects_list as $project_id => $project ) { |
| 171 |
|
| 172 |
$project = new UpStream_Project( $project_id ); |
| 173 |
$start = $project->get_meta( 'start' ); |
| 174 |
if ( ! $start ) { |
| 175 |
$start = 0; |
| 176 |
} |
| 177 |
$end = $project->get_meta( 'end' ); |
| 178 |
if ( ! $end ) { |
| 179 |
$end = 0; |
| 180 |
} |
| 181 |
|
| 182 |
$prog = $project->get_meta( 'progress' ); |
| 183 |
if ( ! $prog ) { |
| 184 |
$prog = 0; |
| 185 |
} |
| 186 |
$stat = $project->get_meta( 'status' ); |
| 187 |
|
| 188 |
$data = (object) array( |
| 189 |
'id' => $project_id, |
| 190 |
'author' => (int) $project->post_author, |
| 191 |
'created_at' => (string) $project->post_date_gmt, |
| 192 |
'modified_at' => (string) $project->post_modified_gmt, |
| 193 |
'title' => $project->post_title, |
| 194 |
'slug' => $project->post_name, |
| 195 |
'status' => $project->post_status, |
| 196 |
'permalink' => get_permalink( $project_id ), |
| 197 |
'startDateTimestamp' => (int) $start, |
| 198 |
'endDateTimestamp' => (int) $end, |
| 199 |
'progress' => (float) round( $prog ), |
| 200 |
'status' => (string) $stat, |
| 201 |
'clientName' => null, |
| 202 |
'categories' => array(), |
| 203 |
'features' => array( |
| 204 |
'', |
| 205 |
), |
| 206 |
); |
| 207 |
|
| 208 |
/* If should archive closed items, we filter the rowset. */ |
| 209 |
if ( $archive_closed_items ) { |
| 210 |
if ( ! empty( $data->status ) && ! in_array( $data->status, $open_statuses ) ) { |
| 211 |
continue; |
| 212 |
} |
| 213 |
} |
| 214 |
|
| 215 |
if ( ! empty( $up_search ) && ! stristr( $project->post_title, $up_search ) ) { |
| 216 |
continue; |
| 217 |
} |
| 218 |
|
| 219 |
$total_projects++; |
| 220 |
$count_pos++; |
| 221 |
|
| 222 |
if ( $count_pos - 1 < $display_start ) { |
| 223 |
continue; |
| 224 |
} |
| 225 |
if ( $count_pos - 1 >= $display_start + $total_per_page ) { |
| 226 |
continue; |
| 227 |
} |
| 228 |
|
| 229 |
$data->start_date = (string) upstream_format_date( $data->startDateTimestamp ); // phpcs:ignore |
| 230 |
$data->end_date = (string) upstream_format_date( $data->endDateTimestamp ); // phpcs:ignore |
| 231 |
$ymd = $project->get_meta( 'start.YMD' ); |
| 232 |
|
| 233 |
if ( $ymd ) { |
| 234 |
if ( is_array( $ymd ) ) { |
| 235 |
$ymd = $ymd[0]; |
| 236 |
} |
| 237 |
$data->startDateTimestamp = \UpStream_Model_Object::ymdToTimestamp( $ymd ); // phpcs:ignore |
| 238 |
$data->start_date = date_i18n( get_option( 'date_format' ), $data->startDateTimestamp ); // phpcs:ignore |
| 239 |
} |
| 240 |
|
| 241 |
$ymd = $project->get_meta( 'end.YMD' ); |
| 242 |
|
| 243 |
if ( $ymd ) { |
| 244 |
if ( is_array( $ymd ) ) { |
| 245 |
$ymd = $ymd[0]; |
| 246 |
} |
| 247 |
$data->endDateTimestamp = \UpStream_Model_Object::ymdToTimestamp( $ymd ); // phpcs:ignore |
| 248 |
$data->end_date = date_i18n( get_option( 'date_format' ), $data->endDateTimestamp ); // phpcs:ignore |
| 249 |
} |
| 250 |
|
| 251 |
if ( $are_clients_enabled ) { |
| 252 |
$data->clientName = trim( (string) upstream_project_client_name( $project_id ) ); // phpcs:ignore |
| 253 |
} |
| 254 |
|
| 255 |
if ( isset( $statuses[ $data->status ] ) ) { |
| 256 |
$data->status = $statuses[ $data->status ]; |
| 257 |
} |
| 258 |
|
| 259 |
$data->timeframe = $data->start_date; |
| 260 |
if ( ! empty( $data->end_date ) ) { |
| 261 |
if ( ! empty( $data->timeframe ) ) { |
| 262 |
$data->timeframe .= ' - '; |
| 263 |
} else { |
| 264 |
$data->timeframe = '<i>' . $i18n['LB_ENDS_AT'] . '</i>'; |
| 265 |
} |
| 266 |
|
| 267 |
$data->timeframe .= $data->end_date; |
| 268 |
} |
| 269 |
|
| 270 |
$categories = (array) wp_get_object_terms( $data->id, 'project_category' ); |
| 271 |
if ( count( $categories ) > 0 ) { |
| 272 |
foreach ( $categories as $category ) { |
| 273 |
if ( is_object( $category ) ) { |
| 274 |
$data->categories[ $category->term_id ] = $category->name; |
| 275 |
} |
| 276 |
} |
| 277 |
} |
| 278 |
|
| 279 |
$projects_list[ $project_id ] = $data; |
| 280 |
} |
| 281 |
|
| 282 |
unset( $project, $project_id ); |
| 283 |
} |
| 284 |
|
| 285 |
unset( $up_current_user->projects ); |
| 286 |
} |
| 287 |
|
| 288 |
$projects_list_count = count( $projects_list ); |
| 289 |
|
| 290 |
if ( ! apply_filters( 'upstream_theme_override_header', false ) ) { |
| 291 |
upstream_get_template_part( 'global/header.php' ); |
| 292 |
} |
| 293 |
|
| 294 |
if ( ! apply_filters( 'upstream_theme_override_sidebar', false ) ) { |
| 295 |
upstream_get_template_part( 'global/sidebar.php' ); |
| 296 |
} |
| 297 |
|
| 298 |
if ( ! apply_filters( 'upstream_theme_override_topnav', false ) ) { |
| 299 |
upstream_get_template_part( 'global/top-nav.php' ); |
| 300 |
} |
| 301 |
|
| 302 |
$categories = (array) get_terms( |
| 303 |
array( |
| 304 |
'taxonomy' => 'project_category', |
| 305 |
'hide_empty' => false, |
| 306 |
) |
| 307 |
); |
| 308 |
|
| 309 |
$projects_view = ! isset( $_GET['view'] ); |
| 310 |
|
| 311 |
|
| 312 |
/* Filters */ |
| 313 |
$table_settings = array( |
| 314 |
'id' => 'projects', |
| 315 |
'type' => 'project', |
| 316 |
'data-ordered-by' => 'start_date', |
| 317 |
'data-order-dir' => 'DESC', |
| 318 |
); |
| 319 |
|
| 320 |
$columns_schema = \UpStream\Frontend\upstream_get_project_fields(); |
| 321 |
$hidden_columns_schema = array(); |
| 322 |
|
| 323 |
foreach ( $columns_schema as $column_name => $column_args ) { |
| 324 |
if ( isset( $column_args['isHidden'] ) && true === (bool) $column_args['isHidden'] ) { |
| 325 |
$hidden_columns_schema[ $column_name ] = $column_args; |
| 326 |
} |
| 327 |
} |
| 328 |
|
| 329 |
$filter_closed_items = upstream_filter_closed_items(); |
| 330 |
$ordering = \UpStream\Frontend\upstream_get_table_order( 'projects' ); |
| 331 |
$order_by = ''; |
| 332 |
$order_dir = ''; |
| 333 |
|
| 334 |
if ( ! empty( $ordering ) ) { |
| 335 |
$order_by = $ordering['column']; |
| 336 |
$order_dir = $ordering['orderDir']; |
| 337 |
} |
| 338 |
?> |
| 339 |
|
| 340 |
<div class="right_col" role="main"> |
| 341 |
<div class="alerts"> |
| 342 |
<?php do_action( 'upstream_frontend_projects_messages' ); ?> |
| 343 |
<?php do_action( 'upstream_single_project_before_overview' ); ?> |
| 344 |
</div> |
| 345 |
|
| 346 |
<?php do_action( 'upstream_archive_project_top' ); ?> |
| 347 |
|
| 348 |
<div class=""> |
| 349 |
<?php if ( $projects_view ) : ?> |
| 350 |
<?php if ( false ) : ?> |
| 351 |
<div class="row"> |
| 352 |
<div class="col-md-12"> |
| 353 |
<div class="x_panel" data-section="projects"> |
| 354 |
<div class="x_title"> |
| 355 |
<h2><i class="fa fa-bar-chart"></i> <?php echo esc_html( __( 'Status' ) ); ?></h2> |
| 356 |
<ul class="nav navbar-right panel_toolbox"> |
| 357 |
<li> |
| 358 |
<a class="collapse-link"> |
| 359 |
<i class="fa fa-chevron-up"></i> |
| 360 |
</a> |
| 361 |
</li> |
| 362 |
</ul> |
| 363 |
<div class="clearfix"></div> |
| 364 |
</div> |
| 365 |
<div class="x_content"> |
| 366 |
|
| 367 |
</div> |
| 368 |
</div> |
| 369 |
</div> |
| 370 |
</div> |
| 371 |
<?php endif; ?> |
| 372 |
|
| 373 |
<div class="row"> |
| 374 |
<div class="col-md-12"> |
| 375 |
<div class="x_panel" data-section="projects"> |
| 376 |
<div class="x_title"> |
| 377 |
<h2><i class="fa fa-briefcase"></i> <?php echo esc_html( $i18n['LB_PROJECTS'] ); ?></h2> |
| 378 |
<ul class="nav navbar-right panel_toolbox"> |
| 379 |
<li> |
| 380 |
<a class="collapse-link"> |
| 381 |
<i class="fa fa-chevron-up"></i> |
| 382 |
</a> |
| 383 |
</li> |
| 384 |
<?php do_action( 'upstream_project_project_top_right' ); ?> |
| 385 |
</ul> |
| 386 |
<div class="clearfix"></div> |
| 387 |
</div> |
| 388 |
<div class="x_content"> |
| 389 |
<?php if ( $projects_list_count > 0 || ! empty( $up_search ) ) : ?> |
| 390 |
<div class="c-data-table table-responsive"> |
| 391 |
<form class="form-inline c-data-table__filters" data-target="#projects" method="get" action="<?php print esc_attr( $project_page_url ); ?>"> |
| 392 |
<div class="d-none d-sm-flex justify-content-between"> |
| 393 |
<div class="form-group"> |
| 394 |
<div class="input-group"> |
| 395 |
<div class="input-group-text"> |
| 396 |
<i class="fa fa-search"></i> |
| 397 |
</div> |
| 398 |
|
| 399 |
<input type="search" class="form-control" |
| 400 |
placeholder="<?php echo esc_attr( $i18n['LB_TITLE'] ); ?>" |
| 401 |
<?php if ( $total_projects > $total_per_page || ! empty( $up_search ) ) { ?> |
| 402 |
data-searchurl="<?php print esc_url( add_query_arg( 'search', '_SEARCH_STR_', $project_page_url ) ); ?>" |
| 403 |
<?php } ?> |
| 404 |
<?php if ( ! empty( $up_search ) ) { ?> |
| 405 |
value="<?php print esc_attr( $up_search ); ?>" |
| 406 |
<?php } ?> |
| 407 |
data-column="title" data-compare-operator="contains"> |
| 408 |
|
| 409 |
</div> |
| 410 |
</div> |
| 411 |
<div class="form-group"> |
| 412 |
<div class="btn-group"> |
| 413 |
<a href="#projects-filters" role="button" |
| 414 |
class="btn border btn-light btn-sm" |
| 415 |
data-bs-toggle="collapse" aria-expanded="false" |
| 416 |
aria-controls="projects-filters"> |
| 417 |
<i class="fa fa-filter"></i> <?php echo esc_html( $i18n['LB_TOGGLE_FILTERS'] ); ?> |
| 418 |
</a> |
| 419 |
</div> |
| 420 |
<div class="btn-group"> |
| 421 |
<button type="button" |
| 422 |
class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 423 |
data-bs-toggle="dropdown" aria-haspopup="true" |
| 424 |
aria-expanded="false"> |
| 425 |
<i class="fa fa-download"></i> <?php echo esc_html( $i18n['LB_EXPORT'] ); ?> |
| 426 |
<span class="caret"></span> |
| 427 |
</button> |
| 428 |
<ul class="dropdown-menu dropdown-menu-right"> |
| 429 |
<li> |
| 430 |
<a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 431 |
<i class="fa fa-file-text-o"></i> <?php echo esc_html( $i18n['LB_PLAIN_TEXT'] ); ?> |
| 432 |
</a> |
| 433 |
</li> |
| 434 |
<li> |
| 435 |
<a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 436 |
<i class="fa fa-file-code-o"></i> <?php echo esc_html( $i18n['LB_CSV'] ); ?> |
| 437 |
</a> |
| 438 |
</li> |
| 439 |
</ul> |
| 440 |
</div> |
| 441 |
</div> |
| 442 |
</div> |
| 443 |
<div class="d-flex justify-content-between d-sm-none"> |
| 444 |
<div class="btn-group"> |
| 445 |
<a href="#projects-filters" role="button" |
| 446 |
class="btn border btn-light btn-sm" |
| 447 |
data-bs-toggle="collapse" aria-expanded="false" |
| 448 |
aria-controls="projects-filters"> |
| 449 |
<i class="fa fa-filter"></i> <?php echo esc_html( $i18n['LB_TOGGLE_FILTERS'] ); ?> |
| 450 |
</a> |
| 451 |
</div> |
| 452 |
<div class="btn-group"> |
| 453 |
<button type="button" |
| 454 |
class="btn btn-light border btn-sm dropdown-toggle upstream-export-button" |
| 455 |
data-bs-toggle="dropdown" aria-haspopup="true" |
| 456 |
aria-expanded="false"> |
| 457 |
<i class="fa fa-download"></i> <?php echo esc_html( $i18n['LB_EXPORT'] ); ?> |
| 458 |
<span class="caret"></span> |
| 459 |
</button> |
| 460 |
<ul class="dropdown-menu dropdown-menu-right"> |
| 461 |
<li> |
| 462 |
<a class="dropdown-item" href="#" data-action="export" data-type="txt"> |
| 463 |
<i class="fa fa-file-text-o"></i> <?php echo esc_html( $i18n['LB_PLAIN_TEXT'] ); ?> |
| 464 |
</a> |
| 465 |
</li> |
| 466 |
<li> |
| 467 |
<a class="dropdown-item" href="#" data-action="export" data-type="csv"> |
| 468 |
<i class="fa fa-file-code-o"></i> <?php echo esc_html( $i18n['LB_CSV'] ); ?> |
| 469 |
</a> |
| 470 |
</li> |
| 471 |
</ul> |
| 472 |
</div> |
| 473 |
</div> |
| 474 |
<div id="projects-filters" class="collapse"> |
| 475 |
<div class="form-group d-block d-sm-none"> |
| 476 |
<div class="input-group"> |
| 477 |
<div class="input-group-text"> |
| 478 |
<i class="fa fa-search"></i> |
| 479 |
</div> |
| 480 |
<input type="search" class="form-control" |
| 481 |
placeholder="<?php echo esc_attr( $i18n['LB_TITLE'] ); ?>" |
| 482 |
data-column="title" data-compare-operator="contains"> |
| 483 |
</div> |
| 484 |
</div> |
| 485 |
<?php if ( ! upstream_is_clients_disabled() ) : ?> |
| 486 |
<div class="form-group d-sm-inline-block"> |
| 487 |
<div class="input-group"> |
| 488 |
<div class="input-group-text"> |
| 489 |
<i class="fa fa-user"></i> |
| 490 |
</div> |
| 491 |
<input type="search" class="form-control" |
| 492 |
placeholder="<?php echo esc_attr( $i18n['LB_CLIENTS'] ); ?>" |
| 493 |
data-column="client" data-compare-operator="contains"> |
| 494 |
</div> |
| 495 |
</div> |
| 496 |
<?php endif; ?> |
| 497 |
<div class="form-group d-sm-inline-block"> |
| 498 |
<div class="input-group flex-nowrap"> |
| 499 |
<div class="input-group-text"> |
| 500 |
<i class="fa fa-bookmark"></i> |
| 501 |
</div> |
| 502 |
<select class="form-control o-select2" data-column="status" |
| 503 |
data-placeholder="<?php echo esc_attr( $i18n['LB_STATUS'] ); ?>" |
| 504 |
multiple> |
| 505 |
<option value></option> |
| 506 |
<option |
| 507 |
value="__none__" <?php echo $filter_closed_items ? 'selected' : ''; ?>><?php echo esc_html( $i18n['LB_NONE_UCF'] ); ?></option> |
| 508 |
<optgroup label="<?php echo esc_html( $i18n['LB_STATUSES'] ); ?>"> |
| 509 |
<?php foreach ( $statuses as $up_status ) : ?> |
| 510 |
<?php |
| 511 |
$attr = ' '; |
| 512 |
if ( $filter_closed_items && 'open' === $up_status['type'] ) : |
| 513 |
$attr .= ' selected'; |
| 514 |
endif; |
| 515 |
?> |
| 516 |
<option |
| 517 |
value="<?php echo esc_attr( $up_status['id'] ); ?>"<?php echo esc_attr( $attr ); ?>><?php echo esc_html( $up_status['name'] ); ?></option> |
| 518 |
<?php endforeach; ?> |
| 519 |
</optgroup> |
| 520 |
</select> |
| 521 |
</div> |
| 522 |
</div> |
| 523 |
<div class="form-group d-sm-inline-block"> |
| 524 |
<div class="input-group flex-nowrap"> |
| 525 |
<div class="input-group-text"> |
| 526 |
<i class="fa fa-tags"></i> |
| 527 |
</div> |
| 528 |
<select class="form-control o-select2" data-column="categories" |
| 529 |
data-placeholder="<?php echo esc_attr( $i18n['LB_CATEGORIES'] ); ?>" |
| 530 |
multiple data-compare-operator="contains"> |
| 531 |
<option value></option> |
| 532 |
<option |
| 533 |
value="__none__"><?php echo esc_html( $i18n['LB_NONE_UCF'] ); ?></option> |
| 534 |
<optgroup |
| 535 |
label="<?php echo esc_html( $i18n['LB_CATEGORIES'] ); ?>"> |
| 536 |
<?php foreach ( $categories as $category ) : ?> |
| 537 |
<option |
| 538 |
value="<?php echo esc_attr( $category->term_id ); ?>"><?php echo esc_html( $category->name ); ?></option> |
| 539 |
<?php endforeach; ?> |
| 540 |
</optgroup> |
| 541 |
</select> |
| 542 |
</div> |
| 543 |
</div> |
| 544 |
|
| 545 |
<?php |
| 546 |
do_action( |
| 547 |
'upstream:project.filters', |
| 548 |
$table_settings, |
| 549 |
$columns_schema |
| 550 |
); |
| 551 |
?> |
| 552 |
</div> |
| 553 |
</form> |
| 554 |
<table id="projects" |
| 555 |
class="o-data-table table table-bordered table-responsive table-hover is-orderable" |
| 556 |
cellspacing="0" |
| 557 |
width="100%" |
| 558 |
data-type="project" |
| 559 |
data-ordered-by="<?php echo esc_attr( $order_by ); ?>" |
| 560 |
data-order-dir="<?php echo esc_attr( $order_dir ); ?>"> |
| 561 |
<thead> |
| 562 |
<tr> |
| 563 |
<th class="is-clickable is-orderable" data-column="title" role="button"> |
| 564 |
<?php echo esc_html( $i18n['LB_PROJECT'] ); ?> |
| 565 |
<span class="pull-right o-order-direction"> |
| 566 |
<i class="fa fa-sort"></i> |
| 567 |
</span> |
| 568 |
</th> |
| 569 |
<th class="is-clickable is-orderable" data-column="startDate" role="button"> |
| 570 |
<?php echo esc_html__( 'Start Date', 'upstream' ); ?> |
| 571 |
<span class="pull-right o-order-direction"> |
| 572 |
<i class="fa fa-sort"></i> |
| 573 |
</span> |
| 574 |
</th> |
| 575 |
<th class="is-clickable is-orderable" data-column="endDate" role="button"> |
| 576 |
<?php echo esc_html__( 'End Date', 'upstream' ); ?> |
| 577 |
<span class="pull-right o-order-direction"> |
| 578 |
<i class="fa fa-sort"></i> |
| 579 |
</span> |
| 580 |
</th> |
| 581 |
<?php if ( $are_clients_enabled ) : ?> |
| 582 |
<th class="is-clickable is-orderable" data-column="client" |
| 583 |
role="button"> |
| 584 |
<?php echo esc_html( $i18n['LB_CLIENT'] ); ?> |
| 585 |
<span class="pull-right o-order-direction"> |
| 586 |
<i class="fa fa-sort"></i> |
| 587 |
</span> |
| 588 |
</th> |
| 589 |
<th data-column="client-users"> |
| 590 |
<?php |
| 591 |
printf( |
| 592 |
// translators: %s: Client label. |
| 593 |
esc_html__( '%s Users', 'upstream' ), |
| 594 |
esc_html( $i18n['LB_CLIENT'] ) |
| 595 |
); |
| 596 |
?> |
| 597 |
</th> |
| 598 |
<?php endif; ?> |
| 599 |
<th data-column="owner"> |
| 600 |
<?php |
| 601 |
printf( |
| 602 |
// translators: %s: Project label. |
| 603 |
esc_html__( '%s Owner', 'upstream' ), |
| 604 |
esc_html( $i18n['LB_PROJECT'] ) |
| 605 |
); |
| 606 |
?> |
| 607 |
</th> |
| 608 |
<th data-column="members"> |
| 609 |
<?php |
| 610 |
printf( |
| 611 |
// translators: %s: Project label. |
| 612 |
esc_html__( '%s Members', 'upstream' ), |
| 613 |
esc_html( $i18n['LB_PROJECT'] ) |
| 614 |
); |
| 615 |
?> |
| 616 |
</th> |
| 617 |
<th class="is-clickable is-orderable" data-column="progress" role="button"> |
| 618 |
<?php echo esc_html( $i18n['LB_PROGRESS'] ); ?> |
| 619 |
<span class="pull-right o-order-direction"> |
| 620 |
<i class="fa fa-sort"></i> |
| 621 |
</span> |
| 622 |
</th> |
| 623 |
<th class="is-clickable is-orderable" data-column="status" role="button"> |
| 624 |
<?php echo esc_html( $i18n['LB_STATUS'] ); ?> |
| 625 |
<span class="pull-right o-order-direction"> |
| 626 |
<i class="fa fa-sort"></i> |
| 627 |
</span> |
| 628 |
</th> |
| 629 |
<th style="max-width: 250px;" data-column="categories"> |
| 630 |
<?php echo esc_html( $i18n['LB_CATEGORIES'] ); ?> |
| 631 |
</th> |
| 632 |
|
| 633 |
<?php |
| 634 |
do_action( |
| 635 |
'upstream:project.columns.header', |
| 636 |
$table_settings, |
| 637 |
$columns_schema |
| 638 |
); |
| 639 |
?> |
| 640 |
</tr> |
| 641 |
</thead> |
| 642 |
<tbody> |
| 643 |
<?php |
| 644 |
$is_project_index_odd = true; |
| 645 |
foreach ( $projects_list as $project_index => $project ) : |
| 646 |
?> |
| 647 |
<?php |
| 648 |
$project = apply_filters( |
| 649 |
'upstream_frontend_project_data', |
| 650 |
$project, |
| 651 |
$project->id |
| 652 |
); |
| 653 |
?> |
| 654 |
<tr class="t-row-<?php echo $is_project_index_odd ? 'odd' : 'even'; ?>" |
| 655 |
data-id="<?php echo esc_attr( $project->id ); ?>"> |
| 656 |
|
| 657 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'title', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 658 |
<td data-column="title" |
| 659 |
data-value="<?php echo esc_attr( $project->title ); ?>"> |
| 660 |
<?php |
| 661 |
do_action( |
| 662 |
'upstream:frontend.project.details.before_title', |
| 663 |
$project |
| 664 |
); |
| 665 |
?> |
| 666 |
<a href="<?php echo esc_url( $project->permalink ); ?>"> |
| 667 |
<?php echo esc_html( $project->title ); ?> |
| 668 |
</a> |
| 669 |
</td> |
| 670 |
<?php else : ?> |
| 671 |
<td data-column="title" |
| 672 |
data-value=""> |
| 673 |
<span class="badge up-o-label" |
| 674 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 675 |
</td> |
| 676 |
<?php endif; ?> |
| 677 |
|
| 678 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'start', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 679 |
<td data-column="startDate" |
| 680 |
data-value="<?php echo esc_attr( $project->startDateTimestamp ); // phpcs:ignore ?>"> |
| 681 |
<?php echo esc_html( $project->start_date ); ?> |
| 682 |
</td> |
| 683 |
<?php else : ?> |
| 684 |
<td data-column="startDate" |
| 685 |
data-value=""> |
| 686 |
<span class="badge up-o-label" |
| 687 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 688 |
</td> |
| 689 |
<?php endif; ?> |
| 690 |
|
| 691 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'end', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 692 |
<td data-column="endDate" |
| 693 |
data-value="<?php echo esc_attr( $project->endDateTimestamp ); // phpcs:ignore ?>"> |
| 694 |
<?php echo esc_html( $project->end_date ); ?> |
| 695 |
</td> |
| 696 |
<?php else : ?> |
| 697 |
<td data-column="endDate" |
| 698 |
data-value=""> |
| 699 |
<span class="badge up-o-label" |
| 700 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 701 |
</td> |
| 702 |
<?php endif; ?> |
| 703 |
|
| 704 |
|
| 705 |
<?php if ( $are_clients_enabled ) : ?> |
| 706 |
|
| 707 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'client', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 708 |
<td data-column="client" |
| 709 |
data-value="<?php echo null !== $project->clientName ? esc_attr( $project->clientName ) : '__none__'; // phpcs:ignore ?>"> |
| 710 |
<?php if ( null !== $project->clientName ) : // phpcs:ignore ?> |
| 711 |
<?php echo esc_html( $project->clientName ); // phpcs:ignore ?> |
| 712 |
<?php else : ?> |
| 713 |
<i class="s-text-color-gray"><?php echo esc_html( $i18n['LB_NONE'] ); ?></i> |
| 714 |
<?php endif; ?> |
| 715 |
</td> |
| 716 |
<?php else : ?> |
| 717 |
<td data-column="client" |
| 718 |
data-value=""> |
| 719 |
<span class="badge up-o-label" |
| 720 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 721 |
</td> |
| 722 |
<?php endif; ?> |
| 723 |
|
| 724 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'client_users', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 725 |
<td data-column="client-users"> |
| 726 |
<?php upstream_output_client_users( $project->id ); ?> |
| 727 |
</td> |
| 728 |
<?php else : ?> |
| 729 |
<td data-column="client-users" |
| 730 |
data-value=""> |
| 731 |
<span class="badge up-o-label" |
| 732 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 733 |
</td> |
| 734 |
<?php endif; ?> |
| 735 |
|
| 736 |
<?php endif; ?> |
| 737 |
|
| 738 |
<?php $powner = upstream_get_project_owner( $project->id ); ?> |
| 739 |
<td data-column="owner" data-value="<?php echo $powner && is_array( $powner ) ? esc_attr( implode( ',', $powner[0] ) ) : ''; ?>"> |
| 740 |
<?php print wp_kses_post( $powner[1] ); ?> |
| 741 |
</td> |
| 742 |
<td data-column="members"> |
| 743 |
<?php upstream_output_project_members( $project->id ); ?> |
| 744 |
</td> |
| 745 |
|
| 746 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'progress', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 747 |
<td data-column="progress" |
| 748 |
data-value="<?php echo esc_attr( $project->progress ); ?>"> |
| 749 |
<div class="progress" style="margin-bottom: 0; height: 10px;"> |
| 750 |
<div |
| 751 |
class="progress-bar<?php echo $project->progress >= 100 ? ' progress-bar-success' : ''; ?>" |
| 752 |
role="progressbar" |
| 753 |
aria-valuenow="<?php echo esc_attr( $project->progress ); ?>" |
| 754 |
aria-valuemin="0" aria-valuemax="100" |
| 755 |
style="width: <?php echo esc_attr( $project->progress ); ?>%;"> |
| 756 |
<span class="sr-only"> |
| 757 |
<?php |
| 758 |
echo esc_html( |
| 759 |
sprintf( |
| 760 |
$i18n['LB_COMPLETE'], |
| 761 |
$project->progress . '%' |
| 762 |
) |
| 763 |
); |
| 764 |
?> |
| 765 |
</span> |
| 766 |
</div> |
| 767 |
</div> |
| 768 |
<small> |
| 769 |
<?php |
| 770 |
echo esc_html( |
| 771 |
sprintf( |
| 772 |
$i18n['LB_COMPLETE'], |
| 773 |
$project->progress . '%' |
| 774 |
) |
| 775 |
); |
| 776 |
?> |
| 777 |
</small> |
| 778 |
</td> |
| 779 |
<?php else : ?> |
| 780 |
<td data-column="progress" |
| 781 |
data-value=""> |
| 782 |
<span class="badge up-o-label" |
| 783 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 784 |
</td> |
| 785 |
<?php endif; ?> |
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
<?php |
| 790 |
if ( null !== $project->status && is_array( $project->status ) ) { |
| 791 |
$up_status = $project->status; |
| 792 |
} else { |
| 793 |
$up_status = array( |
| 794 |
'id' => '', |
| 795 |
'name' => '', |
| 796 |
'color' => '#aaa', |
| 797 |
'order' => '0', |
| 798 |
); |
| 799 |
} |
| 800 |
|
| 801 |
$status_order = array_search( $up_status['id'], $project_order ); |
| 802 |
?> |
| 803 |
|
| 804 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'status', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 805 |
|
| 806 |
<td data-column="status" |
| 807 |
data-value="<?php echo ! empty( $up_status['id'] ) ? esc_attr( $up_status['id'] ) : '__none__'; ?>" |
| 808 |
data-order="<?php echo $status_order > 0 ? esc_attr( $status_order ) : '0'; ?>"> |
| 809 |
<?php if ( null !== $project->status || empty( $up_status['id'] ) || empty( $up_status['name'] ) ) : ?> |
| 810 |
<span class="badge up-o-label" |
| 811 |
style="background-color: <?php echo esc_attr( $up_status['color'] ); ?>;"><?php echo ! empty( $up_status['name'] ) ? esc_html( $up_status['name'] ) : esc_html( $i18n['LB_NONE'] ); ?></span> |
| 812 |
<?php else : ?> |
| 813 |
<i class="s-text-color-gray"><?php echo esc_html( $i18n['LB_NONE'] ); ?></i> |
| 814 |
<?php endif; ?> |
| 815 |
</td> |
| 816 |
<?php else : ?> |
| 817 |
<td data-column="status" |
| 818 |
data-value=""> |
| 819 |
<span class="badge up-o-label" |
| 820 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 821 |
</td> |
| 822 |
<?php endif; ?> |
| 823 |
|
| 824 |
<?php if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, null, 0, 'categories', UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) : ?> |
| 825 |
<td data-column="categories" |
| 826 |
data-value=" |
| 827 |
<?php |
| 828 |
echo count( $project->categories ) ? esc_attr( |
| 829 |
implode( |
| 830 |
',', |
| 831 |
array_keys( (array) $project->categories ) |
| 832 |
) |
| 833 |
) : '__none__'; |
| 834 |
?> |
| 835 |
"> |
| 836 |
<?php if ( count( $project->categories ) > 0 ) : ?> |
| 837 |
<?php |
| 838 |
echo esc_attr( |
| 839 |
implode( |
| 840 |
', ', |
| 841 |
array_values( (array) $project->categories ) |
| 842 |
) |
| 843 |
); |
| 844 |
?> |
| 845 |
<?php else : ?> |
| 846 |
<i class="s-text-color-gray"><?php echo esc_html( $i18n['LB_NONE'] ); ?></i> |
| 847 |
<?php endif; ?> |
| 848 |
</td> |
| 849 |
<?php else : ?> |
| 850 |
<td data-column="categories" |
| 851 |
data-value=""> |
| 852 |
<span class="badge up-o-label" |
| 853 |
style="background-color:#666;color:#fff">(hidden)</span> |
| 854 |
</td> |
| 855 |
<?php endif; ?> |
| 856 |
|
| 857 |
<?php |
| 858 |
do_action( |
| 859 |
'upstream:project.columns.data', |
| 860 |
$table_settings, |
| 861 |
$columns_schema, |
| 862 |
$project->id, |
| 863 |
$project |
| 864 |
); |
| 865 |
?> |
| 866 |
</tr> |
| 867 |
|
| 868 |
<?php if ( ! empty( $hidden_columns_schema ) ) : ?> |
| 869 |
<tr data-parent="<?php echo esc_attr( $project->id ); ?>" aria-expanded="false" |
| 870 |
style="display: none;"> |
| 871 |
<td> |
| 872 |
<div> |
| 873 |
<?php |
| 874 |
foreach ( $hidden_columns_schema as $column_name => $column ) : |
| 875 |
$column_value = isset( $project->{$column_name} ) ? $project->{$column_name} : null; |
| 876 |
if ( is_null( $column_value ) ) { |
| 877 |
continue; |
| 878 |
} |
| 879 |
|
| 880 |
if ( is_array( $column_value ) && isset( $column_value['value'] ) ) { |
| 881 |
$column_value = $column_value['value']; |
| 882 |
} |
| 883 |
?> |
| 884 |
<div class="form-group" |
| 885 |
data-column="<?php echo esc_attr( $column_name ); ?>"> |
| 886 |
<label><?php echo isset( $column['label'] ) ? esc_html( $column['label'] ) : ''; ?></label> |
| 887 |
<?php |
| 888 |
UpStream\Frontend\upstream_render_table_column_value( |
| 889 |
$column_name, |
| 890 |
$column_value, |
| 891 |
$column, |
| 892 |
(array) $project, |
| 893 |
'project', |
| 894 |
$project->id |
| 895 |
); |
| 896 |
?> |
| 897 |
</div> |
| 898 |
<?php endforeach; ?> |
| 899 |
</div> |
| 900 |
</td> |
| 901 |
</tr> |
| 902 |
<?php |
| 903 |
endif; |
| 904 |
|
| 905 |
$is_project_index_odd = ! $is_project_index_odd; |
| 906 |
endforeach; |
| 907 |
?> |
| 908 |
</tbody> |
| 909 |
</table> |
| 910 |
</div> |
| 911 |
|
| 912 |
<span class="p_count"> |
| 913 |
Showing <?php print esc_html( $display_start + 1 ); ?> to <?php print esc_html( min( $display_start + $total_per_page, $total_projects ) ); ?> of <?php print esc_html( $total_projects ); ?> |
| 914 |
</span> |
| 915 |
<?php if ( $total_projects > $total_per_page ) { ?> |
| 916 |
<span class="pagination"> |
| 917 |
<?php |
| 918 |
if ( $up_page > 1 ) { |
| 919 |
?> |
| 920 |
<a href="<?php print esc_url( add_query_arg( 'page', $up_page - 1, $project_page_url ) ); ?>">< Previous</a> <?php } ?> |
| 921 |
|
| 922 |
<select name="" onchange="if (this.value) window.location='<?php print esc_url( add_query_arg( 'page', '__PAGE_N_', $project_page_url ) ); ?>'.replace('__PAGE_N_',this.value);"> |
| 923 |
<option>(Jump to page...)</option> |
| 924 |
<?php for ( $j = 0; $j < ceil( $total_projects / $total_per_page ); $j++ ) : ?> |
| 925 |
<option value="<?php print esc_attr( $j + 1 ); ?>"><?php print esc_html( $j + 1 ); ?></option> |
| 926 |
<?php endfor; ?> |
| 927 |
</select> |
| 928 |
|
| 929 |
<?php |
| 930 |
if ( $display_start + $total_per_page < $total_projects ) { |
| 931 |
?> |
| 932 |
<a href="<?php print esc_url( add_query_arg( 'page', $up_page + 1, $project_page_url ) ); ?>">Next ></a> <?php } ?> |
| 933 |
</span> |
| 934 |
|
| 935 |
<?php } ?> |
| 936 |
<?php else : ?> |
| 937 |
<p> |
| 938 |
<?php |
| 939 |
esc_html_e( |
| 940 |
"It seems that you're not participating in any project right now.", |
| 941 |
'upstream' |
| 942 |
); |
| 943 |
?> |
| 944 |
</p> |
| 945 |
<?php endif; ?> |
| 946 |
</div> |
| 947 |
</div> |
| 948 |
</div> |
| 949 |
</div> |
| 950 |
<?php endif; ?> |
| 951 |
|
| 952 |
<?php do_action( 'upstream:frontend.renderAfterProjectsList' ); // phpcs:ignore ?> |
| 953 |
</div> |
| 954 |
</div> |
| 955 |
|
| 956 |
<?php |
| 957 |
do_action( 'upstream_after_project_list_content' ); |
| 958 |
|
| 959 |
if ( ! apply_filters( 'upstream_theme_override_footer', false ) ) { |
| 960 |
upstream_get_template_part( 'global/footer.php' ); |
| 961 |
} |
| 962 |
|