<div class="row">
    <div style="position: absolute;z-index: 2;">
        <a href="../core/Profiles/settingProfile">
            <?php echo $this->Html->image('/img/core/img/setting-icon@3x.png', ['alt' => 'setting-icon']); ?>
        </a>
    </div>

<!------------------------------->

<?php
class QRGenerator { 

    protected $size; 
    protected $data; 
    protected $encoding; 
    protected $errorCorrectionLevel; 
    protected $marginInRows; 
    protected $debug; 

    public function __construct($data='1334554 5454 545',$size='300',$encoding='UTF-8',$errorCorrectionLevel='L',$marginInRows=4,$debug=false) { 

        $this->data=urlencode($data); 
        $this->size=($size>100 && $size<800)? $size : 300; 
        $this->encoding=($encoding == 'Shift_JIS' || $encoding == 'ISO-8859-1' || $encoding == 'UTF-8') ? $encoding : 'UTF-8'; 
        $this->errorCorrectionLevel=($errorCorrectionLevel == 'L' || $errorCorrectionLevel == 'M' || $errorCorrectionLevel == 'Q' || $errorCorrectionLevel == 'H') ?  $errorCorrectionLevel : 'L';
        $this->marginInRows=($marginInRows>0 && $marginInRows<10) ? $marginInRows:4; 
        $this->debug = ($debug==true)? true:false;     
    }
public function generate(){ 

        $QRLink = "https://chart.googleapis.com/chart?cht=qr&chs=".$this->size."x".$this->size. "&chl=" . $this->data .  
                   "&choe=" . $this->encoding . 
                   "&chld=" . $this->errorCorrectionLevel . "|" . $this->marginInRows; 
        if ($this->debug) echo   $QRLink;          
        return $QRLink; 
    }
}
?>


<!------------------------------->
<div class="box">
        <div class="absolute-right">
            <?php echo $this->Html->image('/img/core/img/location-profile-icon@3x.png', ['alt' => 'location-profile-icon']); ?> สีลม ,บางรัก</div>
    </div>
    <div style="text-align: center;">
        <?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
        <?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => 'profile-img','id'=>'output','style'=>'width: 169px;height: 169px;-webkit-border-radius: 85px;
    -moz-border-radius: 85px;
    border-radius: 85px;')); ?>
        <?php  }else{ ?>
        <img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="profile-img" id="output" style="width: 169px;height: 169px;-webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px;"/>
        <?php }?>
    </div>
    <div data-toggle="modal" data-target="#defaultModal" style="text-align: center;">
        <a href="#">
            <?php echo $this->Html->image('/img/core/img/id-card-button@3x.png', array('div' => false, 'class' => 'id-card-button')); ?>
        </a>
    </div>

<div class="bg-profile"></div>
<div style="margin: 11% 0% -12% 0%;text-align: center;position: relative;"><?php echo $this->Flash->render() ?></div>
    <div style="padding: 40px 20px 0px 20px;">
        <ul class="list list-icons list-primary list-borders">
            
            <li class="promotion-li">
                <a href="#">
                    <div class="row">
                        <div class="col-xs-6 col-sm-7 color-profile">
                            <!--<img src="../img/core/img/eWallet-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
                            My eWallet by Connect
                        </div>
                        <div class="col-xs-6 col-sm-5 right-icon-view">
                            $150 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
                            <!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
                        </div>
                    </div>
                </a>
            </li>
            <li class="promotion-li">
                <a href="#">
                    <div class="row">
                        <div class="col-xs-6 col-sm-7 color-profile">
                            <!--<img src="../img/core/img/point-icon@3x.png" width="53" height="53" style="vertical-align: middle;"/> -->
                            Point ของฉัน
                        </div>
                        <div class="col-xs-6 col-sm-5 right-icon-view">
                            P200 <?php echo $this->Html->image('/img/core/img/next-icon-profile@3x.png', array('div' => false, 'style' => 'vertical-align: middle;')); ?>
                            <!--<img src="../img/core/img/next-icon-profile@3x.png" style="vertical-align: middle;"/>-->
                        </div>
                    </div>
                </a>
            </li>
            
        </ul>
    </div>
</div>

<!--------------------------------------------------------->
<style type="text/css">

</style>
<!--------------------------------------------------------->
<style type="text/css">

</style>
<?php //debug($Profiles);?>
<div class="modal fade" id="defaultModal" tabindex="-1" role="dialog" aria-labelledby="defaultModalLabel" aria-hidden="true">
        <div class="modal-dialog">
                <div class="">
                        <div class="">
                            <div class="col-md-6">
                                    <div class="owl-carousel owl-theme" data-plugin-options="{'items': 1, 'margin': 10}">
                                            <div>
                                                
                                                <div class="idcard-profile"><?php echo __('ID Card');?></div>
                                                <?php echo $this->Html->image('/img/core/img/card-bg-front@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => 'position: absolute;')); ?>
                                                
        <?php if (empty($Profiles['UserProfiles'][0]['img_path'])) { ?>
        <?php echo $this->Html->image('/img/core/img/user-profile@3x.png', array('div' => false, 'class' => '','style' => 'position: absolute;width: 150px; margin: 85% 0% 0% 20%; -webkit-transform: rotate(270deg);
    -moz-transform: rotate(270deg); -o-transform: rotate(270deg);')); ?>
        <?php  }else{ ?>
        <img src="<?php echo $Profiles['UserProfiles'][0]['img_path'];?>" class="" id="" style="position: absolute;width: 150px; height: 150px; margin: 85% 0% 0% 20%; -webkit-border-radius: 85px;-moz-border-radius: 85px;border-radius: 85px; -webkit-transform: rotate(270deg);
    -moz-transform: rotate(270deg); -o-transform: rotate(270deg);"/>
        <?php }?>
        
                                                <div class="idcard-text"><?php echo __('เลขบัตรประจำตัว');?></div>
                                                <div class="idcard-number"><?php echo $Profiles['UserProfiles'][0]['card_code'];?></div>
                                                <div class="idcard-name-th"><?php echo $Profiles['UserPersonals']['firstname_th'];?> <?php echo $Profiles['UserPersonals']['lastname_th'];?></div>
                                                <div class="idcard-name-en"><?php echo $Profiles['UserPersonals']['firstname_en'];?> <?php echo $Profiles['UserPersonals']['lastname_en'];?></div>
                                                
                                                    <?php if (!empty($Profiles['UserProfiles'][0]['dept_id'])) { ?>
                                                <div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo $MasterDepartments_v[0]['dept_name_th'];?></div>
                                                <?php }else{?>
                                                <div class="idcard-faculty"><b><?php echo __('คณะ');?></b> <?php echo __('-');?></div>
                                                <?php }?>
                                                <?php if (!empty($Profiles['UserProfiles'][0]['section_id'])) { ?>
                                                <div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo $MasterSections_v[0]['section_name_th'];?></div>
                                                <?php }else{?>
                                                <div class="idcard-branch"><b><?php echo __('สาขา');?></b> <?php echo __('-');?></div>
                                                <?php }?>
<!--                                                <div class="idcard-faculty"><b><?php //echo __('คณะ');?></b> <?php //echo __('วิทยาการจัดการ');?></div>
                                                <div class="idcard-branch"><b><?php //echo __('สาขา');?></b> <?php //echo __('คอมพิวเตอร์ธุรกิจ');?></div>-->
                                                <div class="idcard-tel"><b><?php echo __('เบอร์');?></b> <?php echo $Profiles['UserProfiles'][0]['phone_no'];?></div>
                                                <div class="idcard-email"><b><?php echo __('email');?></b> <?php echo $Profiles['UserPersonals']['email'];?></div>
                                            <?php echo $this->Html->image('/img/core/img/thumbs-id@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -4px 0px 0px 96px;')); ?>
                                            </div>
                                            <div>
                                                <div class="qrcode-profile"><?php echo __('แสดง QR Code เพื่อรับสิทธิ์');?></div>
                                                <?php echo $this->Html->image('/img/core/img/card-bg-back@3x.png', array('div' => false, 'class' => 'img-responsive img-rounded','style' => '3position: absolute;')); ?>
                                                <div class="qrcode-name">
                                                    <?php
                                                    $ex1 = new QRGenerator(); 
                                                    echo "<img src=".$ex1->generate()." style='position: absolute;width: 150px;border: solid 1px #000;' class='qrcode-name'>";
                                                    ?>
                                                    <?php //echo $this->Html->image('/img/core/img/qr-code.jpg', array('div' => false, 'class' => 'qrcode-name','style' => 'position: absolute;width: 120px;')); ?>
                                                </div>                                                          
                                                <div class="qrcode-faculty"><?php echo __('Date of Issue');?> <?php echo date("m/Y",strtotime($Profiles['Users']['created']));?></div>
                                                <div class="qrcode-branch">| &nbsp;&nbsp;<?php echo __('Date of Expire');?> <?php echo date("m/Y",strtotime($Profiles['Users']['token_expiry'])); ?></div>
                                                <?php echo $this->Html->image('/img/core/img/card-university-logo.png', array('div' => false, 'class' => '','style' => 'width: 25px;position: absolute;margin: -17% 0% 0% 86%;')); ?> 
                                                
                                                    <?php if (!empty($Profiles['UserProfiles'][0]['organize_id'])) { ?>
                                                    <div class="qrcode-university"><?php echo $MasterDepartmentEducations[0]['org_name_th'];?></div>
                                                    <?php }else{?>
                                                    <div class="qrcode-university"><?php echo __('-');?></div>
                                                    <?php }?>
                                                    <?php //echo __('มหาวิทยาลัยราชภัฏจันทรเกษม');?>
                                               
                                                <?php echo $this->Html->image('/img/core/img/card-logo-connect.png', array('div' => false, 'class' => '','style' => 'width: 26px;position: absolute;margin: -114% 0% 0% 86%;')); ?> 
                                                <div class="qrcode-connect"><?php echo __('connect');?></div>
                                                <?php echo $this->Html->image('/img/core/img/thumbs-id2@3x.png', array('div' => false, 'class' => '','style' => 'width:78px;height:78px;position: absolute;margin: -152% 0% 0% 28%;')); ?>    
                                            </div>
                                    </div>
                            </div>
                        </div>
                       
                </div>
        </div>
</div>
<!------------------------------------------------------------------------------->