Exemplo n.º 1
0
********************************************************************/
if ($action == 'update_floors' && !$_POST["cancel"] && $user->rights->place->write) {
    $res = $object->fetch($id);
    $floor_ref = GETPOST('floor_ref');
    $floor_pos = GETPOST('floor_pos');
    // Assemblage du tableau des enfants
    $i = 0;
    while (isset($floor_ref[$i]) && !empty($floor_ref[$i])) {
        $floors[$i]['ref'] = $db->escape($floor_ref[$i]);
        $floors[$i]['pos'] = $db->escape($floor_pos[$i]);
        $floors[$i]['fk_building'] = $db->escape($id);
        $i++;
    }
    // Datas are added in object and saved with trigger after object creation
    $object->floors = $floors;
    $result = $object->insertFloors($user);
    if ($result > 0) {
        setEventMessage($langs->trans('FloorsUpdated'));
    } else {
        $action = "add_floors";
        $mode = 'edit';
    }
} else {
    if ($action == 'delete_floor' && !$_POST["cancel"] && $user->rights->place->delete) {
        $id = GETPOST('id');
        $id_floor = GETPOST('id_floor');
        $result = $object->deleteFloor($id_floor);
        if ($result > 0) {
            setEventMessage($langs->trans('FloorDeletedWithSuccess'));
            Header("Location: floors.php?action=show_floor_form&id=" . $id);
            exit;