//JAVASCRIPT POPUP WINDOW CLASS CONTROLS ETC
var driverId = 0;
var vehicleId = 0;
var typeId = 0;
var customerId = 0;
var sDate;
var eDate;
var sDateDef = new Date('1/1/1970');//.toDateString();
var eDateDef = new Date('12/31/2999');//.toDateString();
var driverStore = new Ext.data.Store({
proxy: new Ext.data.HttpProxy({
url: '/Reporting/GetDrivers',
method: 'GET'
}),
reader: new Ext.data.JsonReader(
{ root: 'data', id: 'id' },
[{ name: 'Value' }, { name: 'Text' }]
),
autoLoad: true
});
var vehicleStore = new Ext.data.Store({
url: '/Reporting/GetVehicles’,
var typeStore = new Ext.data.Store({
url: '/Reporting/GetInsurance’,
Ext.onReady(function () {
Ext.QuickTips.init();
var xg = Ext.grid;
function handleResize() {
var width = window.innerWidth;
var height = window.innerHeight;
if (width == null) {
width = document.documentElement.clientWidth;
height = document.documentElement.clientHeight;
}
if (width == 0) {
width = document.body.clientWidth;
height = document.body.clientHeight;
grid.setHeight(height - 185);
window.onload = handleResize;
window.onresize = handleResize;
var reader = new Ext.data.JsonReader({
idProperty: 'taskId',
root: 'data',
fields: [
{ name: 'vehicle', type: 'string' },
{ name: 'period', type: 'string' },
{ name: 'hours', type: 'float' },
{ name: 'average', type: 'float' },
{ name: 'ridesCount', type: 'int' },
{ name: 'date', type: 'date', dateFormat: 'm/d/Y' }
]
var grid = new xg.EditorGridPanel({
ds: new Ext.data.GroupingStore({
reader: reader,
api: {
read: '/Reporting/GetEmployeeHours?driverId=' + driverId
+ '&sDate=' + sDate + ''
+ '&eDate=' + eDate + ''
autoLoad: false,
sortInfo: { field: 'date', direction: 'ASC' },
groupField: 'vehicle'
columns: [
],
tbar:
[{
xtype: 'label',
style: 'margin-right:5px;margin-left:3px;',
text: 'Driver'
}, {
id: 'DriverId',
xtype: 'combo',
width: 160,
displayField: 'Text',
valueField: 'Value',
emptyText: 'Select a Driver...',
hiddenName: 'Driverid',
forceSelection: true,
triggerAction: 'all',
mode: 'local',
store: driverStore
text: 'Insurance'
id: 'TypeId',
width: 250,
emptyText: 'Select a Type...',
hiddenName: 'TypeId',
store: typeStore
text: 'Vehicle'
id: 'VehicleId',
emptyText: 'Select a Vehicle...',
hiddenName: 'VehicleId',
store: vehicleStore
style: 'margin:0px 5px 0px 5px;',
text: 'Period'
xtype: 'datefield',
id: 'txtStartDate',
name: 'txtStartDate',
width: 100
style: 'margin:0px 3px 0px 3px;',
text: '-'
name: 'txtEndDate',
id: 'txtEndDate',
style: 'margin-right:5px;margin-left:3px',
text: 'Format'
//THIS IS WHERE I WANT THE SELECTION TO CHOOSE A METHOD IN THE CONTROLLER
id: 'FormatId',
width: 140,
emptyText: 'Default',
hiddenName: 'FormatId',
store: formatStore
{
xtype: 'button',
id: 'printxls',
text: 'Export',
style: 'margin-left:5px;',
handler: function () {
driverId = !Ext.getCmp("DriverId").value ? 0 : Ext.getCmp("DriverId").value;
vehicleId = !Ext.getCmp("VehicleId").value ? 0 : Ext.getCmp("VehicleId").value;
typeId = !Ext.getCmp("TypeId").value ? 0 : Ext.getCmp("TypeId").value;
sDate = !Ext.getCmp("txtStartDate").getValue() ? sDateDef : Ext.getCmp("txtStartDate").getValue();
eDate = !Ext.getCmp("txtEndDate").getValue() ? eDateDef : Ext.getCmp("txtEndDate").getValue();
var sMsg = [];
if (driverId == 0) { sMsg.push(" - driver"); }
if (typeId == 0) { sMsg.push(" - insurance"); }
if (sDate <= sDateDef) { sMsg.push(" - period start date"); }
if (eDate >= eDateDef) { sMsg.push(" - period end date"); }
if (sMsg.length != 0) {
Ext.MessageBox.alert('Attention!', 'The following are missing:<br/><br/>' + sMsg.join('<br />'));
return;
document.getElementById("driverId").setAttribute("value", driverId);
document.getElementById("vehicleId").setAttribute("value", vehicleId);
document.getElementById("typeId").setAttribute("value", typeId);
document.getElementById("sDate").setAttribute("value", sDate.toDateString());
document.getElementById("eDate").setAttribute("value", eDate.toDateString());
document.forms["spreadsheetForm"].submit();
}],
frame: true,
width: '100%',
clicksToEdit: 1,
animCollapse: false,
trackMouseOver: false,
renderTo: 'maincontaindiv'
handleResize();
// set up namespace for application
Ext.ns('app.grid');
//ASP.NET CONTROLLER WHERE THE METHODS I WANT TO CALL ARE LOCATED
//WHEN BUTTON IS CLICKED THIS METHOD IS CALLED
[HttpPost]
[Authorize(Roles = RoleAdmin + "," + RoleBilling + "," + RoleBillingDocument)]
public ActionResult GenerateTripLog(int driverId, int vehicleId, int typeId, int customerId, DateTime sDate, DateTime eDate)
try
var results = (from s in db.usp_TripLog(driverId, vehicleId, typeId, customerId, sDate, eDate)
select s).ToList();
var driver = new DriverRepository(GetCurrentUser()).GetDriver(driverId);
var iType = db.insurancetypes.SingleOrDefault(c => c.id == typeId);
var tenant = GetTenant(GetCurrentUser());
var period = "All";
if (DateTime.Compare(sDate, new DateTime(1970, 1, 1)) != 0 || DateTime.Compare(eDate, new DateTime(2099, 12, 31)) != 0)
period = sDate.ToShortDateString() + " to " + eDate.ToShortDateString();
var driverSignature =
(from s in driver.driveravailabilityevents
where
s.eventtime.Date.Equals(eDate.Date)
&& (s.eventtypeid == 9 || s.eventtypeid == 10) // Punch out or No Work
orderby s.createdon descending
select s.signature).FirstOrDefault();
object[] filterStrs =
tenant == null ? "All" : tenant.tenantname,
period,
driver == null || driver.person == null ? "All" : driver.person.fullname,
iType == null ? "All" : iType.name,
driverSignature
};
//THIS IF STATEMENT IS WHAT I WANT THE DROPDOWNLIST TO DECIDE WHAT IS CALLED INSTEAD OF WHAT IS CURRENTLY SETUP LIKE THIS BELOW
string insuranceType = Convert.ToString(iType);
string mtmString = "";
string logicstr = "";
string accessStr = "";
if (insuranceType.Length > 2) mtmString = insuranceType.Substring(0, 3);
if (insuranceType.Length > 10) logicstr = insuranceType.Substring(0, 11);
if (insuranceType.Length > 10) accessStr = insuranceType.Substring(0, 13);
if (logicstr == "Logisticare" || logicstr == "LogistCare" || logicstr == "LogistiCare" || logicstr == "LOGISTICARE")
return TripLogSpreadsheet(results, filterStrs);
else if (mtmString.ToUpper() == "MTM")
return MTMLogSpreadsheet(results, filterStrs);
else if (accessStr == "Access 2 Care" || logicstr == "Access2Care" || logicstr == "Access2care" || accessStr == "Access 2 care" || mtmString.ToUpper() == "A2C" || mtmString == "A2c")
return Access2CareLogSpreadsheet(results, filterStrs);
else
// return MTMLogSpreadsheet(results, filterStrs);
// return Access2CareLogSpreadsheet(results, filterStrs);
catch (Exception ex)
ViewData["errormessage"] = ex.Message;
return View("Error");
private ActionResult TripLogSpreadsheet(List<usp_TripLogResult> list, object[] filterStrs)
const int colRideDate = 0;
const int colJobNum = 1;
const int colMemberName = 2;
const int colAWS = 3;
const int colRNS = 4;
const int colPickupTime = 5;
const int colDropoffTime = 6;
const int colWillCallTime = 7;
const int colTotalTripMileage = 8;
const int colWaitTime = 9;
const int colBilledAmount = 10;
sheet.GetRow(rowTenant).GetCell(8).SetCellValue(filterStrs[1].ToString()); // Ride Dates
sheet.GetRow(rowDriverSignature).GetCell(2).SetCellValue(filterStrs[2].ToString()); // Driver Name
//sheet.GetRow(rowDriver).GetCell(3).SetCellValue(filterStrs[2]); // Driver Name
IRow template_row = sheet.GetRow(start_row);
var row_index = start_row;
foreach (var record in list)
if (row_index == start_row && !String.IsNullOrEmpty(record.VIN) && record.VIN.Length >= vinLength)
sheet.GetRow(rowDriver).GetCell(8).SetCellValue(record.VIN.Substring(record.VIN.Length - vinLength)); // Vehicle number VIN
sheet.ShiftRows(row_index + 1, last_row, 1);
IRow hRow = sheet.CreateRow(row_index);
hRow.Height = template_row.Height;
ICell hCell = hRow.CreateCell(colRideDate, CellType.STRING);
hCell.CellStyle = template_row.GetCell(colRideDate).CellStyle;
hCell.SetCellValue(!String.IsNullOrEmpty(Convert.ToString(record.RideDate)) ? Convert.ToString(record.RideDate.ToString("MM/dd/yyyy")) : String.Empty);
ICell hCell = hRow.CreateCell(colJobNum, CellType.STRING);
hCell.CellStyle = template_row.GetCell(colJobNum).CellStyle;
hCell.SetCellValue(!String.IsNullOrEmpty(record.InsuranceAuthNumber) ? record.InsuranceAuthNumber : String.Empty);
sheet.ForceFormulaRecalculation = true;
var memoryStream = new MemoryStream();
wk.Write(memoryStream);
return File(memoryStream.ToArray(), "application/vnd.ms-excel", "trip_log.xls");