<commit_before><?php

$_POST = json_decode(file_get_contents('php://input'), true);

require_once '../db.php';

$con = new pdo_db();

$sy = $_POST['school_year']['id'];

$filters = [];
$filters[] = array("enrollments.enrollment_school_year = $sy");

switch ($_POST['coverage']) {
	
	case "Daily":

		$date = date("Y-m-d",strtotime($_POST['date']));
		$filters[] = array("payments.payment_date = '$date'");	

	break;
	
	case "Weekly":
	
		$from = date("Y-m-d",strtotime($_POST['week_from']));
		$to = date("Y-m-d",strtotime($_POST['week_to']));
		$filters[] = array("(payments.payment_date >= '$from' AND payments.payment_date <= '$to')");	
	
	break;	
	
	case "Monthly":
	
		$year = $_POST['year'];
		$month = $_POST['month']['id'];
		$filters[] = array("payments.payment_date LIKE '$year-$month-%'");
	
	break;	
	
	case "Annually":
	
		$year = $_POST['year'];
		$filters[] = array("payments.payment_date LIKE '$year-%'");		
	
	break;	
	
	case "SY":
	
	break;	
	
};

$where = "";

foreach ($filters as $i => $filter) {
	
	$criterion = $filter[0];
	if ($i==0) $where .= " $criterion";
	else $where .= " AND $criterion";
	
};

$sql = "SELECT payments.payment_date, (SELECT CONCAT(students.lastname, ', ', students.firstname, ' ', students.middlename) FROM students WHERE students.id = enrollments.student_id) fullname, enrollments.school_id, (SELECT grade_levels.description FROM grade_levels WHERE grade_levels.id = enrollments.grade) grade, IFNULL((SELECT sections.description FROM sections WHERE sections.id = enrollments.section),'') section, (SELECT students.gender FROM students WHERE students.id = enrollments.student_id) gender, (SELECT students.home_address FROM students WHERE students.id = enrollments.student_id) home_address, IFNULL(payments.official_receipt,''), payments.amount FROM payments LEFT JOIN enrollments ON payments.enrollment_id = enrollments.id WHERE $where ORDER BY payments.payment_date ASC, payments.id ASC";

$collections = $con->getData($sql);<commit_msg>Update report-collections.php<commit_after><?php

$_POST = json_decode(file_get_contents('php://input'), true);

require_once '../db.php';

$con = new pdo_db();

$sy = $_POST['school_year']['id'];

$filters = [];
$filters[] = array("enrollments.enrollment_school_year = $sy");

switch ($_POST['coverage']) {
	
	case "Daily":

		$date = date("Y-m-d",strtotime($_POST['date']));
		$filters[] = array("payments.payment_date = '$date'");	

	break;
	
	case "Weekly":
	
		$from = date("Y-m-d",strtotime($_POST['week_from']));
		$to = date("Y-m-d",strtotime($_POST['week_to']));
		$filters[] = array("(payments.payment_date >= '$from' AND payments.payment_date <= '$to')");	
	
	break;	
	
	case "Monthly":
	
		$year = $_POST['year'];
		$month = $_POST['month']['id'];
		$filters[] = array("payments.payment_date LIKE '$year-$month-%'");
	
	break;	
	
	case "Annually":
	
		$year = $_POST['year'];
		$filters[] = array("payments.payment_date LIKE '$year-%'");		
	
	break;	
	
	case "SY":
	
	break;	
	
};

$where = "";

foreach ($filters as $i => $filter) {
	
	$criterion = $filter[0];
	if ($i==0) $where .= " $criterion";
	else $where .= " AND $criterion";
	
};

$sql = "SELECT payments.payment_date, (SELECT CONCAT(students.lastname, ', ', students.firstname, ' ', students.middlename) FROM students WHERE students.id = enrollments.student_id) fullname, enrollments.school_id, (SELECT grade_levels.description FROM grade_levels WHERE grade_levels.id = enrollments.grade) grade, IFNULL((SELECT sections.description FROM sections WHERE sections.id = enrollments.section),'') section, (SELECT students.gender FROM students WHERE students.id = enrollments.student_id) gender, (SELECT students.home_address FROM students WHERE students.id = enrollments.student_id) home_address, IFNULL(payments.official_receipt,'') official_receipt, payments.amount FROM payments LEFT JOIN enrollments ON payments.enrollment_id = enrollments.id WHERE $where ORDER BY payments.payment_date ASC, payments.id ASC";

$collections = $con->getData($sql);
{'fraction_non_alphanumeric': 0.18195451137215696, 'fraction_numerical': 0.000999750062484379, 'mean_word_length': 5.2433697347893915, 'pattern_counts': {'":': 10, '<': 7, '<?xml version=': 0, '>': 9, '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': '497835', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1307, 'n_words': 287}