0

enter image description here

In credit memo page update total button is not showing after installation of the extension. How to add the update total button in that extension code. Please find the layout and template file in that extension to customize the credit memo page.

sales_order_creditmemo_new.xml Codilar_Gst::order/creditmemo/create/items.phtml

    <referenceBlock name="order_items.default">
         <action method="setTemplate" ifconfig="gst/codilar/status">
            <argument name="template" xsi:type="string">Codilar_Gst::order/creditmemo/create/items/renderer/default.phtml</argument>
        </action>
    </referenceBlock>

    <referenceBlock name="tax">
        <action method="setTemplate" ifconfig="gst/codilar/status">
            <argument name="template" xsi:type="string">Codilar_Gst::order/totals/tax.phtml</argument>
        </action>
    </referenceBlock>
</body>

items.phtml

<?php
/**
 * Copyright © 2013-2017 Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

// @codingStandardsIgnoreFile

?>
<?php
/**
 *
 * @var $_gstHelper \Codilar\Gst\Helper\Data
 */
$_gstHelper = $this->helper('Codilar\Gst\Helper\Data');
$productionState = $_gstHelper->getProductionState();
$moduleStatus = $_gstHelper->getModuleStatus();
$_items = $block->getCreditmemo()->getAllItems();
$_order = $block->getOrder();
$productionState = str_replace(' ', '', strtolower($productionState));
$orderDate = $_order->getCreatedAt();
$orderDate = date_create($orderDate);
$date = "2017-06-30 11:59:59";
$gstDate=date_create($date);
$gstOrderStatus = false;
if($gstDate < $orderDate){
    $gstOrderStatus = true;
}
$state = $_order->getShippingAddress()->getRegion();
$state = str_replace(' ', '', strtolower($state));
?>

<section class="admin__page-section">
    <div class="admin__page-section-title">
        <span class="title"><?php /* @escapeNotVerified */ echo __('Items to Refund') ?></span>
    </div>

    <?php if (count($_items)) : ?>
        <div class="admin__table-wrapper">
            <table class="data-table admin__table-primary order-creditmemo-tables">
                <thead>
                <tr class="headings">
                    <th class="col-product"><span><?php /* @escapeNotVerified */ echo __('Product') ?></span></th>
                   <!-- <?php if($moduleStatus): ?>
                        <th class="col-hsn"><span><?php /* @escapeNotVerified */ echo __('HSN') ?></span></th>
                    <?php endif; ?>-->
                    <th class="col-price"><span><?php /* @escapeNotVerified */ echo __('Price') ?></span></th>
                    <th class="col-ordered-qty"><span><?php /* @escapeNotVerified */ echo __('Qty') ?></span></th>
                    <?php if ($block->canReturnToStock()) : ?>
                        <th class="col-return-to-stock"><span><?php /* @escapeNotVerified */ echo __('Return to Stock') ?></span></th>
                    <?php endif; ?>
                    <th class="col-refund"><span><?php /* @escapeNotVerified */ echo __('Qty to Refund') ?></span></th>
                    <th class="col-subtotal"><span><?php /* @escapeNotVerified */ echo __('Subtotal') ?></span></th>
                    <?php if(($state==$productionState) && $gstOrderStatus && $moduleStatus): ?>
                        <th class="col-sgst"><span><?php /* @escapeNotVerified */ echo __('SGST') ?></span></th>
                        <th class="col-cgst"><span><?php /* @escapeNotVerified */ echo __('CGST') ?></span></th>
                    <?php elseif($gstOrderStatus && $moduleStatus): ?>
                        <th class="col-igst"><span><?php /* @escapeNotVerified */ echo __('IGST') ?></span></th>
                    <?php elseif($moduleStatus): ?>
                        <th class="col-tax"><span><?php /* @escapeNotVerified */ echo __('Tax Amount') ?></span></th>
                    <?php else: ?>
                        <th class="col-tax custom"><span><?php /* @escapeNotVerified */ echo __('GST Amount') ?></span></th>
                    <?php endif; ?>
                    <th class="col-discont"><span><?php /* @escapeNotVerified */ echo __('Discount Amount') ?></span></th>
                    <th class="col-total last"><span><?php /* @escapeNotVerified */ echo __('Row Total') ?></span></th>
                </tr>
                </thead>
                <?php if ($block->canEditQty()): ?>
                    <tfoot>
                    <tr>
                        <td colspan="3">&nbsp;</td>
                        <td colspan="3">
                            <?php echo $block->getUpdateButtonHtml() ?>
                        </td>
                        <td colspan="3" class="last">&nbsp;</td>
                    </tr>
                    </tfoot>
                <?php endif; ?>
                <?php $i = 0; foreach ($_items as $_item): ?>
                    <?php if ($_item->getOrderItem()->getParentItem()) {
                        continue;
                    } else {
                        $i++;
                    } ?>
                    <tbody class="<?php /* @escapeNotVerified */ echo $i%2 ? 'even' : 'odd' ?>">
                    <?php echo $block->getItemHtml($_item) ?>
                    <?php echo $block->getItemExtraInfoHtml($_item->getOrderItem()) ?>
                    </tbody>
                <?php endforeach; ?>
            </table>
        </div>
    <?php else : ?>
        <div class="no-items">
            <?php /* @escapeNotVerified */ echo __('No Items To Refund') ?>
        </div>
    <?php endif; ?>
</section>


