diff --git a/add_company_modal.php b/add_company_modal.php new file mode 100644 index 00000000..3a08b32f --- /dev/null +++ b/add_company_modal.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/api.php b/api.php index c62998f2..96803390 100644 --- a/api.php +++ b/api.php @@ -1,149 +1,160 @@ + + "; } - } + if(isset($_GET['incoming_call'])){ - if(isset($_GET['phonebook'])){ + mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'call', log_description = 'incoming', log_created_at = NOW(), company_id = $company_id"); - header('Content-type: text/xml'); - header('Pragma: public'); - header('Cache-control: private'); - header('Expires: -1'); - echo ""; - echo ''; - - $sql = mysqli_query($mysqli,"SELECT * FROM clients;"); - - while($row = mysqli_fetch_array($sql)){ - $client_name = $row['client_name']; - $client_phone = $row['client_phone']; - - ?> - - - - - - - 0 - - - "; + } - ?> - - - - - - - 1 - - - - "; + echo ''; + + $sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $company_id"); + + while($row = mysqli_fetch_array($sql)){ + $client_name = $row['client_name']; + $client_phone = $row['client_phone']; + + ?> + + + + + + + 0 + + + + + + + + + + 1 + + + + + + + + + + + 2 + + + + '; - ?> - - - - - - - 2 - - - - '; + if(isset($_GET['client_emails'])){ - } + $sql = mysqli_query($mysqli,"SELECT * FROM clients WHERE company_id = $company_id"); - if(isset($_GET['client_emails'])){ + while($row = mysqli_fetch_array($sql)){ + $client_name = $row['client_name']; + $client_email = $row['client_email']; - $sql = mysqli_query($mysqli,"SELECT * FROM clients;"); + echo "$client_name - $client_email
"; + } - while($row = mysqli_fetch_array($sql)){ - $client_name = $row['client_name']; - $client_email = $row['client_email']; - - echo "$client_name - $client_email
"; } + if(isset($_GET['account_balance'])){ + + $client_id = intval($_GET['account_balance']); + + //Add up all the payments for the invoice and get the total amount paid to the invoice + $sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' AND company_id = $company_id"); + $row = mysqli_fetch_array($sql_invoice_amounts); + + $invoice_amounts = $row['invoice_amounts']; + + $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id AND payments.company_id = $company_id"); + $row = mysqli_fetch_array($sql_amount_paid); + + $amount_paid = $row['amount_paid']; + + $balance = $invoice_amounts - $amount_paid; + + echo $balance; + + } + + }else{ + echo "Incorrect API Key"; } - - if(isset($_GET['account_balance'])){ - - $client_id = intval($_GET['account_balance']); - - //Add up all the payments for the invoice and get the total amount paid to the invoice - $sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled'"); - $row = mysqli_fetch_array($sql_invoice_amounts); - - $invoice_amounts = $row['invoice_amounts']; - - $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id"); - $row = mysqli_fetch_array($sql_amount_paid); - - $amount_paid = $row['amount_paid']; - - $balance = $invoice_amounts - $amount_paid; - - echo $balance; - - } - + }else{ - header("Location: login.php"); + echo "Missing the API Key"; } ?> \ No newline at end of file diff --git a/calendar_events.php b/calendar_events.php index db636e7b..3eae7865 100644 --- a/calendar_events.php +++ b/calendar_events.php @@ -15,7 +15,7 @@ if(isset($_GET['calendar_id'])){ 2){ + if(strlen($contact_mobile)>2){ $contact_mobile = substr($row['contact_mobile'],0,3)."-".substr($row['contact_mobile'],3,3)."-".substr($row['contact_mobile'],6,4); } $contact_email = $row['contact_email']; diff --git a/clients_old.php b/clients_old.php deleted file mode 100644 index cc83acd7..00000000 --- a/clients_old.php +++ /dev/null @@ -1,100 +0,0 @@ - - - - - -
-
-
Clients
- -
-
-
- - - - - - - - - - - - - 2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_email = $row['client_email']; - $client_website = $row['client_website']; - $client_net_terms = $row['client_net_terms']; - if($client_net_terms == 0){ - $client_net_terms = $config_default_net_terms; - } - - //Add up all the payments for the invoice and get the total amount paid to the invoice - $sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft' AND invoice_status NOT LIKE 'Cancelled' "); - $row = mysqli_fetch_array($sql_invoice_amounts); - - $invoice_amounts = $row['invoice_amounts']; - - $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id"); - $row = mysqli_fetch_array($sql_amount_paid); - - $amount_paid = $row['amount_paid']; - - $balance = $invoice_amounts - $amount_paid; - //set Text color on balance - if($balance > 0){ - $balance_text_color = "text-danger font-weight-bold"; - }else{ - $balance_text_color = ""; - } - - ?> - - - - - - - - - - - - -
NameTypeEmailPhoneBalanceActions
$ - - -
-
-
-
- - - - $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 = "company_id"; + } + + 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 companies, settings + WHERE companies.company_id = settings.company_id + AND companies.company_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); + +?> + + +
+
+
Companies
+ +
+
+
+
+ +
+ +
+
+
+
+ + + + + + + + + + + + + + + + + +
NameAction
+ + + + + + + + +
+ + +
+
+
+ + +
+ + + +
+
+
+ + + + - - - -
- -
- - -
-
-
-
-
- -
-
Total Incomes

