<?php
//error_reporting(0);
session_start();
ob_start();
include "../../../../konfig/dbconnect.php";

$db = new database();
$db->dbsql();   

include "../../../../model/viewfront.php";
include "../../../../controller/upload.php";

$aksi = $_GET[aksi];
if($aksi=='fp1'){
    $front = new viewfront();

    $front->editfrontpage1($_POST[judul],$_POST[keterangan]);

    header("location:../../../../index.php?module=front");
}
elseif($aksi=='fp2'){
    $front = new viewfront();
    $upload = new upload();

    $lokasi_file    = $_FILES['gambar']['tmp_name'];
    $tipe_file      = $_FILES['gambar']['type'];
    $nama_file      = $_FILES['gambar']['name'];
    $acak           = rand(1,99);
    $nama_unik      = $acak.$nama_file;

    $upload->fp2($nama_unik,$db->linkupload());

    $front->addlistfrontpage2($_POST[judul],$_POST[keterangan],$nama_unik);

    header("location:../../../../index.php?module=front");
}
elseif($aksi=='fp3'){
    $front = new viewfront();
    $upload = new upload();

    $lokasi_file    = $_FILES['gambar']['tmp_name'];
    $tipe_file      = $_FILES['gambar']['type'];
    $nama_file      = $_FILES['gambar']['name'];
    $acak           = rand(1,99);
    $nama_unik      = $acak.$nama_file;

    $upload->rekanan($nama_unik,$db->linkupload());

    $front->addlistfrontpage3($_POST[judul],$nama_unik);

    header("location:../../../../index.php?module=front");
}
elseif ($aksi=='fp4') {
    $front = new viewfront();

    if ($_POST[key]=='1') {
        $front->editfrontpage4($_POST[keterangan]);
    }elseif($_POST[key]=='2'){
        $front->addlistfrontpage4($_POST[judul],$_POST[keterangan],$_POST[list1],$_POST[list2],$_POST[list3],$_POST[harga]);
    }

    header("location:../../../../index.php?module=front");
}
elseif($aksi=='delete'){
    $front = new viewfront();

    $front->delete($_GET[id]);
    
    header("location:../../../../index.php?module=front");
}
