- [index.php](/Users/tyemeclifford/Documents/GH/MyKeyser/index.php): events now appear before featured businesses, plus forum pretty-route fallback.
[events.php](/Users/tyemeclifford/Documents/GH/MyKeyser/events.php) and [admin/events.php](/Users/tyemeclifford/Documents/GH/MyKeyser/admin/events.php): event image uploads. [menu.php](/Users/tyemeclifford/Documents/GH/MyKeyser/menu.php), [admin/menus.php](/Users/tyemeclifford/Documents/GH/MyKeyser/admin/menus.php), and [business.php](/Users/tyemeclifford/Documents/GH/MyKeyser/business.php): one configurable menu item image slot. [account.php](/Users/tyemeclifford/Documents/GH/MyKeyser/account.php): circular avatar upload and crop controls. [forum.php](/Users/tyemeclifford/Documents/GH/MyKeyser/forum.php), [admin/forum.php](/Users/tyemeclifford/Documents/GH/MyKeyser/admin/forum.php), [.htaccess](/Users/tyemeclifford/Documents/GH/MyKeyser/.htaccess), and [forum/index.php](/Users/tyemeclifford/Documents/GH/MyKeyser/forum/index.php): forum, categories, topic/reply uploads, permalinks, toggle/moderation. [includes/db.php](/Users/tyemeclifford/Documents/GH/MyKeyser/includes/db.php) and [includes/functions.php](/Users/tyemeclifford/Documents/GH/MyKeyser/includes/functions.php): schema upgrades and shared upload/image helpers. [assets/css/style.css](/Users/tyemeclifford/Documents/GH/MyKeyser/assets/css/style.css): neon styling for forum, images, avatars, attachments.
This commit is contained in:
@@ -4,6 +4,8 @@ requireLogin();
|
||||
$bizId=iget('id');
|
||||
$biz=qone("SELECT * FROM businesses WHERE id=?",[$bizId]);
|
||||
if(!$biz||!owns($bizId)){flash('Access denied.','error');go('/dashboard.php');}
|
||||
$menuImageLimit=max(0,min(1,(int)setting('menu_item_image_limit','1')));
|
||||
$menuImagesEnabled=$menuImageLimit>0;
|
||||
|
||||
if(isPost()){
|
||||
csrfCheck();
|
||||
@@ -28,8 +30,25 @@ if(isPost()){
|
||||
$sid=(int)p('section_id');
|
||||
$name=ps('item_name');
|
||||
if($name){
|
||||
$imagePath='';
|
||||
if($menuImagesEnabled){
|
||||
$upload=storeSingleUpload(
|
||||
'item_image',
|
||||
'menus',
|
||||
imageExts(),
|
||||
mbToBytes(setting('menu_upload_max_mb','5'),5),
|
||||
[
|
||||
'image_only'=>true,
|
||||
'resize_over_bytes'=>mbToBytes(setting('forum_image_resize_threshold_mb','1'),1),
|
||||
'image_max_width'=>(int)setting('forum_image_max_width','1600'),
|
||||
'image_quality'=>(int)setting('forum_image_quality','82'),
|
||||
]
|
||||
);
|
||||
if(!$upload['ok']){flash($upload['error'],'error');go("/menu.php?id=$bizId");}
|
||||
$imagePath=(string)($upload['path']??'');
|
||||
}
|
||||
$order=(int)qval("SELECT COALESCE(MAX(sort_order),0)+1 FROM menu_items WHERE section_id=?",[$sid]);
|
||||
qrun("INSERT INTO menu_items(section_id,name,description,price,sort_order)VALUES(?,?,?,?,?)",[$sid,$name,ps('item_desc'),(float)p('item_price',0),$order]);
|
||||
qrun("INSERT INTO menu_items(section_id,name,description,price,image_path,sort_order)VALUES(?,?,?,?,?,?)",[$sid,$name,ps('item_desc'),(float)p('item_price',0),$imagePath,$order]);
|
||||
flash('Item added!','success');
|
||||
}
|
||||
}
|
||||
@@ -39,8 +58,29 @@ if(isPost()){
|
||||
}
|
||||
if($act==='edit_item'){
|
||||
$iid=(int)p('iid');
|
||||
qrun("UPDATE menu_items SET name=?,description=?,price=?,is_available=? WHERE id=?",[ps('item_name'),ps('item_desc'),(float)p('item_price',0),(int)p('is_available',1),$iid]);
|
||||
flash('Item updated!','success');
|
||||
$item=qone("SELECT mi.* FROM menu_items mi JOIN menu_sections ms ON ms.id=mi.section_id WHERE mi.id=? AND ms.business_id=?",[$iid,$bizId]);
|
||||
if($item){
|
||||
$imagePath=(string)($item['image_path']??'');
|
||||
if($menuImagesEnabled && p('remove_item_image','0')==='1') $imagePath='';
|
||||
if($menuImagesEnabled){
|
||||
$upload=storeSingleUpload(
|
||||
'item_image',
|
||||
'menus',
|
||||
imageExts(),
|
||||
mbToBytes(setting('menu_upload_max_mb','5'),5),
|
||||
[
|
||||
'image_only'=>true,
|
||||
'resize_over_bytes'=>mbToBytes(setting('forum_image_resize_threshold_mb','1'),1),
|
||||
'image_max_width'=>(int)setting('forum_image_max_width','1600'),
|
||||
'image_quality'=>(int)setting('forum_image_quality','82'),
|
||||
]
|
||||
);
|
||||
if(!$upload['ok']){flash($upload['error'],'error');go("/menu.php?id=$bizId");}
|
||||
if(!empty($upload['path'])) $imagePath=(string)$upload['path'];
|
||||
}
|
||||
qrun("UPDATE menu_items SET name=?,description=?,price=?,image_path=?,is_available=? WHERE id=?",[ps('item_name'),ps('item_desc'),(float)p('item_price',0),$imagePath,(int)p('is_available',1),$iid]);
|
||||
flash('Item updated!','success');
|
||||
}
|
||||
}
|
||||
go("/menu.php?id=$bizId");
|
||||
}
|
||||
@@ -97,10 +137,13 @@ include __DIR__.'/includes/header.php';
|
||||
<?php foreach($items[$sec['id']] as $item): ?>
|
||||
<div style="border-bottom:1px solid var(--bdr);padding:.75rem 0">
|
||||
<div style="display:flex;justify-content:space-between;align-items:flex-start;gap:.5rem">
|
||||
<div>
|
||||
<div class="menu-owner-row">
|
||||
<?php if(!empty($item['image_path'])): ?><img src="<?=e($item['image_path'])?>" alt="<?=e($item['name'])?>" class="menu-owner-thumb"><?php endif; ?>
|
||||
<div>
|
||||
<div style="font-weight:600;color:<?=$item['is_available']?'var(--text)':'var(--text-d)'?>"><?=e($item['name'])?> <?php if(!$item['is_available']): ?><span class="badge badge-gray">Unavailable</span><?php endif; ?></div>
|
||||
<?php if($item['description']): ?><div style="font-size:.8rem;color:var(--text-d)"><?=e($item['description'])?></div><?php endif; ?>
|
||||
<?php if($item['price']>0): ?><div style="color:var(--gold);font-family:'Oswald',sans-serif;font-size:.9rem"><?=money((float)$item['price'])?></div><?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex-row" style="gap:.3rem;flex-shrink:0">
|
||||
<button onclick="this.closest('div').parentElement.querySelector('.edit-item-form').classList.toggle('hidden')" class="btn btn-xs btn-secondary">✏️</button>
|
||||
@@ -108,12 +151,25 @@ include __DIR__.'/includes/header.php';
|
||||
</div>
|
||||
</div>
|
||||
<div class="edit-item-form hidden" style="background:var(--bg4);border:1px solid var(--bdr);border-radius:4px;padding:.85rem;margin-top:.65rem">
|
||||
<form method="POST"><?=csrfField()?><input type="hidden" name="_act" value="edit_item"><input type="hidden" name="iid" value="<?=$item['id']?>">
|
||||
<form method="POST" enctype="multipart/form-data"><?=csrfField()?><input type="hidden" name="_act" value="edit_item"><input type="hidden" name="iid" value="<?=$item['id']?>">
|
||||
<div class="form-row" style="margin-bottom:.6rem">
|
||||
<div class="fg"><label class="flabel">NAME</label><input type="text" name="item_name" class="finput" value="<?=e($item['name'])?>" required></div>
|
||||
<div class="fg"><label class="flabel">PRICE ($)</label><input type="number" name="item_price" class="finput" value="<?=e($item['price'])?>" step="0.01" min="0"></div>
|
||||
</div>
|
||||
<div class="fg"><label class="flabel">DESCRIPTION</label><input type="text" name="item_desc" class="finput" value="<?=e($item['description'])?>"></div>
|
||||
<?php if($menuImagesEnabled): ?>
|
||||
<div class="fg">
|
||||
<label class="flabel">ITEM IMAGE</label>
|
||||
<?php if(!empty($item['image_path'])): ?>
|
||||
<div class="menu-admin-image">
|
||||
<img src="<?=e($item['image_path'])?>" alt="<?=e($item['name'])?>">
|
||||
<label style="display:flex;align-items:center;gap:.45rem;font-size:.82rem;color:var(--text-m);cursor:pointer"><input type="checkbox" name="remove_item_image" value="1"> Remove current image</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<input type="file" name="item_image" class="finput" accept="image/*">
|
||||
<div class="fhint">One image allowed. Max <?=e(setting('menu_upload_max_mb','5'))?> MB.</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="fg"><label class="flabel">AVAILABLE</label><select name="is_available" class="fselect"><option value="1"<?=$item['is_available']?' selected':''?>>Yes</option><option value="0"<?=!$item['is_available']?' selected':''?>>No (hidden from menu)</option></select></div>
|
||||
<button type="submit" class="btn btn-success btn-sm">Save Item</button>
|
||||
</form>
|
||||
@@ -125,12 +181,15 @@ include __DIR__.'/includes/header.php';
|
||||
<div style="margin-top:.85rem;padding-top:.85rem">
|
||||
<details><summary style="cursor:pointer;font-size:.82rem;color:var(--gold);font-family:'Oswald',sans-serif;letter-spacing:.08em">➕ Add Item to "<?=e($sec['name'])?>"</summary>
|
||||
<div style="padding:.85rem 0">
|
||||
<form method="POST"><?=csrfField()?><input type="hidden" name="_act" value="add_item"><input type="hidden" name="section_id" value="<?=$sec['id']?>">
|
||||
<form method="POST" enctype="multipart/form-data"><?=csrfField()?><input type="hidden" name="_act" value="add_item"><input type="hidden" name="section_id" value="<?=$sec['id']?>">
|
||||
<div class="form-row" style="margin-bottom:.6rem">
|
||||
<div class="fg"><label class="flabel">ITEM NAME *</label><input type="text" name="item_name" class="finput" required placeholder="e.g. Spaghetti Carbonara"></div>
|
||||
<div class="fg"><label class="flabel">PRICE ($)</label><input type="number" name="item_price" class="finput" value="0" step="0.01" min="0"></div>
|
||||
</div>
|
||||
<div class="fg"><label class="flabel">DESCRIPTION</label><input type="text" name="item_desc" class="finput" placeholder="Brief description…"></div>
|
||||
<?php if($menuImagesEnabled): ?>
|
||||
<div class="fg"><label class="flabel">ITEM IMAGE</label><input type="file" name="item_image" class="finput" accept="image/*"><div class="fhint">Optional. One image allowed, max <?=e(setting('menu_upload_max_mb','5'))?> MB.</div></div>
|
||||
<?php endif; ?>
|
||||
<button type="submit" class="btn btn-primary btn-sm">Add Item</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user