Beispiel #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;
 }
Beispiel #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;
 }
Beispiel #3
0
 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));
 }
 /**
  * Return the sql to generate the list
  */
 public function getListSQL()
 {
     $db = ezcDbInstance::get();
     $lang = R3Locale::getLanguageID();
     $q = $db->createSelectQuery();
     $where = "emo_code='STREET_LIGHTING' AND em_object_id=" . (int) $this->sl_id;
     $q->select("em_object_id, co_id, co_start_date, co_end_date, co_value, co_value_tep, co_value_kwh, co_value_co2, co_bill, co_bill_specific")->from('consumption_data')->where($where);
     return $q;
 }
Beispiel #5
0
 /**
  * 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');
 }
Beispiel #7
0
 /**
  * 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 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();
 }
Beispiel #9
0
 /**
  * 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));
 }
Beispiel #10
0
 /**
  * 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;
 }
Beispiel #11
0
 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'));
     }
 }
Beispiel #12
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;
 }
 /**
  * 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;
 }
Beispiel #14
0
 /**
  * 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)));
 }
Beispiel #15
0
 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));
     }
 }
Beispiel #16
0
 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'));
         }
     }
 }
Beispiel #17
0
 static function getStatGeneralData()
 {
     $db = ezcDbInstance::get();
     $lang = R3Locale::getLanguageID();
     $result = array();
     $sql = "SELECT *, sg_title_{$lang} AS sg_title, sg_upper_text_{$lang} AS sg_upper_text, sg_lower_text_{$lang} AS sg_lower_text\r\n                FROM ecogis.stat_general";
     $vlu = $db->query($sql)->fetch(PDO::FETCH_ASSOC);
     if ($vlu === false) {
         $vlu = array();
     }
     return $vlu;
 }
 /**
  * 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));
 }
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     $db = ezcDbInstance::get();
     $vlu = array();
     if ($this->act != 'add') {
         $sql = "SELECT mu_type FROM ecogis.global_plain_data WHERE gp_id=" . (int) $this->gp_id;
         $vlu['mu_type'] = $db->query($sql)->fetchColumn();
         $vlu['merge_municipality_data'] = $this->merge_municipality_data;
         $vlu['data'] = R3EcoGisGlobalPlainTableHelper::getData($this->do_id, $this->gp_id, $this->merge_municipality_data);
         $vlu['can_monitoring'] = R3EcoGisGlobalPlainTableHelper::canMonitoring($this->do_id, $this->gp_id);
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
Beispiel #20
0
 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'));
     }
 }
Beispiel #21
0
 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'));
     }
 }
Beispiel #22
0
 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));
 }
 /**
  * Return the data for a single customer 
  */
 public function getData($id = null)
 {
     $lang = R3Locale::getLanguageID();
     if ($id === null) {
         $id = $this->id;
     }
     $db = ezcDbInstance::get();
     $vlu = array();
     if ($this->new_udm_divider != '') {
         $lastDivider = $this->auth->setConfigValue('SETTINGS', 'GLOBAL_RESULT_LAST_UDM_DIVIDER', $this->new_udm_divider, array('permanent' => true));
     }
     $lastDivider = $this->auth->getConfigValue('SETTINGS', 'GLOBAL_RESULT_LAST_UDM_DIVIDER', 1);
     $this->udm_divider = initVar('udm_divider', $lastDivider);
     if ($this->act != 'add') {
         $sql = "SELECT mu_type FROM ecogis.global_entry_data WHERE ge_id=" . (int) $this->ge_id;
         $vlu['mu_type'] = $db->query($sql)->fetchColumn();
         $vlu['udm_divider'] = $this->udm_divider;
         $vlu['merge_municipality_data'] = $this->merge_municipality_data;
         $vlu['header'] = R3EcoGisGlobalTableHelper::getParameterList($this->kind);
         $vlu['header']['parameter_count'] = R3EcoGisGlobalTableHelper::getParameterCount($this->kind);
         $vlu['data'] = R3EcoGisGlobalTableHelper::getCategoriesData($this->ge_id, $this->kind, $this->udm_divider, true, $this->gc_id, $this->merge_municipality_data);
     } else {
         $vlu = array();
     }
     $this->data = $vlu;
     // Save the data (prevent multiple sql)
     return $vlu;
 }
 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);
     }
 }
