mirror of https://github.com/itflow-org/itflow
Update the remaining logic to take advantage of the moved contact_primary and contact_location fields
This commit is contained in:
parent
85c19e36c6
commit
a5100ea187
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<!-- Prevent undefined checkbox errors on submit -->
|
||||
<input type="hidden" name="primary_contact" value="0">
|
||||
<input type="hidden" name="contact_primary" value="0">
|
||||
<input type="hidden" name="contact_important" value="0">
|
||||
<input type="hidden" name="contact_billing" value="0">
|
||||
<input type="hidden" name="contact_technical" value="0">
|
||||
|
|
@ -47,7 +47,7 @@
|
|||
<input type="text" class="form-control" name="name" placeholder="Full Name" required autofocus>
|
||||
<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"; } ?>>
|
||||
<input type="checkbox" name="contact_primary" value="1">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -22,14 +22,15 @@ if (isset($_GET['contact_id'])) {
|
|||
$contact_pin = nullable_htmlentities($row['contact_pin']);
|
||||
$contact_initials = initials($contact_name);
|
||||
$contact_notes = nullable_htmlentities($row['contact_notes']);
|
||||
$contact_primary = intval($row['contact_primary']);
|
||||
$contact_important = intval($row['contact_important']);
|
||||
$contact_billing = intval($row['contact_billing']);
|
||||
$contact_technical = intval($row['contact_technical']);
|
||||
$contact_created_at = nullable_htmlentities($row['contact_created_at']);
|
||||
if ($contact_id == $primary_contact) {
|
||||
$primary_contact_display = "<small class='text-success'>Primary Contact</small>";
|
||||
if ($contact_primary == 1 ) {
|
||||
$contact_primary_display = "<small class='text-success'>Primary Contact</small>";
|
||||
} else {
|
||||
$primary_contact_display = false;
|
||||
$contact_primary_display = false;
|
||||
}
|
||||
$contact_location_id = intval($row['contact_location_id']);
|
||||
$location_name = nullable_htmlentities($row['location_name']);
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
</div>
|
||||
<form action="post.php" method="post" enctype="multipart/form-data" autocomplete="off">
|
||||
<!-- Prevent undefined checkbox errors on submit -->
|
||||
<input type="hidden" name="primary_contact" value="0">
|
||||
<input type="hidden" name="contact_primary" value="0">
|
||||
<input type="hidden" name="contact_important" value="0">
|
||||
<input type="hidden" name="contact_billing" value="0">
|
||||
<input type="hidden" name="contact_technical" value="0">
|
||||
|
|
@ -48,7 +48,7 @@
|
|||
<input type="text" class="form-control" name="name" placeholder="Full Name" value="<?php echo $contact_name; ?>" required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<input type="checkbox" name="primary_contact" value="1" <?php if ($contact_id == $primary_contact) { echo "checked"; } ?>>
|
||||
<input type="checkbox" name="contact_primary" value="1" <?php if ($contact_primary == 1) { echo "checked"; } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -116,14 +116,15 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$contact_photo = nullable_htmlentities($row['contact_photo']);
|
||||
$contact_initials = initials($contact_name);
|
||||
$contact_notes = nullable_htmlentities($row['contact_notes']);
|
||||
$contact_primary = intval($row['contact_primary']);
|
||||
$contact_important = intval($row['contact_important']);
|
||||
$contact_billing = intval($row['contact_billing']);
|
||||
$contact_technical = intval($row['contact_technical']);
|
||||
$contact_created_at = nullable_htmlentities($row['contact_created_at']);
|
||||
if ($contact_id == $primary_contact) {
|
||||
$primary_contact_display = "<small class='text-success'>Primary Contact</small>";
|
||||
if ($contact_primary == 1) {
|
||||
$contact_primary_display = "<small class='text-success'>Primary Contact</small>";
|
||||
} else {
|
||||
$primary_contact_display = false;
|
||||
$contact_primary_display = false;
|
||||
}
|
||||
$contact_location_id = intval($row['contact_location_id']);
|
||||
$location_name = nullable_htmlentities($row['location_name']);
|
||||
|
|
@ -170,7 +171,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<?php } ?>
|
||||
<div class="text-dark"><?php echo $contact_name; ?></div>
|
||||
<div><?php echo $contact_title_display; ?></div>
|
||||
<div><?php echo $primary_contact_display; ?></div>
|
||||
<div><?php echo $contact_primary_display; ?></div>
|
||||
</a>
|
||||
</td>
|
||||
|
||||
|
|
@ -189,7 +190,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editContactModal<?php echo $contact_id; ?>">
|
||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||
</a>
|
||||
<?php if ($session_user_role == 3 && $contact_id !== $primary_contact) { ?>
|
||||
<?php if ($session_user_role == 3 && $contact_primary == 0) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="post.php?archive_contact=<?php echo $contact_id; ?>">
|
||||
<i class="fas fa-fw fa-archive mr-2"></i>Archive
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@
|
|||
<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"; } ?>>
|
||||
<input type="checkbox" name="location_primary" value="1" <?php if ($location_primary == 0) { echo "checked"; } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
<input type="text" class="form-control" name="name" placeholder="Name of location" value="<?php echo $location_name; ?>" required>
|
||||
<div class="input-group-append">
|
||||
<div class="input-group-text">
|
||||
<input type="checkbox" name="primary_location" value="1" <?php if ($location_id == $primary_location) { echo "checked"; } ?>>
|
||||
<input type="checkbox" name="location_primary" value="1" <?php if ($location_primary == 1) { echo "checked"; } ?>>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -91,10 +91,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
$location_notes = nullable_htmlentities($row['location_notes']);
|
||||
$location_created_at = nullable_htmlentities($row['location_created_at']);
|
||||
$location_contact_id = intval($row['location_contact_id']);
|
||||
if ($location_id == $primary_location) {
|
||||
$primary_location_display = "<p class='text-success'>Primary Location</p>";
|
||||
$location_primary = intval($row['location_primary']);
|
||||
if ( $location_primary == 1 ) {
|
||||
$location_primary_display = "<p class='text-success'>Primary Location</p>";
|
||||
} else {
|
||||
$primary_location_display = "";
|
||||
$location_primary_display = "";
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -102,7 +103,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<th>
|
||||
<i class="fa fa-fw fa-map-marker-alt text-secondary"></i>
|
||||
<a class="text-dark" href="#" data-toggle="modal" data-target="#editLocationModal<?php echo $location_id; ?>"><?php echo $location_name; ?></a>
|
||||
<?php echo $primary_location_display; ?>
|
||||
<?php echo $location_primary_display; ?>
|
||||
</th>
|
||||
<td><a href="//maps.<?php echo $session_map_source; ?>.com?q=<?php echo "$location_address $location_zip"; ?>" target="_blank"><?php echo $location_address; ?><br><?php echo "$location_city $location_state $location_zip"; ?></a></td>
|
||||
<td><?php echo $location_phone_display; ?></td>
|
||||
|
|
|
|||
|
|
@ -13,8 +13,9 @@ $sql_important_contacts = mysqli_query(
|
|||
$mysqli,
|
||||
"SELECT * FROM contacts
|
||||
WHERE contact_client_id = $client_id
|
||||
AND (contact_important = 1 OR contact_billing = 1 OR contact_technical = 1 OR contact_id = $primary_contact)
|
||||
AND contact_archived_at IS NULL ORDER BY contact_name DESC"
|
||||
AND (contact_important = 1 OR contact_billing = 1 OR contact_technical = 1 OR contact_primary = 1)
|
||||
AND contact_archived_at IS NULL
|
||||
ORDER BY contact_primary DESC, contact_name DESC"
|
||||
);
|
||||
|
||||
$sql_recent_tickets = mysqli_query(
|
||||
|
|
|
|||
4
cron.php
4
cron.php
|
|
@ -435,7 +435,7 @@ foreach ($invoiceAlertArray as $day) {
|
|||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_status NOT LIKE 'Draft'
|
||||
AND invoice_status NOT LIKE 'Paid'
|
||||
AND invoice_status NOT LIKE 'Cancelled'
|
||||
|
|
@ -563,7 +563,7 @@ while ($row = mysqli_fetch_array($sql_recurring)) {
|
|||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $new_invoice_id"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -193,7 +193,7 @@ if (isset($_GET['invoice_id'], $_GET['url_key']) && !isset($_GET['payment_intent
|
|||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $pi_invoice_id
|
||||
AND invoice_status != 'Draft'
|
||||
AND invoice_status != 'Paid'
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ $sql = mysqli_query(
|
|||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $invoice_id
|
||||
AND invoice_url_key = '$url_key'"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -16,8 +16,8 @@ $sql = mysqli_query(
|
|||
$mysqli,
|
||||
"SELECT * FROM quotes
|
||||
LEFT JOIN clients ON quote_client_id = client_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE quote_id = $quote_id
|
||||
AND quote_url_key = '$url_key'"
|
||||
);
|
||||
|
|
|
|||
|
|
@ -14,8 +14,8 @@ if (isset($_GET['client_id'])) {
|
|||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT * FROM clients
|
||||
LEFT JOIN locations ON primary_location = location_id AND location_archived_at IS NULL
|
||||
LEFT JOIN contacts ON primary_contact = contact_id AND contact_archived_at IS NULL
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE client_id = $client_id"
|
||||
);
|
||||
|
||||
|
|
@ -38,8 +38,6 @@ if (isset($_GET['client_id'])) {
|
|||
$client_rate = floatval($row['client_rate']);
|
||||
$client_notes = nullable_htmlentities($row['client_notes']);
|
||||
$client_created_at = nullable_htmlentities($row['client_created_at']);
|
||||
$primary_contact = intval($row['primary_contact']);
|
||||
$primary_location = intval($row['primary_location']);
|
||||
$contact_id = intval($row['contact_id']);
|
||||
$contact_name = nullable_htmlentities($row['contact_name']);
|
||||
$contact_title = nullable_htmlentities($row['contact_title']);
|
||||
|
|
@ -47,6 +45,7 @@ if (isset($_GET['client_id'])) {
|
|||
$contact_phone = formatPhoneNumber($row['contact_phone']);
|
||||
$contact_extension = nullable_htmlentities($row['contact_extension']);
|
||||
$contact_mobile = formatPhoneNumber($row['contact_mobile']);
|
||||
$contact_primary = intval($row['contact_primary']);
|
||||
$location_id = intval($row['location_id']);
|
||||
$location_name = nullable_htmlentities($row['location_name']);
|
||||
$location_address = nullable_htmlentities($row['location_address']);
|
||||
|
|
@ -55,6 +54,7 @@ if (isset($_GET['client_id'])) {
|
|||
$location_zip = nullable_htmlentities($row['location_zip']);
|
||||
$location_country = nullable_htmlentities($row['location_country']);
|
||||
$location_phone = formatPhoneNumber($row['location_phone']);
|
||||
$location_primary = intval($row['location_primary']);
|
||||
|
||||
//Client Tags
|
||||
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ if (isset($_GET['invoice_id'])) {
|
|||
$mysqli,
|
||||
"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE invoice_id = $invoice_id"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ $session_contact_initials = initials($session_contact_name);
|
|||
$session_contact_title = sanitizeInput($contact['contact_title']);
|
||||
$session_contact_email = sanitizeInput($contact['contact_email']);
|
||||
$session_contact_photo = sanitizeInput($contact['contact_photo']);
|
||||
$session_contact_primary = intval($client['contact_primary']);
|
||||
|
||||
$session_contact_is_technical_contact = false;
|
||||
$session_contact_is_billing_contact = false;
|
||||
|
|
@ -60,11 +61,8 @@ if ($contact['contact_billing'] == 1) {
|
|||
$session_contact_is_billing_contact = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Get client info
|
||||
$client_sql = mysqli_query($mysqli, "SELECT * FROM clients WHERE client_id = $session_client_id");
|
||||
$client = mysqli_fetch_array($client_sql);
|
||||
|
||||
$session_client_name = $client['client_name'];
|
||||
$session_client_primary_contact_id = intval($client['primary_contact']);
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.g
|
|||
|
||||
require_once("inc_portal.php");
|
||||
|
||||
if ($session_contact_id !== $session_client_primary_contact_id && !$session_contact_is_technical_contact) {
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_technical_contact) {
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.g
|
|||
|
||||
require_once("inc_portal.php");
|
||||
|
||||
if ($session_contact_id !== $session_client_primary_contact_id && !$session_contact_is_technical_contact) {
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_technical_contact) {
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.g
|
|||
|
||||
require_once("inc_portal.php");
|
||||
|
||||
if ($session_contact_id !== $session_client_primary_contact_id && !$session_contact_is_billing_contact) {
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_billing_contact) {
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ function verifyContactTicketAccess($requested_ticket_id, $expected_ticket_state)
|
|||
{
|
||||
|
||||
// Access the global variables
|
||||
global $mysqli, $session_contact_id, $session_client_primary_contact_id, $session_contact_is_technical_contact, $session_client_id;
|
||||
global $mysqli, $session_contact_id, $session_contact_primary, $session_contact_is_technical_contact, $session_client_id;
|
||||
|
||||
// Setup
|
||||
if ($expected_ticket_state == "Closed") {
|
||||
|
|
@ -27,7 +27,7 @@ function verifyContactTicketAccess($requested_ticket_id, $expected_ticket_state)
|
|||
$row = mysqli_fetch_array($sql);
|
||||
$ticket_id = $row['ticket_id'];
|
||||
|
||||
if (intval($ticket_id) && ($session_contact_id == $row['ticket_contact_id'] || $session_contact_id == $session_client_primary_contact_id || $session_contact_is_technical_contact)) {
|
||||
if (intval($ticket_id) && ($session_contact_id == $row['ticket_contact_id'] || $session_contact_primary == 1 || $session_contact_is_technical_contact)) {
|
||||
// Client is ticket owner, primary contact, or a technical contact
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ header("X-Frame-Options: DENY"); // Legacy
|
|||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (basename($_SERVER['PHP_SELF']) == "tickets.php" || basename($_SERVER['PHP_SELF']) == "ticket_add.php" || basename($_SERVER['PHP_SELF']) == "ticket.php") {echo "active";} ?>" href="tickets.php">Tickets</a>
|
||||
</li>
|
||||
<?php if ($session_contact_id == $session_client_primary_contact_id || $session_contact_is_billing_contact) { ?>
|
||||
<?php if ($session_contact_primary == 1 || $session_contact_is_billing_contact) { ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (basename($_SERVER['PHP_SELF']) == "invoices.php") {echo "active";} ?>" href="invoices.php">Invoices</a>
|
||||
</li>
|
||||
|
|
@ -53,7 +53,7 @@ header("X-Frame-Options: DENY"); // Legacy
|
|||
<a class="nav-link <?php if (basename($_SERVER['PHP_SELF']) == "quotes.php") {echo "active";} ?>" href="quotes.php">Quotes</a>
|
||||
</li>
|
||||
<?php } ?>
|
||||
<?php if ($session_contact_id == $session_client_primary_contact_id || $session_contact_is_technical_contact) { ?>
|
||||
<?php if ($session_contact_primary == 1 || $session_contact_is_technical_contact) { ?>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link <?php if (basename($_SERVER['PHP_SELF']) == "documents.php") {echo "active";} ?>" href="documents.php">Documents</a>
|
||||
</li>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ require_once('inc_portal.php');
|
|||
<p>Email: <?php echo $session_contact_email ?></p>
|
||||
<p>Client: <?php echo $session_client_name ?></p>
|
||||
<br>
|
||||
<p>Client Primary Contact: <?php if ($session_client_primary_contact_id == $session_contact_id) {echo "Yes"; } else {echo "No";} ?></p>
|
||||
<p>Client Primary Contact: <?php if ($session_contact_primary == 1) {echo "Yes"; } else {echo "No";} ?></p>
|
||||
<p>Client Technical Contact: <?php if ($session_contact_is_technical_contact) {echo "Yes"; } else {echo "No";} ?></p>
|
||||
<p>Client Billing Contact: <?php if ($session_contact_is_billing_contact == $session_contact_id) {echo "Yes"; } else {echo "No";} ?></p>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ header("Content-Security-Policy: default-src 'self' fonts.googleapis.com fonts.g
|
|||
|
||||
require_once("inc_portal.php");
|
||||
|
||||
if ($session_contact_id !== $session_client_primary_contact_id && !$session_contact_is_billing_contact) {
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_billing_contact) {
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ $purifier = new HTMLPurifier($purifier_config);
|
|||
if (isset($_GET['id']) && intval($_GET['id'])) {
|
||||
$ticket_id = intval($_GET['id']);
|
||||
|
||||
if ($session_contact_id == $session_client_primary_contact_id || $session_contact_is_technical_contact) {
|
||||
if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id");
|
||||
} else {
|
||||
$ticket_sql = mysqli_query($mysqli, "SELECT * FROM tickets WHERE ticket_id = $ticket_id AND ticket_client_id = $session_client_id AND ticket_contact_id = $session_contact_id");
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
require_once('inc_portal.php');
|
||||
|
||||
if ($session_contact_id !== $session_client_primary_contact_id && !$session_contact_is_technical_contact) {
|
||||
if ($session_contact_primary == 0 && !$session_contact_is_technical_contact) {
|
||||
header("Location: portal_post.php?logout");
|
||||
exit();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ $total_tickets = intval($row['total_tickets']);
|
|||
|
||||
<a href="?status=%" class="btn btn-secondary btn-block p-3 mb-3 text-left">All my tickets | <strong><?php echo $total_tickets ?></strong></a>
|
||||
<?php
|
||||
if ($session_contact_id == $session_client_primary_contact_id || $session_contact_is_technical_contact) {
|
||||
if ($session_contact_primary == 1 || $session_contact_is_technical_contact) {
|
||||
?>
|
||||
|
||||
<hr>
|
||||
|
|
|
|||
|
|
@ -38,10 +38,6 @@ if (isset($_POST['add_client'])) {
|
|||
if (!empty($location_phone) || !empty($address) || !empty($city) || !empty($state) || !empty($zip)) {
|
||||
mysqli_query($mysqli, "INSERT INTO locations SET location_name = 'Primary', location_address = '$address', location_city = '$city', location_state = '$state', location_zip = '$zip', location_phone = '$location_phone', location_country = '$country', location_primary = 1, location_client_id = $client_id");
|
||||
|
||||
//Update Primay location in clients
|
||||
$location_id = mysqli_insert_id($mysqli);
|
||||
mysqli_query($mysqli, "UPDATE clients SET primary_location = $location_id WHERE client_id = $client_id");
|
||||
|
||||
//Extended Logging
|
||||
$extended_log_description .= ", primary location $address added";
|
||||
}
|
||||
|
|
@ -51,10 +47,6 @@ if (isset($_POST['add_client'])) {
|
|||
if (!empty($contact) || !empty($title) || !empty($contact_phone) || !empty($contact_mobile) || !empty($contact_email)) {
|
||||
mysqli_query($mysqli, "INSERT INTO contacts SET contact_name = '$contact', contact_title = '$title', contact_phone = '$contact_phone', contact_extension = '$contact_extension', contact_mobile = '$contact_mobile', contact_email = '$contact_email', contact_primary = 1, contact_important = 1, contact_client_id = $client_id");
|
||||
|
||||
//Update Primary contact in clients
|
||||
$contact_id = mysqli_insert_id($mysqli);
|
||||
mysqli_query($mysqli, "UPDATE clients SET primary_contact = $contact_id WHERE client_id = $client_id");
|
||||
|
||||
//Extended Logging
|
||||
$extended_log_description .= ", primary contact $contact added";
|
||||
}
|
||||
|
|
@ -306,8 +298,8 @@ if (isset($_POST['export_clients_csv'])) {
|
|||
|
||||
//get records from database
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients
|
||||
LEFT JOIN contacts ON clients.primary_contact = contacts.contact_id AND contact_archived_at IS NULL
|
||||
LEFT JOIN locations ON clients.primary_location = locations.location_id AND location_archived_at IS NULL
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
ORDER BY client_name ASC
|
||||
");
|
||||
|
||||
|
|
@ -368,8 +360,8 @@ if (isset($_POST['export_client_pdf'])) {
|
|||
|
||||
//get records from database
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM clients
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE client_id = $client_id
|
||||
");
|
||||
|
||||
|
|
|
|||
|
|
@ -10,4 +10,4 @@ $phone = preg_replace("/[^0-9]/", '',$_POST['phone']);
|
|||
$hours = sanitizeInput($_POST['hours']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
$contact = intval($_POST['contact']);
|
||||
$location_primary = intval($_POST['primary_location']);
|
||||
$location_primary = intval($_POST['location_primary']);
|
||||
|
|
@ -21,11 +21,7 @@ if (isset($_POST['add_contact'])) {
|
|||
$contact_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Update Primary contact in clients if primary contact is checked
|
||||
if ($contact_primary == 1) {
|
||||
// Old way of adding contact_primary Set for Removal
|
||||
mysqli_query($mysqli,"UPDATE clients SET primary_contact = $contact_id WHERE client_id = $client_id");
|
||||
|
||||
// New Way of setting primary contact
|
||||
if ($contact_primary == 1) {
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_primary = 0 WHERE contact_client_id = $client_id");
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_primary = 1, contact_important = 1 WHERE contact_id = $contact_id");
|
||||
}
|
||||
|
|
@ -80,9 +76,6 @@ if (isset($_POST['edit_contact'])) {
|
|||
|
||||
// Update Primary contact in clients if primary contact is checked
|
||||
if ($contact_primary == 1) {
|
||||
// Old way of adding contact_primary Set for Removal
|
||||
mysqli_query($mysqli,"UPDATE clients SET primary_contact = $contact_id WHERE client_id = $client_id");
|
||||
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_primary = 0 WHERE contact_client_id = $client_id");
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_primary = 1, contact_important = 1 WHERE contact_id = $contact_id");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ $extension = preg_replace("/[^0-9]/", '', $_POST['extension']);
|
|||
$mobile = preg_replace("/[^0-9]/", '', $_POST['mobile']);
|
||||
$email = sanitizeInput($_POST['email']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
$contact_primary = intval($_POST['primary_contact']);
|
||||
$contact_primary = intval($_POST['contact_primary']);
|
||||
$contact_important = intval($_POST['contact_important']);
|
||||
$contact_billing = intval($_POST['contact_billing']);
|
||||
$contact_technical = intval($_POST['contact_technical']);
|
||||
|
|
|
|||
|
|
@ -559,7 +559,7 @@ if (isset($_POST['add_payment'])) {
|
|||
//Get the invoice total
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $invoice_id"
|
||||
);
|
||||
|
||||
|
|
@ -721,7 +721,7 @@ if (isset($_GET['email_invoice'])) {
|
|||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $invoice_id"
|
||||
);
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
|
@ -899,7 +899,7 @@ if (isset($_GET['force_recurring'])) {
|
|||
if ($config_recurring_auto_send_invoice == 1) {
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices
|
||||
LEFT JOIN clients ON invoice_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE invoice_id = $new_invoice_id"
|
||||
);
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
|
|
|||
|
|
@ -19,16 +19,12 @@ if(isset($_POST['add_location'])){
|
|||
$location_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Update Primay location in clients if primary location is checked
|
||||
if($location_primary == 1){
|
||||
// Old way of adding contact_primary Set for Removal
|
||||
mysqli_query($mysqli,"UPDATE clients SET primary_location = $location_id WHERE client_id = $client_id");
|
||||
|
||||
// New Way of setting primary location
|
||||
if ($location_primary == 1) {
|
||||
mysqli_query($mysqli,"UPDATE locations SET location_primary = 0 WHERE location_client_id = $client_id");
|
||||
mysqli_query($mysqli,"UPDATE locations SET location_primary = 1 WHERE location_id = $location_id");
|
||||
}
|
||||
|
||||
//Check to see if a file is attached
|
||||
// Check to see if a file is attached
|
||||
if($_FILES['file']['tmp_name'] != ''){
|
||||
if ($new_file_name = checkFileUpload($_FILES['file'], array('jpg', 'jpeg', 'gif', 'png'))) {
|
||||
|
||||
|
|
@ -79,11 +75,7 @@ if(isset($_POST['edit_location'])){
|
|||
mysqli_query($mysqli,"UPDATE locations SET location_name = '$name', location_country = '$country', location_address = '$address', location_city = '$city', location_state = '$state', location_zip = '$zip', location_phone = '$phone', location_hours = '$hours', location_notes = '$notes', location_contact_id = $contact WHERE location_id = $location_id");
|
||||
|
||||
// Update Primay location in clients if primary location is checked
|
||||
if($location_primary == 1){
|
||||
// Old way of adding contact_primary Set for Removal
|
||||
mysqli_query($mysqli,"UPDATE clients SET primary_location = $location_id WHERE client_id = $client_id");
|
||||
|
||||
// New Way of setting primary location
|
||||
if ($location_primary == 1) {
|
||||
mysqli_query($mysqli,"UPDATE locations SET location_primary = 0 WHERE location_client_id = $client_id");
|
||||
mysqli_query($mysqli,"UPDATE locations SET location_primary = 1 WHERE location_id = $location_id");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ if (isset($_GET['email_quote'])) {
|
|||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM quotes
|
||||
LEFT JOIN clients ON quote_client_id = client_id
|
||||
LEFT JOIN contacts ON contact_id = primary_contact
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
WHERE quote_id = $quote_id"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ if (isset($_GET['quote_id'])) {
|
|||
$mysqli,
|
||||
"SELECT * FROM quotes
|
||||
LEFT JOIN clients ON quote_client_id = client_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE quote_id = $quote_id"
|
||||
);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,8 +9,8 @@ if (isset($_GET['recurring_id'])) {
|
|||
$mysqli,
|
||||
"SELECT * FROM recurring
|
||||
LEFT JOIN clients ON recurring_client_id = client_id
|
||||
LEFT JOIN locations ON primary_location = location_id
|
||||
LEFT JOIN contacts ON primary_contact = contact_id
|
||||
LEFT JOIN contacts ON clients.client_id = contacts.contact_client_id AND contact_primary = 1
|
||||
LEFT JOIN locations ON clients.client_id = locations.location_client_id AND location_primary = 1
|
||||
WHERE recurring_id = $recurring_id"
|
||||
);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue