{*
Event details (editable)
This Template displays the detailed information for an event
The difference to event_view.tpl is, that this template provides
a editable view.
This template is used for different tasks:
* if you add a new event
* if you edit a existing event
The event is only written to the backend if all fields are valid and all mandatory
fields are present. Until this is the case, the event only resides inside memory.
The events Data must be transmitted using HTTP POST inside the array
lcc_new_data. Name Input fields like this:
<input ... name="lcc_new_data[my_event_field]">
To display modified data, we can use smartys "default" modifier.
If there is POST data for the field, display it in favor of assigned data.
This saves us much trouble that must be handled inside the core otherwise.
Additionally, a design could be implemented that doesn't have this feature.
Implement it like this:
<input ... value="{$smarty.post.my_event_field|default:$data.my_event_field}">
For the case if a new event was created, we get a new id from the backend which is not equal the id
we transmitted in $_GET['id']. For this reason, we must write something like this:
<form ... action=" ... &id={$data.id|default:$smarty.get.lcc_id}">
This way, SMARTY will use the ID assiged either from the existing event or from the URL.
If you make a mistake here, then it will be possible that the same event is added over and over.
The language variables of event fields should be "lcc_event_" + field name, so
automatic language resulution is possible in case of an error.
To support dynamic display of mandatory fields, we use the LCC_Core object available to every template.
Through the core object we can fetch the loaded driver which in turn can check various states of
fields!
{if $LCC_EVENTDRIVER->checkField('title', 'mandatory')}<span class="mandatory_field">*</span>{/if}
The same is possible to disable input elements that are not writable:
<input ... name="lcc_new_data[title]" {if $LCC_EVENTDRIVER->checkField('title', 'writable')}disabled="disabled"{/if}
Variables assigned by the core:
$data Data of this event as it comes from $event->getData().
This is a associative array containing the fields of the event
If this is a new event, $data == false.
*}
{* Fetch EventDriver from core: *}
{assign var=LCC_EVENTDRIVER value=$LCC_CORE->getEventDriverInstance()}
<form method="POST" action="{$smarty.server.SCRIPT_NAME}?lcc_action=edit_event&lcc_id={$data.id|default:$smarty.get.lcc_id}">
<table class="event_edit_form">
<caption>{if $data}{#lcc_edit_event_title#} {$data.id}{else}{#lcc_edit_event_addtitle#}{/if}</caption>
<tr>
<th>{#lcc_event_desc_title#} {if $LCC_EVENTDRIVER->checkField('title', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><input type="text" name="lcc_new_data[title]" value="{$smarty.post.lcc_new_data.title|default:$data.title}" {if !$LCC_EVENTDRIVER->checkField('title', 'writable')}disabled="disabled"{/if}></td>
</tr>
<tr>
<th>{#lcc_event_desc_start_date#} {if $LCC_EVENTDRIVER->checkField('start_date', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><input type="text" name="lcc_new_data[start_date]" value="{$smarty.post.lcc_new_data.start_date|default:$data.start_date|convertDate}" {if !$LCC_EVENTDRIVER->checkField('start_date', 'writable')}disabled="disabled"{/if}></td>
</tr>
<tr>
<th>{#lcc_event_desc_end_date#} {if $LCC_EVENTDRIVER->checkField('end_date', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><input type="text" name="lcc_new_data[end_date]" value="{$smarty.post.lcc_new_data.end_date|default:$data.end_date|convertDate}" {if !$LCC_EVENTDRIVER->checkField('end_date', 'writable')}disabled="disabled"{/if}></td>
</tr>
<tr>
<th>{#lcc_event_desc_start_time#} {if $LCC_EVENTDRIVER->checkField('start_time', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><input class="time" type="text" name="lcc_new_data[start_time]" value="{$smarty.post.lcc_new_data.start_time|default:$data.start_time}" {if !$LCC_EVENTDRIVER->checkField('start_time', 'writable')}disabled="disabled"{/if}></td>
</tr>
<tr>
<th>{#lcc_event_desc_end_time#} {if $LCC_EVENTDRIVER->checkField('end_time', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><input class="time" type="text" name="lcc_new_data[end_time]" value="{$smarty.post.lcc_new_data.end_time|default:$data.end_time}" {if !$LCC_EVENTDRIVER->checkField('end_time', 'writable')}disabled="disabled"{/if}></td>
</tr>
<tr>
<th>{#lcc_event_desc_color#} {if $LCC_EVENTDRIVER->checkField('color', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td>
<input class="time" onkeyup="javascript:updateColorpreview()" ID="color_1" type="text" name="lcc_new_data[color]" value="{$smarty.post.lcc_new_data.color|default:$data.color|default:"#f0f0f0"}" {if !$LCC_EVENTDRIVER->checkField('color', 'writable')}disabled="disabled"{/if}>
<input onclick="showColorGrid3('color_1','sample_1');" class="colorpreview" ID="sample_1">
</td>
</tr>
<tr>
<th>{#lcc_event_desc_description#} {if $LCC_EVENTDRIVER->checkField('description', 'mandatory')}<span class="mandatory_field">*</span>{/if}</th>
<td><textarea name="lcc_new_data[description]" {if !$LCC_EVENTDRIVER->checkField('description', 'writable')}disabled="disabled"{/if}>{$smarty.post.lcc_new_data.description|default:$data.description}</textarea></td>
</tr>
<tr>
<td colspan="2">
<div class="mandatory_text">
<span class="mandatory_field">*</span>{#lcc_edit_event_mandatory#}
</div>
<center>
<input type="reset" value="{#lcc_edit_event_reset#}">
<input type="submit" value="{#lcc_edit_event_submit#}">
</center>
</td>
</tr>
</table>
</form>
<div>
<a href="{$smarty.server.SCRIPT_NAME}?lcc_action=show_calendar">{#lcc_link_backtocalendar#}</a>
{if $data.id && $LCC_CORE->checkRight('event_del')}| <a href="{$smarty.server.SCRIPT_NAME}?lcc_action=delete_event&lcc_id={$data.id}">{#lcc_link_deletethisevent#}</a>{/if}
</div>
{* Include colorpicker JS code *}
<div id="colorpicker301" class="colorpicker301"></div>
<script type="text/javascript">
<!--
{include file="freecolorpicker.js"}
-->
{* Additionally, here is a small script, that will update the color preview *}
{literal}
function updateColorpreview() { document.getElementById('sample_1').style.background = document.getElementById('color_1').value; }
updateColorpreview(); // issue initial update
{/literal}
</script>