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

	function clients_init(&$options, $memberInfo, &$args) {
		/* Expiration passport */
		//sql("update `clients` set `validite`= if(Date_Add(Date(`expire_le`), interval 180 day)>CurDate(),'INVALIDE',null)",$eo);
		
		
		/* Epiration */		
            if(isset($_REQUEST['SelectedID'])){
			$id = makeSafe($_REQUEST['SelectedID']);
			$today = date('Y-m-d');
			
			sql("update clients set age=floor(datediff('{$today}', date_naissance) / 365.25) where idclient='{$id}'", $eo);
		}
		return TRUE;
	}

	function clients_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 clients_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 clients_before_insert(&$data, $memberInfo, &$args) {

		return TRUE;
	}

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

		return TRUE;
	}

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

		return TRUE;
	}

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

		return TRUE;
	}

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

		return TRUE;
	}

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

	}

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

	}

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

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

		return array();
	}
