$operation_id = CValue::getOrSession("operation_id");
$selOp = new COperation();
$selOp->load($operation_id);
$plageOp = $selOp->loadRefPlageOp();
$listPers = $selOp->loadPersonnelDisponible();
// Creation du tableau d'affectation de personnel
$tabPersonnel = array();
$plageOp->loadAffectationsPersonnel();
$affectations_personnel = $plageOp->_ref_affectations_personnel;
$affectations_plage = array_merge($affectations_personnel["iade"], $affectations_personnel["op"], $affectations_personnel["op_panseuse"], $affectations_personnel["sagefemme"], $affectations_personnel["manipulateur"]);
// Tableau de stockage des affectations
$tabPersonnel["plage"] = array();
$tabPersonnel["operation"] = array();
foreach ($affectations_plage as $key => $affectation_personnel) {
    $affectation = new CAffectationPersonnel();
    $affectation->setObject($selOp);
    $affectation->personnel_id = $affectation_personnel->personnel_id;
    $affectation->parent_affectation_id = $affectation_personnel->_id;
    $affectation->loadMatchingObject();
    if (!$affectation->_id) {
        $affectation->parent_affectation_id = $affectation_personnel->_id;
    }
    $affectation->loadRefPersonnel();
    $affectation->_ref_personnel->loadRefUser();
    $affectation->_ref_personnel->_ref_user->loadRefFunction();
    $tabPersonnel["plage"][$affectation->personnel_id] = $affectation;
}
// Chargement du de l'operation
$affectations_personnel = $selOp->_ref_affectations_personnel;
$affectations_operation = array_merge($affectations_personnel["iade"], $affectations_personnel["op"], $affectations_personnel["op_panseuse"], $affectations_personnel["sagefemme"], $affectations_personnel["manipulateur"]);
foreach ($affectations_operation as $key => $affectation_personnel) {
<?php

/**
 * $Id:$
 *
 * @package    Mediboard
 * @subpackage dPpersonnel
 * @author     SARL OpenXtrem <*****@*****.**>
 * @license    GNU General Public License, see http://www.gnu.org/licenses/gpl.html
 * @version    $Revision:$
 */
global $can;
$can->needsAdmin();
$_multiple = array();
$object = mbGetObjectFromGet(null, null, "object_guid");
$affectation = new CAffectationPersonnel();
$affectation->setObject($object);
$affectation->personnel_id = CValue::get("personnel_id");
$affectation->loadRefPersonnel();
$_multiple["object"] = $affectation->_ref_object;
$_multiple["personnel"] = $affectation->_ref_personnel;
$_multiple["affectations"] = $affectation->loadMatchingList();
$_multiple["affect_count"] = count($_multiple["affectations"]);
// Création du template
$smarty = new CSmartyDP();
$smarty->assign("_multiple", $_multiple);
$smarty->display("inc_affectations_multiple.tpl");