<?php /* CityHub - Communal service - Templates (admin) */ ?>


<!-- City service Response templates start -->
<div id="cs-response-templates">
	<div class="row">
		<div class="col s12" id="vue">
			<div class="widget-holder hoverable fadeIn">
				<div class="widget-heading">
					<h2 class="widget-heading-thick"><?php echo $title; ?></h2>
					<a class="btn-floating waves-effect waves-light btn-primary new-blog-post" id="add-response-template-button" v-on:click="add()"><i class="material-icons">add</i></a>
				</div>
				<div class="widget-content" v-if="templates.length>0">
					<div class="table-wrapper">
						<table class="bordered responsive-table">
							<thead>
							<tr>
								<th><?php echo Lang::get('communalService.header_template_name'); ?></th>
								<th><?php echo Lang::get('communalService.header_template_content'); ?></th>
								<th><?php echo Lang::get('communalService.header_action'); ?></th>
							</tr>
							</thead>

							<tbody>
								<tr v-for="template in templates">
									<td>{{ template.name }}</td>
									<td v-html="template.content"></td>
									<td>
										<a v-on:click="get(template.id)" class="icon-btn icon-btn-edit"><i class="material-icons">mode_edit</i></a>
										<a :href="'templates/delete/'+template.id" class="icon-btn icon-btn-delete" title="<?php echo Lang::get('communalService.tooltip_button_delete_template'); ?>" :data-name="template.name"><i class="material-icons">delete</i></a>
									</td>
								</tr>


							</tbody>
						</table>
					</div>

				</div>
			</div>
			<div id="new-response-template-modal" class="modal">
				<div class="modal-content">
					<h4>{{ title }}</h4>
					<div class="inputs-wrapper">
						<div class="row">
							<div class="input-field col s12">
								<input id="name" v-model="response.name" type="text" class="validate" v-bind:class="invalidCheck">
								<label v-bind:class="activeCheck" v-bind:data-error="validator.name" for="name"><?php echo Lang::get('communalService.label_template_name'); ?>*</label>
							</div>
							<div class="input-field col s12">
								<textarea id="new-repot-desc" class="materialize-textarea validate" v-bind:class="invalidCheck"></textarea>
								<label for="new-repot-desc"><?php echo Lang::get('communalService.label_template_content'); ?></label>
								<div v-show="validator.content && !response.content" class="invalid">{{ validator.content }}</div>
							</div>

						</div>
					</div>
				</div>
				<div class="modal-footer right-align">
					<a class="modal-action modal-close waves-effect waves-light btn-flat modal-cancel"><?php echo Lang::get('core.cancel'); ?></a>
					<a v-on:click="submit()" class="modal-action waves-effect waves-light btn-flat modal-save"><?php echo Lang::get('core.save'); ?></a>

				</div>
				<div id="preloader-bar" class="animated fadeIn progress" v-show="preloader == 'active'">
					<div class="indeterminate"></div>
				</div>
			</div>
		</div>
	</div>
</div>
<!-- City service Response templates end
 <p><span style="font-size: 36px;"><b>Vielen Dank für die Blumen.</b></span></p>


 -->



<script>

	var templatesData = [];
	<?php foreach($templates as $template): ?>
		templatesData.push({"id":'<?php echo $template->id; ?>',"city_id":'<?php echo $template->city_id; ?>',"city_name":'<?php echo $template->city_name; ?>',"name":'<?php echo $template->name; ?>',"content":'<?php echo $template->content; ?>'});
	<?php endforeach; ?>
	console.log(templatesData);

	//controllerData = JSON.parse(controllerData.replace('"',"'"));
	//controllerData = JSON.parse(controllerData);

	var lang_confirm_delete_text = '<?php echo Lang::get('communalService.lang_confirm_delete_template'); ?>';
	var error500 = "<?php echo Lang::get('communalService.msg_error_getting_template_data'); ?>";
	var editTitle = "<?php echo Lang::get('communalService.title_edit_template', array('name'=>'')); ?>";
	var addTitle = "<?php echo Lang::get('communalService.title_add_template'); ?>";

	var urls={
	    editTemplate:"templates/get-template",
		deleteTemplate:"<?php echo URL::route('CommunalServiceGetDeleteTemplate'); ?>",
        postAddTemplate:"<?php echo URL::route('CommunalServicePostAddTemplate'); ?>",
        postEditTemplate:"<?php echo URL::route('CommunalServicePostEditTemplate'); ?>"
	}

</script>
