Skip to content
Snippets Groups Projects
history.js 1.72 KiB
Newer Older
function getAllTransaction(isDriver){
    var id = sessionid;
    var xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function () {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
            document.getElementById('driver-info').innerHTML = xmlhttp.responseText;
            //Make it so the change is only for the user order, not driver orders
            var rating = document.getElementsByClassName('transaction-rating');
            for(i=0; i<rating.length; i++){
                var iterate = rating[i].childNodes[0].nodeValue;
                while(rating[i].hasChildNodes()){
                    rating[i].removeChild(rating[i].lastChild);
                }
                rating[i].innerHTML = 'You rated: ';
                for(j=0; j<iterate; j++){
                    var ratingImage = document.createElement('img');
                    ratingImage.setAttribute('src', '../img/rating.png');
                    ratingImage.classList.add('small-rating-image');
                    var idName = 'transaction-' + i + '-rating';
                    document.getElementById(idName).appendChild(ratingImage);
                }
            }
    xmlhttp.open('GET', '../controller/transactionController.php?id=' + id + '&driver=' + isDriver,true);
    xmlhttp = new XMLHttpRequest();
    xmlhttp.onreadystatechange = function () {
        if(xmlhttp.readyState == 4 && xmlhttp.status == 200){
            var elementId = 'transaction-' + id;
            document.getElementById(elementId).parentNode.parentNode.style.display = "none";
        }
    };
    xmlhttp.open('GET', '../controller/transactionController.php?id=' + id + '&hide=1',true);
    xmlhttp.send();