diff --git a/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php b/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php new file mode 100644 index 000000000..2b8c22332 --- /dev/null +++ b/addons/default/visiosoft/advs-module/migrations/2020_07_20_112724_visiosoft.module.advs__create_standard_price_field.php @@ -0,0 +1,52 @@ + 'advs', + ]; + + /** + * The addon fields. + * + * @var array + */ + protected $fields = [ + 'standard_price' => [ + 'type' => 'visiosoft.field_type.decimal', + 'config' => [ + 'decimal' => 2, + 'separator' => '.', + 'point' => ',' + ], + ], + ]; + + /** + * The field's assignment. + * + * @var array + */ + protected $assignments = [ + 'standard_price' => [ + 'required' => true + ], + ]; + +} diff --git a/addons/default/visiosoft/advs-module/resources/css/detail.css b/addons/default/visiosoft/advs-module/resources/css/detail.css index ff8130448..7a3247d9a 100644 --- a/addons/default/visiosoft/advs-module/resources/css/detail.css +++ b/addons/default/visiosoft/advs-module/resources/css/detail.css @@ -3,6 +3,16 @@ border-color: #ffc107 #ffc107 #ffc107; } +.ad-price-standard { + color: #f00; + text-decoration: line-through; +} + +.ad-price-standard-percentage { + background-color: #f00; + font-size: 16px; +} + /* Pending screen */ .pending-screen { background-color: #f2f2f2; @@ -13,4 +23,4 @@ } .pending-screen p { font-weight: 500; -} \ No newline at end of file +} diff --git a/addons/default/visiosoft/advs-module/resources/js/new-create.js b/addons/default/visiosoft/advs-module/resources/js/new-create.js index d19fcca5a..9feff947b 100644 --- a/addons/default/visiosoft/advs-module/resources/js/new-create.js +++ b/addons/default/visiosoft/advs-module/resources/js/new-create.js @@ -187,7 +187,7 @@ $(document).ready(function () { }); $(document).ready(function () { - $(".priceField").inputmask('currency', { + $(".priceField, .standard-price-field").inputmask('currency', { rightAlign: true, prefix: "", 'groupSeparator': '.', @@ -200,7 +200,7 @@ $(document).ready(function () { }); - $(".priceDecimalField").inputmask('99', { + $(".priceDecimalField, .standard-price-decimal-field").inputmask('99', { rightAlign: true, prefix: "", autoUnmask: true, @@ -210,11 +210,15 @@ $(document).ready(function () { }); - $(".priceField, .priceDecimalField").on('change', function () { + $(".priceField, .priceDecimalField, .standard-price-field, .standard-price-decimal-field").on('change', function () { let price = $(".priceField").val() === "" ? '0' : $(".priceField").val(); + let standardPrice = $(".standard-price-field").val() === "" ? '0' : $(".standard-price-field").val(); price = parseInt(price.replace(/\./g, '')); + standardPrice = parseInt(standardPrice.replace(/\./g, '')); let decimal = parseInt($(".priceDecimalField").val()); + let standardDecimal = parseInt($(".standard-price-decimal-field").val()); $('.priceHidden').find('input').val(parseFloat(price + "." + decimal)); + $('.standard-price-hidden').find('input').val(parseFloat(standardPrice + "." + standardDecimal)); }); // Add dynamic option creation diff --git a/addons/default/visiosoft/advs-module/resources/lang/en/field.php b/addons/default/visiosoft/advs-module/resources/lang/en/field.php index cdb991641..2b46853c5 100644 --- a/addons/default/visiosoft/advs-module/resources/lang/en/field.php +++ b/addons/default/visiosoft/advs-module/resources/lang/en/field.php @@ -19,6 +19,9 @@ return [ 'price' => [ 'name' => 'Price' ], + 'standard_price' => [ + 'name' => 'Standard Price' + ], 'date' => [ 'name' => 'Date' ], diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig index 5b7b06c34..761abb50b 100644 --- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig +++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/detail.twig @@ -4,6 +4,10 @@ {% include "visiosoft.module.advs::ad-detail/partials/ogdata" %} {% endblock %} +{% block styles %} + {{ asset_style("visiosoft.module.advs::css/detail.css") }} +{% endblock %} + {% block content %}
@@ -52,6 +56,5 @@
{{ asset_add("scripts.js", "visiosoft.module.advs::js/viewed.js") }} - {{ asset_add("styles.css", "visiosoft.module.advs::css/detail.css") }} {% endblock %} \ No newline at end of file diff --git a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig index 5a5c3e1b7..efd963ad9 100644 --- a/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig +++ b/addons/default/visiosoft/advs-module/resources/views/ad-detail/partials/detail.twig @@ -1,5 +1,16 @@
+ {% set standardPrice = adv.standard_price.value %} + {% if standardPrice %} +
+

+ {{ adv.standard_price.currency(null,'currency') }} +

+

+ %{{ (100 - ((100 * adv.price.value) / adv.standard_price.value))|round(0, 'common') }} +

+
+ {% endif %}

{{ adv.price.currency(null,'currency') }} diff --git a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig index 5f36bdd84..7556dbd69 100644 --- a/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig +++ b/addons/default/visiosoft/advs-module/resources/views/new-ad/new-create.twig @@ -59,6 +59,27 @@

{{ addBlock('new-ad/fields',{'adv':adv})|raw }} + +
+ +
+ {{ form.fields.standard_price.setAttributes({ + 'required' :true + }).input|raw }} +
+ {% set standardPriceValue = form.fields.standard_price.value|split('.') %} +
+ +
+
+ +
+
+