$

-
- Recievables: $ -
-
-
-
-
-
-
- -
-
Total Expenses

$

-
-
-
-
-
-
-
- -
-
Total Profit

$

-
-
-
- -
- -
-
Cash Flow
-
- -
-
-
- -
-
-
- - Income By Category -
-
- -
-
-
- -
-
-
- - Expense By Category -
-
- -
-
-
- -
-
-
- - Expense By Vendor -
-
- -
-
-
- -
-
-
- Account Balance -
-
- - - - - - - - - - - - -
$
-
-
-
-
-
-
- Latest Payments -
-
- - - - - - - - - - - - - - - - - - - -
DateCustomerInvoiceAmount
$
-
-
-
-
-
-
- Latest Expenses -
-
- - - - - - - - - - - - - - - - - - - -
DateVendorCategoryAmount
$
-
-
-
-
- - - - - \ No newline at end of file diff --git a/dev-clients-server-side.php b/dev-clients-server-side.php deleted file mode 100644 index 639feed2..00000000 --- a/dev-clients-server-side.php +++ /dev/null @@ -1,158 +0,0 @@ - - - - - - -
-
-
Clients
-
-
- -
-
- -
-
- -
-
-
-
- -
- -
-
-
- -
-
- -
- -
-
-
-
- -
-
-
- -
- -
- - - - - - - - - - - - 2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_email = $row['client_email']; - $client_website = $row['client_website']; - $client_net_terms = $row['client_net_terms']; - - //Add up all the payments for the invoice and get the total amount paid to the invoice - $sql_invoice_amounts = mysqli_query($mysqli,"SELECT SUM(invoice_amount) AS invoice_amounts FROM invoices WHERE client_id = $client_id AND invoice_status NOT LIKE 'Draft'"); - $row = mysqli_fetch_array($sql_invoice_amounts); - - $invoice_amounts = $row['invoice_amounts']; - - $sql_amount_paid = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS amount_paid FROM payments, invoices WHERE payments.invoice_id = invoices.invoice_id AND invoices.client_id = $client_id"); - $row = mysqli_fetch_array($sql_amount_paid); - - $amount_paid = $row['amount_paid']; - - $balance = $invoice_amounts - $amount_paid; - //set Text color on balance - if($balance > 0){ - $balance_text_color = "text-danger"; - } - - ?> - - - - - - - - - - - -
Name EmailPhoneBalanceActions
$ - -
- - - -
- -
- - - -" tabindex="-1"> + + \ No newline at end of file diff --git a/guest_header.php b/guest_header.php index 3f8f631d..6a00bd78 100644 --- a/guest_header.php +++ b/guest_header.php @@ -16,7 +16,7 @@ - <?php echo $config_company_name; ?> + <?php echo $company_name; ?> diff --git a/pay_invoice.php b/guest_pay_invoice.php similarity index 100% rename from pay_invoice.php rename to guest_pay_invoice.php diff --git a/guest_post.php b/guest_post.php index 3f6aebbe..e220b3c1 100644 --- a/guest_post.php +++ b/guest_post.php @@ -17,32 +17,49 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){ AND invoices.invoice_url_key = '$url_key'" ); - $row = mysqli_fetch_array($sql); - $invoice_id = $row['invoice_id']; - $invoice_number = $row['invoice_number']; - $invoice_status = $row['invoice_status']; - $invoice_date = $row['invoice_date']; - $invoice_due = $row['invoice_due']; - $invoice_amount = $row['invoice_amount']; - $invoice_note = $row['invoice_note']; - $invoice_category_id = $row['category_id']; - $client_id = $row['client_id']; - $client_name = $row['client_name']; - $client_address = $row['client_address']; - $client_city = $row['client_city']; - $client_state = $row['client_state']; - $client_zip = $row['client_zip']; - $client_email = $row['client_email']; - $client_phone = $row['client_phone']; - if(strlen($client_phone)>2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_website = $row['client_website']; - if(mysqli_num_rows($sql) == 1){ + $row = mysqli_fetch_array($sql); + + $invoice_id = $row['invoice_id']; + $invoice_number = $row['invoice_number']; + $invoice_status = $row['invoice_status']; + $invoice_date = $row['invoice_date']; + $invoice_due = $row['invoice_due']; + $invoice_amount = $row['invoice_amount']; + $invoice_note = $row['invoice_note']; + $invoice_category_id = $row['category_id']; + $client_id = $row['client_id']; + $client_name = $row['client_name']; + $client_address = $row['client_address']; + $client_city = $row['client_city']; + $client_state = $row['client_state']; + $client_zip = $row['client_zip']; + $client_email = $row['client_email']; + $client_phone = $row['client_phone']; + if(strlen($client_phone)>2){ + $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); + } + $client_website = $row['client_website']; + $company_id = $row['company_id']; + + $sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id"); + $row = mysqli_fetch_array($sql_company); + + $company_name = $row['company_name']; + $config_company_address = $row['config_company_address']; + $config_company_city = $row['config_company_city']; + $config_company_state = $row['config_company_state']; + $config_company_zip = $row['config_company_zip']; + $config_company_phone = $row['config_company_phone']; + if(strlen($config_company_phone)>2){ + $config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4); + } + $config_company_email = $row['config_company_email']; + $config_invoice_logo = $row['config_invoice_logo']; + //Mark downloaded in history - mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice downloaded', history_created_at = NOW(), invoice_id = $invoice_id"); + mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice downloaded', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id"); $sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); @@ -123,8 +140,8 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){ - - + +
'.$config_company_name.'
' .$config_company_address.'
'.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'
'.$config_company_phone.'
Invoice No.
INV-'.$invoice_number.'
'.$company_name.'
' .$config_company_address.'
'.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'
'.$config_company_phone.'
Invoice No.
'.$invoice_number.'
@@ -194,8 +211,8 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){ ]); $mpdf->SetProtection(array('print')); - $mpdf->SetTitle("$config_company_name - Invoice"); - $mpdf->SetAuthor("$config_company_name"); + $mpdf->SetTitle("$company_name - Invoice"); + $mpdf->SetAuthor("$company_name"); if($invoice_status == 'Paid'){ $mpdf->SetWatermarkText("Paid"); } @@ -204,7 +221,7 @@ if(isset($_GET['pdf_invoice'], $_GET['url_key'])){ $mpdf->watermarkTextAlpha = 0.1; $mpdf->SetDisplayMode('fullpage'); $mpdf->WriteHTML($html); - $mpdf->Output("$invoice_date-$config_company_name-Invoice$invoice_number.pdf",'D'); + $mpdf->Output("$invoice_date-$company_name-Invoice$invoice_number.pdf",'D'); }else{ echo "GTFO!!!"; @@ -222,28 +239,44 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){ AND quotes.quote_url_key = '$url_key'" ); - $row = mysqli_fetch_array($sql); - $quote_id = $row['quote_id']; - $quote_number = $row['quote_number']; - $quote_status = $row['quote_status']; - $quote_date = $row['quote_date']; - $quote_amount = $row['quote_amount']; - $quote_note = $row['quote_note']; - $quote_url_key = $row['quote_url_key']; - $client_id = $row['client_id']; - $client_name = $row['client_name']; - $client_address = $row['client_address']; - $client_city = $row['client_city']; - $client_state = $row['client_state']; - $client_zip = $row['client_zip']; - $client_email = $row['client_email']; - $client_phone = $row['client_phone']; - if(strlen($client_phone)>2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_website = $row['client_website']; - if(mysqli_num_rows($sql) == 1){ + $row = mysqli_fetch_array($sql); + + $quote_id = $row['quote_id']; + $quote_number = $row['quote_number']; + $quote_status = $row['quote_status']; + $quote_date = $row['quote_date']; + $quote_amount = $row['quote_amount']; + $quote_note = $row['quote_note']; + $quote_url_key = $row['quote_url_key']; + $client_id = $row['client_id']; + $client_name = $row['client_name']; + $client_address = $row['client_address']; + $client_city = $row['client_city']; + $client_state = $row['client_state']; + $client_zip = $row['client_zip']; + $client_email = $row['client_email']; + $client_phone = $row['client_phone']; + if(strlen($client_phone)>2){ + $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); + } + $client_website = $row['client_website']; + $company_id = $row['company_id']; + + $sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id"); + $row = mysqli_fetch_array($sql_company); + + $company_name = $row['company_name']; + $config_company_address = $row['config_company_address']; + $config_company_city = $row['config_company_city']; + $config_company_state = $row['config_company_state']; + $config_company_zip = $row['config_company_zip']; + $config_company_phone = $row['config_company_phone']; + if(strlen($config_company_phone)>2){ + $config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4); + } + $config_company_email = $row['config_company_email']; + $config_invoice_logo = $row['config_invoice_logo']; $sql_items = mysqli_query($mysqli,"SELECT * FROM invoice_items WHERE quote_id = $quote_id ORDER BY item_id ASC"); @@ -316,8 +349,8 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){ - - + +
'.$config_company_name.'
' .$config_company_address.'
'.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'
'.$config_company_phone.'
Quote No.
QUO-'.$quote_number.'
'.$company_name.'
' .$config_company_address.'
'.$config_company_city.' '.$config_company_state.' '.$config_company_zip.'
'.$config_company_phone.'
Quote No.
'.$quote_number.'
@@ -377,15 +410,15 @@ if(isset($_GET['pdf_quote'], $_GET['url_key'])){ 'margin_footer' => 10 ]); $mpdf->SetProtection(array('print')); - $mpdf->SetTitle("$config_company_name - Quote"); - $mpdf->SetAuthor("$config_company_name"); + $mpdf->SetTitle("$company_name - Quote"); + $mpdf->SetAuthor("$company_name"); $mpdf->SetWatermarkText("Quote"); $mpdf->showWatermarkText = true; $mpdf->watermark_font = 'DejaVuSansCondensed'; $mpdf->watermarkTextAlpha = 0.1; $mpdf->SetDisplayMode('fullpage'); $mpdf->WriteHTML($html); - $mpdf->Output("$quote_date-$config_company_name-Quote$quote_number.pdf",'D'); + $mpdf->Output("$quote_date-$company_name-Quote$quote_number.pdf",'D'); }else{ echo "GTFO!!!"; @@ -404,10 +437,9 @@ if(isset($_GET['approve_quote'], $_GET['url_key'])){ if(mysqli_num_rows($sql) == 1){ - mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Approved' WHERE quote_id = $quote_id"); - mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', history_created_at = NOW(), quote_id = $quote_id"); + mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Approved', history_description = 'Client approved Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id"); $_SESSION['alert_message'] = "Quote approved"; @@ -432,7 +464,7 @@ if(isset($_GET['reject_quote'], $_GET['url_key'])){ mysqli_query($mysqli,"UPDATE quotes SET quote_status = 'Rejected' WHERE quote_id = $quote_id"); - mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', history_created_at = NOW(), quote_id = $quote_id"); + mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = 'Rejected', history_description = 'Client rejected Quote!', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id"); $_SESSION['alert_message'] = "Quote rejected"; diff --git a/guest_view_invoice.php b/guest_view_invoice.php index ddddaf48..19e5ad52 100644 --- a/guest_view_invoice.php +++ b/guest_view_invoice.php @@ -13,36 +13,51 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){ AND invoices.invoice_url_key = '$url_key'" ); - $row = mysqli_fetch_array($sql); - $invoice_id = $row['invoice_id']; - $invoice_number = $row['invoice_number']; - $invoice_status = $row['invoice_status']; - $invoice_date = $row['invoice_date']; - $invoice_due = $row['invoice_due']; - $invoice_amount = $row['invoice_amount']; - $invoice_note = $row['invoice_note']; - $invoice_category_id = $row['category_id']; - $client_id = $row['client_id']; - $client_name = $row['client_name']; - $client_address = $row['client_address']; - $client_city = $row['client_city']; - $client_state = $row['client_state']; - $client_zip = $row['client_zip']; - $client_email = $row['client_email']; - $client_phone = $row['client_phone']; - if(strlen($client_phone)>2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_website = $row['client_website']; - $client_net_terms = $row['client_net_terms']; - if($client_net_terms == 0){ - $client_net_terms = $config_default_net_terms; - } - if(mysqli_num_rows($sql) == 1){ - + + $row = mysqli_fetch_array($sql); + $invoice_id = $row['invoice_id']; + $invoice_number = $row['invoice_number']; + $invoice_status = $row['invoice_status']; + $invoice_date = $row['invoice_date']; + $invoice_due = $row['invoice_due']; + $invoice_amount = $row['invoice_amount']; + $invoice_note = $row['invoice_note']; + $invoice_category_id = $row['category_id']; + $client_id = $row['client_id']; + $client_name = $row['client_name']; + $client_address = $row['client_address']; + $client_city = $row['client_city']; + $client_state = $row['client_state']; + $client_zip = $row['client_zip']; + $client_email = $row['client_email']; + $client_phone = $row['client_phone']; + if(strlen($client_phone)>2){ + $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); + } + $client_website = $row['client_website']; + $client_net_terms = $row['client_net_terms']; + if($client_net_terms == 0){ + $client_net_terms = $config_default_net_terms; + } + $company_id = $row['company_id']; + + $sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id"); + $row = mysqli_fetch_array($sql_company); + + $company_name = $row['company_name']; + $config_company_address = $row['config_company_address']; + $config_company_city = $row['config_company_city']; + $config_company_state = $row['config_company_state']; + $config_company_zip = $row['config_company_zip']; + $config_company_phone = $row['config_company_phone']; + if(strlen($config_company_phone)>2){ + $config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4); + } + $config_company_email = $row['config_company_email']; + //Mark viewed in history - mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id"); + mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$invoice_status', history_description = 'Invoice viewed', history_created_at = NOW(), invoice_id = $invoice_id, company_id = $company_id"); $sql_payments = mysqli_query($mysqli,"SELECT * FROM payments, accounts WHERE payments.account_id = accounts.account_id AND payments.invoice_id = $invoice_id ORDER BY payments.payment_id DESC"); @@ -89,7 +104,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){ - Pay Online + Pay Online @@ -105,7 +120,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
    -
  • +
  • @@ -137,7 +152,7 @@ if(isset($_GET['invoice_id'], $_GET['url_key'])){
    -
  • Invoice Number:
    INV-
  • +
  • Invoice Number:
  • Invoice Date:
  • Payment Due:
diff --git a/guest_view_quote.php b/guest_view_quote.php index 265d596e..86d2971d 100644 --- a/guest_view_quote.php +++ b/guest_view_quote.php @@ -13,35 +13,51 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){ AND quotes.quote_url_key = '$url_key'" ); - $row = mysqli_fetch_array($sql); - $quote_id = $row['quote_id']; - $quote_number = $row['quote_number']; - $quote_status = $row['quote_status']; - $quote_date = $row['quote_date']; - $quote_amount = $row['quote_amount']; - $quote_note = $row['quote_note']; - $category_id = $row['category_id']; - $client_id = $row['client_id']; - $client_name = $row['client_name']; - $client_address = $row['client_address']; - $client_city = $row['client_city']; - $client_state = $row['client_state']; - $client_zip = $row['client_zip']; - $client_email = $row['client_email']; - $client_phone = $row['client_phone']; - if(strlen($client_phone)>2){ - $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); - } - $client_website = $row['client_website']; - $client_net_terms = $row['client_net_terms']; - if($client_net_terms == 0){ - $client_net_terms = $config_default_net_terms; - } - if(mysqli_num_rows($sql) == 1){ + $row = mysqli_fetch_array($sql); + + $quote_id = $row['quote_id']; + $quote_number = $row['quote_number']; + $quote_status = $row['quote_status']; + $quote_date = $row['quote_date']; + $quote_amount = $row['quote_amount']; + $quote_note = $row['quote_note']; + $category_id = $row['category_id']; + $client_id = $row['client_id']; + $client_name = $row['client_name']; + $client_address = $row['client_address']; + $client_city = $row['client_city']; + $client_state = $row['client_state']; + $client_zip = $row['client_zip']; + $client_email = $row['client_email']; + $client_phone = $row['client_phone']; + if(strlen($client_phone)>2){ + $client_phone = substr($row['client_phone'],0,3)."-".substr($row['client_phone'],3,3)."-".substr($row['client_phone'],6,4); + } + $client_website = $row['client_website']; + $client_net_terms = $row['client_net_terms']; + if($client_net_terms == 0){ + $client_net_terms = $config_default_net_terms; + } + $company_id = $row['company_id']; + + $sql_company = mysqli_query($mysqli,"SELECT * FROM settings, companies WHERE settings.company_id = companies.company_id AND companies.company_id = $company_id"); + $row = mysqli_fetch_array($sql_company); + + $company_name = $row['company_name']; + $config_company_address = $row['config_company_address']; + $config_company_city = $row['config_company_city']; + $config_company_state = $row['config_company_state']; + $config_company_zip = $row['config_company_zip']; + $config_company_phone = $row['config_company_phone']; + if(strlen($config_company_phone)>2){ + $config_company_phone = substr($row['config_company_phone'],0,3)."-".substr($row['config_company_phone'],3,3)."-".substr($row['config_company_phone'],6,4); + } + $config_company_email = $row['config_company_email']; + //Mark viewed in history - mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', history_created_at = NOW(), quote_id = $quote_id"); + mysqli_query($mysqli,"INSERT INTO history SET history_date = CURDATE(), history_status = '$quote_status', history_description = 'Quote viewed', history_created_at = NOW(), quote_id = $quote_id, company_id = $company_id"); //Set Badge color based off of quote status if($quote_status == "Sent"){ @@ -86,7 +102,7 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
    -
  • +
  • @@ -118,7 +134,7 @@ if(isset($_GET['quote_id'], $_GET['url_key'])){
    -
  • Quote Number:
    QUO-
  • +
  • Quote Number:
  • Quote Date:
diff --git a/invoices_old.php b/invoices_old.php deleted file mode 100644 index f26abd8a..00000000 --- a/invoices_old.php +++ /dev/null @@ -1,209 +0,0 @@ - - - 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-$ - - - - - - -
-
-
-
- - - -', - next: '' - } - } -}); - -$(function () { - $('#datepicker').datetimepicker({ - format: 'L' - }); -}); - //Slide alert up after 2 secs $("#alert").fadeTo(2000, 500).slideUp(500, function(){ - $("#alert").slideUp(500); + $("#alert").slideUp(500); }); new EasyMDE({ @@ -36,9 +14,8 @@ new EasyMDE({ }); new EasyMDE({ - autoDownloadFontAwesome: false, - autofocus: true, - forceSync: true, - element: document.getElementById('editClientNote') - + autoDownloadFontAwesome: false, + autofocus: true, + forceSync: true, + element: document.getElementById('editClientNote') }); \ No newline at end of file diff --git a/login.php b/login.php index f0a2c60d..c9abcc93 100644 --- a/login.php +++ b/login.php @@ -34,7 +34,8 @@ if(isset($_POST['login'])){ if($client_id > 0){ header("Location: client.php?client_id=$client_id"); }else{ - header("Location: $config_start_page"); + //header("Location: $config_start_page"); + header("Location: dashboard.php"); } }else{ @@ -42,7 +43,8 @@ if(isset($_POST['login'])){ if(TokenAuth6238::verify($token,$current_code)){ $_SESSION['logged'] = TRUE; - header("Location: $config_start_page"); + //header("Location: $config_start_page"); + header("Location: dashboard.php"); }else{ $response = "
diff --git a/login_no_label.php b/login_no_label.php deleted file mode 100644 index e254988f..00000000 --- a/login_no_label.php +++ /dev/null @@ -1,114 +0,0 @@ - - - 0){ - header("Location: client.php?client_id=$client_id"); - }else{ - header("Location: $config_start_page"); - } - - }else{ - require_once("rfc6238.php"); - - if(TokenAuth6238::verify($token,$current_code)){ - $_SESSION['logged'] = TRUE; - header("Location: $config_start_page"); - } - } - } -} - -?> - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -
- - - - - - - - - - - - - - diff --git a/post.php b/post.php index 0c3f01d3..77d5e53a 100644 --- a/post.php +++ b/post.php @@ -297,6 +297,41 @@ if(isset($_POST['edit_user'])){ } +if(isset($_POST['add_company'])){ + + $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + + mysqli_query($mysqli,"INSERT INTO companies SET company_name = '$name', company_created_at = NOW()"); + + $_SESSION['alert_message'] = "Company added"; + + header("Location: companies.php"); + +} + +if(isset($_POST['edit_company'])){ + $company_id = intval($_POST['company_id']); + $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); + + mysqli_query($mysqli,"UPDATE companies SET company_name = '$name', company_updated_at = NOW() WHERE company_id = $company_id"); + + $_SESSION['alert_message'] = "Company modified"; + + header("Location: companies.php"); + +} + +if(isset($_GET['delete_company'])){ + $company_id = intval($_GET['delete_company']); + + mysqli_query($mysqli,"DELETE FROM companies WHERE company_id = $company_id"); + + $_SESSION['alert_message'] = "Company deleted"; + + header("Location: " . $_SERVER["HTTP_REFERER"]); + +} + if(isset($_POST['add_client'])){ $name = strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])); diff --git a/settings-carddav.php b/settings-carddav.php deleted file mode 100644 index 4788c1e0..00000000 --- a/settings-carddav.php +++ /dev/null @@ -1,58 +0,0 @@ - - - - -
-
-
CardDAV Settings
-
-
-
-
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- -
-
- -
- - -
-
-
- -General Categories Users + Companies
\ No newline at end of file diff --git a/test.php b/test.php deleted file mode 100644 index c18a37c4..00000000 --- a/test.php +++ /dev/null @@ -1,44 +0,0 @@ - - - - - - -

PHP SELF basename:

-

PHP SELF:

-
-

PHP URI:

-

PHP Server_name:

-

PHP HTTP_HOST:

- -

- -

basename _FILE_ :

-

User Agent: -

This is a great starting point for new custom pages.

- -',TokenAuth6238::getBarCodeUrl('','',$secretkey,'My%20App')); - print TokenAuth6238::getTokenCodeDebug($secretkey,0); - - -?> - - -

- - \ No newline at end of file diff --git a/update_revenues.php b/update_revenues.php deleted file mode 100644 index dd951f44..00000000 --- a/update_revenues.php +++ /dev/null @@ -1,18 +0,0 @@ - - - - -