コード例 #1
0
ファイル: mailer.php プロジェクト: webesen/InvoicePlane
 public function invoice($invoice_id)
 {
     if (!$this->mailer_configured) {
         return;
     }
     $this->load->model('invoices/mdl_templates');
     $this->load->model('invoices/mdl_invoices');
     $this->load->model('email_templates/mdl_email_templates');
     $this->load->helper('template');
     $invoice = $this->mdl_invoices->where('ip_invoices.invoice_id', $invoice_id)->get()->row();
     $email_template_id = select_email_invoice_template($invoice);
     if ($email_template_id) {
         $email_template = $this->mdl_email_templates->where('email_template_id', $email_template_id)->get();
         $this->layout->set('email_template', json_encode($email_template->row()));
     } else {
         $this->layout->set('email_template', '{}');
     }
     $this->layout->set('selected_pdf_template', select_pdf_invoice_template($invoice));
     $this->layout->set('selected_email_template', $email_template_id);
     $this->layout->set('email_templates', $this->mdl_email_templates->where('email_template_type', 'invoice')->get()->result());
     $this->layout->set('invoice', $invoice);
     $this->layout->set('pdf_templates', $this->mdl_templates->get_invoice_templates());
     $this->layout->buffer('content', 'mailer/invoice');
     $this->layout->render();
 }
コード例 #2
0
ファイル: mailer.php プロジェクト: yalmasri/fusioninvoice
 public function invoice($invoice_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');
             $invoice_template = $this->input->post('invoice_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_invoice($invoice_id, $invoice_template, $from, $to, $subject, $body, $cc, $bcc)) {
                 $this->mdl_invoices->mark_sent($invoice_id);
                 $this->session->set_flashdata('alert_success', lang('email_successfully_sent'));
                 redirect('dashboard');
             } else {
                 redirect('mailer/invoice/' . $invoice_id);
             }
         }
         $this->load->model('invoices/mdl_templates');
         $this->load->model('invoices/mdl_invoices');
         $this->load->model('email_templates/mdl_email_templates');
         $invoice = $this->mdl_invoices->where('fi_invoices.invoice_id', $invoice_id)->get()->row();
         $this->load->helper('template');
         $selected_pdf_template = select_pdf_invoice_template($invoice);
         $selected_email_template = select_email_invoice_template($invoice);
         if ($selected_email_template) {
             $email_template = $this->mdl_email_templates->where('email_template_id', $selected_email_template)->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('selected_pdf_template', $selected_pdf_template);
         $this->layout->set('selected_email_template', $selected_email_template);
         $this->layout->set('email_templates', $this->mdl_email_templates->get()->result());
         $this->layout->set('invoice', $invoice);
         $this->layout->set('invoice_templates', $this->mdl_templates->get_invoice_templates());
         $this->layout->buffer('content', 'mailer/invoice');
         $this->layout->render();
     } else {
         $this->layout->buffer('content', 'mailer/not_configured');
         $this->layout->render();
     }
 }