mirror of https://github.com/itflow-org/itflow
Remove Departments table and remove it from the client side nav, takes up too much space, added it as a text input on contact add/edit instead
This commit is contained in:
parent
d5922b25a9
commit
7b35431021
|
|
@ -93,9 +93,6 @@ if(isset($_GET['client_id'])){
|
|||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('location_id') AS num FROM locations WHERE location_archived_at IS NULL AND location_client_id = $client_id"));
|
||||
$num_locations = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('department_id') AS num FROM departments WHERE department_archived_at IS NULL AND department_client_id = $client_id"));
|
||||
$num_departments = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('asset_id') AS num FROM assets WHERE asset_archived_at IS NULL AND asset_client_id = $client_id"));
|
||||
$num_assets = $row['num'];
|
||||
|
|
|
|||
|
|
@ -63,21 +63,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="department">
|
||||
<option value="">- Department -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM departments WHERE department_archived_at IS NULL AND department_client_id = $client_id ORDER BY department_name ASC");
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$department_id = $row['department_id'];
|
||||
$department_name = $row['department_name'];
|
||||
?>
|
||||
<option value="<?php echo $department_id; ?>"><?php echo $department_name; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="text" class="form-control" name="department" placeholder="Department">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -65,21 +65,7 @@
|
|||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
</div>
|
||||
<select class="form-control select2" name="department">
|
||||
<option value="">- Department -</option>
|
||||
<?php
|
||||
|
||||
$sql_departments = mysqli_query($mysqli,"SELECT * FROM departments WHERE department_client_id = $client_id ORDER BY department_name ASC");
|
||||
while($row = mysqli_fetch_array($sql_departments)){
|
||||
$department_id_select = $row['department_id'];
|
||||
$department_name_select = $row['department_name'];
|
||||
?>
|
||||
<option <?php if($department_id_select == $department_id){ echo "selected"; } ?> value="<?php echo $department_id_select; ?>"><?php echo $department_name_select; ?></option>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="text" class="form-control" name="department" placeholder="Department" value="<?php echo $contact_department; ?>">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ $url_query_strings_sb = http_build_query(array_merge($_GET,array('sb' => $sb, 'o
|
|||
|
||||
$sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM contacts
|
||||
LEFT JOIN locations ON location_id = contact_location_id
|
||||
LEFT JOIN departments ON contact_department_id = department_id
|
||||
WHERE contact_archived_at IS NULL
|
||||
AND (contact_name LIKE '%$q%' OR contact_title LIKE '%$q%' OR location_name LIKE '%$q%' OR contact_email LIKE '%$q%' OR department_name LIKE '%$q%' OR contact_phone LIKE '%$n%' OR contact_extension LIKE '%$q%' OR contact_mobile LIKE '%$n%')
|
||||
AND contact_client_id = $client_id ORDER BY $sb $o LIMIT $record_from, $record_to");
|
||||
|
|
@ -70,7 +69,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
<thead class="thead-light <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th class="text-center"><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=contact_name&o=<?php echo $disp; ?>">Name</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=department_name&o=<?php echo $disp; ?>">Department</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=$contact_department&o=<?php echo $disp; ?>">Department</a></th>
|
||||
<th><a class="text-secondary" href="?<?php echo $url_query_strings_sb; ?>&sb=contact_email&o=<?php echo $disp; ?>">Email</a></th>
|
||||
<th>Phone</th>
|
||||
<th>Mobile</th>
|
||||
|
|
@ -90,11 +89,11 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
}else{
|
||||
$contact_title_display = "<small class='text-secondary'>$contact_title</small>";
|
||||
}
|
||||
$department_name = $row['department_name'];
|
||||
if(empty($department_name)){
|
||||
$department_name_display = "-";
|
||||
$contact_department = $row['contact_department'];
|
||||
if(empty($contact_department)){
|
||||
$contact_department_display = "-";
|
||||
}else{
|
||||
$department_name_display = $department_name;
|
||||
$contact_department_display = $contact_department;
|
||||
}
|
||||
$contact_phone = formatPhoneNumber($row['contact_phone']);
|
||||
if(empty($contact_phone)){
|
||||
|
|
@ -131,7 +130,6 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
}else{
|
||||
$location_name_display = $location_name;
|
||||
}
|
||||
$department_id = $row['department_id'];
|
||||
$auth_method = $row['contact_auth_method'];
|
||||
|
||||
// Related Assets Query
|
||||
|
|
@ -181,7 +179,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
</a>
|
||||
</th>
|
||||
|
||||
<td><?php echo $department_name_display; ?></td>
|
||||
<td><?php echo $contact_department_display; ?></td>
|
||||
<td><?php echo $contact_email_display; ?></td>
|
||||
<td><?php echo $contact_phone_display; ?> <?php if(!empty($contact_extension)){ echo "x$contact_extension"; } ?></td>
|
||||
<td><?php echo $contact_mobile_display; ?></td>
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ if(isset($_GET['tab'])){
|
|||
elseif($_GET['tab'] == "locations"){
|
||||
include("client_locations.php");
|
||||
}
|
||||
if($_GET['tab'] == "departments"){
|
||||
include("client_departments.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "assets"){
|
||||
if($session_user_role > 1) {
|
||||
include("client_assets.php");
|
||||
|
|
|
|||
|
|
@ -53,19 +53,6 @@
|
|||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-item">
|
||||
<a href="?client_id=<?php echo $client_id; ?>&tab=departments" class="nav-link <?php if($_GET['tab'] == "departments") { echo "active"; } ?>">
|
||||
<i class="nav-icon fas fa-building"></i>
|
||||
<p>
|
||||
Departments
|
||||
<?php
|
||||
if($num_departments > 0){ ?>
|
||||
<span class="right badge badge-light"><?php echo $num_departments; ?></span>
|
||||
<?php } ?>
|
||||
</p>
|
||||
</a>
|
||||
</li>
|
||||
|
||||
<li class="nav-header mt-3">ASSETS</li>
|
||||
|
||||
<li class="nav-item">
|
||||
|
|
|
|||
|
|
@ -177,11 +177,20 @@ if(LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION){
|
|||
|
||||
if(CURRENT_DATABASE_VERSION == '0.0.6'){
|
||||
// Insert queries here required to update to DB version 0.0.7
|
||||
mysqli_query($mysqli, "ALTER TABLE contacts ADD contact_department VARCHAR(200) NULL AFTER contact_department_id");
|
||||
mysqli_query($mysqli, "DROP TABLE departments");
|
||||
mysqli_query($mysqli, "ALTER TABLE contacts DROP contact_department_id");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.7'");
|
||||
}
|
||||
|
||||
if(CURRENT_DATABASE_VERSION == '0.0.7'){
|
||||
// Insert queries here required to update to DB version 0.0.8
|
||||
|
||||
// ALTER queries.....
|
||||
|
||||
// Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.6'");
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '0.0.8'");
|
||||
}
|
||||
|
||||
// etc
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.0.6");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "0.0.7");
|
||||
102
post.php
102
post.php
|
|
@ -4183,7 +4183,7 @@ if(isset($_POST['add_contact'])){
|
|||
$client_id = intval($_POST['client_id']);
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])));
|
||||
$department = intval($_POST['department']);
|
||||
$department = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['department'])));
|
||||
$phone = preg_replace("/[^0-9]/", '',$_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '',$_POST['extension']);
|
||||
$mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']);
|
||||
|
|
@ -4198,7 +4198,7 @@ if(isset($_POST['add_contact'])){
|
|||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_department_id = $department, contact_location_id = $location_id, contact_client_id = $client_id, company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"INSERT INTO contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_department = '$department', contact_location_id = $location_id, contact_client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
$contact_id = mysqli_insert_id($mysqli);
|
||||
|
||||
|
|
@ -4271,7 +4271,7 @@ if(isset($_POST['edit_contact'])){
|
|||
$client_id = intval($_POST['client_id']);
|
||||
$name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['name'])));
|
||||
$title = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['title'])));
|
||||
$department = intval($_POST['department']);
|
||||
$department = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['department'])));
|
||||
$phone = preg_replace("/[^0-9]/", '',$_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '',$_POST['extension']);
|
||||
$mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']);
|
||||
|
|
@ -4288,7 +4288,7 @@ if(isset($_POST['edit_contact'])){
|
|||
mkdir("uploads/clients/$session_company_id/$client_id");
|
||||
}
|
||||
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_department_id = $department, contact_location_id = $location_id, contact_updated_at = NOW() WHERE contact_id = $contact_id AND company_id = $session_company_id");
|
||||
mysqli_query($mysqli,"UPDATE contacts SET contact_name = '$name', contact_title = '$title', contact_phone = '$phone', contact_extension = '$extension', contact_mobile = '$mobile', contact_email = '$email', contact_notes = '$notes', contact_auth_method = '$auth_method', contact_department = '$department', contact_location_id = $location_id, contact_updated_at = NOW() WHERE contact_id = $contact_id AND company_id = $session_company_id");
|
||||
|
||||
// Update Primary contact in clients if primary contact is checked
|
||||
if($primary_contact > 0){
|
||||
|
|
@ -4680,100 +4680,6 @@ if(isset($_GET['export_client_locations_csv'])){
|
|||
|
||||
}
|
||||
|
||||
// Client Departments
|
||||
if(isset($_POST['add_department'])){
|
||||
|
||||
if($session_user_role != 3){
|
||||
$_SESSION['alert_type'] = "danger";
|
||||
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$department_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['department_name'])));
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO departments SET department_name = '$department_name', department_client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
$contact_id = mysqli_insert_id($mysqli);
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Create', log_description = '$department_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', company_id = $session_company_id, log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] .= "Department added";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_department'])){
|
||||
|
||||
if($session_user_role != 3){
|
||||
$_SESSION['alert_type'] = "danger";
|
||||
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$department_id = intval($_POST['department_id']);
|
||||
$client_id = intval($_POST['client_id']);
|
||||
$department_name = trim(strip_tags(mysqli_real_escape_string($mysqli,$_POST['department_name'])));
|
||||
|
||||
mysqli_query($mysqli,"UPDATE departments SET department_name = '$department_name', department_updated_at = NOW() WHERE department_id = $department_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Modify', log_description = '$department_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] .= "Department updated";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['archive_department'])){
|
||||
|
||||
if($session_user_role != 3){
|
||||
$_SESSION['alert_type'] = "danger";
|
||||
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$department_id = intval($_GET['archive_department']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE departments SET department_archived_at = NOW() WHERE department_id = $department_id");
|
||||
|
||||
//logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Department', log_action = 'Archive', log_description = '$department_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Department Archived!";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['delete_department'])){
|
||||
|
||||
if($session_user_role != 3){
|
||||
$_SESSION['alert_type'] = "danger";
|
||||
$_SESSION['alert_message'] = WORDING_ROLECHECK_FAILED;
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
exit();
|
||||
}
|
||||
|
||||
$department_id = intval($_GET['delete_department']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM departments WHERE department_id = $department_id AND company_id = $session_company_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Contact', log_action = 'Delete', log_description = '$department_id', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Department deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_asset'])){
|
||||
|
||||
if($session_user_role == 1){
|
||||
|
|
|
|||
Loading…
Reference in New Issue