Ejemplo n.º 1
0
$action = GETPOST('action', 'alpha');
$cancel = GETPOST('cancel', 'alpha');
$confirm = GETPOST('confirm', 'alpha');
$id = GETPOST('id', 'int');
// List of status
static $tmpstatus2label = array('0' => 'OpenEtablishment', '1' => 'CloseEtablishment');
$status2label = array('');
foreach ($tmpstatus2label as $key => $val) {
    $status2label[$key] = $langs->trans($val);
}
$object = new Establishment($db);
/*
 * Actions
 */
if ($action == 'confirm_delete' && $confirm == "yes") {
    $result = $object->delete($id);
    if ($result >= 0) {
        header("Location: ../admin/admin_establishment.php");
        exit;
    } else {
        setEventMessages($object->error, $object->errors, 'errors');
    }
} else {
    if ($action == 'add') {
        if (!$cancel) {
            $error = 0;
            $object->name = GETPOST('name', 'alpha');
            if (empty($object->name)) {
                setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Name")), null, 'errors');
                $error++;
            }