<?php defined('BASEPATH')or exit('NO direct Access is Allowed');?>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<link href="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.css" rel="stylesheet"/>
<link href="https://code.jquery.com/ui/1.12.1/themes/pepper-grinder/jquery-ui.css" rel="stylesheet"/>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdn.rawgit.com/dubrox/Multiple-Dates-Picker-for-jQuery-UI/master/jquery-ui.multidatespicker.js"></script>
<style>
.bootstrap-timepicker-widget table td input {
    width: 100%;
  }
  .border_full{
    border: 2px solid #ccc;

  }
  .full_h3{
    margin-top: -4px;
    background-color: #999;
    color: #fff;
    padding: 9px;
  }
  .add_course{
    margin-top: 15px;
    border: 2px solid #ccc;
  }
  .add_h3{
    margin-top: -4px;
    background-color: #dd4b39;
    color: #fff;
    padding: 9px;
}

</style>
<?php
  $last     = $this->uri->total_segments();
  $courseid = $this->uri->segment($last);
  date_default_timezone_set('Asia/Kolkata');
?>

<div class="content-wrapper">
  <section class="content">
      <div class="row">
          <div class="col-xs-12">
              <div class="box">
                  <!-- <div class="box-header">
                      <?php //echo anchor('admin/account/Account/student_wallet','<i class="fa fa-fw fa-list"></i> Student Wallet List',['class'=>'btn btn-default pull-right',
                      //'style'=>'background-color: #ffffff;']); ?>
                      <div class="col-md-12" id="respose">
                      <?php //if ($this->session->flashdata('failure') == TRUE): ?>
                            <div class="alert alert-error"><?php //echo $this->session->flashdata('failure'); ?></div>
                            <?php //endif; ?>
                            <?php //if ($this->session->flashdata('success') == TRUE): ?>
                            <div class="alert alert-success"><?php //echo $this->session->flashdata('success'); ?></div>
                        <?php //endif; ?>
                      </div>
                  </div> -->
                  <!-- /.box-header -->
                  <div class="box-body">
                    <div class="row">
                      <div class="col-md-12">
                        <div class="add_course">
                        <h3 class="add_h3">Add Teacher Pay Type</h3>
                         <form name="add_name"  method="post" action='<?=site_url("admin/account/Account/assign_pay_type_teacher");?>' id="add_name">
                            <div class="table-responsive">
                                <table class="table table-bordered" id="dynamic_field">
                                  <thead>
                                  <tr>
                                     <td>#</td>
                                     <td>Teacher</td>
                                    <td>Payment Mode</td>
                                    <td>Mode Start</td>
                                    <td>Mode End</td>
                                    <td>Price<i class="fa fa-fw fa-rupee"></i></td>
                                    <td>Remarks</td>
                                    <td>Action</td>
                                  </tr>
                                </thead>
                                <tbody>
                                    <tr>
                                         <td>1</td>
                                         <td>  <?php echo form_dropdown('teacher[]',$teacher_list,set_value('student',''),['class'=>'form-control','autocomplete'=>'off','required'=>'required']);?></td>
                                        <td>
                                        <?php echo form_dropdown('mode_of_payment[]',$paymode,set_value('mode_of_payment',''),['class'=>'form-control','autocomplete'=>'off','required'=>'required']);?>
                                      </td>
                                      <td>  <?php echo form_input(['name'=>'mode_start_at[]','class'=>'form-control datepicker','placeholder'=>'Paymode starting date',
                                       'value'=>set_value('mode_start_at',''),'autocomplete'=>'off','required'=>'required','id'=>'']);?></td>
                                       <td>  <?php echo form_input(['name'=>'mode_end_at[]','class'=>'form-control datepicker2','placeholder'=>'Paymode End date',
                                        'value'=>set_value('mode_end_at',''),'autocomplete'=>'off','required'=>'required','id'=>'']);?></td>
                                      <td>  <?php echo form_input(['name'=>'salary_unit[]','class'=>'form-control salary_unit','placeholder'=>'Student Wallet Amount',
                                       'value'=>set_value('student_wallet',''),'autocomplete'=>'off','required'=>'required']);?></td>
                                    <td>  <?php echo form_textarea(['name'=>'remarks[]','class'=>'form-control','id'=>'','placeholder'=>'Remarks',
                                      'value'=>set_value('remarks'),'rows'=> '1','cols' => '10','autocomplete'=>'off']);?></td>
                                        <td><button type="button" name="add" id="add" class="btn btn-success">Add More</button></td>
                                    </tr>
                                  </tbody>
                                </table>
                                <input type="submit" name="submit" id="submit" class="btn btn-info pull-right" value="Submit" />
                            </div>
                         </form>
                          </div>
                      </div>
                    </div>
                  </div>
                  <hr/>

              </div>
          </div>
      </div>
  </section>
