You are on page 1of 12

@Code ViewData("Title") = "Log Detail" End Code @*@Code ViewData("Title") = "SFA Home" End Code*@ <div id="divMenu" class="listMenu"

style="padding-top: 10%;"> <ul data-role="listview" data-inset="true"> <li onclick="resetId();">@Html.ActionLink("Log Details", "LogDetails")</ li> <li onclick="Savedlogs();">@Html.ActionLink("Saved logs", "SFA Logs")</l i> <li>@Html.ActionLink("Offline logs", "OfflineLogList")</li> <li onclick="window.open('http://mobile.corp.inside.tkr/Mobility/FAQ/ind ex.html')"><a href="#">Help</a></li> </ul> </div> <div id="divDataPages" > @section Save <div style="float: left; padding-top: 5px;"> <input type="submit" data-mini="true" data-theme="a" track="SFA Save" on click="return SaveLogDetails(false);" value="Save" /> </div> END section

@section Submit <div style="float: left; padding-top: 5px;" id="btnSubmit"> <input type="submit" data-mini="true" data-theme="a" track="SFA Submit" onclick="return SaveLogDetails(true);" value="Submit" /> </div> END section @*@section Sync <div style="float: right; padding-top: 5px; padding-right: 5px" id="SyncButton "> <input type="submit" data-mini="true" data-theme="a" track="SFA Sync" on click="return SyncLogDetails();" value="Sync" /> </div> END section*@ <script type="text/javascript"> @* var currentLog = new Log(); currentLog.id = '@Model.SFALog.ID'; currentLog.CustomerNo = '@Model.SFALog.CustomerNo'.trim(); currentLog.EndUserNo = '@Model.SFALog.EndUserNo'.trim(); currentLog.EndUserName = '@Model.SFALog.EndUserName'.trim(); var currentActionItem = null; var currentProductsService = null;*@

</script>

<br /> <div data-role="navbar" data-iconpos="left"> <ul> <li><a data-theme="a" data-icon="star" id="lnkTab1" href="#" onclick="ta bLogDetail1();" class="ui-btn-active">Account Info</a></li> <li><a data-theme="a" data-icon="info" id="lnkTab2" href="#" onclick="ta bLogDetail2();">Time Spend & Reporting</a></li> <li><a data-theme="a" data-icon="grid" id="lnkTab3" href="#" onclick="ta bLogDetail3();">Detail Log</a></li> </ul> </div> <div style="float: right; z-index: 2px;"> <b> <label style="font-size: small;" id="lblUserName"></label></b> </div> <div id="divLogDetail1" class="logContent"> @* @Html.Partial("LogDetails1")*@ </div> <div id="divLogDetail2" style="display: none" class="logContent"> @*@Html.Partial("LogDetails2")*@ </div> <div id="divLogDetail3" style="display: none" class="logContent"> @*@Html.Partial("LogDetails3")*@ </div> @Html.ActionLink("Invisible", "SaveLog", Nothing, New With {.style = "display:no ne", .id = "lnkSave"}) @Html.ActionLink("Invisible", "LogDetails2", Nothing, New With {.style = "displa y:none", .id = "lnkLogDetail2"}) @*@Html.ActionLink("Invisible", "CustomersView", Nothing, New With {.style = "di splay:none", .id = "lnkCustLogDetail"})*@ </div>

<script type="text/javascript"> //var idd //idd = id; $("#divDataPages").hide(); $("#OnlineMenu").hide(); function resetId() { // $("#divMenu").hide(); // $("#divDataPages").show(); } function Savedlogs() { $("#divMenu").hide(); $("#OnlineMenu").show(); } $(document).bind("pageinit", function () { $('#divMenu').parent().parent().find('#divHome').hide(); }); $(document).ready(function () { hideAllMessages();

