<?php
pjUtil::printNotice(__('infoAdminNotificaionsTitle', true), __('infoAdminNotificaionsDesc', true)); 
?>
<div class="multilang"></div>
<br/><br/>

<fieldset class="fieldset white">
	<legend><?php __('lblLegendEmails');?></legend>
	<table class="pj-table" cellpadding="0" cellspacing="0" style="width: 100%">
		<thead>
			<tr>
				<th><?php __('lblOption'); ?></th>
				<th><?php __('lblValue'); ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
			for ($i = 0; $i < $count; $i++)
			{
				if ($tpl['arr'][$i]['tab_id'] == 7 && (int) $tpl['arr'][$i]['is_visible'] === 1 && (strpos($tpl['arr'][$i]['key'], 'email') > -1))
				{
				
					$rowClass = NULL;
					$rowStyle = NULL;
					if (in_array($tpl['arr'][$i]['key'], array('o_admin_email_registration_subject', 'o_admin_email_registration_message')))
					{
						$rowClass = " boxAdminRegistration";
						$rowStyle = "display: none";
						switch ($tpl['option_arr']['o_admin_email_registration'])
						{
							case '1':
								$rowStyle = NULL;
								break;
						}
					}
					if (in_array($tpl['arr'][$i]['key'], array('o_admin_email_submission_subject', 'o_admin_email_submission_message')))
					{
						$rowClass = " boxAdminSubmission";
						$rowStyle = "display: none";
						switch ($tpl['option_arr']['o_admin_email_submission'])
						{
							case '1':
								$rowStyle = NULL;
								break;
						}
					}
					$opt_text = __('opt_' . $tpl['arr'][$i]['key'] . '_text', true);
					?>
					<tr class="pj-table-row-odd<?php echo $rowClass; ?>" style="<?php echo $rowStyle; ?>">
						<td width="35%" valign="top">
							<span class="block bold"><?php __('opt_' . $tpl['arr'][$i]['key']); ?></span>
							<?php if (!empty($opt_text)) { ?>
								<span class="fs10"><?php echo nl2br($opt_text); ?></span>
							<?php } ?>
						</td>
						<td valign="top">
							<?php
							switch ($tpl['arr'][$i]['type'])
							{
								case 'string':
									if(in_array($tpl['arr'][$i]['key'], array('o_admin_email_registration_subject','o_admin_email_submission_subject')))
									{
									?>
										<?php
											foreach ($tpl['lp_arr'] as $v)
											{
												?>
												<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
													<span class="inline_block">
														<input type="text" name="i18n[<?php echo $v['id']; ?>][<?php echo $tpl['arr'][$i]['key'] ?>]" class="pj-form-field w400" value="<?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']][$tpl['arr'][$i]['key']]); ?>" />
														<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
													</span>
												</p>
												<?php
											}
										?>
									<?php
									}
									else { ?>
										<input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field w400" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" />
									<?php }
									break;
								case 'text':
									
									if(in_array($tpl['arr'][$i]['key'], array('o_admin_email_registration_message','o_admin_email_submission_message')))
									{
									?>
										<?php
											foreach ($tpl['lp_arr'] as $v)
											{
												?>
												<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
													<span class="inline_block">
														<textarea name="i18n[<?php echo $v['id']; ?>][<?php echo $tpl['arr'][$i]['key'] ?>]" class="pj-form-field" style="width: 400px; height: 200px;"><?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']][$tpl['arr'][$i]['key']]); ?></textarea>
														<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
													</span>
												</p>
												<?php
											}
										?>
										
									<?php
									}
									else { ?>
										<textarea name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field" style="width: 460px; height: 400px;"><?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?></textarea>
									<?php }
											
									break;
								case 'int':
								    ?><input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field field-int w60" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" /><?php
									break;
								case 'float':
								    ?><input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field field-float w60" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" /><?php
									break;
								case 'enum':
									?><select name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field">
									<?php
									$default = explode("::", $tpl['arr'][$i]['value']);
									$enum = explode("|", $default[0]);
									
									$enumLabels = array();
									if (!empty($tpl['arr'][$i]['label']) && strpos($tpl['arr'][$i]['label'], "|") !== false)
									{
										$enumLabels = explode("|", $tpl['arr'][$i]['label']);
									}
									
									foreach ($enum as $k => $el)
									{
										if ($default[1] == $el)
										{
											?><option value="<?php echo $default[0].'::'.$el; ?>" selected="selected"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
										} else {
											?><option value="<?php echo $default[0].'::'.$el; ?>"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
										}
									}
									?>
									</select>
									<?php
									break;
							}
							?>
						</td>
					</tr>
					<?php
				}
			}
			?>
		</tbody>
	</table>
