-
Notifications
You must be signed in to change notification settings - Fork 53
/
template-active.php
129 lines (111 loc) · 4.03 KB
/
template-active.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<?php
/**
* Template Name: Active
*
* @package Genesis CRM
* @author Bill Erickson <[email protected]>
* @copyright Copyright (c) 2011, Bill Erickson
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*
*/
/**
* Custom Loop
*/
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'be_active_loop');
function be_active_loop() {
echo '<div class="two-thirds first">';
$order = array('dev', 'maintenance', 'edit', 'dev-complete', 'project-complete');
setlocale(LC_MONETARY, 'en_US');
foreach ($order as $order_item):
$loop_counter = 1;
global $prefix;
$args = array(
'category_name' => 'active-project',
'posts_per_page' => '-1',
'meta_query' => array(
array(
'key' => $prefix.'project_status',
'value' => $order_item,
)
)
);
$active = new WP_Query($args);
if( $active->have_posts() )
echo '<h2 class="first">' . ucwords($order_item) . '</h2>';
while ($active->have_posts()): $active->the_post();
$status = get_custom_field($prefix.'project_status');
$type = get_custom_field( $prefix . 'project_type' );
$status_summary = get_custom_field($prefix.'status_summary');
$revenue = get_custom_field($prefix.'revenue');
$expense = get_custom_field($prefix.'expense');
$profit = $revenue - $expense;
if (!empty($revenue)) $revenue = money_format( '%(#10n', $revenue );
if (!empty($expense)) $expense = money_format( '%(#10n', $expense );
if (!empty($profit)) $profit = money_format( '%(#10n', $profit );
$work = get_custom_field($prefix.'needs_work');
if (empty($work)) $work = 'yes';
$classes = array('project', strtolower($order_item), $work);
if (($loop_counter % 2 == 1) && ($loop_counter !== '1')) $classes[] = 'first';
echo '<div class=" '. implode(' ', $classes) . '">';
echo '<h4><a href="'.get_edit_post_link().'">'.be_get_project_name().'</a></h4>';
echo '<p>';
echo '<strong>'.ucwords($status).'</strong>: '.$status_summary .'<br />';
if( $type ) echo '<strong>Type</strong>: '. $type . '<br />';
if ($revenue) echo '<strong>Budget</strong>: '. $revenue;
if ($expense) echo ' - '. $expense . ' = '. $profit . '<br />';
echo '</p>';
echo '</div>';
$loop_counter++;
endwhile;
endforeach;
echo '</div><div class="one-third grey">';
echo '<h1>Scheduled Projects</h1>';
global $prefix;
$args = array(
'category_name' => 'scheduled-project',
'posts_per_page' => '-1',
'orderby' => 'meta_value_num',
'order' => 'ASC',
'meta_key' => $prefix.'date_dev_start',
);
$scheduled = new WP_Query($args);
global $be_output_end;
$be_output_end = '';
while ($scheduled->have_posts()): $scheduled->the_post();
$output = '';
global $be_output_end;
$start = get_custom_field($prefix.'date_dev_start');
$type = get_custom_field( $prefix . 'project_type' );
$status_summary = get_custom_field($prefix.'status_summary');
$revenue = get_custom_field($prefix.'revenue');
$expense = get_custom_field($prefix.'expense');
$profit = $revenue - $expense;
if (!empty($revenue)) $revenue = money_format( '%(#10n', $revenue );
if (!empty($expense)) $expense = money_format( '%(#10n', $expense );
if (!empty($profit)) $profit = money_format( '%(#10n', $profit );
$classes = array( 'project' );
$work = get_custom_field($prefix.'needs_work');
$classes[] = $work;
$output .= '<div class="' . implode( ' ', $classes ) . '">';
$output .= '<p><a href="'.get_edit_post_link().'">'.be_get_project_name().'</a><br />';
$output .= '<strong>Scheduled for: </strong>'. date('F j, Y', $start) . '<br />';
if ($status_summary)
$output .= '<strong>Status:</strong> '.$status_summary.'<br />';
if( $type )
$output .= '<strong>Type:</strong> ' . $type . '<br />';
if ($revenue)
$output .= '<strong>Budget</strong>: '. $revenue;
if ($expense)
$output .= ' - '. $expense . ' = '. $profit . '<br />';
$output .= '</div>';
if( 'delayed' == $work )
$be_output_end .= $output;
else
echo $output;
endwhile;
echo $be_output_end;
echo '</div>';
}
genesis();
?>