if ($result > 0) {
            header("Location: " . $_SERVER['PHP_SELF'] . '?action=editref_supplier&id=' . $result);
            exit;
        } else {
            $langs->load("errors");
            $mesg = '<div class="error">' . $langs->trans($object->error) . '</div>';
            $action = '';
        }
    }
} elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) {
    $idwarehouse = GETPOST('idwarehouse');
    $object->fetch($id);
    $object->fetch_thirdparty();
    $qualified_for_stock_change = 0;
    if (empty($conf->global->STOCK_SUPPORTS_SERVICES)) {
        $qualified_for_stock_change = $object->hasProductsOrServices(2);
    } else {
        $qualified_for_stock_change = $object->hasProductsOrServices(1);
    }
    // Check parameters
    if (!empty($conf->stock->enabled) && !empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $qualified_for_stock_change) {
        $langs->load("stocks");
        if (!$idwarehouse || $idwarehouse == -1) {
            $error++;
            $errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse"));
            $action = '';
        }
    }
    if (!$error) {
        $result = $object->validate($user, '', $idwarehouse);
        if ($result < 0) {
Beispiel #2
0
        $result = $object->createFromClone($id);
        if ($result > 0) {
            header("Location: " . $_SERVER['PHP_SELF'] . '?action=editfacnumber&id=' . $result);
            exit;
        } else {
            $langs->load("errors");
            $mesg = '<div class="error">' . $langs->trans($object->error) . '</div>';
            $action = '';
        }
    }
} elseif ($action == 'confirm_valid' && $confirm == 'yes' && $user->rights->fournisseur->facture->valider) {
    $idwarehouse = GETPOST('idwarehouse');
    $object->fetch($id);
    $object->fetch_thirdparty();
    // Check parameters
    if (!empty($conf->global->STOCK_CALCULATE_ON_SUPPLIER_BILL) && $object->hasProductsOrServices(1)) {
        $langs->load("stocks");
        if (!$idwarehouse || $idwarehouse == -1) {
            $error++;
            $errors[] = $langs->trans('ErrorFieldRequired', $langs->transnoentitiesnoconv("Warehouse"));
            $action = '';
        }
    }
    if (!$error) {
        $result = $object->validate($user, '', $idwarehouse);
        if ($result < 0) {
            $mesg = '<div class="error">' . $object->error . '</div>';
        }
    }
} elseif ($action == 'confirm_delete' && $confirm == 'yes' && $user->rights->fournisseur->facture->supprimer) {
    $object->fetch($id);