<?php
if (isset($tpl['status']))
{
	$status = __('status', true);
	switch ($tpl['status'])
	{
		case 2:
			pjUtil::printNotice(NULL, $status[2]);
			break;
	}
} else {
	
	pjUtil::printNotice(__('infoAddFleetTitle', true, false), __('infoAddFleetDesc', true, false));
	
	$index = 'tr_' . rand(1, 999999);
	?>
	<form action="<?php echo $_SERVER['PHP_SELF']; ?>?controller=pjAdminFleets&amp;action=pjActionCreate" method="post" id="frmCreateFleet" class="pj-form form" enctype="multipart/form-data">
		<input type="hidden" name="fleet_create" value="1" />
		<input type="hidden" name="csrf_token" value="<?php echo pjAppController::getCsrfToken(); ?>" />
		<input type="hidden" id="index_arr" name="index_arr" value="<?php echo $index;?>" />
		<?php if ((int) $tpl['option_arr']['o_multi_lang'] === 1 && count($tpl['lp_arr']) > 1) : ?>
		<div class="multilang"></div>
		<?php endif;?>
		<div class="clear_both">
			<?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; ?>">
					<label class="title"><?php __('lblFleet'); ?></label>
					<span class="inline_block">
						<input type="text" name="i18n[<?php echo $v['id']; ?>][fleet]" class="pj-form-field w300<?php echo (int) $v['is_default'] === 0 ? NULL : ' required'; ?>" lang="<?php echo $v['id']; ?>" />
						<?php if ((int) $tpl['option_arr']['o_multi_lang'] === 1 && count($tpl['lp_arr']) > 1) : ?>
						<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
						<?php endif;?>
					</span>
				</p>
				<?php
			}
			?>
			<p>
				<label class="title"><?php __('lblImage'); ?></label>
				<span class="inline_block">
					<input type="file" name="image" id="image" class="pj-form-field w300"/>
				</span>
			</p>
			<?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; ?>">
					<label class="title"><?php __('lblDescription'); ?></label>
					<span class="inline_block">
						<textarea name="i18n[<?php echo $v['id']; ?>][description]" class="pj-form-field w500 h150" lang="<?php echo $v['id']; ?>" ></textarea>
						<?php if ((int) $tpl['option_arr']['o_multi_lang'] === 1 && count($tpl['lp_arr']) > 1) : ?>
						<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
						<?php endif;?>
					</span>
				</p>
				<?php
			}
			?>
			<p>
				<label class="title"><?php __('lblPassengers'); ?></label>
				<span class="inline-block">
					<input type="text" name="passengers" id="passengers" class="pj-form-field field-int w80"/>
				</span>
			</p>
			<p>
				<label class="title"><?php __('lblLuggage'); ?></label>
				<span class="inline-block">
					<input type="text" name="luggage" id="luggage" class="pj-form-field field-int w80"/>
				</span>
			</p>
			
			<p>
				<label class="title"><?php __('lblExtras'); ?></label>
				<span class="inline_block">
					<?php
					if(!empty($tpl['extra_arr']))
					{ 
						?>
						<select name="extra_id[]" id="extra_id" multiple="multiple" size="5" class="pj-form-field required w300">
							<?php
							foreach ($tpl['extra_arr'] as $v)
							{
								?><option value="<?php echo $v['id']; ?>"><?php echo stripslashes($v['name']); ?></option><?php
							}
							?>
						</select>
						<?php
					}
					?>
				</span>
			</p>
			<div id="tr_dropoff_container" class="p tr-dropoff-container">
				<label class="title"><?php __('lblServices'); ?></label>
				<div class="overflow">
					<table id="tr_dropoff_table" class="tr-dropoff-table">
						<tr>
							<td>
								<label class="tr-column-name"><?php __('lblName');?></label>
								<?php 
								foreach ($tpl['lp_arr'] as $v)
								{ 
									?>
									<p class="pj-column-multilang-wrap" data-index="<?php echo $v['id']; ?>" style="display: <?php echo (int) $v['is_default'] === 0 ? 'none' : NULL; ?>">
										<?php if ((int) $tpl['option_arr']['o_multi_lang'] === 1 && count($tpl['lp_arr']) > 1) : ?>
										<span class="pj-multilang-input"><img src="<?php echo PJ_INSTALL_URL . PJ_FRAMEWORK_LIBS_PATH . 'pj/img/flags/' . $v['file']; ?>" alt="" /></span>
										<?php endif;?>
									</p>
									<?php
								} 
								?>
							</td>
							<td><?php __('lblPrice'); ?></td>
							<td><?php __('lblIncludedExtras'); ?></td>
							<td>&nbsp;</td>
						</tr>
						<tr class="tr-location-row" data-index="<?php echo $index;?>">
							<td>
								<?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' : 'inline-block'; ?>">
										<span class="inline_block">
											<input type="text" name="i18n[<?php echo $v['id']; ?>][name][<?php echo $index;?>]"  class="pj-form-field w150<?php echo (int) $v['is_default'] === 0 ? '' : ' required'; ?>" lang="<?php echo $v['id']; ?>" />
										</span>
									</p>
									<?php
								} 
								?>
							</td>
							<td>
								<p>
									<span class="inline_block">
										<span class="pj-form-field-custom pj-form-field-custom-before">
											<span class="pj-form-field-before"><abbr class="pj-form-field-icon-text"><?php echo pjUtil::formatCurrencySign(NULL, $tpl['option_arr']['o_currency'], ""); ?></abbr></span>
											<input type="text" id="service_price_<?php echo $index;?>" name="service_price[<?php echo $index;?>]" class="pj-form-field number w60 required"/>
										</span>
									</span>
								</p>
								
							</td>
							<td>
								<p class="pj-included-extras">
									<span class="inline_block">
										<select name="service_extra_id_<?php echo $index;?>[]" id="service_extra_id_<?php echo $index;?>" multiple="multiple" size="5" class="pj-form-field w200 pj-multieselect">
										<?php
										foreach ($tpl['extra_arr'] as $v)
										{
											?><option value="<?php echo $v['id']; ?>"><?php echo stripslashes($v['name']); ?></option><?php
										}
										?>
									</select>
									</span>
								</p>
							</td>
						</tr>
					</table>
				</div>
			</div>
			<p>
				<label class="title">&nbsp;</label>
				<input type="button" value="<?php __('btnAdd'); ?>" class="pj-button pj-add-service" />
			</p>
			<p>
				<label class="title">&nbsp;</label>
				<input type="submit" value="<?php __('btnSave'); ?>" class="pj-button" />
				<input type="button" value="<?php __('btnCancel'); ?>" class="pj-button" onclick="window.location.href='<?php echo PJ_INSTALL_URL; ?>index.php?controller=pjAdminFleets&action=pjActionIndex';" />
			</p>
		</div>
	</form>
	
	<table id="tr_dropoff_table_clone" style="display: none;">
		<tr class="tr-location-row" data-index="{INDEX}">
			<td>
				<?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' : 'inline-block'; ?>">
						<span class="inline_block">
							<input type="text" name="i18n[<?php echo $v['id']; ?>][name][{INDEX}]"  class="pj-form-field w150<?php echo (int) $v['is_default'] === 0 ? '' : ' required'; ?>" lang="<?php echo $v['id']; ?>" />
						</span>
					</p>
					<?php
				} 
				?>
			</td>
			<td>
				<p>
					<span class="inline_block">
						<span class="pj-form-field-custom pj-form-field-custom-before">
							<span class="pj-form-field-before"><abbr class="pj-form-field-icon-text"><?php echo pjUtil::formatCurrencySign(NULL, $tpl['option_arr']['o_currency'], ""); ?></abbr></span>
							<input type="text" id="service_price_{INDEX}" name="service_price[{INDEX}]" class="pj-form-field number w60 required"/>
						</span>
					</span>
				</p>
				
			</td>
			<td>
				<p class="pj-included-extras">
					<span class="inline_block">
						<select name="service_extra_id_{INDEX}[]" id="service_extra_id_{INDEX}" multiple="multiple" size="5" class="pj-form-field w200 {MULTISELECT}">
						<?php
						foreach ($tpl['extra_arr'] as $v)
						{
							?><option value="<?php echo $v['id']; ?>"><?php echo stripslashes($v['name']); ?></option><?php
						}
						?>
					</select>
					</span>
				</p>
			</td>
			<td>
				<p class="pj-remove-service-outer">
					<span class="inline_block">
						<a href="#" class="pj-remove-service"></a>
					</span>
				</p>
			</td>
		</tr>
	</table>
	
	<script type="text/javascript">
	var locale_array = new Array(); 
	var myLabel = myLabel || {};
	myLabel.field_required = "<?php __('tr_field_required'); ?>";
	myLabel.choose = "-- <?php __('lblChoose'); ?> --";
	<?php
	foreach ($tpl['lp_arr'] as $v)
	{
		?>locale_array.push(<?php echo $v['id'];?>);<?php
	} 
	?>
	myLabel.locale_array = locale_array;
	myLabel.localeId = "<?php echo $controller->getLocaleId(); ?>";
	(function ($) {
		$(function() {
			$(".multilang").multilang({
				langs: <?php echo $tpl['locale_str']; ?>,
				flagPath: "<?php echo PJ_FRAMEWORK_LIBS_PATH; ?>pj/img/flags/",
				tooltip: "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris sit amet faucibus enim.",
				select: function (event, ui) {
					$('.pj-column-multilang-wrap').css('display','none');
					$(".pj-column-multilang-wrap[data-index='" + ui.index + "']").css('display','block');
				}
			});
		});
	})(jQuery_1_8_2);
	</script>
	<?php
}
?>