Anc lib timetables backend

Aus Vosp.info
Version vom 31. Mai 2014, 08:45 Uhr von V (Diskussion | Beiträge) (Blöcke)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu:Navigation, Suche

Struktur

Blöcke

../Block/Adminhtml/Timetables.php
class Anc_Lib_Block_Adminhtml_Timetables extends Mage_Adminhtml_Block_Widget_Grid_Container {
	public function __construct() {
		$this->_controller = 'adminhtml_timetables';
		$this->_blockGroup = 'anc_lib';
		$this->_headerText = Mage::helper('anc_lib/data')->__('Timetable');
		$this->_addButtonLabel =  Mage::helper('anc_lib/data')->__('Timetable erstellen');
		parent::__construct();
	}
	
	public function getCreateUrl()
    {
        return $this->getUrl(
            'lib/adminhtml_timetable/edit'
        );
    }

}
../Block/Adminhtml/Timetables
../Block/Adminhtml/Timetables/Grid.php
<?php

class Anc_Lib_Block_Adminhtml_Timetables_Grid extends Mage_Adminhtml_Block_Widget_Grid
{
   public function __construct()
   {
       parent::__construct();
	   
       $this->setId('anc_lib_timetables_grid');
       $this->setDefaultSort('entity_id');
       $this->setDefaultDir('DESC');
       $this->setSaveParametersInSession(true);
   }
   
   
   
   protected function _getCollectionClass()
    {
        return 'anc_lib/timetable';
    }
   
   
   protected function _prepareCollection()
   {

      $collection = Mage::getModel('anc_lib/timetable')->getCollection()->addFieldToFilter('customer_id',array('lt'=>1));;
//      D::s($collection,'$collection',15,1,1);
	  $this->setCollection($collection);
//	  D::s($collection,'$collection',5,1,1);
      return parent::_prepareCollection();
    }
   protected function _prepareColumns()
   {

       $this->addColumn('entity_id',
             array(
                    'header' => Mage::helper('anc_lib/data')->__('Id'),
                    'align' =>'right',
                    'width' => '50px',
                    'index' => 'entity_id',
               ));
       $this->addColumn('name',
               array(
                    'header' => Mage::helper('anc_lib/data')->__('Name'),
                    'align' =>'left',
                    'index' => 'name',
              ));
       $this->addColumn('comment', array(
                    'header' => Mage::helper('anc_lib/data')->__('Comment'),
                    'align' =>'left',
                    'index' => 'comment',
             ));
        $this->addColumn('admin_user_id', array(
                     'header' => Mage::helper('anc_lib/data')->__('Admin'),
                     'align' =>'left',
                     'index' => 'admin_user_id',
          ));
		$this->addColumn('customer_id', array(
                     'header' => Mage::helper('anc_lib/data')->__('Customer'),
                     'align' =>'left',
                     'index' => 'customer_id',
          ));
		$this->addColumn('created_at', array(
                     'header' => Mage::helper('anc_lib/data')->__('Created'),
                     'align' =>'left',
                     'index' => 'created_at',
          ));
		$this->addColumn('updated_at', array(
                     'header' => Mage::helper('anc_lib/data')->__('Updated'),
                     'align' =>'left',
                     'index' => 'updated_at',
          ));
		
		
		$this->addColumn('updated_at', array(
                     'header' => Mage::helper('anc_lib/data')->__('Updated'),
                     'align' =>'left',
                     'index' => 'updated_at',
          ));
		$this->addColumn('updated_at', array(
                     'header' => Mage::helper('anc_lib/data')->__('Updated'),
                     'align' =>'left',
                     'index' => 'updated_at',
          ));
		$this->addColumn('start', array(
                     'header' => Mage::helper('anc_lib/data')->__('Start'),
                     'align' =>'left',
                     'index' => 'start',
          ));
		$this->addColumn('stop', array(
                     'header' => Mage::helper('anc_lib/data')->__('Stop'),
                     'align' =>'left',
                     'index' => 'stop',
          ));
		$this->addColumn('starthour', array(
                     'header' => Mage::helper('anc_lib/data')->__('Starthour'),
                     'align' =>'left',
                     'index' => 'starthour',
          ));
		$this->addColumn('stophour', array(
                     'header' => Mage::helper('anc_lib/data')->__('Stophour'),
                     'align' =>'left',
                     'index' => 'stophour',
          ));
		$this->addColumn('startmin', array(
                     'header' => Mage::helper('anc_lib/data')->__('Startmin'),
                     'align' =>'left',
                     'index' => 'startmin',
          ));
		$this->addColumn('stopmin', array(
                     'header' => Mage::helper('anc_lib/data')->__('Stopmin'),
                     'align' =>'left',
                     'index' => 'stopmin',
          ));
		$this->addColumn('monday', array(
//					 'type'     => 'checkbox',
					 'values'   => array(0,1),
					 'field_name' => 'checkbox_name',
                     'header' => Mage::helper('anc_lib/data')->__('Monday'),
                     'align' =>'left',
                     'index' => 'monday',
          ));
		$this->addColumn('tuesday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Tuesday'),
					 'values'   => array(0,1),
                     'align' =>'left',
                     'index' => 'tuesday',
          ));
		$this->addColumn('wednesday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Wednesday'),
                     'align' =>'left',
                     'index' => 'wednesday',
          ));	
		$this->addColumn('thursday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Thursday'),
                     'align' =>'left',
                     'index' => 'thursday',
          ));	
		$this->addColumn('friday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Friday'),
                     'align' =>'left',
                     'index' => 'friday',
          ));	
		$this->addColumn('saturday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Saturday'),
                     'align' =>'left',
                     'index' => 'saturday',
          ));	
		$this->addColumn('sunday', array(
                     'header' => Mage::helper('anc_lib/data')->__('Sunday'),
                     'align' =>'left',
                     'index' => 'sunday',
          ));	

         return parent::_prepareColumns();
    }
    public function getRowUrl($row)
    {
         return $this->getUrl('*/*/edit', array('id' => $row->getId()));
    }
}
../Block/Adminhtml/Timetables/Edit.php
class Anc_Lib_Block_Adminhtml_Timetables_Edit
    extends Mage_Adminhtml_Block_Widget_Form_Container
{
    protected function _construct()
    {
		$this->_controller = 'timetables';
		$this->_blockGroup = 'anc_lib_adminhtml';
		
		$this->_updateButton('save', 'label', $this->__('Save'));
        $this->_updateButton('delete', 'label', $this->__('Delete'));
    }
}
../Block/Adminhtml/Timetables/Edit
../Block/Adminhtml/Timetables/Edit/Form.php
<?php
class Anc_Lib_Block_Adminhtml_Timetables_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {

