<?php

echo $this->Html->script('jquery-1.11.2.js');
$menu_modules = unserialize($this->request->session()->read('modules'));

?>

<?php echo $this->Html->script('jsvalidate/validate-latest.js'); ?>
<?php echo $this->Html->script('jsvalidate/custom_validation_methods.js'); ?>

<style>
    .client_info_area{
        display: none;
    }
    .margin-top-10{
        margin-top: 10px;
    }
    
    legend span.image-notice{
        font-size: 14px;
        font-weight: bold;
    }
    .client-imgae-area label{
        padding-left: 0;
    }
    .info{
        float:right;
        text-align:right;
    }
</style>
<div class="row">
    <div class="col-md-12">
        <div class="box box-primary">
            <div class="box-body">
                <div class="row">
                    <div class="col-md-6 col-xs-6 tile">
                        <div class="icon-frame col-md-2" id="light">
                            <i class="fa fa-user" style="color:white"></i>
                        </div>
                        <h3 class="box-title no-margin" style="line-height: 3;float: left;"><?php echo __('&nbspTrial Account'); ?></h3>
                       
                    
                    </div>
                    
                    <div class="col-md-6">
                        <div class="row">
                            <div class="col-md-12 text-right" style="line-height: 5;">
                                <?php
                                if (array_key_exists("add", $module_pages)):
                                    $page_id = $module_pages["index"];
                                    foreach ($user_permission as $permission):
                                        if ($permission['page_id'] == $page_id):
                                            ?>
                                <a href="<?php echo $this->Url->build('/Client/index/'); ?>"  class="btn btn-success btn-flat btn-grid">
                                    <i class="fa fa-list"></i>
                                                <?php echo __('LIST'); ?>
                                </a>
                                            <?php
                                            break;
                                        endif;
                                    endforeach;
                                endif;
                                ?>


                               
                            </div>
                        </div>


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



<div class="box box-primary">
    <!-- /.box-header -->
    <div class="box-body">
        <div class="row">
            <div class="col-md-12">
<?= $this->Form->create(null, ['id' => 'client_form','enctype'=>'multipart/form-data', 'class'=> 'input-form-section','autocomplete'=>'off']); ?>            
               <?php if($member_id > 0 && !empty($member_email)){ ?>
                <input name="member_id" value="<?php echo $member_id; ?>" type="hidden">
                <input name="member_email" value="<?php echo $member_email; ?>" type="hidden">
                <?php } ?>
                <div class="col-md-12">
                    <legend>Basic info</legend>
                </div>    
                <div class="col-md-6">
                    <fieldset>

                        <div id="basic_info_div">

                            <div class="col-md-12 col-sm-12 col-xs-12 text-left">
                                <div class="form-group row <?php if(isset($errors['name'])){ echo 'has-error';} ?>">
                                    <label class="control-label col-lg-3 required">First Name</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('first_name', ['label' =>false,['class' => 'required' ], 'class' => 'form-control', 'required' => false]); ?>
                                        
                                    </div>
                                </div>
                                <div class="form-group row <?php if(isset($errors['name'])){ echo 'has-error';} ?>">
                                    <label class="control-label col-lg-3 required">Last Name</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('last_name', ['label' =>false,['class' => 'required' ], 'class' => 'form-control', 'required' => false]); ?>
                                        
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Username</label>
                                    <div class="col-lg-9">
                                        <span>Use real email to gain access</span>
                                        <?php echo $this->Form->input('username', ['label' =>false, "autocomplete"=>"off", 'class' => 'form-control']); ?>
                                        
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Email</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('email', ['label' =>false, "autocomplete"=>"off", 'class' => 'form-control']); ?>
                                        
                                    </div>
                                </div>

                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Password</label>
                                    <div class="col-lg-9">
                                            <?php echo $this->Form->input('password', ['label' =>false, "autocomplete"=>"off", 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Retype password</label>
                                    <div class="col-lg-9">
                                        <?php echo $this->Form->input('retype_password', ['type'=>'password','label' =>false, "autocomplete"=>"off", 'class' => 'form-control']); ?>
                                    </div>
                                </div>                       
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Phone</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('phone', ['label' =>false, 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>   
                <div class="col-md-6">
                    <fieldset>

                        <div id="basic_info_div">

                            <div class="col-md-12 col-sm-12 col-xs-12 text-left">
                                <div class="form-group row">
                                    <label class="control-label col-lg-3">Mobile</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('mobile', ['label' =>false, 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Street no.</label>
                                    <div class="col-lg-9">
                                             <?php echo $this->Form->input('street_no', ['label' =>false, 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Street name</label>
                                    <div class="col-lg-9">
                                        <?php echo $this->Form->input('street_name', ['label' =>false, 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">Zip Code</label>
                                    <div class="col-lg-9">
                                        <?php echo $this->Form->input('zip_code', ['label' =>false, 'class' => 'form-control', 'required' => false]); ?> 
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">City</label>
                                    <div class="col-lg-9">
                                        <?php echo $this->Form->input('city', ['label' =>false, 'class' => 'form-control']); ?>
                                    </div>
                                </div>
                                <div class="form-group row">
                                    <label class="control-label col-lg-3 required">State</label>
                                    <div class="col-lg-9">
                                        <?php echo $this->Form->input('state', ['label' =>false, 'class' => 'form-control', 'required' => false]); ?>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </fieldset>
                </div>   

                 
                <div class="form-group row">
                    <label class="control-label col-lg-3"></label>
                    <div class="col-lg-12">
                    <?= $this->Form->button(__('Submit'), ['class' => 'btn btn-success tab3Save pull-right btn-grid btn-flat btn-orange-color','style'=>'margin-right: 30px;','id'=>'submit']) ?>
                        <a href="<?php echo $this->Url->build('/Client/index/'); ?>"  class="btn btn-default tab3Save pull-right btn-grid btn-flat" style="margin-right:10px;" id="default-btn">
                            <?php echo __('Back'); ?>
                        </a>
                    </div>
                </div>
<?= $this->Form->end() ?>
            </div>
        </div>
    </div>
</div>
<script src="<?php echo $this->request->webroot;?>js/sweetalert2/sweetalert2.min.js"></script>
<script>

    <?php if($isSuccess){ ?>  
        Swal.fire({
            width:'40rem',
            text: "Thank you ! For submitting information. Please go to your email to get your login information.",
            icon: 'success',
            showCancelButton: false,
            confirmButtonColor: '#3085d6',
            cancelButtonColor: '#d33',
            confirmButtonText: 'OK',
            cancelButtonText:false
        }).then((result) => {
            if (result.value) {
                window.location.href = '<?php echo APP_SERVER_HOST_URL; ?>'
            }
        })          
    <?php } ?>            

    $('#client_form').validate({
        rules: {
            'first_name': 'required',
            'last_name': 'required',
            'username':'required',
            'email': {
                required: true,
                email: true
            },

            'password': {
                required: true,
                minlength: 6
            },
            'retype_password': {
                required: true,
                equalTo: "#password",
                minlength: 6
            },
            'street_no':'required',
            'street_name':'required',
            'zip_code':'required',
            'city':'required',
            'state':'required',
            'phone':'required',
        },
        
        highlight: function (element) {
            $(element).parent().addClass("has-error");
        },
        submitHandler: function (form) {
            //event.preventDefault();
            //form.submit();
            return true;
            
        }
    });

</script>

