<commit_before><?php
$pageTitle = "Users";
$pageSubTitle = "Manage admins and experts";
include $template;

function htmlHead() { ?>
  <script>var token = '<?= \Trust\Server::csrf_token(); ?>';</script>
  <script src="/jslib/moment.min.js"></script>
  <script src="/js/admin/users.js"></script>
<?php }

function mainContent() { ?>
  <div class="row" ng-controller="ctrlUsers">
    <table class="table table-bordered table-striped table-condensed table-responsive">
      <thead>
        <tr>
          <th>Username</th>
          <th>Full Name</th>
          <th>Category</th>
          <th>Organization</th>
          <th>Level</th>
          <th>Validated</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="u in users">
          <td><a ng-click="show(u)">{{u.username}}</a></td>
          <td>{{u.biodata.name}}</td>
          <td><a ng-click="edit(u)">{{u.category}}</a></td>
          <td><a ng-click="edit(u)">{{u.organization}}</a></td>
          <td><a ng-click="edit(u)">{{u.level}}</a></td>
          <td>
            <button ng-click="toggleValidation(u)" ng-if="u.validated" class="btn btn-success btn-xs">{{u.validated}}</button>
            <button ng-click="toggleValidation(u)" ng-if="!u.validated" class="btn btn-danger btn-xs">{{u.validated}}</button>
          </td>
        </tr>
      </tbody>
    </table>
    
<div id="modalShowUser" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">User: {{u.username}}, Level:{{u.level}}</h4>
      </div>
      <div class="modal-body">
        <h3>{{u.username}} ({{u.level}} user)</h3>
        <table>
          <tr><td>date joined </td><td> : {{momenter(u.login_info.join_date)}}</td></tr>
          <tr><td>last login </td><td> : {{momenter(u.login_info.last_login)}}</td></tr>
        </table>
        <table class="table table-condensed table-striped">
            <tr>
              <td>Status</td>
              <td>
                <span ng-if="u.validated" class="label label-success">Validated</span>
                <span ng-if="!u.validated" class="label label-danger">Not Validated</span>
                <span ng-if="u.active" class="label label-success">Activated</span>
                <span ng-if="!u.active" class="label label-danger">Not Activated</span>
              </td>
            </tr>
            <tr><td>Name</td><td>{{u.biodata.name}}</td></tr>
            <tr><td>Category</td><td>{{u.category}}</td></tr>
            <tr><td>Organization</td><td>{{u.organization}}</td></tr>
            <tr><td>E-mail</td><td>{{u.biodata.email}}</td></tr>
            <tr><td>Gender</td><td>{{u.biodata.gender}}</td></tr>
            <tr><td>DOB</td><td>{{u.biodata.dob}}</td></tr>
            <tr><td>City</td><td>{{u.biodata.city}}</td></tr>
            <tr><td>Phone(s)</td><td style="white-space: pre-line">{{phoneLists(u)}}</td></tr>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<div class="modal fade" id="modalEdit" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Edit User: {{editUser.username}}</h4>
      </div>
      <div class="modal-body">
        <table>
          <tr>
            <td>Category</td>
            <td><select ng-model="editUser.category" class="form-control"
                        ng-options="key as key for (key,value) in categories" ng-change="updateOrganizationSelect()"></select>
            </td>
          </tr>
          <tr>
            <td>Organization</td>
            <td><select ng-model="editUser.organization" class="form-control"
                        ng-options="o.name as o.name for o in organizations"></select></td>
          </tr>
          <tr>
            <td>Level</td>
            <td><select ng-model="editUser.level" class="form-control"
                        ng-options="l as l for l in levels"></select></td>
          </tr>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button ng-click="saveChanges(editUser)" type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

  
  <div id="init" style="display:none;"><?php
    $init = new stdClass();
    $init->users = \SSBIN\User::all();
    foreach ($init->users as $k=>$u)
      unset(
            $init->users[$k]->login_sys,
            $init->users[$k]->password
            );
    $init->categories = \SSBIN\Organization::getNestedArray();
    $init->levels = [\SSBIN\User::USER_ADMIN,  \SSBIN\User::USER_EXPERT, \SSBIN\User::USER_STANDARD];
    echo json_encode($init);
  ?></div>
<?php
}<commit_msg>CtrlUsers tambah order by di query select.<commit_after><?php
$pageTitle = "Users";
$pageSubTitle = "Manage admins and experts";
include $template;

function htmlHead() { ?>
  <script>var token = '<?= \Trust\Server::csrf_token(); ?>';</script>
  <script src="/jslib/moment.min.js"></script>
  <script src="/js/admin/users.js"></script>
<?php }

