Merge branch 'test' into prod
This commit is contained in:
commit
6ad29ccd7d
@ -6,6 +6,9 @@ $db_user = 'dbname';
|
||||
$db_pass = 'dbpassword';
|
||||
$db_name = 'dbuser';
|
||||
|
||||
# Email subject prefix
|
||||
$email_subject_prefix = "System name: ";
|
||||
|
||||
# Address to use as the sender for reminder emails
|
||||
$sender = 'noreply@example.com';
|
||||
|
||||
@ -15,7 +18,7 @@ $error_address = 'root@example.com';
|
||||
# Discard notifications
|
||||
# If this is set to an email address, the system will send a notification
|
||||
# there each time a product is discarded.
|
||||
#$notify_discard = 'inventory-tracking@example.com';
|
||||
#$discard_notify = 'inventory-tracking@example.com';
|
||||
$discard_notify = false;
|
||||
|
||||
# Directory to save attachments to
|
||||
|
2
cron.php
2
cron.php
@ -7,7 +7,7 @@ require('./include/functions.php');
|
||||
|
||||
header('Content-Type: text/html; charset=UTF-8');
|
||||
|
||||
$cron = new Cron($sender, $error_address);
|
||||
$cron = new Cron($sender, $error_address, $email_subject_prefix);
|
||||
$cron->run();
|
||||
|
||||
?>
|
||||
|
@ -306,6 +306,8 @@
|
||||
<button>Ladda upp</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
¤¤ product_meta ¤¤
|
||||
<div id="product-history">
|
||||
<h2>Artikelhistorik</h2>
|
||||
¤history¤
|
||||
|
@ -164,7 +164,7 @@ class Ajax extends Responder {
|
||||
}
|
||||
$product = null;
|
||||
try {
|
||||
$product = new Product($_POST['serial'], 'serial');
|
||||
$product = new Product(trim($_POST['serial']), 'serial');
|
||||
} catch(Exception $e) {
|
||||
return new Failure('Ogiltigt serienummer.');
|
||||
}
|
||||
|
@ -5,10 +5,11 @@ class Cron {
|
||||
private $error = '';
|
||||
private $kvs;
|
||||
private $ldap;
|
||||
public function __construct($sender, $error) {
|
||||
public function __construct($sender, $error, $prefix) {
|
||||
$this->now = new DateTimeImmutable();
|
||||
$this->sender = $sender;
|
||||
$this->error = $error;
|
||||
$this->subject_prefix = $prefix;
|
||||
$this->warn_time = DateInterval::createFromDateString('3 days');
|
||||
$this->warn_date = $this->now->add($this->warn_time);
|
||||
$this->run_interval = DateInterval::createFromDateString('1 day');
|
||||
@ -108,7 +109,7 @@ class Cron {
|
||||
}
|
||||
|
||||
private function make_receipt_subject($num_new, $num_extended) {
|
||||
$subject = "DSV Helpdesk: ";
|
||||
$subject = $this->subject_prefix;
|
||||
$messages = array();
|
||||
if($num_new > 1) {
|
||||
$messages[] = $num_new." nya";
|
||||
@ -206,7 +207,7 @@ EOF;
|
||||
}
|
||||
|
||||
private function make_reminder_subject($num_expiring, $num_expired) {
|
||||
$subject = "DSV Helpdesk: ";
|
||||
$subject = $this->subject_prefix;
|
||||
$messages = array();
|
||||
if($num_expiring > 0) {
|
||||
$messages[] = $num_expiring." utgående";
|
||||
|
@ -68,6 +68,13 @@ class Product extends Entity {
|
||||
$this->update_fields();
|
||||
$this->update_info();
|
||||
$this->update_tags();
|
||||
|
||||
# Global variables are bad, but passing these email properties
|
||||
# around everywhere would be worse
|
||||
global $sender, $notify_discard, $email_subject_prefix;
|
||||
$this->discard_email_address = $notify_discard;
|
||||
$this->email_sender = $sender;
|
||||
$this->email_subject_prefix = $email_subject_prefix;
|
||||
}
|
||||
|
||||
private function update_fields() {
|
||||
@ -272,9 +279,42 @@ class Product extends Entity {
|
||||
bind($update, 'ii', $now, $this->id);
|
||||
execute($update);
|
||||
$this->discardtime = $now;
|
||||
if($this->discard_email_address) {
|
||||
$this->send_discard_email();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private function send_discard_email() {
|
||||
$brand = $this->brand;
|
||||
$name = $this->name;
|
||||
$invoice = $this->invoice;
|
||||
$serial = $this->serial;
|
||||
$discardtime = format_date($this->discardtime);
|
||||
|
||||
$subject = $this->email_subject_prefix.$brand.' '.$name.' skrotad';
|
||||
$message = <<<EOF
|
||||
Hej!
|
||||
|
||||
Följande artikel har skrotats i Boka:
|
||||
|
||||
$brand $name, serienummer: $serial, fakturanummer: $invoice
|
||||
|
||||
EOF;
|
||||
try {
|
||||
mb_send_mail($this->discard_email_address,
|
||||
$subject,
|
||||
$message,
|
||||
'From: '.$this->email_sender);
|
||||
} catch(Exception $e) {
|
||||
error_log($e->getMessage());
|
||||
mb_send_mail($this->error,
|
||||
"Kunde inte skicka mail",
|
||||
"Mail kunde inte skickas till "
|
||||
. $this->discard_email_address);
|
||||
}
|
||||
}
|
||||
|
||||
public function toggle_service() {
|
||||
$status = $this->get_status();
|
||||
$now = time();
|
||||
|
@ -69,6 +69,7 @@ class ProductPage extends Page {
|
||||
'label' => '',
|
||||
'label_hidden' => 'hidden',
|
||||
'checkout_hidden' => 'hidden',
|
||||
'hidden' => '',
|
||||
'service' => 'Starta service',
|
||||
'history' => $history,
|
||||
'attachments' => $attachments,
|
||||
@ -86,7 +87,9 @@ class ProductPage extends Page {
|
||||
$fields['checkout_hidden'] = '';
|
||||
}
|
||||
}
|
||||
return replace($fields, $this->fragments['product_form']);
|
||||
$out = replace($fields, $this->fragments['product_form']);
|
||||
$out .= replace($fields, $this->fragments['product_meta']);
|
||||
return $out;
|
||||
}
|
||||
|
||||
private function build_history_table($history) {
|
||||
|
@ -1,3 +1,7 @@
|
||||
body {
|
||||
font-size: 90%;
|
||||
}
|
||||
|
||||
textarea {
|
||||
height: 80px;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user