export to excel

Discuss the integratoin of phpbb and Joomla! here.

Moderator: General Support Moderators

sekarhicas
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jun 22, 2011 7:33 am

export to excel

Postby sekarhicas » Wed Jul 06, 2011 2:46 pm

Hello frends,
i need to export this entire tmpl file to excel.... can any one help me

<?php
/*
* Results HTML View Template
*/
// no direct access
defined('_JEXEC') or die('Restricted access');
$document =& JFactory::getDocument();
$document->addStyleSheet(JURI::base() . 'components/com_order/views/order/tmpl/css/style.css');
$document->addScript(JURI::base() . 'components/com_neworder/views/neworder/tmpl/js/jquery.js');
$session =& JFactory::getSession();
$buyer = $session->get('buyer');

$backorders = $session->get('backorders');
$month = $session->get('month');
$year = $session->get('year');
$check = $session->get('check');


$grid = array(
'GSIZE_I'=>array('0'=>'XXS','1'=>'XS','2'=>'S','3'=>'M','4'=>'L','5'=>'XL','6'=>'XXL','7'=>'3XL','8'=>'4XL'),
'GSIZE_A'=>array('0'=>'2','1'=>'4','2'=>'6','3'=>'8','4'=>'10','5'=>'12','6'=>'14'),
'GSIZE_K'=>array('0'=>'104','1'=>'116','2'=>'128','3'=>'140','4'=>'152'),
'GSIZE_O'=>array('0'=>'I','1'=>'II','2'=>'III','3'=>'IV'),
'GSIZE_S'=>array('0'=>'31/34','1'=>'35/38','2'=>'39/41','3'=>'42/46'),
'GSIZE_OS'=>array('0'=>'28','1'=>'29','2'=>'30','3'=>'31','4'=>'32','5'=>'33','6'=>'34','7'=>'35','8'=>'36','9'=>'37','10'=>'38','11'=>'40','12'=>'41','13'=>'42'),
'GSIZE_W'=>array('0'=>'26','1'=>'27','2'=>'28','3'=>'29','4'=>'30','5'=>'31','6'=>'32','7'=>'33','8'=>'34','9'=>'35','10'=>'36','11'=>'37','12'=>'38','13'=>'40','14'=>'41','15'=>'42'),
'GSIZE_U'=>array('0'=>'U')
);

