mirror of https://github.com/itflow-org/itflow
DB Structure Update - Added Extension to contact on export PDF, finished contact departments
This commit is contained in:
parent
1ed20217d1
commit
a724807782
|
|
@ -93,6 +93,9 @@ 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'];
|
||||
|
|
|
|||
|
|
@ -53,6 +53,30 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Department</label>
|
||||
<div class="input-group">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Phone</label>
|
||||
<div class="form-row">
|
||||
|
|
|
|||
|
|
@ -56,6 +56,30 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Department</label>
|
||||
<div class="input-group">
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label>Phone</label>
|
||||
<div class="form-row">
|
||||
<div class="col-8">
|
||||
|
|
|
|||
|
|
@ -147,7 +147,8 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli,"SELECT FOUND_ROWS()"));
|
|||
$location_name_display = "-";
|
||||
}else{
|
||||
$location_name_display = $location_name;
|
||||
}
|
||||
}
|
||||
$department_id = $row['department_id'];
|
||||
|
||||
?>
|
||||
<tr>
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
<div class="modal" id="addDepartmentModal" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-building"></i> New Department</h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-globe"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="department_name" placeholder="Department name ex. Financial" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="add_department" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<div class="modal" id="editDepartmentModal<?php echo $department_id;?>" tabindex="-1">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content bg-dark">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title"><i class="fa fa-fw fa-building"></i> <?php echo $department_name; ?></h5>
|
||||
<button type="button" class="close text-white" data-dismiss="modal">
|
||||
<span>×</span>
|
||||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="department_id" value="<?php echo $department_id; ?>">
|
||||
<input type="hidden" name="client_id" value="<?php echo $client_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
<label>Name <strong class="text-danger">*</strong></label>
|
||||
<div class="input-group">
|
||||
<div class="input-group-prepend">
|
||||
<span class="input-group-text"><i class="fa fa-fw fa-building"></i></span>
|
||||
</div>
|
||||
<input type="text" class="form-control" name="department_name" placeholder="Department name ex. Financial" value="<?php echo $department_name; ?>" required autofocus>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_department" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -7,6 +7,9 @@ if(isset($_GET['tab'])){
|
|||
elseif($_GET['tab'] == "locations"){
|
||||
include("client_locations.php");
|
||||
}
|
||||
if($_GET['tab'] == "departments"){
|
||||
include("client_departments.php");
|
||||
}
|
||||
elseif($_GET['tab'] == "assets"){
|
||||
include("client_assets.php");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,19 @@
|
|||
</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">
|
||||
|
|
|
|||
3
db.sql
3
db.sql
|
|
@ -361,6 +361,7 @@ CREATE TABLE `departments` (
|
|||
`department_updated_at` datetime DEFAULT NULL,
|
||||
`department_archived_at` datetime DEFAULT NULL,
|
||||
`department_client_id` int(11) NOT NULL,
|
||||
`company_id` int(11) NOT NULL,
|
||||
PRIMARY KEY (`department_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
|
@ -1449,4 +1450,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2022-02-22 1:49:48
|
||||
-- Dump completed on 2022-02-22 13:13:37
|
||||
|
|
|
|||
84
post.php
84
post.php
|
|
@ -3958,6 +3958,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']);
|
||||
$phone = preg_replace("/[^0-9]/", '',$_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '',$_POST['extension']);
|
||||
$mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']);
|
||||
|
|
@ -3970,7 +3971,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_created_at = NOW(), 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_created_at = NOW(), contact_department_id = $department, contact_location_id = $location_id, contact_client_id = $client_id, company_id = $session_company_id");
|
||||
|
||||
$contact_id = mysqli_insert_id($mysqli);
|
||||
|
||||
|
|
@ -4036,6 +4037,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']);
|
||||
$phone = preg_replace("/[^0-9]/", '',$_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '',$_POST['extension']);
|
||||
$mobile = preg_replace("/[^0-9]/", '',$_POST['mobile']);
|
||||
|
|
@ -4050,7 +4052,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_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_department_id = $department, contact_location_id = $location_id, contact_updated_at = NOW() WHERE contact_id = $contact_id AND company_id = $session_company_id");
|
||||
|
||||
//Update Primay contact in clients if primary contact is checked
|
||||
if($primary_contact > 0){
|
||||
|
|
@ -4157,12 +4159,12 @@ if(isset($_GET['export_client_contacts_csv'])){
|
|||
$f = fopen('php://memory', 'w');
|
||||
|
||||
//set column headers
|
||||
$fields = array('Name', 'Title', 'Department', 'Email', 'Phone', 'Mobile', 'Notes');
|
||||
$fields = array('Name', 'Title', 'Department', 'Email', 'Phone', 'Ext', 'Mobile', 'Notes');
|
||||
fputcsv($f, $fields, $delimiter);
|
||||
|
||||
//output each row of the data, format line as csv and write to file pointer
|
||||
while($row = $sql->fetch_assoc()){
|
||||
$lineData = array($row['contact_name'], $row['contact_title'], $row['department_name'], $row['contact_email'], $row['contact_phone'], $row['contact_mobile'], $row['contact_notes']);
|
||||
$lineData = array($row['contact_name'], $row['contact_title'], $row['department_name'], $row['contact_email'], formatPhoneNumber($row['contact_phone']), $row['contact_extension'], formatPhoneNumber($row['contact_mobile']), $row['contact_notes']);
|
||||
fputcsv($f, $lineData, $delimiter);
|
||||
}
|
||||
|
||||
|
|
@ -4398,6 +4400,70 @@ if(isset($_GET['export_client_locations_csv'])){
|
|||
|
||||
}
|
||||
|
||||
// Client Departments
|
||||
if(isset($_POST['add_department'])){
|
||||
|
||||
$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_created_at = NOW(), 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_created_at = NOW(), 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'])){
|
||||
|
||||
$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_created_at = NOW(), 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'])){
|
||||
$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_created_at = NOW(), 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'])){
|
||||
$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_created_at = NOW(), company_id = $session_company_id, log_user_id = $session_user_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Department deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if(isset($_POST['add_asset'])){
|
||||
|
||||
$client_id = intval($_POST['client_id']);
|
||||
|
|
@ -6717,7 +6783,11 @@ if(isset($_GET['export_client_pdf'])){
|
|||
{
|
||||
text: 'Title',
|
||||
style: 'itemHeader'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Department',
|
||||
style: 'itemHeader'
|
||||
},
|
||||
{
|
||||
text: 'Email',
|
||||
style: 'itemHeader'
|
||||
|
|
@ -6725,7 +6795,7 @@ if(isset($_GET['export_client_pdf'])){
|
|||
{
|
||||
text: 'Phone',
|
||||
style: 'itemHeader'
|
||||
},
|
||||
},
|
||||
{
|
||||
text: 'Mobile',
|
||||
style: 'itemHeader'
|
||||
|
|
@ -6764,7 +6834,7 @@ if(isset($_GET['export_client_pdf'])){
|
|||
style: 'item'
|
||||
},
|
||||
{
|
||||
text: <?php echo json_encode($contact_phone); ?>,
|
||||
text: <?php echo json_encode("$contact_phone $contact_extension"); ?>,
|
||||
style: 'item'
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in New Issue