<?php if (empty($data['metas']['id'])):?>

	<script>

		jQuery(document).ready(function(){

			ulpReturnNotification();

		});

	</script>

<?php endif;?>





<form action="<?php echo admin_url('admin.php?page=ultimate_learning_pro&tab=notifications');?>" method="post">

<div class="ulp-wrapper">

		<div class="ulp-stuffbox">

				<h3 class="ulp-h3"><?php _e('Add/Edit Notification', 'ulp');?></h3>

				<div class="inside">

					<div class="ulp-form-line">

						<label class="ulp-labels-special"><?php _e('Action:', 'ulp');?></label>

						<select name="type" id="notf_type" onChange="ulpReturnNotification();">

							<optgroup label="<?php _e('Admin Notifications', 'ulp');?>">

								<?php foreach ($data['action_types']['admin'] as $k=>$v):?>

                		<option value="<?php echo $k;?>" <?php if ($k==$data['metas']['type']) echo 'selected';?> ><?php echo $v;?></option>

								<?php endforeach;?>

							</optgroup>

							<optgroup label="<?php _e('Student Notifications', 'ulp');?>">

								<?php foreach ($data['action_types']['student'] as $k=>$v):?>

                		<option value="<?php echo $k;?>" <?php if ($k==$data['metas']['type']) echo 'selected';?> ><?php echo $v;?></option>

								<?php endforeach;?>

							</optgroup>

							<optgroup label="<?php _e('Announcements Notifications', 'ulp');?>">
								<?php foreach ($data['action_types']['announcements'] as $k=>$v):?>
                		<option value="<?php echo $k;?>" <?php if ($k==$data['metas']['type']) echo 'selected';?> ><?php echo $v;?></option>
								<?php endforeach;?>
							</optgroup>
							<optgroup label="<?php _e('Q&A Notifications', 'ulp');?>">
								<?php foreach ($data['action_types']['qanda'] as $k=>$v):?>
										<option value="<?php echo $k;?>" <?php if ($k==$data['metas']['type']) echo 'selected';?> ><?php echo $v;?></option>
								<?php endforeach;?>
							</optgroup>
							<optgroup label="<?php _e('Other Notifications', 'ulp');?>">
								<?php foreach ($data['action_types']['others'] as $k=>$v):?>
										<option value="<?php echo $k;?>" <?php if ($k==$data['metas']['type']) echo 'selected';?> ><?php echo $v;?></option>
								<?php endforeach;?>
							</optgroup>
						</select>

					</div>

					<div class="ulp-form-line">

						<label class="ulp-labels-special"><?php _e('Course:', 'ulp')?></label>

						<select name="course_id">

                <option value="-1" ><?php _e('All courses', 'ulp');?></option>

                <?php if (!empty($data['courses'])):?>

                  <?php foreach ($data['courses'] as $array):?>

                    <option value="<?php echo $array['ID'];?>" <?php if ($array['ID']==$data['metas']['course_id']) echo 'selected';?> ><?php echo $array['post_title'];?></option>

                  <?php endforeach;?>

                <?php endif;?>

						</select>

						<div style="color: #999;font-size: 10px; font-style: italic;"><?php echo __('Available only for: ', 'ulp') . $data['all_courses_list_labels'];?></div>

					</div>

					<div class="ulp-form-line">

						<label class="ulp-labels-special"><?php _e('Subject:', 'ulp');?></label>

						<input type="text" value="<?php echo $data['metas']['subject'];?>" name="subject" id="notf_subject" style="width: 450px;"/>

					</div>

					<div class="ulp-form-line">

						<label  class="ulp-labels-special" style="vertical-align: top;"><?php _e('Message:', 'ulp');?></label>

						<div style="width: 70%;display:inline-block;">

							<?php wp_editor( $data['metas']['message'], 'notf_message', array('textarea_name'=>'message', 'quicktags'=>TRUE) );?>

						</div>

						<div style="width: 20%; display: inline-block; vertical-align: top;margin-left: 10px; color: #333;">

						<?php

							$constants = [

                        "{username}",

												"{user_email}",

												"{first_name}",

												"{last_name}",

												'{blogname}',

												'{blogurl}',

												"{account_page}",

												"{watch_list_page}",

												"{list_courses_page}",

												"{current_date}",

                        '{course_name}',

												"{course_price}",

												"{lesson_title}",

												"{quiz_title}",

												"{quiz_grade}",

												"{amount}",

												"{currency}",

												"{user_id}",

												"{course_id}",

												"{username}",

							];

							$extra_constants = array();

							foreach ($constants as $v){

								?>

								<div><?php echo $v;?></div>

								<?php

							}

              if ($extra_constants):

							echo "<h4>" . __('Custom Fields constants', 'ulp') . "</h4>";

							foreach ($extra_constants as $k=>$v){

								?>

								<div><?php echo $k;?></div>

								<?php

							}

            endif;

						?>

							<h4><?php _e('Announcements constants', 'ulp');?></h4>
							<?php
							$extra_constants = [
								'{course_name}',
								'{course_link}',
								'{announcement_content}',
								'{announcement_title}',
								'{announcement_link}',
								'{author_name}',
							];
							foreach ($constants as $v){
								?>
								<div><?php echo $v;?></div>
								<?php
							}
							?>
							<h4><?php _e('Q&A constants', 'ulp');?></h4>
							<?php
							$extra_constants = [
								'{course_name}',
								'{course_link}',
								'{student_name}',
								'{qanda_content}',
								'{qanda_title}',
								'{qanda_link}',
								'{comment_content}',
							];
							foreach ($constants as $v){
								?>
								<div><?php echo $v;?></div>
								<?php
							}
							?>
						</div>



						<div class="ulp-clear"></div>



					<div class="ulp-submit-form">

						<input type="submit" value="<?php _e('Save Changes', 'ulp');?>" name="save" class="btn btn-primary">

					</div>

				</div>

			</div>

		</div>



	<input type="hidden" name="status" value="1" />

	<input type="hidden" name="id" value="<?php echo $data['metas']['id'];?>" />



	<!-- PUSHOVER -->

	<?php if (get_option('ulp_pushover_enable')):?>

		<div class="ulp-stuffbox">

			<h3 class="ulp-h3"><?php _e('Pushover Notification', 'ulp');?></h3>

			<div class="inside">

				<div class="ulp-form-line">

					<label class="ulp-labels-special"><?php _e('Send Pushover Notification', 'ulp');?></label>

					<label class="ulp_label_shiwtch" style="margin:10px 0 10px -10px;">

						<?php $checked = (empty($data['metas']['pushover_status'])) ? '' : 'checked';?>

						<input type="checkbox" class="ulp-switch" onClick="UltimateLearningPro.checkAndH(this, '#pushover_status');" <?php echo $checked;?> />

						<div class="switch" style="display:inline-block;"></div>

					</label>

					<input type="hidden" name="pushover_status" value="<?php echo @$data['metas']['pushover_status'];?>" id="pushover_status" />

				</div>



				<div class="ulp-form-line" style="padding: 10px 0px 0px 5px; max-width:600px;">

					<label class="ulp-labels-special"><?php _e('Pushover Message:', 'ulp');?></label>

					<textarea name="pushover_message" style="width: 90%; height: 100px;" onBlur="ulpCheckFieldLimit(1024, this);"><?php echo stripslashes(@$data['metas']['pushover_message']);?></textarea>

					<div style="color: #777; font-weight:bold;font-size: 11px; font-style: italic;"><?php _e('Only Plain Text and up to ', 'ulp');?><span style="color:#000;">1024</span><?php _e(' characters are available!', 'ulp');?></div>

				</div>



				<div class="ulp-submit-form">

					<input type="submit" value="<?php _e('Save Changes', 'ulp');?>" name="save" class="btn btn-primary">

				</div>



			</div>

		</div>

	<?php else :?>

		<input type="hidden" name="pushover_message" value=""/>

		<input type="hidden" name="pushover_status" value=""/>

	<?php endif;?>

	<!-- PUSHOVER -->



	</form>

