当前位置: 首页>>代码示例>>PHP>>正文


PHP Currency::convertToDollar方法代码示例

本文整理汇总了PHP中Currency::convertToDollar方法的典型用法代码示例。如果您正苦于以下问题:PHP Currency::convertToDollar方法的具体用法?PHP Currency::convertToDollar怎么用?PHP Currency::convertToDollar使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Currency的用法示例。


在下文中一共展示了Currency::convertToDollar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testconvertToDollar

 public function testconvertToDollar()
 {
     error_reporting(E_ERROR | E_PARSE);
     $currency = new Currency();
     //test without setting attributes
     $this->assertEquals(0, $currency->convertToDollar(100, 2));
     //test with required attributes set
     $currency->conversion_rate = 1.6;
     $this->assertEquals(62.5, $currency->convertToDollar(100, 2));
 }
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:10,代码来源:CurrencyTest.php

示例2: perform_save

function perform_save(&$focus)
{
    //US DOLLAR
    if (isset($focus->amount) && !number_empty($focus->amount)) {
        $currency = new Currency();
        $currency->retrieve($focus->currency_id);
        $focus->amount_usdollar = $currency->convertToDollar($focus->amount);
    }
}
开发者ID:klr2003,项目名称:sourceread,代码行数:9,代码来源:SaveOverload.php

示例3: perform_save

