First Commit
This commit is contained in:
1 parent
5eb9dd037d
commit
2e62c0e60b
11877 files changed
+2035312
No files matched your search
@@ -0,0 +1,181 @@
|
||||
<?php
|
||||
require_once("include/globals.php");
|
||||
|
||||
if (SessionActive() != 1 || ! UserLoggedIn()) {
|
||||
header("Location: /");
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Start the template and output buffering
|
||||
startTemplate();
|
||||
$headerArgs = "";
|
||||
|
||||
|
||||
// Ensure that only valid user types have access to this module
|
||||
$AllowedUserTypes = array('SuperUser','System Administrator','Application Administrator');
|
||||
if (checkPermission($AllowedUserTypes) != 1) {
|
||||
$error_message = getLanguageText('ERRORMSG-ACCESS-DENIED');
|
||||
$action = '';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Process all actions to list and edit records
|
||||
//
|
||||
$naction = "";
|
||||
|
||||
if (array_key_exists('schedule_num',$_GET)) $schedule_num = intval($_GET['schedule_num']);
|
||||
if (array_key_exists('schedule_num',$_POST)) $schedule_num = intval($_POST['schedule_num']);
|
||||
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
if (!isset($menu_num)) $menu_num = 0;
|
||||
$headerArgs = "&schedule_num=$schedule_num&menu_num=$menu_num&naction=$naction";
|
||||
|
||||
|
||||
if (!isset($schedule_num)) {
|
||||
$error_message = getLanguageText('ERRORMSG-MISSING-DATA');
|
||||
$action = 'schedule-reports';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
// Check if this is a valid schedule
|
||||
$query = "select * from hotlunch_schedules " .
|
||||
"where school_num = $school_num " .
|
||||
"and record_num = $schedule_num";
|
||||
$results = db_query($query);
|
||||
|
||||
if (db_num_rows($results) == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-INVALID-SCHEDULE-NUM');
|
||||
$action = 'schedule-reports';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
|
||||
$hotlunch_schedule = db_fetch_array($results);
|
||||
$schedule_name = $hotlunch_schedule['schedule_name'];
|
||||
|
||||
|
||||
// If this is a ScheduleTeam user check if they have permission to access this schedule
|
||||
if (in_array($_SESSION['UserInfo']['type'],array('Schedule Team','Schedule Volunteer'))) {
|
||||
$userNum = intval($_SESSION['UserInfo']['record_num']);
|
||||
$access = db_getVal("SELECT count(*) FROM hotlunch_schedules_people WHERE school_num = $school_num AND schedule_num = $schedule_num AND user_num = $userNum");
|
||||
|
||||
if (!$access || $access == 0) {
|
||||
$error_message = getLanguageText('ERRORMSG-NO-SCHEDULE-ACCESS');
|
||||
$action = 'schedule-reports';
|
||||
$naction = '';
|
||||
header("Location: /?action=$action&naction=$naction$headerArgs&form_message=" . urlencode($form_message) . "&error_message=" . urlencode($error_message));
|
||||
exit();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
$templatePageTitle = getLanguageText('TEXT-ORDER-DELETION') . "<br>\n$schedule_name";
|
||||
|
||||
include "hotlunch_reports.menu.php";
|
||||
echo("<br>\n");
|
||||
|
||||
|
||||
if (array_key_exists('naction',$_GET)) $naction = $_GET['naction'];
|
||||
if (array_key_exists('naction',$_POST)) $naction = $_POST['naction'];
|
||||
|
||||
$school_num = $school_record['record_num'];
|
||||
|
||||
include "form.messages.php";
|
||||
|
||||
if (!isset($naction) || $naction != 'deletion-verified') {
|
||||
|
||||
$Orders = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND status != 'Deleted' AND ordered_by_type != 'Concession'");
|
||||
$num = db_num_rows($Orders);
|
||||
|
||||
if ($num > 0) {
|
||||
?>
|
||||
<script>
|
||||
$(document).ready(function() {
|
||||
$("#deleteorderform").submit(function(e) {
|
||||
|
||||
var msg = "<?php displayLanguageText('TEXT-CONFIRM-DELETE') ?>";
|
||||
msg = msg+'\n'+"<?php displayLanguageText('TEXT-ALL-ORDERS') ?>"+" - <?php echo($schedule_name) ?>";
|
||||
msg = msg+'\n\n'+"<?php displayLanguageText('WARNING-DELETE-ALL-ORDERS-FOR-SCHEDULE') ?>"
|
||||
var answer = confirm(msg);
|
||||
if (answer) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
});
|
||||
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<p><br></p>
|
||||
<p><b><?php displayLanguageText('TEXT-DELETE-ALL-ORDERS'); ?></b></p>
|
||||
<p style='color:red'><b><?php displayLanguageText('WARNING-DELETE-ALL-ORDERS-FOR-SCHEDULE'); ?></b></p>
|
||||
<form method='post' id='deleteorderform' action="/">
|
||||
<input type='hidden' name='action' value='schedule-order-deletion'>
|
||||
<input type='hidden' name='naction' value='deletion-verified'>
|
||||
<input type='hidden' name='schedule_num' value='<?php echo($schedule_num) ?>'>
|
||||
<input type='submit' name='button' class='btn btn--primary' value="<?php displayLanguageText('TEXT-DELETE-ORDERS'); ?>">
|
||||
</form>
|
||||
<br>
|
||||
<p><br></p>
|
||||
<p><br></p>
|
||||
<?php
|
||||
}
|
||||
else {
|
||||
?>
|
||||
<p><br></p>
|
||||
<p><b><?php displayLanguageText('ERRORMSG-NO-ORDERS-FOUND'); ?></b></p>
|
||||
<?php
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
$user_num = $_SESSION['UserInfo']['record_num'];
|
||||
$user_id = $_SESSION['UserInfo']['userid'];
|
||||
$time = date("Y-m-d H:i:s",time());
|
||||
|
||||
$Orders = db_query("SELECT * FROM hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num AND status != 'Deleted' AND ordered_by_type != 'Concession'");
|
||||
$num = db_num_rows($Orders);
|
||||
|
||||
$entered_time = time();
|
||||
$trx_time = date("Y-m-d H:i:s",$entered_time);
|
||||
|
||||
while ($row = db_fetch_assoc($Orders)) {
|
||||
$order_num = $row['record_num'];
|
||||
$ordered_by_num = $row['ordered_by_num'];
|
||||
$user_num = db_getVal("SELECT user_num FROM people WHERE school_num = $base_school_num AND record_num = $ordered_by_num");
|
||||
$logmsg = getLanguageText('TEXT-SCHEDULE-ORDER-DELETION').": $order_num ($user_id)";
|
||||
$query = "INSERT INTO user_account " .
|
||||
"(school_num,user_num,schedule_num,transaction_datetime,transaction_type,note,transaction_amount,transaction_fee,payment_method,payment_reference,order_payments,deleted,entered_time,transaction_status) " .
|
||||
"VALUES ($school_num,$user_num,$schedule_num,'$trx_time','TRX Note','$logmsg',0,0,NULL,'',NULL,'N',$entered_time,'Closed')";
|
||||
db_query($query);
|
||||
|
||||
logOrderChange($order_num, "SCHEDULE ORDERS DELETED", "hotlunch.schedule_order_deletion.php");
|
||||
}
|
||||
|
||||
$user_num = $_SESSION['UserInfo']['record_num'];
|
||||
echo("<p><br></p>\n");
|
||||
echo("<p><b>".getLanguageText('TEXT-ORDERS-DELETED').": $num</b></p>\n");
|
||||
|
||||
db_query("DELETE from hotlunch_order_items WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
||||
db_query("DELETE from hotlunch_order_header WHERE school_num = $school_num AND schedule_num = $schedule_num");
|
||||
db_query("DELETE from user_account WHERE school_num = $school_num AND schedule_num = $schedule_num AND transaction_type = 'Order'");
|
||||
|
||||
}
|
||||
|
||||
include "hotlunch_orders.print_buttons.php";
|
||||
|
||||
endTemplate();
|
||||
?>
|
||||
Reference in new issue
Block a user