/**
  * function quotelisttable for the emails
  * @param $atts Array - an associative array of attributes (preferences)
  * @param $content  String -  the enclosed content
  * @param $code String -  the shortcode name
  * @code
  * @static
  */
 static function quotelisttable($atts, $content = null, $code = "")
 {
     global $dvin_wcql_settings, $dvin_qlist_products;
     list(, $table) = get_qlist_table($atts);
     return $table;
 }
 /**
  * function send_email, Sends Email
  * @access  public static
  * @return boolean 
  */
 public function send_email()
 {
     global $dvin_qlist_products, $dvin_wcql_settings;
     $overall_tot_price = 0;
     $email = get_option('dvin_wcql_admin_email');
     $postfix_email = get_option('dvin_wcql_admin_postfix_email');
     $subject = get_option('dvin_wcql_email_subject');
     $message = get_option('dvin_wcql_email_msg');
     $cc = get_option('dvin_wcql_copy_toreq');
     list($overall_tot_price, $quote_list) = get_qlist_table(array());
     $overall_tot_price_str = isset($overall_tot_price) ? apply_filters('woocommerce_cart_item_price_html', woocommerce_price($overall_tot_price)) : '';
     $needle_arr = array('[%req_name%]', '[%req_email%]', '[%quotelist%]', '[%total_price%]', '[%comments%]');
     $replace_with_arr = array(ucwords($_POST['req_name']), $_POST['req_email'], $quote_list, $overall_tot_price_str, $_POST['req_details']);
     //apply filters  to capture custom fileds names in [%filed_name%]
     $needle_arr = apply_filters('dvin_wcql_custom_fields_needles', $needle_arr);
     //apply filters for
     $replace_with_arr = apply_filters('dvin_wcql_custom_fields_replacements', $replace_with_arr);
     //include the validation file if exists
     if (file_exists(TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'custom-field-arr.php')) {
         include TEMPLATEPATH . '/' . Dvin_Wcql::template_path() . 'custom-field-arr.php';
     } elseif (file_exists(STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'custom-field-arr.php')) {
         include STYLESHEETPATH . '/' . Dvin_Wcql::template_path() . 'custom-field-arr.php';
     }
     $subject = str_replace($needle_arr, $replace_with_arr, $subject);
     $message = str_replace($needle_arr, $replace_with_arr, $message);
     $message = '<html><body><style>table, th, td{border: 1px solid black;}</style>' . $message . '</body></html>';
     $headers = 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n";
     // Additional headers
     $from_admin_email = !empty($postfix_email) ? $postfix_email : $_POST['req_name'] . '<' . $_POST['req_email'] . '>';
     $to_admin_headers = $headers . 'From: ' . $from_admin_email . "\r\n";
     $to_admin_headers = $to_admin_headers . 'Reply-to: ' . $_POST['req_name'] . '<' . $_POST['req_email'] . ">\r\n";
     //check for whether to send copy to customer
     if ($cc == "on") {
         $to_customer_headers = $headers . 'From: ' . $email . "\r\n";
     }
     //get order info. in case of admin email
     $admin_message = str_replace('[%orderinfo%]', $this->get_order_info(), $message);
     //replace with nothing in case of client
     $message = str_replace('[%orderinfo%]', '', $message);
     //send the email
     if (wp_mail($email, $subject, nl2br($admin_message), $to_admin_headers)) {
         if ($to_customer_headers != '') {
             if (wp_mail($_POST['req_email'], $subject, nl2br($message), $to_customer_headers)) {
                 $dvin_qlist_products = array();
                 WC()->session->set('dvin_qlist_products', array());
                 return true;
             }
         } else {
             $dvin_qlist_products = array();
             WC()->session->set('dvin_qlist_products', array());
             return true;
         }
     }
     return false;
 }