<?php
include_once(dirname(__FILE__) . '/../../class/include.php');
if (isset($_POST['save_invoice'])) {
$createdAt = date('Y-m-d H:i:s');
$INVOICE = new Invoice(NULL);
$INVOICE->date = $_POST['date'];
$INVOICE->created_at = $createdAt;
$INVOICE->customer = $_POST['customer'];
$INVOICE->customer_address = $_POST['customer_address'];
$INVOICE->customer_phone = $_POST['customer_phone'];
$INVOICE->function_date = $_POST['function_date'];
$INVOICE->number_of_pax = $_POST['number_of_pax'];
$result = $INVOICE->create();
foreach ($_POST["description"] as $key => $description) {
$INVOICE_ITEM = new InvoiceItem(NULL);
$INVOICE_ITEM->description = $description;
$INVOICE_ITEM->amount = $_POST["amount"][$key];
$INVOICE_ITEM->invoice = $result['id'];
$INVOICE_ITEM->create();
}
if ($result) {
header("location: ../print-invoice.php?id=" . $result['id']);
} else {
header("location: ../create-invoice.php?message=9");
}
} |