|
|
@ -12,11 +12,13 @@ class Item {
|
|
|
|
|
|
|
|
|
|
|
|
private $itemid = null;
|
|
|
|
private $itemid = null;
|
|
|
|
private $itemdata = [];
|
|
|
|
private $itemdata = [];
|
|
|
|
|
|
|
|
private $itemimages = [];
|
|
|
|
|
|
|
|
|
|
|
|
function __construct($itemid) {
|
|
|
|
function __construct($itemid) {
|
|
|
|
global $binstack;
|
|
|
|
global $binstack;
|
|
|
|
$this->itemdata = $binstack->get('items', ['itemid', 'catid', 'name', 'text1', 'qty', 'want', 'cost', 'price'], ['itemid' => $itemid]);
|
|
|
|
$this->itemdata = $binstack->get('items', ['itemid', 'catid', 'name', 'text1', 'qty', 'want', 'cost', 'price'], ['itemid' => $itemid]);
|
|
|
|
$this->itemid = $itemid;
|
|
|
|
$this->itemid = $itemid;
|
|
|
|
|
|
|
|
$this->itemimages = $binstack->select('images', ['imagename', 'primary', 'imageid'], ['itemid' => $itemid, 'ORDER' => ['primary' => 'DESC']]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function getId() {
|
|
|
|
function getId() {
|
|
|
@ -59,6 +61,68 @@ class Item {
|
|
|
|
return $this->itemdata['catid'];
|
|
|
|
return $this->itemdata['catid'];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getImageCount() {
|
|
|
|
|
|
|
|
return count($this->itemimages);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getPrimaryImage(): ItemImage {
|
|
|
|
|
|
|
|
if (count($this->itemimages) > 0) {
|
|
|
|
|
|
|
|
foreach ($this->itemimages as $i) {
|
|
|
|
|
|
|
|
if ($i['primary'] == true) {
|
|
|
|
|
|
|
|
return new ItemImage($i['imagename'], $i['imageid'], $i['primary'] == true, $this->itemid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
$i = $this->itemimages[0];
|
|
|
|
|
|
|
|
return new ItemImage($i['imagename'], $i['imageid'], $i['primary'] == true, $this->itemid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getImages(): array {
|
|
|
|
|
|
|
|
$images = [];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
foreach ($this->itemimages as $i) {
|
|
|
|
|
|
|
|
$images[] = new ItemImage($i['imagename'], $i['imageid'], $i['primary'] == true, $this->itemid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return $images;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class ItemImage {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private $url = "";
|
|
|
|
|
|
|
|
private $primary = false;
|
|
|
|
|
|
|
|
private $imageid = 0;
|
|
|
|
|
|
|
|
private $itemid = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function __construct(string $url, int $imageid, bool $primary, int $itemid) {
|
|
|
|
|
|
|
|
$this->url = $url;
|
|
|
|
|
|
|
|
$this->imageid = $imageid;
|
|
|
|
|
|
|
|
$this->primary = $primary;
|
|
|
|
|
|
|
|
$this->itemid = $itemid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getName(): string {
|
|
|
|
|
|
|
|
return $this->url;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getAbsoluteUrl(): string {
|
|
|
|
|
|
|
|
return BINSTACK_URL_IMAGEPHP . "?i=" . $this->url;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function isPrimary(): bool {
|
|
|
|
|
|
|
|
return $this->primary == true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getID(): int {
|
|
|
|
|
|
|
|
return $this->imageid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function getItemID(): int {
|
|
|
|
|
|
|
|
return $this->itemid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
class RenderItem {
|
|
|
|
class RenderItem {
|
|
|
@ -69,13 +133,29 @@ class RenderItem {
|
|
|
|
$catid = $item->getCategoryId();
|
|
|
|
$catid = $item->getCategoryId();
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
|
|
|
|
$image = "";
|
|
|
|
|
|
|
|
if ($item->getImageCount() > 0) {
|
|
|
|
|
|
|
|
$image = '<img class="card-img-top" src="' . $item->getPrimaryImage()->getAbsoluteUrl() . '" alt="' . $name . '" />';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* $html = <<<END
|
|
|
|
|
|
|
|
<div class="col-12 col-sm-6 col-md-4 col-lg-4 col-xl-3">
|
|
|
|
|
|
|
|
<div class="card mb-4">
|
|
|
|
|
|
|
|
$image
|
|
|
|
|
|
|
|
<div class="card-body d-flex flex-column justify-content-end align-items-center">
|
|
|
|
|
|
|
|
<a href="./?page=item&id=$id" class="font-weight-bold">$name</a><br />
|
|
|
|
|
|
|
|
<span>$$price</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
END; */
|
|
|
|
$html = <<<END
|
|
|
|
$html = <<<END
|
|
|
|
<div class="card m-2">
|
|
|
|
<div class="card">
|
|
|
|
<div class="card-body text-center">
|
|
|
|
$image
|
|
|
|
<a href="./?page=item&id=$id" class="font-weight-bold">$name</a><br />
|
|
|
|
<div class="card-body d-flex flex-column justify-content-end align-items-center">
|
|
|
|
<span>$$price</span>
|
|
|
|
<a href="./?page=item&id=$id" class="font-weight-bold">$name</a><br />
|
|
|
|
|
|
|
|
<span>$$price</span>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
END;
|
|
|
|
END;
|
|
|
|
return $html;
|
|
|
|
return $html;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -86,8 +166,13 @@ END;
|
|
|
|
$catid = $item->getCategoryId();
|
|
|
|
$catid = $item->getCategoryId();
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
|
|
|
|
$image = "";
|
|
|
|
|
|
|
|
if ($item->getImageCount() > 0) {
|
|
|
|
|
|
|
|
$image = '<img class="d-inline-block mr-2 item-line-img" src="' . $item->getPrimaryImage()->getAbsoluteUrl() . '" alt="' . $name . '" />';
|
|
|
|
|
|
|
|
}
|
|
|
|
$html = <<<END
|
|
|
|
$html = <<<END
|
|
|
|
<div class="list-group-item d-flex flex-wrap">
|
|
|
|
<div class="list-group-item d-flex flex-wrap">
|
|
|
|
|
|
|
|
$image
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h4><a href="./?page=item&id=$id">$name</a></h4>
|
|
|
|
<h4><a href="./?page=item&id=$id">$name</a></h4>
|
|
|
|
<span>$$price</span>
|
|
|
|
<span>$$price</span>
|
|
|
@ -116,8 +201,13 @@ END;
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$catname = $item->getCategoryName();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
$price = $item->getPrice();
|
|
|
|
$linetotal = number_format($price * $qty, 2);
|
|
|
|
$linetotal = number_format($price * $qty, 2);
|
|
|
|
|
|
|
|
$image = "";
|
|
|
|
|
|
|
|
if ($item->getImageCount() > 0) {
|
|
|
|
|
|
|
|
$image = '<img class="d-inline-block mr-2 item-line-img" src="' . $item->getPrimaryImage()->getAbsoluteUrl() . '" alt="' . $name . '" />';
|
|
|
|
|
|
|
|
}
|
|
|
|
$html = <<<END
|
|
|
|
$html = <<<END
|
|
|
|
<div class="list-group-item d-flex flex-wrap">
|
|
|
|
<div class="list-group-item d-flex flex-wrap">
|
|
|
|
|
|
|
|
$image
|
|
|
|
<div>
|
|
|
|
<div>
|
|
|
|
<h4><a href="./?page=item&id=$id">$name</a></h4>
|
|
|
|
<h4><a href="./?page=item&id=$id">$name</a></h4>
|
|
|
|
<span>$$price</span>
|
|
|
|
<span>$$price</span>
|
|
|
|