} if (!empty($action)) { switch ($action) { case 'add': if (empty($date) || strtotime($date) === FALSE) { $error_msg .= gettext("Date inserted is invalid, it must respect a date format YYYY-MM-DD HH:MM:SS (time is optional).<br/>"); } if (empty($price) || !is_numeric($price)) { $error_msg .= gettext("Amount inserted is invalid, it must be a number. Check the format."); } if (!empty($error_msg)) { break; } $DBHandle = DbConnect(); $receipt = new Receipt($id); $receipt->insertReceiptItem($description, $price); Header("Location: A2B_receipt_edit.php?" . "id=" . $id); break; case 'edit': if (!empty($idc) && is_numeric($idc)) { $DBHandle = DbConnect(); $instance_sub_table = new Table("cc_receipt_item", "*"); $result = $instance_sub_table->Get_list($DBHandle, "id = {$idc}"); if (!is_array($result) || sizeof($result) == 0) { Header("Location: A2B_receipt_edit.php?" . "id=" . $id); } else { $description = $result[0]['description']; $price = $result[0]['price']; $date = $result[0]['date']; } }