<section class="content">
    <div class="row">
        <div class="col-sm-12">
            <div class="tabbable">
                <div class="tab-content no-border padding-24">
                    <div class="tab-pane fade in active" id="faq-tab-1">
                        <div class="space-8"></div>
                        <div class="panel-group accordion-style1 accordion-style2" id="faq-list-1">
                            <div class="panel panel-default">
                                <div class="panel-headingnew"><?php echo $this->translate('Edit User License'); ?> </div>
                                <div class="left_panel col-sm-12 padding_margin0" id="add_detail" style="float:left; background:#fff;">
                                    <div class="tab-content tab_editprofile col-sm-12" style="padding-left:0; margin-top:10px; margin-bottom:10px;">
                                        <div class="tab-pane fade in tab_editprofile tab_editprofile1 active">
                                            <div class="change_password tab_editprofile">
                                                <div class="tab-content">
                                                    <div class="tab-pane fade active in">
                                                        <div style="margin: 10px auto 0px !important;padding: 0 10px;" class="col-sm-col-sm-offset-1">
                                                            <?php
                                                            $form = $this->form;
                                                            $form->prepare();
                                                            $form->setAttribute('action', $this->url('license', ['action' => 'edit-user-license']));
                                                            $form->setAttribute('enctype', 'multipart/form-data');

                                                            echo $this->form()->openTag($form);
                                                            
                                                            
$cancellationstring = "";

if ($userRegisterDomains != '') {
//$waiting_fareArr  = json_decode($waiting_fee_upto);-
$cancellationstring = '';
foreach ($userRegisterDomains as $key => $value) {
$counter = $key;
//$kmRate  = explode('_',$value);
$cancellationstring .= '<div class="row1 form-group clearfix margintopbottom20"><label class="col-sm-3 control-label labelalign col-sm-3-new" >' . $this->translate($this->formLabel($form->get('domain_name[]'))) . '</label><div class="col-sm-3 col-sm-4-new">' . $this->formElement($form->get('domain_name[]')->setValue($value['domain_name'])) . '</div><div class="col-sm-1 remove_cancellationfees_row"  id="removeDistanceFields_"' . $counter . '><a href="javascript:void(0)"><i class="fa fa-trash-o fa-2x"></i></a></div></div>';
}
}
                                                ?>
                                                            
                                                             
                                                            <div class="row">
                                                                <div class="col-sm-10">
                                                                    <div class="form-group clearfix margintopbottom20">
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('owner_name'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('owner_name')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('owner_name'), ['class' => 'error']); ?>
                                                                        </div>
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('owner_email'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('owner_email')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('owner_email'), ['class' => 'error']); ?>

                                                                        </div>
                                                                    </div>

                                                                    <div class="form-group clearfix margintopbottom20">
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('owner_mobile'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('owner_mobile')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('owner_mobile'), ['class' => 'error']); ?>
                                                                        </div>
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('owner_address'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('owner_address')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('owner_address'), ['class' => 'error']); ?>

                                                                        </div>
                                                                    </div> 

                                                                    <div class="form-group clearfix margintopbottom20">                                                                       

                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('license_option'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('license_option')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('license_option'), ['class' => 'error']); ?>

                                                                        </div>

                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('package'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('package')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('package'), ['class' => 'error']); ?>

                                                                        </div>

                                                                    </div>    

                                                                    <div class="form-group clearfix margintopbottom20">
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('license_start_date'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('license_start_date')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('license_start_date'), ['class' => 'error']); ?>

                                                                        </div>
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new" ><?php echo $this->translate($this->formLabel($form->get('license_end_date'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('license_end_date')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('license_end_date'), ['class' => 'error']); ?>
                                                                        </div>

                                                                    </div> 




                                                                    <div class="form-group clearfix margintopbottom20">     
                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new"><?php echo $this->translate($this->formLabel($form->get('no_of_domain'))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('no_of_domain')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('no_of_domain'), ['class' => 'error']); ?>

                                                                        </div>

                                                                        <label class="col-sm-3 control-label labelalign col-sm-3-new" ><?php echo $this->translate($this->formLabel($form->get('module')->setValue($userDomainsPackage))); ?></label>
                                                                        <div class="col-sm-3 col-sm-4-new">
                                                                            <?php echo $this->FormElement($form->get('module')); ?>
                                                                            <?php echo $this->FormElementErrors($form->get('module'), ['class' => 'error']); ?>
                                                                        </div>

                                                                    </div>
                    

                    <!--<div class="form-group clearfix margintopbottom20 add-domain-name cloned-row">                   
                        <label class="col-sm-3 control-label labelalign col-sm-3-new" >
                            <?php echo $this->translate($this->formLabel($form->get('domain_name[]'))); ?>
                        </label>
                        <div class="col-sm-3 col-sm-4-new">
                            <?php echo $this->FormElement($form->get('domain_name[]')); ?>
                            <?php echo $this->FormElementErrors($form->get('domain_name[]'), ['class' => 'error']); ?>
                        </div>
                        <div class="col-sm-1 add-more-domain">
                            <a class="btn btn-primary"><i class="fa fa-plus-circle"></i></a>
                        </div>
                    </div> -->      
                                                                    
                                                                   <div id="CancellationfeesDiv_package">
        <div class="row1 form-group clearfix margintopbottom20">
            <label class="col-sm-3 control-label labelalign col-sm-3-new" >
                            <?php echo $this->translate($this->formLabel($form->get('domain_name[]'))); ?>
                        </label>
        <div class="col-sm-3 col-sm-4-new"><?php echo $this->formElement($form->get('domain_name[]')->setValue('')); ?></div>
        <div class="col-sm-2">
        <div class="addcancellation_on_plus no-padding" id="addprewaiting_3">
        <a href="#" class="btn btn-info form-control">Add More</a>
        </div>
        </div>

        </div>

            </div>
 <div id="appended_cancellationfees_package"></div>
 <div class="checkbox_error"></div>
                                                                <?php echo $cancellationstring; ?>


                                                                    <div class="col-sm-12 " align="right">

                                                                        <?php echo $this->FormElement($form->get('submit')); ?>
                                                                        <a class="reset_btn btn btn-danger reset_btn" href="#">
                                                                            <i class="fa fa-retweet"></i>
                                                                            Reset
                                                                        </a>
                                                                    </div>
  <?php echo $this->FormElement($form->get('user_license_id')); ?>
                                                                </div>
                                                                <?php echo $this->form()->closeTag(); ?>
                                                            </div>
                                                        </div>
                                                    </div>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <br>
            </div>
        </div>
