returnForm($url, 'add'); // The validation or display if ($form->validate()) { if ($check) { $values = $form->exportValues(); $values['template'] = $values['email_template']; $values['author_id'] = api_get_user_id(); $values['url_id'] = api_get_current_access_url_id(); $res = $mailTemplate->save($values); if ($res) { Display::addFlash(Display::return_message(get_lang('ItemAdded'), 'confirm')); } } header('Location: '.api_get_self()); exit; } else { $content .= '
'; $content .= Display::url( Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM), api_get_self() ); $content .= '
'; $form->addElement('hidden', 'sec_token'); $form->setConstants(['sec_token' => $token]); $content .= $form->returnForm(); } break; case 'edit': $url = api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&id='.$id; $form = $mailTemplate->returnForm($url, 'edit'); $content .= '
'; $content .= Display::url( Display::return_icon('back.png', get_lang('Back'), '', ICON_SIZE_MEDIUM), api_get_self() ); $content .= '
'; $content .= $form->returnForm(); // The validation or display if ($form->validate()) { //if ($check) { $values = $form->exportValues(); $values['template'] = $values['email_template']; $res = $mailTemplate->update($values); if ($res) { Display::addFlash( Display::return_message(get_lang('ItemUpdated').': '.$values['name'], 'confirm') ); } //} header('Location: '.api_get_self()); exit; } break; case 'delete': $mailTemplate->delete($id); Display::addFlash( Display::return_message(get_lang('Deleted'), 'confirm') ); header('Location: '.api_get_self()); exit; break; case 'set_default': $mailTemplate->setDefault($id); Display::addFlash( Display::return_message(get_lang('Updated'), 'confirm') ); header('Location: '.api_get_self()); break; case 'list': $url = api_get_path(WEB_AJAX_PATH).'model.ajax.php?a=get_mail_template'; $columns = [ get_lang('Name'), get_lang('Type'), get_lang('Default'), get_lang('Actions'), ]; $column_model = [ [ 'name' => 'name', 'index' => 'name', 'width' => '180', 'align' => 'left', ], [ 'name' => 'type', 'index' => 'type', 'width' => '100', 'align' => 'left', ], [ 'name' => 'default_template', 'index' => 'default_template', 'width' => '100', 'align' => 'left', 'hidden' => 'true', ], [ 'name' => 'actions', 'index' => 'actions', 'width' => '100', 'align' => 'left', 'formatter' => 'action_formatter', 'sortable' => 'false', ], ]; $extra_params['autowidth'] = 'true'; //use the width of the parent //$extra_params['editurl'] = $url; //use the width of the parent $extra_params['height'] = 'auto'; //use the width of the parent //With this function we can add actions to the jgrid $action_links = 'function action_formatter (cellvalue, options, rowObject) { var defaultIcon = ""; if (rowObject[2] == 1) { defaultIcon = ""; } return \' '. ' \'+ defaultIcon + \''. '  \'; }'; $content = $mailTemplate->display(); $content .= ' '; break; } $template = new Template(); $template->assign('content', $content); $template->display_one_col_template();