Skip to content

Commit

Permalink
BREAKING CHANGES: Major Backend Code Changes Updated Foreign keys to …
Browse files Browse the repository at this point in the history
…prepend their table names ex invoice_client_id, switched most queries over to JOIN instead of = Combined contacts and location into client removed client email, phone etc fields, tons of small bug fixes, and other small UI changes all across the board
  • Loading branch information
johnnyq committed Aug 28, 2021
1 parent 7fc7383 commit f3053ff
Show file tree
Hide file tree
Showing 86 changed files with 2,190 additions and 2,007 deletions.
8 changes: 4 additions & 4 deletions accounts.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
<tr>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=account_name&o=<?php echo $disp; ?>">Name</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=currency_code&o=<?php echo $disp; ?>">Currency</a></th>
<th><a class="text-dark" href="?<?php echo $url_query_strings_sb; ?>&sb=account_currency_code&o=<?php echo $disp; ?>">Currency</a></th>
<th class="text-right">Balance</th>
<th class="text-center">Action</th>
</tr>
Expand All @@ -84,15 +84,15 @@
$account_currency_code = $row['account_currency_code'];
$account_notes = $row['account_notes'];

$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];

$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id");
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id");
$row = mysqli_fetch_array($sql_revenues);
$total_revenues = $row['total_revenues'];

$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id");
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];

Expand Down
8 changes: 4 additions & 4 deletions add_asset_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
<option value="">- Location -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE location_archived_at IS NULL AND client_id = $client_id ORDER BY location_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
while($row = mysqli_fetch_array($sql)){
$location_id = $row['location_id'];
$location_name = $row['location_name'];
Expand All @@ -141,7 +141,7 @@
<option value="">- Contact -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_archived_at IS NULL AND client_id = $client_id ORDER BY contact_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
while($row = mysqli_fetch_array($sql)){
$contact_id = $row['contact_id'];
$contact_name = $row['contact_name'];
Expand All @@ -165,7 +165,7 @@
<option value="">- Network -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM networks WHERE network_archived_at IS NULL AND client_id = $client_id ORDER BY network_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM networks WHERE network_archived_at IS NULL AND network_client_id = $client_id ORDER BY network_name ASC");
while($row = mysqli_fetch_array($sql)){
$network_id = $row['network_id'];
$network_name = $row['network_name'];
Expand Down Expand Up @@ -215,7 +215,7 @@
<option value="">- Vendor -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND client_id = $client_id ORDER BY vendor_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
Expand Down
4 changes: 2 additions & 2 deletions add_calendar_event_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,10 @@

<?php } ?>

<?php if(!empty($config_smtp_host) AND !empty($client_email)){ ?>
<?php if(!empty($config_smtp_host) AND !empty($contact_email)){ ?>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customControlAutosizing" name="email_event" value="1" >
<label class="custom-control-label" for="customControlAutosizing">Email Event (<?php echo $client_email; ?>)</label>
<label class="custom-control-label" for="customControlAutosizing">Email Event (<?php echo $contact_email; ?>)</label>
</div>
<?php } ?>

Expand Down
10 changes: 10 additions & 0 deletions add_client_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,16 @@
</div>
</div>

<div class="form-group">
<label>Title</label>
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-fw fa-id-badge"></i></span>
</div>
<input type="text" class="form-control" name="title" placeholder="Title">
</div>
</div>

<label>Phone</label>
<div class="form-row">
<div class="col-8">
Expand Down
5 changes: 5 additions & 0 deletions add_contact_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@
<span class="input-group-text"><i class="fa fa-fw fa-id-badge"></i></span>
</div>
<input type="text" class="form-control" name="title" placeholder="Title">
<div class="input-group-append">
<div class="input-group-text">
<input type="checkbox" name="primary_contact" value="1" <?php if($primary_contact == 0){ echo "checked"; } ?>>
</div>
</div>
</div>
</div>

Expand Down
4 changes: 2 additions & 2 deletions add_domain_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<option value="">- Vendor -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND client_id = $client_id ORDER BY vendor_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
Expand All @@ -55,7 +55,7 @@
<option value="">- Vendor -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND client_id = $client_id ORDER BY vendor_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
Expand Down
12 changes: 6 additions & 6 deletions add_expense_copy_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,21 @@
$account_name_select = $row['account_name'];
$opening_balance = $row['opening_balance'];

$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id_select");
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id_select");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];

$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id_select");
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id_select");
$row = mysqli_fetch_array($sql_revenues);
$total_revenues = $row['total_revenues'];

$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id_select");
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id_select");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];

$balance = $opening_balance + $total_payments + $total_revenues - $total_expenses;
?>
<option <?php if($account_id == $account_id_select){ ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo $account_name_select; ?> [$<?php echo number_format($balance,2); ?>]</option>
<option <?php if($expense_account_id == $account_id_select){ ?> selected <?php } ?> value="<?php echo $account_id_select; ?>"><?php echo $account_name_select; ?> [$<?php echo number_format($balance,2); ?>]</option>
<?php
}

Expand All @@ -87,7 +87,7 @@
$vendor_id_select = $row['vendor_id'];
$vendor_name_select = $row['vendor_name'];
?>
<option <?php if($vendor_id == $vendor_id_select){ ?> selected <?php } ?> value="<?php echo $vendor_id_select; ?>"><?php echo $vendor_name_select; ?></option>
<option <?php if($expense_vendor_id == $vendor_id_select){ ?> selected <?php } ?> value="<?php echo $vendor_id_select; ?>"><?php echo $vendor_name_select; ?></option>
<?php
}

Expand Down Expand Up @@ -119,7 +119,7 @@
$category_id_select = $row['category_id'];
$category_name_select = $row['category_name'];
?>
<option <?php if($category_id == $category_id_select){ ?> selected <?php } ?> value="<?php echo $category_id_select; ?>"><?php echo $category_name_select; ?></option>
<option <?php if($expense_category_id == $category_id_select){ ?> selected <?php } ?> value="<?php echo $category_id_select; ?>"><?php echo $category_name_select; ?></option>
<?php
}

Expand Down
8 changes: 4 additions & 4 deletions add_expense_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
$account_name = $row['account_name'];
$opening_balance = $row['opening_balance'];

$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];

