<?php use_helper('I18N', 'Object', 'Validation', 'ModalBox'); ?>
<?php use_helper('tvtl'); ?>
<?php use_helper('Javascript') ?>

<?php
    if ($tbluser->getUsChecked() == 0) {
      //$htmlMenus[] = array('text'=>'Nhờ quý vị xác thực', 'link'=>'#', 'options'=>array('onclick'=>"return sameUser(" . $tbluser->getUsId() . ", 3)"));
      $htmlMenus[] = array('text'=>'Cùng Đơn vị', 'link'=>'#', 'options'=>array("onclick"=>"return sameUser(" . $tbluser->getUsId() . ", 2)" ));
      if ($tblblogcheckinfo->getCiPosition() >= 10)
      $htmlMenus[] = array('text'=>'Cùng Huyện', 'link'=>'#', 'options'=>array('onclick'=>"return sameUser(" . $tbluser->getUsId() . ", 1)" ));
      /*
      $htmlMenus[] = array('text'=>'Cùng Tỉnh', 'link'=>'#', 'options'=>array('onclick'=>"return sameUser(" . $tbluser->getUsId() . ", 0)"));
      */
    //$htmlMenus[] = array('text'=>'Đã được xác thực');
    }
  ?>
    <div class="tab-searchbox">
    <?php if ($tbluser->getUsChecked() == 0):?>
    <?php echo gridTab($htmlMenus, '', $currentTab, null, array('class'=>'csstab', 'style'=>'width:auto; margin:0px')) ?>
    <?php echo form_remote_tag (array ('update'=>'same-user', 'url'=>'user/sameUser')) ?>
       <div class="search-uschecked">
          <input type="text" name="keyword" value="<?php echo $keyword;?>" style="width: 150px; margin-right: 5px; float: left"/>
          <input type="submit" value="Tìm kiếm" />
        </div>
    </form>
    <?php endif;?>
    </div>
   <div style="float: left;">
      <?php if ($isSearch):?>
      <?php $pageNav = showPageNav13($pager, '/user/sameUser?us_id=' . $tbluser->getUsId() . '&status=' . $approve . '&keyword=' . $keyword, 'same-user'); ?>
      <?php else:?>
      <?php $pageNav = showPageNav13($pager, '/user/sameUser?us_id=' . $tbluser->getUsId() . '&status=' . $approve . '&type=' . $type, 'same-user'); ?>
      <?php endif;?>
        <table class="table-content" style="width: 530px" border="0" cellpadding="0" cellspacing="0">
          <?php if ($isInviteCheck):?>
          <tr>
            <td colspan="4" style="text-align: right;">
              <?php //echo select_tag('status', options_for_select(
                    //                            array('' => 'Tất cả', 0 => 'Chưa xác thực', 1=>'Đã xác thực')
                    //                            , $approve
                    //                          )
                    //                        , array('onchange'=>'submit()')
                    //                );
              ?>
            </td>
          </tr>
          <?php endif;?>
          <tr>
            <th>Tên truy nhập</th>
            <th>Họ và tên</th>
            <th>Email</th>
            <th width="80">
              <?php if ($tbluser->getUsChecked() == 1):?>
              <b>Xác thực</b>
              <?php else:?>
              <b>Nhờ xác thực</b>
              <?php endif;?>
            </th>
          </tr>
          <?php if ($isSearch):?>
            <?php foreach ($pager->getResult() as $key => $tbluserschool):?>
              <?php $tbluser = $tbluserschool->getTbluser(); ?>
              <?php $confirm = 'Quý vị có chắc chắn ';?>
              <?php $confirm = $tbluser->getUsChecked() == 0 ? $confirm . 'xác thực cho ' . $tbluser->getUsFullname() . ' không?' : $confirm . 'nhờ ' . $tbluser->getUsFullname() . ' xác thực cho quý vị không?'?>
              <?php $checked = TblblogusercheckPeer::retrieveByPK($us_id, $tbluser->getUsId()) != null; ?>
              <tr class="row<?php echo $key%2?>">
                <td><?php echo m_link_to(myUtility::mb_truncate_text($tbluser->getUsUsername(), 15), 'user/show?id='.$tbluser->getUsId(), array('title'=>'Thông tin cá nhân của thành viên này') )?></td>
                <td><?php echo $tbluser->getUsFullname();?></td>
                <td><?php echo myUtility::mb_truncate_text($tbluser->getUsEmail(), 25);?></td>
                <td><div id="feedback<?php echo $tbluser->getUsId()?>"><?php echo $checked? 'Đã mời':
                  link_to_remote( ($tbluser->getUsChecked() == 0) ? 'Xác thực' : 'Nhờ xác thực',
                  array('update'=>'feedback'.$tbluser->getUsId(), 'url'=>'user/check?id='.$tbluser->getUsId().'&type=0', 'confirm'=>$confirm)
                ) ?></div></td>
              </tr>
            <?php endforeach;?>
          <?php else :?>
            <?php if ($isInviteCheck):?>
              <?php foreach ($pager->getResult() as $key => $tblblogusercheck):?>
                <?php $tbluser = $tblblogusercheck->getTbluser(); ?>
                <tr class="row<?php echo $key%2?>">
                  <td><?php echo myUtility::mb_truncate_text($tbluser->getUsUsername(), 15) ?></td>
                  <td><?php echo myUtility::mb_truncate_text($tbluser->getUsFullname(), 25) ?></td>
                  <td><?php echo myUtility::mb_truncate_text($tbluser->getUsEmail(), 25) ?></td>
                  <td><div id="feedback<?php echo $tbluser->getUsId()?>">
                    <?php
                    $checkLink = m_link_to('Xem xét...', 'user/confirmCheck?id='.$tbluser->getUsId(),
                    array('title'=>'Thông tin xác thực thành viên'));
                    echo $tblblogusercheck->getUcApprove() == 0 ? $checkLink : 'Đã xác thực';
                    ?>
                  </div></td>
                </tr>
              <?php endforeach;?>
            <?php else:?>
              <?php foreach ($pager->getResult() as $key => $tbluserschool):?>
                <?php $confirm = 'Quý vị có chắc chắn ';?>
                <?php $confirm = $tbluserschool->getTbluser()->getUsChecked() == 0 ? $confirm . 'xác thực cho ' . $tbluserschool->getTbluser()->getUsFullname() . ' không?' : $confirm . 'nhờ ' . $tbluserschool->getTbluser()->getUsFullname() . ' xác thực cho quý vị không?'?>
                <?php $checked = TblblogusercheckPeer::retrieveByPK($us_id, $tbluserschool->getTbluser()->getUsId()) != null; ?>
                <tr class="row<?php echo $key%2?>">
                  <td><?php echo m_link_to(myUtility::mb_truncate_text(strtolower($tbluserschool->getTbluser()->getUsUsername()), 15), 'user/show?id='.$tbluserschool->getTbluser()->getUsId(), array('title'=>'Thông tin cá nhân của thành viên này') )?></td>
                  <td><?php echo $tbluserschool->getTbluser()->getUsFullname();?></td>
                  <td><?php echo myUtility::mb_truncate_text(strtolower($tbluserschool->getTbluser()->getUsEmail()), 25);?></td>
                  <td><div id="feedback<?php echo $tbluserschool->getTbluser()->getUsId()?>"><?php echo $checked? 'Đã mời':
                    link_to_remote( ($tbluserschool->getTbluser()->getUsChecked() == 0) ? 'Xác thực' : 'Nhờ xác thực',
                    array('update'=>'feedback'.$tbluserschool->getTbluser()->getUsId(), 'url'=>'user/check?id='.$tbluserschool->getTbluser()->getUsId().'&type=0', 'confirm'=>$confirm)
                  ) ?></div></td>
                </tr>
              <?php endforeach;?>
            <?php endif;?>
          <?php endif;?>
          </table>
        <div style="width: 100%; text-align: center"><?php echo $pageNav ?></div>
  </div>
  <style>
    .tab-searchbox {
      width: 100%;
      padding: 0px;
      margin: 0px;
      float: left;
    }
    .search-uschecked {
      float: right;
    }
    .search-uschecked input{
      float: left;
      height: 20px;
      margin: 0px;
      padding: 0px;
    }
  </style>