$('.info').show() $('.info').animate({ bottom: "0" }, 500).delay(1000 + (500 * 3)).animate ({ bottom: -215 }, 5000, function () { $('.info').hide() }); // When message is clicked, hide it $('.message').click(function () { $(this).animate({ bottom: -215 }, 5000, function () { $('.info').hid e() }); }); }); </script> <script type="text/javascript"> $(document).bind('pagehide', function (event) { var pages = $('.ui-page'); for (var i = 0; i < pages.length; i++) { var page = $(pages[i]); try { if (page.attr("data-url").toLowerCase().indexOf('logdetails') >= 0 && page.attr("class").indexOf('ui-page-active') == -1) { page.remove(); } } catch (e) { } } }); $(document).ready(function () { hideAllMessages(); //alert(window.URL); //alert(urlAction.substr(11, urlAction.length - 1)); //urlAction = urlAction.substr(11, urlAction.length - 1); //hide submit button for offline mode //if (navigator.online) { // $("#btnSubmit").show(); //} //else { // $("#btnSubmit").hide(); //} }); var var var var var var lnkTab1 = $("#lnkTab1"); lnkTab2 = $("#lnkTab2"); lnkTab3 = $("#lnkTab3"); divLogDetail1 = $('#divLogDetail1'); divLogDetail2 = $('#divLogDetail2'); divLogDetail3 = $('#divLogDetail3');

function tabLogDetail1() { if (!divLogDetail1.is(':visible')) { hideAllControl(); divLogDetail1.slideToggle(); } }

