示例#1
0
                            <td align="center">
                                <input type="hidden" name="add_payment" value="0" id="add_payment">
                                <input type="button" name="add_payment_btn" value="<?php 
        _e('Add payment');
        ?>
" class="save_invoice_payment small_button" onclick="$('#add_payment').val('go'); $('#invoice_form')[0].submit(); return false;">
                            </td>
                        </tr>
						</tbody>
                        <?php 
    }
    ?>

                        <tbody>
                        <?php 
    foreach (module_invoice::get_invoice_payments($invoice_id) as $invoice_payment_id => $invoice_payment_data) {
        if (module_invoice::can_i('edit', 'Invoice Payments') && module_security::is_page_editable()) {
            ?>

                                <tr id="invoice_payment_edit_<?php 
            echo $invoice_payment_id;
            ?>
" style="display:none;">
                                    <td>
                                        <input type="text" name="invoice_invoice_payment[<?php 
            echo $invoice_payment_id;
            ?>
][date_paid]" value="<?php 
            echo print_date($invoice_payment_data['date_paid']);
            ?>
" class="date_field" id="invoice_payment_desc_<?php 
示例#2
0
 public static function is_automatic_paying_invoice($invoice_id)
 {
     $invoice_payments = module_invoice::get_invoice_payments($invoice_id);
     foreach ($invoice_payments as $payment) {
         if (isset($payment['invoice_payment_subscription_id']) && $payment['invoice_payment_subscription_id']) {
             return true;
         }
     }
     // check if this is part of a subscription, and if the previous subscription
     if (class_exists('module_subscription', false)) {
         // THIS CODE EXISTS
         // check if this invoice is part of a subscription.
         // if it is we hunt through the subscription history until we find a recent unpaid invoice
         $subscription_history_item = get_single('subscription_history', 'invoice_id', $invoice_id);
         if ($subscription_history_item && $subscription_history_item['subscription_owner_id']) {
             // we have an invoice that is on a subscription!
             $subscription_owner = module_subscription::get_subscription_owner($subscription_history_item['subscription_owner_id']);
             // check if there are unpaid invoices that were generated after this invoice.
             if ($subscription_owner['subscription_owner_id'] == $subscription_history_item['subscription_owner_id']) {
                 $subscription_history = get_multiple('subscription_history', array('subscription_owner_id' => $subscription_owner['subscription_owner_id']));
                 foreach ($subscription_history as $h) {
                     $invoice_payments = module_invoice::get_invoice_payments($h['invoice_id']);
                     foreach ($invoice_payments as $payment) {
                         if (isset($payment['invoice_payment_subscription_id']) && $payment['invoice_payment_subscription_id']) {
                             $payment_subscription = get_single('invoice_payment_subscription', 'invoice_payment_subscription_id', $payment['invoice_payment_subscription_id']);
                             if ($payment_subscription && $payment_subscription['status'] == _INVOICE_SUBSCRIPTION_ACTIVE) {
                                 //} || $payment_subscription['status'] == _INVOICE_SUBSCRIPTION_PENDING)){
                                 return true;
                             }
                         }
                     }
                 }
             }
         }
     }
     return false;
 }
<?php

/** 
 * Copyright: dtbaker 2012
 * Licence: Please check CodeCanyon.net for licence details. 
 * More licence clarification available here:  http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ 
 * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4
 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca
 * Package Date: 2015-11-25 02:55:20 
 * IP Address: 67.79.165.254
 */
// UPDATE:::: to modify this layout please now go to Settings > Templates and look for "invoice_payment_history"
if (module_config::c('invoice_show_payment_history', 1)) {
    $payment_historyies = module_invoice::get_invoice_payments($invoice_id);
    foreach ($payment_historyies as $invoice_payment_id => $invoice_payment_data) {
        if (module_config::c('invoice_hide_pending_payments', 1)) {
            if (!trim($invoice_payment_data['date_paid']) || $invoice_payment_data['date_paid'] == '0000-00-00') {
                unset($payment_historyies[$invoice_payment_id]);
            }
        }
    }
    if (count($payment_historyies)) {
        ob_start();
        ?>
		<table cellpadding="4" cellspacing="0" class="table tableclass tableclass_rows" style="width: 100%" id="invoice_payment_history">
			<thead>
				<tr class="task_header">
                    <th>{l:Payment Date}</th>
                    <th>{l:Payment Method}</th>
                    <th>{l:Details}</th>
                    <th>{l:Amount}</th>
示例#4
0
    public function external_hook($hook)
    {
        switch ($hook) {
            case 'public':
                $job_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false;
                $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false;
                if ($job_id && $hash) {
                    $correct_hash = $this->link_public($job_id, true);
                    if ($correct_hash == $hash) {
                        // all good to print a receipt for this payment.
                        $job_data = $this->get_job($job_id);
                        if ($job_data) {
                            $job_data = self::get_replace_fields($job_id, $job_data);
                            $customer_data = $job_data['customer_id'] ? module_customer::get_replace_fields($job_data['customer_id']) : array();
                            $website_data = $job_data['website_id'] ? module_website::get_replace_fields($job_data['website_id']) : array();
                            module_template::init_template('external_job', '{HEADER}<h2>Job Overview</h2>
Job Name: <strong>{JOB_NAME}</strong> <br/>
{PROJECT_TYPE} Name: <strong>{PROJECT_NAME}</strong> <br/>

<br/>
<h3>Task List: {TASK_PERCENT_COMPLETED}</h3> <br/>
{TASK_LIST}
<br/><br/>
{JOB_INVOICES}
', 'Used when displaying the external view of a job.', 'code');
                            // correct!
                            // load up the receipt template.
                            $template = module_template::get_template_by_key('external_job');
                            // generate the html for the task output
                            ob_start();
                            include module_theme::include_ucm('includes/plugin_job/pages/job_public.php');
                            $public_html = ob_get_clean();
                            $job_data['task_list'] = $public_html;
                            // do we link the job name?
                            $job_data['header'] = '';
                            if (module_security::is_logged_in() && $this->can_i('edit', 'Jobs')) {
                                $job_data['header'] = '<div style="text-align: center; padding: 0 0 10px 0; font-style: italic;">' . _l('You can send this page to your customer as a quote or progress update (this message will be hidden).') . '</div>';
                            }
                            // is this a job or a quote?
                            if ($job_data['date_quote'] != '0000-00-00' && ($job_data['date_start'] == '0000-00-00' && $job_data['date_completed'] == '0000-00-00')) {
                                $job_data['job_or_quote'] = _l('Quote');
                            } else {
                                $job_data['job_or_quote'] = _l('Job');
                            }
                            //$job_data['job_name'] = $job_data['name'];
                            $job_data['job_name'] = self::link_open($job_id, true);
                            // format some dates:
                            $job_data['date_quote'] = $job_data['date_quote'] == '0000-00-00' ? _l('N/A') : print_date($job_data['date_quote']);
                            $job_data['date_start'] = $job_data['date_start'] == '0000-00-00' ? _l('N/A') : print_date($job_data['date_start']);
                            $job_data['date_due'] = $job_data['date_due'] == '0000-00-00' ? _l('N/A') : print_date($job_data['date_due']);
                            $job_data['date_completed'] = $job_data['date_completed'] == '0000-00-00' ? _l('N/A') : print_date($job_data['date_completed']);
                            $job_data['TASK_PERCENT_COMPLETED'] = $job_data['total_percent_complete'] > 0 ? _l('(%s%% completed)', $job_data['total_percent_complete'] * 100) : '';
                            $job_data['job_invoices'] = '';
                            $invoices = module_invoice::get_invoices(array('job_id' => $job_id));
                            $job_data['project_type'] = _l(module_config::c('project_name_single', 'Website'));
                            //$website_data = $job_data['website_id'] ? module_website::get_website($job_data['website_id']) : array();
                            $job_data['project_name'] = isset($website_data['name']) && strlen($website_data['name']) ? $website_data['name'] : _l('N/A');
                            if (count($invoices)) {
                                $job_data['job_invoices'] .= '<h3>' . _l('Job Invoices:') . '</h3>';
                                $job_data['job_invoices'] .= '<ul>';
                                foreach ($invoices as $invoice) {
                                    $job_data['job_invoices'] .= '<li>';
                                    $invoice = module_invoice::get_invoice($invoice['invoice_id']);
                                    $job_data['job_invoices'] .= module_invoice::link_open($invoice['invoice_id'], true);
                                    $job_data['job_invoices'] .= "<br/>";
                                    $job_data['job_invoices'] .= _l('Total: ') . dollar($invoice['total_amount'], true, $invoice['currency_id']);
                                    $job_data['job_invoices'] .= "<br/>";
                                    $job_data['job_invoices'] .= '<span class="';
                                    if ($invoice['total_amount_due'] > 0) {
                                        $job_data['job_invoices'] .= 'error_text';
                                    } else {
                                        $job_data['job_invoices'] .= 'success_text';
                                    }
                                    $job_data['job_invoices'] .= '">';
                                    if ($invoice['total_amount_due'] > 0) {
                                        $job_data['job_invoices'] .= dollar($invoice['total_amount_due'], true, $invoice['currency_id']);
                                        $job_data['job_invoices'] .= ' ' . _l('due');
                                    } else {
                                        $job_data['job_invoices'] .= _l('All paid');
                                    }
                                    $job_data['job_invoices'] .= '</span>';
                                    $job_data['job_invoices'] .= "<br>";
                                    // view receipts:
                                    $payments = module_invoice::get_invoice_payments($invoice['invoice_id']);
                                    if (count($payments)) {
                                        $job_data['job_invoices'] .= "<ul>";
                                        foreach ($payments as $invoice_payment_id => $invoice_payment_data) {
                                            $job_data['job_invoices'] .= "<li>";
                                            $job_data['job_invoices'] .= '<a href="' . module_invoice::link_receipt($invoice_payment_data['invoice_payment_id']) . '" target="_blank">' . _l('View Receipt for payment of %s', dollar($invoice_payment_data['amount'], true, $invoice_payment_data['currency_id'])) . '</a>';
                                            $job_data['job_invoices'] .= "</li>";
                                        }
                                        $job_data['job_invoices'] .= "</ul>";
                                    }
                                    $job_data['job_invoices'] .= '</li>';
                                }
                                $job_data['job_invoices'] .= '</ul>';
                            }
                            $template->assign_values($customer_data);
                            $template->assign_values($website_data);
                            $template->assign_values($job_data);
                            $template->page_title = $job_data['name'];
                            echo $template->render('pretty_html');
                        }
                    }
                }
                break;
        }
    }