+
+// Recalculate report columns if orientation is landscape.
+function recalculate_cols(&$cols)
+{
+ $factor = (user_pagesize() == "A4" ? 1.4 : 1.3);
+ foreach($cols as $key => $col)
+ $cols[$key] = intval($col * $factor);
+}
+
+function flush_dir($path, $wipe = false)
+{
+ if (!file_exists($path))
+ return;
+ $dir = @opendir($path);
+ if(!$dir)
+ return;
+
+ while(false !== ($fname = readdir($dir))) {
+ if($fname=='.' || $fname=='..' || $fname=='CVS' || (!$wipe && $fname=='index.php')) continue;
+ if(is_dir($path.'/'.$fname)) {
+ flush_dir($path.'/'.$fname, $wipe);
+ if ($wipe) @rmdir($path.'/'.$fname);
+ } else
+ @unlink($path.'/'.$fname);
+ }
+}
+/*
+ Returns current path to company private folder.
+ (Current path can change after chdir).
+*/
+function company_path($comp=null)
+{
+ global $path_to_root, $SysPrefs;
+
+ $comp_path = $SysPrefs->comp_path;
+
+
+ if (!isset($comp))
+ $comp = user_company();
+
+ // if path is relative, set current path_to_root
+ return ($comp_path[0]=='.' ? $path_to_root.'/'.basename($comp_path) : $comp_path)
+ . '/'.$comp;
+}
+
+function is_admin_company()
+{
+ return $this->company == 0;
+}
+