	protected function _prepareForm() {

		if (Mage::registry('anc_lib')) {
			$data = Mage::registry('anc_lib')->getData();
		} else {
			$data = array();
		}

		$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);
		$form->setValues($data);
		return parent::_prepareForm();
	}

}
../Block/Adminhtml/Timetables/Edit/Tabs.php
class Anc_Lib_Block_Adminhtml_Timetables_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs {

	public function __construct() {
		parent::__construct();
		$this->setId('timetables_tabs');
		$this->setDestElementId('edit_form'); // this should be same as the form id define above
		$this->setTitle('Timetables');
	}

	protected function _beforeToHtml() {
		$this->addTab(
				'form_section', array(
					'label' => 'Timetables Info', // Mage::helper('news')->__('News Information'),
					'title' => 'Timetables Info', //Mage::helper('news')->__('News Information'),
					'content' => $this->getLayout()->createBlock('anc_lib/adminhtml_timetables_edit_tab_form')->toHtml(),
				)
		);

		$this->addTab('form_section1', array(
			'label' => 'Timetables Extras', //Mage::helper('news')->__('Content'),
			'title' => 'Timetables Extras', //Mage::helper('news')->__('Content'),
			'content' => $this->getLayout()->createBlock('anc_lib/adminhtml_timetables_edit_tab_content')->toHtml(),
		));

		return parent::_beforeToHtml();
	}

}
../Block/Adminhtml/Timetables/Edit/Tab
../Block/Adminhtml/Timetables/Edit/Tab/Form.php
<?php

class Anc_Lib_Block_Adminhtml_Timetables_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form {

