$msg .= "- DatabaseName is the name of the database as defined in the RDMS being used. Typically RDMS allow many databases to be maintained under the same server.\n";
$msg .= " The scripts for MySQL provided use the name logicworks */\n\n\n";
- $msg .= "\$def_coy = " . $def_coy . ";\n\n";
- $msg .= "\$tb_pref_counter = " . $tb_pref_counter . ";\n\n";
+ $msg .= "\$def_coy = " . $def_coy . ";\n\n";
+ $msg .= "\$tb_pref_counter = " . $tb_pref_counter . ";\n\n";
$msg .= "\$db_connections = array (\n";
$msg .= "\t0 => ";
for ($i = 0; $i < $n; $i++)
$filename = $path_to_root . "/config_db.php";
// Check if the file exists and is writable first.
- if (file_exists($filename) && is_writable($filename))
+ if (file_exists($filename) && is_writable($filename))
{
- if (!$zp = fopen($filename, 'w'))
+ if (!$zp = fopen($filename, 'w'))
{
return -1;
- }
- else
+ }
+ else
{
- if (!fwrite($zp, $msg))
+ if (!fwrite($zp, $msg))
{
fclose($zp);
return -2;
// Close file
fclose($zp);
}
- }
- else
+ }
+ else
{
return -3;
}
$sql = "CREATE DATABASE " . $connection["dbname"] . "";
if (!mysql_query($sql))
return 0;
- mysql_select_db($connection["dbname"], $db);
- }
+ mysql_select_db($connection["dbname"], $db);
+ }
return $db;
}
{
$res = db_query("show table status");
$all_tables = array();
- while($row = db_fetch($res))
+ while($row = db_fetch($res))
$all_tables[] = $row;
// get table structures
- foreach ($all_tables as $table)
+ foreach ($all_tables as $table)
{
if (strpos($table['Name'], $connection["tbpref"]) !== false)
db_query("DROP TABLE `".$table['Name'] . "`");
//deleting the tables, how??
return true;
}
-}
+}
-function db_import($filename, $connection)
+function db_import($filename, $connection)
{
$data_queries = array();
$drop_queries = array();
$lines = db_ungzip("lines", $filename);
elseif (strpos($filename, ".zip") || strpos($filename, ".ZIP"))
$lines = db_unzip("lines", $filename);
- else
+ else
$lines = file("". $filename);
// divide insert and create sql queries
$line = trim($line);
$line = str_replace("0_", $connection["tbpref"], $line);
- $line = str_replace("Y_", "0_", $line);
+ // $line = str_replace("Y_", "0_", $line);
// the last line did not belong to a 'create' sql query
- if (!$table)
+ if (!$table)
{
// this line does not, too
- if (strtolower(substr($line,0,6)) == "insert")
+ if (strtolower(substr($line,0,6)) == "insert")
{
$data_queries[] = substr($line, 0, strlen($line) - 1);
// this line does not, too
- }
- elseif (strtolower(substr($line, 0, 20)) == "drop table if exists")
+ }
+ elseif (strtolower(substr($line, 0, 20)) == "drop table if exists")
{
$drop_queries[] = substr($line, 0, strlen($line) - 1);
// this line does!
- }
- elseif (strtolower(substr($line, 0, 6)) == "create")
+ }
+ elseif (strtolower(substr($line, 0, 6)) == "create")
{
$table = true;
$table_queries[] = $line . "\n";
}
// the current line belongs to a create sql query
- }
- else
+ }
+ else
{
// create sql query ending in this line
- if (strtolower(substr($line, 0, 1)) == ")")
+ if (strtolower(substr($line, 0, 1)) == ")")
$table = false;
$table_queries[count($table_queries) - 1] .= $line . "\n";
}
$sql_error = false;
// execute drop tables if exists queries
- if (is_array($drop_queries))
+ if (is_array($drop_queries))
{
- foreach($drop_queries as $drop_query)
+ foreach($drop_queries as $drop_query)
{
$sql_error = false;
- if (!db_query($drop_query))
+ if (!db_query($drop_query))
{
$sql_error = true;
//if ($CONF['import_error']) echo nl2br($drop_query)."\n<div class=\"bold_left\">".mysql_error()."</div><br>\n";
}
// execute create tables queries
- if (is_array($table_queries))
+ if (is_array($table_queries))
{
- foreach($table_queries as $table_query)
+ foreach($table_queries as $table_query)
{
$sql_error = false;
- if (!db_query($table_query))
+ if (!db_query($table_query))
{
$sql_error = true;
//if ($CONF['import_error']) echo nl2br($table_query)."\n<div class=\"bold_left\">".mysql_error()."</div><br>\n";
}
// execute insert data queries
- if (is_array($data_queries))
+ if (is_array($data_queries))
{
- foreach($data_queries as $data_query)
+ foreach($data_queries as $data_query)
{
$sql_error = false;
if (!db_query($data_query))
}
// show number successful executed querys or if an error did occur
- if ($sql_error == 1)
+ if ($sql_error == 1)
return false;
//echo "<div class=\"red\">".IM_ERROR.".</div>\n";
- else
+ else
return true;
//echo "<div class=\"green\">".IM_SUCCESS." ".count($table_queries)." ".IM_TABLES." ".count($data_queries)." ".IM_ROWS." (".$import_file.")</div>\n";
//$shell_command = C_MYSQL_PATH . " -h $host -u $user -p{$password} $dbname < $filename";
}
// returns the content of the gziped $path backup file. use of $mode see below
-function db_ungzip($mode, $path)
+function db_ungzip($mode, $path)
{
$file_data = gzfile($path);
// returns one string or an array of lines
- if ($mode != "lines")
- return implode("",$file_data);
- else
+ if ($mode != "lines")
+ return implode("",$file_data);
+ else
return $file_data;
}
// returns the content of the ziped $path backup file. use of $mode see below
-function db_unzip($mode, $path)
+function db_unzip($mode, $path)
{
$all = false;
$all = implode("", file($path));
// convert path to name of ziped file
$filename = ereg_replace(".*/", "", $path);
$filename = substr($filename, 0, strlen($filename) - 4);
-
+
// compare filname in zip and filename from $_GET
- if (substr($all, 30, strlen($filename)) != $filename)
+ if (substr($all, 30, strlen($filename)) != $filename)
{
return '';
// exit if names differ
//echo F_WRONG_FILE.".";
//exit;
- }
- else
+ }
+ else
{
// get the suffix of the filename in hex
$crc_bugfix = substr(substr($filename, 0, strlen($filename) - 4), strlen($filename) - 12 - 4);
$suffix = false;
// convert hex to ascii
- for ($i=0; $i < 12; )
+ for ($i=0; $i < 12; )
$suffix .= chr($crc_bugfix[$i++] . $crc_bugfix[$i++] . $crc_bugfix[$i++]);
// remove central directory information (we have always just one ziped file)
}
// returns one string or an array of lines
- if ($mode != "lines")
- return $file_data;
- else
+ if ($mode != "lines")
+ return $file_data;
+ else
return explode("\n", $file_data);
}
// generates a dump of $db database
// $drop and $zip tell if to include the drop table statement or dry to pack
-function db_export($conn, $filename, $zip='no', $comment='')
+function db_export($conn, $filename, $zip='no', $comment='')
{
global $app_title, $version, $power_url, $path_to_root;
-
+
$error = false;
-
+
// set max string size before writing to file
$max_size = 1048576 * 2; // 2 MB
// changes max size if value can be retrieved
- if (ini_get("memory_limit"))
+ if (ini_get("memory_limit"))
$max_size = 900000 * ini_get("memory_limit");
-
+
// set backupfile name
- if ($zip == "gzip")
+ if ($zip == "gzip")
$backupfile = $filename . ".gz";
- elseif ($zip == "zip")
+ elseif ($zip == "zip")
$backupfile = $filename . ".zip";
- else
+ else
$backupfile = $filename;
- $company = get_company_pref('coy_name');
+ $company = get_company_pref('coy_name');
//create comment
$out="# MySQL dump of database '".$conn["dbname"]."' on host '".$conn["host"]."'\n";
$out.="# Backup Date and Time: ".date("Y-m-d H:i")."\n";
$out.="# User: ".$_SESSION["wa_current_user"]->name."\n\n";
// write users comment
- if ($comment)
+ if ($comment)
{
$out .= "# Comment:\n";
$comment=preg_replace("'\n'","\n# ","# ".$comment);
//$comment=str_replace("\n", "\n# ", $comment);
- foreach(explode("\n",$comment) as $line)
+ foreach(explode("\n",$comment) as $line)
$out .= $line."\n";
$out.="\n";
}
-
+
//$out.="use ".$db.";\n"; we don't use this option.
// get auto_increment values and names of all tables
$res = db_query("show table status");
$all_tables = array();
- while($row = db_fetch($res))
+ while($row = db_fetch($res))
{
if ($conn["tbpref"] == "" || strpos($row['Name'], $conn["tbpref"]) !== false)
$all_tables[] = $row;
- }
+ }
// get table structures
- foreach ($all_tables as $table)
+ foreach ($all_tables as $table)
{
$res1 = db_query("SHOW CREATE TABLE `" . $table['Name'] . "`");
$tmp = db_fetch($res1);
$fks = array();
if (isset($table_sql))
{
- foreach($table_sql as $tablenme=>$table)
+ foreach($table_sql as $tablenme=>$table)
{
$tmp_table=$table;
// save all tables, needed for creating this table in $fks
- while (($ref_pos = strpos($tmp_table, " REFERENCES ")) > 0)
+ while (($ref_pos = strpos($tmp_table, " REFERENCES ")) > 0)
{
$tmp_table = substr($tmp_table, $ref_pos + 12);
$ref_pos = strpos($tmp_table, "(");
$all_tables = order_sql_tables($all_tables, $fks);
// as long as no error occurred
- if (!$error)
+ if (!$error)
{
- //while($row=@mysql_fetch_array($res))
- foreach ($all_tables as $row)
+ //while($row=@mysql_fetch_array($res))
+ foreach ($all_tables as $row)
{
$tablename = $row['Name'];
$auto_incr[$tablename] = $row['Auto_increment'];
$out.=$table_sql[$tablename];
// add auto_increment value
- if ($auto_incr[$tablename])
+ if ($auto_incr[$tablename])
$out.=" AUTO_INCREMENT=".$auto_incr[$tablename];
$out.=" ;";
$out.="\n\n\n";
// export data
- if (!$error)
+ if (!$error)
{
$out.="### Data of table `".$tablename."` ###\n\n";
$out .= "INSERT INTO `" . $tablename . "` VALUES (";
$row2 = db_fetch_row($res2);
// run through each field
- for ($k = 0; $k < $nf = db_num_fields($res2); $k++)
+ for ($k = 0; $k < $nf = db_num_fields($res2); $k++)
{
// identify null values and save them as null instead of ''
- if ($field_type[$k] != "" && $row2[$k] == "")
- $out .= "NULL";
- else
+ if ($field_type[$k] != "" && $field_type[$k] != "NO" && $row2[$k] == "")
+ $out .= "NULL";
+ else
$out .= "'" . db_escape($row2[$k]) . "'";
- if ($k < ($nf - 1))
+ if ($k < ($nf - 1))
$out .= ", ";
}
$out .= ");\n";
// if saving is successful, then empty $out, else set error flag
- if (strlen($out) > $max_size && $zip != "zip")
+ if (strlen($out) > $max_size && $zip != "zip")
{
- if (save_to_file($backupfile, $zip, $out))
- $out = "";
- else
+ if (save_to_file($backupfile, $zip, $out))
+ $out = "";
+ else
$error = true;
}
}
// an error occurred! Try to delete file and return error status
- }
- elseif ($error)
+ }
+ elseif ($error)
{
@unlink($path_to_root . BACKUP_PATH . $backupfile);
return false;
}
// if saving is successful, then empty $out, else set error flag
- if (strlen($out) > $max_size && $zip != "zip")
+ if (strlen($out) > $max_size && $zip != "zip")
{
- if (save_to_file($backupfile, $zip, $out))
- $out= "";
- else
+ if (save_to_file($backupfile, $zip, $out))
+ $out= "";
+ else
$error = true;
}
}
// an error occurred! Try to delete file and return error status
- }
- else
+ }
+ else
{
@unlink($path_to_root . BACKUP_PATH . $backupfile);
return false;
// if (mysql_error()) return "DB_ERROR";
//@mysql_close($con);
- //if ($zip == "zip")
+ //if ($zip == "zip")
// $zip = $time;
- if (save_to_file($backupfile, $zip, $out))
+ if (save_to_file($backupfile, $zip, $out))
{
$out = "";
- }
- else
+ }
+ else
{
@unlink($path_to_root . BACKUP_PATH . $backupfile);
return false;
// orders the tables in $tables according to the constraints in $fks
// $fks musst be filled like this: $fks[tablename][0]=needed_table1; $fks[tablename][1]=needed_table2; ...
-function order_sql_tables($tables, $fks)
+function order_sql_tables($tables, $fks)
{
// do not order if no contraints exist
- if (!count($fks))
+ if (!count($fks))
return $tables;
// order
$new_tables = array();
$existing = array();
$modified = true;
- while (count($tables) && $modified == true)
+ while (count($tables) && $modified == true)
{
$modified = false;
- foreach ($tables as $key=>$row)
+ foreach ($tables as $key=>$row)
{
// delete from $tables and add to $new_tables
- if (isset($fks[$row['Name']]))
+ if (isset($fks[$row['Name']]))
{
- foreach($fks[$row['Name']] as $needed)
+ foreach($fks[$row['Name']] as $needed)
{
// go to next table if not all needed tables exist in $existing
- if (!in_array($needed,$existing))
+ if (!in_array($needed,$existing))
continue 2;
}
}
}
}
- if (count($tables))
+ if (count($tables))
{
// probably there are 'circles' in the constraints, bacause of that no proper backups can be created yet
// TODO: this will be fixed sometime later through using 'alter table' commands to add the constraints after generating the tables
// until now, just add the lasting tables to $new_tables, return them and print a warning
- foreach($tables as $row)
+ foreach($tables as $row)
$new_tables[] = $row;
echo "<div class=\"red_left\">THIS DATABASE SEEMS TO CONTAIN 'RING CONSTRAINTS'. WA DOES NOT SUPPORT THEM. PROBABLY THE FOLOWING BACKUP IS DEFECT!</div>";
}
// saves the string in $fileData to the file $backupfile as gz file or not ($zip)
// returns backup file name if name has changed (zip), else TRUE. If saving failed, return value is FALSE
-function save_to_file($backupfile, $zip, $fileData)
+function save_to_file($backupfile, $zip, $fileData)
{
global $path_to_root;
-
- if ($zip == "gzip")
+
+ if ($zip == "gzip")
{
- if ($zp = @gzopen($path_to_root . BACKUP_PATH . $backupfile, "a9"))
+ if ($zp = @gzopen($path_to_root . BACKUP_PATH . $backupfile, "a9"))
{
@gzwrite($zp, $fileData);
@gzclose($zp);
return true;
- }
- else
+ }
+ else
{
return false;
}
-
+
// $zip contains the timestamp
- }
- elseif ($zip == "zip")
+ }
+ elseif ($zip == "zip")
{
// based on zip.lib.php 2.2 from phpMyBackupAdmin
// offical zip format: http://www.pkware.com/appnote.txt
-
+
// End of central directory record
$eof_ctrl_dir = "\x50\x4b\x05\x06\x00\x00\x00\x00";
// string needed for decoding (because of crc bug)
//$name_suffix = substr($zdata, -4, 4);
//$name_suffix2 = "_";
- //for ($i = 0; $i < 4; $i++)
+ //for ($i = 0; $i < 4; $i++)
// $name_suffix2 .= sprintf("%03d", ord($name_suffix[$i]));
//$backupfile = substr($backupfile, 0, strlen($backupfile) - 8) . $name_suffix2 . ".sql.zip";
$name = substr($backupfile, 0, strlen($backupfile) -4);
// crc32, compressed filesize, uncompressed filesize
$sub2 = pack('V', $crc) . pack('V', $c_len) . pack('V', $unc_len);
-
+
$fr = "\x50\x4b\x03\x04" . $sub1. $sub2;
-
+
// length of filename, extra field length
$fr .= pack('v', strlen($name)) . pack('v', 0);
$fr .= $name;
$cdrec = "\x50\x4b\x01\x02";
$cdrec .= "\x00\x00"; // version made by
$cdrec .= $sub1 . $sub2;
-
+
// length of filename, extra field length, file comment length, disk number start, internal file attributes, external file attributes - 'archive' bit set, offset
$cdrec .= pack('v', strlen($name)) . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('v', 0) . pack('V', 32) . pack('V',0);
$cdrec .= $name;
// combine data
$fileData = $fr . $cdrec . $eof_ctrl_dir;
-
+
// total # of entries "on this disk", total # of entries overall, size of central dir, offset to start of central dir, .zip file comment length
$fileData .= pack('v', 1) . pack('v', 1) . pack('V', strlen($cdrec)) . pack('V', strlen($fr)) . "\x00\x00";
-
- if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
+
+ if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
{
@fwrite($zp, $fileData);
@fclose($zp);
return true;
- }
- else
+ }
+ else
{
return false;
}
-
+
// uncompressed
- }
- else
+ }
+ else
{
- if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
+ if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
{
@fwrite($zp, $fileData);
@fclose($zp);
return true;
- }
- else
+ }
+ else
{
return false;
}
function FrontReport($title, $filename, $size = 'A4', $fontsize = 9)
{
- switch ($size)
+ switch ($size)
{
case 'A4':
{
$fontinclude = true;
include($locale);
- }
+ }
//if ($this->rtl) // this is good for presentation only
if (!$own)
{
{
$this->rtl = true;
$path = $path_to_root . 'reporting/fonts/farsi_1.afm';
- }
+ }
elseif ($style == 'italic')
$path = $path_to_root . 'reporting/fonts/Helvetica-Oblique.afm';
elseif ($style == 'bold')
$path = $path_to_root . 'reporting/fonts/Helvetica-Bold.afm';
else // even take misspelled styles
$path = $path_to_root . 'reporting/fonts/Helvetica.afm';
- }
+ }
$this->selectFont($path, 'WinAnsiEncoding');
}
$str .= " - " . $this->params[$i]['to'];
$this->Text($this->titleCol, $str, $this->companyCol);
}
- }
+ }
if ($this->params[0] != '') // Comments
{
$this->NewLine();
function Header2($myrow, $branch, $sales_order, $bankaccount, $doctype)
{
- global $path_to_root, $print_as_quote;
-
+ global $path_to_root, $print_as_quote, $print_invoice_no;
+
$this->pageNumber++;
if ($this->pageNumber > 1)
$this->newPage();
$header2type = true;
if ($this->currency != $myrow['curr_code'])
{
- include($path_to_root . "reporting/includes/doctext2.inc");
- }
+ include($path_to_root . "reporting/includes/doctext2.inc");
+ }
else
{
- include($path_to_root . "reporting/includes/doctext.inc");
- }
+ include($path_to_root . "reporting/includes/doctext.inc");
+ }
$this->row = $this->pageHeight - $this->topMargin;
-
+
$upper = $this->row - 2 * $this->lineHeight;
$lower = $this->bottomMargin + 6 * $this->lineHeight;
$iline1 = $upper - 4 * $this->lineHeight;
$this->Text($this->endLine - 35, _("Page") . ' ' . $this->pageNumber);
$this->fontSize -= 4;
$this->row = $upper - 5;
-
+
$this->Text($mcol, $doc_Invoice_no, $mcol + 90);
$this->Text($mcol + 90, $doc_Cust_no, $mcol + 180);
$this->Text($mcol + 180, $doc_Date);
$this->Text($mcol, $myrow['order_no'], $mcol + 90);
else if ($doctype == 9) // SO
$this->Text($mcol, $myrow['order_no'] ." ".$myrow['customer_ref'], $mcol + 90);
- else // INV/CRE/STA
- $this->Text($mcol, $myrow['reference'], $mcol + 90);
+ else // INV/CRE/STA
+ {
+ if ($print_invoice_no == 1)
+ $this->Text($mcol, $myrow['trans_no'], $mcol + 90);
+ else
+ $this->Text($mcol, $myrow['reference'], $mcol + 90);
+ }
$this->Text($mcol + 90, $myrow['debtor_no'], $mcol + 180);
if ($doctype == 8 || $doctype == 9)
$this->Text($mcol + 180, sql2date($myrow['ord_date']));
- else
+ else
$this->Text($mcol + 180, sql2date($myrow['tran_date']));
$this->fontSize -= 4;
$this->Text($ccol, $doc_Charge_To, $icol);
$this->Text($mcol, $doc_Delivered_To);
$this->fontSize += 4;
-
+
$this->NewLine(2);
$temp = $this->row;
if ($doctype == 9)
{
$this->Text($ccol, $myrow['name'], $icol);
//$adr = ?;
- }
+ }
else
{
if ($doctype == 8)
$this->Text($ccol, $myrow['supp_name'], $icol);
- else
+ else
$this->Text($ccol, $myrow['DebtorName'], $icol);
$adr = explode("\n", $myrow['address']);
- }
+ }
for ($i = 0; $i < count($adr); $i++)
- {
+ {
$this->NewLine();
$this->Text($ccol, $adr[$i], $icol);
}
$this->row = $temp;
if ($doctype == 8)
$this->Text($mcol, $this->company['coy_name']);
- else
+ else
$this->Text($mcol, $sales_order['deliver_to']);
$adr = explode("\n", $sales_order['delivery_address']);
for ($i = 0; $i < count($adr); $i++)
- {
+ {
$this->NewLine();
$this->Text($mcol, $adr[$i]);
}
$this->Text($mcol, $doc_Due_Date . ":", $mcol2);
if ($doctype == 9)
$this->Text($mcol2, sql2date($myrow['delivery_date']));
- else if ($doctype != 8)
+ else if ($doctype != 8)
$this->Text($mcol2, sql2date($myrow['due_date']));
if ($branch != null)
{
$row = db_fetch($result);
$this->Text($mcol2, $row['salesman_name']);
- }
+ }
$this->NewLine();
$this->Text($ccol, $doc_Your_VAT_no . ":", $ccol2);
if ($doctype != 8)
$this->Text($ccol2, $row["terms"], $mcol);
$this->Text($mcol, $doc_Our_Order_No . ":", $mcol2);
$this->Text($mcol2, $myrow['order_']);
-
+
$locale = $path_to_root . "lang/" . $_SESSION['language']->code . "/locale.inc";
if (file_exists($locale))
{
$header2include = true;
include($locale);
- }
+ }
$this->row = $iline3 - $this->lineHeight - 2;
$this->Font('bold');
$count = count($this->headers);
if ($branch['disable_branch'] == 1)
{
$amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"], user_price_dec());
- $txt = $doc_Payment_Link . " PayPal: ";
+ $txt = $doc_Payment_Link . " PayPal: ";
$name = urlencode($this->title . " " . $myrow['reference']);
$url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
$name . "&amount=" . $amt . "¤cy_code=" . $myrow['curr_code'];
$this->SetTextColor(0, 0, 0);
$this->addLink($url, $ccol, $this->row, $this->pageWidth - $this->rightMargin, $this->row + $this->lineHeight);
$this->fontSize += 2;
- }
+ }
}
if ($this->params['comments'] != '')
{
$this->Text($ccol, $this->params['comments']);
$this->Font();
}
-
+
$this->row = $lower - 5;
$this->fontSize -= 4;
-
+
$this->Text($ccol, $doc_Address, $ccol2 + 40);
$this->Text($ccol2 + 30, $doc_Phone_Fax_Email, $mcol);
$this->Text($mcol , $doc_Bank, $mcol2);
$this->Text($mcol2, $doc_Bank_Account);
$this->fontSize += 4;
$this->NewLine();
- $adrline = $this->row;
-
+ $adrline = $this->row;
+
$adr = explode("\n", $this->company['postal_address']);
for ($i = 0; $i < count($adr); $i++)
- {
+ {
$this->Text($ccol, $adr[$i], $ccol2 + 40);
$this->NewLine();
}
- $this->row = $adrline;
+ $this->row = $adrline;
$this->Text($ccol2 + 30, $this->company['phone'], $mcol);
$this->NewLine();
$this->Text($ccol2 + 30, $this->company['fax'], $mcol);
$this->NewLine();
$this->Text($ccol2 + 30, $this->company['email'], $mcol);
// fetch this later
- $this->row = $adrline;
+ $this->row = $adrline;
$this->Text($mcol, $bankaccount['bank_name'], $mcol2);
$adr = explode("\n", $bankaccount['bank_address']);
for ($i = 0; $i < count($adr); $i++)
- {
+ {
$this->NewLine();
$this->Text($mcol, $adr[$i], $mcol2);
}
-
- $this->row = $adrline;
+
+ $this->row = $adrline;
$this->Text($mcol2, $bankaccount['bank_account_name']);
$this->NewLine();
$this->Text($mcol2, $bankaccount['bank_account_number']);
$this->addPngFromFile($logo, $x, $y, $w, $h);
else
$this->addJpegFromFile($logo, $x, $y, $w, $h);
- }
+ }
function SetDrawColor($r, $g, $b)
{
$this->setStrokeColor($r / 255, $g / 255, $b / 255);
}
-
+
function SetTextColor($r, $g, $b)
{
$this->setColor($r / 255, $g / 255, $b / 255);
if ($n == 0)
$n = $this->pageWidth - $this->rightMargin;
- return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, 'left');
+ return $this->TextWrap($c, $this->row - $r, $n - $c + $corr, $txt, 'left');
}
-
- function TextWrap($xpos, $ypos, $len, $str, $align = 'left')
+
+ function TextWrap($xpos, $ypos, $len, $str, $align = 'left')
{
if ($this->rtl)
{
$align = 'right';
elseif ($align == 'right')
$align = 'left';
- }
+ }
return $this->addTextWrap($xpos, $ypos, $len, $this->fontSize, $str, $align);
}
{
return $this->TextWrap($this->cols[$c], $this->row - $r, $this->cols[$n] - $this->cols[$c] + $corr, $txt, $this->aligns[$c]);
}
-
+
function TextCol2($c, $n, $txt, $corr=0, $r=0)
{
return $this->TextWrap($this->cols2[$c], $this->row - $r, $this->cols2[$n] - $this->cols2[$c] + $corr, $txt, $this->aligns2[$c]);
}
-
+
function TextColLines($c, $n, $txt, $corr=0)
{
$str = Explode("\n", $txt);
for ($i = 0; $i < count($str); $i++)
{
$l = $str[$i];
- do
+ do
{
- $l = $this->TextCol($c, $n, $l, $corr);
+ $l = $this->TextCol($c, $n, $l, $corr);
$this->NewLine();
}
while ($l != '');
- }
+ }
}
- function LineTo($from, $row, $to, $row2)
+ function LineTo($from, $row, $to, $row2)
{
Cpdf::line($from, $row, $to, $row2);
}
- function Line($row, $height = 0)
+ function Line($row, $height = 0)
{
$this->setLineStyle($height + 1);
Cpdf::line($this->pageWidth - $this->rightMargin, $row ,$this->leftMargin, $row);
$this->row -= ($l * $this->lineHeight);
if ($np > 0 && $this->row < $this->bottomMargin + ($np * $this->lineHeight))
$this->Header();
- }
+ }
function End($email=0, $subject=null, $myrow=null, $doctype = 0)
{
// this is no good in IE so has been replaced, see down under
// but good for debugging purposes in IE
//session_write_close();
-
- if ($go_debug == 1)
+
+ if ($go_debug == 1)
{
$buf = $this->output(1);
$len = strlen($buf);
//header('Pragma: public');
//$this->pdf->stream();
- }
- else
+ }
+ else
{
$buf = $this->output();
$len = strlen($buf);
$emailtype = true;
if ($this->currency != $myrow['curr_code'])
{
- include("doctext2.inc");
- }
+ include("doctext2.inc");
+ }
else
{
- include("doctext.inc");
- }
+ include("doctext.inc");
+ }
require_once($path_to_root . "reporting/includes/class.mail.inc");
$mail = new email($this->company['coy_name'], $this->company['email']);
$from = $this->company['coy_name'] . " <" . $this->company['email'] . ">";
$to = $myrow['DebtorName'] . " <" . $myrow['email'] . ">";
- $msg = $doc_Dear_Sirs . ",\n\n" . $doc_AttachedFile . " " . $subject .
+ $msg = $doc_Dear_Sirs . ",\n\n" . $doc_AttachedFile . " " . $subject .
"\n\n";
if ($myrow['dimension_id'] > 0 && $doctype == 10) // helper for payment links
{
if ($myrow['dimension_id'] == 1)
{
$amt = number_format($myrow["ov_freight"] + $myrow["ov_gst"] + $myrow["ov_amount"], user_price_dec());
- $txt = $doc_Payment_Link . " PayPal: ";
+ $txt = $doc_Payment_Link . " PayPal: ";
$nn = urlencode($this->title . " " . $myrow['reference']);
$url = "https://www.paypal.com/xclick/business=" . $this->company['email'] . "&item_name=" .
$nn . "&amount=" . $amt . "¤cy_code=" . $myrow['curr_code'];
- $msg .= $txt . $url . "\n\n";
- }
+ $msg .= $txt . $url . "\n\n";
+ }
}
$msg .= $doc_Kindest_regards . "\n\n";
$sender = $this->user . "\n" . $this->company['coy_name'];
}
else
{
- echo '<html>
- <head>
- <SCRIPT LANGUAGE="JavaScript"><!--
- function go_now () { window.location.href = "'.$fname.'"; }
- //--></SCRIPT>
- </head>
- <body onLoad="go_now()"; >
- <a href="'.$fname.'">click here</a> if you are not re-directed.
- </body>
- </html>';
- }
+ //echo '<html>
+ // <head>
+ // <SCRIPT LANGUAGE="JavaScript"><!--
+ // function go_now () { window.location.href = "'.$fname.'"; }
+ // //--></SCRIPT>
+ // </head>
+ // <body onLoad="go_now()"; >
+ // <a href="'.$fname.'">click here</a> if you are not re-directed.
+ // </body>
+ // </html>';
+ header('Content-type: application/pdf');
+ header("Content-Disposition: inline; filename=$this->filename");
+ header('Expires: 0');
+ header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
+ header('Pragma: public');
+ $this->stream();
+
+ }
// also have a look through the directory, and remove the files that are older than a week
// rather want to save 'em
/*if ($d = @opendir($dir)) {