<link rel="stylesheet" href="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.bootstrap.min.css">
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/jquery.dataTables.min.js"></script>
<div class="content-wrapper">
            <!-- Content Header (Page header) -->
            <section class="content-header">
                <h1>
                   Add/Edit Companies
                </h1>
                <ol class="breadcrumb">
                    <li><a href="<?php echo base_url();?>"><i class="fa fa-home"></i>Dashboard</a></li>
                    <li class="active">Add/Edit/Delete Companies</li>
                </ol>
            </section>
            <!-- Main content -->
            <div class="content">
                <div class="container-fluid">
                    <!-- Basic forms -->
                    <div class="row">
                        <div class="col-md-8" <?php if(!$this->uri->segment(3)){?> style="display:none;" id="showcom"<?php }?>>
                        <?php if($this->session->flashdata("msg")){echo $this->session->flashdata("msg");}?>
                            <div class="panel">
                                <h3 class="panel-heading">Add/Edit Companies</h3>
                                <div class="panel-body">
                                    <?php if($this->uri->segment(3)){?>
            <form role="form" action="<?php echo base_url();?>admin/update_company_submit" enctype="multipart/form-data" method="post">		
            <div class="row">
            <div class="col-md-6">
			<div class="form-group label-floating">
            <input type="hidden" name="cid" value="<?php echo $company->cid;?>" />
                    	<label class="control-label">Company Name</label>
                        <input type="text" name="com_name" value="<?php echo $company->com_name;?>" required id="com_name" class="form-control" tabindex="0">
					</div>
                    </div>
                    
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">File Data Limit (in MP)</label>
<input type="text" name="data_limit" required  value="<?php echo $company->data_limit;?>" class="form-control" >
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
    <label>
        <input type="checkbox" name="video" value="video" <?php if($company->video_chat!=""){echo "checked";}?> > Video Chat
    </label>
</div>
<div class="checkbox">
    <label>
        <input type="checkbox" name="payments" value="payments" <?php if($company->payments!=""){echo "checked";}?> > Payments
    </label>
</div>
</div>
                    </div>
            <div class="row">
				<div class="col-xs-12 col-sm-6 col-md-6">
					<div class="form-group label-floating">
                    	<label class="control-label">Contact Person Name</label>
                        <input type="text" name="com_con_name" value="<?php echo $company->com_con_name;?>" required id="first_name" class="form-control" tabindex="1">
					</div>
                    <div class="form-group label-floating">
                        <label class="control-label">Company Email</label>
                        <input type="email" name="com_email" value="<?php echo $company->com_email;?>" id="email" required class="form-control" tabindex="4">
                    </div>
                    <div class="form-group label-floating">
                        <label class="control-label">Company Contact Number</label>
                        <input type="text" name="com_contact" id="mobile" value="<?php echo $company->com_contact;?>" required class="form-control"  tabindex="5">
                    </div>
                    <div class="form-group label-floating">
                        <label class="control-label">Short Description</label>
                        <textarea class="form-control" name="com_desc" rows="8"><?php echo $company->com_desc;?></textarea>
                    </div>
				</div>
				<div class="col-xs-12 col-sm-6 col-md-6">
                <div class="row">
                 <div class="form-group label-floating col-md-6">
            <label class="control-label">Max Groups</label>
            <input type="text" name="max_groups" value="<?php echo $company->max_groups;?>"  required class="form-control" tabindex="4">
                    </div>
                     <div class="form-group label-floating col-md-6">
            <label class="control-label">Max Users</label>
            <input type="text" name="max_users" value="<?php echo $company->max_users;?>" required class="form-control" tabindex="4">
                    </div>
                </div>
                	<h4 class="text-primary">Add Company Logo</h4>
                        <input type="file" name="img"  class="btn btn-primary" id="imgInp" />
                        <input type="hidden" name="oldimg" value="<?php echo $company->com_logo;?>" />
<img id="blah" src="<?php echo base_url();?>newadminassets/users/<?php echo $company->com_logo;?>" alt="Identity" class="img img-responsive" height="150" />
				</div>
			</div>
			<span class="text-danger" id="error"></span>
			<input type="submit" id="register" value="Update Company Details" class="btn btn-primary" tabindex="7">
			<a href="<?php echo base_url();?>admin/list_companies" class="btn btn-default addcom">Cancel</a>
		</form>
		<?php }else{?>
        <form role="form" action="<?php echo base_url();?>admin/company_submit" enctype="multipart/form-data" method="post">
<div class="row">
<div class="col-md-6">
<div class="form-group label-floating">
<label class="control-label">Company Name</label>
<input type="text" name="com_name" required id="com_name" class="form-control" tabindex="0">
</div>
</div>
<div class="col-md-3">
<div class="form-group label-floating">
<label class="control-label">File Data Limit (in MB)</label>
<input type="text" name="data_limit" required  class="form-control" >
</div>
</div>
<div class="col-md-3">
<div class="checkbox">
    <label>
        <input type="checkbox" name="video" value="video" checked="checked" > Video Chat
    </label>
</div>
<div class="checkbox">
    <label>
        <input type="checkbox" name="payments" value="payments" checked="checked" > Payments
    </label>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="form-group label-floating">
<label class="control-label">Contact Person Name</label>
<input type="text" name="com_con_name" required id="first_name" class="form-control" tabindex="1">
</div>
<div class="form-group label-floating">
<label class="control-label">Company Email</label>
<input type="email" name="com_email" id="email" required class="form-control" tabindex="4">
</div>
<div class="form-group label-floating">
<label class="control-label">Company Contact Number</label>
<input type="text" name="com_contact" id="mobile" required class="form-control"  tabindex="5">
</div>
<div class="form-group label-floating">
<label class="control-label">Password</label>
<input type="password" name="c_password" required id="pass" class="form-control"  tabindex="6">
</div>
<div class="form-group label-floating">
<label class="control-label">Confirm Password</label>
<input type="password" name="password_confirmation" required id="cpass" class="form-control" tabindex="6">
</div>
<div class="form-group label-floating">
<label class="control-label">Short Description</label>
<textarea class="form-control" name="com_desc" rows="4"></textarea>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<div class="row">
                 <div class="form-group label-floating col-md-6">
                        <label class="control-label">Max Groups</label>
                        <input type="text" name="max_groups"   required class="form-control" tabindex="4">
                    </div>
                     <div class="form-group label-floating col-md-6">
                        <label class="control-label">Max Users</label>
                        <input type="text" name="max_users"  required class="form-control" tabindex="4">
                    </div>
                </div>
<h4 class="text-primary">Add Company Logo</h4>
<input type="file" name="img"  class="btn btn-primary" id="imgInp" />
<img id="blah" src="<?php echo base_url();?>newadminassets/users/company.jpg" alt="Identity" class="img img-responsive" height="150" />

</div>

</div>

<span class="text-danger" id="error"></span>
<input type="submit" id="register" value="Register Company" class="btn btn-primary" tabindex="7">
<button type="button" class="btn btn-default addcom">Cancel</button>
</form>
        <?php }?>
                                </div>
                            </div>
                        </div>
                        <div class="col-md-12">
                <a href="#" id="" class="btn btn-xs btn-success addcom"><i class="fa fa-building"></i> Add New Company</a>
                            <div class="panel">
               
                                <h3 class="panel-heading">List of All Companies</h3>
                                <div class="panel-body">
                                      <table class="table table-striped table-responsive table-bordered dataTable" id="example-2">
                                         <tr><th>S.No.</th><th>Logo</th><th>Company Name</th><th>Contact Person</th><th>Groups/Users</th><th>Email/Phone</th><th>Action</th></tr>
                                        <tbody>
                                        <?php $i=1;foreach($companies as $u){?>
                                        <tr>
                                        	<td><?php echo $i;?></td>
                                        	<td width="70px"><img class="img img-responsive" src="<?php echo base_url();?>newadminassets/users/<?php echo $u->com_logo;?>" /></td>
                                            <td><?php echo $u->com_name;?></td>
                                            <td><?php echo $u->com_con_name;?></td>
                                            <td><?php echo $u->max_groups.'/'.$u->max_users.'<br/>Data : '.$u->data_limit;?> MB</td>
                                            <td><i class="fa fa-envelope"></i> <?php echo $u->com_email;?><br/><i class="fa fa-mobile"></i> <?php echo $u->com_contact;?></td>
                                            
                                            <td>
                                            <a href="<?php echo base_url();?>admin/groups/company/<?php echo $u->cid;?>" class="btn btn-xs btn-info"><i class="fa fa-users"></i> <?php echo $this->db->get_where("groups",array("cid"=>$u->cid))->num_rows();?> Groups</a>
                                            <a href="<?php echo base_url();?>admin/list_users/users/<?php echo $u->cid;?>" class="btn btn-xs btn-primary"><i class="fa fa-users"></i> <?php echo $this->db->get_where("users",array("company"=>$u->cid))->num_rows();?> Users</a>
                                            <a href="#" id="<?php echo $u->cid;?>" class="btn btn-success btn-xs open_popup" data-toggle="modal" data-target="#myModal"><i class="fa fa-lock"></i></a>
                                            <a href="<?php echo base_url();?>admin/list_companies/<?php echo $u->cid;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>
                                         <a href="<?php echo $u->cid;?>" class="btn btn-xs btn-danger com_delete"><i class="fa fa-trash-o"></i></a></td>
                                        </tr>
                                        <?php $i++;}?>
                                        </tbody>
                                        <tfoot>
                                           <tr><th>S.No.</th><th>Logo</th><th>Company Name</th><th>Contact Person</th><th>Groups/Users</th><th>Email/Phone</th><th>Action</th></tr>
                                        </tfoot>
                                    </table>
                                </div>
                            </div>
                        </div>        
                    </div>
                    <div class="modal fade" id="myModal" role="dialog">
                    <div class="modal-dialog modal-sm">
                      <div class="modal-content">
                        <div class="modal-header">
                          <button type="button" class="close" data-dismiss="modal">&times;</button>
                          <h4 class="modal-title"><b id="agentname" class="text-success"></b> Password</h4>
                        </div>
                        <div class="modal-body">
                          <form class="form" action="" method="post" id="changepass">
                          <input type="hidden" name="uid" id="agentid" value="" />
                          	<div class="form-group label-floating">
                            <label class="control-label">New Password</label>
                                <input type="password" name="npass" required id="edit_pass" class="form-control" >
                            </div>
                            <div class="form-group label-floating">
                            <label class="control-label">Confirm Password</label>
                                <input type="password" name="cpass" required id="edit_pass_change" class="form-control">
                            </div>
                            <b class="text-danger" id="passch"></b>
                            <button type="submit" class="btn btn-warning">Change Password</button>
                            <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
                          </form>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
            </div>
            <!-- /.content -->
        </div>
         <footer class="main-footer">
            <!-- To the right -->
           <!-- <div class="pull-right hidden-xs">
                Developed by <i class="fa fa-heart"></i> Floatin
            </div>-->
            <!-- Default to the left -->
            <strong>Copyright &copy; 2018 <a href="#">Docs Manage</a>.</strong> All rights reserved.
        </footer>
    </div>
   <script>
   function readURL(input) {
        if (input.files && input.files[0]) {
			$(".identity_next").attr("disabled",true);
            var reader = new FileReader();
            
            reader.onload = function (e) {
                $('#blah').attr('src', e.target.result);
				$(".identity_next").removeAttr("disabled");
            }
            reader.readAsDataURL(input.files[0]);
        }
    }
    
    $("#imgInp").change(function(){
        readURL(this);
    });
	
	$(document).ready(function(){
		$(".open_popup").click(function(e){e.preventDefault();
			var name=$(this).attr("href");//alert(name);
			$("#passch").html('');
			$("#edit_pass").val('');
			$("#edit_pass_change").val('');
			var id=$(this).attr("id");
			$("#agentid").val(id);
			$("#agentname").text(name);
		});
		$("#changepass").submit(function(e){e.preventDefault();//alert("Asdf"); 
			var formdata=$(this).serialize();
			$.ajax({
			 type: "POST",
			 url: '<?php echo base_url();?>admin/company_change_pass',
			 data: {formdata:formdata},
			 success: function(res){
			//alert(res);
			$("#passch").html(res);
			}
			 }); 
		});
		
		$(".addcom").click(function(){$("#showcom").slideToggle();});
		$(".com_delete").click(function(e){e.preventDefault();
			 if (!confirm("Sure you want to delete?")){
				  return false;
				}
			var id=$(this).attr("href");$(this).closest("tr").remove();
			$.ajax({
							 type: "POST",
							 url: '<?php echo base_url();?>admin/com_delete',
							 data: {id:id},
							 success: function(response){
								 //alert(response);
							 }
							 });
		});
	});
</script>
	 <script src="<?php echo base_url();?>newadminassets/plugins/js/countUp.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/raphael.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/morris.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/jquery-jvectormap-2.0.2.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/jquery-jvectormap-world-mill-en.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/material.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/ripples.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/rendro-easy-pie-chart/dist/jquery.easypiechart.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/Chart.bundle.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/js/jquery.slimscroll.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/dashboard.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/widgets.js"></script>
    
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/jquery.dataTables.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.responsive.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.bootstrap.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/dataTables.buttons.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/jszip.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/pdfmake.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/vfs_fonts.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.html5.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.print.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/plugins/datatables/buttons.colVis.min.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/datatables.js"></script>
    <script src="<?php echo base_url();?>newadminassets/js/app.js"></script>

    <!-- Color Switcher -->
    
    <!-- END Skin switcher -->


</body>

