company_path() helper used.
authorJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 4 Apr 2010 12:11:22 +0000 (12:11 +0000)
committerJanusz Dobrowolski <janusz@frontaccounting.eu>
Sun, 4 Apr 2010 12:11:22 +0000 (12:11 +0000)
19 files changed:
admin/attachments.php
admin/company_preferences.php
admin/create_coy.php
admin/db/fiscalyears_db.inc
admin/display_prefs.php
admin/print_profiles.php
admin/system_diagnostics.php
includes/lang/language.php
includes/page/header.inc
includes/ui/ui_view.inc
inventory/manage/items.php
reporting/includes/excel_report.inc
reporting/includes/header2.inc
reporting/rep102.php
reporting/rep104.php
reporting/rep202.php
reporting/rep303.php
reporting/rep706.php
reporting/rep707.php

index a97843ca3546112100b54672ab4b9b52ee51ac6b..ce4498f6c459b2ebb125eac29c7ba94eb83c45d7 100644 (file)
@@ -38,7 +38,7 @@ if ($view_id != -1)
                        header('Content-Disposition: attachment; filename='.$row['filename']);
                else
                                header("Content-Disposition: inline");
-               echo file_get_contents($comp_path."/".user_company(). "/attachments/".$row['unique_name']);
+               echo file_get_contents(company_path(). "/attachments/".$row['unique_name']);
                exit();
                }
        }       
@@ -60,7 +60,7 @@ if ($download_id != -1)
                header("Content-type: ".$type);
                header('Content-Length: '.$row['filesize']);
                header('Content-Disposition: attachment; filename='.$row['filename']);
-               echo file_get_contents($comp_path."/".user_company(). "/attachments/".$row['unique_name']);
+               echo file_get_contents(company_path()."/attachments/".$row['unique_name']);
                exit();
                }
        }       
@@ -85,7 +85,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
                //$content = base64_encode(file_get_contents($_FILES['filename']['tmp_name']));
                $tmpname = $_FILES['filename']['tmp_name'];
 
