<?php include 'loader.php'; ?>
<?php include 'inc/config.php'; ?>
<?php include 'inc/template_start.php'; ?>
<?php include 'inc/page_head.php'; ?>
<?php
if(!$user->isLogged()) $location->redirect('admin/login');

$path = '';
$support_info = array();
if($func->get('support_id')) {
    $path = '?support_id='.$func->get('support_id');
    $support_info = $db->query("SELECT * FROM " . DBPREFIX . "supports WHERE support_id='" . $func->get('support_id') . "'");
    $support_info = $support_info->num_rows?$support_info->row:array();
}
if($_SERVER['REQUEST_METHOD']=='POST') {
    $query = array();
    foreach ($func->post() as $key=>$item) {
        $query[] = $key."='".$db->escape($item)."'";
    }
    if($func->get('support_id')){
        $sql = "UPDATE " . DBPREFIX . "supports SET " . implode(',', $query)." WHERE support_id='".$func->get('support_id')."'";
    }else {
        $query[] = "date_added='" . date('Y-m-d H:i:s') . "'";
        $sql = "INSERT INTO " . DBPREFIX . "supports SET " . implode(',', $query);
    }
    //echo '<pre>';print_r($sql);echo '</pre>';die();
    $db->query($sql);
    $location->redirect('admin/supports');
}
//echo '<pre>';print_r($_SERVER);echo '</pre>';die();
?>
<!-- Page content -->
<div id="page-content">

    <div class="row">

        <div class="col-lg-12">
            <!-- Meta Data Block -->
            <div class="block">
                <!-- Meta Data Title -->
                <div class="block-title">
                    <h2><i class="fa fa-google"></i> <strong>Hizmet</strong> Ekle/Düzenle</h2>
                </div>
                <!-- END Meta Data Title -->

                <!-- Meta Data Content -->
                <form action="<?php echo SITE_ADMIN; ?>new_support.php<?php echo $path; ?>" method="post" class="form-horizontal form-bordered">
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="product-meta-title">Hizmet Adı</label>
                        <div class="col-md-9">
                            <input type="text" id="product-meta-title" name="name" value="<?php echo $support_info?$support_info['name']:''; ?>" class="form-control" placeholder="İsim/Soyisim..">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-md-3 control-label" for="product-telephone">Telefon</label>
                        <div class="col-md-9">
                            <select class="form-control" name="status">
                                <option value="1" <?php echo $support_info?($support_info['status']?'selected="selected"':''):''; ?>>Aktif</option>
                                <option value="0" <?php echo $support_info?(!$support_info['status']?'selected="selected"':''):''; ?>>Pasif</option>
                            </select>

                        </div>
                    </div>

                    <div class="form-group form-actions">
                        <div class="col-md-9 col-md-offset-3">
                            <button type="submit" class="btn btn-sm btn-primary"><i class="fa fa-floppy-o"></i> Save</button>
                            <a href="<?php echo SITE_ADMIN; ?>supports.php" class="btn btn-sm btn-warning"><i class="fa fa-repeat"></i> İptal</a>
                        </div>
                    </div>
                </form>
                <!-- END Meta Data Content -->
            </div>
            <!-- END Meta Data Block -->

        </div>
    </div>




</div>









<?php include 'inc/page_footer.php'; ?>
<?php include 'inc/template_scripts.php'; ?>

<!-- Load and execute javascript code used only in this page -->
<script src="js/pages/ecomProducts.js"></script>
<script>$(function(){ EcomProducts.init(); });</script>

<?php include 'inc/template_end.php'; ?>
