Current File : //etc/zpanel/panel/modules/csr/module.zpm
<div class="ajax-loader">
  <img src="./modules/csr/assets/ajaxLoader.gif" class="img-responsive ajax_img" />
</div>
<div class="zmodule_content panel" id="zmodule_header_<@ ModuleName @>">
    <div class="panel-heading">
        <img src="<@ ModuleIcon @>" width="35" height="35" border="0" alt="<@ ModuleName @>">

        <div class="zmodule_title">
            <@ ModuleName @>
        </div>
		
        <div class="zmodule_desc" id="zmodule_desc_<@ ModuleName @>"><@ ModuleDesc @></div>

    </div>

        <style>
.helpicon {
display: block;
float: right;
border: 1px solid #ccc;
background-color: #f3f3f3;
padding: 5px 10px;
font-size: 12px;
margin-top:-121px;
margin-right:5px;
-webkit-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: -8px 7px 5px 0px rgba(204,204,204,1);
-webkit-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
-moz-box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
box-shadow: 8px 7px 5px 0px rgba(204,204,204,1);
}

</style>
<div class="helpicon">
<a href="<@ helpicon @>" target="_blank"><img src="etc/styles/CstyleX-master/images/help.png" style="float:left;" ><span style="float:left;margin-top:8px;font-weight:bold;font-size:12px;" >Video Tutorial</span></a>
</div>

	<% if isDisplayResultSuccess %>
		<div class="alert alert-block alert-info">
		<button type="button" Id="close_button" onClick="CloseParent();" class="close" data-dismiss="alert">×</button>
		<p><strong>Success:</strong> CSR Certificate generated. Please check below tab... .</p>
		</div>
	<% endif %>
	
	<% if isDisplayResultFailed %>
		<div class="alert alert-block alert-info">
		<button type="button" Id="close_button" onClick="CloseParent();" class="close" data-dismiss="alert">×</button>
		<p><strong>Failed:</strong> CSR Certificate not generated. Please generate again ...</p>
		</div>
	<% endif %>
	
	<div id="zform_wrapper">
		<@ Result @>
	</div>			
	
	<div class="zform_wrapper">
		<form action="./?module=csr&action=DisplayLogs" method="post">
            <table class="zform" width="100%" cellborder="0" cellspacing="0">
               <tr>
                   <th nowrap="nowrap"><: Domain :>:</th>
                   <td>
                     <select name="domain_id" id="domain_id">
                        <% loop Domains %>
                        <option value="<& id &>"<& selected &>><& name &></option>
                        <% endloop %>
                     </select>
                   </td>
               </tr>
               <tr>
                   <th nowrap="nowrap"><: Log Type :>:</th>
                   <td>
                     <select name="log_type_id" id="log_type_id">
                        <% loop ErrorTypes %>
                        <option value="<& id &>"<& selected &>><& name &></option>
                        <% endloop %>
                     </select>
                   </td>
               </tr>
                <tr>
                    <th></th>
                    <td>
                       <button class="btn btn-primary" type="submit" id="button" name="ViewLogs" value="1">View Logs</button>
                    </td>
                </tr>
            </table>
            <@ CSFR_Tag @>
        </form>        
    </div>
    
	
 <% if isDisplayLogs %>
    <div class="zform_wrapper">
        <h2><@ ErrorType @></h2><& list &>
	    <div class="logview-container" style="overflow: auto;">
	        <@ DisplayLogs @>
	    </div>
	</div>
	<% endif %>						
    
    <div class="zgrid_wrapper">
        <table class="none" width="100%" cellborder="0" cellspacing="0">
            <tr valign="top">
                <td>
                    <h2><: Create a CSR Certificate :></h2>
                        <table class="table table-striped">
                            <tr>
                                <th nowrap="nowrap"><: Email Address :>:</th>
								<td style="padding-top: 4px;"> <@ EmailList @> </td>
                            </tr>
                            <tr>
                                <th nowrap="nowrap"><: Domain :>:</th>
                                <td style="padding-top: 4px;">
                                    <select name="inDomain" id="inDomain" style="width: 173px;">
                                        <option value="" selected="selected">-- <: Select a domain :> --</option>
                                        <% loop DomainList %>
                                        <option value="<& domain &>"><& domain &></option>
                                        <% endloop %>
                                    </select>
                                </td>
                            </tr>
							 <tr>
                                <th nowrap="nowrap"><: Organization :>:</th>
								<td style="padding-top: 4px;"> <input type="text" name="inOrganization" id="inOrganization" /></td>
                            </tr>
							<tr>
                                <th nowrap="nowrap"><: Department :>:</th>
								<td style="padding-top: 4px;"> <input type="text" name="inDepartment" id="inDepartment" /></td>
                                
                            </tr>
							<tr>
                                <th nowrap="nowrap"><: City :>:</th>
								<td style="padding-top: 4px;"> <input type="text" name="inCity" id="inCity" /></td>
                                
                            </tr>
							<tr>
                                <th nowrap="nowrap"><: State / Province :>:</th>
								<td style="padding-top: 4px;"> <input type="text" name="inState" id="inState" /></td>
                                
                            </tr>
							<tr>
                                <th nowrap="nowrap"><: Country :>:</th>
                                <td style="padding-top: 4px;">
                                    <select name="inCountry" id="inCountry" style="width: 174px;">
                                        <% loop CountryList %>
                                        <option value="<& Short &>"><& Country &></option>
                                        <% endloop %>
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>&nbsp;</th>
                                <td><button class="btn btn-primary" type="submit" name="Createcsr" id="Createcsr" value="inCreate"><: Create :></button></td>
                                <td></td>
                            </tr>
                        </table>
                        <@ CSFR_Tag @>                 
                </td>
            </tr>
        </table>
    </div>
</div> 


<script type="text/javascript">
    $(document).ready(function(){
	
		$.ajax({
		type: 'POST',
		url: './?module=csr&action=csrList',
		success: function(data) {
		$("#zgrid_wrapper").html(data);
		},
		error: function(ts) { 
		console.log(ts.responseText);

		}
		});

        $("#Createcsr").click(function(){
			$('.ajax-loader').css("visibility", "visible");
			$("#zloader_overlay").show();
			$("#zloader").show();

			var inDomain=$("#inDomain option:selected").val();
			if(inDomain ==""){
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				alert("Please Select Your Domain");
				document.getElementById("inDomain").focus();
				return false;
			}
			
			var inOrganization=$("#inOrganization").val();
			if(inOrganization ==""){
				alert("Please Enter Your Organization Name");
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				document.getElementById("inOrganization").focus();
				return false;
			}
			
			var inDepartment=$("#inDepartment").val();
			if(inDepartment ==""){
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				alert("Please Enter Your Department");
				document.getElementById("inDepartment").focus();
				return false;
			}
			
			var inCity=$("#inCity").val();
			if(inCity ==""){
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				alert("Please Enter Your City");
				document.getElementById("inCity").focus();
				return false;
			}
			
			var inState=$("#inState").val();
			if(inState ==""){
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				alert("Please Enter Your State");
				document.getElementById("inState").focus();
				return false;
			}
			
			var inCountry=$("#inCountry option:selected").val();
			if(inCountry ==""){
				$("#zloader_overlay").hide();
				$("#zloader").hide();
				$('.ajax-loader').css("visibility", "hidden");
				alert("Please Select Your Country");
				document.getElementById("inCountry").focus();
				return false;
			}
			var xhr = $.ajax({

                type: 'POST',
                url: './?module=csr&action=Createcsr',
				data:{inDomain:inDomain, inOrganization:inOrganization, inDepartment:inDepartment,inCity:inCity, inState:inState, inCountry:inCountry},
               	success: function(data) {
					$('#close_button').trigger("click");

						$.ajax({
								type: 'POST',
								url: './?module=csr&action=csrList',
								success: function(data) {
									$.ajax({

										url : './?module=csr&action=csrSock',
										type : 'POST',
										data:{inDomain:inDomain, inOrganization:inOrganization, inDepartment:inDepartment,inCity:inCity, inState:inState, inCountry:inCountry},
										success : function (result) {
											$("#inOrganization").val("");
											$("#inDepartment").val("");
											$("#inCity").val("");
											$("#inState").val("");
											console.log (result);
											result=result.replace("\n","");
										//	$("#zloader_overlay").hide();
										//	$("#zloader").hide();
											window.location.href = './?module=csr&result='+result;
										},
										error : function () {
											console.log ('error');
										}

									});	
								},
								error: function(ts) { 
								console.log(ts.responseText);

								}
						});
				},
				error: function(ts) { 
					console.log(ts.responseText);
				//	$("#zloader_overlay").hide();
				//	$("#zloader").hide();
				}
			});
			//xhr.abort();
		});
	});
function CloseParent()
{
	$("#close_button").parent().hide();
}

function showLog()
{
	$.ajax({
		url : './?module=csr&action=showLogcontent',
		type : 'POST',
		data:{inDomain:inDomain},
		success : function (result) {
			$("#zform_wrapper").html(result).addClass('alert alert-block alert-info');
		},
		error : function () {
			console.log ('error');
		}
	}); 
	return false;
}
</script>

<style>
td, th {
    padding: 5px !important;
}
.ajax-loader {
	visibility: hidden;
	background-color: rgba(255,255,255,0.7);
	position: absolute;
	z-index: +100 !important;
	width: 100%;
	height: 100%; 
    max-width: 100px;
    left: 58%;
    top: 30%;
}
 
</style>