Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coy Shifflet Final Project #6

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*.DS_Store
*sftp-config.json
*auth.php
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# ixd608OL1FA24
Repo for IXD 608 OL 1 Fall 2024

Binary file added shifflet.coy/.DS_Store
Binary file not shown.
13 changes: 13 additions & 0 deletions shifflet.coy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Shifflet Coy

## Relevent Links
-https://coyshifflet.com
-https://coyshifflet.com/aau/wnm608/shifflet.coy
-https://coyshifflet.com/aau/wnm608/shifflet.coy/styleguide
-https://coyshifflet.com/aau/wnm608/shifflet.coy/admin/index.php

Extra Links

-https://coyshifflet.com/aau/wnm608/shifflet.coy/admin/users/php
-https://coyshifflet.com/aau/wnm608/shifflet.coy/notes/reading_data.php

20 changes: 20 additions & 0 deletions shifflet.coy/about.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About Us - My Online Store</title>
<?php include "parts/meta.php"; ?>
</head>
<body>
<?php include "parts/navbar.php"; ?>

<div class="container">
<div class="card soft">
<h2>About Us</h2>
<p>Learn more about our company and values.</p>
</div>
</div>
<?php include "parts/footer.php"; ?>
</body>
</html>

161 changes: 161 additions & 0 deletions shifflet.coy/admin/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
<?php

include "../lib/php/functions.php";

$empty_product = (object)[
"name"=>"",
"price"=>"",
"category"=>"",
"thumbnail"=>"",
"images"=>"",
];

// Logic
try {
$conn = makePDOConn();
switch($_GET['action']) {
case "update":
$statement = $conn->prepare("UPDATE
`products`
SET
`name`=?,
`price`=?,
`category`=?,
`thumbnail`=?,
`images`=?,
`date_modify`=NOW()
WHERE `id`=?
");
$statement->execute([
$_POST['product-name'],
$_POST['product-price'],
$_POST['product-category'],
$_POST['product-thumbnail'],
$_POST['product-images'],
$_GET['id']
]);
header("location:{$_SERVER['PHP_SELF']}?id={$_GET['id']}");
break;

case "create":
$statement = $conn->prepare("INSERT INTO
`products`
(
`name`,
`price`,
`category`,
`thumbnail`,
`images`,
`date_create`,
`date_modify`
)
VALUES (?,?,?,?,?,NOW(),NOW())
");
$statement->execute([
$_POST['product-name'],
$_POST['product-price'],
$_POST['product-category'],
$_POST['product-thumbnail'],
$_POST['product-images'],
]);
$id = $conn->lastInsertId();
header("location:{$_SERVER['PHP_SELF']}?id=$id");
break;

case "delete":
$statement = $conn->prepare("DELETE FROM `products` WHERE id=?");
$statement->execute([$_GET['id']]);
header("location:{$_SERVER['PHP_SELF']}");
break;
}
} catch(PDOException $e) {
die($e->getMessage());
}

// Templates
function productListItem($r, $o) {
return $r.<<<HTML
<div class="card soft">
<div class="display-flex">
<div class="flex-none images-thumbs"><img src='../img/$o->thumbnail'></div>
<div class="flex-stretch" style="padding:1em">$o->name</div>
<div class="flex-none"><a href="{$_SERVER['PHP_SELF']}?id=$o->id" class="form-button">Edit</a></div>
</div>
</div>
HTML;
}

function showProductPage($o) {
$id = $_GET['id'];
$addoredit = $id == "new" ? "Add" : "Edit";
$createorupdate = $id == "new" ? "create" : "update";
$images = array_reduce(explode(",", $o->images), function($r, $o) {
return $r."<img src='../img/$o'>";
});

$display = <<<HTML
<div>
<h2>$o->name</h2>
<div class="form-control">
<label class="form-label">Price</label>
<span>&dollar;$o->price</span>
</div>
<div class="form-control">
<label class="form-label">Category</label>
<span>$o->category</span>
</div>
<div class="form-control">
<label class="form-label">Thumbnail</label>
<span class="images-thumbs"><img src='../img/$o->thumbnail'></span>
</div>
<div class="form-control">
<label class="form-label">Other Images</label>
<span class="images-thumbs">$images</span>
</div>
</div>
HTML;


$form = <<<HTML
<form method="post" action="{$_SERVER['PHP_SELF']}?id=$id&action=$createorupdate">
<h2>$addoredit Product</h2>
<!-- Form fields -->
</form>
HTML;

$output = $id == "new" ? "<div class='card soft'>$form</div>" :
"<div class='grid gap'>
<div class='col-xs-12 col-md-7'><div class='card soft'>$display</div></div>
<div class='col-xs-12 col-md-5'><div class='card soft'>$form</div></div>
</div>";

$delete = $id == "new" ? "" : "<a href='{$_SERVER['PHP_SELF']}?id=$id&action=delete'>Delete</a>";

echo <<<HTML
<div class="card soft">
<nav class="display-flex">
<div class="flex-stretch"><a href="{$_SERVER['PHP_SELF']}">Back</a></div>
<div class="flex-none">$delete</div>
</nav>
</div>
$output
HTML;
}

?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Product Admin Page</title>
<?php include "../parts/meta.php"; ?>
</head>
<body>
<header class="navbar">
<!-- Navbar content -->
</header>
<div class="container">
<!-- Content based on logic -->
</div>
</body>
</html>
30 changes: 30 additions & 0 deletions shifflet.coy/cart_actions.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

<?php

include_once "lib/php/functions.php";


switch($_GET['action']) {
case "add-to-cart":
$product = makeQuery(makeConn(),"SELECT * FROM `products` WHERE `id`=".$_POST['product-id'])[0];
addToCart($_POST['product-id'],$_POST['product-amount']);
header("location:product_added_to_cart.php?id={$_POST['product-id']}");
break;
case "update-cart-item":
$p = cartItemById($_POST['id']);
$p->amount = $_POST['amount'];
header("location:product_cart.php");
break;
case "delete-cart-item":
$_SESSION['cart'] = array_filter($_SESSION['cart'],function($o){return $o->id!=$_POST['id'];});
header("location:product_cart.php");
break;
case "reset-cart":
resetCart();
break;
default:
die("Incorrect Action");

}

print_p ([$_GET,$_POST,$_SESSION]);
20 changes: 20 additions & 0 deletions shifflet.coy/contact.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Contact Us - My Online Store</title>
<?php include "parts/meta.php"; ?>
</head>
<body>
<?php include "parts/navbar.php"; ?>

<div class="container">
<div class="card soft">
<h2>Contact Us</h2>
<p>Reach out to us with any questions or concerns.</p>
</div>
</div>
<?php include "parts/footer.php"; ?>
</body>
</html>

118 changes: 118 additions & 0 deletions shifflet.coy/css/storetheme.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
:root {
--color-primary: #004175; /* Midnight Blue */
--color-secondary: #708090; /* Slate Gray */
--color-accent: #CCFF00; /* Electric Lime */
--color-offwhite: #f4f4f4;
--color-white: #ffffff;
--color-black: #000000;
}

body {
background-color: var(--color-white);
padding-bottom: 4em;
}

.favorite label {
transition: all 0.3s;
display: inline-block;
transform: scale(1,1);
color: var(--color-black);
}

.favorite input:checked + label {
color: red;
transform: scale(1.5, 1.5);
}

.figure.product {
border-radius: 0.5em;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
overflow: hidden;
height: 100%;
transition: 0.3s;
}

.product.figure img {
width: 100%;
height: 40vh;
object-fit: contain;
}

.productlist a {
text-decoration: none;
font-weight: initial;
}

.product.figure:hover {
box-shadow: 0 2px 15px rgba(0, 0, 0, 0.2);
}

.images-main img {
width: 100%;
height: auto;
max-height: 500px;
object-fit: contain;
}

.images-thumbs img {
width: 80px;
height: 80px;
object-fit: cover;
margin: 5px;
border: 1px solid var(--color-secondary);
border-radius: 0.3em;
cursor: pointer;
}


.images-thumbs img:hover {
transform: scale(1.1);
transition: transform 0.2s;
}

span.badge:not(:empty)::after {
content: ')';
}
span.badge:not(:empty)::before {
content: '(';
}

@media (max-width: 800px) {
.container {
padding-left: 1em;
padding-right: 1em;
}
.navbar h1 {
padding-left: 0.5em;
}
}

.menu-button label {
display: none;
}

@media (max-width: 400px) {
.navbar .display-flex {
flex-wrap: wrap;
}
.navbar .nav {
width: 100%;
display: none;
}

.navbar .nav-flex ul {
display: block;
}
.navbar .nav li {
line-height: 2em;
}

.menu-button label {
display: block;
padding: 0 1em;
}

#menu:checked + .navbar .nav {
display: block;
}
}
Loading