<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
  <!-- Content Header (Page header) -->
  <section class="content-header">
    <h1><i class="fa fa-briefcase"></i> Subscribers<small></small></h1>
    <ol class="breadcrumb">
      <li><a href="<?php echo base_url(); ?>admin/dashboard"><i class="fas fa-tachometer-alt"></i> <?php echo lang('home'); ?></a></li>
      <li class="active"><i class="fa fa-briefcase"></i> Subscribers</li>
      <li class="active"><?php echo lang('create'); ?></li>
    </ol>
  </section>

    <!-- Main content -->
    <section class="content">
      <div class="row">

        
        <div class="col-md-12">
          <!-- general form elements -->
          <div class="box box-primary">
            <div class="box-header with-border">
              <h3 class="box-title"><?php echo lang('details'); ?></h3>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form role="form" id="admin_visitor_create_update_form">
                <div class="col-md-12" <?php echo ($msg !='' && $msg != 'null')?'style="display:block"':'style="display:none"'; ?>>
                    <div class="alert alert-success">
                        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                        <?php 
                        if($msg !='' && $msg != 'null') {
                            if($msg == 'updated')
                                echo "Updated the Subscribers details successfully.";
                            else 
                                echo "Created the Subscribers details successfully.";
                        }
                        ?>
                    </div>
                </div>
              <div class="box-body">
                <div class="row">
                <?php
                if (isset($this->session->userdata('admin')['user_type']) && 
                ($this->session->userdata('admin')['user_type'] == 'security' || 
                $this->session->userdata('admin')['user_type'] == 'admin') ) { 
                ?>
                    <!-- <div class="col-md-6 col-sm-12">
                      <div class="form-group">
                      <label>Flat<span style="color:red;">*</span></label>
                      <select class="form-control select2" id="flat_id" name="flat_id">
                        <option value=""><?php echo lang('none'); ?></option>
                        <?php foreach ($flats as $key => $value) { ?>
                          <option value="<?php echo esc_output($value['flat_id']); ?>" ><?php echo esc_output($value['block_door'], 'html'); ?></option>
                        <?php } ?>
                      </select>
                      </div>
                    </div>

                    <div class="col-md-6 col-sm-12">
                      <div class="form-group">
                      <label>Flat Owner<span style="color:red;">*</span></label>
                      <input type="text" class="form-control" name="flat_owner" id="flat_owner" value="">
                      </div>
                    </div> -->
                <?php
                }
                ?>

                  
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                      <label>Visitor Name<span style="color:red;">*</span></label>
                      <input type="hidden" name="visitor_id" value="<?php echo esc_output($subscribers['visitor_id']); ?>" />
                      <?php if(isset($subscribers['visitor_id']) && $subscribers['visitor_id'] !='') { ?>
                        <input type="hidden" name="last_edited_by" value="<?php echo $this->session->userdata('admin')['user_id']; ?>" />
                      <?php } else { ?>
                        <input type="hidden" name="added_by" value="<?php echo $this->session->userdata('admin')['user_id']; ?>" />
                      <?php } ?>
                      <input type="text" class="form-control" name="visitor_name" value="<?php echo esc_output($subscribers['visitor_name']); ?>">
                    </div>
                  </div>
                  
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                    <label>Mobile Number<span style="color:red;">*</span></label>
                    <input type="text" class="form-control" name="mobile" value="<?php echo esc_output($subscribers['mobile']); ?>">
                    </div>
                  </div>
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                    <label>Email<span style="color:red;">*</span></label>
                    <input type="text" class="form-control" name="email" value="<?php echo esc_output($subscribers['email']); ?>">
                    </div>
                  </div>
                  <div class="col-md-6 col-sm-12">
                  <?php 
                      $flat_id = '';
                      $readonly = '';
                      if (isset($this->session->userdata('admin')['user_type']) && 
                          $this->session->userdata('admin')['user_type'] == 'Flat Owner') { 
                            $flat_id = $this->session->userdata('admin')['flats']['flat_id'];
                            $readonly = 'disabled';
                      }
                  ?>
                    <div class="form-group">
                    <label>Visit Unit<span style="color:red;">*</span></label>
                    <select class="form-control select2" id="visit_unit" name="visit_unit" <?php echo $readonly; ?> >
                      <option value=""><?php echo lang('none'); ?></option>
                      <?php 
                      foreach ($flats as $key => $value) { 
                      ?>
                        <option value="<?php echo esc_output($value['flat_id']); ?>" <?php sel($flat_id, $value['flat_id']); ?> ><?php echo esc_output($value['block_door'], 'html'); ?></option>
                      <?php } ?>
                    </select>
                    </div>
                  </div>
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                      <label>No of Members<span style="color:red;">*</span></label>
                      <input type="text" class="form-control" name="no_of_members" value="<?php echo esc_output($subscribers['no_of_members']); ?>">
                    </div>
                  </div>
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                      <label>Purpose of Visit<span style="color:red;">*</span></label>
                      <input type="text" class="form-control" name="purpose_of_visit" value="<?php echo esc_output($subscribers['purpose_of_visit']); ?>">
                    </div>
                  </div>
                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                      <label>Visiting Date<span style="color:red;">*</span></label>
                      <input class="form-control" type="text" name="visiting_date" id="visiting_date" readonly />
                    </div>
                  </div>

                  <div class="col-md-6 col-sm-12">
                    <div class="form-group">
                      <label>Parking<span style="color:red;">*</span></label></br>
                      <input type='radio' class='form-check-input' name='parking' id='parking_yes' value='Yes'>
                      <label class='form-check-labels'>Yes</label>
                      <input type='radio' class='form-check-input' name='parking' id='parking_no' value='No'>
                      <label class='form-check-labels'>No</label>
                    </div>
                  </div>
                  <div class="col-sm-12 no-padding">
                    <div class="col-md-6 col-sm-12">
                      <div class="form-group">
                        <label>Duration<span style="color:red;">*</span></label>
                        <input type="text" class="form-control" name="duration" value="<?php echo esc_output($subscribers['duration']); ?>">
                      </div>
                    </div>
                    <div class="col-md-6 col-sm-12">
                      <div class="form-group">
                        <label>Id Proof</label>
                        <input type="file" class="form-control" name="id_proof" value="<?php echo esc_output($subscribers['id_proof']); ?>">
                      </div>
                    </div>
                  </div>
                  


              <div class="box-footer">
                <button type="submit" class="btn btn-primary" id="admin_visitor_create_update_form_button">
                  <?php echo lang('save'); ?>
                </button>
              </div>
            </form>
          </div>
          <!-- /.box -->
        </div>
        

      </div>
      <!-- /.row -->
    </section>
    <!-- /.content -->
</div>
<!-- /.content-wrapper -->

<?php include(VIEW_ROOT.'/admin/layout/footer.php'); ?>

<!-- page script -->
<script src="<?php echo base_url(); ?>assets/admin/js/cf/visitor.js"></script>

</body>
</html>

