initAction();
$this->callAction();
}
protected function callAction()
{
if (method_exists($this, $this->actionMethod)) {
$this->{$this->actionMethod}();
}
}
protected function initAction()
{
if (empty($this->action)) {
if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {
$this->action= $_REQUEST['action'];
} else {
$this->action = $this->defaultAction;
}
}
if (key_exists($this->action, $this->actions)){
$this->actionMethod = $this->actions[$this->action];
} else {
$this->action = key($this->actions);
$this->actionMethod = current($this->actions);
}
if ($this->isXmlHttpRequest()) {
$this->actionMethod .= 'Ajax';
}
}
function _doListBind(DB_List $DB_List)
{
$DB_List->def_order_by = 'event_date DESC';
$DB_List->tableAttribs['id'] = 'member-ce-credit-history-grid';
$DB_List->insertColLast('event_date', array(
'title'=>'Date of Event',
'order_by'=>'event_date',
'width'=>120,
'tpl'=>DB_LIST_CELL_DATE,
'params'=>array('event_date'),
));
$DB_List->insertColLast('name', array(
'title'=>'Name',
'order_by'=>'name',
'width'=>220,
'tpl'=>SiteMap::getPath('Member/tpl/CECreditHistory/List/cells/name.tpl'),
'params'=>array('name'),
));
$DB_List->insertColLast('credits', array(
'title'=>'Credits Earned',
'order_by'=>'credits',
'width'=>170,
'tpl'=>DB_LIST_CELL_TEXT_CENTER,
'params'=>array('credits'),
));
$DB_List->insertColLast('attended', array(
'title'=>'Attended',
'order_by'=>'attended',
'width'=>100,
'tpl'=>DB_LIST_CELL_TEXT_CENTER,
'params'=>array('attended'),
));
$DB_List->insertColLast(
'certificate',
array(
'title' => 'CE Certificate',
'order_by' => 'certificate',
'width' => 100,
'fullAlias' => App_Event_Certificate_Obj::ADMIN_FULL_ALIAS,
'tpl' => 'Event/Certificate/cells/download.tpl',
'params' => array('allowed' => 'certificate_allowed', 'id' => 'registration_id'),
)
);
$DB_List->insertColLast('options', array(
'title'=>'Options',
'width'=>150,
'tpl'=>DB_LIST_CELL_EDIT_DEL,
'edit_link'=>BASE_URL.'/'.CURR_PAGE_FULL.'?action=edit&id=',
'del_link'=>BASE_URL.'/'.CURR_PAGE_FULL.'?action=del&id=',
'params'=>array('id'),
));
$DB_List->bind();
return true;
}
function addLink()
{
$link = BASE_URL . '/' . CURR_PAGE_FULL;
$addLink = array(
'tpl' => 'center_link.tpl',
'link_list' => array(
array(
'title' => '<< Back to individual ',
'link' => BASE_URL.'/admin/member?action=edit&id=' . $this->DBObj->memberData['id']
),
array('title' => 'Click here to add a new '.$this->DBObj->itemName, 'link' => $link . '?action=new'),
),
);
$this->Doc->addContent($addLink);
}
function _bindFormFields(Form $form)
{
$form->addElement('calendar', 'event_date', 'Date of Event');
$form->addElement('text', 'name', 'Event Name', array('style'=>'width:330px;'));
$form->addElement('text', 'credits', 'Credits Earned', array('style'=>'width:50px;'));
$form->addRuleRequired(array('name', 'credits'));
$form->addRule('credits', 'Credits Earned is in wrong format', 'numeric');
$form->addRule('credits', 'Credits Earned is in wrong format', 'numeric', null, 'client');
return $form;
}
function doNew()
{
$this->Doc->addContent(array('tpl'=>'text.tpl', 'text'=>'Use the form below to add a non-MNCAR sponsored event.
'));
$form = $this->_getNewForm();
$data = array('event_date'=>time());
$form->setDefaults($data);
$this->renderForm($form);
}
function doEdit()
{
$this->Doc->addContent(array('tpl'=>'text.tpl', 'text'=>'Use the form below to edit a non-MNCAR sponsored event.
'));
$this->DBObj->initFromDB();
$form = $this->_getEditForm();
$form->setDefaults($this->DBObj->getData());
$this->renderForm($form);
}
function doInsert()
{
$form = $this->_getNewForm();
if ($form->validate()){
$this->DBObj->initFromForm($form );
$this->DBObj->insert();
Session::setData($this->_getPage4SaveMessage(), 'msg', $this->DBObj->itemName . ' added');
$this->doBack();
}else {
$this->renderForm($form);
}
return true;
}
function doUpdate()
{
$form = $this->_getEditForm();
if ($form->validate()){
$this->DBObj->initFromForm($form);
$this->DBObj->update();
Session::setData($this->_getPage4SaveMessage(), 'msg', $this->DBObj->itemName . ' updated');
$this->doBack();
}else {
$this->renderForm($form);
}
return true;
}
function renderForm(&$form)
{
$form->cancelUrl=Constant::get('BASE_URL') . '/' . CURR_PAGE_FULL . "?action=cancel";
$form->exec();
}
}