|
|
@@ -20,9 +20,18 @@ var routes =
|
|
|
showPage('login');
|
|
|
},
|
|
|
|
|
|
+ logout: function()
|
|
|
+ {
|
|
|
+ $.post('api/logout.php');
|
|
|
+
|
|
|
+ showPage('login');
|
|
|
+ },
|
|
|
+
|
|
|
sd: function()
|
|
|
{
|
|
|
showPage('sd');
|
|
|
+
|
|
|
+ loadAllData();
|
|
|
}
|
|
|
};
|
|
|
|
|
|
@@ -57,4 +66,146 @@ function showPage(page)
|
|
|
.off('animationend')
|
|
|
.addClass('active')
|
|
|
.focus(); //this needs to be used in conjunction with a "tabindex" field on the html object to maintain keyboard focus
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+function loadAllData()
|
|
|
+{
|
|
|
+ $.post('api/getAllData.php', 'json')
|
|
|
+ .done(function(companies)
|
|
|
+ {
|
|
|
+ //go through each company and add a tab if one isn't present
|
|
|
+
|
|
|
+ if(!companies.length)
|
|
|
+ return;
|
|
|
+
|
|
|
+ for(var c = 0; c < companies.length; c++)
|
|
|
+ {
|
|
|
+ var company = companies[c];
|
|
|
+
|
|
|
+ //if the company's tab doesn't exist, create it
|
|
|
+ if($('#screen-sd ul.nav-tabs > li[data-id_company]').length === 0)
|
|
|
+ {
|
|
|
+ //add tab
|
|
|
+ $('<li><a data-toggle="tab" href="#tabletab-' + company['id_company'] + '">' + company['name'] + '</a></li>')
|
|
|
+ .appendTo('#screen-sd ul.nav-tabs');
|
|
|
+
|
|
|
+ //add table
|
|
|
+ $('<div id="tabletab-' + company['id_company'] + '" class="tab-pane fade in">'
|
|
|
+ + '<div class="table-responsive">'
|
|
|
+ + '<table class="table table-striped editable">'
|
|
|
+ + '<thead>'
|
|
|
+ + '<tr>'
|
|
|
+ + '<th>Division</th>'
|
|
|
+ + '<th>Consignee</th>'
|
|
|
+ + '<th>Called In</th>'
|
|
|
+ + '<th>Dispatch #</th>'
|
|
|
+ + '<th>Shipper</th>'
|
|
|
+ + '<th>Ready</th>'
|
|
|
+ + '<th>Address 1</th>'
|
|
|
+ + '<th>Address 2</th>'
|
|
|
+ + '<th>City</th>'
|
|
|
+ + '<th>ST</th>'
|
|
|
+ + '<th>Zip</th>'
|
|
|
+ + '<th>Phone</th>'
|
|
|
+
|
|
|
+ + '<th>Ready Time</th>'
|
|
|
+ + '<th>Close Time</th>'
|
|
|
+ + '<th class="editable">Pickup Time</th>'
|
|
|
+ + '<th class="editable">Depart Time</th>'
|
|
|
+ + '<th class="editable">BOL Delivered</th>'
|
|
|
+
|
|
|
+ + '<th>Dispatch Refere</th>'
|
|
|
+
|
|
|
+ + '<th>Ctns</th>'
|
|
|
+ + '<th>Weight</th>'
|
|
|
+ + '<th>Cube</th>'
|
|
|
+ + '</tr>'
|
|
|
+ + '</thead>'
|
|
|
+
|
|
|
+ + '<tbody></tbody>'
|
|
|
+ //+ '<tfoot></tfoot>'
|
|
|
+ + '</table>'
|
|
|
+ + '</div>'
|
|
|
+ + '</div>')
|
|
|
+ .appendTo('#screen-sd .tab-content');
|
|
|
+ }
|
|
|
+
|
|
|
+ //empty table
|
|
|
+ var tbody = $('#screen-sd #tabletab-' + company['id_company'] + ' table > tbody');
|
|
|
+ tbody.empty();
|
|
|
+
|
|
|
+ //add all data
|
|
|
+ var rows = company['file_rows'];
|
|
|
+
|
|
|
+ console.log(tbody);
|
|
|
+
|
|
|
+ for(var r = 0; r < rows.length; r++)
|
|
|
+ {
|
|
|
+ var row = rows[r];
|
|
|
+
|
|
|
+ $('<tr>'
|
|
|
+ + '<td class="division">' + (row['division']||'') + '</td>'
|
|
|
+ + '<td class="consignee">' + (row['consignee']||'') + '</td>'
|
|
|
+ + '<td class="date_called_in">' + (row['date_called_in']||'') + '</td>'
|
|
|
+ + '<td class="dispatch_number">' + (row['dispatch_number']||'') + '</td>'
|
|
|
+ + '<td class="shipper">' + (row['shipper']||'') + '</td>'
|
|
|
+ + '<td class="date_ready">' + (row['date_ready']||'') + '</td>'
|
|
|
+ + '<td class="address_1">' + (row['address_1']||'') + '</td>'
|
|
|
+ + '<td class="address_2">' + (row['address_2']||'') + '</td>'
|
|
|
+ + '<td class="city">' + (row['city']||'') + '</td>'
|
|
|
+ + '<td class="state">' + (row['state']||'') + '</td>'
|
|
|
+ + '<td class="zip">' + (row['zip']||'') + '</td>'
|
|
|
+ + '<td class="phone">' + (row['phone']||'') + '</td>'
|
|
|
+ + '<td class="time_ready">' + (row['time_ready']||'') + '</td>'
|
|
|
+ + '<td class="time_close">' + (row['time_close']||'') + '</td>'
|
|
|
+
|
|
|
+ + '<td class="time_pickup">' + (row['time_pickup']||'') + '</td>'
|
|
|
+ + '<td class="time_depart">' + (row['time_depart']||'') + '</td>'
|
|
|
+ + '<td class="bol_delivered">' + (row['bol_delivered']||'') + '</td>'
|
|
|
+ + '<td class="dispatch_reference">' + (row['dispatch_reference']||'') + '</td>'
|
|
|
+ + '<td class="ctns">' + (row['ctns']||'') + '</td>'
|
|
|
+ + '<td class="weight">' + (row['weight']||'') + '</td>'
|
|
|
+ + '<td class="cube">' + (row['cube']||'') + '</td>'
|
|
|
+ + '</tr>')
|
|
|
+ .appendTo(tbody);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if($('#screen-sd ul.nav-tabs > li.active').length === 0)
|
|
|
+ $('#screen-sd ul.nav-tabs > li:eq(0) a').click();
|
|
|
+
|
|
|
+
|
|
|
+ $('table.editable').editableTableWidget();
|
|
|
+
|
|
|
+ $('table.editable td').off('change').on('change', function(evt, newValue)
|
|
|
+ {
|
|
|
+ // do something with the new cell value
|
|
|
+ /* if (....) {
|
|
|
+ return false; // reject change
|
|
|
+ }
|
|
|
+ */
|
|
|
+ });
|
|
|
+ })
|
|
|
+ .fail(function(err, xhr, text)
|
|
|
+ {
|
|
|
+ console.error(err.responseText);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function loadCompanies()
|
|
|
+{
|
|
|
+ $.post('api/getCompanies.php')
|
|
|
+ .done(function(response)
|
|
|
+ {
|
|
|
+
|
|
|
+ })
|
|
|
+ .fail(function(err, xhr, text)
|
|
|
+ {
|
|
|
+ console.error(err.responseText);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function addCompany(company)
|
|
|
+{
|
|
|
}
|