It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In RegisterIt looks like you're new here. If you want to get involved, click one of these buttons!
Hey, if there are guys like me who would like to add attachment to their invoices, follow the guide. credits to developer Eric.
i'm attaching a picture for every step to make it clear. I hope i didn't forget anything, if you have some problems don't hesitate to ask
1: open application/modules/invoices/views/create_invoice_form.php
we're going to create a field/button for uploads. i've added this right under the notes section to my liking, you can add it where you like
<div class="form-group">
<div class="fileinput fileinput-new" data-provides="fileinput">
<span class="btn green btn-file">
<span class="fileinput-new"> <?php _e('message_add_file'); ?> /</span>
<span class="fileinput-exists"> <?php _e('label_change'); ?> </span>
<input type="file" name="invoices_attachment"> </span>
<span class="fileinput-filename"> </span>
<a href="javascript:;" class="close fileinput-exists" data-dismiss="fileinput"> </a>
</div>
</div>
2: open application/modules/invoices/views/index.php
make a place for attachment at the table , add the folowing code to your liking.
<?php _e('label_attachment'); ?>i've added the attachment field after date-due field.
function viewAttachment(value, row, index) {
if (value != "")
{
url = $('#base-url').data('target');
return '' + value + ' ';
}
}
add this code right under create_invoice() function:
//Bijlage toevoegen
$config['upload_path'] = './uploads/incomes/attachments';
$config['allowed_types'] = '*';
$config['overwrite'] = TRUE;
$this->load->library('upload', $config);
$this->upload->do_upload('invoices_attachment');
$invoice_attachment_data = $this->upload->data();
$invoiceTable['attachment_1'] = $invoice_attachment_data['file_name'];
Locate invoices_list and add the folowing code at the end of array_push:
'attachment' => $invoice->attachment_1
replace the send_email function with the following code:
function send_email($to, $message, $subject=null, $from=null, $invoice_number=null)
{
$CI =& get_instance();
$CI->load->library('email');
$config['protocol'] = 'mail';
$config['mailpath'] = '/usr/sbin/sendmail';
$config['charset'] = 'utf-8';
$config['wordwrap'] = TRUE;
$config['mailtype'] = 'html';
$config['validate'] = 'true';
if($invoice_number)
{
$file_name = get_invoice_attachment($invoice_number);
$path = "https://www.HEREYOURSITEANDPATH.COM/uploads/incomes/attachments/";
$path .=$file_name;
}
else {
return false;
}
$CI->email->initialize($config);
$CI->email->from(isset($from) ? $from : get_option('email'), null == get_option('company') ? get_option('email') : get_option('company'));
$CI->email->to($to);
$CI->email->subject(isset($subject) ? $subject : __('no_subject'));
$CI->email->message($message);
if ($path)
{
$CI->email->attach($path); // This portion appends the file name to the path
}
$CI->email->send();
}
Comments
Great job !!

You did 99% by yourself, I added the 1% for bug fix. Thank you for sharing. This will be added with perhaps a drop files area