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();
}
}
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();
}
}
//$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);
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);
}
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);
}
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);
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;
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);
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;
// 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;
}
//---------------------------------------------------------------------------------------------
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";
$_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']);
// 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) {
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);
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";
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');
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'];
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));
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) {
$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);
{
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);
}
$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."));
// 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
{
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"));
$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")
$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
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'];
$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;
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'];
}
if ($pictures)
{
- $image = $comp_path . '/'. $user_comp . "/images/"
+ $image = company_path(). "/images/"
. item_img_name($myrow['stock_id']) . ".jpg";
if (file_exists($image))
{
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'];
$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;
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'];
}
if ($pictures)
{
- $image = $comp_path .'/'. $user_comp . '/images/'
+ $image = company_path() . '/images/'
. item_img_name($trans['stock_id']) . '.jpg';
if (file_exists($image))
{
function print_balance_sheet()
{
- global $comp_path, $path_to_root;
+ global $path_to_root;
$dim = get_company_pref('use_dimension');
$dimension = $dimension2 = 0;
$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;
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;
$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;