if($buyer['ID_SENIOR'] == 0){
$orders = JRequest::getVar('orders');
$details = JRequest::getVar('details');
$by = JRequest::getVar('ref');

?>
<script>
$(document).ready(function(){


$('.orders').mouseover(function() {
$('.div').hide();
var id1 = this.id;
var id2 = id1.split("-");
var id = id2[1];
var offset = $("#"+id1).offset();

if(document.getElementById("div_"+id)){
$("#div_"+id).hide();
<?php
if($by == "order"){
?>
var left=offset.left+120;
<?php
}else{
?>
var left=offset.left+30;
<?php
}
?>
var top=offset.top;
$("#div_"+id).css("position","absolute");
$("#div_"+id).css("left",left);
$("#div_"+id).css("top",top);
$("#div_"+id).css("padding","10px");
$("#div_"+id).show("fast");
}else{
$("#no_data").hide();

<?php
if($by == "order"){
?>
var left=offset.left+120;
<?php
}else{
?>
var left=offset.left+30;
<?php
}
?>
var top=offset.top;
$("#no_data").css("position","absolute");
$("#no_data").css("left",left);
$("#no_data").css("top",top);
$("#no_data").css("padding","10px");
$("#no_data").show("fast");
}
});

$('.orders').mouseout(function() {
var id1 = this.id;
var id2 = id1.split("-");
var id = id2[1];
if(document.getElementById("div_"+id)){
$("#div_"+id).hide();
}
else{
$("#no_data").hide();
}
});

});

</script>





<div id="no_data" class="div" style='display:none; background-color:#dddddd; color:red;'>No data available</div>

<?php
if($by == "model"){


if(count($orders) > 0){



/////////////////////////////////////////////////////////////////////////////////////////////////
$grids_arr= array(); // Array Declaration for storing all grid values
$k = 0;
for($i=0;$i<count($orders);$i++)
{
$test = explode('-',$orders[$i]['BO_MATERIAL_NO']);
$flag = 0; // Set flag variable to 0
for($j=0;$j<count($grids_arr);$j++) // Loop to check if the grid value coming from database exists in the array we declared
{
if($grids_arr[$j]['grid_type'] == $orders[$i]['grid_type'] && $grids_arr[$j]['model'] == $test[0])
{
$flag =1;
// If the grid value coming from database exists in the array set flag variable to 1 and break the loop
foreach($grids_arr[$j]['color'] as $index=>$color){
if($index == $test[1]."###".$test[0]){
foreach($grids_arr[$j]['color'][$index] as $pack){
if($pack == $orders[$i]['BO_SALES_DOC_NO']){

}else{
$grids_arr[$j]['color'][$index][$orders[$i]['ARCLEUNIK']] = $orders[$i]['BO_SALES_DOC_NO'];
}
}

}else{
$grids_arr[$j]['color'][$test[1]."###".$test[1]] = array();

$grids_arr[$j]['color'][$test[1]."###".$test[1]][$orders[$i]['ARCLEUNIK']] = $orders[$i]['BO_SALES_DOC_NO'];


}
}
break;
}

}
if($flag == 0) // If the grid value coming from database does not exists in the array
{
/* array_push($grids_arr, $orders[$i]['GRID_VALUE']); // Push the grid value to array
$grids_arr[]*/
$grids_arr[$k]['grid_type'] = $orders[$i]['grid_type'];
$grids_arr[$k]['model'] = $test[0];
$grids_arr[$k]['model_name'] = $test[0];
$grids_arr[$k]['color'][$test[1]."###".$test[1]] = array();
$grids_arr[$k]['color'][$test[1]."###".$test[1]][$orders[$i]['BO_SALES_DOC_NO']] = $orders[$i]['BO_SALES_DOC_NO'];
$k++;
}

}
/* echo "<pre>";
print_r($grids_arr);
echo "</pre>";*/



$class_names = array();
$a = 0;
for($i=0;$i<count($grids_arr);$i++)
{
echo "<table id='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."' width='100%' bgcolor='#848484' cellspacing='1' cellpadding='3' border='0' >";
echo "<tr bgcolor='#dddddd' class='border1' align='center' style='font-weight:bold'>";
echo "<td width='150px'>".$grids_arr[$i]['model']."</td>";
foreach($grid[$grids_arr[$i]['grid_type']] as $value){
echo "<td>".$value."</td>";
}
echo "<td width='30px'>Total</td>";
echo "</tr>";

foreach($grids_arr[$i]['color'] as $key=>$colorarr)
{
foreach($colorarr as $packs)
{

$key = explode("###",$key);
echo "<tr style='text-align:center; background-color:#ffffff;'><td><table width='100%'><tr><td width='60%'>";
if($packs > 1){
echo "Order No : <a id='".$a."-".$packs."' class='orders' style='cursor:pointer;'>".$packs."</a>";
}
echo "</td><td><table width='100%'><tr><td width='50%'><img src='components/com_neworder/views/neworder/tmpl/colors/".$key[0].".jpg' width='20' height='20' size='2'></td><td> ".$key[1]."</td></tr></table></td>";
$key = $key[0];

echo "</td></tr></table></td>";
foreach($grid[$grids_arr[$i]['grid_type']] as $value){
echo "<td id='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."_".$value."' class='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."' width='30px;'></td>";
}

echo "<td align='right' class='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."_total'></td></tr>";

$class = $grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs;
array_push($class_names, $class);
}
}

echo "</table><br>";
$a++;
}

for($i=0;$i<count($orders);$i++)
{
$test = explode('-',$orders[$i]['BO_MATERIAL_NO']);
$id = $orders[$i]['grid_type']."_".$test[0]."_".$test[1]."_".$orders[$i]['BO_SALES_DOC_NO']."_".$orders[$i]['BO_GRID_VALUE'];
$week = explode('/',$orders[$i]['BO_DEL_WEEK_NO']);
?>
<script>
$("#<?php echo $id; ?>").html("<?php echo $orders[$i]['BO_OPEN_QTY']."(".$week[0].")"; ?>");
</script>
<?php

}


for($i=0;$i<count($class_names);$i++)
{
?>
<script>
var val;
var num = Array();
var total = 0;
jQuery(".<?php echo $class_names[$i]; ?>").each(function(){
val = jQuery(this).html();
num = val.split('(');
var num1 = parseInt(num[0]);
if(!isNaN(num1)){
total = total+num1;
}
});
$(".<?php echo $class_names[$i]; ?>_total").html(total);
</script>
<?php
}



}else{
echo "<br><br><br><br><center><h2>No backorders found.</h2><a href='index.php?option=com_order&task=backorder&Itemid=3'>Back to search</a></center>";
}
}

if($by == "order"){
if(count($orders) > 0){
$final = array();
foreach($orders as $order){
if($final[$order['BO_SALES_DOC_NO']]){
$final[$order['BO_SALES_DOC_NO']][count($final[$order['BO_SALES_DOC_NO']])] = $order;
}else{
$final[$order['BO_SALES_DOC_NO']][0] = $order;
}
}
/* echo "<pre>";
print_r($final);
echo "</pre>";*/
$a = 0;
foreach($final as $index=>$orders){
echo "<h3><a id='".$a."-".$index."' class='orders' style='cursor:pointer;'>Order Number - ".$index."</a></h3>";
$grids_arr= array(); // Array Declaration for storing all grid values
$k = 0;
for($i=0;$i<count($orders);$i++)
{
$test = explode('-',$orders[$i]['BO_MATERIAL_NO']);
$flag = 0; // Set flag variable to 0
for($j=0;$j<count($grids_arr);$j++) // Loop to check if the grid value coming from database exists in the array we declared
{
if($grids_arr[$j]['grid_type'] == $orders[$i]['grid_type'] && $grids_arr[$j]['model'] == $test[0])
{
$flag =1;
// If the grid value coming from database exists in the array set flag variable to 1 and break the loop
foreach($grids_arr[$j]['color'] as $index=>$color){
if($index == $test[1]."###".$test[0]){
foreach($grids_arr[$j]['color'][$index] as $pack){
if($pack == $orders[$i]['BO_SALES_DOC_NO']){

}else{
$grids_arr[$j]['color'][$index][$orders[$i]['ARCLEUNIK']] = $orders[$i]['BO_SALES_DOC_NO'];
}
}

}else{
$grids_arr[$j]['color'][$test[1]."###".$test[1]] = array();

$grids_arr[$j]['color'][$test[1]."###".$test[1]][$orders[$i]['ARCLEUNIK']] = $orders[$i]['BO_SALES_DOC_NO'];


}
}
break;
}

}
if($flag == 0) // If the grid value coming from database does not exists in the array
{
/* array_push($grids_arr, $orders[$i]['GRID_VALUE']); // Push the grid value to array
$grids_arr[]*/
$grids_arr[$k]['grid_type'] = $orders[$i]['grid_type'];
$grids_arr[$k]['model'] = $test[0];
$grids_arr[$k]['model_name'] = $test[0];
$grids_arr[$k]['color'][$test[1]."###".$test[1]] = array();
$grids_arr[$k]['color'][$test[1]."###".$test[1]][$orders[$i]['BO_SALES_DOC_NO']] = $orders[$i]['BO_SALES_DOC_NO'];
$k++;
}

}
/* echo "<pre>";
print_r($grids_arr);
echo "</pre>";*/



$class_names = array();
$a = 0;
$reference = "";
for($i=0;$i<count($grids_arr);$i++)
{

if($reference != $grids_arr[$i]['grid_type']."_".$index){
echo "<table class='".$grids_arr[$i]['grid_type']."_".$index."' id='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."' width='100%' bgcolor='#848484' cellspacing='1' cellpadding='3' border='0' >";

echo "<tr bgcolor='#dddddd' class='border1' align='center' style='font-weight:bold'>";
echo "<td width='150px'></td>";
foreach($grid[$grids_arr[$i]['grid_type']] as $value){
echo "<td>".$value."</td>";
}
echo "<td width='30px'>Total</td>";
echo "</tr>";
}


foreach($grids_arr[$i]['color'] as $key=>$colorarr)
{
foreach($colorarr as $packs)
{

$key = explode("###",$key);
echo "<tr style='text-align:center; background-color:#ffffff;'><td><table width='100%'><tr><td width='60%'>";
echo "<b>".$grids_arr[$i]['model']."</b>";
echo "</td><td><table width='100%'><tr><td width='50%'><img src='components/com_neworder/views/neworder/tmpl/colors/".$key[0].".jpg' width='20' height='20' size='2'></td><td> ".$key[1]."</td></tr></table></td>";
$key = $key[0];

echo "</td></tr></table></td>";
foreach($grid[$grids_arr[$i]['grid_type']] as $value){
echo "<td id='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."_".$value."' class='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."' width='30px;'></td>";
}
echo "<td align='right' class='".$grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs."_total'></td></tr>";
$class = $grids_arr[$i]['grid_type']."_".$grids_arr[$i]['model']."_".$key."_".$packs;
array_push($class_names, $class);
}
}
if($i == count($grids_arr)-1){
echo "</table><br>";
}
$reference = $grids_arr[$i]['grid_type']."_".$index;
$a++;
}

for($i=0;$i<count($orders);$i++)
{
$test = explode('-',$orders[$i]['BO_MATERIAL_NO']);
$id = $orders[$i]['grid_type']."_".$test[0]."_".$test[1]."_".$orders[$i]['BO_SALES_DOC_NO']."_".$orders[$i]['BO_GRID_VALUE'];
$week = explode('/',$orders[$i]['BO_DEL_WEEK_NO']);
?>
<script>
$("#<?php echo $id; ?>").html("<?php echo $orders[$i]['BO_OPEN_QTY']."(".$week[0].")"; ?>");
</script>
<?php

}
for($i=0;$i<count($class_names);$i++)
{
?>
<script>
var val;
var num = Array();
var total = 0;
jQuery(".<?php echo $class_names[$i]; ?>").each(function(){
val = jQuery(this).html();
num = val.split('(');
var num1 = parseInt(num[0]);
if(!isNaN(num1)){
total = total+num1;
}
});
$(".<?php echo $class_names[$i]; ?>_total").html(total);
</script>
<?php
}

$a++;
}


}else{
echo "<br><br><br><br><center><h2>No backorders to found.</h2><a href='index.php?option=com_order&task=backorder&Itemid=3'>Back to search</a></center>";
}
}
foreach($details as $row){
echo "<div id='div_".$row['BO_SALES_DOC_NO']."' class='div' style='display:none; background-color:#dddddd; color:black;'>
<table>
<tr>
<td>Orders Number </td><td> : </td><td>".$row['BO_SALES_DOC_NO']."</td>
</tr>
<tr>
<td>B2B Order Number </td><td> : </td><td>".$row['NONETCLI']."</td>
</tr>
<tr>
<td>Order By </td><td> : </td><td>".$row['NOM']." ".$row['PRENOM']."</td>
</tr>
<tr>
<td>Order Date </td><td> : </td><td>".$row['DATE_COMMANDE']."</td>
</tr>
<tr>
<td>Remarks </td><td> : </td><td>".$row['REMARQUES']."</td>
</tr>

</table>
</div>";
}
}else{
echo "<br><br><br><br><center><h2>Your not authorized to view this page.</h2></center>";
}
?>



