示例#1
1
 /**
  * Formats a number into a currency format.
  *
  * ### Options
  *
  * - `locale` - The locale name to use for formatting the number, e.g. fr_FR
  * - `fractionSymbol` - The currency symbol to use for fractional numbers.
  * - `fractionPosition` - The position the fraction symbol should be placed
  *    valid options are 'before' & 'after'.
  * - `before` - Text to display before the rendered number
  * - `after` - Text to display after the rendered number
  * - `zero` - The text to use for zero values, can be a string or a number. e.g. 0, 'Free!'
  * - `places` - Number of decimal places to use. e.g. 2
  * - `precision` - Maximum Number of decimal places to use, e.g. 2
  * - `pattern` - An ICU number pattern to use for formatting the number. e.g #,###.00
  * - `useIntlCode` - Whether or not to replace the currency symbol with the international
  *   currency code.
  * - `escape` - Whether or not to escape html in resulting string
  *
  * @param float $number Value to format.
  * @param string $currency International currency name such as 'USD', 'EUR', 'JPY', 'CAD'
  * @param array $options Options list.
  * @return string Number formatted as a currency.
  */
 public function currency($number, $currency = null, array $options = [])
 {
     $formatted = $this->_engine->currency($number, $currency, $options);
     $options += ['escape' => true];
     return $options['escape'] ? h($formatted) : $formatted;
 }
示例#2
1
 /**
  * Overwrite to allow
  *
  * - signed: true/false
  *
  * @param float $number
  * @param string $currency
  * @param array $options
  * @return string
  */
 public static function currency($number, $currency = null, array $options = [])
 {
     $defaults = ['positive' => '+', 'signed' => false];
     $options += $defaults;
     $sign = '';
     if ($number > 0 && !empty($options['signed'])) {
         $sign = $options['positive'];
     }
     return $sign . parent::currency($number, $currency, $options);
 }
示例#3
1
 /**
  * [currency description]
  * @param  [type] $value    [description]
  * @param  [type] $currency [description]
  * @return [type]           [description]
  */
 public static function currency($value, $currency)
 {
     $number = \Cake\I18n\Number::currency($value, $currency);
     $formattedValue = preg_split('/(R\\$)/', $number);
     return 'R$ ' . $formattedValue[1];
 }
 /**
  * compteResultat method
  *
  * @param string|null $id Client id.
  * @return void
  * @throws \Cake\Network\Exception\NotFoundException When record not found.
  */
 public function compteResultat($id = null)
 {
     if ($id == null) {
         $id = $this->Auth->user()['id_client'];
     }
     $tab = [];
     $tab['exploitation']['produit'] = $this->Operations->getCompteResultat($id, 'produit_exploitation');
     $tab['exploitation']['charge'] = $this->Operations->getCompteResultat($id, 'charge_exploitation');
     $tab['financier']['produit'] = $this->Operations->getCompteResultat($id, 'produit_financier');
     $tab['financier']['charge'] = $this->Operations->getCompteResultat($id, 'charge_financier');
     $tab['exceptionnel']['produit'] = $this->Operations->getCompteResultat($id, 'produit_exceptionnel');
     $tab['exceptionnel']['charge'] = $this->Operations->getCompteResultat($id, 'charge_exceptionnel');
     $tab['resultat']['exploitation'] = $tab['exploitation']['produit'] - $tab['exploitation']['charge'];
     $tab['resultat']['financier'] = $tab['financier']['produit'] - $tab['financier']['charge'];
     $tab['resultat']['exceptionnel'] = $tab['exceptionnel']['produit'] - $tab['exceptionnel']['charge'];
     $tab['resultat']['net'] = $tab['resultat']['exceptionnel'] + $tab['resultat']['financier'] + $tab['resultat']['exploitation'];
     $query = $this->Operations->find('all');
     $equilibre = $query->select(['sum' => $query->func()->sum('montant')])->where(['id_client' => $id])->first()['sum'];
     if ($equilibre == 0) {
         $this->Flash->success('Vos opérations sont bien équilibrées.');
     } else {
         $this->Flash->error('Vos opérations ne sont pas équilibrées. Différences de ' . Number::currency(abs($equilibre)));
     }
     $this->set('tab', $tab);
 }
示例#5
1
 public function pebble_data_request($order_id)
 {
     $this->layout = null;
     $order = $this->Orders->get($order_id, ["contain" => ["Products", "OrdersProducts", "OrderStatus", "Users"]]);
     $order->pebble_cancel_secret_key = md5($order->id);
     $this->Orders->save($order);
     $total_price = Number::currency($order->total_price, "USD");
     $data = ["user_name" => $order->user->name, "order_id" => $order->id, "order_status" => $order->order_status->name, "total_price" => $total_price, "pebble_cancel_secret_key" => $order->pebble_cancel_secret_key];
     echo json_encode($data);
     exit;
 }