/** * Runs all the methods to store the various settings from the shop * admin zone. * * Note that not all of the methods report their success or failure back * here (yet), so you should not rely on the result of this method. * @return mixed True on success, false on failure, * null if no change is detected. * @static */ static function storeSettings() { global $_CORELANG; self::$success = true; self::$changed = false; self::storeGeneral(); self::storeCurrencies(); self::storePayments(); self::storeShipping(); self::storeCountries(); $result = Zones::store_from_post(); if (isset($result)) { self::$changed = true; self::$success &= $result; } self::storeVat(); if (\Cx\Core\Setting\Controller\Setting::changed()) { self::$changed = true; if (\Cx\Core\Setting\Controller\Setting::updateAll() === false) { return false; } } if (self::$changed) { return self::$success ? \Message::ok($_CORELANG['TXT_CORE_SETTING_STORED_SUCCESSFULLY']) : \Message::error($_CORELANG['TXT_CORE_SETTING_ERROR_STORING']); } return null; }
/** * List all related WaterRequestGeometryZoneProperties. * This is only a proxy function, the real rendering is done by the WaterRequestGeometryZoneProperties view. */ public function actionShowPropsForm($zone_type) { $prop_model = new WaterRequestGeometryZoneProperties(); $params = array(); $zone = $zone_type; while ($zone != null) { $params = ZonesWaterRequestParameters::model()->active_parameters()->findAll('zone=:zone', array(':zone' => $zone)); if ($params) { break; } $zone = Zones::parentZone($zone); } echo $this->renderPartial('//waterRequestGeometryZoneProperties/_not_a_form', array('model' => $prop_model, 'params' => $params)); //echo $this->renderPartial('//waterRequestGeometryZoneProperties/_properties', array('model'=>$prop_model, 'zone_type'=>$zone_type, 'params'=>$params)); Yii::app()->end(); }
/** * Handles database errors * * Also migrates old names to the new structure * @return boolean False. Always. * @static * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Shipment static $break = false; if ($break) { die("\n Shipment::errorHandler(): Recursion detected while handling an error.<br /><br />\n This should not happen. We are very sorry for the inconvenience.<br />\n Please contact customer support: helpdesk@comvation.com"); } $break = true; //die("Shipment::errorHandler(): Disabled!<br />"); // Fix the Zones table first Zones::errorHandler(); $table_name = DBPREFIX . 'module_shop_shipper'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'ord' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'notnull' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); $table_name = DBPREFIX . 'module_shop_shipment_cost'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'auto_increment' => true, 'primary' => true), 'shipper_id' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => true, 'default' => '0'), 'max_weight' => array('type' => 'INT(10)', 'unsigned' => true, 'notnull' => false, 'default' => null), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'cost'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'notnull' => false, 'default' => null, 'renamefrom' => 'price_free')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always! return false; }
/** * Returns the data model based on the primary key given in the GET variable. * If the data model is not found, an HTTP exception will be raised. * @param string $id the identifier of the model to be loaded */ public function loadModel($id) { $model = Zones::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, 'The requested page does not exist.'); } return $model; }
/** * Handles any kind of database errors * * Includes updating the payments table (I guess from version 1.2.0(?), * note that this is unconfirmed) to the current structure * @return boolean False. Always. * @throws Cx\Lib\Update_DatabaseException */ static function errorHandler() { // Payment // Fix the Text and Zones tables first \Text::errorHandler(); Zones::errorHandler(); \Yellowpay::errorHandler(); $table_name = DBPREFIX . 'module_shop_payment'; $table_structure = array('id' => array('type' => 'INT(10)', 'unsigned' => true, 'auto_increment' => true, 'primary' => true), 'processor_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0'), 'fee' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs'), 'free_from' => array('type' => 'DECIMAL(9,2)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'costs_free_sum'), 'ord' => array('type' => 'INT(5)', 'unsigned' => true, 'default' => '0', 'renamefrom' => 'sort_order'), 'active' => array('type' => 'TINYINT(1)', 'unsigned' => true, 'default' => '1', 'renamefrom' => 'status')); $table_index = array(); $default_lang_id = \FWLanguage::getDefaultLangId(); if (\Cx\Lib\UpdateUtil::table_exist($table_name)) { if (\Cx\Lib\UpdateUtil::column_exist($table_name, 'name')) { // Migrate all Payment names to the Text table first \Text::deleteByKey('Shop', self::TEXT_NAME); $query = "\n SELECT `id`, `name`\n FROM `{$table_name}`"; $objResult = \Cx\Lib\UpdateUtil::sql($query); if (!$objResult) { throw new \Cx\Lib\Update_DatabaseException("Failed to query Payment names", $query); } while (!$objResult->EOF) { $id = $objResult->fields['id']; $name = $objResult->fields['name']; if (!\Text::replace($id, $default_lang_id, 'Shop', self::TEXT_NAME, $name)) { throw new \Cx\Lib\Update_DatabaseException("Failed to migrate Payment name '{$name}'"); } $objResult->MoveNext(); } } } \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Update Payments that use obsolete PSPs: // - 05, 'Internal_CreditCard' // - 06, 'Internal_Debit', // Uses 04, Internal \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=4 WHERE `processor_id` IN (5, 6)"); // - 07, 'Saferpay_Mastercard_Multipay_CAR', // - 08, 'Saferpay_Visa_Multipay_CAR', // Uses 01, Saferpay \Cx\Lib\UpdateUtil::sql("UPDATE {$table_name}\n SET `processor_id`=1 WHERE `processor_id` IN (7, 8)"); $table_name = DBPREFIX . 'module_shop_rel_payment'; $table_structure = array('payment_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true), 'zone_id' => array('type' => 'INT(10)', 'unsigned' => true, 'default' => '0', 'primary' => true, 'renamefrom' => 'zones_id')); $table_index = array(); \Cx\Lib\UpdateUtil::table($table_name, $table_structure, $table_index); // Always return false; }
$Smarty->display('fragments/boss/' . str_replace('.frag', '', $_REQUEST['datatype'])); } } else { header('Location: /zone/' . $ZoneInfo['link_name']); } } } } break; case 'npc': if (Text::IsNull($_REQUEST['subcategory'])) { Page::GenerateErrorPage($Smarty, 404); } else { if ($_REQUEST['lastcategory'] == 'tooltip') { Manager::LoadExtension('Zones', $ClassConstructor); $NPCInfo = Zones::GetNPCInfo($_REQUEST['subcategory']); $Smarty->assign('NPC', $NPCInfo); $Smarty->display('blocks/npc_tooltip'); } else { header('Location: /'); } } break; case 'forum': $Smarty->translate('Forums'); Manager::LoadExtension('Forums', $ClassConstructor); if (Text::IsNull($_REQUEST['subcategory'])) { $Smarty->assign('Forums', Forums::GetForums()); $Smarty->assign('Page', Page::Info('forum', array('bodycss' => 'forums forums-home', 'pagetitle' => $Smarty->GetConfigVars('Forum_Page_Title') . ' - '))); $Smarty->display('pages/forums_list_categories'); } else {
<?php if (!$editing) { ?> <div class="zone_parameter"> </div> <?php } else { ?> <div class="zone_parameter"> <?php $zone = $model->zone_name; while ($zone != null) { $params = ZonesWaterRequestParameters::model()->active_parameters()->findAll('zone=:zone', array(':zone' => $zone)); if ($params) { break; } $zone = Zones::parentZone($zone); } echo $this->renderPartial('//waterRequestGeometryZoneProperties/_properties_edit', array('params' => $params, 'local' => $model->properties())); ?> </div> <?php } ?> <div class="row buttons"> <?php //echo CHtml::submitButton(Yii::t('waterrequest', 'Save changes')) echo CHtml::ajaxSubmitButton($model->isNewRecord ? Yii::t('waterrequest', 'Add') : Yii::t('waterrequest', 'Save changes'), $editing ? CController::createUrl('waterRequestGeometryZones/update', array('id' => $model->id)) : CController::createUrl('waterRequestGeometryZones/create', array('id' => $geom_model->id)), array('dataType' => 'json', 'success' => 'function(response){newWRGZresponseHandler(response);}', 'error' => 'function(response){console.log(response);}'), array('id' => 'submitta')); ?> </div>
?> <?php echo $form->textField($model, 'description', array('size' => 60, 'maxlength' => 500)); ?> <?php echo $form->error($model, 'description'); ?> </div> <div id="description_error"></div> <div class="jFormComponent" id="parent_zone_name"> <?php echo $form->labelEx($model, 'parent_zone_name'); ?> <?php echo $form->dropDownList($model, 'parent_zone_name', CHtml::listData(Zones::zonesListAll(), 'name', 'name'), array('empty' => Yii::t('waterrequest', 'Select Area'))); ?> <?php echo $form->error($model, 'parent_zone_name'); ?> </div> <div id="parent_zone_name_error"></div> <?php if (!$model->isNewRecord) { ?> <div class="jFormComponent" id="active"> <?php echo $form->labelEx($model, 'active'); ?>
public function calculateWaterDemand($geom = null) { $zone = $this->zone_name; while ($zone != null) { $formula = WaterRequestFormulas::model()->find('zone=:zone', array(':zone' => $zone)); if ($formula) { break; } $zone = Zones::parentZone($zone); } //Yii::log('ctype_digit='.print_r(ctype_digit($geom_id),true).' geom_id='.$geom_id , CLogger::LEVEL_INFO, 'calculateWaterDemand'); // DEBUG if ($geom == null) { $comuni = Geometry::Get_City_State($this->wr_geometry_id); } else { $comuni = Geometry::Get_City_State_ByWKT($geom); } /* if(!ctype_digit($geom_id)){ $comuni = Geometry::Get_City_State_ByWKT($geom_id); }else{ $comuni = Geometry::Get_City_State($this->wr_geometry_id); }*/ if (count($comuni)) { $city_state = $comuni[0]['nome']; } else { Yii::log('non trovo il comune. geom_id=' . $geom, CLogger::LEVEL_INFO, 'calculateWaterDemand'); // DEBUG $city_state = 'Pisa'; } $water_supply = WaterSupply::model()->find('lower(city_state)=:city_state', array(':city_state' => strtolower($city_state))); if (!$water_supply) { Yii::log('Manca la WaterSupply. $city_state=' . $city_state, CLogger::LEVEL_INFO, 'calculateWaterDemand'); // DEBUG return -1; } $dg = $water_supply->daily_maximum_water_supply; $da = $water_supply->yearly_average_water_supply; $fformula = str_ireplace(array('ae', 'dg', 'da'), array($this->pe, $dg, $da), $formula->formula); //TODO: mettere nel config il valore delle stringe ae, dg e da $ret = Math::safe_eval($fformula); if (is_numeric($ret)) { return $ret; } return -1; }
public function edit_fridge($code) { $fridge = Fridges::getFridge($code); $data['fridge'] = $fridge; $data['title'] = "Fridge Management::Edit Fridge Details"; $data['module_view'] = "add_fridge_view"; $data['quick_link'] = "new_fridge"; $data['power_sources'] = Power_Sources::getAll(); $data['item_types'] = Item_Types::getAll(); $data['gas_types'] = Refrigerant_Gas_Types::getAll(); $data['zones'] = Zones::getAll(); $this->new_base_params($data); }
public static function getAllZones() { $zones = array(); $db = Zend_Registry::get('my_db2'); $adminLevel = $_SESSION['ADMIN_LEVEL']; $adminId = $_SESSION['ADMIN_ID']; $z = new Zones($db); if ($adminLevel == Utility::$SUPER_ADMIN) { $select = $z->select()->order('zone_desc ASC'); $rows = $z->fetchAll($select); } else { $select = $z->select()->where('admin_id = ' . $adminId)->order('zone_desc ASC'); } $rows = $z->fetchAll($select); foreach ($rows as $row) { switch (DB_TYPE) { case 'mysql': $zone = new Zone($row->zone_id, false); break; case 'oci8': $zone = new Zone($row->ZONE_ID, false); break; } array_push($zones, $zone); } return $zones; }
?> <?php echo $form->textField($model, 'measurement_unit', array('size' => 60, 'maxlength' => 255)); ?> <?php echo $form->error($model, 'measurement_unit'); ?> </div> <div id="measurement_unit_error"></div> <div class="jFormComponent" id="zone"> <?php echo $form->labelEx($model->zone_request_parameters, 'zone'); ?> <?php echo $form->dropDownList($model->zone_request_parameters, 'zone', CHtml::listData(Zones::zonesList(null), 'name', 'name'), array('empty' => 'Select Area')); ?> <?php echo $form->error($model->zone_request_parameters, 'zone'); ?> </div> <div id="zone_error"></div> <div class="jFormComponent" id="value"> <?php echo $form->labelEx($model->zone_request_parameters, 'value'); ?> <?php echo $form->textField($model->zone_request_parameters, 'value', array('size' => 60, 'maxlength' => 255)); ?> <?php
/** * Returns the formula associated with the area */ public function getFormula() { $formula = null; $zone = $this->name; while ($zone != null) { $formula = WaterRequestFormulas::model()->find('zone=:zone', array(':zone' => $zone)); if ($formula) { break; } $zone = Zones::parentZone($zone); } return $formula; }
public static function GetBossLoot($LootID) { $Statement = Zones::$WConnection->prepare('SELECT * FROM creature_loot_template WHERE Entry = :lootid'); $Statement->bindParam(':lootid', $LootID); $Statement->execute(); $Result = $Statement->fetchAll(PDO::FETCH_ASSOC); $ArrayIndex = 0; $GetDataForItems = array(); foreach ($Result as $ItemDrop) { if ($ItemDrop['Reference'] != 0) { unset($Result[$ArrayIndex]); } else { $GetDataForItems[] = $ItemDrop['Item']; } $ArrayIndex++; } $Result = array_values($Result); $ItemArray = implode(', ', $GetDataForItems); return Zones::GetItemArrayData($ItemArray); }
/** * The zones settings view */ static function view_settings_zones() { self::$objTemplate->addBlockfile('SHOP_SETTINGS_FILE', 'settings_block', 'module_shop_settings_zones.html'); $arrZones = Zones::getZoneArray(); $selectFirst = false; $strZoneOptions = ''; foreach ($arrZones as $zone_id => $arrZone) { // Skip zone "All" if ($zone_id == 1) { continue; } $strZoneOptions .= '<option value="' . $zone_id . '"' . ($selectFirst ? '' : \Html::ATTRIBUTE_SELECTED) . '>' . $arrZone['name'] . "</option>\n"; $arrCountryInZone = \Cx\Core\Country\Controller\Country::getArraysByZoneId($zone_id); $strSelectedCountries = ''; foreach ($arrCountryInZone['in'] as $country_id => $arrCountry) { $strSelectedCountries .= '<option value="' . $country_id . '">' . $arrCountry['name'] . "</option>\n"; } $strCountryList = ''; foreach ($arrCountryInZone['out'] as $country_id => $arrCountry) { $strCountryList .= '<option value="' . $country_id . '">' . $arrCountry['name'] . "</option>\n"; } self::$objTemplate->setVariable(array('SHOP_ZONE_ID' => $zone_id, 'ZONE_ACTIVE_STATUS' => $arrZone['active'] ? \Html::ATTRIBUTE_CHECKED : '', 'SHOP_ZONE_NAME' => $arrZone['name'], 'SHOP_ZONE_DISPLAY_STYLE' => $selectFirst ? 'display: none;' : 'display: block;', 'SHOP_ZONE_SELECTED_COUNTRIES_OPTIONS' => $strSelectedCountries, 'SHOP_COUNTRY_LIST_OPTIONS' => $strCountryList)); self::$objTemplate->parse('shopZones'); $selectFirst = true; } self::$objTemplate->setVariable(array('SHOP_ZONES_OPTIONS' => $strZoneOptions, 'SHOP_ZONE_COUNTRY_LIST' => \Cx\Core\Country\Controller\Country::getMenuoptions())); }
public static function getZoneId($zoneName) { $db = Zend_Registry::get('my_db'); $z = new Zones($db); $cleanZoneName = $db->quote($zoneName); $result = $z->fetchAll("upper(source_id) = upper({$cleanZoneName})"); switch (DB_TYPE) { case 'mysql': $_SESSION['ZONE_ID'] = intval($result[0]->zone_id); $_SESSION['ZONE_DESC'] = $result[0]->zone_desc; $_SESSION['ZONE_VERSION_ID'] = $result[0]->version_id; $_SESSION['ZONE_SLEEPING'] = $result[0]->sleeping; $_SESSION['ZONE_AUTH_TYPE'] = $result[0]->zone_authentication_type_id; break; case 'oci8': $_SESSION['ZONE_ID'] = intval($result[0]->ZONE_ID); $_SESSION['ZONE_DESC'] = $result[0]->ZONE_DESC; $_SESSION['ZONE_VERSION_ID'] = $result[0]->VERSION_ID; $_SESSION['ZONE_SLEEPING'] = $result[0]->SLEEPING; $_SESSION['ZONE_AUTH_TYPE'] = $result[0]->ZONE_AUTHENTICATION_TYPE_ID; break; } }