 <section class="content-header">
    <h1>
        {{phrase.Assignments}}
    </h1>
</section>


<section class="content" ng-show="views.list">
  <a ng-if="userRole == 'admin' || userRole == 'teacher'" ng-click="changeView('add')" class="floatRTL btn btn-success btn-flat pull-right marginBottom15">{{phrase.AddAssignments}}</a>  
  <div class="box col-xs-12">
      <div class="box-header">
          <h3 class="box-title">{{phrase.listAssignments}}</h3>
          <div class="box-tools">
              <div class="input-group">
                  <input type="text" name="table_search" ng-model="searchText" class="form-control input-sm pull-right" style="width: 150px;" placeholder="{{phrase.Search}}">
                  <div class="input-group-btn">
                      <button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
                  </div>
              </div>
          </div>
      </div>
      <div class="box-body table-responsive">
          <table class="table table-hover">
              <tbody><tr>
                  <th>{{phrase.ID}}</th>
                  <th>{{phrase.AssignmentTitle}}</th>
                  <th>{{phrase.AssignmentDescription}}</th>
                  <th>{{phrase.AssignmentDeadline}}</th>
                  <th>{{phrase.Operations}}</th>
              </tr>
              <tr ng-repeat="assignment in assignments | filter:searchText">
                  <td>{{assignment.id}}</td>
                  <td>{{assignment.AssignTitle}}</td>
                  <td>{{assignment.AssignDescription}}</td>
                  <td>{{assignment.AssignDeadLine}}</td>
                  <td>
                    <a target="_blank" href="{{'uploads/assignments/'+assignment.AssignFile}}" type="button" class="btn btn-info btn-flat" title="{{phrase.Download}}" tooltip><i class="fa fa-cloud-download"></i></a>
                    <a ng-if="userRole == 'admin' || userRole == 'teacher'" ng-click="edit(assignment.id)" type="button" class="btn btn-info btn-flat" title="{{phrase.Edit}}" tooltip><i class="fa fa-pencil"></i></a>
                    <a ng-if="userRole == 'admin' || userRole == 'teacher'" ng-click="remove(assignment,$index)" type="button" class="btn btn-danger btn-flat" title="{{phrase.Remove}}" tooltip><i class="fa fa-trash-o"></i></a>
                  </td>
              </tr>
              <tr ng-show="assignments.length == '0'"><td class="noTableData" colspan="5">{{phrase.noAssignments}}</td></tr>
          </tbody></table>
      </div>
  </div>
</section>

<section class="content" ng-show="views.add">
  <a ng-click="changeView('list')" class="floatRTL btn btn-danger btn-flat pull-right marginBottom15">{{phrase.cancelAdd}}</a>  
  <div class="box col-xs-12">
    <div class="box-header">
        <h3 class="box-title">{{phrase.AddAssignments}}</h3>
    </div>
    <div class="box-body table-responsive">
      <form class="form-horizontal" name="addDorm" role="form" ng-upload="saveAdd(content)" role="form" method="post" action="assignments" novalidate>
        <div class="form-group" ng-class="{'has-error': addDorm.AssignTitle.$invalid}">
          <label for="inputEmail3" class="col-sm-2 control-label">{{phrase.AssignmentTitle}} * </label>
          <div class="col-sm-10">
            <input type="text" name="AssignTitle" ng-model="form.AssignTitle" class="form-control" required placeholder="{{phrase.AssignmentTitle}}">
          </div>
        </div>
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentDescription}}</label>
          <div class="col-sm-10">
            <textarea name="AssignDescription" class="form-control" ng-model="form.AssignDescription" placeholder="{{phrase.AssignmentDescription}}"></textarea>
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': addDorm.AssignDeadLine.$invalid}">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentDeadline}} *</label>
          <div class="col-sm-10">
            <input type="text" id="datemask" name="AssignDeadLine" ng-model="form.AssignDeadLine" required class="form-control datemask">
          </div>
        </div>
        <div date-picker selector=".datemask" ></div>
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentFile}}</label>
          <div class="col-sm-10">
            <input type="file" name="AssignFile">
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': addDorm['classId[]'].$invalid}">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.class}} *</label>
          <div class="col-sm-10">
            <select class="form-control" ng-model="form.classId" name="classId[]" multiple required>
              <option ng-repeat="class in classes" value="{{class.id}}">{{class.className}}</option>
            </select>
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': addDorm.subjectId.$invalid}">
          <label for="inputEmail3" class="col-sm-2 control-label">{{phrase.Subject}} *</label>
          <div class="col-sm-10">
            <select class="form-control" ng-model="form.subjectId" required name="subjectId">
              <option ng-repeat="subjectOne in subject" value="{{subjectOne.id}}">{{subjectOne.subjectTitle}}</option>
            </select>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <input type="hidden" name="_token" value="{{CSRF_TOKEN}}">
            <button type="submit" class="btn btn-default" ng-disabled="addDorm.$invalid">{{phrase.AddAssignments}}</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</section>

