<?php
		defined('BASEPATH') OR exit('No direct script access allowed');
	$this->load->view("admin_includes/head");
	$this->load->view("admin_includes/header");
	$this->load->view("admin_includes/main_sidebar");
?>
	
     <div class="page-wrapper">
       
            <div class="container-fluid">
                <div class="row">
                    <div class="col s12 l12">
                        <div class="card">
                            <div class="card-content">
                                <h5 class="card-title activator">New Packages</h5>
                 	<form action="<?php echo base_url(); ?>index.php/save_package" class="form-horizontal" id="block-validate" method="POST" enctype="multipart/form-data" >
						<div class="form-body">
							<div class="divider"></div>
							<div class="card-content">
								<h6 class="font-medium">Personal Info</h6>
								 <?php
										 
                    foreach ($edit_data as $key => $data) {
					?>
								<input type="hidden" name="package_id" value="<?php echo $data['package_id']; ?>" >
								<div class="row">
									<div class="col s12 m6 l6">
										<div class="input-field">
											<input id="package_name" name="package_name" required value="<?php echo $data['package_name']; ?>"   type="text">
											<label for="f-name1">Package Name</label>
										</div>
									</div>
								
								</div>
								<div class="row">
									<div class="col s12 m6 l6">
										<div class="input-field">
											<input id="user_limit" onkeypress="return isNumber(event);" required value="<?php echo $data['user_min_limit']; ?>"  name="user_limit" type="text">
											<label for="clinic_name">User Min Limit	</label>
										</div>
									</div>
									<div class="col s12 m6 l6">
										<div class="input-field">
											<input id="per_user_cost" onkeypress="return isNumber(event);" required name="per_user_cost" value="<?php echo $data['per_user_cost']; ?>"  type="text">
											<label for="nname">Per User Cost</label>
										</div>
									</div>
								</div>
							</div>
							<div class="divider"></div>
							<div class="card-content">
								
								<div class="row">
								  <h6 class="font-medium">Duration Info</h6>    
									<div class="col s12 m6 l6">
										<div class="input-field">
											<input type="text" id="duration" onkeypress="return isNumber(event);" required value="<?php echo $data['duration']; ?>" name="duration">
											<label for="bio">Duration 	</label>
											
										</div>
									</div>
									<div class="col s12 m6 l6">
										<div class="input-field">
											 <select name="duration_type" id="duration_type">
											 <option value=""></option>
											 <option <?php if($data['duration_type']=='months') { echo "selected"; } ?> value="months">Month</option>
											 <option <?php if($data['duration_type']=='year') { echo "selected"; } ?> value="year">Year</option>
											 </select>
											<label for="l-name2">Duration Type</label>
										</div>
									</div>
								</div>
								
						
							 <div class="row">
									<div class="col s12">
										<div class="input-field">
											<textarea id="package_desc" name="package_desc" class="materialize-textarea"></textarea>
											<label for="bio">Package Description</label>
										</div>
									</div>
								</div>
							</div>
					<?php } ?>
							<div class="divider"></div>
							<div class="card-content">
								<div class="form-action">
									<button class="btn waves-effect waves-light cyan" type="submit" name="update_package_btn" value="update_package_btn">Save
									</button>
								 
								</div>
							</div>
						</div>
					</form> 
					</div>
                         </div>
                    </div>
                  </div>
           </div>
            <!-- ============================================================== -->
            <!-- Container fluid scss in scafholding.scss -->
            <!-- ============================================================== -->
          </div>
    
<?php
	$this->load->view("admin_includes/footer");
?>				
</div><!-- ./wrapper -->	
 <script>
    $(function() {
        $("#formValidate").validate({
            rules: {
                package_name: {
                    required: true
				},
                per_user_cost: {
                    required: true,
                } 
            },
            //For custom messages
            messages: {
                package_name: {
                    required: "Enter a Package Name"
                }, per_user_cost: {
                    required: "Enter a User Cost"
                }
            },
            errorElement: 'div',
            errorPlacement: function(error, element) {
                var placement = $(element).data('error');
                if (placement) {
                    $(placement).append(error)
                } else {
                    error.insertAfter(element);
                }
            },
            invalidHandler: function(e, validator) {
                var errors = validator.numberOfInvalids();
                if (errors) {
                    $('.error-alert-bar').show();
                }
            },
        });
    });
    </script>