<commit_before><?php

$rootpath = './';
$role = 'guest';
require_once $rootpath . 'includes/inc_default.php';
require_once $rootpath . 'includes/inc_pagination.php';
require_once $rootpath . 'includes/inc_transactions.php';

$orderby = (isset($_GET['orderby'])) ? $_GET['orderby'] : 'cdate';
$asc = (isset($_GET['asc'])) ? $_GET['asc'] : 0;
$limit = (isset($_GET['limit'])) ? $_GET['limit'] : 25;
$start = (isset($_GET['start'])) ? $_GET['start'] : 0;
$id = (isset($_GET['id'])) ? $_GET['id'] : false;
$add = (isset($_GET['add'])) ? true : false;
$submit = (isset($_POST['zend'])) ? true : false;

$mid = ($_GET['mid']) ?: false;
$tuid = ($_GET['tuid']) ?: false;
$fuid = ($_GET['fuid']) ?: false;
$uid = ($_GET['uid']) ?: false;
$inline = ($_GET['inline']) ? true : false;

$q = (isset($_GET['q'])) ? $_GET['q'] : '';
$fcode = (isset($_GET['fcode'])) ? $_GET['fcode'] : '';
$tcode = (isset($_GET['tcode'])) ? $_GET['tcode'] : '';
$andor = (isset($_GET['andor'])) ? $_GET['andor'] : 'and';
$fdate = (isset($_GET['fdate'])) ? $_GET['fdate'] : '';
$tdate = (isset($_GET['tdate'])) ? $_GET['tdate'] : '';

/**
 * add
 */
