<commit_before>var args = arguments[0] || {};

setTimeout(function(){
	getSummary(); 
	getProfitSummary();
}, 1000);

$.activityIndicator.show();
$.loadingBar.opacity = "1";
$.loadingBar.height = "100";
$.loadingBar.top = "50";
getAnnouncement();

//Active icon displayed
var summary = $.footer.getView('summary'); 
summary.image = "/images/icons/icon-summary-active.png";
Ti.App.Properties.setString('module', 'dealer_summary');

var pHeight = PixelsToDPUnits(Ti.Platform.displayCaps.platformHeight);
$.webview.height = pHeight - 200 -105;
$.webview.top = 200;

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

if (month < 10) month = '0' + month;
if (day < 10) day = '0' + day;

var today = year+'-'+month+'-'+day;

var label = Titanium.UI.createLabel({
    left: 320,
    width: 300,
    height: 20,
    color:'black',
    text:'horizontal auto scrolling text'
});
 
function getProfitSummary(e){
	var url = Ti.API.GETDEALERDAILYPROFIT + Ti.App.Properties.getString('session');
	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	        
	         if(res.status == "success"){
	         	var dailyProfit = 0;
	         	
				for (var key in res.data){
					var obj = res.data[key];
		       		dailyProfit += (parseFloat(obj.courier) + parseFloat(obj.cod) -parseFloat(obj.ads_cost) -parseFloat(obj.other_cost) )  ;
				}
				$.dailyProfit.text = dailyProfit.toFixed(2);
				
	         }else{
	         	getProfitSummary(e);
	         }
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getProfitSummary(e);
	     },
	     timeout : 5000  // in milliseconds
	 });
	 // Prepare the connection.
	 client.open("GET", url);
	 // Send the request.
	 client.send(); 
}
		
//$.mySession.text = model;
function getSummary(e) {
	var url = Ti.API.GETDAILYSUMMARYBYMONTH + Ti.App.Properties.getString('session')+ "&date=" + year+'-'+month;
	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	         
	         if(res.status == "Success"){
	         	var monthCommission = 0;
				for (var key in res.data){
					var obj = res.data[key];

					if(obj.created == today){
		       			var todaycomm = parseFloat(obj.commission);
		       			$.todayCommission.text = todaycomm.toFixed(2);
		       		}
		    
				}
				//
				$.monthCommission.text = res.total;
				$.activityIndicator.hide();
				$.loadingBar.opacity = "0";
				$.loadingBar.height = "0";
	         }else{
	         	getSummary(e);
	         }
	         
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getSummary(e);
	     },
	     timeout : 10000  // in milliseconds
	 });
	 // Prepare the connection.
	 client.open("GET", url);
	 // Send the request.
	 client.send(); 
  
}

function getAnnouncement(e) {
	var url = Ti.API.GETANNOUNCEMENT + Ti.App.Properties.getString('session'); 
	var totalWidth = 0;
	var text = "";
	var screenWidth = PixelsToDPUnits(Ti.Platform.displayCaps.platformWidth);

	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	         if(res.status == "success"){
	         	
	         	var count =1;
				for (var key in res.data){
					var obj = res.data[key];
					var totalAnnouncement = res.data.length;
					var seperator = "";
					if(totalAnnouncement > count){
						seperator = " | ";
					}
					text = text + obj.message +seperator;
					count++;
				}
				
				var label = Titanium.UI.createLabel({
					    height: 25,
					    left: 50,
					    top:3,
					    font: {
					        fontSize: '16'
					    },
					    color:'black',
					    width: Ti.UI.FIT,
					    wordWrap : false, 
                		horizontalWrap: false,
					    text: text
					});
					
				label.addEventListener('postlayout', function(e) { // not called ...
				  totalWidth = e.source.rect.width;
				  var screenWidthDP = Ti.Platform.displayCaps.platformWidth / (Titanium.Platform.displayCaps.dpi / 160);

				  var animation = Titanium.UI.createAnimation({
					    right:screenWidthDP,
					    duration:8000,
        				curve: Titanium.UI.ANIMATION_CURVE_LINEAR
					});
					animation.addEventListener('complete',function() {
					    e.source.right = 0;
					    e.source.animate(animation); 
					});
				   e.source.animate(animation);
				  
				});
			//	createAlert("Announcement",text);
			//	$.noticeBoard.add(label);
	         }else{
	          	getAnnouncement(e);
	         }
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getAnnouncement(e);
	     },
	     timeout : 5000  // in milliseconds<commit_msg>ignore<commit_after>var args = arguments[0] || {};

setTimeout(function(){
	getSummary(); 
	getProfitSummary();
}, 1000);

$.activityIndicator.show();
$.loadingBar.opacity = "1";
$.loadingBar.height = "100";
$.loadingBar.top = "50";
getAnnouncement();

