<div class="ulp-stuffbox">
<h3 class="ulp-h3"><?php _e('Courses Tags', 'ulp');?></h3>
  <div class="inside">
  <div class="ulp-inside-item">
    <div class="row">
  <div class="wrap">
      <a href="<?php echo admin_url('admin.php?page=ultimate_learning_pro&tab=courses_tags_add_edit');?>" class="page-title-action ulp-add-new-post-bttn"><?php _e('Add new Tag', 'ulp');?></a>
  </div>
  <div>
  <p><?php _e('Once Tags are created and avaialable you can assign them to your courses from "Courses Tags" box when you editing a course.', 'ulp');?></p>
  </div>
  <?php if ($data ['items']!==FALSE && count($data ['items'])>0):?>
      <div class="ulp-wrapper">
        <table class="wp-list-table widefat fixed tags ulp-admin-tables striped ">
          <thead  class="thead-inverse">
            <tr>
              <th class="manage-column"><?php _e('Slug', 'ulp');?></th>
              <th class="manage-column"><?php _e('Label', 'ulp');?></th>
              <th class="manage-column" style="width:80px; text-align: center;"><?php _e('Edit', 'ulp');?></th>
              <th class="manage-column" style="width:80px; text-align: center;"><?php _e('Delete', 'ulp');?></th>
            </tr>
          </thead>
          <tbody>
            <?php	foreach ($data['items'] as $object):?>
                <tr id="<?php echo 'ulp_div_' . $object->slug;?>">
                  <td><div style="color: #21759b; font-weight:bold;font-family: 'Oswald', arial, sans-serif !important;font-size: 14px;font-weight: 400;"><?php echo $object->slug;?></div></td>
                  <td>
                  <div class="ulp-course-tag-admin" style="background-color: <?php echo $object->color;?>;"><?php echo $object->name;?></div>
                  </td>
                  <td style="text-align: center;"><a href="<?php echo admin_url('admin.php?page=ultimate_learning_pro&tab=courses_tags_add_edit&term_id=' .$object->term_id );?>"><i class="fa-ulp fa-edit-ulp"></i></a></td>
                  <td style="text-align: center;"><i class="fa-ulp fa-remove-ulp ulp-delete-course-tag" data-term_id="<?php echo $object->term_id;?>" style="cursor: pointer;"></i></td>
                </tr>
            <?php endforeach;	?>
          </tbody>
        </table>
      </div>
  <?php endif;?>
  </div>
 </div>
</div>  
</div>
<script>
jQuery('.ulp-delete-course-tag').on('click', function(evt){
  swal({
    title: "",
    text: UltimateLearningPro.ulp_admin_general_messages.are_you_sure,
    type: "warning",
    showCancelButton: true,
    confirmButtonClass: "btn-danger",
    confirmButtonText: UltimateLearningPro.ulp_admin_general_messages.delete_it,
    closeOnConfirm: true
  },
  function(){
      var term_id = jQuery(evt.currentTarget).attr('data-term_id');
      jQuery.ajax({
    			type : "post",
    			url : decodeURI(window.ulp_url) + '/wp-admin/admin-ajax.php',
    			data : {
    							action: "ulp_delete_tag",
    							termId: term_id
    					},
    			success: function (r) {
    					location.reload(); /// refresh
    			}
    	});
  });
});
</script>
