mirror of https://github.com/itflow-org/itflow
Started using new php function for Currency formatting as this is best preactice, removed Client Access and removed certian user roles
This commit is contained in:
parent
fcb55a9eed
commit
f2f9f22545
|
|
@ -13,4 +13,11 @@
|
|||
<hr>
|
||||
<p>This is a great starting point for new custom pages.</p>
|
||||
|
||||
<?php
|
||||
|
||||
$fmt = numfmt_create( 'us_EN', NumberFormatter::CURRENCY );
|
||||
echo numfmt_format_currency($fmt, -199.99, "USD")."\n";
|
||||
|
||||
?>
|
||||
|
||||
<?php include("footer.php"); ?>
|
||||
|
|
@ -40,16 +40,10 @@
|
|||
$session_token = $row['user_token'];
|
||||
$session_company_id = $row['user_default_company'];
|
||||
$session_user_role = $row['user_role'];
|
||||
if($session_user_role == 6){
|
||||
$session_user_role_display = "Global Administrator";
|
||||
}elseif($session_user_role == 5){
|
||||
if($session_user_role == 3){
|
||||
$session_user_role_display = "Administrator";
|
||||
}elseif($session_user_role == 4){
|
||||
$session_user_role_display = "Technician";
|
||||
}elseif($session_user_role == 3){
|
||||
$session_user_role_display = "IT Contractor";
|
||||
}elseif($session_user_role == 2){
|
||||
$session_user_role_display = "Client";
|
||||
$session_user_role_display = "Technician";
|
||||
}else{
|
||||
$session_user_role_display = "Accountant";
|
||||
}
|
||||
|
|
@ -69,14 +63,6 @@
|
|||
header('Location: login.php');
|
||||
}
|
||||
|
||||
//LOAD USER CLIENT ACCESS PERMISSIONS
|
||||
$session_user_client_access_sql = mysqli_query($mysqli,"SELECT client_id FROM user_clients WHERE user_id = $session_user_id");
|
||||
$session_user_client_access_array = array();
|
||||
while($row = mysqli_fetch_array($session_user_client_access_sql)){
|
||||
$session_user_client_access_array[] = $row['client_id'];
|
||||
}
|
||||
$session_user_client_access = implode(',',$session_user_client_access_array);
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM companies WHERE company_id = $session_company_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
|
||||
|
|
@ -101,4 +87,7 @@
|
|||
$row = mysqli_fetch_assoc(mysqli_query($mysqli,"SELECT COUNT('alert_id') AS num FROM alerts WHERE alert_ack_date IS NULL AND company_id = $session_company_id"));
|
||||
$num_alerts = $row['num'];
|
||||
|
||||
//Set Currency Format
|
||||
$currency_format = numfmt_create('en-US', NumberFormatter::CURRENCY);
|
||||
|
||||
?>
|
||||
|
|
@ -1,12 +1,5 @@
|
|||
<?php include("header.php");
|
||||
|
||||
// Role / Client Access Permission Check
|
||||
if($session_user_role == 2){
|
||||
$permission_sql = "AND client_id IN ($session_user_client_access)";
|
||||
}else{
|
||||
$permission_sql = "";
|
||||
}
|
||||
|
||||
//Paging
|
||||
if(isset($_GET['p'])){
|
||||
$p = intval($_GET['p']);
|
||||
|
|
@ -94,7 +87,7 @@ $sql = mysqli_query($mysqli,"SELECT SQL_CALC_FOUND_ROWS * FROM clients
|
|||
WHERE (client_name LIKE '%$query%' OR client_type LIKE '%$query%' OR contact_email LIKE '%$query%' OR contact_name LIKE '%$query%' OR contact_phone LIKE '%$query%'
|
||||
OR contact_mobile LIKE '%$query%' OR location_address LIKE '%$query%' OR location_city LIKE '%$query%' OR location_state LIKE '%$query%' OR location_zip LIKE '%$query%')
|
||||
AND DATE(client_created_at) BETWEEN '$date_from' AND '$date_to'
|
||||
AND clients.company_id = $session_company_id $permission_sql
|
||||
AND clients.company_id = $session_company_id
|
||||
ORDER BY $sortby $order LIMIT $record_from, $record_to
|
||||
");
|
||||
|
||||
|
|
|
|||
|
|
@ -122,10 +122,10 @@ $vendors_added = $row['vendors_added'];
|
|||
<!-- small box -->
|
||||
<a class="small-box bg-primary" href="payments.php?dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31">
|
||||
<div class="inner">
|
||||
<h3><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($total_income,2); ?></h3>
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_income, "$session_company_currency"); ?></h3>
|
||||
<p>Income</p>
|
||||
<hr>
|
||||
<small>Receivables: <?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($receivables,2); ?></small>
|
||||
<small>Receivables: <?php echo numfmt_format_currency($currency_format, $receivables, "$session_company_currency"); ?></h3></small>
|
||||
</div>
|
||||
<div class="icon">
|
||||
<i class="fa fa-money-check"></i>
|
||||
|
|
@ -138,7 +138,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<!-- small box -->
|
||||
<a class="small-box bg-danger" href="expenses.php?dtf=<?php echo $year; ?>-01-01&dtt=<?php echo $year; ?>-12-31">
|
||||
<div class="inner">
|
||||
<h3><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($total_expenses,2); ?></h3>
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $total_expenses, "$session_company_currency"); ?></h3>
|
||||
<p>Expenses</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
|
|
@ -152,7 +152,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<!-- small box -->
|
||||
<div class="small-box bg-success">
|
||||
<div class="inner">
|
||||
<h3><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($profit,2); ?></h3>
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $profit, "$session_company_currency"); ?></h3>
|
||||
<p>Profit</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
|
|
@ -166,7 +166,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<!-- small box -->
|
||||
<div class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($recurring_monthly_total,2); ?></h3>
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $recurring_monthly_total, "$session_company_currency"); ?></h3>
|
||||
<p>Monthly Recurring</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
|
|
@ -180,7 +180,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<!-- small box -->
|
||||
<div class="small-box bg-info">
|
||||
<div class="inner">
|
||||
<h3><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($recurring_yearly_total,2); ?></h3>
|
||||
<h3><?php echo numfmt_format_currency($currency_format, $recurring_yearly_total, "$session_company_currency"); ?></h3>
|
||||
<p>Yearly Recurring</p>
|
||||
</div>
|
||||
<div class="icon">
|
||||
|
|
@ -359,7 +359,7 @@ $vendors_added = $row['vendors_added'];
|
|||
$balance = '0.00';
|
||||
}
|
||||
?>
|
||||
<td class="text-right"><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($balance,2); ?></td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $balance, "$session_company_currency"); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
@ -403,7 +403,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<td><?php echo $payment_date; ?></td>
|
||||
<td><?php echo $client_name; ?></td>
|
||||
<td><?php echo "$invoice_prefix$invoice_number"; ?></td>
|
||||
<td class="text-right"><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($payment_amount,2); ?></td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $payment_amount, "$session_company_currency"); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
@ -446,7 +446,7 @@ $vendors_added = $row['vendors_added'];
|
|||
<td><?php echo $expense_date; ?></td>
|
||||
<td><?php echo $vendor_name; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td class="text-right"><?php echo get_currency_symbol($session_company_currency); ?> <?php echo number_format($expense_amount,2); ?></td>
|
||||
<td class="text-right"><?php echo numfmt_format_currency($currency_format, $expense_amount, "$session_company_currency"); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,6 +28,5 @@
|
|||
<!-- AdminLTE App -->
|
||||
<script src="dist/js/adminlte.min.js"></script>
|
||||
<script src="js/app.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -54,6 +54,10 @@ $config_stripe_enable = $row['config_stripe_enable'];
|
|||
$config_stripe_publishable = $row['config_stripe_publishable'];
|
||||
$config_stripe_secret = $row['config_stripe_secret'];
|
||||
|
||||
//Currency
|
||||
|
||||
$config_currency_format = "US_en";
|
||||
|
||||
$colors_array = array(
|
||||
'green',
|
||||
'olive',
|
||||
|
|
|
|||
25
post.php
25
post.php
|
|
@ -330,30 +330,6 @@ if(isset($_POST['edit_user_companies'])){
|
|||
|
||||
}
|
||||
|
||||
if(isset($_POST['edit_user_clients'])){
|
||||
|
||||
$user_id = intval($_POST['user_id']);
|
||||
|
||||
mysqli_query($mysqli,"DELETE FROM user_clients WHERE user_id = $user_id");
|
||||
|
||||
foreach($_POST['clients'] as $client){
|
||||
intval($client);
|
||||
mysqli_query($mysqli,"INSERT INTO user_clients SET user_id = $user_id, client_id = $client");
|
||||
}
|
||||
|
||||
//Logging
|
||||
//Get User Name
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM users WHERE user_id = $user_id");
|
||||
$row = mysqli_fetch_array($sql);
|
||||
$name = $row['user_name'];
|
||||
mysqli_query($mysqli,"INSERT INTO logs SET log_type = 'User', log_action = 'Modify', log_description = '$session_name updated client permissions for user $name', log_ip = '$session_ip', log_user_agent = '$session_user_agent', log_created_at = NOW(), log_user_id = $session_user_id, company_id = $session_company_id");
|
||||
|
||||
$_SESSION['alert_message'] = "Client <strong>$client_imploded</strong> added to user $user_id!";
|
||||
|
||||
header("Location: users.php");
|
||||
|
||||
}
|
||||
|
||||
if(isset($_GET['archive_user'])){
|
||||
$user_id = intval($_GET['archive_user']);
|
||||
|
||||
|
|
@ -383,7 +359,6 @@ if(isset($_GET['delete_user'])){
|
|||
mysqli_query($mysqli,"DELETE FROM tickets WHERE ticket_closed_by = $user_id");
|
||||
mysqli_query($mysqli,"DELETE FROM ticket_replies WHERE ticket_reply_by = $user_id");
|
||||
mysqli_query($mysqli,"DELETE FROM user_companies WHERE user_id = $user_id");
|
||||
mysqli_query($mysqli,"DELETE FROM user_clients WHERE user_id = $user_id");
|
||||
|
||||
//Logging
|
||||
//Get User Name
|
||||
|
|
|
|||
|
|
@ -75,11 +75,8 @@
|
|||
</div>
|
||||
<select class="form-control select2" name="role" required>
|
||||
<option value="">- Role -</option>
|
||||
<option value="6">Global Administrator</option>
|
||||
<option value="5">Administrator</option>
|
||||
<option value="4">Technician</option>
|
||||
<option value="3">IT Contractor</option>
|
||||
<option value="2">Client</option>
|
||||
<option value="3">Administrator</option>
|
||||
<option value="2">Technician</option>
|
||||
<option value="1">Accountant</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -1,52 +0,0 @@
|
|||
<div class="modal" id="editUserClientsModal<?php echo $user_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-users"></i> <?php echo $user_name; ?> Clients</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="user_id" value="<?php echo $user_id; ?>">
|
||||
|
||||
<div class="modal-body bg-white">
|
||||
|
||||
<div class="alert alert-info">
|
||||
Select Clients that the user will need access to
|
||||
</div>
|
||||
|
||||
<ul class="list-group">
|
||||
|
||||
<?php
|
||||
$sql_clients_select = mysqli_query($mysqli,"SELECT * FROM clients, companies WHERE clients.company_id = companies.company_id AND companies.company_id IN ($user_company_access) ORDER BY client_name ASC");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_clients_select)){
|
||||
$client_id_select = $row['client_id'];
|
||||
$client_name_select = $row['client_name'];
|
||||
$company_id_select = $row['company_id'];
|
||||
$company_name_select = $row['company_name'];
|
||||
|
||||
?>
|
||||
<li class="list-group-item">
|
||||
<div class="form-check">
|
||||
<input type="checkbox" class="form-check-input" name="clients[]" value="<?php echo $client_id_select; ?>" <?php if(in_array("$client_id_select",$user_client_access_array)){ echo "checked"; } ?> >
|
||||
<label class="form-check-label ml-2"><?php echo $client_name_select; ?></label>
|
||||
</div>
|
||||
</li>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="modal-footer bg-white">
|
||||
<button type="button" class="btn btn-secondary" data-dismiss="modal">Cancel</button>
|
||||
<button type="submit" name="edit_user_clients" class="btn btn-primary">Save</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -88,11 +88,8 @@
|
|||
</div>
|
||||
<select class="form-control select2" name="role" required>
|
||||
<option value="">- Role -</option>
|
||||
<option <?php if($user_role == 6){ echo "selected"; } ?> value="6">Global Admininstrator</option>
|
||||
<option <?php if($user_role == 5){ echo "selected"; } ?> value="5">Administrator</option>
|
||||
<option <?php if($user_role == 4){ echo "selected"; } ?> value="4">Technician</option>
|
||||
<option <?php if($user_role == 3){ echo "selected"; } ?> value="3">IT Contractor</option>
|
||||
<option <?php if($user_role == 2){ echo "selected"; } ?> value="2">Client</option>
|
||||
<option <?php if($user_role == 3){ echo "selected"; } ?> value="5">Administrator</option>
|
||||
<option <?php if($user_role == 2){ echo "selected"; } ?> value="4">Technician</option>
|
||||
<option <?php if($user_role == 1){ echo "selected"; } ?> value="1">Accountant</option>
|
||||
</select>
|
||||
</div>
|
||||
|
|
|
|||
12
users.php
12
users.php
|
|
@ -87,16 +87,10 @@
|
|||
$user_avatar = $row['user_avatar'];
|
||||
$user_default_company = $row['user_default_company'];
|
||||
$user_role = $row['user_role'];
|
||||
if($user_role == 6){
|
||||
$user_role_display = "Global Administrator";
|
||||
}elseif($user_role == 5){
|
||||
if($user_role == 3){
|
||||
$user_role_display = "Administrator";
|
||||
}elseif($user_role == 4){
|
||||
$user_role_display = "Technician";
|
||||
}elseif($user_role == 3){
|
||||
$user_role_display = "IT Contractor";
|
||||
}elseif($user_role == 2){
|
||||
$user_role_display = "Client";
|
||||
$user_role_display = "Technician";
|
||||
}else{
|
||||
$user_role_display = "Accountant";
|
||||
}
|
||||
|
|
@ -160,7 +154,6 @@
|
|||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editUserModal<?php echo $user_id; ?>">Edit</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editUserCompaniesModal<?php echo $user_id; ?>">Company Access</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editUserClientsModal<?php echo $user_id; ?>">Client Access</a>
|
||||
<div class="dropdown-divider"></div>
|
||||
<a class="dropdown-item text-danger" href="post.php?archive_user=<?php echo $user_id; ?>">Archive</a>
|
||||
</div>
|
||||
|
|
@ -172,7 +165,6 @@
|
|||
|
||||
include("user_edit_modal.php");
|
||||
include("user_companies_modal.php");
|
||||
include("user_clients_modal.php");
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue