<?php
echo form_open("admin/shipping_gateway_save", array("id" => "shipping_gateway_form", "class" => "nvForm"));
FeralHidden("id", $id);
csrf();
?>
<div class="row">
	<div class="<?php echo(TOP_LEFT); ?>">
		<h2>Edit Shipping Gateway: <?php echo($gateway->gateway_name); ?></h2>
	</div>
	<div class="<?php echo(TOP_RIGHT); ?>">
		<button type="submit" name="submit_action" id="submit" value="close" class="btn btn-primary"><em class="fas fa-save" aria-hidden="true"></em> Save &amp; Close</button>
		<button type="submit" name="submit_action" id="submit2" value="continue" class="btn btn-primary"><em class="fas fa-save" aria-hidden="true"></em> Save &amp; Continue</button>
		<a href="/admin/gateways" class="btn btn-secondary"><em class="fas fa-times" aria-hidden="true"></em> Cancel</a>
	</div>

	<div class="<?php echo(TWO_COL); ?>">
		<div class="<?php echo(FORM_ROW); ?>">
			<label for="enabled" class="<?php echo(LABEL_COL); ?>">Enabled</label>
			<div class="<?php echo(FIELD_COL); ?>"><?php yesNo("enabled", $gateway->enabled); ?></div>
		</div>
		<div class="<?php echo(FORM_ROW); ?>">
			<label for="sort" class="<?php echo(LABEL_COL); ?>">Ordering</label>
			<div class="<?php echo(FIELD_COL); ?>"><input type="number" name="sort" id="sort" value="<?php echo($gateway->sort); ?>" min="0" step="1" class="form-control" /></div>
		</div>
		<?php
		$configs = explode("\n", $gateway->configuration);

		foreach($configs as $config)
		{
			if($config != "")
			{
				$line = explode("=", $config, 2);
				?>
				<div class="<?php echo(FORM_ROW); ?>">
					<label for="config_<?php echo($line[0]); ?>" class="<?php echo(LABEL_COL); ?>"><?php echo(ucwords(str_replace("_", " ", $line[0]))); ?></label>
					<div class="<?php echo(FIELD_COL); ?>"><?php FeralText("config_" . $line[0], $line[1], "form-control"); ?></div>
				</div>
				<?php
			}
		}
		?>
	</div>
</div>
<?php
echo form_close();
