Beispiel #1
0
                    $detail = array();
                    array_push($detail, $rs["nama"]);
                    array_push($detail, "Rp " . number_format($rs["harga_3kg"], 0, ",", "."));
                    array_push($detail, "Rp " . number_format($rs["harga_12kg"], 0, ",", "."));
                    array_push($detail, "Rp " . number_format($rs["harga_12kg_bg"], 0, ",", "."));
                    array_push($detail, "Rp " . number_format($rs["harga_50kg"], 0, ",", "."));
                    array_push($detail, "<button type='button' class='btn btn-sm btn-primary' id='btn-ubah-data' data-id='" . $rs["id"] . "' \n\t\t\t\t\t\t\t\t\t\t\tdata-3kg='" . $rs["harga_3kg"] . "' data-12kg='" . $rs["harga_12kg"] . "' data-12kgbg='" . $rs["harga_12kg_bg"] . "' \n\t\t\t\t\t\t\t\t\t\t\tdata-50kg='" . $rs["harga_50kg"] . "'><i class='fa fa-pencil'></i></button>");
                    array_push($collect, $detail);
                    unset($detail);
                }
            }
            echo json_encode(array("aaData" => $collect));
            break;
        case "ubah-harga-jual":
            $arr = array();
            if (isset($_POST['txt-id']) && $_POST['txt-id'] != "" && isset($_POST['txt-3kg']) && $_POST['txt-3kg'] != "" && isset($_POST['txt-12kg']) && $_POST['txt-12kg'] != "" && isset($_POST['txt-12kgbg']) && $_POST['txt-12kgbg'] != "" && isset($_POST['txt-50kg']) && $_POST['txt-50kg'] != "") {
                if ($result = $konsumen->set_harga_jual($_POST['txt-id'], $_POST['txt-3kg'], $_POST['txt-12kg'], $_POST['txt-12kgbg'], $_POST['txt-50kg'])) {
                    $arr['status'] = TRUE;
                    $arr['msg'] = "Data tersimpan..";
                } else {
                    $arr['status'] = FALSE;
                    $arr['msg'] = "Gagal menyimpan..";
                }
            } else {
                $arr['status'] = FALSE;
                $arr['msg'] = "Harap isi data dengan lengkap..";
            }
            echo json_encode($arr);
            break;
    }
}