(a) When a prisoner confined in any state prison, county correctional institution, or other penal institution under the jurisdiction of the Board of Corrections, other than a prisoner under a death sentence, is needed as a witness in any judicial proceeding in any court of record in this state or when it is desired that such person stand trial on an indictment or accusation charging the prisoner with commission of a felony or misdemeanor, the judge of the court wherein the proceeding is pending shall be authorized to and shall issue an ex parte order, directed to the commissioner of corrections, requiring the prisoner's delivery to the sheriff of the county where the prisoner is desired as a witness or accused. The sheriff or his or her deputies shall take custody of the prisoner on the date named in the order, safely keep the prisoner pending the proceeding, and return him or her to the original place of detention after the prisoner's discharge by the trial judge.
(b) If the prisoner was desired as a witness by this state in a criminal proceeding or if the prisoner's release to the sheriff was for the purpose of standing trial on criminal charges, the county wherein the proceeding was pending shall pay all expenses of transportation and keeping, including per diem and mileage of the sheriff, jail fees, and any other proper expense approved by the trial judge.
(c) If the prisoner was desired as a witness by the accused in a criminal proceeding or by either party to a civil proceeding, the costs and expenses referred to in subsection (b) of this Code section shall be borne by the party requesting the prisoner as a witness. The court shall require a deposit of money sufficient to defray same, except where the judge, after examining into the matter, determines that the prisoner's presence is required by the interests of justice and that the party requesting it is financially unable to make the deposit, in which case the expenses shall be taxed as costs of court.
(d) If a prisoner under a death sentence is needed as a witness for either the prosecution or the defense in any felony case, the requesting party may interview the proposed witness. Following such interview, the requesting party may move for a writ of habeas corpus ad testificandum. Such motion shall be accompanied by a proffer of the testimony of the proposed witness. The requesting party shall make such motion and proffer as soon as possible but shall not make such motion later than 20 days prior to the date of the trial. Nothing in this Code section shall limit the right of a party from presenting a material witness at a hearing or trial and to have compulsory process for that purpose.