<?php include '../../../common/view/header.html.php';?>
<div class="alert alert-warning">
  <p><?php printf($lang->user->tips->userLeft, $userLeft);?></p>
</div>

<div class='panel'>
  <form id='ajaxForm' method='post'>
    <table class='table table-form'>
      <thead>
        <tr class='text-center'>
          <th class='w-60px'><?php echo $lang->user->id?></th>
          <th class='w-100px'><?php echo $lang->user->ldapUser;?></th>
          <th class='account required'><?php echo $lang->user->zdooUser;?></th>
          <th class='required'><?php echo $lang->user->realname?></th>
          <th class='w-80px'><?php echo $lang->user->gender?></th>
          <th class='w-140px'><?php echo $lang->user->dept?></th>
          <th class='w-120px'><?php echo $lang->user->role?></th>
          <th class='w-120px'><?php echo $lang->user->group?></th>
          <th class='w-160px required'><?php echo $lang->user->email?></th>
        </tr>
      </thead>
      <tbody>
        <?php foreach($ldapUsers as $i => $user):?>
        <?php
        if($i == 1)
        {
            $depts['ditto']   = $lang->ditto;
            $groups['ditto']  = $lang->ditto;
            $roles['ditto']   = $lang->ditto;
            $genders['ditto'] = $lang->ditto;
        }
        ?>
        <tr class='text-middle text-center'>
          <td class='text-center'>
            <div class='checkbox-primary'>
              <input type='checkbox' name='add[<?php echo $i?>]' value='<?php echo $i?>' checked=true class='add'>
              <label for="add<?php echo $i;?>"><?php printf("%03d", $i + 1)?></label>
            </div>
          </td>
          <td title='<?php echo $user['account'];?>'><?php echo $user['account'] . "<input id='ldapAccount$i' name='ldapAccount[$i]' value='{$user['account']}' type='hidden' />"?></td>
          <td class='text-left'>
            <div class='input-group'>
              <span class='input-group-btn newAccount' style='display: none'><?php echo html::a('javascript:;', $lang->user->asLDAP, "class='btn btn-default asLDAP'");?></span>
              <?php echo html::input("newAccount[$i]", '', "id='newAccount$i' class='form-control newAccount' style='display: none'");?>
              <?php echo html::select("account[$i]", $users, '', "id='account{$i}' class='form-control chosen'");?>
              <span class='input-group-addon'>
                <label class='checkbox-inline'>
                  <input type='checkbox' id='createAccount<?php echo $i;?>' name='createAccount[<?php echo $i;?>]' value='1'>
                  <?php echo $lang->create;?>
                </label>
              </span>
            </div>
          </td>
          <td><?php echo html::input("realname[$i]", '', "id='realname$i' class='form-control'");?></td>
          <td><?php echo html::select("gender[$i]", $genders, $i == 0 ? '' : 'ditto', "class='form-control'");?></td>
          <td><?php echo html::select("dept[$i]", $depts, $i == 0 ? '' : 'ditto', "class='form-control chosen'");?></td>
          <td><?php echo html::select("role[$i]", $roles, $i == 0 ? '' : 'ditto', "class='form-control chosen'");?></td>
          <td><?php echo html::select("group[$i]", $groups, $i == 0 ? '' : 'ditto', "class='form-control chosen'");?></td>
          <td><?php echo html::input("email[$i]", $user['email'], "id='email$i' class='form-control'");?></td>
        </tr>
        <?php endforeach;?>
      </tbody>
    </table>

    <div class='table-footer'>
      <?php if($ldapUsers):?>
      <div class='btn-group'>
        <a id='allCheck' class='btn' href='javascript:;' ><?php echo $lang->selectAll;?></a>
        <a id='reverseCheck' class='btn' href='javascript:;'><?php echo $lang->selectReverse;?></a>
      </div>
      <?php endif;?>

      <?php echo html::submitButton();?>
      <?php echo html::backButton();?>
      <span class='text-warning'><?php echo $lang->user->notice->checkbox;?></span>
      <?php $pager->show();?>
    </div>
  </form>
</div>
<?php include '../../../common/view/footer.html.php';?>
