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

	<div class="ulp-stuffbox">



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

		<div class="inside">

		<div class="ulp-inside-item">

              <div class="row">

               <div class="col-xs-6">



				<h2><?php _e('Badge Info', 'ulp');?></h2>

				 <div class="input-group" style="  max-width: 400px;">

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

                    <span class="input-group-addon" id="basic-addon1"><?php _e('Title', 'ulp');?></span>

                   <input type="text" class="form-control" name="badge_title" value="<?php echo $data ['item']['badge_title'];?>" />

				</div>

				<h4 style="margin-top:25px;"><?php _e('Badge Photo', 'ulp');?></h4>

            	<div class="input-group" style="  max-width: 400px;">

            		 <span class="input-group-addon" id="basic-addon1"><?php _e('Upload', 'ulp');?></span>

                     <input type="text" class="form-control" name="badge_image" value="<?php echo $data ['item']['badge_image'];?>" onClick="openMediaUp(this, '#ulp_preview_badge');"/>

				</div>



				<div class="" style="margin:15px 0;">

						<img src="<?php echo $data ['item']['badge_image'];?>" id="ulp_preview_badge" style="display: none" class="uap-admin-badge-image"/>

				</div>

            </div>

          </div>

      </div>

      <div class="ulp-line-break"></div>

      <div class="ulp-inside-item">

          <div class="row">

              <div class="col-xs-4">

            	<h2><?php _e('Achievements', 'ulp');?></h2>

                <p><?php _e('Decides when the badge will be assigned to your students', 'ulp');?></p>



                <h4 style="margin-top:25px;"><?php _e('Rule Type', 'ulp');?></h4>

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

						<select name="badge_type" onchange="ulp_change_rules();" class="form-control m-bot15">

								<?php foreach (['tier' => __('Tier', 'ulp'), 'static' => __('Static', 'ulp')] as $k => $v):?>

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

								<?php endforeach;?>

						</select>

				</div>

				<div class="" id="rule_types_static">

					<h4 style="margin-top:25px;"><?php _e('Request', 'ulp');?></h4>

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

                    <select name="rule_types_static" class="form-control m-bot15">

							<?php foreach (['finish_course' => __('Finish Course', 'ulp'), 'finish_quiz' => __('Finish Quiz', 'ulp')] as $k => $v):?>

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

							<?php endforeach;?>

					</select>

                    </div>

				</div>

				<div class="" id="rule_types_tier">

					<h4 style="margin-top:25px;"><?php _e('Request', 'ulp');?></h4>

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

					<select name="rule_types_tier" class="form-control m-bot15">

							<?php foreach (['reward_points' => __('Reward points', 'ulp')] as $k => $v):?>

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

							<?php endforeach;?>

					</select>

                    </div>

				</div>



				<div class="input-group" style="  max-width: 400px;">

					<span class="input-group-addon" id="basic-addon1"><?php _e('Rule Value', 'ulp');?></span>

					<input type="text" class="form-control" name="rule_value" value="<?php echo $data['item']['rule_value'];?>" />

				</div>



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

						<i id="badge_rules_examples">

						</i>

				</div>

            </div>

          </div>

      </div>

      <div class="ulp-line-break"></div>

      <div class="ulp-inside-item">

          <div class="row">

              <div class="col-xs-4">

              <h2><?php _e('Additional Details', 'ulp');?></h2>

            	<h4 style="margin-top:25px;"><?php _e('Description:', 'ulp');?></h4>

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

            		<textarea name="badge_content" rows="5" style="width:100%;"><?php echo $data ['item']['badge_content'];?></textarea>

				</div>

            </div>

          </div>

      </div>

      <div class="ulp-inside-item">

          <div class="row">

              <div class="col-xs-6">

      <div class="form-group row">

          <div class="col-4">

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

          </div>

      </div>

			</div>

		 </div>

       </div>

	</div>

 </div>

</form>



<script>

		function ulp_change_rules(){

				var t = jQuery('[name=badge_type]').val();

				if (t=='static'){

						jQuery('#rule_types_tier').css('display', 'none');

						jQuery('#rule_types_static').css('display', 'block');

				} else {

						jQuery('#rule_types_tier').css('display', 'block');

						jQuery('#rule_types_static').css('display', 'none');

				}

		}

		jQuery(document).ready(ulp_change_rules());

</script>

