123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133 |
- angular.module('odoo')
- .controller('OpportunitiesController', function (
- $scope,
- $ionicActionSheet,
- crmStagesDataFactory
- ) {
- $scope.stages = [];
- $scope.opportunities = [
- {
- name: 'Op. 1',
- stage: 'Nuevo'
- },
- {
- name: 'Op. 2',
- stage: 'Perdido'
- },
- {
- name: 'Op. 3',
- stage: 'Propuesta'
- },
- {
- name: 'Op. 1',
- stage: 'Nuevo'
- },
- {
- name: 'Op. 1',
- stage: 'Nuevo'
- },
- {
- name: 'Op. 1',
- stage: 'Nuevo'
- }
- ];
- $scope.title = '';
- $scope.loading = false;
- $scope.selected = -1;
- $scope.$on("$ionicSlides.sliderInitialized", function (event, data){
- $scope.slider = data.slider;
- });
- $scope.$on("$ionicSlides.slideChangeEnd", function (event, data) {
- $scope.stageChanged(data.slider.activeIndex);
- });
- $scope.$on("$ionicView.enter", function () {
- $scope.getStages();
- });
- $scope.getStages = function () {
- crmStagesDataFactory.sync(function (stages) {
- $scope.stages = stages;
- $scope.stageChanged(0);
- }, function (syncErr) {
- console.log(syncErr);
- });
- }
- /**
- * Change the state
- */
- $scope.changeStage = function (mode) {
- $scope.loading = true;
- if (mode) {
- $scope.slider.slideNext();
- } else {
- $scope.slider.slidePrev();
- }
- $scope.loading = false;
- }
- /**
- * Change stage name on title
- */
- $scope.stageChanged = function (index) {
- if (!$scope.stages.length) {
- return;
- }
- $scope.title = $scope.stages[index].name;
- if(!$scope.$$phase) {
- $scope.$apply();
- }
- }
- /**
- * Open the actionsheet action options
- */
- $scope.openOptions = function (index) {
- $scope.selected = index;
- $ionicActionSheet.show({
- titleText: 'Acciones',
- buttons: [
- {
- text: '<i class="icon ion-arrow-expand positive"></i> Abrir'
- },
- {
- text: '<i class="icon ion-forward positive"></i> Mover a'
- }
- ],
- destructiveText: '<i class="icon ion-trash-a assertive"></i> Eliminar',
- cancel: function() {
- $scope.customer = {};
- $scope.selected = -1;
- },
- buttonClicked: function(index) {
- switch (index) {
- case 0:
- $scope.show();
- break;
- case 1:
- $scope.addContact();
- break;
- default:
- $scope.show();
- }
- return true;
- },
- destructiveButtonClicked: function() {
- $scope.delete();
- return true;
- }
- });
- }
- });
|