J2Store4 / j2store4

J2Store 4 - Open Source eCommerce extension for Joomla
https://www.j2store.org
GNU General Public License v3.0
15 stars 7 forks source link

Bug with solar date #17

Closed mehdininja closed 5 months ago

mehdininja commented 1 year ago

hi , Bug with solar date in j2store

By saving the content, the "start publication" and "created date" will change!

You can see the saved content below.

bbg

video : https://drive.google.com/file/d/19HD8vtEb9RmY0RINrbPnPHvoqpoox88Z/view

I found the problem after hours of trying. The problem was with the codes in the "administrator/components/com_j2store/views/product/tmpl/form.php" file.

I changed the codes as follows and the problem was solved :


<?php
/**
 * @package J2Store
 * @copyright Copyright (c)2014-17 Ramesh Elamathi / J2Store.org
 * @license GNU GPL v3 or later
 */
// No direct access to this file
defined('_JEXEC') or die;
require_once(JPATH_ADMINISTRATOR.'/components/com_j2store/helpers/input.php');
$doc = JFactory::getDocument();
$doc->addStyleSheet(JURI::root(true).'/media/j2store/css/font-awesome.min.css');
$doc->addStyleSheet(JURI::root(true).'/media/j2store/css/j2store_admin.css');
$app = JFactory::getApplication();
$option = $app->input->getString('option');
$platform = J2Store::platform();
$platform->loadExtra('behavior.modal');
$row_class = 'row';
$col_class = 'col-md-';
$product_type_class = 'badge bg-success';
if (version_compare(JVERSION, '3.99.99', 'lt')) {
    $row_class = 'row-fluid';
    $col_class = 'span';
    $product_type_class = 'label label-success';
    $doc->addScriptDeclaration("jQuery(function($) {
    SqueezeBox.initialize({});
    SqueezeBox.assign($('a.modal').get(), {
        parse: 'rel'
    });
});");
}
?>

