diff --git a/README.md b/README.md deleted file mode 100644 index 3bae8f5..0000000 --- a/README.md +++ /dev/null @@ -1,18 +0,0 @@ -IF3110-Tubes-I -============== -Repositori ini adalah repositori dasar yang akan dijadikan basis oleh setiap kelompok peserta kuliah IF3110. - -Pengumpulan Tugas: -- Sebutkan URL repositori yang akan dinilai - - Repositori peserta kuliah harus merupakan fork dari repo ini (harus secara langsung) -- Sebutkan anggota dari kelompok (NIM NAMA MAIL GITHUB_ID) -- Kontributor dari repositori tersebut HANYA anggota kelompok yang bersangkutan - -Rule dan Konvensi: -- Setiap peserta harus menggunakan akun pribadi, dan bukan shared-account, pada setiap kegiatan/hubungan dengan github -- Proyek yang dikumpulkan harus memuat file berikut: -- INSTALL.md - berisi how-to untuk proses peng-install-an dari aplikasi -- MEMEBER.md - berisi NIM NAMA MAIL GITHUB_ID dari anggota grup ini -- src/ - berisi semua kode sumber dari aplikasi yang akan anda kumplukan -- docs/ - berisi dokumentasi dari aplikasi, jika diperlukan -- db/ - berisi file sql hasil dump diff --git a/ruserba.sql b/ruserba.sql new file mode 100644 index 0000000..c728443 --- /dev/null +++ b/ruserba.sql @@ -0,0 +1,184 @@ +-- phpMyAdmin SQL Dump +-- version 3.4.5 +-- http://www.phpmyadmin.net +-- +-- Host: localhost +-- Generation Time: Oct 29, 2013 at 03:15 PM +-- Server version: 5.5.16 +-- PHP Version: 5.3.8 + +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; +SET time_zone = "+00:00"; + + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!40101 SET NAMES utf8 */; + +-- +-- Database: `ruserba` +-- + +-- -------------------------------------------------------- + +-- +-- Table structure for table `barang` +-- + +CREATE TABLE IF NOT EXISTS `barang` ( + `id_barang` int(11) NOT NULL AUTO_INCREMENT, + `nama_barang` varchar(256) NOT NULL, + `id_kategori` int(11) NOT NULL, + `harga_barang` bigint(20) NOT NULL, + `gambar` varchar(256) NOT NULL, + `tersedia` int(11) NOT NULL, + `dibeli` int(11) NOT NULL, + PRIMARY KEY (`id_barang`), + KEY `id_kategori` (`id_kategori`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=27 ; + +-- +-- Dumping data for table `barang` +-- + +INSERT INTO `barang` (`id_barang`, `nama_barang`, `id_kategori`, `harga_barang`, `gambar`, `tersedia`, `dibeli`) VALUES +(1, 'Giordano', 1, 300000, 'giordano.jpg', 10, 1), +(2, 'Polo', 1, 150000, 'polo.jpg', 10, 1), +(3, 'Dagadu', 1, 50000, 'dagadu.jpg', 30, 10), +(4, 'Joger', 1, 40000, 'joger.jpg', 5, 1), +(5, 'Samsung', 2, 1500000, 'samsung.jpg', 13, 10), +(6, 'Iphone', 2, 5000000, 'iphone.jpg', 5, 0), +(7, 'Nokia', 2, 2000000, 'nokia.jpg', 6, 3), +(8, 'Mito', 2, 200000, 'mito.jpg', 7, 3), +(9, 'Cubitus', 3, 150000, 'cubitus.jpg', 6, 3), +(10, 'Levis', 3, 400000, 'levis.jpg', 5, 1), +(11, 'Lee', 3, 300000, 'lee.jpg', 4, 2), +(12, 'Ayam Bawang', 4, 2000, 'ayambawang.png', 50, 10), +(13, 'Rendang', 4, 2500, 'rendang.png', 10, 50), +(14, 'Kari Ayam', 4, 2000, 'kariayam.jpg', 40, 15), +(15, 'Cabe Ijo', 4, 2000, 'cabeijo.jpg', 40, 20), +(16, 'Soto', 4, 2000, 'soto.jpg', 25, 10), +(17, 'Aqua', 5, 3000, 'aqua.jpg', 10, 20), +(18, 'Mizone', 5, 5000, 'mizone.jpg', 20, 1), +(19, 'Kiranti', 5, 6000, 'kiranti.jpg', 1, 1), +(20, 'Mix Max', 5, 20000, 'mixmax.jpg', 1, 60), +(21, 'Vit', 5, 1000, 'vit.jpg', 10, 0); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `kartu_kredit` +-- + +CREATE TABLE IF NOT EXISTS `kartu_kredit` ( + `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `no_kartu` varchar(16) NOT NULL, + `nama` varchar(256) NOT NULL, + `kadaluarsa` date NOT NULL, + PRIMARY KEY (`username`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `kartu_kredit` +-- + +INSERT INTO `kartu_kredit` (`username`, `no_kartu`, `nama`, `kadaluarsa`) VALUES +('admin', '1732979879817329', 'admin ga ganteng', '2013-10-31'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `kategori` +-- + +CREATE TABLE IF NOT EXISTS `kategori` ( + `id_kategori` int(11) NOT NULL AUTO_INCREMENT, + `nama_kategori` varchar(256) NOT NULL, + PRIMARY KEY (`id_kategori`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; + +-- +-- Dumping data for table `kategori` +-- + +INSERT INTO `kategori` (`id_kategori`, `nama_kategori`) VALUES +(1, 'Baju'), +(2, 'Gadget'), +(3, 'Celana'), +(4, 'Indomie'), +(5, 'Minuman'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user` +-- + +CREATE TABLE IF NOT EXISTS `user` ( + `username` varchar(20) COLLATE utf8_bin NOT NULL, + `password` varchar(256) COLLATE utf8_bin NOT NULL, + `token` varchar(20) COLLATE utf8_bin DEFAULT NULL, + `last_login` date DEFAULT NULL, + PRIMARY KEY (`username`), + UNIQUE KEY `token` (`token`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; + +-- +-- Dumping data for table `user` +-- + +INSERT INTO `user` (`username`, `password`, `token`, `last_login`) VALUES +('admin', 'asdfasdf', '9kWVGnZp6rxlYeUbrYYT', '2013-10-29'); + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_profile` +-- + +CREATE TABLE IF NOT EXISTS `user_profile` ( + `username` varchar(20) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, + `nama` varchar(256) NOT NULL, + `email` varchar(100) NOT NULL, + `alamat` varchar(256) DEFAULT NULL, + `kota` varchar(256) DEFAULT NULL, + `kode_pos` varchar(5) DEFAULT NULL, + `provinsi` varchar(256) DEFAULT NULL, + `nomor_ponsel` varchar(15) DEFAULT NULL, + PRIMARY KEY (`username`), + UNIQUE KEY `email` (`email`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +-- +-- Dumping data for table `user_profile` +-- + +INSERT INTO `user_profile` (`username`, `nama`, `email`, `alamat`, `kota`, `kode_pos`, `provinsi`, `nomor_ponsel`) VALUES +('admin', 'admin ganteng', 'admin@ruserba.com', 'alamat admin', 'kota admin', '13452', 'prov admin', '0987654321'); + +-- +-- Constraints for dumped tables +-- + +-- +-- Constraints for table `barang` +-- +ALTER TABLE `barang` + ADD CONSTRAINT `barang_ibfk_1` FOREIGN KEY (`id_kategori`) REFERENCES `kategori` (`id_kategori`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `kartu_kredit` +-- +ALTER TABLE `kartu_kredit` + ADD CONSTRAINT `kartu_kredit_ibfk_1` FOREIGN KEY (`username`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE; + +-- +-- Constraints for table `user_profile` +-- +ALTER TABLE `user_profile` + ADD CONSTRAINT `user_profile_ibfk_1` FOREIGN KEY (`username`) REFERENCES `user` (`username`) ON DELETE CASCADE ON UPDATE CASCADE; + +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; diff --git a/ruserba/.htaccess b/ruserba/.htaccess new file mode 100644 index 0000000..7744a54 --- /dev/null +++ b/ruserba/.htaccess @@ -0,0 +1,32 @@ +Options +FollowSymLinks +RewriteEngine on + +RewriteCond %{REQUEST_FILENAME} !-d +RewriteCond %{REQUEST_FILENAME} !-f + +RewriteRule ^search/([^\/\\]+)/?$ index.php?page=search&q=$1 [NC,L] +RewriteRule ^search/([^\/\\]+)/([0-9]+)/?$ index.php?page=search&q=$1&p=$2 [NC,L] +RewriteRule ^search/?$ index.php?page=error [NC,L] + +RewriteRule ^kategori/([0-9]+)/?$ index.php?page=kategori&id=$1 [NC,L] +RewriteRule ^kategori/([0-9]+)/name/?$ index.php?page=kategori&id=$1&orderby=name [NC,L] +RewriteRule ^kategori/([0-9]+)/name/asc/?$ index.php?page=kategori&id=$1&orderby=name&sort=asc [NC,L] +RewriteRule ^kategori/([0-9]+)/name/desc/?$ index.php?page=kategori&id=$1&orderby=name&sort=desc [NC,L] +RewriteRule ^kategori/([0-9]+)/price/?$ index.php?page=kategori&id=$1&orderby=price [NC,L] +RewriteRule ^kategori/([0-9]+)/price/asc/?$ index.php?page=kategori&id=$1&orderby=price&sort=asc [NC,L] +RewriteRule ^kategori/([0-9]+)/price/desc/?$ index.php?page=kategori&id=$1&orderby=price&sort=desc [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/name/?$ index.php?page=kategori&id=$1&p=$2&orderby=name [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/name/asc/?$ index.php?page=kategori&id=$1&p=$2&orderby=name&sort=asc [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/name/desc/?$ index.php?page=kategori&id=$1&p=$2&orderby=name&sort=desc [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/price/?$ index.php?page=kategori&id=$1&p=$2&orderby=price [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/price/asc/?$ index.php?page=kategori&id=$1&p=$2&orderby=price&sort=asc [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/price/desc/?$ index.php?page=kategori&id=$1&p=$2&orderby=price&sort=desc [NC,L] +RewriteRule ^kategori/([0-9]+)/([0-9]+)/?$ index.php?page=kategori&id=$1&p=$2 [NC,L] +RewriteRule ^kategori/?$ index.php?page=error [NC,L] + +RewriteRule ^barang/([0-9]+)/?$ index.php?page=barang&id=$1 [NC,L] +RewriteRule ^barang/?$ index.php?page=error [NC,L] + +RewriteRule ^([a-z0-9]+)/?$ index.php?page=$1 [NC,L] + +ErrorDocument 404 /ruserba/index.php?page=error \ No newline at end of file diff --git a/ruserba/assets/barang/Levis.jpg b/ruserba/assets/barang/Levis.jpg new file mode 100644 index 0000000..73d9a51 Binary files /dev/null and b/ruserba/assets/barang/Levis.jpg differ diff --git a/ruserba/assets/barang/aqua.jpg b/ruserba/assets/barang/aqua.jpg new file mode 100644 index 0000000..b0609e6 Binary files /dev/null and b/ruserba/assets/barang/aqua.jpg differ diff --git a/ruserba/assets/barang/ayambawang.png b/ruserba/assets/barang/ayambawang.png new file mode 100644 index 0000000..b8ba09c Binary files /dev/null and b/ruserba/assets/barang/ayambawang.png differ diff --git a/ruserba/assets/barang/cabeijo.jpg b/ruserba/assets/barang/cabeijo.jpg new file mode 100644 index 0000000..40be3de Binary files /dev/null and b/ruserba/assets/barang/cabeijo.jpg differ diff --git a/ruserba/assets/barang/cubitus.jpg b/ruserba/assets/barang/cubitus.jpg new file mode 100644 index 0000000..f0fc964 Binary files /dev/null and b/ruserba/assets/barang/cubitus.jpg differ diff --git a/ruserba/assets/barang/dagadu.jpg b/ruserba/assets/barang/dagadu.jpg new file mode 100644 index 0000000..ab07bd3 Binary files /dev/null and b/ruserba/assets/barang/dagadu.jpg differ diff --git a/ruserba/assets/barang/giordano.jpg b/ruserba/assets/barang/giordano.jpg new file mode 100644 index 0000000..e9a0788 Binary files /dev/null and b/ruserba/assets/barang/giordano.jpg differ diff --git a/ruserba/assets/barang/iphone.jpg b/ruserba/assets/barang/iphone.jpg new file mode 100644 index 0000000..d9c021f Binary files /dev/null and b/ruserba/assets/barang/iphone.jpg differ diff --git a/ruserba/assets/barang/joger.jpg b/ruserba/assets/barang/joger.jpg new file mode 100644 index 0000000..25d61c6 Binary files /dev/null and b/ruserba/assets/barang/joger.jpg differ diff --git a/ruserba/assets/barang/kariayam.jpg b/ruserba/assets/barang/kariayam.jpg new file mode 100644 index 0000000..bf202f2 Binary files /dev/null and b/ruserba/assets/barang/kariayam.jpg differ diff --git a/ruserba/assets/barang/kiranti.jpg b/ruserba/assets/barang/kiranti.jpg new file mode 100644 index 0000000..4b9e25c Binary files /dev/null and b/ruserba/assets/barang/kiranti.jpg differ diff --git a/ruserba/assets/barang/lee.jpg b/ruserba/assets/barang/lee.jpg new file mode 100644 index 0000000..02001a9 Binary files /dev/null and b/ruserba/assets/barang/lee.jpg differ diff --git a/ruserba/assets/barang/mito.jpg b/ruserba/assets/barang/mito.jpg new file mode 100644 index 0000000..0912eee Binary files /dev/null and b/ruserba/assets/barang/mito.jpg differ diff --git a/ruserba/assets/barang/mixmax.jpg b/ruserba/assets/barang/mixmax.jpg new file mode 100644 index 0000000..50bc520 Binary files /dev/null and b/ruserba/assets/barang/mixmax.jpg differ diff --git a/ruserba/assets/barang/mizone.jpg b/ruserba/assets/barang/mizone.jpg new file mode 100644 index 0000000..af2700d Binary files /dev/null and b/ruserba/assets/barang/mizone.jpg differ diff --git a/ruserba/assets/barang/nokia.jpg b/ruserba/assets/barang/nokia.jpg new file mode 100644 index 0000000..d71b6f0 Binary files /dev/null and b/ruserba/assets/barang/nokia.jpg differ diff --git a/ruserba/assets/barang/polo.jpg b/ruserba/assets/barang/polo.jpg new file mode 100644 index 0000000..e4fbd92 Binary files /dev/null and b/ruserba/assets/barang/polo.jpg differ diff --git a/ruserba/assets/barang/rendang.png b/ruserba/assets/barang/rendang.png new file mode 100644 index 0000000..6cb39ef Binary files /dev/null and b/ruserba/assets/barang/rendang.png differ diff --git a/ruserba/assets/barang/samsung.jpg b/ruserba/assets/barang/samsung.jpg new file mode 100644 index 0000000..32b4d73 Binary files /dev/null and b/ruserba/assets/barang/samsung.jpg differ diff --git a/ruserba/assets/barang/soto.jpg b/ruserba/assets/barang/soto.jpg new file mode 100644 index 0000000..5df35e7 Binary files /dev/null and b/ruserba/assets/barang/soto.jpg differ diff --git a/ruserba/assets/barang/vit.jpg b/ruserba/assets/barang/vit.jpg new file mode 100644 index 0000000..9be5f51 Binary files /dev/null and b/ruserba/assets/barang/vit.jpg differ diff --git a/ruserba/assets/cart.png b/ruserba/assets/cart.png new file mode 100644 index 0000000..d12b372 Binary files /dev/null and b/ruserba/assets/cart.png differ diff --git a/ruserba/assets/favicon.PNG b/ruserba/assets/favicon.PNG new file mode 100644 index 0000000..6f32c66 Binary files /dev/null and b/ruserba/assets/favicon.PNG differ diff --git a/ruserba/assets/icon_recommend.png b/ruserba/assets/icon_recommend.png new file mode 100644 index 0000000..1bca0c1 Binary files /dev/null and b/ruserba/assets/icon_recommend.png differ diff --git a/ruserba/assets/icon_star.png b/ruserba/assets/icon_star.png new file mode 100644 index 0000000..d51eef9 Binary files /dev/null and b/ruserba/assets/icon_star.png differ diff --git a/ruserba/assets/logo.png b/ruserba/assets/logo.png new file mode 100644 index 0000000..f070667 Binary files /dev/null and b/ruserba/assets/logo.png differ diff --git a/ruserba/assets/search.png b/ruserba/assets/search.png new file mode 100644 index 0000000..26dc2b6 Binary files /dev/null and b/ruserba/assets/search.png differ diff --git a/ruserba/index.php b/ruserba/index.php new file mode 100644 index 0000000..e57986d --- /dev/null +++ b/ruserba/index.php @@ -0,0 +1,22 @@ + + + + + + <?php echo getPageTitle(); ?> + + + + +
+ +
+
+ +
+
+ +





