|
@@ -13,8 +13,6 @@ angular.module('odoo')
|
|
customersRemoteFactory,
|
|
customersRemoteFactory,
|
|
customersStorageFactory,
|
|
customersStorageFactory,
|
|
sqlFactory,
|
|
sqlFactory,
|
|
- cameraFactory,
|
|
|
|
- contactFactory,
|
|
|
|
deviceFactory
|
|
deviceFactory
|
|
) {
|
|
) {
|
|
$scope.loading = false;
|
|
$scope.loading = false;
|
|
@@ -27,32 +25,50 @@ angular.module('odoo')
|
|
$scope.customerModal = modal;
|
|
$scope.customerModal = modal;
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
$scope.$on('$ionicView.enter', function () {
|
|
$scope.$on('$ionicView.enter', function () {
|
|
- $scope.fill();
|
|
|
|
|
|
+ $scope.fill(false);
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
$scope.$on('$destroy', function () {
|
|
$scope.$on('$destroy', function () {
|
|
$scope.customerModal.remove();
|
|
$scope.customerModal.remove();
|
|
});
|
|
});
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
$scope.$on('modal.hidden', function () {
|
|
$scope.$on('modal.hidden', function () {
|
|
$scope.customer = {};
|
|
$scope.customer = {};
|
|
});
|
|
});
|
|
|
|
|
|
- $scope.$on('device.shaked', function () {
|
|
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ $scope.$on('device.shaked', function () {
|
|
if ($scope.customerModal.isShown()) {
|
|
if ($scope.customerModal.isShown()) {
|
|
- deviceFactory.getCurrentPosition(function (position) {
|
|
|
|
- console.log(position);
|
|
|
|
|
|
+
|
|
|
|
+ deviceFactory.getCurrentPosition(function (position) {
|
|
|
|
+ $scope.customer.partner_latitude = position.coords.latitude;
|
|
|
|
+ $scope.customer.partner_longitude = position.coords.longitude;
|
|
|
|
+ $scope.customer.date_localization = new Date(position.timestamp).toLocaleString();
|
|
}, function (err) {
|
|
}, function (err) {
|
|
console.log(err);
|
|
console.log(err);
|
|
});
|
|
});
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ $scope.fill(false);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
/**
|
|
/**
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
- $scope.fill = function (refresh = false) {
|
|
|
|
|
|
+ $scope.fill = function (refresh) {
|
|
$scope.loading = !refresh;
|
|
$scope.loading = !refresh;
|
|
|
|
|
|
customersRemoteFactory.sync(function (customers) {
|
|
customersRemoteFactory.sync(function (customers) {
|
|
@@ -111,7 +127,7 @@ angular.module('odoo')
|
|
$scope.customer = $scope.customers[index];
|
|
$scope.customer = $scope.customers[index];
|
|
}
|
|
}
|
|
|
|
|
|
- console.log('Customer selected => ' + angular.toJson($scope.customer));
|
|
|
|
|
|
+ console.log('Customer selected => ' + angular.toJson($scope.customer, true));
|
|
|
|
|
|
$ionicActionSheet.show({
|
|
$ionicActionSheet.show({
|
|
titleText: 'Acciones',
|
|
titleText: 'Acciones',
|
|
@@ -121,6 +137,9 @@ angular.module('odoo')
|
|
},
|
|
},
|
|
{
|
|
{
|
|
text: '<i class="icon ion-archive positive"></i> Agregar a contactos'
|
|
text: '<i class="icon ion-archive positive"></i> Agregar a contactos'
|
|
|
|
+ },
|
|
|
|
+ {
|
|
|
|
+ text: '<i class="icon ion-navigate positive"></i> Ir a la ubicación'
|
|
}
|
|
}
|
|
],
|
|
],
|
|
destructiveText: '<i class="icon ion-trash-a assertive"></i> Eliminar',
|
|
destructiveText: '<i class="icon ion-trash-a assertive"></i> Eliminar',
|
|
@@ -136,6 +155,9 @@ angular.module('odoo')
|
|
case 1:
|
|
case 1:
|
|
$scope.addContact();
|
|
$scope.addContact();
|
|
break;
|
|
break;
|
|
|
|
+ case 2:
|
|
|
|
+ $scope.navigate();
|
|
|
|
+ break;
|
|
default:
|
|
default:
|
|
$scope.show();
|
|
$scope.show();
|
|
}
|
|
}
|
|
@@ -204,7 +226,7 @@ angular.module('odoo')
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
$scope.takePicture = function () {
|
|
$scope.takePicture = function () {
|
|
- cameraFactory.takePicture(function (imageData) {
|
|
|
|
|
|
+ deviceFactory.takePicture(function (imageData) {
|
|
$scope.customer.image_small = imageData;
|
|
$scope.customer.image_small = imageData;
|
|
$scope.customer.image_medium = imageData;
|
|
$scope.customer.image_medium = imageData;
|
|
}, function (error) {
|
|
}, function (error) {
|
|
@@ -216,10 +238,24 @@ angular.module('odoo')
|
|
*
|
|
*
|
|
*/
|
|
*/
|
|
$scope.addContact = function () {
|
|
$scope.addContact = function () {
|
|
- contactFactory.save($scope.customer, function (result) {
|
|
|
|
- $ionicPopup.alert({ title: 'Contacto guardado' });
|
|
|
|
|
|
+ deviceFactory.saveContact($scope.customer, function (result) {
|
|
|
|
+ console.log(result);
|
|
}, function (error) {
|
|
}, function (error) {
|
|
console.log(error);
|
|
console.log(error);
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ *
|
|
|
|
+ */
|
|
|
|
+ $scope.navigate = function () {
|
|
|
|
+ deviceFactory.navigate([
|
|
|
|
+ $scope.customer.partner_latitude,
|
|
|
|
+ $scope.customer.partner_longitude
|
|
|
|
+ ], function (message) {
|
|
|
|
+ console.log(message);
|
|
|
|
+ }, function (err) {
|
|
|
|
+ console.log(err);
|
|
|
|
+ })
|
|
|
|
+ }
|
|
});
|
|
});
|