<?php
namespace App\Smarty\Functions; class FrequentBuyerCardLabel { static public function create($params, $smarty) { $defaultOutput = ''; if ($params['default']) { $defaultOutput = $params['default']; } if (is_object($params['ref']) and get_class($params['ref'])=='Entity\FrequentBuyerCard') { $frequentBuyerCard = $params['ref']; } elseif ( is_numeric($params['ref']) and $params['ref']>0 ) { $frequentBuyerCard = \Entity\FrequentBuyerCard::select($params['ref']); if (!$frequentBuyerCard->recordExists()) { return $defaultOutput; } } else { return $defaultOutput; } if ($params['assign']) { $smarty->assign($params['assign'], $frequentBuyerCard); return ''; } if ($params['hideLink']) { return $frequentBuyerCard->cardNumber ? $frequentBuyerCard->cardNumber : "#{$frequentBuyerCard->getId()}"; } else { return sprintf("<span class=\"remoteLoadLink\" onclick=\"RemoteLoad.loadEntity(this, '%s', '%s');\">%s</span>", 'frequentBuyerCard', $frequentBuyerCard->getId(), ($frequentBuyerCard->cardNumber ?: "#{$frequentBuyerCard->getId()}")); } } }