From: Nik Okuntseff Date: Fri, 8 Mar 2019 17:54:42 +0000 (+0000) Subject: Work in progress on template edit. X-Git-Tag: timetracker_1.19-1~198 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=a6cc5ba9a2fb7a945f9754e9d07a8c0ac52698c3;p=timetracker.git Work in progress on template edit. --- diff --git a/WEB-INF/templates/template_edit.tpl b/WEB-INF/templates/template_edit.tpl new file mode 100644 index 00000000..6f3e406f --- /dev/null +++ b/WEB-INF/templates/template_edit.tpl @@ -0,0 +1,34 @@ +{$forms.templateForm.open} + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
{$i18n.label.thing_name} (*):{$forms.templateForm.name.control}
{$i18n.label.description}:{$forms.templateForm.description.control}
{$i18n.label.template} (*):{$forms.templateForm.content.control}
{$i18n.label.status}:{$forms.templateForm.status.control}
{$i18n.label.required_fields}
 
{$forms.templateForm.btn_submit.control}
+
+{$forms.templateForm.close} diff --git a/template_edit.php b/template_edit.php new file mode 100644 index 00000000..90e5f565 --- /dev/null +++ b/template_edit.php @@ -0,0 +1,95 @@ +isPluginEnabled('tp')) { + header('Location: feature_disabled.php'); + exit(); +} +$cl_template_id = (int) $request->getParameter('id'); +$template = ttTemplateHelper::get($cl_template_id); +if (!$template) { + header('Location: access_denied.php'); + exit(); +} +// End of access checks. + +if ($request->isPost()) { + $cl_name = trim($request->getParameter('name')); + $cl_description = trim($request->getParameter('description')); + $cl_content = trim($request->getParameter('content')); + $cl_status = $request->getParameter('status'); +} else { + $cl_name = $template['name']; + $cl_description = $template['description']; + $cl_content = $template['content']; + $cl_status = $template['status']; +} + +$form = new Form('templateForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_template_id)); +$form->addInput(array('type'=>'text','maxlength'=>'100','name'=>'name','style'=>'width: 250px;','value'=>$cl_name)); +$form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); +$form->addInput(array('type'=>'textarea','name'=>'content','style'=>'width: 250px; height: 80px;','value'=>$cl_content)); +$form->addInput(array('type'=>'combobox','name'=>'status','value'=>$cl_status, + 'data'=>array(ACTIVE=>$i18n->get('dropdown.status_active'),INACTIVE=>$i18n->get('dropdown.status_inactive')))); +$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.submit'))); + +if ($request->isPost()) { + // Validate user input. + if (!ttValidString($cl_name)) $err->add($i18n->get('error.field'), $i18n->get('label.thing_name')); + if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); + if (!ttValidString($cl_content)) $err->add($i18n->get('error.field'), $i18n->get('label.template')); + // Finished validating user input. + + if ($err->no()) { + if (ttTemplateHelper::update(array( + 'id' => $cl_template_id, + 'name' => $cl_name, + 'description' => $cl_description, + 'content' => $cl_content, + 'status' => $cl_status))) { + header('Location: templates.php'); + exit(); + } else + $err->add($i18n->get('error.db')); + } +} // isPost + +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('title', $i18n->get('title.edit_template')); +$smarty->assign('content_page_name', 'template_edit.tpl'); +$smarty->display('index.tpl');