Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mainApp.controller('RegistrationCtrl', function ($scope,$http) {
- $scope.indexCatalog=0;
- $scope.rootNodeCatalog="#idnewCatalogTree";
- // $scope.loadingImg=document.getElementById('namePath').value+"/resources/images/loader.gif";
- $scope.getDisciplines=function(){
- $('#modalLoader').modal('show');
- // $http.get('service/subscriber').success(function(data, status, headers, config) {
- // MOCK
- $http.get(mockPath +'secure.service.subscriber.json').success(function(data, status, headers, config) {
- if(data.result.message=='OK'){
- var data_render=[];
- $(data.response).each(function(index,item){
- data_render.push([
- item.id,
- item.name,
- item.description,
- 0,
- 0,
- 0
- ]);
- });
- if($.fn.DataTable.isDataTable('#dtEvents')){
- $('#dtEvents').DataTable().destroy();
- }
- $('#dtEvents').DataTable({
- data: data_render,
- "columnDefs": [
- {
- "render": function ( data, type, row ) {
- return "<input type='number' class='input-row input-sm form-control' value='0' />";
- },
- "targets": [3,4,5]
- }
- ]
- });
- $('#dtEvents tbody').on('click', 'input.input-row', function () {
- var indexCell = $(this).parents('td').index();
- var indexRow = $(this).parents('tr').index();
- var row = $('#dtEvents').DataTable().row( ':eq('+indexRow+')' );
- row.data()[indexCell]=parseInt($(this).val());
- });
- $("#confirmEvents").click(function(e){
- e.preventDefault();
- e.stopImmediatePropagation();
- var dataEvents={
- "accompanying":{"accompanying":$("#naccpersons").val()},
- "discipline":[]
- };
- $($('#dtEvents').DataTable().rows().nodes()).each(function(){
- var id=$(this).children("td:nth-child(1)").html();
- var athletisFemale=parseInt($(this).children("td:nth-child(4)").children("input").val());
- var athletisMale=parseInt($(this).children("td:nth-child(5)").children("input").val());
- var official=parseInt($(this).children("td:nth-child(6)").children("input").val());
- if(athletisFemale>0 || athletisMale>0 || official>0){
- dataEvents.discipline.push(
- {"id":id,"athletisFemale":athletisFemale,"athletisMale":athletisMale,"official":official}
- )
- }
- });
- $scope.getProducts(dataEvents);
- });
- $('#modalLoader').modal('hide');
- $('#modalRegAthletes').modal('show');
- }else{
- errorService.showModalError(data.result.message);
- }
- }).error(function(data, status, headers, config) {
- errorService.showModalError();
- });
- }
- $scope.navigateCatalog=function(category,parent_index){
- for(var i=0;i<category.length;i++){
- if(category[i].layout){
- $scope.indexCatalog++;
- var class_parent="";
- if(parent_index>0)
- class_parent=" treegrid-parent-"+parent_index;
- var description="Additional Info";
- if(category[i].description)
- description=category[i].description;
- $($scope.rootNodeCatalog).append("<tr class='treegrid-"+$scope.indexCatalog+class_parent+"'><td width='50%'>"+category[i].name+"</td><td>"+description+"</td></tr>");
- var pindex=$scope.indexCatalog;
- }else
- var pindex=parent_index;
- if(category[i].product){
- for(var j=0;j<category[i].product.length;j++){
- $scope.indexCatalog++;
- $($scope.rootNodeCatalog).append("<tr class='treegrid-"+$scope.indexCatalog+" treegrid-parent-"+pindex+"'><td width='50%'>"+category[i].product[j].name+" € "+category[i].product[j].price+"</td><td><input id='"+category[i].product[j].id+"' style='width: 50%;' type='number' min='0' class='form-control' value='0' placeholder='quantity'></td></tr>");
- }
- }
- if(category[i].category){
- $scope.navigateCatalog(category[i].category,(category[i].layout)?pindex:parent_index);
- }
- }
- }
- $scope.getReview = function() {
- // angular.forEach($scope.response.catalog, function(obj){
- // $("#previewStep").append("<p>" + obj + "</p>");
- // })
- // console.log($scope.response.catalog)
- }
- $scope.getProducts=function(dataEvents){
- $('#modalLoader').modal('show');
- // $http.post('service/subscriber', JSON.stringify(dataEvents)).success(function(data, status, headers, config) {
- // MOCK
- $http.get(mockPath +'secure.service.subscriber_post.json').success(function(data, status, headers, config) {
- $('#modalLoader').modal('hide');
- if(data.result.message=="OK"){
- $http.get($scope.$parent.pages.wizard.url).success(function(contentWizard, status, headers, config) {
- $('#wizard').html(contentWizard);
- $($scope.rootNodeCatalog+" tbody").empty();
- $scope.response = data.response;
- $scope.navigateCatalog(data.response.catalog);
- $scope.getReview();
- $("#hajdhTotal").val(data.response.total);
- $('.tree').treegrid({
- expanderExpandedClass: 'glyphicon glyphicon-minus',
- expanderCollapsedClass: 'glyphicon glyphicon-plus'
- });
- $('#wizard').smartWizard();
- $('#modalRegAthletes').modal('hide');
- $('#modalCatalog').modal({
- backdrop : 'static',
- keyboard : false,
- show : true
- });
- $(".payment-block").html(data.response.payment[0].name);
- $(".payment-block").data("name",data.response.payment[0].name);
- $(".payment-block").data("id",data.response.payment[0].id);
- $(".payment-block").click(function(e){
- $scope.setPayment($(this).data("id"),$(this).data("name"),data.response.keyOrder);
- })
- for(var i=1;i<data.response.payment.length;i++){
- $paymentBlock=$(".payment-block").clone().appendTo( ".payments-container" );
- $paymentBlock.data("name",data.response.payment[i].name);
- $paymentBlock.data("id",data.response.payment[i].id);
- $paymentBlock.html(data.response.payment[i].name);
- $paymentBlock.click(function(e){
- $scope.setPayment($(this).data("id"),$(this).data("name"),data.response.keyOrder);
- })
- }
- })
- }else{
- errorService.showModalError(data.result.message);
- }
- }).error(function(data, status, headers, config) {
- errorService.showModalError();
- });
- }
- $scope.payments=[];
- $scope.paymentFields={
- "banktransfer":{
- "iban":"",
- "bank":"",
- "description":"",
- "heading":"",
- "total":"",
- "partial":""
- }
- }
- $scope.setPayment=function(id,type,keyOrder){
- var arrayBankChannel = [];
- var rowCatalogarrayBankChannel = $("#idnewCatalogTree").find('tr');
- $(rowCatalogarrayBankChannel).each(function(index, value){
- var inputs = $(this).find("input");
- inputs.each(function(index, value) {
- var checkifnumber = $(this).val();
- var idcheckifnumber = $(this).attr('id');
- if(checkifnumber!=0){
- arrayBankChannel.push(
- {
- "id": idcheckifnumber,
- "quantity": checkifnumber
- }
- );
- }
- });
- });
- var finaltosend = {
- "totalMember": $("#hajdhTotal").val(),
- "keyOrder": keyOrder,
- "payment": {
- "id":id
- },
- "products" : arrayBankChannel
- };
- switch(id){
- case 2:
- $("#loaderWizard").removeClass("hide");
- $("#wizard").addClass("hide");
- // $http.post('service/order/subscriber', JSON.stringify(finaltosend)).success(function(data, status, headers, config) {
- // MOCK
- $http.get(mockPath +'secure.service.subscriber_post.json').success(function(data, status, headers, config) {
- $http.get($scope.$parent.pages.banktransfer.url).success(function(contentWizard, status, headers, config) {
- if(data.result.message=='OK'){
- $("#loaderWizard").addClass("hide");
- $("#wizard").removeClass("hide");
- $('#wizard').html(contentWizard);
- $("#bt-description").html(data.response.payment.description);
- $("#bt-iban").html(data.response.payment.iban);
- $("#bt-bank").html(data.response.payment.bank);
- $("#bt-event-name").html(data.response.payment.heading);
- $("#bt-totalBank").html("€ "+data.response.totPayment);
- $("#bt-partialBank").html("€ "+data.response.payment.amount);
- }else{
- errorService.showModalError(data.result.message);
- $("#loaderWizard").addClass("hide");
- $("#wizard").removeClass("hide");
- }
- }).error(function(data, status, headers, config) {
- errorService.showModalError();
- $("#loaderWizard").addClass("hide");
- $("#wizard").removeClass("hide");
- });
- }).error(function(data, status, headers, config) {
- errorService.showModalError();
- $("#loaderWizard").addClass("hide");
- $("#wizard").removeClass("hide");
- });
- break;
- case 1:
- // $http.post('service/order/subscriber', JSON.stringify(finaltosend)).success(function(data, status, headers, config) {
- // MOCK
- $http.get(mockPath+'service.order.subscriber_post_CC.json', JSON.stringify(finaltosend)).success(function(data, status, headers, config) {
- if(data.result.message=='OK'){
- var url=data.response.payment.endpoint;
- $("#wizard").html('<iframe width="100%" height="1000" frameborder="0" scrolling="yes" allowtransparency="true" src="'+url+'"></iframe>');
- }else{
- errorService.showModalError(data.result.message);
- }
- }).error(function(data, status, headers, config) {
- errorService.showModalError();
- });
- break;
- }
- }
- $scope.openLoader=function(){
- $("#modalCatalog").modal("hide");
- }
- $scope.init=function(){
- $scope.getDisciplines();
- }
- $scope.$on('showregistration', function(event, args) {
- $scope.init();
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement