summaryrefslogblamecommitdiffstats
path: root/modules-available/dozmod/templates/templates.html
blob: 3ee0ccbcae7079fecf8b360e276921357c76aba5 (plain) (tree)
1
2
3
4
5
6
7
8
9
                                 
 




                                      
 
                                                              
 


                                                                                                            
 
 
                                                                
 
                                      
 














                                                                                                                                                    
 
                                              
                                      




































                                                                                                                                                                            
                                              
                                      
                              

 

                                      
 
                                                                                                                                                                                                                                      


                                                                              
                             
                                                                                                                                                                                                             
                              



















                                                                                                                                                          

                                            
              

      

 





                                                    
                             









                                                                            
                                                                    









                                                                 

                                                      
                                                    



                                                          
                                                                                                                    
                                                                                          



                                                                                                



                                            
                                                        



                 

                                             
         
                  


                                                           
                                                                      
   

              
<h1>{{lang_bwlehrpoolsuite}}</h1>

<div class="panel panel-default">
	<div class="panel-heading">
		{{lang_mailTemplates}}
	</div>
	<div class="panel-body">

		<p><i>{{lang_templatePageDescription}}</i></p>

		<form id="templateForm" role="form" method="POST" action="?do=dozmod&amp;section=templates">
			<input type="hidden" name="token" value="{{token}}">
			<input type="hidden" name="action" value="save">


			<div class="panel-group" id="accordion">

			{{#templates}}

			<div id="frame_{{name}}" class="panel panel-default">
				<div class="panel-heading">
					<div class="panel-title">
						{{#conflict}}
							<span class="glyphicon glyphicon-exclamation-sign pull-left text-danger"></span>
						{{/conflict}}
						{{#modified}}
							<span class="glyphicon glyphicon-pencil pull-left"></span>
						{{/modified}}
						<h4>
							<a class="collapsed" data-toggle="collapse" data-parent="#accordion" href="#panel_{{name}}">
							{{name}}
							</a>
						</h4>
						<small>{{description}}</small>

					</div>
				</div>
				<div id="panel_{{name}}" class="panel-collapse collapse">
					<div class="panel-body">
						<div id="msgbox_{{name}}">
						</div>

						<label for="ta_{{name}}">{{lang_template}}</label>
						<div class="form-group">
							<textarea data-mandatory="{{list_mandatoryVariables}}" name="templates[{{name}}][template]"
										 data-setting="{{name}}" id="ta_{{name}}"
										 class="form-control templateEditor" style="min-height:200px">{{template}}</textarea>
						</div>

						<h4>{{lang_placeholders}}</h4>
						<select name="templates[{{name}}][mandatory_variables]" multiple="multiple" class="hidden">
							{{{html_mandatoryVariables}}}
						</select>
						<select name="templates[{{name}}][optional_variables]" multiple="multiple" class="hidden">
							{{{html_optionalVariables}}}
						</select>
						<ul>
							{{{html_availableVariables}}}
						</ul>
						{{#original_template}}
							<textarea class="hidden" id="orig_{{name}}">{{original_template}}</textarea>
							<div class="pull-right">
								<a href="#" class="btn btn-default" onclick="$('#ta_{{name}}').val($('#orig_{{name}}').val());return false">
									<span class="glyphicon glyphicon-refresh"></span>
									{{lang_replaceWithOriginal}}
								</a>
							</div>
						{{/original_template}}
						<div class="small">
							{{lang_modified}}: {{#modified}}<b>{{lang_yes}}</b>{{/modified}}{{^modified}}{{lang_no}}{{/modified}},
							{{lang_hasNewer}}: {{#conflict}}<b>{{lang_yes}}</b>{{/conflict}}{{^conflict}}{{lang_no}}{{/conflict}},
							{{lang_thisVersion}}: {{edit_version}},
							{{lang_latestVersion}}: {{version}}
						</div>
					</div>
				</div>
			</div>


			{{/templates}}
			</div>

			<button {{^allowedSave}}disabled{{/allowedSave}} type="submit" onclick="return validateForm()" class="btn btn-primary pull-right"><span class="glyphicon glyphicon-floppy-disk"></span> {{lang_save}}</button>
		</form>
		<form method="POST" action="?do=dozmod&amp;section=templates">
			<input type="hidden" name="token" value="{{token}}">
			<div>
				<button {{^allowedReset}}disabled{{/allowedReset}} type="button" data-toggle="modal" data-target="#resetTemplatesModal" class="btn btn-danger">{{lang_loadDefaults}}</button>
			</div>

			<div id="resetTemplatesModal" class="modal fade" role="dialog">
				<div class="modal-dialog">
					<div class="modal-content">
						<div class="modal-header">
							<button type="button" class="close" data-dismiss="modal">&times;</button>
							<h4 class="modal-title"></h4>
						</div>
						<div class="modal-body">
							<p>{{lang_reallyResetTemplates}}</p>
						</div>
						<div class="modal-footer">
							<button type="button" class="btn btn-default" data-dismiss="modal">{{lang_cancel}}</button>
							<button type="submit" name="action" value ="reset" class="btn btn-primary">{{lang_reset}}</button>
						</div>
					</div>

				</div>
			</div>

		</form>
		<div class="clearfix"></div>
	</div>
</div>



<script type="application/javascript"><!--


/* check that all necessary placeholders are used */
function validateForm() {
	var ok = true;
	var $toppest = false;

	$('.templateEditor').each(function (i, editor) {

		var id = $(editor).attr('id');
		var setting = $(editor).attr('data-setting');
		var mandatory = $(editor).attr('data-mandatory').split(",");
		var value = $(editor).val();


		/* ? */
		if (mandatory.length === 1 && mandatory[0] === "") {
			mandatory = [];
		}

		var missing = [];

		mandatory.forEach(function (v,i) {
			if (value.indexOf("%" + v + "%") == -1) {
				missing.push(v);
			}
		});

		var $msgBox = $("#msgbox_" + setting);
		var $frame = $("#frame_" + setting);

		if (missing.length > 0) {
			/* add errors */
			var missingL = missing.join(", ");
			var msg="<strong>{{lang_error}}:</strong> {{lang_followingPlaceholdersUnused}}: " +missingL;
			$msgBox.html('<div class="alert alert-danger">' + msg + '</div>');
			$frame.addClass('witherror');
			if ($toppest === false || $toppest.offset().top > $frame.offset().top) {
				$toppest = $frame;
			}
			/* overall result */
			ok = false;
		} else {
			$msgBox.html("");
			$frame.removeClass('witherror');
		}


	});
	if ($toppest !== false) {
		$toppest[0].scrollIntoView();
	}
	return ok;
}

document.addEventListener("DOMContentLoaded", function () {
	validateForm(); // Do once in case invalid templates are in DB
});

//--></script>