mirror of
https://github.com/itflow-org/itflow
synced 2026-02-28 10:54:52 +00:00
Update logic for adding and editing primary location
This commit is contained in:
@@ -18,9 +18,14 @@ if(isset($_POST['add_location'])){
|
||||
|
||||
$location_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Update Primay location in clients if primary location is checked
|
||||
if($primary_location > 0){
|
||||
// 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
|
||||
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
|
||||
@@ -73,9 +78,14 @@ 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($primary_location > 0){
|
||||
// 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
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user