Пример #1
0
 public function send_quote($quote_id)
 {
     if ($this->input->post('btn_cancel')) {
         redirect('quotes');
     }
     if (!$this->mailer_configured) {
         return;
     }
     $this->load->model('upload/mdl_uploads');
     $from = array($this->input->post('from_email'), $this->input->post('from_name'));
     $pdf_template = $this->input->post('pdf_template');
     $to = $this->input->post('to_email');
     $subject = $this->input->post('subject');
     if (strlen($this->input->post('body')) != strlen(strip_tags($this->input->post('body')))) {
         $body = htmlspecialchars_decode($this->input->post('body'));
     } else {
         $body = htmlspecialchars_decode(nl2br($this->input->post('body')));
     }
     $cc = $this->input->post('cc');
     $bcc = $this->input->post('bcc');
     $attachment_files = $this->mdl_uploads->get_quote_uploads($quote_id);
     if (email_quote($quote_id, $pdf_template, $from, $to, $subject, $body, $cc, $bcc, $attachment_files)) {
         $this->mdl_quotes->mark_sent($quote_id);
         $this->session->set_flashdata('alert_success', lang('email_successfully_sent'));
         redirect('dashboard');
     } else {
         redirect('mailer/quote/' . $quote_id);
     }
 }
Пример #2
0
 public function quote($quote_id)
 {
     if ($this->mailer_configured == TRUE) {
         if ($this->input->post('btn_send')) {
             $from = $this->input->post('from_name') ? array($this->input->post('from_email'), $this->input->post('from_name')) : $this->input->post('from_email');
             $quote_template = $this->input->post('quote_template');
             $to = $this->input->post('to_email');
             $subject = $this->input->post('subject');
             $body = $this->input->post('body') ?: ' ';
             $cc = $this->input->post('to_cc');
             $bcc = $this->input->post('to_bcc');
             if (email_quote($quote_id, $quote_template, $from, $to, $subject, $body, $cc, $bcc)) {
                 $this->mdl_quotes->mark_sent($quote_id);
                 $this->session->set_flashdata('alert_success', lang('email_successfully_sent'));
                 redirect('dashboard');
             } else {
                 redirect('mailer/quote/' . $quote_id);
             }
         }
         $this->load->model('invoices/mdl_templates');
         $this->load->model('quotes/mdl_quotes');
         $this->load->model('email_templates/mdl_email_templates');
         $email_template_id = $this->mdl_settings->setting('default_email_template');
         if ($email_template_id) {
             $email_template = $this->mdl_email_templates->where('email_template_id', $email_template_id)->get();
             if ($email_template->num_rows()) {
                 $this->layout->set('body', $email_template->row()->email_template_body);
             } else {
                 $this->layout->set('body', '');
             }
         } else {
             $this->layout->set('body', '');
         }
         $this->layout->set('email_templates', $this->mdl_email_templates->get()->result());
         $this->layout->set('quote', $this->mdl_quotes->where('fi_quotes.quote_id', $quote_id)->get()->row());
         $this->layout->set('quote_templates', $this->mdl_templates->get_quote_templates());
         $this->layout->buffer('content', 'mailer/quote');
         $this->layout->render();
     } else {
         $this->layout->buffer('content', 'mailer/not_configured');
         $this->layout->render();
     }
 }