Пример #1
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     $db = ezcDbInstance::get();
     if ($this->act == 'add') {
         $vlu = array();
         $vlu['bu_id'] = $this->bu_id;
         $vlu['us_id'] = null;
         $vlu['es_id'] = null;
         $vlu['is_producer'] = 'F';
         $vlu['em_is_production'] = 'F';
         $vlu['devices'] = 0;
         $vlu['consumptions'] = 0;
     } else {
         $q = $db->createSelectQuery();
         $q->select('*')->from('energy_meter_data')->where('em_id=' . (int) $id);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $this->bu_id = $vlu['bu_id'] = $vlu['em_object_id'];
         $vlu['devices'] = $db->query('SELECT COUNT(*) FROM device WHERE em_id=' . (int) $id)->fetchColumn();
         $vlu['consumptions'] = $db->query('SELECT COUNT(*) FROM consumption WHERE em_id=' . (int) $id)->fetchColumn();
         if ($vlu['us_id'] > 0) {
             $vlu['es_id'] = null;
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('energy_meter', $vlu['em_id']));
     }
     $data = R3EcoGisHelper::getBuildingData($vlu['bu_id']);
     $this->mu_id = $data['mu_id'];
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #2
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     $db = ezcDbInstance::get();
     if ($this->act == 'add') {
         $vlu = array();
         if ($this->kind == 'street_lighting') {
             $data = $this->getElectricityUDMData($_SESSION['do_id']);
             $vlu['em_data']['udm_name'] = $data["udm_name_{$lang}"];
         } else {
             $vlu['em_data'] = R3EcoGisHelper::getMeterData($_SESSION['do_id'], $this->em_id);
         }
     } else {
         $q = $db->createSelectQuery();
         $q->select('*')->from('consumption_data')->where('co_id=' . (int) $id);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $this->em_id = $vlu['em_id'];
         $vlu['em_data'] = R3EcoGisHelper::getMeterData($_SESSION['do_id'], $vlu['em_id']);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('consumption', $vlu['co_id']));
         //em_is_production
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #3
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $db = ezcDbInstance::get();
     $sql = "SELECT * FROM stat_general WHERE do_id=" . $this->do_id;
     $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
     if ($vlu === false) {
         $vlu = array('sg_id' => null);
     }
     $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('stat_general', $vlu['sg_id']));
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #4
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     $db = ezcDbInstance::get();
     if ($this->act == 'add') {
         $vlu = array();
         $vlu['em_data'] = R3EcoGisHelper::getMeterData($_SESSION['do_id'], $this->em_id);
     } else {
         $q = $db->createSelectQuery();
         $q->select('*')->from('device_data')->where('dev_id=' . (int) $id);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $this->em_id = $vlu['em_id'];
         $vlu['em_data'] = R3EcoGisHelper::getMeterData($_SESSION['do_id'], $vlu['em_id']);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('device', $vlu['dev_id']));
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #5
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $db = ezcDbInstance::get();
     $id = (int) $id;
     $productMinEntry = 3;
     if ($this->act != 'add') {
         $q = $db->createSelectQuery();
         $q->select('*')->from('utility_supplier')->where("us_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['municipality'] = R3EcoGisUtilityHelper::getSelectedMunicipalityList($this->id);
         $vlu['products'] = R3EcoGisUtilityHelper::getProductsList($this->id);
         foreach ($vlu['products'] as $key => $val) {
             $vlu['products'][$key]['esu_co2_factor'] = R3NumberFormat($val['esu_co2_factor'], null, true);
         }
         $tot = max($productMinEntry - 1, count($vlu['products'])) + 1;
         $key = 0;
         for ($i = count($vlu['products']); $i < $tot; $i++) {
             $vlu['products']["new_{$key}"] = array();
             $key++;
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('utility_supplier', $vlu['us_id']));
     } else {
         $vlu = array();
         $vlu['us_order'] = 0;
         $vlu['municipality'] = array();
         for ($i = 0; $i < $productMinEntry; $i++) {
             $vlu['products']["new_{$i}"] = array();
         }
     }
     $this->data = $vlu;
     return $vlu;
 }
