function attachment($id = FALSE) { $media = Expense::find_by_id($id); header('Content-Description: File Transfer'); header('Content-disposition: attachment; filename=' . $media->attachment); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize('./files/media/' . $media->attachment)); readfile('./files/media/' . $media->attachment); }
function attachment($id = FALSE) { $media = Expense::find_by_id($id); $file = './files/media/' . $media->attachment; if (file_exists($file)) { header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename=' . basename($file)); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize($file)); ob_clean(); flush(); readfile($file); exit; } }
function item($id = FALSE) { if ($_POST) { unset($_POST['send']); $_POST = array_map('htmlspecialchars', $_POST); if ($_POST['name'] != "") { $_POST['name'] = $_POST['name']; $_POST['value'] = $_POST['value']; $_POST['type'] = $_POST['type']; } else { if ($_POST['item_id'] == "-") { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error')); redirect('invoices/view/' . $_POST['invoice_id']); } else { $rebill = explode("_", $_POST['item_id']); if ($rebill[0] == "rebill") { $itemvalue = Expense::find_by_id($rebill[1]); $_POST['name'] = $itemvalue->description; $_POST['type'] = $_POST['item_id']; $_POST['value'] = $itemvalue->value; $itemvalue->rebill = 2; $itemvalue->invoice_id = $_POST['invoice_id']; $itemvalue->save(); } else { $itemvalue = Item::find_by_id($_POST['item_id']); $_POST['name'] = $itemvalue->name; $_POST['type'] = $itemvalue->type; $_POST['value'] = $itemvalue->value; } } } $item = InvoiceHasItem::create($_POST); if (!$item) { $this->session->set_flashdata('message', 'error:' . $this->lang->line('messages_add_item_error')); } else { $this->session->set_flashdata('message', 'success:' . $this->lang->line('messages_add_item_success')); } redirect('invoices/view/' . $_POST['invoice_id']); } else { $this->view_data['invoice'] = Invoice::find($id); $this->view_data['items'] = Item::find('all', array('conditions' => array('inactive=?', '0'))); $this->view_data['rebill'] = Expense::find('all', array('conditions' => array('project_id=? and (rebill=? or invoice_id=?)', $this->view_data['invoice']->project_id, 1, $id))); $this->theme_view = 'modal'; $this->view_data['title'] = $this->lang->line('application_add_item'); $this->view_data['form_action'] = 'invoices/item'; $this->content_view = 'invoices/_item'; } }