<?php $__env->startSection('content'); ?>
<!-- companies content -->
<style type="text/css">
 .imageThumb {

   border: 2px solid;

    padding: 1px;

    width: 100%;

    cursor: pointer;

  }



  .pip {

    display: inline-block;

    margin: 10px 10px 0 0;

    width: 30%;

    vertical-align: top;

}

.remove {

    width: 100%;

    display: block;

    background: #444;

    border: 1px solid black;

    color: white;

    text-align: center;

    cursor: pointer;

    }



    .position {

      width: 100%;

    }
 .clr {
  padding:5px;
  border: 1px solid #CCC;
 }
</style>
<div class="right_col" role="main">
  <div class="row x_panel">
    <div class="col-md-12 col-sm-12 col-xs-12">
    <h1>Companies</h1>
<?php if(isset($data)){ ?>
<form action="<?php echo url('/'); ?>/admin/companies/edit" id="" class="form-horizontal " method="post" enctype="multipart/form-data">
<?php echo e(csrf_field()); ?>

<input type="hidden" name="comp_id" value="<?php echo $data->comp_id; ?>">


<!-- Comp_name Start -->
<div class="form-group">
  <label for="comp_name" class="col-sm-3 control-label"> Company <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <input type="text" class="form-control" id="comp_name" name="comp_name" value="<?php echo e($data->comp_name); ?>">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_name")); ?></div>
      </div>
</div> 
<!-- Comp_name End -->



    <!-- Comp_logo Start -->
    <div class="form-group">
      <label for="comp_logo" class="control-label col-md-3"> Logo </label>
        <div class="col-md-4">
          <input type="file" id="comp_logo" name="comp_logo" class="form-control" /><br>
          <div class="field" align="left">
          <?php if($data->comp_logo!='' && $data->comp_logo!=null){
            echo '<img src="'.url('/')."/uploads/company_profile/{$data->comp_logo}".'" style="width:100px;">'; 
            } ?>
            <input type="hidden" name="old_comp_logo" value="<?php echo $data->comp_logo; ?>">
          </div>
      </div>
      <div class="col-sm-5">
          <div class="label label-danger"><?php echo e($errors->first("comp_logo")); ?></div>
      </div>
    </div>
    <!-- Comp_logo End -->

    

<!-- Comp_email Start -->
<div class="form-group">
  <label for="comp_email" class="col-sm-3 control-label"> Email <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <input type="email" class="form-control" id="comp_email" name="comp_email" value="<?php echo e($data->comp_email); ?>">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_email")); ?></div>
      </div>
</div> 
<!-- Comp_email End -->


<!-- Comp_phone Start -->
<div class="form-group">
  <label for="comp_phone" class="col-sm-3 control-label"> Mobile <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <input type="number" class="form-control" id="comp_phone" name="comp_phone" value="<?php echo e($data->comp_phone); ?>" onkeydown="if(this.value.length==10 && event.keyCode!=8 && event.keyCode!=9) return false;" oninput="this.value = this.value.replace(/[^0-9.]/g, '').replace(/(\..*)\./g, '$1');">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_phone")); ?></div>
      </div>
</div> 
<!-- Comp_phone End -->

<!-- Comp_ceo Start -->
<div class="form-group">
  <label for="comp_ceo" class="col-sm-3 control-label"> Ceo <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <input type="text" class="form-control" id="comp_ceo" name="comp_ceo" value="<?php echo e($data->comp_ceo); ?>">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_ceo")); ?></div>
      </div>
</div> 
<!-- Comp_ceo End -->



	<!-- Comp_industry Start -->
    <div class="form-group">
        <label for="user_id" class="control-label col-md-3"> Industry </label>
          <div class="col-md-4">
          <select id="comp_industry" name="comp_industry[]" class="form-control select2" multiple>
            <option value="">Select</option>
            <?php
              foreach ($industries as $value) {
                $selected = in_array($value->indu_id, explode(',', $data->comp_industries))?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->indu_id.'"> '.$value->indu_title.'</option>';
              }
            ?>
          </select>
        </div>
        <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_industry")); ?></div>
      </div>
    </div>
      <!-- Comp_industry End -->



<!-- Comp_ownership_type Start -->
<div class="form-group">
  <label for="comp_ownership_type" class="col-sm-3 control-label"> Ownership Type </label>
  <div class="col-sm-4">
    <select class="form-control" id="comp_ownership_type" name="comp_ownership_type">
        <option value="">Select</option>
        <option value="1" <?php if($data->comp_ownership_type=='1'){echo 'selected';}?>>Sole Proprietorship</option>
        <option value="2" <?php if($data->comp_ownership_type=='2'){echo 'selected';}?>>Public</option>
        <option value="3" <?php if($data->comp_ownership_type=='3'){echo 'selected';}?>>Private</option>
        <option value="4" <?php if($data->comp_ownership_type=='4'){echo 'selected';}?>>Government</option>
        <option value="5" <?php if($data->comp_ownership_type=='5'){echo 'selected';}?>>NGO</option>
      </select>
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_ownership_type")); ?></div>
      </div>
</div> 
<!-- Comp_ownership_type End -->





<!-- Comp_location Start -->
<div class="form-group">
  <label for="comp_location" class="col-sm-3 control-label"> Location <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <textarea class="form-control" id="comp_location" name="comp_location"><?php echo e($data->comp_location); ?></textarea>
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_location")); ?></div>
      </div>
</div> 
<!-- Comp_location End -->

<!-- Comp_state Start -->
<div class="form-group">
  <label for="comp_state" class="col-sm-3 control-label"> State <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <select id="comp_state" name="comp_state" class="form-control select2" onchange="getCity(this.value)">
       <option value="">Select</option>
            <?php
              foreach ($states as $value) {
                $selected = $data->comp_state==$value->id?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->id.'"> '.$value->name.'</option>';
              }
            ?>
          </select>
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_state")); ?></div>
      </div>
</div> 
<!-- Comp_state End -->

<!-- Comp_city Start -->
<div class="form-group">
  <label for="comp_city" class="col-sm-3 control-label"> City <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <select id="comp_city" name="comp_city" class="form-control select2">
      <option value="">Select</option>
            <?php
              foreach ($cities as $value) {
                $selected = $data->comp_city==$value->id?'selected="selected"':'';
                echo '<option '.$selected.' value="'.$value->id.'"> '.$value->name.'</option>';
              }
            ?>
          </select>
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_city")); ?></div>
      </div>
</div> 
<!-- Comp_city End -->

<!-- Comp_website Start -->
<div class="form-group">
  <label for="comp_website" class="col-sm-3 control-label"> Website <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <input type="text" class="form-control" id="comp_website" name="comp_website" value="<?php echo e($data->comp_website); ?>">
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_website")); ?></div>
      </div>
</div> 
<!-- Comp_website End -->



<!-- Comp_no_of_emp Start -->
<div class="form-group">
  <label for="comp_no_of_emp" class="col-sm-3 control-label"> No Of Employee </label>
  <div class="col-sm-4">
    <input type="text" class="form-control" id="comp_no_of_emp" name="comp_no_of_emp" value="<?php echo e($data->comp_no_of_emp); ?>" >
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_no_of_emp")); ?></div>
      </div>
</div> 
<!-- Comp_no_of_emp End -->



<!-- Comp_establishment Start -->
<div class="form-group">
  <label for="comp_establishment" class="col-sm-3 control-label"> Establishment </label>
  <div class="col-sm-4">
    <input type="text" class="form-control year" id="comp_establishment" name="comp_establishment" value="<?php echo e($data->comp_establishment); ?>" >
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_establishment")); ?></div>
      </div>
</div> 
<!-- Comp_establishment End -->



<!-- Comp_no_of_offices Start -->
<div class="form-group">
  <label for="comp_no_of_offices" class="col-sm-3 control-label"> No Of Offices </label>
  <div class="col-sm-4">
    <input type="text" class="form-control" id="comp_no_of_offices" name="comp_no_of_offices" value="<?php echo e($data->comp_no_of_offices); ?>" >
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_no_of_offices")); ?></div>
      </div>
</div> 
<!-- Comp_no_of_offices End -->





<!-- Comp_details Start -->

<div class="form-group">
  <label for="comp_details" class="col-sm-3 control-label">Company Details <span style="color: red">*</span></label>
  <div class="col-sm-4">
    <textarea class="form-control" id="comp_details" name="comp_details" minlength="100"><?php echo e($data->comp_details); ?></textarea>
  </div>
  <div class="col-sm-5">
         <div class="label label-danger"><?php echo e($errors->first("comp_details")); ?></div>
      </div>
</div> 

<!-- Comp_details End -->


	<!-- Comp_status Start -->
	 <div class="form-group">
        <label class="control-label col-md-3">Status</label>                    
         <div class=" col-md-4 switch">
                    <div class="onoffswitch">
     <input type="checkbox" class="onoffswitch-checkbox"  data-on-label="Yes" data-off-label="No"  name="comp_status" value="1" id="comp_status" <?php if($data->comp_status == 1){echo "checked=checked";}?> style="width:20px; height:20px;"/>
                    </div>
                </div>
      </div>
      <!-- Comp_status End -->


  <div class="form-group">
  <div class="col-sm-3">
  </div>
   <div class="col-sm-6">
    <button type="reset" class="btn btn-default ">Reset</button>
    <button type="submit" class="btn btn-info ">Update</button>
   </div>
  </div>
</form>
<?php } else{
    echo '<h2 align="center" class="text-danger">No record found!</h2>';
  } ?>
    </div>
  </div>
</div>
<!-- /companies content -->
<script type="text/javascript">
  function previewImages() 
  { 
      if (this.files) $.each(this.files, readAndPreview);
      
      function readAndPreview(i, file) 
      {
      if (!/\.(jpe?g|png)$/i.test(file.name))
      {
      return alert(file.name +" is not allowed type.");
    } // else...
      // console.log(file.name);
      var reader = new FileReader();
    i=i+1;
      
      $(reader).on("load", function() 
      {
          var name_file=file.name;
          name_file  = name_file.replace(/\s/g, "#");
      var j = $('.field .pip').length;
      j=j+1;
      // console.log(j);
      $('.field').append($("<span id=\"pip"+j+"\" class='pip'>" +
              "<img class=\"imageThumb\" src=\"" + this.result + "\" />" +
              "<br/><span class=\"remove\" onclick='remove(pip"+j+", \"wi_banner_image\")'>Remove image</span> <input name='banner_image' type='hidden' value="+name_file+" readonly>" +"</span>"+
              "</span>"));
      });

    reader.readAsDataURL(file);
      }
    }
    
  $('#wi_banner_image').on("change", previewImages);

   function remove(span,selector)
   {
      $(span).remove();
      $('#'+selector).val('');
   }

   function getCity(id)
   {
     $.ajax({
      type:"post",
      url:"<?php echo e(url('/')); ?>/admin/getCity",
      data:{"_token":"<?php echo e(csrf_token()); ?>",'state_id':id},
      dataType:"json",
      success:function(res)
      {
        console.log(res);
        var city = ''
        if(res.length>0)
        {
          city += '<option value="">Select</option>';
          for(var i=0;i<res.length;i++)
          {
            city += '<option value="'+res[i].id+'">'+res[i].name+'</option>';
          }
        }
        $('#comp_city').html(city);
      }
     });
   }
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('master', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>