<?php
$debug='0';
$dashboard_report='My Excel Dashboard';
$dashboard_id='myexceldashboard';
$button_text='Go';
$database_config='dbconfig/myexceldashboard_db.php';
$d_options['use_plet_positions']= true; //this will place each parameter at its own x,y location, setting to false will use the grouping feature
$d_options['grid_height_offset']=-80;//this is the offset added to the actual height for accomodating the caption,pager and column header height
$d_options['top_button_offset']=0;//Push all the objects down by this pixel height.
$d_options['top_button_display']=true;//Display the Go button?



  $num_format = 'number_format';
  
  $percent = 'percentof';
function percentof($value,$percent)
{
  return ($value*$percent)/100;
}



  $get_position = 'getPosition';
/*
* Total height /total width of the canvas
offset = deduct this from the actual height or widht
per = percentage of the remaining height or width and based on this return the relative position
*/
function getPosition($total_height,$offset,$per)
{
  return $total_height - (($total_height-$offset)*$per)/100;
}






/************** _p35 *********************/
$plet['_p35']['id']='_p35' ;
$plet['_p35']['name']='' ;
$plet['_p35']['raw_type']='BLET' ;
$plet['_p35']['connection']='Excel Demo' ;
$plet['_p35']['width']=284 ;
$plet['_p35']['height']=69 - 27 ;
$plet['_p35']['x_position']=13 ;
$plet['_p35']['y_position']=3 ;
$plet['_p35']['format']='dd-M-yy' ;
$plet['_p35']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:16px' ;
$plet['_p35']['font_color']='#000000' ;
$plet['_p35']['background_color']='#ffcc00' ;
$plet['_p35']['default_value']='ALL' ;
$plet['_p35']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p35']['all_label']='ALL' ;
$plet['_p35']['all_value']='%' ;
$plet['_p35']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p35']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p35']['default_null_value']='%';  // ;
$plet['_p35']['static_values']='' ;
$plet['_p35']['static_display_values']= $plet['_p35']['static_values']  ;
$plet['_p35']['sql']= <<<EOD

EOD;




/************** _p47 *********************/
$plet['_p47']['id']='_p47' ;
$plet['_p47']['name']='' ;
$plet['_p47']['raw_type']='BLET' ;
$plet['_p47']['connection']='Excel Demo' ;
$plet['_p47']['width']=262 ;
$plet['_p47']['height']=69 - 27 ;
$plet['_p47']['x_position']=423 ;
$plet['_p47']['y_position']=0 ;
$plet['_p47']['format']='dd-M-yy' ;
$plet['_p47']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:16px' ;
$plet['_p47']['font_color']='#000000' ;
$plet['_p47']['background_color']='#ccccff' ;
$plet['_p47']['default_value']='ALL' ;
$plet['_p47']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p47']['all_label']='ALL' ;
$plet['_p47']['all_value']='%' ;
$plet['_p47']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p47']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p47']['default_null_value']='%';  // ;
$plet['_p47']['static_values']='' ;
$plet['_p47']['static_display_values']= $plet['_p47']['static_values']  ;
$plet['_p47']['sql']= <<<EOD

EOD;




/************** _p43 *********************/
$plet['_p43']['id']='_p43' ;
$plet['_p43']['name']='' ;
$plet['_p43']['raw_type']='BLET' ;
$plet['_p43']['connection']='Excel Demo' ;
$plet['_p43']['width']=284 ;
$plet['_p43']['height']=69 - 27 ;
$plet['_p43']['x_position']=692 ;
$plet['_p43']['y_position']=3 ;
$plet['_p43']['format']='dd-M-yy' ;
$plet['_p43']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:16px' ;
$plet['_p43']['font_color']='#000000' ;
$plet['_p43']['background_color']='#b4ce4c' ;
$plet['_p43']['default_value']='ALL' ;
$plet['_p43']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p43']['all_label']='ALL' ;
$plet['_p43']['all_value']='%' ;
$plet['_p43']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p43']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p43']['default_null_value']='%';  // ;
$plet['_p43']['static_values']='' ;
$plet['_p43']['static_display_values']= $plet['_p43']['static_values']  ;
$plet['_p43']['sql']= <<<EOD

EOD;




/************** _p44 *********************/
$plet['_p44']['id']='_p44' ;
$plet['_p44']['name']='' ;
$plet['_p44']['raw_type']='STATIC' ;
$plet['_p44']['connection']='Excel Demo' ;
$plet['_p44']['width']=446 ;
$plet['_p44']['height']=51 - 27 ;
$plet['_p44']['x_position']=323 ;
$plet['_p44']['y_position']=223 ;
$plet['_p44']['format']='dd-M-yy' ;
$plet['_p44']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:12px' ;
$plet['_p44']['font_color']='#ff325d' ;
$plet['_p44']['background_color']='#ffffff' ;
$plet['_p44']['default_value']='ALL' ;
$plet['_p44']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p44']['all_label']='ALL' ;
$plet['_p44']['all_value']='%' ;
$plet['_p44']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p44']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p44']['default_null_value']='%';  // ;
$plet['_p44']['static_values']='' ;
$plet['_p44']['static_display_values']= $plet['_p44']['static_values']  ;
$plet['_p44']['sql']= <<<EOD
<<< Change the drop down values
EOD;




/************** _p41 *********************/
$plet['_p41']['id']='_p41' ;
$plet['_p41']['name']='' ;
$plet['_p41']['raw_type']='BLET' ;
$plet['_p41']['connection']='Excel Demo' ;
$plet['_p41']['width']=284 ;
$plet['_p41']['height']=69 - 27 ;
$plet['_p41']['x_position']=690 ;
$plet['_p41']['y_position']=154 ;
$plet['_p41']['format']='dd-M-yy' ;
$plet['_p41']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:16px' ;
$plet['_p41']['font_color']='#000000' ;
$plet['_p41']['background_color']='#ccffcc' ;
$plet['_p41']['default_value']='ALL' ;
$plet['_p41']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p41']['all_label']='ALL' ;
$plet['_p41']['all_value']='%' ;
$plet['_p41']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p41']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p41']['default_null_value']='%';  // ;
$plet['_p41']['static_values']='' ;
$plet['_p41']['static_display_values']= $plet['_p41']['static_values']  ;
$plet['_p41']['sql']= <<<EOD

EOD;