</fieldset>

<fieldset class="fieldset white">
	<legend><?php __('lblLegendSMS');?></legend>
	<table class="pj-table" cellpadding="0" cellspacing="0" style="width: 100%">
		<thead>
			<tr>
				<th><?php __('lblOption'); ?></th>
				<th><?php __('lblValue'); ?></th>
			</tr>
		</thead>
		<tbody>
			<?php
			for ($i = 0; $i < $count; $i++)
			{
				if ($tpl['arr'][$i]['tab_id'] == 7 && (int) $tpl['arr'][$i]['is_visible'] === 1 && (strpos($tpl['arr'][$i]['key'], 'sms') > -1))
				{
					$rowClass = NULL;
					$rowStyle = NULL;
					if (in_array($tpl['arr'][$i]['key'], array('o_admin_sms_registration_message')))
					{
						$rowClass = " boxAdminSMSRegistration";
						$rowStyle = "display: none";
						switch ($tpl['option_arr']['o_admin_sms_registration'])
						{
							case '1':
								$rowStyle = NULL;
								break;
						}
					}
					if (in_array($tpl['arr'][$i]['key'], array('o_admin_sms_submission_message')))
					{
						$rowClass = " boxAdminSMSSubmission";
						$rowStyle = "display: none";
						switch ($tpl['option_arr']['o_admin_sms_submission'])
						{
							case '1':
								$rowStyle = NULL;
								break;
						}
					}
					$opt_text = __('opt_' . $tpl['arr'][$i]['key'] . '_text', true);
					?>
					<tr class="pj-table-row-odd<?php echo $rowClass; ?>" style="<?php echo $rowStyle; ?>">
						<td width="35%" valign="top">
							<span class="block bold"><?php __('opt_' . $tpl['arr'][$i]['key']); ?></span>
							<?php if (!empty($opt_text)) { ?>
								<span class="fs10"><?php echo nl2br($opt_text); ?></span>
							<?php } ?>
						</td>
						<td valign="top">
							<?php
							switch ($tpl['arr'][$i]['type'])
							{
								case 'string':
									?>
										<input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field w400" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" />
									<?php 
									break;
								case 'text':
									if(in_array($tpl['arr'][$i]['key'], array('o_admin_sms_registration_message', 'o_admin_sms_submission_message')))
									{
										foreach ($tpl['lp_arr'] as $v)
										{
											?>
											<p class="pj-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
												<span class="inline_block">
													<textarea name="i18n[<?php echo $v['id']; ?>][<?php echo $tpl['arr'][$i]['key'] ?>]" class="pj-form-field" style="width: 400px; height: 200px;"><?php echo pjSanitize::html(@$tpl['arr']['i18n'][$v['id']][$tpl['arr'][$i]['key']]); ?></textarea>
													<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
												</span>
											</p>
											<?php
										}
									}else { 
										?>
										<textarea name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field" style="width: 460px; height: 400px;"><?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?></textarea>
										<?php 
									}	
									break;
								case 'int':
								    ?><input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field field-int w60" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" /><?php
									break;
								case 'float':
								    ?><input type="text" name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field field-float w60" value="<?php echo pjSanitize::html($tpl['arr'][$i]['value']); ?>" /><?php
									break;
								case 'enum':
									?><select name="value-<?php echo $tpl['arr'][$i]['type']; ?>-<?php echo $tpl['arr'][$i]['key']; ?>" class="pj-form-field">
									<?php
									$default = explode("::", $tpl['arr'][$i]['value']);
									$enum = explode("|", $default[0]);
									
									$enumLabels = array();
									if (!empty($tpl['arr'][$i]['label']) && strpos($tpl['arr'][$i]['label'], "|") !== false)
									{
										$enumLabels = explode("|", $tpl['arr'][$i]['label']);
									}
									
									foreach ($enum as $k => $el)
									{
										if ($default[1] == $el)
										{
											?><option value="<?php echo $default[0].'::'.$el; ?>" selected="selected"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
										} else {
											?><option value="<?php echo $default[0].'::'.$el; ?>"><?php echo array_key_exists($k, $enumLabels) ? stripslashes($enumLabels[$k]) : stripslashes($el); ?></option><?php
										}
									}
									?>
									</select>
									<?php
									break;
							}
							?>
						</td>
					</tr>
					<?php
				}
			}
			?>
		</tbody>
	</table>
</fieldset>
<p><input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" /></p>