from ..base import BaseView
# from peewee import DoesNotExist, IntegrityError
# from median.database import mysql_db
import logging

logger = logging.getLogger('median')


class RiedlEntreeItems(BaseView):

    def affichage(self, liste, v_orderby_column, v_dir):
        query = """
              SELECT i.x_pk, i.x_item, i.x_etat, i.x_ref, i.x_fraction,
                     x_desig, x_qte_dem, x_qte_serv, x_moment, x_heure
                FROM  f_item i
                inner join f_ref r ON i.x_ref=r.x_ref
               WHERE x_mode='E' and x_liste='{0}' order by {1} {2}
        """.format(liste, v_orderby_column, v_dir)
        return self.render_query(query)