Beispiel #25
0
 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']));
 }
Beispiel #26
0
 /**
  * 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));
 }
 /**
  * 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')));
     }
     if ($this->pr_id != '') {
         $where[] = $q->expr->eq('pr_id', $db->quote((int) $this->pr_id));
     }
     if ($this->mu_id != '') {
         $where[] = $q->expr->eq('mu_id', $db->quote((int) $this->mu_id));
     }
     if ($this->mu_name != '') {
         $where[] = "mu_name_{$lang} ILIKE " . $db->quote("%{$this->mu_name}%");
     }
     if ($this->getFilterValue('gc_id_filter') != '') {
         $isMainCategory = substr($this->getFilterValue('gc_id_filter'), 0, 1) == 'M';
         $gc_id = (int) substr($this->getFilterValue('gc_id_filter'), 1);
         if ($isMainCategory) {
             $where[] = "gc_parent_id={$gc_id}";
         } else {
             $where[] = "gc_id={$gc_id}";
         }
     }
     if ($this->getFilterValue('gpa_name') != '') {
         $gpa_name = $this->getFilterValue('gpa_name');
         $where[] = "gpa_name_{$lang} ILIKE " . $db->quote("%{$gpa_name}%");
     }
     /*
      * global_plain_action_list_data
      */
     $q->select("gp_id, gpr_id, mu_name_{$lang} AS mu_name, gp_name_{$lang} AS gp_name, gc_name_main_{$lang} AS gc_name_main, gc_name_{$lang} AS gc_name,\r\n                    gpa_name_{$lang} AS gpa_name, gpr_start_date, gpr_end_date, gpr_estimated_cost, gpr_expected_energy_saving, gpr_expected_renewable_energy_production, \r\n                    gpr_imported_row, gauge_info,\r\n                    gpr_expected_co2_reduction, NULL AS progress_emission, NULL AS progress_energy")->from('global_plain_action_list_data');
     if (count($where) > 0) {
         $q->where($where);
     }
     return $q;
 }
Beispiel #28
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;
 }
Beispiel #29
0
 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'));
     }
 }
Beispiel #30
0
 /**
  * Verifica che il comune inserito sia valido e dell'utente, altrimenti genera un errore
  * Attenzione: questa funzione viene usata anche in lib/custom.map.php
  *
  * @param array $formData      I dati del submit
  * @param array $errors        Array con altri errori
  * @return integer|null        Il codice del comune o null
  */
 public static function checkFormDataForMunicipality(array $formData, array &$errors)
 {
     $db = ezcDbInstance::get();
     $lang = R3Locale::getLanguageID();
     $mu_id = '';
     if (1 == 2 && $this->auth->getParam('mu_id') != '') {
         // TODO: PERMISSION
         $mu_id = $this->auth->getParam('mu_id');
     } else {
         if (isset($formData['mu_name']) && $formData['mu_name'] != '') {
             $mu_id = $db->query("SELECT mu_id FROM municipality WHERE mu_name_{$lang} ILIKE " . $db->quote($formData['mu_name']))->fetchColumn();
             if ($mu_id == '') {
                 $errors['mu_id'] = array('CUSTOM_ERROR' => _('Il comune immesso non è stato trovato'));
                 if (isset($this)) {
                     $this->removeField('mu_id');
                 }
                 return -1;
             }
         } else {
             if (isset($formData['mu_id']) && $formData['mu_id'] != '') {
                 $mu_id = $formData['mu_id'];
             }
         }
     }
     if ($mu_id == '') {
         $errors['mu_id'] = array('CUSTOM_ERROR' => _("Il campo \"Comune\" è obbligatorio"));
         return -1;
     }
     return $mu_id;
 }