+
+ + \ No newline at end of file diff --git a/ruserba/pages/barang.php b/ruserba/pages/barang.php new file mode 100644 index 0000000..65e9bfe --- /dev/null +++ b/ruserba/pages/barang.php @@ -0,0 +1,55 @@ + + +'; + echo $barang['nama_barang']; + echo ''; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo '
'; + echo '
'; + $query = 'select nama_kategori from kategori where id_kategori=?'; + $params = array($barang['id_kategori']); + include 'scripts/php/query.php'; + echo 'Kategori: '; + echo ''; + echo $result[0]['nama_kategori']; + echo ''; + echo ''; + echo ''; + echo '
'; + if($barang['tersedia']==0){ + echo ''; + echo 'Barang tidak tersedia'; + echo ''; + echo '
'; + } + else{ + echo ''; + echo 'Barang tersedia ('.$barang['tersedia'].' unit)'; + echo ''; + echo '
'; + } + echo ''; + echo 'Rp '.$barang['harga_barang'].',00'; + echo ''; + echo '
'; + echo '
'; + echo '
'; + if ($barang['tersedia'] > 0) { + echo 'Jumlah '; + echo ''; + echo '
'; + echo '
Pesan Barang
'; + } + echo '
'; + echo '
'; +?> \ No newline at end of file diff --git a/ruserba/pages/cart.php b/ruserba/pages/cart.php new file mode 100644 index 0000000..92e9b97 --- /dev/null +++ b/ruserba/pages/cart.php @@ -0,0 +1,83 @@ + + + +

