package info.bukova.isspst.ui.renderers;

import info.bukova.isspst.data.RequirementState;
import info.bukova.isspst.data.TripBillApproval;
import org.zkoss.zul.Listbox;
import org.zkoss.zul.Listitem;

/**
 * @author Pepa Rokos
 */
public class TripBillApprovalItemRenderer extends GenericListitemRenderer<TripBillApproval> {

	@Override
	protected void changeProperties(Listbox lb, Listitem li, int index, String varnm) {

		RequirementState state = getObjectOfStates().getState();

		if (state != null) {
			if (state == RequirementState.PARTIALLY) {
				li.setSclass("req-select-partially");
			}
			else if (state == RequirementState.APPROVED) {
				Boolean isPaid;

				if (getObjectOfStates().getBill() == null) {
					isPaid = false;
				} else {
					isPaid = getObjectOfStates().getBill().getPaid();
				}

				if ((isPaid != null) && (isPaid.booleanValue() == true)) {
					li.setSclass("req-select-approved-project");
				}
				else {
					li.setSclass("req-select-approved");
				}
			}
		}
	}
}
