Linux ip-172-26-7-228 5.4.0-1103-aws #111~18.04.1-Ubuntu SMP Tue May 23 20:04:10 UTC 2023 x86_64
Your IP : 3.142.55.138
Current Path : /var/www/oasis/src_old/ |
| Current File : /var/www/oasis/src_old/general_report_format.php |
<?php
function displayReport($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$format_file=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/src/format.php";
include($format_file);
$report_id = $aobj_context->mobj_data["report_id"];
$schema_name = $aobj_context->mobj_data["schema_name"];
$FromDate = db_date_Format($aobj_context->mobj_data["Fromdate"]);
$ToDate = db_date_Format($aobj_context->mobj_data["Todate"]);
$a_path= "http://".$_SERVER["SERVER_NAME"] ."/{$main_src}/app.php?a=getDownloadReportFile&report_id=".$report_id."&FromDate=".$FromDate."&ToDate=".$ToDate;
$a_pdf_path= "http://".$_SERVER["SERVER_NAME"] ."/{$main_src}/app.php?a=getDownloadPDFReportFile&report_id=".$report_id."&FromDate=".$FromDate."&ToDate=".$ToDate;
if(!in_array($report_id,$_SESSION['report_ids']))
{
$_SESSION['report_count']=$_SESSION['report_count']+1;
$_SESSION['report_ids'][$_SESSION['report_count']]=$report_id;
}
$get_display_cols="select concat(m_2_ele_7,'-',m_2_ele_8)
as 'Activity_Code',expense_type as 'Expense_Type',
amount as Amount from activity_cost a
inner join module_2 m on m.internal_code=activity_code
where
from_date>='{$FromDate}'
and to_date<= '{$ToDate}' order by 1";
$lobj_get_display_cols = $aobj_context->mobj_db->GetRow($get_display_cols);
$header=array_keys($lobj_get_display_cols);
$grid_header='';
$grid_header_val='';
foreach($header as $key=> $value)
{
$grid_header.="'".$header[$key]."',";
$grid_header_val.="{name:'grid_".$header[$key]."',index:'grid_".$header[$key]."', width:50 } ,";
}
$grid_header=substr($grid_header,0,strlen($grid_header)-1);
$grid_header_val=substr($grid_header_val,0,strlen($grid_header_val)-1);
$lstr="<html>
<head>
<title>{$schema_name} Report </title>
<link rel='stylesheet' type='text/css' media='screen' href='../../jqGrid3/themes/tarka/grid.css' />
<link rel='stylesheet' type='text/css' media='screen' href='../../jqGrid3/themes/jqModal.css' />
<script src='../../js/index.js' type='text/javascript'></script>
<script src='../../jqGrid3/jquery.js' type='text/javascript'></script>
<script src='../../jqGrid3/jquery.jqGrid.js' type='text/javascript'></script>
<script src='../../jqGrid3/js/jqModal.js' type='text/javascript'></script>
<script src='../../jqGrid3/js/jqDnR.js' type='text/javascript'></script>
<script type='text/javascript'>
var host_url= \"http://{$_SERVER["SERVER_NAME"]}/{$main_src}/app.php?a=\";
var img_path=\"http://{$_SERVER["SERVER_NAME"]}/{$main_src}/jqGrid3/themes/tarka/images/\";
function displayReportDetails()
{
document.getElementById('sub_grid_div').innerHTML='';
document.getElementById('main_grid_div').innerHTML='';
var main=\"<table id='table_grid' class='scroll' ></table> <div id='sub_grid_div' class='scroll' style='text-align:center;'></div>\";
document.getElementById('main_grid_div').innerHTML=main;
jQuery(\"#table_grid\").jqGrid(
{
url:host_url+'viewGridReportDetails.demo&report_id={$report_id}&FromDate={$FromDate}&ToDate={$ToDate}',
datatype: 'json',
colNames:[{$grid_header}],
colModel:[{$grid_header_val}],
rowNum:20,
rowList:[5,10,15,20,25,30],
imgpath:img_path,
pager: jQuery('#sub_grid_div'),
sortname: 'id',
height:'auto',
viewrecords: true,
sortorder: 'desc',
cellEdit: true,
multiselect: false,
width:'900',
caption:'{$schema_name}'
}
).navGrid('#sub_grid_div',{edit:false,add:false,del:false});
jQuery('#vcol').click(function (){ jQuery('#table_grid').setColumns(); });
}
</script>
</head>
<body bgcolor='#EAEAEA' ONLOAD='displayReportDetails();'>
<div style=' padding-top:12px; padding-bottom:05px;'><a href='{$a_path}'>Download</a> <a href='{$a_pdf_path}'>Download PDF</a></div>
<div id='main_grid_div' style=' width:100%; overflow:auto;'>
<table id='table_grid' class='scroll'></table>
<div id='sub_grid_div' class='scroll' style='text-align:center;'></div>
</div>
<div style='padding-top:12px;'><a href='{$a_path}'>Download</a> <a href='{$a_pdf_path}'>Download PDF</a> <a href='#' id='vcol'>Hide/Show Columns</a></div>
</body>
</html>";
$root_file_name=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Report_details/output/report_display_".$_SESSION['user_id']."_".$report_id.".html";
$root_file_download=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Report_details/output/report_display_".$_SESSION['user_id']."_".$report_id.".csv";
file_put_contents($root_file_download,$down_load);
if(file_put_contents($root_file_name,$lstr))
{
$open_path= $_SERVER["SERVER_NAME"]."/{$main_src}/Report_details/output/report_display_".$_SESSION['user_id']."_".$report_id.".html";
echo $aobj_context->mobj_output->ToJSONEnvelope($open_path,0,"success");
}
}
//ownloadReport1();
function downloadReport($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$report_id = $aobj_context->mobj_data["report_id"];
$FromDate = $aobj_context->mobj_data["FromDate"];
$ToDate = $aobj_context->mobj_data["ToDate"];
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$excel_writer=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Excel_Writer/Writer.php";
include($excel_writer);
$root_xls_file_download=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/Report_details/output/report".$_SESSION['user_id']."_".$report_id.".xls";
$workbook = new Spreadsheet_Excel_Writer($root_xls_file_download);
// sending HTTP headers
//$workbook->send('test.xls');
// Creating a worksheet
$worksheet =& $workbook->addWorksheet('Sheet1');
$get_data="select concat(m_2_ele_7,'-',m_2_ele_8)
as 'Activity_Code',expense_type as 'Expense_Type',
amount as Amount from activity_cost a
inner join module_2 m on m.internal_code=activity_code
where
from_date>='{$FromDate}'
and to_date<= '{$ToDate}' order by 1";
$lobj_details = $aobj_context->mobj_db->GetAll($get_data);
$header_row=(array_keys($lobj_details[0]));
$header_row_cell_indx=0;
foreach($header_row as $key=> $value)
{
$worksheet->write(0,$header_row_cell_indx,$value);
$header_row_cell_indx++;
}
$xlsRow = 1;
foreach($lobj_details as $key=> $value)
{
$xlscol=0;
foreach($value as $key1=> $value1)
{
$worksheet->write($xlsRow,$xlscol,$value1);
$xlscol++;
}
$xlsRow++;
}
$workbook->close();
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=report\"$report_id\".xls");
header("Expires: 0");
header("Cache-Control: must-revalidate, post-check=0,pre-check=0");
header("Pragma: public");
readfile($root_xls_file_download);
unlink($root_xls_file_download);
}
function downloadPDFReport($aobj_context)
{
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
$report_id = $aobj_context->mobj_data["report_id"];
$FromDate = $aobj_context->mobj_data["FromDate"];
$ToDate = $aobj_context->mobj_data["ToDate"];
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$pdf_writer_class=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/maya-pdf/cls.pdf.php";
include($pdf_writer_class);
$pdf= new PDF('P','mm','A4');
$get_data="select concat(m_2_ele_7,'-',m_2_ele_8)
as 'Activity_Code',expense_type as 'Expense_Type',
amount as Amount from activity_cost a
inner join module_2 m on m.internal_code=activity_code
where
from_date>='{$FromDate}'
and to_date<= '{$ToDate}' order by 1";
// dnt change order of execution
// getting data
$lobj_details = $aobj_context->mobj_db->GetAll($get_data);
// getting Header data
$header_row=(array_keys($lobj_details[0]));
// Setting font style
$pdf->SetFont('courier','',10);
// Adding page
$pdf->AddPage();
// Displaying Header information in the PDF File
foreach($header_row as $col)
{
$pdf->Cell(95,5,$col,1,'','C','true');
$pdf->SetFillColor(200,220,255);
}
//Displaying Data in th PDF File
foreach($lobj_details as $row)
{
$pdf->Ln();
foreach($row as $col)
$pdf->Cell(95,5,$col,1);
}
// Downloading file to the Destination using
// d for downloading without going to next page
// I for viewing the PDF file in the browser itself
// default for downloading file and display the new page in the browser
$pdf->Output("report_{$report_id}.pdf","d");
}
function displayGridReportDetails($aobj_context)
{
$main_src_obj=(explode("/",$_SERVER["REQUEST_URI"]));
$main_src=$main_src_obj[1];
$search_file_name=$_SERVER["DOCUMENT_ROOT"]."/".$main_src."/src/getsearchcondition.php";
$FromDate = $aobj_context->mobj_data["FromDate"];
$ToDate = $aobj_context->mobj_data["ToDate"];
include($search_file_name);
$aobj_context->mobj_db->SetFetchMode(ADODB_FETCH_ASSOC);
include("/JSON.php");
$data_qry="select a.internal_code ,concat(m_2_ele_7,'-',m_2_ele_8)
as 'Activity_Code',expense_type as 'Expense_Type',
amount as Amount from activity_cost a
inner join module_2 m on m.internal_code=activity_code
where from_date>='{$FromDate}'
and to_date<= '{$ToDate}' ";
$json = new Services_JSON();
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$page = $_GET['page'];
if(!$sidx)
$sidx =1;
else
$indx=explode("grid_",$sidx);
$sidx=empty($indx[1])?'1':$indx[1];
$table_name=$_GET['table_name'];
$table_field_name=stripcslashes($_GET['field_name']);
$details_array=$_GET['details_array'];
// to take th e parameters from Search field
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$field_name_value=explode('grid_',$_GET['searchField']);
$final_value=getsearchcondition($_GET['searchOper'],$_GET['searchString']);
$cond=$final_value[0];
$value=$final_value[1];
}
$field_name=$field_name_value[1];
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$count_id="select count(*) as count from ({$data_qry}) a where $field_name $cond$value";
}
else
{
$count_id="select count(*) as count from ({$data_qry}) a";
}
$result = mysql_query($count_id);
$row = mysql_fetch_array($result,MYSQL_ASSOC);
$count = $row['count'];
// calculation of total pages for the query
if( $count >0 )
{
$total_pages = ceil($count/$limit);
}
else
{
$total_pages = 0;
}
if ($page > $total_pages)
$page=$total_pages;
$start = $limit*$page - $limit;
if($start <0)
$start = 0;
// the actual query for the grid data
if(isset($_GET['searchField']) && $_GET["_search"]=='true')
{
$SQL="select * from ({$data_qry} )a where $field_name $cond$value
ORDER BY $sidx $sord LIMIT $start,$limit";
//echo $SQL;
}
else
{
$SQL = " {$data_qry}
ORDER BY $sidx $sord LIMIT $start , $limit";
}
$responce->page = $page;
$responce->total = $total_pages;
$responce->records = $count;
$lobj_rs =$aobj_context->mobj_db->GetAll($SQL);
foreach($lobj_rs as $key =>$value)
{
$val='';
$responce->rows[$key]['id']=$value[internal_code];
$l=0;
foreach($value as $key1 =>$value1)
{
if($key1!='internal_code'){
$val[$l]=$value[$key1];
$l++;
}
}
$responce->rows[$key]['cell']=($val);
}
echo $json->encode($responce);
}
?>
|