Anc lib timetables backend: Unterschied zwischen den Versionen
Aus Vosp.info
V (Diskussion | Beiträge) (→Controller.php) |
V (Diskussion | Beiträge) (→Controller.php) |
||
Zeile 25: | Zeile 25: | ||
class Anc_Lib_Adminhtml_TimetableController extends Mage_Adminhtml_Controller_Action { | class Anc_Lib_Adminhtml_TimetableController extends Mage_Adminhtml_Controller_Action { | ||
− | |||
− | |||
public function listAction() { | public function listAction() { | ||
Zeile 130: | Zeile 128: | ||
} | } | ||
$this->_redirect('*/*/list'); | $this->_redirect('*/*/list'); | ||
− | + | ||
} | } | ||
Version vom 31. Mai 2014, 08:36 Uhr
Inhaltsverzeichnis
Struktur
Blöcke
../Block/Adminhtml/Timetables.php ../Block/Adminhtml/Timetables ../Block/Adminhtml/Timetables/Grid.php ../Block/Adminhtml/Timetables/Edit.php ../Block/Adminhtml/Timetables/Edit ../Block/Adminhtml/Timetables/Edit/Form.php ../Block/Adminhtml/Timetables/Edit/Tabs.php ../Block/Adminhtml/Timetables/Edit/Tab ../Block/Adminhtml/Timetables/Edit/Tab/Form.php ../Block/Adminhtml/Timetables/Edit/Tab/Content.php
Helper
../Helper/Data.php
Model
../Model/Resource/Mysql4/Timetable/Collection.php ../Model/Resource/Mysql4/Timetable.php
Controller.php
../controllers/Adminhtml/TimetableController.php
class Anc_Lib_Adminhtml_TimetableController extends Mage_Adminhtml_Controller_Action {
public function listAction() {
$timetableBlock = $this->getLayout()->createBlock('anc_lib/adminhtml_timetables');
$this->loadLayout()
->_addContent($timetableBlock)
->renderLayout();
}
protected function _initAction() {
$this->loadLayout()->_setActiveMenu('anc_lib/ANC')
->_addBreadcrumb('test Manager', 'test Manager');
return $this;
}
public function indexAction() {
$this->_initAction();
$this->renderLayout();
}
public function editAction() {
$id = $this->getRequest()->getParam('id');
$model = Mage::getModel('anc_lib/timetable')->load($id);
if ($model->getId() || $id == 0) {
Mage::register('anc_timetable', $model);
$this->loadLayout();
$this->_setActiveMenu('test/set_time');
$this->_addBreadcrumb('test Manager', 'test Manager');
$this->_addBreadcrumb('Test Description', 'Test Description');
$this->getLayout()->getBlock('head')
->setCanLoadExtJs(true);
$this->_addContent($this->getLayout()
->createBlock('anc_lib/adminhtml_timetables_edit'))
->_addLeft($this->getLayout()
->createBlock('anc_lib/adminhtml_timetables_edit_tabs')
);
$this->renderLayout();
} else {
Mage::getSingleton('adminhtml/session')
->addError('Test does not exist');
$this->_redirect('*/*/');
}
}
public function newAction() {
$this->_forward('edit');
}
public function saveAction() {
if ($this->getRequest()->getPost()) {
try {
$postData = $this->getRequest()->getPost();
$testModel = Mage::getModel('anc_lib/timetable');
if ($this->getRequest()->getParam('id') <= 0)
$testModel->setCreatedTime(
Mage::getSingleton('core/date')
->gmtDate()
);
$testModel
->addData($postData)
->setUpdateTime(
Mage::getSingleton('core/date')
->gmtDate())
->setId($this->getRequest()->getParam('id'))
->save();
Mage::getSingleton('adminhtml/session')
->addSuccess('successfully saved');
Mage::getSingleton('adminhtml/session')
->settestData(false);
$this->_redirect('*/*/list');
return;
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')
->addError($e->getMessage());
Mage::getSingleton('adminhtml/session')
->settestData($this->getRequest()
->getPost()
);
$this->_redirect('*/*/edit', array('id' => $this->getRequest()
->getParam('id')));
return;
}
}
$this->_redirect('*/*/');
}
public function deleteAction() {
if ($this->getRequest()->getParam('id') > 0) {
try {
$testModel = Mage::getModel('anc_lib/timetable');
$testModel->setId($this->getRequest()
->getParam('id'))
->delete();
Mage::getSingleton('adminhtml/session')
->addSuccess('successfully deleted');
$this->_redirect('*/*/');
$this->_redirect('*/*/list');
} catch (Exception $e) {
Mage::getSingleton('adminhtml/session')
->addError($e->getMessage());
$this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
}
}
$this->_redirect('*/*/list');
}
protected function _isAllowed() {
return Mage::getSingleton('admin/session')->isAllowed('lib/form');
}
}
etc
../etc/config.xml
<?xml version="1.0"?>
<config>
<modules>
<Anc_Lib>
<version>0.1.0</version>
</Anc_Lib>
</modules>
<global>
<models>
<anc_lib>
<class>Anc_Lib_Model</class>
<resourceModel>anc_lib_resource</resourceModel>
</anc_lib>
<anc_lib_resource>
<class>Anc_Lib_Model_Resource_Mysql4</class>
<!-- entitie's mit s hier können mehrere Tabellen(namen) untergebracht werden -->
<entities>
<timetable>
<table>anc_lib_timetable</table>
</timetable>
</entities>
</anc_lib_resource>
</models>
<resources>
<!-- hier verbirgt sich das installationsskript um die datenbanktabellen zu erstellen -->
<anc_lib_setup>
<setup>
<module>Anc_Lib</module>
<class>Mage_Sales_Model_Mysql4_Setup</class>
</setup>
<connection>
<use>core_setup</use>
</connection>
</anc_lib_setup>
<!-- datenbank verbindungen -->
<anc_lib_write>
<connection>
<use>core_write</use>
</connection>
</anc_lib_write>
<anc_lib_read>
<connection>
<use>core_read</use>
</connection>
</anc_lib_read>
</resources>
<blocks>
<anc_lib>
<class>Anc_Lib_Block</class>
</anc_lib>
<anc_lib_adminhtml>
<class>Anc_Lib_Block_Adminhtml</class>
</anc_lib_adminhtml>
<customer>
<rewrite>
<account_navigation>Anc_Lib_Block_Account_Navigation</account_navigation>
</rewrite>
</customer>
</blocks>
<helpers>
<anc_lib>
<class>Anc_Lib_Helper</class>
</anc_lib>
</helpers>
</global>
<admin>
<routers>
<anc_lib>
<use>admin</use>
<args>
<module>Anc_Lib</module>
<frontName>lib</frontName>
</args>
</anc_lib>
</routers>
</admin>
<adminhtml>
<menu>
<Anc_Anc module="anc_lib">
<title>ANC</title>
<sort_order>71</sort_order>
<children>
<item2 module="anc_lib">
<title>Playlists</title>
<sort_order>2</sort_order>
<action>site/adminhtml_playlist/list</action>
<children>
<item2b module="anc_lib">
<title>Timetables</title>
<sort_order>3</sort_order>
<action>lib/adminhtml_timetable/list</action>
</item2b>
</children>
</item2>
</children>
</Anc_Anc>
</menu>
</adminhtml>
</config>
../etc/adminhtml.xml
<?xml version="1.0"?>
<config>
<acl>
<resources>
<all>
<title>Allow Everything</title>
</all>
<admin>
<children>
<Anc_Anc module="anc_site">
<title>ANC</title>
<sort_order>71</sort_order>
<children>
<item2 module="anc_site">
<title>Playlists</title>
<sort_order>2</sort_order>
<action>site/adminhtml_site/index</action>
<children>
<item2b module="anc_lib">
<title>Timetables</title>
<sort_order>3</sort_order>
<action>lib/adminhtml_timetable/list</action>
</item2b>
</children>
</item2>
</children>
</Anc_Anc>
<system>
<children>
<config>
<children>
<site translate="title">
<title>Lib</title>
<sort_order>101</sort_order>
</site>
</children>
</config>
</children>
</system>
</children>
</admin>
</resources>
</acl>
</config>
sql
../sql/anc_lib_setup/install-0.1.0.php
<?php
$installer = $this;
$installer->startSetup();
$tableName = $installer->getTable('anc_lib/timetable');
if ($installer->getConnection()->isTableExists($tableName) != true) {
$table = $installer->getConnection()->newTable($tableName)
->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('identity' => true, 'unsigned' => true, 'nullable' => false, 'primary' => true,), 'Id')
->addColumn('name', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(), 'Name')
->addColumn('comment', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(), 'comment')
->addColumn('admin_user_id', Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('unsigned' => true,'nullable' => false,'default' => '0',),'Who Created backend')
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array('unsigned' => true, 'nullable' => false, 'default' => '0',), 'Who Created frontend')
->addColumn('start', Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null,array(),'Start Date as Timestamp')
->addColumn('stop', Varien_Db_Ddl_Table::TYPE_TIMESTAMP,null,array(),'End Date as Timestamp')
->addColumn('starthour', Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('default' => '0'),'Daily start Hour')
->addColumn('stophour', Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('default' => '23'),'Daily stop Hour')
->addColumn('startmin', Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('default' => '0'),'Daily start Min')
->addColumn('stopmin', Varien_Db_Ddl_Table::TYPE_INTEGER,null,array('default' => '59'),'Daily stop Min')
->addColumn('monday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Mondays')
->addColumn('tuesday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Tuesday')
->addColumn('wednesday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Wednesday')
->addColumn('thursday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Thursday')
->addColumn('friday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Friday')
->addColumn('saturday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Saturday')
->addColumn('sunday', Varien_Db_Ddl_Table::TYPE_BOOLEAN, null, array('default' => '1'), 'Runs Sunday')
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), 'When beginn')
->addColumn('updated_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(), 'When updated')
->addColumn('deleted', Varien_Db_Ddl_Table::TYPE_TINYINT, null, array('default' => '0'), 'Deleted')
;
$installer->getConnection()->createTable($table);
}
$installer->endSetup();
?>