Commit c4841066 authored by Malcolm Blaney's avatar Malcolm Blaney

Invoice module allow sorting packing lists by category. SimplePie

Sanitize remove width and height attributes from cached images.
parent d06847ec
Pipeline #37483739 passed with stage
in 1 minute and 11 seconds
......@@ -1511,9 +1511,11 @@ class Invoice extends Base {
}
private function FormatGroupOrders($next_week, $products, $format = '') {
if ($format === '') {
$format = $this->Substitute('invoice-group-format');
}
if ($format === '') $format = $this->Substitute('invoice-group-format');
// This can be used with the packing format to sort the order for each
// member by category.
$sort_by_category =
$this->Substitute('invoice-sort-by-category') === 'true';
// Also want to save this data to a csv file to send to suppliers.
$data = [];
// The message can be re-sorted by product from the next_week data which is
......@@ -1582,14 +1584,28 @@ class Invoice extends Base {
if ($format === 'packing') {
// Create a table for each user in packing mode.
if ($message !== '') {
if ($sort_by_category) {
sort($message_data);
$message .= join($message_data);
$message_data = [];
}
$message .= '</table><div class="divider">' .
'<span class="scissors">&#9986;</span></div>' . "\n";
}
$message .= "<table>\n" . '<tr><th colspan="2">' .
'<b>' . $user . '</b> - packed: ' . date('j-F-Y', $packed). ' </th>' .
'<th></th><th colspan="2">Entered? &#9633;</th></tr>' . "\n" .
'<tr><th>Product</th><th>Quantity</th><th>Weighed</th>' .
'<th>Collect</th></tr>' . "\n";
if ($sort_by_category) {
$message .= "<table>\n" . '<tr><th colspan="3">' .
'<b>' . $user . '</b> - packed: ' . date('j-F-Y', $packed) .
'</th><th colspan="2">Entered? &#9633;</th></tr>' . "\n" .
'<tr><th>Product</th><th>Category</th><th>Quantity</th>' .
'<th>Weighed</th><th>Collect</th></tr>' . "\n";
}
else {
$message .= "<table>\n" . '<tr><th colspan="2">' .
'<b>' . $user . '</b> - packed: ' . date('j-F-Y', $packed) .
'</th><th colspan="2">Entered? &#9633;</th></tr>' . "\n" .
'<tr><th>Product</th><th>Quantity</th><th>Weighed</th>' .
'<th>Collect</th></tr>' . "\n";
}
}
foreach ($orders as $name => $details) {
$supplier = $details['supplier'];
......@@ -1616,8 +1632,18 @@ class Invoice extends Base {
if ($unit !== 'kg' && $unit !== 'g' && $unit !== 'L') {
$unit = '';
}
$message .= '<tr><td>' . $name . '</td><td>' . $quantity . $unit .
'</td><td></td><td></td></tr>' . "\n";
if ($sort_by_category) {
$category = isset($products[$name]['category']) ?
$products[$name]['category'] : '';
if (!isset($message_data[$category])) $message_data[$category] = '';
$message_data[$category] .= '<tr><td>' . $name . '</td><td>' .
$category . '</td><td>' . $quantity . $unit .
"</td><td></td><td></td></tr>\n";
}
else {
$message .= '<tr><td>' . $name . '</td><td>' . $quantity . $unit .
"</td><td></td><td></td></tr>\n";
}
}
// Also store each product order in the supplier data.
if (!isset($data[$supplier])) $data[$supplier] = [];
......@@ -1637,7 +1663,11 @@ class Invoice extends Base {
sort($message_data);
$message .= join($message_data);
}
else if ($format === 'packing' && $sort_by_category) {
// Sort and add the data for the last member.
sort($message_data);
$message .= join($message_data);
}
$message .= '</table>' . "\n";
return [$style . $intro . $message, $data];
}
......
......@@ -363,6 +363,10 @@ class SimplePie_Sanitize
}
}
}
// Remove width and height while inspecting the img node, since
// the reader sets it's own values via css.
if ($img->hasAttribute('width')) $img->removeAttribute('width');
if ($img->hasAttribute('height')) $img->removeAttribute('height');
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment