facturation/www/admin/_inc.php
2021-11-06 22:02:47 +01:00

56 lines
1.6 KiB
PHP

<?php
namespace Garradin;
define('DEVIS', 0);
define('FACT', 1);
define('CERFA', 2);
define('COTIS', 3);
use Garradin\Plugin\Facturation\Facture;
use Garradin\Plugin\Facturation\Client;
use Garradin\Plugin\Facturation\GenDon;
$client = new Client;
$facture = new Facture;
$tpl->assign('f_obj', $facture);
$tpl->assign('plugin_url', Utils::plugin_url());
$identite = (string) Config::getInstance()->get('champ_identite');
$tpl->register_function('money_fac', function (array $params)
{
static $params_list = ['value', 'name', 'user'];
// Extract params and keep attributes separated
$attributes = array_diff_key($params, array_flip($params_list));
$params = array_intersect_key($params, array_flip($params_list));
extract($params, \EXTR_SKIP);
$current_value = null;
if (isset($value)) {
$current_value = $value;
}
if (!isset($user)) {
$user = false;
}
if (!isset($name))
{
$name = 'prix[]';
}
if (null !== $current_value && !$user) {
$current_value = Utils::money_format($current_value, ',', '');
}
$current_value = htmlspecialchars($current_value, ENT_QUOTES, 'UTF-8');
$currency = Config::getInstance()->get('monnaie');
return sprintf('<td><nobr><input type="text" pattern="[0-9]*([.,][0-9]{1,2})?" inputmode="decimal" size="8" class="money" style="width: 60%%" onchange="updateSum();" name="%s" value="%s" /><b>%s</b></nobr></td>', $name, $current_value, $currency);
}
);