include $_SERVER['DOCUMENT_ROOT'] . "/WebBuilder/WebApp.class.php";
$db = new DBMain();
// BUILD invoice Contents
$content = '';
$index = 1;
while ($index < $_POST['rows']) {
if (strlen($_POST['item_desciption_' . $index]) < 1) {
// echo 'les than' . strlen($_POST['item_desciption_' . $index]) . " : {$_POST['item_desciption_' .$index]}";
// echo "
$index
";
} else {
$content = $content . $_POST['item_desciption_' . $index] . "," . $_POST['item_quantity_' . $index] . "," . $_POST['item_amount_' . $index] . "," . $_POST['item_discount_' . $index] . "," . $_POST['item_total_' . $index] . ";";
}
$index++;
}
if($_POST['quote_no'] == '') {
$_POST['quote_no'] = 0;
}
$record_id = $db->Update('invoices', ['invoice_no', 'quotes_id', 'invoice_content', 'total', 'clients_id', 'status', 'date_created', 'date_sent', 'date_due', 'description'], [$_POST['invoice_no'], $_POST['quote_no'], $content, $_POST['total'], $_POST['client_id'], $_POST['status'], $_POST['date'], '', $_POST['exp_date'], $_POST['description']], "record_id = {$_POST['record_id']}");
if ($record_id > 0) {
echo "";
} else {
echo "ENCOUNTERED AN ERROR PLEASE TRY AGAIN";
}