diff --git a/src/CoreFields/MoneyField.php b/src/CoreFields/MoneyField.php index 3564978..25f8419 100644 --- a/src/CoreFields/MoneyField.php +++ b/src/CoreFields/MoneyField.php @@ -2,8 +2,29 @@ namespace PhangoApp\PhaModels\CoreFields; +//Work with cents. + class MoneyField extends DoubleField{ + static public $dec_point=','; + static public $thousands_sep='.'; + + public function __construct() + { + + parent::__construct(11, true, 0, 0); + $this->form='PhangoApp\PhaModels\Forms\MoneyForm'; + + } + + function check($value) + { + $value=$value*100; + + return parent::check($value); + + } + function show_formatted($value) { @@ -16,11 +37,12 @@ class MoneyField extends DoubleField{ static function currency_format($value, $symbol_currency='€') { + $value=$value/100; - return number_format($value, 2).' '.$symbol_currency; + return number_format($value, 2, MoneyField::$dec_point, MoneyField::$thousands_sep).' '.$symbol_currency; } } -?> \ No newline at end of file +?> diff --git a/src/Forms/MoneyForm.php b/src/Forms/MoneyForm.php new file mode 100644 index 0000000..149536a --- /dev/null +++ b/src/Forms/MoneyForm.php @@ -0,0 +1,35 @@ +comment_form='€'; + + } + + public function form() + { + + $value=$this->default_value/100; + + return 'extra_param.'> '.$this->comment_form; + + } + + +} + +?> diff --git a/src/Forms/SelectForm.php b/src/Forms/SelectForm.php index 35be236..5130a23 100644 --- a/src/Forms/SelectForm.php +++ b/src/Forms/SelectForm.php @@ -30,7 +30,7 @@ class SelectForm extends BaseForm{ ob_start(); ?> - extra_param; ?>> arr_select as $value => $select) diff --git a/src/Forms/SelectModelForm.php b/src/Forms/SelectModelForm.php index 3289628..9860199 100644 --- a/src/Forms/SelectModelForm.php +++ b/src/Forms/SelectModelForm.php @@ -47,7 +47,7 @@ class SelectModelForm extends SelectForm{ } - $this->model->set_conditions($this->conditions[0], $this->conditions[1]); + $this->model->set_conditions($this->conditions); $query=$this->model->select(array($this->field_name, $this->field_value), $this->raw_query);