Added ability to check out a product from the product page directly

This commit is contained in:
Erik Thuning 2023-01-11 11:11:42 +01:00
parent fa46874ae3
commit b10bf1eed8
2 changed files with 47 additions and 6 deletions

@ -306,16 +306,52 @@
<button>Ladda upp</button> <button>Ladda upp</button>
</form> </form>
</div> </div>
<div id="product-history" <div id="product-history">
class="¤hidden¤">
<h2>Artikelhistorik</h2> <h2>Artikelhistorik</h2>
¤history¤ ¤history¤
</div> </div>
<div id="product-label" <div id="product-label"
class="¤hidden¤"> class="¤label_hidden¤">
<h2>Etikett</h2> <h2>Etikett</h2>
¤label¤ ¤label¤
</div> </div>
<div id="product-direct-checkout" class="¤checkout_hidden¤">
<h2>Låna ut</h2>
<form class="light"
onSubmit="JavaScript:checkoutProduct(event)">
<datalist id="user_suggest"></datalist>
<input type="hidden"
name="page"
value="checkout" />
<label for="user">Användarnamn:</label>
<input onFocus="JavaScript:suggest(this, 'user')"
type="text"
name="user"
list="user_suggest"
autocomplete="off"
placeholder="Användarnamn"
required />
<input type="hidden"
id="product"
name="product"
value="¤serial¤" />
<button>
Låna ut
</button>
<br/>
<label>Löptid:</label>
<button onClick="JavaScript:loanLength(event, 7, 'day')">1 vecka</button>
<button onClick="JavaScript:loanLength(event, 1, 'year')">1 år</button>
<button onClick="JavaScript:loanLength(event, 3, 'year')">3 år</button>
<br/>
<label for="end">Slutdatum:</label>
<input type="text"
id="end"
onClick="JavaScript:calendar(event)"
name="end"
value="¤end¤" />
</form>
</div>
¤¤ attachment_list ¤¤ ¤¤ attachment_list ¤¤
<ul class="attachment-list"> <ul class="attachment-list">

@ -67,19 +67,24 @@ class ProductPage extends Page {
'tags' => $tags, 'tags' => $tags,
'info' => $info, 'info' => $info,
'label' => '', 'label' => '',
'hidden' => 'hidden', 'label_hidden' => 'hidden',
'checkout_hidden' => 'hidden',
'service' => 'Starta service', 'service' => 'Starta service',
'history' => $history, 'history' => $history,
'attachments' => $attachments); 'attachments' => $attachments,
'end' => format_date(default_loan_end(time())));
if(class_exists('QRcode')) { if(class_exists('QRcode')) {
$fields['label'] = replace($fields, $fields['label'] = replace($fields,
$this->fragments['product_label']); $this->fragments['product_label']);
} }
if(!$this->product->get_discardtime()) { if(!$this->product->get_discardtime()) {
$fields['hidden'] = ''; $fields['label_hidden'] = '';
if($this->product->get_status() == 'service') { if($this->product->get_status() == 'service') {
$fields['service'] = 'Avsluta service'; $fields['service'] = 'Avsluta service';
} }
if($this->product->get_status() == 'available') {
$fields['checkout_hidden'] = '';
}
} }
return replace($fields, $this->fragments['product_form']); return replace($fields, $this->fragments['product_form']);
} }