Ejemplo n.º 1
0
 public static function add_link_to_admin_bar($items)
 {
     if (is_single() && si_get_doc_context()) {
         $items[] = array('id' => 'customizer', 'title' => self::__('Customize'), 'href' => esc_url_raw(add_query_arg(array('url' => urlencode(get_permalink())), admin_url('customize.php'))), 'weight' => 1000);
     }
     return $items;
 }
Ejemplo n.º 2
0
 /**
  * Get the invoice line items
  * @param  integer $id
  * @return array
  */
 function si_get_doc_line_items($id = 0)
 {
     if (!$id) {
         $id = get_the_ID();
     }
     if (si_get_doc_context($id) == 'estimate') {
         return si_get_estimate_line_items($id);
     }
     return si_get_invoice_line_items($id);
 }
Ejemplo n.º 3
0
 /**
  * Get the invoice line items
  * @param  integer $id 
  * @return array      
  */
 function si_get_doc_line_items($id = 0)
 {
     if (!$id) {
         global $post;
         $id = $post->ID;
     }
     if (si_get_doc_context($id) == 'estimate') {
         return si_get_estimate_line_items($id);
     }
     return si_get_invoice_line_items($id);
 }
Ejemplo n.º 4
0
function si_redirect_if_expired()
{
    if (current_user_can('edit_sprout_invoices')) {
        return;
    }
    $expiration = 'invoice' === si_get_doc_context() ? si_get_invoice_due_date() : si_get_estimate_expiration_date();
    if (!$expiration) {
        return;
    }
    if ($expiration < current_time('timestamp')) {
        $redirect_url = home_url();
        wp_redirect($redirect_url);
        exit;
    }
}
    public static function add_deposit_option($doc_id)
    {
        $context = si_get_doc_context($doc_id);
        if ('invoice' !== $context) {
            return;
        }
        $invoice = SI_Invoice::get_instance($doc_id);
        $total = is_a($invoice, 'SI_Invoice') ? $invoice->get_total() : '0.00';
        $total_payments = is_a($invoice, 'SI_Invoice') ? $invoice->get_payments_total() : '0.00';
        $deposit = is_a($invoice, 'SI_Invoice') ? $invoice->get_deposit() : '0.00';
        $status = is_a($invoice, 'SI_Invoice') && $invoice->get_status() !== 'auto-draft' ? $invoice->get_status() : SI_Invoice::STATUS_TEMP;
        if (apply_filters('show_upgrade_messaging', true, 'deposit-line-items')) {
            ?>
			<div id="deposit">
				<b title="Upgrade Sprout Invoices to enable deposits." class="helptip"><?php 
            _e('Deposit Due', 'sprout-invoices');
            ?>
</b>
				<input type="number" name="deposit" min="0" max="0" step="any" disabled="disabled">
			</div>
			<?php 
        } elseif (floatval($total - $total_payments) > 0.0 || 'auto-draft' === $status || 'temp' === $status) {
            ?>
			<div id="deposit">
				<b title="Set the amount due for the next payment&mdash;amount due will be used 0" class="helptip"><?php 
            _e('Deposit Due', 'sprout-invoices');
            ?>
</b>
				<input type="number" name="deposit" value="<?php 
            echo (double) $deposit;
            ?>
" min="0" max="<?php 
            echo floatval($total - $total_payments);
            ?>
"  step="any">
			</div>
			<?php 
        }
    }
Ejemplo n.º 6
0
 public static function load_custom_stylesheet()
 {
     $context = si_get_doc_context();
     if ('' === $context) {
         return;
     }
     $context_stylesheet_path = self::locate_template(array($context . 's.css', $context . '/' . $context . 's.css'), false);
     if ($context_stylesheet_path) {
         $stylesheet_url = _convert_content_file_path_to_url($context_stylesheet_path);
         printf('<link rel="stylesheet" id="sprout_doc_style-%s-css" href="%s" type="text/css" media="all">', $context, esc_url_raw($stylesheet_url));
     }
     $stylesheet_path = self::locate_template(array('sprout-invoices.css'), false);
     if ($stylesheet_path) {
         $general_stylesheet_url = _convert_content_file_path_to_url($stylesheet_path);
         printf('<link rel="stylesheet" id="sprout_doc_style-%s-css" href="%s" type="text/css" media="all">', 'general', esc_url_raw($general_stylesheet_url));
     }
 }
 public static function username($atts = array())
 {
     $id = 0;
     if (si_get_doc_context() == 'estimate') {
         $id = si_get_estimate_id();
     } else {
         $id = si_get_invoice_id();
     }
     $doc = si_get_doc_object($id);
     if (!$doc->get_client_id()) {
         return '';
     }
     $user = si_default_client_user($client_id);
     if (!$user->exists()) {
         return '';
     }
     return $user->display_name;
 }