Пример #6
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     $db = ezcDbInstance::get();
     if ($this->act != 'add') {
         $q = $db->createSelectQuery();
         $q->select('*')->from('global_entry_data')->where('ge_id=' . (int) $id);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['cus_name'] = $vlu['cus_name_' . $lang];
         $vlu['mu_name'] = $vlu['mu_name_' . $lang];
         // Autocomplete
         $vlu['ge_year_as_string'] = $vlu['ge_year'];
         // Prevent number format
         $vlu['ge_green_electricity_purchase'] = $vlu['ge_green_electricity_purchase'] / 1000;
         // Revert to MWh
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_entry', $vlu['ge_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 ($this->auth->getParam('mu_id') > 0) {
             $vlu['mu_id'] = $this->auth->getParam('mu_id');
             $vlu['mu_name'] = R3EcoGisHelper::getMunicipalityName($this->auth->getParam('mu_id'));
         }
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #7
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;
 }
Пример #8
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('action_catalog_data ac')->where("ac_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['mu_name'] = $vlu["mu_name_{$lang}"];
         // Autocomplete
         $vlu['ac_expected_co2_reduction'] = $vlu['ac_expected_co2_reduction_calc'] / 1000;
         // Get the calculated value - the db value is not used
         $vlu['ac_expected_energy_saving_mwh'] = $vlu['ac_expected_energy_saving_kwh'] / 1000;
         $vlu['ac_green_electricity_purchase_mwh'] = R3NumberFormat($vlu['ac_green_electricity_purchase_kwh'] / 1000, 2, true);
         $vlu['ac_co2_reduction_tco2'] = R3NumberFormat($vlu['ac_co2_reduction'] / 1000, 2, true);
         $vlu['ac_expected_renewable_energy_production_mwh'] = $vlu['ac_expected_renewable_energy_production_kwh'] / 1000;
         // Get the calculated value - the db value is not used
         // get expected energy savings
         $vlu['ac_expected_energy_savings'] = array();
         $sql = "SELECT action_catalog_energy.*, energy_source_udm.*, " . "      esu_kwh_factor * ace_expected_energy_saving AS ace_expected_energy_saving_kwh, " . "      esu_co2_factor * ace_expected_energy_saving AS ace_expected_co2_reduction_calc " . " FROM action_catalog_energy " . " INNER JOIN energy_source_udm USING(esu_id) " . " WHERE ac_id={$this->id} " . "ORDER BY ace_id";
         $r = $db->query($sql);
         while ($row = $r->fetch()) {
             $lkp = $this->getLookupDataForEnergySavings($row['ges_id']);
             $tmp = array('ges_id' => $row['ges_id'], 'es_id' => $row['es_id'], 'udm_id' => $row['udm_id'], 'ac_expected_energy_saving' => R3NumberFormat($row['ace_expected_energy_saving'], 2, true), 'ac_expected_energy_saving_mwh' => R3NumberFormat($row['ace_expected_energy_saving_kwh'] / 1000, 2, true), 'ac_expected_co2_reduction' => R3NumberFormat($row['ace_expected_co2_reduction_calc'] / 1000, 2, true), 'es_id_consumption_values' => $lkp['es_id_consumption_values'], 'udm_id_consumption_values' => $lkp['udm_id_consumption_values']);
             $vlu['ac_expected_energy_savings'][] = $tmp;
         }
         // get related actions
         $vlu['ac_related_actions'] = array();
         $vlu['ac_related_required_actions'] = array();
         $vlu['ac_related_excluded_actions'] = array();
         $sql = "SELECT action_catalog.ac_id, ac_name_{$lang}, acd_type " . " FROM action_catalog " . " INNER JOIN action_catalog_dependencies on action_catalog.ac_id = action_catalog_dependencies.ac_related_id " . " WHERE action_catalog_dependencies.ac_id={$this->id}";
         $r = $db->query($sql);
         while ($row = $r->fetch()) {
             if ($row['acd_type'] == 'R') {
                 $index = 'ac_related_required_actions';
             } else {
                 if ($row['acd_type'] == 'D') {
                     $index = 'ac_related_actions';
                 } else {
                     if ($row['acd_type'] == 'E') {
                         $index = 'ac_related_excluded_actions';
                     } else {
                         throw new exceltion('Invalid value for acd_type');
                     }
                 }
             }
             $tmp = array('ac_id' => $row['ac_id'], 'ac_name' => $row['ac_name_' . $lang]);
             array_push($vlu[$index], $tmp);
         }
         // get benefit year
         $vlu['ac_benefit_year'] = array();
         $sql = "SELECT acby_year, acby_benefit \r\n                    FROM action_catalog_benefit_year\r\n                    WHERE ac_id={$this->id}\r\n                    ORDER BY acby_year";
         $vlu['enable_benefit_year'] = 'F';
         foreach ($db->query($sql, PDO::FETCH_ASSOC) as $row) {
             $vlu['ac_benefit_year'][] = $row;
             $vlu['enable_benefit_year'] = 'T';
         }
         if ($this->bu_id != '') {
             $vlu['bu_id'] = $this->bu_id;
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('action_catalog', $vlu['ac_id']));
     } else {
         $vlu = array();
         $vlu['ac_id'] = null;
         $vlu['bu_id'] = $this->bu_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->bu_id != '') {
             $vlu['mu_id'] = $db->query('SELECT mu_id FROM building WHERE bu_id=' . (int) $this->bu_id)->fetchColumn();
             $emo_id = R3EcoGisHelper::getEnergyMeterObjectIdByCode('BUILDING');
             $codePart1 = $db->query('SELECT bu_code FROM building WHERE bu_id=' . (int) $this->bu_id)->fetchColumn();
             $codePart2 = $db->query("SELECT LPAD((COUNT(ac_code) + 1)::TEXT, 2, '0') FROM action_catalog WHERE emo_id={$emo_id} AND ac_object_id=" . (int) $this->bu_id)->fetchColumn();
             if ($codePart1 == '') {
                 $vlu['ac_code'] = $codePart2;
             } else {
                 $vlu['ac_code'] = "{$codePart1}-{$codePart2}";
             }
             // Ricavo Macro-settore, Settore, Sub-settore
             list($gc_id, $gc_id_parent) = R3EcoGisHelper::getGlobalCategoryForActionCatalogBuilding($this->bu_id);
             if ($gc_id_parent === null || $gc_id === null) {
                 throw new Exception(_("Destinazione d'uso dell'edificio mancante, o categoria PAES non valida"));
             }
             $vlu['gc_parent_id'] = $gc_id_parent;
             $vlu['gc_id'] = $gc_id;
         } else {
             if (isset($vlu['mu_id'])) {
                 $vlu['ac_code'] = (int) $db->query('SELECT MAX(ac_code) FROM action_catalog WHERE mu_id=' . (int) $vlu['mu_id'])->fetchColumn() + 1;
             }
         }
         $vlu['ac_benefit_end_date'] = $this->auth->getConfigValue('APPLICATION', 'DEFAULT_ACTION_BENEFIT_END_DATE', '2020-12-31');
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #9
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     if ($this->act == 'open') {
         // open/download the document
         $this->deliver('import_seap');
         die;
     }
     if ($this->act || $this->auth->getParam('mu_id') != '') {
         if ($this->act != 'add') {
             $db = ezcDbInstance::get();
             $q = $db->createSelectQuery();
             $q->select('*')->from('document_data');
             if ($this->auth->getParam('mu_id') != '') {
                 $q->where("doct_code='SEAP' AND doc_object_id=" . $this->auth->getParam('mu_id'));
             } else {
                 $q->where("doct_code='SEAP' AND doc_id=" . (int) $this->id);
             }
             $q->orderBy("doc_id DESC");
             $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
             $vlu['doc_data'] = json_decode($vlu['doc_descr_1'], true);
             $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('document', $vlu['doc_id']));
         } else {
             $vlu = array();
         }
         $this->data = $vlu;
         // Save the data (prevent multiple sql)
         return $vlu;
     }
     return array();
 }
