浏览代码

Invoice App: Misc Updates

Nate Jones 10 年之前
父节点
当前提交
fa8ff139cf

+ 40 - 9
invoices/app_config.php

@@ -1,4 +1,5 @@
 <?php
+
 	//application details
 		$apps[$x]['name'] = 'Invoices';
 		$apps[$x]['uuid'] = 'e5a1f4f5-7766-ec9c-118b-50f76b0788c0';
@@ -9,10 +10,10 @@
 		$apps[$x]['contact_url'] = 'http://www.fusionpbx.com';
 		$apps[$x]['description']['en-us'] = '';
 		$apps[$x]['description']['es-mx'] = '';
-		$apps[$x]['description']['de-de'] = '';
+		$apps[$x]['description']['de'] = '';
 		$apps[$x]['description']['de-ch'] = '';
 		$apps[$x]['description']['de-at'] = '';
-		$apps[$x]['description']['fr-fr'] = '';
+		$apps[$x]['description']['fr'] = '';
 		$apps[$x]['description']['fr-ca'] = '';
 		$apps[$x]['description']['fr-ch'] = '';
 		$apps[$x]['description']['pt-pt'] = '';
@@ -71,14 +72,16 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
-		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
-		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name']['text'] = 'domain_id ';
@@ -92,6 +95,9 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_contacts';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'contact_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Contact ID invoice is sent from';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'contact_uuid_to';
@@ -99,21 +105,44 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_contacts';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'contact_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Contact ID invoice is sent to';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_number';
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Enter the invoice number.';
 		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_type';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Select the record type.';
+		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_date';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'timestamp with time zone';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'datetime';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'timestamp';
-		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Enter the date.';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_notes';
 		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
-		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Enter the invoice notes.';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Enter invoice notes.';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_paid';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'numeric';
+		$apps[$x]['db'][$y]['fields'][$z]['description'] = 'Check if invoice has been paid';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_paid_date';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'timestamp';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Date the invoice was paid.';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_paid_method';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Select the payment method used.';
+		$z++;
+		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'invoice_paid_method_ref';
+		$apps[$x]['db'][$y]['fields'][$z]['type'] = 'text';
+		$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = 'Enter a payment method reference number.';
 		$z++;
 
 		$y = 1; //table array index
@@ -129,14 +158,16 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
-		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'domain_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
-		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'foreign';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = 'v_domains';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = 'domain_uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'v_id';
@@ -153,7 +184,7 @@
 		$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = 'uuid';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = 'text';
 		$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = 'char(36)';
-		$apps[$x]['db'][$y]['fields'][$z]['key'] = 'primary';
+		$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = 'primary';
 		$apps[$x]['db'][$y]['fields'][$z]['description'] = '';
 		$z++;
 		$apps[$x]['db'][$y]['fields'][$z]['name'] = 'item_qty';

+ 42 - 9
invoices/app_languages.php

@@ -31,20 +31,47 @@
 		$text['description-contact_uuid_to']['en-us'] = 'Select the Contact to send the send the invoice to.';
 		$text['description-contact_uuid_to']['pt-pt'] = '';
 
-		$text['label-invoice_number']['en-us'] = 'Invoice Number';
+		$text['label-invoice_number']['en-us'] = 'Number';
 		$text['label-invoice_number']['pt-pt'] = '';
 
 		$text['description-invoice_number']['en-us'] = 'Enter the invoice number.';
 		$text['description-invoice_number']['pt-pt'] = '';
 
-		$text['label-invoice_date']['en-us'] = 'Date';
-		$text['label-invoice_date']['pt-pt'] = '';
+		$text['label-invoice_type']['en-us'] = 'Type';
+		$text['label-invoice_type']['pt-pt'] = '';
+
+		$text['description-invoice_type']['en-us'] = 'Select the record type.';
+		$text['description-invoice_type']['pt-pt'] = '';
+
+		$text['label-invoice_type_invoice']['en-us'] = 'Invoice';
+		$text['label-invoice_type_invoice']['pt-pt'] = '';
+
+		$text['label-invoice_type_quote']['en-us'] = 'Quote';
+		$text['label-invoice_type_quote']['pt-pt'] = '';
+
+		$text['label-invoice_created']['en-us'] = 'Created';
+		$text['label-invoice_created']['pt-pt'] = '';
+
+		$text['label-invoice_paid']['en-us'] = 'Paid';
+		$text['label-invoice_paid']['pt-pt'] = '';
+
+		$text['label-invoice_method_paypal']['en-us'] = 'PayPal';
+		$text['label-invoice_method_paypal']['pt-pt'] = '';
+
+		$text['label-invoice_method_check']['en-us'] = 'Check';
+		$text['label-invoice_method_check']['pt-pt'] = '';
+
+		$text['label-invoice_method_credit_card']['en-us'] = 'Credit Card';
+		$text['label-invoice_method_credit_card']['pt-pt'] = '';
+
+		$text['label-invoice_method_cash']['en-us'] = 'Cash';
+		$text['label-invoice_method_cash']['pt-pt'] = '';
 
 		$text['label-invoice_notes']['en-us'] = 'Invoice Notes';
 		$text['label-invoice_notes']['pt-pt'] = '';
 
 	//Invoice Items
-		$text['title-invoice_items']['en-us'] = 'Invoice Items';
+		$text['title-invoice_items']['en-us'] = 'Items';
 		$text['title-invoice_items']['pt-pt'] = '';
 
 		$text['title-invoice_item']['en-us'] = 'Invoice Item';
@@ -117,19 +144,25 @@
 		$text['label-invoice']['en-us'] = 'INVOICE';
 		$text['label-invoice']['pt-pt'] = '';
 
-		$text['label-invoice_date']['en-us'] = 'Invoice Date:';
+		$text['label-quote']['en-us'] = 'QUOTE';
+		$text['label-quote']['pt-pt'] = '';
+
+		$text['label-estimate']['en-us'] = 'ESTIMATE';
+		$text['label-estimate']['pt-pt'] = '';
+
+		$text['label-invoice_date']['en-us'] = 'Date';
 		$text['label-invoice_date']['pt-pt'] = '';
 
-		$text['label-invoice_number']['en-us'] = 'Invoice Number:';
+		$text['label-invoice_number']['en-us'] = 'Number';
 		$text['label-invoice_number']['pt-pt'] = '';
 
-		$text['label-invoice_notes']['en-us'] = 'Note:';
+		$text['label-invoice_notes']['en-us'] = 'Note';
 		$text['label-invoice_notes']['pt-pt'] = '';
 
-		$text['label-invoice_total']['en-us'] = 'Total:';
+		$text['label-invoice_total']['en-us'] = 'Total';
 		$text['label-invoice_total']['pt-pt'] = '';
 
-		$text['label-invoice_total']['en-us'] = 'Total:';
+		$text['label-invoice_total']['en-us'] = 'Total';
 		$text['label-invoice_total']['pt-pt'] = '';
 
 ?>

+ 21 - 21
invoices/app_menu.php

