app.js 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. angular.module(
  2. 'odoo',
  3. [
  4. 'ionic',
  5. 'ngCordova',
  6. 'xml-rpc',
  7. 'jett.ionic.filter.bar',
  8. 'ionic-toast',
  9. 'pascalprecht.translate'
  10. ]
  11. )
  12. .run(function(
  13. $ionicPlatform,
  14. $state,
  15. configFactory
  16. ) {
  17. $ionicPlatform.ready(function() {
  18. if (window.cordova && window.cordova.plugins.Keyboard) {
  19. cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
  20. cordova.plugins.Keyboard.disableScroll(true);
  21. }
  22. if (window.StatusBar) {
  23. StatusBar.overlaysWebView(false);
  24. StatusBar.backgroundColorByHexString('#387ef5');
  25. }
  26. db = window.sqlitePlugin.openDatabase({ name: 'odoo.db', location: 'default' });
  27. db.executeSql("CREATE TABLE IF NOT EXISTS 'user' (\n\
  28. 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n\
  29. 'remote_id' INTEGER DEFAULT 0,\n\
  30. 'host' VARCHAR(35) DEFAULT 0,\n\
  31. 'port' INTEGER DEFAULT 0,\n\
  32. 'database' VARCHAR(35) DEFAULT NULL,\n\
  33. 'username' VARCHAR(35) DEFAULT NULL,\n\
  34. 'password' VARCHAR(35) DEFAULT NULL)");
  35. db.executeSql("CREATE TABLE IF NOT EXISTS 'partner' (\n\
  36. 'id' INTEGER DEFAULT NULL PRIMARY KEY AUTOINCREMENT,\n\
  37. 'remote_id' INTEGER DEFAULT 0,\n\
  38. 'modified' INTEGER DEFAULT 0,\n\
  39. 'modifiedDate' TEXT DEFAULT CURRENT_TIMESTAMP,\n\
  40. 'name' VARCHAR(35) DEFAULT NULL,\n\
  41. 'city' VARCHAR(35) DEFAULT NULL,\n\
  42. 'mobile' VARCHAR(20) DEFAULT NULL,\n\
  43. 'phone' VARCHAR(20) DEFAULT NULL,\n\
  44. 'fax' VARCHAR(20) DEFAULT NULL,\n\
  45. 'email' VARCHAR(100) DEFAULT NULL,\n\
  46. 'street' VARCHAR(35) DEFAULT NULL,\n\
  47. 'street2' VARCHAR(35) DEFAULT NULL,\n\
  48. 'image_medium' BLOB DEFAULT NULL,\n\
  49. 'image_small' BLOB DEFAULT NULL,\n\
  50. 'comment' VARCHAR(160) DEFAULT NULL,\n\
  51. 'customer' INTEGER DEFAULT 0,\n\
  52. 'employee' INTEGER DEFAULT 0,\n\
  53. 'is_company' INTEGER DEFAULT 0,\n\
  54. 'debit' INTEGER DEFAULT 0,\n\
  55. 'debit_limit' INTEGER DEFAULT 0,\n\
  56. 'opportunity_count' INTEGER DEFAULT 0,\n\
  57. 'contracts_count' INTEGER DEFAULT 0,\n\
  58. 'journal_item_count' INTEGER DEFAULT 0,\n\
  59. 'meeting_count' INTEGER DEFAULT 0,\n\
  60. 'phonecall_count' INTEGER DEFAULT 0,\n\
  61. 'sale_order_count' INTEGER DEFAULT NULL,\n\
  62. 'total_invoiced' INTEGER DEFAULT NULL);");
  63. db.executeSql("CREATE TABLE IF NOT EXISTS 'lead' (\n\
  64. 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n\
  65. 'remote_id' INTEGER DEFAULT 0,\n\
  66. 'modified' INTEGER DEFAULT 0,\n\
  67. 'modifiedDate' TEXT DEFAULT CURRENT_TIMESTAMP,\n\
  68. 'name' VARCHAR(35) DEFAULT NULL,\n\
  69. 'description' VARCHAR(100) DEFAULT NULL,\n\
  70. 'contact_name' VARCHAR(100) DEFAULT NULL,\n\
  71. 'phone' VARCHAR(20) DEFAULT NULL,\n\
  72. 'mobile' VARCHAR(20) DEFAULT NULL,\n\
  73. 'fax' VARCHAR(20) DEFAULT NULL,\n\
  74. 'street' VARCHAR(35) DEFAULT NULL,\n\
  75. 'street2' VARCHAR(35) DEFAULT NULL,\n\
  76. 'meeting_count' INTEGER DEFAULT 0,\n\
  77. 'message_bounce' INTEGER DEFAULT 0,\n\
  78. 'planned_cost' INTEGER DEFAULT 0,\n\
  79. 'planned_revenue' INTEGER DEFAULT 0,\n\
  80. 'priority' INTEGER DEFAULT 0,\n\
  81. 'probability' INTEGER DEFAULT 0,\n\
  82. 'type' VARCHAR(20) DEFAULT NULL,\n\
  83. 'stage_id' INTEGER DEFAULT NULL,\n\
  84. 'user_id' INTEGER DEFAULT 0,\n\
  85. 'partner_id' INTEGER DEFAULT 0);");
  86. db.executeSql("CREATE TABLE IF NOT EXISTS 'crm_stage' (\n\
  87. 'id' INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,\n\
  88. 'remote_id' INTEGER DEFAULT 0,\n\
  89. 'modified' INTEGER DEFAULT 0,\n\
  90. 'modified_date' TEXT DEFAULT CURRENT_TIMESTAMP,\n\
  91. 'name' VARCHAR(35) DEFAULT NULL,\n\
  92. 'probability' REAL DEFAULT 0,\n\
  93. 'type' VARCHAR(100) DEFAULT 'both');");
  94. configFactory(function (configuration) {
  95. if (configuration) {
  96. $state.go('app.main');
  97. } else {
  98. $state.go('configuration');
  99. }
  100. }, function (err) {
  101. $state.go('configuration');
  102. });
  103. });
  104. })
  105. .config(function (
  106. $stateProvider,
  107. $urlRouterProvider,
  108. // $ionicConfigProvider,
  109. $translateProvider,
  110. $ionicFilterBarConfigProvider
  111. ) {
  112. $stateProvider
  113. .state('app', {
  114. url: '/app',
  115. abstract: true,
  116. templateUrl: 'templates/menu.html'
  117. })
  118. .state('app.main', {
  119. url: '/main',
  120. views: {
  121. 'content': {
  122. templateUrl: 'templates/main.html',
  123. controller: 'MainController'
  124. }
  125. }
  126. })
  127. .state('app.sales', {
  128. url: '/sales',
  129. views: {
  130. 'content': {
  131. templateUrl: 'templates/sales/sales.html',
  132. controller: 'SaleController'
  133. }
  134. }
  135. })
  136. .state('app.customers', {
  137. url: '/customers',
  138. views: {
  139. 'content': {
  140. templateUrl: 'templates/sales/customers.html',
  141. controller: 'CustomersController'
  142. }
  143. }
  144. })
  145. .state('app.leads', {
  146. url: '/leads',
  147. views: {
  148. 'content': {
  149. templateUrl: 'templates/sales/leads.html',
  150. controller: 'LeadsController'
  151. }
  152. }
  153. })
  154. .state('app.opportunities', {
  155. url: '/opportunities',
  156. views: {
  157. 'content': {
  158. templateUrl: 'templates/sales/opportunities.html',
  159. controller: 'OpportunitiesController'
  160. }
  161. }
  162. })
  163. .state('app.preferences', {
  164. url: '/preferences',
  165. views: {
  166. 'content': {
  167. templateUrl: 'templates/preferences.html',
  168. controller: 'PreferencesController'
  169. }
  170. }
  171. })
  172. .state('configuration', {
  173. url: '/configuration',
  174. templateUrl: 'templates/configuration.html',
  175. controller: 'ConfigurationController'
  176. });
  177. $translateProvider.translations('es', {
  178. Opportunities: 'Oportunidades',
  179. New: 'Nuevo',
  180. Dead: 'Muerto',
  181. Qualification: 'Calificación',
  182. Proposition: 'Propuesta',
  183. Negotiation: 'Negociación',
  184. Won: 'Ganado',
  185. Lost: 'Perdido'
  186. });
  187. // $urlRouterProvider.otherwise('/configuration');
  188. // $ionicConfigProvider.tabs.position('bottom');
  189. // $ionicConfigProvider.backButton.icon('ion-chevron-left');
  190. $ionicFilterBarConfigProvider.theme('positive');
  191. $ionicFilterBarConfigProvider.placeholder('Buscar');
  192. // $translateProvider.useSanitizeValueStrategy('sanitize');
  193. $translateProvider.useSanitizeValueStrategy('escape');
  194. $translateProvider.preferredLanguage('es');
  195. $translateProvider.fallbackLanguage('es');
  196. });