Пример #10
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('energy_source_udm_data')->where("esu_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['ges_full_name'] = $vlu["ges_full_name_{$lang}"];
         $vlu['gc_full_name'] = $vlu["gc_full_name_{$lang}"];
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('energy_source_udm', $vlu['esu_id']));
     } else {
         $vlu = array();
         $vlu['es_id'] = null;
     }
     $this->data = $vlu;
     return $vlu;
 }
Пример #11
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();
     }
     $opt = array();
     $db = ezcDbInstance::get();
     R3EcoGisSimulationHelper::clearLog();
     if ($this->act != 'add') {
         if ($id === null) {
             throw new Exception("Missing ID for customer");
         }
         $q = $db->createSelectQuery();
         $where = array();
         $where[] = 'sw_id=' . (int) $id;
         $where[] = '(us_id IS NULL OR us_id=' . $this->auth->getUID() . ')';
         if (!$this->auth->hasPerm('SHOW', 'ALL_DOMAINS')) {
             $where[] = $q->expr->eq('do_id', (int) $this->auth->getDomainID());
         }
         $q->select("*, ge_name_{$lang} AS ge_name, ge_2_name_{$lang} AS ge_2_name")->from('simulation_work_data')->where($where);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['mu_name'] = $vlu['mu_name_' . $lang];
         R3EcoGisSimulationHelper::addLog(0, _('Riepilogo calcolo'));
         $sql = "SELECT ac_id, swd_energy_efficacy FROM simulation_work_detail WHERE sw_id=" . (int) $id;
         $ac_id_list = array();
         $ac_perc_list = array();
         foreach ($db->query($sql) as $row) {
             $ac_id_list[] = $row['ac_id'];
             $ac_perc_list[] = $row['swd_energy_efficacy'];
         }
         $vlu['actions'] = $this->getSimulationWork($id, $this->select_done == 'T');
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('simulation_work', $vlu['sw_id']));
     } else {
         $vlu = array();
         $vlu['mu_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 ($vlu['mu_id'] != '') {
             $q = $db->createSelectQuery();
             $q->select("gst_id ")->from('global_strategy')->where('mu_id=' . (int) $vlu['mu_id']);
             $vlu['gst_id'] = $db->query($q)->fetch();
         }
         if ($this->alternativeSimulation) {
             $vlu['sw_title_1'] = sprintf(_('Simulazione comunale del %s'), date('d/m/Y'));
             $vlu['sw_title_2'] = sprintf(_('Simulazione comunale del %s'), date('d/m/Y'));
         } else {
             $vlu['sw_title_1'] = sprintf(_('Simulazione del %s'), date('d/m/Y'));
             $vlu['sw_title_2'] = sprintf(_('Simulazione del %s'), date('d/m/Y'));
         }
         $vlu['sw_efe_is_calculated'] = 'T';
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #12
0
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     // Ricavo nome macro categoria
     $categoryName = '';
     if ($this->gc_id != '') {
         $sql = "SELECT gc_parent.gc_name_{$lang} AS gc_name\r\n                    FROM global_category gc\r\n                    INNER JOIN global_category gc_parent ON gc.gc_parent_id=gc_parent.gc_id\r\n                    WHERE gc.gc_id={$this->gc_id}";
         $categoryName = $db->query($sql)->fetchColumn();
     }
     if ($this->act == 'add') {
         $vlu['gc_id'] = $this->gc_id;
         $vlu['gp_id'] = $this->gp_id;
     } else {
         $sql = "SELECT grp.*, mu_id\r\n                    FROM global_plain_row_data grp\r\n                    INNER JOIN global_plain_data gp ON grp.gp_id=gp.gp_id\r\n                    WHERE gpr_id=" . (int) $this->gpr_id;
         $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
         $this->gc_id = $vlu['gc_id'];
         $vlu['data'] = R3EcoGisGlobalPlainHelper::getGaugeData($this->gpr_id);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_plain_row', $vlu['gpr_id']));
     }
     $vlu['gc_name'] = $categoryName;
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #13
0
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     $sql = "SELECT gc1.gc_id, gc2.gc_name_{$lang} AS gc_name_main, gc1.gc_name_{$lang} AS gc_name\r\n                FROM global_category gc1\r\n                INNER JOIN global_category gc2 ON gc1.gc_parent_id=gc2.gc_id\r\n                WHERE gc1.gc_id=" . (int) $this->id;
     $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
     $gpac_id = $db->query("SELECT gpac_id FROM ecogis.global_plain_action_category WHERE gc_id={$this->id} ORDER BY gpac_id LIMIT 1")->fetchColumn();
     // Ricavo il primo record per determinare la data di modifica
     $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_plain_action_category', $gpac_id));
     return $vlu;
 }