<section class="content" ng-show="views.edit">
  <a ng-click="changeView('list')" class="floatRTL btn btn-danger btn-flat pull-right marginBottom15">{{phrase.cancelEdit}}</a> 
  <div class="box col-xs-12">
    <div class="box-header">
        <h3 class="box-title">{{phrase.editAssignment}}</h3>
    </div>
    <div class="box-body table-responsive">
      <form class="form-horizontal" name="editDorm" role="form"  ng-upload="saveEdit(content)" role="form" method="post" action="{{'assignments/' + form.id}}" novalidate>
        <div class="form-group" ng-class="{'has-error': editDorm.AssignTitle.$invalid}">
          <label for="inputEmail3" class="col-sm-2 control-label">{{phrase.AssignmentTitle}} * </label>
          <div class="col-sm-10">
            <input type="text" name="AssignTitle" ng-model="form.AssignTitle" class="form-control" required placeholder="{{phrase.AssignmentTitle}}">
          </div>
        </div>
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentDescription}}</label>
          <div class="col-sm-10">
            <textarea name="AssignDescription" class="form-control" ng-model="form.AssignDescription" placeholder="{{phrase.AssignmentDescription}}"></textarea>
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': editDorm.AssignDeadLine.$invalid}">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentDeadline}} *</label>
          <div class="col-sm-10">
            <input type="text" id="datemask" name="AssignDeadLine" ng-model="form.AssignDeadLine" required class="form-control datemask">
          </div>
        </div>
        <div date-picker selector=".datemask" ></div>
        <div class="form-group">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.AssignmentFile}}</label>
          <div class="col-sm-10">
            <input type="file" name="AssignFile">
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': editDorm['classId[]'].$invalid}">
          <label for="inputPassword3" class="col-sm-2 control-label">{{phrase.class}} *</label>
          <div class="col-sm-10">
            <select class="form-control" ng-model="form.classId" name="classId[]" id="editClassId" multiple required>
              <option ng-repeat="class in classes" value="{{class.id}}">{{class.className}}</option>
            </select>
          </div>
        </div>
        <div class="form-group" ng-class="{'has-error': editDorm.subjectId.$invalid}">
          <label for="inputEmail3" class="col-sm-2 control-label">{{phrase.Subject}} *</label>
          <div class="col-sm-10">
            <select class="form-control" ng-model="form.subjectId" required name="subjectId">
              <option ng-repeat="subjectOne in subject" value="{{subjectOne.id}}">{{subjectOne.subjectTitle}}</option>
            </select>
          </div>
        </div>
        <div class="form-group">
          <div class="col-sm-offset-2 col-sm-10">
            <input type="hidden" name="_token" value="{{CSRF_TOKEN}}">
            <button type="submit" class="btn btn-default" ng-disabled="editDorm.$invalid">{{phrase.editAssignment}}</button>
          </div>
        </div>
      </form>
    </div>
  </div>
</section>