PluginProbe
UpStream: a Project Management Plugin for WordPress / trunk
UpStream: a Project Management Plugin for WordPress vtrunk
trunk 1.39.0 1.39.1 1.39.2 1.39.3 2.0.7 2.1.0
upstream / templates / single-project / overview.php

overview.php in UpStream: a Project Management Plugin for WordPress trunk, at templates/single-project/overview.php

297 lines 9.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Single project: overview
4 *
5 * @package UpStream
6 */
7
8 // Prevent direct access.
9 if ( ! defined( 'ABSPATH' ) ) {
10 exit;
11 }
12
13 $user_id = (int) get_current_user_id();
14 $project_id = (int) upstream_post_id();
15 $progress_value = upstream_project_progress();
16 $current_timestamp = time();
17 $counter = \UpStream\Factory::get_project_counter( $project_id );
18
19 global $upstream_allcounts;
20
21 $are_milestones_enabled = ! upstream_are_milestones_disabled() && ! upstream_disable_milestones();
22 if ( $are_milestones_enabled ) {
23 $milestones_counts = array(
24 'open' => 0,
25 'mine' => 0,
26 'overdue' => 0,
27 'finished' => 0,
28 'total' => 0,
29 );
30
31 $all = $counter->get_items_of_type( 'milestones' );
32
33 $milestones_counts['total'] = count( $all );
34
35 if ( $milestones_counts['total'] > 0 ) {
36 $milestones_counts['mine'] = $counter->get_total_assigned_to_current_user_of_type( 'milestones' );
37 $milestones_counts['open'] = $counter->get_total_open_items_of_type( 'milestones' );
38
39 foreach ( $all as $milestone ) {
40 $progress = isset( $milestone['progress'] ) ? (float) $milestone['progress'] : 0;
41
42 if ( $progress < 100 ) {
43 if ( isset( $milestone['end_date'] )
44 && (int) $milestone['end_date'] > 0
45 && (int) $milestone['end_date'] < $current_timestamp
46 ) {
47 $milestones_counts['overdue']++;
48 }
49 } else {
50 $milestones_counts['finished']++;
51 }
52 }
53 }
54
55 $upstream_allcounts['milestonesCounts'] = $milestones_counts;
56 }
57
58 $are_tasks_enabled = ! upstream_are_tasks_disabled() && ! upstream_disable_tasks();
59 if ( $are_tasks_enabled ) {
60 $tasks_counts = array(
61 'open' => 0,
62 'mine' => 0,
63 'overdue' => 0,
64 'closed' => 0,
65 'total' => 0,
66 );
67
68 $tasks_options = get_option( 'upstream_tasks' );
69 $tasks_map = array();
70 foreach ( $tasks_options['statuses'] as $task ) {
71 if ( isset( $task['type'] ) ) {
72 $tasks_map[ $task['id'] ] = $task['type'];
73 }
74 }
75 unset( $tasks_options );
76
77 $tasks = get_post_meta( $project_id, '_upstream_project_tasks' );
78 $tasks = ! empty( $tasks ) ? (array) $tasks[0] : array();
79
80 if ( isset( $tasks[0] ) && ! isset( $tasks[0]['id'] ) ) {
81 $tasks = (array) $tasks[0];
82 }
83
84 $tasks_counts['total'] = count( $tasks );
85 if ( $tasks_counts['total'] > 0 ) {
86 foreach ( $tasks as $task ) {
87 if ( isset( $task['assigned_to'] ) ) {
88 $assigned_to = $task['assigned_to'];
89
90 if ( is_array( $assigned_to ) && in_array( $user_id, $assigned_to ) ) {
91 $tasks_counts['mine']++;
92 }
93 }
94
95 $progress = isset( $task['progress'] ) ? (float) $task['progress'] : 0;
96 if ( $progress < 100 ) {
97 if ( isset( $task['status'] )
98 && isset( $tasks_map[ $task['status'] ] )
99 && 'closed' === $tasks_map[ $task['status'] ]
100 ) {
101 $tasks_counts['closed']++;
102 } else {
103 $tasks_counts['open']++;
104
105 if ( isset( $task['end_date'] )
106 && (int) $task['end_date'] > 0
107 && (int) $task['end_date'] < $current_timestamp
108 ) {
109 $tasks_counts['overdue']++;
110 }
111 }
112 } else {
113 $tasks_counts['closed']++;
114 }
115 }
116 }
117 $upstream_allcounts['tasksCounts'] = $tasks_counts;
118
119 }
120
121 $are_bugs_enabled = ! upstream_disable_bugs() && ! upstream_are_bugs_disabled();
122 if ( $are_bugs_enabled ) {
123 $bugs_counts = array(
124 'open' => 0,
125 'mine' => 0,
126 'overdue' => 0,
127 'closed' => 0,
128 'total' => 0,
129 );
130
131 $bugs_options = get_option( 'upstream_bugs' );
132 $bugs_map = array();
133 foreach ( $bugs_options['statuses'] as $bug ) {
134 $bugs_map[ $bug['id'] ] = $bug['type'];
135 }
136 unset( $bugs_options );
137
138 $bugs = get_post_meta( $project_id, '_upstream_project_bugs' );
139 $bugs = ! empty( $bugs ) ? (array) $bugs[0] : array();
140
141 if ( isset( $bugs[0] ) && ! isset( $bugs[0]['id'] ) ) {
142 $bugs = (array) $bugs[0];
143 }
144
145 $bugs_counts['total'] = count( $bugs );
146 if ( $bugs_counts['total'] > 0 ) {
147 foreach ( $bugs as $bug ) {
148 if ( isset( $bug['assigned_to'] ) ) {
149 $assigned_to = $bug['assigned_to'];
150
151 if ( is_array( $assigned_to ) && in_array( $user_id, $assigned_to ) ) {
152 $bugs_counts['mine']++;
153 }
154 }
155
156 if ( isset( $bug['status'] )
157 && ! empty( $bug['status'] )
158 && isset( $bugs_map[ $bug['status'] ] )
159 && 'closed' === $bugs_map[ $bug['status'] ]
160 ) {
161 $bugs_counts['closed']++;
162 } else {
163 $bugs_counts['open']++;
164
165 if ( isset( $bug['due_date'] )
166 && (int) $bug['due_date'] > 0
167 && (int) $bug['due_date'] < $current_timestamp
168 ) {
169 $bugs_counts['overdue']++;
170 }
171 }
172 }
173 }
174
175 $upstream_allcounts['bugsCounts'] = $bugs_counts;
176
177 }
178 ?>
179
180 <div class="col-xs-12 col-sm-12 col-md-12 col-lg-7 c-upstream-overview">
181 <?php if ( $are_milestones_enabled || $are_tasks_enabled || $are_bugs_enabled ) : ?>
182 <?php if ( $are_milestones_enabled ) : ?>
183 <div class="hidden-xs hidden-sm col-md-4 col-lg-4" style="min-width: 185px;">
184 <div class="card" style="margin-bottom: 10px;">
185 <div class="card-body" style="display: flex; position: relative;">
186 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Open', 'upstream' ); ?>">
187 <span class="badge bg-primary"><?php echo esc_html( $milestones_counts['open'] ); ?></span>
188 </div>
189 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Assigned to me', 'upstream' ); ?>">
190 <span class="badge bg-info"><?php echo esc_html( $milestones_counts['mine'] ); ?></span>
191 </div>
192 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Overdue', 'upstream' ); ?>">
193 <span class="badge bg-danger"><?php echo esc_html( $milestones_counts['overdue'] ); ?></span>
194 </div>
195 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Completed', 'upstream' ); ?>">
196 <span class="badge bg-success"><?php echo esc_html( $milestones_counts['finished'] ); ?></span>
197 </div>
198 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Total', 'upstream' ); ?>">
199 <span class="badge"
200 style="background-color: #ecf0f1; color: #3A4E66;"><?php echo esc_html( $milestones_counts['total'] ); ?></span>
201 </div>
202 <i class="fa fa-flag fa-2x" data-toggle="tooltip"
203 title="
204 <?php
205 echo esc_attr(
206 sprintf(
207 '%s %s',
208 upstream_milestone_label_plural(),
209 __( 'Overview', 'upstream' )
210 )
211 );
212 ?>
213 "
214 style="position: absolute; color: #ECF0F1; right: 8px; margin-top: -2px"></i>
215 </div>
216 </div>
217 </div>
218 <?php endif; ?>
219
220 <?php if ( $are_tasks_enabled ) : ?>
221 <div class="hidden-xs hidden-sm col-md-4 col-lg-4" style="min-width: 185px;">
222 <div class="card" style="margin-bottom: 10px;">
223 <div class="card-body" style="display: flex; position: relative;">
224 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Open', 'upstream' ); ?>">
225 <span class="badge bg-primary"><?php echo esc_html( $tasks_counts['open'] ); ?></span>
226 </div>
227 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Assigned to me', 'upstream' ); ?>">
228 <span class="badge bg-info"><?php echo esc_html( $tasks_counts['mine'] ); ?></span>
229 </div>
230 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Overdue', 'upstream' ); ?>">
231 <span class="badge bg-danger"><?php echo esc_html( $tasks_counts['overdue'] ); ?></span>
232 </div>
233 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Closed', 'upstream' ); ?>">
234 <span class="badge bg-success"><?php echo esc_html( $tasks_counts['closed'] ); ?></span>
235 </div>
236 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Total', 'upstream' ); ?>">
237 <span class="badge"
238 style="background-color: #ecf0f1; color: #3A4E66;"><?php echo esc_html( $tasks_counts['total'] ); ?></span>
239 </div>
240 <i class="fa fa-wrench fa-2x" data-toggle="tooltip"
241 title="
242 <?php
243 echo esc_attr(
244 sprintf(
245 '%s %s',
246 upstream_task_label_plural(),
247 __( 'Overview', 'upstream' )
248 )
249 );
250 ?>
251 "
252 style="position: absolute; color: #ECF0F1; right: 8px; margin-top: -2px"></i>
253 </div>
254 </div>
255 </div>
256 <?php endif; ?>
257
258 <?php if ( $are_bugs_enabled ) : ?>
259 <div class="hidden-xs hidden-sm col-md-4 col-lg-4" style="min-width: 185px;">
260 <div class="card" style="margin-bottom: 10px;">
261 <div class="card-body" style="display: flex; position: relative;">
262 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Open', 'upstream' ); ?>">
263 <span class="badge bg-primary"><?php echo esc_html( $bugs_counts['open'] ); ?></span>
264 </div>
265 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Assigned to me', 'upstream' ); ?>">
266 <span class="badge bg-info"><?php echo esc_html( $bugs_counts['mine'] ); ?></span>
267 </div>
268 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Overdue', 'upstream' ); ?>">
269 <span class="badge bg-danger"><?php echo esc_html( $bugs_counts['overdue'] ); ?></span>
270 </div>
271 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Closed', 'upstream' ); ?>">
272 <span class="badge bg-success"><?php echo esc_html( $bugs_counts['closed'] ); ?></span>
273 </div>
274 <div data-toggle="tooltip" title="<?php esc_attr_e( 'Total', 'upstream' ); ?>">
275 <span class="badge"
276 style="background-color: #ecf0f1; color: #3A4E66;"><?php echo esc_html( $bugs_counts['total'] ); ?></span>
277 </div>
278 <i class="fa fa-bug fa-2x" data-toggle="tooltip"
279 title="
280 <?php
281 echo esc_attr(
282 sprintf(
283 '%s %s',
284 upstream_bug_label_plural(),
285 __( 'Overview', 'upstream' )
286 )
287 );
288 ?>
289 "
290 style="position: absolute; color: #ECF0F1; right: 8px; margin-top: -2px"></i>
291 </div>
292 </div>
293 </div>
294 <?php endif; ?>
295 <?php endif; ?>
296 </div>
297