</section>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script type="text/javascript">
    $(document).on('click', '.addcancellation_on_plus', function () {
        var domain_count = $(":input[name='domain_name[]']").length;
        var domain_no = $('#no-of-domain').val();
        var addButtonId = $(this).attr('id');
        var counterArr = addButtonId.split("_");
        var counter = counterArr[1];
        counter++;
        var domain_label = '<?php echo $this->translate($this->formLabel($form->get('domain_name[]'))); ?>';
        var domain_name = '<?php echo $this->formElement($form->get('domain_name[]')); ?>';
        var detailsdiv = "";
        detailsdiv += '<div class="row1 form-group clearfix margintopbottom20"><label class="col-sm-3 control-label labelalign col-sm-3-new" >' + domain_label + '</label><div class="col-sm-3 col-sm-4-new">' + domain_name + '</div><div class="col-sm-1 remove_cancellationfees_row"><a href="javascript:void(0)"  id="removePreWaitingPkgFields_' + counter + '"><i class="fa fa-trash-o fa-2x"></i></a></div></div>';
        if(domain_no>=2){
        if(domain_count <= $('#no-of-domain').val()-1){
        $("#appended_cancellationfees_package").append(detailsdiv);
        }else{
        var msg = 'Please Increase No of Domain';
        $('.checkbox_error').fadeIn();
        }
        }else{
        var msg = 'Please Select No of Domain';
        $('.checkbox_error').fadeIn();
        }      
                
        var strHtml = '<div class="alert alert-success no-border"><button type="button" class="close" data-dismiss="alert"><i class="icon-close2" ></i><span class="sr-only">Close</span></button><span class="text-semibold">' + msg + '</span></div>';
        $('.checkbox_error').html(strHtml);
        setTimeout(function () {
        $('.checkbox_error').fadeOut();
        }, 2000);
        return false;
    });


    $(document).on('click', '.remove_cancellationfees_row', function () {
        var addId = $(".addcancellation_on_plus").attr('id');
        var addIdArr = addId.split("_");
        var counter = addIdArr[1];
        counter--;
        $(this).closest('.row1').remove();
        var addbtn_length = $("#appended_cancellationfees_package .addcancellation_on_plus").length;
        var row_leng = $("#appended_cancellationfees_package .row1").length;
        return false;
    });
</script>