function tabLogDetail2() { if (!divLogDetail2.is(':visible')) { hideAllControl(); divLogDetail2.slideToggle(); } } function tabLogDetail3() { if (!divLogDetail3.is(':visible')) { hideAllControl(); divLogDetail3.slideToggle(); } } function hideAllControl() { divLogDetail1.hide(); divLogDetail2.hide(); divLogDetail3.hide(); } function Navigate(tabId) { switch (tabId) { case 1: lnkTab1.click(); break; case 2: lnkTab2.click(); break; } return false; } function ValidateFields(currentLog) { var invalidLogType = IsInvalidSelect(currentLog.LogTypeID); if (contactTypes.is(':visible')) { invalidContactType = IsInvalidSelect(currentLog.ContactTypeID); } else { invalidContactType = false; } var invalidTrainingContent; var invalidTrainingDuration; var invalidNumberTrained; if (divTraining.is(':visible')) { invalidTrainingDuration = !((currentLog.TrainingDuration * 1) > 0); invalidNumberTrained = !((currentLog.NumberTrained * 1) > 0); } else { invalidTrainingDuration = false; invalidNumberTrained = false; } invalidTrainingContent = (invalidTrainingDuration && invalidNumberTraine d); var invalidCustomerName = (divCustomers.css('display') != 'none') && IsI nvalidSelect(currentLog.CustomerNo);

var invalidEndUserName = (divEndUser.css('display') != 'none') && IsInva lidSelect(currentLog.EndUserNo); var invalidLogSubject = IsEmpty(currentLog.LogSubject); var invalidExecutiveSummary = IsEmpty(currentLog.ExecutiveSummary); //var invalidHighLights = IsEmpty(currentLog.Highlights); var firstScreenInFocus = divLogDetail1.is(':visible'); var secScreenInFocus = divLogDetail2.is(':visible'); var thirdScreenInFocus = !(firstScreenInFocus || secScreenInFocus); var var var var var var var valMsgLogType = $("#valMsgLogType"); valMsgContactType = $("#valMsgContactType"); valMsgCustomerName = $("#valMsgCustomerName"); valMsgEndUser = $("#valMsgEndUserName"); valMsgLogSubject = $("#valMsgLogSubject"); valMsgExecutiveSummary = $("#valMsgExecutiveSummary"); valMsgHighlights = $("#valMsgHighlights");

var valMsgTrainingDuration = $('valMsgTrainingDuration'); var valMsgNumberTrained = $('valMsgNumberTrained'); valMsgLogType.hide(); valMsgContactType.hide(); valMsgCustomerName.hide(); valMsgEndUser.hide(); valMsgLogSubject.hide(); valMsgExecutiveSummary.hide(); valMsgTrainingDuration.hide(); valMsgNumberTrained.hide(); valMsgHighlights.hide(); var firstScreenValFailed = (invalidLogType || invalidContactType || inva lidTrainingContent || invalidCustomerName || invalidEndUserName); var secScreenValFailed = (invalidLogSubject || invalidExecutiveSummary); // invalidHighLights); if (firstScreenInFocus) { if (firstScreenValFailed) { if (invalidLogType) { valMsgLogType.show(); } if (invalidContactType) { valMsgContactType.show(); } if (invalidCustomerName) { valMsgCustomerName.show(); } if (invalidEndUserName) { valMsgEndUser.show(); } if (invalidTrainingDuration) { valMsgTrainingDuration.show(); } if (invalidNumberTrained) { valMsgNumberTrained.show(); } } else { if (secScreenValFailed) { Navigate(2); // if (invalidHighLights) { valMsgHighlights.show(); } if (invalidLogSubject) { valMsgLogSubject.show(); } if (invalidExecutiveSummary) { valMsgExecutiveSummary.show() ; } } } } else {

if (secScreenValFailed) { // if (invalidHighLights) { valMsgHighlights.show(); } if (invalidLogSubject) { valMsgLogSubject.show(); } if (invalidExecutiveSummary) { valMsgExecutiveSummary.show(); } } else { if (firstScreenValFailed) { Navigate(1); if (invalidLogType) { valMsgLogType.show(); } if (invalidContactType) { valMsgContactType.show(); } if (invalidCustomerName) { valMsgCustomerName.show(); } if (invalidEndUserName) { valMsgEndUser.show(); } if (invalidTrainingDuration) { valMsgTrainingDuration.show() ; } if (invalidNumberTrained) { valMsgNumberTrained.show(); } } } } return !(firstScreenValFailed || secScreenValFailed); } var timer = null; var rstatus = null; function SaveLogDetails(submit) { SetLogDetails(); //ping(); if (navigator.onLine) { currentLog.IsSubmited = submit; if ((submit && ValidateFields(currentLog)) || !submit) { var urlAction = $('#lnkSave').attr('href'); $.mobile.showPageLoadingMsg(); //alert(urlAction); var sfaLogSave = { actionItems: WhoWhatWhen(), sfaLog: currentLog } $.ajax({ type: "POST", url: urlAction, contentType: "application/json; charset=utf-8", data: JSON.stringify(sfaLogSave), dataType: "json" }).done(function (response) { currentLog.id = JSON.stringify(response); if (currentLog.IsSubmited) { ShowModelPopup("Submitted Successfully", "Message", true , GoHome); } else { ShowModelPopup("Saved Successfully", "Message", true); } // WhoWhatWhen(currentLog.id); }) .fail(function (jqXHR, textStatus, errorThrown) { ShowModelPopup(errorThrown, "Error Message", true); }) .complete(function () { $.mobile.hidePageLoadingMsg();

}); } } else { var OfflineArr = new Array(); var OfflineOldArray = new Array(); var OfflineData = localStorage["OfflineData"]; //alert(OfflineData); if (typeof OfflineData != "undefined" && OfflineData != null) { OfflineOldArray = JSON.parse(localStorage["OfflineData"]); for (i = 0; i <= OfflineOldArray.length - 1; i++) { var OldData = new Object(); OldData = OfflineOldArray[i]; if (typeof id != 'undefined' && id != null) { if (OldData.id == id) { } else { OfflineArr.push(OldData); } } else { OfflineArr.push(OldData); } } } var count = OfflineOldArray.length + 1; var logdetails = new Object(); if (typeof id == 'undefined' || id == null) { logdetails.id = "Offline-" + count; } else { logdetails.id = id; } logdetails.customerno = Customers.find('option:selected').text(); logdetails.enduserno = EndUsers.find('option:selected').text(); logdetails.loggedby = lblUserName.text(); logdetails.dateofcontact = txtContactDate.val(); if ($("#LogTypes").val() > 0) { logdetails.logtypeid = $("#LogTypes").val(); } if ($("#dropdownlogtype").val() > 0) { logdetails.logtypeid = $("#dropdownlogtype").val(); } if ($("#ContactTypes").val() > 0) { logdetails.contacttypeid = $("#ContactTypes").val(); } if ($("#dropdownContacttype").val() > 0) { logdetails.contacttypeid = $("#dropdownContacttype").val(); }

logdetails.traveltimewcustomer = $('#txtTravelTime').val(); logdetails.FaceToFaceTime = $('#txtFaceToFaceTime').val(); if (divTraining.css('display') != 'none') { logdetails.TrainingDuration = $('#txtTrainingDuration').val(); logdetails.NumberTrained = $('#txtNumberTrained').val(); } else { logdetails.TrainingDuration = null; logdetails.NumberTrained = null; } logdetails.logsubject = txtSubject.val(); logdetails.executivesummary = txtExecutiveSummary.val(); logdetails.logdetail = txtLogDetail.val(); logdetails.IsSubmited = submit; if ($("#ProdServices").val() > 0) { logdetails.ProdSevices = $("#ProdServices").val(); } if ($("#dropdownProduct").val() > 0) { logdetails.ProdSevices = $("#dropdownProduct").val(); } if ($("#Markets").val() > 0) { logdetails.Market = $("#Markets").val(); } if ($("#dropdownMarket").val() > 0) { logdetails.Market = $("#dropdownMarket").val(); } if ($("#FEUs").val() > 0) { logdetails.FEUID = $("#FEUs").val(); } if ($("#dropdownFEU").val() > 0) { logdetails.FEUID = $("#dropdownFEU").val(); } currentLog.TrainingDuration = $('#txtTrainingDuration').val(); currentLog.NumberTrained = $('#txtNumberTrained').val(); logdetails.highlights = txtHighlights.val(); logdetails.installedbased = $(chkInstalledBased).is(':checked');// c urrentlog.installedbased; logdetails.ActionItems = WhoWhatWhen(); if (logdetails.IsSubmited && ValidateLogFields(logdetails)) { //alert(logdetails.IsSubmited); OfflineArr.push(logdetails); localStorage["OfflineData"] = JSON.stringify(OfflineArr); ShowModelPopup("Submitted Successfully", "Message", true); } if (!logdetails.IsSubmited) { //alert(logdetails.IsSubmited); OfflineArr.push(logdetails); localStorage["OfflineData"] = JSON.stringify(OfflineArr);

ShowModelPopup("Saved Successfully", "Message", true); } } return false; } function SetLogDetails() { var txtLogDetail = $("#txtLogDetail"); currentLog.LoggedBy = lblUserName.text(); currentLog.DateOfContact = txtContactDate.val(); currentLog.LogTypeID = logTypes.val(); if (navigator.onLine) { currentLog.ContactTypeID = contactTypes.val(); } else { currentLog.ContactTypeID = $("#dropdownContacttype").val(); } currentLog.LogDetail = txtLogDetail.val(); currentLog.ExecutiveSummary = txtExecutiveSummary.val(); currentLog.Highlights = txtHighlights.val(); currentLog.LogSubject = txtSubject.val(); currentLog.InstalledBased = $(chkInstalledBased).is(':checked') if (divCustomers.css('display') != 'none') { var customerNameArr = Customers.find('option:selected').text().split ('('); currentLog.CustomerName = customerNameArr[0]; currentLog.CustomerNo = Customers.val(); } else { currentLog.CustomerName = ''; currentLog.CustomerNo = ''; } if (divEndUser.css('display') != 'none') { var endUserNameArr = EndUsers.find('option:selected').text().split(' ('); currentLog.EndUserName = endUserNameArr[0]; currentLog.EndUserNo = EndUsers.val(); if (Markets.get(0).selectedIndex > 0) { currentLog.Market = Markets.find('option:selected').text(); } else { currentLog.Market = ''; } // if (SellingCycleStatus.get(0).selectedIndex > 0) { // currentLog.SellingCycleStatus = SellingCycleStatus .find('option:selected').text(); // } // else { // currentLog.SellingCycleStatus = ''; // } currentLog.FEUID = FEUs.val();

// currentLog.AFBValue = txtAFB.val(); } else { currentLog.EndUserNo = ''; currentLog.Market = ''; // currentLog.SellingCycleStatus = ''; currentLog.FEUID = null; // currentLog.AFBValue = null; } if (divTravelTime.css('display') != 'none') { currentLog.TravelTimeWCustomer = $('#txtTravelTime').val(); } else { currentLog.TravelTimeWCustomer = 0; } if (divTraining.css('display') != 'none') { currentLog.TrainingDuration = $('#txtTrainingDuration').val(); currentLog.NumberTrained = $('#txtNumberTrained').val(); } else { currentLog.TrainingDuration = null; currentLog.NumberTrained = null; } currentLog.FaceToFaceTime = $('#txtFaceToFaceTime').val(); if (ProdServices.get(0).selectedIndex > 0) { currentLog.Prod_Svc = ProdServices.find('option:selected').text(); } else { currentLog.Prod_Svc = ''; } } function ValidateLogFields(logdetails) { var invalidLogType = IsInvalidSelect(logdetails.logtypeid); if (contactTypes.is(':visible')) { invalidContactType = IsInvalidSelect(logdetails.contacttypeid); } else { invalidContactType = false; } var invalidTrainingContent; var invalidTrainingDuration; var invalidNumberTrained; if (divTraining.is(':visible')) { invalidTrainingDuration = !((logdetails.TrainingDuration * 1) > 0); invalidNumberTrained = !((logdetails.NumberTrained * 1) > 0); } else { invalidTrainingDuration = false; invalidNumberTrained = false; }

invalidTrainingContent = (invalidTrainingDuration && invalidNumberTraine d); var invalidCustomerName = (divCustomers.css('display') != 'none') && IsI nvalidSelect(logdetails.customerno); var invalidEndUserName = (divEndUser.css('display') != 'none') && IsInva lidSelect(logdetails.enduserno); var invalidLogSubject = IsEmpty(logdetails.logsubject); var invalidExecutiveSummary = IsEmpty(logdetails.executivesummary); //var invalidHighLights = IsEmpty(logdetails.highlights); var firstScreenInFocus = divLogDetail1.is(':visible'); var secScreenInFocus = divLogDetail2.is(':visible'); var thirdScreenInFocus = !(firstScreenInFocus || secScreenInFocus); var var var var var var var valMsgLogType = $("#valMsgLogType"); valMsgContactType = $("#valMsgContactType"); valMsgCustomerName = $("#valMsgCustomerName"); valMsgEndUser = $("#valMsgEndUserName"); valMsgLogSubject = $("#valMsgLogSubject"); valMsgExecutiveSummary = $("#valMsgExecutiveSummary"); valMsgHighlights = $("#valMsgHighlights");

var valMsgTrainingDuration = $('valMsgTrainingDuration'); var valMsgNumberTrained = $('valMsgNumberTrained'); valMsgLogType.hide(); valMsgContactType.hide(); valMsgCustomerName.hide(); valMsgEndUser.hide(); valMsgLogSubject.hide(); valMsgExecutiveSummary.hide(); valMsgTrainingDuration.hide(); valMsgNumberTrained.hide(); valMsgHighlights.hide(); var firstScreenValFailed = (invalidLogType || invalidContactType || inva lidTrainingContent || invalidCustomerName || invalidEndUserName); var secScreenValFailed = (invalidLogSubject || invalidExecutiveSummary); //|| invalidHighLights); if (firstScreenInFocus) { if (firstScreenValFailed) { if (invalidLogType) { valMsgLogType.show(); } if (invalidContactType) { valMsgContactType.show(); } if (invalidCustomerName) { valMsgCustomerName.show(); } if (invalidEndUserName) { valMsgEndUser.show(); } if (invalidTrainingDuration) { valMsgTrainingDuration.show(); } if (invalidNumberTrained) { valMsgNumberTrained.show(); } } else { if (secScreenValFailed) { Navigate(2); // if (invalidHighLights) { valMsgHighlights.show(); } if (invalidLogSubject) { valMsgLogSubject.show(); } if (invalidExecutiveSummary) { valMsgExecutiveSummary.show()

; } } } } else { if (secScreenValFailed) { if (invalidHighLights) { valMsgHighlights.show(); } if (invalidLogSubject) { valMsgLogSubject.show(); } if (invalidExecutiveSummary) { valMsgExecutiveSummary.show(); } } else { if (firstScreenValFailed) { Navigate(1); if (invalidLogType) { valMsgLogType.show(); } if (invalidContactType) { valMsgContactType.show(); } if (invalidCustomerName) { valMsgCustomerName.show(); } if (invalidEndUserName) { valMsgEndUser.show(); } if (invalidTrainingDuration) { valMsgTrainingDuration.show() ; } if (invalidNumberTrained) { valMsgNumberTrained.show(); } } } } return !(firstScreenValFailed || secScreenValFailed); }

</script>

You might also like