Beispiel #1
0
<?php

if (isset($_POST['apa']) && $_POST['apa'] != "") {
    include 'modules/model/class.pembelian.php';
    $pembelian = new pembelian();
    switch ($_POST['apa']) {
        case "get-barang":
            include 'modules/model/class.barang.php';
            $barang = new barang();
            if ($query = $barang->get_barang()) {
                while ($rs = $query->fetch_array()) {
                    echo "<option value='" . $rs['id'] . "' data-harga='" . $rs['harga_beli'] . "'>" . $rs['nama'] . "</option>";
                }
            }
            break;
        case "get-bank":
            $bank = new bank();
            if ($query = $bank->get_bank()) {
                while ($rs = $query->fetch_array()) {
                    echo "<option value='" . $rs['id'] . "'>" . $rs['nama'] . " " . $rs['nomor_rekening'] . "</option>";
                }
            }
            break;
        case "get-spbe":
            include 'modules/model/class.spbe.php';
            $spbe = new spbe();
            if ($query = $spbe->get_spbe_barang_by_barang($_POST['barang'])) {
                while ($rs = $query->fetch_array()) {
                    echo "<option value='" . $rs['id'] . "' data-ship='" . $rs['ship_to'] . "' data-sold='" . $rs['sold_to'] . "'>" . $rs['nama_spbe'] . "</option>";
                }
            }
<?php

if (isset($_POST['apa']) && $_POST['apa'] != "") {
    include 'modules/model/class.barang.php';
    $barang = new barang();
    switch ($_POST['apa']) {
        case "get-harga-beli":
            $collect = array();
            if ($query = $barang->get_harga_beli_all()) {
                while ($rs = $query->fetch_array()) {
                    $detail = array();
                    array_push($detail, $rs["nama"]);
                    array_push($detail, $rs["jumlah"]);
                    array_push($detail, "Rp " . number_format($rs["harga_beli"], 2, ",", "."));
                    array_push($detail, "<button type='button' class='btn btn-sm btn-primary' id='btn-ubah-data' data-id='" . $rs["id"] . "' data-jumlah='" . $rs['jumlah'] . "' data-harga='" . $rs["harga_beli"] . "'>\n\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-pencil'></i></button>\n\t\t\t\t\t\t\t\t\t\t\t<button type='button' class='btn btn-sm btn-danger' id='btn-hapus-data' data-id='" . $rs["id"] . "'>\n\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-trash-o'></i></button>");
                    array_push($collect, $detail);
                    unset($detail);
                }
            }
            echo json_encode(array("aaData" => $collect));
            break;
        case "tambah-harga-beli":
            $arr = array();
            if (isset($_POST['cmb-barang']) && $_POST['cmb-barang'] != "" && isset($_POST['txt-jumlah']) && $_POST['txt-jumlah'] != "" && isset($_POST['txt-harga-beli']) && $_POST['txt-harga-beli'] != "") {
                if ($result = $barang->tambah_harga_beli($_POST['cmb-barang'], $_POST['txt-jumlah'], $_POST['txt-harga-beli'])) {
                    $arr['status'] = TRUE;
                    $arr['msg'] = "Data tersimpan..";
                } else {
                    $arr['status'] = FALSE;
                    $arr['msg'] = "Gagal menyimpan..";
                }
Beispiel #3
0
<?php

if (isset($_POST['apa']) && $_POST['apa'] != "") {
    include 'modules/model/class.barang.php';
    $barang = new barang();
    switch ($_POST['apa']) {
        case "get-stok":
            $collect = array();
            if ($query = $barang->get_barang()) {
                while ($rs = $query->fetch_array()) {
                    $detail = array();
                    array_push($detail, $rs["nama"]);
                    array_push($detail, number_format($rs["stok_kosong"], 0, ",", "."));
                    array_push($detail, number_format($rs["stok_isi"], 0, ",", "."));
                    array_push($detail, number_format($rs["stok_pinjam"], 0, ",", "."));
                    array_push($detail, "<button type='button' class='btn btn-sm btn-primary' id='btn-show-opname' data-kosong='" . $rs["stok_kosong"] . "' \n\t\t\t\t\t\t\t\t\t\t\tdata-isi='" . $rs["stok_isi"] . "' data-pinjam='" . $rs["stok_pinjam"] . "' data-id='" . $rs['id'] . "'><i class='fa fa-pencil'></i></button>");
                    array_push($collect, $detail);
                    unset($detail);
                }
            }
            echo json_encode(array("aaData" => $collect));
            break;
        case "simpan-opname":
            $arr = array();
            if (isset($_POST['txt-kosong-lama']) && $_POST['txt-kosong-lama'] != "" && isset($_POST['txt-kosong-baru']) && $_POST['txt-kosong-baru'] != "" && isset($_POST['txt-isi-lama']) && $_POST['txt-isi-lama'] != "" && isset($_POST['txt-isi-baru']) && $_POST['txt-isi-baru'] != "" && isset($_POST['txt-keterangan']) && $_POST['txt-keterangan'] != "" && isset($_POST['txt-id']) && $_POST['txt-id'] != "" && isset($_POST['txt-pinjam-lama']) && $_POST['txt-pinjam-lama'] != "" && isset($_POST['txt-pinjam-baru']) && $_POST['txt-pinjam-baru'] != "") {
                $tgl = date("Y-m-d");
                if ($result = $barang->stok_opname($tgl, $_POST['txt-id'], $_POST['txt-isi-lama'], $_POST['txt-isi-baru'], $_POST['txt-kosong-lama'], $_POST['txt-kosong-baru'], $_POST['txt-pinjam-lama'], $_POST['txt-pinjam-baru'], $_POST['txt-keterangan'], d_code($_SESSION['en-data']))) {
                    $arr['status'] = TRUE;
                    $arr['msg'] = "Data tersimpan..";
                } else {
                    $arr['status'] = FALSE;
<?php

if (isset($_POST['apa']) && $_POST['apa'] != "") {
    include 'modules/model/class.barang.php';
    $barang = new barang();
    switch ($_POST['apa']) {
        case "get-het":
            $collect = array();
            if ($query = $barang->get_barang()) {
                while ($rs = $query->fetch_array()) {
                    $detail = array();
                    array_push($detail, $rs["nama"]);
                    array_push($detail, "Rp " . number_format($rs["het"], 2, ",", "."));
                    array_push($detail, "<button type='button' class='btn btn-sm btn-primary' id='btn-ubah-data' data-id='" . $rs["id"] . "' data-harga='" . $rs["het"] . "'>\n\t\t\t\t\t\t\t\t\t\t\t<i class='fa fa-pencil'></i></button>");
                    array_push($collect, $detail);
                    unset($detail);
                }
            }
            echo json_encode(array("aaData" => $collect));
            break;
        case "ubah-het":
            $arr = array();
            if (isset($_POST['txt-het']) && $_POST['txt-het'] != "" && isset($_POST['txt-id']) && $_POST['txt-id'] != "") {
                if ($result = $barang->ubah_het($_POST['txt-het'], $_POST['txt-id'])) {
                    $arr['status'] = TRUE;
                    $arr['msg'] = "Data tersimpan..";
                } else {
                    $arr['status'] = FALSE;
                    $arr['msg'] = "Gagal menyimpan..";
                }
            } else {