function customer_admin_email_generate_invoice_list($invoices, $customer_id) { ob_start(); $colspan = 9; $colspan2 = 0; $invoice_total = array(); $invoice_total_due = array(); foreach ($invoices as $invoice) { if (!isset($invoice_total[$invoice['currency_id']])) { $invoice_total[$invoice['currency_id']] = 0; } if ($invoice['c_total_amount'] == 0) { $invoice = module_invoice::get_invoice($invoice['invoice_id']); } $invoice_total[$invoice['currency_id']] += $invoice['c_total_amount']; if (!isset($invoice_total_due[$invoice['currency_id']])) { $invoice_total_due[$invoice['currency_id']] = 0; } $invoice_total_due[$invoice['currency_id']] += $invoice['c_total_amount_due']; } $table_manager = module_theme::new_table_manager(); $columns = array(); $columns['invoice_number'] = array('title' => 'Invoice Number', 'callback' => function ($invoice) { //echo module_invoice::link_open($invoice['invoice_id'],true,$invoice); echo '<a href="' . module_invoice::link_public($invoice['invoice_id']) . '">' . htmlspecialchars($invoice['name']) . '</a>'; }, 'cell_class' => 'row_action'); $columns['invoice_status'] = array('title' => 'Status', 'callback' => function ($invoice) { echo htmlspecialchars($invoice['status']); }); $columns['invoice_create_date'] = array('title' => 'Create Date', 'callback' => function ($invoice) { if (!$invoice['date_create'] || $invoice['date_create'] == '0000-00-00') { //echo print_date($invoice['date_created']); } else { echo print_date($invoice['date_create']); } }); $columns['invoice_due_date'] = array('title' => 'Due Date', 'callback' => function ($invoice) { if ((!$invoice['date_paid'] || $invoice['date_paid'] == '0000-00-00') && strtotime($invoice['date_due']) < time()) { echo '<span class="error_text">'; echo print_date($invoice['date_due']); echo '</span>'; } else { echo print_date($invoice['date_due']); } }); $columns['invoice_sent_date'] = array('title' => 'Sent Date', 'callback' => function ($invoice) { if ($invoice['date_sent'] && $invoice['date_sent'] != '0000-00-00') { ?> <?php echo print_date($invoice['date_sent']); ?> <?php } else { ?> <span class="error_text"><?php _e('Not sent'); ?> </span> <?php } }); $columns['invoice_paid_date'] = array('title' => 'Paid Date', 'callback' => function ($invoice) { if ($invoice['date_paid'] && $invoice['date_paid'] != '0000-00-00') { ?> <?php echo print_date($invoice['date_paid']); ?> <?php } else { if ($invoice['date_cancel'] && $invoice['date_cancel'] != '0000-00-00') { ?> <span class="error_text"><?php _e('Cancelled'); ?> </span> <?php } else { if ($invoice['overdue']) { ?> <span class="error_text" style="font-weight: bold; text-decoration: underline;"><?php _e('Overdue'); ?> </span> <?php } else { ?> <span class="error_text"><?php _e('Not paid'); ?> </span> <?php } } } }); if (class_exists('module_website', false) && module_website::is_plugin_enabled() && module_website::can_i('view', module_config::c('project_name_plural', 'Websites'))) { $colspan++; $columns['invoice_website'] = array('title' => module_config::c('project_name_single', 'Website'), 'callback' => function ($invoice) { if (isset($invoice['website_ids'])) { foreach ($invoice['website_ids'] as $website_id) { if ((int) $website_id > 0) { echo module_website::link_open($website_id, true); echo '<br/>'; } } } }); } $columns['invoice_job'] = array('title' => 'Job', 'callback' => function ($invoice) { foreach ($invoice['job_ids'] as $job_id) { if ((int) $job_id > 0) { //echo module_job::link_open($job_id,true); $job_data = module_job::get_job($job_id); echo '<a href="' . module_job::link_public($job_id) . '">' . htmlspecialchars($job_data['name']) . '</a>'; if ($job_data['date_start'] && $job_data['date_start'] != '0000-00-00' && $job_data['date_renew'] && $job_data['date_renew'] != '0000-00-00') { _e(' (%s to %s)', print_date($job_data['date_start']), print_date(strtotime("-1 day", strtotime($job_data['date_renew'])))); } echo "<br/>\n"; } } hook_handle_callback('invoice_admin_list_job', $invoice['invoice_id']); }); if (!isset($_REQUEST['customer_id']) && module_customer::can_i('view', 'Customers')) { $colspan++; $columns['invoice_customer'] = array('title' => 'Customer', 'callback' => function ($invoice) { echo module_customer::link_open($invoice['customer_id'], true); }); } $columns['c_invoice_total'] = array('title' => 'Invoice Total', 'callback' => function ($invoice) { echo dollar($invoice['total_amount'], true, $invoice['currency_id']); }); $columns['c_invoice_total_due'] = array('title' => 'Amount Due', 'callback' => function ($invoice) { 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 } }); if (class_exists('module_extra', false)) { ob_start(); $colspan2 += module_extra::print_table_header('invoice'); // used in the footer calc. ob_end_clean(); $table_manager->display_extra('invoice', function ($invoice) { module_extra::print_table_data('invoice', $invoice['invoice_id']); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full vendor data before displaying each row so we have access to more details if (isset($row_data['invoice_id']) && (int) $row_data['invoice_id'] > 0) { return module_invoice::get_invoice($row_data['invoice_id']); } return array(); }; $table_manager->set_rows($invoices); if (module_config::c('invoice_list_show_totals', 1)) { $footer_rows = array(); foreach ($invoice_total + $invoice_total_due as $currency_id => $foo) { $currency = get_single('currency', 'currency_id', $currency_id); $footer_rows[] = array('invoice_number' => array('data' => '<strong>' . _l('%s Totals:', $currency && isset($currency['code']) ? $currency['code'] : '') . '</strong>', 'cell_colspan' => $colspan - 2, 'cell_class' => 'text-right'), 'c_invoice_total' => array('data' => '<strong>' . dollar(isset($invoice_total[$currency_id]) ? $invoice_total[$currency_id] : 0, true, $currency_id) . '</strong>'), 'c_invoice_total_due' => array('data' => '<strong>' . dollar(isset($invoice_total_due[$currency_id]) ? $invoice_total_due[$currency_id] : 0, true, $currency_id) . '</strong>'), 'row_bulk_action' => array('data' => ' ', 'cell_colspan' => $colspan2)); } $table_manager->set_footer_rows($footer_rows); } $table_manager->pagination = false; $table_manager->print_table(); return ob_get_clean(); }
public function process() { switch ($_REQUEST['_process']) { case 'quick_save_finance': if (isset($_REQUEST['link_go']) && $_REQUEST['link_go'] == 'go') { module_finance::handle_link_transactions(); } else { // check for date / name at least. $date = trim($_REQUEST['transaction_date']); $name = trim($_REQUEST['name']); if (!$date || !$name) { redirect_browser(module_finance::link_open(false)); } $credit = trim($_REQUEST['credit']); $debit = trim($_REQUEST['debit']); if ($credit > 0) { $_POST['type'] = 'i'; $_POST['amount'] = $credit; } else { $_POST['type'] = 'e'; $_POST['amount'] = $debit; } } case 'save_finance': if (isset($_REQUEST['butt_del'])) { $this->delete($_REQUEST['finance_id']); redirect_browser(self::link_open(false)); } if (isset($_REQUEST['butt_unlink'])) { // unlink this finance_id from other finance_ids. $sql = "UPDATE `" . _DB_PREFIX . "finance` SET parent_finance_id = 0 WHERE parent_finance_id = '" . (int) $_REQUEST['finance_id'] . "'"; query($sql); $sql = "UPDATE `" . _DB_PREFIX . "invoice_payment` SET parent_finance_id = 0 WHERE parent_finance_id = '" . (int) $_REQUEST['finance_id'] . "'"; query($sql); redirect_browser(self::link_open(false)); } $temp_data = $this->get_finance($_REQUEST['finance_id']); $data = $_POST + $temp_data; // save the finance categories and account. $account_id = $_REQUEST['finance_account_id']; if ((string) (int) $account_id != (string) $account_id && strlen($account_id) > 2) { // we have a new account to create. $account_id = update_insert('finance_account_id', 'new', 'finance_account', array('name' => $account_id)); } $data['finance_account_id'] = $account_id; $finance_id = update_insert('finance_id', isset($_REQUEST['finance_id']) ? $_REQUEST['finance_id'] : 'new', 'finance', $data); module_extra::save_extras('finance', 'finance_id', $finance_id); if (!isset($data['tax_ids']) && isset($data['taxes']) && is_array($data['taxes'])) { // default data when saving a new invoice payment to finance area $data['tax_ids'] = array(); $data['tax_names'] = array(); $data['tax_percents'] = array(); $data['tax_increment_checkbox'] = 0; foreach ($data['taxes'] as $tax) { $data['tax_ids'][] = false; $data['tax_names'][] = $tax['name']; $data['tax_percents'][] = $tax['percent']; $data['tax_amount'][] = $tax['amount']; if ($tax['increment']) { $data['tax_increment_checkbox'] = 1; } } } // save the finance tax rates (copied from invoice.php) if (isset($data['tax_ids']) && isset($data['tax_names']) && $data['tax_percents']) { $existing_taxes = get_multiple('finance_tax', array('finance_id' => $finance_id), 'finance_tax_id', 'exact', 'order'); $order = 1; foreach ($data['tax_ids'] as $key => $val) { if ((int) $val > 0 && isset($existing_taxes[$val])) { // this means we are trying to update an existing record on the finance_tax table, we confirm this id matches this finance. $finance_tax_id = $val; unset($existing_taxes[$finance_tax_id]); // so we know which ones to remove from the end. } else { $finance_tax_id = false; // create new record } $finance_tax_data = array('finance_id' => $finance_id, 'percent' => isset($data['tax_percents'][$key]) ? $data['tax_percents'][$key] : 0, 'amount' => isset($data['tax_amount'][$key]) ? $data['tax_amount'][$key] : 0, 'name' => isset($data['tax_names'][$key]) ? $data['tax_names'][$key] : 'TAX', 'order' => $order++, 'increment' => isset($data['tax_increment_checkbox']) && $data['tax_increment_checkbox'] ? 1 : 0); $finance_tax_id = update_insert('finance_tax_id', $finance_tax_id, 'finance_tax', $finance_tax_data); } foreach ($existing_taxes as $existing_tax) { delete_from_db('finance_tax', array('finance_id', 'finance_tax_id'), array($finance_id, $existing_tax['finance_tax_id'])); } } $category_ids = isset($_REQUEST['finance_category_id']) && is_array($_REQUEST['finance_category_id']) ? $_REQUEST['finance_category_id'] : array(); $sql = "DELETE FROM `" . _DB_PREFIX . "finance_category_rel` WHERE finance_id = {$finance_id}"; query($sql); foreach ($category_ids as $category_id) { $category_id = (int) $category_id; if ($category_id <= 0) { continue; } $sql = "REPLACE INTO `" . _DB_PREFIX . "finance_category_rel` SET finance_id = {$finance_id}, finance_category_id = {$category_id}"; query($sql); } if (isset($_REQUEST['finance_category_new']) && strlen(trim($_REQUEST['finance_category_new'])) > 0) { $category_name = trim($_REQUEST['finance_category_new']); $category_id = update_insert('finance_category_id', 'new', 'finance_category', array('name' => $category_name)); if (isset($_REQUEST['finance_category_new_checked'])) { $sql = "REPLACE INTO `" . _DB_PREFIX . "finance_category_rel` SET finance_id = {$finance_id}, finance_category_id = {$category_id}"; query($sql); } } if (isset($_REQUEST['invoice_payment_id']) && (int) $_REQUEST['invoice_payment_id'] > 0) { // link this as a child invoice payment to this one. update_insert('invoice_payment_id', $_REQUEST['invoice_payment_id'], 'invoice_payment', array('parent_finance_id' => $finance_id)); } if (isset($_REQUEST['finance_recurring_id']) && (int) $_REQUEST['finance_recurring_id'] > 0) { // if we have set a custom "next recurring date" then we don't recalculate this date unless we are saving a new finance id. $recurring = self::get_recurring($_REQUEST['finance_recurring_id']); if (!(int) $_REQUEST['finance_id'] || !$recurring['next_due_date_custom']) { self::calculate_recurring_date((int) $_REQUEST['finance_recurring_id'], true); } // we also have to adjust the starting balance of our recurring amount by this amount. // just a little helpful feature. if (!(int) $_REQUEST['finance_id']) { $balance = module_config::c('finance_recurring_start_balance', 0); if ($balance != 0) { if ($data['type'] == 'e') { $balance -= $data['amount']; } else { if ($data['type'] == 'i') { $balance += $data['amount']; } } module_config::save_config('finance_recurring_start_balance', $balance); } } // redirect back to recurring listing. set_message('Recurring transaction saved successfully'); if (isset($_REQUEST['recurring_next']) && $_REQUEST['recurring_next']) { redirect_browser($_REQUEST['recurring_next']); } redirect_browser(self::link_open_recurring(false)); } set_message(_l('Transaction saved successfully: %s', module_finance::link_open($finance_id, true))); if (isset($_REQUEST['job_id']) && (int) $_REQUEST['job_id'] > 0) { redirect_browser(module_job::link_open((int) $_REQUEST['job_id'])); } if (isset($_REQUEST['butt_save_return'])) { if (isset($_REQUEST['_redirect']) && strlen($_REQUEST['_redirect'])) { redirect_browser($_REQUEST['_redirect']); } redirect_browser(self::link_open(false, false)); } if ($_REQUEST['_process'] == 'quick_save_finance') { redirect_browser(self::link_open(false, false)); } redirect_browser(self::link_open($finance_id, false)); break; case 'save_recurring': if (isset($_REQUEST['butt_del'])) { $this->delete_recurring($_REQUEST['finance_recurring_id']); redirect_browser(self::link_open_recurring(false)); } $data = $_POST; // save the finance categories and account. $account_id = $_REQUEST['finance_account_id']; if ((string) (int) $account_id != (string) $account_id && strlen($account_id) > 2) { // we have a new account to create. $account_id = update_insert('finance_account_id', 'new', 'finance_account', array('name' => $account_id)); } if (isset($_REQUEST['finance_recurring_id']) && (int) $_REQUEST['finance_recurring_id']) { $original_finance_recurring = self::get_recurring($_REQUEST['finance_recurring_id']); } else { $original_finance_recurring = array(); } $data['finance_account_id'] = $account_id; $finance_recurring_id = update_insert('finance_recurring_id', isset($_REQUEST['finance_recurring_id']) ? $_REQUEST['finance_recurring_id'] : 'new', 'finance_recurring', $data); if ((int) $finance_recurring_id > 0) { $category_ids = isset($_REQUEST['finance_category_id']) && is_array($_REQUEST['finance_category_id']) ? $_REQUEST['finance_category_id'] : array(); $sql = "DELETE FROM `" . _DB_PREFIX . "finance_recurring_catrel` WHERE finance_recurring_id = {$finance_recurring_id}"; query($sql); foreach ($category_ids as $category_id) { $category_id = (int) $category_id; if ($category_id <= 0) { continue; } $sql = "REPLACE INTO `" . _DB_PREFIX . "finance_recurring_catrel` SET finance_recurring_id = {$finance_recurring_id}, finance_category_id = {$category_id}"; query($sql); } if (isset($_REQUEST['finance_category_new']) && strlen(trim($_REQUEST['finance_category_new'])) > 0) { $category_name = trim($_REQUEST['finance_category_new']); $category_id = update_insert('finance_category_id', 'new', 'finance_category', array('name' => $category_name)); if (isset($_REQUEST['finance_category_new_checked'])) { $sql = "REPLACE INTO `" . _DB_PREFIX . "finance_recurring_catrel` SET finance_recurring_id = {$finance_recurring_id}, finance_category_id = {$category_id}"; query($sql); } } $calculated_next_date = self::calculate_recurring_date($finance_recurring_id); if (isset($data['set_next_due_date']) && $data['set_next_due_date']) { $next_date = input_date($data['set_next_due_date']); $next_due_date_real = module_finance::calculate_recurring_date($finance_recurring_id, true, false); if ($next_date != $next_due_date_real) { // we have accustom date. update_insert('finance_recurring_id', $finance_recurring_id, 'finance_recurring', array('next_due_date' => $next_date, 'next_due_date_custom' => 1)); } else { // date is the same. not doing a custom date any more update_insert('finance_recurring_id', $finance_recurring_id, 'finance_recurring', array('next_due_date' => $next_due_date_real, 'next_due_date_custom' => 0)); } } /* $finance_recurring = self::get_recurring($finance_recurring_id); if($finance_recurring['next_due_date_custom']){ $next_due_date_real = module_finance::calculate_recurring_date($finance_recurring_id,true,false); // unset the "custom" flag if we've picked the same date as what it should be. if($next_due_date_real == $finance_recurring['next_due_date']){ module_finance::calculate_recurring_date($finance_recurring_id,true,true); } }*/ } set_message('Recurring transaction saved successfully'); //redirect_browser(self::link_open($finance_id,false)); redirect_browser(self::link_open_recurring(false, false)); break; } }
public static function delete_report($report_id) { $report_id = (int) $report_id; if (_DEMO_MODE && $report_id == 1) { return; } if ((int) $report_id > 0) { $original_report_data = self::get_report($report_id); if (!$original_report_data || $original_report_data['report_id'] != $report_id) { return false; } } if (!self::can_i('delete', 'reports')) { return false; } $sql = "DELETE FROM " . _DB_PREFIX . "report WHERE report_id = '" . $report_id . "' LIMIT 1"; $res = query($sql); module_note::note_delete("report", $report_id); module_extra::delete_extras('report', 'report_id', $report_id); }
public static function display_extras($options) { $owner_id = isset($options['owner_id']) && $options['owner_id'] ? (int) $options['owner_id'] : false; $owner_table = isset($options['owner_table']) && $options['owner_table'] ? $options['owner_table'] : false; $layout = isset($options['layout']) && $options['layout'] ? $options['layout'] : false; $allow_new = true; if (isset($options['allow_new']) && !$options['allow_new']) { $allow_new = false; } $allow_edit = !isset($options['allow_edit']) || isset($options['allow_edit']) && $options['allow_edit']; if (!module_security::is_page_editable()) { $allow_edit = false; } // todo ^^ flow this permission check through to the "save" section. $html = ''; if ($owner_table) { $default_fields = self::get_defaults($owner_table); // we have all that we need to display some extras!! yey!! if ($owner_id) { $extra_items = self::get_extras(array('owner_table' => $owner_table, 'owner_id' => $owner_id)); $extra_items = self::sort_extras($extra_items, $default_fields); } else { $extra_items = array(); } foreach ($extra_items as $extra_item) { $extra_id = $extra_item['extra_id']; $id = 'extra_' . preg_replace('#\\W+#', '_', $extra_item['extra_key']); ob_start(); ?> <tr id="extra_<?php echo $extra_id; ?> "> <th <?php if (module_config::can_i('edit', 'Settings') && self::can_i('edit', 'Extra Fields') && isset($default_fields[$extra_item['extra_key']]['field_type'])) { echo ' data-settings-url="' . module_extra::link_open_extra_default($default_fields[$extra_item['extra_key']]['extra_default_id'], false) . '"'; } ?> > <?php if ($allow_edit) { ?> <span class="extra_field_key" onclick="$(this).hide(); $(this).parent().find('input').show();"><?php echo htmlspecialchars($extra_item['extra_key']); ?> </span> <input type="text" name="extra_<?php echo $owner_table; ?> _field[<?php echo $extra_id; ?> ][key]" value="<?php echo htmlspecialchars($extra_item['extra_key']); ?> " class="extra_field" style="display:none;"> <?php } else { echo htmlspecialchars($extra_item['extra_key']); ?> <input type="hidden" name="extra_<?php echo $owner_table; ?> _field[<?php echo $extra_id; ?> ][key]" value="<?php echo htmlspecialchars($extra_item['extra_key']); ?> "> <?php } ?> </th> <td> <?php if ($allow_edit) { $field_type = 'text'; if (isset($default_fields[$extra_item['extra_key']]['field_type'])) { $field_type = $default_fields[$extra_item['extra_key']]['field_type']; } if (!$field_type) { $field_type = 'text'; } $form_element = array('type' => $field_type, 'name' => 'extra_' . $owner_table . '_field[' . $extra_id . '][val]', 'value' => $extra_item['extra'], 'class' => 'extra_value_input', 'id' => $id); if ($field_type == 'select') { $form_element['options'] = array(); if (isset($default_fields[$extra_item['extra_key']]['options']) && is_array($default_fields[$extra_item['extra_key']]['options']) && isset($default_fields[$extra_item['extra_key']]['options']['select'])) { foreach (explode("\n", $default_fields[$extra_item['extra_key']]['options']['select']) as $val) { $val = trim($val); if ($val === '') { continue; } $form_element['options'][$val] = $val; } } } module_form::generate_form_element($form_element); } else { echo nl2br($extra_item['extra']); } /* <input type="text" name="extra_<?php echo $owner_table;?>_field[<?php echo $extra_id;?>][val]" id="<?php echo $id;?>" class="extra_value_input" value="<?php echo htmlspecialchars($extra_item['extra']);?>"> */ ?> </td> </tr> <?php $html .= ob_get_clean(); } if (module_security::is_page_editable() && $allow_new) { $extra_id = 'new'; ob_start(); // check if there are any "more" fields to add $more_fields_available = $allow_new; //if(!$more_fields_available){ foreach ($default_fields as $default_id => $default) { // check this key islany already existing. foreach ($extra_items as $extra_item) { if ($extra_item['extra_key'] == $default['key']) { unset($default_fields[$default_id]); continue 2; } } $more_fields_available = true; } //} if ($more_fields_available) { ?> <tr id="extra_<?php echo $owner_table; ?> _options_<?php echo $extra_id; ?> " <?php if (!module_config::c('hide_extra', 1)) { ?> style="display:none;"<?php } ?> > <th> </th> <td> <a href="#" onclick="$('#extra_<?php echo $owner_table; ?> _options_<?php echo $extra_id; ?> ').hide();$('#extra_<?php echo $owner_table; ?> _holder_<?php echo $extra_id; ?> ').show(); return false;"><?php _e('more fields »'); ?> </a> </td> </tr> <?php } // more fields available ?> <?php if (count($default_fields) || $allow_new) { ?> <tbody id="extra_<?php echo $owner_table; ?> _holder_<?php echo $extra_id; ?> " <?php if (module_config::c('hide_extra', 1)) { ?> style="display:none;"<?php } ?> > <!-- show all other options here from this $owner_table --> <?php $defaultid = 0; foreach ($default_fields as $default) { $defaultid++; $id = 'extra_' . preg_replace('#\\W+#', '_', $default['key']); ?> <tr> <th> <?php if ($allow_edit) { ?> <span class="extra_field_key" onclick="$(this).hide(); $(this).parent().find('input').show();"><?php echo htmlspecialchars($default['key']); ?> </span> <input type="text" name="extra_<?php echo $owner_table; ?> _field[new<?php echo $defaultid; ?> ][key]" value="<?php echo htmlspecialchars($default['key']); ?> " class="extra_field" style="display:none;"> <?php } else { echo htmlspecialchars($default['key']); ?> <input type="hidden" name="extra_<?php echo $owner_table; ?> _field[new<?php echo $defaultid; ?> ][key]" value="<?php echo htmlspecialchars($default['key']); ?> "> <?php } ?> </th> <td> <?php $field_type = $default['field_type']; if (!$field_type) { $field_type = 'text'; } $form_element = array('type' => $field_type, 'name' => 'extra_' . $owner_table . '_field[new' . $defaultid . '][val]', 'value' => '', 'class' => 'extra_value_input', 'id' => $id); if ($field_type == 'select') { $form_element['options'] = array(); if (isset($default['options']) && is_array($default['options']) && isset($default['options']['select'])) { foreach (explode("\n", $default['options']['select']) as $val) { $val = trim($val); if ($val === '') { continue; } $form_element['options'][$val] = $val; } } } module_form::generate_form_element($form_element); /*<input type="text" name="extra_<?php echo $owner_table;?>_field[new<?php echo $defaultid;?>][val]" id="<?php echo $id;?>" value="<?php ?>">*/ ?> </td> </tr> <?php } ?> <?php if ($allow_new) { ?> <tr id="extra_<?php echo $extra_id; ?> "> <th> <input type="text" name="extra_<?php echo $owner_table; ?> _field[<?php echo $extra_id; ?> ][key]" value="<?php ?> " class="extra_field"> </th> <td> <input type="text" name="extra_<?php echo $owner_table; ?> _field[<?php echo $extra_id; ?> ][val]" value="<?php ?> "> <?php _h('Enter anything you like in this blank field. eg: Passwords, Links, Notes, etc..'); ?> </td> </tr> <?php } ?> </tbody> <?php } // defaults / allow new $html .= ob_get_clean(); } // is page editable } // pass it out for a hook // this is really only used in the security module. if (function_exists('hook_filter_var')) { $html = hook_filter_var('extra_fields_output', $html, $owner_table, $owner_id); } else { $result = hook_handle_callback('extra_fields_output', $html, $owner_table, $owner_id); if ($result && count($result)) { foreach ($result as $r) { $html = $r; // bad. handle multiple hooks. } } } print $html; }
} }); } } 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']; } echo implode(', ', $g); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full vendor data before displaying each row so we have access to more details return module_quote::get_quote($row_data['quote_id']); }; $table_manager->set_rows($quotes); if (class_exists('module_extra', false)) { $table_manager->display_extra('quote', function ($quote) { module_extra::print_table_data('quote', $quote['quote_id']); }); } $table_manager->pagination = true; $table_manager->print_table(); ?> </form>
public function delete_product($product_id) { $product_id = (int) $product_id; $product = self::get_product($product_id); if ($product && $product['product_id'] == $product_id) { $sql = "DELETE FROM " . _DB_PREFIX . "product WHERE product_id = '" . $product_id . "' LIMIT 1"; query($sql); module_extra::delete_extras('product', 'product_id', $product_id); } }
$to_select = false; $to = array(); if ($invoice['customer_id']) { $customer = module_customer::get_customer($invoice['customer_id']); $replace['customer_name'] = $customer['customer_name']; if ($invoice['user_id']) { $primary = module_user::get_user($invoice['user_id']); if ($primary) { $to_select = $primary['email']; } } else { $to = module_user::get_contacts(array('customer_id' => $invoice['customer_id'])); // hunt for 'accounts' extra field $field_to_find = strtolower(module_config::c('accounts_extra_field_name', 'Accounts')); foreach ($to as $contact) { $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact['user_id'])); foreach ($extras as $e) { if (strtolower($e['extra_key']) == $field_to_find) { // this is the accounts contact - woo! $to_select = $contact['email']; } } } if (!$to_select && $customer['primary_user_id']) { $primary = module_user::get_user($customer['primary_user_id']); if ($primary) { $to_select = $primary['email']; } } } } else {
/** * @static * @param $args * @return array * * The newsletter system requests updated customer / user data from this group plugin. * It does this when building the member list, and also */ public static function newsletter_callback($args) { if (!isset($args['owner_table']) || !$args['owner_table']) { return array(); } switch ($args['owner_table']) { case 'user': if ((int) $args['owner_id'] > 0) { $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name"; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " ,c.credit "; $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= ' FROM `' . _DB_PREFIX . "user` pu"; $sql .= " LEFT JOIN `" . _DB_PREFIX . "customer` c ON pu.customer_id = c.customer_id"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= " WHERE pu.user_id = " . (int) $args['owner_id']; $user = qa1($sql); if (!is_array($user) || !isset($user['user_id']) || !$user['user_id']) { return false; } if (isset($args['basic']) && $args['basic']) { return $user; } // $name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name'])); // $user['first_name'] = array_shift($name_parts); // $user['last_name'] = implode(' ',$name_parts); // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } // get extras for the customer. if (isset($user['customer_id']) && $user['customer_id'] > 0) { $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } if ($user['customer_id']) { $user['_edit_link'] = module_user::link_open_contact($user['user_id'], false, $user); } else { $user['_edit_link'] = module_user::link_open($user['user_id'], false, $user); } return $user; } break; case 'customer': if (module_config::c('newsletter_send_all_customer_contacts', 1)) { // update - we use the above 'user' callback and return a listing for each contact in the array. // using the special _multi flag hack to tell our newsletter plugin that this result contains multiple entries. $users = array('_multi' => true); $sql = "SELECT u.user_id FROM `" . _DB_PREFIX . "user` u WHERE u.customer_id = " . (int) $args['owner_id']; $contacts = qa($sql); foreach ($contacts as $contact) { $data_args = array('owner_id' => $contact['user_id'], 'owner_table' => 'user'); $users[$contact['user_id']] = self::newsletter_callback($data_args); if ($users[$contact['user_id']]) { $users[$contact['user_id']]['data_args'] = json_encode($data_args); } } return $users; } else { $sql = "SELECT c.customer_name AS company_name, c.customer_name AS customer_name"; $sql .= " ,c.credit "; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " , pu.name AS user_name, pu.name AS first_name, pu.last_name AS last_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= " FROM `" . _DB_PREFIX . "customer` c "; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id"; $sql .= " WHERE c.customer_id = " . (int) $args['owner_id']; $user = qa1($sql); if (!$user || !isset($user['customer_id'])) { return array(); } //$name_parts = explode(" ",preg_replace('/\s+/',' ',$user['user_name'])); //$user['first_name'] = array_shift($name_parts); //$user['last_name'] = implode(' ',$name_parts); if (isset($args['basic']) && $args['basic']) { return $user; } // get extras for the customer. $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } if (isset($user['user_id']) && $user['user_id'] > 0) { // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user); return $user; } case 'website': $sql = "SELECT c.customer_name AS company_name"; $sql .= " ,c.credit "; $sql .= " ,w.name AS website_name"; $sql .= " ,w.url AS website_url"; $sql .= " , pu.user_id "; $sql .= " , c.customer_id "; $sql .= " , pu.name AS user_name, pu.phone AS phone, pu.`email` AS `email`, pu.`mobile` AS `mobile`"; $sql .= " , a.line_1, a.line_2, a.suburb, a.state, a.region, a.country, a.post_code "; $sql .= " FROM `" . _DB_PREFIX . "website` w "; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "customer` c ON w.customer_id = c.customer_id"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "address` a ON c.customer_id = a.owner_id AND a.owner_table = 'customer' AND a.address_type = 'physical'"; $sql .= ' LEFT JOIN `' . _DB_PREFIX . "user` pu ON c.primary_user_id = pu.user_id"; $sql .= " WHERE w.website_id = " . (int) $args['owner_id']; $user = qa1($sql); $name_parts = explode(" ", preg_replace('/\\s+/', ' ', $user['user_name'])); $user['first_name'] = array_shift($name_parts); $user['last_name'] = implode(' ', $name_parts); if (isset($args['basic']) && $args['basic']) { return $user; } // get extras for the website. $extras = module_extra::get_extras(array('owner_table' => 'website', 'owner_id' => $args['owner_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } // then get extras for the company $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $user['customer_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } if (isset($user['user_id']) && $user['user_id'] > 0) { // get extras for the user. $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); foreach ($extras as $extra) { if (!strlen(trim($extra['extra']))) { continue; } $key = $extra['extra_key']; $x = 1; while (isset($user[$key])) { $key = $extra['extra_key'] . $x; $x++; } $user[$key] = trim($extra['extra']); } } $user['_edit_link'] = module_customer::link_open($user['customer_id'], false, $user); return $user; case 'ticket': //echo 'Getting ticket for '.$args['owner_id'] . ' and basic is '.var_export($args['basic'],true);exit; return module_ticket::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); case 'member': return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); case 'newsletter_subscription': return module_member::get_newsletter_recipient($args['owner_id'], isset($args['basic']) && $args['basic']); } return array(); }
$x++; } ?> <li> <fieldset> <legend>Please upload any attachments for this project below:</legend> <label><input type="file" name="customerfiles[]" value=""></label> <label><input type="file" name="customerfiles[]" value=""></label> <label><input type="file" name="customerfiles[]" value=""></label> <label><input type="file" name="customerfiles[]" value=""></label> <!-- add more files here by simply duplicating a line above --> </fieldset> </li> <?php $x = 1; foreach (module_extra::get_defaults('website') as $default) { ?> <li> <label for="website_extra_<?php echo $x; ?> "><?php echo htmlspecialchars($default['key']); ?> </label> <input type="text" id="website_extra_<?php echo $x; ?> " name="website[extra][<?php echo htmlspecialchars($default['key']); ?>
$user_temp = module_user::get_user($invoice['user_id'], false); $c[$invoice['user_id']] = $user_temp['name'] . ' ' . $user_temp['last_name'] . ' ' . _l('(under different customer)'); } echo print_select_box($c, 'user_id', $invoice['user_id']); ?> </td> </tr> <?php } ?> </tbody> <?php module_extra::display_extras(array('owner_table' => 'invoice', 'owner_key' => 'invoice_id', 'owner_id' => $invoice['invoice_id'], 'layout' => 'table_row', 'allow_new' => module_job::can_i('create', 'Invoices'), 'allow_edit' => module_job::can_i('create', 'Invoices'))); ?> </table> <?php if ((int) $invoice_id > 0) { ?> <?php hook_handle_callback('invoice_sidebar', $invoice_id); ?>
} // find available "to" recipients. // customer contacts. $to_select = false; if ($file['customer_id']) { $customer = module_customer::get_customer($file['customer_id']); $file['customer_name'] = $customer['customer_name']; $to = module_user::get_contacts(array('customer_id' => $file['customer_id'])); if ($customer['primary_user_id']) { $primary = module_user::get_user($customer['primary_user_id']); if ($primary) { $to_select = $primary['email']; } } } else { $to = array(); } if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('file'); foreach ($all_extra_fields as $e) { $file[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'file', 'owner_id' => $file_id)); foreach ($extras as $e) { $file[$e['extra_key']] = $e['extra']; } } $template->assign_values($file); ob_start(); module_email::print_compose(array('title' => _l('Email File: %s', $file['file_name']), 'find_other_templates' => 'file_approval_email', 'current_template' => $template_name, 'customer_id' => $file['customer_id'], 'job_id' => $file['job_id'], 'file_id' => $file['file_id'], 'debug_message' => 'Sending file as email', 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_file::link_open($file_id), 'success_callback' => 'module_file::email_sent', 'success_callback_args' => array('file_id' => $file_id), 'cancel_url' => module_file::link_open($file_id)));
function metris_generate_fieldset($callback, $options) { $defaults = array('id' => false, 'type' => 'table', 'title' => false, 'title_type' => 'h5', 'heading' => false, 'row_title_class' => 'width1', 'row_data_class' => '', 'elements' => array(), 'class' => 'tableclass tableclass_form', 'extra_settings' => array(), 'elements_before' => '', 'elements_after' => ''); $options = array_merge($defaults, $options); if (function_exists('hook_filter_var')) { $options = hook_filter_var('generate_fieldset_options', $options); } ob_start(); ?> <div class="box <?php echo isset($options['heading']['responsive']) ? ' box-responsive' : ''; ?> "> <header> <?php if ($options['heading']) { if (!isset($options['heading']['type']) || $options['heading']['type'] != 'h5') { $options['heading']['type'] = 'h5'; } print_heading($options['heading']); } else { if ($options['title']) { ?> <<?php echo $options['title_type']; ?> ><?php _e($options['title']); ?> </<?php echo $options['title_type']; ?> > <?php } } ?> </header> <!-- .block --> <div class="body"> <?php echo $options['elements_before']; ?> <?php if ($options['elements']) { ?> <table class="<?php echo $options['class']; ?> "> <tbody> <?php foreach ($options['elements'] as $element) { if (isset($element['ignore']) && $element['ignore']) { continue; } if (isset($element['field']) && !isset($element['fields'])) { $element['fields'] = array($element['field']); unset($element['field']); } ?> <tr> <?php if (isset($element['message']) && $element['message'] || isset($element['warning']) && isset($element['warning'])) { ?> <th colspan="2" style="text-align:center"> <?php if (isset($element['message'])) { ?> <?php echo $element['message']; ?> <?php } else { if (isset($element['warning'])) { ?> <span class="error_text"><?php echo $element['warning']; ?> </span> <?php } } ?> </th> <?php } else { ?> <?php if (isset($element['title'])) { ?> <th class="<?php echo isset($element['row_title_class']) ? $element['row_title_class'] : $options['row_title_class']; ?> "> <?php echo htmlspecialchars(_l($element['title'])); ?> </th> <?php } if (isset($element['fields'])) { ?> <td class="<?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php if (is_array($element['fields'])) { foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { // treat this as a call to the form generate option module_form::generate_form_element($field); echo ' '; } else { if (is_closure($field)) { $field(); } else { echo $field . ' '; } } } } else { echo $element['fields']; } ?> </td> <?php } ?> </tr> <?php } } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && $options['extra_settings']) { module_extra::display_extras($options['extra_settings']); } ?> </tbody> </table> <?php } echo $options['elements_after']; ?> </div> <!-- /.block --> </div> <?php return ob_get_clean(); }
public static function generate_fieldset($options) { // let the themes override this search bar function. $result = hook_handle_callback('generate_fieldset', $options); if (is_array($result)) { // has been handed by a theme. return current($result); } $defaults = array('id' => false, 'type' => 'table', 'title' => false, 'title_type' => 'h3', 'heading' => false, 'row_title_class' => 'width1', 'row_data_class' => '', 'elements' => array(), 'class' => 'tableclass tableclass_form', 'extra_settings' => array(), 'elements_before' => '', 'elements_after' => ''); $options = array_merge($defaults, $options); if (function_exists('hook_filter_var')) { $options = hook_filter_var('generate_fieldset_options', $options); } //todo - hook in here for themes. ob_start(); if ($options['heading']) { print_heading($options['heading']); } else { if ($options['title']) { ?> <<?php echo $options['title_type']; ?> ><?php _e($options['title']); ?> </<?php echo $options['title_type']; ?> > <?php } } ?> <?php echo $options['elements_before']; ?> <?php if ($options['elements']) { ?> <table class="<?php echo $options['class']; ?> "> <tbody> <?php foreach ($options['elements'] as $element) { if (isset($element['ignore']) && $element['ignore']) { continue; } if (isset($element['field']) && !isset($element['fields'])) { $element['fields'] = array($element['field']); unset($element['field']); } ?> <tr> <?php if (isset($element['message']) && $element['message'] || isset($element['warning']) && isset($element['warning'])) { ?> <td colspan="2" align="center"> <?php if (isset($element['message'])) { ?> <?php echo $element['message']; ?> <?php } else { if (isset($element['warning'])) { ?> <span class="error_text"><?php echo $element['warning']; ?> </span> <?php } } ?> </td> <?php } else { ?> <?php if (isset($element['title'])) { ?> <th class="<?php echo isset($element['row_title_class']) ? $element['row_title_class'] : $options['row_title_class']; ?> "> <?php echo htmlspecialchars(_l($element['title'])); ?> </th> <?php } if (isset($element['fields'])) { ?> <td class="<?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php if (is_array($element['fields'])) { foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { // treat this as a call to the form generate option self::generate_form_element($field); echo ' '; } else { if (is_closure($field)) { $field(); } else { echo $field . ' '; } } } } else { echo $element['fields']; } ?> </td> <?php } ?> </tr> <?php } } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && $options['extra_settings']) { module_extra::display_extras($options['extra_settings']); } ?> </tbody> </table> <?php } echo $options['elements_after']; ?> <?php return ob_get_clean(); }
function adminlte_generate_fieldset($callback, $options) { $defaults = array('id' => false, 'type' => 'table', 'title' => false, 'title_type' => 'h3', 'heading' => false, 'row_title_class' => 'width1', 'row_data_class' => '', 'elements' => array(), 'class' => 'tableclass tableclass_form', 'extra_settings' => array(), 'elements_before' => '', 'elements_after' => ''); $options = array_merge($defaults, $options); if (function_exists('hook_filter_var')) { $options = hook_filter_var('generate_fieldset_options', $options); } ob_start(); ?> <div class="box <?php echo module_theme::get_config('adminlte_boxstyle', 'box-solid'); echo isset($options['heading']['responsive']) ? ' box-responsive' : ''; ?> "> <div class="box-header"> <?php if ($options['heading']) { if (!isset($options['heading']['type']) || $options['heading']['type'] != 'h3') { $options['heading']['type'] = 'h3'; } $options['heading']['class'] = 'box-title'; print_heading($options['heading']); } else { if ($options['title']) { ?> <<?php echo $options['title_type']; ?> class="box-title"><?php _e($options['title']); ?> </<?php echo $options['title_type']; ?> > <?php } } ?> </div> <!-- .block --> <div class="box-body"> <?php echo $options['elements_before']; ?> <?php if ($options['elements']) { if (module_theme::get_config('adminlte_formstyle', 'table') == 'table') { ?> <table class="<?php echo $options['class']; ?> "> <tbody> <?php foreach ($options['elements'] as $element) { if (isset($element['ignore']) && $element['ignore']) { continue; } if (isset($element['field']) && !isset($element['fields'])) { $element['fields'] = array($element['field']); unset($element['field']); } ?> <tr> <?php if (isset($element['message']) && $element['message'] || isset($element['warning']) && isset($element['warning'])) { ?> <th colspan="2" class="text-center"> <?php if (isset($element['message'])) { ?> <?php echo $element['message']; ?> <?php } else { if (isset($element['warning'])) { ?> <span class="error_text"><?php echo $element['warning']; ?> </span> <?php } } ?> </th> <?php } else { ?> <th class="<?php echo isset($element['row_title_class']) ? $element['row_title_class'] : $options['row_title_class']; ?> "> <?php if (isset($element['title'])) { ?> <?php echo htmlspecialchars(_l($element['title'])); ?> <?php } ?> </th> <td class="<?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php if (isset($element['fields'])) { ?> <?php if (is_array($element['fields'])) { foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { // treat this as a call to the form generate option module_form::generate_form_element($field); echo ' '; } else { if (is_closure($field)) { $field(); } else { echo $field . ' '; } } } } else { echo $element['fields']; } ?> <?php } // fields ?> </td> <!-- /.input-group --> <?php } //else ?> </tr> <!-- /.form-group --> <?php } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && $options['extra_settings']) { module_extra::display_extras($options['extra_settings']); } ?> </tbody> </table> <!-- /.elements --> <?php // end table layout } else { if (module_theme::get_config('adminlte_formstyle', 'table') == 'div') { ?> <div class="<?php echo $options['class']; ?> "> <?php foreach ($options['elements'] as $element) { if (isset($element['ignore']) && $element['ignore']) { continue; } if (isset($element['field']) && !isset($element['fields'])) { $element['fields'] = array($element['field']); unset($element['field']); } ?> <div class="form-group"> <?php if (isset($element['message']) && $element['message'] || isset($element['warning']) && isset($element['warning'])) { ?> <div class="text-center"> <?php if (isset($element['message'])) { ?> <?php echo $element['message']; ?> <?php } else { if (isset($element['warning'])) { ?> <span class="error_text"><?php echo $element['warning']; ?> </span> <?php } } ?> </div> <?php } else { ?> <div class="input-group<?php echo !isset($element['title']) ? '-notitle' : ''; ?> "> <?php if (isset($element['title'])) { ?> <span class="input-group-addon table-row-title"><span class="<?php echo isset($element['row_title_class']) ? $element['row_title_class'] : $options['row_title_class']; ?> "><?php echo htmlspecialchars(_l($element['title'])); ?> </span></span> <?php } if (isset($element['fields'])) { ?> <?php if (is_array($element['fields'])) { // if there is only one element we put it up in the form-control so that it displays nicely. // if there are more than one elements we wrap them in a div form-control. $do_wrap = true; if (count($element['fields']) == 1) { $field = current($element['fields']); if (is_array($field) && $field['type'] != 'wysiwyg' && $field['type'] != 'check' && $field['type'] != 'checkbox') { $do_wrap = false; $currency = false; if ($field['type'] == 'currency') { $field['type'] = 'text'; $currency = true; //$field['class'] = (isset($field['class']) ? $field['class'] : '') .' currency '; } $field['class'] = (isset($field['class']) ? $field['class'] : '') . ' form-control ' . (isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']); $help_text = false; if (isset($field['help'])) { // we put the help element outside in its own <span class="input-group-addon"></span> // don't let the generatE_form_element produce it. $help_text = $field['help']; unset($field['help']); } module_form::generate_form_element($field); if ($currency) { ?> <span class="input-group-addon"><?php echo currency('', true, isset($field['currency_id']) ? $field['currency_id'] : false); ?> </span> <?php } if ($help_text) { ?> <span class="input-group-addon"><?php _h($help_text); ?> </span> <?php } } } if ($do_wrap) { ?> <div class="form-control<?php echo !isset($element['title']) ? '-notitle' : ''; ?> <?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php $help_text = false; foreach ($element['fields'] as $dataid => $field) { if (is_array($field) && isset($field['help'])) { // this element has a help text. if ($help_text) { // already a help text (shouldn't happen, ditch it.. and display multiple as normal) $help_text = false; break; } else { $help_text = $field['help']; } } } foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { if (isset($field['help']) && $help_text) { unset($field['help']); } // treat this as a call to the form generate option module_form::generate_form_element($field); echo ' '; } else { if (is_closure($field)) { $field(); } else { echo $field . ' '; } } } ?> </div> <?php if ($help_text) { ?> <span class="input-group-addon"><?php _h($help_text); ?> </span> <?php } } } else { ?> <div class="form-control <?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php echo $element['fields']; ?> </div> <?php } ?> <?php } // fields ?> </div> <!-- /.input-group --> <?php } //else ?> </div> <!-- /.form-group --> <?php } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && $options['extra_settings']) { module_extra::display_extras($options['extra_settings']); } ?> </div> <!-- /.elements --> <?php } else { if (module_theme::get_config('adminlte_formstyle', 'table') == 'long') { ?> <div class="<?php echo $options['class']; ?> "> <?php foreach ($options['elements'] as $element) { if (isset($element['ignore']) && $element['ignore']) { continue; } if (isset($element['field']) && !isset($element['fields'])) { $element['fields'] = array($element['field']); unset($element['field']); } ?> <div class="form-group form-group-long"> <?php if (isset($element['message']) && $element['message'] || isset($element['warning']) && isset($element['warning'])) { ?> <div class="text-center"> <?php if (isset($element['message'])) { ?> <?php echo $element['message']; ?> <?php } else { if (isset($element['warning'])) { ?> <span class="error_text"><?php echo $element['warning']; ?> </span> <?php } } ?> </div> <?php } else { ?> <?php if (isset($element['title'])) { ?> <label class="<?php echo isset($element['row_title_class']) ? $element['row_title_class'] : $options['row_title_class']; ?> "><?php echo htmlspecialchars(_l($element['title'])); ?> </label> <?php } if (isset($element['fields'])) { ?> <?php if (is_array($element['fields'])) { foreach ($element['fields'] as $dataid => $field) { if (is_array($field)) { // treat this as a call to the form generate option $field['class'] = (isset($field['class']) ? $field['class'] : '') . ' ' . (isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']); switch ($field['type']) { case 'check': case 'checkbox': case 'wysiwyg': break; default: $field['class'] .= ' form-control '; } module_form::generate_form_element($field); echo ' '; } else { if (is_closure($field)) { $field(); } else { echo $field . ' '; } } } } else { ?> <div class="form-control <?php echo isset($element['row_data_class']) ? $element['row_data_class'] : $options['row_data_class']; ?> "> <?php echo $element['fields']; ?> </div> <?php } ?> <?php } // fields ?> <?php } //else ?> </div> <!-- /.form-group --> <?php } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && $options['extra_settings']) { module_extra::display_extras($options['extra_settings']); } ?> </div> <!-- /.elements --> <?php } } } // end div layout } echo $options['elements_after']; ?> <!-- /.block --> </div> </div> <?php return ob_get_clean(); }
$fieldset_data['elements']['primary'] = array('title' => 'Primary', 'fields' => array(array('type' => 'check', 'name' => 'customer_primary', 'value' => '1', 'checked' => $primary), _hr('This users details will be used as a primary point of contact for this customer. These details will display in the main customer listing for this customer. Also if you send an invoice or a newsletter to this "customer" then this email address will be used.'))); } else { if (isset($show_more_button) && $show_more_button) { $fieldset_data['heading']['button'] = array('title' => 'More', 'url' => module_user::link_open_contact($user_id, false)); } } $fieldset_data['elements']['fname'] = array('title' => 'First Name', 'fields' => array(array('type' => 'text', 'name' => 'name', 'value' => $user['name']))); $fieldset_data['elements']['last_name'] = array('title' => 'Last Name', 'fields' => array(array('type' => 'text', 'name' => 'last_name', 'value' => $user['last_name']))); $fieldset_data['elements']['email'] = array('title' => 'Email Address', 'fields' => array(array('type' => 'text', 'name' => 'email', 'value' => $user['email']))); $fieldset_data['elements']['phone'] = array('title' => 'Phone', 'fields' => array(array('type' => 'text', 'name' => 'phone', 'value' => $user['phone']))); $fieldset_data['elements']['mobile'] = array('title' => 'Mobile', 'fields' => array(array('type' => 'text', 'name' => 'mobile', 'value' => $user['mobile']))); $fieldset_data['elements']['fax'] = array('title' => 'Fax', 'fields' => array(array('type' => 'text', 'name' => 'fax', 'value' => $user['fax']))); if (class_exists('module_language', false) && isset($user['language'])) { $attr = array(); foreach (module_language::get_languages_attributes() as $langauge) { $attr[$langauge['language_code']] = $langauge['language_name']; } $fieldset_data['elements']['language'] = array('title' => 'Language', 'fields' => array(array('type' => 'select', 'name' => 'language', 'options' => $attr, 'value' => $user['language']))); } if (class_exists('module_extra') && module_extra::is_plugin_enabled() && module_extra::can_i('view', 'Contacts')) { $fieldset_data['extra_settings'] = array('owner_table' => 'user', 'owner_key' => 'user_id', 'owner_id' => $user['user_id'], 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', 'Contacts'), 'allow_edit' => module_extra::can_i('edit', 'Contacts')); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); ?> <input type="hidden" name="user_id" value="<?php echo $user_id; ?> " />
_e('(unsubscribed %s)', print_date($res['time'])); } else { if (isset($res['reason']) && $res['reason'] == 'no_email') { _e('(do not send)'); } else { if (isset($res['reason']) && $res['reason'] == 'doubleoptin') { _e('(double opt-in incomplete)', print_date($res['time'])); } else { _e('(unsubscribed %s)', print_date($res['time'])); } } } } } }); } } if (class_exists('module_extra', false)) { $table_manager->display_extra('member', function ($member) { module_extra::print_table_data('member', $member['member_id']); }); } $table_manager->set_columns($columns); $table_manager->set_rows($members); $table_manager->pagination = true; $table_manager->print_table(); $pagination = process_pagination($members); ?> </form>
<a href="<?php echo $import_tasks_link; ?> " class=""><?php _e('Import Tasks'); ?> </a> <?php } })); } else { if ((int) $job_id > 0 && !class_exists('module_import_export', false) && module_config::c('show_ucm_ads', 1)) { $fieldset_data['elements'][] = array('title' => 'Task CSV Data', 'fields' => array('(import/export available in <a href="http://codecanyon.net/item/ultimate-client-manager-pro-edition/2621629?ref=dtbaker" target="_blank">UCM Pro Edition</a>)')); } } if (class_exists('module_extra', false) && module_extra::is_plugin_enabled() && module_config::c('job_enable_default_tasks', 1)) { $fieldset_data['elements'][] = array('title' => 'Task Defaults', 'fields' => array(function () use($job_id, &$job) { $job_default_tasks = module_job::get_default_tasks(); echo print_select_box($job_default_tasks, 'default_task_list_id', '', '', true, '', true); ?> <?php if ((int) $job_id > 0) { ?> <input type="button" name="s" id="save_saved" value="<?php _e('Save'); ?> " class="task_defaults small_button"> <?php
echo implode(', ', $g); }); } if (module_config::c('ticket_allow_priority', 0) && module_config::c('ticket_show_priority', 1)) { $columns['ticket_priority'] = array('title' => 'Priority', 'callback' => function ($ticket) use($priorities) { echo $priorities[$ticket['priority']]; }); } if (module_ticket::can_edit_tickets()) { $columns['ticket_action'] = array('title' => ' <input type="checkbox" name="bulk_operation_all" id="bulk_operation_all" value="yehaw" > ', 'callback' => function ($ticket) { echo '<input type="checkbox" name="bulk_operation[' . $ticket['ticket_id'] . ']" class="ticket_bulk_check" value="yes">'; }); } if (class_exists('module_extra', false)) { $table_manager->display_extra('ticket', function ($ticket) { module_extra::print_table_data('ticket', $ticket['ticket_id']); }); } $table_manager->set_columns($columns); $time = time(); $today = strtotime(date('Y-m-d')); $table_manager->row_callback = function ($row_data) use($time, $today, $limit_time) { // load the full vendor data before displaying each row so we have access to more details /*if(class_exists('module_envato',false) && isset($_REQUEST['faq_product_envato_hack']) && (!$ticket['faq_product_id'] || $ticket['faq_product_id'] == $_REQUEST['faq_product_envato_hack'])){ }*/ $return = array(); if (isset($row_data['ticket_id']) && (int) $row_data['ticket_id'] > 0) { $return = module_ticket::get_ticket($row_data['ticket_id']); } $return['time'] = $time; $return['today'] = $today;
if (class_exists('module_quote', false) && module_quote::is_plugin_enabled()) { $columns['file_quote'] = array('title' => 'Quote', 'callback' => function ($file) { echo module_quote::link_open($file['quote_id'], true); }); } $columns['file_date_added'] = array('title' => 'Date Added', 'callback' => function ($file) { echo _l('%s by %s', print_date($file['date_created']), module_user::link_open($file['create_user_id'], true)); }); if (module_file::can_i('edit', 'Files')) { $columns['file_action'] = array('title' => ' ', 'callback' => function ($file) { echo '<input type="checkbox" name="bulk_operation[' . $file['file_id'] . ']" value="yes">'; }); } if (class_exists('module_extra', false)) { $table_manager->display_extra('file', function ($file) { module_extra::print_table_data('file', $file['file_id']); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full file data before displaying each row so we have access to more details if (isset($row_data['file_id']) && (int) $row_data['file_id'] > 0) { // not needed in this case //return module_file::get_file($row_data['file_id']); } return array(); }; $table_manager->set_rows($files); $table_manager->pagination = true; $table_manager->print_table(); ?>
public static function run_pagination_hook(&$rows, &$per_page) { if (self::$table_sort_options) { self::is_currently_sorting(); // loads the session data. $new_sort_column = $new_sort_direction = $new_sort_per_page = false; if (isset($_SESSION['_table_sort']) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']]) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']][0])) { $new_sort_column = $_SESSION['_table_sort'][self::$table_sort_options['table_id']][0]; } if (isset($_SESSION['_table_sort']) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']]) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']][1])) { $new_sort_direction = $_SESSION['_table_sort'][self::$table_sort_options['table_id']][1]; } if (isset($_SESSION['_table_sort']) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']]) && isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']][2])) { $new_sort_per_page = $_SESSION['_table_sort'][self::$table_sort_options['table_id']][2]; } // count how many results for the "per page" drop down below. self::$table_sort_options['row_count'] = is_resource($rows) ? mysql_num_rows($rows) : count($rows); if (!isset($_SESSION['_table_sort']) || !isset($_SESSION['_table_sort'][self::$table_sort_options['table_id']])) { return; } if ($new_sort_column && $new_sort_direction) { // clear defaults! time for a user defined one. foreach (self::$table_sort_options['sortable'] as $column_id => $options) { if (isset($options['current'])) { unset(self::$table_sort_options['sortable'][$column_id]['current']); } if ($column_id == $new_sort_column) { self::$table_sort_options['sortable'][$column_id]['current'] = $new_sort_direction; } } } if ($new_sort_per_page >= 1) { $per_page = $new_sort_per_page; } else { if ($new_sort_per_page == -2) { // special flag for "all" $per_page = false; } } if (!$new_sort_column) { return; } // sort results by selected option. if (is_resource($rows)) { $new_rows = array(); while ($row = mysql_fetch_assoc($rows)) { $new_rows[] = $row; } mysql_free_result($rows); $rows = $new_rows; } else { // rows stays the same. } if (is_array($rows) && count($rows)) { foreach (self::$table_sort_options['sortable'] as $column_id => $options) { if (isset($options['current'])) { // we have a sortable key! yay! // is this a special "group sort" ? if (isset($options['group_sort']) && $options['group_sort'] && $options['owner_table'] && $options['owner_id']) { // find the group(s) for EVERY row in the result set. // this is super slow, but only way to sort. // we also sort multiple groups in the same order that is selected here. if (class_exists('module_group', false)) { foreach ($rows as $row_id => $row) { if (!isset($row[$options['owner_id']]) || !$row[$options['owner_id']]) { continue; } // find the groups for this customer. $groups = module_group::get_groups_search(array('owner_table' => $options['owner_table'], 'owner_id' => $row[$options['owner_id']])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } natcasesort($g); if ($options['current'] == 1) { // ascendine } else { // descenting $g = array_reverse($g); } $rows[$row_id]['group_sort_' . $options['owner_table']] = implode($g, ', '); } self::$sortables['group_sort_' . $options['owner_table']] = $options['current']; } } else { if (isset($options['extra_sort']) && $options['extra_sort'] && $options['owner_table'] && $options['owner_id']) { // find the extra(s) for EVERY row in the result set. // this is super slow, but only way to sort. // we also sort multiple extras in the same order that is selected here. if (class_exists('module_extra', false)) { foreach ($rows as $row_id => $row) { if (!isset($row[$options['owner_id']]) || !$row[$options['owner_id']]) { continue; } // find the extras for this customer. $extras = module_extra::get_extras(array('owner_table' => $options['owner_table'], 'owner_id' => $row[$options['owner_id']], 'extra_key' => $options['field'])); if (count($extras) == 1) { // found a match! $extra_val = current($extras); if (isset($options['field_type']) && $options['field_type'] == 'date') { $extra_val['extra'] = input_date($extra_val['extra']); } $rows[$row_id]['extra_header_' . $options['default_field_id']] = $extra_val['extra']; } } self::$sortables['extra_header_' . $options['default_field_id']] = $options['current']; } } else { // nope! yay! normal sort. self::$sortables[$options['field']] = $options['current']; } } } } uasort($rows, array('module_table_sort', 'dosort')); } // set the 'per page' value based on session setting. } }
<form action="" method="post"> <input type="hidden" name="_process" value="save_customer_type"> <input type="hidden" name="customer_type_id" value="<?php echo $customer_type_id; ?> " /> <?php module_form::print_form_auth(); $fieldset_data = array('heading' => array('type' => 'h3', 'title' => 'Edit Customer Type'), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array()); $fieldset_data['elements'][] = array('title' => 'Customer Type', 'fields' => array(array('type' => 'text', 'name' => 'type_name', 'value' => $customer_type['type_name'], 'help' => 'example: Lead'))); $fieldset_data['elements'][] = array('title' => 'Customer Type (plural)', 'fields' => array(array('type' => 'text', 'name' => 'type_name_plural', 'value' => $customer_type['type_name_plural'], 'help' => 'example: Leads'))); $fieldset_data['elements'][] = array('title' => 'Menu Position', 'fields' => array(array('type' => 'text', 'name' => 'menu_position', 'value' => $customer_type['menu_position'], 'help' => 'Where this should appear in the main menu'))); $fieldset_data['elements'][] = array('title' => 'Menu Icon', 'fields' => array(array('type' => 'text', 'name' => 'menu_icon', 'value' => $customer_type['menu_icon'], 'help' => 'Type the icon name from http://fontawesome.io/icons/ (eg: bell). Compatible with the Metis theme.'))); if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $fieldset_data['extra_settings'] = array('owner_table' => 'customer_type', 'owner_key' => 'customer_type_id', 'owner_id' => $customer_type_id, 'layout' => 'table_row'); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); $form_actions = array('class' => 'action_bar action_bar_center', 'elements' => array(array('type' => 'save_button', 'name' => 'butt_save', 'value' => _l('Save')), array('ignore' => !(int) $customer_type_id, 'type' => 'delete_button', 'name' => 'butt_del', 'value' => _l('Delete')), array('type' => 'button', 'name' => 'cancel', 'value' => _l('Cancel'), 'class' => 'submit_button', 'onclick' => "window.location.href='" . $module->link_open_customer_type(false) . "';"))); echo module_form::generate_form_actions($form_actions); ?> </form> <?php } else { $customer_types = module_customer::get_customer_types(); $header = array('title' => _l('Customer Types'), 'type' => 'h2', 'main' => true, 'button' => array());
?> <input type="checkbox" name="link_finance_ids[<?php echo $finance['finance_id']; ?> ]" value="<?php echo number_format($finance['credit'], 2) . '_' . number_format($finance['debit'], 2); ?> " class="link_box"> <?php } } }); if (class_exists('module_extra', false)) { $table_manager->display_extra('finance', function ($finance) { module_extra::print_table_data('finance', isset($finance['finance_id']) ? $finance['finance_id'] : 0); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($finance) { if (isset($finance['finance_id']) && $finance['finance_id']) { $finance['finance_record'] = module_finance::get_finance($finance['finance_id']); } else { $finance['finance_record'] = false; } return $finance; }; if (module_finance::can_i('create', 'Finance')) { $header_rows = array(); ob_start(); ?>
public function renew_invoice($invoice_id) { $invoice = $this->get_invoice($invoice_id); if (strtotime($invoice['date_renew']) <= strtotime('+' . module_config::c('alert_days_in_future', 5) . ' days')) { // /we are allowed to renew. unset($invoice['invoice_id']); // work out the difference in start date and end date and add that new renewl date to the new order. $time_diff = strtotime($invoice['date_renew']) - strtotime($invoice['date_create']); if ($time_diff > 0) { // our renewal date is something in the future. if (!$invoice['date_create'] || $invoice['date_create'] == '0000-00-00') { set_message('Please set a invoice create date before renewing'); redirect_browser($this->link_open($invoice_id)); } // if the time_diff is 28, 29, 30 or 31 days then we stick to the same day a month in the future. if (module_config::c('invoice_renew_monthly_fix', 1) && $time_diff >= 2419100 && $time_diff <= 2678500) { $new_renewal_date = date('Y-m-d', strtotime("+1 month", strtotime($invoice['date_renew']))); } else { // work out the next renewal date. $new_renewal_date = date('Y-m-d', strtotime($invoice['date_renew']) + $time_diff); } $invoice['name'] = self::new_invoice_number($invoice['customer_id']); $invoice['date_create'] = $invoice['date_renew']; $invoice['date_renew'] = $new_renewal_date; $invoice['date_sent'] = false; $invoice['date_paid'] = false; $invoice['deposit_job_id'] = 0; if (module_config::c('invoice_renew_discounts', 0)) { // keep the discounts from previous invoices. } else { // clear the discounts back to defaults. $invoice['discount_amount'] = 0; $invoice['discount_description'] = _l('Discount:'); $invoice['discount_type'] = !isset($invoice['discount_type']) ? module_config::c('invoice_discount_type', _DISCOUNT_TYPE_BEFORE_TAX) : $invoice['discount_type']; // 1 = After Tax } $invoice['tax_type'] = !isset($invoice['tax_type']) ? module_config::c('invoice_tax_type', 0) : $invoice['tax_type']; $invoice['date_due'] = date('Y-m-d', strtotime('+' . module_config::c('invoice_due_days', 30) . ' days', strtotime($invoice['date_create']))); $invoice['status'] = module_config::s('invoice_status_default', 'New'); // todo: copy the "more" listings over to the new invoice // todo: copy any notes across to the new listing. // hack to copy the 'extra' fields across to the new invoice. // save_invoice() does the extra handling, and if we don't do this // then it will move the extra fields from the original invoice to this new invoice. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $owner_table = 'invoice'; // get extra fields from this invoice $extra_fields = module_extra::get_extras(array('owner_table' => $owner_table, 'owner_id' => $invoice_id)); $x = 1; foreach ($extra_fields as $extra_field) { $_REQUEST['extra_' . $owner_table . '_field']['new' . $x] = array('key' => $extra_field['extra_key'], 'val' => $extra_field['extra']); $x++; } } // taxes copy across if (isset($invoice['taxes']) && is_array($invoice['taxes'])) { $invoice['tax_ids'] = array(); $invoice['tax_names'] = array(); $invoice['tax_percents'] = array(); foreach ($invoice['taxes'] as $tax) { $invoice['tax_ids'][] = 0; $invoice['tax_names'][] = $tax['name']; $invoice['tax_percents'][] = $tax['percent']; if ($tax['increment']) { $invoice['tax_increment_checkbox'] = 1; } } } $new_invoice_id = $this->save_invoice('new', $invoice); if ($new_invoice_id) { // now we create the tasks $tasks = $this->get_invoice_items($invoice_id); 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); } // link this up with the old one. update_insert('invoice_id', $invoice_id, 'invoice', array('renew_invoice_id' => $new_invoice_id)); } module_cache::clear('invoice'); return $new_invoice_id; } } return false; }
public static function get_default_task($default_task_list_id) { $extra = module_extra::get_extra($default_task_list_id); return array('default_task_list_id' => $extra['extra_id'], 'name' => $extra['extra_key'], 'task_data' => unserialize($extra['extra'])); }
public function external_hook($hook) { switch ($hook) { case 'view': $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false; $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false; if ($file_id && $hash) { $correct_hash = $this->link_public($file_id, true); if ($correct_hash == $hash) { // all good to print a receipt for this payment. $file_data = $this->get_file($file_id, false); if ($file_data && $file_data['file_id'] == $file_id) { if (isset($_POST['save_file_comments'])) { if (isset($_POST['file_approve']) && isset($_POST['file_approve_go']) && isset($_POST['file_approve_name']) && strlen($_POST['file_approve_name']) > 0) { update_insert('file_id', $file_id, 'file', array('approved_time' => time(), 'approved_by' => $_POST['file_approve_name'])); // send email, same 'updated' email as before. $this->send_file_changed_notice($file_id, false, true); //redirect_browser($this->link_public($file_id)); $_REQUEST['new_comment_text'] = _l('File was approved at %s by %s', print_date(time(), true), htmlspecialchars($_POST['file_approve_name'])); } if (isset($_POST['pointers'])) { update_insert('file_id', $file_id, 'file', array('pointers' => $_POST['pointers'])); } $this->save_file_comments($file_id); redirect_browser($this->link_public($file_id)); } module_template::init_template('file_approval_view', '<h2>File Details</h2> File Name: <strong>{FILE_NAME}</strong> <br/> Download: <strong><a href="{FILE_DOWNLOAD_URL}">Click Here</a></strong> <br/> Status: <strong>{STATUS}</strong> <br/> Customer: <strong>{CUSTOMER_NAME}</strong> <br/> {if:JOB_NAME}Job: <strong>{JOB_NAME}</strong> <br/>{endif:JOB_NAME} {if:FILE_APPROVAL_PENDING} <h2>File Approval Pending</h2> <p>If you would like to approve this file please complete the form below:</p> <p>Your Name: <input type="text" name="file_approve_name"> </p> <p><input type="checkbox" name="file_approve_go" value="yes"> Yes, I approve this file. </p> <p><input type="submit" name="file_approve" value="Approve File" class="submit_button save_button"></p> {endif:FILE_APPROVAL_PENDING} {if:FILE_APPROVED} <h2>File Has Been Approved</h2> <p>Thank you, the file was approved by <strong>{APPROVED_BY}</strong> on <strong>{APPROVED_TIME}</strong>.</p> {endif:FILE_APPROVED} <h2>File Comments</h2> <p>Please feel free to add comments to this file using the form below.</p> {FILE_COMMENTS} {if:FILE_PREVIEW} <h2>File Preview</h2> <div style="overflow:scroll;">{FILE_PREVIEW}</div> {endif:FILE_PREVIEW} ', 'Used when displaying the file to a customer for approval.', 'code'); $template = module_template::get_template_by_key('file_approval_view'); // generate the html for the task output $job_data = $file_data['job_id'] ? module_job::get_replace_fields($file_data['job_id']) : array(); if (class_exists('module_quote', false)) { $quote_data = $file_data['quote_id'] ? module_quote::get_replace_fields($file_data['quote_id']) : array(); } $customer_data = $file_data['customer_id'] ? module_customer::get_replace_fields($file_data['customer_id']) : array(); $file_data['file_preview'] = module_file::generate_preview($file_id, $file_data['file_name'], $file_data); $file_data['FILE_DOWNLOAD_URL'] = module_file::link_public_view($file_id); if (isset($file_data['approved_time'])) { switch ($file_data['approved_time']) { case -1: $file_data['FILE_APPROVAL_PENDING'] = 1; break; case 0: break; default: $file_data['FILE_APPROVED'] = 1; $file_data['APPROVED_TIME'] = print_date($file_data['approved_time'], true); } } if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('file'); foreach ($all_extra_fields as $e) { $file_data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'file', 'owner_id' => $file_id)); foreach ($extras as $e) { $file_data[$e['extra_key']] = $e['extra']; } } ob_start(); ?> <div id="file_notes"> <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;"> <textarea name="new_comment_text" style="width:100%;" class="no_permissions"></textarea> <div style="text-align: right;"> <input type="submit" name="butt_save_note" id="butt_save_note" value="<?php echo _l('Add Comment'); ?> " class="submit_button no_permissions"> </div> </div> <?php foreach (module_file::get_file_comments($file_id) as $item) { $note_text = forum_text($item['comment']); if (preg_match_all('/#(\\d+)/', $note_text, $matches)) { // foreach ($matches[1] as $digit) { $note_text = preg_replace('/#' . $digit . '([^\\d]*)/', '<span node_id=' . $digit . ' class="pointer-ids pointer-id-' . $digit . '">#' . $digit . '</span>$1', $note_text); } } ?> <div style="border-top:1px dashed #CCCCCC; padding:3px; margin:3px 0;"> <?php echo $note_text; ?> <div style="font-size:10px; text-align:right; color:#CCCCCC;">From <?php echo $item['create_user_id'] ? module_user::link_open($item['create_user_id'], true) : _l('Customer'); ?> on <?php echo print_date($item['date_created'], true); ?> </div> </div> <?php } ?> </div> <?php $file_data['file_comments'] = ob_get_clean(); $template->assign_values($file_data); $template->assign_values($customer_data); $template->assign_values($job_data); if (class_exists('module_quote', false)) { $quote_data['quote_approved_by'] = $quote_data['approved_by']; $quote_data['quote_date_approved'] = $quote_data['date_approved']; unset($quote_data['approved_by']); unset($quote_data['date_approved']); $template->assign_values($quote_data); } $template->page_title = $file_data['file_name']; $template->content = '<form action="" method="post"><input type="hidden" name="save_file_comments" value="1">' . $template->content . '</form>'; echo $template->render('pretty_html'); } } } break; case 'download_bucket': @ob_end_clean(); $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false; $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false; if ($file_id && $hash) { $correct_hash = $this->link_public_download_bucket($file_id, true); if ($correct_hash == $hash) { // all good to print a receipt for this payment. $file_data = $this->get_file($file_id, false); @ignore_user_abort(true); $search = array(); $search['bucket_parent_file_id'] = $file_id; $files = module_file::get_files($search); //Create ZIP $zip = new ZipArchive(); $zipName = "bucket-" . $file_id . "-" . md5($file_id . _UCM_SECRET) . ".zip"; if ($zip->open(_FILE_UPLOAD_PATH . $zipName, ZIPARCHIVE::CREATE) !== TRUE) { echo 'Failed to create bucket zip file'; exit; } foreach ($files as $file) { if (is_file($file['file_path'])) { $zip->addFromString($file['file_name'], file_get_contents($file['file_path'])); } } $zip->close(); //Set headers header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: public"); header("Content-Description: File Transfer"); header("Content-type: application/octet-stream"); //header("Content-Disposition: attachment; filename='" . $zipName . "'"); header("Content-Disposition: attachment; filename=\"" . preg_replace("#[^a-zA-Z0-9]+#", "-", $file_data['file_name']) . ".zip\";"); header("Content-Transfer-Encoding: binary"); header("Content-Length: " . filesize(_FILE_UPLOAD_PATH . $zipName)); @clearstatcache(); //Make sure the file size isn't cached $size = @readfile(_FILE_UPLOAD_PATH . $zipName); if (!$size) { echo file_get_contents(_FILE_UPLOAD_PATH . $zipName); } @unlink(_FILE_UPLOAD_PATH . $zipName); } } exit; break; case 'download': @ob_end_clean(); $file_id = isset($_REQUEST['i']) ? (int) $_REQUEST['i'] : false; $hash = isset($_REQUEST['hash']) ? trim($_REQUEST['hash']) : false; if ($file_id && $hash) { $correct_hash = $this->link_public_view($file_id, true); if ($correct_hash == $hash) { // all good to print a receipt for this payment. $file_data = $this->get_file($file_id, false); if (isset($file_data['file_url']) && strlen($file_data['file_url'])) { redirect_browser($file_data['file_url']); } else { if (is_file($file_data['file_path'])) { header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private", false); header("Content-type: " . dtbaker_mime_type($file_data['file_name'], $file_data['file_path'])); if (!isset($_REQUEST['embed'])) { header("Content-Disposition: attachment; filename=\"" . $file_data['file_name'] . "\";"); header("Content-Transfer-Encoding: binary"); } header("Content-Length: " . filesize($file_data['file_path'])); //readfile($file_data['file_path']); $size = @readfile($file_data['file_path']); if (!$size) { echo file_get_contents($file_data['file_path']); } } else { echo 'Not found'; } } } } exit; break; } }
public function delete_subscription($subscription_id) { $subscription_id = (int) $subscription_id; $subscription = self::get_subscription($subscription_id); if ($subscription && $subscription['subscription_id'] == $subscription_id) { $sql = "DELETE FROM " . _DB_PREFIX . "subscription WHERE subscription_id = '" . $subscription_id . "' LIMIT 1"; query($sql); module_extra::delete_extras('subscription', 'subscription_id', $subscription_id); } }
echo popup_link('<a href="' . module_faq::link_open_list($ticket['faq_product_id']) . '">' . _l('FAQ') . '</a>', array('force' => true, 'width' => 1100, 'height' => 600)); //} })); } if (module_config::c('ticket_support_accounts', 1) && module_ticket::get_accounts_rel()) { $fieldset_data['elements'][] = array('title' => _l('Account'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'ticket_account_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['ticket_account_id'] : friendly_key(module_ticket::get_accounts_rel(), $ticket['ticket_account_id']), 'options' => module_ticket::get_accounts_rel()))); } $fieldset_data['elements'][] = array('title' => _l('Status'), 'fields' => array(array('type' => module_ticket::can_edit_tickets() ? 'select' : 'html', 'name' => 'status_id', 'value' => module_ticket::can_edit_tickets() ? $ticket['status_id'] : friendly_key(module_ticket::get_statuses(), $ticket['status_id']), 'options' => module_ticket::get_statuses()))); if (module_ticket::can_edit_tickets() || module_config::c('ticket_allow_priority_selection', 0)) { $priorities = module_ticket::get_ticket_priorities(); if (!module_ticket::can_edit_tickets() && isset($priorities[_TICKET_PRIORITY_STATUS_ID]) && $ticket['priority'] != _TICKET_PRIORITY_STATUS_ID) { unset($priorities[_TICKET_PRIORITY_STATUS_ID]); } $fieldset_data['elements'][] = array('title' => _l('Priority'), 'fields' => array(array('type' => 'select', 'name' => 'priority', 'value' => $ticket['priority'], 'blank' => false, 'options' => $priorities))); } $fieldset_data['extra_settings'] = array('owner_table' => 'ticket', 'owner_key' => 'ticket_id', 'owner_id' => $ticket['ticket_id'], 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', 'Tickets'), 'allow_edit' => module_extra::can_i('edit', 'Tickets')); echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); $done_messages = false; if (class_exists('module_mobile', false)) { if (module_mobile::is_mobile_browser()) { // we're on mobile, display the ticket messages here: $tickets_in_reverse = false; include module_theme::include_ucm('includes/plugin_ticket/pages/ticket_admin_edit_messages.php'); $done_messages = true; } } if ($ticket['user_id']) { if (module_config::c('ticket_other_list_by', 'user') == 'user') { $other_tickets = module_ticket::get_tickets(array('user_id' => $ticket['user_id'])); } else {
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']); }, 'primary_user_id'); } $table_manager->enable_table_sorting(array('table_id' => 'customer_list', 'sortable' => array('customer_name' => array('field' => 'customer_name'), 'primary_contact_name' => array('field' => 'primary_user_name'), 'primary_contact_email' => array('field' => 'primary_user_email'), 'customer_group' => array('group_sort' => true, 'owner_table' => 'customer', 'owner_id' => 'customer_id')))); if (module_customer::can_i('view', 'Export ' . $page_type)) { $table_manager->enable_export(array('name' => $page_type_single . ' Export', 'fields' => array($page_type_single . ' ID' => 'customer_id', $page_type_single . ' Name' => 'customer_name', 'Credit' => 'credit', 'Address Line 1' => 'line_1', 'Address Line 2' => 'line_2', 'Address Suburb' => 'suburb', 'Address Country' => 'country', 'Address State' => 'state', 'Address Region' => 'region', 'Address Post Code' => 'post_code', 'Primary Contact First Name' => 'primary_user_name', 'Primary Contact Last Name' => 'primary_user_last_name', 'Primary Phone' => 'primary_user_phone', 'Primary Email' => 'primary_user_email', 'Primary Fax' => 'primary_user_fax', 'Primary Mobile' => 'primary_user_mobile', 'Primary Language' => 'primary_user_language', 'Invoice Prefix' => 'default_invoice_prefix', 'Tax Name' => 'default_tax_name', 'Tax Rate' => 'default_tax', 'Staff' => 'customer_staff'), 'extra' => array(array('owner_table' => 'customer', 'owner_id' => 'customer_id'), array('owner_table' => 'user', 'owner_id' => 'primary_user_id')), 'group' => array(array('title' => $page_type_single . ' Group', 'owner_table' => 'customer', 'owner_id' => 'customer_id')))); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full customer data before displaying each row so we have access to more details return module_customer::get_customer($row_data['customer_id']); }; $table_manager->set_rows($customers); $table_manager->pagination = true; $table_manager->print_table(); /** END TABLE LAYOUT **/
break; } }); } if (class_exists('module_group', false) && module_user::can_i('view', 'Contact Groups')) { $columns['group'] = array('title' => 'Group', 'callback' => function ($user) { $groups = module_group::get_groups_search(array('owner_table' => 'user', 'owner_id' => $user['user_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } echo implode(', ', $g); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full vendor data before displaying each row so we have access to more details return $row_data; //module_user::get_user($row_data['user_id']); }; $table_manager->set_rows($users); if (class_exists('module_extra', false)) { $table_manager->display_extra('user', function ($user) { module_extra::print_table_data('user', $user['user_id']); }); } $table_manager->pagination = true; $table_manager->print_table(); ?> </form>
if (isset($website['group_sort_website'])) { echo htmlspecialchars($website['group_sort_website']); } else { // find the groups for this website. $groups = module_group::get_groups_search(array('owner_table' => 'website', 'owner_id' => $website['website_id'])); $g = array(); foreach ($groups as $group) { $g[] = $group['name']; } echo htmlspecialchars(implode(', ', $g)); } }); } if (class_exists('module_extra', false)) { $table_manager->display_extra('website', function ($website) { module_extra::print_table_data('website', $website['website_id']); }); } if (class_exists('module_subscription', false)) { $table_manager->display_subscription('website', function ($website) { module_subscription::print_table_data('website', $website['website_id']); }); } $table_manager->set_columns($columns); $table_manager->row_callback = function ($row_data) { // load the full vendor data before displaying each row so we have access to more details return module_website::get_website($row_data['website_id']); }; $table_manager->set_rows($websites); $table_manager->pagination = true; $table_manager->print_table();