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; } }
<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());
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; }
$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; ?> " />
<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
public static function delete_quote($quote_id) { $quote_id = (int) $quote_id; if (_DEMO_MODE && $quote_id == 1) { return; } if ((int) $quote_id > 0) { $original_quote_data = self::get_quote($quote_id); if (!$original_quote_data || $original_quote_data['quote_id'] != $quote_id) { return false; } } else { return false; } if (!self::can_i('delete', 'Quotes')) { return false; } $sql = "DELETE FROM " . _DB_PREFIX . "quote WHERE quote_id = '" . $quote_id . "' LIMIT 1"; $res = query($sql); $sql = "DELETE FROM " . _DB_PREFIX . "quote_tax WHERE quote_id = '" . $quote_id . "'"; $res = query($sql); $sql = "DELETE FROM " . _DB_PREFIX . "quote_task WHERE quote_id = '" . $quote_id . "'"; $res = query($sql); if (class_exists('module_file', false)) { $sql = "UPDATE " . _DB_PREFIX . "file SET quote_id = 0 WHERE quote_id = '" . $quote_id . "'"; query($sql); } if (class_exists('module_group', false)) { module_group::delete_member($quote_id, 'quote'); } if (class_exists('module_note', false) && module_note::is_plugin_enabled()) { module_note::note_delete("quote", $quote_id); } if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { module_extra::delete_extras('quote', 'quote_id', $quote_id); } hook_handle_callback('quote_delete', $quote_id); module_cache::clear('quote'); }
public static function delete_job($job_id) { $job_id = (int) $job_id; if (_DEMO_MODE && $job_id == 1) { return; } if ((int) $job_id > 0) { $original_job_data = self::get_job($job_id); if (!$original_job_data || $original_job_data['job_id'] != $job_id) { return false; } } if (!self::can_i('delete', 'Jobs')) { return false; } $sql = "DELETE FROM " . _DB_PREFIX . "job WHERE job_id = '" . $job_id . "' LIMIT 1"; $res = query($sql); $sql = "DELETE FROM " . _DB_PREFIX . "task WHERE job_id = '" . $job_id . "'"; $res = query($sql); $sql = "DELETE FROM " . _DB_PREFIX . "task_log WHERE job_id = '" . $job_id . "'"; $res = query($sql); $sql = "UPDATE " . _DB_PREFIX . "job SET renew_job_id = NULL WHERE renew_job_id = '" . $job_id . "'"; $res = query($sql); if (class_exists('module_file', false)) { $sql = "UPDATE " . _DB_PREFIX . "file SET job_id = 0 WHERE job_id = '" . $job_id . "'"; query($sql); } if (class_exists('module_group', false)) { module_group::delete_member($job_id, 'job'); } foreach (module_invoice::get_invoices(array('job_id' => $job_id)) as $val) { // only delete this invoice if it has no tasks left // it could be a combined invoice with other jobs now. $invoice_items = module_invoice::get_invoice_items($val['invoice_id']); if (!count($invoice_items)) { module_invoice::delete_invoice($val['invoice_id']); } } if (class_exists('module_note', false) && module_note::is_plugin_enabled()) { module_note::note_delete("job", $job_id); } if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { module_extra::delete_extras('job', 'job_id', $job_id); } hook_handle_callback('job_delete', $job_id); module_cache::clear('job'); }
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 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(); }
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(); }
public static function get_replace_fields($customer_id, $primary_user_id = false) { $customer_data = module_customer::get_customer($customer_id); $address_combined = array(); if (isset($customer_data['customer_address'])) { foreach ($customer_data['customer_address'] as $key => $val) { if (strlen(trim($val))) { $address_combined[$key] = $val; } } } // do we use the primary contact or $contact_data = module_user::get_user($primary_user_id ? $primary_user_id : $customer_data['primary_user_id']); //print_r($contact_data);exit; if ($contact_data && $contact_data['customer_id'] != $customer_id && (!isset($contact_data['linked_parent_user_id']) || !$contact_data['linked_parent_user_id'])) { $contact_data = array('user_id' => 0, 'customer_id' => 0, 'name' => '', 'last_name' => '', 'email' => '', 'password' => '', 'phone' => '', 'mobile' => '', 'fax' => ''); } $data = array('customer_details' => ' - todo - ', 'customer_name' => isset($customer_data['customer_name']) ? htmlspecialchars($customer_data['customer_name']) : _l('N/A'), 'customer_address' => htmlspecialchars(implode(', ', $address_combined)), 'contact_name' => $contact_data['name'] != $contact_data['email'] ? htmlspecialchars($contact_data['name'] . ' ' . $contact_data['last_name']) : '', 'contact_first_name' => $contact_data['name'], 'contact_last_name' => $contact_data['last_name'], 'first_name' => $contact_data['name'], 'last_name' => $contact_data['last_name'], 'contact_email' => htmlspecialchars($contact_data['email']), 'contact_phone' => htmlspecialchars($contact_data['phone']), 'contact_mobile' => htmlspecialchars($contact_data['mobile']), 'customer_invoice_prefix' => isset($customer_data['default_invoice_prefix']) ? $customer_data['default_invoice_prefix'] : ''); $data = array_merge($customer_data, $data); foreach ($customer_data['customer_address'] as $key => $val) { $data['address_' . $key] = $val; } if (class_exists('module_group', false) && module_group::is_plugin_enabled()) { // get the customer groups $g = array(); if ((int) $customer_data['customer_id'] > 0) { foreach (module_group::get_groups_search(array('owner_table' => 'customer', 'owner_id' => $customer_data['customer_id'])) as $group) { $g[] = $group['name']; } } $data['customer_group'] = implode(', ', $g); // get the customer groups $g = array(); if ($customer_id > 0) { $customer_data = module_customer::get_customer($customer_id); foreach (module_group::get_groups_search(array('owner_table' => 'customer', 'owner_id' => $customer_id)) as $group) { $g[$group['group_id']] = $group['name']; } } $data['customer_group'] = implode(', ', $g); } // addition. find all extra keys for this customer and add them in. // we also have to find any EMPTY extra fields, and add those in as well. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('customer'); foreach ($all_extra_fields as $e) { $data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'customer', 'owner_id' => $customer_id)); foreach ($extras as $e) { $data[$e['extra_key']] = $e['extra']; } // and the primary contact $all_extra_fields = module_extra::get_defaults('user'); foreach ($all_extra_fields as $e) { $data[$e['key']] = _l('N/A'); } if ($contact_data && $contact_data['user_id']) { // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact_data['user_id'])); foreach ($extras as $e) { $data[$e['extra_key']] = $e['extra']; } } } return $data; }
public static function get_replace_fields($user_id) { // do we use the primary contact or $contact_data = module_user::get_user($user_id); //print_r($contact_data);exit; if ($contact_data && $contact_data['user_id'] != $user_id) { $contact_data = array('user_id' => 0, 'customer_id' => 0, 'name' => '', 'last_name' => '', 'email' => '', 'password' => '', 'phone' => '', 'mobile' => '', 'fax' => ''); } $contact_data['password'] = ''; $contact_data['first_name'] = $contact_data['name']; // addition. find all extra keys for this customer and add them in. // we also have to find any EMPTY extra fields, and add those in as well. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { // and the primary contact $all_extra_fields = module_extra::get_defaults('user'); foreach ($all_extra_fields as $e) { $contact_data[$e['key']] = _l('N/A'); } if ($contact_data && $contact_data['user_id']) { // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'user', 'owner_id' => $contact_data['user_id'])); foreach ($extras as $e) { $contact_data[$e['extra_key']] = $e['extra']; } } } return $contact_data; }
$heading['button'] = array('url' => '#', 'onclick' => "alert('{$help_text}'); return false;", 'title' => 'help'); } //print_heading($heading); $company_fields = array(); foreach ($companys as $company) { $company_fields[] = array('type' => 'hidden', 'name' => "available_customer_company[" . $company['company_id'] . "]", 'value' => 1); $company_fields[] = array('type' => 'check', 'name' => "customer_company[" . $company['company_id'] . "]", 'value' => $company['company_id'], 'checked' => isset($customer['company_ids'][$company['company_id']]) || !$customer_id && !module_company::can_i('edit', 'Company'), 'label' => htmlspecialchars($company['name'])); } $fieldset_data = array('heading' => $heading, 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('company' => array('title' => _l('Company'), 'fields' => $company_fields))); echo module_form::generate_fieldset($fieldset_data); } /** CUSTOMER INFORMATION **/ $responsive_summary = array(); $responsive_summary[] = htmlspecialchars($customer['customer_name']); $fieldset_data = array('heading' => array('type' => 'h3', 'title' => $page_type_single . ' Information', 'responsive' => array('title' => $page_type_single, 'summary' => implode(', ', $responsive_summary))), 'class' => 'tableclass tableclass_form tableclass_full', 'elements' => array('name' => array('title' => _l('Name'), 'field' => array('type' => 'text', 'name' => 'customer_name', 'value' => $customer['customer_name'])), 'type' => array('title' => _l('Type'), 'ignore' => !module_customer::get_customer_types(), 'field' => array('type' => 'select', 'name' => 'customer_type_id', 'value' => $customer['customer_type_id'], 'blank' => false, 'options' => module_customer::get_customer_types(), 'options_array_id' => 'type_name')))); if (class_exists('module_extra', false) && module_extra::is_plugin_enabled() && module_extra::can_i('view', $page_type)) { $fieldset_data['extra_settings'] = array('owner_table' => 'customer', 'owner_key' => 'customer_id', 'owner_id' => $customer_id, 'layout' => 'table_row', 'allow_new' => module_extra::can_i('create', $page_type), 'allow_edit' => module_extra::can_i('edit', $page_type)); } echo module_form::generate_fieldset($fieldset_data); unset($fieldset_data); /** PRIMARY CONTACT DETAILS **/ // we use the "user" module to find the user details // for the currently selected primary contact id if ($customer['primary_user_id']) { if (!module_user::can_i('view', 'All ' . $page_type_single . ' Contacts', 'Customer', 'customer') && $customer['primary_user_id'] != module_security::get_loggedin_id()) { ob_start(); echo '<div class="content_box_wheader"><table width="100%" border="0" cellspacing="0" cellpadding="2" class="tableclass tableclass_form"><tbody><tr><td>'; _e('Details hidden'); echo '</td></tr></tbody></table></div>'; $responsive_summary = array(); $responsive_summary[] = htmlspecialchars($customer['customer_name']);
public static function get_replace_fields($ticket_id, $ticket_data = array()) { if (!$ticket_data) { $ticket_data = module_ticket::get_ticket($ticket_id); } $staff_user_id = $ticket_data['assigned_user_id'] ? $ticket_data['assigned_user_id'] : module_config::c('ticket_default_user_id', 1); $to = module_user::get_user($staff_user_id); //$ticket_data['assigned_user_id']); $ticket_data['staff_name'] = $to['name'] . ' ' . $to['last_name']; $ticket_data['ticket_number'] = module_ticket::ticket_number($ticket_data['ticket_id']); $ticket_contact = module_user::get_user($ticket_data['user_id'], false); $ticket_data['contact_name'] = (isset($ticket_contact['name']) ? $ticket_contact['name'] . ' ' : '') . (isset($ticket_contact['last_name']) ? $ticket_contact['last_name'] : ''); $ticket_data['contact_fname'] = isset($ticket_contact['name']) ? $ticket_contact['name'] : ''; $ticket_data['contact_lname'] = isset($ticket_contact['last_name']) ? $ticket_contact['last_name'] : ''; // addition. find all extra keys for this ticket and add them in. // we also have to find any EMPTY extra fields, and add those in as well. if (class_exists('module_extra', false) && module_extra::is_plugin_enabled()) { $all_extra_fields = module_extra::get_defaults('ticket'); foreach ($all_extra_fields as $e) { $ticket_data[$e['key']] = _l('N/A'); } // and find the ones with values: $extras = module_extra::get_extras(array('owner_table' => 'ticket', 'owner_id' => $ticket_id)); foreach ($extras as $e) { $ticket_data[$e['extra_key']] = $e['extra']; } } if (isset($ticket_data['faq_product_id']) && (int) $ticket_data['faq_product_id'] > 0) { $ticket_data['faq_product'] = friendly_key(module_faq::get_faq_products_rel(), $ticket_data['faq_product_id']); } else { $ticket_data['faq_product'] = _l('N/A'); } // find any extra keys (defined in the db for ticket submission, not the module_extra extra keys) $extras = module_ticket::get_ticket_extras_keys(); if (count($extras)) { foreach ($extras as $extra) { $key = strtolower($extra['key']); if (!isset($ticket_data[$key])) { $ticket_data[$key] = isset($ticket_data['extra_data'][$extra['ticket_data_key_id']]) ? $ticket_data['extra_data'][$extra['ticket_data_key_id']]['value'] : ''; } } } return $ticket_data; }