<?php wp_enqueue_script('UlpAdminSendEmail', ULP_URL . 'assets/js/UlpAdminSendEmail.js', [], null);?>
<div class="ulp-wrapper">

<div class="ulp-page-title">Ultimate Learning Pro - <span class="second-text"><?php _e('Instructors', 'ulp');?></span></div>

    <div style="margin-bottom: 10px;">

        <form method="post" action="<?php echo admin_url('user-new.php');?>">

            <input type="hidden" name="role" value="ulp_instructor" />

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

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

            <div class="col-md-3">

                <button type="submit" class="ulp-add-new-bttn" ><?php _e('Add new User Instructor', 'ulp');?></button>

            </div>

        </form>

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

      </div>



      <div class="tablenav_light top">

      		<div style="float: right; width: 40%;">

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

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

                    <?php echo $data['pagination'];?>

                <?php endif;?>

            </div>

            <div class="col-md-8">

              <form method="post" action="">

                <div class="input-group col-md-12">

                    <input type="text" class="search-query form-control" name="search_q" placeholder="Search" />

                    <span class="input-group-btn">

                        <button class="button" type="button"><?php _e('Search', 'ulp');?></button>

                    </span>

                </div>

              </form>

            </div>

          </div>

      		<br class="clear">

      </div>



  <div class="inside">

  <?php if ($data['instructors']):?>

    <table class="ulp-admin-tables ">

        <thead class="thead-inverse">

          <tr>

            <th><?php _e('User ID', 'ulp');?></th>

            <th><?php _e('Username', 'ulp');?></th>

            <th><?php _e('E-mail address', 'ulp');?></th>

            <th><?php _e('Full name', 'ulp');?></th>

            <th style="max-width:500px;"><?php _e('Courses', 'ulp');?></th>

            <th><?php _e('User registered date', 'ulp');?></th>
            <th><?php _e('Details', 'ulp');?></th>

          </tr>

        </thead>

        <tfoot class="thead-inverse">

          <tr>

            <th><?php _e('User ID', 'ulp');?></th>

            <th><?php _e('Username', 'ulp');?></th>

            <th><?php _e('E-mail address', 'ulp');?></th>

            <th><?php _e('Full name', 'ulp');?></th>

            <th><?php _e('Courses', 'ulp');?></th>

            <th><?php _e('User registered date', 'ulp');?></th>
            <th><?php _e('Details', 'ulp');?></th>

          </tr>

        </tfoot>

        <tbody>

            <?php  $i = 1;

			     foreach ($data['instructors'] as $object):?>

                <tr id="<?php echo 'row_'.$object->uid;?>" onMouseOver="ulpDhSelector(('<?php echo '#hidden' . $object->uid;?>', 1);" onMouseOut="ulpDhSelector(('<?php echo '#hidden' . $object->uid;?>', 0);" class="<?php if($i%2==0) echo 'alternate';?>">

                  <td scope="row"><?php echo $object->uid;?></td>

                  <td class="column-instructor">



                      <?php if ($object->avatar):?>

                          <img src="<?php echo $object->avatar;?>" />

                      <?php endif;?>
					  <?php
					  	$pending = '';
					  	if(isset($object->roles['ulp_instructor-pending'])){
					  		$pending = ' class="ulp-admin-instructor-pending" ';
						}
					  ?>
                      <?php echo '<a href="' . admin_url('user-edit.php?user_id=' . $object->uid) . '" target="_blank" '.$pending.'>'.$object->user_login.'</a>';?>

                      <div id="<?php echo 'hidden' . $object->uid;?>" style="visibility: hidden;">

                          <a href="<?php echo admin_url('user-edit.php?user_id='.$object->uid);?>"><?php _e('Edit', 'ulp');?></a> |

                          <span class="ulp-delete js-ulp-instructor-become-normal-user" data-uid="<?php echo $object->uid;?>" ><?php _e('Remove', 'ulp');?></span>

                      </div>

                  </td>

                  <td><a href="mailto:<?php echo $object->user_email;?>"><?php echo $object->user_email;?></a></td>

                  <td><?php echo $object->full_name;?></td>

                  <td style="max-width:600px;"><?php

                      if (!empty($object->courses)){

                          foreach ($object->courses as $course_object){

                              echo '<div class="ulp-property"><a href="' . admin_url('post.php?post=' . $course_object->post_id . '&action=edit') . '" target="_blank">' . $course_object->post_title . '</a></div>';

                          }

                      }

                  ?></td>

                  <td><?php echo ulp_print_date_like_wp($object->user_registered);?></td>
                  <td>
                    <div class="ulp-small-button ulp-grey-button ulp-admin-do-send-email-via-ulp" data-uid="<?php echo $object->uid;?>" ><?php _e('Direct Email', 'ulp');?></div>
                  </td>

                </tr>

              <?php  $i++;

			    endforeach;?>

        </tbody>

    </table>

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



  <?php else:?>

      <div><?php _e('No instructors yet!', 'ulp');?></div>

  <?php endif;?>

  </div>

</div>

<?php
