 <?php         
     $today_date                         = date('Y-m-d');    
    $monthly_start_date                 = date('Y-m-01');    
    $monthly_end_date                   = date('Y-m-t');
    $yearly_start_date                  = date('Y-01-01');    
    $yearly_end_date                    = date('Y-12-t');      ?>
<div id="lead" >
   <div class="heading"><span>MTD</span></div>
<br>
<span><b>On Quantity</b></span>
<br><br>
    <div class="row">
        
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Sales Group
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_chart"></figure>
                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Lead Owner
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_lo_chart"></figure>
                </div>
            </section>
        </div>
         <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Country
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_country_chart"></figure>
                </div>
            </section>
        </div>
    </div>

<span><b>On Value</b></span>
<br><br>
    <div class="row">
        
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Sales Group
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_val_chart"></figure>
                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Lead Owner
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_lo_val_chart"></figure>
                </div>
            </section>
        </div>
         <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Country
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="lead_country_val_chart"></figure>
                </div>
            </section>
        </div>
    </div>

<br>
<div class="heading"><span>YTD</span></div>
<br>
<span><b>On Quantity</b></span>
<br><br>
    <div class="row">
        
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Sales Group
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd_lead_chart"></figure>
                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Lead Owner
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd_lead_lo_chart"></figure>
                </div>
            </section>
        </div>
         <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Country
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd_lead_country_chart"></figure>
                </div>
            </section>
        </div>
    </div>

<span><b>On Value</b></span>
<br><br>
    <div class="row">
        
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Sales Group
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd_lead_val_chart"></figure>
                </div>
            </section>
        </div>
        <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Lead Owner
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd_lead_lo_val_chart"></figure>
                </div>
            </section>
        </div>
         <div class="col-md-4">
            <section class="panel">
                <header class="panel-heading">
                    Lead- Country
                </header>
                <div class="panel-body">
                    <figure class="demo-xchart" id="ytd1_lead_country_val_chart"></figure>
                </div>
            </section>
        </div>
    </div>
