<commit_before><?php
/**
 * Created : 8 juin 2016
 * Creator : quinton
 * Encoding : UTF-8
 * Copyright 2016 - All rights reserved
 */
include_once 'modules/classes/container.class.php';
require_once 'modules/classes/object.class.php';
$dataClass = new Container ( $bdd, $ObjetBDDParam );
$keyName = "uid";
$id = $_REQUEST [$keyName];
$_SESSION["moduleParent"] = "container";

switch ($t_module ["param"]) {
	case "list":
		/*
		 * Display the list of all records of the table
		 */
		$_SESSION ["searchContainer"]->setParam ( $_REQUEST );
		$dataSearch = $_SESSION ["searchContainer"]->getParam ();
		if ($_SESSION ["searchContainer"]->isSearch () == 1) {
			$data = $dataClass->containerSearch( $dataSearch );
			$smarty->assign ( "containers", $data );
			$smarty->assign ( "isSearch", 1 );
		}
		$smarty->assign ( "containerSearch", $dataSearch );
		$smarty->assign ( "corps", "gestion/containerList.tpl" );
		/*
		 * Ajout des listes deroulantes
		 */
		include 'modules/gestion/container.functions.php';
		break;
	case "display":
		/*
		 * Display the detail of the record
		 */
		$data = $dataClass->lire ( $id );
		$smarty->assign ( "data", $data );
		/*
		 * Recuperation des conteneurs parents
		 */
		$smarty->assign("parents", $dataClass->getAllParents($data["uid"]));
		/*
		 * Recuperation des conteneurs  et des échantillons contenus
		 */
		$smarty->assign("containers", $dataClass->getContentContainer($data["uid"]));
		$smarty->assign("samples", $dataClass->getContentSample($data["uid"]));
		/*
		 * Recuperation des evenements
		 */
		require_once 'modules/classes/event.class.php';
		$event = new Event($bdd, $ObjetBDDParam);
		$smarty->assign("events", $event->getListeFromUid($data["uid"]));
		/*
		 * Recuperation des mouvements
		 */
		require_once 'modules/classes/storage.class.php';
		$storage = new Storage($bdd, $ObjetBDDParam);
		$smarty->assign("storages", $storage->getAllMovements($id));
		$smarty->assign("moduleParent", "container");
		$smarty->assign ( "corps", "gestion/containerDisplay.tpl" );
		break;
	case "change":
		/*
		 * open the form to modify the record
		 * If is a new record, generate a new record with default value :
		 * $_REQUEST["idParent"] contains the identifiant of the parent record
		 */
		dataRead ( $dataClass, $id, "gestion/containerChange.tpl" );
		//$object = new Object ( $bdd, $ObjetBDDParam );
		//$smarty->assign ( "objectData", $object->lire ( $data ["uid"] ) );
		if ($_REQUEST["container_parent_uid"] > 0 && is_numeric($_REQUEST["container_parent_uid"])) {
			$container_parent = $dataClass->lire($_REQUEST["container_parent_uid"]);
			$smarty->assign("container_parent_uid",$container_parent["uid"]);
			$smarty->assign("container_parent_identifier", $container_parent["identifier"]);
		}
		include 'modules/gestion/container.functions.php';
		break;
	case "write":
		/*
		 * write record in database
		 */
		$id = dataWrite ( $dataClass, $_REQUEST );
		if ($id > 0) {
			$_REQUEST [$keyName] = $id;
			/*
			 * Recherche s'il s'agit d'un conteneur a associer dans un autre conteneur
			 */
			if ($_REQUEST["container_parent_uid"] > 0 && is_numeric($_REQUEST["container_parent_uid"])) {
				require_once 'modules/classes/storage.class.php';
				$storage = new Storage($bdd, $ObjetBDDParam);
				$data = array ("uid" =>$id,
						"storage_date"=> date('d/m/Y H:i:s'),
						"movement_type_id"=>1,
						"login"=>$_SESSION["login"],
						"container_id"=>$dataClass->getIdFromUid($_REQUEST["container_parent_uid"]),
						"storage_id"=>0
				);
				$storage->ecrire($data);
			}
		}
		break;
	case "delete":
		/*<commit_msg>Correction dans la recherche d'un container<commit_after><?php
/**
 * Created : 8 juin 2016
 * Creator : quinton
 * Encoding : UTF-8
 * Copyright 2016 - All rights reserved
 */
include_once 'modules/classes/container.class.php';
require_once 'modules/classes/object.class.php';
$dataClass = new Container ( $bdd, $ObjetBDDParam );
$keyName = "uid";
$id = $_REQUEST [$keyName];
$_SESSION["moduleParent"] = "container";

switch ($t_module ["param"]) {
	case "list":
		/*
		 * Display the list of all records of the table
		 */
		$_SESSION ["searchContainer"]->setParam ( $_REQUEST );
		$dataSearch = $_SESSION ["searchContainer"]->getParam ();
		if ($_SESSION ["searchContainer"]->isSearch () == 1) {
			$data = $dataClass->containerSearch( $dataSearch );
			$smarty->assign ( "containers", $data );
			$smarty->assign ( "isSearch", 1 );
		}
		$smarty->assign ( "containerSearch", $dataSearch );
		$smarty->assign ( "corps", "gestion/containerList.tpl" );
		/*
		 * Ajout des listes deroulantes
		 */
		include 'modules/gestion/container.functions.php';
		break;
	case "display":
		/*
		 * Display the detail of the record
		 */
		$data = $dataClass->lire ( $id );
		$vue->set($data, "data");
		/*
		 * Recuperation des conteneurs parents
		 */
		$vue->set( $dataClass->getAllParents($data["uid"]),"parents");
		/*
		 * Recuperation des conteneurs  et des échantillons contenus
		 */
		$vue->set($dataClass->getContentContainer($data["uid"]),"containers");
		$vue->set($dataClass->getContentSample($data["uid"]),"samples");
		/*
		 * Recuperation des evenements
		 */
		require_once 'modules/classes/event.class.php';
		$event = new Event($bdd, $ObjetBDDParam);
		$vue->set($event->getListeFromUid($data["uid"]),"events");
		/*
		 * Recuperation des mouvements
		 */
		require_once 'modules/classes/storage.class.php';
		$storage = new Storage($bdd, $ObjetBDDParam);
		$vue->set($storage->getAllMovements($id),"storages" );
		/*
		 * Recuperation des reservations
		 */
		require_once 'modules/classes/booking.class.php';
		$booking = new Booking($bdd, $ObjetBDDParam);
		$vue->set($booking->getListFromParent($data["uid"],'date_from desc'), "bookings");

		$vue->set( "container", "moduleParent");
		$vue->set("gestion/containerDisplay.tpl", "corps" );
		break;
	case "change":
		/*
		 * open the form to modify the record
		 * If is a new record, generate a new record with default value :
		 * $_REQUEST["idParent"] contains the identifiant of the parent record
		 */
		dataRead ( $dataClass, $id, "gestion/containerChange.tpl" );
		//$object = new Object ( $bdd, $ObjetBDDParam );
		//$smarty->assign ( "objectData", $object->lire ( $data ["uid"] ) );
		if ($_REQUEST["container_parent_uid"] > 0 && is_numeric($_REQUEST["container_parent_uid"])) {
			$container_parent = $dataClass->lire($_REQUEST["container_parent_uid"]);
			$vue->set($container_parent["uid"],"container_parent_uid");
			$vue->set($container_parent["identifier"], "container_parent_identifier");
		}
		include 'modules/gestion/container.functions.php';
		break;
	case "write":
		/*
		 * write record in database
		 */
		$id = dataWrite ( $dataClass, $_REQUEST );
		if ($id > 0) {
			$_REQUEST [$keyName] = $id;
			/*
			 * Recherche s'il s'agit d'un conteneur a associer dans un autre conteneur
			 */
			if ($_REQUEST["container_parent_uid"] > 0 && is_numeric($_REQUEST["container_parent_uid"])) {
				require_once 'modules/classes/storage.class.php';
				$storage = new Storage($bdd, $ObjetBDDParam);
				$data = array ("uid" =>$id,
						"storage_date"=> date('d/m/Y H:i:s'),
						"movement_type_id"=>1,
						"login"=>$_SESSION["login"],
						"container_id"=>$dataClass->getIdFromUid($_REQUEST["container_parent_uid"]),
						"storage_id"=>0
				);
				$storage->ecrire($data);
			}
		}
		break;
	case "delete":
		/*
{'fraction_non_alphanumeric': 0.17954268705181978, 'fraction_numerical': 0.004600189419564335, 'mean_word_length': 4.235127478753541, 'pattern_counts': {'":': 10, '<': 5, '<?xml version=': 0, '>': 81, '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': '750405', 'n_tokens_mistral': 2777, 'n_tokens_neox': 2442, 'n_words': 496}