Hallo Matthias, ich dachte der Rest wäre nicht relevant.
Delete-Container:
<div class="modal fade" id="delete-modal">
<div class="modal-dialog modal-sm">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id='delete-modal-title'></h4>
</div>
<div class="modal-body">
<p><strong>Are you sure?</strong></p>
<form id='delete_form_id'>
<input type='hidden' name='tID' id='tID_delete' value=''>
<input type='hidden' name='timestamp' id='timestamp-delete' value=''>
<input type='hidden' name='user_' id='user_delete' value='' />
<input type='hidden' name='appointment' id='appointment_delete' value='' />
</form>
<input type='hidden' id='delete-id' value='' />
<input type='hidden' id='delete-type' value='' />
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Abort</button>
<button type="button" class="btn btn-primary" id='delete-modal-save-btn'>Accept</button>
</div>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
cancelAppointment.php:
<?php
include_once('inc_user.php');
include_once('database.php');
include_once('../includes/php/functions.php');
//include_once('../includes/php/js_css_include.php');
$time = filter_input(INPUT_POST, 'timestamp');
$user = filter_input(INPUT_POST, 'user_');
$aID = filter_input(INPUT_POST, 'appointment');
echo $data='{ "appointment_ID" : '.$aID.'}';
if ($aID != "" && $aID != 0) {
cancelAppointmentByAdmin($aID);
}
Add-Container:
<?php
$arrUsers = getAdditionalUsers($clientID);
$availible= setArrayOfAvailibleAppointments($tID);
?>
<div class="modal fade" id="add-appointment-by-admin-modal">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
<h4 class="modal-title">New Appointment</h4>
</div>
<form class="form-horizontal" role="form" id='frm_addAppointment' name='frm_addAppointment'>
<div class="modal-body">
<div class="form-group">
<label for="frm_adminID" class="col-sm-2 control-label">Appointment</label>
<div class="col-sm-8 required">
<select name='frm_timestamp_add' id='frm_timestamp_add' class='form-control'>
<option value='' DISABLED SELECTED style='background-color:#E0E0E0'>Select an appointment time</option>
<?php foreach( $availible as $time ) { ?>
<option value="<?= $time;?>"><?= date("H:i", $time);?></option>
<?php } ?>
</select>
</div>
</div>
<div class="form-group">
<label for="frm_adminID" class="col-sm-2 control-label">User</label>
<div class="col-sm-8 required">
<select name='frm_user_add' id='frm_user_add' class='form-control'>
<option value='' DISABLED SELECTED style='background-color:#E0E0E0'>Select a User</option>
<?php foreach( $arrUsers as $user_ ) { ?>
<option value="<?= $user_;?>"><?= $user_;?></option>
<?php } ?>
</select>
</div>
</div>
<input type='hidden' name='tID' id='tID_add' value='<?=$tID;?>'>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button>
<button type="button" class="btn btn-primary" id="add-appointment-save-btn" >Save</button>
</div>
</form>
</div><!-- /.modal-content -->
</div><!-- /.modal-dialog -->
</div><!-- /.modal -->
addAppointment.php:
<?php
include_once('inc_user.php');
include_once('database.php');
include_once('../includes/php/functions.php');
$time = filter_input(INPUT_POST, 'frm_timestamp_add');
$user_ = filter_input(INPUT_POST, 'frm_user_add');
$tID = filter_input(INPUT_POST, 'tID');
$username= trim(strchr($user_,"(",true));
$userID= strstr($user_, '(');
$userID=str_replace('(', '', $userID);
$userID=str_replace(')', '', $userID);
$date=date("H:i", $time);
insertAppointmentByAdmin($userID, $time, $tID, 1);
$aID = getAppointmentID($userID, $time, $tID, 1);
$data= array('user_'=> $userID, 'username'=> $username, 'date'=> $date, 'timestamp'=> $time,'tID'=> $tID ,'appointment_ID'=> $aID);
echo json_encode($data);
$('#delete-modal').on('show.bs.modal', function(e) {
//get data-id attribute of the clicked element
var tID = $(e.relatedTarget).data('tid');
$("#tID_delete").val(tID);
var timestamp = $(e.relatedTarget).data('timestamp');
$("#timestamp-delete").val(timestamp);
var user_ = $(e.relatedTarget).data('user_');
$("#user_delete").val(user_);
var appointment = $(e.relatedTarget).data('appointment');
$("#appointment_delete").val(appointment);
console.log($(e.relatedTarget).data());
$('#add-appointment-by-admin-modal').on('show.bs.modal', function(e) {
//get data-id attribute of the clicked element
var tID = $(e.relatedTarget).data('tid');
$("#tID_add").val(tID);
console.log($(e.relatedTarget).data());
});
});