123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134 |
- angular.module('odoo')
- .factory('config', function (storage) {
- return function (success, error) {
- storage.get('user', function (users) {
- success(users);
- }, function (err) {
- error(err);
- });
- };
- })
- .factory('async', function () {
- return {
- loop: function (iterations, func, callback) {
- var index = 0;
- var done = false;
- var loop = {
- next: function () {
- if (done) {
- return;
- }
- if (index < iterations) {
- index++;
- func(loop);
- } else {
- done = true;
- callback();
- }
- },
- iteration: function() {
- return index - 1;
- },
- break: function() {
- done = true;
- callback();
- }
- };
- loop.next();
- return loop;
- }
- }
- })
- .factory('camera', function ($cordovaCamera) {
- return {
- takePicture: function (success, error) {
- var options = {
- quality: 75,
- destinationType: Camera.DestinationType.DATA_URL,
- sourceType: Camera.PictureSourceType.CAMERA,
- allowEdit: true,
- encodingType: Camera.EncodingType.JPEG,
- targetWidth: 300,
- targetHeight: 300,
- popoverOptions: CameraPopoverOptions,
- saveToPhotoAlbum: false,
- correctOrientation:true
- };
- $cordovaCamera.getPicture(options).then(function(imageData) {
- success(imageData);
- }, function(err) {
- error(err);
- });
- }
- }
- })
- .factory('contact', function ($cordovaContacts) {
- return {
- save: function (customer, success, error) {
- if(!customer.mobile && !customer.phone && !customer.email) {
- error();
- return;
- }
- var contact = {
- name: {
- givenName: customer.name,
- familyName: '',
- formatted: ''
- },
- nickname: '',
- phoneNumbers: [
- {
- value: customer.phone,
- type: 'phone'
- },
- {
- value: customer.mobile,
- type: 'mobile'
- }
- ],
- emails: [
- {
- value: customer.email,
- type: 'home'
- }
- ],
- addresses: [
- {
- type: 'home',
- formatted: '',
- streetAddress: customer.street,
- locality: customer.city,
- region: '',
- postalCode: '',
- country: 'Paraguay'
- }
- ],
- ims: null,
- organizations: null,
- birthday: null,
- note: null,
- photos: null,
- categories: null,
- urls: null
- };
- $cordovaContacts.save(contact).then(function (result) {
- success(result);
- }, function (err) {
- error(err);
- });
- }
- }
- });
|