mirror of https://github.com/itflow-org/itflow
Updates to recurring invoice, updated the cron.php to loop through arrays
This commit is contained in:
parent
1f02a1d287
commit
3dd1905176
168
cron.php
168
cron.php
|
|
@ -7,147 +7,59 @@
|
|||
|
||||
//DOMAINS EXPIRING
|
||||
|
||||
//Get Domains Expiring within 1 days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains, clients
|
||||
WHERE domains.client_id = clients.client_id
|
||||
AND domain_expire = CURDATE() + INTERVAL 1 DAY
|
||||
ORDER BY domain_id DESC"
|
||||
);
|
||||
$domainAlertArray = [1, 14, 30, 90];
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$domain_id = $row['domain_id'];
|
||||
$domain_name = $row['domain_name'];
|
||||
$domain_expire = $row['domain_expire'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
foreach ($domainAlertArray as $day) {
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Domain', alert_message = 'Domain $domain_name will expire tomorrow on $domain_expire', alert_date = CURDATE()");
|
||||
//Get Domains Expiring within 1 days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains, clients
|
||||
WHERE domains.client_id = clients.client_id
|
||||
AND domain_expire = CURDATE() + INTERVAL $day DAY
|
||||
ORDER BY domain_id DESC"
|
||||
);
|
||||
|
||||
}
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$domain_id = $row['domain_id'];
|
||||
$domain_name = $row['domain_name'];
|
||||
$domain_expire = $row['domain_expire'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
//Get Domains Expiring within 14 days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains, clients
|
||||
WHERE domains.client_id = clients.client_id
|
||||
AND domain_expire = CURDATE() + INTERVAL 1 DAY
|
||||
ORDER BY domain_id DESC"
|
||||
);
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Domain', alert_message = 'Domain $domain_name will expire $day Days on $domain_expire', alert_date = CURDATE()");
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$domain_id = $row['domain_id'];
|
||||
$domain_name = $row['domain_name'];
|
||||
$domain_expire = $row['domain_expire'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Domain', alert_message = 'Domain $domain_name will expire in 14 Days on $domain_expire', alert_date = CURDATE()");
|
||||
|
||||
}
|
||||
|
||||
//Get Domains Expiring within 30 days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains, clients
|
||||
WHERE domains.client_id = clients.client_id
|
||||
AND domain_expire = CURDATE() + INTERVAL 1 DAY
|
||||
ORDER BY domain_id DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$domain_id = $row['domain_id'];
|
||||
$domain_name = $row['domain_name'];
|
||||
$domain_expire = $row['domain_expire'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Domain', alert_message = 'Domain $domain_name will expire in 30 Days on $domain_expire', alert_date = CURDATE()");
|
||||
|
||||
}
|
||||
|
||||
//Get Domains Expiring within 90 days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM domains, clients
|
||||
WHERE domains.client_id = clients.client_id
|
||||
AND domain_expire = CURDATE() + INTERVAL 1 DAY
|
||||
ORDER BY domain_id DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$domain_id = $row['domain_id'];
|
||||
$domain_name = $row['domain_name'];
|
||||
$domain_expire = $row['domain_expire'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Domain', alert_message = 'Domain $domain_name will expire in 90 Days on $domain_expire', alert_date = CURDATE()");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//PAST DUE INVOICES
|
||||
|
||||
//14 Days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_number > 0
|
||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||
AND invoices.invoice_due = CURDATE() + INTERVAL 14 DAY
|
||||
ORDER BY invoices.invoice_number DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_status = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$invoiceAlertArray = [1, 14, 30, 90];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Invoice', alert_message = 'Invoice INV-$invoice_number for $client_name in the amount of $invoice_amount is overdue by 14 days', alert_date = CURDATE()");
|
||||
}
|
||||
foreach ($invoiceAlertArray as $day) {
|
||||
|
||||
//30 Days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_number > 0
|
||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||
AND invoices.invoice_due = CURDATE() + INTERVAL 30 DAY
|
||||
ORDER BY invoices.invoice_number DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_status = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_number > 0
|
||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||
AND invoices.invoice_status NOT LIKE 'Cancelled'
|
||||
AND invoices.invoice_due = CURDATE() + INTERVAL $day DAY
|
||||
ORDER BY invoices.invoice_number DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_status = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Invoice', alert_message = 'Invoice INV-$invoice_number for $client_name in the amount of $invoice_amount is overdue by 30 days', alert_date = CURDATE()");
|
||||
}
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Invoice', alert_message = 'Invoice INV-$invoice_number for $client_name in the amount of $invoice_amount is overdue by $day days', alert_date = CURDATE()");
|
||||
}
|
||||
|
||||
//90 Days
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM invoices, clients
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_number > 0
|
||||
AND invoices.invoice_status NOT LIKE 'Draft'
|
||||
AND invoices.invoice_status NOT LIKE 'Paid'
|
||||
AND invoices.invoice_due = CURDATE() + INTERVAL 90 DAY
|
||||
ORDER BY invoices.invoice_number DESC"
|
||||
);
|
||||
|
||||
while($row = mysqli_fetch_array($sql)){
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_number = $row['invoice_number'];
|
||||
$invoice_status = $row['invoice_status'];
|
||||
$invoice_date = $row['invoice_date'];
|
||||
$invoice_due = $row['invoice_due'];
|
||||
$invoice_amount = $row['invoice_amount'];
|
||||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
|
||||
mysqli_query($mysqli,"INSERT INTO alerts SET alert_type = 'Invoice', alert_message = 'Invoice INV-$invoice_number for $client_name in the amount of $invoice_amount is overdue by 90 days', alert_date = CURDATE()");
|
||||
}
|
||||
|
||||
//LOW BALANCE ALERTS
|
||||
|
|
@ -179,7 +91,7 @@ while($row = mysqli_fetch_array($sql)){
|
|||
|
||||
$sql_recurring = mysqli_query($mysqli,"SELECT * FROM recurring, clients, invoices WHERE clients.client_id = invoices.client_id AND invoices.invoice_id = recurring.invoice_id AND recurring.recurring_next_date = CURDATE() AND recurring.recurring_status = 1");
|
||||
|
||||
while($row = mysqli_fetch_array($sql_recurring_invoices)){
|
||||
while($row = mysqli_fetch_array($sql_recurring)){
|
||||
$recurring_id = $row['recurring_id'];
|
||||
$recurring_frequency = $row['recurring_frequency'];
|
||||
$recurring_status = $row['recurring_status'];
|
||||
|
|
|
|||
|
|
@ -2,9 +2,10 @@
|
|||
|
||||
<?php
|
||||
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring, invoices, clients
|
||||
$sql = mysqli_query($mysqli,"SELECT * FROM recurring, invoices, clients, categories
|
||||
WHERE invoices.client_id = clients.client_id
|
||||
AND invoices.invoice_id = recurring.invoice_id
|
||||
AND invoices.category_id = categories.category_id
|
||||
ORDER BY recurring.recurring_id DESC");
|
||||
?>
|
||||
|
||||
|
|
@ -23,6 +24,7 @@
|
|||
<th>Start Date</th>
|
||||
<th>Last Sent</th>
|
||||
<th>Next Date</th>
|
||||
<th>Category</th>
|
||||
<th>Status</th>
|
||||
<th class="text-center">Actions</th>
|
||||
</tr>
|
||||
|
|
@ -43,6 +45,8 @@
|
|||
$client_id = $row['client_id'];
|
||||
$client_name = $row['client_name'];
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$category_id = $row['category_id'];
|
||||
$category_name = $row['category_name'];
|
||||
if($recurring_status == 1){
|
||||
$status = "Active";
|
||||
$status_badge_color = "success";
|
||||
|
|
@ -60,6 +64,7 @@
|
|||
<td><?php echo $recurring_start_date; ?></td>
|
||||
<td><?php echo $recurring_last_sent; ?></td>
|
||||
<td><?php echo $recurring_next_date; ?></td>
|
||||
<td><?php echo $category_name; ?></td>
|
||||
<td>
|
||||
<span class="p-2 badge badge-<?php echo $status_badge_color; ?>">
|
||||
<?php echo $status; ?>
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ if(isset($_GET['recurring_id'])){
|
|||
$recurring_status = $row['recurring_status'];
|
||||
$recurring_start_date = $row['recurring_start_date'];
|
||||
$recurring_last_sent = $row['recurring_last_sent'];
|
||||
if($recurring_last_sent == 0){
|
||||
$recurring_last_sent = '-';
|
||||
}
|
||||
$recurring_next_date = $row['recurring_next_date'];
|
||||
$invoice_id = $row['invoice_id'];
|
||||
$invoice_status = $row['invoice_status'];
|
||||
|
|
@ -74,8 +77,7 @@ if(isset($_GET['recurring_id'])){
|
|||
<i class="fas fa-ellipsis-h"></i>
|
||||
</button>
|
||||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceModal">Edit</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editInvoiceNoteModal">Note</a>
|
||||
<a class="dropdown-item" href="#" data-toggle="modal" data-target="#editRecurringModal<?php echo $recurring_id; ?>">Edit</a>
|
||||
<?php if($recurring_status == 1){ ?>
|
||||
<a class="dropdown-item" href="post.php?recurring_deactivate=<?php echo $recurring_id; ?>">Deactivate</a>
|
||||
<?php }else{ ?>
|
||||
|
|
@ -216,17 +218,22 @@ if(isset($_GET['recurring_id'])){
|
|||
</div>
|
||||
|
||||
<div class="row mb-4">
|
||||
<div class="col-5">
|
||||
<div class="col-7">
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
Notes
|
||||
</div>
|
||||
<div class="card-body mb-5">
|
||||
<p><?php echo $invoice_note; ?></p>
|
||||
<div class="card-body">
|
||||
<div class="d-none d-print-block"><?php echo $invoice_note; ?></div>
|
||||
<form class="d-print-none" action="post.php" method="post">
|
||||
<input type="hidden" name="invoice_id" value="<?php echo $invoice_id; ?>">
|
||||
<textarea rows="6" class="form-control mb-2" name="invoice_note"><?php echo $invoice_note; ?></textarea>
|
||||
<button class="btn btn-primary btn-sm float-right" type="submit" name="edit_invoice_note"><i class="fa fa-fw fa-check"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-3 offset-4">
|
||||
<div class="col-3 offset-2">
|
||||
<table class="table table-borderless">
|
||||
<tbody>
|
||||
<tr class="border-bottom">
|
||||
|
|
@ -285,7 +292,6 @@ if(isset($_GET['recurring_id'])){
|
|||
?>
|
||||
<tr>
|
||||
<td><?php echo $invoice_history_date; ?></td>
|
||||
<td><?php echo $invoice_history_status; ?></td>
|
||||
<td><?php echo $invoice_history_description; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
|
|
@ -300,7 +306,7 @@ if(isset($_GET['recurring_id'])){
|
|||
</div>
|
||||
|
||||
<?php include("edit_invoice_modal.php"); ?>
|
||||
<?php include("edit_invoice_note_modal.php"); ?>
|
||||
|
||||
<?php } ?>
|
||||
|
||||
<?php include("footer.php");
|
||||
Loading…
Reference in New Issue