<?php

global $ari;
$ari->popup = 1;
// no mostrar el main_frame
$language = $ari->get('agent')->getLang();
//CAMBIO EL VALOR DE LAS MONEDAS
if (isset($_POST['NewsValuesData'])) {
    $news_values = json_decode($_POST['NewsValuesData'], true);
    foreach ($news_values['items'] as $item) {
        $currency = new currency_currency($item['id']);
        if ($currency->get("type") == 2) {
            $date = new Date(date('Y-m-d', strtotime($news_values['fecha'])) . " " . date('H:i:s'));
            $separador = trim($ari->locale->get('decimal', 'numbers'));
            $currency->addChange(number_format(1 / $item['value'], 6, $separador, ""), $date);
        }
    }
}
//SE OBTIENE EL LISTADO DE CAMBIOS DE MONEDAS
$i = 0;
$return = array();
//para que no muestre las monedas de cambio fijo
$where = ' AND type = 2';
if ($currencies = currency_currency::listCurrenciesForLanguage(USED, 'name', OPERATOR_EQUAL, $language, $where)) {
    foreach ($currencies as $c) {
        $return[$i]['id'] = $c->get('id');
        $return[$i]['currency'] = $c->get('name') . " (" . $c->get('sign') . ")";
        if ($lastValue = $c->getLastChange()) {
            $return[$i]['value'] = round(1 / $lastValue['value'], 2);
            $return[$i]['date'] = $lastValue['date'];
        }
示例#2
0
 public function Printable($value, $currency = false, $negative = false)
 {
     global $ari;
     $separador = trim($ari->locale->get('decimal', 'numbers'));
     if ($currency) {
         $moneda = $currency;
     } else {
         $moneda = currency_currency::getDefault();
     }
     return $moneda->get('sign') . " " . ($negative ? '-' : '') . number_format(strval($value), 2, $separador, "");
 }
示例#3
0
<?php

global $ari;
$ari->popup = 1;
// no mostrar el main_frame
$language = $ari->get('agent')->getLang();
if (!isset($_POST['data'])) {
    $_POST['data'] = "";
}
//SE SETEA POR DEFECTO LA MONEDA QUE SE PASA POR PARAMETRO
if (isset($_POST['ChangePredeterminadaData'])) {
    //DECODIFICADO EL JSON
    $default_item = json_decode($_POST['ChangePredeterminadaData'], true);
    //SE CREA EL OBJETO Y SE SETEA COMO DEFAULT
    $currency = new currency_currency($default_item["0"]["id"]);
    $currency->set('default', YES);
    //SE GUARDAN LOS CAMBIOS
    $currency->store();
}
//FILTRO POR COLUMNAS
$where = "";
if ($_POST['data'] != "") {
    $filtros = admin_session_state::cache_filters(json_decode($_POST['data'], true));
    $operadores = array();
    $operadores["eq"] = "=";
    $operadores["lt"] = "<";
    $operadores["gt"] = ">";
    foreach ($filtros as $filtro) {
        switch ($filtro['type']) {
            case "string":
                $operador_inicio = " LIKE '%";
示例#4
0
		$predeterminada = NO ;		
		if (isset ($_POST['predeterminada']))
		{	
			if( $_POST['predeterminada'] == 'true' || $_POST['predeterminada'] == true )
			{				
				$predeterminada = YES;
				$tipo = FIXED_CHANGE;
				$valor = "1";
			}
		}else{
			throw new OOB_Exception_400("La variable [predeterminada] no esta definida");
		}
		file_put_contents('fewfwfw.txt',$predeterminada);
		
//SE CREA EL OBJETO
		$currency = new currency_currency();
		$currency->set( 'name', $nombre );		
		$currency->set( 'sign', $signo );
		$currency->set( 'type', $tipo );
		$currency->set( 'value', $valor );
		$currency->set( 'default', $predeterminada );		
		$currency->set( 'status', USED );
		
//FIN DE SETEO DE VALORES		
		
		//INTENTAMOS GUARDAR LOS DATOS
		if( $currency->store() ){
				
		//IDIOMAS
		//PASO A UN ARRAY LOS IDIOMAS SELECCIONADOS
		if ( isset( $_POST['idiomas'] ) )
示例#5
0
// dynamic content
$language = $ari->get('agent')->getLang();
//var_dump($params);exit;
//validar parametros del bloque
$currency_selected = false;
if (isset($params['currencyID']) && OOB_validatetext::isNumeric($params['currencyID']) && $params['currencyID'] > 0) {
    $currency_selected = $params['currencyID'];
}
$value = '';
if (isset($params['value']) && OOB_validatetext::isNumeric($params['value'])) {
    $value = $params['value'];
}
$prefix = 'currency';
if (isset($params['prefix'])) {
    $prefix = $params['prefix'];
}
if ($currencies = currency_currency::listCurrenciesForLanguage(USED, 'name', $operator = OPERATOR_EQUAL, $language)) {
    $i = 0;
    foreach ($currencies as $c) {
        $array_currencies[$c->get('id')] = $c->get('name') . " (" . $c->get('sign') . ")";
        if ($currency_selected === false && $c->get('default') == YES) {
            $currency_selected = $c->get('id');
        }
        $i++;
    }
}
$plantilla_bl->assign("options", $array_currencies);
$plantilla_bl->assign("prefix", $prefix);
$plantilla_bl->assign("value", $value);
$plantilla_bl->assign("currency_selected", $currency_selected);
$plantilla_bl->display($modulo->admintpldir() . "/bl_selector.tpl");
示例#6
0
 public function Convert($currency_value, $currency, $previous_change = false)
 {
     $multiplicador = 0;
     //moneda predeterminada
     $default = currency_currency::getDefault();
     if ($previous_change) {
         $last_change_from = $currency_value->get('currency')->get_quote($currency_value);
         $last_change_from_value = $last_change_from[0]['value'];
         $last_change_to = $currency->get_quote($currency_value);
         $last_change_to_value = $last_change_to[0]['value'];
     } else {
         $last_change_from = $currency_value->get('currency')->getLastChange();
         $last_change_from_value = $last_change_from['value'];
         $last_change_to = $currency->getLastChange();
         $last_change_to_value = $last_change_to['value'];
     }
     $default_is_from = $currency_value->get('currency')->id() == $default->id();
     $defailt_is_to = $currency->id() == $default->id();
     $valor = $currency_value->get('value');
     $new_value = 0;
     //si la moneda desde es la predeterminada
     if ($default_is_from) {
         //si tengo que convertir a una moneda fija(1)
         if ($currency->get('type') == 1) {
             $new_value = $valor * $currency->get('value');
         } else {
             $new_value = $valor * $last_change_to_value;
         }
         //end if
     } else {
         //NO PREDETERMINADA
         // //si tengo que convertir a una moneda fija(1)
         if ($currency_value->get('currency')->get('type') == 1) {
             if ($defailt_is_to) {
                 $new_value = $valor / $currency_value->get('currency')->get('value');
             } else {
                 if ($currency->get('type') == 1) {
                     $new_value = $valor / $currency_value->get('currency')->get('value') * $currency->get('value');
                 } else {
                     $new_value = $valor / $currency_value->get('currency')->get('value') * $last_change_to_value;
                 }
                 //end if
             }
             //end if
         } else {
             if ($defailt_is_to) {
                 $new_value = $valor / $last_change_from_value;
             } else {
                 if ($currency->get('type') == 1) {
                     $new_value = $valor / $last_change_from_value * $currency->get('value');
                 } else {
                     $new_value = $valor / $last_change_from_value * $last_change_to_value;
                 }
                 //end if
             }
             //end if
         }
         //end if
     }
     //end if
     $new_currency_value = new currency_value();
     $new_currency_value->set('value', $new_value);
     $new_currency_value->set('currency', $currency);
     return $new_currency_value;
 }
示例#7
0
$ari->t->assign("selMoneda", $selMoneda);
//---------------
//cargar las monedas
$language = $ari->get('agent')->getLang();
$ari->t->assign("error", false);
$ari->t->assign('lang', $language);
$array_currencies = array();
if ($currencies = currency_currency::listCurrenciesForLanguage(USED, 'name', $operator = OPERATOR_EQUAL, $language)) {
    foreach ($currencies as $c) {
        $array_currencies[$c->get('id')] = $c->get('name') . " (" . $c->get('sign') . ")";
    }
}
$ari->t->assign("optMoneda", $array_currencies);
if (isset($_POST['mostrar']) && isset($_POST['moneda'])) {
    //currency object
    $moneda = new currency_currency($_POST['moneda']);
    //fecha desde
    $desde = false;
    if (isset($_POST['desdeYear']) && isset($_POST['desdeMonth']) && isset($_POST['desdeDay'])) {
        //begin if
        $fecha = $_POST['desdeYear'] . "-";
        $fecha .= OOB_validatetext::addZero($_POST['desdeMonth']) . "-";
        $fecha .= OOB_validatetext::addZero($_POST['desdeDay']);
        $fecha .= ' 00:00:00';
        $desde = new Date($fecha);
    }
    //fecha hasta
    $hasta = false;
    if (isset($_POST['hastaYear']) && isset($_POST['hastaMonth']) && isset($_POST['hastaDay'])) {
        //begin if
        $fecha = $_POST['hastaYear'] . "-";
		//MONEDA PREDETERMINADA
		$predeterminada = NO ;
		if (isset ($_POST['opt-predeterminada']))
		{	
			if ($_POST['opt-predeterminada'] == 'yes')
			{
				$predeterminada = YES;
				$type = FIXED_CHANGE;
				$valor = "1";
			}
		}else{
			throw new OOB_Exception_400("La variable [opt-predeterminada] no esta definida");
		}
		
//SE CREA EL OBJETO Y SE LE PASAN LOS VALORES
		$currency = new currency_currency($_POST['id']);
		$currency->set ('name', $nombre);		
		$currency->set ('sign', $signo);
		$currency->set ('type', $tipo);
		$currency->set ('value', $valor);
		$currency->set ('default', $predeterminada);		
		$currency->set ('status', USED);
		
//FIN DE SETEO DE VALORES		
		
		//INTENTAMOS GUARDAR LOS DATOS
		if($currency->store()){
		
		if (isset ($_POST['idiomas']))
		{	
			$idiomas = array();
示例#9
0
}
include_once 'PhpExtUx/Multiselect/Itemselector.php';
global $ari;
$ari->popup = 1;
// no mostrar el main_frame
$field_width = 180;
//ancho de los controles
$separador_decimal = trim($ari->locale->get('decimal', 'numbers'));
$page_size = PAGE_SIZE;
$grid_id = '';
if (isset($_POST['gid'])) {
    $grid_id = $_POST['gid'];
}
//CREO EL OBJECTO MONEDA CON EL ID QUE ME PASAN
if (isset($_POST['id'])) {
    $currency = new currency_currency($_POST["id"]);
} else {
    throw new OOB_Exception_400("La variable [id] no esta definida");
}
PhpExt_Javascript::sendContentType();
//CREACION DE LOS CONTROLES
//MONEDA
$txt_moneda = PhpExt_Form_TextField::createTextField("txt_moneda", "Moneda")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setWidth($field_width)->setValue($currency->get("name"));
//SIGNO
$txt_signo = PhpExt_Form_TextField::createTextField("txt_signo", "Signo")->setMsgTarget(PhpExt_Form_FormPanel::MSG_TARGET_SIDE)->setWidth($field_width)->setValue($currency->get("sign"));
//TIPO DE CAMBIO
$opt_tipo_fijo = new PhpExt_Form_Radio();
$opt_tipo_fijo->setBoxLabel("Fijo")->setInputValue("fixed")->setName("opt-tipo-cambio");
if ($currency->get("type") == "1") {
    $opt_tipo_fijo->setChecked(true);
}