</div>
<script>
$(document).ready(function () {
  //called when key is pressed in textbox
  $(".salary_unit").keypress(function (e) {
     //if the letter is not digit then display error and don't type anything
     if (e.which != 8 && e.which != 0 && (e.which < 48 || e.which > 57)) {
        //display error message
        $("#errmsg").html("Digits Only").show().fadeOut("slow");
               return false;
    }
   });
});
$(document).ready(function(){
	$(".addCF").click(function(){
		$("#customFields").append('<tr valign="top"><th scope="row"><label for="customFieldName">Custom Field</label></th><td><input type="text" class="code" id="customFieldName" name="customFieldName[]" value="" placeholder="Input Name" /> &nbsp; <input type="text" class="code" id="customFieldValue" name="customFieldValue[]" value="" placeholder="Input Value" /> &nbsp; <a href="javascript:void(0);" class="remCF">Remove</a></td></tr>');
	});
    $("#customFields").on('click','.remCF',function(){
        $(this).parent().parent().remove();
    });
});
</script>
<style>
.SumoSelect {
    display: block;
    position: relative;
    outline: none;
}

</style>
<script>$('#mdp-demo').multiDatesPicker();</script>


<script type="text/javascript">
    $(document).ready(function(){
    //  var postURL = "/addmore.php";
      var i=1;
	  var limit= 5;

  $('#add').on('click',function(){
			//  if(i>=limit){
			// 	alert("You dont have right to add more than "+limit+" class at one time");
			// }
		  //   else{

				i++;
           // $('#dynamic_field').append('<tr id="row'+i+'" class="dynamic-added"><td><input type="text" name="name[]" placeholder="Enter your Name" class="form-control name_list" required /></td><td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');
                      $('#dynamic_field').append('<tr id="row'+i+'" class="dynamic-added"> \
                      <td>'+i+'</td> \
                      <td><select name="teacher[]" class="form-control  name_list" data-placeholder="Student Name" style="" tabindex="-1" aria-hidden="true" required> \
                      <?php foreach($teacher_list as $p=>$b){ ?>\
                                  <option value="<?=$p?>"> <?=$b?></option>\
                                  <?php }?>\
                      </select></td> \
                      <td><select name="mode_of_payment[]" class="form-control  name_list" data-placeholder="Mode Of Payment" style="" tabindex="-1" aria-hidden="true" required> \
                      <?php foreach($paymode as $p=>$b){ ?>\
                                  <option value="<?=$p?>"> <?=$b?></option>\
                                  <?php }?>\
                      </select></td> \
                      <td> \
                         <input type="text" name="mode_start_at[]" class="form-control datepick" id="" placeholder="Paymode starting date" required autocomplete="off"> \
                       </td> \
                       <td> \
                          <input type="text" name="mode_end_at[]" class="form-control datepick2" id="" placeholder="Paymode End date" required autocomplete="off"> \
                        </td> \
                      <td> \
                         <input type="text" name="salary_unit[]" class="form-control salary_unit" id="" placeholder="Student Wallet Amount" required autocomplete="off"> \
                       </td> \
                      <td> <textarea name="remarks[]" cols="10" rows="1" class="form-control" id="" placeholder="Remarks" autocomplete="off"></textarea></td> \
                      <td><button type="button" name="remove" id="'+i+'" class="btn btn-danger btn_remove">X</button></td></tr>');

              $('.datepick').each(function(){
                $(this).datepicker();
              });
              $('.datepick2').each(function(){
                $(this).datepicker();
              });
              $('.timepicker').each(function(){
                showInputs: false;
                minuteStep: 5;
                $(this).timepicker();
                });

    //  }

      });

      $(document).on('click', '.btn_remove', function(){
           var button_id = $(this).attr("id");
           $('#row'+button_id+'').remove();
      });


      $('#submit').click(function(){
           $.ajax({
                url:postURL,
                method:"POST",
                data:$('#add_name').serialize(),
                type:'json',
                success:function(data)
                {
                  	i=1;
                  	$('.dynamic-added').remove();
                  	$('#add_name')[0].reset();
    				        alert('Record Inserted Successfully.');
                }
           });
      });

    });
</script>