function perform_save(&$focus)
{
    require_once 'modules/Currencies/Currency.php';
    //US DOLLAR
    if (isset($focus->price) && !number_empty($focus->price)) {
        $currency = new Currency();
        $currency->retrieve($focus->currency_id);
        $focus->price_usdollar = $currency->convertToDollar(unformat_number($focus->price));
    }
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:10,代码来源:SaveOverload.php

示例4: updateAmountByID

function updateAmountByID($id, $curID, $price)
{
    global $db, $currencies;
    if (isset($id) && !empty($id)) {
        $currency = new Currency();
        $currency->retrieve($curID);
        $dollars = $currency->convertToDollar($price);
        $query = "update opportunities set price='{$price}', currency_id='{$curID}', price_usdollar='{$dollars}' where id='{$id}';";
        $db->query($query);
    }
}
开发者ID:BackupTheBerlios,项目名称:livealphaprint,代码行数:11,代码来源:UpgradeCurrency.php

示例5: save

 function save($check_notify = FALSE)
 {
     //"amount_usdollar" is really amount_basecurrency. We need to save a copy of the amount in the base currency.
     if (isset($this->amount) && !number_empty($this->amount)) {
         if (!number_empty($this->currency_id)) {
             $currency = new Currency();
             $currency->retrieve($this->currency_id);
             $this->amount_usdollar = $currency->convertToDollar($this->amount);
         } else {
             $this->amount_usdollar = $this->amount;
         }
     }
     return parent::save($check_notify);
 }
开发者ID:omusico,项目名称:sugar_work,代码行数:14,代码来源:Sale.php

示例6: perform_aos_save

/**
 * Products, Quotations & Invoices modules.
 * Extensions to SugarCRM
 * @package Advanced OpenSales for SugarCRM
 * @subpackage Products
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <info@salesagility.com>
 */
function perform_aos_save($focus)
{
    foreach ($focus->field_defs as $field) {
        $fieldName = $field['name'];
        $fieldNameDollar = $field['name'] . '_usdollar';
        if (isset($focus->field_defs[$fieldNameDollar])) {
            $focus->{$fieldNameDollar} = '';
            if (!number_empty($focus->field_defs[$field['name']])) {
                $currency = new Currency();
                $currency->retrieve($focus->currency_id);
                $focus->{$fieldNameDollar} = $currency->convertToDollar(unformat_number($fieldName));
            }
        }
    }
}
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:39,代码来源:AOS_Utils.php

示例7: perform_aos_save

/**
 * Products, Quotations & Invoices modules.
 * Extensions to SugarCRM
 * @package Advanced OpenSales for SugarCRM
 * @subpackage Products
 * @copyright SalesAgility Ltd http://www.salesagility.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
 * along with this program; if not, see http://www.gnu.org/licenses
 * or write to the Free Software Foundation,Inc., 51 Franklin Street,
 * Fifth Floor, Boston, MA 02110-1301  USA
 *
 * @author Salesagility Ltd <info@salesagility.com>
 */
function perform_aos_save($focus)
{
    //US DOLLAR
    foreach ($focus->field_defs as $field) {
        if (isset($focus->field_defs[$field['name'] . '_usdollar'])) {
            $fieldName = $field['name'] . '_usdollar';
            $focus->{$fieldName} = '';
            if (!number_empty($focus->field_defs[$field['name']])) {
                $currency = new Currency();
                $currency->retrieve($focus->currency_id);
                $focus->{$fieldName} = $currency->convertToDollar($focus->{$field}['name']);
            }
        }
    }
}
开发者ID:BMLP,项目名称:memoryhole-ansible,代码行数:39,代码来源:AOS_Utils.php

示例8: save

 function save($check_notify = FALSE)
 {
     //US DOLLAR
     if (isset($this->amount) && !empty($this->amount)) {
         $currency = new Currency();
         $currency->retrieve($this->currency_id);
         $this->amount_usdollar = $currency->convertToDollar($this->amount);
     }
     $this->unformat_all_fields();
     return parent::save($check_notify);
 }
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:11,代码来源:Campaign.php

示例9: Currency

 function update_currency_id($fromid, $toid)
 {
     $idequals = '';
     $currency = new Currency();
     $currency->retrieve($toid);
     foreach ($fromid as $f) {
         if (!empty($idequals)) {
             $idequals .= ' or ';
         }
         $idequals .= "currency_id='{$f}'";
     }
     if (!empty($idequals)) {
         $query = "select amount, id from opportunities where (" . $idequals . ") and deleted=0 and opportunities.sales_stage <> 'Closed Won' AND opportunities.sales_stage <> 'Closed Lost';";
         $result = $this->db->query($query);
         while ($row = $this->db->fetchByAssoc($result)) {
             $query = "update opportunities set currency_id='" . $currency->id . "', amount_usdollar='" . $currency->convertToDollar($row['amount']) . "' where id='" . $row['id'] . "';";
             $this->db->query($query);
         }
     }
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:20,代码来源:Opportunity.php

示例10: generateSearchWhere


//.........这里部分代码省略.........
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         } catch (Exception $timeException) {
                             //In the event that a date value is given that cannot be correctly processed by getDayStartEndGMT method,
                             //just skip searching on this field and continue.  This may occur if user switches locale date formats
                             //in another browser screen, but re-runs a search with the previous format on another screen
                             $GLOBALS['log']->error($timeException->getMessage());
                             continue;
                         }
                     }
                     if ($type == 'decimal' || $type == 'float' || $type == 'currency' || !empty($parms['enable_range_search']) && empty($parms['is_date_field'])) {
                         require_once 'modules/Currencies/Currency.php';
                         //we need to handle formatting either a single value or 2 values in case the 'between' search option is set
                         //start by splitting the string if the between operator exists
                         $fieldARR = explode('<>', $field_value);
                         //set the first pass through boolean
                         $values = array();
                         foreach ($fieldARR as $fv) {
                             //reset the field value, it will be rebuild in the foreach loop below
                             $tmpfield_value = unformat_number($fv);
                             if ($type == 'currency' && stripos($field, '_usdollar') !== FALSE) {
                                 // It's a US Dollar field, we need to do some conversions from the user's local currency
                                 $currency_id = $GLOBALS['current_user']->getPreference('currency');
                                 if (empty($currency_id)) {
                                     $currency_id = -99;
                                 }
                                 if ($currency_id != -99) {
                                     $currency = new Currency();
                                     $currency->retrieve($currency_id);
                                     $tmpfield_value = $currency->convertToDollar($tmpfield_value);
                                 }
                             }
                             $values[] = $tmpfield_value;
                         }
                         $field_value = join('<>', $values);
                         if (!empty($parms['enable_range_search']) && $parms['operator'] == '=' && $type != 'int') {
                             // Databases can't really search for floating point numbers, because they can't be accurately described in binary,
                             // So we have to fuzz out the math a little bit
                             $field_value = array($field_value - 0.01, $field_value + 0.01);
                             $operator = 'between';
                         }
                     }
                     if ($db->supports("case_sensitive") && isset($parms['query_type']) && $parms['query_type'] == 'case_insensitive') {
                         $db_field = 'upper(' . $db_field . ")";
                         $field_value = strtoupper($field_value);
                     }
                     $itr++;
                     if (!empty($where)) {
                         $where .= " OR ";
                     }
                     //Here we make a last attempt to determine the field type if possible
                     if (empty($type) && isset($parms['db_field']) && isset($parms['db_field'][0]) && isset($this->seed->field_defs[$parms['db_field'][0]]['type'])) {
                         $type = $this->seed->field_defs[$parms['db_field'][0]]['type'];
                     }
                     switch (strtolower($operator)) {
                         case 'subquery':
                             $in = 'IN';
                             if (isset($parms['subquery_in_clause'])) {
                                 if (!is_array($parms['subquery_in_clause'])) {
                                     $in = $parms['subquery_in_clause'];
                                 } elseif (isset($parms['subquery_in_clause'][$field_value])) {
                                     $in = $parms['subquery_in_clause'][$field_value];
开发者ID:jeffcao,项目名称:fzglsys_v5,代码行数:67,代码来源:SearchForm2.php

示例11: save

 function save($check_notify = false)
 {
     //US DOLLAR
     if (isset($this->amount) && !empty($this->amount)) {
         $currency = new Currency();
         $currency->retrieve($this->currency_id);
         $this->amount_usdollar = $currency->convertToDollar($this->amount);
     }
     // Bug53301
     if ($this->campaign_type != 'NewsLetter') {
         $this->frequency = '';
     }
     return parent::save($check_notify);
 }
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:14,代码来源:Campaign.php

示例12: getModuleField


//.........这里部分代码省略.........
            $value = $function($focus, $fieldname, $value, $view);
            $value = str_ireplace($fieldname, $aow_field, $value);
        }
    }
    if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'link') {
        $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id';
        if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) {
            $relName = $fieldlist[$fieldname]['name'];
            $fieldlist[$fieldname]['module'] = $focus->{$relName}->getRelatedModuleName();
        }
    }
    if (isset($fieldlist[$fieldname]['name']) && ($fieldlist[$fieldname]['name'] == 'date_entered' || $fieldlist[$fieldname]['name'] == 'date_modified')) {
        $fieldlist[$fieldname]['name'] = 'aow_temp_date';
        $fieldlist['aow_temp_date'] = $fieldlist[$fieldname];
        $fieldname = 'aow_temp_date';
    }
    $quicksearch_js = '';
    if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) {
        $rel_value = $value;
        require_once "include/TemplateHandler/TemplateHandler.php";
        $template_handler = new TemplateHandler();
        $quicksearch_js = $template_handler->createQuickSearchCode($fieldlist, $fieldlist, $view);
        $quicksearch_js = str_replace($fieldname, $aow_field . '_display', $quicksearch_js);
        $quicksearch_js = str_replace($fieldlist[$fieldname]['id_name'], $aow_field, $quicksearch_js);
        echo $quicksearch_js;
        if (isset($fieldlist[$fieldname]['module']) && $fieldlist[$fieldname]['module'] == 'Users') {
            $rel_value = get_assigned_user_name($value);
        } else {
            if (isset($fieldlist[$fieldname]['module'])) {
                require_once $beanFiles[$beanList[$fieldlist[$fieldname]['module']]];
                $rel_focus = new $beanList[$fieldlist[$fieldname]['module']]();
                $rel_focus->retrieve($value);
                if (isset($fieldlist[$fieldname]['rname']) && $fieldlist[$fieldname]['rname'] != '') {
                    $relDisplayField = $fieldlist[$fieldname]['rname'];
                } else {
                    $relDisplayField = 'name';
                }
                $rel_value = $rel_focus->{$relDisplayField};
            }
        }
        $fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $value;
        $fieldlist[$fieldname]['value'] = $rel_value;
        $fieldlist[$fieldname]['id_name'] = $aow_field;
        $fieldlist[$fieldlist[$fieldname]['id_name']]['name'] = $aow_field;
        $fieldlist[$fieldname]['name'] = $aow_field . '_display';
    } else {
        if (isset($fieldlist[$fieldname]['type']) && $view == 'DetailView' && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) {
            $value = $focus->convertField($value, $fieldlist[$fieldname]);
            if (!empty($params['date_format']) && isset($params['date_format'])) {
                $convert_format = "Y-m-d H:i:s";
                if ($fieldlist[$fieldname]['type'] == 'date') {
                    $convert_format = "Y-m-d";
                }
                $fieldlist[$fieldname]['value'] = $timedate->to_display($value, $convert_format, $params['date_format']);
            } else {
                $fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true);
            }
            $fieldlist[$fieldname]['name'] = $aow_field;
        } else {
            if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime' || $fieldlist[$fieldname]['type'] == 'date')) {
                $value = $focus->convertField($value, $fieldlist[$fieldname]);
                $fieldlist[$fieldname]['value'] = $timedate->to_display_date($value);
                //$fieldlist[$fieldname]['value'] = $timedate->to_display_date_time($value, true, true);
                //$fieldlist[$fieldname]['value'] = $value;
                $fieldlist[$fieldname]['name'] = $aow_field;
            } else {
                $fieldlist[$fieldname]['value'] = $value;
                $fieldlist[$fieldname]['name'] = $aow_field;
            }
        }
    }
    if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView') {
        static $sfh;
        if (!isset($sfh)) {
            require_once 'include/SugarFields/SugarFieldHandler.php';
            $sfh = new SugarFieldHandler();
        }
        if ($currency_id != '' && !stripos($fieldname, '_USD')) {
            $userCurrencyId = $current_user->getPreference('currency');
            if ($currency_id != $userCurrencyId) {
                $currency = new Currency();
                $currency->retrieve($currency_id);
                $value = $currency->convertToDollar($value);
                $currency->retrieve($userCurrencyId);
                $value = $currency->convertFromDollar($value);
            }
        }
        $parentfieldlist[strtoupper($fieldname)] = $value;
        return $sfh->displaySmarty($parentfieldlist, $fieldlist[$fieldname], 'ListView', $displayParams);
    }
    $ss->assign("QS_JS", $quicksearch_js);
    $ss->assign("fields", $fieldlist);
    $ss->assign("form_name", $view);
    $ss->assign("bean", $focus);
    // add in any additional strings
    $ss->assign("MOD", $mod_strings);
    $ss->assign("APP", $app_strings);
    //$return = str_replace($fieldname,$ss->fetch($file));
    return $ss->fetch($file);
}
开发者ID:sacredwebsite,项目名称:SuiteCRM,代码行数:101,代码来源:aow_utils.php

