<?php
namespace TourOperatorProFrontend\app\models;
defined('_TOUROPERATOR_EXEC') or die;

use TourOperatorPro\Factory;
use TourOperatorPro\Mvc\Model\ModelForm;
use TourOperatorPro\Form\Form;
use TourOperatorPro\Mvc\Model\ModelList;
use TourOperatorPro\Registry\Registry;

class CurrencyModel extends ModelForm
{
    /**
     * @var string
     */
    public $context = "currency";
    /**
     * @var string
     */
    public $table_name = "currency";
    public function getItem($id = 0)
    {
        $db=$this->_db;
        return parent::getItem($id); // TODO: Change the autogenerated stub
    }

    public function format_currency($based = "USD"){
        $db=$this->_db;
        $query=$db->getQuery(true);
        $query->select('currency.symbol')
            ->from($this->getTableName('currency').' AS currency')
            ->where('currency.code='.$query->quote($based));
        $code = $this->_db->setQuery($query)->loadObject();
        return $code;
    }
}
