<?php
// This script and data application were generated by AppGini 5.76
// Download AppGini for free from https://bigprof.com/appgini/download/

	$currDir=dirname(__FILE__);
	include("$currDir/defaultLang.php");
	include("$currDir/language.php");
	include("$currDir/lib.php");
	@include("$currDir/hooks/informations.php");
	include("$currDir/informations_dml.php");

	// mm: can the current member access this page?
	$perm=getTablePermissions('informations');
	if(!$perm[0]){
		echo error_message($Translation['tableAccessDenied'], false);
		echo '<script>setTimeout("window.location=\'index.php?signOut=1\'", 2000);</script>';
		exit;
	}

	$x = new DataList;
	$x->TableName = "informations";

	// Fields that can be displayed in the table view
	$x->QueryFieldsTV = array(   
		"`informations`.`idinformation`" => "idinformation",
		"`informations`.`situation`" => "situation",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`, '   '), '') /* Matricule */" => "matricule",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') /* Nom prenom */" => "nom_prenom",
		"`informations`.`education`" => "education",
		"`informations`.`diplome_primordial`" => "diplome_primordial",
		"if(`informations`.`date_diplome`,date_format(`informations`.`date_diplome`,'%d/%m/%Y'),'')" => "date_diplome",
		"`informations`.`institution`" => "institution",
		"`informations`.`lieu_diplome`" => "lieu_diplome",
		"`informations`.`diplome_certificat`" => "diplome_certificat",
		"`informations`.`specialite`" => "specialite",
		"`informations`.`institution_specialite`" => "institution_specialite",
		"`informations`.`lieu_specialite`" => "lieu_specialite",
		"`informations`.`langues`" => "langues",
		"`informations`.`arabe`" => "arabe",
		"`informations`.`francais`" => "francais",
		"`informations`.`anglais`" => "anglais",
		"`informations`.`autres1`" => "autres1",
		"`informations`.`autres2`" => "autres2",
		"`informations`.`informatique`" => "informatique",
		"`informations`.`utilisation`" => "utilisation",
		"`informations`.`programmation`" => "programmation"
	);
	// mapping incoming sort by requests to actual query fields
	$x->SortFields = array(   
		1 => '`informations`.`idinformation`',
		2 => 2,
		3 => 3,
		4 => '`dossier_individuel1`.`nom_prenom`',
		5 => 5,
		6 => 6,
		7 => '`informations`.`date_diplome`',
		8 => 8,
		9 => 9,
		10 => 10,
		11 => 11,
		12 => 12,
		13 => 13,
		14 => 14,
		15 => 15,
		16 => 16,
		17 => 17,
		18 => 18,
		19 => 19,
		20 => 20,
		21 => 21,
		22 => 22
	);

	// Fields that can be displayed in the csv file
	$x->QueryFieldsCSV = array(   
		"`informations`.`idinformation`" => "idinformation",
		"`informations`.`situation`" => "situation",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`, '   '), '') /* Matricule */" => "matricule",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') /* Nom prenom */" => "nom_prenom",
		"`informations`.`education`" => "education",
		"`informations`.`diplome_primordial`" => "diplome_primordial",
		"if(`informations`.`date_diplome`,date_format(`informations`.`date_diplome`,'%d/%m/%Y'),'')" => "date_diplome",
		"`informations`.`institution`" => "institution",
		"`informations`.`lieu_diplome`" => "lieu_diplome",
		"`informations`.`diplome_certificat`" => "diplome_certificat",
		"`informations`.`specialite`" => "specialite",
		"`informations`.`institution_specialite`" => "institution_specialite",
		"`informations`.`lieu_specialite`" => "lieu_specialite",
		"`informations`.`langues`" => "langues",
		"`informations`.`arabe`" => "arabe",
		"`informations`.`francais`" => "francais",
		"`informations`.`anglais`" => "anglais",
		"`informations`.`autres1`" => "autres1",
		"`informations`.`autres2`" => "autres2",
		"`informations`.`informatique`" => "informatique",
		"`informations`.`utilisation`" => "utilisation",
		"`informations`.`programmation`" => "programmation"
	);
	// Fields that can be filtered
	$x->QueryFieldsFilters = array(   
		"`informations`.`idinformation`" => "ID",
		"`informations`.`situation`" => "SITUATION",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`, '   '), '') /* Matricule */" => "Matricule",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') /* Nom prenom */" => "Nom prenom",
		"`informations`.`education`" => "EDUCATION",
		"`informations`.`diplome_primordial`" => "DIPL&#212;ME PRIMORDIAL",
		"`informations`.`date_diplome`" => "DATE",
		"`informations`.`institution`" => "INSTITUTION",
		"`informations`.`lieu_diplome`" => "LIEU ",
		"`informations`.`diplome_certificat`" => "DIPL&#214;ME / CERTIFICAT DE SP&#201;CIALIT&#201;",
		"`informations`.`specialite`" => "SP&#201;CIALIT&#201;",
		"`informations`.`institution_specialite`" => "INSTITUTION ",
		"`informations`.`lieu_specialite`" => "LIEU  ",
		"`informations`.`langues`" => "LANGUES",
		"`informations`.`arabe`" => "ARABE",
		"`informations`.`francais`" => "FRAN&#199;AIS",
		"`informations`.`anglais`" => "ANGLAIS",
		"`informations`.`autres1`" => "AUTRES ",
		"`informations`.`autres2`" => "NIVEAU",
		"`informations`.`informatique`" => "INFORMATIQUE",
		"`informations`.`utilisation`" => "UTILISATION",
		"`informations`.`programmation`" => "PROGRAMMATION"
	);

	// Fields that can be quick searched
	$x->QueryFieldsQS = array(   
		"`informations`.`idinformation`" => "idinformation",
		"`informations`.`situation`" => "situation",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`matricule`), CONCAT_WS('',   `dossier_individuel1`.`matricule`, '   '), '') /* Matricule */" => "matricule",
		"IF(    CHAR_LENGTH(`dossier_individuel1`.`nom_prenom`), CONCAT_WS('',   `dossier_individuel1`.`nom_prenom`), '') /* Nom prenom */" => "nom_prenom",
		"`informations`.`education`" => "education",
		"`informations`.`diplome_primordial`" => "diplome_primordial",
		"if(`informations`.`date_diplome`,date_format(`informations`.`date_diplome`,'%d/%m/%Y'),'')" => "date_diplome",
		"`informations`.`institution`" => "institution",
		"`informations`.`lieu_diplome`" => "lieu_diplome",
		"`informations`.`diplome_certificat`" => "diplome_certificat",
		"`informations`.`specialite`" => "specialite",
		"`informations`.`institution_specialite`" => "institution_specialite",
		"`informations`.`lieu_specialite`" => "lieu_specialite",
		"`informations`.`langues`" => "langues",
		"`informations`.`arabe`" => "arabe",
		"`informations`.`francais`" => "francais",
		"`informations`.`anglais`" => "anglais",
		"`informations`.`autres1`" => "autres1",
		"`informations`.`autres2`" => "autres2",
		"`informations`.`informatique`" => "informatique",
		"`informations`.`utilisation`" => "utilisation",
		"`informations`.`programmation`" => "programmation"
	);

	// Lookup fields that can be used as filterers
	$x->filterers = array(  'matricule' => 'Matricule');

	$x->QueryFrom = "`informations` LEFT JOIN `dossier_individuel` as dossier_individuel1 ON `dossier_individuel1`.`iddindividuel`=`informations`.`matricule` ";
	$x->QueryWhere = '';
	$x->QueryOrder = '';

	$x->AllowSelection = 1;
	$x->HideTableView = ($perm[2]==0 ? 1 : 0);
	$x->AllowDelete = $perm[4];
	$x->AllowMassDelete = true;
	$x->AllowInsert = $perm[1];
	$x->AllowUpdate = $perm[3];
	$x->SeparateDV = 1;
	$x->AllowDeleteOfParents = 0;
	$x->AllowFilters = 1;
	$x->AllowSavingFilters = 1;
	$x->AllowSorting = 1;
	$x->AllowNavigation = 1;
	$x->AllowPrinting = 1;
	$x->AllowPrintingDV = 1;
	$x->AllowCSV = 1;
	$x->RecordsPerPage = 100;
	$x->QuickSearch = 1;
	$x->QuickSearchText = $Translation["quick search"];
	$x->ScriptFileName = "informations_view.php";
	$x->RedirectAfterInsert = "informations_view.php?SelectedID=#ID#";
	$x->TableTitle = "EXPERIENCES";
	$x->TableIcon = "resources/table_icons/chart_pie_alternative.png";
	$x->PrimaryKey = "`informations`.`idinformation`";
	$x->DefaultSortField = '1';
	$x->DefaultSortDirection = 'asc';

	$x->ColWidth   = array(  150, 150, 150, 150, 150, 150, 150, 150);
	$x->ColCaption = array("DIPL&#212;ME PRIMORDIAL", "DATE", "INSTITUTION", "LIEU ", "DIPL&#214;ME / CERTIFICAT DE SP&#201;CIALIT&#201;", "SP&#201;CIALIT&#201;", "INSTITUTION ", "LIEU  ");
	$x->ColFieldName = array('diplome_primordial', 'date_diplome', 'institution', 'lieu_diplome', 'diplome_certificat', 'specialite', 'institution_specialite', 'lieu_specialite');
	$x->ColNumber  = array(6, 7, 8, 9, 10, 11, 12, 13);

	// template paths below are based on the app main directory
	$x->Template = 'templates/informations_templateTV.html';
	$x->SelectedTemplate = 'templates/informations_templateTVS.html';
	$x->TemplateDV = 'templates/informations_templateDV.html';
	$x->TemplateDVP = 'templates/informations_templateDVP.html';

	$x->ShowTableHeader = 0;
	$x->TVClasses = "";
	$x->DVClasses = "";
	$x->HighlightColor = '#FFF0C2';

	// mm: build the query based on current member's permissions
	$DisplayRecords = $_REQUEST['DisplayRecords'];
	if(!in_array($DisplayRecords, array('user', 'group'))){ $DisplayRecords = 'all'; }
	if($perm[2]==1 || ($perm[2]>1 && $DisplayRecords=='user' && !$_REQUEST['NoFilter_x'])){ // view owner only
		$x->QueryFrom.=', membership_userrecords';
		$x->QueryWhere="where `informations`.`idinformation`=membership_userrecords.pkValue and membership_userrecords.tableName='informations' and lcase(membership_userrecords.memberID)='".getLoggedMemberID()."'";
	}elseif($perm[2]==2 || ($perm[2]>2 && $DisplayRecords=='group' && !$_REQUEST['NoFilter_x'])){ // view group only
		$x->QueryFrom.=', membership_userrecords';
		$x->QueryWhere="where `informations`.`idinformation`=membership_userrecords.pkValue and membership_userrecords.tableName='informations' and membership_userrecords.groupID='".getLoggedGroupID()."'";
	}elseif($perm[2]==3){ // view all
		// no further action
	}elseif($perm[2]==0){ // view none
		$x->QueryFields = array("Not enough permissions" => "NEP");
		$x->QueryFrom = '`informations`';
		$x->QueryWhere = '';
		$x->DefaultSortField = '';
	}
	// hook: informations_init
	$render=TRUE;
	if(function_exists('informations_init')){
		$args=array();
		$render=informations_init($x, getMemberInfo(), $args);
	}

	if($render) $x->Render();

	// hook: informations_header
	$headerCode='';
	if(function_exists('informations_header')){
		$args=array();
		$headerCode=informations_header($x->ContentType, getMemberInfo(), $args);
	}  
	if(!$headerCode){
		include_once("$currDir/header.php"); 
	}else{
		ob_start(); include_once("$currDir/header.php"); $dHeader=ob_get_contents(); ob_end_clean();
		echo str_replace('<%%HEADER%%>', $dHeader, $headerCode);
	}

	echo $x->HTML;
	// hook: informations_footer
	$footerCode='';
	if(function_exists('informations_footer')){
		$args=array();
		$footerCode=informations_footer($x->ContentType, getMemberInfo(), $args);
	}  
	if(!$footerCode){
		include_once("$currDir/footer.php"); 
	}else{
		ob_start(); include_once("$currDir/footer.php"); $dFooter=ob_get_contents(); ob_end_clean();
		echo str_replace('<%%FOOTER%%>', $dFooter, $footerCode);
	}
?>