	protected function _prepareForm() {

		$arrayhour = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23');
		$arraymin = array('0' => '0', '1' => '1', '2' => '2', '3' => '3', '4' => '4', '5' => '5', '6' => '6', '7' => '7', '8' => '8', '9' => '9', '10' => '10', '11' => '11', '12' => '12', '13' => '13', '14' => '14', '15' => '15', '16' => '16', '17' => '17', '18' => '18', '19' => '19', '20' => '20', '21' => '21', '22' => '22', '23' => '23', '24' => '24', '25' => '25', '26' => '26', '27' => '27', '28' => '28', '29' => '29',
			'30' => '30', '31' => '31', '32' => '32', '33' => '33', '34' => '34', '35' => '35', '36' => '36', '37' => '37', '38' => '38', '39' => '39', '40' => '40', '41' => '41', '42' => '42', '43' => '43', '44' => '44', '44' => '45', '46' => '46', '47' => '47', '48' => '48', '49' => '49', '50' => '50', '51' => '51', '52' => '52', '53' => '53', '54' => '54', '55' => '55', '56' => '56', '57' => '57', '58' => '58', '59' => '59');


		if (Mage::registry('anc_timetable')) {
			$data = Mage::registry('anc_timetable')->getData();
		} else {
			$data = array();
		}

		$form = new Varien_Data_Form();
		$this->setForm($form);
		$fieldset = $form->addFieldset('anc_timetable', array('name' => 'name')); //Mage::helper('news')->__('news information')));

		$fieldset->addField('name', 'text', array(
			'label' => Mage::helper('anc_lib/data')->__('Name'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'name',
		));

		$fieldset->addField('comment', 'textarea', array(
			'label' => Mage::helper('anc_lib/data')->__('Comment'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'comment',
		));

		$fieldset->addField('start', 'date', array(
			'label' => Mage::helper('anc_lib/data')->__('Start'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'start',
			'tabindex' => 1,
			'image' => $this->getSkinUrl('images/grid-cal.gif'),
			'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
		));
		$fieldset->addField('stop', 'date', array(
			'label' => Mage::helper('anc_lib/data')->__('Stop'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stop',
			'tabindex' => 1,
			'image' => $this->getSkinUrl('images/grid-cal.gif'),
			'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
		));


		$fieldset->addField('starthour', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('Starthour'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'starthour',
			'onclick' => "",
			'onchange' => "",
			'values' => $arrayhour,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('stophour', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('stophour'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stophour',
			'onclick' => "",
			'onchange' => "",
			'values' => $arrayhour,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('startmin', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('startmin'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'startmin',
			'onclick' => "",
			'onchange' => "",
			'values' => $arraymin,
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 2
		));
		$fieldset->addField('stopmin', 'select', array(
			'label' => Mage::helper('anc_lib/data')->__('stopmin'),
			'class' => 'required-entry',
			'required' => true,
			'name' => 'stopmin',
			'onclick' => "",
			'onchange' => "",
			'values' => $arraymin,
			'disabled' => false,
			'readonly' => false,
		));
		$fieldset->addField('monday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('monday'),
			'name' => 'monday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('tuesday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('tuesday'),
			'name' => 'tuesday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('wednesday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('wednesday'),
			'name' => 'wednesday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('thursday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('thursday'),
			'name' => 'thursday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('friday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('friday'),
			'name' => 'friday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('saturday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('saturday'),
			'name' => 'saturday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));
		$fieldset->addField('sunday', 'radios', array(
			'label' => Mage::helper('anc_lib/data')->__('sunday'),
			'name' => 'sunday',
			'onclick' => "",
			'onchange' => "",
			'value' => '1',
			'values' => array(
				array('value' => '1', 'label' => 'Ja'),
				array('value' => '0', 'label' => 'Nein'),
			),
			'disabled' => false,
			'readonly' => false,
			'tabindex' => 1
		));

		/**
		 * Setzen der Hidden Id für Admin muss über den $data array erfolgen da sonst Magento für neue Elemente 0 setzt
		 */
		$data['admin_user_id'] = $admin = Mage::getSingleton('admin/session')->getUser()->getId();
		$fieldset->addField('admin_user_id', 'hidden', array('name' => 'admin_user_id'));

		$form->setValues($data);

		return parent::_prepareForm();
	}

}
../Block/Adminhtml/Timetables/Edit/Tab/Content.php
class Anc_Lib_Block_Adminhtml_Timetables_Edit_Tab_Content extends Mage_Adminhtml_Block_Widget_Form {

	protected function _prepareForm() {
		if (Mage::registry('anc_timetable')) {
			$data = Mage::registry('anc_timetable')->getData();
		} else {
			$data = array();
		}
		$form = new Varien_Data_Form();
		$this->setForm($form);
		$fieldset = $form->addFieldset('anc_timetable', array('name' => 'Info'));//Mage::helper('news')->__('news information')));
		$form->setValues($data);
		return parent::_prepareForm();
	}

}

Helper

../Helper/Data.php
<?php

class Anc_Lib_Helper_Data extends Mage_Core_Helper_Abstract {

}

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();
?>