 <?php $__env->startSection('content'); ?>
<?php Fun::lang() ?>
<div class="title-page">
    <div class="page-bar">
        <ul class="page-breadcrumb">
            <li><a href="#"><i class="fa fa-dashboard"></i> Dashboard</a></li>
            <li><a href="#">Construction</a></li>
            <li><a href="#">Set Up Information</a></li>
            <li><a href="#">Product List</a></li>
            <li><a href="#">Create</a></li>
        </ul>
    </div>
</div>
<div class="page">
    <div class="top-content">
        <div class="row">
            <div class="col-sm-12 col-xs-12">
                <div class="title-page">
                    <div class="pull-left">
                        <h3>Create Product</h3>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="row">
        <div class="col-sm-12 col-xs-12">

            <div class="form-wrapper">
                <?php echo Form::open(array('route' => 'construction-product.store','method'=>'POST', 'enctype'=>'multipart/form-data')); ?>

                <div class="row">
                    <div class="form-group col-sm-4 col-xs-12">
                        <label>Code</label>
                        <?php echo Form::text('code', null, array('placeholder' => 'Code','class' => 'form-control')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Name</label>
                        <?php echo Form::text('name', null, array('placeholder' => 'Name','class' => 'form-control','required')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label>Model</label>
                        <?php echo Form::text('model', null, array('placeholder' => 'Model','class' => 'form-control')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Category</label>
                        <?php echo Form::select('category_id', $categories, null, ['class' => 'form-control select2','required','id'=>'category-id']); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Sub Category</label>
                        <?php echo Form::select('brand_id', [], null, ['class' => 'form-control select2','required','id'=>'sub-category-id']); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label>Unit Price($)</label>
                        <?php echo Form::text('current_price', null, array('placeholder' => 'Unit Price','class' => 'form-control number-only')); ?>

                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label class="required">Unit</label>
                        <select name="unit_id" class="form-control select2" required>
                            <?php echo $unit_option; ?>

                        </select>`
                    </div>
                    <div class="form-group col-sm-4 col-xs-12">
                        <label>Description</label>
                        <?php echo Form::textarea('description', null, array('placeholder' => 'Description','class' => 'form-control','rows'=>'2')); ?>

                    </div>
                    <div class="form-group col-sm-12 col-xs-12">
                        <label>Feature Image ( <a href="javascript:void(0)" onclick="add_more_picture(this)" data-count = '0'>Add more</a> )</label>
                        <div class="form-group col-sm-12 col-xs-12 panel panel-default append-image">
                            <br/>
                            <div class="imageupload" style="float: left;" >
                                <img src="<?php echo e(asset('assets/images/default.png')); ?>" class="hide_img" width="100px">
                                <div class="file-tab panel-body">
                                    <label class="btn button_warning btn-file">
                                        <span>Browse</span>
                                        <input type="file" name="image[]">
                                    </label>
                                    <button type="button" class="btn button_danger">Remove</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-sm-12 col-xs-12">
                        <div class="form-group">
                            <button type="submit" class="button_sm button_primary pull-right"><span class="fa fa-save"></span> Save</button>
                            <button type="button" onClick="javascript:history.go(-1)" class="button_sm button_warning pull-right">
                                <span class=" fa fa-arrow-circle-left"></span> Back</button>
                        </div>
                    </div>
                </div>

                <?php echo Form::close(); ?>

            </div>
        </div>
    </div>
</div>
<?php $__env->stopSection(); ?> <?php $__env->startSection('js'); ?>
<script>
    function add_more_picture(obj){
        let count = $(obj).attr('data-count');
        $(obj).attr('data-count',Number(count+1));
        $('.append-image').append(`
                        <div class="imageupload${count}" style="float: left;">
                            <img src="<?php echo e(asset('assets/images/default.png')); ?>" class="hide_img" width="100px">
                            <div class="file-tab panel-body">
                                <label class="btn button_warning btn-file">
                                    <span>Browse</span>
                                    <input type="file" name="image[]">
                                </label>
                                <button type="button" class="btn button_danger">Remove</button>
                            </div>
                        </div>`);
                        $(".imageupload"+count).imageupload();
    }
    $(document).on("change","#category-id",function(){
        $("#main-spinner").show();
        var route = "<?php echo e(route('get_sub_cagegory_product',':id')); ?>";
        route = route.replace(":id",$(this).val());
        $.ajax({
            url:route,
            type:"get",
            dataType:"JSON",
            success:function(data){
                $("#main-spinner").hide();
                $("#sub-category-id").empty();
                $("#sub-category-id").append("<option value=''>Please Select</option>");
                $.each(data,function(index,value)
                {
                    $("#sub-category-id").append(`<option value='${value.id}'>${value.name}</option>`);
                });
            },
            complete:function(){
                $("#main-spinner").hide();
            }
        });
    });
</script>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('adminlte::page', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>