<?php echo $header; ?>
<div class="container">
    <ul class="breadcrumb">
        <?php foreach ($breadcrumbs as $breadcrumb) { ?>
        <li><a href="<?php echo $breadcrumb['href']; ?>"><?php echo $breadcrumb['text']; ?></a></li>
        <?php } ?>
    </ul>
    <?php if ($success) { ?>
    <div class="alert alert-success"><i class="fa fa-check-circle"></i> <?php echo $success; ?>
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <?php if ($error_warning) { ?>
    <div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> <?php echo $error_warning; ?>
        <button type="button" class="close" data-dismiss="alert">&times;</button>
    </div>
    <?php } ?>
    <div class="row"><?php echo $column_left; ?>
        <?php if ($column_left && $column_right) { ?>
        <?php $class = 'col-sm-6'; ?>
        <?php } elseif ($column_left || $column_right) { ?>
        <?php $class = 'col-sm-9'; ?>
        <?php } else { ?>
        <?php $class = 'col-sm-12'; ?>
        <?php } ?>
        <div id="content" class="<?php echo $class; ?>"><?php echo $content_top; ?>
            <h2><?php echo $heading_title; ?></h2>
<form action="<?=$action;?>" method="post" class="form-horizontal">
                <fieldset>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Adınız: </label>
                        <div class="col-sm-9">
                            <input type="text" name="shipping_firstname" value="<?=$shipping_firstname;?>" class="form-control" />
                            <?php if($error_shipping_firstname){ ?>
                            <?=$error_shipping_firstname;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Soyadınız: </label>
                        <div class="col-sm-9">
                            <input type="text" name="shipping_lastname" value="<?=$shipping_lastname;?>" class="form-control" />
                            <?php if($error_shipping_lastname){ ?>
                            <?=$error_shipping_lastname;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Telefon: </label>
                        <div class="col-sm-9">
                            <input type="text" name="telephone" value="<?=$telephone;?>" class="form-control" />
                            <?php if($error_telephone){ ?>
                                <?=$error_telephone;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Teslimat Adresi: </label>
                        <div class="col-sm-9">
                            <textarea name="shipping_address_1" class="form-control"><?=$shipping_address_1;?></textarea>
                            <?php if($error_shipping_address_1){ ?>
                            <?=$error_shipping_address_1;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">İlçe: </label>
                        <div class="col-sm-9">
                            <input type="text" name="shipping_city" value="<?=$shipping_city;?>" class="form-control" />
                            <?php if($error_shipping_city){ ?>
                            <?=$error_shipping_city;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Şehir: </label>
                        <div class="col-sm-9">
                            <select name="zone_id" class="form-control"></select>
                            <?php if($error_zone_id){ ?>
                            <?=$error_zone_id;?>
                            <?php } ?>
                        </div>
                    </div>
                    <div class="form-group required">
                        <label class="col-sm-3 control-label">Ülke: </label>
                        <div class="col-sm-9">
                            <select name="country_id" id="shipping-address" class="form-control">
                                <?php foreach($countries as $country){ ?>
                                    <?php if($country['country_id'] == $shipping_country_id){ ?>
                                        <option value="<?=$country['country_id'];?>" selected ><?=$country['name'];?></option>
                                    <?php }else{ ?>
                                        <option value="<?=$country['country_id'];?>"><?=$country['name'];?></option>
                                    <?php } ?>
                                <?php } ?>
                            </select>
                            <?php if($error_country_id){ ?>
                            <?=$error_country_id;?>
                            <?php } ?>
                        </div>
                    </div>
                </fieldset>
                <div class="buttons clearfix">
                    <div class="pull-right">
                        <input type="submit" value="Kaydet" class="btn btn-primary" />
                    </div>
                </div>
            </form>
<?php echo $content_bottom; ?></div>
        <?php echo $column_right; ?></div>
</div>
<script type="text/javascript">
$(function () {
setTimeout(function () {
            $('select[name=\'country_id\']').trigger('change');
        }, 1000);
$('select[name=\'country_id\']').on('change', function() {
            $.ajax({
                url: 'index.php?route=quickcheckout/checkout/country&country_id=' + this.value,
                dataType: 'json',
                cache: false,
                beforeSend: function() {
                    $('select[name=\'country_id\']').after('<i class="fa fa-spinner fa-spin"></i>');
                },
                complete: function() {
                    $('.fa-spinner').remove();
                },
                success: function(json) {
html = '';
                    if (json['zone'] != '') {
html += '<option value=""';
                        html += '> Seçiniz</option>';
for (i = 0; i < json['zone'].length; i++) {
                            html += '<option value="' + json['zone'][i]['zone_id'] + '"';
if (json['zone'][i]['zone_id'] == '<?php echo $shipping_zone_id; ?>') {
                                html += ' selected="selected"';
                            }
html += '>' + json['zone'][i]['name'] + '</option>';
                        }
                    } else {
                        html += '<option value="0" selected="selected"><?php echo $text_none; ?></option>';
                    }
$('select[name=\'zone_id\']').html(html).trigger('change');
                }
        });
        });
    });
</script>
<?php echo $footer; ?>