2019-11-02 17:53:27 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Garradin;
|
|
|
|
|
2020-12-29 18:07:26 +01:00
|
|
|
define('DEVIS', 0);
|
|
|
|
define('FACT', 1);
|
|
|
|
define('CERFA', 2);
|
|
|
|
define('COTIS', 3);
|
|
|
|
|
2019-11-02 17:53:27 +01:00
|
|
|
use Garradin\Plugin\Facturation\Facture;
|
|
|
|
use Garradin\Plugin\Facturation\Client;
|
|
|
|
|
|
|
|
$client = new Client;
|
2019-11-03 17:51:31 +01:00
|
|
|
$facture = new Facture;
|
2020-10-24 09:19:21 +02:00
|
|
|
|
2021-11-24 23:44:46 +01:00
|
|
|
$tpl->assign('www_url', WWW_URL);
|
2020-12-29 18:07:26 +01:00
|
|
|
$tpl->assign('f_obj', $facture);
|
2021-11-06 22:02:47 +01:00
|
|
|
$tpl->assign('plugin_url', Utils::plugin_url());
|
2020-12-29 18:07:26 +01:00
|
|
|
|
|
|
|
$identite = (string) Config::getInstance()->get('champ_identite');
|
2021-11-05 23:47:36 +01:00
|
|
|
|
|
|
|
$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);
|
|
|
|
}
|
|
|
|
);
|