-
Notifications
You must be signed in to change notification settings - Fork 53
/
template-complete.php
69 lines (58 loc) · 2.01 KB
/
template-complete.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
<?php
/**
* Template Name: Complete
*
* @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_complete_loop');
function be_complete_loop() {
do_action( 'genesis_before_post_title' );
do_action( 'genesis_post_title' );
do_action( 'genesis_after_post_title' );
global $prefix;
$args = array(
'category_name' => 'complete',
'posts_per_page' => '20',
'meta_query' => array(
array(
'key' => $prefix.'include_complete'
)
)
);
$complete = new WP_Query($args);
setlocale(LC_MONETARY, 'en_US');
$loop_counter = 0;
while ($complete->have_posts()): $complete->the_post();
$revenue = get_custom_field($prefix.'revenue');
$expense = get_custom_field($prefix.'expense');
$profit = $revenue - $expense;
$time = get_custom_field($prefix.'time_setup') + get_custom_field($prefix.'time_development') + get_custom_field($prefix.'time_phone') + get_custom_field($prefix.'time_hourly') + get_custom_field($prefix.'time_other');
if ($time) $rate = money_format('%(#10n', $profit / $time );
if (!empty($revenue)) $revenue = money_format( '%(#10n', $revenue );
if (!empty($expense)) $expense = money_format( '%(#10n', $expense );
if (!empty($profit)) $profit = money_format( '%(#10n', $profit );
if ($loop_counter % 3 == 0) echo '<div class="first project">';
else echo '<div class="project">';
echo '<h3><a href="'.get_edit_post_link().'">'.be_get_project_name().'</a></h3>';
echo '<p>';
if ($revenue) {
echo '<strong>Budget</strong>: '. $revenue;
if ($expense) echo ' - '. $expense . ' = '. $profit;
echo '<br />';
}
if ($time) echo '<strong>Time Spent:</strong> '. $time . ' hrs <br /><strong>Effective rate:</strong> '. $rate . ' /hr<br />';
echo '</p>';
echo '</div>';
$loop_counter++;
endwhile;
}
genesis();
?>