miniCal
  • Quick Start
    • Introduction
  • miniCal Configuration
    • miniCal Hosted Service
    • Configure Feature Settings
    • Install Extensions
    • Create Multiple Properties
  • Local Installation
    • Local Installation
    • ENV Set-Up
    • Configuration Settings
    • Common Installations Errors
  • Contribution
    • Contribute to miniCal Core
  • Build an Extension
    • Build Your First Extension
      • Controllers
      • Assets
      • Config
      • language
      • Models
      • View
      • Helper
      • Library
      • Hooks
    • Open-source Extensions
    • Config Folder Files
      • Autoload File
      • Config File
      • Route File
    • miniCal Filters
    • miniCal Actions
    • Create Custom Hooks
    • Store Custom Data
      • POSTS
      • POSTMETA
      • OPTIONS
    • Composer Dependencies
  • Marketplace
    • miniCal Marketplace
  • Other resources
    • Overbooking for OTAs
    • miniCal Cron Setup
    • Automated Night Audit
    • Nginx Configuration
    • Docker Installation
    • Custom Domain Setup
  • Minical API Docs
    • API Documentation
  • Coming soon!
    • Access minical Data Using Helpers
      • Company Helper Functions
      • Customer Helper Functions
      • Booking Helper Functions
      • Rates Helper Functions
      • Rate Plan Helper Functions
      • Availability Helper Functions
      • Statement Helper Functions
      • Tax Helper Functions
      • Room Helper Functions
      • Charge Helper Functions
      • Payment Helper Functions
    • Access data in Extension
Powered by GitBook
On this page
  1. Build an Extension
  2. Build Your First Extension

Library

The library is a class with functions or methods that allows creating an instance of that class. For your extensions you can add a library under the libraries folder, the naming convention should be like GreetingEmail.php. here is an example of a library.

<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class GreetingEmail {

    public function __construct()
    {
        $this->ci =& get_instance();

        $this->ci->load->library('Email');
        $this->module_name = 'minical-extension-boilerplate';

    }   

    function send_greeting_email()
    {
        $company_id = $this->ci->session->userdata('current_company_id');
        $company = $this->ci->Company_model->get_company($company_id);

        $content =  'Dear [first name] I hope this email finds you well';
        $content1 = "<br/><br/>".'Thank you for your business'.",<br/><br/>"
            .$company['name']."
                <br/>".$company['email']. "<br/>".$company['phone']."<br/>";


        $config['mailtype'] = 'html';

        $this->ci->email->initialize($config);

        $email_data = array (
            'company_name' => $company['name'],
            'company_email' => $company['email'],
            'content' => $content,
            'content1' => $content1
        );

        $customer_email = $company['email'];

        $from_email = 'donotreply@minical.io';

        $email_from = $company['email'];

        $this->ci->email->from($email_from, $company['name']);
        $this->ci->email->to($customer_email);
        $this->ci->email->reply_to($email_data['company_email']);

        $this->ci->email->subject('Hello From miniCal');

        $this->ci->email->message($this->ci->load->view('../extensions/'.$this->module_name.'/views/gretting-mail-html', $email_data, true));

        $this->ci->email->send();
        $msg = l('minical-extension-boilerplate/Email successfully sent to ', true);
        return $msg.$customer_email;
    }

}
?>

Loading of library

You can load the library into controller, hooks, helper, or model, for loading your custom extension's library use the given syntax.

$this->module_name will have the extension name as value, or you can use the hardcode extension name at its place.

//In controller 
$this->load->library('../extensions/'.$this->module_name.'/libraries/GreetingEmail');
$this->load->library('../extensions/minical-extension-boilerplate/libraries/GreetingEmail');

//In hooks and filter
$CI = &get_instance();
$CI->load->library('../extensions/minical-extension-boilerplate/libraries/GreetingEmail');
 
PreviousHelperNextHooks

Last updated 3 years ago