/************** _p40 *********************/
$plet['_p40']['id']='_p40' ;
$plet['_p40']['name']='' ;
$plet['_p40']['raw_type']='BLET' ;
$plet['_p40']['connection']='Excel Demo' ;
$plet['_p40']['width']=284 ;
$plet['_p40']['height']=69 - 27 ;
$plet['_p40']['x_position']=690 ;
$plet['_p40']['y_position']=77 ;
$plet['_p40']['format']='dd-M-yy' ;
$plet['_p40']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:16px' ;
$plet['_p40']['font_color']='#000000' ;
$plet['_p40']['background_color']='#cccc00' ;
$plet['_p40']['default_value']='ALL' ;
$plet['_p40']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p40']['all_label']='ALL' ;
$plet['_p40']['all_value']='%' ;
$plet['_p40']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p40']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p40']['default_null_value']='%';  // ;
$plet['_p40']['static_values']='' ;
$plet['_p40']['static_display_values']= $plet['_p40']['static_values']  ;
$plet['_p40']['sql']= <<<EOD

EOD;




/************** region_p34 *********************/
$plet['region_p34']['type']='dynamic_lov' ;
$plet['region_p34']['data_type']='CHAR' ;
$plet['region_p34']['id']='region_p34' ;
$plet['region_p34']['name']='Region' ;
$plet['region_p34']['raw_type']='PLET' ;
$plet['region_p34']['connection']='Excel Demo' ;
$plet['region_p34']['width']=192 ;
$plet['region_p34']['height']=50 - 27 ;
$plet['region_p34']['x_position']=130 ;
$plet['region_p34']['y_position']=217 ;
$plet['region_p34']['format']='dd-M-yy' ;
$plet['region_p34']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:12px' ;
$plet['region_p34']['font_color']='#0033ff' ;
$plet['region_p34']['background_color']='#ccccff' ;
$plet['region_p34']['default_value']='ALL Values' ;
$plet['region_p34']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['region_p34']['all_label']='ALL' ;
$plet['region_p34']['all_value']='%' ;
$plet['region_p34']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['region_p34']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['region_p34']['default_null_value']='%';  // ;
$plet['region_p34']['static_values']='' ;
$plet['region_p34']['static_display_values']= $plet['region_p34']['static_values']  ;
$plet['region_p34']['sql']= <<<EOD
 select 
 distinct "Country_Region" 
,country_region 
 from ( select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x  )  as  x  
EOD;




/************** year_p32 *********************/
$plet['year_p32']['type']='dynamic_lov' ;
$plet['year_p32']['data_type']='CHAR' ;
$plet['year_p32']['id']='year_p32' ;
$plet['year_p32']['name']='Year' ;
$plet['year_p32']['raw_type']='PLET' ;
$plet['year_p32']['connection']='Excel Demo' ;
$plet['year_p32']['width']=100 ;
$plet['year_p32']['height']=50 - 27 ;
$plet['year_p32']['x_position']=26 ;
$plet['year_p32']['y_position']=217 ;
$plet['year_p32']['format']='dd-M-yy' ;
$plet['year_p32']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:12px' ;
$plet['year_p32']['font_color']='#0033ff' ;
$plet['year_p32']['background_color']='#ccccff' ;
$plet['year_p32']['default_value']='2001' ;
$plet['year_p32']['enable_all']='N' ;
$plet['year_p32']['all_label']='ALL' ;
$plet['year_p32']['all_value']='%' ;
$plet['year_p32']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['year_p32']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['year_p32']['default_null_value']='%';  // ;
$plet['year_p32']['static_values']='' ;
$plet['year_p32']['static_display_values']= $plet['year_p32']['static_values']  ;
$plet['year_p32']['sql']= <<<EOD
 select 
 distinct trim(fiscal_year) 
 From 
      [detail_data$]     
EOD;




/************** _p46 *********************/
$plet['_p46']['id']='_p46' ;
$plet['_p46']['name']='' ;
$plet['_p46']['raw_type']='STATIC' ;
$plet['_p46']['connection']='Excel Demo' ;
$plet['_p46']['width']=446 ;
$plet['_p46']['height']=55 - 27 ;
$plet['_p46']['x_position']=202 ;
$plet['_p46']['y_position']=154 ;
$plet['_p46']['format']='dd-M-yy' ;
$plet['_p46']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:12px' ;
$plet['_p46']['font_color']='#3300cc' ;
$plet['_p46']['background_color']='#ffffff' ;
$plet['_p46']['default_value']='ALL' ;
$plet['_p46']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p46']['all_label']='ALL' ;
$plet['_p46']['all_value']='%' ;
$plet['_p46']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p46']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p46']['default_null_value']='%';  // ;
$plet['_p46']['static_values']='' ;
$plet['_p46']['static_display_values']= $plet['_p46']['static_values']  ;
$plet['_p46']['sql']= <<<EOD
NOTE: You can always launch this sample dashboard by going to
menu Run -> Open Sample Dashboard
EOD;




/************** _p36 *********************/
$plet['_p36']['id']='_p36' ;
$plet['_p36']['name']='' ;
$plet['_p36']['raw_type']='STATIC' ;
$plet['_p36']['connection']='Excel Demo' ;
$plet['_p36']['width']=446 ;
$plet['_p36']['height']=79 - 27 ;
$plet['_p36']['x_position']=14 ;
$plet['_p36']['y_position']=73 ;
$plet['_p36']['format']='dd-M-yy' ;
$plet['_p36']['font']='font-family:Arial;font-name:Arial;font-style:bold;font-size:12px' ;
$plet['_p36']['font_color']='#3366ff' ;
$plet['_p36']['background_color']='#ffffff' ;
$plet['_p36']['default_value']='ALL' ;
$plet['_p36']['enable_all']='INCLUDE_ALL_AS_LIKE' ;
$plet['_p36']['all_label']='ALL' ;
$plet['_p36']['all_value']='%' ;
$plet['_p36']['display_members']='1';  //value decides whether it is a multilist combo or single selection ;
$plet['_p36']['control_type']='LIST';  //In future, other values could be radio,slider,checkbox etc ;
$plet['_p36']['default_null_value']='%';  // ;
$plet['_p36']['static_values']='' ;
$plet['_p36']['static_display_values']= $plet['_p36']['static_values']  ;
$plet['_p36']['sql']= <<<EOD
The following charts and tables are derived from Excel data.
What you see is truly interactive dashboard (try changing Parameters)
You can build this kind of dashboard without any CODE

EOD;