@@ -1,22 +1,22 @@
-<?php
-
-	$y = 0;
-	$apps[$x]['menu'][$y]['title']['en-us'] = 'Invoices';
-	$apps[$x]['menu'][$y]['title']['es-mx'] = '';
-	$apps[$x]['menu'][$y]['title']['de-de'] = '';
-	$apps[$x]['menu'][$y]['title']['de-ch'] = '';
-	$apps[$x]['menu'][$y]['title']['de-at'] = '';
-	$apps[$x]['menu'][$y]['title']['fr-fr'] = '';
-	$apps[$x]['menu'][$y]['title']['fr-ca'] = '';
-	$apps[$x]['menu'][$y]['title']['fr-ch'] = '';
-	$apps[$x]['menu'][$y]['title']['pt-pt'] = '';
-	$apps[$x]['menu'][$y]['title']['pt-br'] = '';
-	$apps[$x]['menu'][$y]['uuid'] = '6ebe753b-0f83-dc34-1c0b-51df2c6f0c3b';
-	$apps[$x]['menu'][$y]['parent_uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
-	$apps[$x]['menu'][$y]['category'] = 'internal';
-	$apps[$x]['menu'][$y]['path'] = '/app/invoices/invoices.php';
-	//$apps[$x]['menu'][$y]['groups'][] = 'user';
-	//$apps[$x]['menu'][$y]['groups'][] = 'admin';
-	$apps[$x]['menu'][$y]['groups'][] = 'superadmin';
-
+<?php
+
+	$y = 0;
+	$apps[$x]['menu'][$y]['title']['en-us'] = 'Invoices';
+	$apps[$x]['menu'][$y]['title']['es-mx'] = '';
+	$apps[$x]['menu'][$y]['title']['de'] = '';
+	$apps[$x]['menu'][$y]['title']['de-ch'] = '';
+	$apps[$x]['menu'][$y]['title']['de-at'] = '';
+	$apps[$x]['menu'][$y]['title']['fr'] = '';
+	$apps[$x]['menu'][$y]['title']['fr-ca'] = '';
+	$apps[$x]['menu'][$y]['title']['fr-ch'] = '';
+	$apps[$x]['menu'][$y]['title']['pt-pt'] = '';
+	$apps[$x]['menu'][$y]['title']['pt-br'] = '';
+	$apps[$x]['menu'][$y]['uuid'] = '6ebe753b-0f83-dc34-1c0b-51df2c6f0c3b';
+	$apps[$x]['menu'][$y]['parent_uuid'] = 'fd29e39c-c936-f5fc-8e2b-611681b266b5';
+	$apps[$x]['menu'][$y]['category'] = 'internal';
+	$apps[$x]['menu'][$y]['path'] = '/app/invoices/invoices.php';
+	//$apps[$x]['menu'][$y]['groups'][] = 'user';
+	//$apps[$x]['menu'][$y]['groups'][] = 'admin';
+	$apps[$x]['menu'][$y]['groups'][] = 'superadmin';
+
 ?>

+ 4 - 8
invoices/invoice_delete.php

@@ -44,6 +44,7 @@ else {
 	if (count($_GET) > 0) {
 		$id = check_str($_GET["id"]);
 		$contact_uuid = check_str($_GET["contact_uuid"]);
+		$back = check_str($_GET["back"]);
 	}
 
 //delete invoice
@@ -57,12 +58,7 @@ else {
 	}
 
 //redirect the user
-	require_once "resources/header.php";
-	echo "<meta http-equiv=\"refresh\" content=\"2;url=invoices.php?id=$contact_uuid\">\n";
-	echo "<div align='center'>\n";
-	echo $text['message-delete']."\n";
-	echo "</div>\n";
-	require_once "resources/footer.php";
-	return;
-
+	$_SESSION['message'] = $text['message-delete'];
+	header("Location: ".(($back != '') ? $back : "invoices.php?id=".$contact_uuid));
+	exit;
 ?>

+ 99 - 39
invoices/invoice_edit.php

@@ -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";
 	}

+ 5 - 10
invoices/invoice_item_delete.php

@@ -40,6 +40,7 @@ if (count($_GET) > 0) {
 	$id = check_str($_GET["id"]);
 	$invoice_uuid = check_str($_GET["invoice_uuid"]);
 	$contact_uuid = check_str($_GET["contact_uuid"]);
+	$back = check_str($_GET["back"]);
 }
 
 //add multi-lingual support
@@ -59,14 +60,8 @@ if (strlen($id) > 0) {
 }
 
 //redirect the user
-	require_once "resources/header.php";
-	echo "<meta http-equiv=\"refresh\" content=\"2;url=invoice_items.php\">\n";
-	echo "<div align='center'>\n";
-	echo $text['message-delete']."\n";
-	echo "</div>\n";
-
-//include the footer
-	require_once "resources/footer.php";
-	return;
-
+	$_SESSION['message'] = $text['message-delete'];
+	$back = ($back != '') ? "&back=".$back : null;
+	header("Location: invoice_edit.php?id=".$invoice_uuid."&contact_uuid=".$contact_uuid.$back);
+	exit;
 ?>

+ 29 - 37
invoices/invoice_item_edit.php

@@ -46,9 +46,11 @@ else {
 	if (isset($_REQUEST["id"])) {
 		$action = "update";
 		$invoice_item_uuid = check_str($_REQUEST["id"]);
+		$back = check_str($_REQUEST['back']);
 	}
 	else {
 		$action = "add";
+		$back = check_str($_REQUEST['back']);
 	}
 
 if (strlen(count($_REQUEST)) > 0) {
@@ -115,13 +117,12 @@ 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=invoice_edit.php?id=$invoice_uuid&contact_uuid=$contact_uuid\">\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'];
+				$back = ($back != '') ? "&back=".$back : null;
+				header("Location: invoice_edit.php?id=".$invoice_uuid."&contact_uuid=".$contact_uuid.$back);
+				exit;
+
 			} //if ($action == "add")
 
 			if ($action == "update" && permission_exists('invoice_item_edit')) {
@@ -134,15 +135,14 @@ 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=invoice_items.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'];
+				$back = ($back != '') ? "&back=".$back : null;
+				header("Location: invoice_edit.php?id=".$invoice_uuid."&contact_uuid=".$contact_uuid.$back);
+				exit;
+
 			} //if ($action == "update")
-		} //if ($_POST["persistformvar"] != "true") 
+		} //if ($_POST["persistformvar"] != "true")
 } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
 
 //pre-populate the form
