var Dom = YAHOO.util.Dom;
var Event = YAHOO.util.Event;
var DDM = YAHOO.util.DragDropMgr;
var MY = new Object(); // Stores classes
MY.fnInit = new Object(); // defaults
MY.defaults = new Object(); // defaults
MY.defaults.selectStyle = {width:'auto', margin:'5px auto'};
MY.defaults.textareaStyle = {width:'auto', margin:'5px auto'};
MY.fnInit[DATASET_USER_SMTP_LOOKUP] = function(argArray) {
this.noFirstIfZero = true;
this.fnInitBase = MY.fnInit[DATASET_USER_SMTP];
return this.fnInitBase(argArray);
}
MY.fnInit[DATASET_HISTORY] = function initHistory(argArray) {
this.getSummary = function getSummary(elLiner, oRecord, oColumn, oData){
var oDataset = MY[DATASET_HISTORY];
var val = "?";
msg("getSummary(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
if(typeof(oRecord)!='undefined' && oRecord != null) {
var recordIndex = oRecord.getData('ID');
if(recordIndex>=0) {
val = oDataset.get(recordIndex, '_summary_');
}
var emailID = oDataset.get(recordIndex, 'emailID');
var requestID = oDataset.get(recordIndex, 'requestID');
var statusID = oDataset.get(recordIndex, 'statusID');
var src = IMAGE_UNKNOWN;
if(typeof(requestID)!='undefined' && requestID>0 && statusID==REQUEST_STATUS_QUOTED) {
src = IMAGE_REQUEST;
val = 'Request - ' + val;
// Add any quotes
var quotes = oDataset.get(recordIndex, 'quotes');
var qContent = '';
if(typeof(quotes)!='undefined' && quotes.length) {
var qContentArray = new Array();
for(var q in quotes) {
var quoteSummary = MY[DATASET_QUOTES].getSummary(quotes[q]);
//var quoteSummary = quotes[q]['_summary_'];
qContentArray.push(quoteSummary);
}
var sep = "";
val += "
" + sep + qContentArray.join(sep) + "
";
}
} else {
//if(typeof(emailID)!='undefined' && emailID>0) {
//}
var isFrom = oDataset.get(recordIndex, 'isFrom');
if(isFrom==0) src = IMAGE_EMAIL_TO;
else src = IMAGE_EMAIL_FROM;
}
}
if(typeof(elLiner)=='object' && elLiner!=null) {
//elLiner.innerHTML = getContentWithMore(val);
elLiner.innerHTML = "" + val;
} else return val;
}
this.inputs.uniqueField = "email";
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "Email");
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['submitTimestamp'] = new s('submitTimestamp', INPUT_TYPE_TIMESTAMP, "When");
this.inputs.fields['submitTimestamp'].formatter = MVRZ.util.formatter.DataTable.timestampRecent;
this.inputs.fields['submitTimestamp'].readonly = true;
this.inputs.fields['_summary_'] = new s('summary', INPUT_TYPE_TEXT, "Summary");
this.inputs.fields['_summary_'].readonly = true;
this.inputs.fields['_summary_'].notOnServer = true;
this.inputs.fields['summary'] = new s('summary', this.getSummary, "Summary", "", false, v.isAlpha);
this.inputs.fields['summary'].noEditRender = true;
this.inputs.fields['summary'].readonly = true;
this.inputs.fields['summary'].formatter = this.getSummary;
this.inputs.fields['summary'].sortable = false;
this.inputs.fields['summary'].notOnServer = true;
this.viewList = ['ID',"submitTimestamp", "summary"];
}
var gReservationCounter = 0;
MY.fnInit[DATASET_ORDER] = function initOrder(){
msg('fnInit:'+this.datasetName);
this.renderSelectOption = function renderSelectOption(datasetData, datasetRowIndex) {
var name = '';
var travelerId = datasetData[datasetRowIndex]['travelerID'];
var propertyId = datasetData[datasetRowIndex]['propertyID'];
//popupInfo("datasetRowIndex="+datasetRowIndex+", travelerId="+travelerId+", propertyId="+propertyId);
var propertyName = MY[DATASET_PROPERTY].get(propertyId, 'name', "ID");
if(typeof(MY[DATASET_TRAVELERCONTACT])!='undefined') {
var name = MY[DATASET_TRAVELERCONTACT].getFullName(travelerId);
}
if(name.length) name = " - " + name;
var ret = propertyName + name + ' :: ' + datasetData[datasetRowIndex]['arrivalDate'] + ' - ' + datasetData[datasetRowIndex]['departureDate'] + ' [' + datasetData[datasetRowIndex]['ID'] + ']';
//var ret = datasetData[datasetRowIndex]['arrivalDate'] + ' - ' + datasetData[datasetRowIndex]['departureDate'] + ' [' + datasetData[datasetRowIndex]['ID'] + ']';
return ret;
}
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectOptionLabelField = this.renderSelectOption;
var nowDate = new Date();
this.inputs.selectField.selectConfig = new Object();
////this.inputs.selectField.selectConfig['matchArray'] = [{eval: "(MVRZ.util.formatter._getDatabaseDate(oData[dataIndex]['departureDate']))!=null && MVRZ.util.formatter._getDatabaseDate(oData[dataIndex]['departureDate']).getTime()>="+nowDate.getTime()}];
this.inputs.selectField.selectConfig.fnSkip = function(oDatasetEntry){
var skip = true;
if(typeof(oDatasetEntry)=='undefined') return skip;
var d = MVRZ.util.parser.date(oDatasetEntry['departureDate']);
if(d != null && d.getTime() >= gNowDate.getTime()) skip = false;
return skip;
}
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['isCancelled'] = new s('isCancelled', INPUT_TYPE_CHECKBOX, "Cancelled?", "Check this to cancel the reservation.", false);
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "Property", "Choose the property that this reservation is for.", true, null, null, MY[DATASET_PROPERTY]);
this.inputs.fields['statusID'] = new s('statusID', INPUT_TYPE_SELECT, "Status", "Select the status for this Reservation.", true, null, null, MY[DATASET_STATUS]);
this.inputs.fields['orderDateTime'] = new s('orderDateTime', INPUT_TYPE_DATETIME, "Reserved On", "The day/time that this reservation was made (or loaded from the HomeAwayConnect calendar if using that as your up-to-date calendar).", false,'','','','','',MVRZ.util.formatter.datetime.unformat());
this.inputs.fields['orderDateTime'].sortable = true;
this.inputs.fields['arrivalDate'] = new s('arrivalDate', INPUT_TYPE_DATE, "Arrival Date", "The day that the guest arrives", true);
this.inputs.fields['arrivalDate'].sortable = true;
this.inputs.fields['checkinTime'] = new s('checkinTime', INPUT_TYPE_TIME, "Check-in Time", "The time that the property is available from on the Arrival Day", true);
this.inputs.fields['departureDate'] = new s('departureDate', INPUT_TYPE_DATE, "Departure Date", "The day that the guest departs", true);
this.inputs.fields['departureDate'].sortable = true;
this.inputs.fields['checkoutTime'] = new s('checkoutTime', INPUT_TYPE_TIME, "Check-out Time", "The time that the property is available to on the Departure Day", true);
this.inputs.fields['sourceID'] = new s('sourceID', INPUT_TYPE_SELECT, "Direct Referral", "Choose the direct source of this referral - the one that sent you the inquiry directly.", false, null, null, MY[DATASET_SOURCE]);
this.inputs.fields['source2ID'] = new s('source2ID', INPUT_TYPE_SELECT, "Indirect Referral", "Choose the in-direct source of this referral - the place that the inquirer started at but ultimately submitted the request through the Direct source. This would typically happen if you have a link from an advertiser's site to your own website and the inquiry came through the request form on your own website. In that case, the Advertiser is the indirect source and your site is the direct one.", false, null, null, MY[DATASET_SOURCE]);
this.inputs.fields['heatTo'] = new s('heatTo', INPUT_TYPE_TEMPERATURE, "Ideal Heating Temperature (F)", "This is the temperature that you'd like the home to be heated to when the heating system is on. Leave blank for default property value.", false);
this.inputs.fields['coolTo'] = new s('coolTo', INPUT_TYPE_TEMPERATURE, "Ideal Cooling Temperature (F)", "This is the temperature that you'd like the home to be cooled to when the cooling system is on. Leave blank for default property value.", false);
//this.renderView = renderView;
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('Reservation('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_QUOTES] = function initQuotes(){
msg('fnInit:'+this.datasetName);
this.getOptionsSummary = function getOptionsSummary(idValue) {
if(typeof(this.optionsSummary)=='undefined') this.optionsSummary = new Array();
if(typeof(idValue)=='undefined') idValue = this.getDatasetId();
if(typeof(idValue)!='undefined') {
if(typeof(idValue)=='object') {
var optionsSummary = idValue['_options_'];
} else {
var datasetRowIndex = this.getDatasetRowIndex(idValue);
var optionsSummary = MY[DATASET_QUOTEOPTIONS].getOptionsSummary(datasetRowIndex);
this.optionsSummary[datasetRowIndex] = optionsSummary;
}
}
return optionsSummary;
}
this.getSummary = function getSummary(elLiner, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_QUOTES];
msg("getSummary(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
var idValue, val = '';
var idField = oDataset.getUniqueField();
var isValid;
if(isElement(elLiner)) { // Usually a table cell
if(typeof(oRecord)!='undefined' && oRecord != null) {
idValue = oRecord.getData(idField);
}
isValid = typeof(idValue)!='undefined' && idValue != null && idValue>=0 && MVRZ.util.validation.datasetIsValid(oDataset.datasetName, idValue);
} else { // Assume recordID is in eLiner & possibly the array of value in oRecord
idValue = elLiner;
isValid = typeof(idValue) == 'object';
}
if(isValid) {
var arrivalDate = oDataset.get(idValue, "arrivalDate", idField);
var departureDate = oDataset.get(idValue, "departureDate", idField);
var nights = oDataset.get(idValue, "nights", idField);
var rentTaxableAmount = oDataset.get(idValue, "rentTaxableAmount", idField) || 0;
var rentNontaxableAmount = oDataset.get(idValue, "rentNontaxableAmount", idField) || 0;
var rentTax = oDataset.get(idValue, "rentTax", idField) || 0;
var discountAmount = oDataset.get(idValue, "discountAmount", idField) || 0;
var discountReason = oDataset.get(idValue, "discountReason", idField);
var surchargeAmount = oDataset.get(idValue, "surchargeAmount", idField) || 0;
var surchargeReason = oDataset.get(idValue, "surchargeReason", idField);
var gapBefore = oDataset.get(idValue, "gapBefore", idField);
var gapAfter = oDataset.get(idValue, "gapAfter", idField);
var quoteTypeID = oDataset.get(idValue, "quoteTypeID", idField);
if(typeof(quoteTypeID)=='undefined' || quoteTypeID.length==0) quoteTypeID = 'CUST';
var isAvailable = oDataset.get(idValue, "isAvailable", idField);
if(typeof(isAvailable)=='undefined') isAvailable = 1;
var prePendl1 = '';
var propertyName = '';
if(MY[DATASET_PROPERTY].rows()>1) {
var propertyId = oDataset.get(idValue, "propertyID", idField);
propertyName = MY[DATASET_PROPERTY].get(propertyId, 'name', idField) + ' ';
//prePendl1 = propertyName + " ";
}
// Options
var optionsSummary = oDataset.getOptionsSummary(idValue);
//var optionsSummary = MY[DATASET_QUOTEOPTIONS].getOptionsSummary(recordIndex);
var optionsAmount = optionsSummary.amount || 0;
var optionsTax = optionsSummary.tax || 0;
var optionsTotal = optionsSummary.total || 0;
var optionsList = '';
if(typeof(optionsSummary.list)!='undefined' && optionsSummary.list instanceof Array)
optionsList = optionsSummary.list.join(',');
//if(typeof(MY[DATASET_QUOTES].optionsSummary)=='undefined') MY[DATASET_QUOTES].optionsSummary = new Array();
//MY[DATASET_QUOTES].optionsSummary[recordIndex] = optionsSummary;
var rentTaxableAmountFormatted = MVRZ.util.formatter.currency.format(rentTaxableAmount);
var rentNontaxableAmountFormatted = MVRZ.util.formatter.currency.format(rentNontaxableAmount);
var rentTaxFormatted = MVRZ.util.formatter.currency.format(rentTax);
var discountAmountFormatted = MVRZ.util.formatter.currency.format(discountAmount);
var surchargeAmountFormatted = MVRZ.util.formatter.currency.format(surchargeAmount);
var optionsAmountFormatted = MVRZ.util.formatter.currency.format(optionsAmount);
var optionsTotalFormatted = MVRZ.util.formatter.currency.format(optionsTotal);
var rentTotal = parseFloat(rentTaxableAmount) + parseFloat(rentNontaxableAmount);
var rentTotalFormatted = MVRZ.util.formatter.currency.format(rentTotal);
var total = parseFloat(rentTaxableAmount) + parseFloat(rentNontaxableAmount) - parseFloat(discountAmount) + parseFloat(surchargeAmount) + parseFloat(rentTax) + parseFloat(optionsTotal);
var totalFormatted = MVRZ.util.formatter.currency.format(total);
var totalTax = parseFloat(rentTax) + parseFloat(optionsTax);
var totalTaxFormatted = MVRZ.util.formatter.currency.format(totalTax);
var rateStr = totalFormatted + " (" + rentTotalFormatted + "-" + discountAmountFormatted + "+" + surchargeAmountFormatted + "+" + optionsAmountFormatted + "+" + totalTaxFormatted + ")";
if(typeof(gapAfter)!='undefined' && gapAfter>99) gapAfter = "99+";
if(typeof(gapBefore!='undefined') && gapBefore>99) gapBefore = "+99";
var gaps = "";
if(typeof(gapBefore)!='undefined' && typeof(gapBefore)!='undefined') gaps = " <" + gapBefore + "|" + gapAfter + ">";
// Construct the summary
var dateStr = MVRZ.util.formatter.date.format(arrivalDate) + " > " + MVRZ.util.formatter.date.format(departureDate) +" (" + nights + ")";
/*
var imgSrc;
switch(quoteTypeID) {
case('RQST'):
imgSrc = '/images/buttons/play.png';
break;
case('ALBF'):
imgSrc = '/images/buttons/rewind.png';
break;
case('ALAF'):
imgSrc = '/images/buttons/fast_forward.png';
break;
case('GPBF'):
imgSrc = '/images/buttons/skip_backward.png';
break;
case('GPAF'):
imgSrc = '/images/buttons/skip_forward.png';
break;
default:
imgSrc = '';
}
*/
//var availableText = '';
//if(!isAvailable) availableText = " UNAVAILABLE";
val = "
";
} else {
if(isValid) val = "?"
else val = "Quote fields are not completed";
}
if(val.length==0) val = "?";
msg("getFullName() returning " + val);
if(isElement(elLiner)) {
elLiner.innerHTML = getContentWithMore(val);
} else return val;
}
this.getIsIncludedInput = function getIsIncludedInput(elLiner, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_QUOTES];
msg("getIsIncludedInput(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
var idValue, oVal;
var idField = oDataset.getUniqueField();
var isValid;
if(isElement(elLiner)) { // Usually a table cell
if(typeof(oRecord)!='undefined' && oRecord != null) {
idValue = oRecord.getData(idField);
}
isValid = typeof(idValue)!='undefined' && idValue != null && idValue>=0 && MVRZ.util.validation.datasetIsValid(oDataset.datasetName, idValue);
} else { // Assume recordID is in eLiner & possibly the array of value in oRecord
idValue = elLiner;
isValid = typeof(idValue) == 'object';
}
if(isValid) {
var input = "isIncluded";
var dataValue = oDataset.get(idValue, "isIncluded", idField);
var isAvailable = oDataset.get(idValue, "isAvailable", idField);
if(typeof(isAvailable)=='undefined') isAvailable = 1;
var oInput = oDataset.inputs.fields['isIncluded'];
var datasetRowIndex = oDataset.getDatasetRowIndex(idValue);
var id = MVRZ.util.encodeInputId(oDataset.datasetName, datasetRowIndex, idValue, input);
oVal = MVRZ.util.render.input(oInput, id, dataValue, oDataset, false, false, idValue);
} else {
oVal = document.createElement('em');
oVal.InnerHTML = "NO";
}
if(isElement(elLiner)) {
elLiner.appendChild(oVal);
} else return oVal;
}
this.preRender = function preRender(idValue, elContent) {
return true;
// Create dummy ID numbers for the quotes
var oDataset = MY[DATASET_QUOTES];
if(typeof(oDataset.datasetData)!='undefined' && oDataset.datasetData.length>0) {
for(var i in oDataset.datasetData) {
//oDataset.datasetData[i][oDataset.inputs.uniqueField] = -( parseInt(i) + 1 );
oDataset.datasetData[i][oDataset.inputs.uniqueField] = parseInt(i) + 1;
}
}
}
// General stuff
this.noSave = true; // Don't save to the server by default
this.emptyNotice = "No quotes for this request";
this.loadingNotice = "Getting quotes...";
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
/*
this.inputs.fields['_notes_'] = new s('notes', INPUT_TYPE_TEXTAREA, "Quotation Notes", "Notes about what this quote comprises.");
this.inputs.fields['_notes_'].readonly = true;
this.inputs.fields['_notes_'].formatter = MVRZ.util.formatter.html.format;
*/
this.inputs.isDisabled = function isDisabled(idValue) {
var isAvailable = MY[DATASET_QUOTES].get(idValue, 'isAvailable', MY[DATASET_QUOTES].getUniqueField());
if(typeof(isAvailable)=='undefined' || isAvailable!=0) return false;
return true;
}
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['requestID'] = new s('requestID', INPUT_TYPE_NUMBER, "RequestID");
this.inputs.fields['requestID'].readonly = true;
this.inputs.fields['requestID'].isHidden = true;
this.inputs.fields['isIncluded'] = new s('isIncluded', INPUT_TYPE_CHECKBOX, "Include?");
//this.inputs.fields['isIncluded'].formatter = this.getIsIncludedInput;
this.inputs.fields['quoteTypeID'] = new s('quoteTypeID', INPUT_TYPE_TEXT, "Type", "The type of quote:
RQST = Requested dates
GPAF = Gap After - At the beginning of a gap after the arrival date
GPBF = Gap Before - At the end of a gap before the arrival date
");
this.inputs.fields['quoteTypeID'].readonly = true;
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "Property", "Choose the property that this reservation is for.", true, null, null, MY[DATASET_PROPERTY]);
this.inputs.fields['propertyID'].selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.inputs.fields['arrivalDate'] = new s('arrivalDate', INPUT_TYPE_DATE, "Arrival Date", "The day that the guest arrives", true);
this.inputs.fields['arrivalDate'].sortable = true;
this.inputs.fields['arrivalDate'].defaultVal = MVRZ.util.formatter.date.unformat(new Date());
this.inputs.fields['departureDate'] = new s('departureDate', INPUT_TYPE_DATE, "Departure Date", "The day that the guest departs", true);
this.inputs.fields['departureDate'].sortable = true;
this.inputs.fields['departureDate'].noEditRender = true;
//this.inputs.fields['departureDate'].formatter = MVRZ.util.formatter.date.format;
this.inputs.fields['nights'] = new s('nights', INPUT_TYPE_NUMBER, "Nights", "Nights wanted (minimum).", true );
this.inputs.fields['rentTaxableAmount'] = new s('rentTaxableAmount', INPUT_TYPE_CURRENCY, "Rent (taxable)");
this.inputs.fields['rentTaxableAmount'].readonly = true;
this.inputs.fields['rentNontaxableAmount'] = new s('rentNontaxableAmount', INPUT_TYPE_CURRENCY, "Rent (non-taxable)");
this.inputs.fields['rentNontaxableAmount'].readonly = true;
this.inputs.fields['rentTax'] = new s('rentTax', INPUT_TYPE_CURRENCY, "Rent Tax");
this.inputs.fields['rentTax'].readonly = true;
this.inputs.fields['setRentAmount'] = new s('setRentAmount', INPUT_TYPE_CURRENCY, "Set Rent to", "Set the total accommodation to this amount.");
this.inputs.fields['rentPercent'] = new s('rentPercent', INPUT_TYPE_NUMBER, "Change Rent by %", "A -ve amount decreases the total amount.");
this.inputs.fields['discountAmount'] = new s('discountAmount', INPUT_TYPE_CURRENCY, "Discount Amount", "Amount of any discount. Use a positive number to discount. If a Percentage is specified then that take precedence over this amount.");
this.inputs.fields['discountPercent'] = new s('discountPercent', INPUT_TYPE_NUMBER, "Discount Percent", "Percentage discount - taken from the total accommodation amount after any 'Set Amount' has been applied. This takes precedence over any fixed Discount Amount.");
this.inputs.fields['discountReason'] = new s('discountReason', INPUT_TYPE_TEXT, "Discount Reason");
this.inputs.fields['discountFootnote'] = new s('discountFootnote', INPUT_TYPE_TEXT, "Discount Footnote");
this.inputs.fields['surchargeAmount'] = new s('surchargeAmount', INPUT_TYPE_CURRENCY, "Surcharge Amount", "Amount of any surcharge. Use a positive number to add the surcharge. If a Percentage is specified then that take precedence over this amount.");
this.inputs.fields['surchargePercent'] = new s('surchargePercent', INPUT_TYPE_NUMBER, "Surcharge Percent", "Percentage surcharge - added to the total accommodation amount after any 'Set Amount' has been applied. This takes precedence over any fixed Surcharge Amount.");
this.inputs.fields['surchargeReason'] = new s('surchargeReason', INPUT_TYPE_TEXT, "Surcharge Reason");
this.inputs.fields['surchargeFootnote'] = new s('surchargeFootnote', INPUT_TYPE_TEXT, "Surcharge Footnote");
//this.inputs.fields['dateTime'] = new s('dateTime', INPUT_TYPE_DATETIME, "");
this.inputs.fields['summary'] = new s('summary', this.getSummary, "Quote Summary", "", false, v.isAlpha);
this.inputs.fields['summary'].noEditRender = true;
this.inputs.fields['summary'].readonly = true;
this.inputs.fields['summary'].formatter = this.getSummary;
this.inputs.fields['summary'].sortable = false;
this.inputs.fields['summary'].notOnServer = true;
//this.inputs.fields['isIncludedTable'] = new s('isIncludedTable', this.getIsIncludedInput, "Include???");
//this.inputs.fields['isIncludedTable'].formatter = this.getIsIncludedInput;
this.viewList = ["ID","isIncluded","summary"];
msg('Quotes('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_QUOTEOPTIONS] = function initQuoteOptions(){
msg('fnInit:'+this.datasetName);
this.getSummary = function getSummary(elLiner, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_QUOTEOPTIONS];
msg("getSummary(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
if(typeof(oRecord)!='undefined' && oRecord != null) {
var recordIndex = oRecord.getData(oDataset.inputs.uniqueField);
var optionAmount = oDataset.get(recordIndex, "optionAmount", 'ID') || "0";
var optionTax = oDataset.get(recordIndex, "optionTax", 'ID') || "0";
var optionAmountFormatted = MVRZ.util.formatter.currency.format(optionAmount);
var optionTaxFormatted = MVRZ.util.formatter.currency.format(optionTax);
var optionName = '';
if(MY[DATASET_OPTION].rows()>1) {
var optionId = oDataset.get(recordIndex, "optionID", 'ID');
optionName = MY[DATASET_OPTION].get(optionId, 'name', 'id');
}
var total = parseFloat(optionAmount) + parseFloat(optionTax);
var totalFormatted = MVRZ.util.formatter.currency.format(total);
//var l1 = prePendl1 + ;
var l2 = optionAmountFormatted + "+" + optionTaxFormatted;
val = "
";
} else {
val = "?";
}
if(val.length==0) val = "?";
msg("getSummary() returning " + val);
if(typeof(elLiner)=='object' && elLiner!=null) elLiner.innerHTML = val;
else return val;
}
this.preRender = function preRender(idValue, elContent) {
return true;
// Create dummy ID numbers for the quotes
var oDataset = MY[DATASET_QUOTEOPTIONS];
if(typeof(oDataset.datasetData)!='undefined' && oDataset.datasetData.length>0) {
for(var i in oDataset.datasetData) {
//oDataset.datasetData[i][oDataset.inputs.uniqueField] = -( parseInt(i) + 1 );
oDataset.datasetData[i][oDataset.inputs.uniqueField] = parseInt(i) + 1;
oDataset.datasetData[i]['quoteID'] = parseInt(oDataset.datasetData[i]['quoteID']) + 1;
}
}
}
this.getOptionsSummary = function getOptionsTotal(quoteId) {
var ret = {amount: parseFloat(0.0), tax:parseFloat(0.0), total:parseFloat(0.0), list: []};
if(typeof(quoteId)=='undefined') return ret;
var oDataset = MY[DATASET_QUOTEOPTIONS];
if(oDataset.rows()>0) {
var rows = oDataset.getRows();
for(var i in rows) {
if(rows[i]['quoteID']===quoteId && rows[i]['isIncluded']!=="0") {
//Check that this is included for this property
var oArgs = {propertyID: rows[i]['propertyID'], optionID: rows[i]['optionID']};
if(MY[DATASET_PROPERTY].isOptionIdOnList(oArgs)) {
var amount = parseFloat(rows[i]['optionAmount']);
var tax = parseFloat(rows[i]['optionTax']);
ret.amount += amount;
ret.tax += tax;
var abbr = MY[DATASET_OPTION].get(rows[i]['optionID'], 'abbreviation', 'ID');
var str = abbr;
if(typeof(abbr)=='undefined' || abbr == null || abbr.length==0) {
str = MY[DATASET_OPTION].get(rows[i]['optionID'], 'name', 'ID');
}
ret.list.push(str);
}
}
}
ret.total = ret.amount + ret.tax;
}
return ret;
}
// General stuff
this.noSave = true; // Don't save to the server by default
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['quoteID'] = new s('quoteID', INPUT_TYPE_NUMBER, "QuoteID");
this.inputs.fields['quoteID'].readonly = true;
this.inputs.fields['isIncluded'] = new s('isIncluded', INPUT_TYPE_CHECKBOX, "Include?");
this.inputs.fields['isIncludedInQuote'] = new s('isIncludedInQuote', INPUT_TYPE_CHECKBOX, "Include?");
this.inputs.fields['isIncludedInQuote'].hidden = true;
//this.inputs.fields['optionID'] = new s('optionID', INPUT_TYPE_SELECT, "Option", "The option.", true, null, null, MY[DATASET_OPTIONS]);
this.inputs.fields['optionID'] = new s('optionID', INPUT_TYPE_NUMBER, "Option", "Option");
this.inputs.fields['optionAmount'] = new s('optionAmount', INPUT_TYPE_CURRENCY, "Rent (taxable)");
this.inputs.fields['optionTax'] = new s('optionTax', INPUT_TYPE_CURRENCY, "Rent Tax");
this.inputs.fields['summary'] = new s('summary', this.getSummary, "Quote Summary", "", false, v.isAlpha);
this.inputs.fields['summary'].noEditRender = true;
this.inputs.fields['summary'].readonly = true;
this.inputs.fields['summary'].formatter = this.getSummary;
this.inputs.fields['summary'].sortable = false;
// Filter
this.oConfig.oFilter['quoteID'] = '==MY[DATASET_QUOTES].getDatasetId()';
this.oConfig.oFilter['optionID'] = {fn: MY[DATASET_PROPERTY].isOptionIdOnList, arg: {fields: ['propertyID', 'optionID']}};
this.viewList = ["ID","isIncluded","summary"];
msg('Quotes('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_OPTION] = function initOption() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
//this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_NUMBER, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['ID'].sortable = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "Option Name", true);
this.inputs.fields['optionTypeID'] = new s('optionTypeID', INPUT_TYPE_SELECT, "Option Type", "the type of option.", true, null, null, MY[DATASET_OPTIONTYPE]);
this.inputs.fields['abbreviation'] = new s('abbreviation', INPUT_TYPE_TEXT, "ABBR", "Option Abbreviation", true);
this.inputs.fields['includeText'] = new s('includeText', INPUT_TYPE_TEXT, "Include Text", "What to display to the user when this option is included");
this.inputs.fields['excludeText'] = new s('excludeText', INPUT_TYPE_TEXT, "Exclude Text", "What to display to the user when this option is NOT included");
this.viewList = ['ID','name', 'abbreviation','optionTypeID','includeText', 'excludeText'];
msg('Option('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_OPTIONTYPE] = function initOptionType() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
//this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_NUMBER, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = false;
this.inputs.fields['ID'].sortable = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "Option Name", true);
this.viewList = ['ID','name'];
msg('OptionType('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_HOMEAUTOMATION] = function initHomeautomation(argArray) {
msg('fnInit:'+this.datasetName);
var aPeriodMode = new Array("Drift to Occupied", "Drift to this", "Don't drift");
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_CREATENEW;
this.renderSelectsList = [DATASET_PROPERTY];
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].hidden = true;
this.inputs.fields['userID'] = new s('userID', INPUT_TYPE_SELECT, "UserID", "Which user is this for.", true);
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "Property", "Choose the property for this Home Automation.", true, null, null, MY[DATASET_PROPERTY]);
//this.inputs.fields['orderID'] = new s('orderID', INPUT_TYPE_SELECT, "Order", "The specific reservation for this automation data", true, null, null, MY[DATASET_ORDER]);
this.inputs.fields['temperatureIsInC'] = new s('temperatureIsInC', INPUT_TYPE_SELECT, "Temperature Scale", "The temperature scale that you wish to specify your numbers in", true, null, null, new Array("Fahrenheit", "Celsius/Centigrade"));
this.inputs.fields['temperatureIsInC'].readonly = true;
this.inputs.fields['turnOnBeforeArrivalMins'] = new s('turnOnBeforeArrivalMins', INPUT_TYPE_NUMBER, "Set to Occupied Before Arrival Time (mins)", "Number of minutes before the scheduled arrival time to set to Occupied mode. This would allow you to ensure that the home is at the desired temperature in time for arrival.", true);
this.inputs.fields['turnOffAfterDepartureMins'] = new s('turnOffAfterDepartureMins', INPUT_TYPE_NUMBER, "Set to Unoccupied After Departure Time (mins)", "Number of minutes after the scheduled departure time to set to Unoccupied mode. This would allow you to leave the settings as occupied for your cleaners.", true);
this.inputs.fields['skipUnoccupiedGapDays'] = new s('skipUnoccupiedGapDays', INPUT_TYPE_NUMBER, "Days between reservations to stay occupied", "When you only have a few days between reservations you may want to leave the home in the Occupied mode. The number you put here determines the maximum gap size in which to stay in Occupied mode. Examples: Set it to zero to change state after every reservation (the Before and After Departure Time settings will then apply). Set it to 1 to stay in Occupied mode if there's just one day between reservations.", true);
this.inputs.fields['minCool'] = new s('minCool', INPUT_TYPE_TEMPERATURE, "Minimum Cooling Temperature", "This is the minimum value that the cooling temperature should be set to - whether occupied or unoccupied. The cooling setpoint will be reset to this value if an attempt is made to cool lower.", true);
this.inputs.fields['maxHeat'] = new s('maxHeat', INPUT_TYPE_TEMPERATURE, "Maximum Heating Temperature", "This is the maximum value that the heating temperature should be set to - whether occupied or unoccupied. The heating setpoint will be reset to this value if an attempt is made to heat higher.", true);
this.inputs.fields['occupiedTargetHeat'] = new s('occupiedTargetHeat', INPUT_TYPE_TEMPERATURE, "Target Occupied Heating", "When Occupied, this is the temperature that you'd like the home to be heated to by default. If the Drift Period is set then when the heating setpoint is set to a higher value then the heating setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached.", true);
this.inputs.fields['occupiedTargetCool'] = new s('occupiedTargetCool', INPUT_TYPE_TEMPERATURE, "Target Occupied Cooling", "When Occupied, this is the temperature that you'd like the home to be cooled to by default. If the Drift Period is set then when the cooling setpoint is set to a lower value then the cooling setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached.", true);
//this.inputs.fields['period1'] = new s('period1', renderPeriodInput, "Occupied Away Period 1", '', false );
//this.inputs.fields['period2'] = new s('period2', renderPeriodInput, "Occupied Away Period 2", '', false );
this.inputs.fields['period1TimeStart'] = new s('period1TimeStart', INPUT_TYPE_TIME, "Start Time", '', false );
this.inputs.fields['period1TimeEnd'] = new s('period1TimeEnd', INPUT_TYPE_TIME, "End Time", '', false );
this.inputs.fields['period1HeatTo'] = new s('period1HeatTo', INPUT_TYPE_TEMPERATUREOROFFSET, "HeatTo", '', false );
this.inputs.fields['period1CoolTo'] = new s('period1CoolTo', INPUT_TYPE_TEMPERATUREOROFFSET, "CoolTo", '', false );
this.inputs.fields['period1Mode'] = new s('period1Mode', INPUT_TYPE_SELECT, "Mode", '', false, null, null, aPeriodMode );
this.inputs.fields['period2TimeStart'] = new s('period2TimeStart', INPUT_TYPE_TIME, "Start Time", '', false );
this.inputs.fields['period2TimeEnd'] = new s('period2TimeEnd', INPUT_TYPE_TIME, "End Time", '', false );
this.inputs.fields['period2HeatTo'] = new s('period2HeatTo', INPUT_TYPE_TEMPERATUREOROFFSET, "HeatTo", '', false );
this.inputs.fields['period2CoolTo'] = new s('period2CoolTo', INPUT_TYPE_TEMPERATUREOROFFSET, "CoolTo", '', false );
this.inputs.fields['period2Mode'] = new s('period2Mode', INPUT_TYPE_SELECT, "Mode", '', false, null, null, aPeriodMode );
this.inputs.fields['period3TimeStart'] = new s('period3TimeStart', INPUT_TYPE_TIME, "Start Time", '', false );
this.inputs.fields['period3TimeEnd'] = new s('period3TimeEnd', INPUT_TYPE_TIME, "End Time", '', false );
this.inputs.fields['period3HeatTo'] = new s('period3HeatTo', INPUT_TYPE_TEMPERATUREOROFFSET, "HeatTo", '', false );
this.inputs.fields['period3CoolTo'] = new s('period3CoolTo', INPUT_TYPE_TEMPERATUREOROFFSET, "CoolTo", '', false );
this.inputs.fields['period3Mode'] = new s('period3Mode', INPUT_TYPE_SELECT, "Mode", '', false, null, null, aPeriodMode );
this.inputs.fields['period4TimeStart'] = new s('period4TimeStart', INPUT_TYPE_TIME, "Start Time", '', false );
this.inputs.fields['period4TimeEnd'] = new s('period4TimeEnd', INPUT_TYPE_TIME, "End Time", '', false );
this.inputs.fields['period4HeatTo'] = new s('period4HeatTo', INPUT_TYPE_TEMPERATUREOROFFSET, "HeatTo", '', false );
this.inputs.fields['period4CoolTo'] = new s('period4CoolTo', INPUT_TYPE_TEMPERATUREOROFFSET, "CoolTo", '', false );
this.inputs.fields['period4Mode'] = new s('period4Mode', INPUT_TYPE_SELECT, "Mode", '', false, null, null, aPeriodMode );
this.inputs.fields['unoccupiedTargetHeat'] = new s('unoccupiedTargetHeat', INPUT_TYPE_TEMPERATURE, "Target Unoccupied Heating", "When Unoccupied, this is the temperature that you'd like the home to be heated to by default. If the Drift Period is set then when the heating setpoint is set to a higher value then the heating setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached.", true);
this.inputs.fields['unoccupiedTargetCool'] = new s('unoccupiedTargetCool', INPUT_TYPE_TEMPERATURE, "Target Unoccupied Cooling", "When Unoccupied, this is the temperature that you'd like the home to be cooled to by default. If the Drift Period is set then when the cooling setpoint is set to a lower value then the cooling setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached.", true);
//this.inputs.fields['driftToTargetMins'] = new s('driftToTargetMins', INPUT_TYPE_NUMBER, "Drift Period to return to Target Temperature (mins)", "When this is non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by 1 degree every period set by this number. Examples If the Drift Period is set to 60 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes", true);
this.inputs.fields['occupiedDriftPeriod'] = new s('occupiedDriftPeriod', INPUT_TYPE_NUMBER, "Occupied Drift Period (mins) to change temp towards target", "When occupied and this is non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by this number. Examples If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes", true);
this.inputs.fields['unoccupiedDriftPeriod'] = new s('unoccupiedDriftPeriod', INPUT_TYPE_NUMBER, "Unoccupied Drift Period (mins) to change temp towards target", "When occupied and this is non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by this number. Examples If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes", true);
this.inputs.fields['occupiedDriftPercent'] = new s('occupiedDriftPercent', INPUT_TYPE_NUMBER, "Occupied Drift Percent when changing temp towards target", "When unoccupied and this is non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by this number. Examples If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes", true);
this.inputs.fields['unoccupiedDriftPercent'] = new s('unoccupiedDriftPercent', INPUT_TYPE_NUMBER, "Unoccupied Drift Percent when changing temp towards target", "When unoccupied and this is non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by this number. Examples If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes", true);
this.inputs.fields['switchToCoolOffset'] = new s('switchToCoolOffset', INPUT_TYPE_TEMPERATURE, "Switch to Cooling (Temp Offset)", "If the temperature reaches this many degrees above the current Target Cooling setting then the system will switch to Cooling (does not affect any temperature settings).", true);
this.inputs.fields['switchToHeatOffset'] = new s('switchToHeatOffset', INPUT_TYPE_TEMPERATURE, "Switch To Heating (Temp Offset)", "If the temperature reaches this many degrees below the current Target Heating setting then the system will switch to Heating (does not affect any temperature settings).", true);
this.inputs.fields['historyUrl'] = new s('historyUrl', INPUT_TYPE_URL, "URL to history data", "Enter the full URL to the history file.");
this.inputs.fields['username'] = new s('username', INPUT_TYPE_TEXT, "Login Username", "To read the temperature history, please enter the username (if any) required to gain access to the History URL.", false);
this.inputs.fields['password'] = new s('password', INPUT_TYPE_PASSWORD, "Login Password", "To read the temperature history, please enter the password (if any) required to gain access to the History URL.", false);
//this.inputs.fields['uploadTimestamp'] = new s('uploadTimestamp', INPUT_TYPE_TIMESTAMP, "Last Upload Date", "The last time that temperature data was uploaded from the home.");
//this.inputs.fields['uploadTimestamp'].readonly = true;
this.inputs.fields['uploadDatetime'] = new s('uploadDatetime', INPUT_TYPE_DATETIME, "Last Upload Date", "The last time that temperature data was uploaded from the home.");
this.inputs.fields['uploadDatetime'].readonly = true;
var beforeAfterStyle = {width:'2.5em'};
var temperatureStyle = {width:'2.0em'};
var timeStyle = {width:'3.5em'};
var datetimeStyle = {width:'15em'};
var driftStyle = {width:'2em'};
var modeStyle = {width:'10em'};
var urlStyle = {width:'20em'};
var usernamePasswordStyle = {width:'6em'};
var periodTimeHelp = "When the home is occupied these Periods can be used to override the default temperature settings. Define the start and end times as well as the new temperatures and drift mode for this period. Use a '+' or '-' in front of the temperature to indicate an offset from the Target Temperature Use the 24hour clock notation hh:mm for times (eg. 18:15 for 6:15 pm)";
var periodSettingsHelp = " After the period has finished, temperatures will go back to the normal Occupied values. NOTES: The temperatures are changed once at the beginning of each new Period - so if the guests are in the home and manually change the temperature settings then that will override the temperatures defined in this Period until another period begins.";
periodSettingsHelp += " Use the drift mode to specify what happens during the mode if the temperatures are changed.";
periodSettingsHelp += " A Temperature left blank or zero means use the current target occupied temperature - remember that each reservation can override that value so don't rely on it staying the same as displayed above.";
periodSettingsHelp += " Examples:Set the temperature to '+3' to set the temperature to 3 degrees above the Target temperature. The target temperature will be taken from the reservation first and then the default set here for this property.";
var periodHelp = periodTimeHelp + periodSettingsHelp;
this.inputs.editList = [
'propertyID', 'temperatureIsInC',
{
label: 'Turn on in advance of and delay after reservation',
help: "Number of minutes before the scheduled arrival time/after the scheduled departure time to set to Occupied/Unoccupied mode. This would allow you to ensure that the home is at the desired temperature in time for arrival or will stay occupied after departure for your cleaning crew.",
fields: [
{field:'turnOnBeforeArrivalMins', preText: '', postText: "mins before Arrival", style: beforeAfterStyle},
{field:'turnOffAfterDepartureMins', preText: ', ', postText: "mins after Departure", style: beforeAfterStyle}
]
},
'skipUnoccupiedGapDays',
{
label: 'Min Cool Temp/Max Heat Temp',
help: "This is the minimum/maximum value that the cooling/heating temperature should be set to - whether occupied or unoccupied. The cooling/heating setpoint will be reset to this value if an attempt is made to cool lower/heat higher than this.",
fields: [
{field:'minCool', preText: 'Cool ', postText: "F", style: temperatureStyle},
{field:'maxHeat', preText: ', Heat ', postText: "F", style: temperatureStyle}
]
},
{
label: 'Target Unoccupied Cooling/Heating',
help: "When Unoccupied, this is the temperature that you'd like the home to be cooled/heated to by default. If the Drift Period is set when the cooling/heating setpoint is set to a lower/higher value than this, then the cooling/heating setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached.",
fields: [
{field:'unoccupiedTargetCool', preText: 'Cool ', postText: "F", style: temperatureStyle},
{field:'unoccupiedTargetHeat', preText: ', Heat ', postText: "F", style: temperatureStyle}
]
},
{
label: 'Target Occupied Cooling/Heating',
help: "When Occupied, this is the temperature that you'd like the home to be cooled/heated to by default. If the Drift Period is set when the cooling/heating setpoint is set to a lower/higher value than this, then the cooling/heating setpoint will be changed by 1 degree each Drift Period towards this temperature until it is reached. NOTEThese are the default values for each reservation but each reservation can override them.",
fields: [
{field:'occupiedTargetCool', preText: 'Cool ', postText: "F", style: temperatureStyle},
{field:'occupiedTargetHeat', preText: ', Heat ', postText: "F", style: temperatureStyle}
]
},
{
label: 'Occupied Period #1',
help: periodHelp,
fields: [
{field:'period1TimeStart', preText: 'Between', postText: "", style: timeStyle},
{field:'period1TimeEnd', preText: ' and ', postText: "", style: timeStyle},
{field:'period1CoolTo', preText: ' set Cool=', postText: "F", style: temperatureStyle},
{field:'period1HeatTo', preText: ' and Heat=', postText: "F", style: temperatureStyle},
{field:'period1Mode', preText: ' and ', postText: "", style: modeStyle}
]
},
{
label: 'Occupied Period #2',
help: periodHelp,
fields: [
{field:'period2TimeStart', preText: 'Between', postText: "", style: timeStyle},
{field:'period2TimeEnd', preText: ' and ', postText: "", style: timeStyle},
{field:'period2CoolTo', preText: ' set Cool=', postText: "F", style: temperatureStyle},
{field:'period2HeatTo', preText: ' and Heat=', postText: "F", style: temperatureStyle},
{field:'period2Mode', preText: ' and ', postText: "", style: modeStyle}
]
},
{
label: 'Occupied Period #3',
help: periodHelp,
fields: [
{field:'period3TimeStart', preText: 'Between', postText: "", style: timeStyle},
{field:'period3TimeEnd', preText: ' and ', postText: "", style: timeStyle},
{field:'period3CoolTo', preText: ' set Cool=', postText: "F", style: temperatureStyle},
{field:'period3HeatTo', preText: ' and Heat=', postText: "F", style: temperatureStyle},
{field:'period3Mode', preText: ' and ', postText: "", style: modeStyle}
]
},
{
label: 'Occupied Period #4',
help: periodHelp,
fields: [
{field:'period4TimeStart', preText: 'Between', postText: "", style: timeStyle},
{field:'period4TimeEnd', preText: ' and ', postText: "", style: timeStyle},
{field:'period4CoolTo', preText: ' set Cool=', postText: "F", style: temperatureStyle},
{field:'period4HeatTo', preText: ' and Heat=', postText: "F", style: temperatureStyle},
{field:'period4Mode', preText: ' and ', postText: "", style: modeStyle}
]
},
{
label: 'Switch to Cooling/Heating (temperature offset)',
help: "If the temperature reaches this many degrees below/above the appropriate target Heat/Cool setting (depends on current occupied or unoccupied mode) then the system will switch over to Heating/Cooling (does not affect any temperature settings).",
fields: [
{field:'switchToCoolOffset', preText: 'Cool ', postText: "F", style: temperatureStyle},
{field:'switchToHeatOffset', preText: ', Heat ', postText: "F", style: temperatureStyle}
]
},
//'driftToTargetMins',
{
label: 'Occupied Drift',
help: "When occupied and these values are non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by the Period number. Example If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes",
fields: [
{field:'occupiedDriftPeriod', preText: 'Every ', postText: "mins", style: driftStyle},
{field:'occupiedDriftPercent', preText: ' move to target by ', postText: "%", style: driftStyle}
]
},
{
label: 'Unoccupied Drift',
help: "When unoccupied and these values are non-zero AND the current heating setpoint is above the Target Heating Temperature or the current cooling setpoint is below the Target Cooling Temperature, then the appropriate setpoint will be gradually changed back to the Target Temperature by the % of the difference set in the % change amount (at least 1 degree) every period set by the Period number. Example If the Drift Period is set to 60mins with the % to 10 and the heating setpoint is 80 degrees and the Target Heating temperature is 78 then the heating setpoint will be set to 79 after 60 minutes and then to 78 in another 60 minutes",
fields: [
{field:'unoccupiedDriftPeriod', preText: 'Every ', postText: "mins", style: driftStyle},
{field:'unoccupiedDriftPercent', preText: ' move to target by ', postText: "%", style: driftStyle}
]
},
{
label: this.inputs.fields['historyUrl'].label,
help: this.inputs.fields['historyUrl'].help,
fields: [
{field:'historyUrl', style: urlStyle},
]
},
//'historyUrl',
{
label: 'History Login Details',
help: "To read the temperature history, please enter the username/password (if any) required to gain access to the History URL.",
fields: [
{field:'username', preText: 'Username', postText: "", style: usernamePasswordStyle},
{field:'password', preText: ', Password', postText: "", style: usernamePasswordStyle}
]
},
//'username', 'password',
{
label: this.inputs.fields['uploadDatetime'].label,
help: this.inputs.fields['uploadDatetime'].help,
fields: [
{field:'uploadDatetime', style: datetimeStyle},
]
}
];
this.inputs.fieldDefaults = {
ID: 0,
temperatureIsInC: 0,
turnOnBeforeArrivalMins: 120,
turnOffAfterDepartureMins: 0,
skipUnoccupiedGapDays: 0,
minCool: 74,
maxHeat: 78,
occupiedTargetHeat: 78,
occupiedTargetCool: 78,
unoccupiedTargetHeat: 55,
unoccupiedTargetCool: 90,
//driftToTargetMins: 60,
switchToCoolOffset: 5,
switchToHeatOffset: 5,
uploadTimestamp: 0,
occupiedDriftPeriod: 0,
occupiedDriftPercent: 0,
unoccupiedDriftPeriod: 0,
unoccupiedDriftPercent: 0
}
/*
this._getDatsetId = function(oElInfo, doUpdate) {
msg("this._getDatsetId(), doUpdate="+doUpdate);
if (typeof(doUpdate) == 'undefined') doUpdate = false;
var ret = this.currentDatasetId;
if(typeof(oElInfo)!='object') {
msg("this._getDatsetId() - no elementInfo");
} else {
switch(oElInfo.datasetName) {
case(DATASET_PROPERTY):
// Lookup the HA ID for this property ID
msg("this._getDatsetId() - getting localID for "+DATASET_PROPERTY+", value="+oElInfo.value);
var localID = this.get(oElInfo.value, 'ID', 'propertyID');
if(localID.length>0) ret = localID;
else ret = 0;
// Update the othe dataset as needed
if(doUpdate) {
msg("this._getDatsetId() - getting localID for "+DATASET_PROPERTY+", doing update to ="+oElInfo.value);
MY[oElInfo.datasetName].setDatasetId(oElInfo.value);
} else {
msg("this._getDatsetId() - getting localID for "+DATASET_PROPERTY+", NOT doing update to ="+oElInfo.value);
}
break;
default:
}
}
msg("this._getDatsetId() returning "+ret);
return ret;
}
*/
this.preRender = function(idValue, elContent){
msg('Home Automation preRender('+idValue+', '+elContent.id+'), datsetName=' + this.datasetName);
//popupInfo("AUTO prerender()");
var elContentId;
if(elContent) {
elContentId = elContent.id;
}
var propertyId = MY[DATASET_PROPERTY].currentDatasetIdValue;
if(typeof(idValue)=='undefined' || idValue==null || idValue==0) {
// Load the value based upon the propertyID
if (propertyId) {
idValue = this.get(propertyId, 'ID', 'propertyID');
msg('', this.datasetName + ":: preRender() finding ID for propertyId="+propertyId+' returned '+idValue);
if (typeof(idValue) == 'undefined' || idValue == null || idValue == 0) {
// Create a new entry in the DB for this
idValue = 0;
this.append(idValue, this.inputs.fieldDefaults);
}
}
}
if(typeof(idValue)=='undefined' || idValue==null) idValue = 0;
this.inputs.selectField = DATASET_PROPERTY; // Use this dataset's select field
this.inputs.fields['userID'].inputType = INPUT_TYPE_HIDDEN;
this.inputs.fields['propertyID'].inputType = INPUT_TYPE_HIDDEN;
//this.inputs.fields['orderID'].inputType = INPUT_TYPE_HIDDEN;
//popup('', "preRender() idValue="+idValue);
this.setByIdField( idValue, 'userID', gUserId);
this.setByIdField( idValue, 'propertyID', propertyId);
//this.setByIdField( idValue, 'orderID', 0);
//popup('', "preRender() DONE with idValue="+idValue);
this.dataValue = this.currentDatasetIdValue = idValue;
if (propertyId && typeof(elContentId)!='undefined') {
var argArray = this.renderInfo[elContentId]['argArray'];
msg('renderSetupPropertyHomeAutomationContent() - about to get username...');
var username = MY[DATASET_USER].get(0, 'email');
msg('renderSetupPropertyHomeAutomationContent() - about to get token...');
var token = MY[DATASET_USER].get(0, 'token');
msg('renderSetupPropertyHomeAutomationContent() - username = ' + username);
argArray['sIntroHtml'] = '
'
+ '
When setting up your Vera unit to access this account information, use the following:
';
}
*/
}
msg('Utilities Data('+this.datasetName+') - DONE');
return true;
}
function renderPeriodInput(dataObject, oInput) {
var input = oInput.name;
var dataRowIndex = dataObject.dataRowIndex;
var datasetRowIndex = dataObject.datasetRowIndex;
var displayRowIndex = dataObject.displayRowIndex;
var ret = '';
this.inputs = dataObject.inputs;
var idField = this.inputs.uniqueField;
if(typeof(dataObject.args)=='undefined') var dataObjectIndex = dataObject.datasetName;
else var dataObjectIndex = dataObject.args.what;
msg('renderPeriodInput('+dataObjectIndex+', '+datasetRowIndex+', '+input+', '+idField+')');
var dataArrayRow = MY[dataObjectIndex].getRow(datasetRowIndex);
msg('dataArrayRow:: '+serializeArray(dataArrayRow));
// Get all the values set up
var inputTimeStartField = oInput.name+'TimeStart';
var inputTimeEndField = oInput.name+'TimeEnd';
var inputHeatToField = oInput.name+'HeatTo';
var inputCoolToField = oInput.name+'CoolTo';
if(typeof(dataArrayRow) != 'undefined') {
msg('dataRow:: '+serializeArray(dataArrayRow));
var idValue = dataArrayRow[idField];
var inputTimeStartValue = typeof(dataArrayRow[inputTimeStartField])=='undefined' ? null : dataArrayRow[inputTimeStartField];
var inputTimeEndValue = typeof(dataArrayRow[inputTimeEndField])=='undefined' ? null : dataArrayRow[inputTimeEndField];
var inputHeatToValue = typeof(dataArrayRow[inputHeatToField])=='undefined' ? null : dataArrayRow[inputHeatToField];
var inputCoolToValue = typeof(dataArrayRow[inputCoolToField])=='undefined' ? null : dataArrayRow[inputCoolToField];
msg('renderPeriodInput datarow is in data array '+datasetRowIndex+': ('+idValue+'):'+inputTimeStartValue+'/'+inputTimeEndValue+'/'+inputHeatToValue+'/'+inputCoolToValue);
} else {
msg('renderContactTelephoneType datarow is NOT in data array '+datasetRowIndex);
var idValue = '0';
var inputTimeStartValue = '';
var inputTimeEndValue = '';
var inputHeatToValue = '';
var inputCoolToValue = '';
}
var s = MVRZ.util.setInputDef;
// Create the time start input
var oInputDef = new s(inputTimeStartField, INPUT_TYPE_TIME, oInput.label, "", oInput.isRequired);
oInputDef.style.width="40px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputTimeStartField);
var oInputTimeStart = MVRZ.util.render.input(oInputDef, id, inputTimeStartValue, dataObject);
// Create the time end input
var oInputDef = new s(inputTimeEndField, INPUT_TYPE_TIME, oInput.label, "", oInput.isRequired);
oInputDef.style.width="40px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputTimeEndField);
var oInputTimeEnd = MVRZ.util.render.input(oInputDef, id, inputTimeEndValue, dataObject);
// Create the heat to input
var oInputDef = new s(inputHeatToField, INPUT_TYPE_TEMPERATURE, "Heat", "", oInput.isRequired);
oInputDef.style.width="20px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputHeatToField);
var oInputHeatTo = MVRZ.util.render.input(oInputDef, id, inputHeatToValue, dataObject);
// Create the cool to input
var oInputDef = new s(inputCoolToField, INPUT_TYPE_TEMPERATURE, "Cool", "", oInput.isRequired);
oInputDef.style.width="20px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputCoolToField);
var oInputCoolTo = MVRZ.util.render.input(oInputDef, id, inputCoolToValue, dataObject);
// Now render it
var oContent = document.createElement("div");
oContent.appendChild(oInputTimeStart);
oContent.appendChild(document.createTextNode('to'));
oContent.appendChild(oInputTimeEnd);
oContent.appendChild(document.createTextNode('Heat:'));
oContent.appendChild(oInputHeatTo);
oContent.appendChild(document.createTextNode('F, Cool:'));
oContent.appendChild(oInputCoolTo);
oContent.appendChild(document.createTextNode('F'));
return oContent;
}
MY.fnInit[DATASET_USER_SMTP] = function initUserSmtp(argArray) {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
if (this.datasetName === DATASET_USER_SMTP_LOOKUP) {
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
} else {
//this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_CREATENEW;
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
}
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].hidden = true;
this.inputs.fields['isDisabled'] = new s('isDisabled', INPUT_TYPE_CHECKBOX, "Disable?", "Check this to disable use of this account for sending emails.");
this.inputs.fields['smtpServer'] = new s('smtpServer', INPUT_TYPE_TEXT, "SMTP Host", "The name or IP address of your SMTP mail server (used for sending email).", true);
this.inputs.fields['username'] = new s('username', INPUT_TYPE_TEXT, "Username", "The username or login name used to access your SMTP server", true);
this.inputs.fields['password'] = new s('password', INPUT_TYPE_PASSWORD, "Password", "The password used to access your SMTP server", true);
this.inputs.fields['fromEmail'] = new s('fromEmail', INPUT_TYPE_TEXT, "From Email", "The email address of a valid account at this domain. DEFAULT is your current email address.", false);
this.inputs.fields['useAuth'] = new s('useAuth', INPUT_TYPE_CHECKBOX, "Use Authentication?", "Use Authentication to access this server? This should usually be checked.");
this.inputs.fields['useSecure'] = new s('useSecure', INPUT_TYPE_CHECKBOX, "Use SSL?", "Use the secure SSL protocol to access this server?");
this.inputs.fields['port'] = new s('port', INPUT_TYPE_NUMBER, "Port number", "Enter the port number required if this is not the standard one.");
if(this.datasetName === DATASET_USER_SMTP_LOOKUP) return; // Don't need the rest for this
////this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
this.setDefault = function setDefault(input) {
msg('SMTP preRender setDefault ' + input);
oInput = MVRZ.util.decodeInputId(input);
////MVRZ.util.setInput(input, MY[DATASET_USER_SMTP_LOOKUP].get(0, oInput.input));
var dataValue = MY[DATASET_USER_SMTP_LOOKUP].get(0, oInput.input);
MVRZ.util.render.input(MY[DATASET_USER_SMTP].inputs.fields[oInput.input], input, dataValue, MY[DATASET_USER_SMTP]);
MVRZ.util.remote.saveInput(input, MY[DATASET_USER_SMTP]);
////MVRZ.util.remote.saveDirtyInputs();
}
this.setDefaults = function setDefaults(argArray) {
var elContent = argArray['elContent'];
var elContentId = elContent.id;
var idValue = argArray['idValue'];
if(!idValue) idValue = 0;
msg('SMTP setDefaults ' + DATASET_USER_SMTP+','+idValue+', '+elContent+', elContentId='+elContentId);
var sMsg = '';
var username = MY[DATASET_USER_SMTP].get(0, 'username');
var smtpServer = MY[DATASET_USER_SMTP_LOOKUP].get(0, 'smtpServer');
if ((typeof(username)=='undefined' || username.length == 0)) {
if (typeof(smtpServer) != 'undefined' && smtpServer.length > 0) {
// Update the display when available
////var idValue = MY[DATASET_USER_SMTP].get(0, 'ID');
var sId = MVRZ.util.encodeInputId(DATASET_USER_SMTP, 0, idValue, 'smtpServer');
YAHOO.util.Event.onAvailable(sId, this.setDefault, sId);
var sId = MVRZ.util.encodeInputId(DATASET_USER_SMTP, 0, idValue, 'useAuth');
YAHOO.util.Event.onAvailable(sId, this.setDefault, sId);
var sId = MVRZ.util.encodeInputId(DATASET_USER_SMTP, 0, idValue, 'useSecure');
YAHOO.util.Event.onAvailable(sId, this.setDefault, sId);
var sId = MVRZ.util.encodeInputId(DATASET_USER_SMTP, 0, idValue, 'port');
YAHOO.util.Event.onAvailable(sId, this.setDefault, sId);
var sMsg = "
The standard settings have been pre-filled - just enter your username and password.
";
}
}
if ((typeof(smtpServer) === 'undefined' || smtpServer.length == 0) && (typeof(username)!='undefined' && username.length>0)) {
var sMsg = "
Outgoing SMTP mail is not supported at this domain. Please choose an email address with a domain that supports outgoing SMTP. If you own your own domain then you should be able to do this.
";
}
sHelpHtml = MY[DATASET_USER_SMTP_LOOKUP].get(0, 'help');
if (typeof(sHelpHtml) == 'undefined' || sHelpHtml == null || sHelpHtml.length == 0) {
if (sMsg.length==0)
sHelpHtml = 'Sorry, no directions available for setting up this domain.';
else
sHelpHtml = '';
}
//if(typeof(sHelpHtml)=='undefined' || sHelpHtml == null || !sHelpHtml.length) sHelpHtml = 'Sorry, no directions are available for setting up this domain.';
sHelpHtml = "
Domain Info
" + this.domain.toUpperCase() + "
" + sMsg + sHelpHtml;
MY[DATASET_USER_SMTP].sHelpHtml = sHelpHtml;
setPageHelp(MY[DATASET_USER_SMTP].sHelpHtml, true, DATASET_USER_SMTP);
/*
YAHOO.util.Event.onAvailable(ID_PAGE_HELP,
function(){
msg('SMTP setDefaults calling setPageHelp');
setPageHelp(MY[DATASET_USER_SMTP].sHelpHtml);
}
);
*/
//YAHOO.util.Event.onAvailable(ID_PAGE_HELP, function(sId){document.getElementById(ID_PAGE_HELP).innerHTML='Hello';});
if(typeof(MY[DATASET_USER_SMTP].renderInfo[elContentId])=='undefined') {
msg(this.datasetName+"::fnInit() - no renderInfo at index elContentId="+elContentId);
return;
}
msg('new argArray::' + serializeArray(MY[DATASET_USER_SMTP].renderInfo[elContentId]['argArray']));
}
this.preRender = function(idValue, elContent){
msg('SMTP preRender('+idValue+', '+elContent+')' + this.datasetName);
// Are the server settings already entered - if not then prefill if possible
//if (this.get(0, 'smtpServer').length == 0) {
var fromEmail = this.getFromEmail();
var emailArray = fromEmail.split('@', 2);
var domain = emailArray[1];
this.domain = domain;
if (typeof(domain) == 'undefined' || domain.length == 0)
return true;
// See if this domain exists in the DB and if so, get the settings
var tArgArray = new Object();
tArgArray[GET_DOMAIN] = domain;
if(MY[DATASET_USER_SMTP_LOOKUP].domain !== domain) { // Email domain has changed
MY[DATASET_USER_SMTP_LOOKUP].unload(); // Force re-load in case email address changed
msg('SMTP setDefaults preRender calling setPageHelp');
//setPageHelp('');
}
MY[DATASET_USER_SMTP_LOOKUP].domain = domain; // Save this
if (MY[DATASET_USER_SMTP_LOOKUP].load(tArgArray, this, {elContent: elContent, idValue: idValue}, "setDefaults") == LOAD_STATUS_LOADED) {
msg('SMTP preRender() Calling setDefaults after already loaded');
this.setDefaults({elContent: elContent, idValue: idValue});
}
//}
return true;
}
this.getFromEmail = function getFromEmail() {
var email = MY[DATASET_RESERVATIONSCONTACT].get(0, 'email');
if(typeof(email)=='undefined' || !email.length) email = MY[DATASET_ACCOUNTCONTACT].get(0, 'email');
if(typeof(email)=='undefined' || !email.length) email = MY[DATASET_USER].get(0, 'email');
msg('getFromEmail() = '+email);
this.fromEmail = email;
return email;
}
msg('User Smtp('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_USERS] = function initUsers() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
//this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_NUMBER, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = false;
this.inputs.fields['ID'].sortable = true;
this.inputs.fields['firstName'] = new s('firstName', INPUT_TYPE_TEXT, "First Name", "User's first Name", true);
this.inputs.fields['lastName'] = new s('lastName', INPUT_TYPE_TEXT, "Last Name", "User's last Name", true);
this.inputs.fields['email'] = new s('email', INPUT_TYPE_TEXT, "User Email", "User's login email", true);
this.inputs.fields['email'].sortable = true;
this.inputs.fields['lastTouchDateTime'] = new s('lastTouchDateTime', INPUT_TYPE_DATETIME, "Last Touched", "User's last access date-time");
this.inputs.fields['lastTouchDateTime'].readonly = true;
this.inputs.fields['lastTouchDateTime'].sortable = true;
this.inputs.fields['isActive'] = new s('isActive', INPUT_TYPE_CHECKBOX, "Account Active?", "Is the account active");
this.inputs.fields['isActive'].sortable = true;
this.inputs.fields['planID'] = new s('planID', INPUT_TYPE_NUMBER, "PlanID", "Plan Number");
this.inputs.fields['planID'].sortable = true;
this.inputs.fields['sourceID'] = new s('sourceID', INPUT_TYPE_NUMBER, "UPD Source ID", "Up-to-date SourceID");
this.inputs.fields['sourceID'].sortable = true;
this.inputs.fields['planExpireDate'] = new s('planExpireDate', INPUT_TYPE_DATE, "Plan Expires", "Plan Expiration Date");
this.inputs.fields['planExpireDate'].sortable = true;
this.viewList = ['ID','firstName', 'lastName','email','isActive', 'planID', 'sourceID', 'planExpireDate', 'lastTouchDateTime'];
////this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
//this.preload = preload;
msg('Users('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_EXCHANGE] = function initExchange() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_COUNTRY] = function initCountry() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_REGION] = function initRegion() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_CITY] = function initCity() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_ACCOUNTCONTACT] = function initAccountContact(argArray) {
this.contactType = CONTACT_TYPE_ACCOUNT;
this.noFirstIfZero = true;
this.fnInitBase = MY.fnInit[DATASET_CONTACT];
return this.fnInitBase(argArray);
}
MY.fnInit[DATASET_RESERVATIONSCONTACT] = function initReservationsContact(argArray) {
this.contactType = CONTACT_TYPE_RESERVATIONS;
this.noFirstIfZero = true;
this.fnInitBase = MY.fnInit[DATASET_CONTACT];
return this.fnInitBase(argArray);
}
MY.fnInit[DATASET_TRAVELERCONTACT] = function initTravelerContact(argArray) {
this.contactType = CONTACT_TYPE_GUEST;
this.noFirstIfZero = false;
this.fnInitBase = MY.fnInit[DATASET_CONTACT];
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectOptionLabelField = function selectOptionLabelField(datasetData, index) {
var ret = datasetData[index]['lastName'] + ', ' + datasetData[index]['firstName'] + ' [' + index + ']';
return ret;
}
return this.fnInitBase(argArray);
}
MY.fnInit[DATASET_CONTACT] = function initContact(argArray) {
if(typeof(this.contactType)=='undefined') {
this.contactType = CONTACT_TYPE_ACCOUNT;
}
var type = this.contactType;
msg('fnInit:'+this.datasetName+'/'+type);
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.ignoreRemoteIdField = false;
this.inputs.fields['ID'] = new s('ID', "id");
// Rest of the input are filled a preRender time as they depend on the type
////this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
this.preRender = function() {
msg('Contact preRender '+this.datasetName);
//this.contactType = this.get(this.dataValue, 'contactType');
/*
var reservationsContactID = MY[DATASET_USER].get(0,'reservationsContactID','');
msg('Contact preRender():'+this.dataValue+'//'+reservationsContactID);
if(this.dataValue == reservationsContactID) this.type = CONTACT_TYPE_RESERVATIONS;
else this.type = CONTACT_TYPE_ACCOUNT;
*/
// Define the inputs
this.viewList = new Array("ID");
this.viewList.push("firstName");
if(this.contactType == CONTACT_TYPE_RESERVATIONS) {
this.inputs.fields['firstName'] = new s('firstName', INPUT_TYPE_TEXT, "Reservations Name", "What to display to guests when referring to you/your properties (in conjunction with any company name in brackets). The name will be displayed for contact info on the Mini-site and in emails. Eg. 'Reservations' or 'Jim\'s Place'", false, v.isAlpha);
} else {
this.inputs.fields['firstName'] = new s('firstName', INPUT_TYPE_TEXT, "First Name", "Your first Name", false, v.isAlpha);
this.inputs.fields['lastName'] = new s('lastName', INPUT_TYPE_TEXT, "Last Name", "Your last Name", false, v.isAlpha);
this.viewList.push("lastName");
}
this.inputs.fields['email'] = new s('email', INPUT_TYPE_TEXT, "Email", "Email address", false);
if (this.contactType != CONTACT_TYPE_RESERVATIONS && this.contactType != CONTACT_TYPE_ACCOUNT) {
this.inputs.fields['customText2'] = new s('altEmail', INPUT_TYPE_TEXT, "Alternate Email", "An additional email address", false);
}
this.inputs.fields['companyName'] = new s('companyName', INPUT_TYPE_TEXT, "Company Name", "Your Company Name", false);
this.inputs.fields['url'] = new s('url', INPUT_TYPE_TEXT, "Website", "Your website, if any", false, v.isUrl);
this.inputs.fields['addressLine1'] = new s('addressLine1', INPUT_TYPE_TEXT, "Street Address", "The first line of your address", false);
this.inputs.fields['addressLine2'] = new s('addressLine2', INPUT_TYPE_TEXT, "Street Address Line 2", "The second line of your address (if any)", false);
this.inputs.fields['city'] = new s('city', INPUT_TYPE_TEXT, "City", "This is your postal city", false);
this.inputs.fields['state'] = new s('state', INPUT_TYPE_TEXT, "State / Region", "The state or region within your country", false);
this.inputs.fields['zip'] = new s('zip', INPUT_TYPE_TEXT, "Zip / Postal Code", "Enter the postal / zip code identifier here");
////this.inputs.fields['countryID'] = new s('countryID', "select", "Country", "Select the country from the list.", false, null, null, MY[DATASET_SELECTCOUNTRIES].options );
this.inputs.fields['countryID'] = new s('countryID', INPUT_TYPE_SELECT, "Country", "Select the country from the list.", false, null, null, MY[DATASET_COUNTRY] );
// Telephone numbers
this.inputs.fields['telephone1'] = new s('telephone1', renderContactTelephoneInput, "Telephone 1", '', false, v.isPhone );
this.inputs.fields['telephone2'] = new s('telephone2', renderContactTelephoneInput, "Telephone 2", '', false, v.isPhone );
this.inputs.fields['telephone3'] = new s('telephone3', renderContactTelephoneInput, "Telephone 3", '', false, v.isPhone );
this.inputs.fields['telephone4'] = new s('telephone4', renderContactTelephoneInput, "Telephone 4", '', false, v.isPhone );
this.inputs.fields['telephone1TypeID'] = new s('telephone1TypeID');
this.inputs.fields['telephone1TypeID'].noEditRender = true;
this.inputs.fields['telephone2TypeID'] = new s('telephone2TypeID');
this.inputs.fields['telephone2TypeID'].noEditRender = true;
this.inputs.fields['telephone3TypeID'] = new s('telephone3TypeID');
this.inputs.fields['telephone3TypeID'].noEditRender = true;
this.inputs.fields['telephone4TypeID'] = new s('telephone4TypeID');
this.inputs.fields['telephone4TypeID'].noEditRender = true;
this.viewList.push("email");
if(this.contactType == CONTACT_TYPE_GUEST) {
this.inputs.fields['customBool1'] = new s('badGuest', INPUT_TYPE_CHECKBOX, "Bad Guest?", "If this a bad guest?", false);
//this.inputs.fields['customBool1'] = new s('badGuest', INPUT_TYPE_TEXT, "Bad Guest?", "If this a bad guest?", false);
this.inputs.fields['customBool1'].formatter = "checkbox";
this.inputs.fields['customBool1'].parser = MVRZ.util.parser.checkbox;
//this.inputs.fields['customBool1'].parser = YAHOO.util.DataSource.parseBoolean
this.viewList.push("customBool1");
}
//if(this.contactType == CONTACT_TYPE_ACCOUNT) {
switch(this.contactType) {
case(CONTACT_TYPE_ACCOUNT):
this.inputs.fields['addressLine1'].isRequired = true;
this.inputs.fields['city'].isRequired = true;
this.inputs.fields['state'].isRequired = true;
this.inputs.fields['zip'].isRequired = true;
this.inputs.fields['countryID'].isRequired = true;
this.inputs.fields['telephone1'].isRequired = true;
this.inputs.fields['firstName'].isRequired = true;
this.inputs.fields['lastName'].isRequired = true;
// No break
case(CONTACT_TYPE_GUEST):
this.inputs.fields['email'].isRequired = true;
// No break
case(CONTACT_TYPE_RESERVATIONS):
}
//deliberateError();
msg('Contact preRender viewlist: '+serializeArray(this.viewList));
/*
if(this.contactType == CONTACT_TYPE_RESERVATIONS) {
for(field in this.inputs.fields) {
this.inputs.fields[field].isRequired = false;
}
}
*/
return true;
}
this.getFullName = function getFullName(idValue) {
msg("getFullName("+idValue+"):"+this.datasetName);
if(typeof(idValue)!='undefined' && idValue != null) {
var datasetRowIndex = this.getDatasetRowIndex(idValue, 'ID');
var fName = this.get(datasetRowIndex, "firstName");
var lName = this.get(datasetRowIndex, "lastName");
var val = '';
if(typeof(fName)!='undefined') val = fName;
if(typeof(lName)!='undefined' && lName.length) {
if(val.length) val += " ";
val += lName;
}
} else {
val = "?";
}
if(val.length==0) val = "?";
msg("getFullName() returning " + val);
return val;
}
/*
msg('Contact('+this.datasetName+') - calling set request');
setRequest();
*/
msg('Contact('+this.datasetName+') - DONE');
}
function renderContactTelephoneInput(dataObject, oInput) {
var input = oInput.name;
var dataRowIndex = dataObject.dataRowIndex;
var datasetRowIndex = dataObject.datasetRowIndex;
var displayRowIndex = dataObject.displayRowIndex;
var ret = '';
this.inputs = dataObject.inputs;
var idField = this.inputs.uniqueField;
if(typeof(dataObject.args)=='undefined') var dataObjectIndex = dataObject.datasetName;
else var dataObjectIndex = dataObject.args.what;
msg('renderContactTelephoneInput('+dataObjectIndex+', '+datasetRowIndex+', '+input+', '+idField+')');
//var inputs = gInputs[dataObjectIndex].inputs;
//var dataArrayRow = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA][datasetRowIndex];
var dataArrayRow = MY[dataObjectIndex].getRow(datasetRowIndex);
// Get all the values set up
var inputField = oInput.name;
var inputTypeField = inputField+'TypeID';
if(typeof(dataArrayRow) != 'undefined') {
msg('dataRow:: '+serializeArray(dataArrayRow));
var idValue = dataArrayRow[idField];
var inputDataValue = typeof(dataArrayRow[inputField])=='undefined' ? null : dataArrayRow[inputField];
var inputTypeDataValue = typeof(dataArrayRow[inputTypeField])=='undefined' ? null : dataArrayRow[inputTypeField];
msg('renderContactTelephoneType datarow is in data array '+datasetRowIndex+': ('+idValue+'):'+inputDataValue+'/'+inputTypeDataValue);
} else {
msg('renderContactTelephoneType datarow is NOT in data array '+datasetRowIndex);
var idValue = '0';
var inputDataValue = '';
var inputTypeDataValue = '';
}
var s = MVRZ.util.setInputDef;
// Create the number input
var oInputDef = new s(inputField, INPUT_TYPE_TELEPHONE, oInput.label, "", oInput.isRequired);
oInputDef.style.width="136px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputField);
var oInput = MVRZ.util.render.input(oInputDef, id, inputDataValue, dataObject);
// Create a drop-down telephone type
var oInputTelType = new s(inputTypeField, INPUT_TYPE_SELECT, "Telephone Type", "", false, null, null, MVRZ.util.select.telephoneTypes);
oInputTelType.style.width="60px";
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), inputTypeField);
msg('renderContactTelephoneType set id to '+id);
var oInputType = MVRZ.util.render.input(oInputTelType, id, inputTypeDataValue, dataObject);
// Now render it
var oContent = document.createElement("div");
oContent.appendChild(oInput);
oContent.appendChild(oInputType);
return oContent;
}
function renderContactTelephoneTypeHelp(dataObject, oInput, idField) {
var input = oInput.name;
var dataRowIndex = dataObject.dataRowIndex;
var datasetRowIndex = dataObject.datasetRowIndex;
var displayRowIndex = dataObject.displayRowIndex;
if(typeof(dataObject.args)=='undefined') var dataObjectIndex = dataObject.datasetName;
else var dataObjectIndex = dataObject.args.what;
msg('renderContactTelephoneType('+dataObjectIndex+', '+displayRowIndex+', '+input+', '+idField+')');
this.inputs = dataObject.inputs;
//var inputs = gInputs[dataObjectIndex].inputs;
//var dataArrayRow = MVRZ.data.object[dataObjectIndex][JSON_RESPONSE_INDEX_DATA][datasetRowIndex];
var dataArrayRow = MY[dataObjectIndex].getRow(datasetRowIndex);
var newInput = input+'TypeID';
if(typeof(dataArrayRow) != 'undefined') {
msg('dataRow:: '+serializeArray(dataArrayRow));
var dataValue = typeof(dataArrayRow[newInput])=='undefined' ? null : dataArrayRow[newInput];
var idValue = dataArrayRow[idField];
msg('renderContactTelephoneType datarow is in data array '+datasetRowIndex+': ('+newInput+'):'+dataValue);
} else {
msg('renderContactTelephoneType datarow is NOT in data array '+datasetRowIndex);
var idValue = '0';
var dataValue = '';
}
//var id = datasetRowIndex + ":" + dataObjectIndex + ":" + idValue + ":" +newInput;
var id = MVRZ.util.encodeInputId(dataObjectIndex, datasetRowIndex, (typeof(idValue)=='undefined'?'0':idValue), newInput);
msg('renderContactTelephoneType set id to '+id);
//var id = datasetRowIndex + ":" + idValue + ":" +newInput;
var s = MVRZ.util.setInputDef;
//oInputTelType = new MVRZ.util.setInputDef(newInput, "select", "Telephone Type", "Which telephone number is this", false, null, null, MVRZ.util.select.telephoneTypes);
var oInputTelType = new MVRZ.util.setInputDef(newInput, INPUT_TYPE_SELECT, "Telephone Type", "", false, null, null, MVRZ.util.select.telephoneTypes);
oInputTelType.style.width="60px";
//this.inputs.fields[newInput] = oInputTelType;
var oContent = document.createElement("div");
if(oInput.isRequired) var sRequired = "Required: ";
else var sRequired = "Optional: ";
var oText = document.createTextNode(" " + sRequired + oInputTelType.help);
var oInput = MVRZ.util.render.input(oInputTelType, id, dataValue, dataObject);
oContent.appendChild(oInput);
oContent.appendChild(oText);
return oContent;
}
MY.fnInit[DATASET_STATIONERY] = function initStationery() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Stationery Name", "The name for this stationery - internal use only", true);
this.inputs.fields['name'].sortable = true;
this.inputs.fields['text'] = new s('text', INPUT_TYPE_TEXTAREA, "Stationery text", "The actual text that makes up the stationery", true);
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('Stationery('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_TEMPLATE] = function initTemplate() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Template Name", "The name for this template - internal use only", true);
this.inputs.fields['name'].sortable = true;
this.inputs.fields['subjectText'] = new s('subjectText', INPUT_TYPE_TEXT, "Subject text", "The subject line to use when emailing", true);
this.inputs.fields['stationeryID'] = new s('stationeryID', INPUT_TYPE_SELECT, "Stationery to use", "Choose the stationery to use - select default to use the global one or choose a different one to override it", false, null, null, MY[DATASET_STATIONERY]);
this.inputs.fields['text'] = new s('text', INPUT_TYPE_TEXTAREA, "Template text", "The actual text that makes up the template", true);
this.inputs.fields['text'].style['height'] = "400px";
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('Template('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_SOURCE] = function initSource() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.selectConfig = {zeroSelect: '-- Select --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "The name of this referral source");
this.inputs.fields['name'].sortable = true;
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('Source('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_SOURCEDATA] = function initSourceData() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "sourceID";
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['isEnabled'] = new s('isEnabled', INPUT_TYPE_CHECKBOX, "Enable Auto-sync?", "Check this box to enable synchronization to occur automatically");
this.inputs.fields['isEnabled'].sortable = true;
this.inputs.fields['sourceID'] = new s('sourceID', INPUT_TYPE_TEXT, "Related Advertiser/Source", "The advertiser/Source ID for this login", true);
this.inputs.fields['sourceID'].readonly = true;
this.inputs.fields['username'] = new s('text', INPUT_TYPE_TEXT, "Login/User Name", "What you use as the username to log in to this Advertiser/Source");
this.inputs.fields['password'] = new s('text', INPUT_TYPE_TEXT, "Template text", "What you use for the password when logging in to this Advertiser/Source", true);
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('SourceLogin('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_LISTTYPE] = function initListType() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.zeroSelect = '';
this.inputs.defaultSelectId = 1;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name of the amenity type", "For internal use only", true);
this.inputs.fields['description'] = new s('description', INPUT_TYPE_TEXTAREA, "Description", "For internal use only");
////this.renderForEdit = renderForEdit;
//this.preload = preload;
msg('Amenity Types('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_AMENITIES] = function initAmenities() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_CREATENEW;
this.inputs.allowNew = true;
//this.inputs.newSelect = '-- NEW --';
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {newSelect: '-- NEW --', parentField: 'parentID', sortByFieldName: 'name'};
this.inputs.selectOptionLabelField = function selectOptionLabelField(datasetData, index, datasetObject) {
var parentField = datasetObject.inputs.selectField.selectConfig.parentField;
var parentId = datasetObject.datasetData[index][parentField];
var ret = datasetObject.datasetData[index]['name'];
var depth=0;
while(parentId!=0) {
var datasetRowIndex = datasetObject.getDatasetRowIndex(parentId);
if(datasetRowIndex<0) break;
ret = datasetObject.datasetData[datasetRowIndex]['name'] + ' - ' + ret;
parentId = datasetObject.datasetData[datasetRowIndex][parentField];
depth++;
if(depth>5) break;
}
return ret;
}
this.inputs.listMapping = {id: 'ID', label: 'name', isSearchable: 'isSearchable', isNotSelectable: 'isNotSelectable', parentId: 'parentID', typeId: 'typeID', description: 'description'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name of the amenity", "This will be displayed to refer to the amenity", true);
this.inputs.fields['isSearchable'] = new s('isSearchable', INPUT_TYPE_CHECKBOX, "Is Searchable?", "Check this box to allow this amenity to be used to search on");
this.inputs.fields['isSearchable'].sortable = true;
this.inputs.fields['isSearchable'].formatter = "checkbox";
this.inputs.fields['isSearchable'].parser = MVRZ.util.parser.checkbox;
this.inputs.fields['isNotSelectable'] = new s('isNotSelectable', INPUT_TYPE_CHECKBOX, "Is NOT selectable?", "Check this box if this item is not selectable. Usually this will be because it's a grouping item and its sub-items should be selected instead");
this.inputs.fields['isNotSelectable'].sortable = true;
this.inputs.fields['isNotSelectable'].formatter = "checkbox";
this.inputs.fields['isNotSelectable'].parser = MVRZ.util.parser.checkbox;
this.inputs.fields['parentID'] = new s('parentID', INPUT_TYPE_SELECT, "Parent Amenity", "If this amenity is in a hierarchy then choose the parent amenity here", false, null, null, this);
this.inputs.fields['parentID'].selectConfig = {newSelect: '', zeroSelect: '-- No Parent --', removeCurrentId: true, sortByFieldName: 'name', parentField: 'parentID', label: this.inputs.selectOptionLabelField};
this.inputs.fields['typeID'] = new s('typeID', INPUT_TYPE_SELECT, "Type of Amenity", "Choose how this amenity should be entered", false, null, null, MY[DATASET_LISTTYPE]);
this.inputs.fields['imgSrc'] = new s('imgSrc', INPUT_TYPE_TEXT, "Amenity Image/Symbol name", "Enter the image name found under /images/amenities", false);
this.inputs.fields['description'] = new s('description', INPUT_TYPE_TEXTAREA, "Description", "This explains more about the amenity - this will also be displayed to assist viewers in understanding what this amenity is");
this.viewList = ['ID','name','isSearchable','parentID','typeID'];
////this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
//this.preload = preload;
msg('Amenities('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_RESORT] = function initResort() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_CREATENEW;
this.inputs.allowNew = true;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
//this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.selectField.selectConfig = {zeroSelect: '-- Choose --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name of the amenity", "This will be displayed to refer to the amenity", true);
this.inputs.fields['cityID'] = new s('cityID', INPUT_TYPE_TEXT, "City Located", "The city where this location is", true, null, null, this);
this.inputs.fields['cityID'].selectConfig = {newSelect: '', zeroSelect: '-- Choose City --', removeCurrentId: false, sortByFieldName: 'name'};
this.inputs.fields['imgSrc'] = new s('imgSrc', INPUT_TYPE_TEXT, "Resort Image name", "Enter the image name found under /images/location/{ID}", false);
this.inputs.fields['description'] = new s('description', INPUT_TYPE_TEXTAREA, "Description", "Textual overview/summary/description");
this.inputs.fields['amenitiesList'] = new s('amenitiesList', INPUT_TYPE_LIST, "Amenities", "Select all amenities that apply", false, null, null, MY[DATASET_AMENITIES],null, true);
this.viewList = ['ID','name','cityID'];
//this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
//this.preload = preload;
msg('Resort('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_SEASON] = function initSeason() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Season Name", "The name of this season", true);
this.inputs.fields['name'].readonly = true;
this.inputs.fields['excludeInLists'] = new s('excludeInLists', INPUT_TYPE_CHECKBOX, "Exclude in Lists", "Do not show this in drop-down lists if checked.");
this.inputs.fields['excludeInLists'].sortable = true;
this.inputs.fields['adjustAll'] = new s('text', INPUT_TYPE_TEXT, "??Adjust All??", "??What is this for??");
this.inputs.fields['adjustAnnually'] = new s('text', INPUT_TYPE_TEXT, "??Adjust Annually??", "??What is this for??");
////this.renderForEdit = renderForEdit;
msg('Season('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_SOURCELOGIN] = function initSourceLogin() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['isEnabled'] = new s('isEnabled', INPUT_TYPE_CHECKBOX, "Enable Auto-sync?", "Check this box to enable synchronization to occur automatically");
this.inputs.fields['isEnabled'].sortable = true;
this.inputs.fields['sourceID'] = new s('sourceID', INPUT_TYPE_HIDDEN, "Related Advertiser/Source", "The advertiser/Source ID for this login", true);
this.inputs.fields['sourceID'].readonly = true;
this.inputs.fields['username'] = new s('text', INPUT_TYPE_TEXT, "Login/User Name", "What you use as the username to log in to this Advertiser/Source");
this.inputs.fields['password'] = new s('text', INPUT_TYPE_TEXT, "Password", "What you use for the password when logging in to this Advertiser/Source");
////this.renderForEdit = renderForEdit;
msg('SourceLogin('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_WHENTYPE] = function initWhenType() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "When type name.", true);
this.inputs.fields['name'].sortable = true;
/*
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'ID'};
*/
this.load = function(){
msg('fnInit load():'+this.datasetName);
if(this.isLoaded()) return;
// Set the values
this.append(WHEN_TYPE_ALWAYS, {
name: "Always"
}, "ID");
/*
this.append(WHEN_TYPE_SEASON, {
name: "Season"
}, "ID");
*/
this.setload(LOAD_STATUS_LOADED);
}
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_RATEADJUSTTYPE] = function initRateAdjustType() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "Rate adjustment name.", true);
this.inputs.fields['name'].sortable = true;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'ID'};
this.load = function(){
msg('fnInit load():'+this.datasetName);
if(this.isLoaded()) return;
// Set the values
this.append(RATEADJUST_TYPE_PROMOCODE, {
name: "Promotional Code (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_DISCOUNT_LATEAVAILABILITY, {
name: "Late Availability (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_DISCOUNT_EARLYBOOKING, {
name: "Early Booking (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_DISCOUNT_LONGSTAY, {
name: "Long Stay (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_DISCOUNT_LOWOCCUPANCY, {
name: "Low Occupancy (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_DISCOUNT_REPEATGUEST, {
name: "Repeat Guest (Discount)"
}, "ID");
this.append(RATEADJUST_TYPE_SURCHARGE_HIGHOCCUPANCY, {
name: "High Occupancy (Surcharge)"
}, "ID");
this.append(RATEADJUST_TYPE_SURCHARGE_SHORTSTAY, {
name: "Short Stay (Surcharge)"
}, "ID");
this.setload(LOAD_STATUS_LOADED);
}
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_RATEADJUST] = function initRateAdjust() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.selectConfig = {preLabel: "Choose existing adjustment:", canAddNew: true, addNewLabel: "Add New Adjustment"};
this.inputs.selectField.label = "Choose Rate Adjustment";
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['rateAdjustTypeID'] = new s('rateAdjustTypeID', INPUT_TYPE_SELECT, "Type of Adjustment", "Is this an automatic discount, automatic surcharge or Promotional Code discount?", false, null, null, MY[DATASET_RATEADJUSTTYPE]);
this.inputs.fields['rateAdjustTypeID'].sortable = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "The name for your own use and reference - only displayed to the guest if the Display Name is not set.", true);
this.inputs.fields['name'].sortable = true;
this.inputs.fields['isDisabled'] = new s('isDisabled', INPUT_TYPE_CHECKBOX, "Disable?");
this.inputs.fields['isDisabled'].sortable = true;
this.inputs.fields['startDate'] = new s('startDate', INPUT_TYPE_DATE, "Start Date", "The date of inquiry that this adjustment is valid from (this date is included). This is NOT related to the arrival date, just the date of the request itself.");
this.inputs.fields['endDate'] = new s('endDate', INPUT_TYPE_DATE, "End Date", "The date of inquiry that this adjustment is valid to (this date is included). This is NOT related to the arrival date, just the date of the request itself.");
this.inputs.fields['endDate'].reference = {date: {earliest: function(){return MY[DATASET_RATEADJUST].get(null,'startDate','ID');}}};
this.inputs.fields['updateQuoteExpiration'] = new s('updateQuoteExpiration', INPUT_TYPE_CHECKBOX, "Adjust Quote Expiration?", "Check this box to make the quote expire when this adjustment expires (if it would normally expire at a later date). For example: if your normal quote expiration is in 30 days and a Promo Code expires in 10 days then checking this box will make the quote expire in 10 days instead of 30.");
this.inputs.fields['isNotExclusive'] = new s('isNotExclusive', INPUT_TYPE_CHECKBOX, "Not Exclusive?", "Check the box if this adjustment can be made in addition to other discounts, surcharges and promo codes. If not checked and more than one adjustment applies at the same time then the largest adjustment will be chosen. For Example: If you have a 10% Late Availability and 5% Low Occupancy and neither or just one of these has this checkbox checked then the discount used will be the 10% Late Availability. If both have this checkbox checked then the discount used will be a combined 15% Late Availability+Low Occupancy.");
this.inputs.fields['isNotExclusive'].sortable = true;
this.inputs.fields['displayName'] = new s('displayName', INPUT_TYPE_TEXT, "Display Name", "The name used to display to the guest when this adjustment applies. Make this short, eg (Late Availability, High Occupancy, PROMO:FALL12).
If blank then the Name provided will be used.", false);
this.inputs.fields['displayName'].sortable = true;
this.inputs.fields['displayFootnote'] = new s('displayFootnote', INPUT_TYPE_TEXTAREA, "Display Footnote", "More text used to tell the guest if there are any special restrictions/requirements for the adjustment.", false);
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "For property", "Choose a specific property to apply this to, or apply to all by default.", false, null, null, MY[DATASET_PROPERTY]);
this.inputs.fields['propertyID'].sortable = true;
this.inputs.fields['propertyID'].selectConfig = {zeroSelect: '-- All Properties --'};
this.inputs.fields['amountFixed'] = new s('amountFixed', INPUT_TYPE_NUMBER, "Fixed Amount", "This amount is fixed and not dependent on the actual rate (pre-tax).
NOTE: If both a percentage and fixed amount are specified then the Percentage is used.");
this.inputs.fields['amountPercent'] = new s('amountPercent', INPUT_TYPE_NUMBER, "Percentage Amount", "This amount is a percentage of the total accommodation rate for the whole stay (pre-tax, any options are not included in the adjustment).
NOTE: This is NOT applied to the nightly rate, just to the total NOTE: Any options that are percentages of the rental amount will apply their percentages to the adjusted amount. NOTE: If both a percentage and fixed amount are specified then the Percentage is used.
Example:To apply a 10% discount, set this Percentage Amount to '10' and apply it 'Once per quote'");
this.inputs.fields['triggerAmount'] = new s('triggerAmount', INPUT_TYPE_NUMBER, "Trigger", "Trigger amount", false);
this.inputs.fields['applyTypeID'] = new s('applyTypeID', INPUT_TYPE_SELECT, "How to Apply", "Choose how this adjustment should be applied", false);
this.inputs.fields['applyTypeID'].sortable = true;
this.inputs.fields['whenTypeID'] = new s('whenTypeID', INPUT_TYPE_SELECT, "When to Apply", "Choose when this adjustment should be applied", false, null, null, MY[DATASET_WHENTYPE]);
this.inputs.fields['whenTypeID'].sortable = true;
this.inputs.fields['when'] = new s('when', INPUT_TYPE_TEXT, "When", "What to apply this to.");
this.inputs.fields['when'].sortable = false;
/*
this.handleUpdate = function handleUpdate(oDatatable){
popupInfo('Update '+this.datasetName + ', ')
}
this.tableCfg = {
rowselects: true,
actions: [
{actionType: ACTION_TYPE_BUTTON,
button: {label: "Delete", type: BUTTON_TYPE_TEXT, onclick: {fn: this.handleDatatableAction, action: ACTION_TABLE_DELETE}}
}
]
}
//this.viewList = ['ID', 'hash', 'filename', 'size', 'name', 'description', 'displayInGuestZone', 'propertyID', 'minDaysBeforeArrival', 'minOrderStatus', 'minPaymentStatus'];
this.viewList = ['ID', 'isDisabled', 'name', 'isNotExclusive',
{label: 'Display Text', children:['displayName', 'displayFootnote']},
{label: 'When', help: 'When to apply this.', children: ['whenTypeID', 'when', 'autoAdjustTypeID']},
{label: 'Amount', help: 'Amount to adjust by', children: ['amountFixed', 'amountPercent']}
];
*/
this.inputs.editList =
['ID',
{fieldName: 'rateAdjustTypeID', cfg: {onChange: {datasetName: DATASET_RATEADJUST, fnName:"render"}}},
{},
{fieldName: 'name', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
fnGetCfg: function(refVal) {
if(refVal == RATEADJUST_TYPE_PROMOCODE) {
return {label: 'Promo Code', help: "This is the code that the inquirer needs to enter."};
} else return null;
}
}
},
'isDisabled',
{spacer: "How to apply this"},
'propertyID',
'isNotExclusive',
{fieldName: 'triggerAmount', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
indexList: [
{index: RATEADJUST_TYPE_PROMOCODE, cfg: {inputType: INPUT_TYPE_HIDDEN}},
{index: RATEADJUST_TYPE_DISCOUNT_LATEAVAILABILITY, cfg: {label: "Max days before Arrival", help: "Maximum number of days before arrival. If within this period then the discount is applied."}},
{index: RATEADJUST_TYPE_DISCOUNT_EARLYBOOKING, cfg: {label: "Min days before Arrival", help: "Minimum number of days before arrival. If outside of this period then the discount is applied."}},
{index: RATEADJUST_TYPE_DISCOUNT_LONGSTAY, cfg: {label: "Min days in stay", help: "If the stay is this many days or longer then the discount is applied."}},
{index: RATEADJUST_TYPE_SURCHARGE_SHORTSTAY, cfg: {label: "Max days in stay", help: "If the stay is this many days or shorter then the surcharge is applied."}},
{index: RATEADJUST_TYPE_DISCOUNT_LOWOCCUPANCY, cfg: {label: "Max number of people", help: "If the number of people (Adults+Children) is this number or less then the discount is applied."}},
{index: RATEADJUST_TYPE_SURCHARGE_HIGHOCCUPANCY, cfg: {label: "Min number of people", help: "If the number of people (Adults+Children) is this number or more then the surcharge is applied."}},
{index: RATEADJUST_TYPE_DISCOUNT_REPEATGUEST, cfg: {label: "Max days after last departure", help: "If the number of days after the last departure date is less than or equal to this then the discount is applied.
Leave this blank for it to apply to all previous bookings.
NOTE: The system checks for a previous confirmed, uncanceled booking by a guest with the same email address as the inquirer. If previous bookings buy this inquirer are not in the system then this discount will not be applied automatically."}},
]}
},
{fieldName: 'startDate', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
fnGetCfg: function(refVal) {
if(refVal != RATEADJUST_TYPE_PROMOCODE) {
return {inputType: INPUT_TYPE_HIDDEN};
} else return null;
}
}
},
{fieldName: 'endDate', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
fnGetCfg: function(refVal) {
if(refVal != RATEADJUST_TYPE_PROMOCODE) {
return {inputType: INPUT_TYPE_HIDDEN};
} else {
return;
}
}
}
},
{fieldName: 'updateQuoteExpiration', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
fnGetCfg: function(refVal) {
if(refVal != RATEADJUST_TYPE_PROMOCODE) {
return {inputType: INPUT_TYPE_HIDDEN};
} else {
return;
}
}
}
},
{spacer: "How much to adjust the rate by"},
'amountPercent',
'amountFixed',
{fieldName: 'applyTypeID', dependsOn: {datasetName: this.datasetName, fieldName: 'rateAdjustTypeID',
fnGetCfg: function(refVal) {
var aInputOverride =
[
["Once per quote", APPLY_TYPE_ONCE],
["Per Night", APPLY_TYPE_PERNIGHT],
["Per Occupant", APPLY_TYPE_PEROCCUPANT],
["Per Occupant per Night", APPLY_TYPE_PEROCCUPANTPERNIGHT]
];
switch(parseInt(refVal)) {
case(RATEADJUST_TYPE_DISCOUNT_LOWOCCUPANCY):
aInputOverride.push(["Per Occupant under", APPLY_TYPE_PERUNDEROCCUPANT]);
aInputOverride.push(["Per Occupant under per Night", APPLY_TYPE_PERUNDEROCCUPANTPERNIGHT]);
break;
case(RATEADJUST_TYPE_SURCHARGE_HIGHOCCUPANCY):
aInputOverride.push(["Per Occupant over", APPLY_TYPE_PEROVEROCCUPANT]);
aInputOverride.push(["Per Occupant over per Night", APPLY_TYPE_PEROVEROCCUPANTPERNIGHT]);
break;
case(RATEADJUST_TYPE_DISCOUNT_LONGSTAY):
aInputOverride.push(["Per Night over", APPLY_TYPE_PEROVERNIGHT]);
aInputOverride.push(["Per Night over per Occupant", APPLY_TYPE_PEROVERNIGHTPEROCCUPANT]);
break;
case(RATEADJUST_TYPE_SURCHARGE_SHORTSTAY):
aInputOverride.push(["Per Night under", APPLY_TYPE_PERUNDERNIGHT]);
aInputOverride.push(["Per Night under per Occupant", APPLY_TYPE_PERUNDERNIGHTPEROCCUPANT]);
break;
case(RATEADJUST_TYPE_PROMOCODE):
case(RATEADJUST_TYPE_DISCOUNT_LATEAVAILABILITY):
case(RATEADJUST_TYPE_DISCOUNT_EARLYBOOKING):
case(RATEADJUST_TYPE_DISCOUNT_REPEATGUEST):
case(RATEADJUST_TYPE_DISCOUNT_LATEAVAILABILITY):
case(RATEADJUST_TYPE_DISCOUNT_LATEAVAILABILITY):
default:
}
var oInputOverride = {optionsFunction: aInputOverride};
return oInputOverride;
}
}
},
{spacer: "What is seen by the Inquirer"},
'displayName', 'displayFootnote',
/*
{fieldName: 'whenTypeID', cfg: {onChange: {datasetName: DATASET_RATEADJUST, fnName:"render"}}},
{fieldName: 'when', dependsOn: {datasetName: this.datasetName, fieldName: 'whenTypeID',
indexList: [
{index: WHEN_TYPE_ALWAYS, cfg: {inputType: INPUT_TYPE_HIDDEN}},
{index: WHEN_TYPE_SEASON, cfg: {
inputType: INPUT_TYPE_SELECT,
label: "Choose Season",
help: "If the dates include this season, then the discount is applied to rates in that season. If other seasons are also present then this discount will not apply to those (use another reate adjustment for that).",
optionsFunction: MY[DATASET_SEASON]
}},
]}
},*/
];
this.preRender = function() {
msg('RateAdjust preRender '+this.datasetName);
if(this.getDatasetId()) return true;
return false;
}
msg('RateAdjust('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_ATTACH] = function initAttach() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['replace'] = new s('replace', INPUT_TYPE_UPLOAD, "Replace", "", true);
this.inputs.fields['replace'].sortable = false;
this.inputs.fields['hash'] = new s('hash', INPUT_TYPE_HIDDEN, "hash");
this.inputs.fields['hash'].readonly = true;
this.inputs.fields['hash'].isHidden = true;
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "Property", "If not set to 'Any' then the file will only be displayed if:
The Mini-Site is displaying that property or
The GuestZone is showing a reservation for that property
", false, null, null, MY[DATASET_PROPERTY]);
this.inputs.fields['propertyID'].sortable = true;
this.inputs.fields['filename'] = new s('isEnabled', INPUT_TYPE_TEXT, "File name", "");
this.inputs.fields['filename'].sortable = true;
this.inputs.fields['filename'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Name", "A friendly name for the file - this is what the guests will see displayed.
Note: This is just text and does not need to look like a file name.", true);
this.inputs.fields['name'].sortable = true;
this.inputs.fields['description'] = new s('description', INPUT_TYPE_TEXT, "Description", "Text to describe the usage of the file.
This will be displayed next to the Name in the 'Files' section of the Guest Zone's Reservation page and wherever there is a help popup.");
this.inputs.fields['displayInGuestZone'] = new s('displayInGuestZone', INPUT_TYPE_CHECKBOX, "Display?", "Check this to allow display in the GuestZone or Mini-Site.
If checked and no other conditions are set then the file will always be shown.");
this.inputs.fields['minDaysBeforeArrival'] = new s('minDaysBeforeArrival', INPUT_TYPE_NUMBER, "Days before Arrival", "If non-zero then only show the file if today's date is within this many days of the guest's arrival date.
If set then this file will never be shown in the Mini-Site.", false);
this.inputs.fields['minOrderStatus'] = new s('minOrderStatus', INPUT_TYPE_SELECT, "Min Status", "If not set to 'Any' then the reservation must be at least in this status for the file to show. Setting to Tentative allows all reservations and can be used to ensure that the viewer has a reservation.
If set then this file will never be shown in the Mini-Site.", false, null, null, MY[DATASET_STATUS]);
this.inputs.fields['minPaymentStatus'] = new s('minPaymentStatus', INPUT_TYPE_SELECT, "Min Payment", "If not set to 'Any' then the reservation must have cleared payments at or above the level shown for the file to be displayed. Use
'Booking Deposit' for the initial payment
'Rent' for the full amount due except for anything refundable
'All' for rent plus any refundable amounts
If set then this file will never be shown in the Mini-Site.", false, null, null, MY[DATASET_PAYMENT_STATUS]);
this.inputs.fields['size'] = new s('size', INPUT_TYPE_NUMBER, "Size (B)", "");
this.inputs.fields['size'].readonly = true;
this.handleUpdate = function handleUpdate(oDatatable){
popupInfo('Update '+this.datasetName + ', ')
}
this.tableCfg = {
rowselects: true,
precols: {
/*
replace: {label: "Replace", readonly:false, help: 'Click to replace thsi file with another, leaving all other settings the same. Use this to update a file with a newer version',
formatter: function(elCell, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_ATTACH];
var recordIndex = oRecord.getData(oDataset.inputs.uniqueField || 'id');
var primaryKey = oRecord.getData('hash');
elCell.innerHTML = "{{file-" + primaryKey + "}}";
elCell.innerHTML = "Click";
}
},*/
token: {label: "Template Token", readonly:true, help: 'Use this as a token in your templates to provide a link to this file',
formatter: function(elCell, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_ATTACH];
var recordIndex = oRecord.getData(oDataset.inputs.uniqueField || 'id');
var primaryKey = oRecord.getData('hash');
elCell.innerHTML = "{{file-" + primaryKey + "}}";
}
}
},
actions: [
{actionType: ACTION_TYPE_BUTTON,
button: {label: "Delete", type: BUTTON_TYPE_TEXT, onclick: {fn: this.handleDatatableAction, action: ACTION_TABLE_DELETE}}
}
]
}
//this.viewList = ['ID', 'hash', 'filename', 'size', 'name', 'description', 'displayInGuestZone', 'propertyID', 'minDaysBeforeArrival', 'minOrderStatus', 'minPaymentStatus'];
this.viewList = ['ID', 'hash',
{label: 'Uploaded File Info', children:['filename', 'size']},
{label: 'Display Text', children:['name', 'description']},
{label: 'MiniSite/GuestZone Display Conditions', help: 'Choose the conditions under which the file will be displayed in the GuestZone or Mini-Site.
Note: All of the conditions must be true for the file to be displayed.', children: ['displayInGuestZone', 'propertyID', 'minDaysBeforeArrival', 'minOrderStatus', 'minPaymentStatus']}];
/*
this.renderForEdit = function(pElContentId, idValue, renderFresh) {
msg('fnInit:renderForEdit:'+this.datasetName);
var oCfg = {};
var pSelect = new pane(pElContentId, oCfg);
pSelect.cfg.setProperty('render', function(oPane) {
//return "Select content";
return oPane.getDatasetSelect(DATASET_PROPERTY);
});
pSelect.render();
var pOther = new pane(pElContentId, oCfg);
pOther.cfg.setProperty('render', function() {
return "Other content: propertyID=" + MY[DATASET_PROPERTY].getSelectedId();
});
pSelect.event.change.subscribe(function(type, fireArgs, subscribeArg) {
//popupInfo("change fired: "+type+", " + fireArgs[0].name + ", " + subscribeArg.datasetName);
pOther.render();
}, this);
pOther.render();
}
*/
//this.renderForView = renderForView;
msg('Attach('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_IMAGES] = function initImages() {
msg('fnInit:'+this.datasetName);
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
//this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.renderSelectsList = [DATASET_PROPERTY];
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['caption'] = new s('caption', INPUT_TYPE_TEXT, "Caption", "The caption for this image", false);
this.inputs.fields['caption'].sortable = true;
this.inputs.fields['caption'].style['width'] = '400px';
this.inputs.fields['url'] = new s('url', INPUT_TYPE_TEXT, "URL", "The URL to this image", false);
this.inputs.fields['url'].readonly = true;
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_TEXT, "PropertyID", "The property that this image belongs to", false);
this.inputs.fields['propertyID'].sortable = true;
this.inputs.fields['propertyID'].readonly = true;
this.inputs.fields['position'] = new s('position', INPUT_TYPE_NUMBER, "Position Order", "The position of this property (1 is first)", false);
this.inputs.fields['position'].sortable = true;
this.inputs.fields['position'].readonly = true;
this.inputs.fields['localFile'] = new s('localFile', INPUT_TYPE_TEXT, "Local File", "The local filename for this image", false);
this.inputs.fields['localFile'].readonly = true;
this.viewList = new Array("ID", "propertyID", "position", 'url', 'localFile', 'caption');
this.oConfig.oFilter['propertyID'] = '==MY[DATASET_PROPERTY].getDatasetId()';
//this.renderForView = renderForView;
//this.preload = preload;
this.postUpload = function(json) {
//var plural = uploadCount==1? ' has' : 's have';
//popupInfo(uploadCount + ' image' + plural + ' been uploaded.');
displayResponseMessages(json);
this.unload();
this.load('','','', MY[DATASET_IMAGES].DD.update);
}
// Drag and Drop stuff
this.DD = {
init: function(pElContentId, idValue){
dbgp('this.DD.init('+pElContentId+') editElContent::'+serializeArray(this.editElContent));
var oDataset = MY[DATASET_IMAGES];
if (typeof(pElContentId) == 'undefined' || pElContentId == null || pElContentId.length == 0) {
var elContentId = oDataset['elContentIdLast'+DISPLAY_TYPE_EDIT];
} else {
var elContentId = pElContentId;
}
if (typeof(elContentId) == 'object') {
var elContent = elContentId;
}
else {
var elContent = document.getElementById(elContentId);
}
dbgp('this.DD.init() elContent.id=::'+elContent.id);
elContent.innerHTML = '';
var oDataset = MY[DATASET_IMAGES];
var oDiv = document.createElement("div");
oDiv.className = 'imgsDiv';
// Render an uploader for getting images
var oUploadDiv = document.createElement("div");
oUploadDiv.id = 'uploaderDiv';
oUploadDiv.className = 'upload';
oDiv.appendChild(oUploadDiv);
/* IE Bug
* IE will not submit dynamically created FILE inputs
*/
var oUploadForm = document.createElement("form");
oUploadForm.id = 'uploaderFormDD';
oUploadForm.name = 'uploaderFormDD';
oUploadForm.className = 'upload';
var cbVal = rawurlencode('MY["'+this.datasetName+'"].postUpload');
oUploadForm.action = '/Data/YUI/?'+GET_WHAT+'='+this.datasetName+'&'+GET_ACTION+'='+YUI_ACTION_UPLOAD+'&'+GET_CALLBACK+'='+cbVal;
oUploadForm.target = '__upload';
oUploadForm.enctype = 'multipart/form-data';
oUploadForm.method = 'post';
oUploadDiv.appendChild(oUploadForm);
var oImgInfo = document.createElement("p");
oImgInfo.id = "upload-button-info"
oUploadForm.appendChild(oImgInfo);
var oUploadButtonDiv = document.createElement("div");
oUploadButtonDiv.id = "upload-button-div";
oUploadForm.appendChild(oUploadButtonDiv);
var oSubmitButton = new YAHOO.widget.Button({label: "Upload selected images...", id: "imageLoaderSubmit", container: oUploadButtonDiv.id});
oSubmitButton.on("click", function(e){
var el = document.getElementById('propertyID');
if(el) el.value = MY[DATASET_PROPERTY].getSelectedId();
// Find the right form index (IE workaround as ir needs an index?)
for(var i in document.forms) {
if(document.forms[i].id == 'uploaderFormDD') {
var uploadForm = document.forms[i];
break;
}
}
//var uploadForm = document.getElementById('uploaderFormDD');
document.forms['uploaderFormDD'].submit();
//uploadForm.submit();
return false;
});
// Uploader inputs
for (var i=0; i '); // Do it like this to get IE to work around setting "name" dynamically
//popupInfo(navigator.appCodeName+' '+navigator.appName);
//alert(BrowserDetect.browser + ', ' + BrowserDetect.version);
if(BrowserDetect.browser=="Explorer" && BrowserDetect.version<9) {
//var oInput = document.createElement(''); // Do it like this to get IE to work around setting "name" dynamically
var oInput = document.createElement(''); // Do it like this to get IE to work around setting "name" dynamically
} else {
var oInput = document.createElement('input');
oInput.name = id;
oInput.type = "FILE";
}
//oInput.id = id;
oUploadInputDiv.appendChild(oInput);
}
// Add hidden propertyID to form inputs
var oInput = document.createElement("input");
oInput.type = "hidden";
oInput.id = "propertyID";
oInput.name = oInput.id;
oUploadForm.appendChild(oInput);
// Add hidden iframe for posting the form to
var oIframe = document.createElement("iframe");
oIframe.name = oUploadForm.target;
oIframe.src = "#";
oIframe.style.display = "none";
oUploadDiv.appendChild(oIframe);
var oInstructions = document.createElement("p");
oInstructions.appendChild(document.createTextNode("Click and drag the images to change the order"));
oUploadDiv.appendChild(oInstructions);
// Display the images and allow re-ordering on0screen via drag and drop
var oUl = document.createElement("ul");
oUl.id = oDataset.datasetName+'-imgUl';
oUl.className = 'imgUl';
// Render each image
//var oData = MVRZ.data.object[this.datasetName][JSON_RESPONSE_INDEX_DATA];
for (var id=0; id Select more images then click the button below.";
} else {
oButtonDiv.style.display = 'none';
oImgInfo.innerHTML = "You have uploaded all "+IMAGE_PROPERTY_MAX+" images. Delete an existing one to make space for another.";
}
for (var i=0; i =numImages) {
oLi.style.display = "none"; // Hide
msg('this.DD.update() hiding image '+i);
continue;
}
} else {
msg('this.DD.update() no LI for image '+i);
continue;
}
var id = oData[i].ID;
msg('this.DD.update() updating image '+i+', id='+id);
//popupInfo("img index="+dataRowIndex+", id="+id);
var position = oData[i].position;
var propertyID = oData[i].propertyID;
var localFile = oData[i].localFile;
var caption = oData[i].caption;
var lastSlashPos = localFile.lastIndexOf('/');
var filepart = localFile.substr(lastSlashPos + 1);
var imgUrlBase = imgBase + '/' + gUserId + '/' + propertyID + '/';
var imgUrl = imgBase + '/' + gUserId + '/' + propertyID + '/' + filepart;
var imgThumbUrl = imgBase + '/' + gUserId + '/' + propertyID + IMAGE_THUMB_POSTFIX + '/' + filepart;
// Set the display for the correct image
// - Image src
var oImg = document.getElementById(oLi.id+"-handle");
if (typeof(oImg)!='undefined') {
oImg.src = imgThumbUrl;
msg('this.DD.update() updating image src '+i+', id='+id);
}
// - Caption
var idInputId = oDataset.datasetName+"-input-id-"+i;
var oTdInput = document.getElementById(oDataset.datasetName+"-td-input-"+i);
if (typeof(oTdInput)!='undefined') {
var aInputs = YAHOO.util.Dom.getElementsByClassName("input", "input", oTdInput);
var oInputNow = aInputs[0];
if(oInputNow.id == idInputId) oInputNow = aInputs[1];
if (typeof(oInputNow)!='undefined') {
var captionId = MVRZ.util.encodeInputId(DATASET_IMAGES, i, id, 'caption');
oInputNow.id = captionId; // Need this for auto-saving
oDataset.inputs.fields['caption'].doHandlers = true;
oInput = MVRZ.util.render.input(oDataset.inputs.fields['caption'], captionId, caption, oDataset); // Add listeners etc
}
}
var oIdInput = document.getElementById(idInputId);
oIdInput.value = id;
oLi.style.display = "block"; // Show
}
}
}
this.renderForEdit = this.DD.init;
msg('Images('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_STREET] = function initStreet() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
var REQUEST_STATUS_UNKNOWN = 'UNKN';
var REQUEST_STATUS_QUOTED = 'QTD';
var REQUEST_STATUS_BOOKED = 'BKD';
var REQUEST_STATUS_TOOBIG = '2FEW';
var REQUEST_STATUS_TOOSMALL = '2MNY';
var REQUEST_STATUS_GUESTMIX = 'UNST';
var REQUEST_STATUS_COMMUNICATIONS = 'FLUP';
var REQUEST_STATUS_SCAM = 'SCAM';
var REQUEST_STATUS_REFERRAL = 'VRRN'
var REQUEST_STATUS_REPLY = 'RPLY';
MY.fnInit[DATASET_REQUEST_STATUS] = function initRequestStatus() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "Status", "This shows the staus of the request.", false, null, null, this),
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'ID', labelField: 'actionName'};
/*
this.postload = function postload() {
// Add label for action
var rows = this.getRows();
for(index in rows) {
var name = rows[index].name;
this.set(index, 'actionName', 'Mark as ' + name);
}
}
*/
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_STATUS] = function initStatus() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'ID'};
this.load = function(){
msg('fnInit load():'+this.datasetName);
if(this.isLoaded()) return;
// Set the values
/* this.append(0, {
name: "-- Any --"
}, "ID");
*/ this.append(ORDER_STATUS_TENTATIVE, {
name: "Tentative"
}, "ID");
this.append(ORDER_STATUS_PENDING, {
name: "Pending"
}, "ID");
this.append(ORDER_STATUS_CONFIRMED, {
name: "Confirmed"
}, "ID");
this.setload(LOAD_STATUS_LOADED);
}
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_PAYMENT_STATUS] = function initPaymentStatus() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'ID'};
this.load = function(){
msg('fnInit load():'+this.datasetName);
if(this.isLoaded()) return;
// Set the values
/* this.append(0, {
name: "-- Any --"
}, "ID");
*/
delete(this.dataset.data); // Reset it
delete(this.datasetData); // Reset it, yes both this and dataset.data
this.append(PAYMENT_STATUS_BOOKINGDEPOSIT, {
name: "Booking Deposit"
}, "ID");
this.append(PAYMENT_STATUS_BALANCE, {
name: "Rent"
}, "ID");
this.append(PAYMENT_STATUS_FULL, {
name: "All"
}, "ID");
this.unload();
}
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_PROPERTYTYPE] = function initPropertyType() {
msg('fnInit:'+this.datasetName);
//this.zeroSelect = "-- XX --";
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
this.inputs.selectField.sortByFieldName = 'name';
this.inputs.selectField.selectConfig = {sortByFieldName: 'name'};
this.renderForEdit = function() {
msg('fnInit::renderForEdit:'+this.datasetName);
}
}
MY.fnInit[DATASET_PROPERTY] = function initProperty(){
msg('fnInit:'+this.datasetName);
this.isOptionIdOnList = function isOptionIdOnList(oArgs) {
var oDataset = MY[DATASET_PROPERTY];
var ret = true;
var optionID = oArgs.optionID;
var propertyID = oArgs.propertyID;
if(typeof(optionID)!='undefined' && optionID!=null && typeof(propertyID)!='undefined' && propertyID!=null) {
var sheetsID = oDataset.get(propertyID, 'optionListSheetsID', oDataset.getUniqueField());
var sheetRows = MY[DATASET_OPTIONLISTSHEET].getRows({optionListSheetsID:'=="'+sheetsID+'"', optionID:'=="'+optionID+'"', isIncluded:'!=0'});
ret = sheetRows.length>0 ? true : false;
}
return ret;
}
// Set up the inputs
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
//this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, MVRZ.util.select[this.datasetName]);
this.inputs.selectField = new s(this.datasetName+'ID', INPUT_TYPE_SELECT, "", "ID", true, null, null, this);
this.inputs.selectField.styleWrapper = MY.defaults.selectStyle;
//this.inputs.selectField.selectConfig = {newSelect: '-- NEW --'};
this.inputs.fields['ID'] = new s('ID', INPUT_TYPE_TEXT, "ID");
this.inputs.fields['ID'].readonly = true;
this.inputs.fields['name'] = new s('name', INPUT_TYPE_TEXT, "Property Name", "The name for this property", true);
this.inputs.fields['name'].sortable = true;
this.inputs.fields['isDisabled'] = new s('isDisabled', "checkbox", "Disable", "Disable this property. To the outside world this property will no longer exist but you can re-enable it at any time.", false);
this.inputs.fields['checkinTime'] = new s('checkinTime', INPUT_TYPE_TIME, "Check-in Time", "The normal check-in time for this property", true);
this.inputs.fields['checkoutTime'] = new s('checkoutTime', INPUT_TYPE_TIME, "Check-out Time", "The normal check-out time for this property", true);
/*
$paramArray['displayVars']['checkinTime'] = array('label'=>'Check in Time', 'input'=>CONTROL_TYPE_TIMENOSECONDS, 'validate'=>'IsTime', 'help'=>'Enter the check-in time for the property here. This can be in any unambiguous format, eg 5.30pm, 6pm, 17:30. A 24 hour format is assumed if am/pm is not specified.');
$paramArray['displayVars']['checkoutTime'] = array('label'=>'Check out Time', 'input'=>CONTROL_TYPE_TIMENOSECONDS, 'validate'=>'IsTime', 'help'=>'Enter the check-out time for the property here. This can be in any unambiguous format, eg 10.30pm, 10am, 09:30. A 24 hour format is assumed if am/pm is not specified.');
*/
var sHelp = 'Choose Property Type '
+' '+PROPERTY_TYPE_HOME_NAME+''
+' A Single Family Home or Unit, detached/separated from all other units. No other units share the building.'
+' '+PROPERTY_TYPE_APARTMENT_NAME+''
+' A Unit on one storey/level, with others units above or below it. This unit shares a building with other units.'
+' '+PROPERTY_TYPE_TOWNHOME_NAME+''
+' A Unit on multiple storeys/levels, with other units to the side of it. This unit shares a building with other units.'
+' '+PROPERTY_TYPE_DUPLEX_NAME+''
+' A Unit attached to one other unit. This unit shares a building with one other unit.'
;
this.inputs.fields['propertyTypeID'] = new s('propertyTypeID', INPUT_TYPE_SELECT, "Property Type", sHelp, true, null, null, MY[DATASET_PROPERTYTYPE]);
this.inputs.fields['lineDescription'] = new s('lineDescription', INPUT_TYPE_TEXTAREA, "Line Description (100 chars)", 'Enter a single line description for your property. Eg. Very close to everything.
You can optionally display this property line description with your calendar view.' + LISTING_WARNING, false);
this.inputs.fields['shortDescription'] = new s('shortDescription', INPUT_TYPE_TEXTAREA, "Short property description", 'Enter a short description of your property. This text would be used to display a summary of your property\'s best features to attract a traveler to look further. Some advertising sites may accept a limited amount of text so concentrate on your property information first, the community information can be provided in a separate field below.' + LISTING_WARNING, false);
// TODO only if plan is >= PLAN_3
this.inputs.fields['bulletDescription'] = new s('bulletDescription', INPUT_TYPE_TEXTAREA, "Property amenity list", 'Enter a list of your property\'s amenities - each separated by a new line. This text is used to create a bulleted list to summarize your properties amenities in quotations. ' + LISTING_WARNING, false);
//this.inputs.fields['bulletDescription'].style['width'] = "600px";
this.inputs.fields['bulletDescription'].style['height'] = "15em";
this.inputs.fields['fullDescription'] = new s('fullDescription', INPUT_TYPE_TEXTAREA, "Full property description", 'Enter a full description of your property here. Please do NOT enter any Community/Resort details here - use the Community Description field for that.
Simple HTML tags ' + SIMPLE_HTML_TAGS + ' can be used here.' + LISTING_WARNING, false);
this.inputs.fields['fullDescription'].style['height'] = "15em";
this.inputs.fields['communityDescription'] = new s('communityDescription', INPUT_TYPE_TEXTAREA, "Community Description", 'Enter a description of your community/resort here. When combined with the Short and Full Property descriptions above this will form the full description of your offering.
Simple HTML tags ' + SIMPLE_HTML_TAGS + ' can be used here.' + LISTING_WARNING, false);
this.inputs.fields['communityDescription'].style['height'] = "15em";
this.inputs.fields['termsAndConditions'] = new s('termsAndConditions', INPUT_TYPE_TEXTAREA, "Terms & Conditions", 'Enter the property\'s Terms & Conditions here. All HTML tags can be used here.' + LISTING_WARNING, false);
this.inputs.fields['termsAndConditions'].style['height'] = "15em";
// Location info
this.inputs.fields['streetID'] = new s('streetID', INPUT_TYPE_SELECT, "Street", 'Select the Street that the property is located in. DO NOT ENTER THE PROPERTY NUMBER HERE. If the Street is not in the list then click on \'New\' to add it.', true, null, null, MY[DATASET_STREET]);
this.inputs.fields['streetID'].selectConfig = {canAddNew: true};
input = 'cityID';
id = MVRZ.util.encodeInputId(this.datasetName, 0, 0, input)
this.inputs.fields['streetID'].addNewArgs = [{name: input, eval: "document.getElementById('"+id+"').value"}];
this.inputs.fields['locationID'] = new s('locationID', INPUT_TYPE_SELECT, "Community/Resort", 'Select the Resort or Community that the property is located in. If yours is not in the list then click on \'New\' to add it. If you don\'t have one then just leave this unset.', false, null, null, MY[DATASET_RESORT]);
this.inputs.fields['locationID'].selectConfig = {canAddNew: true};
this.inputs.fields['locationID'].addNewArgs = [{name: input, eval: "document.getElementById('"+id+"').value"}];
this.inputs.fields['streetNumber'] = new s('streetNumber', INPUT_TYPE_TEXT, "Street Number", 'Enter your property\'s street number here. Just enter the number. This will not be published unless you want it to be.', true);
this.inputs.fields['zip'] = new s('zip', INPUT_TYPE_TEXT, "Zip/Post Code", 'Enter your property\'s zip or postal code here.', false);
this.inputs.fields['phone'] = new s('phone', INPUT_TYPE_TELEPHONE, "Phone Number", 'Enter your property\'s phone number here.', false);
this.inputs.fields['timezoneOffset'] = new s('timezoneOffset', INPUT_TYPE_NUMBER, "Timezone Offset", 'Enter your property\'s timezone offset in hourse from GMT.', false);
/*
$paramArray['displayVars']['country'] = array('label'=>'Country', 'required'=>'countryID', 'validate'=>'IsSelectTextNZ', 'help'=>'Select the country that the property is located in.');
$paramArray['displayVars']['region'] = array('label'=>'Region', 'required'=>'regionID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the Region that the property is located in. If the Region is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['city'] = array('label'=>'City', 'required'=>'cityID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the City that the property is located in - this should be the city in the postal address of the property. If the City is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['streetNumber'] = array('label'=>'Street Number', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'1', 'help'=>'Enter your property\'s street number here. Just enter the number. This will not be published unless you want it to be.');
$paramArray['displayVars']['zip'] = array('label'=>'Zip/Post Code', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'Enter your property\'s zip or postal code here.');
$paramArray['displayVars']['phone'] = array('label'=>'Phone Number', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'validate'=>'isPhone', 'help'=>'Enter your property\'s phone number here.');
$paramArray['displayVars']['street'] = array('label'=>'Street', 'required'=>'streetID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the Street that the property is located in. DO NOT ENTER THE PROPERTY NUMBER HERE. If the Street is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['location'] = array('label'=>'Community', 'required'=>'0', 'help'=>'Select the Community that the property is located in. If the Community is not in the list then click on \'New\' to add it.');
*/
/*
$propertyType = new PropertyType();
$destinations = new Destination();
$paramArray['displayVars']['propertyTypeID'] = array('label'=>'Property Type', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'1', 'validate'=>'isSelectNumberGZ', 'select' => $propertyType->simpleSelectArray('','',array('0'=>'--Select--')), 'help'=>$propertyType->fieldsArray['name']['help']);
$paramArray['displayVars']['sleeps'] = array('label'=>'Sleeps', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'1', 'validate'=>'isNumberGEZ', 'help'=>'This is the maximum number of people requiring beds that you will accept into the property. Infants are often treated separately when they do not require a bed.');
$paramArray['displayVars']['bedrooms'] = array('label'=>'Bedrooms', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'1', 'validate'=>'isNumberGEZ', 'help'=>'This is the total number of bedrooms that you have and must be a whole number.');
$paramArray['displayVars']['bathrooms'] = array('label'=>'Bathrooms', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'1', 'validate'=>'isNumberGEZ', 'help'=>'This is the total number of bathrooms that you have and can be fractional, eg 3.5.');
$paramArray['displayVars']['url'] = array('label'=>'Website/URL', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'validate'=>'isURL', 'help'=>'This is the URL (website address) that is specific to this property. A single website may cover more than one property so a link to somewhere more specific in that website could be used.');
$paramArray['displayVars']['destinationID'] = array('label'=>'Destination', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $destinations->simpleSelectArray('','',array('0'=>'--Destination--')), 'help'=>'If your property is located in one of the Destinations listed then select it here.
If your property is in a Destination that is not listed here then use the contact link in the top-right corner of the page to ask for it to be added.');
if($user->planID >= PLAN_2) {
debug("adding manager stuff");
$paramArray['displayVars']['ownerContactID'] = array('label'=>'Owner Contact', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $ownerSelectArray, 'help'=>'This is the contact for the Owner of the property - the entity that purchased it. This contact must already be defined on the Contacts page.');
$paramArray['displayVars']['propertymanagerContactID'] = array('label'=>'ManCo Contact', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $pmSelectArray, 'help'=>'This is the contact for the Property Manager of the property - the entity that manages the local day to day operations. This contact must already be defined on the Contacts page.');
}
if($user->planID >= PLAN_2) {
#$paramArray['displayVars']['initialPaymentIsPercent'] = array('label'=>'Initial Payment due is a Percentage?', 'input'=>CONTROL_TYPE_CHECKBOX, 'help'=>'Check this box if your require a percentage of the total rent at the time of booking. Otherwise, a fixed amount is assumed.');
#$paramArray['displayVars']['initialPaymentAmount'] = array('label'=>'Initial Payment Amount?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This is either the Percentage or Fixed amount required at the time of booking as determined by the above. This can be zero if nothing is required at time of booking. Example: When a Pecentage: \'20\' for 20% Example: When not a percentage: \'200\' for 200 currency units');
$paramArray['displayVars']['initialPaymentAmount'] = array('label'=>'Initial Payment Amount?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This is any Fixed amount required at the time of booking. This can be zero if nothing is required at time of booking. This can be set in addition to any initial percentage due.');
$paramArray['displayVars']['initialPaymentPercent'] = array('label'=>'Initial Payment Percent?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This is any Percentage of the total amount owed required at the time of booking. This can be zero if nothing is required at time of booking. This can be set in addition to any initial fixed amount due. Choose whether any Refundable Amount is included in this total or not below.');
$paramArray['displayVars']['initialPaymentPercentIncludeRefundable'] = array('label'=>'Include Refundable in Percent?', 'input'=>CONTROL_TYPE_CHECKBOX, 'help'=>'When calculating the Initial Payment amount as a Percentage, check this box if any refundable amount should be included in the total.');
$paramArray['displayVars']['initialPaymentDaysToPay'] = array('label'=>'Initial Payment Days To Pay?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This sets the Initial Booking Deposit payment schedule. Enter the number of days after the booking date that the first payment is due. This could be zero to indicate that it\'s due immediately. Example: \'7\' for 7 days after the booking was created.
Full Examples: See next field help');
$paramArray['displayVars']['finalPaymentDaysBeforeArrival'] = array('label'=>'Final Payment Days Before Arrival?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This sets the final payment schedule. Enter the number of days before the arrival date that the balance of any payment is due. This could be zero to indicate that it\'s due on the arrival date. Example: \'60\' for 60 days before arrival.
Full Examples: 1. 20% Booking Deposit due in 2 days with Balance due 60 days before arrival Initial Payment Percentage: 20 Initial Payment Amount: 0 Initial Payment Days To Pay: 2 Final Payment Days Before Arrival: 60
2. $100 Booking Deposit due in 7 days with Balance due on arrival Initial Payment Percentage: 0 Initial Payment Amount: 100 Initial Payment Days To Pay: 7 Final Payment Days Before Arrival: 0');
$paramArray['displayVars']['refundableName'] = array('label'=>'Name of Refundable Amount?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'Give this Refundable Amount a name that you\'d like to be used instead of the default. Typically, this may be "Security Deposit".');
$paramArray['displayVars']['refundablePaymentDaysBeforeArrival'] = array('label'=>'Refundable Payment Days Before Arrival?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This sets the Refundable Amount payment schedule. Enter the number of days before the arrival date that this is due. This could be zero to indicate that it\'s due on the arrival date.');
$paramArray['displayVars']['refundableReturnDaysAfterDeparture'] = array('label'=>'Refundable Return Days After Departure?', 'input'=>CONTROL_TYPE_TEXT, 'validate'=>'isNumberGEZ', 'help'=>'This sets the Refundable Amount return schedule. Enter the number of days after the departure date that this should be returned. This could be zero to indicate that it\'s due on the departure date.');
$paramArray['displayVars']['refundableTerms'] = array('label'=>'Refundable Terms?', 'input'=>CONTROL_TYPE_TEXTAREA, 'attrib'=>'style="width:100%;"', 'help'=>'If you have some special terms that you wish the guest to agree to for refundable amount Credit Card authorizations then enter it here. Otherwise some default language will be included.
This is used for cases where a refundable amount is due and you wish to take a paper authorization for a Credit Card charge.');
$paramArray['displayVars']['refundableByPayment'] = array('label'=>'Refundable can be Paid?', 'input'=>CONTROL_TYPE_CHECKBOX, 'help'=>'Check this if you accept payments for Refundable Amounts by Cash, Check, CCard - where an actual charge is made. If you take Credit Card authorizations then check that box below.
Note: For PayPal users, often a real charge will be made as it can be refunded within 60 days with no fees. If you use PayPal and do this then do not check the Authorization box below.');
$paramArray['displayVars']['refundableByAuth'] = array('label'=>'Refundable can be Authorized?', 'input'=>CONTROL_TYPE_CHECKBOX, 'help'=>'Check this if you accept payments for Refundable Amounts by a CCard authorization - where no actual charge is made. It does not matter if you are using a merchant account integrated here or not. If you take authorizations then please check this box - a standard authorization form will be generated.');
$paramArray['displayVars']['refundableAuthAdvanceDays'] = array('label'=>'Refundable Authorization advance days?', 'input'=>CONTROL_TYPE_TEXT, 'help'=>'Indicate the number of days in advance of the due date that the Authorization can be made.
Often, a credit card authorization has an expiration date, so use this to restrict how far in advance of the reservation it can be made.');
}
#if($this->user->hasService(SERVICE_QUOTEZONE) || ($this->user->hasService(SERVICE_MANAGEZONE) && $user->hasOwnDb)) {
#if($this->user->hasService(SERVICE_QUOTEZONE) || ($this->user->hasService(SERVICE_MANAGEZONE) && $this->user->hasOwnDb)) {
if($user->planID >= PLAN_3) {
$helpStr = 'Choose the base currency for this property\'s rates. All rates in the system will be in this currency and other currencies will be calculated from this using exchange rates that you provide.';
} else {
$helpStr = 'Choose the base currency for this property\'s reservations.';
}
$paramArray['displayVars']['baseCurrency'] = array('label'=>'Base Currency', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'1', 'select' => $exchange->simpleSelectArray(), 'help'=>$helpStr. ' To add more to the list, please include other currencies on the Setup->Account->Currencies Tab');
$jsActive = "onclick=\"javascript: updateActiveInput(this)\"";
$jsActive .= " onkeyup=\"javascript: updateActiveInput(this)\"";
$paramArray['displayVars']['termsAndConditions'] = array('label'=>'Terms & Conditions', 'input'=>CONTROL_TYPE_TEXTAREA, 'required'=>'0', 'help'=>'Enter your terms and conditions for this property here. This can be in HTML and if it is make sure that it is a full, standalone HTML document as it will be opened in a window all by itself. This will be linked to from the online booking form.', 'class'=>'', 'attrib'=>'style="width:100%; height:400px;" '.$jsActive);
$paramArray['displayVars']['postBookingInstructions'] = array('label'=>'Post Booking Instructions', 'input'=>CONTROL_TYPE_TEXTAREA, 'required'=>'0', 'help'=>'Enter any instructions for the guest after they have submitted the Booking Form online. The format can be simple HTML, no layout control is permitted.', 'class'=>'', 'attrib'=>'style="width:100%; height:400px;" '.$jsActive);
#}
if($user->planID >= PLAN_3) {
$paramArray['displayVars']['bulletDescription'] = array('label'=>'Bullet Description', 'input'=>CONTROL_TYPE_TEXTAREA, 'help'=>'Enter a number of lines as a bullet description for your property. Just enter the text and the bullet itself will be added later. Separate your bullet lines with a new line.'.$listingWarning);
$paramArray['displayVars']['availableFrom'] = array('label'=>'Available From', 'input'=>CONTROL_TYPE_DATE, 'validate'=>'isDate', 'help'=>'If your property is not available right now then enter the date from which it can be booked here.');
$paramArray['displayVars']['availableTo'] = array('label'=>'Available To', 'input'=>CONTROL_TYPE_DATE, 'validate'=>'isDate', 'help'=>'If your property is coming to a point where it can no longer be booked then enter the date at which that happens here.');
$paramArray['displayVars']['dateSheetsID'] = array('label'=>'Dates', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $user->dateSheets->simpleSelectArray(), 'help'=>'Choose the set of seasons for this property here. These must already be defined on the Setup->Quote tab.');
$paramArray['displayVars']['rateSheetsID'] = array('label'=>'Rates', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $user->rateSheets->simpleSelectArray(), 'help'=>'Choose the set of rates for this property here. These must already be defined on the Setup->Quote tab.');
$paramArray['displayVars']['dayID'] = array('label'=>'Preferred Arrival Day', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $day->simpleSelectArray('','',array('0'=>'-- None --')), 'help'=>'If you have a preferred day of the week for arrival then enter it here. This determines whether quotes will be provided aligned to this day.');
$paramArray['displayVars']['quoteNoGaps'] = array('label'=>'Don\'t find back-to-backs?', 'input'=>CONTROL_TYPE_CHECKBOX, 'required'=>'0', 'help'=>'When using Quoted Online Booking check this to stop the system offering quotes for available periods before and after requested dates that are back-to-back with existing reservations - but still within the allowed search range. Requested dates that happen to be back-to-backs will still be offered.');
$paramArray['displayVars']['limitMinToGap'] = array('label'=>'Limit Price to Gap?', 'input'=>CONTROL_TYPE_CHECKBOX, 'required'=>'0', 'help'=>'For seasons with minimum night requirements, if you have a request inside a gap that is less than the minimum nights you can choose to ignore the minimum night charge in order to offer a lower rate. If you do want to ignore the minimum charge then check this box, otherwise leave it unchecked to quote the minimum nights rate.
When checked, the rate offered is pro-rated from the reference rate entered for that season and NOT the sum of the appropriate daily and weekend rates.');
}
if($user->planID >= PLAN_2) {
$selectArray = $user->taxSheets->simpleSelectArray();
$selectArray["-1"] = "-- No Taxes --";
$paramArray['displayVars']['taxSheetsID'] = array('label'=>'Rent Taxes', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $selectArray, 'help'=>'Choose the set of taxes to apply to the rents for this property here. These must already be defined on the Setup->Quote tab.');
#$paramArray['displayVars']['optionTaxSheetsID'] = array('label'=>'Option Taxes', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $selectArray, 'help'=>'Choose the default set of taxes to apply to the options for property here. These must already be defined on the Setup->Quote tab.');
$paramArray['displayVars']['optionListSheetsID'] = array('label'=>'Options', 'input'=>CONTROL_TYPE_SELECT, 'required'=>'0', 'select' => $user->optionListSheets->simpleSelectArray(), 'help'=>'Choose the set of options for this property here. These must already be defined on the Setup->Quote tab.');
$paramArray['displayVars']['weekdayPercent'] = array('label'=>'Weekday Percentage', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'This is for cases where an explicit weekday amount is not provided in the Rates. Enter the % of a defined amount that should be applied to generate the weekday amount.
If the weekly amount is set to 100% and this is set to 16% then any weekday amount will be 16% of the weekly amount.');
$paramArray['displayVars']['weekendPercent'] = array('label'=>'Weekend Day Percentage', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'This is for cases where an explicit weekend amount is not provided in the Rates. Enter the % of a defined amount that should be applied to generate the daily weekend amount.
If the weekly amount is set to 100% and this is set to 25% then any weekday amount will be 25% of the weekly amount.');
$paramArray['displayVars']['weeklyPercent'] = array('label'=>'Weekly Percentage', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'This is for cases where an explicit weekly amount is not provided in the Rates. Enter the % of a defined amount that should be applied to generate the weekly amount.
If the monthly amount is set to 100% and this is set to 30% then any weekly amount will be 30% of the monthly amount.');
$paramArray['displayVars']['monthlyPercent'] = array('label'=>'Monthly Percentage', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'This is for cases where an explicit monthly amount is not provided in the Rates. Enter the % of a defined amount that should be applied to generate the monthly amount.
If the weekly amount is set to 100% and this is set to 300% then any monthly amount will be 300% of the weekly amount.');
}
$paramArray['displayVars']['checkinTime'] = array('label'=>'Check in Time', 'input'=>CONTROL_TYPE_TIMENOSECONDS, 'validate'=>'IsTime', 'help'=>'Enter the check-in time for the property here. This can be in any unambiguous format, eg 5.30pm, 6pm, 17:30. A 24 hour format is assumed if am/pm is not specified.');
$paramArray['displayVars']['checkoutTime'] = array('label'=>'Check out Time', 'input'=>CONTROL_TYPE_TIMENOSECONDS, 'validate'=>'IsTime', 'help'=>'Enter the check-out time for the property here. This can be in any unambiguous format, eg 10.30pm, 10am, 09:30. A 24 hour format is assumed if am/pm is not specified.');
$paramArray['displayVars']['adultAgeStart'] = array('label'=>'Adult Age', 'input'=>CONTROL_TYPE_TEXT, 'help'=>'Enter the minimum age of an Adult. This is for your information only. All Adults count towards the occupancy of the property.
This is used on the Request and Bookings Forms.');
$paramArray['displayVars']['childAgeStart'] = array('label'=>'Child Age', 'input'=>CONTROL_TYPE_TEXT, 'help'=>'Enter the minimum age of a Child. This is a person that legally requires a bed. All Children count towards the occupancy of the property. Any age below this is considered to be an Infant and does not contribute to the occupancy count.
This is used on the Request and Bookings Forms.');
$paramArray['displayVars']['primaryAgeStart'] = array('label'=>'Reservation Age', 'input'=>CONTROL_TYPE_TEXT, 'help'=>'Enter the minimum age for persons responsible for the reservation. This is used on the Booking Form.');
// Address
#$paramArray['displayVars']['address'] = array('label'=>'Address & Location');
$paramArray['displayVars']['country'] = array('label'=>'Country', 'required'=>'countryID', 'validate'=>'IsSelectTextNZ', 'help'=>'Select the country that the property is located in.');
$paramArray['displayVars']['region'] = array('label'=>'Region', 'required'=>'regionID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the Region that the property is located in. If the Region is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['city'] = array('label'=>'City', 'required'=>'cityID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the City that the property is located in - this should be the city in the postal address of the property. If the City is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['streetNumber'] = array('label'=>'Street Number', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'1', 'help'=>'Enter your property\'s street number here. Just enter the number. This will not be published unless you want it to be.');
$paramArray['displayVars']['zip'] = array('label'=>'Zip/Post Code', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'help'=>'Enter your property\'s zip or postal code here.');
$paramArray['displayVars']['phone'] = array('label'=>'Phone Number', 'input'=>CONTROL_TYPE_TEXT, 'required'=>'0', 'validate'=>'isPhone', 'help'=>'Enter your property\'s phone number here.');
$paramArray['displayVars']['street'] = array('label'=>'Street', 'required'=>'streetID', 'validate'=>'IsSelectNumberGZ', 'help'=>'Select the Street that the property is located in. DO NOT ENTER THE PROPERTY NUMBER HERE. If the Street is not in the list then click on \'New\' to add it.');
$paramArray['displayVars']['location'] = array('label'=>'Community', 'required'=>'0', 'help'=>'Select the Community that the property is located in. If the Community is not in the list then click on \'New\' to add it.');
*/
//this.renderView = renderView;
////this.renderForEdit = renderForEdit;
this.getTimezoneOffset = function getTimezoneOffset() {
return -5;
}
/*
this.render = function(elContent, sIntroHtml, oSteps){
var idValue = '';
var displayType = MVRZ_DISPLAY_TYPE_EDIT_SINGLE;
this.renderForEdit(elContent, idValue, displayType, sIntroHtml, oSteps);
}
*/
/*
this.renderEditFirst = renderEdit;
this.renderEdit = function(elContent, idValue, displayType, sIntroHtml, oSteps) {
msg("renderEdit: Feature first: "+elContent);
el = document.getElementById(elContent);
if(!el) {
msg("renderEdit: Feature first - no element");
return;
}
var oDivEdit = document.createElement('div');
oDivEdit.id = elContent+":Edit";
if(!document.getElementById(oDivEdit.id)) el.appendChild(oDivEdit);
var oDivView = document.createElement('div');
oDivView.id = elContent+":View";
if(!document.getElementById(oDivView.id)) el.appendChild(oDivView);
this.renderEditFirst(oDivEdit.id, idValue, displayType, sIntroHtml, oSteps);
// Add table of features that this customer has assigned to it
var oConfig = new Object();
oConfig.oFilter = new Object();
var el = document.getElementById(MVRZ.util.encodeSelectId(dataObjectIndex, dataObjectIndex+'ID'));
var value = el.value;
if(value==0) value = 0; // Ensure it's not blank
oConfig.oFilter['featureID'] = '=='+value;
oConfig.fnAfterTableSave = function(){
msg("renderEdit: fnAfterTableSave ");
MY.feature.renderEdit('tabfeature');
}
oConfig.newRows=1;
oConfig.newRowPreset = new Object();
oConfig.newRowPreset['featureID'] = value;
MY.featureCustomer.renderView(oDivView.id, oConfig);
}
*/
//this.preload = preload;
/*
msg('Property('+this.datasetName+') - calling set request');
//this.setRequest();
setRequest(this);
*/
this.updateTheAddress = function updateTheAddress(e){
oTarget = YAHOO.util.Event.getTarget(e, 1);
var sId = oTarget.id;
var eInput = MVRZ.util.getInput(sId);
var countryID = '';
var regionID = cityID = streetID = locationID = 0;
msg("updateTheAddress: "+oTarget.id+" = "+oTarget.value+' ('+oInput.name+')');
oInput = MVRZ.util.decodeInputId(sId);
switch(oInput.input) {
case('countryID'):
//popup('','Changing '+oInput.input+ ' to '+oTarget.value);
MY[DATASET_REGION].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['countryID']=='"+oTarget.value+"'"}];
MY[DATASET_CITY].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['regionID']==0"}];
MY[DATASET_STREET].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']==0"}];
MY[DATASET_RESORT].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']==0"}];
if(oTarget.value.length == 0) MY[DATASET_NONE].inputs.fields['regionID'].readonly = true;
else MY[DATASET_NONE].inputs.fields['regionID'].readonly = false;
MY[DATASET_NONE].inputs.fields['cityID'].readonly = true;
MY[DATASET_PROPERTY].inputs.fields['streetID'].readonly = true;
MY[DATASET_PROPERTY].inputs.fields['locationID'].readonly = true;
break;
case('regionID'):
//popup('','Changing '+oInput.input+ ' to '+oTarget.value);
countryID = MY[DATASET_NONE].get(0, 'countryID');
regionID = oTarget.value;
MY[DATASET_CITY].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['regionID']=="+oTarget.value}];
MY[DATASET_STREET].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']==0"}];
MY[DATASET_RESORT].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']==0"}];
if(oTarget.value == 0) MY[DATASET_NONE].inputs.fields['cityID'].readonly = true;
else MY[DATASET_NONE].inputs.fields['cityID'].readonly = false;
MY[DATASET_PROPERTY].inputs.fields['streetID'].readonly = true;
MY[DATASET_PROPERTY].inputs.fields['locationID'].readonly = true;
break;
case('cityID'):
//popup('','Changing '+oInput.input+ ' to '+oTarget.value);
regionID = MY[DATASET_NONE].get(0, 'regionID');
cityID = oTarget.value;
MY[DATASET_STREET].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']=="+oTarget.value}];
MY[DATASET_RESORT].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']=="+oTarget.value}];
var bState = false;
if(oTarget.value == 0) bState = true;
MY[DATASET_PROPERTY].inputs.fields['streetID'].readonly = bState;
MY[DATASET_PROPERTY].inputs.fields['locationID'].readonly = bState;
break;
default:
sysErr(POPUP_TYPE_ERROR,'Unknown address input '+oInput.input+ ' with value '+oTarget.value);
break;
}
var idValue = 0;
var input = 'regionID';
var datasetName = DATASET_NONE;
var id = MVRZ.util.encodeInputId(datasetName, 0, idValue, input);
MVRZ.util.render.input(MY[datasetName].inputs.fields[input], id, regionID, MY[datasetName]);
input = 'cityID';
var id = MVRZ.util.encodeInputId(datasetName, 0, 0, input);
MVRZ.util.render.input(MY[datasetName].inputs.fields[input], id, cityID, MY[datasetName]);
idValue = MY[DATASET_PROPERTY].setDatasetId();
datasetName = DATASET_PROPERTY;
input = 'streetID';
var id = MVRZ.util.encodeInputId(datasetName, 0, idValue, input);
MVRZ.util.render.input(MY[datasetName].inputs.fields[input], id, streetID, MY[datasetName]);
input = 'locationID';
var id = MVRZ.util.encodeInputId(datasetName, 0, idValue, input);
MVRZ.util.render.input(MY[datasetName].inputs.fields[input], id, locationID, MY[datasetName]);
}
this.renderTheAddress = function renderTheAddress(poAppendTo, countryID, regionID, cityID) {
var oFields = new Array();
var oAppendTo = poAppendTo;
if(typeof(oAppendTo)!='object') oAppendTo = document.getElementById(oDivInputs);
if (typeof(oAppendTo) != 'object' || oAppendTo==null) {
msg("renderTheAddress(): No append object, id="+poAppendTo);
return;
}
var input = "countryID";
var oDataset = MY[DATASET_NONE];
var idValue = countryID;
oFields.push({input: input, datasetName: oDataset.datasetName, dataRowIndex: idValue});
//msg("renderAddress(): set " + input + ' to datasetName=' + oDataset.datasetName + ', index='+idValue);
var input = "regionID";
var oDataset = MY[DATASET_NONE];
var idValue = regionID;
MY[DATASET_REGION].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['countryID']=='"+countryID+"'"}];
oFields.push({input: input, datasetName: oDataset.datasetName, dataRowIndex: idValue});
msg("renderAddress(): set " + input + ' to datasetName=' + oDataset.datasetName + ', index='+idValue);
var input = "cityID";
var oDataset = MY[DATASET_NONE];
var idValue = cityID;
MY[DATASET_CITY].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['regionID']=='"+regionID+"'"}];
oFields.push({input: input, datasetName: oDataset.datasetName, dataRowIndex: idValue});
msg("renderAddress(): set " + input + ' to datasetName=' + oDataset.datasetName + ', index='+idValue);
var idValue = this.setDatasetId();
var input = "streetID";
var oDataset = this;
MY[DATASET_STREET].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']=='"+cityID+"'"}];
oFields.push({input: input, datasetName: oDataset.datasetName, dataRowIndex: idValue});
msg("renderAddress(): set " + input + ' to datasetName=' + oDataset.datasetName + ', index='+idValue);
var input = "locationID";
var oDataset = this;
MY[DATASET_RESORT].inputs.selectField.selectConfig['matchArray'] = [{eval: "oData[dataIndex]['cityID']=='"+cityID+"'"}];
oFields.push({input: input, datasetName: oDataset.datasetName, dataRowIndex: idValue});
msg("renderAddress(): set " + input + ' to datasetName=' + oDataset.datasetName + ', index='+idValue);
// Render all inputs
//msg("renderAddress(): oFields:: " + serializeArray(oFields));
var sId = "address";
var sClass = "";
//var oContent = MVRZ.util.render.inputs(MY[DATASET_NONE].inputs.fields, MY[DATASET_NONE], '', sId, sClass);
var oContent = MVRZ.util.render.inputs(oFields, '', '', sId, sClass);
if(typeof(oContent)!='undefined') oAppendTo.appendChild(oContent);
}
this.renderAddress = function renderAddress(oElAppendTo, argArray) {
msg("renderAddress()");
// Ensure that all datasets are loaded
MY[DATASET_RESORT].load();
MY[DATASET_STREET].load();
MY[DATASET_CITY].load();
MY[DATASET_REGION].load();
MY[DATASET_COUNTRY].load();
this.elAppendTo_renderAddress = oElAppendTo;
this.argArray_renderAddress = argArray;
// Find the dataset value for all parts of the address - generated from the streetId or locationId
this.renderit = function renderit(oThis) {
MVRZ.util.event.unsubscribe(EVENT_CONNECTION_PROCESSED, oThis.datasetName);
if(typeof(oThis.elAppendTo_renderAddress)!='object') {
var oAppendTo = document.getElementById(oThis.elAppendTo_renderAddress);
} else var oAppendTo = oThis.elAppendTo_renderAddress;
if(typeof(oThis.argArray_renderAddress)!='undefined') {
var argArray = oThis.argArray_renderAddress;
} else var argArray = new Object();
if (typeof(argArray['sIntroHtml']) != 'undefined') {
oAppendTo.innerHTML = argArray['sIntroHtml'];
} else {
oAppendTo.innerHTML = '';
}
// Prepare the address data
var input;
var propertyID = oThis.setDatasetId();
var streetID = oThis.get(propertyID, "streetID", "ID")
var locationID = oThis.get(propertyID, "locationID", "ID")
var cityID = MY[DATASET_STREET].get(streetID, "cityID", "ID");
var regionID = MY[DATASET_CITY].get(cityID, "regionID", "ID");
var countryID = MY[DATASET_REGION].get(regionID, "countryID", "ID");
MVRZ.data.object[DATASET_NONE] = new Object();
MY[DATASET_NONE] = new datasetObject(DATASET_NONE);
with (MY[DATASET_NONE].inputs) {
fields['countryID'] = new s('countryID', INPUT_TYPE_SELECT, "Country", '', true, null, null, MY[DATASET_COUNTRY]);
fields['countryID'].fnOnChange = oThis.updateTheAddress;
fields['countryID'].onlyChangeHandler = true;
fields['regionID'] = new s('regionID', INPUT_TYPE_SELECT, "Region/State", '', true, null, null, MY[DATASET_REGION]);
fields['regionID'].fnOnChange = oThis.updateTheAddress;
fields['regionID'].onlyChangeHandler = true;
//fields['regionID'].canAddNew = true;
fields['regionID'].selectConfig = {canAddNew: true};
input = 'countryID';
id = MVRZ.util.encodeInputId(DATASET_NONE, 0, 0, input)
fields['regionID'].addNewArgs = [{name: input, eval: "document.getElementById('"+id+"').value"}];
fields['cityID'] = new s('cityID', INPUT_TYPE_SELECT, "City", '', true, null, null, MY[DATASET_CITY]);
fields['cityID'].fnOnChange = oThis.updateTheAddress;
fields['cityID'].onlyChangeHandler = true;
//fields['cityID'].canAddNew = true;
fields['cityID'].selectConfig = {canAddNew: true};
input = 'regionID';
id = MVRZ.util.encodeInputId(DATASET_NONE, 0, 0, input)
fields['cityID'].addNewArgs = [{name: input, eval: "document.getElementById('"+id+"').value"}];
}
MY[DATASET_NONE].set(0, 'countryID', countryID);
MY[DATASET_NONE].set(0, 'regionID', regionID);
MY[DATASET_NONE].set(0, 'cityID', cityID);
MY[DATASET_NONE].inputs.appendInputs = true;
MY[DATASET_NONE].inputs.lastInputCount = MY[DATASET_PROPERTY].lastInputCount;
oThis.renderTheAddress(oAppendTo, countryID, regionID, cityID);
//MVRZ.util.render.input(oInput, "", streetID, MY[DATASET_STREET]);
}
if(!MVRZ.util.haveConnectionsCompleted(this.renderit, this)) {
MVRZ.util.event.subscribe(EVENT_CONNECTION_PROCESSED, this.datasetName, MVRZ.util.haveConnectionsCompleted, this.renderit, this);
}
}
msg('Property('+this.datasetName+') - DONE');
}
MY.fnInit[DATASET_REQUESTSNOTDONE] = function initRequestsDone(argArray) {
msg('fnInit:'+this.datasetName);
this.emptyNotice = "No requests";
this.loadingNotice = "Getting requests...";
this.inputs.forDisplay = this.forDisplay;
this.inputs.uniqueField = "ID";
this.inputs.ignoreRemoteIdField = false;
this.inputs.editDivClass = "mvrz-compact";
this.inputs.viewDivClass = "mvrz-compact";
////this.inputs.whenIdNotSet = INPUT_WHENIDNOTSET_PICKFIRST;
// Data Table setup
this.inputs.dataTableConfig = new Object({
selectionMode: "singlecell"
});
this.tableCfg = {
rowselects: true,
//buttons: [
// {label: "Old Delete", type: BUTTON_TYPE_TEXT, onclick: {fn: this.handleDatatableAction, arg: {datasetName: this.datasetName}}}
//],
actions: [
//{actionType: ACTION_TYPE_BUTTON,
// button: {label: "Delete", type: BUTTON_TYPE_TEXT, onclick: {fn: this.handleDatatableAction, action: ACTION_TABLE_DELETE}}
//},
{actionType: ACTION_TYPE_SELECT,
//preText: " Mark as ",
select: MY[DATASET_REQUEST_STATUS].inputs.selectField,
selectLabelField: 'actionName',
button: {label: "Apply", type: BUTTON_TYPE_PUSHMAIN, onclick: {fn: function(mvrzArgs) {
MY[DATASET_REQUESTSNOTDONE].handleDatatableAction(mvrzArgs);
}}}
},
]
}
/*
this.onEventSelectRow = function(oArgs) {
// Scope is the datatable
// Update the editable display with the new record
msg(DATASET_REQUESTSNOTDONE+': onEventSelectRow()');
var oRecord = this.getRecord(oArgs.target);
//var idField = this.inputs.uniqueField;
var idField = "ID";
var recordIndex = oRecord.getData(idField);
MY[DATASET_REQUESTSNOTDONE].setDatasetId(recordIndex);
//alert(idField + "=" + recordIndex);
this.unselectAllRows();
this.selectRow(this.getRow(oArgs.target));
msg(DATASET_REQUESTSNOTDONE+': calling fnFireEventChange()');
MY[DATASET_REQUESTSNOTDONE].fnFireEventChange(this);
////renderQuotesPage('', PANE_QUOTES_LIST, {idValue: recordIndex});
}
this.inputs.dataTableSubscribe = new Object();
this.inputs.dataTableSubscribe['rowClickEvent'] = this.onEventSelectRow;
*/
this.inputs.fields['ID'] = new s('ID', "id");
// Rest of the input are filled a preRender time as they depend on the type
////this.renderForEdit = renderForEdit;
//this.renderForView = renderForView;
this.getFullName = function getFullName(elLiner, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_REQUESTSNOTDONE];
msg("getFullName(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
if(typeof(oRecord)!='undefined' && oRecord != null) {
var recordIndex = oRecord.getData(oDataset.inputs.uniqueField);
var fName = oDataset.get(recordIndex, "firstName", 'ID');
var lName = oDataset.get(recordIndex, "lastName", 'ID');
var val = '';
if(typeof(fName)!='undefined') val = fName;
if(typeof(lName)!='undefined' && lName.length) {
if(val.length) val += " ";
val += lName;
}
} else {
val = "?";
}
if(val.length==0) val = "?";
msg("getFullName() returning " + val);
if(typeof(elLiner)=='object' && elLiner!=null) elLiner.innerHTML = val;
else return val;
}
this.getSummary = function getSummary(elLiner, oRecord, oColumn, oData) {
var oDataset = MY[DATASET_REQUESTSNOTDONE];
msg("getSummary(,"+oRecord+","+oColumn+","+oData+"):"+oDataset.datasetName);
if(typeof(oRecord)!='undefined' && oRecord != null) {
var recordIndex = oRecord.getData(oDataset.inputs.uniqueField);
if(recordIndex>0) {
var submitTimestamp = oDataset.get(recordIndex, "submitTimestamp", 'ID')
var arrivalDate = oDataset.get(recordIndex, "arrivalDate", 'ID');
var nights = oDataset.get(recordIndex, "nights", 'ID');
var bedrooms = oDataset.get(recordIndex, "bedrooms", 'ID');
var email = oDataset.get(recordIndex, "email", 'ID');
var fName = oDataset.get(recordIndex, "firstName", 'ID');
var lName = oDataset.get(recordIndex, "lastName", 'ID');
var sBeds = '';
if(typeof(bedrooms)!='undefined' && bedrooms>0) sBeds = " ["+bedrooms+" bdrm]";
var name = '';
if(typeof(fName)!='undefined') name = fName;
if(typeof(lName)!='undefined' && lName.length) {
if(name.length) name += " ";
name += lName;
}
// Recent time
var recentTime = "" + MVRZ.util.formatter.timestamp.formatRecent(submitTimestamp) + "";
var l1='';
if(name.length==0) l1 = email;
else l1 = name;
if(l1.length==0) l1 = "No name or email";
var l2 = 'Arriving: ' + (arrivalDate.length>0 && arrivalDate !== '0000-00-00' ? arrivalDate : '?') + " for ";
l2 += (nights>0 ? nights : "?") + " nights" + sBeds;
val = recentTime + "
" + l1 + "
";
val += "
" + l2 + "
";
} else {
val = "Request data has not been completed";
}
} else {
val = "?";
}
if(val.length==0) val = "?";
msg("getFullName() returning " + val);
if(typeof(elLiner)=='object' && elLiner!=null) {
elLiner.innerHTML = "
" + getContentWithMore(val) + "
";
} else return val;
}
this.preRender = function() {
msg('Request preRender '+this.datasetName);
// Define the inputs
//this.viewList = new Array("ID","submitTimestamp", "sourceID", 'arrivalDate', 'nights', 'bedrooms', "name", 'email');
this.viewList = ["ID","summary"];
this.oConfig.oFilter["ID"] = "!=0";
this.inputs.fields['ID'] = new s('id', INPUT_TYPE_HIDDEN, "ID");
this.inputs.fields['ID'].isHidden = true;
this.inputs.fields['summary'] = new s('summary', this.getSummary, "Inquiry Summary", "", false, v.isAlpha);
this.inputs.fields['summary'].noEditRender = true;
this.inputs.fields['summary'].readonly = true;
this.inputs.fields['summary'].formatter = this.getSummary;
this.inputs.fields['summary'].sortable = false;
this.inputs.fields['summary'].notOnServer = true;
this.inputs.fields['submitTimestamp'] = new s('submitTimestamp', INPUT_TYPE_TIMESTAMP, "Submitted", "", false );
//this.inputs.fields['submitTimestamp'].formatter = MVRZ.util.formatter.DataTable.timestamp;
this.inputs.fields['submitTimestamp'].readonly = true;
//this.inputs.fields['submitTimestamp'].noEditRender = true;
this.inputs.fields['submitTimestamp'].defaultVal = getTimestampNow();
this.inputs.fields['submitDateTime'] = new s('submitDateTime', INPUT_TYPE_DATETIME, "Submitted", "", false );
//this.inputs.fields['submitTimestamp'].formatter = MVRZ.util.formatter.DataTable.timestamp;
this.inputs.fields['submitDateTime'].noEditRender = true;
this.inputs.fields['submitDateTime'].readonly = true;
this.inputs.fields['submitDateTime'].defaultVal = MVRZ.util.formatter.datetime.unformat();
this.inputs.fields['propertyID'] = new s('propertyID', INPUT_TYPE_SELECT, "Property", "Select the property from the list.", false, null, null, MY[DATASET_PROPERTY] );
this.inputs.fields['propertyID'].selectConfig = {zeroSelect: '-- Any --'};
this.inputs.fields['firstName'] = new s('firstName', INPUT_TYPE_TEXT, "First Name", "Inquirer's first Name", false, v.isAlphaNumeric);
this.inputs.fields['lastName'] = new s('lastName', INPUT_TYPE_TEXT, "Last Name", "Inquirer's last Name", false, v.isAlphaNumeric);
this.inputs.fields['name'] = new s('name', this.getFullName, "Name", "Your Full Name", false, v.isAlphaNumeric);
this.inputs.fields['name'].noEditRender = true;
this.inputs.fields['name'].formatter = this.getFullName;
//this.inputs.fields['name'].sortable = true;
this.inputs.fields['email'] = new s('email', INPUT_TYPE_TEXT, "Email", "Email address", false, v.isEmail);
this.inputs.fields['countryID'] = new s('countryID', INPUT_TYPE_SELECT, "Country", "Select the country from the list.", false, null, null, MY[DATASET_COUNTRY] );
this.inputs.fields['countryID'].selectConfig = {zeroSelect: '-- Choose --'};
this.inputs.fields['exchangeID'] = new s('exchangeID', INPUT_TYPE_SELECT, "Currency", "Select the currency from the list.", false, null, null, MY[DATASET_EXCHANGE] );
this.inputs.fields['exchangeID'].selectConfig = {sortByFieldName: 'name', zeroSelect: '-- Choose --'};
this.inputs.fields['exchangeID'].selectConfig['matchArray'] = [{eval: "oData[dataIndex]['isIncluded']!='0'"}];
this.inputs.fields['sourceID'] = new s('sourceID', INPUT_TYPE_SELECT, "Direct Source", "Select the direct source of this referral - where it came from straight to you.", false, null, null, MY[DATASET_SOURCE] );
this.inputs.fields['sourceID'].selectConfig = {zeroSelect: '-- Choose --'};
this.inputs.fields['source2ID'] = new s('source2ID', INPUT_TYPE_SELECT, "Original Source", "Select the in-direct source of this referral - where the inquirer first found you. They may then have gone to your website and inquired directly from there", false, null, null, MY[DATASET_SOURCE] );
this.inputs.fields['source2ID'].selectConfig = {zeroSelect: '-- Choose --'};
function sourceFormatter(elLiner, oRecord, oColumn, oData){
var val=MY[DATASET_SOURCE].get(oData, "abbreviation");
if(typeof(elLiner)=='object' && elLiner!=null) elLiner.innerHTML = val;
else return val;
}
this.inputs.fields['sourceID'].formatter = sourceFormatter;
this.inputs.fields['source2ID'].formatter = sourceFormatter;
this.inputs.fields['bedrooms'] = new s('bedrooms', INPUT_TYPE_TEXT, "Bedrooms (minimum)", "Number of bedrooms required (minimum).", false, v.isNumeric );
this.inputs.fields['arrivalFlexibility'] = new s('arrivalFlexibility', INPUT_TYPE_CHECKBOX, "Flexibility", "Does the inquirer have flexibility in their arrival date?" );
this.inputs.fields['arrivalFlexibility'].notOnServer = true;
this.inputs.fields['arrivalFlexibility'].setVal = function(oArg){
var val1 = MY[DATASET_REQUESTSNOTDONE].get(oArg.idValue, 'arrivalDate', MY[DATASET_REQUESTSNOTDONE].getUniqueField());
var val2 = MY[DATASET_REQUESTSNOTDONE].get(oArg.idValue, 'arrival2Date', MY[DATASET_REQUESTSNOTDONE].getUniqueField());
if(val1 === val2) return 0;
else return 1;
}
this.inputs.fields['arrivalFlexibility'].callback = {changed:{action: 'updateArrival2', groupId: 'mvrz-flexibility'}};
this.inputs.fields['arrivalDate'] = new s('arrivalDate', INPUT_TYPE_DATE, "Arriving", "Arrival date (earliest)", true, v.isDate );
this.inputs.fields['arrivalDate'].reference = {date:{earliest: new Date()}};
this.inputs.fields['arrival2Date'] = new s('arrival2Date', INPUT_TYPE_DATE, "Arriving (latest)", "Arrival date (latest)", false, v.isDate );
this.inputs.fields['arrival2Date'].reference = {date:{init: {input:'arrivalDate'}, earliest: new Date()}};
this.inputs.fields['departureDate'] = new s('departureDate', INPUT_TYPE_DATE, "Departing", "Departure date", false, v.isDate );
this.inputs.fields['departureDate'].noEditRender = true;
this.inputs.fields['nights'] = new s('nights', INPUT_TYPE_NUMBER, "Nights", "Nights wanted (minimum).", true, v.isGEToValue, 1 );
this.inputs.fields['nights2'] = new s('nights2', INPUT_TYPE_NUMBER, "Nights (max)", "Nights wanted (maximum).", false, v.isNumeric, 1 );
this.inputs.fields['adults'] = new s('adults', INPUT_TYPE_NUMBER, "Adults", "Number of Adults in group.", false, v.isNumeric );
this.inputs.fields['children'] = new s('children', INPUT_TYPE_NUMBER, "Children", "Number of Children in group.", false, v.isNumeric );
this.inputs.fields['infants'] = new s('infants', INPUT_TYPE_NUMBER, "Infants", "Number of Infants in group.", false, v.isNumeric );
// Telephone numbers
this.inputs.fields['telephoneDay'] = new s('telephone1', INPUT_TYPE_TELEPHONE, "Telephone", '', false, v.isPhone );
// Text/Notes etc
//this.inputs.fields['notes'] = new s('notes', INPUT_TYPE_TEXTAREA, "Request Notes", "Request notes taken from the email.");
//this.inputs.fields['notes'].style['height'] = '2em';
this.inputs.fields['responseNotes'] = new s('responseNotes', INPUT_TYPE_TEXTAREA, "Response Notes", "Response text for inserting into the quotation email as the '{{ResponseNotes}}' token.");
this.inputs.fields['responseNotes'].style['height'] = '10em';
this.inputs.fields['responseNotes'].noRenderEdit = true;
this.inputs.fields['responseNotes2'] = new s('responseNotes2', INPUT_TYPE_TEXTAREA, "Response Notes2", "Response text for inserting into the quotation email as the '{{ResponseNotes2}}' token.");
this.inputs.fields['responseNotes2'].style['height'] = '10em';
this.inputs.fields['responseNotes2'].noRenderEdit = true;
//this.inputs.fields['text'] = new s('text', INPUT_TYPE_TEXTAREA, "Original Email", "The orginal inquiry email.");
//this.inputs.fields['text'].readonly = true;
//this.inputs.fields['text'].formatter = MVRZ.util.formatter.html.format;
//this.inputs.fields['text'].noRenderEdit;
// Edit rendering layout
var styleName = {width:"45%"};
var styleDate = {width:"75%"};
var styleNights = {width:"15%"};
var styleACI = {width:"27%"};
this.inputs.editList = [
'submitTimestamp', 'propertyID',
{
label: 'First/Last Name',
help: "",
fields: [
{field:'firstName', preText: '', postText: "", style: styleName},
{field:'lastName', preText: '/', postText: "", style: styleName}
]
},
{
label: 'Flexible Dates?',
help: this.inputs.fields['arrivalFlexibility'].help,
fields: [
{field:'arrivalFlexibility', preText: '', postText: ""}
]
},
{
label: 'Arriving/Nights',
help: "Arrival date and number of nights. When flexible, enter the earliest arrival date and minimum number of nights",
fields: [
{field:'arrivalDate', preText: '', postText: "", style: styleDate},
{field:'nights', preText: '/', postText: "", style: styleNights}
]
},
{
groupId: 'mvrz-flexibility',
updateArrival2: {
field: 'arrivalFlexibility', cond: '!=0',
ifTrue: {
//groupStyle:{display:"table-row"}
set: {arrival2Date: ''}
},
ifFalse: {
//groupStyle:{display:"none"},
set: {arrival2Date: function(oArg) {
return MY[DATASET_REQUESTSNOTDONE].get(oArg.idValue, 'arrivalDate', MY[DATASET_REQUESTSNOTDONE].getUniqueField());
}
}
}
},
label: 'Arriving/Nights (max)',
help: "When flexible, enter the latest arrival date and max number of nights",
fields: [
{field:'arrival2Date', preText: '', postText: "", style: styleDate},
{field:'nights2', preText: '/', postText: "", style: styleNights}
]
},
'email', 'countryID', 'exchangeID', 'sourceID', 'source2ID','bedrooms',
{
label: 'Adult/Child/Infant #',
help: "Number of adults, children and infants",
fields: [
{field:'adults', preText: '', postText: "", style: styleACI},
{field:'children', preText: '/', postText: "", style: styleACI},
{field:'infants', preText: '/', postText: "", style: styleACI}
]
}, 'telephoneDay'
];
//if(this.contactType == CONTACT_TYPE_ACCOUNT) {
msg('Contact preRender viewlist: '+serializeArray(this.viewList));
return true;
}
msg('Contact('+this.datasetName+') - DONE');
}
function getSortedDataObj(oData, field, inputType, fnSort) {
// Need to do an index sort
msg('getSortedDataObj(oData, '+field+','+typeof(fnSort)+')');
var aRefData = new Array();
var aSortData = new Array();
var aData = new Array();
var counter = 0;
//var fnParser = MVRZ.util.parser.getParser(inputType);
if(typeof(fnSort)!='function') fnSort = MVRZ.util.sorter.getSorter(inputType, field);
for(dataRowIndex in oData) {
aRefData[counter] = oData[dataRowIndex];
counter++;
}
// Now sort
if(typeof(fnSort)=='function') {
var aSortedData = aRefData.sort(fnSort);
} else {
var aSortedData = aRefData.sort();
}
return aSortedData;
}
function getFilteredDataObj(oDataset) {
msg('getFilteredDataObj('+oDataset.datasetName+')');
// Filter the data as needed
var rowCount = 0;
var jsonDataObj = oDataset.dataset[JSON_RESPONSE_INDEX_DATA];
var jsonDataObjFiltered = new Array();
var oFilter = oDataset.oConfig.oFilter;
if(typeof(oFilter)=='object') {
for(dataRowIndex in jsonDataObj) {
var failed = false;
for(filter in oFilter) {
var evalStr = "var result = ("+jsonDataObj[dataRowIndex][filter]+oFilter[filter]+")";
//msg('xFILTERING: '+dataRowIndex+','+filter+':'+evalStr);
eval(evalStr);
if(!result) {
msg(' - failed filter eval');
failed = true;
break;
}
}
if(failed) continue; // Next row
// If we get here then the filter has passed
msg('FILTERING: Adding row to filtered data: '+dataRowIndex+", position="+jsonDataObj[dataRowIndex]['position']);
jsonDataObjFiltered[rowCount++] = jsonDataObj[dataRowIndex];
//jsonDataObjFiltered[dataRowIndex] = jsonDataObj[dataRowIndex];
}
} else {
jsonDataObjFiltered = jsonDataObj;
}
msg('getFilteredDataObj() - done, returning #elements=' + jsonDataObjFiltered.length);
return jsonDataObjFiltered;
}
var gOffsetX;
datasetObject.prototype.renderForView = function renderForView(elContentId, idValue, renderFresh) {
//var elContent = this.renderInfo['elContent'];
if (typeof(elContentId) == 'undefined' || elContentId == null || elContentId.length == 0) {
elContentId = this['elContentIdLast'+DISPLAY_TYPE_VIEW];
}
var el = document.getElementById(elContentId);
if(typeof(el)=='undefined' || el==null) {
msg("renderForEdit() no element in DOM for elContentId="+elContentId);
return;
}
this.viewElContentIdLast = el.id;
var argArray = this.renderInfo[elContentId]['argArray'];
//var elContent = this.renderInfo[elContentId]['elContent'];
var oSteps = argArray['oSteps'];
var displayType = argArray[DISPLAY_TYPE];
var viewType = argArray[VIEW_TYPE];
var idValue = argArray['idValue'];
var sIntroHtml = argArray['sIntroHtml'];
var sOutroHtml = argArray['sOutroHtml'];
var refreshDatasource = argArray['refreshDatasource'];
var dataId = argArray['dataId'];
if(typeof(dataId)=='undefined') dataId = elContentId;
// Pre-render function?
msg('renderForView::Calling doPreRender');
if(!this.doPreRender(idValue, el, elContentId)) {
return;
}
// Filter the data as needed
var rowCount = new Array();
var oDatasetData = this.dataset[JSON_RESPONSE_INDEX_DATA];
var oDatasetDataFiltered = new Array();
var oFilter = this.oConfig.oFilter;
var maxX = new Array();
var maxY = new Array();
var minX = new Array();
var minY = new Array();
//maxX = maxY = 0;
//minX = minY = Number.MAX_VALUE;
//var seriesDef = new Array();
if (viewType == VIEW_TYPE_CHART) {
var fieldX = this.inputs.chartSettings.xField;
var fieldY = this.inputs.chartSettings.yField;
var setpointStyleHeatTo = this.inputs.chartSettings.setpointStyleHeatTo;
var setpointStyleCoolTo = this.inputs.chartSettings.setpointStyleCoolTo;
var seriesField = this.inputs.chartSettings.seriesField;
var seriesFieldLabelBase = this.inputs.chartSettings.seriesFieldLabelBase;
var seriesFieldColors = this.inputs.chartSettings.seriesFieldColors;
if (typeof(this.inputs.chartSettings.seriesDef) != 'undefined') {
for(var i in this.inputs.chartSettings.seriesDef) {
seriesDef[i] = new Object();
for(item in this.inputs.chartSettings.seriesDef[i]) seriesDef[i][item] = this.inputs.chartSettings.seriesDef[i][item];
}
}
}
var aSeries = new Array();
var splitIndexMax = 0;
var splitIndex = 0;
var aSplitIndexLookup = new Array();
var aSplitIndexReverseLookup = new Array();
var datasetSplitField = this.inputs.datasetSplitField;
for(dataRowIndex in oDatasetData) {
if (typeof(oFilter) == 'object') {
var failed = false;
for (filter in oFilter) {
//if(oFilter instanceof Array) sCompare = oFilter[filter];
//else sCompare = filter;
var rhs = oFilter[filter];
if(typeof(rhs)=='object') {
var fn = rhs.fn;
if(typeof(fn)=='function') {
var arg = rhs.arg;
if(typeof(arg)!='undefined') {
var fields = arg.fields;
var oArgs = {};
if (fields instanceof Array) {
for(var field in fields) {
oArgs[fields[field]] = oDatasetData[dataRowIndex][fields[field]];
}
}
}
// Call the function with args
failed = !fn(oArgs);
}
} else {
var sCompare = rhs;
var evalStr = "var result = (oDatasetData[dataRowIndex][filter] " + sCompare + ")";
//var evalStr = "var result = ("+oDatasetData[dataRowIndex][filter]+"!=0"+")";
msg('yFILTERING: ' + dataRowIndex + ',' + filter + ':' + evalStr);
eval(evalStr);
//alert('FILTERING: '+dataRowIndex+','+filter+':'+oDatasetData[dataRowIndex][filter]+'::'+evalStr + ' = '+result);
if (!result) {
msg(' - failed filter eval with oFilter['+filter+']:'+oDatasetData[dataRowIndex][filter]+sCompare);
failed = true;
break;
}
}
}
if (failed)
continue; // Next row
}
// If we get here then the filter has passed
msg('FILTERING: Adding row to filtered data: '+dataRowIndex);
if (typeof(datasetSplitField) != 'undefined') {
splitIndexValue = oDatasetData[dataRowIndex][datasetSplitField];
if (typeof(splitIndexValue) == 'undefined') continue;
splitIndex=aSplitIndexLookup[splitIndexValue];
if (typeof(splitIndex) == 'undefined') {
splitIndex = splitIndexMax;
aSplitIndexLookup[splitIndexValue] = splitIndex;
aSplitIndexReverseLookup[splitIndex] = splitIndexValue;
splitIndexMax++;
}
}
else
splitIndex = 0;
if (typeof(oDatasetDataFiltered[splitIndex]) == 'undefined') {
oDatasetDataFiltered[splitIndex] = new Array();
rowCount[splitIndex] = 0;
}
oDatasetDataFiltered[splitIndex][rowCount[splitIndex]++] = oDatasetData[dataRowIndex];
//jsonDataObjFiltered[dataRowIndex] = jsonDataObj[dataRowIndex];
// Capture min/max values
if(viewType == VIEW_TYPE_CHART) {
switch(this.inputs.fields[fieldX].inputType){
case(INPUT_TYPE_DATE):
case(INPUT_TYPE_DATETIME):
//popupInfo('min/max X date/time:'+dataRowIndex+'::'+this.inputs.fields[fieldX].inputType);
if(typeof(maxX[splitIndex])=='undefined') maxX[splitIndex] = MVRZ.util.parser.date(MIN_DATE);
if(typeof(minX[splitIndex])=='undefined') minX[splitIndex] = MVRZ.util.parser.date(MAX_DATE);
var thisDate = MVRZ.util.parser.date(oDatasetData[dataRowIndex][fieldX]);
if (typeof(thisDate.getTime) == 'function') {
var thisTime = thisDate.getTime();
} else {
//popupErr("thisDate.getTime not a function, dataRowIndex="+dataRowIndex+', fieldX='+fieldX);
break;
}
//popupInfo("thisDate="+thisDate+", maxX="+maxX+", minX="+minX+" :: maxY="+maxY+", minY="+minY);
//var thisVal = Date(oDatasetData[dataRowIndex][fieldX]);
if(thisTime < minX[splitIndex].getTime()) minX[splitIndex] = thisDate;
if(thisTime > maxX[splitIndex].getTime()) maxX[splitIndex] = thisDate;
//maxX = Math.max(maxX,oDatasetData[dataRowIndex][fieldX]);
//minX = Math.min(minX,oDatasetData[dataRowIndex][fieldX]);
break;
default:
//popupInfo('min/max X Default:'+dataRowIndex+'::'+this.inputs.fields[fieldX].inputType);
if(typeof(maxX[splitIndex])=='undefined') maxX[splitIndex] = 0;
if(typeof(minX[splitIndex])=='undefined') minX[splitIndex] = Number.MAX_VALUE;
maxX[splitIndex] = Math.max(maxX[splitIndex],oDatasetData[dataRowIndex][fieldX]);
minX[splitIndex] = Math.min(minX[splitIndex],oDatasetData[dataRowIndex][fieldX]);
}
if (typeof(this.inputs.chartSettings.yMinMaxArray) != 'undefined' && this.inputs.chartSettings.yMinMaxArray.length) {
if (typeof(maxY[splitIndex]) == 'undefined')
maxY[splitIndex] = 0;
if (typeof(minY[splitIndex]) == 'undefined')
minY[splitIndex] = Number.MAX_VALUE;
for (fIndex in this.inputs.chartSettings.yMinMaxArray) {
field = this.inputs.chartSettings.yMinMaxArray[fIndex];
//field = fieldY;
//popupInfo(dataRowIndex+"::"+splitIndex+": field="+field+", data="+oDatasetData[dataRowIndex][field]);
maxY[splitIndex] = Math.max(maxY[splitIndex], oDatasetData[dataRowIndex][field]);
minY[splitIndex] = Math.min(minY[splitIndex], oDatasetData[dataRowIndex][field]);
}
}
}
}
var seriesDef = new Array();
var chart = new Array();
var aDivId = new Array();
var numCharts = splitIndexMax;
var tabView;
this.dataSource = new Array();
MVRZ.oDatasetDataFiltered = oDatasetDataFiltered;
MVRZ.seriesDef = seriesDef;
MVRZ.numCharts = numCharts;
MVRZ.chart = new Array();
//el.innerHTML = '';
if(typeof(sIntroHtml)!='undefined') el.innerHTML += sIntroHtml;
if(!oDatasetDataFiltered.length) {
el.innerHTML += getEmptyNotice(this.emptyNotice);
return;
}
function addColumn(oDataset, oCfg, pInputName, colDefs, schemaFields, viewType) {
//var inputName = viewList[input];
//var formatter = null;
var formatter;
var parser;
var readonly = oCfg ? (oCfg.readonly ? true : false) : false;
var sortable = oCfg ? (typeof(oCfg.sortable)=='undefined' ? true : oCfg.sortable) : true; // Default to true - why not?
var inputName = pInputName;
var editor, isHidden, children;
if(typeof(pInputName)==='object') {
children = new Array();
for(var ch in inputName.children) {
addColumn(oDataset, oDataset.inputs.fields[inputName.children[ch]], inputName.children[ch], children, schemaFields);
}
if(typeof(oCfg)=='undefined') oCfg = pInputName;
inputName = null;
}
msg('renderForView: Loop '+ inputName);
if(inputName!=null) {
if(viewType!=VIEW_TYPE_CHART) {
if(typeof(oCfg.formatter) != 'undefined') {
formatter = oCfg.formatter;
} else {
var oFormat = MVRZ.util.formatter[oCfg.inputType];
if(typeof(oFormat) != 'undefined' && typeof(oFormat.formatTableCell) != 'undefined') {
formatter = oFormat.formatTableCell;
} else {
if(typeof(MVRZ.util.formatter.DataTable[oCfg.inputType])!='undefined') {
formatter = MVRZ.util.formatter.DataTable[oCfg.inputType];
}
if(typeof(formatter)=='undefined' || formatter == null) formatter = MVRZ.util.formatter.getFormatter(oCfg.inputType);
}
}
//readOnly = true;
if(inputName==oDataset.inputs.uniqueField) {
var isNotEditable = true;
} else {
var isNotEditable = oCfg.isNotEditable;
}
editor = (readonly || isNotEditable) ? null : MVRZ.util.render.cellEditor(oDataset, inputName);
}
if(typeof(oCfg.parser) != 'undefined') {
parser = oCfg.parser;
} else {
var oParser = MVRZ.util.parser[oCfg.inputType];
if(typeof(oParser) != 'undefined') {
parser = oParser;
} else {
parser = MVRZ.util.parser.getParser(oCfg.inputType);
}
}
isHidden = typeof(oCfg.isHidden)=='undefined' ? false : oCfg.isHidden ;
schemaFields[schemaFields.length] = {
key: inputName,
parser: parser
};
}
// Label
var label = oCfg.label;
// Help text?
if(viewType!=VIEW_TYPE_CHART) {
var helpText = getHelpText(oCfg);
if(typeof(helpText)!='undefined' && helpText.length) {
var helpId = YAHOO.util.Dom.generateId();
var ttId = helpId + '-tt';
/*
var helpStr = '