$invoiceItem->save(); } } } } } } $TPL["message_good"][] = "Invoice Item saved."; alloc_redirect($TPL["url_alloc_invoice"] . "invoiceID=" . $invoiceItem->get_value("invoiceID")); } else { if ($_POST["invoiceItem_edit"]) { // Hmph. Nothing needs to go here? } else { if ($_POST["invoiceItem_delete"]) { $invoiceItem->select(); $invoiceItem->delete(); $TPL["message_good"][] = "Invoice Item deleted."; alloc_redirect($TPL["url_alloc_invoice"] . "invoiceID=" . $invoiceID); } } } // Displaying a record $invoice->set_id($invoiceID); $invoice->select(); // if someone uploads an attachment } else { if ($_POST["save_attachment"]) { move_attachment("invoice", $invoiceID); $TPL["message_good"][] = "Attachment saved."; alloc_redirect($TPL["url_alloc_invoice"] . "invoiceID=" . $invoiceID); }
function delete() { $timeSheetID = $this->get_value("timeSheetID"); $db = new db_alloc(); $q = prepare("SELECT invoiceItem.*\n FROM invoiceItem\n LEFT JOIN invoice ON invoiceItem.invoiceID = invoice.invoiceID\n WHERE timeSheetID = %d\n AND invoiceStatus != 'finished'", $timeSheetID); $db->query($q); while ($row = $db->row()) { $ii = new invoiceItem(); $ii->set_id($row["invoiceItemID"]); $ii->select(); if ($ii->get_value("timeSheetItemID") == $this->get_id()) { $ii->delete(); } else { if (!$ii->get_value("timeSheetItemID")) { invoiceEntity::save_invoice_timeSheet($row["invoiceID"], $timeSheetID); // will update the existing invoice item } } } return parent::delete(); }