0

Why Cant I click enter image description here

if im creating a new Quote, but if the will edit the save quote, it will be functional. Here is my file code.

public function __construct()
{
    parent::__construct();

    $this->_objectId = 'id';
    $this->_blockGroup = 'quotation';
    $this->_controller = 'adminhtml_quotation';

    $this->_updateButton('save', 'label', Mage::helper('quotation')->__('Save Quote'));
    $this->_updateButton('delete', 'label', Mage::helper('quotation')->__('Delete Quote'));

    $this->_addButton('saveandcontinue', array(
        'label'     => Mage::helper('adminhtml')->__('Save && Continue Edit'),
        'onclick'   => 'saveandcon()',
        'class'     => 'save',
    ), -100);


    $this->_formScripts[] = "
        function toggleEditor() {
            if (tinyMCE.getInstanceById('quotation_content') == null) {
                tinyMCE.execCommand('mceAddControl', false, 'quotation_content');
            } else {
                tinyMCE.execCommand('mceRemoveControl', false, 'quotation_content');
            }
        }

        function saveandcon(){
            var edit_form = " . $this->getRequest()->getParam("id") . ";
            editForm.submit($('edit_form').action+'back/1/');
        }

public function getHeaderText()
{
    if( Mage::registry('quotation_data') && Mage::registry('quotation_data')->getId() ) {
        return Mage::helper('quotation')->__("Edit Sales Quote '%s'", $this->htmlEscape(Mage::registry('quotation_data')->getQuoteNumber()));
    } else {
        return Mage::helper('quotation')->__('Create new Sales Quotation');
    }
}

Now what should I need to do it properly.

Here is my controller file.

public function saveAction() {
    $data = $this->getRequest()->getPost();
    $qbill = $this->getRequest()->getPost('bill_street');
    $qship = $this->getRequest()->getPost('ship_street');
    $qnote = $this->getRequest()->getPost('salesquotenotes');
    $groupid = $this->getRequest()->getPost('quote_custgroupid');
    $storeid = $this->getRequest()->getPost('quote_store_id');

    if ($data) {

        $model = Mage::getModel('quotation/quotation');
        $model->setData($data)
                ->setId($this->getRequest()->getParam('id'));
        $model->setBillStreet($qbill[0] . ' ' . ($qbill[1] ? $qbill[1] : '') );
        $model->setShipStreet($qship[0] . ' ' . ($qship[1] ? $qship[1] : '') );
        $model->setQuoteNotes($qnote);
        $model->setQuoteCustgroupid($groupid);
        $model->setQuoteStoreId($storeid);

        try {
            /*if ($model->getCreatedTime == NULL || $model->getUpdateTime() == NULL) {
                    $model->setCreatedTime(now())
                            ->setUpdateTime(now());
            } else {
                    $model->setUpdateTime(now());
            }*/

            $c = $this->getRequest()->getPost('add_product');
            $productsToAdd = $this->_decodeInput($c);

            foreach($productsToAdd as $key => $value)
            {
                $product_id = $key;

                $product = mage::getModel('catalog/product')->load($product_id);

                $quotationItem = Mage::getModel('quotation/quotation_items');
                $quotationItem->setQuotationId($this->getRequest()->getParam('id'));
                $quotationItem->setItemId($product_id);
                $quotationItem->setSku($product->getSku());
                $quotationItem->setName($product->getName());
                $quotationItem->setQty(1);
                if ($product->getSpecialPrice() > 0) {
                    $quotationItem->setUnitPrice($product->getSpecialPrice());
                }
                else {
                    $quotationItem->setUnitPrice($product->getPrice());
                }
                $quotationItem->setWeight($product->getWeight());
                $quotationItem->setTaxClassId($product->getTaxClassId());
                $model->addItem($quotationItem);
            }

            $model->save();

            if ($this->getRequest()->getParam('back')) {
                $this->_redirect('*/*/edit', array('id' => $model->getId()));
                return;
            }
            else {
                Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('quotation')->__('Quotation was successfully saved'));
                Mage::getSingleton('adminhtml/session')->setFormData(false);

            }
            $this->_redirect('*/*/');
            return;
        } catch (Exception $e) {
            Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
            Mage::getSingleton('adminhtml/session')->setFormData($data);
            $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
            return;
        }
    }
    Mage::getSingleton('adminhtml/session')->addError(Mage::helper('quotation')->__('Unable to find item to save'));
    $this->_redirect('*/*/');
}

Here is my form.php

protected function _prepareForm()


{
  $form = new Varien_Data_Form(array(
                                  'id' => 'edit_form',
                                  'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
                                  'method' => 'post',
                                  'enctype' => 'multipart/form-data'
                               )
  );
  $form->setUseContainer(true);
  $this->setForm($form);
  return parent::_prepareForm();

}

0

Edit your _construct function

public function __construct()
{
    parent::__construct();

    $this->_objectId = 'id';
    $this->_blockGroup = 'quotation';
    $this->_controller = 'adminhtml_quotation';

    $this->_updateButton('save', 'label', Mage::helper('quotation')->__('Save Quote'));
    $this->_updateButton('delete', 'label', Mage::helper('quotation')->__('Delete Quote'));

    $this->_addButton('saveandcontinue', array(
        'label'     => Mage::helper('adminhtml')->__('Save && Continue Edit'),
        'onclick'   => 'saveandcon()',
        'class'     => 'save',
    ), -100);


    $this->_formScripts[] = "
        function toggleEditor() {
            if (tinyMCE.getInstanceById('quotation_content') == null) {
                tinyMCE.execCommand('mceAddControl', false, 'quotation_content');
            } else {
                tinyMCE.execCommand('mceRemoveControl', false, 'quotation_content');
            }
        }

        function saveandcon(){
            editForm.submit($('edit_form').action+'back/edit/');
        }
";
}
  • still not working sir. – Jon Carl Maramara Aug 23 '17 at 21:57
  • i already updated the _construct function.. but still if i create a quote, i can only save but cannot save&continueEdit – Jon Carl Maramara Aug 23 '17 at 23:19
0

Add the below lines in your admin block constructor.

$this->_formScripts[] = " function saveandcon(){
        editForm.submit($('edit_form').action+'back/edit/');
    }
";

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.