TEMPLATE_GLOBAL_TAGS = array (
'upper',
'tofloat',
'sample_with_args',
'debug',
'url',
'url2',
'function_deny',
'isset',
'empty',
'make_date',
'inarray' ,
'getGlobals'
);
/**
* Define as class (optional)
* class TemplateTag { public static test(){} public static test2(){} }
*/
function getGlobals($var) {
if ($var=='NEW')
getReceiptCount();
elseif ($var=='NEW2')
getExeCount();
//echo $GLOBALS['NEW'].'
';
return $GLOBALS[$var] ;
}
function inarray($v1, $v2) {
return in_array ( $v1, $v2 );
}
function make_date() {
return date ( "Y-m" );
}
function upper($str) {
return strtoupper ( $str );
}
function tofloat($str) {
return sprintf ( "%.2f", $str );
}
function sample_with_args($str, $prefix) {
return $str . ' with args: ' . $prefix;
}
function debug($var) {
if (! empty ( $var )) {
echo '
'; print_r ( $var ); echo ''; } } // This will be called when a function NOT Registered is used in IF or ElseIF statment function function_deny($var = null) { echo 'Function denied in IF or ElseIF statement!'; exit (); } // Build URL based on route id function url($id, $param = null, $addRootUrl = false) { Doo::loadHelper ( 'DooUrlBuilder' ); // param pass in as string with format // 'param1=>this_is_my_value, param2=>something_here' if ($param != null) { $param = explode ( ', ', $param ); $param2 = null; foreach ( $param as $p ) { $splited = explode ( '=>', $p ); $param2 [$splited [0]] = $splited [1]; } return DooUrlBuilder::url ( $id, $param2, $addRootUrl ); } return DooUrlBuilder::url ( $id, null, $addRootUrl ); } // Build URL based on controller and method name function url2($controller, $method, $param = null, $addRootUrl = false) { Doo::loadHelper ( 'DooUrlBuilder' ); // param pass in as string with format // 'param1=>this_is_my_value, param2=>something_here' if ($param != null) { $param = explode ( ', ', $param ); $param2 = null; foreach ( $param as $p ) { $splited = explode ( '=>', $p ); $param2 [$splited [0]] = $splited [1]; } return DooUrlBuilder::url2 ( $controller, $method, $param2, $addRootUrl ); } return DooUrlBuilder::url2 ( $controller, $method, null, $addRootUrl ); } function getReceiptCount(){ $status=2; $year=date('Y'); Doo::loadModel('receipt'); $receipt=new receipt(); $dateCondition=" and Year(date) =".$year; $approvalCondition=' and nowStaff like "%'.$_COOKIE["staff"].'%" '; $receiptList=$receipt->find(array('where'=>' status='.$status.$dateCondition.$approvalCondition,'desc'=>'rid','asArray'=>true)); $GLOBALS['NEW']= count($receiptList); } function getExeCount(){ Doo::loadModel('receipt'); $receipt=new receipt(); $receiptList=$receipt->find(array('where'=>'(executeCopy like \'%["'.$_COOKIE["staff"].'%\' and executeStaff NOT LIKE \'%'.$_COOKIE["staff"].'%\' ) and (status=1 or status=6)','desc'=>'rid','asArray'=>true)); $GLOBALS['NEW2']= count($receiptList); } ?>