mirror of https://github.com/itflow-org/itflow
Migrated Vendor Templates to its own table, lots of code modifications here
This commit is contained in:
parent
f672991089
commit
e7e7272002
|
|
@ -76,7 +76,7 @@ require_once "includes/inc_all_admin.php";
|
|||
<option value="">- Do not expense Stripe fees -</option>
|
||||
<?php
|
||||
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_select)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -1,20 +1,15 @@
|
|||
<?php
|
||||
|
||||
// Default Column Sortby Filter
|
||||
$sort = "software_name";
|
||||
$sort = "software_template_name";
|
||||
$order = "ASC";
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sort = http_build_query($get_copy);
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM software
|
||||
WHERE software_template = 1
|
||||
AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%')
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM software_templates
|
||||
WHERE software_template_name LIKE '%$q%' OR software_template_type LIKE '%$q%'
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
|
|
@ -53,18 +48,18 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<thead class="text-dark <?php if($num_rows[0] == 0){ echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_name&order=<?php echo $disp; ?>">
|
||||
Template <?php if ($sort == 'software_name') { echo $order_icon; } ?>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_template_name&order=<?php echo $disp; ?>">
|
||||
Template <?php if ($sort == 'software_template_name') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_type&order=<?php echo $disp; ?>">
|
||||
Type <?php if ($sort == 'software_type') { echo $order_icon; } ?>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_template_type&order=<?php echo $disp; ?>">
|
||||
Type <?php if ($sort == 'software_template_type') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_license_type&order=<?php echo $disp; ?>">
|
||||
License Type <?php if ($sort == 'software_license_type') { echo $order_icon; } ?>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=software_template_license_type&order=<?php echo $disp; ?>">
|
||||
License Type <?php if ($sort == 'software_template_license_type') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th class="text-center">Action</th>
|
||||
|
|
@ -74,41 +69,41 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<?php
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$software_id = intval($row['software_id']);
|
||||
$software_name = nullable_htmlentities($row['software_name']);
|
||||
$software_version = nullable_htmlentities($row['software_version']);
|
||||
$software_description = nullable_htmlentities($row['software_description']);
|
||||
$software_type = nullable_htmlentities($row['software_type']);
|
||||
$software_license_type = nullable_htmlentities($row['software_license_type']);
|
||||
$software_notes = nullable_htmlentities($row['software_notes']);
|
||||
$software_template_id = intval($row['software_template_id']);
|
||||
$software_template_name = nullable_htmlentities($row['software_template_name']);
|
||||
$software_template_version = nullable_htmlentities($row['software_template_version']);
|
||||
$software_template_description = nullable_htmlentities($row['software_template_description']);
|
||||
$software_template_type = nullable_htmlentities($row['software_template_type']);
|
||||
$software_template_license_type = nullable_htmlentities($row['software_template_license_type']);
|
||||
$software_template_notes = nullable_htmlentities($row['software_template_notes']);
|
||||
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a class="text-dark" href="#" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_software_template_edit.php" data-ajax-id="<?php echo $software_id; ?>">
|
||||
<a class="text-dark" href="#" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_software_template_edit.php" data-ajax-id="<?php echo $software_template_id; ?>">
|
||||
<div class="media">
|
||||
<i class="fa fa-fw fa-2x fa-cube mr-3"></i>
|
||||
<div class="media-body">
|
||||
<div><?php echo "$software_name <span>$software_version</span>"; ?></div>
|
||||
<div><small class="text-secondary"><?php echo $software_description; ?></small></div>
|
||||
<div><?php echo "$software_template_name <span>$software_template_version</span>"; ?></div>
|
||||
<div><small class="text-secondary"><?php echo $software_template_description; ?></small></div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</td>
|
||||
<td><?php echo $software_type; ?></td>
|
||||
<td><?php echo $software_license_type; ?></td>
|
||||
<td><?php echo $software_template_type; ?></td>
|
||||
<td><?php echo $software_template_license_type; ?></td>
|
||||
<td>
|
||||
<div class="dropdown dropleft text-center">
|
||||
<button class="btn btn-secondary btn-sm" data-toggle="dropdown">
|
||||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu">
|
||||
<a class="dropdown-item" href="#" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_software_template_edit.php" data-ajax-id="<?php echo $software_id; ?>">
|
||||
<a class="dropdown-item" href="#" data-toggle="ajax-modal" data-ajax-url="ajax/ajax_software_template_edit.php" data-ajax-id="<?php echo $software_template_id; ?>">
|
||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||
</a>
|
||||
<?php if($session_user_role == 3) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_software=<?php echo $software_id; ?>">
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_software_template=<?php echo $software_template_id; ?>">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -1,20 +1,15 @@
|
|||
<?php
|
||||
|
||||
// Default Column Sortby Filter
|
||||
$sort = "vendor_name";
|
||||
$sort = "vendor_template_name";
|
||||
$order = "ASC";
|
||||
|
||||
require_once "includes/inc_all_admin.php";
|
||||
|
||||
|
||||
//Rebuild URL
|
||||
$url_query_strings_sort = http_build_query($get_copy);
|
||||
|
||||
$sql = mysqli_query(
|
||||
$mysqli,
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM vendors
|
||||
WHERE vendor_template = 1
|
||||
AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$phone_query%') ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
"SELECT SQL_CALC_FOUND_ROWS * FROM vendor_templates
|
||||
WHERE vendor_template_name LIKE '%$q%' OR vendor_template_description LIKE '%$q%' OR vendor_template_account_number LIKE '%$q%' OR vendor_template_website LIKE '%$q%' OR vendor_template_contact_name LIKE '%$q%' OR vendor_template_email LIKE '%$q%' OR vendor_template_phone LIKE '%$phone_query%' ORDER BY $sort $order LIMIT $record_from, $record_to"
|
||||
);
|
||||
|
||||
$num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
||||
|
|
@ -53,13 +48,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<thead class="text-dark <?php if ($num_rows[0] == 0) { echo "d-none"; } ?>">
|
||||
<tr>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=vendor_name&order=<?php echo $disp; ?>">
|
||||
Vendor <?php if ($sort == 'vendor_name') { echo $order_icon; } ?>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=vendor_template_name&order=<?php echo $disp; ?>">
|
||||
Vendor <?php if ($sort == 'vendor_template_name') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=vendor_description&order=<?php echo $disp; ?>">
|
||||
Description <?php if ($sort == 'vendor_description') { echo $order_icon; } ?>
|
||||
<a class="text-secondary" href="?<?php echo $url_query_strings_sort; ?>&sort=vendor_template_description&order=<?php echo $disp; ?>">
|
||||
Description <?php if ($sort == 'vendor_template_description') { echo $order_icon; } ?>
|
||||
</a>
|
||||
</th>
|
||||
<th>Contact</th>
|
||||
|
|
@ -70,30 +65,29 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<?php
|
||||
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
$vendor_description = nullable_htmlentities($row['vendor_description']);
|
||||
if (empty($vendor_description)) {
|
||||
$vendor_description_display = "-";
|
||||
$vendor_template_id = intval($row['vendor_template_id']);
|
||||
$vendor_template_name = nullable_htmlentities($row['vendor_template_name']);
|
||||
$vendor_template_description = nullable_htmlentities($row['vendor_template_description']);
|
||||
if (empty($vendor_template_description)) {
|
||||
$vendor_template_description_display = "-";
|
||||
} else {
|
||||
$vendor_description_display = $vendor_description;
|
||||
$vendor_template_description_display = $vendor_template_description;
|
||||
}
|
||||
$vendor_account_number = nullable_htmlentities($row['vendor_account_number']);
|
||||
$vendor_contact_name = nullable_htmlentities($row['vendor_contact_name']);
|
||||
if (empty($vendor_contact_name)) {
|
||||
$vendor_contact_name_display = "-";
|
||||
$vendor_template_account_number = nullable_htmlentities($row['vendor_template_account_number']);
|
||||
$vendor_template_contact_name = nullable_htmlentities($row['vendor_template_contact_name']);
|
||||
if (empty($vendor_template_contact_name)) {
|
||||
$vendor_template_contact_name_display = "-";
|
||||
} else {
|
||||
$vendor_contact_name_display = $vendor_contact_name;
|
||||
$vendor_template_contact_name_display = $vendor_template_contact_name;
|
||||
}
|
||||
$vendor_phone = formatPhoneNumber($row['vendor_phone']);
|
||||
$vendor_extension = nullable_htmlentities($row['vendor_extension']);
|
||||
$vendor_email = nullable_htmlentities($row['vendor_email']);
|
||||
$vendor_website = nullable_htmlentities($row['vendor_website']);
|
||||
$vendor_hours = nullable_htmlentities($row['vendor_hours']);
|
||||
$vendor_sla = nullable_htmlentities($row['vendor_sla']);
|
||||
$vendor_code = nullable_htmlentities($row['vendor_code']);
|
||||
$vendor_notes = nullable_htmlentities($row['vendor_notes']);
|
||||
$vendor_template = intval($row['vendor_template']);
|
||||
$vendor_template_phone = formatPhoneNumber($row['vendor_template_phone']);
|
||||
$vendor_template_extension = nullable_htmlentities($row['vendor_template_extension']);
|
||||
$vendor_template_email = nullable_htmlentities($row['vendor_template_email']);
|
||||
$vendor_template_website = nullable_htmlentities($row['vendor_template_website']);
|
||||
$vendor_template_hours = nullable_htmlentities($row['vendor_template_hours']);
|
||||
$vendor_template_sla = nullable_htmlentities($row['vendor_template_sla']);
|
||||
$vendor_template_code = nullable_htmlentities($row['vendor_template_code']);
|
||||
$vendor_template_notes = nullable_htmlentities($row['vendor_template_notes']);
|
||||
|
||||
?>
|
||||
<tr>
|
||||
|
|
@ -101,38 +95,38 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<a class="text-dark" href="#"
|
||||
data-toggle="ajax-modal"
|
||||
data-ajax-url="ajax/ajax_vendor_template_edit.php"
|
||||
data-ajax-id="<?php echo $vendor_id; ?>"
|
||||
data-ajax-id="<?php echo $vendor_template_id; ?>"
|
||||
>
|
||||
<i class="fa fa-fw fa-building text-secondary mr-2"></i><?php echo $vendor_name; ?>
|
||||
<i class="fa fa-fw fa-building text-secondary mr-2"></i><?php echo $vendor_template_name; ?>
|
||||
</a>
|
||||
<?php
|
||||
if (!empty($vendor_account_number)) {
|
||||
if (!empty($vendor_template_account_number)) {
|
||||
?>
|
||||
<br>
|
||||
<small class="text-secondary"><?php echo $vendor_account_number; ?></small>
|
||||
<small class="text-secondary"><?php echo $vendor_template_account_number; ?></small>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</th>
|
||||
<td><?php echo $vendor_description_display; ?></td>
|
||||
<td><?php echo $vendor_template_description_display; ?></td>
|
||||
<td>
|
||||
<?php
|
||||
if (!empty($vendor_contact_name)) {
|
||||
if (!empty($vendor_template_contact_name)) {
|
||||
?>
|
||||
<i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i><?php echo $vendor_contact_name_display; ?>
|
||||
<i class="fa fa-fw fa-user text-secondary mr-2 mb-2"></i><?php echo $vendor_template_contact_name_display; ?>
|
||||
<br>
|
||||
<?php
|
||||
} else {
|
||||
echo $vendor_contact_name_display;
|
||||
echo $vendor_template_contact_name_display;
|
||||
}
|
||||
|
||||
if (!empty($vendor_phone)) { ?>
|
||||
<i class="fa fa-fw fa-phone text-secondary mr-2 mb-2"></i><?php echo $vendor_phone; ?>
|
||||
if (!empty($vendor_template_phone)) { ?>
|
||||
<i class="fa fa-fw fa-phone text-secondary mr-2 mb-2"></i><?php echo $vendor_template_phone; ?>
|
||||
<br>
|
||||
<?php }
|
||||
|
||||
if (!empty($vendor_email)) { ?>
|
||||
<i class="fa fa-fw fa-envelope text-secondary mr-2 mb-2"></i><?php echo $vendor_email; ?>
|
||||
if (!empty($vendor_template_email)) { ?>
|
||||
<i class="fa fa-fw fa-envelope text-secondary mr-2 mb-2"></i><?php echo $vendor_template_email; ?>
|
||||
<br>
|
||||
<?php } ?>
|
||||
|
||||
|
|
@ -146,13 +140,13 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<a class="dropdown-item" href="#"
|
||||
data-toggle="ajax-modal"
|
||||
data-ajax-url="ajax/ajax_vendor_template_edit.php"
|
||||
data-ajax-id="<?php echo $vendor_id; ?>"
|
||||
data-ajax-id="<?php echo $vendor_template_id; ?>"
|
||||
>
|
||||
<i class="fas fa-fw fa-edit mr-2"></i>Edit
|
||||
</a>
|
||||
<?php if ($session_user_role == 3) { ?>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_vendor=<?php echo $vendor_id; ?>">
|
||||
<a class="dropdown-item text-danger text-bold confirm-link" href="post.php?delete_vendor=<?php echo $vendor_template_id; ?>">
|
||||
<i class="fas fa-fw fa-trash mr-2"></i>Delete
|
||||
</a>
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -341,7 +341,7 @@ ob_start();
|
|||
<option value="">- Select Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id AND vendor_template = 0 ORDER BY vendor_name ASC");
|
||||
$sql_vendors = 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_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -105,7 +105,7 @@ ob_start();
|
|||
<select class="form-control select2" name="vendor" required>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ ob_start();
|
|||
<select class="form-control select2" name="vendor" required>
|
||||
<?php
|
||||
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND (vendor_archived_at > '$expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND (vendor_archived_at > '$expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_select)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ ob_start();
|
|||
<select class="form-control select2" name="vendor" required>
|
||||
<?php
|
||||
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND (vendor_archived_at > '$recurring_expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
||||
$sql_select = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND (vendor_archived_at > '$recurring_expense_created_at' OR vendor_archived_at IS NULL) ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_select)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -211,7 +211,7 @@ ob_start();
|
|||
<?php
|
||||
$selected_ids = array_column(mysqli_fetch_all($sql_vendors, MYSQLI_ASSOC), "vendor_id");
|
||||
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$service_created_at' OR vendor_archived_at IS NULL) AND vendor_template = 0 AND vendor_client_id = $client_id");
|
||||
$sql_all = mysqli_query($mysqli, "SELECT * FROM vendors WHERE (vendor_archived_at > '$service_created_at' OR vendor_archived_at IS NULL) AND vendor_client_id = $client_id");
|
||||
while ($row_all = mysqli_fetch_array($sql_all)) {
|
||||
$vendor_id = intval($row_all['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row_all['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -2,16 +2,16 @@
|
|||
|
||||
require_once '../includes/ajax_header.php';
|
||||
|
||||
$software_id = intval($_GET['id']);
|
||||
$software_template_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM software WHERE software_id = $software_id LIMIT 1");
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM software_templates WHERE software_template_id = $software_template_id LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$software_name = nullable_htmlentities($row['software_name']);
|
||||
$software_version = nullable_htmlentities($row['software_version']);
|
||||
$software_description = nullable_htmlentities($row['software_description']);
|
||||
$software_type = nullable_htmlentities($row['software_type']);
|
||||
$software_license_type = nullable_htmlentities($row['software_license_type']);
|
||||
$software_notes = nullable_htmlentities($row['software_notes']);
|
||||
$software_name = nullable_htmlentities($row['software_template_name']);
|
||||
$software_version = nullable_htmlentities($row['software_template_version']);
|
||||
$software_description = nullable_htmlentities($row['software_template_description']);
|
||||
$software_type = nullable_htmlentities($row['software_template_type']);
|
||||
$software_license_type = nullable_htmlentities($row['software_template_license_type']);
|
||||
$software_notes = nullable_htmlentities($row['software_template_notes']);
|
||||
|
||||
// Generate the HTML form content using output buffering.
|
||||
ob_start();
|
||||
|
|
@ -24,7 +24,7 @@ ob_start();
|
|||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="software_id" value="<?php echo $software_id; ?>">
|
||||
<input type="hidden" name="software_template_id" value="<?php echo $software_template_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="form-group">
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ ob_start();
|
|||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -104,10 +104,10 @@ ob_start();
|
|||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_template = 1 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendor_templates)) {
|
||||
$vendor_template_id_select = $row['vendor_id'];
|
||||
$vendor_template_name_select = nullable_htmlentities($row['vendor_name']); ?>
|
||||
$vendor_template_id_select = $row['vendor_template_id'];
|
||||
$vendor_template_name_select = nullable_htmlentities($row['vendor_template_name']); ?>
|
||||
<option <?php if ($vendor_template_id == $vendor_template_id_select) { echo "selected"; } ?> value="<?php echo $vendor_template_id_select; ?>"><?php echo $vendor_template_name_select; ?></option>
|
||||
|
||||
<?php } ?>
|
||||
|
|
|
|||
|
|
@ -2,23 +2,22 @@
|
|||
|
||||
require_once '../includes/ajax_header.php';
|
||||
|
||||
$vendor_id = intval($_GET['id']);
|
||||
$vendor_template_id = intval($_GET['id']);
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_id = $vendor_id LIMIT 1");
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendor_templates WHERE vendor_template_id = $vendor_template_id LIMIT 1");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
$vendor_description = nullable_htmlentities($row['vendor_description']);
|
||||
$vendor_account_number = nullable_htmlentities($row['vendor_account_number']);
|
||||
$vendor_contact_name = nullable_htmlentities($row['vendor_contact_name']);
|
||||
$vendor_phone = formatPhoneNumber($row['vendor_phone']);
|
||||
$vendor_extension = nullable_htmlentities($row['vendor_extension']);
|
||||
$vendor_email = nullable_htmlentities($row['vendor_email']);
|
||||
$vendor_website = nullable_htmlentities($row['vendor_website']);
|
||||
$vendor_hours = nullable_htmlentities($row['vendor_hours']);
|
||||
$vendor_sla = nullable_htmlentities($row['vendor_sla']);
|
||||
$vendor_code = nullable_htmlentities($row['vendor_code']);
|
||||
$vendor_notes = nullable_htmlentities($row['vendor_notes']);
|
||||
$vendor_template = intval($row['vendor_template']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_template_name']);
|
||||
$vendor_description = nullable_htmlentities($row['vendor_template_description']);
|
||||
$vendor_account_number = nullable_htmlentities($row['vendor_template_account_number']);
|
||||
$vendor_contact_name = nullable_htmlentities($row['vendor_template_contact_name']);
|
||||
$vendor_phone = formatPhoneNumber($row['vendor_template_phone']);
|
||||
$vendor_extension = nullable_htmlentities($row['vendor_template_extension']);
|
||||
$vendor_email = nullable_htmlentities($row['vendor_template_email']);
|
||||
$vendor_website = nullable_htmlentities($row['vendor_template_website']);
|
||||
$vendor_hours = nullable_htmlentities($row['vendor_template_hours']);
|
||||
$vendor_sla = nullable_htmlentities($row['vendor_template_sla']);
|
||||
$vendor_code = nullable_htmlentities($row['vendor_template_code']);
|
||||
$vendor_notes = nullable_htmlentities($row['vendor_template_notes']);
|
||||
|
||||
// Generate the HTML form content using output buffering.
|
||||
ob_start();
|
||||
|
|
@ -31,18 +30,18 @@ ob_start();
|
|||
</button>
|
||||
</div>
|
||||
<form action="post.php" method="post" autocomplete="off">
|
||||
<input type="hidden" name="vendor_id" value="<?php echo $vendor_id; ?>">
|
||||
<input type="hidden" name="vendor_template_id" value="<?php echo $vendor_template_id; ?>">
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<ul class="nav nav-pills nav-justified mb-3">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-details<?php echo $vendor_id; ?>">Details</a>
|
||||
<a class="nav-link active" data-toggle="pill" href="#pills-details<?php echo $vendor_template_id; ?>">Details</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-support<?php echo $vendor_id; ?>">Support</a>
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-support<?php echo $vendor_template_id; ?>">Support</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-notes<?php echo $vendor_id; ?>">Notes</a>
|
||||
<a class="nav-link" data-toggle="pill" href="#pills-notes<?php echo $vendor_template_id; ?>">Notes</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
|
@ -52,7 +51,7 @@ ob_start();
|
|||
|
||||
<div class="tab-content">
|
||||
|
||||
<div class="tab-pane fade show active" id="pills-details<?php echo $vendor_id; ?>">
|
||||
<div class="tab-pane fade show active" id="pills-details<?php echo $vendor_template_id; ?>">
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
|
|
@ -117,14 +116,14 @@ ob_start();
|
|||
|
||||
<div class="form-group">
|
||||
<div class="custom-control custom-checkbox">
|
||||
<input type="checkbox" class="custom-control-input" id="updateVendorsCheckbox<?php echo $vendor_id; ?>" name="update_base_vendors" value="1" >
|
||||
<label class="custom-control-label" for="updateVendorsCheckbox<?php echo $vendor_id; ?>">Update All Base Vendors</label>
|
||||
<input type="checkbox" class="custom-control-input" id="updateVendorsCheckbox<?php echo $vendor_template_id; ?>" name="update_base_vendors" value="1" >
|
||||
<label class="custom-control-label" for="updateVendorsCheckbox<?php echo $vendor_template_id; ?>">Update All Base Vendors</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-support<?php echo $vendor_id; ?>">
|
||||
<div class="tab-pane fade" id="pills-support<?php echo $vendor_template_id; ?>">
|
||||
|
||||
<label>Support Phone</label>
|
||||
<div class="form-row">
|
||||
|
|
@ -225,7 +224,7 @@ ob_start();
|
|||
|
||||
</div>
|
||||
|
||||
<div class="tab-pane fade" id="pills-notes<?php echo $vendor_id; ?>">
|
||||
<div class="tab-pane fade" id="pills-notes<?php echo $vendor_template_id; ?>">
|
||||
|
||||
<div class="form-group">
|
||||
<textarea class="form-control" rows="8" placeholder="Enter some notes" name="notes"><?php echo $vendor_notes; ?></textarea>
|
||||
|
|
|
|||
|
|
@ -13,15 +13,12 @@ $insert_id = false;
|
|||
if (!empty($name) && !(empty($content))) {
|
||||
|
||||
// Create document
|
||||
$insert_sql = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_template = 0, document_folder_id = $folder, document_created_by = 0, document_client_id = $client_id");
|
||||
$insert_sql = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_folder_id = $folder, document_created_by = 0, document_client_id = $client_id");
|
||||
|
||||
// Check insert & get insert ID
|
||||
if ($insert_sql) {
|
||||
$insert_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Update field document_parent to be the same id as document ID as this is the only version of the document.
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_parent = $insert_id WHERE document_id = $insert_id");
|
||||
|
||||
// Logging
|
||||
logAction("Document", "Create", "$name via API ($api_key_name)", $client_id, $insert_id);
|
||||
logAction("API", "Success", "Created document $name via API ($api_key_name)", $client_id);
|
||||
|
|
|
|||
|
|
@ -18,34 +18,12 @@ if (!empty($document_id)) {
|
|||
require_once 'document_model.php';
|
||||
|
||||
// Documents are a little weird as we update them by *inserting* a new document row
|
||||
$update_insert_sql = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_template = 0, document_folder_id = $folder, document_created_by = 0, document_client_id = $client_id");
|
||||
$update_insert_sql = mysqli_query($mysqli,"INSERT INTO documents SET document_name = '$name', document_description = '$description', document_content = '$content', document_content_raw = '$content_raw', document_folder_id = $folder, document_created_by = 0, document_client_id = $client_id");
|
||||
|
||||
// Check insert & get insert ID
|
||||
if ($update_insert_sql) {
|
||||
$insert_id = $new_document_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Update the parent ID of the new document to match its new document ID
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_parent = $new_document_id WHERE document_id = $new_document_id");
|
||||
|
||||
// Link all existing links with old document with new document
|
||||
mysqli_query($mysqli,"UPDATE documents SET document_parent = $new_document_id, document_archived_at = NOW() WHERE document_parent = $document_id");
|
||||
|
||||
// Update Links to the new parent document:-
|
||||
// Document files
|
||||
mysqli_query($mysqli,"UPDATE document_files SET document_id = $new_document_id WHERE document_id = $document_id");
|
||||
|
||||
// Contact documents
|
||||
mysqli_query($mysqli,"UPDATE contact_documents SET document_id = $new_document_id WHERE document_id = $document_id");
|
||||
|
||||
// Asset documents
|
||||
mysqli_query($mysqli,"UPDATE asset_documents SET document_id = $new_document_id WHERE document_id = $document_id");
|
||||
|
||||
// Software documents
|
||||
mysqli_query($mysqli,"UPDATE software_documents SET document_id = $new_document_id WHERE document_id = $document_id");
|
||||
|
||||
// Vendor documents
|
||||
mysqli_query($mysqli,"UPDATE vendor_documents SET document_id = $new_document_id WHERE document_id = $document_id");
|
||||
|
||||
// Logging
|
||||
logAction("Document", "Edit", "$name via API ($api_key_name) previous version kept", $client_id, $insert_id);
|
||||
logAction("API", "Success", "Edited document $name via API ($api_key_name)", $client_id);
|
||||
|
|
|
|||
|
|
@ -303,7 +303,7 @@ while ($row = mysqli_fetch_array($sql)) {
|
|||
}
|
||||
|
||||
//Vendors Added Created
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN vendors ON client_id = vendor_client_id $client_query AND vendor_template = 0 ");
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM clients LEFT JOIN vendors ON client_id = vendor_client_id $client_query");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$event_id = intval($row['vendor_id']);
|
||||
$client_id = intval($row['client_id']);
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ if ($user_config_dashboard_financial_enable == 1) {
|
|||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(client_id) AS clients_added FROM clients WHERE YEAR(client_created_at) = $year AND client_archived_at IS NULL"));
|
||||
$clients_added = intval($row['clients_added']);
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(vendor_id) AS vendors_added FROM vendors WHERE YEAR(vendor_created_at) = $year AND vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT(vendor_id) AS vendors_added FROM vendors WHERE YEAR(vendor_created_at) = $year AND vendor_client_id = 0 AND vendor_archived_at IS NULL"));
|
||||
$vendors_added = intval($row['vendors_added']);
|
||||
?>
|
||||
<div class="card card-body">
|
||||
|
|
|
|||
|
|
@ -3545,10 +3545,135 @@ if (LATEST_DATABASE_VERSION > CURRENT_DATABASE_VERSION) {
|
|||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.1.7'");
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '2.1.7') {
|
||||
// // Insert queries here required to update to DB version 2.1.8
|
||||
if (CURRENT_DATABASE_VERSION == '2.1.7') {
|
||||
mysqli_query($mysqli, "CREATE TABLE `software_templates` (
|
||||
`software_template_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`software_template_name` VARCHAR(200) NOT NULL,
|
||||
`software_template_description` TEXT DEFAULT NULL,
|
||||
`software_template_version` VARCHAR(200) DEFAULT NULL,
|
||||
`software_template_type` VARCHAR(200) NOT NULL,
|
||||
`software_template_license_type` VARCHAR(200) DEFAULT NULL,
|
||||
`software_template_notes` TEXT DEFAULT NULL,
|
||||
`software_template_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`software_template_updated_at` DATETIME NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
`software_template_archived_at` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`software_template_id`)
|
||||
)");
|
||||
|
||||
// Copy software Templates over to new software templates table
|
||||
mysqli_query($mysqli, "
|
||||
INSERT INTO software_templates (
|
||||
software_template_name,
|
||||
software_template_description,
|
||||
software_template_version,
|
||||
software_template_type,
|
||||
software_template_license_type,
|
||||
software_template_notes,
|
||||
software_template_created_at,
|
||||
software_template_updated_at,
|
||||
software_template_archived_at
|
||||
)
|
||||
SELECT
|
||||
software_name,
|
||||
software_description,
|
||||
software_version,
|
||||
software_type,
|
||||
software_license_type,
|
||||
software_notes,
|
||||
software_created_at,
|
||||
software_updated_at,
|
||||
software_archived_at
|
||||
FROM
|
||||
software
|
||||
WHERE
|
||||
software_template = 1
|
||||
");
|
||||
|
||||
mysqli_query($mysqli, "DELETE FROM software WHERE software_template = 1");
|
||||
|
||||
mysqli_query($mysqli, "ALTER TABLE `software` DROP `software_template`");
|
||||
|
||||
mysqli_query($mysqli, "ALTER TABLE `software` DROP `software_template_id`");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.1.8'");
|
||||
}
|
||||
|
||||
if (CURRENT_DATABASE_VERSION == '2.1.8') {
|
||||
mysqli_query($mysqli, "CREATE TABLE `vendor_templates` (
|
||||
`vendor_template_id` INT(11) NOT NULL AUTO_INCREMENT,
|
||||
`vendor_template_name` VARCHAR(200) NOT NULL,
|
||||
`vendor_template_description` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_contact_name` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_phone_country_code` VARCHAR(10) DEFAULT NULL,
|
||||
`vendor_template_phone` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_extension` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_email` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_website` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_hours` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_sla` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_code` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_account_number` VARCHAR(200) DEFAULT NULL,
|
||||
`vendor_template_notes` TEXT DEFAULT NULL,
|
||||
`vendor_template_created_at` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
|
||||
`vendor_template_updated_at` DATETIME NULL ON UPDATE CURRENT_TIMESTAMP,
|
||||
`vendor_template_archived_at` DATETIME NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`vendor_template_id`)
|
||||
)");
|
||||
|
||||
// Copy Vendor Templates over to new vendor templates table
|
||||
mysqli_query($mysqli, "
|
||||
INSERT INTO vendor_templates (
|
||||
vendor_template_name,
|
||||
vendor_template_description,
|
||||
vendor_template_contact_name,
|
||||
vendor_template_phone_country_code,
|
||||
vendor_template_phone,
|
||||
vendor_template_extension,
|
||||
vendor_template_email,
|
||||
vendor_template_website,
|
||||
vendor_template_hours,
|
||||
vendor_template_sla,
|
||||
vendor_template_code,
|
||||
vendor_template_account_number,
|
||||
vendor_template_notes,
|
||||
vendor_template_created_at,
|
||||
vendor_template_updated_at,
|
||||
vendor_template_archived_at
|
||||
)
|
||||
SELECT
|
||||
vendor_name,
|
||||
vendor_description,
|
||||
vendor_contact_name,
|
||||
vendor_phone_country_code,
|
||||
vendor_phone,
|
||||
vendor_extension,
|
||||
vendor_email,
|
||||
vendor_website,
|
||||
vendor_hours,
|
||||
vendor_sla,
|
||||
vendor_code,
|
||||
vendor_account_number,
|
||||
vendor_notes,
|
||||
vendor_created_at,
|
||||
vendor_updated_at,
|
||||
vendor_archived_at
|
||||
FROM
|
||||
vendors
|
||||
WHERE
|
||||
vendor_template = 1
|
||||
");
|
||||
|
||||
mysqli_query($mysqli, "DELETE FROM vendors WHERE vendor_template = 1");
|
||||
|
||||
mysqli_query($mysqli, "ALTER TABLE `vendors` DROP `vendor_template`");
|
||||
|
||||
mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.1.9'");
|
||||
}
|
||||
|
||||
// if (CURRENT_DATABASE_VERSION == '2.1.9') {
|
||||
// // Insert queries here required to update to DB version 2.2.0
|
||||
// // Then, update the database to the next sequential version
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.1.8'");
|
||||
// mysqli_query($mysqli, "UPDATE `settings` SET `config_current_database_version` = '2.2.0'");
|
||||
// }
|
||||
|
||||
} else {
|
||||
|
|
|
|||
56
db.sql
56
db.sql
|
|
@ -1941,14 +1941,12 @@ CREATE TABLE `software` (
|
|||
`software_purchase` date DEFAULT NULL,
|
||||
`software_expire` date DEFAULT NULL,
|
||||
`software_notes` text DEFAULT NULL,
|
||||
`software_template` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`software_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`software_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`software_archived_at` datetime DEFAULT NULL,
|
||||
`software_accessed_at` datetime DEFAULT NULL,
|
||||
`software_vendor_id` int(11) DEFAULT 0,
|
||||
`software_client_id` int(11) NOT NULL,
|
||||
`software_template_id` int(11) NOT NULL DEFAULT 0,
|
||||
PRIMARY KEY (`software_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
|
@ -2038,6 +2036,28 @@ CREATE TABLE `software_files` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `software_templates`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `software_templates`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `software_templates` (
|
||||
`software_template_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`software_template_name` varchar(200) NOT NULL,
|
||||
`software_template_description` text DEFAULT NULL,
|
||||
`software_template_version` varchar(200) DEFAULT NULL,
|
||||
`software_template_type` varchar(200) NOT NULL,
|
||||
`software_template_license_type` varchar(200) DEFAULT NULL,
|
||||
`software_template_notes` text DEFAULT NULL,
|
||||
`software_template_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`software_template_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`software_template_archived_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`software_template_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `tags`
|
||||
--
|
||||
|
|
@ -2500,6 +2520,35 @@ CREATE TABLE `vendor_files` (
|
|||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `vendor_templates`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `vendor_templates`;
|
||||
/*!40101 SET @saved_cs_client = @@character_set_client */;
|
||||
/*!40101 SET character_set_client = utf8mb4 */;
|
||||
CREATE TABLE `vendor_templates` (
|
||||
`vendor_template_id` int(11) NOT NULL AUTO_INCREMENT,
|
||||
`vendor_template_name` varchar(200) NOT NULL,
|
||||
`vendor_template_description` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_contact_name` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_phone_country_code` varchar(10) DEFAULT NULL,
|
||||
`vendor_template_phone` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_extension` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_email` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_website` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_hours` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_sla` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_code` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_account_number` varchar(200) DEFAULT NULL,
|
||||
`vendor_template_notes` text DEFAULT NULL,
|
||||
`vendor_template_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`vendor_template_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`vendor_template_archived_at` datetime DEFAULT NULL,
|
||||
PRIMARY KEY (`vendor_template_id`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
|
||||
/*!40101 SET character_set_client = @saved_cs_client */;
|
||||
|
||||
--
|
||||
-- Table structure for table `vendors`
|
||||
--
|
||||
|
|
@ -2522,7 +2571,6 @@ CREATE TABLE `vendors` (
|
|||
`vendor_code` varchar(200) DEFAULT NULL,
|
||||
`vendor_account_number` varchar(200) DEFAULT NULL,
|
||||
`vendor_notes` text DEFAULT NULL,
|
||||
`vendor_template` tinyint(1) NOT NULL DEFAULT 0,
|
||||
`vendor_created_at` datetime NOT NULL DEFAULT current_timestamp(),
|
||||
`vendor_updated_at` datetime DEFAULT NULL ON UPDATE current_timestamp(),
|
||||
`vendor_archived_at` datetime DEFAULT NULL,
|
||||
|
|
@ -2542,4 +2590,4 @@ CREATE TABLE `vendors` (
|
|||
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
|
||||
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
|
||||
|
||||
-- Dump completed on 2025-06-17 19:00:19
|
||||
-- Dump completed on 2025-06-17 22:44:10
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<option value="">- All Vendors -</option>
|
||||
|
||||
<?php
|
||||
$sql_vendors_filter = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 ORDER BY vendor_name ASC");
|
||||
$sql_vendors_filter = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_client_id = 0 ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors_filter)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
@ -348,7 +348,7 @@ $num_rows = mysqli_fetch_row(mysqli_query($mysqli, "SELECT FOUND_ROWS()"));
|
|||
<i class="fas fa-fw fa-copy mr-2"></i>Copy
|
||||
</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item"
|
||||
<a class="dropdown-item" href="#"
|
||||
data-toggle="ajax-modal"
|
||||
data-modal-size="lg"
|
||||
data-ajax-url="ajax/ajax_expense_refund.php"
|
||||
|
|
|
|||
|
|
@ -43,7 +43,6 @@ if (isset($_GET['query'])) {
|
|||
$sql_vendors = mysqli_query($mysqli, "SELECT * FROM vendors
|
||||
LEFT JOIN clients ON vendor_client_id = client_id
|
||||
WHERE vendor_archived_at IS NULL
|
||||
AND vendor_template = 0
|
||||
AND (vendor_name LIKE '%$query%' OR vendor_phone LIKE '%$phone_query%')
|
||||
$access_permission_query
|
||||
ORDER BY vendor_id DESC LIMIT 5"
|
||||
|
|
|
|||
|
|
@ -5,4 +5,4 @@
|
|||
* It is used in conjunction with database_updates.php
|
||||
*/
|
||||
|
||||
DEFINE("LATEST_DATABASE_VERSION", "2.1.7");
|
||||
DEFINE("LATEST_DATABASE_VERSION", "2.1.9");
|
||||
|
|
|
|||
|
|
@ -158,7 +158,7 @@ if (isset($_GET['client_id'])) {
|
|||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('service_id') AS num FROM services WHERE service_client_id = $client_id"));
|
||||
$num_services = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id AND vendor_template = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id"));
|
||||
$num_vendors = $row['num'];
|
||||
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('credential_id') AS num FROM credentials WHERE credential_archived_at IS NULL AND credential_client_id = $client_id"));
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@
|
|||
<option value="">- Select Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id AND vendor_template = 0 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 = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@
|
|||
<option value="">- All Vendors -</option>
|
||||
|
||||
<?php
|
||||
$sql_vendors_filter = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 ORDER BY vendor_name ASC");
|
||||
$sql_vendors_filter = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_client_id = 0 ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors_filter)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -125,7 +125,7 @@
|
|||
<option value="">- Vendor -</option>
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@
|
|||
<label for="vendors">Select related vendors</label>
|
||||
<select class="form-control select2" id="vendors" name="vendors[]" multiple>
|
||||
<?php
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_template = 0 AND vendor_archived_at IS NULL AND vendor_client_id = $client_id");
|
||||
$sql = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_archived_at IS NULL AND vendor_client_id = $client_id");
|
||||
while ($row = mysqli_fetch_array($sql)) {
|
||||
$vendor_id = intval($row['vendor_id']);
|
||||
$vendor_name = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -20,10 +20,10 @@
|
|||
<select class="form-control" name="software_template_id" required>
|
||||
<option value="">- Select Template -</option>
|
||||
<?php
|
||||
$sql_software_templates = mysqli_query($mysqli, "SELECT * FROM software WHERE software_template = 1 AND software_archived_at IS NULL ORDER BY software_name ASC");
|
||||
$sql_software_templates = mysqli_query($mysqli, "SELECT * FROM software_templates WHERE software_template_archived_at IS NULL ORDER BY software_template_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_software_templates)) {
|
||||
$software_template_id = intval($row['software_id']);
|
||||
$software_template_name = nullable_htmlentities($row['software_name']);
|
||||
$software_template_id = intval($row['software_template_id']);
|
||||
$software_template_name = nullable_htmlentities($row['software_template_name']);
|
||||
|
||||
?>
|
||||
<option value="<?php echo $software_template_id ?>"><?php echo $software_template_name; ?></option>
|
||||
|
|
|
|||
|
|
@ -393,7 +393,7 @@
|
|||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']); ?>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
<option value="0">- None -</option>
|
||||
<?php
|
||||
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_template = 0 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_vendors = mysqli_query($mysqli, "SELECT vendor_id, vendor_name FROM vendors WHERE vendor_client_id = $client_id AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendors)) {
|
||||
$vendor_id_select = intval($row['vendor_id']);
|
||||
$vendor_name_select = nullable_htmlentities($row['vendor_name']);
|
||||
|
|
|
|||
|
|
@ -22,10 +22,10 @@
|
|||
<select class="form-control" name="vendor_template_id" required>
|
||||
<option value="">- Select Template -</option>
|
||||
<?php
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendors WHERE vendor_template = 1 AND vendor_archived_at IS NULL ORDER BY vendor_name ASC");
|
||||
$sql_vendor_templates = mysqli_query($mysqli, "SELECT * FROM vendor_templates WHERE vendor_template_archived_at IS NULL ORDER BY vendor_template_name ASC");
|
||||
while ($row = mysqli_fetch_array($sql_vendor_templates)) {
|
||||
$vendor_template_id = intval($row['vendor_id']);
|
||||
$vendor_template_name = nullable_htmlentities($row['vendor_name']);
|
||||
$vendor_template_id = intval($row['vendor_template_id']);
|
||||
$vendor_template_name = nullable_htmlentities($row['vendor_template_name']);
|
||||
|
||||
?>
|
||||
<option value="<?php echo $vendor_template_id ?>"><?php echo $vendor_template_name; ?></option>
|
||||
|
|
|
|||
|
|
@ -4,10 +4,6 @@
|
|||
|
||||
defined('FROM_POST_HANDLER') || die("Direct file access is not allowed");
|
||||
|
||||
// Import shared code from software-side tickets as we reuse functions
|
||||
require_once 'post/user/software.php';
|
||||
|
||||
|
||||
if (isset($_POST['add_software_template'])) {
|
||||
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
|
|
@ -17,12 +13,12 @@ if (isset($_POST['add_software_template'])) {
|
|||
$license_type = sanitizeInput($_POST['license_type']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO software SET software_name = '$name', software_version = '$version', software_description = '$description', software_type = '$type', software_license_type = '$license_type', software_notes = '$notes', software_template = 1, software_client_id = 0");
|
||||
mysqli_query($mysqli,"INSERT INTO software_templates SET software_template_name = '$name', software_template_version = '$version', software_template_description = '$description', software_template_type = '$type', software_template_license_type = '$license_type', software_template_notes = '$notes'");
|
||||
|
||||
$software_id = mysqli_insert_id($mysqli);
|
||||
$software_template_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Logging
|
||||
logAction("Software Template", "Create", "$session_name created software template $name", 0, $software_id);
|
||||
logAction("Software Template", "Create", "$session_name created software template $name", 0, $software_template_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Software template <strong>$name</strong> created";
|
||||
|
||||
|
|
@ -32,7 +28,7 @@ if (isset($_POST['add_software_template'])) {
|
|||
|
||||
if (isset($_POST['edit_software_template'])) {
|
||||
|
||||
$software_id = intval($_POST['software_id']);
|
||||
$software_template_id = intval($_POST['software_template_id']);
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
$version = sanitizeInput($_POST['version']);
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
|
|
@ -40,13 +36,34 @@ if (isset($_POST['edit_software_template'])) {
|
|||
$license_type = sanitizeInput($_POST['license_type']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE software SET software_name = '$name', software_version = '$version', software_description = '$description', software_type = '$type', software_license_type = '$license_type', software_notes = '$notes' WHERE software_id = $software_id");
|
||||
mysqli_query($mysqli,"UPDATE software_templates SET software_template_name = '$name', software_template_version = '$version', software_template_description = '$description', software_template_type = '$type', software_template_license_type = '$license_type', software_template_notes = '$notes' WHERE software_template_id = $software_template_id");
|
||||
|
||||
// Logging
|
||||
logAction("Software Template", "Edit", "$session_name edited software template $name", 0, $software_id);
|
||||
logAction("Software Template", "Edit", "$session_name edited software template $name", 0, $software_template_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Software template <strong>$name</strong> edited";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_software_template'])) {
|
||||
|
||||
$software_template_id = intval($_GET['delete_software_template']);
|
||||
|
||||
// Get Software Template Name for logging and alert message
|
||||
$sql = mysqli_query($mysqli,"SELECT software_template_name FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$software_template_name = sanitizeInput($row['software_template_name']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
|
||||
//Logging
|
||||
logAction("Software Template", "Delete", "$session_name deleted software template $software_template_name");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Software Template <strong>$software_template_name</strong> deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -80,7 +80,7 @@ if (isset($_GET['update'])) {
|
|||
$payment_count = $row['num'];
|
||||
|
||||
// Company Vendor Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_client_id = 0"));
|
||||
$company_vendor_count = $row['num'];
|
||||
|
||||
// Expense Count
|
||||
|
|
@ -108,11 +108,11 @@ if (isset($_GET['update'])) {
|
|||
$asset_count = $row['num'];
|
||||
|
||||
// Software Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_id') AS num FROM software WHERE software_template = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_id') AS num FROM software"));
|
||||
$software_count = $row['num'];
|
||||
|
||||
// Software Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_id') AS num FROM software WHERE software_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('software_template_id') AS num FROM software_templates"));
|
||||
$software_template_count = $row['num'];
|
||||
|
||||
// Password Count
|
||||
|
|
@ -136,11 +136,11 @@ if (isset($_GET['update'])) {
|
|||
$service_count = $row['num'];
|
||||
|
||||
// Client Vendor Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id > 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_client_id > 0"));
|
||||
$client_vendor_count = $row['num'];
|
||||
|
||||
// Vendor Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('vendor_template_id') AS num FROM vendor_templates"));
|
||||
$vendor_template_count = $row['num'];
|
||||
|
||||
// File Count
|
||||
|
|
@ -148,11 +148,11 @@ if (isset($_GET['update'])) {
|
|||
$file_count = $row['num'];
|
||||
|
||||
// Document Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('document_id') AS num FROM documents WHERE document_template = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('document_id') AS num FROM documents"));
|
||||
$document_count = $row['num'];
|
||||
|
||||
// Document Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('document_id') AS num FROM documents WHERE document_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('document_template_id') AS num FROM document_templates"));
|
||||
$document_template_count = $row['num'];
|
||||
|
||||
// Shared Item Count
|
||||
|
|
|
|||
|
|
@ -9,14 +9,26 @@ require_once 'post/user/vendor.php';
|
|||
|
||||
if (isset($_POST['add_vendor_template'])) {
|
||||
|
||||
require_once 'post/user/vendor_model.php';
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
$account_number = sanitizeInput($_POST['account_number']);
|
||||
$contact_name = sanitizeInput($_POST['contact_name']);
|
||||
$phone_country_code = preg_replace("/[^0-9]/", '', $_POST['phone_country_code']);
|
||||
$phone = preg_replace("/[^0-9]/", '', $_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '', $_POST['extension']);
|
||||
$email = sanitizeInput($_POST['email']);
|
||||
$website = preg_replace("(^https?://)", "", sanitizeInput($_POST['website']));
|
||||
$hours = sanitizeInput($_POST['hours']);
|
||||
$sla = sanitizeInput($_POST['sla']);
|
||||
$code = sanitizeInput($_POST['code']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO vendors SET vendor_name = '$name', vendor_description = '$description', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_hours = '$hours', vendor_sla = '$sla', vendor_code = '$code', vendor_account_number = '$account_number', vendor_notes = '$notes', vendor_template = 1, vendor_client_id = 0");
|
||||
mysqli_query($mysqli,"INSERT INTO vendor_templates SET vendor_template_name = '$name', vendor_template_description = '$description', vendor_template_contact_name = '$contact_name', vendor_template_phone = '$phone', vendor_template_extension = '$extension', vendor_template_email = '$email', vendor_template_website = '$website', vendor_template_hours = '$hours', vendor_template_sla = '$sla', vendor_template_code = '$code', vendor_template_account_number = '$account_number', vendor_template_notes = '$notes'");
|
||||
|
||||
$vendor_id = mysqli_insert_id($mysqli);
|
||||
$vendor_template_id = mysqli_insert_id($mysqli);
|
||||
|
||||
// Logging
|
||||
logAction("Vendor Template", "Create", "$session_name created vendor template $name", 0, $vendor_id);
|
||||
logAction("Vendor Template", "Create", "$session_name created vendor template $name", 0, $vendor_template_id);
|
||||
|
||||
$_SESSION['alert_message'] = "Vendor template <strong>$name</strong> created";
|
||||
|
||||
|
|
@ -25,10 +37,20 @@ if (isset($_POST['add_vendor_template'])) {
|
|||
|
||||
if (isset($_POST['edit_vendor_template'])) {
|
||||
|
||||
require_once 'post/user/vendor_model.php';
|
||||
|
||||
$vendor_id = intval($_POST['vendor_id']);
|
||||
$vendor_template_id = intval($_POST['vendor_template_id']);
|
||||
$name = sanitizeInput($_POST['name']);
|
||||
$description = sanitizeInput($_POST['description']);
|
||||
$account_number = sanitizeInput($_POST['account_number']);
|
||||
$contact_name = sanitizeInput($_POST['contact_name']);
|
||||
$phone_country_code = preg_replace("/[^0-9]/", '', $_POST['phone_country_code']);
|
||||
$phone = preg_replace("/[^0-9]/", '', $_POST['phone']);
|
||||
$extension = preg_replace("/[^0-9]/", '', $_POST['extension']);
|
||||
$email = sanitizeInput($_POST['email']);
|
||||
$website = preg_replace("(^https?://)", "", sanitizeInput($_POST['website']));
|
||||
$hours = sanitizeInput($_POST['hours']);
|
||||
$sla = sanitizeInput($_POST['sla']);
|
||||
$code = sanitizeInput($_POST['code']);
|
||||
$notes = sanitizeInput($_POST['notes']);
|
||||
|
||||
if ($_POST['global_update_vendor_name'] == 1) {
|
||||
$sql_global_update_vendor_name = ", vendor_name = '$name'";
|
||||
|
|
@ -97,7 +119,7 @@ if (isset($_POST['edit_vendor_template'])) {
|
|||
}
|
||||
|
||||
// Update just the template
|
||||
mysqli_query($mysqli,"UPDATE vendors SET vendor_name = '$name', vendor_description = '$description', vendor_contact_name = '$contact_name', vendor_phone = '$phone', vendor_extension = '$extension', vendor_email = '$email', vendor_website = '$website', vendor_hours = '$hours', vendor_sla = '$sla', vendor_code = '$code', vendor_account_number = '$account_number', vendor_notes = '$notes' WHERE vendor_id = $vendor_id");
|
||||
mysqli_query($mysqli,"UPDATE vendor_templates SET vendor_template_name = '$name', vendor_template_description = '$description', vendor_template_contact_name = '$contact_name', vendor_template_phone = '$phone', vendor_template_extension = '$extension', vendor_template_email = '$email', vendor_template_website = '$website', vendor_template_hours = '$hours', vendor_template_sla = '$sla', vendor_template_code = '$code', vendor_template_account_number = '$account_number', vendor_template_notes = '$notes' WHERE vendor_template_id = $vendor_template_id");
|
||||
|
||||
if ($_POST['update_base_vendors'] == 1) {
|
||||
// Update client related vendors if anything is checked
|
||||
|
|
@ -106,7 +128,7 @@ if (isset($_POST['edit_vendor_template'])) {
|
|||
// Remove the first comma to prevent MySQL error
|
||||
$sql = preg_replace('/,/', '', $sql, 1);
|
||||
|
||||
mysqli_query($mysqli,"UPDATE vendors SET $sql WHERE vendor_template_id = $vendor_id");
|
||||
mysqli_query($mysqli,"UPDATE vendors SET $sql WHERE vendor_template_id = $vendor_template_id");
|
||||
}
|
||||
|
||||
// Logging
|
||||
|
|
@ -116,3 +138,25 @@ if (isset($_POST['edit_vendor_template'])) {
|
|||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (isset($_GET['delete_vendor_template'])) {
|
||||
$vendor_template_id = intval($_GET['delete_vendor_template']);
|
||||
|
||||
//Get Vendor Template Name
|
||||
$sql = mysqli_query($mysqli,"SELECT vendor_template_name FROM vendor_templates WHERE vendor_template_id = $vendor_template_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$vendor_template_name = sanitizeInput($row['vendor_template_name']);
|
||||
|
||||
// If its a template reset all vendors based off this template to no template base
|
||||
mysqli_query($mysqli,"UPDATE vendors SET vendor_template_id = 0 WHERE vendor_template_id = $vendor_template_id");
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM vendor_templates WHERE vendor_template_id = $vendor_template_id");
|
||||
|
||||
// Logging
|
||||
logAction("Vendor Template", "Delete", "$session_name deleted vendor template $vendor_template_name");
|
||||
|
||||
$_SESSION['alert_type'] = "error";
|
||||
$_SESSION['alert_message'] = "Vendor Template <strong>$vendor_template_name</strong> deleted";
|
||||
|
||||
header("Location: " . $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,15 +14,15 @@ if (isset($_POST['add_software_from_template'])) {
|
|||
$client_id = intval($_POST['client_id']);
|
||||
$software_template_id = intval($_POST['software_template_id']);
|
||||
|
||||
// GET Software Info
|
||||
$sql_software = mysqli_query($mysqli,"SELECT * FROM software WHERE software_id = $software_template_id");
|
||||
$row = mysqli_fetch_array($sql_software);
|
||||
$name = sanitizeInput($row['software_name']);
|
||||
$version = sanitizeInput($row['software_version']);
|
||||
$description = sanitizeInput($row['software_description']);
|
||||
$type = sanitizeInput($row['software_type']);
|
||||
$license_type = sanitizeInput($row['software_license_type']);
|
||||
$notes = sanitizeInput($row['software_notes']);
|
||||
// GET Software Template Info
|
||||
$sql_software_templates = mysqli_query($mysqli,"SELECT * FROM software_templates WHERE software_template_id = $software_template_id");
|
||||
$row = mysqli_fetch_array($sql_software_templates);
|
||||
$name = sanitizeInput($row['software_template_name']);
|
||||
$version = sanitizeInput($row['software_template_version']);
|
||||
$description = sanitizeInput($row['software_template_description']);
|
||||
$type = sanitizeInput($row['software_template_type']);
|
||||
$license_type = sanitizeInput($row['software_template_license_type']);
|
||||
$notes = sanitizeInput($row['software_template_notes']);
|
||||
$vendor = sanitizeInput($_POST['vendor'] ?? 0);
|
||||
|
||||
// Software add query
|
||||
|
|
|
|||
|
|
@ -143,9 +143,6 @@ if (isset($_GET['delete_vendor'])) {
|
|||
|
||||
mysqli_query($mysqli,"DELETE FROM vendors WHERE vendor_id = $vendor_id");
|
||||
|
||||
//Logging
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'Vendor', log_action = 'Delete', log_description = '$session_name deleted vendor $vendor_name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_client_id = $client_id, log_user_id = $session_user_id");
|
||||
|
||||
// Logging
|
||||
logAction("Vendor", "Delete", "$session_name deleted vendor $vendor_name", $client_id);
|
||||
|
||||
|
|
|
|||
|
|
@ -29,8 +29,6 @@ $sql_vendor_expenses = mysqli_query($mysqli, "
|
|||
vendors
|
||||
LEFT JOIN
|
||||
expenses ON vendors.vendor_id = expenses.expense_vendor_id $year_condition
|
||||
WHERE
|
||||
vendors.vendor_template = 0
|
||||
GROUP BY
|
||||
vendors.vendor_id
|
||||
HAVING
|
||||
|
|
|
|||
|
|
@ -997,7 +997,7 @@ if ($config_telemetry > 0 || $config_telemetry == 2) {
|
|||
$payment_count = $row['num'];
|
||||
|
||||
// Company Vendor Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_client_id = 0"));
|
||||
$company_vendor_count = $row['num'];
|
||||
|
||||
// Expense Count
|
||||
|
|
@ -1025,11 +1025,11 @@ if ($config_telemetry > 0 || $config_telemetry == 2) {
|
|||
$asset_count = $row['num'];
|
||||
|
||||
// Software Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('software_id') AS num FROM software WHERE software_template = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('software_id') AS num FROM software"));
|
||||
$software_count = $row['num'];
|
||||
|
||||
// Software Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('software_id') AS num FROM software WHERE software_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('software_template_id') AS num FROM software_templates"));
|
||||
$software_template_count = $row['num'];
|
||||
|
||||
// Credential Count
|
||||
|
|
@ -1053,11 +1053,11 @@ if ($config_telemetry > 0 || $config_telemetry == 2) {
|
|||
$service_count = $row['num'];
|
||||
|
||||
// Client Vendor Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 0 AND vendor_client_id > 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_client_id > 0"));
|
||||
$client_vendor_count = $row['num'];
|
||||
|
||||
// Vendor Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_id') AS num FROM vendors WHERE vendor_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('vendor_template_id') AS num FROM vendor_templates"));
|
||||
$vendor_template_count = $row['num'];
|
||||
|
||||
// File Count
|
||||
|
|
@ -1065,11 +1065,11 @@ if ($config_telemetry > 0 || $config_telemetry == 2) {
|
|||
$file_count = $row['num'];
|
||||
|
||||
// Document Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_id') AS num FROM documents WHERE document_template = 0"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_id') AS num FROM documents"));
|
||||
$document_count = $row['num'];
|
||||
|
||||
// Document Template Count
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_id') AS num FROM documents WHERE document_template = 1"));
|
||||
$row = mysqli_fetch_assoc(mysqli_query($mysqli, "SELECT COUNT('document_template_id') AS num FROM document_templates"));
|
||||
$document_template_count = $row['num'];
|
||||
|
||||
// Shared Item Count
|
||||
|
|
|
|||
|
|
@ -51,9 +51,8 @@ $sql = mysqli_query(
|
|||
"SELECT SQL_CALC_FOUND_ROWS * FROM software
|
||||
LEFT JOIN clients ON client_id = software_client_id
|
||||
LEFT JOIN vendors ON vendor_id = software_vendor_id
|
||||
WHERE software_template = 0
|
||||
WHERE (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
AND $archive_query
|
||||
AND (software_name LIKE '%$q%' OR software_type LIKE '%$q%' OR software_key LIKE '%$q%' OR client_name LIKE '%$q%')
|
||||
$access_permission_query
|
||||
$client_query
|
||||
ORDER BY $sort $order LIMIT $record_from, $record_to");
|
||||
|
|
|
|||
|
|
@ -20,7 +20,6 @@ $sql = mysqli_query(
|
|||
"SELECT SQL_CALC_FOUND_ROWS * FROM vendors
|
||||
LEFT JOIN clients ON client_id = vendor_client_id
|
||||
WHERE vendor_$archive_query
|
||||
AND vendor_template = 0
|
||||
AND (vendor_name LIKE '%$q%' OR vendor_description LIKE '%$q%' OR vendor_account_number LIKE '%$q%' OR vendor_website LIKE '%$q%' OR vendor_contact_name LIKE '%$q%' OR vendor_email LIKE '%$q%' OR vendor_phone LIKE '%$phone_query%')
|
||||
$client_query
|
||||
$access_permission_query
|
||||
|
|
|
|||
Loading…
Reference in New Issue