<?php
/**
 * Smarty plugin
 *
 * @category Smarty
 * @license /_licenses/untermStrich/agb_normal.pdf
 * @author Christian Wengg
 * @copyright 2009 untermStrich
 * @package Smarty
 * @subpackage plugins
 * @version $Id$
*/

/**
 * Smarty boolean view function plugin
 *
 * Purpose:  Create the view for a bool value for is_absent
 *
 * @param   array   $params Parameters:
 *                  <ul>
 *                      <li>value   boolean     The variable</li>
 *                  </ul>
 * @return  string  The field source
 */
function smarty_function_vacation_type(array $params)
{
    if (isset($params['value'])) {
        $title = '';
        if (isset($params['title'])) {
            $title = $params['title'];
        }
        if ($title==='') {
            $CI = CI_Controller::get_instance();
        }
        
        $elem = 'div';
        if (isset($params['elem'])) {
            $elem = $params['elem'];
        }
        
        if ($params['value']==Vacations_model::TYPE_ABSENT) {
            if ($title==='') {
                $title = $CI->lang->line('holidayadmin_type_absent');
            }
            return '<'.$elem.' class="dialog_make_btn14 is_absence" title="'.$title.'">AB</'.$elem.'>';
        } else {
            if ($title==='') {
                $title = $CI->lang->line('holidayadmin_holiday');
            }
            return '<'.$elem.' class="dialog_make_btn14 is_holiday_2d" title="'.$title.'">HO</'.$elem.'>';
        }
    } else {
        return '';
    }
}