Commit b88ebed5 authored by Jonathan Yudi Gunawan's avatar Jonathan Yudi Gunawan
Browse files

php 5.6 compatible, deployed, update readme

parent 1ce6da39
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_URI} !\.(?:css|js|jpe?g|gif|png)$ [NC]
RewriteRule ^([a-zA-Z0-9\-\_\/\s@,\:]*)$ index.php?p=$1
\ No newline at end of file
......@@ -3,36 +3,38 @@
Simple Stock Management Website made using pure PHP, HTML, CSS, and JS. Here are the key features:
- Login and Register account,
- User can buy items,
- Superuser/Admin can create new item and restock item,
- User can buy chocolate,
- Superuser/Admin can create new chocolate and restock chocolate,
- Some functions updated using AJAX,
- Data are saved on MySQL databases,
- no framework library used, but I made my own, worked around MVC concept
Update Oct 19, 2020: deployed on [http://jonathan.elseproperty.com/](http://jonathan.elseproperty.com/)
## Requirements
1. PHP
1. Mysql
1. PHP (tested on 5.6+)
1. Mysql (tested on 5.5.8)
1. Python 3 (tested on 3.6+)
1. Your favorite browser
## Setting Up
1. Install Requirements (I used [XAMPP](https://www.apachefriends.org/download.html) to install all requirements)
1. Clean (delete all files) inside PHP `htdocs` folder
1. Clone repo inside PHP `htdocs` folder
1. Clean (delete all files) inside PHP root document folder (i.e: `htdocs` on XAMPP)
1. Clone repo inside PHP root document folder (i.e: `htdocs` on XAMPP)
1. Open folder `application/config`
1. Duplicate `config.example.ini`, rename to `config.ini`
1. Adjust `config.ini` if needed
1. Run PHP and MySQL (more info see next section)
1. Restore database schema (more info see next section)
1. Restore database images (more info see next section)
1. Restore chocolate images (more info see next section)
## Running
1. Run PHP and MySQL (again, I used [XAMPP](https://www.apachefriends.org/download.html))
- If using XAMPP: press `Start` on Apache(PHP) and MySQL
2. Open localhost:\$PORT on browser (default url is [localhost:80](http://localhost:80/))
2. Open localhost:\$PORT on browser (default url is [http://localhost:80/](http://localhost:80/))
## Restoring Database
......@@ -68,7 +70,7 @@ This will create:
- 100 chocolates
- 2211 transactions
## Restoring Database Images
## Restoring Chocolate Images
sample images is not all saved on repo, you can populate them by running this script:
......
......@@ -43,7 +43,7 @@ class Framework
// Define path constants
define("DS", DIRECTORY_SEPARATOR);
define("ROOT", dirname(getcwd()) . DS . 'htdocs' . DS);
define("ROOT", realpath(dirname(__FILE__) . DS . '..' . DS . '..') . DS);
define("APP_PATH", ROOT . 'application' . DS);
define("FRAMEWORK_PATH", ROOT . "framework" . DS);
define("PUBLIC_PATH", ROOT . "public" . DS);
......
......@@ -34,6 +34,6 @@ class View
}
public function __get($k)
{
return (($this->properties[$k]) ?? '');
return (isset($this->properties[$k]) ? $this->properties[$k] : '');
}
}
......@@ -24,7 +24,7 @@ echo $view->render('navbar.php');
</div>
</div>
<div class="form-group row">
<div class="col-xs-12 col-sm-2 form-label">Image</div>
<div class="col-xs-12 col-sm-2 form-label">Image (only accepts jpg, max 1MB)</div>
<div class="col-xs-12 col-sm-10">
<input type="file" class="form-input" name="image" accept="image/jpeg" required>
</div>
......
......@@ -19,7 +19,7 @@ echo "<script>var choco_id = $ChocoID;</script>";
<p class='mb-1 inline'>Price: Rp<p id='price' class='inline'>" . number_format($Price, 0, ',', '.') . "</p>,00</p>
<p class='mb-1 inline'>Amount Remaining: <p id='stock' class='inline'>$Stock</p></p>
<p class='mb-1'>Description</p>
<p class='mb-1'>" . ($Description ?? '-') . "</p>
<p class='mb-1'>" . (isset($Description) ? $Description : '-') . "</p>
"
?>
</div>
......
......@@ -34,7 +34,7 @@ for ($i = 1; $i <= min(CHOCOLATES_PER_PAGE, $numRows); $i++) {
<p class='card-text inline'>Price: Rp <p class='inline' id='chocoprice$i'>" . number_format($Price, 0, ',', '.') . ",00</p></p>
<p class='card-text inline'>Amount Remaining: <p class='inline' id='chocostock$i'>$Stock</p></p>
<p class='card-text'>Description</p>
<p class='card-text' id='chocodesc$i'>" . ($Description ?? '-') . "</p>
<p class='card-text' id='chocodesc$i'>" . (isset($Description) ? $Description : '-') . "</p>
</div>
</a>
</div>";
......
......@@ -21,7 +21,7 @@ echo "<script>var choco_id = $ChocoID;</script>";
<p class='mb-1 inline'>Price: Rp <p id='price' class='inline'>" . number_format($Price, 0, ',', '.') . "</p>,00</p>
<p class='mb-1 inline'>Amount Remaining: <p id='stock' class='inline'>$Stock</p></p>
<p class='mb-1'>Description</p>
<p class='mb-1'>" . ($Description ?? '-') . "</p>
<p class='mb-1'>" . (isset($Description) ? $Description : '-') . "</p>
"?>
<div class="row">
<div class="col-xs-12 row">
......
......@@ -20,7 +20,7 @@ echo "<script>var choco_id = $ChocoID;</script>";
<p class='mb-1 inline'>Price: Rp<p id='price' class='inline'>" . number_format($Price, 0, ',', '.') . "</p>,00</p>
<p class='mb-1 inline'>Amount Remaining: <p id='stock' class='inline'>$Stock</p></p>
<p class='mb-1'>Description</p>
<p class='mb-1'>" . ($Description ?? '-') . "</p>
<p class='mb-1'>" . (isset($Description) ? $Description : '-') . "</p>
"?>
</div>
<div class="col-xs-12 row two-button">
......
......@@ -15,7 +15,7 @@
<link rel="stylesheet" type="text/css" href="/public/css/form.css" />
<link rel="stylesheet" type="text/css" href="/public/css/table.css" />
<script src="/public/js/ajax.js"></script>
<title><?=$this->title ?? 'A-Chong-co'?></title>
<title><?=isset($this->title) ? $this->title : 'A-Chong-co'?></title>
</head>
<body>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment