<script>
 /**
 *  BootTree Treeview plugin for Bootstrap.
 *
 *  Based on BootSnipp TreeView Example by Sean Wessell
 *  URL:	http://bootsnipp.com/snippets/featured/bootstrap-30-treeview
 *
 *	Revised code by Leo "LeoV117" Myers
 *
 */
$.fn.extend({
	treeview:	function() {
		return this.each(function() {
			// Initialize the top levels;
			var tree = $(this);
			
			tree.addClass('treeview-tree');
			tree.find('li').each(function() {
				var stick = $(this);
			});
			tree.find('li').has("ul").each(function () {
				var branch = $(this); //li with children ul
				
				branch.prepend("<i class='tree-indicator glyphicon glyphicon-chevron-right'></i>");
				branch.addClass('tree-branch');
				branch.on('click', function (e) {
					if (this == e.target) {
						var icon = $(this).children('i:first');
						
						icon.toggleClass("glyphicon-chevron-down glyphicon-chevron-right");
						$(this).children().children().toggle();
					}
				})
				branch.children().children().toggle();
				
				/**
				 *	The following snippet of code enables the treeview to
				 *	function when a button, indicator or anchor is clicked.
				 *
				 *	It also prevents the default function of an anchor and
				 *	a button from firing.
				 */
				branch.children('.tree-indicator, button, a').click(function(e) {
					branch.click();
					
					e.preventDefault();
				});
			});
		});
	}
});

/**
 *	The following snippet of code automatically converst
 *	any '.treeview' DOM elements into a treeview component.
 */
$(window).on('load', function () {
	$('.treeview').each(function () {
		var tree = $(this);
		tree.treeview();
	})
})
 </script>
<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/Delete Audios
                </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 Audios</li>
                </ol>
            </section>
            <!-- Main content -->
            <div class="content">
                <div class="container-fluid">
                    <!-- Basic forms -->
                    <div class="row">
                        <div class="col-md-7" <?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 Audios</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/add_audio" enctype="multipart/form-data" method="post">
<div class="row">
	<div class="col-md-6">
    	<h4 class="text-info">Choose Categories</h4>
        <div class="treeview">
               <ul>
                	<?php $cc=$this->db->get("category")->result();
									foreach($cc as $c){?> 
                    <li id="li<?php echo $c->cid;?>" style="list-style:none;">
                    	<a href="#" id="<?php echo $c->cid;?>" style="font-weight:600;"><?php echo $c->cat_name;?></a>
                        <?php $c2=$this->db->get_where("subcategory",array("cid"=>$c->cid))->result();
							foreach($c2 as $c3){?><ul>
                            	 <li id="li<?php echo $c3->sid;?>" style="list-style:none;">
                                 
                                 <div class="checkbox" style="margin:5px;">
    <label>
        <input type="checkbox" name="cats[]" value="<?php echo $c->cid.'-'.$c3->sid;?>" > <?php echo $c3->subcat_name;?>
    </label>
</div>
                                 	
                                 </li>
                            </ul><?php }?>
                	</li>
                    <?php }?></ul>
                
            </div>
    </div>
    <div class="col-md-6">
     
    
    	<h4 class="text-primary">Upload Track(s)</h4>
       <div class="checkbox">
        <label>
            <input type="checkbox" name="zip" value="zip"  id="zip"> Album 
        </label>
        <label>
            <input type="checkbox" name="download" value="download" > Downloadable
        </label>
     </div>
    	 <div class="form-group label-floating" id="album" style="display:none;">
            <label class="control-label">Album Name/Title</label>
            <input type="text" name="album"   class="form-control" >
        </div>
		<input type="file" name="audio[]" multiple class="btn btn-primary" style="width: 250px;" />
    	<div class="form-group label-floating">
        <select class="form-control" name="artist">
        	<option value="">Select Artist</option>
            <?php foreach($arts as $a){?>
        	<option value="<?php echo $a->aid;?>"><?php echo $a->a_name;?></option>
            <?php }?>
        </select>
        </div>
        <div class="form-group label-floating">
        <select class="form-control" name="genre">
        	<option value="">Select Genre</option>
        	<option value="Rock">Rock</option>
        	<option value="Dance">Dance</option>
        	<option value="HipHop">HipHop</option>
        </select>
        </div>
        <div class="form-group label-floating">
        <label class="control-label">Language</label>
        <input type="text" name="lang" required id="com_name" class="form-control" tabindex="0">
        </div>
    </div>
</div>
<span class="text-danger" id="error"></span>
<input type="submit" id="register" value="Add Music" class="btn btn-warning pull-right" tabindex="7">
</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 Music Track</a>
                            <div class="panel">
               
                                <h3 class="panel-heading">List of All Music Tracks</h3>
                                <div class="panel-body">
                                      <table class="table table-striped table-responsive table-bordered dataTable" id="example-2">
          <thead> <tr><th>S.No.</th><th>Title</th><th>Track Details</th><th>Year</th><th>Genre</th><th>Language</th><th>PlayTime & Size</th><th>Category</th><th>Downloads</th><th>Action</th></tr></thead>
                                        <tbody>
                                        <?php $i=1;foreach($audios as $aud){?>
                                        <tr>
                                        <td><?php echo $i;?></td>
                                        <td><?php echo $aud->aud_title;?></td>
                                        <td><span class="label label-info">Artist - <?php echo $aud->meta_artist;?></span><br/>
                                        <span class="label label-primary">Album - <?php echo $aud->meta_album;?></span><br/>
                                        <span class="label label-success">Genre - <?php echo $aud->meta_genre;?></span></td>
                                        <td><?php echo $aud->meta_year;?></td>
                                        <td><?php echo $aud->aud_genre;?></td>
                                        <td><?php echo $aud->aud_lang;?></td>
                                        <td><?php echo round($aud->aud_size/1024,1);?> MB</td>
                           <td><a href="<?php echo '#';//$aud->aud_id;?>" class="btn btn-xs btn-success"><i class="fa fa-eye"></i></a></td>
                                        <td>0</td>
                                        <td>
<a href="<?php echo base_url();?>admin/audios/<?php echo $aud->aud_id;?>" class="btn btn-xs btn-warning"><i class="fa fa-edit"></i></a>
<a href="<?php echo $aud->aud_id;?>" class="btn btn-xs btn-danger track_delete"><i class="fa fa-trash-o"></i></a></td>
                                        </tr>
                                        <?php $i++;}?>
                                        </tbody>
                                        <tfoot>
                                            <tr><th>S.No.</th><th>Title</th><th>Track Details</th><th>Genre</th><th>Language</th><th>PlayTime & Size</th><th>Category</th><th>Downloads</th><th>Action</th></tr>
                                        </tfoot>
                                    </table>
                                </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>
   	$(document).ready(function(){
		$("#zip").click(function(){
			$("#album").slideToggle();
		});
		$(".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();});
		$(".track_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/track_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>

