May 8, 2013

We are now on magento commerce with our extensions

Hello Guys,

We are not on magento community, we have listed few of our extensions there,

please checkout out profile here : http://www.magentocommerce.com/magento-connect/developer/DolphinWeb


Please checkout below extensions

Dolphin_Slideshow

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/17656/

Dolphin_QuickWatch

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/17643/

 Dolphin_Respondereview

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/17531/

Dolphin ScrollUp

http://www.magentocommerce.com/magento-connect/catalog/product/view/id/17499/

Hope this will be useful to you, we are continuously creating new extensions and publishing it for magento community

 Please send us your suggestion so we can improve our extensions and help magento community

 You can check our website here : http://www.dolphinwebsolution.com/ 

January 31, 2011

Add custom attribute to Magento’s PDF invoice

Add custom attribute to Magento’s PDF invoice
Hello everyone! Today I’ll show you how to add custom attribute to Magento’s generated PDF invoice in just a few steps. Since this article is pretty straight-forward, here we go.

One of my recent tasks was to create a custom attribute for products called inchoo_warehouse_location, and output it when click on “Print” (invoice in admin section) occurs. Since PDF generation is Magento’s core functionality, we’ll have to rewrite it a bit.

Step 1

Create the following three files in your Magento’s installation:
app/code/local/Inchoo/Invoice/Model/Order/Pdf/Items/Invoice/Default.php
app/code/local/Inchoo/Invoice/Model/Order/Pdf/Invoice.php
app/code/local/Inchoo/Invoice/etc/config.xml
Those will be used for our extension that will modify Magento’s core functionality.

Step 2

Fill in the data to according files:
config.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?xml version="1.0"?>
<config>
    <modules>
        <Inchoo_Invoice>
            <version>0.1.0</version>
        </Inchoo_Invoice>
    </modules>
    <global>
        <models>
            <sales>
                <rewrite>
                    <order_pdf_invoice>Inchoo_Invoice_Model_Order_Pdf_Invoice</order_pdf_invoice>
                    <order_pdf_items_invoice_default>Inchoo_Invoice_Model_Order_Pdf_Items_Invoice_Default</order_pdf_items_invoice_default>
                </rewrite>
            </sales>
        </models>
    </global>
</config>
Default.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<?php
/**
 * Inchoo PDF rewrite for custom attribute
 * Attribute "inchoo_warehouse_location" has to be set manually
 * Original: Sales Order Invoice Pdf default items renderer
 *
 * @category   Inchoo
 * @package    Inhoo_Invoice
 * @author     Mladen Lotar - Inchoo <mladen.lotar@inchoo.net>
 */
 
class Inchoo_Invoice_Model_Order_Pdf_Items_Invoice_Default extends Mage_Sales_Model_Order_Pdf_Items_Invoice_Default
{
    /**
     * Draw item line
     **/
    public function draw()
    {
        $order  = $this->getOrder();
        $item   = $this->getItem();
        $pdf    = $this->getPdf();
        $page   = $this->getPage();
        $lines  = array();
 
        //Inchoo - Added custom attribute to PDF, first get it if exists
        $WarehouseLocation = $this->getWarehouseLocationValue($item);
 
        // draw Product name
        $lines[0] = array(array(
            'text' => Mage::helper('core/string')->str_split($item->getName(), 60, true, true),
            'feed' => 35,
        ));
 
        //Inchoo - Added custom attribute
        //draw Warehouse Location
        $lines[0][] = array(
            'text'  => Mage::helper('core/string')->str_split($WarehouseLocation, 25),
            'feed'  => 245
        );
 
        // draw SKU
        $lines[0][] = array(
            'text'  => Mage::helper('core/string')->str_split($this->getSku($item), 25),
            'feed'  => 325
        );
 
        // draw QTY
        $lines[0][] = array(
            'text'  => $item->getQty()*1,
            'feed'  => 435
        );
 
        // draw Price
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getPrice()),
            'feed'  => 395,
            'font'  => 'bold',
            'align' => 'right'
        );
 
        // draw Tax
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getTaxAmount()),
            'feed'  => 495,
            'font'  => 'bold',
            'align' => 'right'
        );
 
        // draw Subtotal
        $lines[0][] = array(
            'text'  => $order->formatPriceTxt($item->getRowTotal()),
            'feed'  => 565,
            'font'  => 'bold',
            'align' => 'right'
        );
 
        // custom options
        $options = $this->getItemOptions();
        if ($options) {
            foreach ($options as $option) {
                // draw options label
                $lines[][] = array(
                    'text' => Mage::helper('core/string')->str_split(strip_tags($option['label']), 70, true, true),
                    'font' => 'italic',
                    'feed' => 35
                );
 
                if ($option['value']) {
                    $_printValue = isset($option['print_value']) ? $option['print_value'] : strip_tags($option['value']);
                    $values = explode(', ', $_printValue);
                    foreach ($values as $value) {
                        $lines[][] = array(
                            'text' => Mage::helper('core/string')->str_split($value, 50, true, true),
                            'feed' => 40
                        );
                    }
                }
            }
        }
 
        $lineBlock = array(
            'lines'  => $lines,
            'height' => 10
        );
 
        $page = $pdf->drawLineBlocks($page, array($lineBlock), array('table_header' => true));
        $this->setPage($page);
 
    }
 
    /*
     * Return Value of custom attribute
     * */
    private function getWarehouseLocationValue($item)
    {
        $prod = Mage::getModel('catalog/product')->load($item->getProductId());
 
        if(!($return_location = $prod->getInchooWarehouseLocation()))
            return 'N/A';
        else
            return $return_location;
    }
}
And finally Invoice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php
/**
 * Inchoo PDF rewrite for custom attribute
 * * Attribute "inchoo_warehouse_location" has to be set manually
 * Original: Sales Order Invoice PDF model
 *
 * @category   Inchoo
 * @package    Inhoo_Invoice
 * @author     Mladen Lotar - Inchoo <mladen.lotar@inchoo.net>
 */
