<?php
	// For help on using hooks, please refer to https://bigprof.com/appgini/help/working-with-generated-web-database-application/hooks

	function oumrah_init(&$options, $memberInfo, &$args) {
		$resp1=db_query("SELECT * FROM oumrah");
		while($row=db_fetch_assoc($resp1))
		{
			$sortie_total=sqlValue("SELECT SUM(montant) FROM sorties WHERE oumrah=".$row['idoumrah']);
			
			$entree_total=sqlValue("SELECT SUM(montant) FROM entrees  WHERE oumrah=".$row['idoumrah']);
			
			$solde_restant=$entree_total-$sortie_total;
			
			$resp=db_query("UPDATE oumrah SET total_entree='$entree_total',total_sortie='$sortie_total',solde='$solde_restant' WHERE idoumrah=".$row['idoumrah']);
		}
		return TRUE;
	}

	function oumrah_header($contentType, $memberInfo, &$args) {
		$header='';

		switch($contentType) {
			case 'tableview':
				$header='';
				break;

			case 'detailview':
				$header='';
				break;

			case 'tableview+detailview':
				$header='';
				break;

			case 'print-tableview':
				$header='';
				break;

			case 'print-detailview':
				$header='';
				break;

			case 'filters':
				$header='';
				break;
		}

		return $header;
	}

	function oumrah_footer($contentType, $memberInfo, &$args) {
		$footer='';

		switch($contentType) {
			case 'tableview':
				$footer='';
				break;

			case 'detailview':
				$footer='';
				break;

			case 'tableview+detailview':
				$footer='';
				break;

			case 'print-tableview':
				$footer='';
				break;

			case 'print-detailview':
				$footer='';
				break;

			case 'filters':
				$footer='';
				break;
		}

		return $footer;
	}

	function oumrah_before_insert(&$data, $memberInfo, &$args) {

		return TRUE;
	}

	function oumrah_after_insert($data, $memberInfo, &$args) {

		return TRUE;
	}

	function oumrah_before_update(&$data, $memberInfo, &$args) {

		return TRUE;
	}

	function oumrah_after_update($data, $memberInfo, &$args) {

		return TRUE;
	}

	function oumrah_before_delete($selectedID, &$skipChecks, $memberInfo, &$args) {

		return TRUE;
	}

	function oumrah_after_delete($selectedID, $memberInfo, &$args) {

	}

	function oumrah_dv($selectedID, $memberInfo, &$html, &$args) {

	}

	function oumrah_csv($query, $memberInfo, &$args) {

		return $query;
	}
	function oumrah_batch_actions(&$args) {

		return array();
	}
