<?php
/*
   Author     : Naresh Lakhara
   Date       : 04-02-2022
   Description: Response HTTP error
*/
function response($data) {
   echo json_encode($data);
   exit;
}

/* 
   Author : Naresh Lakhara
   Date   : 27-04-2022
   Description :  QR Code Generate 
*/
function qr_code_generate($qr_id = '0', $errorCorrectionLevel = 'L', $matrixPointSize = '10') {
   
    require_once APPPATH."third_party/php_qr_code/qrlib.php";

    $PNG_TEMP_DIR   = getcwd().'/uploads/qr_code';

    if(!file_exists($PNG_TEMP_DIR)) {
        mkdir($PNG_TEMP_DIR, 0777, true);
        if( chmod($PNG_TEMP_DIR, 0777) ) {
            chmod($PNG_TEMP_DIR, 0777);
        }
    }

    // echo '<pre>';print_r('herer'); 
    // echo '<pre>';print_r($qr_id); exit;

    $filename = getcwd().'/uploads/qr_code/'.$qr_id.'_qr_code.png';;
    QRcode::png($qr_id, $filename, $errorCorrectionLevel, $matrixPointSize, 2);               
}

?>