Professional Documents
Culture Documents
php
/**
* Display help and module information
* @param path which path of the site we're displaying help
* @param arg array that holds the current path as would be returned from arg()
function
* @return help text for the path
*/
function custom_financials_help($path, $arg) {
$doQuote=!get_magic_quotes_gpc();
$output = '';
switch ($path) {
case "admin/help#custom_financials":
$output = '<p>'. t("Financials management") .'</p>';
break;
}
return $output;
} // function custom_financials_help
function custom_financials_perm() {
return array('administer module','download files');
}
function custom_financials_menu(){
$items = array();
$items['admin/settings/custom-financials/manage-periods'] = array(
'title' => 'Custom Financials - Manage Financials (periods)',
'description' => 'Custom Financials - Manage Financials (periods)',
'page callback' => 'custom_financials_manage_periods',
'access arguments' => array('administer module'),
'type' => MENU_NORMAL_ITEM,
);
$items['admin/settings/custom-financials/manage-files'] = array(
'title' => 'Custom Financials - Manage Financials (files)',
'description' => 'Custom Financials - Manage Financials (files)',
'page callback' => 'custom_financials_manage_files',
'access arguments' => array('administer module'),
'type' => MENU_NORMAL_ITEM,
);
$items['financials-downloadfile'] = array(
'title' => 'Custom Financials - Download Files',
'description' => 'Custom Financials - Download Files',
'page callback' => 'custom_financials_download_file',
'access arguments' => array('download files'),
'type' => MENU_NORMAL_ITEM,
);
$items['financials-results'] = array(
'title' => 'Financial Results',
'description' => 'Financial Results',
'page callback' => 'custom_financials_results_frontend',
'access arguments' => array('download files'),
'type' => MENU_NORMAL_ITEM,
);
$items['financials-results-period'] = array(
'title' => 'Financial Results',
'description' => 'Financial Results (specific period)',
'page callback' => 'custom_financials_results_showfiles',
'access arguments' => array('download files'),
'type' => MENU_NORMAL_ITEM,
);
return $items;
function custom_financials_deletefile($id){
if(!user_access("administer module"))
return "In-valid operation";
$file_storage_path=customforms_getvalue("financials_files_path");
if(!$file_storage_path)
return "Please add a key 'financials_files_path' having the storage
path value in 'custom - Manage keys' module";
function custom_financials_deletesection($id){
if(!user_access("administer module"))
return "In-valid operation";
function custom_financials_deletefinancial($id){
if(!user_access("administer module"))
return "In-valid operation";
function custom_financials_manage_files(){
return include_once("manage_files.php");
}
function custom_financials_manage_periods(){
return include_once("manage_periods.php");
//return $content;
}
function custom_financials_download_file(){
$doQuote=!get_magic_quotes_gpc();
$valid=true;
$show=true;
$content="";
$file_path=customforms_getvalue("financials_files_path");
preg_match("#/([^/]*)$#",$_SERVER["REQUEST_URI"],$matches);
$file=urldecode($matches[1]);
if(!file_exists($file_path.DIRECTORY_SEPARATOR.$file)){
drupal_set_message(t('File you are trying to access does not exist
'.$file),'error');
return "";
}
ob_clean();
header('Content-Type: application/octet-stream');
header('Content-Length: '.filesize($file_path.DIRECTORY_SEPARATOR.$file));
header('Content-Disposition: attachment; filename=' . urlencode($file));
readfile($file_path.DIRECTORY_SEPARATOR.$file);
exit;
}
function custom_financials_results_frontend(){
$base_path = base_path();
$menu_string=":::About Us:::Investor Relations:::Financial Results";
$menu_href_string=":::".$base_path."aboutus:::".$base_path."investor-
relations:::aaa";
variable_set("menu_string_1",$menu_string);
variable_set("menu_href_string_1",$menu_href_string);
$doQuote=!get_magic_quotes_gpc();
$valid=true;
$show=true;
$content="";
$spacer=" ";
$period_year=date("Y");
$year_present=true;
if(preg_match("#/([^/]*)$#",$_SERVER["REQUEST_URI"],$matches)){
$matches[1]=urldecode($matches[1]);
if(is_numeric($matches[1]))
$period_year=$matches[1];
else
$year_present=false;
}else
$year_present=false;
if(!$year_present){
$query="select max(period_year) as max_year from custom_financials
where status='1'";
$resultset=db_query($query);
if($row=db_fetch_object($resultset))
$period_year=$row->max_year;
}
$inner_content="";
$query="select * from custom_financials where period_year='".$period_year."'
and status='1' order by sortindex desc, period_text1";
$resultset=db_query($query);
while($row=db_fetch_object($resultset))
$inner_content.="<tr><td><img src=\"".$images_path."/dot.gif\"
align=\"texttop\" height=\"6px\" width=\"6px\" />".$spacer."<a class=\"greenlink\"
href=\"".$base_path."financials-results-period/".$row->id."\">".$row-
>period_text1."</a><br /><br /></td></tr>";
if(strlen($inner_content)>0){
$content.="<div class=\"headboldgreen\" style=\"margin-
bottom:10px;\">".$period_year."</div>";
$content.="<table>".$inner_content."</table>";
}
return $content;
function custom_financials_results_showfiles(){
$base_path = base_path();
$menu_string=":::About Us:::Investor Relations:::Financial Results";
$menu_href_string=":::".$base_path."aboutus:::".$base_path."investor-
relations:::aaa";
variable_set("menu_string_1",$menu_string);
variable_set("menu_href_string_1",$menu_href_string);
$doQuote=!get_magic_quotes_gpc();
$valid=true;
$show=true;
$content="";
$spacer=" ";
$directory = path_to_theme();
$images_path=$base_path.$module_path."/images";
drupal_add_css($module_path."/css/fin-styles.css");
//print "<br />".$base_path.$module_path."/css/styles.css"."<br />";
$id=0;
if(preg_match("#/([^/]*)$#",$_SERVER["REQUEST_URI"],$matches)){
$matches[1]=urldecode($matches[1]);
if(is_numeric($matches[1]))
$id=$matches[1];
else
return "Please enter a proper period";
}else
return "Please enter a proper period";
//print $query;exit;
$files_array=array();
$resultset=db_query($query);
while($row=db_fetch_array($resultset))
$files_array[]=$row;
if(count($files_array)==0)
return "No records were found";
//print $query;exit;
$sections_array=array();
$resultset=db_query($query);
while($row=db_fetch_array($resultset))
$sections_array[]=$row;
$j=0;
$period_year=$sections_array[0]["period_year"];
for($i=0;$i<count($sections_array);$i++){
if($i==0 || $period_year!=$sections_array[$i]["period_year"])
$content.="<div class=\"headboldgreen\" style=\"margin-
bottom:10px;\">".$sections_array[$i]["period_year"]."</div>";
$content.="<div class=\"conttable1\" style=\"margin-
bottom:10px;\">".$sections_array[$i]["section_body"]."</div>";
$content.="<div style=\"margin-bottom:15px\">";
for(;$j<count($files_array) &&
$files_array[$j]["section_id"]==$sections_array[$i]["section_id"];$j++)
$content.="<img src=\"".$images_path."/dot.gif\"
align=\"absmiddle\" height=\"6px\" width=\"6px\" style=\"padding-bottom:2px;\"
/>".$spacer."<a class=\"greenlink\" href=\"".$base_path."financials-
downloadfile/".$files_array[$j]["file_name"]."\">".$files_array[$j]["heading"]."</
a><br />";
$content.="</div>";
}
return $content;
}
$block['subject'] = '';
$block['content'] = '';
$period_year=date("Y");
if(count($periods_array)>0){
for($i=0;$i<count($periods_array);$i++){
$period_year=$periods_array[$i]["period_year"];
if($i==0 || $period_year!=$periods_array[$i-
1]["period_year"]){
$content.="<div class=\"headboldgreen\"
style=\"margin-bottom:10px;\">".$periods_array[$i]["period_year"]."</div>
<div class=\"year_financial\"
style=\"margin-bottom:10px;\">
";
}
$content.="<img
src=\"".$images_path."/dot.gif\" align=\"absmiddle\" height=\"6px\" width=\"6px\"
style=\"padding-bottom:2px;\" />".$spacer."<a class=\"rightnavbottomlink\"
href=\"".$base_path."financials-results-
period/".$periods_array[$i]["id"]."\">".$periods_array[$i]["period_text2"]."</a><b
r />";
if($period_year!=$periods_array[$i+1]["period_year"])
$content.="</div>";
}
}
$block["content"]=$content;
}
break;
}
}
return $block;
}