Custom_financials Module Of Drupal

  • Uploaded by: sharmila
  • 0
  • 0
  • November 2019
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View Custom_financials Module Of Drupal as PDF for free.

More details

  • Words: 810
  • Pages: 7
'. t("Financials management") .'

'; 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"; $query="select * from custom_financials_files where id='".$id."'"; $result=db_query($query); if(!($record_row=$row=db_fetch_object($result))) return "Im-proper operation"; $filename=$form_file_name=$record_row->file_name; $query="delete from custom_financials_files where id='".$id."'"; db_query($query); if(db_affected_rows()==1){ unlink($file_storage_path."/".$filename); return true; }else{ return false; } } function custom_financials_deletesection($id){ if(!user_access("administer module")) return "In-valid operation"; $query="select * from custom_financials_section where id='".$id."'"; $result=db_query($query); if(!($record_row=$row=db_fetch_object($result))) return "Im-proper operation"; $query="select id from custom_financials_files where cfs_id='".$id."'"; $result=db_query($query); while($row=db_fetch_object($result)) custom_financials_deletefile($row->id); $query="delete from custom_financials_section where id='".$id."'"; db_query($query); if(db_affected_rows()==1){ return true;

}else{ return false; } } function custom_financials_deletefinancial($id){ if(!user_access("administer module")) return "In-valid operation"; $query="select * from custom_financials where id='".$id."'"; $result=db_query($query); if(!($record_row=$row=db_fetch_object($result))) return "Im-proper operation"; $query="select id from custom_financials_section where cf_id='".$id."'"; $result=db_query($query); while($row=db_fetch_object($result)) custom_financials_deletesection($row->id); $query="delete from custom_financials db_query($query); if(db_affected_rows()==1){ return true; }else{ return false; }

where id='".$id."'";

} 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 ""; } $query="select * from custom_financials_files where

file_name='".trim(addslashes($file))."'"; $result=db_query($query); if(!($row=db_fetch_object($result))){ drupal_set_message(t('This file cannot be downloaded'),'error'); return ""; }else{ if(!($row->status || user_access('administer module'))){ drupal_set_message(t('This file cannot be downloaded'),'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."investorrelations:::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="   "; $module_path = drupal_get_path('module', 'custom_financials'); $directory = path_to_theme(); $images_path=$base_path.$module_path."/images"; drupal_add_css($module_path."/css/fin-styles.css"); //print "
".$base_path.$module_path."/css/styles.css"."
"; $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.="".$spacer."id."\">".$row>period_text1."

"; if(strlen($inner_content)>0){ $content.="
".$period_year."
"; $content.="".$inner_content."
"; } 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."investorrelations:::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="   "; $module_path = drupal_get_path('module', 'custom_financials'); $directory = path_to_theme(); $images_path=$base_path.$module_path."/images"; drupal_add_css($module_path."/css/fin-styles.css"); //print "
".$base_path.$module_path."/css/styles.css"."
"; $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"; //build query 1 starts $query=" SELECT custom_financials_files.heading, custom_financials_files.file_name, custom_financials_section.id as section_id, custom_financials.period_year FROM custom_financials_files,custom_financials_section,custom_financials WHERE custom_financials_files.cfs_id=custom_financials_section.id and custom_financials_files.status=1 and

custom_financials_section.cf_id=custom_financials.id and custom_financials.id='".$id."' and custom_financials.status=1 order by custom_financials_section.sortindex desc, custom_financials_section.id"; //build query 1 ends //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"; //build query 2 starts $query=" SELECT custom_financials_section.body as section_body, custom_financials_section.id as section_id, custom_financials.period_year FROM custom_financials_section,custom_financials WHERE custom_financials_section.cf_id=custom_financials.id and custom_financials.id='".$id."' and custom_financials.status=1 order by custom_financials_section.sortindex desc, custom_financials_section.id"; //build query 2 ends //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".$sections_array[$i]["period_year"]."
"; $content.="
".$sections_array[$i]["section_body"]."
"; $content.=""; } return $content; } function custom_financials_block($op='list', $delta=0) { $doQuote=!get_magic_quotes_gpc(); $website_name=variable_get("website_name","sifycorp"); $base_path = base_path(); $directory = drupal_get_path('module', 'newupload');

$content=""; $block['subject'] = ''; $block['content'] = ''; // listing of blocks, such as on the admin/block page if ($op == "list") { $block[0]["info"] = t('Custom Financials Module - Show on right side'); } if ($op == 'view') { switch($delta){ case 0: $block['subject'] = ''; $block['content'] = ''; if(user_access('download files')){ $periods_array=array(); $query="select * from custom_financials where status='1' order by period_year desc, sortindex desc, period_text2"; $resultset=db_query($query); while($row=db_fetch_array($resultset)) $periods_array[]=$row; $period_year=date("Y"); if(count($periods_array)>0){ for($i=0;$i
$content.="
".$periods_array[$i]["period_year"]."
"; } $content.="".$spacer."".$periods_array[$i]["period_text2"].""; if($period_year!=$periods_array[$i+1]["period_year"]) $content.="
"; } } $block["content"]=$content; } break; }

}

} return $block;

Related Documents

Drupal
June 2020 12
Drupal
December 2019 23
Drupal
December 2019 27
Hvorfor Drupal?
July 2020 9
Apuntes-drupal
December 2019 14

More Documents from ""

F(1).txt
May 2020 26
October 2019 24