<script src="<?php echo base_url();?>assets/plugins/jSignature/jSignature.min.js" ></script>
<div class="wrapper">
    <div class="container">
        <div class="row">
            <div class="col-sm-12 col-xm-12"></div>
        </div>        

        <div class="row">
            <div class="col-md-12 col-sm-12 col-xs-12">
                <div class="card-box">
                    <div class="row">
                        <div class="pull-left">
                            <h3 class="logo invoice-logo"><?php if(isset($business)){ echo "<img src='".base_url().'assets/images/business/'.$business[0]['business_logo']."' alt='".$business[0]['business_name']."' class='img-responsive' />";} else {echo 'SalonPK';}?></h3>
                        </div>
                    </div>
                    <!-- Title -->
                    <div class="row">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <h2 class="text-center formtitle">CONSENT FORM (<?php echo strtoupper($formdata->form_title);?>)</h2>
                            <input type="hidden" id="visit_id" value="<?php echo $formdata->visit_id;?> ">
                            <input type="hidden" id="customer_id" value="<?php echo $formdata->customer_id;?> ">
                            <input type="hidden" id="id_concent_form_data" value="<?php echo $formdata->id_concent_form_data;?> ">
                        </div>
                    </div>

                     <!--Customer Details-->
                     <div class="row m-t-20">
                        <div class="col-md-12 col-sm-12 col-xs-12">   
                            <div class="row">
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Client Name:</h5>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="customer_name" name="customer_name" ><?php echo $formdata->customer_name; ?></p>
                                </div>
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Date of Visit:</h5>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="visit_date" name="visit_date"><?php echo $formdata->visit_date=='' ? '-' :  $formdata->visit_date; ?></p>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Client Cell:</h5>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="customer_cell" name="customer_cell"><?php echo $formdata->customer_cell; ?></p>
                                </div>
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Area of Residence:</h5>
                                </div>
                                <div class="col-md-4 col-sm-2 col-xs-2" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="customer_area" name="customer_area"><?php echo $formdata->customer_area=='' ? '-' :  $formdata->customer_area; ?></p>
                                </div>
                            </div>
                            <div class="row">
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Tech Consultant:</h5>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="consultant" name="consultant"><?php echo $formdata->consultant_name=='' ? '-' :  $formdata->consultant_name; ?></p>                                    
                                </div>
                                <div class="col-md-2 col-sm-2 col-xs-2">
                                    <h5 style="font-weight:500">Event Date:</h5>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom:1px solid #000;">
                                    <p style="font-size:14px;" id="eventdate" name="eventdate"><?php echo $formdata->event_date=='' ? '-' :  $formdata->event_date; ?></p>                                    
                                </div>
                            </div>
                        </div>
                    </div>

                    <div  class="row m-t-20">
                        <div class="col-md-12 col-sm-12 col-xs-12" id="structuredata">                            
                            <?php $lastsection=''; $lastsectionheading='';?>
                            <?php //foreach($formdata->concent_data as $fd){?>
                                <?php $sJson = json_decode($formdata->concent_data);?>
                                <?php  foreach($sJson  as $section => $sectionheading) {?>
                                    <div class="row me">
                                        <div class="col-md-12 col-sm-12 col-xs-12">
                                            <?php if(strpos($section,"-")==0){?>                                            
                                            <h5 class="section" key = "<?php  print_r($section); ?>" style="font-weight:700 "><?php print_r($section); ?>:</h5>                                       
                                            <?php } ?>
                                            <?php foreach($sectionheading as $s => $elems){?>                                            
                                                <?php if(strpos($s,"-")==0){?>
                                                    <div class="row">
                                                        <div class="col-md-2 col-sm-2 col-xs-2 " >     
                                                            <?php if($s != $section){?>                                       
                                                            <h5 style="font-weight:500;"><span class="section_heading"><?php print_r($s); ?></span>:</h5>
                                                            <?php } ?>
                                                        </div>                                                                                              
                                                        <div class="col-md-10 col-sm-10 col-xs-10">                                           
                                                <?php } else {?>                                            
                                                <div class="row">    
                                                    <div class="col-md-12 col-sm-12 col-xs-12">                                                                                                    
                                                <?php } ?>
                                                        <div class="form-horizontal ">                                 
                                                            <?php foreach($elems as $key => $value){?>
                                                                <?php $thiskey = explode("||",$key);?>
                                                                <?php if($thiskey[1]=='checkbox'){ ?>   
                                                                    <div class="form-group checkbox" style="display:inline-table; margin-right:25px; ">                                                             
                                                                        <input  <?php if($value=='true'){echo 'checked="checked"';}?>  type="checkbox" disabled="disabled" class="checkbox-inline m-l-15" name="<?php echo $s;?>" id="<?php echo str_replace(' ','',$s."_".$thiskey[0]); ?>">
                                                                        <label style="font-size: 14px; color:#000000 !important" class="checkbox-label " for="<?php echo str_replace(' ','',$s."_".$thiskey[0]); ?>"> <?php echo $thiskey[0]; ?></label>                                                                
                                                                    </div>
                                                                <?php }elseif($thiskey[1]=='radio'){ ?>   
                                                                    <div class="form-group checkbox" style="display:inline-table; margin-right:25px; ">                                                             
                                                                        <input  <?php if($value=='true'){echo 'checked="checked"';}?>  type="checkbox" disabled="disabled" class="checkbox-inline m-l-15" name="<?php echo $s;?>" id="<?php echo str_replace(' ','',$s."_".$thiskey[0]); ?>">
                                                                        <label style="font-size: 14px; color:#000000 !important" class="checkbox-label " for="<?php echo str_replace(' ','',$s."_".$thiskey[0]); ?>"> <?php echo $thiskey[0]; ?></label>                                                                
                                                                    </div>
                                                                <?php } elseif ($thiskey[1]=='para'){?>
                                                                    <div class="row">
                                                                        <div class="col-md-12">
                                                                        <?php if(strpos($thiskey[0],"-")==0){?>
                                                                        <p style="font-size: 14px;" class="col-sm-1 col-xs-1 m-l-15" for="<?php echo $thiskey[0]; ?>"> <?php echo $thiskey[0]; ?>:</p>    
                                                                        <?php } ?>
                                                                        <p class="jsonelem epara" style="font-size: 14px; <?php if(strpos($thiskey[0],"-")==0){?>text-decoration:underline<?php } ?>"><?php echo urldecode($value);?></p>
                                                                        </div>
                                                                    </div>
                                                                <?php } elseif ($thiskey[1]=='list'){?>
                                                                    <div class="row">
                                                                        <?php if(strpos($thiskey[0],"-")==0){?>
                                                                        <p style="font-size: 14px;" class="col-sm-1 col-xs-1 m-l-15" for="<?php echo $thiskey[0]; ?>"> <?php echo $thiskey[0]; ?>:</p>    
                                                                        <?php } ?>
                                                                        <div class="jsonelem elist" style="font-size: 14px;"><?php echo $value;?></div>
                                                                    </div>  
                                                                <?php } elseif ($thiskey[1]=='img'){?>
                                                                    <div class="row">
                                                                        <div class="col-md-12">                                                                        
                                                                            <img class="img eimage" src="<?php echo base_url().'assets/images/'.$thiskey[0];?>" >                                                                        
                                                                        </div>                 
                                                                        
                                                                    </div>                                                                  
                                                                <?php } elseif ($thiskey[1]=='imghalf'){?>
                                                                    <div class="row">
                                                                        <div class="col-md-4">                                                                        
                                                                            <img class="img eimghalf" src="<?php echo base_url().'assets/images/'.$thiskey[0];?>" style="max-height:250px;">                                                                        
                                                                        </div>                 
                                                                        <div class="col-md-8">
                                                                            <p class="jsonelem etexthalf eimghalf" style="font-size: 14px; <?php if(strpos($thiskey[0],"-")==0){?>text-decoration:underline<?php } ?>"><?php echo $value;?></p>
                                                                        </div>                                                           
                                                                    </div>
                                                                <?php } ?>
                                                            <?php } ?>
                                                        </div>
                                                    </div>
                                                </div>                                                
                                            <?php } ?>
                                        </div>    
                                    </div>
                                <?php } ?>

                            <?php //} ?>
                            
                        </div>
                    </div>

                    <!-- Client Signature -->
                    <div id="signaturedata" class="row m-t-20 m-b-20">
                        <div class="col-md-12 col-sm-12 col-xs-12">
                            <div class="row">
                                <div class="col-md-2 col-sm-2 col-xs-2">                            
                                    <label style="font-size:14px;">Client Signature: </label>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4"  style="border-bottom: 1px solid #000;">
                                    <div id="container" >
                                        <div id="customer_signature"></div>
                                    </div>                   
                                </div>
                                <div class="col-md-2 col-sm-2 col-xs-2">                            
                                    <label style="font-size:14px;">Consultant Signature: </label>
                                </div>
                                <div class="col-md-4 col-sm-4 col-xs-4" style="border-bottom: 1px solid #000;">
                                    <div id="container" >
                                        <div id="consultant_signature"></div>
                                    </div>                     
                                </div>
                            </div>
                        </div>
                    </div>


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

    <script>
        $(document).ready(function(){
            var i = new Image();
            i.src = "data:" + "<?php echo $formdata->customer_signature; ?>"
            $(i).appendTo($("#customer_signature"));

            var i1 = new Image();
            i1.src = "data:" + "<?php echo $formdata->consultant_signature; ?>"
            $(i1).appendTo($("#consultant_signature"));
        });
    </script>
