|
@@ -44,6 +44,7 @@ else {
|
|
|
if (isset($_REQUEST["id"])) {
|
|
|
$action = "update";
|
|
|
$invoice_uuid = check_str($_REQUEST["id"]);
|
|
|
+ $back = check_str($_REQUEST['back']);
|
|
|
}
|
|
|
else {
|
|
|
$action = "add";
|
|
@@ -52,6 +53,7 @@ else {
|
|
|
//get http post variables and set them to php variables
|
|
|
if (count($_POST) > 0) {
|
|
|
$invoice_number = check_str($_POST["invoice_number"]);
|
|
|
+ $invoice_type = check_str($_POST["invoice_type"]);
|
|
|
$contact_uuid_from = check_str($_POST["contact_uuid_from"]);
|
|
|
$contact_uuid_to = check_str($_POST["contact_uuid_to"]);
|
|
|
$invoice_notes = check_str($_POST["invoice_notes"]);
|
|
@@ -94,6 +96,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
$sql .= "domain_uuid, ";
|
|
|
$sql .= "invoice_uuid, ";
|
|
|
$sql .= "invoice_number, ";
|
|
|
+ $sql .= "invoice_type, ";
|
|
|
$sql .= "contact_uuid_from, ";
|
|
|
$sql .= "contact_uuid_to, ";
|
|
|
$sql .= "invoice_notes, ";
|
|
@@ -104,6 +107,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
$sql .= "'$domain_uuid', ";
|
|
|
$sql .= "'$invoice_uuid', ";
|
|
|
$sql .= "'$invoice_number', ";
|
|
|
+ $sql .= "'$invoice_type', ";
|
|
|
$sql .= "'$contact_uuid_from', ";
|
|
|
$sql .= "'$contact_uuid_to', ";
|
|
|
$sql .= "'$invoice_notes', ";
|
|
@@ -112,33 +116,47 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
$db->exec(check_sql($sql));
|
|
|
unset($sql);
|
|
|
|
|
|
- require_once "resources/header.php";
|
|
|
- echo "<meta http-equiv=\"refresh\" content=\"2;url=invoices.php\">\n";
|
|
|
- echo "<div align='center'>\n";
|
|
|
- echo " ".$text['message-add']."\n";
|
|
|
- echo "</div>\n";
|
|
|
- require_once "resources/footer.php";
|
|
|
- return;
|
|
|
+ //set redirect
|
|
|
+ $_SESSION['message'] = $text['message-add'];
|
|
|
+ header("Location: invoices.php");
|
|
|
+ exit;
|
|
|
+
|
|
|
} //if ($action == "add")
|
|
|
|
|
|
if ($action == "update" && permission_exists('invoice_edit')) {
|
|
|
+ $invoice_paid = check_str($_POST["invoice_paid"]);
|
|
|
+ if ($invoice_paid == '1') {
|
|
|
+ $invoice_paid_date = check_str($_POST["invoice_paid_date"]);
|
|
|
+ $invoice_paid_method = check_str($_POST["invoice_paid_method"]);
|
|
|
+ $invoice_paid_method_ref = check_str($_POST["invoice_paid_method_ref"]);
|
|
|
+ }
|
|
|
+
|
|
|
+ //set defaults
|
|
|
+ $invoice_paid = ($invoice_paid != '1') ? 'null' : $invoice_paid;
|
|
|
+ $invoice_paid_date = ($invoice_paid_date == '') ? 'null' : "'".$invoice_paid_date."'";
|
|
|
+ $invoice_paid_method = ($invoice_paid_method == '') ? 'null' : "'".$invoice_paid_method."'";
|
|
|
+ $invoice_paid_method_ref = ($invoice_paid_method_ref == '') ? 'null' : "'".$invoice_paid_method_ref."'";
|
|
|
+
|
|
|
$sql = "update v_invoices set ";
|
|
|
$sql .= "invoice_number = '$invoice_number', ";
|
|
|
+ $sql .= "invoice_type = '$invoice_type', ";
|
|
|
$sql .= "contact_uuid_from = '$contact_uuid_from', ";
|
|
|
$sql .= "contact_uuid_to = '$contact_uuid_to', ";
|
|
|
+ $sql .= "invoice_paid = $invoice_paid, ";
|
|
|
+ $sql .= "invoice_paid_date = $invoice_paid_date, ";
|
|
|
+ $sql .= "invoice_paid_method = $invoice_paid_method, ";
|
|
|
+ $sql .= "invoice_paid_method_ref = $invoice_paid_method_ref, ";
|
|
|
$sql .= "invoice_notes = '$invoice_notes' ";
|
|
|
$sql .= "where domain_uuid = '$domain_uuid' ";
|
|
|
$sql .= "and invoice_uuid = '$invoice_uuid' ";
|
|
|
$db->exec(check_sql($sql));
|
|
|
unset($sql);
|
|
|
|
|
|
- require_once "resources/header.php";
|
|
|
- echo "<meta http-equiv=\"refresh\" content=\"2;url=invoices.php\">\n";
|
|
|
- echo "<div align='center'>\n";
|
|
|
- echo " ".$text['message-update']."\n";
|
|
|
- echo "</div>\n";
|
|
|
- require_once "resources/footer.php";
|
|
|
- return;
|
|
|
+ //set redirect
|
|
|
+ $_SESSION['message'] = $text['message-update'];
|
|
|
+ header("Location: ".(($back != '') ? $back : "invoices.php"));
|
|
|
+ exit;
|
|
|
+
|
|
|
} //if ($action == "update")
|
|
|
} //if ($_POST["persistformvar"] != "true")
|
|
|
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
|
|
@@ -154,13 +172,24 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
|
|
|
foreach ($result as &$row) {
|
|
|
$invoice_number = $row["invoice_number"];
|
|
|
+ $invoice_type = $row["invoice_type"];
|
|
|
$invoice_date = $row["invoice_date"];
|
|
|
+ $invoice_paid = $row["invoice_paid"];
|
|
|
+ $invoice_paid_date = $row["invoice_paid_date"];
|
|
|
+ $invoice_paid_method = $row["invoice_paid_method"];
|
|
|
+ $invoice_paid_method_ref = $row["invoice_paid_method_ref"];
|
|
|
$contact_uuid_from = $row["contact_uuid_from"];
|
|
|
$contact_uuid_to = $row["contact_uuid_to"];
|
|
|
$invoice_notes = $row["invoice_notes"];
|
|
|
break; //limit to 1 row
|
|
|
}
|
|
|
unset ($prep_statement);
|
|
|
+
|
|
|
+ //format paid date (if any)
|
|
|
+ if ($invoice_paid_date != '') {
|
|
|
+ $tmp = explode(' ',$invoice_paid_date);
|
|
|
+ $invoice_paid_date = $tmp[0];
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//show the header
|
|
@@ -183,26 +212,21 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
}
|
|
|
|
|
|
//show the content
|
|
|
- echo "<div align='center'>";
|
|
|
- echo "<table width='100%' border='0' cellpadding='0' cellspacing=''>\n";
|
|
|
- echo "<tr class='border'>\n";
|
|
|
- echo " <td align=\"left\">\n";
|
|
|
- echo " <br>";
|
|
|
-
|
|
|
echo "<form method='post' name='frm' action=''>\n";
|
|
|
- echo "<div align='center'>\n";
|
|
|
- echo "<table width='100%' border='0' cellpadding='6' cellspacing='0'>\n";
|
|
|
+ echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
|
|
|
echo "<tr>\n";
|
|
|
- echo "<td align='left' width='30%' nowrap='nowrap'><b>".$text['title-invoice']."</b></td>\n";
|
|
|
- echo "<td width='70%' align='right'>\n";
|
|
|
- echo " <input type='button' class='btn' name='' alt='".$text['button-pdf']."' onclick=\"window.location='invoice_pdf.php?id=".$_GET["id"]."'\" value='".$text['button-pdf']."'>\n";
|
|
|
- echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='invoices.php'\" value='".$text['button-back']."'>\n";
|
|
|
+ echo "<td align='left' width='30%' valign='top' nowrap='nowrap'><b>".$text['title-invoice']."</b></td>\n";
|
|
|
+ echo "<td width='70%' align='right' valign='top'>\n";
|
|
|
+ echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='".(($back != '') ? $back : "invoices.php")."'\" value='".$text['button-back']."'>\n";
|
|
|
+ if ($action == "update") {
|
|
|
+ echo " <input type='button' class='btn' name='' alt='".$text['button-pdf']."' onclick=\"window.open('invoice_pdf.php?id=".$_GET["id"]."&type=' + document.getElementById('invoice_type').options[document.getElementById('invoice_type').selectedIndex].value);\" value='".$text['button-pdf']."'>\n";
|
|
|
+ }
|
|
|
echo "</td>\n";
|
|
|
echo "</tr>\n";
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
- echo " ".$text['label-invoice_number'].":\n";
|
|
|
+ echo " ".$text['label-invoice_number']."\n";
|
|
|
echo "</td>\n";
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
echo " <input class='formfld' type='text' name='invoice_number' maxlength='255' value='$invoice_number'>\n";
|
|
@@ -213,7 +237,21 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
- echo " ".$text['label-contact_uuid_from'].":\n";
|
|
|
+ echo " ".$text['label-invoice_type']."\n";
|
|
|
+ echo "</td>\n";
|
|
|
+ echo "<td class='vtable' align='left'>\n";
|
|
|
+ echo " <select name='invoice_type' id='invoice_type' class='formfld'>\n";
|
|
|
+ echo " <option value='invoice' ".(($invoice_type == 'invoice') ? "selected" : null).">".$text['label-invoice_type_invoice']."</option>";
|
|
|
+ echo " <option value='quote' ".(($invoice_type == 'quote') ? "selected" : null).">".$text['label-invoice_type_quote']."</option>";
|
|
|
+ echo " </select>";
|
|
|
+ echo "<br />\n";
|
|
|
+ echo $text['description-invoice_type']."\n";
|
|
|
+ echo "</td>\n";
|
|
|
+ echo "</tr>\n";
|
|
|
+
|
|
|
+ echo "<tr>\n";
|
|
|
+ echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
+ echo " ".$text['label-contact_uuid_from']."\n";
|
|
|
echo "</td>\n";
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
$sql = "";
|
|
@@ -256,7 +294,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
- echo " ".$text['label-contact_uuid_to'].":\n";
|
|
|
+ echo " ".$text['label-contact_uuid_to']."\n";
|
|
|
echo "</td>\n";
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
$sql = "";
|
|
@@ -303,17 +341,41 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
//show the formatted date
|
|
|
echo "<tr>\n";
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
- echo " ".$text['label-invoice_date'].":\n";
|
|
|
+ echo " ".$text['label-invoice_created']."\n";
|
|
|
+ echo "</td>\n";
|
|
|
+ echo "<td class='vtable' align='left'>\n";
|
|
|
+ echo " ".$invoice_date."\n";
|
|
|
+ echo "</td>\n";
|
|
|
+ echo "</tr>\n";
|
|
|
+
|
|
|
+ echo "<tr>\n";
|
|
|
+ echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
+ echo " ".$text['label-invoice_paid']."\n";
|
|
|
echo "</td>\n";
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
- echo " $invoice_date\n";
|
|
|
+ echo " <table cellpadding='0' cellspacing='0' border='0'>";
|
|
|
+ echo " <tr>";
|
|
|
+ echo " <td><input type='checkbox' class='formfld' name='invoice_paid' id='invoice_paid' value='1' ".(($invoice_paid) ? "checked='checked'" : null)." onchange=\"$('#td_paid_details').fadeToggle('fast');\"></td>";
|
|
|
+ echo " <td id='td_paid_details' style='".((!$invoice_paid) ? "display: none;" : null)." padding: 0px 3px 0px 8px;'>";
|
|
|
+ echo " <input type='text' class='formfld' style='min-width: 85px; max-width: 85px;' name='invoice_paid_date' data-calendar=\"{format: '%Y-%m-%d', listYears: true, hideOnPick: true, fxName: null, showButtons: true}\" placeholder='Date' value='".$invoice_paid_date."'>";
|
|
|
+ echo " <select name='invoice_paid_method' id='invoice_paid_method' class='formfld' onchange=\"document.getElementById('invoice_paid_method_ref').focus();\">\n";
|
|
|
+ echo " <option value=''></option>";
|
|
|
+ echo " <option value='pp' ".(($invoice_paid_method == 'pp') ? "selected" : null).">".$text['label-invoice_method_paypal']."</option>";
|
|
|
+ echo " <option value='chk' ".(($invoice_paid_method == 'chk') ? "selected" : null).">".$text['label-invoice_method_check']."</option>";
|
|
|
+ echo " <option value='cc' ".(($invoice_paid_method == 'cc') ? "selected" : null).">".$text['label-invoice_method_credit_card']."</option>";
|
|
|
+ echo " <option value='csh' ".(($invoice_paid_method == 'csh') ? "selected" : null).">".$text['label-invoice_method_cash']."</option>";
|
|
|
+ echo " </select>";
|
|
|
+ echo " <input type='text' class='formfld' style='min-width: 85px;' name='invoice_paid_method_ref' id='invoice_paid_method_ref' placeholder='Ref #' value='".$invoice_paid_method_ref."'>";
|
|
|
+ echo " </td>";
|
|
|
+ echo " </tr>";
|
|
|
+ echo " </table>";
|
|
|
echo "</td>\n";
|
|
|
echo "</tr>\n";
|
|
|
}
|
|
|
|
|
|
echo "<tr>\n";
|
|
|
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
|
|
|
- echo " ".$text['label-invoice_notes'].":\n";
|
|
|
+ echo " ".$text['label-invoice_notes']."\n";
|
|
|
echo "</td>\n";
|
|
|
echo "<td class='vtable' align='left'>\n";
|
|
|
echo " <textarea class='formfld' type='text' name='invoice_notes'>$invoice_notes</textarea>\n";
|
|
@@ -325,19 +387,17 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
|
|
|
echo " <tr>\n";
|
|
|
echo " <td colspan='2' align='right'>\n";
|
|
|
if ($action == "update") {
|
|
|
- echo " <input type='hidden' name='invoice_uuid' value='$invoice_uuid'>\n";
|
|
|
+ if ($back != '') {
|
|
|
+ echo " <input type='hidden' name='back' value='".$back."'>";
|
|
|
+ }
|
|
|
+ echo " <input type='hidden' name='invoice_uuid' value='$invoice_uuid'>\n";
|
|
|
}
|
|
|
- echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
|
|
|
+ echo " <br><input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
|
|
|
echo " </td>\n";
|
|
|
echo " </tr>";
|
|
|
echo "</table>";
|
|
|
echo "</form>";
|
|
|
|
|
|
- echo " </td>";
|
|
|
- echo " </tr>";
|
|
|
- echo "</table>";
|
|
|
- echo "</div>";
|
|
|
-
|
|
|
if ($action == "update") {
|
|
|
require "invoice_items.php";
|
|
|
}
|