public static function widget_dashboard_invoices()
 {
     $si_project_id = self::get_si_project_id_from_psp_project_id();
     if (is_a($si_project_id, 'WP_Post')) {
         $si_project_id = $si_project_id->ID;
     }
     $si_project = SI_Project::get_instance($si_project_id);
     if (!is_a($si_project, 'SI_Project')) {
         return;
     }
     $invoices = $si_project->get_invoices();
     $estimates = $si_project->get_estimates();
     $payments = $si_project->get_payments();
     if ($invoices) {
         self::load_addon_view('panorama/invoices-widget', array('invoices' => $invoices, 'estimates' => $estimates, 'payments' => $payments), true);
     }
     /**
      * By default we are only going to show estimates
      * that do not have invoices associated. That estimate can
      * be linked from the invoices table instead.
      */
     $estimates_to_show = array();
     foreach ($estimates as $estimate_id) {
         $ass_invoice_id = si_get_estimate_invoice_id($estimate_id);
         if (!$ass_invoice_id || get_post_type($ass_invoice_id) != SI_Invoice::POST_TYPE) {
             $estimates_to_show[] = $estimate_id;
         }
     }
     if ($estimates) {
         self::load_addon_view('panorama/estimates-widget', array('invoices' => $invoices, 'estimates' => $estimates_to_show, 'payments' => $payments), true);
     }
 }
예제 #2
0
$records = new WP_Query($args);
$i = 0;
while ($records->have_posts()) {
    $records->the_post();
    // Calculate the percentage
    $i++;
    $percent = intval($i / $records->found_posts * 100) . "%";
    // Javascript for updating the progress bar and information
    echo '<script language="javascript" id="progress_js">
						document.getElementById("rows_progress").innerHTML="<div style=\\"width:' . $percent . ';background-color:#ddd;\\">&nbsp;</div>";
						document.getElementById("table_progress").innerHTML="' . sprintf(self::__('%o records(s) of %o added.'), $i, $records->found_posts) . '";
						document.getElementById("progress_js").remove();
						</script>';
    $table_total_estimated += si_get_estimate_total();
    $table_subtotal += si_get_estimate_subtotal();
    $invoice_name = si_get_estimate_invoice_id() ? sprintf('<a href="%s">%s</a>', get_edit_post_link(si_get_estimate_invoice_id()), get_the_title(si_get_estimate_invoice_id())) : self::__('N/A');
    $client_name = si_get_estimate_client_id() ? sprintf('<a href="%s">%s</a>', get_edit_post_link(si_get_estimate_client_id()), get_the_title(si_get_estimate_client_id())) : self::__('N/A');
    ?>
						<tr> 
							<td><?php 
    the_ID();
    ?>
</td>
							<td><span class="si_status estimate_status <?php 
    si_estimate_status();
    ?>
"><?php 
    si_estimate_status();
    ?>
</span></td>
							<td><?php 
예제 #3
0
 public static function total_estimate_data_by_date_segment($segment = 'weeks', $span = 6)
 {
     // Return cache if present.
     $cache = self::get_cache(__FUNCTION__ . $segment . $span);
     if ($cache) {
         return $cache;
     }
     $frames = self::walk_back_x_span($span, $segment);
     $date_format = self::get_segment_date_format($segment);
     $year = date('Y', strtotime($span . ' ' . $segment . ' ago'));
     $start_date = date('Y-m-d', strtotime($span . ' ' . $segment . ' ago'));
     // Build data array, without a explicit build segments without posts will not show.
     $data = array();
     foreach ($frames as $frame_date) {
         $data[$frame_date] = array('estimates' => 0, 'requests' => 0, 'totals' => 0, 'subtotals' => 0, 'invoices_generated' => 0, 'status_request' => 0, 'status_pending' => 0, 'status_approved' => 0, 'status_declined' => 0);
     }
     $args = array('post_type' => SI_Estimate::POST_TYPE, 'post_status' => 'any', 'posts_per_page' => -1, 'orderby' => 'date', 'fields' => 'ids', 'date_query' => array(array('after' => $start_date, 'inclusive' => true)));
     $estimates = new WP_Query($args);
     foreach ($estimates->posts as $estimate_id) {
         $frame = get_the_time($date_format, $estimate_id);
         $data[$frame]['estimates'] += 1;
         $data[$frame]['totals'] += si_get_estimate_total($estimate_id);
         $data[$frame]['subtotals'] += si_get_estimate_subtotal($estimate_id);
         if (si_get_estimate_invoice_id($estimate_id)) {
             $data[$frame]['invoices_generated'] += 1;
         }
         // If there are submission fields than it's a request
         if (si_is_estimate_submission($estimate_id)) {
             $data[$frame]['requests'] += 1;
         }
         switch (get_post_status($estimate_id)) {
             case SI_Estimate::STATUS_REQUEST:
                 $data[$frame]['status_request'] += 1;
                 break;
             case SI_Estimate::STATUS_PENDING:
                 $data[$frame]['status_pending'] += 1;
                 break;
             case SI_Estimate::STATUS_APPROVED:
                 $data[$frame]['status_approved'] += 1;
                 break;
             case SI_Estimate::STATUS_DECLINED:
                 $data[$frame]['status_declined'] += 1;
                 break;
             default:
                 break;
         }
     }
     return self::set_cache(__FUNCTION__ . $segment . $span, $data, self::CACHE_TIMEOUT);
 }
<?php

if (!empty($estimates)) {
    /**
     * By default we are only going to show estimates 
     * that do not have invoices associated. That estimate can
     * be linked from the invoices table instead.
     */
    $estimates_to_show = array();
    foreach ($estimates as $estimate_id) {
        $asscoated_invoice_id = si_get_estimate_invoice_id($estimate_id);
        if (!$asscoated_invoice_id || get_post_type($asscoated_invoice_id) != SI_Invoice::POST_TYPE) {
            $estimates_to_show[] = $estimate_id;
        }
    }
    ?>
	<table id="si_client_dashboard_estimates" class="table table-hover">
		<thead>
			<tr>
				<th><?php 
    _e('Issued', 'sprout-invoices');
    ?>
</th>
				<!--<th><?php 
    _e('Number', 'sprout-invoices');
    ?>
</th>-->
				<th><?php 
    _e('Estimate', 'sprout-invoices');
    ?>
</th>
예제 #5
0
 /**
  * Echo the estimate invoice_id
  * @param  integer $id
  * @return string
  */
 function si_estimate_invoice_id($id = 0)
 {
     if (!$id) {
         $id = get_the_ID();
     }
     echo apply_filters('si_estimate_invoice_id', si_get_estimate_invoice_id($id), $id);
 }
예제 #6
0
 /**
  * Echo the estimate invoice_id
  * @param  integer $id 
  * @return string      
  */
 function si_estimate_invoice_id($id = 0)
 {
     if (!$id) {
         global $post;
         $id = $post->ID;
     }
     echo apply_filters('si_estimate_invoice_id', si_get_estimate_invoice_id($id), $id);
 }