app.js 6.8 KB

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