示例13: getEditFieldHTML


//.........这里部分代码省略.........
    $focus = new $beanList[$module]();
    // create the dropdowns for the parent type fields
    $vardefFields[$fieldname] = $focus->field_defs[$fieldname];
    if ($vardefFields[$fieldname]['type'] == 'parent') {
        $focus->field_defs[$fieldname]['options'] = $focus->field_defs[$vardefFields[$fieldname]['group']]['options'];
    }
    foreach ($vardefFields as $name => $properties) {
        $fieldlist[$name] = $properties;
        // fill in enums
        if (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($app_list_strings[$fieldlist[$name]['options']])) {
            $fieldlist[$name]['options'] = $app_list_strings[$fieldlist[$name]['options']];
        } elseif (isset($fieldlist[$name]['options']) && is_string($fieldlist[$name]['options']) && isset($mod_strings[$fieldlist[$name]['options']])) {
            $fieldlist[$name]['options'] = $mod_strings[$fieldlist[$name]['options']];
        }
    }
    // fill in function return values
    if (!in_array($fieldname, array('email1', 'email2'))) {
        if (!empty($fieldlist[$fieldname]['function']['returns']) && $fieldlist[$fieldname]['function']['returns'] == 'html') {
            $function = $fieldlist[$fieldname]['function']['name'];
            // include various functions required in the various vardefs
            if (isset($fieldlist[$fieldname]['function']['include']) && is_file($fieldlist[$fieldname]['function']['include'])) {
                require_once $fieldlist[$fieldname]['function']['include'];
            }
            $_REQUEST[$fieldname] = $value;
            $value = $function($focus, $fieldname, $value, $view);
            $value = str_ireplace($fieldname, $aow_field, $value);
        }
    }
    if ($fieldlist[$fieldname]['type'] == 'link') {
        $fieldlist[$fieldname]['id_name'] = $fieldlist[$fieldname]['name'] . '_id';
        if ((!isset($fieldlist[$fieldname]['module']) || $fieldlist[$fieldname]['module'] == '') && $focus->load_relationship($fieldlist[$fieldname]['name'])) {
            $relateField = $fieldlist[$fieldname]['name'];
            $fieldlist[$fieldname]['module'] = $focus->{$relateField}->getRelatedModuleName();
        }
    }
    if ($fieldlist[$fieldname]['type'] == 'parent') {
        $fieldlist['parent_id']['name'] = 'parent_id';
    }
    if (isset($fieldlist[$fieldname]['name']) && $fieldlist[$fieldname]['name'] == 'date_modified') {
        $fieldlist[$fieldname]['name'] = 'aow_temp_date';
        $fieldlist['aow_temp_date'] = $fieldlist[$fieldname];
        $fieldname = 'aow_temp_date';
    }
    if (isset($fieldlist[$fieldname]['id_name']) && $fieldlist[$fieldname]['id_name'] != '' && $fieldlist[$fieldname]['id_name'] != $fieldlist[$fieldname]['name']) {
        if ($value) {
            $relateIdField = $fieldlist[$fieldname]['id_name'];
            $rel_value = $bean->{$relateIdField};
        }
        $fieldlist[$fieldlist[$fieldname]['id_name']]['value'] = $rel_value;
        $fieldlist[$fieldname]['value'] = $value;
        $fieldlist[$fieldname]['id_name'] = $aow_field;
        $fieldlist[$fieldname]['name'] = $aow_field . '_display';
    } else {
        if (isset($fieldlist[$fieldname]['type']) && ($fieldlist[$fieldname]['type'] == 'datetimecombo' || $fieldlist[$fieldname]['type'] == 'datetime')) {
            $value = $focus->convertField($value, $fieldlist[$fieldname]);
            if (!$value) {
                $value = date($timedate->get_date_time_format());
            }
            $fieldlist[$fieldname]['name'] = $aow_field;
            $fieldlist[$fieldname]['value'] = $value;
        } else {
            if (isset($fieldlist[$fieldname]['type']) && $fieldlist[$fieldname]['type'] == 'date') {
                $value = $focus->convertField($value, $fieldlist[$fieldname]);
                $fieldlist[$fieldname]['name'] = $aow_field;
                if (empty($value) == "") {
                    $value = str_replace("%", "", date($date_format));
                }
                $fieldlist[$fieldname]['value'] = $value;
            } else {
                $fieldlist[$fieldname]['value'] = $value;
                $fieldlist[$fieldname]['name'] = $aow_field;
            }
        }
    }
    if ($fieldlist[$fieldname]['type'] == 'currency' && $view != 'EditView') {
        static $sfh;
        if (!isset($sfh)) {
            require_once 'include/SugarFields/SugarFieldHandler.php';
            $sfh = new SugarFieldHandler();
        }
        if ($currency_id != '' && !stripos($fieldname, '_USD')) {
            $userCurrencyId = $current_user->getPreference('currency');
            if ($currency_id != $userCurrencyId) {
                $currency = new Currency();
                $currency->retrieve($currency_id);
                $value = $currency->convertToDollar($value);
                $currency->retrieve($userCurrencyId);
                $value = $currency->convertFromDollar($value);
            }
        }
        $parentfieldlist[strtoupper($fieldname)] = $value;
        return $sfh->displaySmarty($parentfieldlist, $fieldlist[$fieldname], 'ListView', $displayParams);
    }
    $ss->assign("fields", $fieldlist);
    $ss->assign("form_name", $view);
    $ss->assign("bean", $focus);
    $ss->assign("MOD", $mod_strings);
    $ss->assign("APP", $app_strings);
    return json_encode($ss->fetch($file));
}
开发者ID:auf,项目名称:crm_auf_org,代码行数:101,代码来源:InlineEditing.php

