Exemple #1
0
        } catch (RM_Validator_Exception $e) {
            VE($e, 'equipment');
        }
    }
    if (!empty($row['destination_holder_id'][0]) && !empty($row['destination_holder_id'][1])) {
        error(L('equipment.bad_destination', array('id' => $row['id'])));
    } else {
        $destination_id = empty($row['destination_holder_id'][0]) ? @$row['destination_holder_id'][1] : $row['destination_holder_id'][0];
        if (!isNull($obDestination = M('Holder')->loadHolderById($destination_id))) {
            try {
                $obEquipment = M('Equipment')->loadById($row['id']);
                $obSource = $obEquipment->getHolder();
                if ($obSource->moveEntity($obEquipment, $obDestination)) {
                    $message = L('equipment.operation_ok');
                } else {
                    @($error .= L('equipment.operation_bad', array('id' => $obEquipment->id)));
                }
            } catch (RM_Validator_Exception $e) {
                VE($e, 'equipment');
            } catch (RM_Permission_Exception $e) {
                PE($e);
            }
        }
    }
}
if (@$message) {
    message($message);
}
if (@$error) {
    error($error);
}
Exemple #2
0
<?php

require_once $_SERVER["ROOT_DIR"] . "/init.php";
if (!me()->id) {
    goU('main');
}
$data = $_POST['data'];
foreach ($data as $row) {
    if (!isNull($obOrder = M('Presents')->loadOrderById(@$row['id']))) {
        if (!empty($row['state']) && $row['state'] != $obOrder->state) {
            if (!$obOrder->changeState($row['state'])) {
                error(L('presents.cant_change_state', array('id' => $obOrder->id)));
            }
            try {
                $obOrder->save();
            } catch (RM_Validator_Excception $e) {
                VE($e, 'presents');
            }
        }
    }
}