Exemplo n.º 1
0
function managePersonnel($obj)
{
    global $_iade_id, $_aideop_id, $_op_panseuse_id, $_sagefemme_id, $_manipulateur_id, $del_personnel;
    if ($_iade_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_iade_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("IADE ajoutée", UI_MSG_OK);
        }
    }
    if ($_aideop_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_aideop_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Aide opératoire ajoutée", UI_MSG_OK);
        }
    }
    if ($_op_panseuse_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_op_panseuse_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Panseuse ajoutée", UI_MSG_OK);
        }
    }
    if ($_sagefemme_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_sagefemme_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Sage femme ajoutée", UI_MSG_OK);
        }
    }
    if ($_manipulateur_id) {
        $affectation_personnel = new CAffectationPersonnel();
        $affectation_personnel->object_class = $obj->_class;
        $affectation_personnel->object_id = $obj->_id;
        $affectation_personnel->personnel_id = $_manipulateur_id;
        if ($msg = $affectation_personnel->store()) {
            CAppUI::setMsg($msg, UI_MSG_ERROR);
        } else {
            CAppUI::setMsg("Manipulateur ajouté", UI_MSG_OK);
        }
    }
    foreach ($del_personnel as $_personnel_id) {
        if ($_personnel_id) {
            $affectation_personnel = new CAffectationPersonnel();
            $affectation_personnel->object_class = $obj->_class;
            $affectation_personnel->object_id = $obj->_id;
            $affectation_personnel->personnel_id = $_personnel_id;
            $affectation_personnel->loadMatchingObject();
            if ($affectation_personnel->_id) {
                if ($msg = $affectation_personnel->delete()) {
                    CAppui::setMsg($msg, UI_MSG_ERROR);
                } else {
                    CAppUI::setMsg("Personnel supprimé");
                }
            }
        }
    }
}
$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) {
    $personnel = $affectation_personnel->_ref_personnel;
    if ($affectation_personnel->parent_affectation_id) {
        unset($affectations_operation[$key]);