//Active icon displayed
var summary = $.footer.getView('summary'); 
summary.image = "/images/icons/icon-summary-active.png";
Ti.App.Properties.setString('module', 'dealer_summary');

var pHeight = PixelsToDPUnits(Ti.Platform.displayCaps.platformHeight);
$.webview.height = pHeight - 200 -105;
$.webview.top = 200;

var currentTime = new Date();
var month = currentTime.getMonth() + 1;
var day = currentTime.getDate();
var year = currentTime.getFullYear();

if (month < 10) month = '0' + month;
if (day < 10) day = '0' + day;

var today = year+'-'+month+'-'+day;

var label = Titanium.UI.createLabel({
    left: 320,
    width: 300,
    height: 20,
    color:'black',
    text:'horizontal auto scrolling text'
});
 
function getProfitSummary(e){
	var url = Ti.API.GETDEALERDAILYPROFIT + Ti.App.Properties.getString('session');
	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	        
	         if(res.status == "success"){
	         	var dailyProfit = 0;
	         	
				for (var key in res.data){
					var obj = res.data[key];
		       		dailyProfit += (parseFloat(obj.courier) + parseFloat(obj.cod) -parseFloat(obj.ads_cost) -parseFloat(obj.other_cost) )  ;
				}
				$.dailyProfit.text = dailyProfit.toFixed(2);
				
	         }else{
	         	getProfitSummary(e);
	         }
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getProfitSummary(e);
	     },
	     timeout : 5000  // in milliseconds
	 });
	 // Prepare the connection.
	 client.open("GET", url);
	 // Send the request.
	 client.send(); 
}
		
//$.mySession.text = model;
function getSummary(e) {
	var url = Ti.API.GETDAILYSUMMARYBYMONTH + Ti.App.Properties.getString('session')+ "&date=" + year+'-'+month;
	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	         
	         if(res.status == "Success"){
	         	var monthCommission = 0;
				for (var key in res.data){
					var obj = res.data[key];

					if(obj.created == today){
		       			var todaycomm = parseFloat(obj.commission);
		       			$.todayCommission.text = todaycomm.toFixed(2);
		       		}
		    
				}
				//
				$.monthCommission.text = res.total;
				$.activityIndicator.hide();
				$.loadingBar.opacity = "0";
				$.loadingBar.height = "0";
	         }else{
	         	getSummary(e);
	         }
	         
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getSummary(e);
	     },
	     timeout : 10000  // in milliseconds
	 });
	 // Prepare the connection.
	 client.open("GET", url);
	 // Send the request.
	 client.send(); 
  
}

function getAnnouncement(e) {
	var url = Ti.API.GETANNOUNCEMENT + Ti.App.Properties.getString('session'); 
	var totalWidth = 0;
	var text = "";
	var screenWidth = PixelsToDPUnits(Ti.Platform.displayCaps.platformWidth);

	var client = Ti.Network.createHTTPClient({
	     // function called when the response data is available
	     onload : function(e) {
	         var res = JSON.parse(this.responseText);
	         if(res.status == "success"){
	         	
	         	var count =1;
				for (var key in res.data){
					var obj = res.data[key];
					var totalAnnouncement = res.data.length;
					var seperator = "";
					if(totalAnnouncement > count){
						seperator = " | ";
					}
					text = text + obj.message +seperator;
					count++;
				}
				
				var label = Titanium.UI.createLabel({
					    height: 25,
					    left: 50,
					    top:3,
					    font: {
					        fontSize: '16'
					    },
					    color:'black',
					    width: Ti.UI.FIT,
					    wordWrap : false, 
                		horizontalWrap: false,
					    text: text
					});
					
				label.addEventListener('postlayout', function(e) { // not called ...
				  totalWidth = e.source.rect.width;
				  var screenWidthDP = Ti.Platform.displayCaps.platformWidth / (Titanium.Platform.displayCaps.dpi / 160);

				  var animation = Titanium.UI.createAnimation({
					    right:screenWidthDP,
					    duration:8000,
        				curve: Titanium.UI.ANIMATION_CURVE_LINEAR
					});
					animation.addEventListener('complete',function() {
					    e.source.right = 0;
					    e.source.animate(animation); 
					});
				   e.source.animate(animation);
				  
				});
				$.noticeBoard.add(label);
	         }else{
	          	getAnnouncement(e);
	         }
	     },
	     // function called when an error occurs, including a timeout
	     onerror : function(e) {
	         getAnnouncement(e);
	     },
	     timeout : 5000  // in milliseconds
{'fraction_non_alphanumeric': 0.13692413929170366, 'fraction_numerical': 0.014008089178257866, 'mean_word_length': 2.2724338282763075, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5608048', 'n_tokens_mistral': 3833, 'n_tokens_neox': 3087, 'n_words': 688}