if ($add)
{
	if ($s_guest)
	{
		$alert->error('Je hebt geen rechten om een transactie toe te voegen.');
		cancel();
	}

	$transaction = array();

	$redis_transid_key = $schema . '_transid_u_' . $s_id;

	if ($submit)
	{
		$errors = array();

		$stored_transid = $redis->get($redis_transid_key);

		if (!$stored_transid)
		{
			$errors[] = 'Formulier verlopen.';
		}

		$transaction['transid'] = $_POST['transid'];
		$transaction['description'] = $_POST['description'];
		list($letscode_from) = explode(' ', $_POST['letscode_from']);
		list($letscode_to) = explode(' ', $_POST['letscode_to']);
		$transaction['amount'] = $amount = ltrim($_POST['amount'], '0 ');;
		$transaction['date'] = date('Y-m-d H:i:s');
		$group_id = $_POST['group_id'];

		if ($stored_transid != $transaction['transid'])
		{
			$errors[] = 'Fout transactie id.';
		}

		if ($db->fetchColumn('select transid from transactions where transid = ?', array($stored_transid)))
		{
			$errors[] = 'Een herinvoer van de transactie werd voorkomen.';
		}

		if (strlen($transaction['description']) > 60)
		{
			$errors[] = 'De omschrijving mag maximaal 60 tekens lang zijn.';
		}

		if ($group_id != 'self')
		{
			$group = $db->fetchAssoc('SELECT * FROM letsgroups WHERE id = ?', array($group_id));

			if (!isset($group))
			{
				$errors[] = 'Letsgroep niet gevonden.';
			}
		}

		if ($s_user)
		{
			$fromuser = $db->fetchAssoc('SELECT * FROM users WHERE id = ?', array($s_id));
		}
		else
		{
			$fromuser = $db->fetchAssoc('SELECT * FROM users WHERE letscode = ?', array($letscode_from));
		}

		$letscode_touser = ($group_id == 'self') ? $letscode_to : $group['localletscode'];

		$touser = $db->fetchAssoc('select * from users where letscode = ?', array($letscode_touser));

		if ($group_id == 'self' && $touser['status'] == 7)
		{
			$errors[] = 'Je kan niet rechtstreeks naar een interletsrekening overschrijven.';
		}

		if ($fromuser['status'] == 7)
		{
			$errors[] = 'Je kan niet rechtstreeks van een interletsrekening overschrijven.';
		}

		$transaction['id_from'] = $fromuser['id'];
		$transaction['id_to'] = $touser['id'];

		if (!$transaction['description'])
		{
			$errors[]= 'De omschrijving is niet ingevuld';
		}

		if (!$transaction['amount'])<commit_msg>apimethod check transactions of interlets accounts<commit_after><?php

$rootpath = './';
$role = 'guest';
require_once $rootpath . 'includes/inc_default.php';
require_once $rootpath . 'includes/inc_pagination.php';
require_once $rootpath . 'includes/inc_transactions.php';

$orderby = (isset($_GET['orderby'])) ? $_GET['orderby'] : 'cdate';
$asc = (isset($_GET['asc'])) ? $_GET['asc'] : 0;
$limit = (isset($_GET['limit'])) ? $_GET['limit'] : 25;
$start = (isset($_GET['start'])) ? $_GET['start'] : 0;
$id = (isset($_GET['id'])) ? $_GET['id'] : false;
$add = (isset($_GET['add'])) ? true : false;
$submit = (isset($_POST['zend'])) ? true : false;

$mid = ($_GET['mid']) ?: false;
$tuid = ($_GET['tuid']) ?: false;
$fuid = ($_GET['fuid']) ?: false;
$uid = ($_GET['uid']) ?: false;
$inline = ($_GET['inline']) ? true : false;

$q = (isset($_GET['q'])) ? $_GET['q'] : '';
$fcode = (isset($_GET['fcode'])) ? $_GET['fcode'] : '';
$tcode = (isset($_GET['tcode'])) ? $_GET['tcode'] : '';
$andor = (isset($_GET['andor'])) ? $_GET['andor'] : 'and';
$fdate = (isset($_GET['fdate'])) ? $_GET['fdate'] : '';
$tdate = (isset($_GET['tdate'])) ? $_GET['tdate'] : '';

/**
 * add
 */
if ($add)
{
	if ($s_guest)
	{
		$alert->error('Je hebt geen rechten om een transactie toe te voegen.');
		cancel();
	}

	$transaction = array();

	$redis_transid_key = $schema . '_transid_u_' . $s_id;

	if ($submit)
	{
		$errors = array();

		$stored_transid = $redis->get($redis_transid_key);

		if (!$stored_transid)
		{
			$errors[] = 'Formulier verlopen.';
		}

		$transaction['transid'] = $_POST['transid'];
		$transaction['description'] = $_POST['description'];
		list($letscode_from) = explode(' ', $_POST['letscode_from']);
		list($letscode_to) = explode(' ', $_POST['letscode_to']);
		$transaction['amount'] = $amount = ltrim($_POST['amount'], '0 ');;
		$transaction['date'] = date('Y-m-d H:i:s');
		$group_id = $_POST['group_id'];

		if ($stored_transid != $transaction['transid'])
		{
			$errors[] = 'Fout transactie id.';
		}

		if ($db->fetchColumn('select transid from transactions where transid = ?', array($stored_transid)))
		{
			$errors[] = 'Een herinvoer van de transactie werd voorkomen.';
		}

		if (strlen($transaction['description']) > 60)
		{
			$errors[] = 'De omschrijving mag maximaal 60 tekens lang zijn.';
		}

		if ($group_id != 'self')
		{
			$group = $db->fetchAssoc('SELECT * FROM letsgroups WHERE id = ?', array($group_id));

			if (!isset($group))
			{
				$errors[] = 'Letsgroep niet gevonden.';
			}
		}

		if ($s_user)
		{
			$fromuser = $db->fetchAssoc('SELECT * FROM users WHERE id = ?', array($s_id));
		}
		else
		{
			$fromuser = $db->fetchAssoc('SELECT * FROM users WHERE letscode = ?', array($letscode_from));
		}

		$letscode_touser = ($group_id == 'self') ? $letscode_to : $group['localletscode'];

		$touser = $db->fetchAssoc('select * from users where letscode = ?', array($letscode_touser));

		if ($group_id == 'self')
		{
			$to_apimethod_check = fetchColumn('select apimethod
				from letsgroups
				where localletscode = ?', array($letscode_to));

			if ($to_apimethod_check != 'mail')
			{
				$errors[] = 'Je kan enkel rechtstreeks naar een interletsrekening met apimethod <strong>mail</strong> overschrijven';
			}

			if ($touser['status'] == 7)
			{
				$errors[] = 'Je kan niet rechtstreeks naar een interletsrekening overschrijven.';
			}
		}

		if ($fromuser['status'] == 7 || $fromuser['accountrole'] == 'interlets')
		{
			$errors[] = 'Je kan niet rechtstreeks van een interletsrekening overschrijven.';
		}

		$transaction['id_from'] = $fromuser['id'];
		$transaction['id_to'] = $touser['id'];

		if (!$transaction['description'])
		{
			$errors[]= 'De omschrijving is niet ingevuld';
		}

		if (!$transaction['amount'])
{'fraction_non_alphanumeric': 0.23048797637463087, 'fraction_numerical': 0.003093798340599072, 'mean_word_length': 4.631037212984957, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '62344', 'n_tokens_mistral': 2882, 'n_tokens_neox': 2660, 'n_words': 526}