include('quote_public.php'); $quote['quote_tasks'] = ob_get_clean();*/ // generate the PDF ready for sending. $pdf = module_quote::generate_pdf($quote_id); // find available "to" recipients. // customer contacts. $to_select = false; if ($quote['customer_id']) { $customer = module_customer::get_customer($quote['customer_id']); $quote['customer_name'] = $customer['customer_name']; $to = module_user::get_contacts(array('customer_id' => $quote['customer_id'])); if ($quote['contact_user_id']) { $primary = module_user::get_user($quote['contact_user_id']); if ($primary) { $to_select = $primary['email']; } } else { if ($customer['primary_user_id']) { $primary = module_user::get_user($customer['primary_user_id']); if ($primary) { $to_select = $primary['email']; } } } } else { $to = array(); } $template->assign_values($quote); ob_start(); module_email::print_compose(array('title' => _l('Email Quote: %s', $quote['name']), 'find_other_templates' => 'quote_email', 'current_template' => $template_name, 'customer_id' => $quote['customer_id'], 'quote_id' => $quote['quote_id'], 'debug_message' => 'Sending quote 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_quote::link_open($quote_id), 'cancel_url' => module_quote::link_open($quote_id), 'attachments' => array(array('path' => $pdf, 'name' => basename($pdf), 'preview' => module_quote::link_public_print($quote_id)))));
$data_field['value'] = $data_items[$data_field_id]['data_text']; // todo, could be data_number or data_varchar as well... hmmm } $replace[$data_field['title']] = $module->get_form_element($data_field, true, isset($data_record) ? $data_record : array()); } } //$pdf = module_invoice::generate_pdf($invoice_id); // template for sending emails. // are we sending the paid one? or the dueone. $original_template_name = $template_name = $data_type['email_template']; $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : $template_name; $template = module_template::get_template_by_key($template_name); $template->assign_values($replace); $module->page_title = htmlspecialchars($data_type['data_type_name']); print_heading(array('main' => true, 'type' => 'h2', 'title' => htmlspecialchars($data_type['data_type_name']))); module_email::print_compose(array('title' => _l('Email: %s', htmlspecialchars($data_type['data_type_name'])), 'find_other_templates' => $original_template_name, 'current_template' => $template_name, 'customer_id' => isset($_REQUEST['customer_id']) ? (int) $_REQUEST['customer_id'] : 0, 'to' => array(), 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => $module->link('', array('data_type_id' => $data_type_id, 'data_record_id' => $data_record_id, 'mode' => 'view')), 'cancel_url' => $module->link('', array('data_type_id' => $data_type_id, 'data_record_id' => $data_record_id, 'mode' => 'view')))); ?> <p> Available Template Keys: </p> <ul> <?php foreach ($replace as $key => $val) { if (strpos($val, 'encrypt_popup')) { continue; } ?> <li><strong>{<?php echo strtoupper(htmlspecialchars($key)); ?> }</strong> = <?php echo $val;
$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 { if ($invoice['member_id']) { $member = module_member::get_member($invoice['member_id']); $to = array($member); $replace['customer_name'] = $member['first_name']; } else { $to = array(); } } $template->assign_values($replace); module_email::print_compose(array('title' => _l('Email Invoice: %s', $invoice['name']), 'find_other_templates' => 'invoice_email', 'current_template' => $template_name, 'customer_id' => $invoice['customer_id'], 'company_id' => isset($invoice['company_id']) ? $invoice['company_id'] : 0, 'to' => $to, 'to_select' => $to_select, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_invoice::link_open($invoice_id), 'success_callback' => 'module_invoice::email_sent', 'success_callback_args' => array('invoice_id' => $invoice_id, 'template_name' => $template_name), 'invoice_id' => $invoice_id, 'cancel_url' => module_invoice::link_open($invoice_id), 'attachments' => array(array('path' => $pdf, 'name' => basename($pdf), 'preview' => module_invoice::link_generate($invoice_id, array('arguments' => array('go' => 1, 'print' => 1), 'page' => 'invoice_admin', 'full' => false))))));
// are we sending the paid one? or the dueone. $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'quote_staff_email'; $template = module_template::get_template_by_key($template_name); $quote['quote_name'] = $quote['name']; $quote['staff_name'] = $staff['name']; $quote['quote_url'] = module_quote::link_open($quote_id); $quote['quote_tasks'] = '<ul>'; $quote['task_count'] = 0; foreach ($quote_tasks as $quote_task) { if ($quote_task['user_id'] != $staff_id) { continue; } $quote['quote_tasks'] .= '<li><strong>' . $quote_task['description'] . '</strong>'; $quote['quote_tasks'] .= ' <br/>'; if ($quote_task['long_description']) { $quote['quote_tasks'] .= _l('Notes:') . ' <em>' . $quote_task['long_description'] . '</em><br/>'; } if ($quote_task['hours']) { $quote['quote_tasks'] .= _l('Hours:') . ' ' . $quote_task['hours'] . '<br/>'; } $quote['quote_tasks'] .= '</li>'; $quote['task_count']++; } $quote['quote_tasks'] .= '</ul>'; // find available "to" recipients. // customer contacts. $to = array(); $to[] = array('name' => $staff['name'], 'email' => $staff['email']); $template->assign_values($quote); module_email::print_compose(array('title' => _l('Email Quote: %s', $quote['name']), 'find_other_templates' => 'quote_staff_email', 'current_template' => $template_name, 'quote_id' => $quote['quote_id'], 'debug_message' => 'Sending quote to staff', 'to' => $to, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_quote::link_open($quote_id), 'cancel_url' => module_quote::link_open($quote_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)));
<?php /** * Copyright: dtbaker 2012 * Licence: Please check CodeCanyon.net for licence details. * More licence clarification available here: http://codecanyon.net/wiki/support/legal-terms/licensing-terms/ * Deploy: 9809 f200f46c2a19bb98d112f2d32a8de0c4 * Envato: 4ffca17e-861e-4921-86c3-8931978c40ca * Package Date: 2015-11-25 02:55:20 * IP Address: 67.79.165.254 */ if (!$ticket_safe) { die('failed'); } $ticket_id = (int) $_REQUEST['ticket_id']; $ticket = module_ticket::get_ticket($ticket_id); print_heading(_l('Notify Staff About Ticket: %s', module_ticket::ticket_number($ticket['ticket_id']))); // template for sending emails. // are we sending the paid one? or the dueone. $template = module_template::get_template_by_key('ticket_email_notify'); $ticket['ticket_number'] = module_ticket::ticket_number($ticket['ticket_id']); $ticket['from_name'] = module_security::get_loggedin_name(); $ticket['ticket_url'] = module_ticket::link_open($ticket_id); $ticket['ticket_subject'] = $ticket['subject']; // sending to the staff member. $to = module_user::get_user($ticket['assigned_user_id']); $ticket['staff_name'] = $to['name'] . ' ' . $to['last_name']; $to = array($to); $template->assign_values($ticket); module_email::print_compose(array('to' => $to, 'bcc' => module_config::c('admin_email_address', ''), 'content' => $template->render('html'), 'subject' => $template->replace_description(), 'success_url' => module_ticket::link_open($ticket_id), 'cancel_url' => module_ticket::link_open($ticket_id)));
$invoices = module_invoice::get_invoices(array('customer_id' => $customer['customer_id'], 'date_paid' => '0000-00-00')); // remove cancelled invoices foreach ($invoices as $invoice_id => $invoice) { if ($invoice['date_cancel'] != '0000-00-00') { unset($invoices[$invoice_id]); } } if (count($invoices)) { $fieldset_data = array('heading' => array('type' => 'h3', 'title' => _l('Unpaid Invoices'))); $fieldset_data['elements_before'] = customer_admin_email_generate_invoice_list($invoices, $customer_id); $email_details .= module_form::generate_fieldset($fieldset_data); } } } $template->assign_values(array('email_details' => $email_details)); module_email::print_compose(array('title' => _l('Email Customer: %s', $customer['customer_name']), 'find_other_templates' => 'customer_statement_email', 'current_template' => $template_name, 'customer_id' => $customer['customer_id'], 'debug_message' => 'Sending customer statement 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_customer::link_open($customer['customer_id']), 'cancel_url' => module_customer::link_open($customer['customer_id']))); } else { ?> <form action="" method="post" id="customer_form"> <input type="hidden" name="customer_id" value="<?php echo $customer_id; ?> " /> <input type="hidden" name="email" value="1" /> <input type="hidden" name="preview_email" value="1" /> <?php module_form::prevent_exit(array('valid_exits' => array('.submit_button'))); module_form::print_form_auth(); $elements = array();
Thank you,<br><br> {FROM_NAME} ', 'Change Request: {URL}', array('NAME' => 'Customers Name', 'URL' => 'Website address', 'REQUEST' => 'Change REquest', 'FROM_NAME' => 'Your name', 'CHANGE_REQUEST_URL' => 'Link to change request for customer')); // template for sending emails. // are we sending the paid one? or the dueone. //$template_name = 'change_request_email'; $template_name = isset($_REQUEST['template_name']) ? $_REQUEST['template_name'] : 'change_request_email'; $template = module_template::get_template_by_key($template_name); $change_request['from_name'] = module_security::get_loggedin_name(); $change_request['change_request_url'] = module_change_request::link_public_change($website_data['website_id'], $change_request_id); ob_start(); $change_request['change_request_tasks'] = ob_get_clean(); // find available "to" recipients. // customer contacts. $to_select = false; if ($website_data['customer_id']) { $customer = module_customer::get_customer($website_data['customer_id']); $change_request['customer_name'] = $customer['customer_name']; $to = module_user::get_contacts(array('customer_id' => $website_data['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(); } $template->assign_values($change_request); module_email::print_compose(array('find_other_templates' => 'change_request_email', 'current_template' => $template_name, 'customer_id' => $website_data['customer_id'], 'change_request_id' => $change_request['change_request_id'], 'debug_message' => 'Sending change request 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_website::link_open($website_data['website_id']), 'cancel_url' => module_website::link_open($website_data['website_id'])));