<div class="j2store">
    <div class="j2store-product-edit-form">

        <div class="<?php echo $row_class;?>">
            <div class="<?php echo $col_class;?><?php echo ($this->item->j2store_product_id) ?'4':'12'; ?>">
                <div class="panel panel-default">
                    <div class="panel-heading">
                        <h3 class="panel-title"><?php echo JText::_('J2STORE_PRODUCT_INFORMATION'); ?></h3>
                    </div>
                    <div class="panel-body">
                        <div class="control-group form-group form-inline" id="j2store-product-enable">
                            <?php echo J2Html::label(JText::_('J2STORE_TREAT_AS_PRODUCT'), 'enabled',array('class'=>'control-label'));?>
                            <?php echo J2Html::radio($this->form_prefix.'[enabled]', $this->item->enabled, array('id'=>'j2store-product-enabled-radio-group', 'class'=>'radio'));?>
                        </div>
                        <div class="control-group form-group" id="j2store-product-type">
                            <?php if(!empty($this->item->product_type)): ?>
                                <?php echo J2Html::label(JText::_('J2STORE_PRODUCT_TYPE'), 'product_type',array('class'=>'control-label')); ?>
                                <span class="<?php echo $product_type_class;?>"><?php echo JText::_('J2STORE_PRODUCT_TYPE_'.strtoupper($this->item->product_type)) ?></span></label>
                                <?php echo J2Html::hidden($this->form_prefix.'[product_type]', $this->item->product_type); ?>
                            <?php else: ?>
                                <?php echo J2Html::label(JText::_('J2STORE_PRODUCT_TYPE'), 'product_type',array('class'=>'control-label')); ?>
                                <div class="controls"><?php echo $this->product_types; ?></div>
                            <?php endif; ?>
                        </div>
                        <?php if(!$this->item->enabled): ?>
                            <!-- Show this only when this was not a product -->
                            <?php if($option == 'com_content' && J2Store::platform()->isClient('administrator')): ?>
                                <div class="control-group form-group">
                                    <input type="button" onclick="Joomla.submitbutton('article.apply')" class="btn btn-large btn-success" value="<?php echo JText::_('J2STORE_SAVE_AND_CONTINUE'); ?>" />
                                </div>
                            <?php endif; ?>
                        <?php endif; ?>

                        <?php if($this->item->j2store_product_id && $this->item->enabled && $this->item->product_type): ?>
                            <div class="j2store-confirm-cont">
                                <a data-fancybox data-src="#j2storeConfirmChange" type="button" class="btn btn-warning" ><?php echo  JText::_('J2STORE_CHANGE_PRODUCT_TYPE');?></a>
                                <!-- here load the confim modal -->
                                <?php echo $this->loadTemplate('confirm_change'); ?>
                            </div>
                        <?php endif; ?>
                    </div>
                </div>
            </div>

            <?php if($this->item->j2store_product_id && $this->item->enabled && $this->item->product_type): ?>
                <div class="<?php echo $col_class;?>7">
                    <div class="panel panel-solid-success">
                        <div class="panel-body">
                            <p class="lead">
                                <?php echo JText::_('J2STORE_PRODUCT_ID'); ?> : <strong><?php echo $this->item->j2store_product_id; ?></strong>
                            </p>
                            <h3><?php echo JText::_('J2STORE_PLUGIN_SHORTCODE')?></h3>
                            <p class="shortcode">
                                {j2store}<?php echo $this->item->j2store_product_id; ?>|cart{/j2store}
                            </p>
                            <small>
                                <?php echo JText::_('J2STORE_PLUGIN_SHORTCODE_HELP_TEXT');?>
                            </small>
                            <br />

                            <span class="pull-right">
                    <button type="button" class="btn btn-small btn-warning"
                            href="javascript:void(0);"
                            onclick="jQuery('#hide-icon-<?php echo $this->item->j2store_product_id;?>').toggle('click');jQuery('#show-icon-<?php echo $this->item->j2store_product_id;?>').toggle('click');jQuery('.additional-short-code').toggle('click');jQuery('.panel-solid-success .panel-footer').toggle('click');">
                        <?php echo JText::_('J2STORE_EXPAND_CLOSE'); ?>
                        <i id="show-icon-<?php echo $this->item->j2store_product_id;?>"
                           class="icon icon-plus"></i> <i
                                id="hide-icon-<?php echo $this->item->j2store_product_id;?>"
                                class="icon icon-minus" style="display: none;"></i>
                    </button>
                </span>
                            <br/>

                            <div class="additional-short-code" style="display: none;">
                                <h4><?php echo JText::_('J2STORE_PLUGIN_SHORTCODE_ADDITIONAL')?></h4>
                                <p>
                                    <?php echo JText::_('J2STORE_PLUGIN_SHORTCODE_HELP_TEXT_ADDITIONAL');?> <strong style="color:black;"> {j2store}<?php echo $this->item->j2store_product_id; ?>|upsells|crosssells{/j2store}</strong>
                                </p>
                                <p class="shortcode">price|thumbnail|mainimage|mainadditional|upsells|crosssells</p>
                            </div>

                        </div>
                        <div class="panel-footer" style="display: none;">
                            <strong>
                                <?php echo JText::_('J2STORE_PLUGIN_SHORTCODE_FOOTER_WARNING');?>
                            </strong>
                        </div>
                    </div>
                </div>
            <?php endif;?>
        </div>
        <input type="hidden" name="<?php echo $this->form_prefix.'[j2store_product_id]'?>" value="<?php echo $this->item->j2store_product_id; ?>" />

        <!-- @TODO should fix with css -->
        <hr>
        <?php if($this->item->j2store_product_id && $this->item->enabled && $this->item->product_type): ?>
            <div class="panel panel-default">
                <div class="panel-body">
                    <?php echo $this->loadTemplate($this->item->product_type); ?>
                    <input type="hidden" name="<?php echo $this->form_prefix.'[product_type]'?>" value="<?php echo $this->item->product_type; ?>" />
                </div>
            </div>
        <?php endif; ?>
    </div> <!--  end of J2Store Product Form -->