@@ -167,25 +167,18 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 	require_once "resources/header.php";
 
 //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_item']."</b></td>\n";
-	echo "<td width='70%' align='right'>\n";
+	echo "<td align='left' width='30%' valign='top' nowrap='nowrap'><b>".$text['title-invoice_item']."</b></td>\n";
+	echo "<td width='70%' align='right' valign='top'>\n";
 	echo "	<input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"history.go(-1);\" value='".$text['button-back']."'>\n";
 	echo "</td>\n";
 	echo "</tr>\n";
 
 	echo "<tr>\n";
 	echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
-	echo "	".$text['label-item_qty'].":\n";
+	echo "	".$text['label-item_qty']."\n";
 	echo "</td>\n";
 	echo "<td class='vtable' align='left'>\n";
 	echo "  <input class='formfld' type='text' name='item_qty' maxlength='255' value='$item_qty'>\n";
@@ -196,7 +189,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-item_unit_price'].":\n";
+	echo "	".$text['label-item_unit_price']."\n";
 	echo "</td>\n";
 	echo "<td class='vtable' align='left'>\n";
 	echo "  <input class='formfld' type='text' name='item_unit_price' maxlength='255' value='$item_unit_price'>\n";
@@ -207,7 +200,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-item_desc'].":\n";
+	echo "	".$text['label-item_desc']."\n";
 	echo "</td>\n";
 	echo "<td class='vtable' align='left'>\n";
 	echo "  <textarea class='formfld' type='text' rows='15' name='item_desc'>$item_desc</textarea>\n";
@@ -218,22 +211,21 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
 
 	echo "	<tr>\n";
 	echo "		<td colspan='2' align='right'>\n";
-	echo "				<input type='hidden' name='invoice_uuid' value='$invoice_uuid'>\n";
-	echo "				<input type='hidden' name='contact_uuid' value='$contact_uuid'>\n";
+	echo "			<input type='hidden' name='invoice_uuid' value='$invoice_uuid'>\n";
+	echo "			<input type='hidden' name='contact_uuid' value='$contact_uuid'>\n";
 	if ($action == "update") {
-		echo "				<input type='hidden' name='invoice_item_uuid' value='$invoice_item_uuid'>\n";
+		if ($back != '') {
+			echo "		<input type='hidden' name='back' value='".$back."'>";
+		}
+		echo "		<input type='hidden' name='invoice_item_uuid' value='$invoice_item_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 "<br><br>";
 	echo "</form>";
 
-	echo "	</td>";
-	echo "	</tr>";
-	echo "</table>";
-	echo "</div>";
-
 //include the footer
 	require_once "resources/footer.php";
 ?>

+ 12 - 24
invoices/invoice_items.php

@@ -41,15 +41,9 @@ else {
 	$order = $_GET["order"];
 
 //show the content
-	echo "<div align='center'>";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
-	echo "<tr class='border'>\n";
-	echo "	<td align=\"center\">\n";
-	echo "		<br />";
-
-	echo "<table width='100%' border='0'>\n";
+	echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
 	echo "	<tr>\n";
-	echo "		<td width='50%' align='left' nowrap='nowrap'><b>".$text['title-invoice_items']."</b></td>\n";
+	echo "		<td width='50%' align='left' nowrap='nowrap'><b>".$text['title-invoice_items']."</b><br><br></td>\n";
 	echo "		<td width='50%' align='right'>&nbsp;</td>\n";
 	echo "	</tr>\n";
 	echo "</table>\n";
@@ -77,7 +71,7 @@ else {
 		$page = $_GET['page'];
 		if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
 		//list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
-		$offset = $rows_per_page * $page; 
+		$offset = $rows_per_page * $page;
 
 	//get the list
 		$sql = "select * from v_invoice_items ";
@@ -95,16 +89,16 @@ else {
 	$row_style["0"] = "row_style0";
 	$row_style["1"] = "row_style1";
 
-	echo "<div align='center'>\n";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
 	echo "<tr>\n";
 	echo th_order_by('item_qty', $text['label-item_qty'], $order_by, $order);
 	echo th_order_by('item_unit_price', $text['label-item_unit_price'], $order_by, $order);
 	echo th_order_by('item_desc', $text['label-item_desc'], $order_by, $order);
 	echo "<th nowrap='nowrap'>".$text['label-item_amount']."</th>\n";
 	echo "<td align='right' width='42'>\n";
+	$back = ($back != '') ? "&back=".$back : null;
 	if (permission_exists('invoice_item_add')) {
-		echo "	<a href='invoice_item_edit.php?invoice_uuid=".$_GET['id']."&contact_uuid=".$contact_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+		echo "	<a href='invoice_item_edit.php?invoice_uuid=".$_GET['id']."&contact_uuid=".$contact_uuid_to.$back."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
 	}
 	else {
 		echo "	&nbsp;\n";
@@ -116,17 +110,18 @@ else {
 		foreach($result as $row) {
 			$item_desc = $row['item_desc'];
 			$item_desc = str_replace("\n", "<br />", $item_desc);
-			echo "<tr >\n";
+			$tr_link = (permission_exists('invoice_item_edit')) ? "href='invoice_item_edit.php?invoice_uuid=".$row['invoice_uuid']."&id=".$row['invoice_item_uuid']."&contact_uuid=".$contact_uuid_to.$back."'" : null;
+			echo "<tr ".$tr_link.">\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['item_qty']."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".number_format($row['item_unit_price'], 2)."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$item_desc."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".number_format(($row['item_qty'] * $row['item_unit_price']), 2)."&nbsp;</td>\n";
-			echo "	<td valign='top' align='right'>\n";
+			echo "	<td class='list_control_icons'>\n";
 			if (permission_exists('invoice_item_edit')) {
-				echo "		<a href='invoice_item_edit.php?invoice_uuid=".$row['invoice_uuid']."&id=".$row['invoice_item_uuid']."&contact_uuid=".$contact_uuid."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
+				echo 	"<a href='invoice_item_edit.php?invoice_uuid=".$row['invoice_uuid']."&id=".$row['invoice_item_uuid']."&contact_uuid=".$contact_uuid_to.$back."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
 			}
 			if (permission_exists('invoice_item_delete')) {
-				echo "		<a href='invoice_item_delete.php?invoice_uuid=".$row['invoice_uuid']."&id=".$row['invoice_item_uuid']."&contact_uuid=".$contact_uuid."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
+				echo 	"<a href='invoice_item_delete.php?invoice_uuid=".$row['invoice_uuid']."&id=".$row['invoice_item_uuid']."&contact_uuid=".$contact_uuid_to.$back."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
 			}
 			echo "	</td>\n";
 			echo "</tr>\n";
@@ -143,7 +138,7 @@ else {
 	echo "		<td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
 	echo "		<td width='33.3%' align='right'>\n";
 	if (permission_exists('invoice_item_add')) {
-		echo "			<a href='invoice_item_edit.php?invoice_uuid=".$_GET['id']."&contact_uuid=".$contact_uuid."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
+		echo "			<a href='invoice_item_edit.php?invoice_uuid=".$_GET['id']."&contact_uuid=".$contact_uuid_to.$back."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
 	}
 	else {
 		echo "			&nbsp;\n";
@@ -155,13 +150,6 @@ else {
 	echo "</tr>\n";
 
 	echo "</table>";
-	echo "</div>";
-	echo "<br /><br />";
-
-	echo "</td>";
-	echo "</tr>";
-	echo "</table>";
-	echo "</div>";
 	echo "<br /><br />";
 
 //include the footer

+ 9 - 3
invoices/invoice_pdf.php

@@ -17,7 +17,7 @@
 
 	The Initial Developer of the Original Code is
 	Mark J Crane <[email protected]>
-	Portions created by the Initial Developer are Copyright (C) 2008-2014
+	Portions created by the Initial Developer are Copyright (C) 2008-2012
 	the Initial Developer. All Rights Reserved.
 
 	Contributor(s):
@@ -43,6 +43,7 @@ else {
 //action invoice_uuid
 	if (isset($_REQUEST["id"])) {
 		$invoice_uuid = check_str($_REQUEST["id"]);
+		$type = check_str($_REQUEST["type"]);
 	}
 
 //get the invoice details
@@ -191,14 +192,19 @@ else {
 	$pdf->SetY(10);
 	$pdf->Cell(150,10,'');
 	$pdf->SetFont('Arial','',23);
-	$pdf->Cell(40,10,$text['label-invoice']);
+	if ($type == "quote") {
+		$pdf->Cell(40,10,$text['label-quote']);	
+	}
+	else {
+		$pdf->Cell(40,10,$text['label-invoice']);
+	}
 	$pdf->Ln();
 	$pdf->SetFont('Arial','',9);
 	$pdf->Cell(150,5,'');
 	$pdf->Cell(40,5,$text['label-invoice_date'].' '.$invoice_date);
 	$pdf->Ln();
 	$pdf->Cell(150,5,'');
-	$pdf->Cell(40,5,$text['label-invoice_date'].' '.$invoice_number);
+	$pdf->Cell(40,5,$text['label-invoice_number'].' '.$invoice_number);
 	$pdf->Ln();
 	$pdf->Ln();
 	$pdf->Ln();

+ 31 - 32
invoices/invoices.php

@@ -50,17 +50,13 @@ require_once "resources/paging.php";
 	$contact_uuid = check_str($_REQUEST["id"]);
 
 //show the content
-	echo "<div align='center'>";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='2'>\n";
-	echo "<tr class='border'>\n";
-	echo "	<td align=\"center\">\n";
-	echo "		<br />";
-
-	echo "<table width='100%' border='0'>\n";
+	echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
 	echo "	<tr>\n";
-	echo "		<td width='50%' align='left' nowrap='nowrap'><b>".$text['title-invoices']."</b></td>\n";
-	echo "		<td width='50%' align=\"right\">\n";
-	echo "			<input type='button' class='btn' name='' alt='back' onclick=\"history.go(-1);\" value='Back'>\n";
+	echo "		<td width='50%' align='left' valign='top' nowrap='nowrap'><b>".$text['title-invoices']."</b><br><br></td>\n";
+	echo "		<td width='50%' align=\"right\" valign='top'>\n";
+	if ($contact_uuid != '') {
+		echo "			<input type='button' class='btn' name='' alt='back' onclick=\"history.go(-1);\" value='Back'>\n";
+	}
 	echo "		</td>\n";
 	echo "	</tr>\n";
 	echo "</table>\n";
@@ -89,9 +85,9 @@ require_once "resources/paging.php";
 		$rows_per_page = 150;
 		$param = "";
 		$page = $_GET['page'];
-		if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } 
-		list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); 
-		$offset = $rows_per_page * $page; 
+		if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
+		list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
+		$offset = $rows_per_page * $page;
 
 	//get the list
 		$sql = "SELECT * FROM v_invoices ";
@@ -101,10 +97,10 @@ require_once "resources/paging.php";
 		if (strlen($contact_uuid) > 0) {
 			$sql .= "and v_invoices.contact_uuid_to = '$contact_uuid' ";
 		}
-		if (strlen($order_by) == 0) { 
+		if (strlen($order_by) == 0) {
 			$sql .= "order by v_invoices.invoice_number asc ";
 		}
-		else { 
+		else {
 			$sql .= "order by v_invoices.$order_by $order ";
 		}
 		$sql .= "limit $rows_per_page offset $offset ";
@@ -118,9 +114,9 @@ require_once "resources/paging.php";
 	$row_style["0"] = "row_style0";
 	$row_style["1"] = "row_style1";
 
-	echo "<div align='center'>\n";
-	echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
+	echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
 	echo "<tr>\n";
+	echo "<th>&nbsp;</th>\n";
 	echo th_order_by('invoice_number', $text['label-invoice_number'], $order_by, $order);
 	echo th_order_by('contact_organization', $text['label-contact_to_organization'], $order_by, $order);
 	echo th_order_by('contact_name_given', $text['label-contact_to_given_name'], $order_by, $order);
@@ -138,20 +134,30 @@ require_once "resources/paging.php";
 
 	if ($result_count > 0) {
 		foreach($result as $row) {
-			echo "<tr >\n";
-			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['invoice_number']."&nbsp;</td>\n";
+			$back = ($contact_uuid != '') ? "&back=".urlencode("invoices.php?id=".$contact_uuid) : null;
+			$tr_link = (permission_exists('invoice_edit')) ? "href='invoice_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid'].$back."'" : null;
+			echo "<tr ".$tr_link.">\n";
+			echo "	<td align='center' valign='middle' class='".$row_style[$c]."' style='padding: 0px 0px 0px 5px;'>";
+			if ($row['invoice_paid'] == 1) {
+				echo "<img src='paid.png' style='width: 16px; height: 16px; border; none;'>";
+			}
+			else {
+				echo "<img src='unpaid.png' style='width: 16px; height: 16px; border; none;'>";
+			}
+			echo "	</td>\n";
+			echo "	<td valign='top' class='".$row_style[$c]."'><a href='invoice_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid'].$back."' alt='".$text['button-edit']."'>".$row['invoice_number']."</a>&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['contact_organization']."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['contact_name_given']."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['contact_name_family']."&nbsp;</td>\n";
 			echo "	<td valign='top' class='".$row_style[$c]."'>".$row['invoice_date']."&nbsp;</td>\n";
-			echo "	<td valign='top' align='right'>\n";
+			echo "	<td class='list_control_icons'>\n";
 			if (permission_exists('invoice_edit')) {
-				echo "		<a href='invoice_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>\n";
+				echo 	"<a href='invoice_edit.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid'].$back."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
 			}
 			if (permission_exists('invoice_delete')) {
-				echo "		<a href='invoices_delete.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>\n";
+				echo 	"<a href='invoices_delete.php?contact_uuid=".$row['contact_uuid']."&id=".$row['invoice_uuid'].$back."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
 			}
-			echo "	</td>\n";
+			echo 	"</td>\n";
 			echo "</tr>\n";
 			if ($c==0) { $c=1; } else { $c=0; }
 		} //end foreach
@@ -159,7 +165,7 @@ require_once "resources/paging.php";
 	} //end if results
 
 	echo "<tr>\n";
-	echo "<td colspan='8' align='left'>\n";
+	echo "<td colspan='9' align='left'>\n";
 	echo "	<table width='100%' cellpadding='0' cellspacing='0'>\n";
 	echo "	<tr>\n";
 	echo "		<td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
@@ -169,7 +175,7 @@ require_once "resources/paging.php";
 	echo "			<a href='invoice_edit.php?contact_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>\n";
 	}
 	else {
-		echo "			&nbsp;\n";
+		echo "		&nbsp;\n";
 	}
 	echo "		</td>\n";
 	echo "	</tr>\n";
@@ -178,13 +184,6 @@ require_once "resources/paging.php";
 	echo "</tr>\n";
 
 	echo "</table>";
-	echo "</div>";
-	echo "<br /><br />";
-
-	echo "</td>";
-	echo "</tr>";
-	echo "</table>";
-	echo "</div>";
 	echo "<br /><br />";
 
 //include the footer

二进制
invoices/paid.png


二进制
invoices/unpaid.png