Jump to content

Edit History

burrots

burrots

private function _postProcess()
    {
        if (Tools::isSubmit('submitConfiguration'))
        {
            Configuration::updateValue('PP_AA_SEPARATOR', Tools::getValue('PP_AA_SEPARATOR'));
        }
        elseif (Tools::isSubmit('submitOrders'))
        {               
            if ($file_attachment = Tools::fileAttachment()) {
                $handle = fopen($file_attachment['tmp_name'], "r");
                while (($data = fgetcsv($handle, 1000, Configuration::get('PP_AA_SEPARATOR'))) !== false) {
                	$data = array_map("utf8_encode", $data);
                	$order = new Order((int)$data[0]);
                    if (Validate::isLoadedObject($order)) {
                        if (!$order->setCurrentState((int)$data[1])) {
                            $this->_errors[] = $this->l('Unable to update Orders State in id_order: ' . $data[0]);
                        }
                    } else {
						 $this->_errors[] = $this->l('Not exists id_order: ' . $data[0]);
                }
            }
        }

        if ($this->_errors)
            foreach ($this->_errors as $error)
                $this->_html .= $this->displayError($this->l($error));
        else {
            Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&conf=6&token='.Tools::getAdminTokenLite('AdminModules'));
        }
    }

Asi ahora especifica mas si hay error

burrots

burrots

private function _postProcess()
    {
        if (Tools::isSubmit('submitConfiguration'))
        {
            Configuration::updateValue('PP_AA_SEPARATOR', Tools::getValue('PP_AA_SEPARATOR'));
        }
        elseif (Tools::isSubmit('submitOrders'))
        {               
            if ($file_attachment = Tools::fileAttachment()) {
                $handle = fopen($file_attachment['tmp_name'], "r");
                while (($data = fgetcsv($handle, 1000, Configuration::get('PP_AA_SEPARATOR'))) !== false) {
                	$data = array_map("utf8_encode", $data);
                	$order = new Order((int)$data[0]);
                    if (Validate::isLoadedObject($order)) {
                        if (!$order->setCurrentState((int)$data[1])) {
                            $this->_errors[] = $this->l('Unable to update Orders State in id_order: ' . $data[0]);
                        }
                    } else {
						 $this->_errors[] = $this->l('Not exists id_order: ' . $data[0]);
                }
            }
        }

        if ($this->_errors)
            foreach ($this->_errors as $error)
                $this->_html .= $this->displayError($this->l($error));
        else {
            Tools::redirectAdmin('index.php?tab=AdminModules&configure='.$this->name.'&conf=6&token='.Tools::getAdminTokenLite('AdminModules'));
        }
    }

Asi mas pulido

×
×
  • Create New...