mirror of
https://github.com/itflow-org/itflow
synced 2026-03-06 13:54:51 +00:00
Merge pull request #357 from johnnyq/scheduled-tickets
Scheduled tickets - frequency
This commit is contained in:
18
cron.php
18
cron.php
@@ -121,6 +121,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
|||||||
$new_config_ticket_next_number = $config_ticket_next_number + 1;
|
$new_config_ticket_next_number = $config_ticket_next_number + 1;
|
||||||
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = '$company_id'");
|
mysqli_query($mysqli,"UPDATE settings SET config_ticket_next_number = $new_config_ticket_next_number WHERE company_id = '$company_id'");
|
||||||
|
|
||||||
|
// Raise the ticket
|
||||||
mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 'Open', ticket_created_at = NOW(), ticket_created_by = $created_id, ticket_contact_id = $contact_id, ticket_client_id = $client_id, ticket_asset_id = $asset_id, company_id = $company_id");
|
mysqli_query($mysqli,"INSERT INTO tickets SET ticket_prefix = '$config_ticket_prefix', ticket_number = $ticket_number, ticket_subject = '$subject', ticket_details = '$details', ticket_priority = '$priority', ticket_status = 'Open', ticket_created_at = NOW(), ticket_created_by = $created_id, ticket_contact_id = $contact_id, ticket_client_id = $client_id, ticket_asset_id = $asset_id, company_id = $company_id");
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
@@ -128,10 +129,7 @@ while($row = mysqli_fetch_array($sql_companies)){
|
|||||||
|
|
||||||
// Set the next run date
|
// Set the next run date
|
||||||
if($frequency == "weekly"){
|
if($frequency == "weekly"){
|
||||||
//NOTE: We seemingly have to initialize a new datetime for each loop.
|
// Note: We seemingly have to initialize a new datetime for each loop to avoid stacking the dates
|
||||||
//Otherwise it stacks the dates of $now / $tomorrow, e.g. by the third scheduled ticket it will schedule the next run for three weeks/months out instead of one
|
|
||||||
//This isn't clean but it works
|
|
||||||
//TODO: Refactor this
|
|
||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
$next_run = date_add($now, date_interval_create_from_date_string('1 week 1 day'));
|
$next_run = date_add($now, date_interval_create_from_date_string('1 week 1 day'));
|
||||||
}
|
}
|
||||||
@@ -139,6 +137,18 @@ while($row = mysqli_fetch_array($sql_companies)){
|
|||||||
$now = new DateTime();
|
$now = new DateTime();
|
||||||
$next_run = date_add($now, date_interval_create_from_date_string('1 month 1 day'));
|
$next_run = date_add($now, date_interval_create_from_date_string('1 month 1 day'));
|
||||||
}
|
}
|
||||||
|
elseif($frequency == "quarterly"){
|
||||||
|
$now = new DateTime();
|
||||||
|
$next_run = date_add($now, date_interval_create_from_date_string('3 months 1 day'));
|
||||||
|
}
|
||||||
|
elseif($frequency == "biannually"){
|
||||||
|
$now = new DateTime();
|
||||||
|
$next_run = date_add($now, date_interval_create_from_date_string('6 months 1 day'));
|
||||||
|
}
|
||||||
|
elseif($frequency == "annually"){
|
||||||
|
$now = new DateTime();
|
||||||
|
$next_run = date_add($now, date_interval_create_from_date_string('12 months 1 day'));
|
||||||
|
}
|
||||||
|
|
||||||
// Update the run date
|
// Update the run date
|
||||||
$next_run = $next_run->format('Y-m-d');
|
$next_run = $next_run->format('Y-m-d');
|
||||||
|
|||||||
@@ -69,6 +69,9 @@
|
|||||||
<select class="form-control select2" name="frequency" required>
|
<select class="form-control select2" name="frequency" required>
|
||||||
<option>Weekly</option>
|
<option>Weekly</option>
|
||||||
<option>Monthly</option>
|
<option>Monthly</option>
|
||||||
|
<option>Quarterly</option>
|
||||||
|
<option>Biannually</option>
|
||||||
|
<option>Annually</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -21,6 +21,9 @@
|
|||||||
<select class="form-control select2" name="frequency" required>
|
<select class="form-control select2" name="frequency" required>
|
||||||
<option <?php if($scheduled_ticket_frequency == "Weekly") {echo "selected";} ?>>Weekly</option>
|
<option <?php if($scheduled_ticket_frequency == "Weekly") {echo "selected";} ?>>Weekly</option>
|
||||||
<option <?php if($scheduled_ticket_frequency == "Monthly") {echo "selected";} ?>>Monthly</option>
|
<option <?php if($scheduled_ticket_frequency == "Monthly") {echo "selected";} ?>>Monthly</option>
|
||||||
|
<option <?php if($scheduled_ticket_frequency == "Quarterly") {echo "selected";} ?>>Quarterly</option>
|
||||||
|
<option <?php if($scheduled_ticket_frequency == "Biannually") {echo "selected";} ?>>Biannually</option>
|
||||||
|
<option <?php if($scheduled_ticket_frequency == "Annually") {echo "selected";} ?>>Annually</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user