Made the deafult loan length configurable in config.php
This commit is contained in:
parent
d4cf2498fe
commit
16f48cd28d
@ -20,6 +20,9 @@ $language = 'en';
|
||||
# Site name
|
||||
$name = 'My product tracker';
|
||||
|
||||
# Default loan length
|
||||
$default_loan_length = '1 day';
|
||||
|
||||
# Email subject prefix
|
||||
# Will be prepended without change, so should probably end with a space
|
||||
$email_subject_prefix = "System name: ";
|
||||
|
@ -85,7 +85,7 @@ class CheckoutPage extends Page {
|
||||
$email = $this->user->get_email($this->ldap);
|
||||
$displayname = $this->user->get_displayname($this->ldap);
|
||||
$notes = $this->user->get_notes();
|
||||
$enddate = format_date(default_loan_end(time()));
|
||||
$enddate = format_date(default_loan_end());
|
||||
$disabled = '';
|
||||
$loans = $this->user->get_loans('active');
|
||||
$loan_table = i18n('No active loans.');
|
||||
|
@ -84,7 +84,7 @@ class ProductPage extends Page {
|
||||
'service' => i18n('Start service'),
|
||||
'history' => $history,
|
||||
'attachments' => $attachments,
|
||||
'end' => format_date(default_loan_end(time())));
|
||||
'end' => format_date(default_loan_end()));
|
||||
if(class_exists('QRcode')) {
|
||||
$fields['label'] = replace($fields,
|
||||
$this->fragments['product_label']);
|
||||
@ -123,7 +123,7 @@ class ProductPage extends Page {
|
||||
$this->fragments['item_link']);
|
||||
if(!$end) {
|
||||
$end = $event->get_endtime();
|
||||
$extend = format_date(default_loan_end(time()));
|
||||
$extend = format_date(default_loan_end());
|
||||
$note = replace(array('id' => $product->get_id(),
|
||||
'end_new' => $extend),
|
||||
$this->fragments['loan_extend_form']);
|
||||
|
@ -287,8 +287,12 @@ function format_date($date) {
|
||||
return $date;
|
||||
}
|
||||
|
||||
function default_loan_end($start) {
|
||||
return $start + 604800; # 1 week later
|
||||
function default_loan_end() {
|
||||
global $default_loan_length;
|
||||
$now = new DateTimeImmutable();
|
||||
$duration = DateInterval::createFromDateString($default_loan_length);
|
||||
$end = $now->add($duration);
|
||||
return $end->getTimestamp();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user