riainvoice/application/modules/invoices/models/Mdl_templates.php
gandhimathi Bharathirajan c940cb1a2c all files
2017-09-11 14:38:03 +05:30

71 lines
1.6 KiB
PHP

<?php
if (!defined('BASEPATH')) exit('No direct script access allowed');
/*
* InvoicePlane
*
* @author InvoicePlane Developers & Contributors
* @copyright Copyright (c) 2012 - 2017 InvoicePlane.com
* @license https://invoiceplane.com/license.txt
* @link https://invoiceplane.com
*/
/**
* Class Mdl_Templates
*/
class Mdl_Templates extends CI_Model
{
/**
* @param string $type
* @return array
*/
public function get_invoice_templates($type = 'pdf')
{
$this->load->helper('directory');
if ($type == 'pdf') {
$templates = directory_map(APPPATH . '/views/invoice_templates/pdf', true);
} elseif ($type == 'public') {
$templates = directory_map(APPPATH . '/views/invoice_templates/public', true);
}
$templates = $this->remove_extension($templates);
return $templates;
}
/**
* @param $files
* @return mixed
*/
private function remove_extension($files)
{
foreach ($files as $key => $file) {
$files[$key] = str_replace('.php', '', $file);
}
return $files;
}
/**
* @param string $type
* @return array|mixed
*/
public function get_quote_templates($type = 'pdf')
{
$this->load->helper('directory');
if ($type == 'pdf') {
$templates = directory_map(APPPATH . '/views/quote_templates/pdf', true);
} elseif ($type == 'public') {
$templates = directory_map(APPPATH . '/views/quote_templates/public', true);
}
$templates = $this->remove_extension($templates);
return $templates;
}
}