Esempio n. 1
0
        if (isset($_POST['discountRate'])) {
            $discountEnabled = isset($_POST['discountEnabled']) ? 1 : 0;
            $discountRate = $_POST['discountRate'];
        }
        $cmp = new \Pasteque\Product($_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::create($cmp, $img, null)) {
            $message = \i18n("Changes saved", PLUGIN_NAME);
        } else {
            $error = \i18n("Unable to save changes", PLUGIN_NAME);
        }
    }
}
if (isset($_GET['productId'])) {
    $composition = \Pasteque\CompositionsService::get($_GET['productId']);
    $taxCat = \Pasteque\TaxesService::get($composition->taxCatId);
    $tax = $taxCat->getCurrentTax();
    $vatprice = $composition->priceSell * (1 + $tax->rate);
    $price = sprintf("%.2f", $composition->priceSell);
} else {
    $vatprice = "";
    $price = "";
    $composition = NULL;
}
?>

<h1><?php 
\pi18n('Composition edit', PLUGIN_NAME);
?>
</h1>
Esempio n. 2
0
            $prd = new \Pasteque\Product($_POST['reference'], $_POST['label'], $_POST['realsell'], $catId, $provId, $disp_order, $taxCatId, $visible, $scaled, $_POST['priceBuy'], $attr, $_POST['barcode'], $img !== null, $discount_enabled, $discount_rate);
            $id = \Pasteque\ProductsService::create($prd, $img);
            if ($id !== FALSE) {
                $message = \i18n("Product saved. <a href=\"%s\">Go to the product page</a>.", PLUGIN_NAME, \Pasteque\get_module_url_action(PLUGIN_NAME, 'product_edit', array('id' => $id)));
            } else {
                $error = \i18n("Unable to save changes");
            }
        }
    }
}
$product = NULL;
$vatprice = "";
$price = "";
if (isset($_GET['id'])) {
    $product = \Pasteque\ProductsService::get($_GET['id']);
    $taxCat = \Pasteque\TaxesService::get($product->taxCatId);
    $tax = $taxCat->getCurrentTax();
    $vatprice = $product->priceSell * (1 + $tax->rate);
    $price = sprintf("%.2f", $product->priceSell);
}
$taxes = \Pasteque\TaxesService::getAll();
$categories = \Pasteque\CategoriesService::getAll();
$providers = \Pasteque\ProvidersService::getAll();
$level = NULL;
if ($stocks === TRUE && $product != NULL) {
    $level = \Pasteque\StocksService::getLevel($product->id);
}
?>
<h1><?php 
\pi18n("Edit a product", PLUGIN_NAME);
?>
Esempio n. 3
0
            $start = \i18nRevDate($_POST['new-startDate']);
        }
        $taxCat = new \Pasteque\TaxCat($_POST['label']);
        $tax = new \Pasteque\Tax(null, $_POST['label-new'], $start, floatval($_POST['rate-new']));
        $taxCat->addTax($tax);
        $taxCatId = \Pasteque\TaxesService::createCat($taxCat);
        if ($taxCatId === false) {
            $error = \i18n("Unable to save tax.", PLUGIN_NAME);
        } else {
            $message = \i18n("Tax saved", PLUGIN_NAME);
        }
    }
}
$taxCat = null;
if (isset($_GET['id'])) {
    $taxCat = \Pasteque\TaxesService::get($_GET['id']);
}
?>
<h1><?php 
\pi18n("Edit tax", PLUGIN_NAME);
?>
</h1>

<?php 
\Pasteque\tpl_msg_box($message, $error);
?>

<!-- Tax category edit -->
<form class="edit" action="<?php 
echo \Pasteque\get_current_url();
?>