Ejemplo n.º 1
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     if ($this->act != 'add') {
         $q = $db->createSelectQuery();
         $q->select('*')->from('building_data')->where("bu_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['mu_name'] = $vlu["mu_name_{$lang}"];
         // Autocomplete
         $vlu['fr_name'] = $vlu["fr_name_{$lang}"];
         // Autocomplete
         $vlu['st_name'] = $vlu["st_name_{$lang}"];
         // Autocomplete
         $vlu['bu_usage_h_from'] = substr($vlu['bu_usage_h_from'], 0, 5);
         $vlu['bu_usage_h_to'] = substr($vlu['bu_usage_h_to'], 0, 5);
         $vlu['bu_build_year_as_string'] = $vlu['bu_build_year'];
         // Prevent number format
         $vlu['bu_restructure_year_as_string'] = $vlu['bu_restructure_year'];
         // Prevent number format
         // Immgini
         $sql = "SELECT doc_file_id, doct_code\n                    FROM document doc\n                    INNER JOIN document_type doct ON doc.doct_id=doct.doct_id\n                    WHERE doc_object_id={$this->id} AND doct_code IN ('BUILDING_PHOTO', 'BUILDING_THERMOGRAPHY', 'BUILDING_LABEL')";
         // echo $sql;
         $images = array();
         foreach ($db->query($sql) as $row) {
             $images[strtolower($row['doct_code'])][] = $row['doc_file_id'];
         }
         $vlu['images'] = $images;
         if ($vlu['has_geometry']) {
             $vlu['map_preview_url'] = htmlspecialchars(R3EcoGisHelper::getMapPreviewURL($this->do_id, 'building', $this->id, $lang));
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('building', $vlu['bu_id']));
     } else {
         $vlu = array();
         $vlu['do_id'] = $this->do_id;
         $vlu['cus_name'] = R3EcoGisHelper::getDomainName($this->do_id);
         $mu_values = R3EcoGisHelper::getMunicipalityList($this->do_id);
         if (count($mu_values) == 1) {
             $vlu['mu_id'] = key($mu_values);
         } else {
             if ($this->auth->getParam('mu_id') > 0) {
                 $vlu['mu_id'] = $this->auth->getParam('mu_id');
             }
         }
         if (isset($vlu['mu_id']) && $vlu['mu_id'] != '') {
             $vlu['mu_name'] = R3EcoGisHelper::getMunicipalityName($vlu['mu_id']);
             if ($this->auth->getConfigValue('APPLICATION', 'BUILDING_CODE_TYPE') == 'AUTO' || $this->auth->getConfigValue('APPLICATION', 'BUILDING_CODE_TYPE') == 'PROPOSED') {
                 $fmt = $this->auth->getConfigValue('APPLICATION', 'BUILDING_CODE_FORMAT');
                 try {
                     $vlu['bu_code'] = sprintf($fmt == '' ? '%s' : $fmt, $db->query("SELECT MAX(bu_code::integer) FROM building WHERE mu_id={$vlu['mu_id']}")->fetchColumn() + 1);
                 } catch (Exception $e) {
                 }
             }
         }
         $vlu['ez_id'] = null;
         $vlu['ec_id'] = null;
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Ejemplo n.º 2
0
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     if ($this->auth->hasPerm('SHOW', 'ALL_DOMAINS')) {
         $do_id = $_SESSION['do_id'];
     } else {
         $do_id = $this->auth->getDomainID();
     }
     $db = ezcDbInstance::get();
     $vlu = array();
     if ($this->act != 'add') {
         if ($id === null) {
             throw new Exception("Missing ID for customer");
         }
         $q = $db->createSelectQuery();
         $where = array();
         $where[] = 'sl_id=' . (int) $id;
         if (!$this->auth->hasPerm('SHOW', 'ALL_DOMAINS')) {
             $where[] = $q->expr->eq('do_id', (int) $this->auth->getDomainID());
         }
         $q->select('*')->from('street_lighting_data')->where($where);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['cus_name'] = $vlu['cus_name_' . $lang];
         $vlu['mu_name'] = $vlu['mu_name_' . $lang];
         if ($vlu['has_geometry']) {
             $vlu['map_preview_url'] = R3EcoGisHelper::getMapPreviewURL($this->do_id, 'street_lighting', $this->id, $lang);
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('street_lighting', $vlu['sl_id']));
     } else {
         $vlu = array();
         $vlu['do_id'] = $_SESSION['do_id'];
         $vlu['cus_name'] = R3EcoGisHelper::getDomainName($_SESSION['do_id']);
         $mu_values = R3EcoGisHelper::getMunicipalityList($this->do_id);
         if (count($mu_values) == 1) {
             $vlu['mu_id'] = key($mu_values);
         } else {
             if ($this->auth->getParam('mu_id') > 0) {
                 $vlu['mu_id'] = $this->auth->getParam('mu_id');
             }
         }
         if (isset($vlu['mu_id']) && $vlu['mu_id'] != '') {
             $vlu['mu_name'] = R3EcoGisHelper::getMunicipalityName($vlu['mu_id']);
         }
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }