<?php
/**
 * Ce script définit la classe 'voie'.
 *
 * @package opencimetiere
 * @version SVN : $Id$
 */

require_once "../gen/obj/voie.class.php";

/**
 * Définition de la classe 'voie' (om_dbform).
 */
class voie extends voie_gen {

    /**
     *
     * @return void
     */
    function init_class_actions() {
        parent::init_class_actions();
        // ACTION - 101 - edition
        //
        $this->class_actions[101] = array(
            "identifier" => "pdf-edition",
            "portlet" => array(
                "type" => "action-blank",
                "libelle" => __("récapitulatif"),
                "description" => __('télécharger le récapitulatif au format pdf'),
                "class" => "pdf-16",
                "order" => 30,
            ),
            "permission_suffix" => "edition",
            "view" => "view_pdf_edition_etat",
            "condition" => array(
                "exists",
            ),
        );
    }

    /**
     * @return string
     */
    function get_om_etat_id() {
        return $this->get_absolute_class_name();
    }

    /**
     *
     * @return string
     */
    function get_var_sql_forminc__sql_zone() {
        //
        $sql_zone_common = "SELECT zone.zone, (zone_type.libelle||' '||zone.zonelib||' ('||cimetiere.cimetierelib||')') as lib " ;
        $sql_zone_common .= " FROM ".DB_PREFIXE."zone ";
        $sql_zone_common .= " LEFT JOIN ".DB_PREFIXE."zone_type ";
        $sql_zone_common .= " ON zone.zonetype = zone_type.zone_type ";
        $sql_zone_common .= " LEFT JOIN ".DB_PREFIXE."cimetiere ";
        $sql_zone_common .= " ON zone.cimetiere = cimetiere.cimetiere ";
        //
        return $sql_zone_common." ORDER BY cimetiere.cimetierelib, (zone_type.libelle||' '||zone.zonelib) ";
    }

    /**
     *
     * @return string
     */
    function get_var_sql_forminc__sql_zone_by_id() {
        //
        $sql_zone_common = "SELECT zone.zone, (zone_type.libelle||' '||zone.zonelib||' ('||cimetiere.cimetierelib||')') as lib " ;
        $sql_zone_common .= " FROM ".DB_PREFIXE."zone ";
        $sql_zone_common .= " LEFT JOIN ".DB_PREFIXE."zone_type ";
        $sql_zone_common .= " ON zone.zonetype = zone_type.zone_type ";
        $sql_zone_common .= " LEFT JOIN ".DB_PREFIXE."cimetiere ";
        $sql_zone_common .= " ON zone.cimetiere = cimetiere.cimetiere ";
        //
        return $sql_zone_common." WHERE zone = <idx> ";
    }

    function setLib(&$form, $maj) {
        //
        parent::setLib($form, $maj);
        //
        $form->setLib($this->clePrimaire, __("id"));
        $form->setLib("voielib", __("libelle"));
    }

    function setType(&$form, $maj) {
        //
        parent::setType($form, $maj);
        // Gestion du champs geom
        $form->setType('geom','hidden');
        if ($this->f->getParameter("option_localisation") == "sig_interne") {
            if ($maj == 0 || $maj == 1 || $maj == 3) {
                $form->setType('geom', 'geom');
            }
        }
    }

    function setOnchange(&$form, $maj) {
        //
        parent::setOnchange($form, $maj);
        //
        $form->setOnchange("voielib","this.value=this.value.toUpperCase()");
    }
}
