<div>
    <ul class="nav nav-tabs push" data-toggle="tabs">
        <li class="active"><a href="#tab-infos">Informations générales</a></li>
        <li><a href="#tab-categories">Catégories</a></li>
        <?php $i=0; ?>
        <?php foreach($languages as $language): ?>
        <?php $i++; ?>
        <li><a href="#tab-<?php echo $language->short; ?>"><i class="fa fa-flag"></i> <?php echo ucfirst($language->name); ?></a></li>
        <?php endforeach; ?>
        <li><a href="#tab-photos"><i class="fa fa-picture-o"></i> Photos</a></li>
        <?php /*
        <li><a href="#tab-files"><i class="fa fa-file-o"></i> Documents</a></li>
        */ ?>
        <li><a href="#tab-realisations">Réalisations</a></li>
    </ul>
    <div class="tab-content">
        <div class="tab-pane active" id="tab-infos">
	        <div class="form-group<?php if($errors->has('published')) { echo ' has-error'; } ?>">
			    <label class="col-md-3 control-label" for="published">Publié sur le site ?</label>
			    <div class="col-md-9">
			        <label class="switch switch-primary"><input type="checkbox" name="published" value="1" <?php echo (isset($produit) && $produit->published==1) ? 'checked' : ''; ?>><span></span></label>
			    </div>
			</div>
			<div class="form-group<?php if($errors->has('reference')) { echo ' has-error'; } ?>">
			    <label class="col-md-3 control-label" for="reference">Référence</label>
			    <div class="col-md-3">
			        <?php echo Form::text('ref', (isset($produit) && $produit->ref!='') ? $produit->ref : '', ['class' => 'form-control']); ?>

			    </div>
			</div>
	        <div class="form-group<?php if($errors->has('nouveaute')) { echo ' has-error'; } ?>">
			    <label class="col-md-3 control-label" for="nouveaute">Nouveauté ?</label>
			    <div class="col-md-9">
			        <label class="switch switch-primary"><input type="checkbox" name="nouveaute" value="1" <?php echo (isset($produit) && $produit->nouveaute==1) ? 'checked' : ''; ?>><span></span></label>
			    </div>
			</div>
			<div class="form-group<?php if($errors->has('promotion')) { echo ' has-error'; } ?>">
			    <label class="col-md-3 control-label" for="promotion">Promotion ?</label>
			    <div class="col-md-9">
			        <label class="switch switch-primary"><input type="checkbox" name="promotion" value="1" <?php echo (isset($produit) && $produit->promotion==1) ? 'checked' : ''; ?>><span></span></label>
			    </div>
			</div>
			<div class="form-group<?php if($errors->has('type')) { echo ' has-error'; } ?>">
			    <label class="col-md-3 control-label" for="type">Type de matériaux</label>
			    <div class="col-md-3">
			        <?php echo Form::select('type', ['ancien'=>'Matériaux ancien', 'neuf'=>'Matériaux neuf'], (isset($produit) ? $produit->type : NULL), ['class'=>'form-control']); ?>

			    </div>
			</div>
        </div>
        <div class="tab-pane" id="tab-categories">
        	<?php echo $__env->make('admin.produits._categories', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        </div>
        <div class="tab-pane" id="tab-photos">
        	<?php echo $__env->make('admin.produits._photos', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        </div>
        <?php /*
        <div class="tab-pane" id="tab-files">
        	@include('admin.produits._files')
        </div>
        */ ?>
        <?php foreach($languages as $language): ?>
        <div class="tab-pane" id="tab-<?php echo $language->short; ?>">
            <?php echo $__env->make('admin.produits._lang_form', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        </div>
        <?php endforeach; ?>
        <div class="tab-pane" id="tab-realisations">
        	<?php echo $__env->make('admin.produits._realisations', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>
        </div>
    </div>
</div>

<?php $__env->startSection('scripts'); ?>
@parent
<script type="text/javascript">
$('.datepicker').datepicker({
	format: 'yyyy-mm-dd'
});
</script>

<script src="<?php echo asset('assets/admin/js/ckeditor/ckeditor.js'); ?>"></script>
<script src="<?php echo asset('assets/admin/js/ckeditor/adapters/jquery.js'); ?>"></script>
<script type="text/javascript">
var nb_editor = <?=($i*1)+1?>;
var cfg_editor = {
	fullPage : false,
	height : 400,
	language: 'fr',
	toolbar: [
		{ name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source', '-', 'Save', 'NewPage', 'Preview', 'Print', '-', 'Templates' ] },
		{ name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
		{ name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
		{ name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
		'/',
		{ name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
		{ name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock', '-', 'BidiLtr', 'BidiRtl', 'Language' ] },
		{ name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
		{ name: 'insert', items: [ 'Image', 'Flash', 'Table', 'HorizontalRule', 'Smiley', 'SpecialChar', 'PageBreak', 'Iframe' ] },
		'/',
		{ name: 'styles', items: [ 'Format', 'FontSize' ] },
		//{ name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize' ] },
		{ name: 'colors', items: [ 'TextColor', 'BGColor' ] },
		{ name: 'tools', items: [ 'Maximize', 'ShowBlocks' ] },
		{ name: 'others', items: [ '-' ] },
		{ name: 'about', items: [ 'About' ] }
	],
	//contentsCss : '/assets/admin/js/ckeditor/samples/assets/outputxhtml/outputxhtml.css',
	contentsCss : ['//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css', '/css/style.css']
}
for (var i = 1; i < nb_editor; i++) {
	CKEDITOR.replace( 'editor1'+i, cfg_editor);
};
</script>

<script type="text/javascript">
$('#sortable2, #sortable3, #sortable4').sortable({
	placeholder: "ui-state-highlight"
});
// Evite le bug Firefox du clic sur le select
$('#sortable2 select, #sortable3 select, #sortable4 select').bind('click.sortable mousedown.sortable',function(ev){
	ev.target.focus();
});

var upload_script = '<?php echo URL::route('postproduitsfiles'); ?>';

$(document).ready(function() {
	if(typeof(upload_script)!='undefined' && upload_script!=''){
	    $('#file_upload2').uploadifive({
			'auto'             : true,
			'buttonClass'      : 'btn',
			'buttonText'       : 'Ajouter des images',
			'removeCompleted' : true,
			'queueID'          : 'queue2',
			'height'           : 'auto',
			'width'            : 'auto',
			'uploadScript'     : upload_script,
			'formData': {'type':'photo'},
			'onUploadComplete' : function(file, data) {
				var r = data.split("|");
				$('#sortable2').append('<li class="col-xs-12 col-sm-4"><input type="hidden" name="photos[]" value="'+r[0]+'"><p class="text-center"><img src="'+r[1]+'" alt=""></p><p class="text-center"><a href="#" class="btn btn-danger delete_file">Supprimer</a></p></li>');
				update_delete_nico();
			}
		});
		$('#file_upload3').uploadifive({
			'auto'             : true,
			'buttonClass'      : 'btn',
			'buttonText'       : 'Ajouter des documents',
			'removeCompleted' : true,
			'queueID'          : 'queue3',
			'height'           : 'auto',
			'width'            : 'auto',
			'uploadScript'     : upload_script,
			'formData': {'type':'file'},
			'onUploadComplete' : function(file, data) {
				var r2 = data.split("|");
				$('#sortable3').append('<li class="col-xs-12 col-sm-3"><input type="hidden" name="files[]" value="'+r2[0]+'"><p class="text-center">'+file.name+'</p><p><select name="language_'+r2[0]+'" class="form-control"><option value="0">Toutes les langues</option><option value="1">Français</option><option value="2">Anglais</option></select></p><p class="text-center"><a href="#" class="btn btn-danger delete_file">Supprimer</a></p></li>');
				update_delete_nico();
			}
		});
		$('#file_upload4').uploadifive({
			'auto'             : true,
			'buttonClass'      : 'btn',
			'buttonText'       : 'Ajouter des images',
			'removeCompleted' : true,
			'queueID'          : 'queue4',
			'height'           : 'auto',
			'width'            : 'auto',
			'uploadScript'     : upload_script,
			'formData': {'type':'realisation'},
			'onUploadComplete' : function(file, data) {
				var r = data.split("|");
				$('#sortable4').append('<li class="col-xs-12 col-sm-4"><input type="hidden" name="realisations[]" value="'+r[0]+'"><p class="text-center"><img src="'+r[1]+'" alt=""></p>'+r[2]+'<p class="text-center"><a href="#" class="btn btn-danger delete_file">Supprimer</a></p></li>');
				update_delete_nico();
			}
		});
    }
});
</script>

<?php $__env->stopSection(); ?>