$quote['total_amount_due_print'] = dollar($quote['total_amount_due'], true, $quote['currency_id']); $quote['quote_name'] = $quote['name']; $quote['from_name'] = module_security::get_loggedin_name(); $quote['quote_url'] = module_quote::link_public($quote_id); ob_start(); include module_theme::include_ucm('includes/plugin_quote/template/quote_task_list.php'); $public_html = ob_get_clean(); $quote['task_list'] = $public_html; /*ob_start(); $quote_data = $quote; $ignore_task_hook=true; $for_email=true; include('quote_public.php'); $quote['quote_tasks'] = ob_get_clean();*/ // generate the PDF ready for sending. $pdf = module_quote::generate_pdf($quote_id); // 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']);
public static function quote_approved($quote_id) { module_cache::clear('quote'); $quote_data = module_quote::get_quote($quote_id); hook_handle_callback('quote_approved', $quote_id); self::add_history($quote_id, 'Quote approved by ' . $quote_data['approved_by']); if (module_config::c('quote_approval_auto_email', 1) && $quote_data['user_id']) { // send an email to the assigned staff member letting them know the quote was approved. $template = module_template::get_template_by_key('quote_approved_email'); $replace = module_quote::get_replace_fields($quote_id, $quote_data); if (defined('_BLOCK_EMAILS') && _BLOCK_EMAILS) { $pdf = false; } else { $pdf = module_quote::generate_pdf($quote_id); } $template->assign_values($replace); $html = $template->render('html'); // send an email to this user. $email = module_email::new_email(); $email->replace_values = $replace; $email->set_to('user', $quote_data['user_id']); $email->set_bcc_manual(module_config::c('admin_email_address', ''), ''); //$email->set_from('user',); // nfi $email->set_subject($template->description); // do we send images inline? $email->set_html($html); if ($pdf) { $email->add_attachment($pdf); } $email->quote_id = $quote_id; $email->customer_id = $quote_data['customer_id']; $email->prevent_duplicates = true; if ($email->send()) { // it worked successfully!! // record a log on the quote when it's done. self::add_history($quote_id, _l('Quote approval emailed to staff member')); } else { /// log err? } } module_cache::clear('quote'); }