<?php
include "../../asset/mod/autoLoad.php";

if (isset($_POST['submitProse'])) {

    $id_setor = $_POST['id_setor'];
    $src = $_POST['src'];
    $status = $_POST['status'];
    $tahun = $_POST['tahun'];

    $tb_siswa = "tb_siswa" . $tahun_tabel;
    $tb_transaksi = "db_transaksi" . $tahun_tabel;
    $tb_detailakun = "detail_akun" . $tahun_tabel;
    $tb_setor = "db_setor" .  $tahun_tabel;

    if ($status == 1) {
        $toast = "batalSetor";
    } elseif ($status == 2) {
        $toast = "successSetor";
    };

    $time = new time();
    $waktu = $time->getTime();

    $crud = new crudData();
    $dataarray1 = [
        'setor_status' => $status,
        'setor_tanggal' => $waktu
    ];
    $update1 = $crud->updateData($tb_setor, $dataarray1, ['id_setor', ' = ', $id_setor]);

    $dataarray2 = [
        'setor' => $status
    ];
    $update2 = $crud->updateData($tb_transaksi, $dataarray2, ['id_setor', ' = ', $id_setor]);

    $direct = new toast();
    echo  $direct->redirectID('toast', $toast, $id_setor, 'setor/setor_read_proses');
} else {
    echo "";
};