$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id");
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id");
$row = mysqli_fetch_array($sql_revenues);
$total_revenues = $row['total_revenues'];

$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id");
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];

Expand All @@ -83,7 +83,7 @@
<option value="">- Vendor -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE client_id = 0 AND vendor_archived_at IS NULL AND company_id = $session_company_id ORDER BY vendor_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_client_id = 0 AND vendor_archived_at IS NULL AND company_id = $session_company_id ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
Expand Down
6 changes: 3 additions & 3 deletions add_expense_refund_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</div>
<form action="post.php" method="post" autocomplete="off">
<div class="modal-body bg-white">
<input type="hidden" name="account" value="<?php echo $account_id; ?>">
<input type="hidden" name="vendor" value="<?php echo $vendor_id; ?>">
<input type="hidden" name="category" value="<?php echo $category_id; ?>">
<input type="hidden" name="account" value="<?php echo $expense_account_id; ?>">
<input type="hidden" name="vendor" value="<?php echo $expense_vendor_id; ?>">
<input type="hidden" name="category" value="<?php echo $expense_category_id; ?>">

<div class="form-row">

Expand Down
9 changes: 7 additions & 2 deletions add_location_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@
<span class="input-group-text"><i class="fa fa-fw fa-map-marker"></i></span>
</div>
<input type="text" class="form-control" name="name" placeholder="Name of location" required autofocus>
<div class="input-group-append">
<div class="input-group-text">
<input type="checkbox" name="primary_location" value="1" <?php if($primary_location == 0){ echo "checked"; } ?>>
</div>
</div>
</div>
</div>

Expand All @@ -62,8 +67,8 @@
<option value="">- Contact -</option>
<?php

