Whenever a juror, witness, or officer is required to attend a court, or travel on official business out of the limits of his or her own county, and entitled to mileage, in lieu thereof he or she may at his or her option receive his or her actual and necessary traveling expenses by the usually traveled route in going to and returning from the place where the court is held, or where the business is discharged. At the close of each term of the district court, the clerk shall ascertain the amount due each juror for his or her mileage and per diem; and he or she shall also certify the amount of fees that may be due to the sheriff of any other county than that in which the court is held, who may have attended the term, having a prisoner in custody charged with or convicted of a crime, or for the purpose of conveying such prisoner to or from the county, which, when approved by the court or judge, shall be a charge upon the county to which the prisoner belongs; and he or she shall also certify the amount which may be due witnesses attending from another county in a criminal case for their fees, which, when approved by the court or judge, shall be a charge upon the county to which the case belongs.