<?php

/*
Module Name: Swiss QR Code
Description: Swiss QR Code Addon for PerfexCRM
Version: 1.0
Requires at least: 2.9.3
Author: thomassommer.org
Author URI: allmybusiness.ch
License: MIT
*/

defined('BASEPATH') or exit('No direct script access allowed');

define('SWISSQRCODE_MODULE_NAME', 'swissqrcode');

register_language_files(SWISSQRCODE_MODULE_NAME, [SWISSQRCODE_MODULE_NAME]);

hooks()->add_action('admin_init', 'swissqrcode_init_settings');
hooks()->add_action('pdf_close', 'swissqrcode_image_footer');

function swissqrcode_init_settings()
    {
    $CI = &get_instance();
    $CI->app_tabs->add_settings_tab('swissqrcode', [
        'name' => _l('swissqrcode'),
        'view' => SWISSQRCODE_MODULE_NAME . '/settings',
        'position' => 70,
    ]);
    }

// render Swiss QR Code upon pdf close event
function swissqrcode_image_footer($data)
    {    
    $ci = &get_instance();
    $ci->load->library(SWISSQRCODE_MODULE_NAME . '/swissqrcode_module');
    $ci->swissqrcode_module->render($data);
    }
