HEX
Server: Apache/2.4.41 (Ubuntu)
System: Linux ip-172-31-42-149 5.15.0-1084-aws #91~20.04.1-Ubuntu SMP Fri May 2 07:00:04 UTC 2025 aarch64
User: ubuntu (1000)
PHP: 7.4.33
Disabled: pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare,
Upload Files
File: /var/www/vhost/disk-apps/demo.sports-crowd.com/public/js/comments.js

/*
 * En caso de que se haga clic en el icono de editar 
 * se redirecciona a la vista de edición de categoría
 */
function clickSendComment(value) {

    $("#modal-send-comment").attr('data-id',value);
    $("#modal-send-comment").modal('show');
  }

    /**
     * Esta función hace un llamado AJAX y envia un json creando un nuevo registro de categoría
     * @param info el json con la informacion de la vista
     * @version 2018/05/20
     */
    function createAdminComment() {

        var text = $('#commentTxt').val();
        var id = $('#modal-send-comment').attr('data-id');
        var idSucursal = $('#sucursal').val();

        if(idSucursal == 0){
            swal("Error",Lang.get('messagesClient.screen_chats_error_tag2'), "error");
        }else{
            var info = {
                'id': id,
                'comment': text,
                'sucursal': idSucursal
            }
            console.log(info);

            $.ajax({
            url: "/comments/update",
            type: "POST",
            contentType: 'application/json',
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
                'Content-Type': 'application/json'
            },
            data: JSON.stringify(info),
            success: function (r) {
                
                if (r) {

                        swal(r.m, {
                            icon: "success",
                            buttons: {
                                Ok: true,
                            }
                        }).then((val) => {
                            if (val == "Ok") {
                                $('#modal-send-comment').modal('toggle');
                                $(location).attr('href', '/comments');
                            }
                        });
                    
                } else {
                    
                    swal(Lang.get('messagesClient.screen_chats_error_tag3'), "error");
                    $("#btn-create-category").prop("disabled", false);
                }
            }, error :function(e){
                swal("Error",Lang.get('messagesClient.screen_categories_tag6'), "error");
                $("#btn-create-category").prop("disabled", false);
            }
        });

        }
        
    }




function clickInfoComment(id) {

    var info = {
        'id': id
    }

    $.ajax({
        url: "/comments/check",
        type: "POST",
        contentType: 'application/json',
        headers: {
          'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
          'Content-Type': 'application/json'
        },
        data: JSON.stringify(info),
        success: function (r) {
            if(r.d != null){
                
                var rateClient = r.d[0].qualification_client;
                var rateAdmin =r.d[0].qualification_admin;
                var rateDeliveryMan =r.d[0].qualification_delivery_man;

                var commentClient=r.d[0].observations_client; 
                var commentAdmin=r.d[0].observations_admin;
                var commentDeliveryMan=r.d[0].observation_delivery_man;
                $('#order').text(r.d[0].order.code);
                $('#client').text(r.d[0].client.first_name+' '+r.d[0].client.last_name);
                if(r.d[0].admin){
                    $('#admin').text(r.d[0].admin.first_name+' '+r.d[0].admin.last_name);
                }else{
                    $('#admin').text('No hay admin');
                }
               if(r.d[0].delivery_man){
                $('#delivery_man').text(r.d[0].delivery_man.first_name+' '+r.d[0].delivery_man.last_name);
                
               }else{
                $('#delivery_man').text('No hay mensajero');
               }
                
                if(commentAdmin == null){
                    $('#admin_comment').text('No hay respuesta');
                }else{
                    $('#admin_comment').text(commentAdmin);
                }
                
                if(commentClient == null){
                    $('#client_comment').text('No hay respuesta');
                }else{
                    $('#client_comment').text(commentClient);
                }
                
                if(commentDeliveryMan == null){
                    $('#delivery_man_comment').text('No hay respuesta');
                }else{
                    $('#delivery_man_comment').text(commentDeliveryMan);
                }
               
                //CLIENT
                var starsClient = $('#clientStars li').parent().children('li.star');

                for (i = 0; i < starsClient.length; i++) {
                    $(starsClient[i]).removeClass('selected');
                }

                for (i = 0; i < rateClient; i++) {
                    $(starsClient[i]).addClass('selected');
                }

                //ADMIN
                var starsAdmin = $('#adminStars li').parent().children('li.star');

                for (i = 0; i < starsAdmin.length; i++) {
                    $(starsAdmin[i]).removeClass('selected');
                }

                for (i = 0; i < rateAdmin; i++) {
                    $(starsAdmin[i]).addClass('selected');
                }
                
                //Delivery
                var starsDelivery = $('#deliveryManStars li').parent().children('li.star');

                for (i = 0; i < starsDelivery.length; i++) {
                    $(starsDelivery[i]).removeClass('selected');
                }

                for (i = 0; i < rateDeliveryMan; i++) {
                    $(starsDelivery[i]).addClass('selected');
                }
                $("#modal-info-comment").modal('show');
            
            }
  
      },
      error: function (err) {
        swal("Error", err.responseJSON.message, "error");
      }
    });
  }



//alert de confirmación al eliminar comentario
function clickDeleteComment(value) {
    
    var info = {
        "id": value
    }
    swal(Lang.get('messagesClient.screen_delete_comment_tag1'), {
        buttons: {
            cancel: "No",
            Ok: true,
        }
    }).then((val) => {
        if (val == "Ok") {
            deleteComment(info);
        }
    });
};


//funcion eliminar comentario
function deleteComment(info) {
    $.ajax({
        url: "/comments/delete",
        type: "POST",
        contentType: 'application/json',
        headers: {
            'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content'),
            'Content-Type': 'application/json'
        },
        data: JSON.stringify(info),
        success: function (r) {
            if (r.r) {
                swal(r.m, {
                    icon: "success",
                    buttons: {
                        Ok: true,
                    }
                }).then((val) => {
                    if (val == "Ok") {
                        $(location).attr('href', url + '/comments');
                    }
                });
            } else {
                swal("Error", Lang.get('messagesClient.screen_delete_categories_tag2'), "error");
            }
        },
        error: function (e) {

            swal("Error", Lang.get('messagesClient.screen_delete_categories_tag2'), "error");

        }
    });

}