/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

var app = angular.module("PrePago", []);

var base_url = 'http://localhost/painel_multi_2015/prepago/';

app.service('PlanosService', function ($http) {

    var planos = {};

    this.getPlanos = function (callback) {
        $http.get(base_url + 'index.php/planos/planos_revendas').success(callback);
    };

    /*this.addPlanos = function (desc_plano, qtd_logins, valor_cobrado) {
     $http.post(base_url + 'index.php/planos/planos_revendas',{desc_plano: desc_plano}).success();
     };*/
});

app.controller('Planos', function ($scope, PlanosService, $http) {

    //atualiza planos para revendas
    PlanosService.getPlanos(function (data) {
        $scope.planos = data;
    });
    // ativa o botão de enviar o formulario
    $scope.ativaSubmit = function () {
        if (typeof $scope.desc_plano === 'undefined' || typeof $scope.qtd_login === 'undefined' || typeof $scope.valor_cobrado === 'undefined') {
            return true;
        } else {
            return false;
        }
    };
    //adiciona plano
    /*$scope.addPlano = function () {
     PlanosService.addPlanos(0, $scope.desc_plano, $scope.qtd_login, $scope.valor_cobrado);
     
     PlanosService.getPlanos(function (data) {
     $scope.planos = data;
     });
     };*/   

});