<label for="subscription_<?php echo $subscription['subscription_id']; ?> "> <input type="checkbox" name="subscription[subscriptions][<?php echo $subscription['subscription_id']; ?> ]" value="1" id="subscription_<?php echo $subscription['subscription_id']; ?> "> <?php echo htmlspecialchars($subscription['name']); ?> - <?php echo dollar($subscription['amount']); if (!$subscription['days'] && !$subscription['months'] && !$subscription['years']) { //echo _l('Once off'); } else { $bits = array(); if ($subscription['days'] > 0) { $bits[] = _l('%s days', $subscription['days']); } if ($subscription['months'] > 0) { $bits[] = _l('%s months', $subscription['months']); } if ($subscription['years'] > 0) { $bits[] = _l('%s years', $subscription['years']); } echo ' '; echo _l('Every %s', implode(', ', $bits));
} ?> </td> <td> <span class="currency"> <?php /* echo $invoice_payment_data['amount']>0 ? dollar($invoice_payment_data['amount'],true,$invoice['currency_id']) : dollar($invoice_payment_data['hours']*$invoice['hourly_rate'],true,$invoice['currency_id']); */ ?> <?php echo dollar($invoice_payment_data['amount'], true, $invoice_payment_data['currency_id']); // is there a fee? if ($invoice_payment_data['fee_total'] != 0) { echo ' '; _e('(includes %s %s)', dollar($invoice_payment_data['fee_total'], true, $invoice_payment_data['currency_id']), htmlspecialchars($invoice_payment_data['fee_description'])); } ?> </span> </td> <td> <?php if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) { $details = @unserialize($invoice_payment_data['data']); if ($details && isset($details['custom_notes'])) { echo htmlspecialchars($details['custom_notes']) . '<br>'; } if ($details && isset($details['log'])) { ?>
</td> <td> <?php echo $total['hours_billed']; ?> </td> <td> <?php echo dollar($total['amount_billed']); ?> </td> <td> <?php echo dollar($total['amount_invoiced']); ?> </td> </tr> </tfoot> </table> <ul> <li>Staff Members: users who have the "Job Tasks" - "edit" permission</li> <li>Assigned Jobs: number of jobs where job "Create Date" is within range and staff members is assigned to overall job</li> <li>Assigned Tasks: number of individual job tasks where job "Create Date" is within range and staff members is assigned to individual job task</li> <li>Tasks Completed: number of tasks that were assigned to this staff member and have a "done date" within specified range</li> <li>Hours Logged: how many hours were logged against all tasks (complete or not) within date range. Staff can log more (or less) hours than task was quoted.</li> <li>Hours Billed: how many hours were logged against all completed tasks.</li> <li>Amount Billed: value of the "hours billed" </li>
continue; } echo module_invoice::link_open($invoice['invoice_id'], true); echo " "; echo '<span class="'; if ($invoice['total_amount_due'] > 0) { echo 'error_text'; } else { echo 'success_text'; } echo '">'; if ($invoice['total_amount_due'] > 0) { echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']); echo ' ' . _l('due'); } else { echo _l('%s paid', dollar($invoice['total_amount'], true, $invoice['currency_id'])); } echo '</span>'; echo "<br>"; } } }); } } if (class_exists('module_group', false)) { $columns['group'] = array('title' => 'Group', 'callback' => function ($quote) { $groups = module_group::get_groups_search(array('owner_table' => 'quote', 'owner_id' => $quote['quote_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; }
$grand_total = round($grand_total); } // FORM FOR PAYPAL ?> <body onLoad="document.order_form.submit();"> <form action="https://www.paypal.com/cgi-bin/webscr" name="order_form" method="post"> <input type="hidden" name="cmd" value="_xclick"> <input type="hidden" name="business" value="<? echo $setting->paypal_email; ?>"> <input type="hidden" name="item_name" value="<? echo $setting->site_title;?> Photos - <? echo $_SESSION['visitor_id'] ; ?>"> <input type="hidden" name="item_number" value="<? echo $order_num; ?>"> <input type="hidden" name="amount" value="<? echo $grand_total; ?>"> <input type="hidden" name="return" value="<? echo $setting->site_url; ?>/download.php?order=<?php echo $order_num; ?>"> <input type="hidden" name="cancel_return" value="<? echo $setting->site_url; ?>"> <input type="hidden" name="tax" value="<? echo dollar($tax); ?>"> <input type="hidden" name="no_shipping" value="2"> <input type="hidden" name="shipping" value="<?php echo dollar($shipping); ?>"> <input type="hidden" name="no_note" value="1"> <input type="hidden" name="notify_url" value="<? echo $setting->site_url; ?>/paypal_ipn.php"> <input type="hidden" name="currency_code" value="<? echo $currency->code; ?>"> <!--<input type="hidden" name="currency_code" value="EUR"> EUROS--> <!--<input type="hidden" name="lc" value="US"> NOT USED--> </form> <?PHP echo $public_paypal_redirect; ?> <? break; case "purchase3": //ADDED IN PS350 FOR EXTRA SECURITY if($setting->force_members == 1 && !$_SESSION['sub_member']){ echo $order_error_no_login; exit;
<?php if ($recurring['type'] == 'i') { $balance += $recurring['amount']; ?> <span class="success_text">+<?php echo dollar($recurring['amount'], true, $recurring['currency_id']); ?> </span><?php } ?> </td> <td> <?php if ($recurring['type'] == 'e') { $balance -= $recurring['amount']; ?> <span class="error_text">-<?php echo dollar($recurring['amount'], true, $recurring['currency_id']); ?> </span><?php } ?> </td> </tr> <?php } ?> </tbody> </table> <!-- end -->
public function process() { $errors = array(); if ($_REQUEST['_process'] == 'make_payment') { $this->handle_payment(); } else { if (isset($_REQUEST['butt_del']) && $_REQUEST['butt_del'] && $_REQUEST['invoice_id'] && module_invoice::can_i('delete', 'Invoices')) { $data = self::get_invoice($_REQUEST['invoice_id']); if (module_form::confirm_delete('invoice_id', _l("Really delete invoice: %s", htmlspecialchars($data['name'])), self::link_open($_REQUEST['invoice_id']))) { $invoice_data = self::get_invoice($_REQUEST['invoice_id'], true); $this->delete_invoice($_REQUEST['invoice_id']); set_message("Invoice deleted successfully"); if (isset($invoice_data['job_ids']) && $invoice_data['job_ids']) { redirect_browser(module_job::link_open(current($invoice_data['job_ids']))); } else { redirect_browser(self::link_open(false)); } } } else { if ("assign_credit_to_customer" == $_REQUEST['_process']) { $invoice_id = (int) $_REQUEST['invoice_id']; if ($invoice_id > 0) { $invoice_data = $this->get_invoice($invoice_id); $credit = $invoice_data['total_amount_credit']; if ($credit > 0) { if ($invoice_data['customer_id']) { // assign to customer. module_customer::add_credit($invoice_data['customer_id'], $credit); // assign this as a negative payment, and also give it to the customer account. $this->add_history($invoice_id, 'Added ' . dollar($credit) . ' credit to customers account from this invoice overpayment'); update_insert('invoice_payment_id', 'new', 'invoice_payment', array('invoice_id' => $invoice_id, 'amount' => -$credit, 'payment_type' => _INVOICE_PAYMENT_TYPE_OVERPAYMENT_CREDIT, 'currency_id' => $invoice_data['currency_id'], 'method' => _l('Assigning Credit'), 'date_paid' => date('Y-m-d'))); module_cache::clear('invoice'); } } redirect_browser($this->link_open($invoice_id)); } } else { if ("save_invoice" == $_REQUEST['_process']) { $invoice_id = isset($_REQUEST['invoice_id']) ? (int) $_REQUEST['invoice_id'] : false; // check the user has permissions to edit this page. if ($invoice_id > 0) { $invoice = $this->get_invoice($invoice_id); if (!module_security::can_access_data('invoice', $invoice, $invoice_id)) { echo 'Data access denied. Sorry.'; exit; } } if (!$this->can_i('edit', 'Invoices')) { // bug fix, customer making a payment displays this edit access denied. if (isset($_REQUEST['butt_makepayment']) && $_REQUEST['butt_makepayment'] == 'yes') { //redirect_browser(self::link_public_pay($invoice_id)); self::handle_payment(); return; } else { echo 'Edit access denied. Sorry.'; exit; } } $data = $_POST; if (isset($data['default_renew_auto']) && !isset($data['renew_auto'])) { $data['renew_auto'] = 0; } if (isset($data['default_renew_email']) && !isset($data['renew_email'])) { $data['renew_email'] = 0; } if (isset($data['default_overdue_email_auto']) && !isset($data['overdue_email_auto'])) { $data['overdue_email_auto'] = 0; } if (isset($data['set_manual_company_id'])) { $data['company_id'] = $data['set_manual_company_id']; } if (isset($data['customer_id']) && $data['customer_id'] && (!isset($data['user_id']) || !$data['user_id'])) { // find the primary contact for this invoice and set that there? // no - we don't! we leave it as blank so we can update the customer primary contact when needed. /* $customer_data = module_customer::get_customer($data['customer_id']); if($customer_data && $customer_data['customer_id'] == $data['customer_id']){ if($customer_data['primary_user_id']){ $data['user_id'] = $customer_data['primary_user_id']; }else{ $customer_contacts = module_user::get_contacts(array('customer_id'=>$data['customer_id'])); foreach($customer_contacts as $contact){ // todo - search roles or something to find the accountant. $data['user_id'] = $contact['user_id']; break; } } }*/ } // check for credit assessment. if (isset($_POST['apply_credit_from_customer']) && $_POST['apply_credit_from_customer'] == 'do') { $invoice_data = $this->get_invoice($invoice_id); $customer_data = module_customer::get_customer($invoice_data['customer_id']); if ($customer_data['credit'] > 0) { $apply_credit = min($invoice_data['total_amount_due'], $customer_data['credit']); //$invoice_data['discount_amount'] += $customer_data['credit']; //$this->save_invoice($invoice_id,array('discount_amount'=>$invoice_data['discount_amount'],'discount_description'=>_l('Credit:'))); update_insert('invoice_payment_id', false, 'invoice_payment', array('invoice_id' => $invoice_id, 'payment_type' => _INVOICE_PAYMENT_TYPE_CREDIT, 'method' => _l('Credit'), 'amount' => $apply_credit, 'currency_id' => $invoice_data['currency_id'], 'other_id' => $invoice_data['customer_id'], 'date_paid' => date('Y-m-d'))); $this->add_history($invoice_id, _l('Applying %s customer credit to this invoice.', dollar($apply_credit))); module_cache::clear('invoice'); module_customer::remove_credit($customer_data['customer_id'], $apply_credit); } } // check for subsscription credit assessment. if (isset($_POST['apply_credit_from_subscription_bucket']) && $_POST['apply_credit_from_subscription_bucket'] == 'do' && (int) $_POST['apply_credit_from_subscription_id'] > 0) { $invoice_data = $this->get_invoice($invoice_id); $subscription_owner = module_subscription::get_subscription_owner($_POST['apply_credit_from_subscription_id']); $available_subscription_credit = module_subscription::get_available_credit($subscription_owner['owner_table'], $subscription_owner['owner_id']); //print_r($subscription_owner); print_r($available_subscription_credit);exit; if ($subscription_owner['subscription_owner_id'] && $available_subscription_credit[$subscription_owner['subscription_id']]['remain'] > 0) { $apply_credit = min($invoice_data['total_amount_due'], $available_subscription_credit[$subscription_owner['subscription_id']]['remain']); //$invoice_data['discount_amount'] += $customer_data['credit']; //$this->save_invoice($invoice_id,array('discount_amount'=>$invoice_data['discount_amount'],'discount_description'=>_l('Credit:'))); update_insert('invoice_payment_id', false, 'invoice_payment', array('invoice_id' => $invoice_id, 'payment_type' => _INVOICE_PAYMENT_TYPE_SUBSCRIPTION_CREDIT, 'method' => _l('Credit'), 'amount' => $apply_credit, 'currency_id' => $invoice_data['currency_id'], 'other_id' => $subscription_owner['subscription_owner_id'], 'date_paid' => date('Y-m-d'))); $this->add_history($invoice_id, _l('Applying %s subscription credit to this invoice.', dollar($apply_credit))); module_cache::clear('invoice'); } } $invoice_id = $this->save_invoice($invoice_id, $data); if (isset($_REQUEST['allowed_payment_method_check'])) { // todo - ability to disable ALL payment methods. - array wont be set if none are ticked $payment_methods = handle_hook('get_payment_methods'); foreach ($payment_methods as &$payment_method) { if ($payment_method->is_enabled()) { // is this one already enabled for this invoice? //$is_already_allowed = $payment_method->is_allowed_for_invoice($invoice_id); if (isset($_REQUEST['allowed_payment_method']) && isset($_REQUEST['allowed_payment_method'][$payment_method->module_name])) { $payment_method->set_allowed_for_invoice($invoice_id, 1); } else { $payment_method->set_allowed_for_invoice($invoice_id, 0); } } } } // check if we are generating any renewals if (isset($_REQUEST['generate_renewal']) && $_REQUEST['generate_renewal'] > 0) { $new_invoice_id = $this->renew_invoice($invoice_id); if ($new_invoice_id) { set_message("Invoice renewed successfully"); redirect_browser(module_invoice::link_open($new_invoice_id, false)); } else { } } if (isset($_REQUEST['butt_makepayment']) && $_REQUEST['butt_makepayment'] == 'yes') { //redirect_browser(self::link_public_pay($invoice_id)); self::handle_payment(); } else { if (isset($_REQUEST['butt_print']) && $_REQUEST['butt_print']) { $_REQUEST['_redirect'] = self::link_generate($invoice_id, array('arguments' => array('print' => 1))); } else { if (isset($_REQUEST['butt_merge']) && $_REQUEST['butt_merge'] && isset($_REQUEST['merge_invoice']) && is_array($_REQUEST['merge_invoice'])) { $merge_invoice_ids = self::check_invoice_merge($invoice_id); foreach ($merge_invoice_ids as $merge_invoice) { if (isset($_REQUEST['merge_invoice'][$merge_invoice['invoice_id']])) { // copy all the tasks from that invoice over to this invoice. $sql = "UPDATE `" . _DB_PREFIX . "invoice_item` SET invoice_id = " . (int) $invoice_id . " WHERE invoice_id = " . (int) $merge_invoice['invoice_id'] . " "; query($sql); $this->delete_invoice($merge_invoice['invoice_id']); } } $_REQUEST['_redirect'] = $this->link_open($invoice_id); set_message('Invoices merged successfully'); } else { if (isset($_REQUEST['butt_email']) && $_REQUEST['butt_email']) { $_REQUEST['_redirect'] = self::link_generate($invoice_id, array('arguments' => array('email' => 1))); } else { if (isset($_REQUEST['butt_generate_credit']) && $_REQUEST['butt_generate_credit']) { // generate a credit note against this invioce. // to do this we duplicate the invoice, remove the cancel date, remove the sent date, // set a new create date, set the credit_note_id variable, remove the paid date, // (copied from the generate renewal code above) $invoice = $this->get_invoice($invoice_id); unset($invoice['invoice_id']); unset($invoice['date_renew']); unset($invoice['date_sent']); unset($invoice['date_paid']); unset($invoice['date_cancel']); unset($invoice['renew_invoice_id']); unset($invoice['deposit_job_id']); $invoice['name'] = self::new_invoice_number($invoice['customer_id']); $invoice['credit_note_id'] = $invoice_id; $invoice['date_create'] = date('Y-m-d'); $invoice['discount_amount'] = 0; $invoice['discount_description'] = _l('Discount:'); $invoice['discount_type'] = module_config::c('invoice_discount_type', _DISCOUNT_TYPE_BEFORE_TAX); // 1 = After Tax $invoice['tax_type'] = module_config::c('invoice_tax_type', 0); $invoice['date_due'] = false; $invoice['status'] = module_config::s('invoice_status_default', 'New'); $new_invoice_id = $this->save_invoice('new', $invoice); if ($new_invoice_id) { // now we create the tasks $tasks = $this->get_invoice_items($invoice_id, $invoice); foreach ($tasks as $task) { unset($task['invoice_item_id']); if ($task['custom_description']) { $task['description'] = $task['custom_description']; } if ($task['custom_long_description']) { $task['long_description'] = $task['custom_long_description']; } $task['invoice_id'] = $new_invoice_id; $task['date_done'] = $invoice['date_create']; update_insert('invoice_item_id', 'new', 'invoice_item', $task); } set_message("Credit note generated successfully"); module_cache::clear('invoice'); redirect_browser($this->link_open($new_invoice_id)); } else { set_error('Generating credit note failed'); redirect_browser($this->link_open($invoice_id)); } } else { $_REQUEST['_redirect'] = isset($_REQUEST['_redirect']) && !empty($_REQUEST['_redirect']) ? $_REQUEST['_redirect'] : $this->link_open($invoice_id); set_message("Invoice saved successfully"); } } } } } } } } } if (!count($errors)) { redirect_browser($_REQUEST['_redirect']); exit; } print_error($errors, true); }
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; } }
}); } if (class_exists('module_invoice', false) && module_invoice::can_i('view', 'Invoices') && module_config::c('customer_list_show_invoices', 1)) { $columns['customer_invoices'] = array('title' => 'Invoices', 'callback' => function ($customer) { $invoices = module_invoice::get_invoices(array('customer_id' => $customer['customer_id'])); if (count($invoices)) { $total_due = 0; $total_paid = 0; foreach ($invoices as $invoice) { $invoice = module_invoice::get_invoice($invoice['invoice_id']); $total_due += $invoice['total_amount_due']; $total_paid += $invoice['total_amount_paid']; } $old_customer_id = isset($_REQUEST['customer_id']) ? $_REQUEST['customer_id'] : false; $_REQUEST['customer_id'] = $customer['customer_id']; echo '<a href="' . module_invoice::link_open(false) . '">' . _l('%s invoice%s: %s', count($invoices), count($invoices) > 1 ? 's' : '', ($total_due > 0 ? '<span class="error_text">' . _l('%s due', dollar($total_due, true, $invoice['currency_id'])) . ' </span>' : '') . ($total_paid > 0 ? '<span class="success_text">' . _l('%s paid', dollar($total_paid, true, $invoice['currency_id'])) . ' </span>' : '')) . '</a>'; if ($old_customer_id) { $_REQUEST['customer_id'] = $old_customer_id; } else { unset($_REQUEST['customer_id']); } } }); } if (class_exists('module_extra', false)) { // do extra before "table sorting" so that it can hook in with the table sort call $table_manager->display_extra('customer', function ($customer) { module_extra::print_table_data('customer', $customer['customer_id']); }, 'customer_id'); $table_manager->display_extra('user', function ($customer) { module_extra::print_table_data('user', $customer['primary_user_id']);
// skip empty ones. } if (!isset($options['credit'])) { // we dont want to show credit items. if ($recent_transaction['credit'] > 0) { continue; } } if (!isset($options['debit'])) { // we dont want to show credit items. if ($recent_transaction['debit'] > 0) { continue; } } $time = strtotime($timezone_hours . ' hours', strtotime($recent_transaction['transaction_date'])); echo 'BEGIN:VEVENT UID:' . md5(mt_rand(1, 100)) . '@ultimateclientmanager.com '; if (strlen($recent_transaction['name'])) { $recent_transaction['name'] = '(' . $recent_transaction['name'] . ")"; } // work out the UTC time for this event, based on the timezome we have set in the configuration options echo 'DTSTAMP:' . date('Ymd') . 'T090000Z DTSTART;VALUE=DATE:' . date('Ymd', $time) . ' DTEND;VALUE=DATE:' . date('Ymd', strtotime('+1 day', $time)) . ' SUMMARY:' . ($recent_transaction['credit'] > 0 ? '+' . dollar($recent_transaction['credit']) : '') . ($recent_transaction['debit'] > 0 ? '-' . dollar($recent_transaction['debit']) : '') . " " . $recent_transaction['name'] . ' DESCRIPTION:' . preg_replace('#[\\r\\n]+#', '<br>', $recent_transaction['description']) . ' <br><a href="' . $recent_transaction['url'] . '">' . _('Open Link') . '</a> END:VEVENT '; } echo 'END:VCALENDAR';
?> <input type="checkbox" name="finance_category_new_checked" value="new"> <input type="text" name="finance_category_new" value=""> </div> <?php $header_cats = ob_get_clean(); $header_rows[] = array('sort_date' => array('data' => '<input type="text" name="transaction_date" class="date_field" value="' . print_date(time()) . '"> '), 'sort_name' => array('data' => '<input type="text" name="name" id="new_transaction_name">'), 'finance_description' => array('data' => '<input type="text" name="description">'), 'finance_customer' => array('data' => ''), 'sort_credit' => array('data' => currency('') . '<input type="text" name="credit" class="currency">', 'cell_class' => 'success_text'), 'sort_debit' => array('data' => currency('') . '<input type="text" name="debit" class="currency">', 'cell_class' => 'error_text'), 'sort_account' => array('data' => print_select_box(module_finance::get_accounts(), 'finance_account_id', '', '', true, 'name', true)), 'finance_categories' => array('data' => $header_cats), 'finance_tick' => array('data' => '<input type="submit" name="addnew" value="' . _l('Quick Add') . '" class="small_button">')); $table_manager->set_header_rows($header_rows); } $table_manager->set_rows($recent_transactions); if (module_config::c('finance_list_show_totals', 1)) { $footer_rows = array(); foreach ($finance_credit_total + $finance_debit_total as $currency_id => $foo) { $currency = get_single('currency', 'currency_id', $currency_id); $footer_rows[] = array('sort_date' => array('data' => ' ', 'cell_colspan' => 3), 'finance_customer' => array('data' => '<strong>' . _l('%s Totals:', $currency && isset($currency['code']) ? $currency['code'] : '') . '</strong>', 'cell_class' => 'text-right'), 'sort_credit' => array('data' => '<strong>' . dollar(isset($finance_credit_total[$currency_id]) ? $finance_credit_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'sort_debit' => array('data' => '<strong>' . dollar(isset($finance_debit_total[$currency_id]) ? $finance_debit_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'sort_account' => array('data' => ' ', 'cell_colspan' => 4)); } $footer_rows[] = array('sort_date' => array('data' => ' ', 'cell_colspan' => 8), 'finance_tick' => array('data' => '<input type="button" name="link" value="' . _l('Link') . '" class="small_button" onclick="$(\'#link_go\').val(\'go\'); $(\'#quick_add_form\')[0].submit();"> <input type="hidden" name="link_go" value="0" id="link_go"> ' . _hr('Combine transactions together. eg: an invoice payment history with corresponding bank statement transaction. Transactions need to be the same dollar amount to link successfully.'), 'cell_colspan' => 4)); $table_manager->set_footer_rows($footer_rows); } $table_manager->pagination = true; $table_manager->print_table(); ?> </form> <?php if ($show_excluded_payment_info) { ?>
$row_replace['item_amount_or_rate'] = dollar($quote_item_data['task_hourly_rate'], true, $quote['currency_id'], $task_decimal_places_trim, $task_decimal_places); } else { $row_replace['item_amount_or_rate'] = '-'; } $row_replace['item_total'] = dollar($quote_item_data['quote_item_amount'], true, $quote['currency_id']); // taxes per item if (isset($quote_item_data['taxes']) && is_array($quote_item_data['taxes']) && $quote_item_data['taxable'] && class_exists('module_finance', false)) { // this passes off the tax calculation to the 'finance' class, which modifies 'amount' to match the amount of tax applied here. $this_taxes = module_finance::sanatise_taxes($quote_item_data['taxes'], $quote_item_data['quote_item_amount']); $this_taxes_amounts = array(); $this_taxes_rates = array(); if (!count($this_taxes)) { $this_taxes = array('amount' => 0, 'percent' => 0); } foreach ($this_taxes as $this_tax) { $this_taxes_amounts[] = dollar($this_tax['amount'], true, $quote['currency_id']); $this_taxes_rates[] = $this_tax['percent'] . '%'; } $row_replace['item_tax'] = implode(', ', $this_taxes_amounts); $row_replace['item_tax_rate'] = implode(', ', $this_taxes_rates); } $this_item_row_html = $item_row_html; $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html); // we pass this through the template system so we can make use of things like arithmatic. $temp_template = new module_template(); $temp_template->assign_values($row_replace); $temp_template->content = $this_item_row_html; $this_item_row_html = $temp_template->replace_content(); /*foreach($row_replace as $key=>$val){ $this_item_row_html = str_replace('{'.strtoupper($key).'}', $val, $this_item_row_html); }*/
echo module_customer::link_open($ticket['customer_id'], true); }); } $columns['ticket_contact'] = array('title' => 'Contact', 'callback' => function ($ticket) { echo module_user::link_open($ticket['user_id'], true, array(), true); }); if (class_exists('module_faq', false) && module_config::c('ticket_show_product_list', 1)) { $columns['ticket_product'] = array('title' => 'Product', 'callback' => function ($ticket) { if ($ticket['faq_product_id']) { $faq_product = module_faq::get_faq_product($ticket['faq_product_id']); echo $faq_product && isset($faq_product['name']) ? htmlspecialchars($faq_product['name']) : ''; } }); } if (class_exists('module_envato', false)) { $columns['ticket_envato'] = array('title' => _l('Envato%s', module_config::c('envato_show_ticket_earning', 0) ? ' (' . dollar($envato_count * 0.7) . ')' : ''), 'callback' => function ($ticket) { $items = module_envato::get_items_by_ticket($ticket['ticket_id']); foreach ($items as $item) { echo '<a href="' . $item['url'] . '">' . htmlspecialchars($item['name']) . '</a> '; } }); } if (class_exists('module_group', false) && module_config::c('ticket_enable_groups', 1) && module_group::groups_enabled()) { $columns['ticket_group'] = array('title' => 'Group', 'callback' => function ($ticket) { // find the groups for this customer. $groups = module_group::get_groups_search(array('owner_table' => 'ticket', 'owner_id' => $ticket['ticket_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } echo implode(', ', $g);
public static function start_payment($invoice_id, $payment_amount, $invoice_payment_id, $user_id = false) { if ($invoice_id && $payment_amount && $invoice_payment_id) { // we are starting a payment via paypal! // setup a pending payment and redirect to paypal. $invoice_data = module_invoice::get_invoice($invoice_id); if (!$user_id) { $user_id = $invoice_data['user_id']; } if (!$user_id) { $user_id = isset($invoice_data['primary_user_id']) ? $invoice_data['primary_user_id'] : 0; } $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id); // we add the fee details to the invoice payment record so that the new invoice total can be calculated. $fee_percent = module_config::c('payment_method_paypal_charge_percent', 0); $fee_amount = module_config::c('payment_method_paypal_charge_amount', 0); $fee_description = module_config::c('payment_method_paypal_charge_description', 'PayPal Fee'); $fee_total = 0; if ($fee_percent != 0 || $fee_amount != 0) { $fee_total = module_invoice::calculate_fee($invoice_id, $invoice_data, $payment_amount, array('percent' => $fee_percent, 'amount' => $fee_amount, 'description' => $fee_description)); if ($fee_total != 0) { // add this percent/amount to the invoice payment $payment_amount = $payment_amount + $fee_total; update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('fee_percent' => $fee_percent, 'fee_amount' => $fee_amount, 'fee_description' => $fee_description, 'fee_total' => $fee_total, 'amount' => $payment_amount)); } } // we check if this payment is a recurring payment or a standard one off payment. if (module_config::c('payment_method_paypal_subscriptions', 0)) { // we support subscriptions! // first check if the subscription module is active, and if this invoice is part of an active subscription. $is_subscription = false; if (class_exists('module_subscription', false)) { $subscription_history = get_single('subscription_history', 'invoice_id', $invoice_id); if ($subscription_history && $subscription_history['subscription_id']) { // this invoice is for a subscription! woo! // work out when we should bill for this subscription. $subscription = module_subscription::get_subscription($subscription_history['subscription_id']); $subscription_owner = module_subscription::get_subscription_owner($subscription_history['subscription_owner_id']); if ($subscription_owner['owner_table'] && $subscription_owner['owner_id']) { // work out when the next invoice will be generated for this subscription. $members_subscriptions = module_subscription::get_subscriptions_by($subscription_owner['owner_table'], $subscription_owner['owner_id']); if (isset($members_subscriptions[$subscription_history['subscription_id']])) { $member_subscription = $members_subscriptions[$subscription_history['subscription_id']]; // everything checks out! good to go.... // for now we just do a basic "EVERY X TIME" subscription // todo: work out how long until next generate date, and set that (possibly smaller) time period as the first portion of the subscription /*echo '<pre>'; print_r($subscription_history); print_r($subscription); print_r($subscription_owner); print_r($member_subscription); exit;*/ $is_subscription = array(); if ($subscription['days'] > 0) { $is_subscription['days'] = $subscription['days']; } if ($subscription['months'] > 0) { $is_subscription['months'] = $subscription['months']; } if ($subscription['years'] > 0) { $is_subscription['years'] = $subscription['years']; } if (count($is_subscription)) { $is_subscription['name'] = $subscription['name']; } } } } } // todo: check if this invoice has a manual renewal date, perform subscription feature as above. if ($is_subscription) { $bits = array(); if (isset($is_subscription['days']) && $is_subscription['days'] > 0) { $bits[] = _l('%s days', $is_subscription['days']); } if (isset($is_subscription['months']) && $is_subscription['months'] > 0) { $bits[] = _l('%s months', $is_subscription['months']); } if (isset($is_subscription['years']) && $is_subscription['years'] > 0) { $bits[] = _l('%s years', $is_subscription['years']); } $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id); if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) { // existing subscription already! // not really sure what to do here, just redirect to paypal as if the user is doing it for the first time. $_REQUEST['payment_subscription'] = true; // hacks! } if (isset($_REQUEST['payment_subscription']) || module_config::c('payment_method_paypal_force_subscription', 0)) { // user is setting up a subscription! yes!! // we create an entry in our database for this particular subscription // or if one exists for this payment already then we just continue with that (ie: the user is going in again to redo it) // setup a new subscription in the database for us. if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) { $invoice_payment_subscription_id = $invoice_payment_data['invoice_payment_subscription_id']; } else { $invoice_payment_subscription_id = update_insert('invoice_payment_subscription_id', false, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_PENDING, 'days' => isset($is_subscription['days']) ? $is_subscription['days'] : 0, 'months' => isset($is_subscription['months']) ? $is_subscription['months'] : 0, 'years' => isset($is_subscription['years']) ? $is_subscription['years'] : 0, 'date_start' => '0000-00-00', 'date_last_pay' => '0000-00-00', 'date_next' => '0000-00-00')); update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('invoice_payment_subscription_id' => $invoice_payment_subscription_id)); } $description = _l('Recurring payment for %s every %s', $is_subscription['name'], implode(', ', $bits)); unset($is_subscription['name']); // so reset/key cals below rosk. $currency = module_config::get_currency($invoice_payment_data['currency_id']); $url = 'https://www.' . (self::is_sandbox() ? 'sandbox.' : '') . 'paypal.com/cgi-bin/webscr?'; // if there are more than 1 recurring amounts then we convert it to days, as paypal only supports one time period. if (count($is_subscription) > 1) { $days = isset($is_subscription['days']) ? $is_subscription['days'] : 0; if (isset($is_subscription['months'])) { $days += $is_subscription['months'] * 30; unset($is_subscription['months']); } if (isset($is_subscription['years'])) { $days += $is_subscription['years'] * 365; unset($is_subscription['years']); } $is_subscription['days'] = $days; } reset($is_subscription); $time = key($is_subscription); if ($time == 'days') { $time = 'D'; } else { if ($time == 'months') { $time = 'M'; } else { if ($time == 'years') { $time = 'Y'; } } } $fields = array('cmd' => '_xclick-subscriptions', 'business' => module_config::c('payment_method_paypal_email', _ERROR_EMAIL), 'currency_code' => $currency['code'], 'item_name' => $description, 'no_shipping' => 1, 'page_style' => module_config::c('paypal_page_style', ''), 'return' => module_invoice::link_public_payment_complete($invoice_id), 'rm' => 1, 'cancel_return' => module_invoice::link_public($invoice_id), 'notify_url' => full_link(_EXTERNAL_TUNNEL . '?m=paymethod_paypal&h=ipn&method=paypal'), 'custom' => self::paypal_custom($user_id, $invoice_payment_id, $invoice_id, $invoice_payment_subscription_id), 'a3' => $payment_amount, 'p3' => current($is_subscription), 't3' => $time, 'src' => 1, 'sra' => 1, 'no_note' => 1); // is there a subscription trail period if (isset($subscription['settings']['trial_period']) && $subscription['settings']['trial_period'] > 0) { // we have to hacck the payment_amount here. // $payment_amount will be the discounted amount (eg: $5 instead of $10) // so we reverse that discounted amount for the real amount. $real_amount = $payment_amount - $fee_amount - (isset($subscription['settings']['trial_price_adjust']) ? $subscription['settings']['trial_price_adjust'] : 0); $real_fee_total = module_invoice::calculate_fee($invoice_id, $invoice_data, $real_amount, array('percent' => $fee_percent, 'amount' => $fee_amount, 'description' => $fee_description)); $real_amount += $real_fee_total; $fields['a3'] = $real_amount; $fields['a1'] = $payment_amount; // $real_amount + (isset($subscription['settings']['trial_price_adjust']) ? $subscription['settings']['trial_price_adjust'] : 0); $fields['p1'] = current($is_subscription); // * $subscription['settings']['trial_period']; $fields['t1'] = $time; } //echo '<pre>'; print_r($fields);exit; foreach ($fields as $key => $val) { $url .= $key . '=' . urlencode($val) . '&'; } //echo '<a href="'.$url.'">'.$url.'</a>';exit; redirect_browser($url); } else { if (isset($_REQUEST['payment_single'])) { // use is choosing to continue payment as a once off amount } else { // give the user an option module_template::init_template('invoice_payment_subscription', '<h2>Payment for Invoice {INVOICE_NUMBER}</h2> <p>Please choose from the available payment options below:</p> <form action="{PAYMENT_URL}" method="post"> <input type="hidden" name="invoice_payment_id" value="{INVOICE_PAYMENT_ID}"> <input type="hidden" name="payment_method" value="{PAYMENT_METHOD}"> <input type="hidden" name="payment_amount" value="{PAYMENT_AMOUNT}"> <p><input type="submit" name="payment_single" value="Pay a Once Off amount of {PRETTY_PAYMENT_AMOUNT}"></p> <p><input type="submit" name="payment_subscription" value="Setup Automatic Payments of {PRETTY_PAYMENT_AMOUNT} every {SUBSCRIPTION_PERIOD}"></p> </form> ', 'Used when a customer tries to pay an invoice that has a subscription option.', 'code'); $template = module_template::get_template_by_key('invoice_payment_subscription'); $template->page_title = htmlspecialchars($invoice_data['name']); $template->assign_values($invoice_payment_data); $template->assign_values(module_invoice::get_replace_fields($invoice_data['invoice_id'], $invoice_data)); $template->assign_values(array('invoice_payment_id' => $invoice_payment_id, 'payment_url' => module_invoice::link_public_pay($invoice_data['invoice_id']), 'payment_method' => 'paymethod_paypal', 'payment_amount' => $payment_amount, 'pretty_payment_amount' => dollar($payment_amount, true, $invoice_data['currency_id']), 'subscription_period' => implode(', ', $bits), 'fee_amount' => dollar($fee_amount, true, $invoice_data['currency_id']), 'fee_total' => dollar($fee_total, true, $invoice_data['currency_id']), 'fee_percent' => $fee_percent, 'fee_description' => $fee_description)); echo $template->render('pretty_html'); exit; } } } } $description = _l('Payment for Invoice %s', $invoice_data['name']); self::paypal_redirect($description, $payment_amount, $user_id, $invoice_payment_id, $invoice_id, $invoice_payment_data['currency_id']); return true; } return false; }
" value="1"></td> <td></td> </tr> <?php } ?> <tr> <td align="center" bgcolor="#89A6DB"><b> </b></td> <td align="center" bgcolor="#89A6DB"><b> </b></td> <td align="Center" bgcolor="#89A6DB"><b> </b></td> <td align="Center" bgcolor="#89A6DB"><?php echo $photog_d_unpaid_title; ?> <b><?php echo $currency->sign; echo dollar($unpaid2); ?> </b></td> <td align="Center" bgcolor="#89A6DB"><td align="Center" bgcolor="#89A6DB"><input type="checkbox" name="checkall" onclick="checkUncheckAll(this);"/></td> <td align="Center" bgcolor="#89A6DB"><?php echo $photog_u_upload_title; ?> <br><b><?php echo $photog2_rows; ?> </b></td> </tr> <tr> <td colspan="11" align="right"><a href="javascript:mark_hide_upload();"><img src="images/hide_all.gif" border="0"></a> <a href="javascript:mark_paid_upload();"><img src="images/mgr_button_mark_paid_sel.gif" border="0"></a> <a href="javascript:delete_upload_data();"><img src="images/delete_all.gif" border="0"></a></td> </tr> </form>
echo "<br>"; echo "Photo ID: <a href=\"" . $setting->site_url . "/details.php?pid=" . $pg->reference_id . "\" target=\"_blank\" class=\"title_links\">" . $pg->reference_id . "</a><br>"; echo "Filename: " . $pg->filename . " | <a href=\"../download_file2.php?pid=" . $pg->id . "\"><font color=\"#ffffff\">Download Photo</font></a>"; echo "<br>"; if($print->bypass == 1){ echo "PICKUP ITEM! In store pickup required.<br>"; } ?> <!--<font color="#A4A4A4"><a href="details.php?gid=<? echo $_GET['gid']; ?>&sgid=<? echo $_GET['sgid']; ?>&pid=<? echo $cart->photo_id; ?>" class="photo_links">Details</a> | <a href="public_actions.php?pmode=delete_cart&gid=<? echo $_GET['gid']; ?>&sgid=<? echo $_GET['sgid']; ?>&cid=<? echo $cart->id; ?>" class="photo_links">Remove From Cart</a>--> </td> <td valign="top" align="left" style="padding-left: 10px;"> Quantity: <?php echo $cart->quantity; ?><br> <? $qtotal= $cart->price * $cart->quantity; ?> Total: <? echo $currency->sign; ?><? echo dollar($qtotal); ?> </td> </form> </tr> </table> </td> <? } } ?> </tr> </table> </span> </td> </tr> <?
} ?> </td> </tr> <tr> <th> <?php _e('Payment Amount'); ?> </th> <td> <?php if (module_config::c('invoice_allow_payment_amount_adjustment', 1)) { echo currency('<input type="text" name="payment_amount" value="' . number_out($invoice['total_amount_due']) . '" class="currency">', true, $invoice['currency_id']); } else { echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']); echo '<input type="hidden" name="payment_amount" value="' . number_out($invoice['total_amount_due']) . '">'; } ?> </td> </tr> <tr> <td> </td> <td> <input type="submit" name="pay" value="<?php _e('Make Payment'); ?> " class="submit_button save_button"> </td> </tr>
public function replace_content() { $content = $this->content; $this->add_tags($this->template_key, $this->values); // add todays date values if (!isset($this->values['day'])) { $this->values['day'] = date('d'); } if (!isset($this->values['month'])) { $this->values['month'] = date('m'); } if (!isset($this->values['year'])) { $this->values['year'] = date('y'); } if (!isset($this->values['current_user']) && module_security::is_logged_in()) { $this->values['current_user'] = module_security::get_loggedin_id(); $user_details = module_user::get_replace_fields(module_security::get_loggedin_id()); foreach ($user_details as $key => $val) { $this->values['current_' . $key . ''] = $val; } } // basic conditional tags - eg: {if:name}Dear {name},{else:name}Hello,{endif:name} // todo - support nested if - pass to template module. $debug = false; if (preg_match_all('#\\{if:([^\\}=]+)([^\\}]*)\\}(.*){endif:\\1\\}.*#imsU', $content, $matches)) { foreach ($matches[1] as $key => $template_tag) { // does this first if have a conditional statement (eg: {if:STATUS=New}sdfasdf{else}asdfasdf{/if:STATUS} $bits = preg_split('#{else[^\\}]*}#', $matches[3][$key]); preg_match_all('#\\{(else)?(if:([^\\}=]+)([^\\}]*))?\\}#ims', $matches[0][$key], $elseif_matches); $new_content = false; if ($debug) { echo $matches[0][$key] . "\n"; } if ($debug) { print_r($bits); } if ($debug) { print_r($elseif_matches); } foreach ($elseif_matches[0] as $elseif_key => $elseif_condition) { $template_tag_value = isset($this->values[strtolower($elseif_matches[3][$elseif_key])]) ? trim($this->values[strtolower($elseif_matches[3][$elseif_key])]) : ''; if (!strlen(trim($elseif_matches[3][$elseif_key]))) { // we are at the final {else} statement, this means all other checks before have failed. we use this content. if ($debug) { echo "Reached final {else} statement, using this value\n"; } $new_content = $bits[$elseif_key]; break; } else { if ($debug) { echo "Checking {$elseif_condition} against " . $elseif_matches[3][$elseif_key] . " which has the value: " . $template_tag_value . "\n"; } if (strlen($elseif_matches[4][$elseif_key]) && $elseif_matches[4][$elseif_key][0] == '=') { // the if/elseif tag is checking a condition, rather than just an "does exist" check $check_matching_value = ltrim(trim($elseif_matches[4][$elseif_key]), '='); if ($debug) { echo "Checking if it matches {$check_matching_value} \n"; } if ($check_matching_value == $template_tag_value) { if ($debug) { echo "YES WE HAVE A MATCH \n"; } // this first if statement matches this query! yes! // use its value in the final $new_content $new_content = $bits[$elseif_key]; break; } else { if ($debug) { echo "No match this time \n"; } } } else { // we're just checking if this value exists or not. if (strlen($template_tag_value) > 0 && $template_tag_value != '0000-00-00' && $template_tag_value != _l('N/A')) { // it's a match! $new_content = $bits[$elseif_key]; break; } else { // no match, move onto next bit. } } } } if ($debug) { echo "Final content to use will be: \n" . $new_content; } $content = str_replace($matches[0][$key], $new_content, $content); } } foreach ($this->values as $key => $val) { if (is_array($val)) { continue; } // if this isn't a html field we add newlines. if (!preg_match('#<[^>]+>#', $val)) { // raw text. nl2br $val = nl2br($val); } $content = str_replace('{' . strtoupper($key) . '}', $val, $content); // we perform some basic arithmetic on some replace fields. if (preg_match_all('#\\{(currency:)?' . preg_quote(strtoupper($key), '#') . '([*+-])([\\d\\.]+)\\}#', $content, $matches)) { // pull the "number" portion out of this string for math processing. // string could look like this: "$150.10 USD" $mathval = $originalval = $val; if (preg_match('#([\\d.,]+)#', $val, $mathvalmatches)) { $mathval = $originalval = $mathvalmatches[1]; } foreach ($matches[0] as $i => $v) { $mathval = $originalval; if ($matches[2][$i] == '-') { $mathval = $mathval - $matches[3][$i]; } else { if ($matches[2][$i] == '+') { $mathval = $mathval + $matches[3][$i]; } else { if ($matches[2][$i] == '*') { $mathval = $mathval * $matches[3][$i]; } } } if (strtolower($matches[1][$i]) == 'currency:') { $mathval = dollar($mathval, true, isset($this->values['currency_id']) ? $this->values['currency_id'] : false); } $newval = str_replace($originalval, $mathval, $val); $content = str_replace($v, $newval, $content); } } if (preg_match_all('#\\{currency:(' . preg_quote(strtoupper($key), '#') . ')\\}#', $content, $matches)) { foreach ($matches[0] as $i => $v) { $content = str_replace($v, dollar($val, true, isset($this->values['currency_id']) ? $this->values['currency_id'] : false), $content); } } // we perform some arithmetic on date fields. $matches = false; if (stripos($key, 'date') !== false && $val && strlen($val) > 6 && preg_match_all('#' . preg_quote('{' . strtoupper($key), '#') . '((?>[+-]\\d+[ymd])*)\\}#', $content, $matches)) { //$processed_date = (input_date($val)); $processed_date_timeo = $processed_date_time = strtotime(input_date($val)); foreach ($matches[0] as $i => $v) { if (preg_match_all('#([+-])(\\d+)([ymd])#', $matches[1][$i], $date_math)) { foreach ($date_math[1] as $di => $dv) { $period = $date_math[3][$di]; $period = $period == 'd' ? 'day' : ($period == 'm' ? 'month' : ($period == 'y' ? 'year' : 'days')); //echo $dv.$date_math[2][$di]." ".$period."\n"; $processed_date_time = strtotime($dv . $date_math[2][$di] . " " . $period, $processed_date_time); } $content = str_replace($v, print_date($processed_date_time), $content); //echo "Processing date: $val - $processed_date (time: $processed_date_timeo / ".print_date($processed_date_timeo).") with result of: ".print_date($processed_date_time); exit; } } } // we perform some date splitting $matches = false; if (stripos($key, 'date') !== false && $val && strlen($val) > 6 && preg_match_all('#' . preg_quote('{' . strtoupper($key), '#') . '-([ymdYMDjlSWFn])\\}#', $content, $matches)) { $processed_date_time = strtotime(input_date($val)); foreach ($matches[0] as $i => $v) { $content = str_replace($v, date($matches[1][$i], $processed_date_time), $content); } } //$val = str_replace(array('\\', '$'), array('\\\\', '\$'), $val); //$content = preg_replace('/\{'.strtoupper(preg_quote($key,'/')).'\}/',$val,$content); } if (preg_match_all('#\\{l:([^\\}]+)\\}#', $content, $matches)) { foreach ($matches[1] as $key => $label) { $content = str_replace($matches[0][$key], _l($label), $content); } } return $content; }
_h('The default is hourly rate + amount. This will show the "Hours" column along with an "Amount" column. Inputing a number of hours will auto complete the price based on the job hourly rate. <br>Quantity and Amount will allow you to input a Quantity (eg: 2) and an Amount (eg: $100) and the final price will be $200 (Quantity x Amount). The last option "Amount Only" will just have the amount column for manual input of price. Change the advanced setting "default_task_type" between 0, 1 and 2 to change the default here.'); ?> </td> </tr> <tr> <th> <?php _e('Discount Amount'); ?> </th> <td> <?php echo !module_security::is_page_editable() ? '<span class="currency">' . dollar($job['discount_amount'], true, $job['currency_id']) . '</span>' : currency('<input type="text" name="discount_amount" value="' . number_out($job['discount_amount']) . '" class="currency">'); ?> <?php _h('Here you can apply a before tax discount to this job. You can name this anything, eg: DISCOUNT, CREDIT, REFUND, etc..'); ?> </td> </tr> <tr> <th> <?php _e('Discount Name'); ?> </th>
<?php echo dollar($invoice['total_amount'], true, $invoice['currency_id']); ?> </td> <td> <?php echo dollar($invoice['total_amount_due'], true, $invoice['currency_id']); ?> <?php if ($invoice['total_amount_credit'] > 0) { ?> <span class="success_text"><?php echo _l('Credit: %s', dollar($invoice['total_amount_credit'], true, $invoice['currency_id'])); ?> </span> <?php } ?> </td> </tr> <?php } ?> </tbody> </table> <?php
if ($full_amount != $task_data[$hours_prefix . 'amount']) { echo '<br/>(' . dollar($full_amount, true, $job['currency_id']) . ')'; } } ?> </span> <?php if ($show_split_hours) { echo '<br/><span class="currency">'; echo $task_data['staff_amount'] != 0 ? dollar($task_data['staff_amount'], true, $job['currency_id']) : dollar($task_data['staff_hours'] * $job['staff_hourly_rate'], true, $job['currency_id']); ?> <?php if ($task_data['manual_task_type'] == _TASK_TYPE_QTY_AMOUNT) { $full_amount = $task_data['staff_hours'] * $task_data['staff_amount']; if ($full_amount != $task_data['staff_amount']) { echo '<br/>(' . dollar($full_amount, true, $job['currency_id']) . ')'; } } echo '</span>'; } ?> </td> <?php } ?> <?php if (module_config::c('job_show_due_date', 1)) { ?> <td valign="top" class="task_drag_handle"> <?php if ($task_data['date_due'] && $task_data['date_due'] != '0000-00-00') {
public static function start_payment($invoice_id, $payment_amount, $invoice_payment_id, $user_id = false) { if ($invoice_id && $payment_amount && $invoice_payment_id) { // we are starting a payment via coinbase! // setup a pending payment and redirect to coinbase. $invoice_data = module_invoice::get_invoice($invoice_id); if (!$user_id) { $user_id = $invoice_data['user_id']; } if (!$user_id) { $user_id = isset($invoice_data['primary_user_id']) ? $invoice_data['primary_user_id'] : 0; } if (!$user_id) { $user_id = module_security::get_loggedin_id(); } $user_data = module_user::get_user($user_id); if (!$user_data || !strpos($user_data['email'], '@')) { die('Please ensure your user account has a valid email address before paying with coinbase'); } $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id); // we add the fee details to the invoice payment record so that the new invoice total can be calculated. $fee_percent = module_config::c('payment_method_coinbase_charge_percent', 0); $fee_amount = module_config::c('payment_method_coinbase_charge_amount', 0); $fee_description = module_config::c('payment_method_coinbase_charge_description', 'Coinbase Fee'); $fee_total = 0; if ($fee_percent != 0 || $fee_amount != 0) { $fee_total = module_invoice::calculate_fee($invoice_id, $invoice_data, $payment_amount, array('percent' => $fee_percent, 'amount' => $fee_amount, 'description' => $fee_description)); if ($fee_total != 0) { // add this percent/amount to the invoice payment $payment_amount = $payment_amount + $fee_total; update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('fee_percent' => $fee_percent, 'fee_amount' => $fee_amount, 'fee_description' => $fee_description, 'fee_total' => $fee_total, 'amount' => $payment_amount)); } } // we check if this payment is a recurring payment or a standard one off payment. if (module_config::c('payment_method_coinbase_subscriptions', 0)) { // we support subscriptions! // first check if the subscription module is active, and if this invoice is part of an active subscription. $is_subscription = false; if (class_exists('module_subscription', false)) { $subscription_history = get_single('subscription_history', 'invoice_id', $invoice_id); if ($subscription_history && $subscription_history['subscription_id']) { // this invoice is for a subscription! woo! // work out when we should bill for this subscription. $subscription = module_subscription::get_subscription($subscription_history['subscription_id']); $subscription_owner = module_subscription::get_subscription_owner($subscription_history['subscription_owner_id']); if ($subscription_owner['owner_table'] && $subscription_owner['owner_id']) { // work out when the next invoice will be generated for this subscription. $members_subscriptions = module_subscription::get_subscriptions_by($subscription_owner['owner_table'], $subscription_owner['owner_id']); if (isset($members_subscriptions[$subscription_history['subscription_id']])) { $member_subscription = $members_subscriptions[$subscription_history['subscription_id']]; // everything checks out! good to go.... // for now we just do a basic "EVERY X TIME" subscription // todo: work out how long until next generate date, and set that (possibly smaller) time period as the first portion of the subscription /*echo '<pre>'; print_r($subscription_history); print_r($subscription); print_r($subscription_owner); print_r($member_subscription); exit;*/ $is_subscription = array(); if ($subscription['days'] > 0) { $is_subscription['days'] = $subscription['days']; } if ($subscription['months'] > 0) { $is_subscription['months'] = $subscription['months']; } if ($subscription['years'] > 0) { $is_subscription['years'] = $subscription['years']; } if (count($is_subscription)) { $is_subscription['name'] = $subscription['name']; $is_subscription['id'] = $subscription_history['subscription_id']; } } } } } // todo: check if this invoice has a manual renewal date, perform subscription feature as above. if ($is_subscription) { // coinbase only supports these recurring methods: // daily, weekly, every_two_weeks, monthly, quarterly, and yearly // work out which one our days are at. $days = isset($is_subscription['days']) ? $is_subscription['days'] : 0; if (isset($is_subscription['months'])) { $days += $is_subscription['months'] * 30; unset($is_subscription['months']); } if (isset($is_subscription['years'])) { $days += $is_subscription['years'] * 365; unset($is_subscription['years']); } $is_subscription['days'] = $days; if ($days == 1) { $is_subscription['coinbase_period'] = 'daily'; } else { if ($days == 7 || $days == 6 || $days == 8) { $is_subscription['coinbase_period'] = 'weekly'; } else { if ($days == 14 || $days == 13 || $days == 15) { $is_subscription['coinbase_period'] = 'every_two_weeks'; } else { if ($days == 29 || $days == 30 || $days == 31) { $is_subscription['coinbase_period'] = 'monthly'; } else { if ($days >= 87 && $days <= 95) { $is_subscription['coinbase_period'] = 'quarterly'; } else { if ($days >= 363 && $days <= 370) { $is_subscription['coinbase_period'] = 'yearly'; } else { send_error('Someone tried to pay with coinbase but coinbase does not support a recurring subscription period of ' . $days . ' days. Only: daily, weekly, every_two_weeks, monthly, quarterly, and yearly '); $is_subscription = false; // not supported. } } } } } } } if ($is_subscription && isset($is_subscription['coinbase_period'])) { $invoice_payment_data = module_invoice::get_invoice_payment($invoice_payment_id); if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) { // existing subscription already! // not really sure what to do here, just redirect to coinbase as if the user is doing it for the first time. $_REQUEST['payment_subscription'] = true; // hacks! } if (isset($_REQUEST['payment_subscription']) || module_config::c('payment_method_coinbase_force_subscription', 0)) { // user is setting up a subscription! yes!! // we create an entry in our database for this particular subscription // or if one exists for this payment already then we just continue with that (ie: the user is going in again to redo it) // setup a new subscription in the database for us. if (isset($invoice_payment_data['invoice_payment_subscription_id']) && (int) $invoice_payment_data['invoice_payment_subscription_id'] > 0) { $invoice_payment_subscription_id = $invoice_payment_data['invoice_payment_subscription_id']; } else { $invoice_payment_subscription_id = update_insert('invoice_payment_subscription_id', false, 'invoice_payment_subscription', array('status' => _INVOICE_SUBSCRIPTION_PENDING, 'days' => isset($is_subscription['days']) ? $is_subscription['days'] : 0, 'months' => isset($is_subscription['months']) ? $is_subscription['months'] : 0, 'years' => isset($is_subscription['years']) ? $is_subscription['years'] : 0, 'date_start' => '0000-00-00', 'date_last_pay' => '0000-00-00', 'date_next' => '0000-00-00')); update_insert('invoice_payment_id', $invoice_payment_id, 'invoice_payment', array('invoice_payment_subscription_id' => $invoice_payment_subscription_id)); } $description = _l('Recurring payment for %s %s', $is_subscription['name'], _l(str_replace('_', ' ', $is_subscription['coinbase_period']))); $subscription_name = $is_subscription['name']; unset($is_subscription['name']); // so reset/key cals below rosk. $subscription_id = $is_subscription['id']; unset($is_subscription['id']); // so reset/key cals below rosk. $currency = module_config::get_currency($invoice_payment_data['currency_id']); $currency_code = $currency['code']; include module_theme::include_ucm('includes/plugin_paymethod_coinbase/pages/coinbase_form.php'); exit; } else { if (isset($_REQUEST['payment_single'])) { // use is choosing to continue payment as a once off amount } else { // give the user an option $template = module_template::get_template_by_key('invoice_payment_subscription'); $template->page_title = htmlspecialchars($invoice_data['name']); $template->assign_values($invoice_payment_data); $template->assign_values(module_invoice::get_replace_fields($invoice_data['invoice_id'], $invoice_data)); $template->assign_values(array('invoice_payment_id' => $invoice_payment_id, 'payment_url' => module_invoice::link_public_pay($invoice_data['invoice_id']), 'payment_method' => 'paymethod_coinbase', 'payment_amount' => $payment_amount, 'pretty_payment_amount' => dollar($payment_amount, true, $invoice_data['currency_id']), 'subscription_period' => _l('%s days (%s)', $is_subscription['days'], $is_subscription['coinbase_period']), 'fee_amount' => dollar($fee_amount, true, $invoice_data['currency_id']), 'fee_total' => dollar($fee_total, true, $invoice_data['currency_id']), 'fee_percent' => $fee_percent, 'fee_description' => $fee_description)); echo $template->render('pretty_html'); exit; } } } } $description = _l('Payment for invoice %s', $invoice_data['name']); //self::coinbase_redirect($description,$payment_amount,$user_id,$invoice_payment_id,$invoice_id,$invoice_payment_data['currency_id']); $currency = module_config::get_currency($invoice_payment_data['currency_id']); $currency_code = $currency['code']; include module_theme::include_ucm('includes/plugin_paymethod_coinbase/pages/coinbase_form.php'); /*$template = new module_template(); ob_start(); $template->content = ob_get_clean(); echo $template->render('pretty_html');*/ exit; } return false; }
public function handle_hook($hook, $mod = false) { switch ($hook) { case 'dashboard_widgets': $widgets = array(); include 'pages/dashboard_summary_widgets.php'; return $widgets; break; case 'dashboard': include 'pages/dashboard_summary.php'; // not in lite edition: if (is_file(dirname(__FILE__) . '/pages/finance_quick.php')) { include 'pages/finance_quick.php'; } return false; break; case "home_alerts": $alerts = array(); if ($mod != 'calendar' && module_config::c('finance_alerts', 1) && module_finance::can_i('view', 'Finance Upcoming')) { // find any jobs that are past the due date and dont have a finished date. $sql = "SELECT * FROM `" . _DB_PREFIX . "finance_recurring` r "; $sql .= " WHERE r.next_due_date != '0000-00-00' AND r.next_due_date <= '" . date('Y-m-d', strtotime('+' . module_config::c('finance_alert_days_in_future', 14) . ' days')) . "'"; $sql .= " AND (r.end_date = '0000-00-00' OR r.next_due_date < r.end_date)"; $upcoming_finances = qa($sql); foreach ($upcoming_finances as $finance) { $alert_res = process_alert($finance['next_due_date'], _l('Upcoming Transaction Due'), module_config::c('finance_alert_days_in_future', 14)); if ($alert_res) { $alert_res['link'] = $this->link_open_recurring($finance['finance_recurring_id']); $alert_res['name'] = ($finance['type'] == 'i' ? '+' . dollar($finance['amount']) : '') . ($finance['type'] == 'e' ? '-' . dollar($finance['amount']) : '') . ' (' . $finance['name'] . ')'; $alerts[] = $alert_res; } } } return $alerts; break; } }
echo !trim($transaction['name']) ? 'N/A' : htmlspecialchars($transaction['name']); ?> </a> </td> <td> <?php echo $transaction['description']; ?> </td> <td> <span class="success_text"><?php echo $transaction['credit'] > 0 ? '+' . dollar($transaction['credit'], true, $transaction['currency_id']) : ''; ?> </span> </td> <td> <span class="error_text"><?php echo $transaction['debit'] > 0 ? '-' . dollar($transaction['debit'], true, $transaction['currency_id']) : ''; ?> </span> </td> </tr> <?php } ?> </tbody> </table> </div> <?php $fieldset_data = array('heading' => array('title' => 'Job Finances:', 'type' => 'h3', 'button' => array('title' => _l('Add New'), 'url' => module_finance::link_open('new') . '&from_job_id=' . $job_id)), 'elements_before' => ob_get_clean()); echo module_form::generate_fieldset($fieldset_data);
$replace['title'] = '<h3>' . _l('Payment History:') . '</h3>'; } else { $replace['title'] = '<strong>' . _l('Payment History:') . '</strong><br/>'; } if (preg_match('#<tr[^>]+data-item-row="true">.*</tr>#imsU', $t->content, $matches)) { $item_row_html = $matches[0]; $t->content = str_replace($item_row_html, '{ITEM_ROW_CONTENT}', $t->content); } else { set_error('Please ensure a TR with data-item-row="true" is in the invoice_payment_history template'); $item_row_html = ''; } $all_item_row_html = ''; $item_count = 0; // changed from 1 foreach ($payment_historyies as $invoice_payment_id => $invoice_payment_data) { $row_replace = array('ITEM_ODD_OR_EVEN' => $item_count++ % 2 ? 'odd' : 'even', 'ITEM_PAYMENT_DATE' => !trim($invoice_payment_data['date_paid']) || $invoice_payment_data['date_paid'] == '0000-00-00' ? _l('Pending on %s', print_date($invoice_payment_data['date_created'])) : print_date($invoice_payment_data['date_paid']), 'ITEM_PAYMENT_METHOD' => htmlspecialchars($invoice_payment_data['method']), 'ITEM_PAYMENT_DETAILS' => '', 'ITEM_PAYMENT_AMOUNT' => dollar($invoice_payment_data['amount'], true, $invoice_payment_data['currency_id']), 'ITEM_PAYMENT_RECEIPT_URL' => module_invoice::link_receipt($invoice_payment_data['invoice_payment_id'])); if (isset($invoice_payment_data['data']) && $invoice_payment_data['data']) { $details = unserialize($invoice_payment_data['data']); if (isset($details['custom_notes'])) { $row_replace['ITEM_PAYMENT_DETAILS'] = htmlspecialchars($details['custom_notes']); } } $this_item_row_html = $item_row_html; $this_item_row_html = str_replace(' data-item-row="true"', '', $this_item_row_html); foreach ($row_replace as $key => $val) { $this_item_row_html = str_replace('{' . strtoupper($key) . '}', $val, $this_item_row_html); } $all_item_row_html .= $this_item_row_html; } $replace['ITEM_ROW_CONTENT'] = $all_item_row_html; $t->assign_values($replace);
<form action="" method="post"> <?php /** START TABLE LAYOUT **/ $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['product_name'] = array('title' => _l('Product Name'), 'callback' => function ($product) { echo module_product::link_open($product['product_id'], true, $product); }, 'cell_class' => 'row_action'); $columns['product_category_name'] = array('title' => _l('Category Name')); $columns['quantity'] = array('title' => _l('Hours/Quantity')); $columns['amount'] = array('title' => _l('Amount'), 'callback' => function ($product) { echo dollar($product['amount']); }); if (module_product::can_i('edit', 'Products')) { $columns['bulk_action'] = array('title' => ' ', 'callback' => function ($product) { echo '<input type="checkbox" name="bulk_operation[' . $product['product_id'] . ']" value="yes">'; }); } $table_manager->set_id('product_list'); $table_manager->set_columns($columns); $table_manager->set_rows($products); $table_manager->pagination = true; $table_manager->print_table(); /** END TABLE LAYOUT **/ ?> </form>
$bits[] = _l('%s days', $subscription['days']); } if ($subscription['months'] > 0) { $bits[] = _l('%s months', $subscription['months']); } if ($subscription['years'] > 0) { $bits[] = _l('%s years', $subscription['years']); } echo _l('Every %s', implode(', ', $bits)); } ?> </td> <td> <?php echo dollar($subscription['amount'], true, $subscription['currency_id']); ?> </td> <td> <?php echo htmlspecialchars($subscription['member_count']); ?> </td> <td> <?php echo htmlspecialchars($subscription['customer_count']); ?> </td> <td> <?php echo htmlspecialchars($subscription['website_count']); ?> </td>
</td> <?php if (module_invoice::can_i('view', 'Invoices')) { ?> <td nowrap=""> <?php if ($task_editable) { ?> <?php echo currency('<input type="text" name="job_task[' . $task_id . '][staff_amount]" value="' . ($task_data['staff_amount'] != 0 ? number_out($task_data['staff_amount']) : number_out($task_data['staff_hours'] * $job['staff_hourly_rate'])) . '" id="' . $task_id . 'staff_taskamount" class="currency" tabindex="15">'); ?> <?php } else { ?> <?php echo $task_data['staff_amount'] != 0 ? dollar($task_data['staff_amount'], true, $job['currency_id']) : dollar($task_data['staff_hours'] * $job['staff_hourly_rate'], true, $job['currency_id']); ?> <?php } ?> </td> <?php } ?> <td colspan="<?php echo $colspan; ?> "> <?php _h('Here you can set a split amount for this staff member. This is what the staff member will be paid for the task.'); ?>
*/ if (!$quote_safe) { die('failed'); } if (!module_quote::can_i('edit', 'Quotes')) { die('no perms'); } $quote_id = (int) $_REQUEST['quote_id']; $quote = module_quote::get_quote($quote_id); // template for sending emails. // are we sending the paid one? or the dueone. //$template_name = 'quote_email'; $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'quote_email'; $template = module_template::get_template_by_key($template_name); $quote['total_amount_print'] = dollar($quote['total_amount'], true, $quote['currency_id']); $quote['total_amount_due_print'] = dollar($quote['total_amount_due'], true, $quote['currency_id']); $quote['quote_name'] = $quote['name']; $quote['from_name'] = module_security::get_loggedin_name(); $quote['quote_url'] = module_quote::link_public($quote_id); ob_start(); include module_theme::include_ucm('includes/plugin_quote/template/quote_task_list.php'); $public_html = ob_get_clean(); $quote['task_list'] = $public_html; /*ob_start(); $quote_data = $quote; $ignore_task_hook=true; $for_email=true; include('quote_public.php'); $quote['quote_tasks'] = ob_get_clean();*/ // generate the PDF ready for sending. $pdf = module_quote::generate_pdf($quote_id);
if (isset($total_by_currency[$currency_id]['total_debit_tax'][$tax_percent])) { echo dollar($total_by_currency[$currency_id]['total_debit_tax'][$tax_percent], true, $currency_id); } ?> </td> <?php } } ?> <td> <?php if (isset($total_by_currency[$currency_id]['total_debit'])) { ?> <span class="error_text">-<?php echo dollar($total_by_currency[$currency_id]['total_debit'], true, $currency_id); ?> </span> <?php } ?> </td> <?php } ?> <?php } ?>