/** * 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; }
public function askDelGlobalPlainSum($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $gc_id = (int) $request['gc_id']; $name = $db->query("SELECT gc_name_{$lang} FROM global_category WHERE gc_id={$gc_id}")->fetchColumn(); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler eliminare gli obiettivi per la categoria \"%s\"?"), $name)); }
public function __construct(array $request = array(), array $opt = array()) { parent::__construct($request, $opt); $this->fields = $this->defFields(); $this->act = initVar('act', 'mod'); $this->do_id = $_SESSION['do_id']; setLang(R3Locale::getLanguageCode()); setLangInfo(array('thousands_sep' => ".")); $this->registerAjaxFunction('getHelp'); $this->registerAjaxFunction('submitFormData'); }
/** * Create the table header * param string $order The table order */ public function createListTableHeader(&$order) { $lang = R3Locale::getLanguageID(); $this->simpleTable->addSimpleField(_('Nome utente'), 'us_name', 'text', null, array('sortable' => true)); $this->simpleTable->addSimpleField(_('Email/login'), 'us_login', 'text', null, array('sortable' => true)); if ($this->auth->getConfigValue('PUBLIC_SITE', 'REGISTRATION_NEED_OPERATOR_CONFIRM', 'F') == 'T') { $this->simpleTable->addSimpleField(_('Stato'), 'us_status_text', 'text', 150, array('sortable' => true)); } $this->simpleTable->addSimpleField(_('Data registrazione'), 'us_ins_date', 'date', 80, array('sortable' => true, 'align' => 'center')); $this->simpleTable->addSimpleField(_('Azione'), '', 'link', 50); $this->tableHtml = $this->simpleTable->CreateTableHeader($order); }
public function __construct(array $request = array(), array $opt = array()) { parent::__construct($request, $opt); $this->kind = initVar('kind'); $this->act = initVar('act', 'add'); $this->mu_id = initVar('mu_id'); $this->mu_name = initVar('mu_name'); if ($this->mu_name != '') { // Convert municipality text into id $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $this->mu_id = (int) $db->query("SELECT mu_id FROM municipality WHERE mu_name_{$lang} ILIKE " . $db->quote($request['mu_name']))->fetchColumn(); } setLang(R3Locale::getLanguageCode()); $this->registerAjaxFunction('submitFormData'); }
/** * Return the sql to generate the list */ public function getListSQL() { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $q = $db->createSelectQuery(); $where = array(); $where[] = $q->expr->eq('do_id', $this->do_id); if (!$this->auth->hasPerm('SHOW', 'ALL_DOMAINS') && $this->auth->getParam('mu_id') != '') { $where[] = $q->expr->eq('mu_id', $db->quote((int) $this->auth->getParam('mu_id'))); } $where[] = $q->expr->eq('doct_code', "'SEAP'"); $q->select("doc_id, doc_file_id, mu_name_{$lang} AS mu_name, doc_file, doc_date")->from('ecogis.document_data doc')->innerJoin('ecogis.municipality mu', 'doc.doc_object_id=mu_id'); if (count($where) > 0) { $q->where($where); } // echo $q; return $q; }
public function loadSimulationData($ac_id, $perc) { static $stmt1 = null, $stmt2, $stmt3; if ($stmt1 === null) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); //Totale riduzione CO2 da azioni // Nome simulazione e totale energia prodotta $sql1 = "SELECT ac_name_{$lang} AS ac_name, es_name_{$lang} AS es_name, udm_name_{$lang} AS udm_name,\r\n ac_estimated_cost, ac_estimated_public_financing, ac_estimated_other_financing, esu_co2_factor, esu_kwh_factor,\r\n ac_co2_reduction,\r\n ac_expected_renewable_energy_production, esu_id_production,\r\n ac_green_electricity_purchase, ac_green_electricity_co2_factor, ac.gc_id\r\n FROM action_catalog ac\r\n LEFT JOIN energy_source_udm esu ON ac.esu_id_production=esu.esu_id\r\n LEFT JOIN energy_source es ON esu.es_id=es.es_id\r\n LEFT JOIN udm ON esu.udm_id=udm.udm_id\r\n WHERE ac_id=?"; // Energia risparmiata (più entry in più udm - possibile applicazione efe al posto del fattore standard) $sql2 = "SELECT et_code, es_name_{$lang} AS es_name, udm_name_{$lang} AS udm_name, ace_expected_energy_saving, esu_co2_factor, esu_kwh_factor\r\n FROM action_catalog_energy ace\r\n LEFT JOIN energy_source_udm esu ON ace.esu_id=esu.esu_id\r\n LEFT JOIN energy_source es ON esu.es_id=es.es_id\r\n LEFT JOIN energy_type et ON es.et_id=et.et_id\r\n LEFT JOIN udm ON esu.udm_id=udm.udm_id\r\n WHERE ace.ac_id=?"; $sql3 = "SELECT acby_year, acby_benefit\r\n FROM action_catalog_benefit_year WHERE ac_id=? AND acby_year<=2020\r\n ORDER BY acby_year DESC\r\n LIMIT 1"; $stmt1 = $db->prepare($sql1); $stmt2 = $db->prepare($sql2); $stmt3 = $db->prepare($sql3); } $stmt1->execute(array($ac_id)); $acData = $stmt1->fetch(PDO::FETCH_ASSOC); $stmt2->execute(array($ac_id)); $stmt3->execute(array($ac_id)); $acDataBenefit = $stmt3->fetch(PDO::FETCH_ASSOC); $gc_id = $acData['gc_id']; // Inizializzazione variabili globali $hasElectricity = false; $hasEnergySaving = false; $actionGoodness = $perc / 100; // Bontà azione if ($acDataBenefit === false) { $benefit = 1; // Beneficio } else { $benefit = $acDataBenefit['acby_benefit'] / 100; // beneficio } $logText = sprintf('Simulazione %s ', $acData['ac_name']) . ($actionGoodness != 1 ? sprintf('[Efficacia: %s%%] ', 100 * $actionGoodness) : '') . ($acDataBenefit !== false ? sprintf('[Beneficio: %s%% al %s] ', 100 * $benefit, $acDataBenefit['acby_year']) : ''); self::addLog(2, $logText); $result = array('estimated_cost' => null, 'electricity_saving_kwh' => null, 'energy_saving_kwh' => null, 'energy_saving_co2' => null, 'energy_production_kwh' => null, 'energy_purchase_kwh' => null, 'energy_purchase_factor' => null, 'energy_purchase_co2' => null, 'co2_reduction' => null); $globalResult = array(); $globalResult[$gc_id] = $result; if ($acData['ac_estimated_cost'] == '') { $acData['ac_estimated_cost'] = 0; } if (!isset($acData['ac_estimated_public_financing']) || $acData['ac_estimated_public_financing'] == '') { $acData['ac_estimated_public_financing'] = 0; } if (!isset($acData['ac_estimated_other_financing']) || $acData['ac_estimated_other_financing'] == '') { $acData['ac_estimated_other_financing'] = 0; } // Costi totali stimati if ($acData['ac_estimated_cost'] != '0' || $acData['ac_estimated_public_financing'] != '0' || $acData['ac_estimated_other_financing'] != '0') { $cost = $acData['ac_estimated_cost'] - $acData['ac_estimated_public_financing'] - $acData['ac_estimated_other_financing']; //$totals['estimated_cost'] += $cost; // Non applico efficacia e benficio ai costi $result['estimated_cost'] = $cost; $globalResult[$gc_id]['estimated_cost'] = $cost; self::addLog(3, sprintf(_('Costo: €%.2f'), $cost)); } while ($acDataEnergy = $stmt2->fetch(PDO::FETCH_ASSOC)) { if ($acDataEnergy['ace_expected_energy_saving'] == '') { $acDataEnergy['ace_expected_energy_saving'] = 0; } //echo "[{$acDataEnergy['ace_expected_energy_saving']}]"; if ($acDataEnergy['ace_expected_energy_saving'] != '0') { $energySavingKWh = $acDataEnergy['ace_expected_energy_saving'] * $acDataEnergy['esu_kwh_factor']; $energySavingkgCO2 = $acDataEnergy['ace_expected_energy_saving'] * $acDataEnergy['esu_co2_factor']; $logText = sprintf('Risparmio energetico previsto: %.2f%s di %s (=%.2fMWh)', $acDataEnergy['ace_expected_energy_saving'], $acDataEnergy['udm_name'], $acDataEnergy['es_name'], $energySavingKWh / 1000); if ($actionGoodness != 1) { $energySavingKWh = $energySavingKWh * $actionGoodness; $energySavingkgCO2 = $energySavingkgCO2 * $actionGoodness; $logText .= sprintf('; Applicazione efficacia: %.2fMWh', $energySavingKWh / 1000); } if ($benefit != 1) { $energySavingKWh = $energySavingKWh * $benefit; $energySavingkgCO2 = $energySavingkgCO2 * $benefit; $logText .= sprintf('; Applicazione beneficio: %.2fMWh', $energySavingKWh / 1000); } if ($acDataEnergy['et_code'] == 'ELECTRICITY') { //$totals['electricity_saving_kwh'] += $energySavingKWh; $result['electricity_saving_kwh'] += $energySavingKWh; $globalResult[$gc_id]['electricity_saving_kwh'] += $energySavingKWh; $hasElectricity = true; } else { $logText .= sprintf('; CO2: %.2f tCO2 ', $energySavingkgCO2 / 1000); //$totals['energy_saving_kwh'] += $energySavingKWh; //$totals['energy_saving_co2'] += $energySavingkgCO2; $result['energy_saving_kwh'] += $energySavingKWh; $result['energy_saving_co2'] += $energySavingkgCO2; $globalResult[$gc_id]['energy_saving_kwh'] += $energySavingKWh; $globalResult[$gc_id]['energy_saving_co2'] += $energySavingkgCO2; $hasEnergySaving = true; } self::addLog(3, $logText); } } if (isset($acData['ac_expected_renewable_energy_production']) && $acData['ac_expected_renewable_energy_production'] != '') { $productionKWh = $acData['ac_expected_renewable_energy_production'] * $acData['esu_kwh_factor']; $logText = sprintf('Produzione prevista: %.2f%s di %s (=%.2fMWh) ', $acData['ac_expected_renewable_energy_production'], $acData['udm_name'], $acData['es_name'], $productionKWh / 1000); if ($actionGoodness != 1) { $productionKWh = $productionKWh * $actionGoodness; $logText .= sprintf('Applicazione efficacia: %.2fMWh ', $productionKWh / 1000); } if ($benefit != 1) { $productionKWh = $productionKWh * $benefit; $logText .= sprintf('Applicazione beneficio: %.2fMWh ', $productionKWh / 1000); } $result['energy_production_kwh'] = $productionKWh; $globalResult[$gc_id]['energy_production_kwh'] = $productionKWh; self::addLog(3, $logText); } if (isset($acData['ac_green_electricity_purchase']) && $acData['ac_green_electricity_purchase'] != '' && $acData['ac_green_electricity_purchase'] != '0') { $purchaseKWh = $acData['ac_green_electricity_purchase']; $logText = sprintf('Acquisti energia verde: %.2fMWh ', $purchaseKWh / 1000); if ($actionGoodness != 1) { $purchaseKWh = $purchaseKWh * $actionGoodness; $logText .= sprintf('Applicazione efficacia: %.2fMWh ', $purchaseKWh / 1000); } if ($benefit != 1) { $purchaseKWh = $purchaseKWh * $benefit; $logText .= sprintf('Applicazione beneficio: %.2fMWh ', $purchaseKWh / 1000); } $result['energy_purchase_kwh'] = $purchaseKWh; $result['energy_purchase_factor'] = $acData['ac_green_electricity_co2_factor']; $result['energy_purchase_co2'] = $purchaseKWh * $acData['ac_green_electricity_co2_factor']; $globalResult[$gc_id]['energy_purchase_kwh'] = $purchaseKWh; $globalResult[$gc_id]['energy_purchase_factor'] = $acData['ac_green_electricity_co2_factor']; $globalResult[$gc_id]['energy_purchase_co2'] = $purchaseKWh * $acData['ac_green_electricity_co2_factor']; self::addLog(3, $logText); } if (isset($acData['ac_co2_reduction']) && $acData['ac_co2_reduction'] != '' && $acData['ac_co2_reduction'] != '0') { $co2FixedReduction = $acData['ac_co2_reduction']; $logText = sprintf('Riduzione fissa di CO2: %.2ftCO2 ', $co2FixedReduction / 1000); if ($actionGoodness != 1) { $co2FixedReduction = $co2FixedReduction * $actionGoodness; $logText .= sprintf('Applicazione efficacia: %.2ftCO2 ', $co2FixedReduction / 1000); } if ($benefit != 1) { $co2FixedReduction = $co2FixedReduction * $benefit; $logText .= sprintf('Applicazione beneficio: %.2ftCO2 ', $co2FixedReduction / 1000); } $result['co2_reduction'] = $co2FixedReduction; $globalResult[$gc_id]['co2_reduction'] = $co2FixedReduction; self::addLog(3, $logText); } $this->simData['detail'][$ac_id] = $result; $this->globalSimData['detail'][$gc_id][$ac_id] = $result; }
public function askDelGlobalPlainGauge($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $name = $db->query("SELECT gpg_name_{$lang} FROM ecogis.global_plain_gauge WHERE gpg_id={$id}")->fetchColumn(); if ($this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare l'indicatore \"%s\"?"), $name)); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questa voce dal catalogo azioni poichè vi sono dei dati ad esso legati')); } $name = $db->query("SELECT ac_name_{$lang} FROM action_catalog WHERE ac_id={$id}")->fetchColumn(); }
/** * Return the UDM * @param array $request the request * @return array the result data */ public function confirmDeleteStreetLighting($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = (int) $request['id']; $name = $db->query("SELECT sl_full_name_{$lang} AS sw_title FROM street_lighting_data WHERE sl_id={$id}")->fetchColumn(); $hasEnergyMeter = R3EcoGisHelper::hasEnergyMeter('STREET_LIGHTING', $id); $hasDocument = R3EcoGisHelper::hasDocument('STREET_LIGHTING', $id); if (!$hasEnergyMeter && !$hasDocument && $this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_('Sei sicuro di voler cancellare il tratto "%s"?'), $name)); } return array('status' => R3_AJAX_NO_ERROR, 'alert' => sprintf(_('Impossibile cancellare il tratto "%s", poichè vi sono dei dati ad esso associati'), $name)); }
/** * Return the data for a single customer */ public function getData($id = null) { global $mdb2, $dsn; $lang = R3Locale::getLanguageID(); $db = ezcDbInstance::get(); if ($this->act == 'add') { $vlu = array(); $vlu['do_template'] = DEFAULT_DOMAIN; // 'SYSTEM'; $vlu['gr_name'] = 'ADMIN'; $vlu['app_language'] = 1; $vlu['app_cat_type'] = 'IT'; $vlu['do_building_code_type'] = 'PROPOSED'; $vlu['do_building_code_required'] = 'F'; $vlu['do_calculate_global_plain_totals'] = 'T'; $vlu['do_building_code_unique'] = 'F'; $vlu['do_building_show_id'] = 'F'; $vlu['do_building_extra_descr'] = 'F'; $vlu['do_public_site'] = 'F'; $vlu['do_grid_size'] = 0; $vlu['do_build_year_type'] = 'TABLE'; $vlu['do_build_restructure_year_type'] = 'TABLE'; $vlu['do_gc_streeview'] = 'T'; $vlu['do_gc_quick_search'] = 'T'; $vlu['do_gc_digitize_has_selection'] = 'T'; $vlu['do_gc_digitize_has_editing'] = 'T'; } else { $sql = "SELECT dn.do_id AS do_id_org, dn_name, cus.*\r\n FROM auth.domains d\r\n INNER JOIN auth.domains_name dn on d.do_id=dn.do_id and dn_type='N'\r\n INNER JOIN auth.domains_applications da on da.do_id=d.do_id\r\n LEFT JOIN auth.applications app on da.app_id=app.app_id\r\n LEFT JOIN ecogis.customer cus on cus.do_id=d.do_id\r\n WHERE dn.do_id=" . $this->id; $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC); $data = $this->auth->getDomainData($vlu['dn_name'], true); $alias = array(); foreach ($data['names'] as $name) { if ($vlu['dn_name'] != $name) { $alias[] = $name; } } $vlu['dn_name_alias'] = implode(',', $alias); $vlu['do_database_login'] = $dsn['dbuser']; $vlu['do_schema'] = R3EcoGisHelper::getGeoSchema($vlu['do_id']); $vlu['cus_srid_text'] = R3EcoGisCustomerHelper::getSRIDDesc($vlu['cus_srid']); $vlu['images'] = R3EcoGisCustomerHelper::getImagesList($vlu['dn_name']); $vlu['reference_image'] = R3EcoGisCustomerHelper::getReferenceImages($vlu['dn_name']); // Dati presi da gestione utenti $vlu['app_language'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'NUM_LANGUAGES'); $vlu['app_cat_type'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'CATASTRAL_TYPE'); $vlu['do_building_code_type'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_CODE_TYPE'); $vlu['do_building_code_required'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_CODE_REQUIRED'); $vlu['do_calculate_global_plain_totals'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'CALCULATE_GLOBAL_PLAIN_TOTALS'); $vlu['do_building_code_unique'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_CODE_UNIQUE'); $vlu['do_building_extra_descr'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_EXTRA_DESCR'); $vlu['do_public_site'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'ENABLE_PUBLIC_SITE', 'F'); $vlu['do_grid_size'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'STAT_GRID_SIZE', 0); $vlu['do_building_show_id'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_SHOW_ID'); $vlu['do_build_year_type'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_YEAR_TYPE'); $vlu['do_build_restructure_year_type'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_RESTRUCTURE_YEAR_TYPE'); $vlu['do_municipality_mode'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_MUNICIPALITY_MODE'); $vlu['do_fraction_mode'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_FRACTION_MODE'); $vlu['do_street_mode'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_STREET_MODE'); $vlu['do_catastral_mode'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'BUILDING_CATASTRAL_MODE'); $vlu['do_public_css_url'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'PUBLIC_CSS_URL'); $vlu['consumption_start_year'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'CONSUMPTION_START_YEAR'); $vlu['consumption_end_year'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'APPLICATION', 'CONSUMPTION_END_YEAR'); $vlu['do_gc_project'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'PROJECT'); $vlu['do_gc_mapset'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'MAPSET'); $vlu['do_gc_streeview'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'HAS_STREETVIEW', 'T'); $vlu['do_gc_quick_search'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'HAS_QUICK_SEARCH', 'T'); $vlu['do_gc_digitize_has_selection'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'DIGITIZE_HAS_SELECTION', 'T'); $vlu['do_gc_digitize_has_editing'] = $this->auth->getConfigValueFor($vlu['dn_name'], APPLICATION_CODE, null, 'GISCLIENT', 'DIGITIZE_HAS_EDITING', 'T'); if ($vlu['do_grid_size'] == 0) { $vlu['do_grid_size'] = ''; } } $catalog = R3DbCatalog::factory('pgsql', $mdb2); $data = $catalog->getUserData(); $vlu['can_create_db_user'] = $data['rolsuper'] == 't' || $data['rolcreaterole'] == 't'; $vlu['do_database_version'] = DATABASE_VERSION; $this->data = $vlu; // Save the data (prevent multiple sql) return $vlu; }
public function askDelActionCatalog($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $name = $db->query("SELECT ac_name_{$lang} FROM action_catalog WHERE ac_id={$id}")->fetchColumn(); $sql = "select count(acd_id) from ecogis.action_catalog_dependencies where ac_related_id=" . $db->quote($id, PDO::PARAM_INT); $num = $db->query($sql)->fetchColumn(0); if ($num > 0) { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _("Impossibile cancellare questa voce dal catalogo azioni poichè è un'azione correlata ad un'altra azione")); } if ($this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare la voce \"%s\" dal catalogo azioni?"), $name)); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questa voce dal catalogo azioni poichè vi sono dei dati ad esso legati')); } }
public function askDelUtility($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $sql = "SELECT COUNT(*)\r\n FROM utility_product up\r\n INNER JOIN energy_meter em ON em.up_id=up.up_id\r\n WHERE us_id={$id}"; if ($db->query($sql)->fetchColumn() > 0) { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questo produttore di servizi poichè vi sono dei dati ad esso legati')); } else { $name = $db->query("SELECT us_name_{$lang} FROM utility_supplier WHERE us_id={$id}")->fetchColumn(); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare il produttore di servizi \"%s\"?"), $name)); } }
/** * Return the help data (ajax) * @param array $request the request * @return text the help text (usually html) */ public function getHelp($request) { require_once R3_LIB_DIR . 'eco_help.php'; $body = R3Help::getHelpPartFromSection($request['section'], $request['id'], R3Locale::getLanguageCode()); return array('data' => $body !== null ? $body : ''); }
public function convert2Locale($vlu) { if (!is_array($vlu)) { return $vlu; } setLangInfo(array('thousands_sep' => ".")); foreach ($this->fields as $key => $field) { if (isset($field['name'])) { $key = $field['name']; if (isset($field['dec']) && !isset($field['precision'])) { $field['precision'] = $field['dec']; } if (array_key_exists($key, $vlu)) { if ($vlu[$key] === null) { $vlu[$key] = ''; } else { $type = strToLower($field['type']); switch ($field['type']) { case 'real': case 'double': case 'number': case 'float': $vlu[$key] = R3NumberFormat($vlu[$key], isset($field['precision']) ? $field['precision'] : null, true); break; case 'integer': $vlu[$key] = R3NumberFormat($vlu[$key], isset($field['precision']) ? $field['precision'] : 0, true); break; case 'date': $vlu[$key] = SQLDateToStr($vlu[$key], R3Locale::getPhpDateFormat()); break; case 'datetime': case 'now': $vlu[$key] = SQLDateToStr($vlu[$key], R3Locale::getPhpDateTimeFormat()); break; case 'boolean': if ($vlu[$key] === true) { $vlu[$key] = 'T'; } else { if ($vlu[$key] === false) { $vlu[$key] = 'F'; } } } } } } } return $vlu; }
/** * Return the UDM * @param array $request the request * @return array the result data */ public function confirm_delete_device($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $name = $db->query("SELECT dev_name_{$lang} AS dev_name FROM device_data WHERE dev_id=" . (int) $request['id'])->fetchColumn(); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare l'impianto \"%s\"?"), trim($name))); }
public function askDelESU($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $data = $db->query("SELECT es_name_{$lang} AS es_name, udm_name_{$lang} AS udm_name, mu_id FROM energy_source_udm_data WHERE esu_id={$id}")->fetch(PDO::FETCH_ASSOC); if ($request['type'] == 'MUNICIPALITY') { $mu_name = R3EcoGisHelper::getMunicipalityName($data['mu_id']); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare il fattore di conversione \"%s (%s)\" e ripristinare il valore standard per i consumi già inseriti nel comune di \"%s\"?"), $data['es_name'], $data['udm_name'], $mu_name)); } else { if ($this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare il fattore di conversione \"%s (%s)\"?"), $data['es_name'], $data['udm_name'])); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questo fattore di conversione poichè vi sono dei dati ad esso legati')); } } }
private static function cacheEnergySourceUDM($do_id) { $db = ezcDbInstance::get(); $sql = "SELECT * FROM energy_source_udm_default WHERE do_id=" . (int) $do_id; foreach ($db->query($sql, PDO::FETCH_ASSOC) as $row) { R3EcoGisCalculatorHelper::$energySourceUDMData[$row['esu_id']] = R3Locale::convert2PHP($row); } }
/** * Return the UDM * @param array $request the request * @return array the result data */ public function confirmDeleteMunicipalityCollection($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = (int) $request['id']; $name = $db->query("SELECT mu_name_{$lang} FROM municipality_collection_data WHERE mu_id={$id}")->fetchColumn(); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare il raggruppamento \"%s\"?"), $name)); }
public function getPageVars() { $tabMode = 'iframe'; return array('gp_id' => $this->gp_id, 'tab_mode' => $tabMode, 'parent_act' => $this->parent_act, 'short_format' => true, 'tab_mode' => $tabMode, 'date_format' => R3Locale::getJQueryDateFormat()); }
public function askDelSimulation($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = $request['id']; $name = $db->query("SELECT sw_title_{$lang} FROM simulation_work WHERE sw_id={$id}")->fetchColumn(); if ($this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare la simulazione \"%s\"?"), $name)); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questa simulazione poichè vi sono dei dati ad essa collegati')); } }
public function askDelGlobalResult($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $name = $db->query("SELECT ge_name_{$lang} FROM global_entry WHERE ge_id={$id}")->fetchColumn(); if ($this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare l'inventario emissioni \"%s\"?"), $name)); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questo inventario emissioni poichè vi sono dei dati ad esso legati')); } }
public function askDelGlobalPlain($request) { $db = ezcDbInstance::get(); $id = (int) @$request['id']; R3Security::checkGlobalPlain($id); $lang = R3Locale::getLanguageID(); $name = $db->query("SELECT gp_name_{$lang} AS gp_name FROM global_plain_data WHERE gp_id=" . (int) $request['id'])->fetchColumn(); if (R3EcoGisHelper::hasGlobalPlainRowHasGauge($id)) { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _("Impossibile cancellare questo piano d'azione, poichè vi sono definiti degli indicatori ad esso legati")); } if (R3EcoGisHelper::hasDocument('GLOBAL_PLAIN', $id)) { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _("Impossibile cancellare questo piano d'azione, poichè vi sono dei documenti ad esso legati")); } return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare il piano di azione \"%s\"?"), $name)); }
public function getPageVars() { $tabMode = 'iframe'; $result = array('ge_id' => $this->ge_id, 'gs_id' => $this->gs_id, 'kind' => $this->kind, 'open_category' => $this->getCategoryIdFromGlobalSubcategory($this->gs_id), 'toggle_subcategory' => $this->toggle_subcategory, 'last_openclose_status' => $this->auth->getConfigValue('SETTINGS', 'GLOBAL_RESULT_LAST_OPEN_CLOSE_STATUS'), 'parent_act' => $this->parent_act, 'has_action_column' => true, 'has_partial_total_row' => true, 'can_change_udm' => true, 'tab_mode' => $tabMode, 'max_inventory_row' => $this->auth->getConfigValue('APPLICATION', 'MAX_INVENTORY_ROW'), 'date_format' => R3Locale::getJQueryDateFormat()); $lastOpenCategories = json_decode($this->auth->getConfigValue('SETTINGS', 'GLOBAL_RESULT_LAST_OPEN_CATEGORIES'), true); if (!empty($lastOpenCategories[$this->ge_id][strtolower($this->kind)])) { $result['last_open_categories'] = implode(',', $lastOpenCategories[$this->ge_id][strtolower($this->kind)]); } return $result; }
/** * Return the UDM * @param array $request the request * @return array the result data */ public function confirm_delete_document($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $name = $db->query("SELECT doc_title_{$lang} AS doc_title FROM document WHERE doc_id=" . (int) $request['id'])->fetchColumn(); return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_('Sei sicuro di voler cancellare il documento "%s"?'), $name)); }
public function loadGE_GS($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); if (isset($request['mu_name'])) { $request['mu_id'] = R3EcoGisHelper::getMunicipalityIdByName($this->do_id, $request['mu_name'], $this->auth->getParam('mu_id')); } $data = R3EcoGisGlobalStrategyHelper::getGlobalData($_SESSION['do_id'], $request['mu_id'], array('allow_empty' => true)); return array('status' => 0, 'data' => array('mu_id_selected' => (int) $request['mu_id'], 'ge_id' => array('options' => $data['ge_values']), 'ge_id_2' => array('options' => $data['ge_values']), 'gp_id' => array('options' => $data['gp_values']), 'info_text' => $data['info_text'])); }
/** * 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; }
public function getPageVars() { $tabMode = TAB_MODE; $tabs = array(); if ($this->act == 'mod' || $this->act == 'show') { $tabs[] = array('id' => 'indicator', 'label' => _('Indicatori'), 'url' => "list.php?on=global_plain_gauge&gpr_id={$this->id}&parent_act={$this->act}&tab_mode={$tabMode}"); $tabs[] = array('id' => 'meter', 'label' => _('% Completamento'), 'url' => "list.php?on=global_plain_meter&gpr_id={$this->id}&parent_act={$this->act}&tab_mode={$tabMode}"); } $vars = array('tabs' => $tabs, 'parent_act' => $this->parent_act, 'tab_mode' => $tabMode, 'date_format' => R3Locale::getJQueryDateFormat()); if ($this->act == 'list') { // piano d'azione selezionato $vars['gp_id'] = $this->gp_id; } return $vars; }
/** * Return the help data (ajax) * @param array $request the request * @return text the help text (usually html) */ public function getHelp($request) { require_once R3_LIB_DIR . 'eco_help.php'; $body = R3Help::getHelpPartFromSection($request['section'], $request['id'], R3Locale::getLanguageCode()); // Help can be cacheable $ttl = 1 * 24 * 60 * 60; header('Expires: ' . gmdate('D, d M Y H:i:s', time() + $ttl) . ' GMT'); header('Cache-Control: max-age=' . $ttl); header("Pragma: public", true); return array('data' => $body !== null ? $body : ''); }
public function askDelBuilding($request) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $id = forceInteger($request['id'], 0, false, '.'); $name = $db->query("SELECT bu_name_{$lang} FROM building WHERE bu_id={$id}")->fetchColumn(); $hasEnergyMeter = R3EcoGisHelper::hasEnergyMeter('BUILDING', $id); $hasDocument = R3EcoGisHelper::hasDocument('BUILDING', $id); if (!$hasEnergyMeter && !$hasDocument && $this->tryDeleteData($id)) { return array('status' => R3_AJAX_NO_ERROR, 'confirm' => sprintf(_("Sei sicuro di voler cancellare l'edificio \"%s\"?"), $name)); } else { return array('status' => R3_AJAX_NO_ERROR, 'alert' => _('Impossibile cancellare questo edificio poichè vi sono dei dati ad esso legati')); } }
public static function getCategoriesData($ge_id, $kind, $divider = 1, $returnAsLocale = false, $gc_id = null, $mergeMunicipalityCollection = true) { $db = ezcDbInstance::get(); $lang = R3Locale::getLanguageID(); $sql = "SELECT mu_id, mu_type, ge_year FROM ecogis.global_entry_data WHERE ge_id=" . (int) $ge_id; $muData = $db->query($sql)->fetch(PDO::FETCH_ASSOC); if ($muData === false) { throw new Exception("Global entry #{$ge_id} not found"); } if ($muData['mu_type'] == 'C') { // Municipality collection // Get collection data and other municipality data $result = self::getCategoriesDataMunicipality($ge_id, $kind, $divider, false, $gc_id); if ($mergeMunicipalityCollection) { // Get all the other municipality inventory. Multiple inventory/year can be present. $sql = "SELECT ge_id, mu_name_{$lang} as mu_name\r\n FROM ecogis.municipality mu\r\n INNER JOIN ecogis.global_entry ge ON mu.mu_id=ge.mu_id AND ge_year={$muData['ge_year']} AND ge_exclude_from_collection IS FALSE\r\n WHERE mu_parent_id={$muData['mu_id']} \r\n ORDER BY mu_name_{$lang}"; foreach ($db->query($sql, PDO::FETCH_ASSOC) as $row) { $data = self::getCategoriesDataMunicipality($row['ge_id'], $kind, $divider, false, $gc_id); self::meregeCategoriesData($result, $data, $row['mu_name']); } } if ($returnAsLocale) { self::convertToLocale($result, $divider == 1 ? 0 : 1); } return $result; } else { // Single municipality return self::getCategoriesDataMunicipality($ge_id, $kind, $divider, $returnAsLocale, $gc_id); } }