<?php include($tpl_common_dir . 'action_confirm.tpl'); ?>

<?php echo $extension_summary;
echo $tabs;?>
<div id="content" class="panel panel-default">

	<div class="panel-heading col-xs-12">
		<div class="primary_content_actions pull-left">
		</div>
		<?php include($tpl_common_dir . 'content_buttons.tpl'); ?>
	</div>

	<?php echo $form['form_open']; ?>
	<div class="panel-body panel-body-nopadding tab-content col-xs-12">

		<label class="h4 heading" id="<?php echo $section;?>"><?php echo ${'tab_' . $section}; ?></label>
			<?php foreach ($form['fields'] as $name => $field) { ?>
			<?php
				//Logic to calculate fields width
				$widthcasses = "col-sm-7";
				if ( is_int(stripos($field->style, 'large-field')) ) {
					$widthcasses = "col-sm-7";
				} else if ( is_int(stripos($field->style, 'medium-field')) || is_int(stripos($field->style, 'date')) ) {
					$widthcasses = "col-sm-5";
				} else if ( is_int(stripos($field->style, 'small-field')) || is_int(stripos($field->style, 'btn_switch')) ) {
					$widthcasses = "col-sm-3";
				} else if ( is_int(stripos($field->style, 'tiny-field')) ) {
					$widthcasses = "col-sm-2";
				}
				$widthcasses .= " col-xs-12";
		 ?>

		<div id="ship_<?php echo $name; ?>" class="form-group <?php if (!empty($error[$name])) { echo "has-error"; } ?>">
			<label class="control-label col-sm-3 col-xs-12" for="<?php echo $field->element_id; ?>"><?php echo ${'entry_' . $name}; ?></label>
			<?php if($name=='service'){ ?>
				<div id="service"  class="form-group input-group afield <?php echo $widthcasses; ?>">
			<?php	foreach($field as $group => $flds){	?>
						<div id="<?php echo $group;?>" class="service_group input-group afield col-sm-12 col-xs-12">
								<?php foreach((array)$flds as $k=>$f){
									$f->style = 'btn_switch'; ?>
									<div class="form-group input-group afield"><?php echo $f.' &nbsp;' .${'text_'.$k}; ?></div>
							<?php } ?>
						</div>

			<?php } ?>
				</div>
			<?php }else if($name=='dimensions'){ ?>
				<div id="<?php echo $name; ?>"  class="form-group input-group afield <?php echo $widthcasses; ?>">
					<?php foreach($field as $k=>$fld){	?>
						<div class="form-group input-group afield col-sm-2 col-xs-12">
							<?php echo $fld; ?>
						</div>
					<?php } ?>
				</div>
				<?php
				if (!empty($error[$name])) { ?>
			        <span class="help-block field_err"><?php echo $error[$name]; ?></span>
			    <?php } ?>
			<?php }else{ ?>
				<div class="input-group afield <?php echo $widthcasses; ?> <?php echo ($name == 'description' ? 'ml_ckeditor' : '')?>">
					<?php echo $field; ?>
				</div>
			    <?php if (!empty($error[$name])) { ?>
			        <span class="help-block field_err"><?php echo $error[$name]; ?></span>
			    <?php } ?>
			<?php } ?>
		</div>



		<?php } ?><!-- <div class="fieldset"> -->

	</div>

	<div class="panel-footer col-xs-12">
		<div class="text-center">
			<button class="btn btn-primary">
			<i class="fa fa-save fa-fw"></i> <?php echo $form['submit']->text; ?>
			</button>
			<button class="btn btn-default" type="reset">
			<i class="fa fa-refresh fa-fw"></i> <?php echo $button_reset; ?>
			</button>
			<a class="btn btn-default" href="<?php echo $cancel; ?>">
			<i class="fa fa-arrow-left fa-fw"></i> <?php echo $form['cancel']->text; ?>
			</a>
		</div>
	</div>
	</form>

</div>


<script type="text/javascript"><!--
jQuery(function($){
	$('#editFrm_default_ups_origin').on('change', function() {
		$('#service div.service_group').hide();
		$('#' + this.value).show();
	});

	$('#editFrm_default_ups_origin').change();
});
//--></script>