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 / progress.php

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

302 lines 12.7 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Single project: progress
4 *
5 * @package UpStream
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11 global $upstream_allcounts;
12
13 $plugin_options = get_option( 'upstream_general' );
14 $collapse_box = isset( $plugin_options['collapse_project_progress'] ) && true === (bool) $plugin_options['collapse_project_progress'];
15 $collapse_box_state = \UpStream\Frontend\upstream_get_section_collapse_state( 'progress' );
16 $project_id = upstream_post_id();
17
18 if ( false !== $collapse_box_state ) {
19 $collapse_box = 'closed' === $collapse_box_state;
20 }
21
22 $count_enabled = 0;
23 if ( ! upstream_disable_tasks() ) {
24 $count_enabled++;
25 }
26 if ( ! upstream_disable_bugs() ) {
27 $count_enabled++;
28 }
29
30
31 $manager = \UpStream_Model_Manager::get_instance();
32 $project = $manager->getByID( UPSTREAM_ITEM_TYPE_PROJECT, $project_id );
33
34
35 // pie chart and barcode color option.
36 $upstream_customizer = get_option( 'upstream_customizer' );
37 $progress_chart_text_color = '#aaa';
38 $progress_chart_pie_color_1 = '#dd3333';
39 $progress_chart_pie_color_2 = '#dd9933';
40 $progress_chart_pie_color_3 = '#81d742';
41 $progress_chart_pie_color_4 = '#1e73be';
42 $progress_chart_pie_color_5 = '#8224e3';
43 $progress_chart_pie_color_6 = '#c12cbc';
44 $progress_chart_bar_color_open = '#4285f4';
45 $progress_chart_bar_color_mine = '#db4437';
46 $progress_chart_bar_color_overdue = '#f4b400';
47 $progress_chart_bar_color_finished = '#0f9d58';
48 $progress_chart_bar_color_total = '#ab47bc';
49
50 if ( ! empty( $upstream_customizer['progress_chart_text_color'] ) ) {
51 $progress_chart_text_color = $upstream_customizer['progress_chart_text_color'];
52 }
53
54 if ( ! empty( $upstream_customizer['progress_chart_pie_color_1'] ) ) {
55 $progress_chart_pie_color_1 = $upstream_customizer['progress_chart_pie_color_1'];
56 }
57
58 if ( ! empty( $upstream_customizer['progress_chart_pie_color_2'] ) ) {
59 $progress_chart_pie_color_2 = $upstream_customizer['progress_chart_pie_color_2'];
60 }
61
62 if ( ! empty( $upstream_customizer['progress_chart_pie_color_3'] ) ) {
63 $progress_chart_pie_color_3 = $upstream_customizer['progress_chart_pie_color_3'];
64 }
65
66 if ( ! empty( $upstream_customizer['progress_chart_pie_color_4'] ) ) {
67 $progress_chart_pie_color_4 = $upstream_customizer['progress_chart_pie_color_4'];
68 }
69
70 if ( ! empty( $upstream_customizer['progress_chart_pie_color_5'] ) ) {
71 $progress_chart_pie_color_5 = $upstream_customizer['progress_chart_pie_color_5'];
72 }
73
74 if ( ! empty( $upstream_customizer['progress_chart_pie_color_6'] ) ) {
75 $progress_chart_pie_color_6 = $upstream_customizer['progress_chart_pie_color_6'];
76 }
77
78 if ( ! empty( $upstream_customizer['progress_chart_bar_color_open'] ) ) {
79 $progress_chart_bar_color_open = $upstream_customizer['progress_chart_bar_color_open'];
80 }
81
82 if ( ! empty( $upstream_customizer['progress_chart_bar_color_mine'] ) ) {
83 $progress_chart_bar_color_mine = $upstream_customizer['progress_chart_bar_color_mine'];
84 }
85
86 if ( ! empty( $upstream_customizer['progress_chart_bar_color_overdue'] ) ) {
87 $progress_chart_bar_color_overdue = $upstream_customizer['progress_chart_bar_color_overdue'];
88 }
89
90 if ( ! empty( $upstream_customizer['progress_chart_bar_color_finished'] ) ) {
91 $progress_chart_bar_color_finished = $upstream_customizer['progress_chart_bar_color_finished'];
92 }
93
94 if ( ! empty( $upstream_customizer['progress_chart_bar_color_total'] ) ) {
95 $progress_chart_bar_color_total = $upstream_customizer['progress_chart_bar_color_total'];
96 }
97 ?>
98
99 <div class="col-xs-12 col-sm-12 col-md-12">
100 <div class="x_panel" data-section="progress">
101 <div class="x_title" id="progress">
102 <h2>
103 <i class="fa fa-bars sortable_handler"></i>
104 <i class="fa fa-comments"></i> <?php esc_html_e( 'Progress', 'upstream' ); ?>
105 </h2>
106 <ul class="nav navbar-right panel_toolbox">
107 <li>
108 <a class="collapse-link">
109 <i class="fa fa-chevron-<?php echo $collapse_box ? 'down' : 'up'; ?>"></i>
110 </a>
111 </li>
112 </ul>
113 <div class="clearfix"></div>
114 </div>
115 <div class="x_content" style="display: <?php echo $collapse_box ? 'none' : 'block'; ?>;">
116 <script type="text/javascript">
117
118 google.charts.load('current', {'packages':['bar', 'corechart']});
119 google.charts.setOnLoadCallback(drawChart);
120
121 function drawChart() {
122 var data = [ [
123 "",
124 <?php print json_encode( __( 'Open', 'upstream' ) ); ?>,
125 <?php print json_encode( __( 'Assigned to me', 'upstream' ) ); ?>,
126 <?php print json_encode( __( 'Overdue', 'upstream' ) ); ?>,
127 <?php print json_encode( __( 'Completed', 'upstream' ) ); ?>,
128 <?php print json_encode( __( 'Total', 'upstream' ) ); ?> ]
129 ];
130
131 <?php if ( ! upstream_disable_milestones() ) : ?>
132 var milestone_open = parseInt("<?php echo esc_js( $upstream_allcounts['milestonesCounts']['open'] ); ?>");
133 var milestone_mine = parseInt("<?php echo esc_js( $upstream_allcounts['milestonesCounts']['mine'] ); ?>");
134 var milestone_overdue = parseInt("<?php echo esc_js( $upstream_allcounts['milestonesCounts']['overdue'] ); ?>");
135 var milestone_finished = parseInt("<?php echo esc_js( $upstream_allcounts['milestonesCounts']['finished'] ); ?>");
136 var milestone_total = parseInt("<?php echo esc_js( $upstream_allcounts['milestonesCounts']['total'] ); ?>");
137
138 data.push([<?php print json_encode( upstream_milestone_label_plural() ); ?>,
139 milestone_open,
140 milestone_mine,
141 milestone_overdue,
142 milestone_finished,
143 milestone_total]);
144 <?php endif; ?>
145
146 <?php if ( ! upstream_disable_tasks() ) : ?>
147 var task_open = parseInt("<?php echo esc_js( $upstream_allcounts['tasksCounts']['open'] ); ?>");
148 var task_mine = parseInt("<?php echo esc_js( $upstream_allcounts['tasksCounts']['mine'] ); ?>");
149 var task_overdue = parseInt("<?php echo esc_js( $upstream_allcounts['tasksCounts']['overdue'] ); ?>");
150 var task_finished = parseInt("<?php echo esc_js( $upstream_allcounts['tasksCounts']['closed'] ); ?>");
151 var task_total = parseInt("<?php echo esc_js( $upstream_allcounts['tasksCounts']['total'] ); ?>");
152
153 data.push([<?php print json_encode( upstream_task_label_plural() ); ?>,
154 task_open,
155 task_mine,
156 task_overdue,
157 task_finished,
158 task_total]);
159 <?php endif; ?>
160
161 <?php if ( ! upstream_disable_bugs() ) : ?>
162 var bug_open = parseInt("<?php echo esc_js( $upstream_allcounts['bugsCounts']['open'] ); ?>");
163 var bug_mine = parseInt("<?php echo esc_js( $upstream_allcounts['bugsCounts']['mine'] ); ?>");
164 var bug_overdue = parseInt("<?php echo esc_js( $upstream_allcounts['bugsCounts']['overdue'] ); ?>");
165 var bug_finished = parseInt("<?php echo esc_js( $upstream_allcounts['bugsCounts']['closed'] ); ?>");
166 var bug_total = parseInt("<?php echo esc_js( $upstream_allcounts['bugsCounts']['total'] ); ?>");
167
168 data.push([<?php print json_encode( upstream_bug_label_plural() ); ?>,
169 bug_open,
170 bug_mine,
171 bug_overdue,
172 bug_finished,
173 bug_total]);
174 <?php endif; ?>
175
176 var options = {
177 chart: {
178 width: '100%',
179 },
180 colors: ["<?php echo esc_js( $progress_chart_bar_color_open ); ?>", "<?php echo esc_js( $progress_chart_bar_color_mine ); ?>", "<?php echo esc_js( $progress_chart_bar_color_overdue ); ?>", "<?php echo esc_js( $progress_chart_bar_color_finished ); ?>", "<?php echo esc_js( $progress_chart_bar_color_total ); ?>"],
181 };
182
183 var chart = new google.charts.Bar(document.getElementById('progress_chart_div'));
184 chart.draw(google.visualization.arrayToDataTable(data), google.charts.Bar.convertOptions(options));
185
186
187 <?php
188 if ( ! upstream_disable_tasks() ) :
189
190 $tasks = $project->tasks();
191 $status_counts = array();
192 foreach ( $tasks as $t ) {
193 if ( upstream_override_access_object( true, UPSTREAM_ITEM_TYPE_TASK, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) {
194 if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_TASK, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, 'title', UPSTREAM_PERMISSIONS_ACTION_VIEW ) &&
195 upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_TASK, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, 'status', UPSTREAM_PERMISSIONS_ACTION_VIEW )
196 ) {
197 if ( trim( $t->status ) == '' ) {
198 $key = __( 'None', 'upstream' );
199 } else {
200 $key = $t->status;
201 }
202 if ( isset( $status_counts[ $key ] ) ) {
203 $status_counts[ $key ]++;
204 } else {
205 $status_counts[ $key ] = 1;
206 }
207 }
208 }
209 }
210
211 ?>
212 var data = google.visualization.arrayToDataTable([
213 ['', ''],
214 <?php foreach ( $status_counts as $key => $value ) : ?>
215 [<?php print json_encode( $key ); ?>, parseInt("<?php print esc_js( $value ); ?>")],
216 <?php endforeach; ?>
217 ]);
218
219 var options = {
220 pieSliceText: 'label',
221 legend: 'none',
222 pieSliceTextStyle: { color: "<?php echo esc_js( $progress_chart_text_color ); ?>" },
223 height: 300,
224 pieHole: .5,
225 colors: ["<?php echo esc_js( $progress_chart_pie_color_1 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_2 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_3 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_4 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_5 ); ?>","<?php echo esc_js( $progress_chart_pie_color_6 ); ?>"],
226 };
227
228 var chart = new google.visualization.PieChart(document.getElementById('task_chart_div'));
229 chart.draw(data, options);
230 <?php endif; ?>
231
232 <?php
233 if ( ! upstream_disable_bugs() ) :
234
235
236 $bugs = $project->bugs();
237 $status_counts = array();
238 foreach ( $bugs as $t ) {
239 if ( upstream_override_access_object( true, UPSTREAM_ITEM_TYPE_BUG, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, UPSTREAM_PERMISSIONS_ACTION_VIEW ) ) {
240 if ( upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_BUG, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, 'title', UPSTREAM_PERMISSIONS_ACTION_VIEW ) &&
241 upstream_override_access_field( true, UPSTREAM_ITEM_TYPE_BUG, $t->id, UPSTREAM_ITEM_TYPE_PROJECT, $project->id, 'status', UPSTREAM_PERMISSIONS_ACTION_VIEW )
242 ) {
243 if ( trim( $t->status ) == '' ) {
244 $key = __( 'None', 'upstream' );
245 } else {
246 $key = $t->status;
247 }
248 if ( isset( $status_counts[ $key ] ) ) {
249 $status_counts[ $key ]++;
250 } else {
251 $status_counts[ $key ] = 1;
252 }
253 }
254 }
255 }
256
257 ?>
258
259
260 var data = google.visualization.arrayToDataTable([
261 ['', ''],
262 <?php foreach ( $status_counts as $key => $value ) : ?>
263 [<?php print json_encode( $key ); ?>, parseInt("<?php print esc_js( $value ); ?>")],
264 <?php endforeach; ?>
265 ]);
266
267 var options = {
268 pieHole: .5,
269 legend: 'none',
270 pieSliceText: 'label',
271 pieSliceTextStyle: { color: "<?php echo esc_js( $progress_chart_text_color ); ?>" },
272 height: 300,
273 colors: ["<?php echo esc_js( $progress_chart_pie_color_1 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_2 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_3 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_4 ); ?>", "<?php echo esc_js( $progress_chart_pie_color_5 ); ?>","<?php echo esc_js( $progress_chart_pie_color_6 ); ?>"],
274 };
275
276 var chart = new google.visualization.PieChart(document.getElementById('bug_chart_div'));
277 chart.draw(data, options);
278 <?php endif; ?>
279 }
280 </script>
281
282 <div style="width:100%;display:block">
283 <?php if ( ! upstream_disable_tasks() ) : ?>
284 <div style="width:<?php print esc_attr( 100 / $count_enabled - 1 ); ?>%;position: relative;display: inline-block;text-align: center"><?php print esc_html( upstream_task_label_plural() ); ?></div>
285 <?php endif; ?>
286 <?php if ( ! upstream_disable_bugs() ) : ?>
287 <div style="width:<?php print esc_attr( 100 / $count_enabled - 1 ); ?>%;position: relative;display: inline-block;text-align: center"><?php print esc_html( upstream_bug_label_plural() ); ?></div>
288 <?php endif; ?>
289 </div>
290
291 <?php if ( ! upstream_disable_tasks() ) : ?>
292 <div id="task_chart_div" style="width:<?php print esc_attr( 100 / $count_enabled - 1 ); ?>%;position: relative;display: inline-block"></div>
293 <?php endif; ?>
294 <?php if ( ! upstream_disable_bugs() ) : ?>
295 <div id="bug_chart_div" style="width:<?php print esc_attr( 100 / $count_enabled - 1 ); ?>%;position: relative;display: inline-block"></div>
296 <?php endif; ?>
297
298 <div id="progress_chart_div" style="width:100%;position: relative;display: block"></div>
299 </div>
300 </div>
301 </div>
302