<?php
$session =& JFactory::getSession();
$user = $session->get('buyer');
if($user['ID_SENIOR'] == 0){
if($user['DST_CHNL'] == "C"){
?>
<script>
jQuery(document).ready(function(){
jQuery('#cluborder_a').remove();
// jQuery('#sampleorder_a').remove();
});
</script>
<?php
}
if($user['DST_CHNL'] == "R"){
?>
<script>
jQuery(document).ready(function(){
// jQuery('#cluborder_a').remove();
jQuery('#sampleorder_a').remove();
});
</script>
<?php
}
}else{
?>
<script>
jQuery(document).ready(function(){
jQuery('#cluborder_a').remove();
jQuery('#sampleorder_a').remove();
});
</script>
<?php
}
?>

User avatar
Per Yngve Berg
Joomla! Master
Joomla! Master
Posts: 23921
Joined: Mon Oct 27, 2008 9:27 pm
Location: Akershus, Norway

Re: export to excel

Postby Per Yngve Berg » Wed Jul 06, 2011 7:08 pm

What do you mean by exporting a template to excel?

sekarhicas
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Wed Jun 22, 2011 7:33 am

Re: export to excel

Postby sekarhicas » Thu Jul 07, 2011 5:47 am

sorry friend..its a view file inside tmpl folder ie.component... i need to write export to excel function for this code.

This is not a template


Return to “phpbb - Joomla! Integration”

Who is online

Users browsing this forum: No registered users and 1 guest