$d_options['top_button_x_location']=996;//X position where the Go button will appear
$d_options['top_button_y_location']=$d_options['top_button_offset'] +15;//Y Position of the Go button
$d_options['top_button_width']=40;//Width of the Go button
$d_options['top_button_height']=20;//Height of the Go Button
$d_options['use_go_checkobx_x_location']=996+$d_options['top_button_width']+5 ;//X- position of the Checkbox. The checkbox is used to disable AutoRefresh when you change the drop down value
$plet['list'] = array ('_p35' , '_p47' , '_p43' , '_p44' , '_p41' , '_p40' , 'region_p34' , 'year_p32' , '_p46' , '_p36');


$plet_group['list'] =array('g1'); 
$plet_group['g1']['label']='Select Values'; 
$plet_group['g1']['members'] = array ('_p35' , '_p47' , '_p43' , '_p44' , '_p41' , '_p40' , 'region_p34' , 'year_p32' , '_p46' , '_p36');


$plet_group['g1']['width']=700; 


/******************************Parameter End********************************/
$qlet['relative_position']=true;// 



/************** details_q31 *********************/
$qlet['details_q31']['id']='details_q31' ;
$qlet['details_q31']['name']='Details' ;
$qlet['details_q31']['type']='table' ;
$qlet['details_q31']['connection']='Excel Demo' ;
$qlet['details_q31']['width']=937 ;
$qlet['details_q31']['height']=489 ;
$qlet['details_q31']['x_position']=27 ;
$qlet['details_q31']['y_position']=789 ;
$qlet['details_q31']['max_rows']=100 ;
$qlet['details_q31']['number_of_columns']=14 ;
$qlet['details_q31']['show_pager']= false  ;
$qlet['details_q31']['column_names']= array('Promo_Name','Promo_Id','Promo_Category','Promo_Cost','Calendar_Month_Name','Fiscal_Year','Prod_Category','Channel_Class','Country_Name','Country_Subregion','Country_Region','Cust_State_Province','Quantity_Sold','Amount_Sold' ) ;
$qlet['details_q31']['column_display_names']= array('Promo_Name','Promo_Id','Promo_Category','Promo_Cost','Calendar_Month_Name','Fiscal_Year','Prod_Category','Channel_Class','Country_Name','Country_Subregion','Country_Region','Cust_State_Province','Quantity_Sold','Amount_Sold' ) ;
$qlet['details_q31']['column_alignment']= array('left','right','left','right','left','right','left','left','left','left','left','left','right','right' ) ;
$qlet['details_q31']['column_class']= array('String','Double','String','Double','String','Double','String','String','String','String','String','String','Double','Double' ) ;
$qlet['details_q31']['column_width']= array(75,75,75,75,75,75,75,75,75,75,75,75,75,75 ) ;

//Make sure the primary column is marked as non-editable.
$qlet['details_q31']['edit_options']= array("editable:false","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true","editable:true" ) ;
$qlet['details_q31']['insert_template']=''; 
$qlet['details_q31']['edit_template']=''; 
$qlet['details_q31']['delete_template']=''; 
$qlet['details_q31']['template'] = <<<EOT

  jQuery("#details_q31").jqGrid({
    #url#,
    datatype: 'xml',
    mtype: 'POST',
    #column_names#,
    #column_model#,
    #pager_str#,
    rowNum:100,
    rowList:[100,200,300],
    sortname: '',
    sortorder: "desc",
    rowHeight:10,
    scrollOffset:0,
    viewrecords: true,
        height:#height#,
        width:{$qlet['details_q31']['width']},
    imgpath: 'themes/basic/images',
        #edit_url#,
    caption: '{$qlet['details_q31']['name']}',
                footerrow : false,
        userDataOnFooter : false,
        viewsortcols: false,
        altRows:true,
        ExpandColClick: true,
        altclass: 'other_row',
        mtype:'POST',
        loadError : function(xhr,st,err)
        {
    	//jQuery("#status").html("Type: "+st+"; Response: "+ xhr.status + " "+xhr.statusText);
        },
        loadComplete: function()
        {

        }
  }).navGrid('#pager_details_q31',{view:true,edit:true,add:true,del:true});
EOT;

$qlet['details_q31']['background_color']= '' ;
$qlet['details_q31']['enable_column_sort']= 'Y' ;
$qlet['details_q31']['dynamic_script']= <<<EOD
  
EOD;
$qlet['details_q31']['total_script']= <<<EOD
  
EOD;
$qlet['details_q31']['sql']= <<<EOD
 select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'   
EOD;




/**************  *********************/


/************** byproductcategory_g37 *********************/
$qlet['byproductcategory_g37']['id']='byproductcategory_g37' ;
$qlet['byproductcategory_g37']['name']='By Product Category' ;
$qlet['byproductcategory_g37']['type']=  'chart_pie' ;
$qlet['byproductcategory_g37']['connection']='Excel Demo' ;
$qlet['byproductcategory_g37']['original_type']='chart' ;
$qlet['byproductcategory_g37']['width']=312 ;
$qlet['byproductcategory_g37']['height']=250 ;
$qlet['byproductcategory_g37']['x_position']=28 ;
$qlet['byproductcategory_g37']['y_position']=537 ;
$qlet['byproductcategory_g37']['max_rows']=100 ;
$qlet['byproductcategory_g37']['number_of_columns']=2 ;
$qlet['byproductcategory_g37']['column_names']= array('Prod_Category','SUM_Quantity_Sold' ) ;
$qlet['byproductcategory_g37']['column_display_names']= array('Prod_Category','SUM_Quantity_Sold' ) ;
$qlet['byproductcategory_g37']['column_alignment']= array('right','right' ) ;
$qlet['byproductcategory_g37']['column_width']= array(156,156 ) ;
$qlet['byproductcategory_g37']['display_tooltip']= true  ;
$qlet['byproductcategory_g37']['tooltip_template']= <<<EOD
#percent#%, #label# = #value#
EOD;
$qlet['byproductcategory_g37']['background_color']= 'FFFFFF' ;
$qlet['byproductcategory_g37']['total_script']= <<<EOD
  
EOD;
$qlet['byproductcategory_g37']['sql']= <<<EOD
 Select   "Prod_Category", SUM( "Quantity_Sold" ) as "SUM_Quantity_Sold" 
from ( 
select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'  
 )  as  g_tabx
 group by "Prod_Category" 
