Просмотр файла restdininguide/diningtrax/index.php

Размер файла: 20.61Kb
<?
/*
[ Program: ] MyDiningGuide System
[ Version: ] 0.8
[ Author:  ] V. Christianto <[email protected]>
[ Purpose: ] Manage dining guide information to customer
[ Date:    ] 12 June 2002
[ License: ] GPL.  By installing this software you agree to the terms of the
                GPL, as available from www.opensource.org
*/

/* I recommend strongly that you use some sort of
authentication / password protection with this
program.  On my own site I use a simple .htaccess
system.  Simple, but secure.  Future releases MAY
include HTTP-Basic authentication, as it is not
too hard to implement.  */

/* START CONFIG */

$yourname = "myDiningGuide www.eazt.com";

$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$database = "resturaunts";

$color1 = "orange";        /* First alternating table color, text or HEX */
$color2 = "white";        /* Second alternating table color, text or HEX */

/* END CONFIG */

mysql_connect($dbhost,$dbuser,$dbpass);
mysql_select_db($database);

if ($insert == "yes") {
        /* Insert into DB */
        if (!$name || !$location || !$phone || !$desc) {
                echo "Anda mesti mengentrikan name, location, phone, description, serta memilih \n";
                echo "tipe of food.  Silakan entrikan lagi.";
                footer();
                exit;
        }

        $result = mysql_query("insert into info (id,name,location,phone_number,description,type_of_food) VALUES (\"\",\"$name\",\"$location\",\"$phone\",\"$desc\",\"$type\")");
        if (mysql_error()) {
                echo "Ada error pada database. Silakan ulangi entrikan data.";
                footer();
                exit;
        }
        $message = "Entri resto Dining Guide baru telah ditambahkan. Terimakasih.";
}

if ($action != "help") {
        echo "<html>\n<head>\n<title>myDiningGuide System untuk $yourname</title>\n";
        ?><SCRIPT LANGUAGE="JavaScript">
        <!-- Begin
        function showHelp(helpfile) {
                var windowprops = "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=yes,resizable=0,width=350,height=400";

                OpenWindow = window.open("<? echo $PHP_SELF; ?>?action=help&section=" + helpfile, "help", windowprops); // opens help window
        }
        //  End -->
        </script><?
        echo "</head>\n<body bgcolor=orange text=black link=blue alink=blue vlink=blue>\n\n";
        echo "<h1 align=center><font face=Tahoma size=-1>Welcome to Dining Guide System for $yourname</h1>\n\n";
        if ($message) { echo "<font color=red><center><b>Message: $message</b></center></font>\n\n"; }
        echo "</font><br><br>\n\n<table border=5 bgcolor=white bordercolor=black align=center cellspacing=0 cellpadding=5 width=90%>\n<tr>\n<td>\n";
        echo "<font face=Tahoma size=-1><center>[ <a href=\"$PHP_SELF?action=main\">Main Page</a> ] - [ <a href=\"$PHP_SELF?action=new\">New Data Entry</a> ] - [ <a href=\"javascript:showHelp('main');\">Petunjuk</a> ] - [ <a href=\"../logout.php\">Logout</a> ]</center></font>\n</td></tr>\n";
        echo "<tr><td>\n<font face=Tahoma size=-1>\n\n";
} else {
        echo "<html><head><title>Dining Guide Help</title></head><body bgcolor=skyblue text=black>\n";
        echo "<table border=2 bordercolor=black bgcolor=white width=90% cellspacing=0 align=center cellpadding=5>";
        echo "<tr><td><font face=Tahoma size=-1>\n";
}

function footer() {
        echo "</font>\n\n</td>\n</tr>\n</table>\n\n";
        echo "<font face=Tahoma size=-2><center>\n<a href=\"http://www.eazt.com\" target=\"_new\">Dining Guide System v0.8</a> &copy; Copyright 2002 V. Christianto, <a href=\"mailto:[email protected]\">[email protected]</a>.  All Rights Reserved.\n</center></font>\n\n<br><br>\n\n</body>\n</html>\n\n";
}