</div>

 <?php 
    //------------------------------------------------  MTD ----------------------------------------------------------------
     // lead - salesgroup chart 
    $lead_sg_graph_data = array();
    $lead_sg_target_axis="";
    $model = MasSalesGroup::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasSalesGroup::model()->findAll();
             foreach ($model_project_type as $j=>$value) { 
                $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND sales_group_id ='.$value->id));
              
                       if($lead_sg_target_axis=="")
                              $lead_sg_target_axis= '{"y":'.$type->value.',"x":"'.$value->group_name.'"}';
                      else
                              $lead_sg_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->group_name.'"}';         
              
           
           
           }
           $lead_sg_graph_data[$i]	= $lead_sg_target_axis;
         
      }
     
    
      
    $lead_lo_graph_data = array();
    $lead_lo_target_axis="";
    $model = User::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = User::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {   
                 $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND crm_user_id ='.$value->id));
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                 if(!empty($type)){ 

                       if($lead_lo_target_axis=="")
                              $lead_lo_target_axis= '{"y":'.$type->value.',"x":"'.$value->username.'"}';
                      else
                              $lead_lo_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->username.'"}';         
                 }
                 else{
                              $lead_lo_target_axis= '{"y":0,"x":"'.$value->username.'"}'; 
                 }
           
           
           }
           $lead_lo_graph_data[$i] = $lead_lo_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
      
      // lead - country chart 
     
    $lead_country_graph_data = array();
    $lead_country_target_axis="";
    $model = MasEmiratesList::model()->findAll();
    foreach ($model as $i=>$val) {   
             $model_project_type = MasEmiratesList::model()->findAll();
             foreach ($model_project_type as $j=>$value) {           
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                  $type = Lead::model()->with('customer')->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND customer.customer_emirates_name ='.$value->id));
                 if(!empty($type)){ 

                       if($lead_country_target_axis=="")
                              $lead_country_target_axis= '{"y":'.$type->value.',"x":"'.$value->emirates_name.'"}';
                      else
                              $lead_country_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->emirates_name.'"}';         
                 }
                 else{
                              $lead_country_target_axis= '{"y":0,"x":"'.$value->emirates_name.'"}'; 
                 }
           
           
           }
           $lead_country_graph_data[$i] = $lead_country_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
    
    //lead- salesgroup by value---------------------------------------------------------------------------------------------------
      
    $lead_sg_val_graph_data = array();
    $lead_sg_val_target_axis="";
    $model = MasSalesGroup::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasSalesGroup::model()->findAll();
             foreach ($model_project_type as $j=>$value) { 
                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND sales_group_id ='.$value->id));
                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND sales_group_id ='.$value->id));
                $total= $type->value+$type_base->value;
                //$type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND sales_group_id ='.$value->id));
               // $type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE sales_group_id=" . $value->id . "")->queryScalar();                    
                 if(!empty($type)){ 

                       if($lead_sg_val_target_axis=="")
                              $lead_sg_val_target_axis= '{"y":'.$total.',"x":"'.$value->group_name.'"}';
                      else
                              $lead_sg_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->group_name.'"}';         
                 }
                  else{
                              $lead_sg_val_target_axis= '{"y":0,"x":"'.$value->group_name.'"}'; 
                 }
           
           
           }
           $lead_sg_val_graph_data[$i]	= $lead_sg_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
     
     // lead - leadowner by value 
      
    $lead_lo_val_graph_data = array();
    $lead_lo_val_target_axis="";
    $model = User::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = User::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {  
                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND crm_user_id ='.$value->id));
                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND crm_user_id ='.$value->id));
                $total= $type->value+$type_base->value;
               
                // $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND crm_user_id ='.$value->id));
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                 if(!empty($total)){ 

                       if($lead_lo_val_target_axis=="")
                              $lead_lo_val_target_axis= '{"y":'.$total.',"x":"'.$value->username.'"}';
                      else
                              $lead_lo_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->username.'"}';         
                 }
                  else{
                              $lead_lo_val_target_axis= '{"y":0,"x":"'.$value->username.'"}'; 
                 }
           
           
           }
           $lead_lo_val_graph_data[$i] = $lead_lo_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
      
      // lead - country by value 
      
    $lead_country_val_graph_data = array();
    $lead_country_val_target_axis="";
    $model = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {           
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND customer.customer_country ='.$value->id));
                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND customer.customer_country ='.$value->id));
                $total= $type->value+$type_base->value;
               
                // $type = Lead::model()->with('customer')->find(array('select'=>'COUNT(*) as value','condition'=>' customer.customer_country ='.$value->id));
                 if(!empty($total)){ 

                       if($lead_country_val_target_axis=="")
                              $lead_country_val_target_axis= '{"y":'.$total.',"x":"'.$value->country_name.'"}';
                      else
                              $lead_country_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->country_name.'"}';         
                 }
                  else{
                              $lead_country_val_target_axis= '{"y":0,"x":"'.$value->country_name.'"}'; 
                 }
           
           
           }
           $lead_country_val_graph_data[$i] = $lead_country_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      //------------------------------------------------  YTD ----------------------------------------------------------------
     // lead - salesgroup chart 
    $ytd_lead_sg_graph_data = array();
    $ytd_lead_sg_target_axis="";
    $model = MasSalesGroup::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasSalesGroup::model()->findAll();
             foreach ($model_project_type as $j=>$value) { 
                $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND sales_group_id ='.$value->id));
               // $type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE sales_group_id=" . $value->id . "")->queryScalar();                    
                // if(!empty($type)){ 

                       if($ytd_lead_sg_target_axis=="")
                              $ytd_lead_sg_target_axis= '{"y":'.$type->value.',"x":"'.$value->group_name.'"}';
                      else
                              $ytd_lead_sg_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->group_name.'"}';         
               //  }
           
           
           }
           $ytd_lead_sg_graph_data[$i]	= $ytd_lead_sg_target_axis;
          // print_r($ytd_lead_sg_target_axis);die();
      }
     
     // lead - leadowner chart 
      
    $ytd_lead_lo_graph_data = array();
    $ytd_lead_lo_target_axis="";
    $model = User::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = User::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {   
                 $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND crm_user_id ='.$value->id));
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                 if(!empty($type)&& $type->value!=0){ 

                       if($ytd_lead_lo_target_axis=="")
                              $ytd_lead_lo_target_axis= '{"y":'.$type->value.',"x":"'.$value->username.'"}';
                      else
                              $ytd_lead_lo_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->username.'"}';         
                 }
                 else
                 {
                     continue;
                 }
           
           
           }
           $ytd_lead_lo_graph_data[$i] = $ytd_lead_lo_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
      
      // lead - country chart 
      
    $ytd_lead_country_graph_data = array();
    $ytd_lead_country_target_axis="";
    $model = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {           
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                  $type = Lead::model()->with('customer')->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND customer.customer_country ='.$value->id));
                 if(!empty($type)){ 

                       if($ytd_lead_country_target_axis=="")
                              $ytd_lead_country_target_axis= '{"y":'.$type->value.',"x":"'.$value->country_name.'"}';
                      else
                              $ytd_lead_country_target_axis.= ',{"y":'.$type->value.',"x":"'.$value->country_name.'"}';         
                 }
           
           
           }
           $ytd_lead_country_graph_data[$i] = $ytd_lead_country_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
 //lead- salesgroup by value---------------------------------------------------------------------------------------------------
      
    $ytd_lead_sg_val_graph_data = array();
    $ytd_lead_sg_val_target_axis="";
    $model = MasSalesGroup::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasSalesGroup::model()->findAll();
             foreach ($model_project_type as $j=>$value) { 
                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND sales_group_id ='.$value->id));
                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND sales_group_id ='.$value->id));
                $total= $type->value+$type_base->value;
                //$type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND sales_group_id ='.$value->id));
               // $type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE sales_group_id=" . $value->id . "")->queryScalar();                    
                // if(!empty($type)){ 

                       if($ytd_lead_sg_val_target_axis=="")
                              $ytd_lead_sg_val_target_axis= '{"y":'.$total.',"x":"'.$value->group_name.'"}';
                      else
                              $ytd_lead_sg_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->group_name.'"}';         
               //  }
           
           
           }
           $ytd_lead_sg_val_graph_data[$i]	= $ytd_lead_sg_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
     
     // lead - leadowner by value 
      
    $ytd_lead_lo_val_graph_data = array();
    $ytd_lead_lo_val_target_axis="";
    $model = User::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = User::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {  
                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND crm_user_id ='.$value->id));
                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND crm_user_id ='.$value->id));
                $total= $type->value+$type_base->value;
               
                // $type = Lead::model()->find(array('select'=>'COUNT(*) as value','condition'=>'enq_date>="'.$monthly_start_date.'" AND enq_date<="'.$today_date.'" AND crm_user_id ='.$value->id));
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
                 if(!empty($total)){ 

                       if($ytd_lead_lo_val_target_axis=="")
                              $ytd_lead_lo_val_target_axis= '{"y":'.$total.',"x":"'.$value->username.'"}';
                      else
                              $ytd_lead_lo_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->username.'"}';         
                 }
           
           
           }
           $ytd_lead_lo_val_graph_data[$i] = $ytd_lead_lo_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }
      
      
      // lead - country by value 
      
    $ytd1_lead_country_val_graph_data = array();
    $ytd1_lead_country_val_target_axis="";
    $model = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
    foreach ($model as $i=>$val) {   
             $model_project_type = MasCountry::model()->findAll(array('condition'=>'isActive="Y"'));
             foreach ($model_project_type as $j=>$value) {           
                //$type = Yii::app()->db->createCommand("SELECT COUNT(*) FROM crm_lead WHERE crm_user_id=" . $value->id . "")->queryScalar();                    
//                $type =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="Y" AND customer.customer_country ='.$value->id));
//                $type_base =  Lead::model()->with('currency','customer')->find(array('select'=>'SUM(value*currency.exchange_rate) as value','condition'=>'enq_date>="'.$yearly_start_date.'" AND enq_date<="'.$today_date.'" AND currency.IsBaseCurrency="N" AND customer.customer_country ='.$value->id));
//                $total= $type->value+$type_base->value;
//               
                // $type = Lead::model()->with('customer')->find(array('select'=>'COUNT(*) as value','condition'=>' customer.customer_country ='.$value->id));
                 if(!empty($total)){ 

                       if($ytd1_lead_country_val_target_axis=="")
                              $ytd1_lead_country_val_target_axis= '{"y":'.$total.',"x":"'.$value->country_name.'"}';
                      else
                              $ytd1_lead_country_val_target_axis.= ',{"y":'.$total.',"x":"'.$value->country_name.'"}';         
                 }
                  else{
                      continue;
                 }
           
           
           }
           $ytd1_lead_country_val_graph_data[$i] = $ytd1_lead_country_val_target_axis;
           //print_r($lead_sg_target_axis);die();
      }

 ?>     
  <script type="text/javascript">