EOD;
$qlet['byproductcategory_g37']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['byproductcategory_g37']['chart_size']=
                           array(
                                 width=>$qlet['byproductcategory_g37']['width'] - $qlet['byproductcategory_g37']['chart_margin']['left']- $qlet['byproductcategory_g37']['chart_margin']['right']
                                ,height =>$qlet['byproductcategory_g37']['height'] - $qlet['byproductcategory_g37']['chart_margin']['top']- $qlet['byproductcategory_g37']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['byproductcategory_g37']['chart_position']=
                           array(
                                 top_x=> $qlet['byproductcategory_g37']['chart_margin']['left']
                                ,top_y => $qlet['byproductcategory_g37']['chart_margin']['top']
                                 );
                                 
$qlet['byproductcategory_g37']['legend']=
                           array(
                                 width=> $qlet['byproductcategory_g37']['width'] - $qlet['byproductcategory_g37']['chart_margin']['left']- $qlet['byproductcategory_g37']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['byproductcategory_g37']['chart_margin']['left']
                                ,top_y => $qlet['byproductcategory_g37']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$qlet['byproductcategory_g37']['template']= <<<EOD

	<chart_label  size='10'  as_percentage='true'/>  
	
<chart_rect x='0' y='20' width='{$qlet['byproductcategory_g37']['width']}' height='{$percent($qlet['byproductcategory_g37']['height']-20,65)}' positive_color='000000' positive_alpha='0' negative_color='ff0000' negative_alpha='0' />		

 <legend layout='horizontal' 
           fill_color='F0EBE6'
           bullet='square'
           font='arial'
           bold='true'
           size='10'
		  width='{$percent($qlet['byproductcategory_g37']['width'],80)}'
		  height='{$percent($qlet['byproductcategory_g37']['height']-20,35)}'
		   y='{$get_position($qlet['byproductcategory_g37']['height'],20,35)}'
           alpha='90'
           />			
		   
  <draw>
   <text   size='15' x='0' y='0' width='{$qlet['byproductcategory_g37']['width']}' height='20' h_align='center' v_align='top'>{$qlet['byproductcategory_g37']['name']}</text>
  </draw>
  
<chart_pref
        select='true'            
            />   
  
	<chart_type>#chart_type#</chart_type>

    	#chart_data#

EOD;




/**************  *********************/


/************** bychannel_g36 *********************/
$qlet['bychannel_g36']['id']='bychannel_g36' ;
$qlet['bychannel_g36']['name']='By channel' ;
$qlet['bychannel_g36']['type']=  'chart_pie' ;
$qlet['bychannel_g36']['connection']='Excel Demo' ;
$qlet['bychannel_g36']['original_type']='chart' ;
$qlet['bychannel_g36']['width']=312 ;
$qlet['bychannel_g36']['height']=250 ;
$qlet['bychannel_g36']['x_position']=656 ;
$qlet['bychannel_g36']['y_position']=537 ;
$qlet['bychannel_g36']['max_rows']=100 ;
$qlet['bychannel_g36']['number_of_columns']=2 ;
$qlet['bychannel_g36']['column_names']= array('Channel_Class','SUM_Quantity_Sold' ) ;
$qlet['bychannel_g36']['column_display_names']= array('Channel_Class','SUM_Quantity_Sold' ) ;
$qlet['bychannel_g36']['column_alignment']= array('right','right' ) ;
$qlet['bychannel_g36']['column_width']= array(156,156 ) ;
$qlet['bychannel_g36']['display_tooltip']= true  ;
$qlet['bychannel_g36']['tooltip_template']= <<<EOD
#percent#%, #label# = #value#
EOD;
$qlet['bychannel_g36']['background_color']= 'FFFFFF' ;
$qlet['bychannel_g36']['total_script']= <<<EOD
  
EOD;
$qlet['bychannel_g36']['sql']= <<<EOD
 Select   "Channel_Class", SUM( "Quantity_Sold" ) as "SUM_Quantity_Sold" 
from ( 
select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'  
 )  as  g_tabx
 group by "Channel_Class" 
EOD;
$qlet['bychannel_g36']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['bychannel_g36']['chart_size']=
                           array(
                                 width=>$qlet['bychannel_g36']['width'] - $qlet['bychannel_g36']['chart_margin']['left']- $qlet['bychannel_g36']['chart_margin']['right']
                                ,height =>$qlet['bychannel_g36']['height'] - $qlet['bychannel_g36']['chart_margin']['top']- $qlet['bychannel_g36']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['bychannel_g36']['chart_position']=
                           array(
                                 top_x=> $qlet['bychannel_g36']['chart_margin']['left']
                                ,top_y => $qlet['bychannel_g36']['chart_margin']['top']
                                 );
                                 
$qlet['bychannel_g36']['legend']=
                           array(
                                 width=> $qlet['bychannel_g36']['width'] - $qlet['bychannel_g36']['chart_margin']['left']- $qlet['bychannel_g36']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['bychannel_g36']['chart_margin']['left']
                                ,top_y => $qlet['bychannel_g36']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$qlet['bychannel_g36']['template']= <<<EOD

	<chart_label  size='10'  as_percentage='true'/>  
	
<chart_rect x='0' y='20' width='{$qlet['bychannel_g36']['width']}' height='{$percent($qlet['bychannel_g36']['height']-20,65)}' positive_color='000000' positive_alpha='0' negative_color='ff0000' negative_alpha='0' />		

 <legend layout='horizontal' 
           fill_color='F0EBE6'
           bullet='square'
           font='arial'
           bold='true'
           size='10'
		  width='{$percent($qlet['bychannel_g36']['width'],80)}'
		  height='{$percent($qlet['bychannel_g36']['height']-20,35)}'
		   y='{$get_position($qlet['bychannel_g36']['height'],20,35)}'
           alpha='90'
           />			
		   
  <draw>
   <text   size='15' x='0' y='0' width='{$qlet['bychannel_g36']['width']}' height='20' h_align='center' v_align='top'>{$qlet['bychannel_g36']['name']}</text>
  </draw>
  
<chart_pref
        select='true'            
            />   
  
	<chart_type>#chart_type#</chart_type>

    	#chart_data#

EOD;




/**************  *********************/


/************** bypromocategory_g38 *********************/
$qlet['bypromocategory_g38']['id']='bypromocategory_g38' ;
$qlet['bypromocategory_g38']['name']='By Promo Category' ;
$qlet['bypromocategory_g38']['type']=  'chart_pie' ;
$qlet['bypromocategory_g38']['connection']='Excel Demo' ;
$qlet['bypromocategory_g38']['original_type']='chart' ;
$qlet['bypromocategory_g38']['width']=312 ;
$qlet['bypromocategory_g38']['height']=250 ;
$qlet['bypromocategory_g38']['x_position']=341 ;
$qlet['bypromocategory_g38']['y_position']=537 ;
$qlet['bypromocategory_g38']['max_rows']=100 ;
$qlet['bypromocategory_g38']['number_of_columns']=2 ;
$qlet['bypromocategory_g38']['column_names']= array('Promo_Category','SUM_Quantity_Sold' ) ;
$qlet['bypromocategory_g38']['column_display_names']= array('Promo_Category','SUM_Quantity_Sold' ) ;
$qlet['bypromocategory_g38']['column_alignment']= array('right','right' ) ;
$qlet['bypromocategory_g38']['column_width']= array(156,156 ) ;
$qlet['bypromocategory_g38']['display_tooltip']= true  ;
$qlet['bypromocategory_g38']['tooltip_template']= <<<EOD
#percent#%, #label# = #value#
EOD;
$qlet['bypromocategory_g38']['background_color']= 'FFFFFF' ;
$qlet['bypromocategory_g38']['total_script']= <<<EOD
  
EOD;
$qlet['bypromocategory_g38']['sql']= <<<EOD
 Select   "Promo_Category", SUM( "Quantity_Sold" ) as "SUM_Quantity_Sold" 
from ( 
select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'  
 )  as  g_tabx
 group by "Promo_Category" 
EOD;
$qlet['bypromocategory_g38']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['bypromocategory_g38']['chart_size']=
                           array(
                                 width=>$qlet['bypromocategory_g38']['width'] - $qlet['bypromocategory_g38']['chart_margin']['left']- $qlet['bypromocategory_g38']['chart_margin']['right']
                                ,height =>$qlet['bypromocategory_g38']['height'] - $qlet['bypromocategory_g38']['chart_margin']['top']- $qlet['bypromocategory_g38']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['bypromocategory_g38']['chart_position']=
                           array(
                                 top_x=> $qlet['bypromocategory_g38']['chart_margin']['left']
                                ,top_y => $qlet['bypromocategory_g38']['chart_margin']['top']
                                 );
                                 
$qlet['bypromocategory_g38']['legend']=
                           array(
                                 width=> $qlet['bypromocategory_g38']['width'] - $qlet['bypromocategory_g38']['chart_margin']['left']- $qlet['bypromocategory_g38']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['bypromocategory_g38']['chart_margin']['left']
                                ,top_y => $qlet['bypromocategory_g38']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$qlet['bypromocategory_g38']['template']= <<<EOD

	<chart_label  size='10'  as_percentage='true'/>  
	
<chart_rect x='0' y='20' width='{$qlet['bypromocategory_g38']['width']}' height='{$percent($qlet['bypromocategory_g38']['height']-20,65)}' positive_color='000000' positive_alpha='0' negative_color='ff0000' negative_alpha='0' />		

 <legend layout='horizontal' 
           fill_color='F0EBE6'
           bullet='square'
           font='arial'
           bold='true'
           size='10'
		  width='{$percent($qlet['bypromocategory_g38']['width'],80)}'
		  height='{$percent($qlet['bypromocategory_g38']['height']-20,35)}'
		   y='{$get_position($qlet['bypromocategory_g38']['height'],20,35)}'
           alpha='90'
           />			
		   
  <draw>
   <text   size='15' x='0' y='0' width='{$qlet['bypromocategory_g38']['width']}' height='20' h_align='center' v_align='top'>{$qlet['bypromocategory_g38']['name']}</text>
  </draw>
  
<chart_pref
        select='true'            
            />   
  
	<chart_type>#chart_type#</chart_type>

    	#chart_data#

EOD;




/**************  *********************/


/************** categoryavgsold(in1000)_g35 *********************/
$qlet['categoryavgsoldin1000_g35']['id']='categoryavgsoldin1000_g35' ;
$qlet['categoryavgsoldin1000_g35']['name']='Category Avg Sold (in 1000)' ;
$qlet['categoryavgsoldin1000_g35']['type']=  'gauge_dial' ;
$qlet['categoryavgsoldin1000_g35']['connection']='Excel Demo' ;
$qlet['categoryavgsoldin1000_g35']['original_type']='chart' ;
$qlet['categoryavgsoldin1000_g35']['width']=312 ;
$qlet['categoryavgsoldin1000_g35']['height']=250 ;
$qlet['categoryavgsoldin1000_g35']['x_position']=656 ;
$qlet['categoryavgsoldin1000_g35']['y_position']=283 ;
$qlet['categoryavgsoldin1000_g35']['max_rows']=100 ;
$qlet['categoryavgsoldin1000_g35']['number_of_columns']=10 ;
$qlet['categoryavgsoldin1000_g35']['column_names']= array('avg_unit','l1','h1','c1','l2','h2','c2','l3','h3','c3' ) ;
$qlet['categoryavgsoldin1000_g35']['column_display_names']= array('avg_unit','l1','h1','c1','l2','h2','c2','l3','h3','c3' ) ;
$qlet['categoryavgsoldin1000_g35']['column_alignment']= array('right','right','right','right','right','right','right','right','right','right' ) ;
$qlet['categoryavgsoldin1000_g35']['column_width']= array(31,31,31,31,31,31,31,31,31,31 ) ;
$qlet['categoryavgsoldin1000_g35']['display_tooltip']= true  ;
$qlet['categoryavgsoldin1000_g35']['tooltip_template']= "#label# = #value#"  ;
$qlet['categoryavgsoldin1000_g35']['background_color']= 'FFFFFF' ;
$qlet['categoryavgsoldin1000_g35']['total_script']= <<<EOD
  
EOD;
$qlet['categoryavgsoldin1000_g35']['sql']= <<<EOD
 Select   AVG(qty_sold)/1000   as avg_unit, 0 as l1, 25 as h1, 'default' as c1, 25 as l2, 45 as h2, 'default' as c2, 45 as l3, 120 as h3, '(120,120,250)' as c3
from ( 
select prod_category, sum(quantity_sold) as qty_sold,
sum(amount_sold) as amt_sold
from [detail_data$]
where fiscal_year =     PVAL['year_p32']
and country_region like     'PVAL['region_p34']'    
group by prod_category
order by sum(amount_sold) desc

 ) as g_tabx 
EOD;
$qlet['categoryavgsoldin1000_g35']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['categoryavgsoldin1000_g35']['chart_size']=
                           array(
                                 width=>$qlet['categoryavgsoldin1000_g35']['width'] - $qlet['categoryavgsoldin1000_g35']['chart_margin']['left']- $qlet['categoryavgsoldin1000_g35']['chart_margin']['right']
                                ,height =>$qlet['categoryavgsoldin1000_g35']['height'] - $qlet['categoryavgsoldin1000_g35']['chart_margin']['top']- $qlet['categoryavgsoldin1000_g35']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['categoryavgsoldin1000_g35']['chart_position']=
                           array(
                                 top_x=> $qlet['categoryavgsoldin1000_g35']['chart_margin']['left']
                                ,top_y => $qlet['categoryavgsoldin1000_g35']['chart_margin']['top']
                                 );
                                 
$qlet['categoryavgsoldin1000_g35']['legend']=
                           array(
                                 width=> $qlet['categoryavgsoldin1000_g35']['width'] - $qlet['categoryavgsoldin1000_g35']['chart_margin']['left']- $qlet['categoryavgsoldin1000_g35']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['categoryavgsoldin1000_g35']['chart_margin']['left']
                                ,top_y => $qlet['categoryavgsoldin1000_g35']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$title_height=20;
$qlet['categoryavgsoldin1000_g35']['x_center']= $qlet['categoryavgsoldin1000_g35']['width']/2 ;
$qlet['categoryavgsoldin1000_g35']['y_center']= ($qlet['categoryavgsoldin1000_g35']['height']- $title_height)/2 +$title_height ;
$qlet['categoryavgsoldin1000_g35']['radius']= min ($qlet['categoryavgsoldin1000_g35']['width'], $qlet['categoryavgsoldin1000_g35']['height']- $title_height)/2 -10 ;//radius of the outer circle
$qlet['categoryavgsoldin1000_g35']['range_radius']= $qlet['categoryavgsoldin1000_g35']['radius']*0.915 ;//radius of the colorful ranges
$qlet['categoryavgsoldin1000_g35']['tick_radius']= $qlet['categoryavgsoldin1000_g35']['range_radius'] * 0.90;//radius of the number markers
$qlet['categoryavgsoldin1000_g35']['number_radius']= $qlet['categoryavgsoldin1000_g35']['tick_radius'] * 0.90;//
$qlet['categoryavgsoldin1000_g35']['major_ticks']= 
                                array(
                                      color     => '000000' ,
                                      length    => 10,
                                      thickness => 3,
                                      number_of_parts => 10); //0 is for auto- engine will compute the increment automatically by dividing the range into 10 equal parts,
                   
$qlet['categoryavgsoldin1000_g35']['minor_ticks']= 
                                array(
                                      color     => '000000' ,
                                      length    => 5,
                                      thickness => 1,
                                      number_of_parts => 4); //this will divide the major tick into equal parts. 0 will indicate to divide the major ticks into 10 equal parts
                   

//ticks_range_angle is the span of the dial that will use to display the ticks and numbers.
$qlet['categoryavgsoldin1000_g35']['ticks_range_angle']= array(start_angle => -120, end_angle =>120);//The 12 o'clock position is the zero angle position. Anything clockwise from 12'0clock position is positive angle and anything anti-clockwise is -ve angle. For complete circle use -180 to +180.
$qlet['categoryavgsoldin1000_g35']['tick_numbers']= array(font_size => $qlet['categoryavgsoldin1000_g35']['radius']*0.15, color =>'000000');//The 12 o'clock position is the zero angle position. Anything clockwise from 12'0clock position is positive angle and anything anti-clockwise is -ve angle. For complete circle use -180 to +180.


//

//

//the gauge is divided into multiple sections. typically it has 3 sections but you may have as many of them as needed
//each section is defined by a numeric range and has its own color
//the range is defined between start and end value. The attribute define the properties of the section such as color etc
                   $qlet['categoryavgsoldin1000_g35']['range']=

             array(
                           array( start_value => 0,
                      end_value => 25,
                      attributes => "<circle x='#x_center#' y='#y_center#' radius='#radius#' fill_color='008400' fill_alpha='100' line_thickness='1' line_color='008400' line_alpha='90' />"
                    ) , 
              array( start_value => 25,
                      end_value => 45,
                      attributes => "<circle x='#x_center#' y='#y_center#' radius='#radius#' fill_color='ffff00' fill_alpha='100' line_thickness='1' line_color='ffff00' line_alpha='90' />"
                    ) , 
              array( start_value => 45,
                      end_value => 120,
                      attributes => "<circle x='#x_center#' y='#y_center#' radius='#radius#' fill_color='7878fa' fill_alpha='100' line_thickness='1' line_color='7878fa' line_alpha='90' />"
                    )
             );
$qlet['categoryavgsoldin1000_g35']['pointer']['radius']=$qlet['categoryavgsoldin1000_g35']['radius'] - 5; //

//relative co-ordinates from the center of the gauge. This polygon will define the shape of the pointer
//for e.g if you need a 2 pixel thick line, then you just need a 4 (x,y) points relative to the center of the gauge
$qlet['categoryavgsoldin1000_g35']['pointer']['points']=
                                  array(
                                         array ( x => 3.5, y => 0),
                                         array ( x => 0, y => -$qlet['categoryavgsoldin1000_g35']['pointer']['radius']),
                                         array ( x => -0, y => -$qlet['categoryavgsoldin1000_g35']['pointer']['radius']),
                                         array ( x => -3.5 , y=> 0),
                                       );
                                         
$qlet['categoryavgsoldin1000_g35']['pointer']['attributes']=<<<EOD
<polygon fill_color='DEffff' fill_alpha='90' line_alpha='0'>
EOD;


$qlet['categoryavgsoldin1000_g35']['pointer']['value']=
                                   array(
                                           decimals=>0 , decimal_str => '.' , thousand_separator => ','
                                         );
$qlet['categoryavgsoldin1000_g35']['text_x']=$qlet['categoryavgsoldin1000_g35']['x_center']-$qlet['categoryavgsoldin1000_g35']['radius'] * 0.90;
$qlet['categoryavgsoldin1000_g35']['text_y']=$qlet['categoryavgsoldin1000_g35']['y_center']+$qlet['categoryavgsoldin1000_g35']['radius'] * 0.22;
$qlet['categoryavgsoldin1000_g35']['text_width']=$qlet['categoryavgsoldin1000_g35']['radius'] * 1.80;
$qlet['categoryavgsoldin1000_g35']['template']= <<<EOD

<text   size='15' x='0' y='0' width='{$qlet['categoryavgsoldin1000_g35']['width']}' height='{$title_height}' align='center' >{$qlet['categoryavgsoldin1000_g35']['name']}</text>

	<circle  x='#x_center#' y='#y_center#' radius='#radius#' fill_color='FFFFFF' fill_alpha='100' line_thickness='6' line_color='333333' line_alpha='90' />

     	#range_code#

        <circle x='#x_center#' y='#y_center#' radius='{$percent($qlet['categoryavgsoldin1000_g35']['radius'],33)}' fill_color='FFFFFF' fill_alpha='255' line_thickness='0' line_alpha='50' />
	#radial_ticks#

        #radial_numbers#
        #pointer_code#

        <circle x='#x_center#' y='#y_center#' radius='{$percent($qlet['categoryavgsoldin1000_g35']['radius'],84)}' start='135' end='225' fill_color='111111' fill_alpha='80' />
        <circle x='#x_center#' y='#y_center#' radius='{$percent($qlet['categoryavgsoldin1000_g35']['radius'],15)}' fill_color='111111' fill_alpha='100' line_thickness='5' line_alpha='50' />





	<text x='{$qlet['categoryavgsoldin1000_g35']['text_x']}' y='{$qlet['categoryavgsoldin1000_g35']['text_y']}' width='{$qlet['categoryavgsoldin1000_g35']['text_width']}' size='{$percent($qlet['categoryavgsoldin1000_g35']['radius'],21.5)}' color='cccfff' alpha='70' align='center'>#pointer_value# 
Unit</text>

	

EOD;




/**************  *********************/


/************** byperiod_g34 *********************/
$qlet['byperiod_g34']['id']='byperiod_g34' ;
$qlet['byperiod_g34']['name']='By Period' ;
$qlet['byperiod_g34']['type']=  'chart_column' ;
$qlet['byperiod_g34']['connection']='Excel Demo' ;
$qlet['byperiod_g34']['original_type']='chart' ;
$qlet['byperiod_g34']['width']=312 ;
$qlet['byperiod_g34']['height']=250 ;
$qlet['byperiod_g34']['x_position']=340 ;
$qlet['byperiod_g34']['y_position']=283 ;
$qlet['byperiod_g34']['max_rows']=100 ;
$qlet['byperiod_g34']['number_of_columns']=2 ;
$qlet['byperiod_g34']['column_names']= array('Calendar_Month_Name','SUM_Quantity_Sold' ) ;
$qlet['byperiod_g34']['column_display_names']= array('Calendar_Month_Name','SUM_Quantity_Sold' ) ;
$qlet['byperiod_g34']['column_alignment']= array('right','right' ) ;
$qlet['byperiod_g34']['column_width']= array(156,156 ) ;
$qlet['byperiod_g34']['display_tooltip']= true  ;
$qlet['byperiod_g34']['tooltip_template']= "#label# = #value#"  ;
$qlet['byperiod_g34']['background_color']= 'FFFFFF' ;
$qlet['byperiod_g34']['total_script']= <<<EOD
  
EOD;
$qlet['byperiod_g34']['sql']= <<<EOD
 Select   "Calendar_Month_Name", SUM( "Quantity_Sold" ) as "SUM_Quantity_Sold" 
from ( 
select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'  
 )  as  g_tabx
 group by "Calendar_Month_Name" 
EOD;
$qlet['byperiod_g34']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['byperiod_g34']['chart_size']=
                           array(
                                 width=>$qlet['byperiod_g34']['width'] - $qlet['byperiod_g34']['chart_margin']['left']- $qlet['byperiod_g34']['chart_margin']['right']
                                ,height =>$qlet['byperiod_g34']['height'] - $qlet['byperiod_g34']['chart_margin']['top']- $qlet['byperiod_g34']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['byperiod_g34']['chart_position']=
                           array(
                                 top_x=> $qlet['byperiod_g34']['chart_margin']['left']
                                ,top_y => $qlet['byperiod_g34']['chart_margin']['top']
                                 );
                                 
$qlet['byperiod_g34']['legend']=
                           array(
                                 width=> $qlet['byperiod_g34']['width'] - $qlet['byperiod_g34']['chart_margin']['left']- $qlet['byperiod_g34']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['byperiod_g34']['chart_margin']['left']
                                ,top_y => $qlet['byperiod_g34']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$qlet['byperiod_g34']['template']= <<<EOD
	<chart_guide horizontal='true' vertical='true' thickness='1' color='000000' alpha='35' type='dashed' radius='3' fill_alpha='75' line_alpha='0' background_color='FF4400' text_h_alpha='90' text_v_alpha='90' prefix_h=' ' suffix_h=' ' suffix_v=' ' />
	<chart_label  color='000000' alpha='50' size='8' position='middle' as_percentage='true'/>  


	<chart_grid_h thickness='1' type='solid' />


	<series bar_gap='0' set_gap='20' transfer='false' />
	
	<axis_category alpha='75' orientation='diagonal_up' size='9'/>
	
	<axis_value  
         	prefix=''  
			suffix=''  
            decimals=''
            decimal_char=''  
            separator='' 
            show_min='true' 
            size='10' 
            alpha='75'
            orientation='diagonal_up' 
            />

 <legend layout='horizontal' 
           fill_color='F0EBE6'
           bullet='square'
           font='arial'
           bold='true'
           size='10'
 		   width='{$qlet['byperiod_g34']['legend']['width']}'
		   height='{$qlet['byperiod_g34']['legend']['height']}'
		   x='{$qlet['byperiod_g34']['legend']['top_x']}'		   
		   y='{$qlet['byperiod_g34']['legend']['top_y']}'
           alpha='90'
           />			
		   
<chart_rect x='{$qlet['byperiod_g34']['chart_position']['top_x']}' 
            y='{$qlet['byperiod_g34']['chart_position']['top_y']}' 
			width='{$qlet['byperiod_g34']['chart_size']['width']}' 
			height='{$qlet['byperiod_g34']['chart_size']['height']}' 
			positive_color='000000' positive_alpha='0' negative_color='ff0000' negative_alpha='0' />				   
  <draw>
   <text   size='15' x='0' y='0' width='{$qlet['byperiod_g34']['width']}' height='20' h_align='center' v_align='top'>{$qlet['byperiod_g34']['name']}</text>
  </draw> 		   
  
<chart_pref line_thickness='3'     
            point_shape='square'     
            point_size='7'
            fill_shape='false'
            connect='false'
            tip='none'
                        
            
            point_size='7'         
            point_shape='square'
            trend_thickness='3'
            trend_alpha='20'
            line_thickness='0'
            
            rotation_x='30'        
            rotation_y='30'
            drag='true'
    

            select='true'            
            
            zero_line='true'      
            />   
  
	<chart_type>#chart_type#</chart_type>

    	#chart_data#
		
		#link_data#
EOD;




/**************  *********************/


/************** topcountries_g33 *********************/
$qlet['topcountries_g33']['id']='topcountries_g33' ;
$qlet['topcountries_g33']['name']='Top Countries' ;
$qlet['topcountries_g33']['type']=  'chart_column' ;
$qlet['topcountries_g33']['connection']='Excel Demo' ;
$qlet['topcountries_g33']['original_type']='chart' ;
$qlet['topcountries_g33']['width']=312 ;
$qlet['topcountries_g33']['height']=250 ;
$qlet['topcountries_g33']['x_position']=26 ;
$qlet['topcountries_g33']['y_position']=283 ;
$qlet['topcountries_g33']['max_rows']=100 ;
$qlet['topcountries_g33']['number_of_columns']=2 ;
$qlet['topcountries_g33']['column_names']= array('Country_Name','SUM_Quantity_Sold' ) ;
$qlet['topcountries_g33']['column_display_names']= array('Country_Name','SUM_Quantity_Sold' ) ;
$qlet['topcountries_g33']['column_alignment']= array('right','right' ) ;
$qlet['topcountries_g33']['column_width']= array(156,156 ) ;
$qlet['topcountries_g33']['display_tooltip']= true  ;
$qlet['topcountries_g33']['tooltip_template']= "#label# = #value#"  ;
$qlet['topcountries_g33']['background_color']= 'FFFFFF' ;
$qlet['topcountries_g33']['total_script']= <<<EOD
  
EOD;
$qlet['topcountries_g33']['sql']= <<<EOD
 Select   "Country_Name", SUM( "Quantity_Sold" ) as "SUM_Quantity_Sold" 
from ( 
select * from ( 
Select 
       ade."Promo_Name" ,
       ade."Promo_Id" ,
       ade."Promo_Category" ,
       ade."Promo_Cost" ,
       ade."Calendar_Month_Name" ,
       ade."Fiscal_Year" ,
       ade."Prod_Category" ,
       ade."Channel_Class" ,
       ade."Country_Name" ,
       ade."Country_Subregion" ,
       ade."Country_Region" ,
       ade."Cust_State_Province" ,
       ade."Quantity_Sold" ,
       ade."Amount_Sold"
From 
      [detail_data$]    ade
 ) as  x 
 where "Fiscal_Year" in (PVAL['year_p32'])  
 and  "Country_Region" like 'PVAL['region_p34']'  
 )  as  g_tabx
 group by "Country_Name" 
EOD;
$qlet['topcountries_g33']['chart_margin']= array(left =>'35',right=>'15',top=>'25',bottom=>'45');
$qlet['topcountries_g33']['chart_size']=
                           array(
                                 width=>$qlet['topcountries_g33']['width'] - $qlet['topcountries_g33']['chart_margin']['left']- $qlet['topcountries_g33']['chart_margin']['right']
                                ,height =>$qlet['topcountries_g33']['height'] - $qlet['topcountries_g33']['chart_margin']['top']- $qlet['topcountries_g33']['chart_margin']['bottom']-20
                                 );
                                 
$qlet['topcountries_g33']['chart_position']=
                           array(
                                 top_x=> $qlet['topcountries_g33']['chart_margin']['left']
                                ,top_y => $qlet['topcountries_g33']['chart_margin']['top']
                                 );
                                 
$qlet['topcountries_g33']['legend']=
                           array(
                                 width=> $qlet['topcountries_g33']['width'] - $qlet['topcountries_g33']['chart_margin']['left']- $qlet['topcountries_g33']['chart_margin']['right']
                                ,height => 20
                                ,top_x=> $qlet['topcountries_g33']['chart_margin']['left']
                                ,top_y => $qlet['topcountries_g33']['height'] - 20
                                ,label_max_length =>10
                                 );
                                 
$qlet['topcountries_g33']['template']= <<<EOD
	<chart_guide horizontal='true' vertical='true' thickness='1' color='000000' alpha='35' type='dashed' radius='3' fill_alpha='75' line_alpha='0' background_color='FF4400' text_h_alpha='90' text_v_alpha='90' prefix_h=' ' suffix_h=' ' suffix_v=' ' />
	<chart_label  color='000000' alpha='50' size='8' position='middle' as_percentage='true'/>  


	<chart_grid_h thickness='1' type='solid' />


	<series bar_gap='0' set_gap='20' transfer='false' />
	
	<axis_category alpha='75' orientation='diagonal_up' size='9'/>
	
	<axis_value  
         	prefix=''  
			suffix=''  
            decimals=''
            decimal_char=''  
            separator='' 
            show_min='true' 
            size='10' 
            alpha='75'
            orientation='diagonal_up' 
            />

 <legend layout='horizontal' 
           fill_color='F0EBE6'
           bullet='square'
           font='arial'
           bold='true'
           size='10'
 		   width='{$qlet['topcountries_g33']['legend']['width']}'
		   height='{$qlet['topcountries_g33']['legend']['height']}'
		   x='{$qlet['topcountries_g33']['legend']['top_x']}'		   
		   y='{$qlet['topcountries_g33']['legend']['top_y']}'
           alpha='90'
           />			
		   
<chart_rect x='{$qlet['topcountries_g33']['chart_position']['top_x']}' 
            y='{$qlet['topcountries_g33']['chart_position']['top_y']}' 
			width='{$qlet['topcountries_g33']['chart_size']['width']}' 
			height='{$qlet['topcountries_g33']['chart_size']['height']}' 
			positive_color='000000' positive_alpha='0' negative_color='ff0000' negative_alpha='0' />				   
  <draw>
   <text   size='15' x='0' y='0' width='{$qlet['topcountries_g33']['width']}' height='20' h_align='center' v_align='top'>{$qlet['topcountries_g33']['name']}</text>
  </draw> 		   
  
<chart_pref line_thickness='3'     
            point_shape='square'     
            point_size='7'
            fill_shape='false'
            connect='false'
            tip='none'
                        
            
            point_size='7'         
            point_shape='square'
            trend_thickness='3'
            trend_alpha='20'
            line_thickness='0'
            
            rotation_x='30'        
            rotation_y='30'
            drag='true'
    

            select='true'            
            
            zero_line='true'      
            />   
  
	<chart_type>#chart_type#</chart_type>

    	#chart_data#
		
		#link_data#
EOD;


$qlet['list'] = array ('details_q31' , 'byproductcategory_g37' , 'bychannel_g36' , 'bypromocategory_g38' , 'categoryavgsoldin1000_g35' , 'byperiod_g34' , 'topcountries_g33');





$d_options['lowest_y_location'] = 283



?>