mayokun Posted November 14, 2013 Share Posted November 14, 2013 Hello All, I have gone through the vast posts on this forum regarding creation of backoffice admin tabs. I have been able to successfully create the tabs. I can load the list but view and edit are not working! I am not sure of what I am doing wrongly! Kindly help. Below is the relevant portion of my code: Object Model =========== class InterswitchData extends ObjectModel { public $customername; public $order_reference; public $txn_reference; public $ret_reference; public $pay_reference; public $order_amount; public $txn_fee; public $total_payable; public $status; public $response_code; public $response_description; public $card_number; /** * @see ObjectModel::$definition */ public static $definition = array( 'table' => 'interswitch_data', 'primary' => 'id_interswitch_data', 'multilang' => true, 'fields' => array( 'customername' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'order_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'txn_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'ret_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'pay_reference' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'order_amount' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'txn_fee' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'total_payable' => array('type' => self::TYPE_FLOAT, 'validate' => 'isPrice'), 'status' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'response_code' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'response_description' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), 'card_number' => array('type' => self::TYPE_STRING, 'validate' => 'isGenericName'), ), ); } Admin Controller ================ class AdminInterswitchController extends ModuleAdminController { public function __construct() { $this->table = 'interswitch_data'; $this->className = 'InterswitchData'; $this->lang = true; $this->deleted = false; $this->addRowAction('edit'); $this->addRowAction('view'); $this->fields_list = array( 'id_interswitch_data' => array( 'title' => $this->l('ID'), 'align' => 'center', 'width' => 25 ), 'order_reference' => array( 'title' => $this->l('Reference'), 'width' => 'auto', ), 'txn_reference' => array( 'title' => $this->l('Txn Reference'), 'width' => 'auto', ), 'customername' => array( 'title' => $this->l('Customer'), 'width' => 'auto', ), 'order_amount' => array( 'title' => $this->l('Order Total'), 'width' => 'auto', ), 'txn_fee' => array( 'title' => $this->l('Txn Fee'), 'width' => 'auto', ), 'total_payable' => array( 'title' => $this->l('Total Payable'), 'width' => 'auto', ), 'status' => array( 'title' => $this->l('Status'), 'width' => 'auto', ), 'response_code' => array( 'title' => $this->l('Resp Code'), 'width' => 'auto', ), 'response_description' => array( 'title' => $this->l('Resp Description'), 'width' => 'auto', ), ); parent::__construct(); } public function renderForm() { if (!($obj = $this->loadObject(true))) return; if (Tools::isSubmit('id_interswitch_data')) { $interswitch_data = new InterswitchData((int)Tools::getValue('id_interswitch_data')); $parent = $shop->id_interswitch_data; } $this->fields_form = array( 'tinymce' => true, 'legend' => array( 'title' => $this->l('Interswitch'), 'image' => '../img/admin/cog.gif' ), 'input' => array( array( 'type' => 'text', 'label' => $this->l('Customer:'), 'name' => 'customername', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Order Reference:'), 'name' => 'order_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Transaction Reference:'), 'name' => 'txn_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Order Total:'), 'name' => 'order_amount', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Transaction Fee:'), 'name' => 'txn_fee', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Total Payable:'), 'name' => 'total_payable', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Response Code:'), 'name' => 'response_code', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Response Description:'), 'name' => 'response_description', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Retrieval Reference:'), 'name' => 'ret_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Payment Reference:'), 'name' => 'pay_reference', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Card Number:'), 'name' => 'card_number', 'size' => 40 ), array( 'type' => 'text', 'label' => $this->l('Status:'), 'name' => 'status', 'size' => 40 ), ), 'submit' => array( 'title' => $this->l('Query'), 'class' => 'button' ) ); return parent::renderForm(); } } SQL Table ========= // Create Table in Database $sql[] = 'CREATE TABLE IF NOT EXISTS `'._DB_PREFIX_.'interswitch_data` ( `id_interswitch_data` int(10) NOT NULL AUTO_INCREMENT, `customername` varchar(50), `order_reference` varchar(50), `txn_reference` varchar(50), `ret_reference` varchar(50), `pay_reference` varchar(50), `order_amount` DECIMAL(17,2) DEFAULT 0.00, `txn_fee` DECIMAL(17,2) DEFAULT 0.00, `total_payable` DECIMAL(17,2) DEFAULT 0.00, `status` varchar(20), `response_code` varchar(10), `response_description` varchar(50), `card_number` varchar(4), PRIMARY KEY (`id_interswitch_data`) ) ENGINE='._MYSQL_ENGINE_.' DEFAULT CHARSET=utf8'; Link to comment Share on other sites More sharing options...
Recommended Posts