<?php $__env->startSection('content'); ?>
<div class="container">
    <section class="content">
        <div class="row">
        	<div class="col-md-12 col-sm-offset-0">
            	<div class="box box-success">
                	<div class="box-header with-border">
                    	<h3 class="box-title">Ticket </h3> 
                	</div>
                	<div class="box-body">

                		<div class="col-sm-12">
    						
    						<div class="card">
    							<div class="card-header">
    								<h3 class="text-center"><i class="fa fa-pencil"></i> Create Form of <code><b>Ticket</b></code> </h3>
    							</div>
                                <span style="display: none;" id='wd_today_count'><?php echo e($wdTodayCount); ?></span>
                                <span style="display: none;" id="ymd"><?php echo e(date('ymd')); ?></span>
    							<div class="card-body">
    						  		
                                    
                                    <?php echo Form::open(['url' => 'ticket', 'method' => 'post', 'class' => 'form-horizontal', 'id' => 'ticketForm']); ?>

                                   
                                    <div class="row">

                                        <div class="col-xs-12 col-sm-7">
                                            <div class="form-group <?php echo e($errors->has('phone_number') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('phone_number', 'Customer Phone Number', ['class' => 'required col-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::text('phone_number', null, ['class' => 'form-control', 'placeholder' => 'Enter Customer Phone Number', 'autocomplete' => 'off']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('phone_number')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('subject') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('subject', 'Subject', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::select('subject', $subjectList, null, ['class' => 'form-control','placeholder' => 'Select Subject', 'id' => 'subject']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('subject')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('customer_name') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('customer_name', 'Customer Name', ['class' => 'required col-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::text('customer_name', null, ['class' => 'form-control', 'placeholder' => 'Enter Customer Name', 'autocomplete' => 'off']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('customer_name')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                           
                                            <div class="form-group <?php echo e($errors->has('division_id') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('division_id', 'Select Division', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    
                                                        <?php echo Form::select('division_id', $divisionList, null, ['class' => 'form-control js-example-basic-single', 'placeholder' => 'Select Customer Division', 'id' => 'division_id']); ?>

                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('division_id')); ?>

                                                        </span>
                                                    
                                                </div>
                                            </div>
                                       
                                            <div class="form-group <?php echo e($errors->has('district_id') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('district_id', 'Select District', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    
                                                        <?php echo Form::select('district_id', [], null, ['class' => 'form-control js-example-basic-single', 'placeholder' => 'Select Customer District', 'id' => 'district_id']); ?>

                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('district_id')); ?>

                                                        </span>
                                                   
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('customer_address') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('customer_address', 'Customer Address', ['class' => 'required col-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::text('customer_address', null, ['class' => 'form-control', 'placeholder' => 'Enter Customer Address', 'autocomplete' => 'off']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('customer_address')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('ticket_type_id') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('ticket_type_id', 'Ticket Type', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    
                                                        <?php echo Form::select('ticket_type_id', $ticketTypeList, null, ['class' => 'form-control','placeholder' => 'Select Ticket Type', 'id' => 'ticket_type_id']); ?>

                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('ticket_type_id')); ?>

                                                        </span>
                                                   
                                                </div>
                                            </div>
                                            <div class="form-group <?php echo e($errors->has('assigned_id') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('assigned_id', 'Assign, Mail & SMS To (PIC)', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <span id="type_to_assign_show">
                                                        <?php echo Form::select('assigned_id', $userList, null, ['class' => 'form-control','placeholder' => 'Select Assign To', 'id' => 'assigned_id']); ?>

                                                        <!-- <?php echo Form::select('assigned_id', [], null, ['class' => 'form-control','placeholder' => 'Select Assign To', 'id' => 'assigned_id']); ?> -->
                                                    </span>
                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('assigned_id')); ?>

                                                    </span>
                                                    
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('cc_to') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('cc_to', 'CC To', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <span id="type_to_cc_show">
                                                        <!-- <?php echo Form::select('cc_to[]', [], null, ['class' => 'form-control js-example-basic-multiple', 'id' => 'cc_to', 'multiple' => 'multiple']); ?> -->
                                                    </span>
                                                        <?php echo Form::select('cc_to[]', $userList, [1], ['class' => 'form-control select2', 'id' => 'cc_to', 'multiple' => 'multiple']); ?></span>
                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('cc_to')); ?>

                                                        </span>
                                                    
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('product_model') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('product_model', 'Product Model', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::select('product_model', $productModelList, null, ['class' => 'form-control select2','placeholder' => 'Select Product Model', 'id' => 'product_model']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('product_model')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('sources_of_purchase') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('sources_of_purchase', 'Sources of Purchase', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::select('sources_of_purchase', $sourceOfPurposeList, null, ['class' => 'form-control','placeholder' => 'Select Sources of Purchase', 'id' => 'sources_of_purchase']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('sources_of_purchase')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('usage_purpose') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('usage_purpose', 'Usage Purpose', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::select('usage_purpose', $usagePurposeList, null, ['class' => 'form-control','placeholder' => 'Select Usage Purpose', 'id' => 'usage_purpose']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('usage_purpose')); ?>

                                                    </span>
                                                </div>
                                            </div>

                                            <div class="form-group <?php echo e($errors->has('date_of_purchase') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('date_of_purchase', 'Date of Purchase', ['class' => 'required col-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    <?php echo Form::text('date_of_purchase', null, ['class' => 'form-control', 'placeholder' => 'Enter Date of Purchase', 'autocomplete' => 'off', 'id' => 'date_of_purchase', 'readonly' => 'readonly']); ?>

                                                    <span class="text-danger">
                                                        <?php echo e($errors->first('date_of_purchase')); ?>

                                                    </span>
                                                </div>
                                            </div>
                                            
                                            <div class="form-group <?php echo e($errors->has('verbatim_or_issue') ? 'has-error' : ''); ?>">
                                                <?php echo Form::label('verbatim_or_issue', 'Verbatim or Issue', ['class' => 'required col-xs-3 col-sm-3 control-label']); ?>

                                                <div class="col-xs-9 col-sm-9">
                                                    
                                                        <?php echo Form::textarea('verbatim_or_issue', null, ['class' => 'form-control', 'placeholder' => 'Enter Verbatim or Issue', 'autocomplete' => 'off', 'rows' => 3]); ?>

                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('verbatim_or_issue')); ?>

                                                        </span>
                                                   
                                                </div>
                                            </div>
                                        </div>

                                        <div class="col-xs-12 col-sm-5">
                                            <div class="input_fields_wrap">
                                                <button class="add_field_button btn btn-danger btn-xs btn-flat">VEL Add Product Serial & Warranty Code</button>
                                                <!-- <div><input type="text" name="mytext[]"></div> -->

                                                <!-- <div class="form-group <?php echo e($errors->has('product_serial') ? 'has-error' : ''); ?>">
                                                    <label class="required control-label col-sm-3" for="product_serial">Product Serial</label>
                                                    <div class="col-xs-9 col-sm-9">
                                                        <input type="text" class="form-control" placeholder="Enter Product Serial" name="product_serial[]" autocomplete="off">
                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('product_serial')); ?>

                                                        </span>
                                                    </div>
                                                </div>

                                                <div class="form-group <?php echo e($errors->has('customer_name') ? 'has-error' : ''); ?>">
                                                    <label class="required control-label col-sm-3" for="warranty_code">Warranty Code</label>
                                                    <div class="col-xs-9 col-sm-9">
                                                        <input type="text" class="form-control" placeholder="Enter Warranty Code" name="warranty_code[]" autocomplete="off">
                                                        <span class="text-danger">
                                                            <?php echo e($errors->first('warranty_code')); ?>

                                                        </span>
                                                    </div>
                                                </div> -->


                                            </div>

                                            <!-- For Transcom Digital -->
                                            <div class="input_fields_wrap_TD" style="margin-top: 20px;">
                                                <button class="add_field_button_TD btn btn-success btn-xs btn-flat">TD Add Product Serial & Warranty Code</button>
                                            </div>


                                        </div>
                                    </div>

                                    <div class="box-footer">
                                        <!-- <button type="button" class="btn btn-default">Cancel</button> -->
                                        <a href="<?php echo e(url('/ticket-type')); ?>" class="btn btn-default">Cancel</a>
                                       
                                        <?php echo Form::button('Submit', ['class' => 'btn btn-primary pull-right', 'data-toggle' => 'modal', 'data-target' => '#ticket_create']); ?>

                                        
                                        
                                    </div>

                                    <div class="modal modal-info fade" id="ticket_create">
                                        <div class="modal-dialog">
                                            <div class="modal-content">
                                                <div class="modal-header">
                                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                                        <span aria-hidden="true">&times;</span>
                                                    </button>
                                                    <h4 class="modal-title">Confirmation Message</h4>
                                                </div>
                                                <div class="modal-body">
                                                    <h3>Want to Create Ticket?</h3>
                                                </div>
                                                <div class="modal-footer">
                                                    <button type="button" class="btn btn-outline pull-left" data-dismiss="modal">Close</button>
                                                    <button type="submit" class="btn btn-outline submitBtnTicket">Create Ticket</button>
                                                </div>
                                            </div>
                                        </div>
                                    </div>

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

    								

    							</div>
    						</div>
    					</div>

                	</div>
          		</div>
        	</div>
      	</div>
    </section>
</div>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('style'); ?>
    <link rel="stylesheet" href="<?php echo e(asset('assets/css/bootstrap-datepicker.min.css')); ?>">
    <link rel="stylesheet" href="<?php echo e(asset('assets/css/select2.min.css')); ?>">
    <style type="text/css">
        .select2-container--default .select2-selection--multiple .select2-selection__choice {
            background-color: #3c8dbc;
            border-color: #367fa9;
            padding: 1px 10px;
            color: #fff;
        }
    </style>
<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>
    <script src="<?php echo e(asset('assets/js/bootstrap-datepicker.min.js')); ?>"></script>
    <script src="<?php echo e(asset('assets/js/select2.full.min.js')); ?>"></script>

    <script type="text/javascript">
        $(document).ready(function() {
            var max_fields      = 15; 
            var wrapper         = $(".input_fields_wrap"); 
            var add_button      = $(".add_field_button"); 

            //var fullYear = new Date().getFullYear().toString().substr(2,2) +"mo"+ new Date().getMonth()+"day"+ new Date().getDate();

            var ymd = $("#ymd").text();
            var wdTodayCount = parseInt($("#wd_today_count").text());
            var x = 0; 
            $(add_button).click(function(e){ 
                e.preventDefault();
                if(x < max_fields){ 
                    x++; 
                    wdTodayCount++;

                    if(wdTodayCount < 10) {
                        var addZero = '00';
                    } else {
                        var addZero = '0'
                    }
                    //$(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field">Remove</a></div>'); 
                    $(wrapper).append('<div>'+ 
                                        '<div class="form-group">'+
                                            '<label class="required control-label col-sm-4" for="product_serial">Product Serial</label>'+
                                            '<div class="col-xs-8 col-sm-8">'+
                                                '<input type="text" class="form-control" placeholder="Enter Product Serial" name="product_serial[]" autocomplete="off">'+
                                            '</div>'+
                                        '</div>'+
                                        '<div class="form-group">'+
                                            '<label class="required control-label col-sm-4" for="warranty_code">Warranty Code</label>'+
                                            '<div class="col-xs-8 col-sm-8">'+
                                                '<input type="text" class="form-control" placeholder="Enter Warranty Code" name="warranty_code[]" autocomplete="off" value="VEL'+ ymd + addZero + wdTodayCount +'" readonly>'+
                                            '</div>'+
                                        '</div>'+  
                                        //'<a href="#" class="remove_field">Remove</a>'+
                                    '</div>'); 
                }
            });
            
            $(wrapper).on("click",".remove_field", function(e){ 
                e.preventDefault(); $(this).parent('div').remove(); x--;
            })
        });
    </script>

<!-- For Transcom Digital -->
    <script type="text/javascript">
        $(document).ready(function() {
            var max_fields      = 15; 
            var wrapper         = $(".input_fields_wrap_TD"); 
            var add_button      = $(".add_field_button_TD"); 

            //var fullYear = new Date().getFullYear().toString().substr(2,2) +"mo"+ new Date().getMonth()+"day"+ new Date().getDate();

            var ymd = $("#ymd").text();
            var wdTodayCount = parseInt($("#wd_today_count").text());
            var x = 0; 
            $(add_button).click(function(e){ 
                e.preventDefault();
                if(x < max_fields){ 
                    x++; 
                    wdTodayCount++;

                    if(wdTodayCount < 10) {
                        var addZero = '00';
                    } else {
                        var addZero = '0'
                    }
                    //$(wrapper).append('<div><input type="text" name="mytext[]"/><a href="#" class="remove_field_TD">Remove</a></div>'); 
                    $(wrapper).append('<div>'+ 
                                        '<div class="form-group">'+
                                            '<label class="required control-label col-sm-4" for="product_serial">Product Serial</label>'+
                                            '<div class="col-xs-8 col-sm-8">'+
                                                '<input type="text" class="form-control" placeholder="Enter Product Serial" name="product_serial[]" autocomplete="off">'+
                                            '</div>'+
                                        '</div>'+
                                        '<div class="form-group">'+
                                            '<label class="required control-label col-sm-4" for="warranty_code">Warranty Code</label>'+
                                            '<div class="col-xs-8 col-sm-8">'+
                                                '<input type="text" class="form-control" placeholder="Enter Warranty Code" name="warranty_code[]" autocomplete="off" value="TD'+ ymd + addZero + wdTodayCount +'" readonly>'+
                                            '</div>'+
                                        '</div>'+  
                                        //'<a href="#" class="remove_field_TD">Remove</a>'+
                                    '</div>'); 
                }
            });
            
            $(wrapper).on("click",".remove_field_TD", function(e){ 
                e.preventDefault(); $(this).parent('div').remove(); x--;
            })
        });
    </script>

    <script>
        $(document).ready(function(){
            $(".add_field_button_TD").click(function(){
                $(".input_fields_wrap").hide();
            });

            $(".add_field_button").click(function(){
                $(".input_fields_wrap_TD").hide();
            });
        });
    </script>

    <script type="text/javascript">
        $(function() {
            $('#division_id').change(function() {
                var divisionId = $(this).val();
                getDistrict(divisionId);
            });
        });

        function getDistrict(divisionId) {
            
            resetField('district_id', 'Select DISTRICT');
            var url = '<?php echo e(url("ticket/get-district")); ?>';
            $.get(url+'?division_id='+divisionId, function (response) {
                $.map( response, function( name, id ) {
                    $('#district_id').append('<option value="'+ id +'">' + name + '</option>');
                });
            });
        }

        function resetField(id, placeholder) {
            $('#' + id).empty();
            $('#' + id).append('<option value="">'+ placeholder +'</option>');
        }

        $('#date_of_purchase').datepicker({
            format:'yyyy-mm-dd',
            autoclose: true
        });

        $(function () {
            $('.select2').select2();
        });

        $(document).ready(function () {
            $("#ticketForm").submit(function () {
                $(".submitBtnTicket").attr("disabled", true);
                return true;
            });
        });
        
    </script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_except(get_defined_vars(), array('__data', '__path')))->render(); ?>