Пример #14
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('global_plain_data')->where("gp_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['mu_name'] = $vlu["mu_name_{$lang}"];
         // Autocomplete
         $vlu['gp_url_1'] = $this->adjURL($vlu["gp_url_1"], true);
         if (isset($vlu["gp_url_2"])) {
             $vlu['gp_url_2'] = $this->adjURL($vlu["gp_url_2"], true);
         }
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_plain', $vlu['gp_id']));
     } else {
         $vlu = array();
         $vlu['do_id'] = $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']);
         }
         $vlu['gp_url_1'] = $this->adjURL('', true);
         $vlu['gp_url_2'] = $this->adjURL('', true);
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #15
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     if ($this->auth->getParam('mu_id') != '') {
         // override the default action if it is a municipality user
         $sql = "SELECT gst_id FROM global_strategy WHERE mu_id=" . $db->quote($this->auth->getParam('mu_id'));
         $this->id = $db->query($sql)->fetchColumn();
         $this->act = $this->id > 0 ? 'mod' : 'add';
     }
     $vlu = array();
     if ($this->act != 'add') {
         R3Security::checkGlobalStrategy($this->id);
         $q = $db->createSelectQuery();
         $q->select('*')->from('global_strategy_data')->where("gst_id={$this->id}");
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu['mu_name'] = $vlu["mu_name_{$lang}"];
         // Autocomplete
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_strategy', $this->id));
     } else {
         $vlu['do_id'] = $this->do_id;
         $mu_values = R3EcoGisGlobalStrategyHelper::getAvailableMunicipalityList($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['gst_name_1'] = 'Adesione al Patto dei Sindaci - Comune di ' . R3EcoGisHelper::getMunicipalityName($vlu['mu_id'], 1);
             $vlu['gst_name_2'] = 'Bürgermeisterkonvents - Gemeinde ' . R3EcoGisHelper::getMunicipalityName($vlu['mu_id'], 2);
         } else {
             $vlu['gst_name_1'] = 'Adesione al Patto dei Sindaci';
             $vlu['gst_name_2'] = 'Bürgermeisterkonvents';
         }
         $vlu['gst_reduction_target'] = 20;
         $vlu['gst_reduction_target_year'] = 2020;
         $vlu['gst_reduction_target_absolute'] = $vlu['gst_reduction_target_absolute_long_term'] = 'T';
         $vlu['gst_emission_factor_type_ipcc'] = $vlu['gst_emission_unit_co2'] = 'T';
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     if ($this->act == 'add') {
         $vlu = array();
         $vlu['gt_id'] = null;
     } else {
         $sql = "SELECT *\r\n                    FROM global_type\r\n                    WHERE gt_id=" . $this->id;
         $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('global_type', $vlu['gt_id']));
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #17
0
 public function getData()
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     $id = $this->id;
     $vlu = array();
     if ($this->act != 'add') {
         $id = (int) $this->id;
         try {
             $this->checkLookupDomainSecurity($id, $this->act);
         } catch (Exception $e) {
             die('Security error');
         }
         $pkName = $this->getPrimaryKeyName();
         $q = "SELECT * FROM {$this->table} WHERE {$pkName}={$id}";
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData($this->table, $id));
     } else {
         $vlu = array();
         foreach ($this->fields as $key => $field) {
             if (isset($field['name'])) {
                 $key = $field['name'];
             }
             if (isset($field['default'])) {
                 $vlu[$key] = $field['default'];
             }
         }
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #18
0
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $db = ezcDbInstance::get();
     if ($this->act == 'open') {
         // open/download the document
         $this->deliver($this->documentType);
         die;
     }
     $db = ezcDbInstance::get();
     if ($this->act == 'add') {
         $sep = R3Locale::getDateSeparator();
         $vlu = array();
         $vlu['doc_date'] = date('Y-m-d');
     } else {
         $q = $db->createSelectQuery();
         $q->select('*')->from('document_data')->where('doc_id=' . (int) $this->id);
         $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
         $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('document', $vlu['doc_id']));
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Пример #19
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;
 }
Пример #20
0
 /**
  * Return the data for a single customer
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     //R3Security::checkBuilding($this->id);
     $q = $db->createSelectQuery();
     $q->select('*')->from('stat_type_data')->where("st_id={$this->id}");
     $vlu = $db->query($q)->fetch(PDO::FETCH_ASSOC);
     $capabilities = $this->getStatisticCapabilitiesByCode($vlu['st_code']);
     $context = R3EcoGisStatHelper::getBetterContext($vlu['st_code']);
     $childContext = R3EcoGisStatHelper::getBetterChildContext($vlu['st_code']);
     $classes['absolute'] = R3EcoGisStatHelper::getStatsLegend($vlu['do_id'], $vlu['st_code'], $context, $childContext, true);
     if ($vlu['st_has_relative_data']) {
         $classes['relative'] = R3EcoGisStatHelper::getStatsLegend($vlu['do_id'], $vlu['st_code'], $context, $childContext, false);
     }
     $vlu = array_merge($vlu, R3EcoGisHelper::getChangeLogData('building', $vlu['st_id']), array('capabilities' => $capabilities, 'classes' => $classes));
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }