diff --git a/client_contacts.php b/client_contacts.php index 0b6d74b8..0debe121 100644 --- a/client_contacts.php +++ b/client_contacts.php @@ -1,19 +1,79 @@ - + $sb, 'o' => $o))); + +if(isset($_GET['p'])){ + $p = intval($_GET['p']); + $record_from = (($p)-1)*10; + $record_to = 10; +}else{ + $record_from = 0; + $record_to = 10; + $p = 1; +} + +if(isset($_GET['q'])){ + $q = $_GET['q']; +}else{ + $q = ""; +} + +if(!empty($_GET['sb'])){ + $sb = $_GET['sb']; +}else{ + $sb = "contact_name"; +} + +if(isset($_GET['o'])){ + if($_GET['o'] == 'ASC'){ + $o = "ASC"; + $disp = "DESC"; + }else{ + $o = "DESC"; + $disp = "ASC"; + } +}else{ + $o = "ASC"; + $disp = "DESC"; +} + + +$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM contacts WHERE client_id = $client_id AND (contact_name LIKE '%$q%') ORDER BY $sb $o LIMIT $record_from, $record_to"); + +$num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); +$total_found_rows = $num_rows[0]; +$total_pages = ceil($total_found_rows / 10); + +?> +
-
+
Contacts
- +
+
+ + +
+ +
+ +
+
+
+
- - +
+ - - + + - + @@ -76,6 +136,9 @@
NameTitleNameTitle Email PhoneActionsAction
+ + +
diff --git a/clients.php b/clients.php index 09085cf3..f05751fd 100644 --- a/clients.php +++ b/clients.php @@ -1,7 +1,7 @@ - + $sb, 'o' => $o))); if(isset($_GET['p'])){ @@ -39,10 +39,6 @@ if(isset($_GET['o'])){ $disp = "DESC"; } -?> - -
Clients
- +
@@ -137,8 +133,10 @@ $total_pages = ceil($total_found_rows / 10); Edit Delete
- - + + + + diff --git a/get_settings.php b/get_settings.php index b4795826..a4abaaff 100644 --- a/get_settings.php +++ b/get_settings.php @@ -54,6 +54,12 @@ $client_types_array = array( 'Automotive', 'Retail', 'Staffing Agency', + 'Photography', + 'Restaurant', + 'Bar', + 'Real Estate', + 'Dental', + 'Farm', 'Other' ); diff --git a/header.php b/header.php index db2cb8af..bbcf6d5e 100644 --- a/header.php +++ b/header.php @@ -20,7 +20,7 @@ <?php echo $config_company_name; ?> - + diff --git a/invoices.php b/invoices.php index f26abd8a..f123ebb9 100644 --- a/invoices.php +++ b/invoices.php @@ -44,11 +44,55 @@ $real_overdue_amount = $total_overdue - $total_overdue_partial; + //Rebuild URL - $sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, categories + $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o' => $o))); + + if(isset($_GET['p'])){ + $p = intval($_GET['p']); + $record_from = (($p)-1)*10; + $record_to = 10; + }else{ + $record_from = 0; + $record_to = 10; + $p = 1; + } + + if(isset($_GET['q'])){ + $q = $_GET['q']; + }else{ + $q = ""; + } + + if(!empty($_GET['sb'])){ + $sb = $_GET['sb']; + }else{ + $sb = "invoice_number"; + } + + if(isset($_GET['o'])){ + if($_GET['o'] == 'ASC'){ + $o = "ASC"; + $disp = "DESC"; + }else{ + $o = "DESC"; + $disp = "ASC"; + } + }else{ + $o = "DESC"; + $disp = "ASC"; + } + + $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM invoices, clients, categories WHERE invoices.client_id = clients.client_id AND invoices.category_id = categories.category_id - ORDER BY invoices.invoice_number DESC"); + AND (invoice_number LIKE '%$q%' OR client_name LIKE '%$q%') + ORDER BY $sb $o LIMIT $record_from, $record_to"); + + $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()")); + $total_found_rows = $num_rows[0]; + $total_pages = ceil($total_found_rows / 10); + ?>
@@ -98,23 +142,32 @@
-
+
Invoices
- +
+
+
+ +
+ +
+
+
+
- - +
+ - - - - - - - - + + + + + + + + @@ -200,6 +253,9 @@
NumberClientAmountInvoice DateDue DateCategoryStatusActionsNumberClientAmountInvoice DateDue DateCategoryStatusAction
+ + +
diff --git a/invoices_old.php b/invoices_old.php new file mode 100644 index 00000000..f26abd8a --- /dev/null +++ b/invoices_old.php @@ -0,0 +1,209 @@ + + + CURDATE()")); + $overdue_count = $row['num']; + + $sql_total_draft = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_draft FROM invoices WHERE invoice_status = 'Draft'"); + $row = mysqli_fetch_array($sql_total_draft); + $total_draft = $row['total_draft']; + + $sql_total_sent = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_sent FROM invoices WHERE invoice_status = 'Sent'"); + $row = mysqli_fetch_array($sql_total_sent); + $total_sent = $row['total_sent']; + + $sql_total_cancelled = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_cancelled FROM invoices WHERE invoice_status = 'Cancelled'"); + $row = mysqli_fetch_array($sql_total_cancelled); + $total_cancelled = $row['total_cancelled']; + + $sql_total_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial'"); + $row = mysqli_fetch_array($sql_total_partial); + $total_partial = $row['total_partial']; + $total_partial_count = mysqli_num_rows($sql_total_partial); + + $sql_total_overdue_partial = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_overdue_partial FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.invoice_status = 'Partial' AND invoices.invoice_due < CURDATE()"); + $row = mysqli_fetch_array($sql_total_overdue_partial); + $total_overdue_partial = $row['total_overdue_partial']; + + $sql_total_overdue = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS total_overdue FROM invoices WHERE invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Paid' AND invoice_due < CURDATE()"); + $row = mysqli_fetch_array($sql_total_overdue); + $total_overdue = $row['total_overdue']; + + $real_overdue_amount = $total_overdue - $total_overdue_partial; + + + $sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients, categories + WHERE invoices.client_id = clients.client_id + AND invoices.category_id = categories.category_id + ORDER BY invoices.invoice_number DESC"); +?> + +
+
+
+
+
+ +
+
Draft

$

+
+
+
+ +
+
+
+
+ +
+
Sent

$

+
+
+
+ +
+
+
+
+ +
+
Partial

$

+
+
+
+ +
+
+
+
+ +
+
Cancelled

$

+
+
+
+
+ +
+
+
Invoices
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NumberClientAmountInvoice DateDue DateCategoryStatusActions
INV-$ + + + + + + +
+
+
+
+ + + + 10) { + +?>
"; +} +echo "

Records: $total_found_rows
"; ?> \ No newline at end of file