function whatis($bleh) {
        if ($bleh == "American") {
                $return = "American Food";
        } elseif ($bleh == "Oriental") {
                $return = "Oriental Food";
        } elseif ($bleh == "Mexican") {
                $return = "Mexican Food";
        } elseif ($bleh == "Italian") {
                $return = "Italian Food";
        } elseif ($bleh == "Fastfood") {
                $return = "Fast Food";
        } elseif ($bleh == "Coffeshop") {
                $return = "Coffe Shop";
        } elseif ($bleh == "Steak/BBQ") {
                $return = "Steak/BBQ";
        } elseif ($bleh == "Seafood") {
                $return = "Seafood";
        }

        return $return;
}

if ($action == "new") {
/* Display form to allow user to add a new transaction to the DB */
        $curdate = date("Y-m-d H:i:s");
        ?>
        <h3 align=center>New Resto data Entry</h3>
        Gunakan form berikut untuk menambahkan data resto.  Jika kemudian ada masalah, silakan lihat <a href="javascript:showHelp('new');">petunjuk online</a>.<br><br>

        <form method=post action="<? echo $PHP_SELF; ?>">
        <input type=hidden name="insert" value="yes">
        <b>Name</b> [<a href="javascript:showHelp('entity');">?</a>]<br>
        <input type="text" name="name" value=""><br>
        <b>Tipe food</b> [<a href="javascript:showHelp('type');">?</a>]<br>
        <select name="type"><option value="" selected>Pilih satu<option value="a">American<option value="o">Oriental<option value="m">Mexican<option value="i">Italian<option value="f">Fastfood<option value="c">Cofeeshop<option value="b">Steak/BBQ<option value="s">Seafood</select><br>
        <b>Phone</b> <i>(Entrikan hanya bilangan dan atau desimal.  Jangan ada tanda positif atau negatif.)</i> [<a href="javascript:showHelp('amount');">?</a>]<br>
        <input type=text name="phone" value=""><br>
        <b>Location</b> [<a href="javascript:showHelp('entity');">?</a>]<br>
        <input type="text" name="location" value=""><br>
        <b>Decription</b> [<a href="javascript:showHelp('entity');">?</a>]<br>
        <input type="text" name="desc" value=""><br>
        <input type=submit value="Add It!"> <input type=reset value="Reset Fields"></form>
        <?
} elseif ($action == "delete") {
        if (!$confirm) {
                echo "Apakah yakin Anda ingin menghapus data resto \n";
                echo "bernomor $id?  \n";
                echo "[<a href=\"javascript:showHelp('delete');\">Help</a>]<br><br>\n\n";
                echo "<a href=\"$PHP_SELF?action=delete&id=$id&confirm=yes\">Yes</a><br>\n";
                echo "<a href=\"$PHP_SELF?action=main\">No</a><br>\n";
        } else {
                $result = mysql_query("delete from info where id = '$id'");
                if (mysql_error()) {
                        echo "Database error<br>\n";
                        footer();
                        exit;
                }
                echo "Data resto bernomor $id telah dihapus.\n\n";
        }
} elseif ($action == "edit") {
        if (!$confirm) {
                $result = mysql_query("select * from info where id = '$id'");
                $name = mysql_result($result,0,"name");
                $phone = mysql_result($result,0,"phone");
                $location = mysql_result($result,0,"location");
        $type = mysql_result($result,0,"type");
                echo "Mengisi form berikut akan mengijinkan Anda untuk \n";
                echo "mengedit data resto yang telah ada.  ";
                echo "[<a href=\"javascript:showHelp('edit');\">Help</a>]<br><br>\n";
                echo "<form method=post action=\"$PHP_SELF\">\n";
                echo "<input type=hidden name=action value=edit>\n";
                echo "<input type=hidden name=confirm value=yes>\n";
                echo "<input type=hidden name=id value='$id'>\n";
                echo "<b>Lokasi Resto</b> [<a href=\"javascript:showHelp('entity');\">?</a>]<br><input type=text name=entity value='$entity'><br>\n";
                echo "<b>Tipe Resto</b> [<a href=\"javascript:showHelp('type');\">?</a>]<br><select name=\"type\">";
                echo "<option value='American'";
                if ($type == "American") { echo " selected"; }
                echo ">American Food\n";
                echo "<option value='Oriental'";
                if ($type == "Oriental") { echo " selected"; }
                echo ">Oriental Food\n";
                echo "<option valued='Mexican'";
                if ($type == "Mexican") { echo " selected"; }
                echo ">Mexican Food\n";
                echo "<option value='Italian'";
                if ($type == "Italian") { echo " selected"; }
                echo ">Italian Food\n";
                           echo "<option value='Fastfood'";
                if ($type == "Fastfood") { echo " selected"; }
                echo ">Fastfood\n";
                                echo "<option value='Coffeshop'";
                if ($type == "Coffeshop") { echo " selected"; }
                echo ">Coffeshop\n";
                                     echo "<option value='Steak/BBQ'";
                if ($type == "SteakBBQ") { echo " selected"; }
                echo ">Steak/BBQ\n";
                                      echo "<option value='s'";
                if ($type == "Seafood") { echo " selected"; }
                echo ">Seafood\n";
                echo "</select><br>\n";
                echo "<b>Location</b> [<a href=\"javascript:showHelp('location');\">?</a>]<br><input type=text name=location value='$location'><br>\n";
        echo "<b>Description</b> [<a href=\"javascript:showHelp('desc');\">?</a>]<br><input type=text name=desc value='$desc'><br>\n";
                echo "<input type=submit value=\"Update\"></form>\n\n";
        } else {
                if (!$amount || !$entity) {
                        echo "Anda mesti menginputkan Lokasi dan Type Resto. Silakan ulangi.\n\n";
                        footer();
                        exit;
                }
                $result = mysql_query("update info SET name=\"$name\",location=\"$location\",phone_number=\"$phone\",description=\"$desc\", type_of_food=\"$type\"where id = '$id'");
                if (mysql_error()) {
                        echo "There was a database error.\n\n";
                        footer();
                        exit;
                }
                echo "Data resto $id telah diperbarui.\n\n";
        }
} elseif ($action == "help") {
/* Display help for topic $section */
        if ($section == "delete") {
                echo "<h3 align=center>Petunjuk: <i>Hapus</i></h3>\n";
                echo "<p align=justify>Mengklik 'yes' pada layar ini akan \n";
                echo "menghapus data yang dipilih dari database.</p>\n";
                echo "<p align=justify>Mengklik no akan membawa Anda kembali ke \n";
                echo "layar utama.  Fungsi delete atau hapus mesti digunakan secara berhati \n";
                echo "hati.</p>\n\n";
        } elseif ($section == "edit") {
                echo "<h3 align=center>Petunjuk: <i>Edit</i></h3>\n";
                echo "<p align=justify>Dining Guide System ini mencakup \n";
                echo "fitur edit yang bagus. Cukup memperbarui nilai-nilai \n";
                echo "untuk mencerminkan data paling anyar.</p>\n\n";
        } elseif ($section == "entity") {
                echo "<h3 align=center>Petunjuk: <i>Entity</i></h3>\n";
                echo "<p align=justify>Di Dining Guide ini, suatu Lokasi adalah alamat ";
                echo "atau nama jalan tempat resto berada.</p>\n";
                echo "<p align=justify><b>Contoh:</b> Suatu lokasi boleh berisikan \"Tj Mas ";
                echo "Sby\" or \"Jl MH  Thamrin Jkt\".</p>\n";
        } elseif ($section == "transno") {
                echo "<h3 align=center>Petunjuk: <i>Nomor Transaksi</i></h3>\n";
                echo "<p align=justify>Nomor transaksi adalah \n";
                echo "suatu angka yang terus meningkat yang digunakan untuk \n";
                echo "mencatat rekaman transaksi, dan tidak memiliki arti \n";
                echo "khusus bagi pengguna, kecuali untuk sistem dalam \n";
                echo "menelusuri apa dan siapa. Dalam banyak kasus, hal ini bisa  \n";
                echo "diabaikan.</p>\n\n";
        } elseif ($section == "date") {
                echo "<h3 align=center>Petunjuk: <i>Date</i></h3>\n";
                echo "<p align=justify>Tanggal berguna untuk Anda dan pengguna \n";
                echo "dalam melacak kapan data tersebut dientrikan.  Tanggal  \n";
                echo "dientrikan ke sistem secara otomatis ketika Anda menambahkan \n";
                echo "suatu transaksi baru, dan bisa disesuaikan bergantung dari \n";
                echo "zonawaktu Anda -- lihat source untuk detil.</p>\n\n";
        } elseif ($section == "total") {
                echo "<h3 align=center>Petunjuk: <i>Total</i></h3>\n";
                echo "<p align=justify>On the main screen, the total is \n";
                echo "the aggregate total money you \"own\" at the time \n";
                echo "of the listed transaction. It adds debits and \n";
                echo "deposits, and subtracts credits or \n";
                echo "withdrawals.</p>\n\n";
        } elseif ($section == "options") {
                echo "<h3 align=center>Petunjuk: <i>Options</i></h3>\n";
                echo "<p align=justify>Layar utama pilihan terdiri dari \n";
                echo "dua pilihan yang berkaitan dengan transaksi:</p><ul>\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=delete\">Delete</a>, shown by the [D] sign; and\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=edit\">Edit</a>, shown by the [E] sign.\n\n</ul>\n";
                echo "<p align=justify>Petunjuk tersebut adalah cukup -\n";
                echo "jelas, meskipun mengklik nama di atas akan \n";
                echo "memberikan informasi tambahan. Anda akan diberikan kesempatan \n";
                echo "untuk menegaskan Anda apakah akan menghapus atau mengedit, jadi clik \n";
                echo "tidak disengaja tidak akan membahayakan data Anda.</p>\n\n";
        } elseif ($section == "type") {
                echo "<h3 align=center>Petunjuk: <i>Tipe</i></h3>\n";
                echo "<p align=justify>Cargo Tracking System ini membedakan cargo menjadi empat jenis. \n";
                echo "Masing-masing menunjukkan ketegori kargo yang berbeda yang sedang digunakan.</p>\n\n";
                echo "&#183; <b>Cargo Type A</b>: Cargo berukuran minimal 1000x1800x1200 mm \n";
                echo ".<br>&#183; <b>Cargo Type B</b>: Cargo berukuran 1000x2400x1600 mm \n";
                echo ".<br>&#183; <b>Cargo Type C</b>: Cargo berukuran 1200x3000x1600 mm \n";
                echo ". \"own\" yang mencerminkan ukuran cargo standar.<br>&#183; <b>Cargo Type D</b>: Cargo \n";
                echo "berukuran 1600x3600x2400 mm \"own\" maksimum ukuran kargo.\n\n";
        } elseif ($section == "amount") {
                echo "<h3 align=center>Petunjuk: <i>Cargo ID</i></h3>\n";
                echo "<p align=justify>Field Cargo ID harus terdiri dari angka saja, dengan desimal bila perlu (EG, \n";
                echo "Jangan menggunakan tanda negatif atau plus \n";
                echo "Cargo ID dipergunakan untuk mengakses data dari mobile phone.\n\n";
        } elseif ($section == "new") {
                echo "<h3 align=center>Petunjuk: <i>New Cargo Entri</i></h3>\n";
                echo "<p align=justify>Layar ini mengijinkan Anda untuk menambahkan suatu data entri baru ke dalam \n";
                echo "database. Juga memberikan petunjuk akses yang mudah dengan mengklik pada  <i>[?]</i> link \n";
                echo "di sebelah judul masing-masing tabel.</p>\n\n";
                echo "<p align=justify>Kategori entri data adalah:<ul><li><a href=\"$PHP_SELF?action=help&section=entity\">Posisi Cargo</a>\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=type\">Tipe Cargo</a>\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=amount\">Cargo ID</a>\n";
                echo "</ul><br>Mengklik pada judul tersebut akan menunjukkan Anda informasi yang lebih lengkap.</p><br>\n\n";
        } else {
                echo "<h3 align=center>Petunjuk: <i>Keterangan</i></h3>\n\n";
                echo "<p align=justify>\n";
                echo "Dining Guide system mencakup sistem tunjuk komprehensif, ";
                echo "yang jarang dijumpai dalam package sejenis. Silakan klik ";
                echo "sebarang tanda [?] button atau Help link untuk melihat halaman petunjuk ";
                echo "yang diinginkan ";
                echo "untuk ditampilkan.</p>\n\n";
                echo "<ul><li><a href=\"$PHP_SELF?action=help&section=new\">New Data Resto</a>\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=delete\">Menghapus Data</a>\n";
                echo "<li><a href=\"$PHP_SELF?action=help&section=edit\">Mengedit Data</a>\n";
                echo "</ul><p align=justify>Layar ini bisa diakses setiap waktu ";
                echo "dengan mengklik link 'help contents'";
                echo "pada layar petunjuk lainnya.\n\n</p>";
        }

        echo "</font></td></tr></table>\n\n";
        echo "<center><font size=-1 face=Tahoma><br>\n";
        echo "<a href=\"javascript:history.back();\">Kembali</a><br><a href=\"javascript:window.close();\">Tutup jendela ini</a></font><br>\n\n";
        echo "<br><center><font size=-1 face=Tahoma><a href=\"$PHP_SELF?action=help&section=main\">Petunjuk Content</a></font></center>\n\n";
        echo "<br><font size=-2 face=Tahoma><a href=\"http://www.eazt.com/\" target=\"_new\">Dining Guide System 0.8</a> &copy Copyright 2002 V. Christianto.  Copyleft Reserved.</font></center><br>\n\n";
        echo "</body></html>\n\n";
        exit;
} else {
/* Display transaction listing */
        $result = mysql_query("select * from info order by id asc");
        if (mysql_num_rows($result) == "0") {
                echo "<b>Belum ada data sama sekali!</b> - Anda mesti memasukkan suatu data menggunakan link \n";
                echo "di atas!\n\n";
                footer();
                exit;
        }

        echo "<table border=1 bordercolor=black width=100% cellspacing=0 cellpadding=2>\n";
        echo "<tr bgcolor=#C0C0C1><th align=right><font face=Tahoma size=-1><nobr>ID [<a href=\"javascript:showHelp('transno');\">?</a>]</nobr></font></th>\n";
        echo "<th align=center><font face=Tahoma size=-1><nobr>Name [<a href=\"javascript:showHelp('name');\">?</a>]</nobr></font></th>\n";
        echo "<th align=left><font face=Tahoma size=-1><nobr>Lokasi [<a href=\"javascript:showHelp('location');\">?</a>]</nobr></font></th>\n";
        echo "<th align=left><font face=Tahoma size=-1><nobr>Phone [<a href=\"javascript:showHelp('phone');\">?</a>]</nobr></font></th>\n";
        echo "<th align=right><font face=Tahoma size=-1><nobr>Description [<a href=\"javascript:showHelp('desc');\">?</a>]</nobr></font></th>\n";
        echo "<th align=right><font face=Tahoma size=-1><nobr>Type of Food [<a href=\"javascript:showHelp('type');\">?</a>]</nobr></font></th>\n";
        echo "<th align=center><font face=Tahoma size=-1><nobr>Options [<a href=\"javascript:showHelp('options');\">?</a>]</nobr></font></th></tr>\n";

        $total = 0;
        $colorcount = 1;
        while ($row = mysql_fetch_array($result)) {
                if ($row[type] == "d" || $row[type] == "b") {
                        $total = $total + $row[amount];
                } else {
                        $total = $total - $row[amount];
                }

                if ($colorcount % 2) { $color = $color1; } else { $color = $color2; }

                $type = whatis($row[type]);

                echo "<tr align=top bgcolor=\"$color\">\n";
                echo "<td align=right><font face=Tahoma size=-1>$row[ID]</font></td>\n";
                echo "<td align=center><font face=Tahoma size=-1><nobr>$row[name]</nobr></font></td>\n";
                echo "<td align=left><font face=Tahoma size=-1>$row[location]</font></td>\n";
                echo "<td align=left><font face=Tahoma size=-1>$row[phone_number]</font></td>\n";
                echo "<td align=right><font face=Tahoma size=-1>$row[description]</font></td>\n";
                echo "<td align=right><font face=Tahoma size=-1>$row[type_of_food]</font></td>\n";
                echo "<td align=center><font face=Tahoma size=-1>";
                echo "[<a href=\"$PHP_SELF?action=delete&id=$row[id]\">D</a>] ";
                echo "[<a href=\"$PHP_SELF?action=edit&id=$row[id]\">E</a>]";
                echo "</font></td></tr>\n\n";

                $colorcount++;

        }
        echo "</table>\n\n";
}

footer();  /* Called if script isn't exited because of error above */

?>