示例14: generateSearchWhere


//.........这里部分代码省略.........
                                 $operator = '=';
                             } else {
                                 $operator = 'db_date';
                             }
                         } else {
                             if ($GLOBALS['db']->dbType == 'mssql') {
                                 if (preg_match('/^\\d{4}.\\d{1,2}$/', $field_value) == 0) {
                                     $field_value = "Convert(DateTime, '" . $timedate->to_db_date($field_value, false) . "')";
                                 }
                                 $operator = 'db_date';
                             } else {
                                 $field_value = $timedate->to_db_date($field_value, false);
                                 $operator = '=';
                             }
                         }
                     }
                     if ($type == 'datetime' || $type == 'datetimecombo') {
                         $dates = $timedate->getDayStartEndGMT($field_value);
                         $field_value = $dates["start"] . "<>" . $dates["end"];
                         $operator = 'between';
                     }
                     if ($type == 'decimal' || $type == 'float' || $type == 'currency') {
                         require_once 'modules/Currencies/Currency.php';
                         $field_value = unformat_number($field_value);
                         if ($type == 'currency' && stripos($field, '_usdollar') !== FALSE) {
                             // It's a US Dollar field, we need to do some conversions from the user's local currency
                             $currency_id = $GLOBALS['current_user']->getPreference('currency');
                             if (empty($currency_id)) {
                                 $currency_id = -99;
                             }
                             if ($currency_id != -99) {
                                 $currency = new Currency();
                                 $currency->retrieve($currency_id);
                                 $field_value = $currency->convertToDollar($field_value);
                             }
                         }
                         // Databases can't really search for floating point numbers, because they can't be accurately described in binary,
                         // So we have to fuzz out the match a little bit
                         $top = $field_value + 0.01;
                         $bottom = $field_value - 0.01;
                         $field_value = $bottom . "<>" . $top;
                         $operator = 'between';
                     }
                     $itr++;
                     if (!empty($where)) {
                         $where .= " OR ";
                     }
                     switch (strtolower($operator)) {
                         case 'subquery':
                             $in = 'IN';
                             if (isset($parms['subquery_in_clause'])) {
                                 if (!is_array($parms['subquery_in_clause'])) {
                                     $in = $parms['subquery_in_clause'];
                                 } elseif (isset($parms['subquery_in_clause'][$field_value])) {
                                     $in = $parms['subquery_in_clause'][$field_value];
                                 }
                             }
                             $sq = $parms['subquery'];
                             if (is_array($sq)) {
                                 $and_or = ' AND ';
                                 if (isset($sq['OR'])) {
                                     $and_or = ' OR ';
                                 }
                                 $first = true;
                                 foreach ($sq as $q) {
                                     if (empty($q) || strlen($q) < 2) {
开发者ID:aldridged,项目名称:gtg-sugar,代码行数:67,代码来源:SearchForm2.php

示例15: generateSearchWhere


//.........这里部分代码省略.........
                                     break;
                                 case 'last_year':
                                     $startDate = $timedate->getDayStartEndGMT(date('m/d/Y', mktime(0, 0, 0, 01, 01, date("Y") - 1)));
                                     $endDate = $timedate->getDayStartEndGMT(date('m/d/Y', mktime(0, 0, 0, 12, 31, date("Y") - 1)));
                                     break;
                                 case 'next_year':
                                     $startDate = $timedate->getDayStartEndGMT(date('m/d/Y', mktime(0, 0, 0, 01, 01, date("Y") + 1)));
                                     $endDate = $timedate->getDayStartEndGMT(date('m/d/Y', mktime(0, 0, 0, 12, 31, date("Y") + 1)));
                                     break;
                             }
                             $field_value = $startDate['start'] . "<>" . $endDate['end'];
                             $operator = 'between';
                         }
                     }
                     if ($type == 'decimal' || $type == 'float' || $type == 'currency' || !empty($parms['enable_range_search']) && empty($parms['is_date_field'])) {
                         require_once 'modules/Currencies/Currency.php';
                         //we need to handle formatting either a single value or 2 values in case the 'between' search option is set
                         //start by splitting the string if the between operator exists
                         $fieldARR = explode('<>', $field_value);
                         //set the first pass through boolean
                         $first_between = true;
                         foreach ($fieldARR as $fk => $fv) {
                             //reset the field value, it will be rebuild in the foreach loop below
                             $tmpfield_value = unformat_number($fv);
                             if ($type == 'currency' && stripos($field, '_usdollar') !== FALSE) {
                                 // It's a US Dollar field, we need to do some conversions from the user's local currency
                                 $currency_id = $GLOBALS['current_user']->getPreference('currency');
                                 if (empty($currency_id)) {
                                     $currency_id = -99;
                                 }
                                 if ($currency_id != -99) {
                                     $currency = new Currency();
                                     $currency->retrieve($currency_id);
                                     $field_value = $currency->convertToDollar($tmpfield_value);
                                 }
                             }
                             //recreate the field value
                             if ($first_between) {
                                 //set the field value with the new formatted temp value
                                 $field_value = $tmpfield_value;
                             } else {
                                 //this is a between query, so append the between operator and add the second formatted temp value
                                 $field_value .= '<>' . $tmpfield_value;
                             }
                             //set the first pass through variable to false
                             $first_between = false;
                         }
                         if (!empty($parms['enable_range_search']) && $parms['operator'] == '=') {
                             // Databases can't really search for floating point numbers, because they can't be accurately described in binary,
                             // So we have to fuzz out the math a little bit
                             $field_value = $field_value - 0.01 . "<>" . ($field_value + 0.01);
                             $operator = 'between';
                         }
                     }
                     $itr++;
                     if (!empty($where)) {
                         $where .= " OR ";
                     }
                     switch (strtolower($operator)) {
                         case 'subquery':
                             $in = 'IN';
                             if (isset($parms['subquery_in_clause'])) {
                                 if (!is_array($parms['subquery_in_clause'])) {
                                     $in = $parms['subquery_in_clause'];
                                 } elseif (isset($parms['subquery_in_clause'][$field_value])) {
                                     $in = $parms['subquery_in_clause'][$field_value];
开发者ID:dinhquyet92,项目名称:sugarcrm_advanced_workflows,代码行数:67,代码来源:SearchForm2.php


注:本文中的Currency::convertToDollar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。