var _bidSearchUrl = ""; var _bidDetailsUrl = ""; var _bidGrid; var _bidUrl = ""; var _searchParams = ""; var _dataTable; var _autoLoad = false; function buildSearchParameters() { var advertiseStartDate = String.empty; var advertiseEndDate = String.empty; var submissionStartDate = String.empty; var submissionEndDate = String.empty; var openingStartDate = String.empty; var openingEndDate = String.empty; if ($('input[name=advertised]:checked').size() > 0) { advertiseStartDate = $("#StartDate").val(); advertiseEndDate = $("#EndDate").val(); } if ($('input[name=submission]:checked').size() > 0) { submissionStartDate = $("#StartDate").val(); submissionEndDate = $("#EndDate").val(); } if ($('input[name=opening]:checked').size() > 0) { openingStartDate = $("#StartDate").val(); openingEndDate = $("#EndDate").val(); } _searchParams = getSearchParameters($("#Keyword").val(), advertiseStartDate, advertiseEndDate, submissionStartDate, submissionEndDate, openingStartDate, openingEndDate, $("#ProcurmentCategory").val(), $("#SubProcurmentCategory").val(), $("#Status").val(), $("#BidNumber").val(), $("#ObjectID").val(), $("#Agency").val(), $("#BidType").val()); return _searchParams; } function getSearchParameters(keyword, advertiseStartDate, advertiseEndDate, submissionStartDate, submissionEndDate, openingStartDate, openingEndDate, procurmentCategory, subProcurementCategory, status, bidNumber, objectId, agency, bidType, autoloadGrid) { var params = "?AppId=1" + ((bidNumber) ? "&BidNumber=" + bidNumber : "") + ((bidType) ? "&BidType=" + bidType : "") + ((agency) ? "&Agency=" + agency : "") + ((submissionStartDate) ? "&SubmissionStartDate=" + submissionStartDate : "") + ((submissionEndDate) ? "&SubmissionEndDate=" + submissionEndDate : "") + ((openingStartDate) ? "&OpeningStartDate=" + openingStartDate : "") + ((openingEndDate) ? "&OpeningEndDate=" + openingEndDate : "") + ((advertiseStartDate) ? "&AdvertiseStartDate=" + advertiseStartDate : "") + ((advertiseEndDate) ? "&AdvertiseEndDate=" + advertiseEndDate : "") + ((status) ? "&Status=" + status : "") + ((keyword) ? "&Keyword=" + keyword : "") + ((objectId) ? "&ObjectID=" + objectId : "") + ((procurmentCategory) ? "&ProcurementCategoryID=" + procurmentCategory : "") + ((subProcurementCategory) ? "&SubProcurementCategoryID=" + subProcurementCategory : "") + ((autoloadGrid) ? "&autoloadGrid=" + autoloadGrid : ""); return params; } function gridReload(controllerUrl, searchParam) { _dataTable.fnReloadAjax(controllerUrl + searchParam, null, true); } function SearchGrid() { gridReload(_bidSearchUrl, buildSearchParameters()); } function getUrlVars() { var vars = [], hash; var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); for (var i = 0; i < hashes.length; i++) { hash = hashes[i].split('='); vars.push(hash[0]); vars[hash[0]] = hash[1]; } return vars; } function returnSearch(returnUrl) { _searchParams = getSearchParameters(getUrlVars()["Keyword"], getUrlVars()["SubmissionStartDate"], getUrlVars()["SubmissionEndDate"], getUrlVars()["OpeningStartDate"], getUrlVars()["OpeningEndDate"], getUrlVars()["AdvertiseStartDate"], getUrlVars()["AdvertiseEndDate"], getUrlVars()["ProcurementCategoryID"], getUrlVars()["SubProcurementCategoryID"], getUrlVars()["Status"], getUrlVars()["BidNumber"], getUrlVars()["ObjectID"],getUrlVars()["Agency"], getUrlVars()["BidType"], true); window.location = returnUrl + "" + _searchParams; } function deleteBid(deleteUrl, id) { if (confirm('Are you sure you want to delete this Bid?')) { _searchParams = getSearchParameters(getUrlVars()["Keyword"], getUrlVars()["SubmissionStartDate"], getUrlVars()["SubmissionEndDate"], getUrlVars()["OpeningStartDate"], getUrlVars()["OpeningEndDate"], getUrlVars()["AdvertiseStartDate"], getUrlVars()["AdvertiseEndDate"], getUrlVars()["ProcurmentCategoryID"], getUrlVars()["SubProcurementCategoryID"], getUrlVars()["Status"], getUrlVars()["BidNumber"], getUrlVars()["ObjectID"], getUrlVars()["Agency"], getUrlVars()["BidType"], true); window.location = deleteUrl + "" + _searchParams + "&id=" + id; } else { return false; } return true; } function deleteAttachment(deleteUrl, id) { if (confirm('Are you sure you want to delete this Attachment?')) { _searchParams = getSearchParameters(getUrlVars()["Keyword"], getUrlVars()["SubmissionStartDate"], getUrlVars()["SubmissionEndDate"], getUrlVars()["OpeningStartDate"], getUrlVars()["OpeningEndDate"], getUrlVars()["AdvertiseStartDate"], getUrlVars()["AdvertiseEndDate"], getUrlVars()["ProcurmentCategoryID"], getUrlVars()["SubProcurementCategoryID"], getUrlVars()["Status"], getUrlVars()["BidNumber"], getUrlVars()["ObjectID"], getUrlVars()["Agency"], getUrlVars()["BidType"], true); $.getJSON(deleteUrl + "" + _searchParams + "&id=" + id, function(data) { $('#attachmentTable #' + id).remove(); }); } else { return false; } return true; } function deleteAttachment(id) { if (confirm('Are you sure you want to delete this Attachment?')) { _searchParams = getSearchParameters(getUrlVars()["Keyword"], getUrlVars()["SubmissionStartDate"], getUrlVars()["SubmissionEndDate"], getUrlVars()["OpeningStartDate"], getUrlVars()["OpeningEndDate"], getUrlVars()["AdvertiseStartDate"], getUrlVars()["AdvertiseEndDate"], getUrlVars()["ProcurmentCategoryID"], getUrlVars()["SubProcurementCategoryID"], getUrlVars()["Status"], getUrlVars()["BidNumber"], getUrlVars()["ObjectID"], getUrlVars()["Agency"], getUrlVars()["BidType"], true); $.getJSON("/dfa/contract_bid_search/Bid/DeleteBidAttachment/?id=" + id, function(data) { location.reload(); }); } else { return false; } return true; } function addAttachment(attachmentUrl, id, url, desc) { _searchParams = getSearchParameters(getUrlVars()["Keyword"], getUrlVars()["SubmissionStartDate"], getUrlVars()["SubmissionEndDate"], getUrlVars()["OpeningStartDate"], getUrlVars()["OpeningEndDate"], getUrlVars()["AdvertiseStartDate"], getUrlVars()["AdvertiseEndDate"], getUrlVars()["ProcurmentCategoryID"], getUrlVars()["SubProcurementCategoryID"], getUrlVars()["Status"], getUrlVars()["BidNumber"], getUrlVars()["ObjectID"], getUrlVars()["Agency"], getUrlVars()["BidType"], true); var jsonUrl = attachmentUrl + "" + _searchParams + "&id=" + id + "&url=" + url + "&desc=" + desc; $.getJSON(jsonUrl, function (data) { $('#attachmentTable').append('Attachments
' + data.desc + '
' + ' '); }); } function InitializeDataTable(searchUrl, detailsUrl, gridSelector) { _searchParams = buildSearchParameters(); _bidSearchUrl = searchUrl; _bidDetailsUrl = detailsUrl; _bidGrid = gridSelector; _dataTable = $(_bidGrid).dataTable({ "sDom": "rt", "bProcessing": true, "searching": false, "responsive": true, "bServerSide": true, "sAjaxSource": _bidSearchUrl + _searchParams, "deferLoading": 0, "iDisplayLength": 9999, "fnServerData": function(url, data, callback) { $.ajax({ "url": url, "data": data, "success": callback, "dataType": "json", "type": "POST", "cache": false, "error": function() { alert("DataTables warning: JSON data from server failed to load or be parsed. " + "This is most likely to be caused by a JSON formatting error."); } }); }, "aoColumns": [ { "mData": "Agency", "render": function (data, type, row) { if (data === "MPTAP" || data === "MS DEVELOPMENT AUTHORITY") return "MPTAP - ​*See attachment for details"; return data === "" ? "Statewide" : data; } }, { "mData": "BidNumber", "render": function(data, type, row) { return "" + data + ""; } }, { "mData": "ObjectID", "render": function(data, type, row) { if (data !== null) return "" + data + ""; return ""; } }, { "width": "20%", "mData": "VerNumber", "render": function(data, type, row) { return buildDescription(row); } }, { "mData": "BidStatus", "render": function(data, type, row) { return formatBidStatus(row); } }, { "mData": "AdvertiseDate", "render": function(data, type, row) { if (data !== null) return moment(data).format("MM/DD/YYYY"); return ""; } }, { "mData": "SubmissionDate", "render": function(data, type, row) { if (data !== null) return moment(data).format("MM/DD/YYYY"); return ""; } }, { "mData": "OpeningDate", "render": function(data, type, row) { if (data !== null) return moment(data).format("MM/DD/YYYY"); return ""; } }, { "mData": "BidID", "render": function(data, type, row) { if (row.BidType !== "MDA - RFx") return "View Contact" + ""; return ""; } } ], "aoColumnDefs": [ { "bSortable": false, "aTargets": [8] } ] }); if (getUrlVars()["autoloadGrid"] === 'true') SearchGrid(); } function formatBidStatus(row) { if (row.BidStatus !== "Closed") return row.BidStatus === "Awarded" ? "" + row.BidStatus + "" : "" + row.BidStatus + ""; return "" + row.BidStatus + ""; } function buildDescription(row) { var desc = ""; var descCheck = row.BidDescription.length >= 60 ? row.BidDescription.substring(0, 60) + "..." : row.BidDescription; desc += "

Major Procurement
" + row.ProcurementCategoryDescription + "

"; desc += "

" + descCheck + "

"; $(row.Attachments).each(function(index) { desc += "" + "Attachment - " + row.Attachments[index].Description + "" + "
"; }); return desc; } function formatPhone(text) { text = text.replace(/(\d{3})(\d{3})(\d{4})/, "($1) $2-$3"); return text; }