class Inchoo_Invoice_Model_Order_Pdf_Invoice extends Mage_Sales_Model_Order_Pdf_Invoice
{
    public function getPdf($invoices = array())
    {
        $this->_beforeGetPdf();
        $this->_initRenderer('invoice');
 
        $pdf = new Zend_Pdf();
        $this->_setPdf($pdf);
        $style = new Zend_Pdf_Style();
        $this->_setFontBold($style, 10);
 
        foreach ($invoices as $invoice) {
            if ($invoice->getStoreId()) {
                Mage::app()->getLocale()->emulate($invoice->getStoreId());
            }
            $page = $pdf->newPage(Zend_Pdf_Page::SIZE_A4);
            $pdf->pages[] = $page;
 
            $order = $invoice->getOrder();
 
            /* Add image */
            $this->insertLogo($page, $invoice->getStore());
 
            /* Add address */
            $this->insertAddress($page, $invoice->getStore());
 
            /* Add head */
            $this->insertOrder($page, $order, Mage::getStoreConfigFlag(self::XML_PATH_SALES_PDF_INVOICE_PUT_ORDER_ID, $order->getStoreId()));
 
            $page->setFillColor(new Zend_Pdf_Color_GrayScale(1));
            $this->_setFontRegular($page);
            $page->drawText(Mage::helper('sales')->__('Invoice # ') . $invoice->getIncrementId(), 35, 780, 'UTF-8');
 
            /* Add table */
            $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
            $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
            $page->setLineWidth(0.5);
 
            $page->drawRectangle(25, $this->y, 570, $this->y -15);
            $this->y -=10;
 
            /* Add table head */
            $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
            $page->drawText(Mage::helper('sales')->__('Products'), 35, $this->y, 'UTF-8');
            //Added for custom attribute "inchoo_warehouse_location"
            $page->drawText(Mage::helper('sales')->__('Warehouse Location'), 245, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('SKU'), 325, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Qty'), 430, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
 
            $this->y -=15;
 
            $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
 
            /* Add body */
            foreach ($invoice->getAllItems() as $item){
                if ($item->getOrderItem()->getParentItem()) {
                    continue;
                }
 
                if ($this->y < 15) {
                    $page = $this->newPage(array('table_header' => true));
                }
 
                /* Draw item */
                $page = $this->_drawItem($item, $page, $order);
            }
 
            /* Add totals */
            $page = $this->insertTotals($page, $invoice);
 
            if ($invoice->getStoreId()) {
                Mage::app()->getLocale()->revert();
            }
        }
        $this->_afterGetPdf();
 
        return $pdf;
    }
 
    public function newPage(array $settings = array())
    {
        /* Add new table head */
        $page = $this->_getPdf()->newPage(Zend_Pdf_Page::SIZE_A4);
        $this->_getPdf()->pages[] = $page;
        $this->y = 800;
 
        if (!empty($settings['table_header'])) {
            $this->_setFontRegular($page);
            $page->setFillColor(new Zend_Pdf_Color_RGB(0.93, 0.92, 0.92));
            $page->setLineColor(new Zend_Pdf_Color_GrayScale(0.5));
            $page->setLineWidth(0.5);
            $page->drawRectangle(25, $this->y, 570, $this->y-15);
            $this->y -=10;
 
            $page->setFillColor(new Zend_Pdf_Color_RGB(0.4, 0.4, 0.4));
            $page->drawText(Mage::helper('sales')->__('Product'), 35, $this->y, 'UTF-8');
            //Added for custom attribute "inchoo_warehouse_location"
            $page->drawText(Mage::helper('sales')->__('Warehouse Location'), 245, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('SKU'), 325, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Price'), 380, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Qty'), 430, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Tax'), 480, $this->y, 'UTF-8');
            $page->drawText(Mage::helper('sales')->__('Subtotal'), 535, $this->y, 'UTF-8');
 
            $page->setFillColor(new Zend_Pdf_Color_GrayScale(0));
            $this->y -=20;
        }
        return $page;
    }
}

Step 3

Now, you’ve done it. Test it out by going to “Sales->Invoices->(View any of them)->Print”. You shoud be asked to download PDF, and when you do, it should contain “Warehouse Location” by each of order items.
All you have to do is test it out and / or change it according to your needs!
I hope this was of help to someone!
Cheers!

Local setup for Facebook Connect app development

Local setup for Facebook Connect app development
As you might know, if you wish to work with Facebook Connect it requires your development site to be accessible to it for security reasons. So that it can verify that you (your application) have rights to access certain information from its users. In this article, in short, I’ll show you how to make your local development machine accessible from the internet. If that’s what you need, read on!

There are 3 main steps you need to do in order to accomplish this kind of accessibility:
  • Getting the Accessibility
  • Setup of local host
  • Generating Facebook API key
So, to move on:

Getting the Accessibility

For this I chose free DynDns service. Basically what it does is that it gives you a domain you chose that will represent your local connection IP (that your ISP provided).
In order to complete this part you must do the following:
  • Go to that site and register for free
  • Create a new (add) host, with “hostname” you want
  • For “Service Type” field, chose “Host with IP address”
  • And if it isn’t already set, enter your IP
  • Save the changes
Just so that this article would be easier to follow, for my “hostname” on DynDns, I chose “myproject.dyndns.org”.
And those few simple steps conclude this first part of “getting it done”. :D

Setup of local host

In this part it all comes to 2 files – “httpd-vhosts.conf” and “hosts”.
Now their location depends on you local setup. Here’s a link that explain the basics about virtual hosts if you haven’t heard of them before.
My sample setup for “httpd-vhosts.conf” is as follows:
1
2
3
4
5
6
7
8
9
<VirtualHost *:80>
    ServerAdmin webmaster@marcus.lc
    DocumentRoot /home/mladen/workspace/myproject.dyndns.org/
    ServerName myproject.dyndns.org
    <Directory "/home/mladen/workspace/myproject.dyndns.org/">
    Options Indexes FollowSymLinks
    AllowOverride all
    </Directory>
</VirtualHost>
And in “hosts” file, I’ve added this line:
1
127.0.0.1    myproject.dyndns.org
And that’s about it for second part.

Generating Facebook API key

First, go to Facebook Developers page, enter App Name as you wish, and on next step confirm it.
On next screen’s left side you’ll see “Web Site” link. Follow it and enter URL like this: “http://myproject.dyndns.org/”, and for Domain enter: “myproject.dyndns.org”. Save changes.
Guess what, now you have your “Application ID” and “Application Secret” and all you have to do is start with the development. If this will be your first Facebook application, this is a good place for start.
I hope it was helpful, cheers!

December 27, 2010

“Remember Me” checkbox module in Magento

Hello everyone! I’ve created a small and simple module that creates “Remember Me” functionality to any Magento website. Its currently in testing phase, so I’d say it’s an alpha release.
Never mind the alpha release (v 0.1.0), if someone is willing to try it and trace possible bugs, I’ll do my best to fix them. :D
Module doesn’t have any admin functionality. Though it can be disabled through admin at any time. There’s a small change on customer/form/login.phtml file (added checkbox with input name set), and besides that, only thing is that this module will save hashed and salted Magento customer’s password hash in a cookie, so it is safe as it can be (if I’m wrong, I’m opened for suggestions).
There’s nothing else to say besides it’s placed on login form for Magento customers. It looks like this:

As far as setting it up goes, you only need to extract attached file over your “app” folder (it won’t overwrite anything, I’ve set it up like this because of the folder structure).
And a small note, It’s been tested on community version 1.4.
And here’s the download link.
And one last thing, I’d like to hear your opinions on this one, as this is fist module that I’ve created and have given it to public.
Cheers!

Magento 1.4.0.1 Google Analytics fix

Magento 1.4.0.1 Google Analytics fix
If you updated to latest Magento 1.4.0.0 or 1.4.0.1 version you may notice that Google Analytics implementation is broken. Here are few easy instructions how to fix this.


Navigate to and open app/code/core/Mage/GoogleAnalytics/Block/Ga.php and add this on line 179

var _gaq = _gaq || [];


Since this bug is already reported and fix can be seen on latest official svn, I don’t see any harm in modifying core files in this particular situation.


http://www.magentocommerce.com/bug-tracking/issue?issue=8658
http://svn.magentocommerce.com/source/branches/1.4-trunk/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
As Magento Team said, changes will be included in next stable release.

January 12, 2010

Fetching all the options values of attribute.

The below post show he syntax of  fetching values of attribute furniturebrand.
“furniturebrand” attribute type is combo.
Syntax ::
$product = Mage::getModel(“catalog/product”);
$attributes = Mage::getResourceModel(“eav/entity_attribute_collection”)
->setEntityTypeFilter($product->getResource()->getTypeId())
->addFieldToFilter(“attribute_code”, “furniturebrand”) // This can be changed to any attribute code
->load(false);
$attribute = $attributes->getFirstItem()->setEntity($product->getResource()); /* @var $attribute Mage_Eav_Model_Entity_Attribute */
$sortby = $attribute->getSource()->getAllOptions(false);
foreach($sortby as $sort_attribute) {
echo $sort_attribute['value'];
}
The above foreach loop is to display all the values of attribute furniturebrand.

To get all level categories name and url…

<?php
require_once ‘app/Mage.php’;
Mage::app();
$category = Mage::getModel(‘catalog/category’);
$tree = $category->getTreeModel();
$tree->load();
$ids = $tree->getCollection()->getAllIds();   // we can get all level categories id
if ($ids):
foreach ($ids as $id){
$cat = Mage::getModel(‘catalog/category’);
$cat->load($id);
if($id != 3): // if  category id is not “root catalog” id – here root catalog id is 3
if($cat->getIsActive()): // if category is active
$catName[] =  $cat->getName(); //  To get name of the category
$path[] = $cat->getUrl(); // to get url of category
endif;
endif;
}
?>

SQL to delete all orders

This query is very helpful to delete all records of orders from the database.
Please replace “YOUR_DB_NAME” with your database name
– Reset Magento TEST Data
SET FOREIGN_KEY_CHECKS=0;
– reset dashboard search queries
TRUNCATE `catalogsearch_query`;
ALTER TABLE `catalogsearch_query` AUTO_INCREMENT=1;
– reset sales order info
TRUNCATE `sales_order`;
TRUNCATE `sales_order_datetime`;
TRUNCATE `sales_order_decimal`;
TRUNCATE `sales_order_entity`;
TRUNCATE `sales_order_entity_datetime`;
TRUNCATE `sales_order_entity_decimal`;
TRUNCATE `sales_order_entity_int`;
TRUNCATE `sales_order_entity_text`;
TRUNCATE `sales_order_entity_varchar`;
TRUNCATE `sales_order_int`;
TRUNCATE `sales_order_text`;
TRUNCATE `sales_order_varchar`;
TRUNCATE `sales_flat_quote`;
TRUNCATE `sales_flat_quote_address`;
TRUNCATE `sales_flat_quote_address_item`;
TRUNCATE `sales_flat_quote_item`;
TRUNCATE `sales_flat_quote_item_option`;
TRUNCATE `sales_flat_order_item`;
TRUNCATE `sendfriend_log`;
TRUNCATE `tag`;
TRUNCATE `tag_relation`;
TRUNCATE `tag_summary`;
TRUNCATE `wishlist`;
TRUNCATE `log_quote`;
TRUNCATE `report_event`;
ALTER TABLE `sales_order` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_datetime` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_decimal` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_entity_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_int` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_text` AUTO_INCREMENT=1;
ALTER TABLE `sales_order_varchar` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_address_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_quote_item_option` AUTO_INCREMENT=1;
ALTER TABLE `sales_flat_order_item` AUTO_INCREMENT=1;
ALTER TABLE `sendfriend_log` AUTO_INCREMENT=1;
ALTER TABLE `tag` AUTO_INCREMENT=1;
ALTER TABLE `tag_relation` AUTO_INCREMENT=1;
ALTER TABLE `tag_summary` AUTO_INCREMENT=1;
ALTER TABLE `wishlist` AUTO_INCREMENT=1;
ALTER TABLE `log_quote` AUTO_INCREMENT=1;
ALTER TABLE `report_event` AUTO_INCREMENT=1;
– Reset all ID counters
TRUNCATE `eav_entity_store`;
ALTER TABLE  `eav_entity_store` AUTO_INCREMENT=1;
SET FOREIGN_KEY_CHECKS=1;
– set appropriate prefixes for orders, invoices, shipments, credit memos
INSERT INTO  `YOUR_DB_NAME`.`eav_entity_store` (`entity_store_id` ,`entity_type_id` ,`store_id` ,`increment_prefix` ,`increment_last_id`) VALUES (‘1′,  ‘11′,  ‘1′,  ‘1′,  ‘000000000′);
update `eav_entity_store` set `increment_prefix`= 1 where `entity_type_id`=’4′ and `store_id`=’1′;
update `eav_entity_store` set `increment_last_id`= ‘000000000′ where `entity_type_id`=’4′ and `store_id`=’1′;
INSERT INTO  `YOUR_DB_NAME`.`eav_entity_store` (`entity_store_id` ,`entity_type_id` ,`store_id` ,`increment_prefix` ,`increment_last_id`) VALUES (‘2′,  ‘16′,  ‘1′,  ‘2′,  ‘000000000′);
update `eav_entity_store` set `increment_prefix`= 2 where `entity_type_id`=’18′ and `store_id`=’1′;
update `eav_entity_store` set `increment_last_id`= ‘000000000′ where `entity_type_id`=’18′ and `store_id`=’1′;
INSERT INTO  `YOUR_DB_NAME`.`eav_entity_store` (`entity_store_id` ,`entity_type_id` ,`store_id` ,`increment_prefix` ,`increment_last_id`) VALUES (‘3′,  ‘19′,  ‘1′,  ‘3′,  ‘000000000′);
update `eav_entity_store` set `increment_prefix`= 3 where `entity_type_id`=’24′ and `store_id`=’1′;
update `eav_entity_store` set `increment_last_id`= ‘000000000′ where `entity_type_id`=’24′ and `store_id`=’1′;
INSERT INTO  `YOUR_DB_NAME`.`eav_entity_store` (`entity_store_id` ,`entity_type_id` ,`store_id` ,`increment_prefix` ,`increment_last_id`) VALUES (‘4′,  ‘23′,  ‘1′,  ‘4′,  ‘000000000′);
update `eav_entity_store` set `increment_prefix`= 4 where `entity_type_id`=’28′ and `store_id`=’1′;
update `eav_entity_store` set `increment_last_id`= ‘000000000′ where `entity_type_id`=’28′ and `store_id`=’1′;

How to get different URLs?

* Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS);
http://magesite.extension/js/
* Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
http://magesite.extension/index.php/
* Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
http://magesite.extension/media/
* Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN);
http://magesite.extension/skin/
* Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);

To add custom date field in custom module of admin panel

You can see the below code to add start date and end date field in admin custom module(Which is created using module creator).
Create two fields “start_date” and “end_date” in database table of your custom module.
$dateFormatIso = Mage::app()->getLocale() ->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
$fieldset->addField(’start_date’, ‘date’, array(
‘label’ => Mage::helper(‘banner’)->__(‘Start Date’),
‘title’ => Mage::helper(‘banner’)->__(‘Start Date’),
‘name’ => ’start_date’,
‘image’ => $this->getSkinUrl(‘images/grid-cal.gif’),
‘format’ => $dateFormatIso,
‘value’ => ’start_date’,
//’required’ => true,
));
$fieldset->addField(‘end_date’, ‘date’, array(
‘label’ => Mage::helper(‘banner’)->__(‘End Date’),
‘title’ => Mage::helper(‘banner’)->__(‘End Date’),
‘name’ => ‘end_date’,
‘image’ => $this->getSkinUrl(‘images/grid-cal.gif’),
‘format’ => $dateFormatIso,
‘value’ => ‘end_date’,
//’required’ => true,
));
Copy and paste the above code to your custom_module/block/adminhtml/custom_module/Edit/Tab/Form.php file
and than open controller of the same module
Path :: custom_module/controllers/adminhtml/custommoduleController.php
Add below lines before $model->save() to save dates in
function saveAction().
if($data['start_date'] != NULL )
{
$date = Mage::app()->getLocale()->date($data['start_date'], Zend_Date::DATE_SHORT);
$model->setStartDate($date->toString(‘YYYY-MM-dd HH:mm:ss’));
}
if($data['end_date'] != NULL)
{
$date1 = Mage::app()->getLocale()->date($data['end_date'], Zend_Date::DATE_SHORT);
$model->setEndDate($date1->toString(‘YYYY-MM-dd HH:mm:ss’));
}