$sql_vendors = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_archived_at IS NULL AND client_id = $client_id ORDER BY contact_name ASC");
while($row = mysqli_fetch_array($sql_vendors)){
$sql_contacts = mysqli_query($mysqli,"SELECT * FROM contacts WHERE contact_archived_at IS NULL AND contact_client_id = $client_id ORDER BY contact_name ASC");
while($row = mysqli_fetch_array($sql_contacts)){
$contact_id = $row['contact_id'];
$contact_name = $row['contact_name'];
?>
Expand Down
6 changes: 3 additions & 3 deletions add_login_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
<option value="">- Vendor -</option>
<?php

$sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE client_id = $client_id ORDER BY vendor_name ASC");
$sql_vendors = mysqli_query($mysqli,"SELECT * FROM vendors WHERE vendor_client_id = $client_id ORDER BY vendor_name ASC");
while($row = mysqli_fetch_array($sql_vendors)){
$vendor_id = $row['vendor_id'];
$vendor_name = $row['vendor_name'];
Expand All @@ -120,7 +120,7 @@
<option value="">- Asset -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM assets WHERE client_id = $client_id ORDER BY asset_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM assets WHERE asset_client_id = $client_id ORDER BY asset_name ASC");
while($row = mysqli_fetch_array($sql)){
$asset_id = $row['asset_id'];
$asset_name = $row['asset_name'];
Expand All @@ -144,7 +144,7 @@
<option value="">- software -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM software WHERE client_id = $client_id ORDER BY software_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM software WHERE software_client_id = $client_id ORDER BY software_name ASC");
while($row = mysqli_fetch_array($sql)){
$software_id = $row['software_id'];
$software_name = $row['software_name'];
Expand Down
2 changes: 1 addition & 1 deletion add_network_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
<option value="">- Location -</option>
<?php

$sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE location_archived_at IS NULL AND client_id = $client_id ORDER BY location_name ASC");
$sql = mysqli_query($mysqli,"SELECT * FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id ORDER BY location_name ASC");
while($row = mysqli_fetch_array($sql)){
$location_id = $row['location_id'];
$location_name = $row['location_name'];
Expand Down
10 changes: 5 additions & 5 deletions add_payment_modal.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@
$account_name = $row['account_name'];
$opening_balance = $row['opening_balance'];

$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE account_id = $account_id");
$sql_payments = mysqli_query($mysqli,"SELECT SUM(payment_amount) AS total_payments FROM payments WHERE payment_account_id = $account_id");
$row = mysqli_fetch_array($sql_payments);
$total_payments = $row['total_payments'];

$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE account_id = $account_id");
$sql_revenues = mysqli_query($mysqli,"SELECT SUM(revenue_amount) AS total_revenues FROM revenues WHERE revenue_account_id = $account_id");
$row = mysqli_fetch_array($sql_revenues);
$total_revenues = $row['total_revenues'];

$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE account_id = $account_id");
$sql_expenses = mysqli_query($mysqli,"SELECT SUM(expense_amount) AS total_expenses FROM expenses WHERE expense_account_id = $account_id");
$row = mysqli_fetch_array($sql_expenses);
$total_expenses = $row['total_expenses'];

Expand Down Expand Up @@ -117,13 +117,13 @@
</div>
</div>

<?php if(!empty($config_smtp_host) AND !empty($client_email)){ ?>
<?php if(!empty($config_smtp_host) AND !empty($contact_email)){ ?>

<div class="form-group">
<label>Email Receipt</label>
<div class="custom-control custom-checkbox">
<input type="checkbox" class="custom-control-input" id="customControlAutosizing" name="email_receipt" value="1" checked>
<label class="custom-control-label" for="customControlAutosizing"><?php echo $client_email; ?></label>
<label class="custom-control-label" for="customControlAutosizing"><?php echo $contact__email; ?></label>
</div>
</div>

Expand Down
Loading

0 comments on commit f3053ff

Please sign in to comment.