<commit_before><?php
defined('C5_EXECUTE') or die("Access Denied.");

use \Concrete\Core\Support\Facade\Url;
use \Concrete\Core\Support\Facade\Config;
use \Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product as StoreProduct;
use \Concrete\Core\Page\Page;

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$listViews = ['view', 'updated', 'removed', 'success'];
$addViews = ['add', 'edit', 'save'];
$attributeViews = ['attributes', 'attributeadded', 'attributeremoved'];
$ps = $app->make('helper/form/page_selector');

?>

<?php if (in_array($controller->getAction(), $addViews)) { //if adding or editing a product
    if (!is_object($product)) {
        $product = new StoreProduct();
        $product->setIsUnlimited(true);
        $product->setIsTaxable(true);
        $product->setIsShippable(true);
    } else {
        $images = $product->getImages();
        $options = $product->getOptions();
        $locationPages = $product->getLocationPages();
        $pgroups = $product->getGroupIDs();
    }

    $pID = $product->getID()
    ?>

    <?php if ($pID > 0) { ?>
        <div class="ccm-dashboard-header-buttons">

            <form class="pull-right" method="post" id="delete" action="<?= Url::to('/dashboard/store/products/delete/', $pID) ?>">
                <?= $token->output('community_store'); ?>&nbsp;
                <button class="btn btn-danger"><?= t("Delete Product") ?></button>
            </form>

            <form class="pull-right" method="get" id="duplicate" action="<?= Url::to('/dashboard/store/products/duplicate/', $pID) ?>">
                <button class="btn btn-default"><?= t("Duplicate Product") ?></button>
            </form>


            <script type="text/javascript">
                $(function () {
                    $('#delete').submit(function () {
                        return confirm('<?=  t("Are you sure you want to delete this product?"); ?>');
                    });
                });
            </script>
        </div>
    <?php } ?>

    <form method="post" action="<?= $view->action('save') ?>">
        <?= $token->output('community_store'); ?>
        <input type="hidden" name="pID" value="<?= $product->getID() ?>"/>

        <div class="row">
            <div class="col-sm-3">
                <ul class="nav nav-pills nav-stacked">
                    <li class="active"><a href="#product-overview" data-pane-toggle><?= t('Overview') ?></a></li>
                    <li><a href="#product-categories" data-pane-toggle><?= t('Categories and Groups') ?></a></li>
                    <li><a href="#product-shipping" data-pane-toggle><?= t('Shipping') ?></a></li>
                    <li><a href="#product-images" data-pane-toggle><?= t('Images') ?></a></li>
                    <li><a href="#product-options" data-pane-toggle><?= t('Options and Variations') ?></a></li>
                    <li><a href="#product-related" data-pane-toggle><?= t('Related Products') ?></a></li>
                    <li><a href="#product-attributes" data-pane-toggle><?= t('Attributes') ?></a></li>
                    <li><a href="#product-digital" data-pane-toggle><?= t("Downloads and User Groups") ?></a></li>
                    <li><a href="#product-checkout" data-pane-toggle><?= t("Checkout Options") ?></a></li>
                    <li><a href="#product-page" data-pane-toggle><?= t('Detail Page') ?></a></li>
                </ul>
            </div>

            <div class="col-sm-9" id="product-header">
                <div class="row">
                    <div class="col-xs-8">
                        <div class="form-group">
                            <?= $form->label("pName", t("Product Name")); ?>
                            <?= $form->text("pName", $product->getName(), ['required' => 'required']); ?>
                        </div>
                    </div>
                    <div class="col-xs-4">
                        <div class="form-group">
                            <?= $form->label("pSKU", t("Code / SKU")); ?>
                            <?= $form->text("pSKU", $product->getSKU()); ?>
                        </div>
                    </div>
                </div>
                <hr/>
            </div>


            <div class="col-sm-9 store-pane active" id="product-overview">
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pManufacturer", t("Brand / Manufacturer")); ?>
                            <?= $form->select('pManufacturer', $manufacturers, $product->getManufacturer() ? $product->getManufacturer()->getID() : '',  ['class' => 'selectize']); ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pBarcode", t("Barcode")); ?>
                            <?= $form->text("pBarcode", $product->getBarcode()); ?>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pActive", t("Active")); ?>
                            <?= $form->select("pActive", ['1' => t('Active'), '0' => t('Inactive')], $product->isActive() ? '1' : '0'); ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pFeatured", t("Featured Product")); ?>
                            <?= $form->select("pFeatured", ['0' => t('No'), '1' => t('Yes')], $product->isFeatured() ? '1' : '0'); ?>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?php
                            $priceclass = 'nonpriceentry';
                            $defaultpriceclass = 'priceentry';
                            if ($product->allowCustomerPrice()) {
                                $priceclass .= ' hidden';
                            } else {
                                $defaultpriceclass .= ' hidden';
                            }
                            ?>
                            <?= $form->label("pPrice", t("Price"), ['class' => $priceclass]); ?>
                            <?= $form->label("pPrice", t("Default Price"), ['class' => $defaultpriceclass]); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $price = $product->getBasePrice(); ?>
                                <?= $form->text("pPrice", $price, ['placeholder' => ($product->allowCustomerPrice() ? t('No Price Set') : '')]); ?>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group nonpriceentry <?= ($product->allowCustomerPrice() ? 'hidden' : ''); ?>">
                            <?= $form->label("pSalePrice", t("Sale Price"), ['class' => $priceclass]); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $salePrice = $product->getSalePrice(); ?>
                                <?= $form->text("pSalePrice", $salePrice, ['placeholder' => 'No Sale Price Set']); ?>
                            </div>
                        </div>
                        <div class="form-group priceentry <?= ($product->allowCustomerPrice() ? '' : 'hidden'); ?>">
                            <?= $form->label('pPriceSuggestions', t('Price Suggestions')) ?>
                            <?= $form->text('pPriceSuggestions', $product->getPriceSuggestions(), ['placeholder' => 'e.g. 10,20,30']) ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group nonpriceentry <?= ($product->allowCustomerPrice() ? 'hidden' : '');?>">
                            <?= $form->label("pWholesalePrice", t("Wholesale Price"), array('class'=>$priceclass));?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol');?>
                                </div>
                                <?php $wholesalePrice = $product->getWholesalePrice(); ?>
                                <?= $form->text("pWholesalePrice", $wholesalePrice, array('placeholder'=>'No Wholesale Price Set'));?>
                            </div>
                        </div>
                    </div>

                    <script>
                        $(document).ready(function () {
                            $('#pCustomerPrice').change(function () {
                                if ($(this).prop('checked')) {
                                    $('.priceentry').removeClass('hidden');
                                    $('.nonpriceentry').addClass('hidden');
                                } else {
                                    $('.priceentry').addClass('hidden');
                                    $('.nonpriceentry').removeClass('hidden');
                                }
                            });
                        });
                    </script>

                </div>
                <div class="row priceentry <?= ($product->allowCustomerPrice() ? '' : 'hidden'); ?>">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pPriceMinimum", t("Minimum Price")); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $minimumPrice = $product->getPriceMinimum(); ?>
                                <?= $form->text("pPriceMinimum", $minimumPrice, ['placeholder' => 'No Minimum Price Set']); ?>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pPriceMaximum", t("Maximum Price")); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $maximumPrice = $product->getPriceMaximum(); ?>
                                <?= $form->text("pPriceMaximum", $maximumPrice, ['placeholder' => 'No Maximum Price Set']); ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->checkbox('pCustomerPrice', '1', $product->allowCustomerPrice()) ?>
                            <?= $form->label('pCustomerPrice', t('Allow customer to enter price')) ?>
                        </div>
                    </div>

                </div>

                <div class="row">

                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->checkbox('pQuantityPrice', '1', $product->hasQuantityPrice()) ?>
                            <?= $form->label('pQuantityPrice', t('Quantity based pricing')) ?>
                        </div>

                    </div>

                    <div id="tieredoptionscontainer" class="col-xs-12  <?= $product->hasQuantityPrice() ? '' : 'hidden' ?>">

                        <div id="tierscontainer">
                            <div class="row">
                                <div class="col-xs-3"><strong><?= t('From'); ?></strong></div>
                                <div class="col-xs-3"><strong><?= t('To'); ?></strong></div><commit_msg>Update products.php (#486)<commit_after><?php
defined('C5_EXECUTE') or die("Access Denied.");

use \Concrete\Core\Support\Facade\Url;
use \Concrete\Core\Support\Facade\Config;
use \Concrete\Package\CommunityStore\Src\CommunityStore\Product\Product as StoreProduct;
use \Concrete\Core\Page\Page;

$app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
$listViews = ['view', 'updated', 'removed', 'success'];
$addViews = ['add', 'edit', 'save'];
$attributeViews = ['attributes', 'attributeadded', 'attributeremoved'];
$ps = $app->make('helper/form/page_selector');

?>

<?php if (in_array($controller->getAction(), $addViews)) { //if adding or editing a product
    if (!is_object($product)) {
        $product = new StoreProduct();
        $product->setIsUnlimited(true);
        $product->setIsTaxable(true);
        $product->setIsShippable(true);
    } else {
        $images = $product->getImages();
        $options = $product->getOptions();
        $locationPages = $product->getLocationPages();
        $pgroups = $product->getGroupIDs();
    }

    $pID = $product->getID()
    ?>

    <?php if ($pID > 0) { ?>
        <div class="ccm-dashboard-header-buttons">

            <form class="pull-right" method="post" id="delete" action="<?= Url::to('/dashboard/store/products/delete/', $pID) ?>">
                <?= $token->output('community_store'); ?>&nbsp;
                <button class="btn btn-danger"><?= t("Delete Product") ?></button>
            </form>

            <form class="pull-right" method="get" id="duplicate" action="<?= Url::to('/dashboard/store/products/duplicate/', $pID) ?>">
                <button class="btn btn-default"><?= t("Duplicate Product") ?></button>
            </form>


            <script type="text/javascript">
                $(function () {
                    $('#delete').submit(function () {
                        return confirm('<?=  t("Are you sure you want to delete this product?"); ?>');
                    });
                });
            </script>
        </div>
    <?php } ?>

    <form method="post" action="<?= $view->action('save') ?>">
        <?= $token->output('community_store'); ?>
        <input type="hidden" name="pID" value="<?= $product->getID() ?>"/>

        <div class="row">
            <div class="col-sm-3">
                <ul class="nav nav-pills nav-stacked">
                    <li class="active"><a href="#product-overview" data-pane-toggle><?= t('Overview') ?></a></li>
                    <li><a href="#product-categories" data-pane-toggle><?= t('Categories and Groups') ?></a></li>
                    <li><a href="#product-shipping" data-pane-toggle><?= t('Shipping') ?></a></li>
                    <li><a href="#product-images" data-pane-toggle><?= t('Images') ?></a></li>
                    <li><a href="#product-options" data-pane-toggle><?= t('Options and Variations') ?></a></li>
                    <li><a href="#product-related" data-pane-toggle><?= t('Related Products') ?></a></li>
                    <li><a href="#product-attributes" data-pane-toggle><?= t('Attributes') ?></a></li>
                    <li><a href="#product-digital" data-pane-toggle><?= t("Downloads and User Groups") ?></a></li>
                    <li><a href="#product-checkout" data-pane-toggle><?= t("Checkout Options") ?></a></li>
                    <li><a href="#product-page" data-pane-toggle><?= t('Detail Page') ?></a></li>
                </ul>
            </div>

            <div class="col-sm-9" id="product-header">
                <div class="row">
                    <div class="col-xs-8">
                        <div class="form-group">
                            <?= $form->label("pName", t("Product Name")); ?>
                            <?= $form->text("pName", $product->getName(), ['required' => 'required']); ?>
                        </div>
                    </div>
                    <div class="col-xs-4">
                        <div class="form-group">
                            <?= $form->label("pSKU", t("Code / SKU")); ?>
                            <?= $form->text("pSKU", $product->getSKU()); ?>
                        </div>
                    </div>
                </div>
                <hr/>
            </div>


            <div class="col-sm-9 store-pane active" id="product-overview">
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pManufacturer", t("Brand / Manufacturer")); ?>
                            <?= $form->select('pManufacturer', $manufacturers, $product->getManufacturer() ? $product->getManufacturer()->getID() : '',  ['class' => 'selectize']); ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pBarcode", t("Barcode")); ?>
                            <?= $form->text("pBarcode", $product->getBarcode()); ?>
                        </div>
                    </div>
                </div>

                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pActive", t("Active")); ?>
                            <?= $form->select("pActive", ['1' => t('Active'), '0' => t('Inactive')], $product->isActive() ? '1' : '0'); ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pFeatured", t("Featured Product")); ?>
                            <?= $form->select("pFeatured", ['0' => t('No'), '1' => t('Yes')], $product->isFeatured() ? '1' : '0'); ?>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?php
                            $priceclass = 'nonpriceentry';
                            $defaultpriceclass = 'priceentry';
                            if ($product->allowCustomerPrice()) {
                                $priceclass .= ' hidden';
                            } else {
                                $defaultpriceclass .= ' hidden';
                            }
                            ?>
                            <?= $form->label("pPrice", t("Price"), ['class' => $priceclass]); ?>
                            <?= $form->label("pPrice", t("Default Price"), ['class' => $defaultpriceclass]); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $price = $product->getBasePrice(); ?>
                                <?= $form->text("pPrice", $price, ['placeholder' => ($product->allowCustomerPrice() ? t('No Price Set') : '')]); ?>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group nonpriceentry <?= ($product->allowCustomerPrice() ? 'hidden' : ''); ?>">
                            <?= $form->label("pSalePrice", t("Sale Price"), ['class' => $priceclass]); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $salePrice = $product->getSalePrice(); ?>
                                <?= $form->text("pSalePrice", $salePrice, ['placeholder' => t('No Sale Price Set')]); ?>
                            </div>
                        </div>
                        <div class="form-group priceentry <?= ($product->allowCustomerPrice() ? '' : 'hidden'); ?>">
                            <?= $form->label('pPriceSuggestions', t('Price Suggestions')) ?>
                            <?= $form->text('pPriceSuggestions', $product->getPriceSuggestions(), ['placeholder' => t('e.g. 10,20,30')]) ?>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group nonpriceentry <?= ($product->allowCustomerPrice() ? 'hidden' : '');?>">
                            <?= $form->label("pWholesalePrice", t("Wholesale Price"), array('class'=>$priceclass));?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol');?>
                                </div>
                                <?php $wholesalePrice = $product->getWholesalePrice(); ?>
                                <?= $form->text("pWholesalePrice", $wholesalePrice, array('placeholder'=>t('No Wholesale Price Set')));?>
                            </div>
                        </div>
                    </div>

                    <script>
                        $(document).ready(function () {
                            $('#pCustomerPrice').change(function () {
                                if ($(this).prop('checked')) {
                                    $('.priceentry').removeClass('hidden');
                                    $('.nonpriceentry').addClass('hidden');
                                } else {
                                    $('.priceentry').addClass('hidden');
                                    $('.nonpriceentry').removeClass('hidden');
                                }
                            });
                        });
                    </script>

                </div>
                <div class="row priceentry <?= ($product->allowCustomerPrice() ? '' : 'hidden'); ?>">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pPriceMinimum", t("Minimum Price")); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $minimumPrice = $product->getPriceMinimum(); ?>
                                <?= $form->text("pPriceMinimum", $minimumPrice, ['placeholder' => t('No Minimum Price Set')]); ?>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->label("pPriceMaximum", t("Maximum Price")); ?>
                            <div class="input-group">
                                <div class="input-group-addon">
                                    <?= Config::get('community_store.symbol'); ?>
                                </div>
                                <?php $maximumPrice = $product->getPriceMaximum(); ?>
                                <?= $form->text("pPriceMaximum", $maximumPrice, ['placeholder' => t('No Maximum Price Set')]); ?>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="row">
                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->checkbox('pCustomerPrice', '1', $product->allowCustomerPrice()) ?>
                            <?= $form->label('pCustomerPrice', t('Allow customer to enter price')) ?>
                        </div>
                    </div>

                </div>

                <div class="row">

                    <div class="col-xs-6">
                        <div class="form-group">
                            <?= $form->checkbox('pQuantityPrice', '1', $product->hasQuantityPrice()) ?>
                            <?= $form->label('pQuantityPrice', t('Quantity based pricing')) ?>
                        </div>

                    </div>

                    <div id="tieredoptionscontainer" class="col-xs-12  <?= $product->hasQuantityPrice() ? '' : 'hidden' ?>">

                        <div id="tierscontainer">
                            <div class="row">
                                <div class="col-xs-3"><strong><?= t('From'); ?></strong></div>
                                <div class="col-xs-3"><strong><?= t('To'); ?></strong></div>
{'fraction_non_alphanumeric': 0.18009404388714734, 'fraction_numerical': 0.003095611285266458, 'mean_word_length': 1.2469624933967247, 'pattern_counts': {'":': 0, '<': 469, '<?xml version=': 0, '>': 635, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 34, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5028443', 'n_tokens_mistral': 6630, 'n_tokens_neox': 6308, 'n_words': 1075}