/**
  * Calcule et affecte la nomenclature abrégée à  partir de l'arbre
  *
  * @return void
  * @access public
  */
 public function calc_abbreviation()
 {
     $tinstruments = array();
     $musicstand_standard_all = true;
     if (is_array($this->instruments)) {
         foreach ($this->instruments as $instrument) {
             if (count($instrument->get_others_instruments())) {
                 $musicstand_standard_all = false;
             }
             $nomenclature_instrument = new nomenclature_instrument($instrument->get_id(), $instrument->get_code(), $instrument->get_name());
             $nomenclature_instrument->calc_abbreviation();
             if ($instrument->is_standard()) {
                 if ($instrument->get_part()) {
                     $tinstruments[$instrument->get_part()] = $nomenclature_instrument->get_abbreviation();
                 } else {
                     $tinstruments[$instrument->get_order()] = $nomenclature_instrument->get_abbreviation();
                 }
             } else {
                 $tinstruments[$instrument->get_order()] = $nomenclature_instrument->get_abbreviation();
                 $musicstand_standard_all = false;
             }
         }
         if ($musicstand_standard_all) {
             $this->set_abbreviation($this->effective);
         } else {
             ksort($tinstruments);
             $this->set_abbreviation($this->effective . "[" . implode(".", $tinstruments) . "]");
         }
     } else {
         $this->set_abbreviation("0");
     }
 }
 public function get_other_instrument()
 {
     if (!$this->other_instrument_definition_in_progress) {
         $this->other_instrument_definition_in_progress = true;
         $no_std_inst = new nomenclature_instrument(0, "", "");
         $no_std_inst->set_standard(false);
         return $no_std_inst;
     }
 }
// +-------------------------------------------------+
// $Id: ajax_main.inc.php,v 1.1 2016-01-06 15:05:58 dgoron Exp $
if (stristr($_SERVER['REQUEST_URI'], ".inc.php")) {
    die("no access");
}
require_once $class_path . "/encoding_normalize.class.php";
require_once $class_path . "/nomenclature/nomenclature_instrument.class.php";
switch ($sub) {
    case "instrument":
        switch ($action) {
            case "create":
                $return = nomenclature_instrument::create();
                print encoding_normalize::json_encode($return);
                break;
        }
        break;
    case "forms":
        switch ($action) {
            case "get_form":
                switch ($form) {
                    case "nomenclature_instrument_form_tpl":
                        print nomenclature_instrument::get_dialog_form();
                        break;
                }
                break;
        }
        break;
    default:
        ajax_http_send_error('400', $msg["ajax_commande_inconnue"]);
        break;
}