Example #1
0
/**
 * Customize Post Titles. 
 * @uses be_get_project_name() for Title
 * @uses get_edit_post_link() for Permalink
 *
 * @author Bill Erickson
 * @param string, original title output
 * @return string, modified title output 
 */
function be_post_title($title)
{
    $title = be_get_project_name();
    if (strlen($title) == 0) {
        return;
    }
    if (is_singular()) {
        $title = sprintf('<h1 class="entry-title">%s</h1>', apply_filters('genesis_post_title_text', $title));
    } else {
        $title = sprintf('<h2 class="entry-title"><a href="%s" title="%s" rel="bookmark">%s</a></h2>', get_edit_post_link(), the_title_attribute('echo=0'), apply_filters('genesis_post_title_text', $title));
    }
    return $title;
}
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++;
    }
}
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++;
        }
    }
    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;
        }
    }
    echo $be_output_end;
    echo '</div>';
}
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        echo $before_title . 'Outstanding Quotes' . $after_title;
        $args = array('category_name' => 'outstanding-quote', 'posts_per_page' => '-1');
        $new = new WP_Query($args);
        $count = 0;
        global $prefix;
        if ($new->have_posts()) {
            echo '<ol>';
            while ($new->have_posts()) {
                $new->the_post();
                global $post;
                ?>
				<li><a href="<?php 
                echo get_edit_post_link();
                ?>
"><?php 
                echo be_get_project_name();
                ?>
</a>, <?php 
                the_date();
                ?>
 <?php 
                edit_post_link('Edit', '(', ')');
                ?>
				<?php 
                $status = get_custom_field($prefix . 'status_summary');
                if ($status) {
                    echo '<br /><strong>Status:</strong> ' . $status;
                }
                ?>
				<br />
				<?php 
                $revenue = get_custom_field($prefix . 'revenue');
                if ($revenue) {
                    echo 'Quote: ' . $revenue . '<br />';
                }
                $email = get_custom_field($prefix . 'client_email');
                if ($email) {
                    echo 'Email: ' . $email;
                }
                $phone = get_custom_field($prefix . 'client_phone');
                if ($phone) {
                    echo 'Phone: ' . $phone;
                }
                ?>
				</li>
				<?php 
                $count++;
            }
            if ($count < 1) {
                echo "<p>This displays any contacts with a status of Outstanding Quote.</p>";
            }
            echo '</ol>';
        } else {
            echo "<p>This displays any contacts with a status of Outstanding Quote.</p>";
        }
        wp_reset_query();
        echo $after_widget;
    }
    function widget($args, $instance)
    {
        extract($args);
        echo $before_widget;
        echo $before_title . 'Newest Prospects' . $after_title;
        $new = new WP_Query('category_name=prospect&posts_per_page=20');
        $count = 0;
        global $prefix;
        if ($new->have_posts()) {
            echo '<ol>';
            while ($new->have_posts()) {
                $new->the_post();
                global $post;
                ?>
				<li><a href="<?php 
                echo get_edit_post_link();
                ?>
"><?php 
                echo be_get_project_name();
                ?>
</a>, <?php 
                the_date();
                ?>
 <?php 
                edit_post_link('Edit', '(', ')');
                ?>
				<?php 
                $status = get_custom_field($prefix . 'status_summary');
                if ($status) {
                    echo '<br /><strong>Status:</strong> ' . $status;
                }
                ?>
				<br />Source: <?php 
                $sources = get_the_terms($post->ID, 'sources', '', ', ', '');
                $list = '';
                if ($sources) {
                    foreach ($sources as $data) {
                        $list .= $data->name . ', ';
                    }
                    echo $list;
                }
                $email = get_custom_field($prefix . 'client_email');
                if ($email) {
                    echo '<br />Email: ' . $email;
                }
                $phone = get_custom_field($prefix . 'client_phone');
                if ($phone) {
                    echo '<br />Phone: ' . $phone;
                }
                ?>
				</li>
				<?php 
                $count++;
            }
            if ($count < 1) {
                echo "<p>WooHoo! You're either really fast at responding to prospects, or you haven't set up your categories yet. </p><p>This area shows posts that are 10 days or older and in the 'Prospect' category. If you haven't done so already, create a category with the slug 'prospect'.</p>";
            }
            echo '</ol>';
        } else {
            echo "<p>WooHoo! You're either really fast at responding to prospects, or you haven't set up your categories yet. </p><p>This area shows posts that are 10 days or older and in the 'Prospect' category. If you haven't done so already, create a category with the slug 'prospect'.</p>";
        }
        wp_reset_query();
        echo $after_widget;
    }