function mainContent() { ?>
  <div class="row" ng-controller="ctrlUsers">
    <table class="table table-bordered table-striped table-condensed table-responsive">
      <thead>
        <tr>
          <th>Username</th>
          <th>Full Name</th>
          <th>Category</th>
          <th>Organization</th>
          <th>Level</th>
          <th>Validated</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="u in users">
          <td><a ng-click="show(u)">{{u.username}}</a></td>
          <td>{{u.biodata.name}}</td>
          <td><a ng-click="edit(u)">{{u.category}}</a></td>
          <td><a ng-click="edit(u)">{{u.organization}}</a></td>
          <td><a ng-click="edit(u)">{{u.level}}</a></td>
          <td>
            <button ng-click="toggleValidation(u)" ng-if="u.validated" class="btn btn-success btn-xs">{{u.validated}}</button>
            <button ng-click="toggleValidation(u)" ng-if="!u.validated" class="btn btn-danger btn-xs">{{u.validated}}</button>
          </td>
        </tr>
      </tbody>
    </table>
    
<div id="modalShowUser" class="modal fade" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">User: {{u.username}}, Level:{{u.level}}</h4>
      </div>
      <div class="modal-body">
        <h3>{{u.username}} ({{u.level}} user)</h3>
        <table>
          <tr><td>date joined </td><td> : {{momenter(u.login_info.join_date)}}</td></tr>
          <tr><td>last login </td><td> : {{momenter(u.login_info.last_login)}}</td></tr>
        </table>
        <table class="table table-condensed table-striped">
            <tr>
              <td>Status</td>
              <td>
                <span ng-if="u.validated" class="label label-success">Validated</span>
                <span ng-if="!u.validated" class="label label-danger">Not Validated</span>
                <span ng-if="u.active" class="label label-success">Activated</span>
                <span ng-if="!u.active" class="label label-danger">Not Activated</span>
              </td>
            </tr>
            <tr><td>Name</td><td>{{u.biodata.name}}</td></tr>
            <tr><td>Category</td><td>{{u.category}}</td></tr>
            <tr><td>Organization</td><td>{{u.organization}}</td></tr>
            <tr><td>E-mail</td><td>{{u.biodata.email}}</td></tr>
            <tr><td>Gender</td><td>{{u.biodata.gender}}</td></tr>
            <tr><td>DOB</td><td>{{u.biodata.dob}}</td></tr>
            <tr><td>City</td><td>{{u.biodata.city}}</td></tr>
            <tr><td>Phone(s)</td><td style="white-space: pre-line">{{phoneLists(u)}}</td></tr>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->


<div class="modal fade" id="modalEdit" tabindex="-1" role="dialog">
  <div class="modal-dialog">
    <div class="modal-content">
      <div class="modal-header">
        <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
        <h4 class="modal-title">Edit User: {{editUser.username}}</h4>
      </div>
      <div class="modal-body">
        <table>
          <tr>
            <td>Category</td>
            <td><select ng-model="editUser.category" class="form-control"
                        ng-options="key as key for (key,value) in categories" ng-change="updateOrganizationSelect()"></select>
            </td>
          </tr>
          <tr>
            <td>Organization</td>
            <td><select ng-model="editUser.organization" class="form-control"
                        ng-options="o.name as o.name for o in organizations"></select></td>
          </tr>
          <tr>
            <td>Level</td>
            <td><select ng-model="editUser.level" class="form-control"
                        ng-options="l as l for l in levels"></select></td>
          </tr>
        </table>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
        <button ng-click="saveChanges(editUser)" type="button" class="btn btn-primary">Save changes</button>
      </div>
    </div><!-- /.modal-content -->
  </div><!-- /.modal-dialog -->
</div><!-- /.modal -->

  
  <div id="init" style="display:none;"><?php
    $init = new stdClass();
    $init->users = \SSBIN\User::allWhere(" ORDER BY category, organization",[]);
    foreach ($init->users as $k=>$u)
      unset(
            $init->users[$k]->login_sys,
            $init->users[$k]->password
            );
    $init->categories = \SSBIN\Organization::getNestedArray();
    $init->levels = [\SSBIN\User::USER_ADMIN,  \SSBIN\User::USER_EXPERT, \SSBIN\User::USER_STANDARD];
    echo json_encode($init);
  ?></div>
<?php
}
{'fraction_non_alphanumeric': 0.21963007714471605, 'fraction_numerical': 0.0014871270564178827, 'mean_word_length': 2.4420985284708894, 'pattern_counts': {'":': 0, '<': 431, '<?xml version=': 0, '>': 447, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6781070', 'n_tokens_mistral': 3613, 'n_tokens_neox': 3500, 'n_words': 568}