Keranjang Belanja

+
+
+
+
+ $amount) { + $query = 'select * from barang left join kategori on barang.id_kategori=kategori.id_kategori where id_barang=?'; + $params = array($id); + include 'scripts/php/query.php'; + $barang = $result[0]; + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo $barang['nama_barang']; + echo ''; + echo '
'; + echo 'Kategori: '; + echo ''; + echo $barang['nama_kategori']; + echo ''; + echo '
'; + echo '
'; + if($barang['tersedia']==0){ + echo ''; + echo 'Tidak tersedia'; + echo ''; + echo '
'; + } + else{ + echo ''; + echo 'Tersedia '.$barang['tersedia'].' unit'; + echo ''; + echo '
'; + } + echo '
'; + echo ''; + echo 'Rp '.$barang['harga_barang'].',00'; + echo ''; + echo '
'; + echo '
'; + echo 'Jumlah '; + echo ''; + echo '
'; + $subtotal = $amount * $barang['harga_barang']; + echo '
Subtotal: Rp '.$subtotal.',00
'; + echo '
'; + echo '
'; + echo '
'; + $total += $subtotal; + } + } + ?> +
+
+

Total:

+

+ Rp ,00 +

+
+ 0) { + ?> +
Bayar
+ +
\ No newline at end of file diff --git a/ruserba/pages/error.php b/ruserba/pages/error.php new file mode 100644 index 0000000..8675dc2 --- /dev/null +++ b/ruserba/pages/error.php @@ -0,0 +1 @@ +

Halaman tidak ditemukan

\ No newline at end of file diff --git a/ruserba/pages/footer.php b/ruserba/pages/footer.php new file mode 100644 index 0000000..551196c --- /dev/null +++ b/ruserba/pages/footer.php @@ -0,0 +1 @@ +© 2013 \ No newline at end of file diff --git a/ruserba/pages/header.php b/ruserba/pages/header.php new file mode 100644 index 0000000..0426592 --- /dev/null +++ b/ruserba/pages/header.php @@ -0,0 +1,44 @@ + + + +
+
Masuk
+
+ Username

+ Kata sandi

+ Username atau kata sandi salah + +
Masuk
+
+
+
Daftar
+
+
+
Selamat datang, !
+
Keluar
+
+
+ + $amount) { + $total += $amount; + } + echo $total; + } + else { + echo 0; + } + ?> barang +
+
+ \ No newline at end of file diff --git a/ruserba/pages/home.php b/ruserba/pages/home.php new file mode 100644 index 0000000..e0f4ba5 --- /dev/null +++ b/ruserba/pages/home.php @@ -0,0 +1,57 @@ +

Barang terpopuler

+ +'; + echo ''; + echo ''; + echo ' '; + echo ''; + echo $kategori['nama_kategori']; + echo ''; + echo ''; + echo '
'; + echo '
'; + $query = "select * from barang where barang.id_kategori = ? order by dibeli desc limit 0, 3"; + $params = array($kategori['id_kategori']); + include 'scripts/php/query.php'; + echo '
'; + foreach ($result as $barang){ + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + echo ''; + echo ''; + echo $barang['nama_barang']; + echo ''; + echo ''; + echo '
'; + if($barang['tersedia']==0){ + echo ''; + echo 'Barang tidak tersedia'; + echo ''; + echo '
'; + } + else{ + echo ''; + echo 'Barang tersedia ('.$barang['tersedia'].' unit)'; + echo ''; + echo '
'; + } + echo ''; + echo 'Rp '.$barang['harga_barang'].',00'; + echo ''; + echo '
'; + echo '
'; + } + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo '
'; + } +?> diff --git a/ruserba/pages/kategori.php b/ruserba/pages/kategori.php new file mode 100644 index 0000000..238f92c --- /dev/null +++ b/ruserba/pages/kategori.php @@ -0,0 +1,106 @@ + + + +Kategori: '; + echo $result[0]['nama_kategori']; + echo ''; + $query = "select * from barang where id_kategori=?"; + $params = array($_GET['id']); + include 'scripts/php/query.php'; + $banyakBarang = count($result); + $page = isset($_GET['p']) ? $_GET['p'] : 1; + $limit = 10; + $mulai_dari = $limit * ($page - 1); + echo ''; + echo '
'; + echo '
'; + $params = array($_GET['id'], $mulai_dari, $limit); + include 'scripts/php/query.php'; + foreach($result as $barang){ + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo $barang['nama_barang']; + echo ''; + echo ''; + echo '
'; + if($barang['tersedia']==0){ + echo ''; + echo 'Barang tidak tersedia'; + echo ''; + echo '
'; + } + else{ + echo ''; + echo 'Barang tersedia ('.$barang['tersedia'].' unit)'; + echo ''; + echo '
'; + } + echo ''; + echo 'Rp '.$barang['harga_barang'].',00'; + echo ''; + echo '
'; + echo '
'; + if ($barang['tersedia'] > 0) { + echo '
Pesan Barang
'; + } + echo '
'; + echo '
'; + echo '
'; + } + //membuat pagination + $banyakHalaman = ceil($banyakBarang / $limit); + if ($banyakHalaman > 1) { + echo '
'; + echo 'Halaman: '; + for($i = 1; $i <= $banyakHalaman; $i++){ + if($page != $i){ + echo '['.$i.'] '; + } + else { + echo "[$i] "; + } + } + echo '
'; + } +?> \ No newline at end of file diff --git a/ruserba/pages/profile.php b/ruserba/pages/profile.php new file mode 100644 index 0000000..bc36e0e --- /dev/null +++ b/ruserba/pages/profile.php @@ -0,0 +1,38 @@ + +
+

+
+
+ Nama lengkap
+ Nama lengkap harus terdiri dari paling sedikit 2 kata
+ + Kata sandi
+ Kata sandi paling sedikit 8 karakter + Kata sandi tidak boleh sama dengan username + Kata sandi tidak boleh sama dengan alamat email
+ + Konfirmasi kata sandi
+ Kata sandi tidak cocok
+ + Alamat
+
+ + Kota/kabupaten
+
+ + Kode pos
+ Format kode pos salah +
+ + Provinsi
+
+ + Nomor ponsel
+ Nomor ponsel tidak boleh melebihi 15 angka + Format nomor ponsel salah +
+ +
+ +
+
\ No newline at end of file diff --git a/ruserba/pages/register.php b/ruserba/pages/register.php new file mode 100644 index 0000000..3c09c46 --- /dev/null +++ b/ruserba/pages/register.php @@ -0,0 +1,28 @@ + +
+

Pendaftaran RuSerbA

+
+
+ Username
+ Username paling sedikit 5 karakter + Username sudah digunakan
+ + Kata sandi
+ Kata sandi paling sedikit 8 karakter + Kata sandi tidak boleh sama dengan username + Kata sandi tidak boleh sama dengan alamat email
+ + Konfirmasi kata sandi
+ Kata sandi tidak cocok
+ + Nama lengkap
+ Nama lengkap harus terdiri dari paling sedikit 2 kata
+ + Alamat email
+ Format alamat email salah + Alamat email sudah digunakan
+ +
+ +
+
\ No newline at end of file diff --git a/ruserba/pages/registerkartu.php b/ruserba/pages/registerkartu.php new file mode 100644 index 0000000..3c57d63 --- /dev/null +++ b/ruserba/pages/registerkartu.php @@ -0,0 +1,19 @@ + +
+

Pendaftaran Kartu Kredit

+
Lewati tahap ini
+
+
+
+ Nomor kartu
+
+ + Nama pada kartu
+
+ + Tanggal kadaluarasa
+
+ + +
+
\ No newline at end of file diff --git a/ruserba/pages/search.php b/ruserba/pages/search.php new file mode 100644 index 0000000..2323634 --- /dev/null +++ b/ruserba/pages/search.php @@ -0,0 +1,78 @@ + +'; + echo 'Hasil pencarian untuk: '.$q.' ('.($mulai_dari + 1).'-'.($mulai_dari + count($result)).' dari '.$banyakBarang.' hasil)'; + echo ''; + if (count($result) > 0) { + foreach ($result as $barang) { + echo '
'; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo ''; + echo '
'; + echo '
'; + echo ''; + echo ''; + echo $barang['nama_barang']; + echo ''; + echo '
'; + echo 'Kategori: '; + echo ''; + echo $barang['nama_kategori']; + echo ''; + echo '
'; + echo '
'; + if($barang['tersedia']==0){ + echo ''; + echo 'Barang tidak tersedia'; + echo ''; + echo '
'; + } + else{ + echo ''; + echo 'Barang tersedia ('.$barang['tersedia'].' unit)'; + echo ''; + echo '
'; + } + echo ''; + echo 'Rp '.$barang['harga_barang'].',00'; + echo ''; + echo '
'; + echo '
'; + if ($barang['tersedia'] > 0) { + echo '
Pesan Barang
'; + } + echo '
'; + echo '
'; + echo '
'; + } + } + //membuat pagination + $banyakHalaman = ceil($banyakBarang / $limit); + if ($banyakHalaman > 1) { + echo '
'; + echo 'Halaman: '; + for($i = 1; $i <= $banyakHalaman; $i++){ + if($page != $i){ + echo '['.$i.'] '; + } + else { + echo "[$i] "; + } + } + } + echo '
'; +?> \ No newline at end of file diff --git a/ruserba/scripts/addamounttocart.js b/ruserba/scripts/addamounttocart.js new file mode 100644 index 0000000..512b3fc --- /dev/null +++ b/ruserba/scripts/addamounttocart.js @@ -0,0 +1,38 @@ +window.addEventListener('load', function() { + var inputjumlah = document.getElementsByClassName('inputjumlah')[0]; + var belibutton = document.getElementsByClassName('beli')[0]; + + belibutton.onclick = function() { + if (localStorage.getItem('auth_token') != null) { + if (inputjumlah.value * 1 > 0 && inputjumlah.value * 1 <= inputjumlah.max * 1) { + var idbarang = this.name; + if (!(idbarang in cartcontent)) { + cartcontent[idbarang] = 0; + } + cartcontent[idbarang] += inputjumlah.value * 1; + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/updatecart.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'cartcontent=' + JSON.stringify(cartcontent); + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + document.write(xhr.responseText); + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + window.location.reload(); + } + } + } + } + else { + alert('Barang yang tersedia tidak mencukupi'); + } + } + else { + window.location.href = '/ruserba/register'; + } + return false; + } + +}); \ No newline at end of file diff --git a/ruserba/scripts/addtocart.js b/ruserba/scripts/addtocart.js new file mode 100644 index 0000000..8614903 --- /dev/null +++ b/ruserba/scripts/addtocart.js @@ -0,0 +1,31 @@ +window.addEventListener('load', function() { + var belibutton = document.getElementsByClassName('beli'); + + for(var i=0; i this.max * 1) { + this.value = this.max; + } + var harga = document.getElementById('harga_' + this.name).innerHTML; + var oldsub = document.getElementById('subtotal_' + this.name).innerHTML; + var newtotal = document.getElementById('angkatotal').innerHTML - oldsub; + var newsub = this.value * harga; + document.getElementById('subtotal_' + this.name).innerHTML = newsub; + newtotal += newsub; + document.getElementById('angkatotal').innerHTML = newtotal; + var barang = document.getElementById('totalbarang').innerHTML - cartcontent[this.name]; + barang += this.value * 1; + document.getElementById('totalbarang').innerHTML = barang; + cartcontent[this.name] = this.value * 1; + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/updatecart.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'cartcontent=' + JSON.stringify(cartcontent); + xhr.send(postParams); + } + } + +}); \ No newline at end of file diff --git a/ruserba/scripts/pay.js b/ruserba/scripts/pay.js new file mode 100644 index 0000000..a76970a --- /dev/null +++ b/ruserba/scripts/pay.js @@ -0,0 +1,31 @@ +window.addEventListener('load', function() { + var paybutton = document.getElementsByName('bayar')[0]; + + paybutton.onclick = function() { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/pay.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'username=' + localStorage.getItem('username'); + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + window.location.href = '/ruserba'; + } + else if (response['status'] == 'partial') { + alert('Beberapa barang tidak mencukupi'); + window.location.reload(); + } + else if (response['status'] == 'expired') { + alert('Kartu kredit yang digunakan telah kadaluarsa'); + window.location.href = '/ruserba/registerkartu'; + } + else { + window.location.href = '/ruserba/registerkartu'; + } + } + } + } + +}); \ No newline at end of file diff --git a/ruserba/scripts/php/addtocart.php b/ruserba/scripts/php/addtocart.php new file mode 100644 index 0000000..d368604 --- /dev/null +++ b/ruserba/scripts/php/addtocart.php @@ -0,0 +1,35 @@ +0){ + $amount = 1; + if (isset($_POST['amount'])) { + $amount = $_POST['amount']; + } + if($result[0]['tersedia']>=$amount){ + session_start(); + if (isset($_SESSION['cart'])){ + if (array_key_exists($_POST['id'], $_SESSION['cart'])) { + $_SESSION['cart'][$_POST['id']] += $amount; + } + else { + $_SESSION['cart'][$_POST['id']] = $amount; + } + } + else { + $_SESSION['cart'] = array($_POST['id'] => $amount); + } + echo json_encode(array('status'=>'success')); + } + else{ + echo json_encode(array('status'=>'failed')); + } + + } + else { + echo json_encode(array('status'=>'failed')); + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/check_user.php b/ruserba/scripts/php/check_user.php new file mode 100644 index 0000000..da569cc --- /dev/null +++ b/ruserba/scripts/php/check_user.php @@ -0,0 +1,24 @@ + 0) { + echo json_encode(array('status'=>'exists')); + } + else { + echo json_encode(array('status'=>'not exists')); + } + } + else if (isset($_POST['email'])) { + $query = 'select email from user_profile where email=?'; + $params = array($_POST['email']); + include 'query.php'; + if (count($result) > 0) { + echo json_encode(array('status'=>'exists')); + } + else { + echo json_encode(array('status'=>'not exists')); + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/login.php b/ruserba/scripts/php/login.php new file mode 100644 index 0000000..c3911a6 --- /dev/null +++ b/ruserba/scripts/php/login.php @@ -0,0 +1,42 @@ + 0) { + include 'token_generator.php'; + $query = 'update user set token=?, last_login=? where username=?'; + $params = array($token, date('Y-m-d'), $_POST['username']); + include 'query.php'; + echo json_encode(array('status'=>'success', 'token'=>$token)); + } + else { + echo json_encode(array('status'=>'failed')); + } + } + else if (isset($_POST['token'])) { + $query = 'select token, last_login from user where token=?'; + $params = array($_POST['token']); + include 'query.php'; + if (count($result) > 0) { + $dt1 = new DateTime(date('Y-m-d')); + $dt2 = new DateTime($result[0]['last_login']); + $diff = date_diff($dt1, $dt2); + if ($diff->format('%m') > 0 || $diff->format('%d') > 30) { + $query = 'update user set token=?, last_login=? where token=?'; + $params = array(null, null, $_POST['token']); + include 'query.php'; + echo json_encode(array('status'=>'failed')); + } + else { + $query = 'update user set last_login=? where token=?'; + $params = array(date('Y-m-d'), $_POST['token']); + include 'query.php'; + echo json_encode(array('status'=>'success')); + } + } + else { + echo json_encode(array('status'=>'failed')); + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/logout.php b/ruserba/scripts/php/logout.php new file mode 100644 index 0000000..02638d8 --- /dev/null +++ b/ruserba/scripts/php/logout.php @@ -0,0 +1,15 @@ + 0) { + $query = 'update user set token=null, last_login=null where username=?'; + $params = array($result[0]['username']); + include 'query.php'; + } + session_destroy(); + echo json_encode(array('status'=>'success')); + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/page.php b/ruserba/scripts/php/page.php new file mode 100644 index 0000000..2ec9a00 --- /dev/null +++ b/ruserba/scripts/php/page.php @@ -0,0 +1,53 @@ + 'Pendaftaran', 'search' => ' - Hasil Pencarian', 'profile' => 'Profil', 'registerkartu' => 'Pendaftaran Kartu Kredit', 'kategori' => '', 'barang' => '', 'cart' => 'Keranjang Belanja'); + $appName = 'Ruko Serba Ada'; + + if (isset($_GET['page']) && $_GET['page'] == 'kategori') { + $query = 'select nama_kategori from kategori where id_kategori=?'; + $params = array($_GET['id']); + include 'query.php'; + $pages['kategori'] = $result[0]['nama_kategori']; + } + + if (isset($_GET['page']) && $_GET['page'] == 'barang') { + $query = 'select nama_barang from barang where id_barang=?'; + $params = array($_GET['id']); + include 'query.php'; + $pages['barang'] = $result[0]['nama_barang']; + } + + if (isset($_GET['page']) && $_GET['page'] == 'search') { + $pages['search'] = urldecode($_GET['q']) . $pages['search']; + } + + function getPageTitle() { + global $pages, $appName; + $suffix = ' | ' . $appName; + if (isset($_GET['page'])) { + if (array_key_exists($_GET['page'], $pages)) { + return $pages[$_GET['page']] . $suffix; + } + else { + return '404' . $suffix; + } + } + else { + return 'Beranda' . $suffix; + } + } + + function getPageContent() { + global $pages; + if (isset($_GET['page'])) { + if (array_key_exists($_GET['page'], $pages)) { + return 'pages/' . $_GET['page'] . '.php'; + } + else { + return 'pages/error.php'; + } + } + else { + return 'pages/home.php'; + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/pay.php b/ruserba/scripts/php/pay.php new file mode 100644 index 0000000..51e5a53 --- /dev/null +++ b/ruserba/scripts/php/pay.php @@ -0,0 +1,39 @@ + 0) { + if (time() > strtotime($result[0]['kadaluarsa'])) { + echo json_encode(array('status'=>'expired')); + } + else { + session_start(); + $success = true; + foreach ($_SESSION['cart'] as $id => $amount) { + $query = 'select tersedia from barang where id_barang=?'; + $params = array($id); + include 'query.php'; + if ($result[0]['tersedia'] >= $amount) { + $query = 'update barang set tersedia=tersedia-?, dibeli=dibeli+? where id_barang=?'; + $params = array($amount, $amount, $id); + include 'query.php'; + unset($_SESSION['cart'][$id]); + } + else { + $success = false; + } + } + if ($success) { + echo json_encode(array('status'=>'success')); + } + else { + echo json_encode(array('status'=>'partial')); + } + } + } + else { + echo json_encode(array('status'=>'failed')); + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/query.php b/ruserba/scripts/php/query.php new file mode 100644 index 0000000..b228d97 --- /dev/null +++ b/ruserba/scripts/php/query.php @@ -0,0 +1,23 @@ + $value) { + $funcparams[$key] = &$params[$key]; + $s .= 's'; + } + array_unshift($funcparams, $stmt, $s); + call_user_func_array('mysqli_stmt_bind_param', $funcparams); + } + mysqli_stmt_execute($stmt); + $affected = mysqli_affected_rows($con); + $result = @mysqli_fetch_all(mysqli_stmt_get_result($stmt), MYSQLI_ASSOC); + mysqli_stmt_close($stmt); + } + mysqli_close($con); + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/register.php b/ruserba/scripts/php/register.php new file mode 100644 index 0000000..cb73036 --- /dev/null +++ b/ruserba/scripts/php/register.php @@ -0,0 +1,12 @@ +'success', 'token'=>$token)); + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/registerkartu.php b/ruserba/scripts/php/registerkartu.php new file mode 100644 index 0000000..3310e5f --- /dev/null +++ b/ruserba/scripts/php/registerkartu.php @@ -0,0 +1,17 @@ + 0) { + $query = 'update kartu_kredit set no_kartu=?, nama=?, kadaluarsa=? where username=?'; + $params = array($_POST['nokartu'], $_POST['nama'], $_POST['kadaluarsa'], $_POST['username']); + } + else { + $query = 'insert into kartu_kredit values (?,?,?,?)'; + $params = array($_POST['username'], $_POST['nokartu'], $_POST['nama'], $_POST['kadaluarsa']); + } + include 'query.php'; + echo json_encode(array('status'=>'success')); + } +?> diff --git a/ruserba/scripts/php/retrieve_profile.php b/ruserba/scripts/php/retrieve_profile.php new file mode 100644 index 0000000..1bdf472 --- /dev/null +++ b/ruserba/scripts/php/retrieve_profile.php @@ -0,0 +1,13 @@ +'failed')); + } + else { + echo json_encode(array('status'=>'success', 'record'=>$result[0])); + } + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/save_profile.php b/ruserba/scripts/php/save_profile.php new file mode 100644 index 0000000..179a27d --- /dev/null +++ b/ruserba/scripts/php/save_profile.php @@ -0,0 +1,11 @@ +'success')); + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/token_generator.php b/ruserba/scripts/php/token_generator.php new file mode 100644 index 0000000..e29ba65 --- /dev/null +++ b/ruserba/scripts/php/token_generator.php @@ -0,0 +1,15 @@ + 0; + } +?> \ No newline at end of file diff --git a/ruserba/scripts/php/updatecart.php b/ruserba/scripts/php/updatecart.php new file mode 100644 index 0000000..d7235df --- /dev/null +++ b/ruserba/scripts/php/updatecart.php @@ -0,0 +1,12 @@ + $value) { + if ($value == 0) { + unset($_SESSION['cart'][$key]); + } + } + echo json_encode(array('status'=>'success')); + } +?> \ No newline at end of file diff --git a/ruserba/scripts/profile.js b/ruserba/scripts/profile.js new file mode 100644 index 0000000..115221f --- /dev/null +++ b/ruserba/scripts/profile.js @@ -0,0 +1,197 @@ +window.addEventListener('load', function() { + if (localStorage.getItem('auth_token') === null) { + window.location.href = '/ruserba/register'; + } + + document.getElementById('formtitle').innerHTML = 'Profil ' + localStorage.getItem('username'); + + var name = document.getElementsByName('name')[0]; + var password = document.getElementsByName('password')[0]; + var confirm = document.getElementsByName('confirm')[0]; + var alamat = document.getElementsByName('alamat')[0]; + var provinsi = document.getElementsByName('provinsi')[0]; + var kotakabupaten = document.getElementsByName('kotakabupaten')[0]; + var kodepos= document.getElementsByName('kodepos')[0]; + var nohp = document.getElementsByName('nohp')[0]; + var submit = document.getElementsByName('esubmit')[0]; + + var record; + + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/retrieve_profile.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhr.send('username=' + localStorage.getItem('username')); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + record = response['record']; + name.value = record['nama']; + password.value = record['password']; + confirm.value = record['password']; + alamat.value = record['alamat']; + provinsi.value = record['provinsi']; + kotakabupaten.value = record['kota']; + kodepos.value = record['kode_pos']; + nohp.value = record['nomor_ponsel']; + } + } + } + + var errorname = document.getElementById('errorname'); + var errorpass = document.getElementById('errorpass'); + var errorpassuser = document.getElementById('errorpassuser'); + var errorpassemail = document.getElementById('errorpassemail'); + var errorcpass = document.getElementById('errorcpass'); + var errorjumlah = document.getElementById('errorjumlah'); + var errorposint = document.getElementById('errorposint'); + var errornoint = document.getElementById('errornoint'); + + name.onkeyup = function() { + var splitname = name.value.split(' '); + if (splitname.length > 1 && splitname[0] != '' && splitname[splitname.length - 1] != '') { + name.className = 'formok'; + errorname.style.display = 'none'; + } + else { + name.className = 'formerror'; + errorname.style.display = 'inline'; + } + }; + + password.onkeyup = function() { + if (password.value.length >= 8) { + if (password.value != username.value) { + if (password.value != email.value) { + password.className = 'formok'; + submitButton(formOk, submit); + errorpass.style.display = 'none'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'none'; + } + else { + password.className = 'formerror'; + submitButton(formOk, submit); + errorpass.style.display = 'none'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'inline'; + } + } + else { + password.className = 'formerror'; + errorpass.style.display = 'none'; + errorpassuser.style.display = 'inline'; + errorpassemail.style.display = 'none'; + } + } + else { + password.className = 'formerror'; + errorpass.style.display = 'inline'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'none'; + } + }; + + confirm.onkeyup = function() { + if (confirm.value == password.value) { + confirm.className = 'formok'; + errorcpass.style.display = 'none'; + } + else { + confirm.className = 'formerror'; + errorcpass.style.display = 'inline'; + } + }; + + kodepos.onkeyup= function(){ + var intRegex = /^\d+$/; + if (intRegex.test(kodepos.value)) { + kodepos.className = 'formok' + errorposint.style.display = 'none'; + } + else{ + kodepos.className = 'formerror' + errorposint.style.display = 'inline'; + } + }; + + nohp.onkeyup = function(){ + var intRegex = /^\d+$/; + if (nohp.value.length <= 15){ + if (intRegex.test(nohp.value)) { + nohp.className = 'formok' + errorjumlah.style.display = 'none'; + errornoint.style.display = 'none'; + } + else{ + nohp.className = 'formerror' + errorjumlah.style.display = 'none'; + errornoint.style.display = 'inline'; + } + } + else{ + nohp.className = 'formerror' + errorjumlah.style.display = 'inline'; + errornoint.style.display = 'none'; + } + }; + + document.getElementById('formprofile').onsubmit = function() { + if (record['alamat'] == null) { + record['alamat'] = ''; + } + if (record['kota'] == null) { + record['kota'] = ''; + } + if (record['kode_pos'] == null) { + record['kode_pos'] = ''; + } + if (record['provinsi'] == null) { + record['provinsi'] = ''; + } + if (record['nomor_ponsel'] == null) { + record['nomor_ponsel'] = ''; + } + if (name.value != record['nama'] || password.value != record['password'] || alamat.value != record['alamat'] || provinsi.value != record['provinsi'] || kotakabupaten.value != record['kota'] || kodepos.value != record['kode_pos'] || nohp.value != record['nomor_ponsel']) { + if (record['username'] != password.value) { + if (record['email'] != password.value) { + if (password.value == confirm.value) { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/save_profile.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'username=' + record['username']; + postParams += '&password=' + password.value; + postParams += '&nama=' + name.value; + postParams += '&alamat=' + alamat.value; + postParams += '&kota=' + kotakabupaten.value; + postParams += '&kodepos=' + kodepos.value; + postParams += '&provinsi=' + provinsi.value; + postParams += '&nohp=' + nohp.value; + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + window.location.reload(); + } + } + } + } + else { + alert('Kata sandi tidak cocok'); + } + } + else { + alert('Kata sandi tidak boleh sama dengan email'); + } + } + else { + alert('Kata sandi tidak boleh sama dengan username'); + } + } + else { + alert('Data tidak berubah'); + } + return false; + }; +}); \ No newline at end of file diff --git a/ruserba/scripts/register.js b/ruserba/scripts/register.js new file mode 100644 index 0000000..8ab5cce --- /dev/null +++ b/ruserba/scripts/register.js @@ -0,0 +1,209 @@ +window.addEventListener('load', function() { + if (localStorage.getItem('auth_token') !== null) { + window.location.href = '/ruserba'; + } + + var username = document.getElementsByName('username')[0]; + var password = document.getElementsByName('password')[0]; + var confirm = document.getElementsByName('confirm')[0]; + var name = document.getElementsByName('name')[0]; + var email = document.getElementsByName('email')[0]; + var submit = document.getElementsByName('submit')[0]; + + var erroruser5 = document.getElementById('erroruser5'); + var erroruser = document.getElementById('erroruser'); + var errorpass = document.getElementById('errorpass'); + var errorpassuser = document.getElementById('errorpassuser'); + var errorpassemail = document.getElementById('errorpassemail'); + var errorcpass = document.getElementById('errorcpass'); + var errorname = document.getElementById('errorname'); + var erroremailformat = document.getElementById('erroremailformat'); + var erroremail = document.getElementById('erroremail'); + + username.focus(); + submit.disabled = true; + + var formOk = [false, false, false, false, false]; + + username.onkeyup = function() { + if (username.value.length >= 5) { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/check_user.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhr.send('username=' + username.value); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'exists') { + username.className = 'formerror'; + formOk[0] = false; + submitButton(formOk, submit); + erroruser5.style.display = 'none'; + erroruser.style.display = 'inline'; + } + else { + formOk[0] = true; + username.className = 'formok'; + submitButton(formOk, submit); + erroruser5.style.display = 'none'; + erroruser.style.display = 'none'; + } + } + } + } + else { + username.className = 'formerror'; + formOk[0] = false; + submitButton(formOk, submit); + erroruser5.style.display = 'inline'; + erroruser.style.display = 'none'; + } + }; + + password.onkeyup = function() { + if (password.value.length >= 8) { + if (password.value != username.value) { + if (password.value != email.value) { + formOk[1] = true; + password.className = 'formok'; + submitButton(formOk, submit); + errorpass.style.display = 'none'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'none'; + } + else { + formOk[1] = false; + password.className = 'formerror'; + submitButton(formOk, submit); + errorpass.style.display = 'none'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'inline'; + } + } + else { + formOk[1] = false; + password.className = 'formerror'; + submitButton(formOk, submit); + errorpass.style.display = 'none'; + errorpassuser.style.display = 'inline'; + errorpassemail.style.display = 'none'; + } + } + else { + formOk[1] = false; + password.className = 'formerror'; + submitButton(formOk, submit); + errorpass.style.display = 'inline'; + errorpassuser.style.display = 'none'; + errorpassemail.style.display = 'none'; + } + }; + + confirm.onkeyup = function() { + if (confirm.value == password.value) { + formOk[2] = true; + confirm.className = 'formok'; + submitButton(formOk, submit); + errorcpass.style.display = 'none'; + } + else { + formOk[2] = false; + confirm.className = 'formerror'; + submitButton(formOk, submit); + errorcpass.style.display = 'inline'; + } + }; + + name.onkeyup = function() { + var splitname = name.value.split(' '); + if (splitname.length > 1 && splitname[0] != '' && splitname[splitname.length - 1] != '') { + formOk[3] = true; + name.className = 'formok'; + submitButton(formOk, submit); + errorname.style.display = 'none'; + } + else { + formOk[3] = false; + name.className = 'formerror'; + submitButton(formOk, submit); + errorname.style.display = 'inline'; + } + }; + + email.onkeyup = function() { + var splitusername = email.value.split('@'); + if (splitusername.length == 2 && splitusername[0] != '' && splitusername[1] != '') { + var splitdomain = splitusername[1].split('.'); + if (splitdomain.length > 1 && splitdomain[0] != '' && splitdomain[splitdomain.length - 1] != '') { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/check_user.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + xhr.send('email=' + email.value); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'exists') { + email.className = 'formerror'; + formOk[4] = false; + submitButton(formOk, submit); + erroremailformat.style.display = 'none'; + erroremail.style.display = 'inline'; + } + else { + formOk[4] = true; + email.className = 'formok'; + submitButton(formOk, submit); + erroremailformat.style.display = 'none'; + erroremail.style.display = 'none'; + } + } + } + } + else { + email.className = 'formerror'; + formOk[4] = false; + submitButton(formOk, submit); + erroremailformat.style.display = 'inline'; + erroremail.style.display = 'none'; + } + } + else { + email.className = 'formerror'; + formOk[4] = false; + submitButton(formOk, submit); + erroremailformat.style.display = 'inline'; + erroremail.style.display = 'none'; + } + }; + + document.getElementById('registerform').onsubmit = function() { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/register.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'username=' + username.value; + postParams += '&password=' + password.value; + postParams += '&name=' + name.value; + postParams += '&email=' + email.value; + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + localStorage.setItem('username', username.value); + localStorage.setItem('auth_token', response['token']); + window.location.href = '/ruserba/registerkartu'; + } + } + } + return false; + }; +}); + +function submitButton(formOk, button) { + if (formOk.indexOf(false) == -1) { + button.disabled = false; + } + else { + button.disabled = true; + } +} \ No newline at end of file diff --git a/ruserba/scripts/registerkartu.js b/ruserba/scripts/registerkartu.js new file mode 100644 index 0000000..dce12d6 --- /dev/null +++ b/ruserba/scripts/registerkartu.js @@ -0,0 +1,34 @@ +window.addEventListener('load', function() { + if (localStorage.getItem('auth_token') === null) { + window.location.href = '/ruserba/register'; + } + + var nokartu = document.getElementsByName('nokartu')[0]; + var namakartu = document.getElementsByName('namakartu')[0]; + var expiry = document.getElementsByName('expiry')[0]; + + nokartu.focus(); + + expiry.min = new Date().toISOString().split('T')[0]; + + document.getElementById('formregisterkartu').onsubmit = function() { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/registerkartu.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'username=' + localStorage.getItem('username'); + postParams += '&nokartu=' + nokartu.value; + postParams += '&nama=' + namakartu.value; + postParams += '&kadaluarsa=' + expiry.value; + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + window.location.href = '/ruserba'; + } + } + } + return false; + }; + +}); \ No newline at end of file diff --git a/ruserba/scripts/search.js b/ruserba/scripts/search.js new file mode 100644 index 0000000..49f427e --- /dev/null +++ b/ruserba/scripts/search.js @@ -0,0 +1,14 @@ +window.addEventListener('load', function() { + var searchform = document.getElementById('searchform'); + var searchinput = document.getElementsByName('searchinput')[0]; + var searchbutton = document.getElementById('searchbutton'); + + searchbutton.onclick = function () { + searchform.onsubmit(); + }; + + searchform.onsubmit = function() { + window.location.href = '/ruserba/search/' + encodeURIComponent(searchinput.value); + return false; + } +}); \ No newline at end of file diff --git a/ruserba/scripts/session.js b/ruserba/scripts/session.js new file mode 100644 index 0000000..c2be399 --- /dev/null +++ b/ruserba/scripts/session.js @@ -0,0 +1,104 @@ +window.addEventListener('load', function() { + var loginbutton = document.getElementById('loginbutton'); + var registerbutton = document.getElementById('registerbutton'); + var logoutbutton = document.getElementById('logoutbutton'); + var loginform = document.getElementById('loginform'); + var loginsubmit = document.getElementById('loginsubmit'); + + loginbutton.onclick = function() { + loginbutton.style.display = 'none'; + loginform.style.display = 'inline-block'; + loginform.getElementsByTagName('input')[0].focus(); + }; + + registerbutton.onclick = function() { + window.location.href = '/ruserba/register'; + } + + logoutbutton.onclick = function() {var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/logout.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'token=' + localStorage.getItem('auth_token'); + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + localStorage.removeItem('auth_token'); + window.location.replace('/ruserba'); + } + } + } + } + + document.onmouseup = function(e) { + if (localStorage.getItem('auth_token') == null) { + if (loginform.style.display != 'none' && e.target.id != 'loginform' && e.target.parentNode.id != 'loginform' && e.target.parentNode.parentNode.id != 'loginform') { + loginbutton.style.display = 'inline-block'; + loginform.style.display = 'none'; + document.getElementById('loginerror').style.visibility = 'hidden'; + } + } + } + + loginsubmit.onclick = function() { + loginform.onsubmit(); + } + + loginform.onsubmit = function() { + var loginuser = document.getElementsByName('loginuser')[0].value; + var loginpass = document.getElementsByName('loginpass')[0].value; + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/login.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'username=' + loginuser; + postParams += '&password=' + loginpass; + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + localStorage.setItem('username', loginuser); + localStorage.setItem('auth_token', response['token']); + window.location.replace('/ruserba'); + } + else { + document.getElementById('loginerror').style.visibility = 'visible'; + } + } + } + return false; + } + + var elementToRemove; + if (localStorage.getItem('auth_token') != null) { + var xhr = new XMLHttpRequest(); + xhr.open('POST', '/ruserba/scripts/php/login.php', true); + xhr.setRequestHeader('Content-type', 'application/x-www-form-urlencoded'); + var postParams = 'token=' + localStorage.getItem('auth_token'); + xhr.send(postParams); + xhr.onreadystatechange = function() { + if (xhr.readyState == 4 && xhr.status == 200) { + var response = JSON.parse(xhr.responseText); + if (response['status'] == 'success') { + var user = document.getElementById('user'); + user.innerHTML = localStorage.getItem('username'); + user.href = '/ruserba/profile/'; + remove = document.getElementById('loggedout'); + remove.parentNode.removeChild(remove); + } + else { + localStorage.removeItem('auth_token'); + document.getElementsByName('loginuser')[0].value = localStorage.getItem('username'); + remove = document.getElementById('loggedin'); + remove.parentNode.removeChild(remove); + } + } + } + } + else { + document.getElementsByName('loginuser')[0].value = localStorage.getItem('username'); + remove = document.getElementById('loggedin'); + remove.parentNode.removeChild(remove); + } +}); \ No newline at end of file diff --git a/ruserba/scripts/sort.js b/ruserba/scripts/sort.js new file mode 100644 index 0000000..6e44e5d --- /dev/null +++ b/ruserba/scripts/sort.js @@ -0,0 +1,43 @@ +window.addEventListener('load', function() { + var selectorder = document.getElementById('selectorder'); + var selectsort = document.getElementById('selectsort'); + + selectorder.onchange = function() { + if (selectorder.selectedIndex == 0) { + if (selectsort.selectedIndex == 0) { + window.location.href = basePageUrl + '/name/asc'; + } + else { + window.location.href = basePageUrl + '/name/desc'; + } + } + else { + if (selectsort.selectedIndex == 0) { + window.location.href = basePageUrl + '/price/asc'; + } + else { + window.location.href = basePageUrl + '/price/desc'; + } + } + }; + + selectsort.onchange = function() { + if (selectorder.selectedIndex == 0) { + if (selectsort.selectedIndex == 0) { + window.location.href = basePageUrl + '/name/asc'; + } + else { + window.location.href = basePageUrl + '/name/desc'; + } + } + else { + if (selectsort.selectedIndex == 0) { + window.location.href = basePageUrl + '/price/asc'; + } + else { + window.location.href = basePageUrl + '/price/desc'; + } + } + }; + +}); \ No newline at end of file diff --git a/ruserba/stylesheets/desktop.css b/ruserba/stylesheets/desktop.css new file mode 100644 index 0000000..55b6974 --- /dev/null +++ b/ruserba/stylesheets/desktop.css @@ -0,0 +1,319 @@ +html { + width:100%; + height:100%; + overflow-x:hidden; + font-family:Segoe UI; + margin:0px; +} + +body { + width:100%; + height:300px; + margin:0px; + margin:0px; +} + +a { + text-decoration:none; +} + +#wrapper { + width:75%; + height:auto; + margin:auto; +} + +#header, #footer{ + width:100%; + height:auto; + margin:10px 0; +} + +#logo { + display:inline-block; +} + +#logo img { + height:120px; +} + +.divider { + width:100%; + height:5px; + margin:10px 0; + background:linear-gradient(white, rgb(177, 189, 53)); +} + +#searchbar { + float:right; + margin:10px 50px; + position:relative; + display:inline-block; +} + +#searchbar input[type=text] { + width:300px; + border:1px solid rgb(177, 189, 53); + padding:4px 7px; + color:grey; +} + +#searchbar input[type=submit] { + display:none; +} + +#searchbar a { + top:5px; + left:295px; + position:absolute; +} + +#searchbar a img { + width:15px; +} + +#welcome { + color:rgb(177, 189, 53); + display:inline-block; + margin:0 10px; +} + +#welcome a { + text-decoration:underline; + color:rgb(177, 189, 53); +} + +#loggedin, #loggedout { + float:right; + margin:10px 0; + display:inline-block; +} + +#loginform { + border:1px solid rgb(177, 189, 53); + border-radius:5px; + padding:5px; + color:rgb(177, 189, 53); + display:none; +} + +#loginform input[type=text], #loginform input[type=password] { + float:right; + border:1px solid rgb(177, 189, 53); +} + +#loginform input[type=submit] { + width:0px; + visibility:hidden; +} + +#loginerror { + color:red; + font-size:small; + visibility:hidden; +} + +.button { + color:white; + text-decoration:none; + display:inline-block; + vertical-align:top; +} + +.button div { + padding:3px 7px; + border:1px solid rgb(177, 189, 53); + border-radius:5px; + background:rgb(177, 189, 53); +} + +#cartbutton { + float:right; + margin:50px 0; +} + +#cartbutton img { + width:30px; +} + +.formcontainer { + width:800px; + margin:auto; + padding:20px 20px 80px 20px; + border:3px solid rgb(177, 189, 53); + border-radius:5px; + background:lightgrey; +} + +.formcontainer h2 { + text-align:center; +} + +.formlabel { + margin:50px; +} + +.formcontainer input[type=text], .formcontainer input[type=password], .formcontainer input[type=date] { + width:50%; + float:right; + margin:0 50px 0 0; +} + +.formcontainer input[type=submit] { + float:right; + margin:0 75px; + background:white; +} + +.formok { + border:2px solid rgb(177, 189, 53); +} + +.formerror { + border:2px solid red; +} + +.formerrortext { + left:350px; + color:red; + font-size:small; + position:relative; + display:none; +} + +#skipregisterkartu { + text-align:center; + text-decoration:underline; +} + +#footer { + width:100%; + margin:auto; + color:grey; + text-align:center; + font-size:xx-small; +} + +#error { + text-align:center; + margin:50px; +} + +#content{ + margin:20px 0 50px 0; + padding:0 10px; + position:relative; +} + +.judul_halaman { + margin:0 30px; + color:rgb(75, 64, 31); +} + +#hr_mostwanted{ + width:30%; + float:left; + margin:0; +} + +.mostwanted{ + float:left; + font-family:Arial; + font-size:23px; +} + +.category_container { + width:95%; + height:250px; + margin-left:5%; + margin-top:30px; + margin-bottom:50px; + display:block; +} + +.category { + float:left; +} + +.category a { + color:rgb(177, 189, 53); + font-family:Tahoma; + font-size:23px; +} + +.barang_container{ + margin-top:5px; + margin-left:auto; + margin-right:auto; + display:block; +} + +.barang { + width:20%; + height:120px; + float:left; + margin-right:12%; +} + +.barang_nama a { + color:rgb(177, 189, 53); + font-size:18px; +} + +.barang_tersedia{ + color:#676669; + font-size:14px; +} + +.barang_harga{ + color:rgb(75, 64, 31); + font-size:16px; + font-weight:bold; +} + +#dropdownsort { + float:right; +} + +.halaman_category_container { + width:95%; + height:200px; + margin-left:5%; + margin-top:30px; + margin-bottom:auto; + display:block; +} + +.barang_gambar_detail { + width:30%; + margin-right:20%; + display:inline-block; +} + +.barang_detail { + vertical-align:top; + display:inline-block; +} + +.inputjumlah { + margin-left:10px; + width:60px; + text-align:right; +} + +.paginasi { + float:right; +} + +#detailkeranjang { + width:70%; + display:inline-block; +} + +#totalkeranjang { + width:25%; + text-align:center; + display:inline-block; + vertical-align:top; + color:rgb(75, 64, 31); +} \ No newline at end of file