(function() {
        
 //-------------------------------------MTD-----------------------------------------
 //---------Qty-----------
  var lead_sg_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [ <?php if(isset($lead_sg_graph_data[0])) {echo $lead_sg_graph_data[0];}?> ]}
                ],
                "type": "line",
                "yScale": "linear"}, ];
                
  var lead_lo_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($lead_lo_graph_data[0])) {echo $lead_lo_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
     
  var lead_country_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($lead_country_graph_data[0])) {echo $lead_country_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
                
   //---------Value-----------             
                
   var lead_sg_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($lead_sg_val_graph_data[0])) {echo $lead_sg_val_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
                
  var lead_lo_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($lead_lo_val_graph_data[0])) {echo $lead_lo_val_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
     
  var lead_country_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($lead_country_val_graph_data[0])) {echo $lead_country_val_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
                
////-------------------------------------YTD-----------------------------------------
// //---------Qty-----------    
 var ytd_lead_sg_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($ytd_lead_sg_graph_data[0])) {echo $ytd_lead_sg_graph_data[0];}?>]}
                ],
                "type": "line",
                "yScale": "linear"}, ];
                
  var ytd_lead_lo_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($ytd_lead_lo_graph_data[0])) {echo $ytd_lead_lo_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
     
  var ytd_lead_country_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [<?php if(isset($ytd_lead_country_graph_data[0])) {echo $ytd_lead_country_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
                
//---------Value-----------             
                
   var ytd_lead_sg_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [ <?php if(isset($ytd_lead_sg_val_graph_data[0])) {echo $ytd_lead_sg_val_graph_data[0];}?> ]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
                
  var ytd_lead_lo_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [  <?php if(isset($ytd_lead_lo_val_graph_data[0])) {echo $ytd_lead_lo_val_graph_data[0];}?>]}
                ],
                "type": "bar",
                "yScale": "linear"}, ];
     
  var ytd1_lead_country_val_data = [{
                "xScale": "ordinal",
                "comp": [],
                "main": [{
                        "className": ".main.l2",
                        "data": [ <?php if(isset($ytd1_lead_country_val_graph_data[0])) {echo $ytd1_lead_country_val_graph_data[0];}?> ]}
                ],
                "type": "bar",
                "yScale": "linear"}, ]; 
                
                
 lead_chart = new xChart('bar', lead_sg_data[0], '#lead_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
    lead_lo_chart = new xChart('bar', lead_lo_data[0], '#lead_lo_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
    lead_country_chart = new xChart('bar', lead_country_data[0], '#lead_country_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
  //Value
  
  lead_val_chart = new xChart('bar', lead_sg_val_data[0], '#lead_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
    lead_lo_val_chart = new xChart('bar', lead_lo_val_data[0], '#lead_lo_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
    lead_country_val_chart = new xChart('bar', lead_country_val_data[0], '#lead_country_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
//================================================== YTD ==================================
//Qty

    ytd_lead_chart = new xChart('bar', ytd_lead_sg_data[0], '#ytd_lead_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
    ytd_lead_lo_chart = new xChart('bar', ytd_lead_lo_data[0], '#ytd_lead_lo_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
    ytd_lead_country_chart = new xChart('bar', ytd_lead_country_data[0], '#ytd_lead_country_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
//Value
  
  ytd_lead_val_chart = new xChart('bar', ytd_lead_sg_val_data[0], '#ytd_lead_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
        
    ytd_lead_lo_val_chart = new xChart('bar', ytd_lead_lo_val_data[0], '#ytd_lead_lo_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });
    ytd1_lead_country_val_chart = new xChart('bar', ytd1_lead_country_val_data[0], '#ytd1_lead_country_val_chart', {
            axisPaddingTop: 5,
            dataFormatX: function (x) {
                return x;
            },
            dataFormatY: function (y) {
                return y;
            },
        });        


 }());               
</script>          