本文整理汇总了PHP中floatVal函数的典型用法代码示例。如果您正苦于以下问题:PHP floatVal函数的具体用法?PHP floatVal怎么用?PHP floatVal使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了floatVal函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getOrderWithAccountAndDeadline
function getOrderWithAccountAndDeadline($accountEmail, $deadline)
{
global $GetOrder_URL;
$orders = array();
$json = file_get_contents($GetOrder_URL);
$data = json_decode($json, TRUE);
$rows = $data['feed']['entry'];
foreach ($rows as $item) {
$account_email = $item['gsx$account']['$t'];
$orderDeadline = $item['gsx$orderdeadline']['$t'];
if ($orderDeadline === $deadline && (strlen($accountEmail) === 0 || $accountEmail == $account_email)) {
$timeStamp = $item['gsx$timestamp']['$t'];
$pickup = $item['gsx$pickup']['$t'];
$vendor = $item['gsx$vendor']['$t'];
$price = $item['gsx$price']['$t'];
$remit = $item['gsx$remit']['$t'];
$count = $item['gsx$count']['$t'];
$remitRate = trim($remit);
$remitRateFloat = floatVal($remitRate) / 100.0;
//trim off % sign;
$countInt = intVal($count);
$price = trim($price);
$price = substr($price, 1, strlen($price) - 1);
$priceFloat = floatVal($price);
array_push($orders, array($timeStamp, $account_email, $pickup, $vendor, $priceFloat, $remitRateFloat, $countInt));
}
}
return $orders;
}
开发者ID:hnzhang,项目名称:scrape,代码行数:29,代码来源:giftcards_common.php
示例2: is_positive_int
function is_positive_int($num)
{
$intNum = floor($num);
$result = floatVal($num - $intNum);
if ($result == 0) {
return true;
} else {
return false;
}
}
开发者ID:CheBurashka334,项目名称:zakrepi,代码行数:10,代码来源:function.php
示例3: generateCoupon
public function generateCoupon($type, $store = null)
{
$couponData = array();
$couponData['name'] = 'Special Coupon ' . date('Y-m-d');
$couponData['is_active'] = 1;
// all websites here:
$couponData['website_ids'] = array_keys(Mage::app()->getWebsites(true));
$couponData['coupon_type'] = 2;
// for mahento 1.4.1.1
$couponData['coupon_code'] = strtoupper(uniqid());
$maxUses = intVal(Mage::getStoreConfig('ambirth/' . $type . '/coupon_uses'));
$usesPerCustomer = intVal(Mage::getStoreConfig('ambirth/' . $type . '/uses_per_customer'));
$couponData['uses_per_coupon'] = $maxUses;
$couponData['uses_per_customer'] = $usesPerCustomer;
$couponData['from_date'] = '';
//current date
$days = intVal(Mage::getStoreConfig('ambirth/' . $type . '/coupon_days', $store));
$date = date('Y-m-d', time() + $days * 24 * 3600);
$couponData['to_date'] = $date;
$couponData['simple_action'] = Mage::getStoreConfig('ambirth/' . $type . '/coupon_type', $store);
$couponData['discount_amount'] = Mage::getStoreConfig('ambirth/' . $type . '/coupon_amount', $store);
if ('ampromo_cart' == $couponData['simple_action']) {
$couponData['promo_sku'] = $couponData['discount_amount'];
$couponData['discount_amount'] = 0;
}
$couponData['conditions'] = array('1' => array('type' => 'salesrule/rule_condition_combine', 'aggregator' => 'all', 'value' => 1, 'new_child' => ''), '1--1' => array('type' => 'salesrule/rule_condition_address', 'attribute' => 'base_subtotal', 'operator' => '>=', 'value' => floatVal(Mage::getStoreConfig('ambirth/' . $type . '/min_order', $store))));
$couponData['actions'] = array(1 => array('type' => 'salesrule/rule_condition_product_combine', 'aggregator' => 'all', 'value' => 1, 'new_child' => ''));
//compatibility with aitoc's individ promo module
$couponData['customer_individ_ids'] = array();
//create for all customer groups
$couponData['customer_group_ids'] = array();
if (!Mage::getStoreConfig('ambirth/' . $type . '/customer_group', $store)) {
$customerGroups = Mage::getResourceModel('customer/group_collection')->load();
$found = false;
foreach ($customerGroups as $group) {
if (0 == $group->getId()) {
$found = true;
}
$couponData['customer_group_ids'][] = $group->getId();
}
if (!$found) {
$couponData['customer_group_ids'][] = 0;
}
} else {
$groups = Mage::getStoreConfig('ambirth/' . $type . '/customer_group', $store);
$couponData['customer_group_ids'] = explode(',', $groups);
}
try {
Mage::getModel('salesrule/rule')->loadPost($couponData)->save();
} catch (Exception $e) {
//print_r($e); exit;
$couponData['coupon_code'] = '';
}
return $couponData['coupon_code'];
}
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:55,代码来源:Data.php
示例4: ValorEnLetras
function ValorEnLetras($x, $Moneda )
{
$s="";
$Ent="";
$Frc="";
$Signo="";
if(floatVal($x) < 0)
$Signo = $this->Neg . " ";
else
$Signo = "";
if(intval(number_format($x,2,'.','') )!=$x) //<- averiguar si tiene decimales
$s = number_format($x,2,'.','');
else
$s = number_format($x,0,'.','');
$Pto = strpos($s, $this->Dot);
if ($Pto === false)
{
$Ent = $s;
$Frc = $this->Void;
}
else
{
$Ent = substr($s, 0, $Pto );
$Frc = substr($s, $Pto+1);
}
if($Ent == $this->Zero || $Ent == $this->Void)
$s = "Cero ";
elseif( strlen($Ent) > 7)
{
$s = $this->SubValLetra(intval( substr($Ent, 0, strlen($Ent) - 6))) .
"Millones " . $this->SubValLetra(intval(substr($Ent,-6, 6)));
}
else
{
$s = $this->SubValLetra(intval($Ent));
}
if (substr($s,-9, 9) == "Millones " || substr($s,-7, 7) == "Millón ")
$s = $s . "de ";
$s = $s . $Moneda;
if($Frc != $this->Void)
{
$s = $s . " Con " . $this->SubValLetra(intval($Frc)) . "Centavos";
//$s = $s . " " . $Frc . "/100";
}
return ($Signo . $s . " M.N.");
}
开发者ID:sigmadesarrollo,项目名称:logisoft,代码行数:55,代码来源:EnLetras.php
示例5: save_post
function save_post($post_id)
{
if (get_post_type($post_id) != $this->slug) {
return;
}
if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) {
return;
}
if (isset($_POST['conferencer_nonce']) && !wp_verify_nonce($_POST['conferencer_nonce'], plugin_basename(__FILE__))) {
return;
}
if (!current_user_can('edit_post', $post_id)) {
return;
}
foreach ($this->options as $key => $option) {
if ($option['type'] == 'internal') {
continue;
}
if (isset($_POST['conferencer_' . $key])) {
$value = deep_trim($_POST['conferencer_' . $key]);
} else {
$value = "";
}
if ($option['type'] == 'int') {
$value = intval($value);
}
if ($option['type'] == 'money') {
$value = floatVal($value);
}
if ($option['type'] == 'multi-select') {
$values = array();
if (isset($_POST['conferencer_' . $key])) {
foreach ($_POST['conferencer_' . $key] as $value) {
if (!empty($value)) {
$values[] = $value;
}
}
}
$value = $values;
}
if ($option['type'] == 'date-time') {
$value = 0;
if (isset($_POST['conferencer_' . $key])) {
$date = getdate(strtotime($_POST['conferencer_' . $key]['date']));
$time = getdate(strtotime($_POST['conferencer_' . $key]['time']));
$value = mktime($time['hours'], $time['minutes'], $time['seconds'], $date['mon'], $date['mday'], $date['year']);
}
}
update_post_meta($post_id, '_conferencer_' . $key, $value);
}
}
开发者ID:paulcote,项目名称:2016.waq.paulcote.net,代码行数:51,代码来源:custom_post_type.php
示例6: checkDecimalAndPositive
public function checkDecimalAndPositive()
{
if (is_numeric($this->data[$this->alias]['marks'])) {
$floatVal = floatVal($this->data[$this->alias]['marks']);
if ($floatVal < 0) {
return false;
} else {
// check if it has 1 decimal place at most
if (fmod($floatVal * 10, 1) != 0) {
return false;
}
}
return true;
} else {
return false;
}
}
开发者ID:ivanbautsita,项目名称:gestion-escolar-campus-virtuales,代码行数:17,代码来源:ClassResult_.php
示例7: __construct
public function __construct($conditions = [])
{
parent::__construct($conditions);
// post processing
foreach ($this->iterate() as &$curTpl) {
$curTpl['spells'] = [];
// [spellId, triggerType, charges, chanceOrPpm]
for ($i = 1; $i <= 3; $i++) {
if ($curTpl['object' . $i] <= 0) {
continue;
}
switch ($curTpl['type' . $i]) {
case 1:
$proc = -$this->getField('ppmRate') ?: ($this->getField('procChance') ?: $this->getField('amount' . $i));
$curTpl['spells'][$i] = [$curTpl['object' . $i], 2, $curTpl['charges'], $proc];
$this->relSpells[] = $curTpl['object' . $i];
break;
case 3:
$curTpl['spells'][$i] = [$curTpl['object' . $i], 1, $curTpl['charges'], 0];
$this->relSpells[] = $curTpl['object' . $i];
break;
case 7:
$curTpl['spells'][$i] = [$curTpl['object' . $i], 0, $curTpl['charges'], 0];
$this->relSpells[] = $curTpl['object' . $i];
break;
}
}
// floats are fetched as string from db :<
$curTpl['dmg'] = floatVal($curTpl['dmg']);
$curTpl['dps'] = floatVal($curTpl['dps']);
// remove zero-stats
foreach (Util::$itemMods as $str) {
if ($curTpl[$str] == 0) {
// empty(0.0f) => true .. yeah, sure
unset($curTpl[$str]);
}
}
if ($curTpl['dps'] == 0) {
unset($curTpl['dps']);
}
}
if ($this->relSpells) {
$this->relSpells = new SpellList(array(['id', $this->relSpells]));
}
}
开发者ID:saqar,项目名称:aowow,代码行数:45,代码来源:enchantment.class.php
示例8: convert_to_letter
function convert_to_letter($x, $Moneda = '')
{
$s = "";
$Ent = "";
$Frc = "";
$Signo = "";
if (floatVal($x) < 0) {
$Signo = $this->Neg . " ";
} else {
$Signo = "";
}
if (intval(number_format($x, 2, '.', '')) != $x) {
//<- averiguar si tiene decimales
$s = number_format($x, 2, '.', '');
} else {
$s = number_format($x, 2, '.', '');
}
$Pto = strpos($s, $this->Dot);
if ($Pto === false) {
$Ent = $s;
$Frc = $this->Void;
} else {
$Ent = substr($s, 0, $Pto);
$Frc = substr($s, $Pto + 1);
}
if ($Ent == $this->Zero || $Ent == $this->Void) {
$s = "Cero ";
} elseif (strlen($Ent) > 7) {
$s = $this->SubValLetra(intval(substr($Ent, 0, strlen($Ent) - 6))) . "Millones " . $this->SubValLetra(intval(substr($Ent, -6, 6)));
} else {
$s = $this->SubValLetra(intval($Ent));
}
if (substr($s, -9, 9) == "Millones " || substr($s, -7, 7) == "Millón ") {
$s = $s . "de ";
}
$s = $s . $Moneda;
if ($Frc != $this->Void) {
$s = $s . " " . $Frc . "/100";
//$s = $s . " " . $Frc . "/100";
}
$letrass = $Signo . $s . "";
return $Signo . $s . "";
}
开发者ID:RooseveltJavier,项目名称:Proyecto,代码行数:43,代码来源:number_letter.php
示例9: gini_impurity
public function gini_impurity()
{
/*
Returns the gini impurity score associated to the distribution in the node
*/
$purity = floatval(0);
if ($this->distribution == null) {
return null;
}
foreach ($this->distribution as $distribution) {
$purity += pow($distribution[1] / floatval($this->count), 2);
}
return (floatVal(1) - $purity) / 2;
}
开发者ID:sdesimone,项目名称:bigml-php,代码行数:14,代码来源:tree.php
示例10: SetMeetingParams
public static function SetMeetingParams($userId, $eventId, $arFields)
{
global $DB;
$eventId = intVal($eventId);
$userId = intVal($userId);
// Check $arFields
if (!in_array($arFields['ACCESSIBILITY'], array('busy', 'quest', 'free', 'absent'))) {
$arFields['ACCESSIBILITY'] = 'busy';
}
$arReminders = array();
if ($arFields['REMIND'] && is_array($arFields['REMIND'])) {
foreach ($arFields['REMIND'] as $remind) {
if (in_array($remind['type'], array('min', 'hour', 'day'))) {
$arReminders[] = array('type' => $remind['type'], 'count' => floatVal($remind['count']));
}
}
}
$arFields['REMIND'] = count($arReminders) > 0 ? serialize($arReminders) : '';
// Reminding options
$Event = CCalendarEvent::GetById($eventId);
if (!$Event) {
return false;
}
$path = CCalendar::GetPath($arFields['CAL_TYPE']);
$path = CHTTP::urlDeleteParams($path, array("action", "sessid", "bx_event_calendar_request", "EVENT_ID"));
$viewPath = CHTTP::urlAddParams($path, array('EVENT_ID' => $eventId));
$remAgentParams = array('eventId' => $eventId, 'userId' => $userId, 'viewPath' => $viewPath, 'calendarType' => $Event["CAL_TYPE"], 'ownerId' => $Event["OWNER_ID"]);
// 1. clean reminders
CCalendar::RemoveAgent($remAgentParams);
// 2. Set new reminders
foreach ($arReminders as $reminder) {
$delta = intVal($reminder['count']) * 60;
//Minute
if ($reminder['type'] == 'hour') {
$delta = $delta * 60;
} elseif ($reminder['type'] == 'day') {
$delta = $delta * 60 * 24;
}
//Day
if ($Event['DT_FROM_TS'] - $delta >= time() - 60 * 5) {
// Inaccuracy - 5 min
CCalendar::AddAgent(CCalendar::Date($Event['DT_FROM_TS'] - $delta), $remAgentParams);
}
}
// Select meeting info about event
$res = CCalendarEvent::GetList(array('arFilter' => array("ID" => $eventId, "DELETED" => "N"), 'parseRecursion' => false));
if ($Event = $res[0]) {
if ($Event['IS_MEETING']) {
// Try to find this user into attendees for this event
$strSql = "SELECT * FROM b_calendar_attendees WHERE USER_KEY={$userId} AND EVENT_ID={$eventId}";
$dbAtt = $DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
if ($att = $dbAtt->Fetch()) {
//Set params
$strSql = "UPDATE b_calendar_attendees SET " . $DB->PrepareUpdate("b_calendar_attendees", $arFields) . " WHERE EVENT_ID=" . $eventId . " AND USER_KEY=" . $userId;
$DB->Query($strSql, false, "File: " . __FILE__ . "<br>Line: " . __LINE__);
}
}
}
CCalendar::ClearCache('attendees_list');
return true;
}
开发者ID:mrdeadmouse,项目名称:u136006,代码行数:61,代码来源:calendar_event.php
示例11: getMultiRowEvolution
/** Get row evolution for a multiple labels */
private function getMultiRowEvolution($idSite, $period, $date, $apiModule, $apiAction, $labels, $segment, $column, $language = false)
{
$actualLabels = array();
$metadata = $this->getRowEvolutionMetaData($idSite, $period, $date, $apiModule, $apiAction, $segment, $language);
if (!isset($metadata['metrics'][$column])) {
// invalid column => use the first one that's available
$column = reset(array_keys($metadata['metrics']));
}
// load the tables for each label
$dataTablesPerLabel = array();
$dataTableMetadata = false;
foreach ($labels as $labelIndex => $label) {
$dataTable = $this->loadRowEvolutionData($idSite, $period, $date, $apiModule, $apiAction, $label, $segment);
$dataTablesPerLabel[$labelIndex] = $dataTable->getArray();
if (!$dataTableMetadata) {
$dataTableMetadata = $dataTable->metadata;
}
$urlFound = false;
foreach ($dataTablesPerLabel[$labelIndex] as $table) {
if ($table->getRowsCount() > 0) {
$firstRow = $table->getFirstRow();
// in case labels were replaced in the data table (e.g. for browsers report),
// display the label from the table, not the one passed as filter
$columnLabel = $firstRow->getColumn('label');
if (!empty($columnLabel)) {
$actualLabels[$labelIndex] = $columnLabel;
// TODO: confirm we need this
// special case: websites report
//if ($apiAction == 'getWebsites')
//{
// $actualLabels[$labelIndex] = html_entity_decode($actualLabels[$labelIndex]);
//}
}
// if url is available as metadata, use it (only for actions reports)
if ($url = $firstRow->getMetadata('url')) {
$actualLabels[$labelIndex] = $url;
$urlFound = true;
}
break;
}
}
if (!$urlFound) {
// if we have a recursive label and no url, use the path
$actualLabels[$labelIndex] = str_replace(Piwik_API_DataTableLabelFilter::SEPARATOR_RECURSIVE_LABEL, ' - ', $label);
}
}
// combine the tables
$dataTable = new Piwik_DataTable_Array();
$dataTable->setKeyName($dataTable->getKeyName());
$dataTable->metadata = $dataTableMetadata;
foreach (array_keys(reset($dataTablesPerLabel)) as $dateLabel) {
$newRow = new Piwik_DataTable_Row();
foreach ($dataTablesPerLabel as $labelIndex => $tableArray) {
$table = $tableArray[$dateLabel];
if ($table->getRowsCount() == 0) {
$value = 0;
} else {
$value = $table->getFirstRow()->getColumn($column);
$value = floatVal(str_replace(',', '.', $value));
if ($value == '') {
$value = 0;
}
}
// keep metric in the label so that unit (%, s, ...) can be guessed correctly
$label = $column . '_' . $labelIndex;
$newRow->addColumn($label, $value);
}
$newTable = new Piwik_DataTable();
$newTable->addRow($newRow);
$dataTable->addTable($newTable, $dateLabel);
}
// the available metrics for the report are returned as metadata / availableColumns
$metadata['availableColumns'] = $metadata['metrics'];
// metadata / metrics should document the rows that are compared
// this way, UI code can be reused
$metadata['metrics'] = array();
foreach ($actualLabels as $labelIndex => $label) {
$label .= ' (' . $metadata['availableColumns'][$column] . ')';
$metadata['metrics'][$column . '_' . $labelIndex] = $label;
}
$this->enhanceRowEvolutionMetaData($metadata, $dataTable);
return array('column' => $column, 'data' => $dataTable, 'metadata' => $metadata);
}
开发者ID:0h546f6f78696342756e4e59,项目名称:piwik,代码行数:84,代码来源:API.php
示例12: array
$arHeaders = array(array("id" => "USER_ID", "content" => "ID", "sort" => "USER_ID"), array("id" => "BUYER", "content" => GetMessage("BUYER_ROW_BUYER"), "sort" => "NAME", "default" => true), array("id" => "LOGIN", "content" => GetMessage("BUYER_ROW_LOGIN"), "sort" => "LOGIN"), array("id" => "LAST_NAME", "content" => GetMessage("BUYER_ROW_LAST"), "sort" => "LAST_NAME"), array("id" => "NAME", "content" => GetMessage("BUYER_ROW_NAME"), "sort" => "NAME"), array("id" => "SECOND_NAME", "content" => GetMessage("BUYER_ROW_SECOND"), "sort" => "SECOND_NAME"), array("id" => "EMAIL", "content" => GetMessage("BUYER_ROW_MAIL"), "sort" => "EMAIL", "default" => true), array("id" => "PERSONAL_PHONE", "content" => GetMessage("BUYER_ROW_PHONE"), "sort" => "PERSONAL_PHONE", "default" => true), array("id" => "LAST_LOGIN", "content" => GetMessage('BUYER_ROW_LAST_LOGIN'), "sort" => "LAST_LOGIN", "default" => false), array("id" => "DATE_REGISTER", "content" => GetMessage('BUYER_ROW_DATE_REGISTER'), "sort" => "DATE_REGISTER", "default" => true), array("id" => "LAST_ORDER_DATE", "content" => GetMessage('BUYER_ROW_LAST_ORDER_DATE'), "sort" => "LAST_ORDER_DATE", "default" => true), array("id" => "ORDER_COUNT", "content" => GetMessage('BUYER_ROW_COUNT_ORDER'), "sort" => "ORDER_COUNT", "default" => true, "align" => "right"), array("id" => "ORDER_SUM", "content" => GetMessage('BUYER_ROW_SUM_ORDER'), "sort" => "ORDER_SUM", "default" => true, "align" => "right"), array("id" => "GROUPS_ID", "content" => GetMessage('BUYER_ROW_GROUP')));
$lAdmin->AddHeaders($arHeaders);
$arVisibleColumns = $lAdmin->GetVisibleHeaderColumns();
$arOrderBuyer[$by] = $order;
$dbUsersList = CSaleUser::GetBuyersList($arOrderBuyer, $arFilter, false, array("nPageSize" => CAdminResult::GetNavSize($sTableID)), array("ID", "LID", "ACTIVE", "DATE_REGISTER", "LOGIN", "EMAIL", "NAME", "LAST_NAME", "SECOND_NAME", "PERSONAL_PHONE", "USER_ID", "LAST_LOGIN", "ORDER_COUNT", "ORDER_SUM", "CURRENCY", "LAST_ORDER_DATE"));
$dbUsersList = new CAdminResult($dbUsersList, $sTableID);
$dbUsersList->NavStart();
$lAdmin->NavText($dbUsersList->GetNavPrint(GetMessage("BUYER_PRLIST")));
while ($arBuyers = $dbUsersList->Fetch()) {
$row =& $lAdmin->AddRow($arBuyers["USER_ID"], $arBuyers, "sale_buyers_profile.php?USER_ID=" . $arBuyers["USER_ID"] . "&lang=" . LANGUAGE_ID, GetMessage("BUYER_SUB_ACTION_PROFILE"));
$profile = '<a href="sale_buyers_profile.php?USER_ID=' . $arBuyers["USER_ID"] . '&lang=' . LANGUAGE_ID . '">' . $arBuyers["USER_ID"] . '</a>';
$row->AddField("USER_ID", $profile);
if (floatVal($arBuyers["ORDER_SUM"]) > 0 && in_array("ORDER_SUM", $arVisibleColumns)) {
$row->AddField("ORDER_SUM", SaleFormatCurrency($arBuyers["ORDER_SUM"], $arBuyers["CURRENCY"]));
}
if (floatVal($arBuyers["ORDER_COUNT"]) <= 0) {
$row->AddField("ORDER_COUNT", ' ');
}
if (in_array("GROUPS_ID", $arVisibleColumns)) {
$strUserGroup = '';
$arUserGroups = CUser::GetUserGroup($arBuyers["USER_ID"]);
foreach ($arUsersGroups as $arGroup) {
if (in_array($arGroup["ID"], $arUserGroups)) {
$strUserGroup .= htmlspecialcharsbx($arGroup["NAME"]) . "<br>";
}
}
$row->AddField("GROUPS_ID", $strUserGroup);
}
if (in_array("LID", $arVisibleColumns)) {
$row->AddField("LID", $arSites[$arBuyers["LID"]]["NAME"]);
}
开发者ID:DarneoStudio,项目名称:bitrix,代码行数:31,代码来源:buyers.php
示例13: _initRule
private function _initRule($rule, $address, $quote)
{
$types = array(Amasty_Rules_Helper_Data::TYPE_XY_PERCENT, Amasty_Rules_Helper_Data::TYPE_XY_FIXED);
if (in_array($rule->getSimpleAction(), $types)) {
return $this->_initRuleXY($rule, $address, $quote);
}
$r = array();
$prices = $this->_getSortedCartPices($rule, $address);
if (!$prices) {
return $r;
}
$qty = $this->_getQty($rule, count($prices));
if ($qty < 1) {
return $r;
}
$step = (int) $rule->getDiscountStep();
if ($rule->getSimpleAction() == Amasty_Rules_Helper_Data::TYPE_CHEAPEST) {
$prices = array_slice($prices, 0, $qty);
} elseif ($rule->getSimpleAction() == Amasty_Rules_Helper_Data::TYPE_EXPENCIVE) {
$prices = array_slice($prices, -$qty, $qty);
} elseif ($rule->getSimpleAction() == Amasty_Rules_Helper_Data::TYPE_EACH_N) {
$prices = array_reverse($prices);
// now it is from big to small (80, 50, 50, 30 ...)
}
$percentage = floatVal($rule->getDiscountAmount());
if (!$percentage) {
$percentage = 100;
}
$percentage = $percentage / 100.0;
$lastId = -1;
$currQty = 0;
// for each N we need to limit Max applied qty also
foreach ($prices as $i => $price) {
// skip items beside each, say 3-d, depends on the $step
$types = array(Amasty_Rules_Helper_Data::TYPE_EACH_N, Amasty_Rules_Helper_Data::TYPE_FIXED);
if (in_array($rule->getSimpleAction(), $types) && $step > 1 && ($i + 1) % $step) {
continue;
}
// introduce limit for each N with discount or each N with fixed.
if ($currQty >= $qty) {
continue;
}
++$currQty;
$discount = $price['price'] * $percentage;
$baseDiscount = $price['base_price'] * $percentage;
if ($rule->getSimpleAction() == Amasty_Rules_Helper_Data::TYPE_FIXED) {
$discount = $price['price'] - $quote->getStore()->convertPrice($rule->getDiscountAmount());
$baseDiscount = $price['base_price'] - $rule->getDiscountAmount();
}
if ($price['id'] != $lastId) {
$lastId = intVal($price['id']);
$r[$lastId] = array();
$r[$lastId]['discount'] = $discount;
$r[$lastId]['base_discount'] = $baseDiscount;
} else {
$r[$lastId]['discount'] += $discount;
$r[$lastId]['base_discount'] += $baseDiscount;
}
}
return $r;
}
开发者ID:bevello,项目名称:bevello,代码行数:61,代码来源:Observer.php
示例14: siteconfig
function siteconfig()
{
if (!DB::isConnected(DB_AOWOW)) {
CLISetup::log();
CLISetup::log("database not yet set up!\n Please use --dbconfig for setup", CLISetup::LOG_WARN);
return;
}
while (true) {
CLISetup::log();
CLISetup::log('select a numerical index to use the corresponding entry');
$results = DB::Aowow()->select('SELECT *, (flags & ?d) AS php FROM ?_config ORDER BY php ASC', CON_FLAG_PHP);
$hasEmpty = false;
foreach ($results as $idx => $data) {
if (!($data['flags'] & CON_FLAG_PHP) && $data['value'] === '') {
$hasEmpty = true;
}
$php = $data['flags'] & CON_FLAG_PHP;
$buff = "[" . CLISetup::bold($idx) . "] " . ($idx > 9 ? '' : ' ') . ($php ? ' PHP ' : ' AOWOW ');
$buff .= str_pad($php ? strtolower($data['key']) : strtoupper('cfg_' . $data['key']), 35);
if ($data['value'] === '') {
$buff .= CLISetup::red('<empty>');
} else {
$info = explode(' - ', $data['comment']);
if ($data['flags'] & CON_FLAG_TYPE_BOOL) {
$buff .= '[bool] ' . ($data['value'] ? '<Enabled>' : '<Disabled>');
} else {
if ($data['flags'] & CON_FLAG_OPT_LIST && !empty($info[2])) {
$buff .= "[opt] ";
foreach (explode(', ', $info[2]) as $option) {
$opt = explode(':', $option);
$buff .= '[' . ($data['value'] == $opt[0] ? 'x' : ' ') . ']' . $opt[1] . ' ';
}
} else {
if ($data['flags'] & CON_FLAG_BITMASK && !empty($info[2])) {
$buff .= "[mask] ";
foreach (explode(', ', $info[2]) as $option) {
$opt = explode(':', $option);
$buff .= '[' . ($data['value'] & 1 << $opt[0] ? 'x' : ' ') . ']' . $opt[1] . ' ';
}
} else {
if ($data['flags'] & CON_FLAG_TYPE_STRING) {
$buff .= "[str] " . $data['value'];
} else {
if ($data['flags'] & CON_FLAG_TYPE_FLOAT) {
$buff .= "[float] " . floatVal($data['value']);
} else {
/* if ($data['flags'] & CON_FLAG_TYPE_INT) */
$buff .= "[int] " . intVal($data['value']);
}
}
}
}
}
}
CLISetup::log($buff);
}
CLISetup::log(str_pad("[" . CLISetup::bold(count($results)) . "]", 21) . "add another php configuration");
if ($hasEmpty) {
CLISetup::log();
CLISetup::log("please configure the required empty setings", CLISetup::LOG_WARN);
}
$inp = ['idx' => ['', false, '/\\d/']];
if (CLISetup::readInput($inp) && $inp && $inp['idx'] !== '') {
// add new php setting
if ($inp['idx'] == count($results)) {
CLISetup::log();
CLISetup::log("Adding additional php configuration.");
while (true) {
$setting = array('key' => ['option name', false, '/[\\w_\\.\\-]/i'], 'val' => ['value']);
if (CLISetup::readInput($setting) && $setting) {
CLISetup::log();
$key = strtolower($setting['key']);
if (ini_get($key) === false || ini_set($key, $setting['val']) === false) {
CLISetup::log("this configuration option cannot be set", CLISetup::LOG_ERROR);
sleep(1);
} else {
if (DB::Aowow()->selectCell('SELECT 1 FROM ?_config WHERE `flags` & ?d AND `key` = ?', CON_FLAG_PHP, $key)) {
CLISetup::log("this configuration option is already in use", CLISetup::LOG_ERROR);
sleep(1);
} else {
DB::Aowow()->query('INSERT IGNORE INTO ?_config (`key`, `value`, `flags`) VALUES (?, ?, ?d)', $key, $setting['val'], CON_FLAG_TYPE_STRING | CON_FLAG_PHP);
CLISetup::log("new php configuration added", CLISetup::LOG_OK);
sleep(1);
}
}
break;
} else {
CLISetup::log();
CLISetup::log("edit canceled! returning to list...", CLISetup::LOG_WARN);
sleep(1);
break;
}
}
} else {
if ($inp['idx'] >= 0 && $inp['idx'] < count($results)) {
$conf = $results[$inp['idx']];
$info = explode(' - ', $conf['comment']);
$buff = '';
CLISetup::log();
$buff .= $conf['flags'] & CON_FLAG_PHP ? " PHP: " : "AOWOW: ";
//.........这里部分代码省略.........
开发者ID:aikon-com-cn,项目名称:aowow,代码行数:101,代码来源:siteconfig.func.php
示例15: loadCityData
/**
* {@inheritDoc}
*/
public function loadCityData(ObjectManager $manager, $code)
{
$enabledLocale = $this->container->getParameter('enabled_locale');
$locale = $this->container->getParameter('locale');
$contentArray = array('ANDAU' => array(array('name' => 'CTY_ANDAU', 'translations' => array('field' => 'name', 'en_GB' => 'Andau', 'de_DE' => 'Andau'))), 'APETL' => array(array('name' => 'CTY_APETL', 'translations' => array('field' => 'name', 'en_GB' => 'Apetlon', 'de_DE' => 'Apetlon'))), 'KUKMI' => array(array('name' => 'CTY_KUKMI', 'translations' => array('field' => 'name', 'en_GB' => 'Kukmirn', 'de_DE' => 'Kukmirn'))), 'ARRIA' => array(array('name' => 'CTY_ARRIA', 'translations' => array('field' => 'name', 'en_GB' => 'Arriach', 'de_DE' => 'Arriach'))), 'GUTTA' => array(array('name' => 'CTY_GUTTA', 'translations' => array('field' => 'name', 'en_GB' => 'Guttaring', 'de_DE' => 'Guttaring'))), 'PREIT' => array(array('name' => 'CTY_PREIT', 'translations' => array('field' => 'name', 'en_GB' => 'Preitenegg', 'de_DE' => 'Preitenegg'))), 'LINZ' => array(array('name' => 'CTY_LINZ', 'translations' => array('field' => 'name', 'en_GB' => 'Linz', 'de_DE' => 'Linz'))), 'STEYR' => array(array('name' => 'CTY_STEYR', 'translations' => array('field' => 'name', 'en_GB' => 'Steyr', 'de_DE' => 'Steyr'))), 'WELS' => array(array('name' => 'CTY_WELS', 'translations' => array('field' => 'name', 'en_GB' => 'Wels', 'de_DE' => 'Wels'))), 'WAIDH' => array(array('name' => 'CTY_WAIDH', 'translations' => array('field' => 'name', 'en_GB' => 'Waidhofen an der Ybbs', 'de_DE' => 'Waidhofen an der Ybbs'))), 'KERMS' => array(array('name' => 'CTY_KERMS', 'translations' => array('field' => 'name', 'en_GB' => 'Krems an der Donau', 'de_DE' => 'Krems an der Donau'))), 'WIENR' => array(array('name' => 'CTY_WIENR', 'translations' => array('field' => 'name', 'en_GB' => 'Wiener Neustadt', 'de_DE' => 'Wiener Neustadt'))), 'MAISH' => array(array('name' => 'CTY_MAISH', 'translations' => array('field' => 'name', 'en_GB' => 'Maishofen', 'de_DE' => 'Maishofen'))), 'LOFER' => array(array('name' => 'CTY_LOFER', 'translations' => array('field' => 'name', 'en_GB' => 'Lofer', 'de_DE' => 'Lofer'))), 'ABERS' => array(array('name' => 'CTY_ABERS', 'translations' => array('field' => 'name', 'en_GB' => 'Abersee', 'de_DE' => 'Abersee'))), 'FEHRG' => array(array('name' => 'CTY_FEHRG', 'translations' => array('field' => 'name', 'en_GB' => 'Fehring', 'de_DE' => 'Fehring'))), 'GUNDE' => array(array('name' => 'CTY_GUNDE', 'translations' => array('field' => 'name', 'en_GB' => 'Gundersdorf', 'de_DE' => 'Gundersdorf'))), 'ADMOT' => array(array('name' => 'CTY_ADMOT', 'translations' => array('field' => 'name', 'en_GB' => 'Admont', 'de_DE' => 'Admont'))), 'GUNDE' => array(array('name' => 'CTY_GUNDE', 'translations' => array('field' => 'name', 'en_GB' => 'Gundersdorf', 'de_DE' => 'Gundersdorf'))), 'FEHRG' => array(array('name' => 'CTY_FEHRG', 'translations' => array('field' => 'name', 'en_GB' => 'Fehring', 'de_DE' => 'Fehring'))), 'BLP' => array(array('name' => 'CTY_BLP', 'translations' => array('field' => 'name', 'en_GB' => 'Belp', 'de_DE' => 'Belp'))), 'AHOR' => array(array('name' => 'CTY_AHOR', 'translations' => array('field' => 'name', 'en_GB' => 'Ahorn', 'de_DE' => 'Ahorn'))), 'BLP' => array(array('name' => 'CTY_BLP', 'translations' => array('field' => 'name', 'en_GB' => 'Belp', 'de_DE' => 'Belp'))), 'ALLER' => array(array('name' => 'CTY_ALLER', 'translations' => array('field' => 'name', 'en_GB' => 'Allershausen', 'de_DE' => 'Allershausen'))), 'ALCH' => array(array('name' => 'CTY_ALCH', 'translations' => array('field' => 'name', 'en_GB' => 'Aichach', 'de_DE' => 'Aichach'))), 'BAYE' => array(array('name' => 'CTY_BAYE', 'translations' => array('field' => 'name', 'en_GB' => 'Altdorf', 'de_DE' => 'Altdorf'))));
foreach ($contentArray as $id => $contents) {
foreach ($contents as $content) {
if ($code === $id) {
$city = new City();
$city->setName($content['name']);
$city->setCounty($this->getReference($code));
$city->setLatitude(floatVal(rand(1, 99) . '.' . rand(11111, 99999)));
$city->setLongitude(floatVal(rand(1, 99) . '.' . rand(11111, 99999)));
foreach ($enabledLocale as $locales) {
if (array_key_exists($locales, $content['translations'])) {
$city->addTranslation(new CityTranslations($locales, $content['translations']['field'], $content['translations'][$locales]));
} else {
$city->addTranslation(new CityTranslations($locales, $content['translations']['field'], $content['translations'][$locale]));
}
}
$manager->persist($city);
$manager->flush();
$this->addReference($content['name'], $city);
}
}
}
}
开发者ID:jignesh-russmediatech,项目名称:rmcdemo,代码行数:30,代码来源:LoadLocationData.php
示例16: evalConstant
/**
* Tries to evaluate a constant value expressed as a string.
*
* @param string $exp
* @param bool $valid [optional] Outputs `true` if the expression was successfully evaluated.
* @return mixed
*/
static function evalConstant($exp, &$valid = null)
{
$exp = trim($exp);
if ($exp !== '') {
$valid = true;
if ($exp[0] == '"' || $exp[0] == "'") {
return substr($exp, 1, -1);
}
if (is_numeric($exp)) {
return ctype_digit($exp) ? intval($exp) : floatVal($exp);
}
if (defined($exp)) {
return constant($exp);
}
}
$valid = false;
return null;
}
开发者ID:php-kit,项目名称:tools,代码行数:25,代码来源:php-code.php
示例17: set_custom_price
public static function set_custom_price($cartandbuggy)
{
global $woocommerce;
$pid = 0;
$amt = 0;
$qty = 0;
$vri = 0;
if (isset($_POST)) {
if (isset($_POST[self::ID . '_pid']) || !empty($_POST[self::ID . '_pid'])) {
$pid = intval(filter_var($_POST[self::ID . '_pid'], FILTER_SANITIZE_STRING));
}
if (isset($_POST[self::ID . '_amt']) || !empty($_POST[self::ID . '_amt'])) {
$amt = floatval(filter_var($_POST[self::ID . '_amt'], FILTER_SANITIZE_STRING));
}
if (isset($_POST[self::ID . '_qty']) || !empty($_POST[self::ID . '_qty'])) {
$qty = floatval(filter_var($_POST[self::ID . '_qty'], FILTER_SANITIZE_STRING));
}
if (isset($_POST[self::ID . '_vri']) || !empty($_POST[self::ID . '_vri'])) {
$vri = intval(filter_var($_POST[self::ID . '_vri'], FILTER_SANITIZE_STRING));
}
if (!isset($pid) || !isset($amt) || !isset($vri) || $amt < 0 || $vri < 0 || $pid < 1) {
// DOOP ... SHIT HAPPENS!
} else {
$min_amt = get_post_meta($pid, self::ID . '_amount_min_price', true);
$max_amt = get_post_meta($pid, self::ID . '_amount_max_price', true);
if (isset($min_amt) && !empty($min_amt)) {
$min_amt = floatVal($min_amt);
if ($amt < 0) {
$amt = 0;
}
if ($amt < $min_amt) {
$amt = $min_amt;
}
}
if (isset($max_amt) && !empty($max_amt)) {
$max_amt = floatVal($max_amt);
if ($amt > $max_amt && $max_amt > 0) {
$amt = $max_amt;
}
}
|
请发表评论