This commit is contained in:
2019-07-05 14:23:20 +00:00
parent b7accbacf1
commit 021199a2f4
3 changed files with 172 additions and 151 deletions

View File

@@ -93,6 +93,8 @@ namespace rockfishCore.Controllers
public IEnumerable<dtoNameIdChildrenItem> GetActiveSubsForSites([FromRoute] long id) public IEnumerable<dtoNameIdChildrenItem> GetActiveSubsForSites([FromRoute] long id)
{ {
long EpochNow = DateUtil.NowAsEpoch();
var res = from c in _context.Site var res = from c in _context.Site
.Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name) .Where(c => c.CustomerId.Equals(id)).OrderBy(c => c.Name)
select new dtoNameIdChildrenItem select new dtoNameIdChildrenItem
@@ -108,7 +110,7 @@ namespace rockfishCore.Controllers
{ {
var subs = from c in _context.Purchase var subs = from c in _context.Purchase
.Where(c => c.SiteId.Equals(child.id)) .Where(c => c.SiteId.Equals(child.id))
.Where(c => c.CancelDate == null) .Where(c => c.CancelDate == null || c.CancelDate > EpochNow)
.OrderByDescending(c => c.PurchaseDate) .OrderByDescending(c => c.PurchaseDate)
select new dtoNameIdItem select new dtoNameIdItem
{ {

View File

@@ -328,34 +328,33 @@ namespace rockfishCore.Util
quoted.WriteLine("On {0}, {1} wrote:", message.Date.ToString("f"), name); quoted.WriteLine("On {0}, {1} wrote:", message.Date.ToString("f"), name);
//TODO: get text message just like in reader here for html only message //Try to get the original message text and format it as > quoted
//sometimes body text is empty.
/* var theBody = message.GetTextBody(MimeKit.Text.TextFormat.Plain);
var theBody = m.GetTextBody(MimeKit.Text.TextFormat.Plain);
if (theBody == null) if (theBody == null)
{ {
//No text body so go with the new method to extract the text part
// might be an html email, try to get the text anyway // might be an html email, try to get the text anyway
var ht = m.HtmlBody; var ht = message.HtmlBody;
if (!string.IsNullOrWhiteSpace(ht)) if (!string.IsNullOrWhiteSpace(ht))
{ {
theBody = "**** HTML-ONLY MESSAGE ****";
theBody += "\r\n=-=-=-=- TEXT CONVERSION =-=-=-=-\r\n"; theBody = StripHTML(ht, true);
theBody += StripHTML(ht, true); theBody += "> ";
theBody += "\r\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-"; theBody = theBody.Replace("\r\n", "\r\n> ").Trim().TrimEnd('>');
theBody += "\r\n=-=-=-=- SOURCE HTML =-=-=-=-\r\n"; theBody ="\r\n"+theBody;//descend the first line under the On you wrote bit
theBody += ht;
theBody += "\r\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-";
theBody += "\r\n******* END MESSAGE *******";
} }
else else
{ {
theBody = "NO MESSAGE BODY WAS FOUND NEITHER HTML NOR TEXT"; theBody = "> Source Message Empty";
} }
quoted.WriteLine(theBody);
} }
sb.AppendLine(theBody); else
*/ {
//has a text body so go with old method
using (var reader = new StringReader(message.TextBody)) using (var reader = new StringReader(message.TextBody))
{ {
string line; string line;
@@ -366,6 +365,10 @@ namespace rockfishCore.Util
quoted.WriteLine(line); quoted.WriteLine(line);
} }
} }
}
reply.Body = new TextPart("plain") reply.Body = new TextPart("plain")
{ {

View File

@@ -8,11 +8,9 @@
/*global $, app */ /*global $, app */
app.purchases = (function() { app.purchases = (function() {
'use strict'; "use strict";
//---------------- BEGIN MODULE SCOPE VARIABLES -------------- //---------------- BEGIN MODULE SCOPE VARIABLES --------------
var var configMap = {
configMap = {
//main_html: '', //main_html: '',
settable_map: {} settable_map: {}
@@ -20,71 +18,80 @@ app.purchases = (function () {
stateMap = { stateMap = {
$append_target: null $append_target: null
}, },
onSubmit, loadList, configModule, initModule; onSubmit,
loadList,
configModule,
initModule;
//----------------- END MODULE SCOPE VARIABLES --------------- //----------------- END MODULE SCOPE VARIABLES ---------------
//------------------- BEGIN UTILITY METHODS ------------------ //------------------- BEGIN UTILITY METHODS ------------------
loadList = function() { loadList = function() {
var epochNow = Math.round(new Date().getTime() / 1000);
//---- //----
//fetch //fetch
app.api.get('site/' + stateMap.id + '/purchases', function (res) { app.api.get("site/" + stateMap.id + "/purchases", function(res) {
if (res.error) { if (res.error) {
$.gevent.publish('app-show-error',res.msg); $.gevent.publish("app-show-error", res.msg);
} else { } else {
//get the list ul //get the list ul
var $appList = $('#rf-list'); var $appList = $("#rf-list");
$appList.empty(); $appList.empty();
$.each(res, function(i, obj) { $.each(res, function(i, obj) {
//bugbug: don't just check for the presence of a cancel date but also is it in the past otherwise it's not cancelled
if (obj.cancelDate) { if (obj.cancelDate && obj.cancelDate < epochNow) {
$appList.append("<li class='rfc-list-item-inactive'><a href=\"#!/purchaseEdit/" + obj.id + "/" + stateMap.id + "\">" + $appList.append(
"<li class='rfc-list-item-inactive'><a href=\"#!/purchaseEdit/" +
obj.id +
"/" +
stateMap.id +
'">' +
// app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) + // app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) +
// '&nbsp;' + // '&nbsp;' +
"<span class='text-muted'>" + "<span class='text-muted'>" +
app.utilB.genListColumn(obj.name) + app.utilB.genListColumn(obj.name) +
"&nbsp;cancelled&nbsp;" + "&nbsp;cancelled&nbsp;" +
app.utilB.genListColumn(app.utilB.epochToShortDate(obj.cancelDate)) + app.utilB.genListColumn(
app.utilB.epochToShortDate(obj.cancelDate)
) +
"</span>" + "</span>" +
"</a></li>"); "</a></li>"
);
} else { } else {
$appList.append("<li><a href=\"#!/purchaseEdit/" + obj.id + "/" + stateMap.id + "\">" + $appList.append(
'<li><a href="#!/purchaseEdit/' +
obj.id +
"/" +
stateMap.id +
'">' +
// app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) + // app.utilB.genListColumn(app.utilB.epochToShortDate(obj.purchaseDate)) +
// '&nbsp;' + // '&nbsp;' +
app.utilB.genListColumn(obj.name) + app.utilB.genListColumn(obj.name) +
"&nbsp;expires&nbsp;" + "&nbsp;expires&nbsp;" +
app.utilB.genListColumn(app.utilB.epochToShortDate(obj.expireDate)) + app.utilB.genListColumn(
"</a></li>"); app.utilB.epochToShortDate(obj.expireDate)
) +
"</a></li>"
);
// //
} }
}); });
} }
}); });
//------ //------
} };
//-------------------- END UTILITY METHODS ------------------- //-------------------- END UTILITY METHODS -------------------
//--------------------- BEGIN DOM METHODS -------------------- //--------------------- BEGIN DOM METHODS --------------------
// Begin private DOM methods // Begin private DOM methods
// End private DOM methods // End private DOM methods
//---------------------- END DOM METHODS --------------------- //---------------------- END DOM METHODS ---------------------
//------------------- BEGIN EVENT HANDLERS ------------------- //------------------- BEGIN EVENT HANDLERS -------------------
//-------------------- END EVENT HANDLERS -------------------- //-------------------- END EVENT HANDLERS --------------------
//------------------- BEGIN PUBLIC METHODS ------------------- //------------------- BEGIN PUBLIC METHODS -------------------
@@ -106,26 +113,37 @@ app.purchases = (function () {
// Throws : none // Throws : none
// //
initModule = function($container) { initModule = function($container) {
if (typeof $container === 'undefined') { if (typeof $container === "undefined") {
$container = $('#app-shell-main-content'); $container = $("#app-shell-main-content");
} }
stateMap.sortOrder = 'd'; stateMap.sortOrder = "d";
$container.html(Handlebars.templates['app.purchases']({})); $container.html(Handlebars.templates["app.purchases"]({}));
if (!stateMap.id) { if (!stateMap.id) {
throw ('app.purchases.js::initModule - There is no stateMap.id!'); throw "app.purchases.js::initModule - There is no stateMap.id!";
} }
app.api.get('site/' + stateMap.id, function (res) { app.api.get("site/" + stateMap.id, function(res) {
if (res.error) { if (res.error) {
$.gevent.publish('app-show-error',res.msg); $.gevent.publish("app-show-error", res.msg);
} else { } else {
//Context menu //Context menu
app.nav.contextClear(); app.nav.contextClear();
app.nav.contextAddLink('purchaseEdit/new/' + stateMap.id, "New", "plus"); app.nav.contextAddLink(
app.nav.contextAddLink("customerEdit/" + res.customerId, "Customer", "account"); "purchaseEdit/new/" + stateMap.id,
app.nav.contextAddLink("customerSiteEdit/" + stateMap.id + '/' + res.customerId, "Site", "city"); "New",
"plus"
);
app.nav.contextAddLink(
"customerEdit/" + res.customerId,
"Customer",
"account"
);
app.nav.contextAddLink(
"customerSiteEdit/" + stateMap.id + "/" + res.customerId,
"Site",
"city"
);
if (stateMap.id) { if (stateMap.id) {
loadList(); loadList();
} }
@@ -134,12 +152,10 @@ app.purchases = (function () {
}; };
// End public method /initModule/ // End public method /initModule/
// return public methods // return public methods
return { return {
configModule: configModule, configModule: configModule,
initModule: initModule initModule: initModule
}; };
//------------------- END PUBLIC METHODS --------------------- //------------------- END PUBLIC METHODS ---------------------
}()); })();