コード例 #1
0
            $img = NULL;
        } else {
            $img = "";
        }
    }
    $scaled = isset($_POST['scaled']) ? 1 : 0;
    $visible = isset($_POST['visible']) ? 1 : 0;
    $discountEnabled = FALSE;
    $discountRate = 0.0;
    if (isset($_POST['discountRate'])) {
        $discountEnabled = isset($_POST['discountEnabled']) ? 1 : 0;
        $discountRate = $_POST['discountRate'];
    }
    $cmp = \Pasteque\Composition::__build($_POST['id'], $_POST['reference'], $_POST['label'], $_POST['realsell'], $catId, null, $dispOrder, $taxCatId, $visible, $scaled, $_POST['priceBuy'], null, $_POST['barcode'], $img != null, $discountEnabled, $discountRate);
    $cmp->groups = parseSubgroups($_POST['subgroupData'], $products);
    if (\Pasteque\CompositionsService::update($cmp, $img, null)) {
        $message = \i18n("Changes saved", PLUGIN_NAME);
    } else {
        $error = \i18n("Unable to save changes", PLUGIN_NAME);
    }
} else {
    if (isset($_POST['reference'])) {
        // Create composition
        $catId = \Pasteque\CompositionsService::CAT_ID;
        $dispOrder = $_POST['dispOrder'] == "" ? NULL : $_POST['dispOrder'];
        $taxCatId = $_POST['taxCatId'];
        if ($_FILES['image']['tmp_name'] !== "") {
            $img = file_get_contents($_FILES['image']['tmp_name']);
        } else {
            $img = NULL;
        }