<?php $orderTotalBar = $block->getChildHtml('order_totalbar'); ?>
<?php if (!empty($orderTotalBar)): ?>
    <section class="fieldset-wrapper">
        <?php /* @escapeNotVerified */ echo $orderTotalBar; ?>
    </section>
<?php endif; ?>

<section class="admin__page-section">
    <input type="hidden" name="creditmemo[do_offline]" id="creditmemo_do_offline" value="0" />
    <div class="admin__page-section-title">
        <span class="title"><?php /* @escapeNotVerified */ echo __('Order Total') ?></span>
    </div>
    <div class="admin__page-section-content">
        <div class="admin__page-section-item order-comments-history">
            <div class="admin__page-section-item-title">
                <span class="title"><?php /* @escapeNotVerified */ echo __('Credit Memo Comments') ?></span>
            </div>
            <div id="history_form" class="admin__fieldset-wrapper-content">
                <div class="admin__field">
                    <label class="normal admin__field-label"
                           for="creditmemo_comment_text">
                        <span><?php /* @escapeNotVerified */ echo __('Comment Text') ?></span></label>
                    <div class="admin__field-control">
                        <textarea id="creditmemo_comment_text"
                                  class="admin__control-textarea"
                                  name="creditmemo[comment_text]"
                                  rows="3"
                                  cols="5"><?php /* @escapeNotVerified */ echo $block->getCreditmemo()->getCommentText(); ?></textarea>
                    </div>
                </div>
            </div>
        </div>
        <div class="admin__page-section-item order-totals creditmemo-totals">
            <div class="admin__page-section-item-title">
                <span class="title"><?php /* @escapeNotVerified */ echo __('Refund Totals') ?></span>
            </div>
            <?php echo $block->getChildHtml('creditmemo_totals') ?>
            <div class="order-totals-actions">
                <div class="field choice admin__field admin__field-option field-append-comments">
                    <input id="notify_customer"
                           class="admin__control-checkbox"
                           name="creditmemo[comment_customer_notify]"
                           value="1"
                           type="checkbox" />
                    <label for="notify_customer" class="admin__field-label">
                        <span><?php /* @escapeNotVerified */ echo __('Append Comments') ?></span>
                    </label>
                </div>
                <?php if ($block->canSendCreditmemoEmail()):?>
                    <div class="field choice admin__field admin__field-option field-email-copy">
                        <input id="send_email"
                               class="admin__control-checkbox"
                               name="creditmemo[send_email]"
                               value="1"
                               type="checkbox" />
                        <label for="send_email" class="admin__field-label">
                            <span><?php /* @escapeNotVerified */ echo __('Email Copy of Credit Memo') ?></span>
                        </label>
                    </div>
                <?php endif; ?>
                <?php echo $block->getChildHtml('submit_before') ?>
                <div class="actions">
                    <?php echo $block->getChildHtml('submit_offline') ?>
                    <?php echo $block->getChildHtml('submit_button') ?>
                    <?php echo $block->getChildHtml('submit_after') ?>
                </div>
            </div>
        </div>
    </div>
</section>

<script>
    require(['jquery', 'prototype'], function(jQuery){

//<![CDATA[
        var submitButtons = $$('.submit-button');
        var updateButtons = $$('.update-button');
        var fields = $$('.qty-input');

        updateButtons.each(function (elem) {elem.disabled=true;elem.addClassName('disabled');});

        for(var i=0;i<fields.length;i++){
            fields[i].observe('change', checkButtonsRelation)
            fields[i].baseValue = fields[i].value;
        }

        function checkButtonsRelation() {
            var hasChanges = false;
            fields.each(function (elem) {
                if (elem.baseValue != elem.value) {
                    hasChanges = true;
                }
            }.bind(this));
            if (hasChanges) {
                submitButtons.each(function (elem) {elem.disabled=true;elem.addClassName('disabled');});
                updateButtons.each(function (elem) {elem.disabled=false;elem.removeClassName('disabled');});
            }
            else {
                submitButtons.each(function (elem) {elem.disabled=false;elem.removeClassName('disabled');});
                updateButtons.each(function (elem) {elem.disabled=true;elem.addClassName('disabled');});
            }
        }

        submitCreditMemo = function() {
            if ($('creditmemo_do_offline')) $('creditmemo_do_offline').value=0;
            // Temporary solution will be replaced after refactoring order functionality
            jQuery('#edit_form').triggerHandler('save');
        }

        submitCreditMemoOffline = function() {
            if ($('creditmemo_do_offline')) $('creditmemo_do_offline').value=1;
            // Temporary solution will be replaced after refactoring order functionality
            jQuery('#edit_form').triggerHandler('save');
        }

        var sendEmailCheckbox = $('send_email');

        if (sendEmailCheckbox) {
            var notifyCustomerCheckbox = $('notify_customer');
            var creditmemoCommentText = $('creditmemo_comment_text');
            Event.observe(sendEmailCheckbox, 'change', bindSendEmail);
            bindSendEmail();
        }

        function bindSendEmail()
        {
            if (sendEmailCheckbox.checked == true) {
                notifyCustomerCheckbox.disabled = false;
                //creditmemoCommentText.disabled = false;
            }
            else {
                notifyCustomerCheckbox.disabled = true;
                //creditmemoCommentText.disabled = true;
            }
        }

        window.bindSendEmail = bindSendEmail;
        window.checkButtonsRelation = checkButtonsRelation;
//]]>

    });
</script>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.