function sync(){
		// console.log('wwwwwwww');

	  		dbService.connect().then(function(){
	  			var orderQuery = dbService.db_.select()
			  					.from(dbService.orderTable)
			  					.where(dbService.orderTable.synced.eq(false))
			  					.exec();

		  		var orders = [];
		  		var itemsQuery = orderQuery.then(function(_orders){
		  			orders = _orders;
		  			var orderIds = orders.map(function(r){
		  				return r.id;
		  			});

		  			return dbService.db_
		  					.select()
		  					.from(dbService.orderItemsTable)
		  					.where(dbService.orderItemsTable.order_id.in(orderIds))
		  					.exec();
		  		});


	  			itemsQuery.then(function(order_items){
			  		//nothing to post
			  		if(orders.length == 0){
			  			toastr.Warning(order_items.Message,'Warning');
			  			return;
			  		};

			  		angular.forEach(orders, function(o){
			  			o.items = [];
			  			angular.forEach(order_items, function(i){
			  				if(i.order_id == o.id)
			  					o.items.push(i);
			  			});
			  		});

	  				var data = {
	  					Orders : orders,
	  				};
	  				console.log(data);

	  				setTimeout(() => {
	  					$('#LoaderDiv').hide();
					}, 2000);
	  				ajaxService.post('order/sync', data, true)
	  					.then(function (response) {
	  					    if (response.IsValid) {
	  					        /*toastr.success('Order have been synced successfully','Orders Synced');
	  					        let lang = languageService.get('Order Synced');
                   console.log(lang);*/
                    toastr.success(response.Message,'Success');
	  							updateSyncTime(orders);
	  						}
	  					});
	  			});
	  		});
	  	}
/* 
	  	* read all unsynced orders from local db
	  	* and post them to server.
	  	*/
read all unsynced orders from local db
and post them to server.
read all unsynced orders from local db and post them to server .
function sync(){
	  		dbService.connect().then(function(){
	  			var orderQuery = dbService.db_.select()
			  					.from(dbService.orderTable)
			  					.where(dbService.orderTable.synced.eq(false))
			  					.exec();
		  		var orders = [];
		  		var itemsQuery = orderQuery.then(function(_orders){
		  			orders = _orders;
		  			var orderIds = orders.map(function(r){
		  				return r.id;
		  			});
		  			return dbService.db_
		  					.select()
		  					.from(dbService.orderItemsTable)
		  					.where(dbService.orderItemsTable.order_id.in(orderIds))
		  					.exec();
		  		});
	  			itemsQuery.then(function(order_items){
			  		if(orders.length == 0){
			  			toastr.Warning(order_items.Message,'Warning');
			  			return;
			  		};
			  		angular.forEach(orders, function(o){
			  			o.items = [];
			  			angular.forEach(order_items, function(i){
			  				if(i.order_id == o.id)
			  					o.items.push(i);
			  			});
			  		});
	  				var data = {
	  					Orders : orders,
	  				};
	  				console.log(data);
	  				setTimeout(() => {
	  					$('#LoaderDiv').hide();
					}, 2000);
	  				ajaxService.post('order/sync', data, true)
	  					.then(function (response) {
	  					    if (response.IsValid) {
                    toastr.success(response.Message,'Success');
	  							updateSyncTime(orders);
	  						}
	  					});
	  			});
	  		});
	  	}
function sync ( ) { dbService . connect ( ) . then ( function ( ) { var orderQuery = dbService . db_ . select ( ) . from ( dbService . orderTable ) . where ( dbService . orderTable . synced . eq ( false ) ) . exec ( ) ; var orders = [ ] ; var itemsQuery = orderQuery . then ( function ( _orders ) { orders = _orders ; var orderIds = orders . map ( function ( r ) { return r . id ; } ) ; return dbService . db_ . select ( ) . from ( dbService . orderItemsTable ) . where ( dbService . orderItemsTable . order_id . in ( orderIds ) ) . exec ( ) ; } ) ; itemsQuery . then ( function ( order_items ) { if ( orders . length == 0 ) { toastr . Warning ( order_items . Message , 'Warning' ) ; return ; } ; angular . forEach ( orders , function ( o ) { o . items = [ ] ; angular . forEach ( order_items , function ( i ) { if ( i . order_id == o . id ) o . items . push ( i ) ; } ) ; } ) ; var data = { Orders : orders , } ; console . log ( data ) ; setTimeout ( ( ) => { $ ( '#LoaderDiv' ) . hide ( ) ; } , 2000 ) ; ajaxService . post ( 'order/sync' , data , true ) . then ( function ( response ) { if ( response . IsValid ) { toastr . success ( response . Message , 'Success' ) ; updateSyncTime ( orders ) ; } } ) ; } ) ; } ) ; }
read all unsynced orders from local db
 and post them to server.
read all unsynced orders from local db and post them to server .
// console.log('wwwwwwww'); //nothing to post /*toastr.success('Order have been synced successfully','Orders Synced');
	  					        let lang = languageService.get('Order Synced');
                   console.log(lang);*/