

<div class="card-header d-flex justify-content-between">
    <div class="card-heading">
        <h4 class="card-title">Reminders</h4>
    </div>                 
</div>
<div class="card-body">

    <form name="reminderaddform">

        <input type="hidden" name="patient_id" value="<?= $patient_id ?>" >
        <div class="form-row">
            <div class="form-group col-md-12">                                        
                <textarea name="reminder_text" class="form-control" id="remindr_text"   placeholder="Reminder Text"></textarea>
            </div>
        </div>


        <div class="form-row">
            <div class="form-group col-md-6">
                <label for="inputEmail4">Start Date</label>
                <input type="text" class="form-control date-picker-default" value="" name="start_date">
            </div>
            <div class="form-group col-md-6">
                <label for="inputEmail4">End Date</label>
                <input type="text" class="form-control date-picker-default" value="" name="end_date">
            </div>
        </div>

        <div class="form-row">
            <div class="form-group col-md-12">
                <label for="sel1">Select Reminder:</label>
                <select class="form-control" id="sel1"  name="reminder_type">
                    <option value='0'>Email</option>
                    <option value='1' selected>Email + Notification</option>
                    <option value='2'>Email</option>
                    <option value='3'>SMS Notification</option>
                </select>
            </div>
        </div>


        <div class="form-row">
            <div class="form-group col-md-6">
                <div id="link_result"></div>
            </div>
            <div class="form-group col-md-6">
                <button type="submit" id="rem_link_submit" class="btn btn-primary btn-block btn-sm" onclick="return addPatientReminder()">Set Reminder</button>
            </div>
        </div>


    </form>

    <hr size="1">

    <ul class="activity">
        <?
        // print_r($patient_reminder_list[0]);
        foreach ($patient_reminder_list as $prm) {
            ?>

            <li class="activity-item info">
                <div class="activity-info">
                    <h5 class="mb-0"><?= $prm->description ?></h5>
                    <span><?= $prm->start_date ?> to <?= $prm->end_date ?></span>
                </div>
            </li>
            <?
        }
        ?>


    </ul>
</div>

<script type="text/javascript">
<!--

    function addPatientReminder() {
        var reminder_text = document.reminderaddform.reminder_text.value;
        var start_date = document.reminderaddform.start_date.value;
        var end_date = document.reminderaddform.end_date.value;
        var reminder_type = document.reminderaddform.reminder_type.value;
        var patient_id = document.reminderaddform.patient_id.value;
        // alert(patient_link_id);

        if (reminder_text === '' || start_date === '' || end_date === '' || reminder_type === '') {
            alert('All felids are required to add a reminder!');
            return false;
        }

        // alert(job_description);
        $('#link_result').html('Processing...');
        $('#rem_link_submit').prop('disabled', true);
        $.ajax({
            url: "/patient/addPatientReminder?reminder_text=" + reminder_text + "&patient_id=" + patient_id +"&reminder_text=" + reminder_text +"&start_date=" + start_date +"&end_date=" + end_date + "&reminder_type="+reminder_type
        }).done(function (data) {
            $('#link_result').html(data);
            document.linkform.reminder_text.value = '';
            $('#rem_link_submit').prop('disabled', false);
        });
        return false;
    }

    // -->    
</script>

