Friday, February 16, 2018

How to use loading image while downloading file like csv,xls ? [SOLVED]

Hey Guys,

Please follow the below step to download using ajax request in PHP and loader show while fetching and download the file .



//Total  members Registered in a month   
jQuery('#total-members-month-report').click(function(event){  
jQuery('.overlay').show();
var buildername = $('#builder-name').val();
var date1 = jQuery('#date1').val();
var date2 = jQuery('#date2').val();   
var URL = component_path+'&task=universityreport.registeredMembers&buildername='+buildername+'&date1='+date1+'&date2='+date2;
jQuery.ajax({url: URL, success: function(result){
        setTimeout(function(){ 
  window.location.href = URL;
  jQuery('.overlay').hide();
  }, 1000);
    }});
});

Hope it will help you!!

Thursday, February 8, 2018

How to create Dynamic div tag14 and 7 modular using php AJAX/JSON respone?


Hey Every once ,

I have made below function that create dynamic div for slider 14 and 7 modular which create for slider slick js 2*7 rows and in a slider box.

//create a function HTML OUT PUT
public function getCompleteHTMLOUTPUT($logoJsonDecode = array()){
$outputArray = array();
$assets  = JURI::base().'modules/mod_logo_slider/assets';
//echo "<pre>";
//print_r($logoJsonDecode);
//echo count($logoJsonDecode);
$totalLogoCount = count($logoJsonDecode);
$completeHTMLOUTPUT = '';
if(count($logoJsonDecode) > 0){
$completeHTMLOUTPUT = '<div class="slick-slide"><div>';
for($i=0,$count=1;$i<$totalLogoCount;$i++,$count++){
$logo = $logoJsonDecode[$i];
$blankDivFlag = false;
$wrapperDivFlag = false;
$url='';
if($logo->isMicroSite==0){
$url=$logo->company_url;
}else{
$url=JURI::ROOT().'ecosystem/'.$logo->microSiteURL;
}
$completeHTMLOUTPUT .='<div class="item" style="width: 14.2857%; display: inline-block;">';
$logoImage = str_replace('images/','',$logo->csp_logo_image);
$imagePath=JPATH_BUILDERS.'images/registeredcompanylogo/'.$logoImage;
list($width, $height) = getimagesize($imagePath);
$gaSource='Hits on External Links';
$rel = 'rel="nofollow"';
if($logo->isMicroSite==1)
{
$gaSource='Hits on Internal Links';
$rel = '';
}

$gafunc='onclick="ga(\'send\', \'event\', \''.$gaSource.'\', \''.$logo->organization_name.'\', \''.$url.'\');"';
$completeHTMLOUTPUT .='<a '. $rel.' title="'.$logo->organization_name.'" target="_blank" href="'.$url.'" '.$gafunc.'>
<img alt="'.$logo->organization_name.'" title="'.$logo->organization_name.'" data-lazy="'.JPATH_BUILDERS.'images/registeredcompanylogo/'.$logoImage.'" width="'.$width.'" height="'.$height.'" >
</a>
</div>';
if(($count % 14) == 0){
$completeHTMLOUTPUT .= '</div>';
$wrapperDivFlag = true;
$outputArray[] = $completeHTMLOUTPUT;
$completeHTMLOUTPUT = '';
if($i < $totalLogoCount){
$completeHTMLOUTPUT .= '<div class="slick-slide"><div>';
}
}else if(($count % 7) == 0){
$completeHTMLOUTPUT .= '</div>';
$blankDivFlag = true;
if($i < $totalLogoCount){
$completeHTMLOUTPUT .= '<div>';
}
}

}
if(!$blankDivFlag){
$completeHTMLOUTPUT .= '</div>';


}
if(!$wrapperDivFlag){
$completeHTMLOUTPUT .= '</div>';
}
$completeHTMLOUTPUT = '';
$outputArray[] = $completeHTMLOUTPUT;

}
return $outputArray;
exit;
}

// Call it passing JSON object to decode

$logoJsonDecode = json_decode($ajaxlogosList);

$completeHTMLOUTPUT = $this->getCompleteHTMLOUTPUT($logoJsonDecode);

Hope fully it will help you  for slider slick.