Your IP : 216.73.217.64


Current Path : /home3/gp97/jscb.97gp.net/data/plugins/caisse/admin/
Upload File :
Current File : //home3/gp97/jscb.97gp.net/data/plugins/caisse/admin/session_open.php

<?php

namespace Paheko;

use Paheko\Plugin\Caisse\Locations;
use Paheko\Plugin\Caisse\Sessions;
use function Paheko\Plugin\Caisse\get_amount;

require __DIR__ . '/_inc.php';

$pos_session = null;
$csrf_key = 'pos_open_session';

$form->runIf('open', function () use ($session) {
	if (trim(f('amount')) === '') {
		throw new UserException('Le solde de la caisse ne peut ĂȘtre laissĂ© vide.');
	}

	$l = intval(f('id_location')) ?: null;
	$amount = get_amount(f('amount'));
	$name = f('user_name') ?: $session->getUser()->name();
	$s = Sessions::open($name, $amount, $l);
	Utils::redirect(Utils::plugin_url(['file' => 'tab.php', 'query' => 'session=' . $s->id()]));
}, $csrf_key);

$locations = Locations::listAssoc();

$tpl->assign(compact('csrf_key', 'pos_session', 'locations'));

$tpl->assign('user_name', $session->getUser()->name());
$tpl->assign('current_pos_session', Sessions::getCurrentId());

$tpl->display(PLUGIN_ROOT . '/templates/session_open.tpl');