-               $dir =  $comp_path."/".user_company(). "/attachments";
+               $dir =  company_path()."/attachments";
                if (!file_exists($dir))
                {
                        mkdir ($dir,0777);
@@ -127,7 +127,7 @@ if ($Mode == 'ADD_ITEM' || $Mode == 'UPDATE_ITEM')
 if ($Mode == 'Delete')
 {
        $row = get_attachment($selected_id);
-       $dir =  $comp_path."/".user_company(). "/attachments";
+       $dir =  company_path()."/attachments";
        if (file_exists($dir."/".$row['unique_name']))
                unlink($dir."/".$row['unique_name']);
        delete_attachment($selected_id);        
index 4acb80746917fd8a6a739acc0fe843edf7c42c3d..bc550789d66b4e5404cf25f35ef07732d1ebd1aa 100644 (file)
@@ -40,9 +40,8 @@ if (isset($_POST['update']) && $_POST['update'] != "")
        }
        if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
        {
-               $user_comp = user_company();
                $result = $_FILES['pic']['error'];
-               $filename = $comp_path . "/$user_comp/images";
+               $filename = company_path()."/images";
                if (!file_exists($filename))
                {
                        mkdir($filename);
@@ -86,8 +85,7 @@ if (isset($_POST['update']) && $_POST['update'] != "")
        }
        if (check_value('del_coy_logo'))
        {
-               $user_comp = user_company();
-               $filename = $comp_path . "/$user_comp/images/".$_POST['coy_logo'];
+               $filename = company_path()."/images/".$_POST['coy_logo'];
                if (file_exists($filename))
                {
                        $result = unlink($filename);
index 29acd007ae6c31105881537f7529e5f13f2d55f6..aa765395b0db5054569ac8ba37e90aeed3a1c988 100644 (file)
@@ -80,7 +80,7 @@ function remove_connection($id) {
 function handle_submit()
 {
        global $db_connections, $def_coy, $tb_pref_counter, $db,
-           $comp_path, $comp_subdirs, $path_to_root;
+           $comp_subdirs, $path_to_root;
 
        $new = false;
        $error = false;
@@ -165,7 +165,7 @@ function handle_submit()
 
        if ($new)
        {
-               create_comp_dirs("$comp_path/$id", $comp_subdirs);
+               create_comp_dirs(company_path($id), $comp_subdirs);
        }
        $exts = get_company_extensions();
        write_extensions($exts, $id);
@@ -177,13 +177,14 @@ function handle_submit()
 
 function handle_delete()
 {
-       global $comp_path, $def_coy, $db_connections, $comp_subdirs, $path_to_root;
+       global $def_coy, $db_connections, $comp_subdirs, $path_to_root;
 
        $id = $_GET['id'];
 
        // First make sure all company directories from the one under removal are writable. 
        // Without this after operation we end up with changed per-company owners!
        for($i = $id; $i < count($db_connections); $i++) {
+                       $comp_path = company_path($i);
                if (!is_dir($comp_path.'/'.$i) || !is_writable($comp_path.'/'.$i)) {
                        display_error(_('Broken company subdirectories system. You have to remove this company manually.'));
                        return;
@@ -198,15 +199,15 @@ function handle_delete()
        // rename directory to temporary name to ensure all
        // other subdirectories will have right owners even after
        // unsuccessfull removal.
-       $cdir = $comp_path.'/'.$id;
-       $tmpname  = $comp_path.'/old_'.$id;
+       $cdir = company_path($id);
+       $tmpname  = company_path('/old_'.$id);
        if (!@rename($cdir, $tmpname)) {
                display_error(_('Cannot rename subdirectory to temporary name.'));
                return;
        }
        // 'shift' company directories names
        for ($i = $id+1; $i < count($db_connections); $i++) {
-               if (!rename($comp_path.'/'.$i, $comp_path.'/'.($i-1))) {
+               if (!rename(company_path($i), company_path($i-1))) {
                        display_error(_("Cannot rename company subdirectory"));
                        return;
                }
index cbd4784ee9de60787cf55abce2cc6f65b24e9e6c..4dc32b6952de79e35ceb4e50a7f8d72336a16e44 100644 (file)
@@ -159,13 +159,12 @@ function open_year($year)
 //---------------------------------------------------------------------------------------------
 function delete_attachments_and_comments($type_no, $trans_no)
 {
-       global $comp_path;
        
        $sql = "SELECT * FROM ".TB_PREF."attachments WHERE type_no = $type_no AND trans_no = $trans_no";
        $result = db_query($sql, "Could not retrieve attachments");
        while ($row = db_fetch($result))
        {
-               $dir =  $comp_path."/".user_company(). "/attachments";
+               $dir =  company_path(). "/attachments";
                if (file_exists($dir."/".$row['unique_name']))
                        unlink($dir."/".$row['unique_name']);
                $sql = "DELETE FROM ".TB_PREF."attachments WHERE  type_no = $type_no AND trans_no = $trans_no";
index fb7004da738808dcbbda4bd7539ecb345b63422e..78809c0c6c7c56defa38e41feb75c753bcface6b 100644 (file)
@@ -45,7 +45,7 @@ if (isset($_POST['setprefs']))
                        $_SESSION['language']->set_language($_POST['language']);
                        // refresh main menu
 
-               flush_dir($comp_path.'/'.user_company().'/js_cache');   
+               flush_dir(company_path().'/js_cache');  
 
                if ($chg_theme || $chg_lang)
                        meta_forward($_SERVER['PHP_SELF']);
index 59f9ec8085ff1c0b10723eb8e545aac54c78bcef..f9972980fc7b0800650181c84b4ddf06f6950e01 100644 (file)
@@ -23,13 +23,13 @@ $selected_id = get_post('profile_id','');
 // Returns array of defined reports
 //
 function get_reports() {
-       global $path_to_root, $comp_path, $go_debug;
+       global $path_to_root, $go_debug;
 
 if ($go_debug || !isset($_SESSION['reports'])) {       
        // to save time, store in session.
                $paths = array (
                        $path_to_root.'/reporting/',
-                       $comp_path .'/'. user_company() . '/reporting/');
+                       company_path(). '/reporting/');
                $reports = array( '' => _('Default printing destination'));
 
        foreach($paths as $dirno => $path) {
index 3b2bfbb834ac89baa2ca3e91e5b5f48c056817ab..44cd37ce5506dcef34a2fe73832018386f11bb8e 100644 (file)
@@ -160,25 +160,26 @@ function tst_dbversion()
 
 function tst_subdirs()
 {
-       global $db_connections, $comp_path;
+       global $db_connections;
 
        $comp_subdirs = array('images', 'pdf_files', 'backup','js_cache');
 
        $test['descr'] = _('Company subdirectories consistency');
        $test['type'] = 3;
-       $test['test'] = array($comp_path.'/*');
+       $test['test'] = array(company_path().'/*');
        foreach($comp_subdirs as $sub) {
-               $test['test'][] = $comp_path.'/*/'.$sub;
+               $test['test'][] = company_path().'/*/'.$sub;
        }
        $test['result'] = true;
-
+       
+       $comp_path = company_path();
        if (!is_dir($comp_path) || !is_writable($comp_path) ) {
                $test['result'] = false;
                $test['comments'][] = sprintf(_("'%s' is not writeable"), $comp_path);
                return $test;
        };
        foreach ($db_connections as $n => $comp) {
-               $path = "$comp_path/$n";
+               $path = company_path($n);
                if (!is_dir($path) || !is_writable($path) ) {
                        $test['result'] = false;
                        $test['comments'][] = sprintf(_("'%s' is not writeable"), $path);
@@ -272,17 +273,17 @@ function tst_dbconfig()
 
 function tst_extconfig()
 {
-       global $path_to_root, $db_connections, $comp_path;
+       global $path_to_root, $db_connections;
 
        $test['descr'] = _('Extensions configuration files');
        $test['type'] = 3;
        $test['test'] = $path_to_root.'/installed_extensions.php';
        $test['result'] = is_file($test['test']) && is_writable($test['test']);
-       $test['test'] . ','.$comp_path.'/*/installed_extensions.php';
+       $test['test'] . ','.company_path().'/*/installed_extensions.php';
        $test['comments'][] = sprintf(_("'%s' file should be writeable"), $test['test']);
 
        foreach ($db_connections as $n => $comp) {
-               $path = "$comp_path/$n";
+               $path = company_path($n);
                if (!is_dir($path)) continue;
 
                $path .= "/installed_extensions.php";
index 824a528ca7ee2da58d35a6aef0c6c13f656064a6..0b8ba215021c68587c14f33a58c96e33e90db989 100644 (file)
@@ -47,7 +47,7 @@ class language
 
        function set_language($code) 
        {
-           global $comp_path, $path_to_root, $installed_languages;
+           global $path_to_root, $installed_languages;
 
                $changed = $this->code != $code;
                $lang = array_search_value($code, $installed_languages, 'code');
@@ -55,7 +55,7 @@ class language
                if ($lang && $changed)
                {
                // flush cache as we can use several languages in one account
-                       flush_dir($comp_path.'/'.user_company().'/js_cache');
+                       flush_dir(company_path().'/js_cache');
 
                        $this->name = $lang['name'];
                        $this->code = $lang['code'];
index b0364cbebcec0e19c6c94ae187dfe13ea768455c..6d6fbdb88016478344569b79cbcfaf62a356fd84 100644 (file)
@@ -47,13 +47,12 @@ function help_url($context=null)
 
 function send_scripts()
 {
-    global $js_lib, $js_static, $js_path, $js_userlib, $comp_path,
-       $path_to_root, $go_debug;
+    global $js_lib, $js_static, $js_path, $js_userlib, $path_to_root, $go_debug;
 
        $js ='';
        foreach($js_static as $jsfile)
        {
-           $fpath = $comp_path.'/'.user_company().'/js_cache/'.$jsfile;
+           $fpath = company_path().'/js_cache/'.$jsfile;
            // compress also static files
                if (!file_exists($fpath) || $go_debug)
                        cache_js_file($fpath, file_get_contents($js_path.$jsfile));
index f2dc7646c810dfbb3c8d7981ced267d032dba643..fe54a261bc2637c68c444ad678d816636701c343 100644 (file)
@@ -799,8 +799,8 @@ function get_js_png_fix()
 
 function get_js_date_picker()
 {
-    global $comp_path, $go_debug;
-    $fpath = $comp_path.'/'.user_company().'/js_cache/'.'date_picker.js';
+    global $go_debug;
+    $fpath = company_path().'/js_cache/'.'date_picker.js';
 
     if (!file_exists($fpath) || $go_debug) {
 
index 250b657857ae54b97976b4f17c1fa186db9daf34..900641ecf2bec717e7efee964b989bf042ee6067 100644 (file)
@@ -56,7 +56,7 @@ if (isset($_FILES['pic']) && $_FILES['pic']['name'] != '')
        $stock_id = $_POST['NewStockID'];
        $result = $_FILES['pic']['error'];
        $upload_file = 'Yes'; //Assume all is well to start off with
-       $filename = $comp_path . "/$user_comp/images";
+       $filename = company_path().'/images';
        if (!file_exists($filename))
        {
                mkdir($filename);
@@ -155,7 +155,7 @@ if (isset($_POST['addupdate']))
        {
                if (check_value('del_image'))
                {
-                       $filename = $comp_path . "/$user_comp/images/".item_img_name($_POST['NewStockID']).".jpg";
+                       $filename = company_path().'/images/'.item_img_name($_POST['NewStockID']).".jpg";
                        if (file_exists($filename))
                                unlink($filename);
                }
@@ -228,7 +228,7 @@ if (isset($_POST['delete']) && strlen($_POST['delete']) > 1)
 
                $stock_id = $_POST['NewStockID'];
                delete_item($stock_id);
-               $filename = $comp_path . "/$user_comp/images/".item_img_name($stock_id).".jpg";
+               $filename = company_path().'/images/'.item_img_name($stock_id).".jpg";
                if (file_exists($filename))
                        unlink($filename);
                display_notification(_("Selected item has been deleted."));
@@ -388,14 +388,14 @@ file_row(_("Image File (.jpg)") . ":", 'pic', 'pic');
 // Add Image upload for New Item  - by Joe
 $stock_img_link = "";
 $check_remove_image = false;
-if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/"
+if (isset($_POST['NewStockID']) && file_exists(company_path().'/images/'
        .item_img_name($_POST['NewStockID']).".jpg")) 
 {
  // 31/08/08 - rand() call is necessary here to avoid caching problems. Thanks to Peter D.
        $stock_img_link .= "<img id='item_img' alt = '[".$_POST['NewStockID'].".jpg".
-               "]' src='$comp_path/$user_comp/images/".item_img_name($_POST['NewStockID']).".jpg?nocache=".rand()."'".
-               " height='$pic_height' border='0'>";
-       $check_remove_image = true;     
+               "]' src='".company_path().'images/'.item_img_name($_POST['NewStockID']).
+               ".jpg?nocache=".rand()."'"." height='$pic_height' border='0'>";
+       $check_remove_image = true;
 } 
 else 
 {
index aca0e2c7bfa7f004ca4ff1c1e39619e75090091e..ceadc52f0a6367b944081a05b910c382c75f0270 100644 (file)
@@ -58,7 +58,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
 
        function FrontReport($title, $filename, $size = 'A4', $fontsize = 9, $orientation = 'P', $margins = NULL, $excelColWidthFactor = 6.5)
        {
-               global $comp_path, $dateseps, $page_security;
+               global $dateseps, $page_security;
                if (!$_SESSION["wa_current_user"]->can_access_page($page_security))
                {
                        display_error(_("The security settings on your account do not permit you to print this report"));
@@ -78,7 +78,7 @@ class FrontReport extends Spreadsheet_Excel_Writer_Workbook
                $this->code = strtolower($_SESSION['language']->encoding);
                $this->filename = $filename.".xls";
                $this->unique_name = uniqid('').".xls";
-               $this->path = $comp_path.'/'.user_company(). '/pdf_files';
+               $this->path = company_path(). '/pdf_files';
                $this->Spreadsheet_Excel_Writer_Workbook($this->path."/".$this->unique_name);
                //$this->setCountry(48);
                if ($this->code != "iso-8859-1")
index 42d99bac05c178ebf098ab2a3e3e91d3a99c6fbe..141881017385ddb909fc78ea0faa5570836738a7 100644 (file)
@@ -59,7 +59,7 @@
                $this->NewLine();
                if ($this->company['coy_logo'] != '')
                {
-                       $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
+                       $logo = company_path() . "/images/" . $this->company['coy_logo'];
                        $this->AddImage($logo, $ccol, $this->row, 0, 40);
                }
                else
index a2f938c0a8413e80b91b3c99f648f084ed9896f4..62128b5022a543ce24c65fd69e1267ef7f80e4f2 100644 (file)
@@ -64,7 +64,7 @@ function get_invoices($customer_id, $to)
 
 function print_aged_customer_analysis()
 {
-    global $comp_path, $path_to_root, $systypes_array;
+    global $path_to_root, $systypes_array;
 
     $to = $_POST['PARAM_0'];
     $fromcust = $_POST['PARAM_1'];
@@ -228,7 +228,7 @@ function print_aged_customer_analysis()
                $pg->built_in  = false;
                $pg->fontfile  = $path_to_root . "/reporting/fonts/Vera.ttf";
                $pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
-               $filename = $comp_path .'/'. user_company(). "/images/test.png";
+               $filename = company_path(). "/images/test.png";
                $pg->display($filename, true);
                $w = $pg->width / 1.5;
                $h = $pg->height / 1.5;
index 2c34f63a096d4ece97ea05de1ef5f5200b2d7e64..e952eacbe60f5ed228f7a4cc25b2cf4ce8b44857 100644 (file)
@@ -66,7 +66,7 @@ function get_kits($category=0)
 
 function print_price_listing()
 {
-    global $comp_path, $path_to_root, $pic_height, $pic_width;
+    global $path_to_root, $pic_height, $pic_width;
 
     $currency = $_POST['PARAM_0'];
     $category = $_POST['PARAM_1'];
@@ -159,7 +159,7 @@ function print_price_listing()
                }
                if ($pictures)
                {
-                       $image = $comp_path . '/'. $user_comp . "/images/" 
+                       $image = company_path(). "/images/" 
                                . item_img_name($myrow['stock_id']) . ".jpg";
                        if (file_exists($image))
                        {
index b443e6d79579c7de37c91992476f66847f1669ab..2915fc8f54592298508804318e2991ef75b041ea 100644 (file)
@@ -65,7 +65,7 @@ function get_invoices($supplier_id, $to)
 
 function print_aged_supplier_analysis()
 {
-    global $comp_path, $path_to_root, $systypes_array;
+    global $path_to_root, $systypes_array;
 
     $to = $_POST['PARAM_0'];
     $fromsupp = $_POST['PARAM_1'];
@@ -230,7 +230,7 @@ function print_aged_supplier_analysis()
                $pg->built_in  = false;
                $pg->fontfile  = $path_to_root . "/reporting/fonts/Vera.ttf";
                $pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
-               $filename = $comp_path.'/'.user_company(). "/pdf_files/test.png";
+               $filename = company_path(). "/pdf_files/test.png";
                $pg->display($filename, true);
                $w = $pg->width / 1.5;
                $h = $pg->height / 1.5;
index 1cd151a62b34ce4c82dc7aaa6208328bd6e45218..73f58ee52659ddc5818a561fb79408184e3375f1 100644 (file)
@@ -61,7 +61,7 @@ function getTransactions($category, $location)
 
 function print_stock_check()
 {
-    global $comp_path, $path_to_root, $pic_height, $pic_width;
+    global $path_to_root, $pic_height, $pic_width;
 
     $category = $_POST['PARAM_0'];
     $location = $_POST['PARAM_1'];
@@ -174,7 +174,7 @@ function print_stock_check()
                }
                if ($pictures)
                {
-                       $image = $comp_path .'/'. $user_comp . '/images/' 
+                       $image = company_path() . '/images/' 
                                . item_img_name($trans['stock_id']) . '.jpg';
                        if (file_exists($image))
                        {
index 529893d7d8031eb365e42765ccc02c0185ba551e..6f36b2f31800e2d0cd7f3526678c4feccfdfa13d 100644 (file)
@@ -122,7 +122,7 @@ print_balance_sheet();
 
 function print_balance_sheet()
 {
-       global $comp_path, $path_to_root;
+       global $path_to_root;
 
        $dim = get_company_pref('use_dimension');
        $dimension = $dimension2 = 0;
@@ -297,7 +297,7 @@ function print_balance_sheet()
                $pg->built_in  = false;
                $pg->fontfile  = $path_to_root . "/reporting/fonts/Vera.ttf";
                $pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
-               $filename = $comp_path.'/'.user_company(). "/pdf_files/test.png";
+               $filename = company_path(). "/pdf_files/test.png";
                $pg->display($filename, true);
                $w = $pg->width / 1.5;
                $h = $pg->height / 1.5;
index c4ef3b6d113a8cc0856d80ced414919764c4f6e7..55bf0aa95f93805fe63f8c897d2cc7f93b849723 100644 (file)
@@ -144,7 +144,7 @@ function Achieve($d1, $d2)
 
 function print_profit_and_loss_statement()
 {
-       global $comp_path, $path_to_root;
+       global $path_to_root;
 
        $dim = get_company_pref('use_dimension');
        $dimension = $dimension2 = 0;
@@ -316,7 +316,7 @@ function print_profit_and_loss_statement()
                $pg->built_in  = false;
                $pg->fontfile  = $path_to_root . "/reporting/fonts/Vera.ttf";
                $pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
-               $filename = $comp_path.'/'.user_company(). "/pdf_files/test.png";
+               $filename = company_path(). "/pdf_files/test.png";
                $pg->display($filename, true);
                $w = $pg->width / 1.5;
                $h = $pg->height / 1.5;