Magento – Adding Custom Date Range on Admin Dashboard Chart Magento

admin-paneldashboardmagento-1.7

I am working on a task to show Date Range on Dashboard chart. so data chart will display on custom date range selection. I have added calendar on chart but result is not coming properly. I know its very specific requirement. I am looking if someone has already done such modification and can provide me some guidence to achieve this.

I have added calendar from the following code in adminhtml/default/default/template/dashboard/graph.phtml:

<div class="field">
    <label for="startdate"><?php echo Mage::helper('contacts')->__('Start Date') ?></label>
    <div class="input-box">
        <input name="startdate" id="startdate" value="" type="text">
        <img title="Select date" id="startdate_trig" src="<?php echo 'http://192.168.0.32/pankgento/skin/adminhtml/default/default/images/grid-cal.gif'; ?>" class="v-middle">
    </div>
 </div>

 <div class="field">
    <label for="enddate"><?php echo Mage::helper('contacts')->__('End Date') ?></label>
    <div class="input-box">
        <input name="enddate" id="enddate" value="" type="text">
        <img title="Select date" id="enddate_trig" src="<?php echo Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'/adminhtml/default/default/images/grid-cal.gif'; ?>" class="v-middle">
    </div>
 </div>

 <div class="field">
    <div class="input-box">
        <input type="button" name="btn" value="Search" onchange="changeDiagramsPeriod();" />
    </div>
 </div>

Already a function changeDiagramsPeriod created in adminhtml/default/default/template/dashboard/index.phtml. It is responsible for making the ajax request, its creating ajax request for every dynamic block.

Best Answer

Magento filter and search date in format ,Use date php as

    $fromDate = date('Y-m-d'. ' 00:00:00', strtotime($fromDate));
    $toDate = date('Y-m-d'. ' 23:59:00', strtotime($toDate));

or javascript set like as

var from = new Date(year, month, day, 00, 00, 00);
var toDate = new Date(year, month, day, 23, 59, 00);
Related Topic