Commit 0af325a6 authored by Malcolm Blaney's avatar Malcolm Blaney

A few small changes: Post module can pass a link through when

receiving a webmention. Stock module now optionally updates
availability based on category. Manager module displays when
showing supplier price.
parent cfc176e0
......@@ -926,6 +926,11 @@ class Post extends Base {
}
$author = $purifier->purify($author);
}
if (isset($entry['properties']['url'][0])) {
// If h-entry provides a link, use that rather than the source for
// linking a comment to the original post (ie passed through bridgy).
$us_source = $entry['properties']['url'][0];
}
if (isset($entry['properties']['content'][0]['html'])) {
$content = $entry['properties']['content'][0]['html'];
$content = $purifier->purify($content);
......
......@@ -313,23 +313,23 @@ class Stock extends Base {
$group = $run_groups[$i]['group'];
$timezone = $run_groups[$i]['timezone'];
$this->user = new User($this->owner, $group, $timezone);
$supplier_query = '';
// Allow the update to be done to only a limited list of suppliers.
$suppliers = $this->Substitute('stock-update-suppliers');
if ($suppliers !== '') {
$supplier_list = explode(',', $suppliers);
for ($j = 0; $j < count($supplier_list); $j++) {
if ($supplier_query !== '') {
$supplier_query .= ' OR ';
$category_query = '';
// Allow the update to be done for only a limited list of categories.
$categories = $this->Substitute('stock-update-categories');
if ($categories !== '') {
$category_list = explode(',', $categories);
for ($j = 0; $j < count($category_list); $j++) {
if ($category_query !== '') {
$category_query .= ' OR ';
}
$supplier_query .= 'stock.user = "'.$supplier_list[$j].'"';
$category_query .= 'category = "'.$category_list[$j].'"';
}
if ($supplier_query !== '') {
$supplier_query = '('.$supplier_query.') AND ';
if ($category_query !== '') {
$category_query = '('.$category_query.') AND ';
}
}
$query = 'UPDATE stock LEFT JOIN users ON stock.user = users.user SET '.
'purchase_available = order_available WHERE '.$supplier_query.
'purchase_available = order_available WHERE '.$category_query.
'users.system_group = "'.$group.'"';
if (!$mysqli->query($query)) {
$this->Log('Stock->Cron: '.$mysqli->error);
......
......@@ -121,7 +121,9 @@ var start=parseInt($.datepicker.formatDate("@",$("#manager-start-date-input").da
var end=parseInt($.datepicker.formatDate("@",$("#manager-end-date-input").datepicker("getDate")),10);if(!end){end="";}
var exportData=$("#manager-export-data:checked").length;dobrado.log("Searching...","info");$.post("/php/request.php",{request:"manager",username:$("#manager-username-input").val(),timestamp:timestamp,product:$("#manager-product-input").val(),supplier:$("#manager-supplier-input").val(),quantity:"",price:"",start:start,end:end,group:$("#manager-group-input:checked").length,exportData:exportData,action:"search",url:location.href,token:dobrado.token},function(response){if(dobrado.checkResponseError(response,"manager search")){return;}
var data=JSON.parse(response);purchase=data.search;if(purchase.length===0){$(".manager .search-info").html("No data found for search.");$(managerGridId).hide();return;}
if(managerGrid){$(".manager .search-info").html("");managerGrid.setData(purchase);managerGrid.updateRowCount();managerGrid.render();managerGrid.setSelectedRows([]);$(managerGridId).show();currentDate=null;}
if(managerGrid){if($("#manager-username-input").val()===""&&$("#manager-supplier-input").val()!==""){$(".manager .search-info").html("<i>Displaying supplier price</i>");}
else{$(".manager .search-info").html("");}
managerGrid.setData(purchase);managerGrid.updateRowCount();managerGrid.render();managerGrid.setSelectedRows([]);$(managerGridId).show();currentDate=null;}
if(exportData){location.href="/php/private.php?file="+data.filename;}});return false;}
function clearDate(){$("#manager-date-input").val("");}
function clearSearchDates(){$("#manager-start-date-input").val("");$("#manager-end-date-input").val("");}
......
......@@ -832,7 +832,15 @@ if (!this.dobrado.manager) {
}
// Reload the grid with the search data.
if (managerGrid) {
$(".manager .search-info").html("");
// The search results return the supplier price when only a supplier
// name is given, make sure the user knows this.
if ($("#manager-username-input").val() === "" &&
$("#manager-supplier-input").val() !== "") {
$(".manager .search-info").html("<i>Displaying supplier price</i>");
}
else {
$(".manager .search-info").html("");
}
managerGrid.setData(purchase);
managerGrid.updateRowCount();
managerGrid.render();
......
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