</div>
<?php if($this->item->j2store_product_id && $this->item->enabled && $this->item->product_type): ?>
    <script type="text/javascript">

        (function($) {
            $(document).on("click","#j2storeConfirmChange #changeTypeBtn", function(e) {
                $.ajax({
                    url :'index.php?option=com_j2store&view=products&task=changeProductType',
                    type: 'post',
                    data:{'product_id' :<?php echo $this->item->j2store_product_id; ?> ,'product_type' : '<?php echo $this->item->product_type; ?>' },
                    dataType: 'json',
                    beforeSend:function(){
                        $('#changeTypeBtn').html('<i class="icon-spin icon-refresh glyphicon glyphicon-refresh glyphicon-spin"></i> Changing type...');
                    },
                    success: function(json) {
                        if(json['success']){
                            location.reload();
                        }
                    }
                });

            });
            $(document).on("click","#j2storeConfirmChange #closeTypeBtn", function(e) {
                $.fancybox.close();
            });
        })(jQuery);
    </script>
<?php endif;?>
<script type="text/javascript">
    (function($) {
        $(document).ready(function() {
            $("div.j2store-tab-menu>div.list-group>a").click(function(e) {
                e.preventDefault();
                $(this).siblings('a.active').removeClass("active");
                $(this).addClass("active");
                var index = $(this).index();
                $("div.j2store-tab>div.j2store-tab-content").removeClass("active");
                $("div.j2store-tab>div.j2store-tab-content").eq(index).addClass("active");
            });
        });
    })(jQuery);

    (function($) {
        $('#j2store-product-enable').bind('change', function() {
            var enabled = $('#j2store-product-enable input[type=radio]:checked').val();
            if(enabled == 1) {
                $("#j2store-product-type").show();
            }else {
                $("#j2store-product-type").hide();
            }
        });

        $('#j2store-product-enable').trigger('change');

    })(jQuery);

</script>
Thomastomy2001 commented 11 months ago

We examined the following scenario on our website:

scenario 1: Initially, when we created the article, both the publish date and the create date were saved based on the article's creation date. scenario 2: Subsequently, when we made modifications to the article, only the "modify date" was updated. The create and publish dates remained unchanged, displaying the original date of the article's initial creation. Check this reference video:https://nimb.ws/KcAXPR On your site, both the article's creation date and publish date will be automatically updated whenever you edit the article. You can implement the modified code as described earlier, and rest assured, there should be no issues.

mehdininja commented 10 months ago

We examined the following scenario on our website:

scenario 1: Initially, when we created the article, both the publish date and the create date were saved based on the article's creation date. scenario 2: Subsequently, when we made modifications to the article, only the "modify date" was updated. The create and publish dates remained unchanged, displaying the original date of the article's initial creation. Check this reference video:https://nimb.ws/KcAXPR On your site, both the article's creation date and publish date will be automatically updated whenever you edit the article. You can implement the modified code as described earlier, and rest assured, there should be no issues.

hi, Your system date is Gregorian. (2023) My system date is solar. (1402) install Persian Language and set admin language to Persian,Check again.

niaziblog commented 10 months ago

Hello I checked this problem in Persian language and (solar calendar , persian calendar ) the last version 4.0.3 and this problem exists in saving publication date, creation and editing date

mgopin3 commented 5 months ago

@mehdininja We have conducted a thorough review of our website and identified the need to set the administrator language to Persian. In our efforts to make this adjustment, we have meticulously manipulated the product settings and carefully examined the publishing process. We can confirm that the modified date is updating seamlessly without encountering any issues. To provide you with a visual reference, we have prepared a video that demonstrates these steps[video]

mehdininja commented 5 months ago

@mgopin3 start publication (آغاز انتشار) and created date (تاریخ ایجاد) changed to update date . start publication and created date : 1402-10-01 After saving changed to 1402-12-18 If you watch your video carefully, you will see the problem

jjj

jj

mgopin3 commented 5 months ago

@mehdininja Upon reviewing our site in our native language, we've confirmed that the Start Publishing and Created Date functionalities update seamlessly without any issues. However, upon switching the language to Persian, we have identified an issue with these functionalities. Rest assured, we are committed to addressing this matter promptly. We will thoroughly test and resolve this issue in an upcoming release. Thank you for bringing this to our attention.

mgopin3 commented 5 months ago

@mehdininja We believe the reported issue has been addressed. Could you please confirm that the problem is resolved on your end? If everything looks good, we'll go ahead and close this issue.

If you have any further questions or if there's anything else you'd like assistance with, please don't hesitate to let us know. We appreciate your feedback!