From: Joe Hunt Date: Sat, 4 Jul 2020 12:54:43 +0000 (+0200) Subject: PHP 7.4 compatibility bug X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=commitdiff_plain;ds=sidebyside;h=de2da4b73a8505f8e6032bb04b26d859339c89f4;p=fa-stable.git PHP 7.4 compatibility bug --- diff --git a/gl/includes/db/gl_db_trans.inc b/gl/includes/db/gl_db_trans.inc index fc535ad6..459db9f4 100644 --- a/gl/includes/db/gl_db_trans.inc +++ b/gl/includes/db/gl_db_trans.inc @@ -462,7 +462,7 @@ function add_trans_tax_details($trans_type, $trans_no, $tax_id, $rate, $included // guess tax register if not set if (!isset($reg_type)) $reg_type = in_array($trans_type, array(ST_SUPPINVOICE, ST_SUPPCREDIT)) ? TR_OUTPUT - : in_array($trans_type, array(ST_SALESINVOICE, ST_CUSTCREDIT)) ? TR_INPUT : null; + : (in_array($trans_type, array(ST_SALESINVOICE, ST_CUSTCREDIT)) ? TR_INPUT : null); $sql = "INSERT INTO ".TB_PREF."trans_tax_details (trans_type, trans_no, tran_date, tax_type_id, rate, ex_rate, diff --git a/reporting/includes/barcodes.php b/reporting/includes/barcodes.php index bfe7f4a8..4b88fff8 100644 --- a/reporting/includes/barcodes.php +++ b/reporting/includes/barcodes.php @@ -243,7 +243,7 @@ class TCPDFBarcode { $bararray = array("code" => $code, "maxw" => 0, "maxh" => 1, "bcode" => array()); $k = 0; for($i=0; $i < strlen($code); $i++) { - $char = $code{$i}; + $char = $code[$i]; if(!isset($chr[$char])) { // invalid character return false; @@ -254,7 +254,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $chr[$char]{$j}; + $w = $chr[$char][$j]; $bararray["bcode"][$k] = array("t" => $t, "w" => $w, "h" => 1, "p" => 0); $bararray["maxw"] += $w; $k++; @@ -308,10 +308,10 @@ class TCPDFBarcode { chr(124) => '%Q', chr(125) => '%R', chr(126) => '%S', chr(127) => '%T'); $code_ext = ''; for ($i = 0 ; $i < strlen($code); $i++) { - if (ord($code{$i}) > 127) { + if (ord($code[$i]) > 127) { return false; } - $code_ext .= $encode[$code{$i}]; + $code_ext .= $encode[$code[$i]]; } return $code_ext; } @@ -330,7 +330,7 @@ class TCPDFBarcode { 'W', 'X', 'Y', 'Z', '-', '.', ' ', '$', '/', '+', '%'); $sum = 0; for ($i=0 ; $i < strlen($code); $i++) { - $k = array_keys($chars, $code{$i}); + $k = array_keys($chars, $code[$i]); $sum += $k[0]; } $j = ($sum % 43); @@ -369,8 +369,8 @@ class TCPDFBarcode { $bararray = array("code" => $code, "maxw" => 0, "maxh" => 1, "bcode" => array()); $k = 0; for($i=0; $i < strlen($code); $i=$i+2) { - $char_bar = $code{$i}; - $char_space = $code{$i+1}; + $char_bar = $code[$i]; + $char_space = $code[$i+1]; if((!isset($chr[$char_bar])) OR (!isset($chr[$char_space]))) { // invalid character return false; @@ -378,7 +378,7 @@ class TCPDFBarcode { // create a bar-space sequence $seq = ""; for($s=0; $s < strlen($chr[$char_bar]); $s++){ - $seq .= $chr[$char_bar]{$s} . $chr[$char_space]{$s}; + $seq .= $chr[$char_bar][$s] . $chr[$char_space][$s]; } for($j=0; $j < strlen($seq); $j++) { if (($j % 2) == 0) { @@ -386,7 +386,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq{$j}; + $w = $seq[$j]; $bararray["bcode"][$k] = array("t" => $t, "w" => $w, "h" => 1, "p" => 0); $bararray["maxw"] += $w; $k++; @@ -541,7 +541,7 @@ class TCPDFBarcode { } $new_code = ""; for ($i=0; $i < (strlen($code) / 2); $i++) { - $new_code .= chr(intval($code{(2 * $i)}.$code{(2 * $i + 1)})); + $new_code .= chr(intval($code[(2 * $i)].$code[(2 * $i + 1)])); } $code = $new_code; break; @@ -553,7 +553,7 @@ class TCPDFBarcode { // calculate check character $sum = $startid; for ($i=0; $i < strlen($code); $i++) { - $sum += (strpos($keys, $code{$i}) * ($i+1)); + $sum += (strpos($keys, $code[$i]) * ($i+1)); } $check = ($sum % 103); @@ -563,9 +563,9 @@ class TCPDFBarcode { $k = 0; $len = strlen($code); for($i=0; $i < $len; $i++) { - $ck = strpos($keys, $code{$i}); + $ck = strpos($keys, $code[$i]); if (($i == 0) OR ($i > ($len-4))) { - $seq = $chr[ord($code{$i})]; + $seq = $chr[ord($code[$i])]; } elseif(($ck >= 0) AND isset($chr[$ck])) { $seq = $chr[$ck]; } else { @@ -578,7 +578,7 @@ class TCPDFBarcode { } else { $t = false; // space } - $w = $seq{$j}; + $w = $seq[$j]; $bararray["bcode"][$k] = array("t" => $t, "w" => $w, "h" => 1, "p" => 0); $bararray["maxw"] += $w; $k++; @@ -610,14 +610,14 @@ class TCPDFBarcode { // calculate check digit $sum_a = 0; for ($i = 1; $i < $data_len; $i+=2) { - $sum_a += $code{$i}; + $sum_a += $code[$i]; } if ($len > 12) { $sum_a *= 3; } $sum_b = 0; for ($i = 0; $i < $data_len; $i+=2) { - $sum_b += ($code{$i}); + $sum_b += ($code[$i]); } if ($len < 13) { $sum_b *= 3; @@ -629,7 +629,7 @@ class TCPDFBarcode { if ($code_len == $data_len) { // add check digit $code .= $r; - } elseif ($r !== intval($code{$data_len})) { + } elseif ($r !== intval($code[$data_len])) { // wrong checkdigit return false; } @@ -740,7 +740,7 @@ class TCPDFBarcode { $bararray = array('code' => $upce_code, 'maxw' => 0, 'maxh' => 1, 'bcode' => array()); $p = $upce_parities[$code[1]][$r]; for ($i = 0; $i < 6; ++$i) { - $seq .= $codes[$p[$i]][$upce_code{$i}]; + $seq .= $codes[$p[$i]][$upce_code[$i]]; } $seq .= '010101'; // right guard bar } else { @@ -748,17 +748,17 @@ class TCPDFBarcode { $half_len = intval(ceil($len / 2)); if ($len == 8) { for ($i = 0; $i < $half_len; ++$i) { - $seq .= $codes['A'][$code{$i}]; + $seq .= $codes['A'][$code[$i]]; } } else { $p = $parities[$code[0]]; for ($i = 1; $i < $half_len; ++$i) { - $seq .= $codes[$p[$i-1]][$code{$i}]; + $seq .= $codes[$p[$i-1]][$code[$i]]; } } $seq .= '01010'; // center guard bar for ($i = $half_len; $i < $len; ++$i) { - $seq .= $codes['C'][$code{$i}]; + $seq .= $codes['C'][$code[$i]]; } $seq .= '101'; // right guard bar } @@ -766,8 +766,8 @@ class TCPDFBarcode { $w = 0; for ($i = 0; $i < $clen; ++$i) { $w += 1; - if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq{$i} != $seq{($i+1)}))) { - if ($seq{$i} == '1') { + if (($i == ($clen - 1)) OR (($i < ($clen - 1)) AND ($seq[$i] != $seq[($i+1)]))) { + if ($seq[$i] == '1') { $t = true; // bar } else { $t = false; // space @@ -809,7 +809,7 @@ class TCPDFBarcode { // calculate checksum $sum = 0; for($i=0; $i < $len; $i++) { - $sum += intval($code{$i}); + $sum += intval($code[$i]); } if(($sum % 10) == 0) { return false; @@ -822,7 +822,7 @@ class TCPDFBarcode { $bararray["maxw"] += 2; for ($i=0; $i < $len; $i++) { for ($j=0; $j < 5; $j++) { - $h = $barlen[$code{$i}][$j]; + $h = $barlen[$code[$i]][$j]; $p = floor(1 / $h); $bararray["bcode"][$k++] = array("t" => 1, "w" => 1, "h" => $h, "p" => $p); $bararray["bcode"][$k++] = array("t" => 0, "w" => 1, "h" => 2, "p" => 0); @@ -872,17 +872,17 @@ class TCPDFBarcode { $code = "A".strtoupper($code)."A"; $len = strlen($code); for($i=0; $i < $len; $i++) { - if (!isset($chr[$code{$i}])) { + if (!isset($chr[$code[$i]])) { return false; } - $seq = $chr[$code{$i}]; + $seq = $chr[$code[$i]]; for($j=0; $j < 8; $j++) { if (($j % 2) == 0) { $t = true; // bar } else { $t = false; // space } - $w = $seq{$j}; + $w = $seq[$j]; $bararray["bcode"][$k] = array("t" => $t, "w" => $w, "h" => 1, "p" => 0); $bararray["maxw"] += $w; $k++; diff --git a/reporting/includes/tcpdf.php b/reporting/includes/tcpdf.php index 803416a8..71fb75ef 100644 --- a/reporting/includes/tcpdf.php +++ b/reporting/includes/tcpdf.php @@ -1,4 +1,4 @@ -_getfontpath().strtolower($file)); $compressed = (substr($file,-2)=='.z'); if ((!$compressed) AND (isset($info['length2']))) { - $header = (ord($font{0}) == 128); + $header = (ord($font[0]) == 128); if ($header) { //Strip first binary header $font = substr($font,6); } - if ($header AND (ord($font{$info['length1']}) == 128)) { + if ($header AND (ord($font[$info['length1']]) == 128)) { //Strip second binary header $font = substr($font, 0, $info['length1']).substr($font, $info['length1']+6); } @@ -5395,7 +5395,7 @@ if (!class_exists('TCPDF')) { $strarr = array(); $strlen = strlen($str); for($i=0; $i < $strlen; $i++) { - $strarr[] = ord($str{$i}); + $strarr[] = ord($str[$i]); } return $strarr; } @@ -5405,7 +5405,7 @@ if (!class_exists('TCPDF')) { $str .= ""; // force $str to be a string $length = strlen($str); for($i = 0; $i < $length; $i++) { - $char = ord($str{$i}); // get one string character at time + $char = ord($str[$i]); // get one string character at time if (count($bytes) == 0) { // get starting octect if ($char <= 0x7F) { $unicode[] = $char; // use the character "as is" because is ASCII @@ -5774,7 +5774,7 @@ if (!class_exists('TCPDF')) { $j = 0; for ($i=0; $i < 256; $i++) { $t = $rc4[$i]; - $j = ($j + $t + ord($k{$i})) % 256; + $j = ($j + $t + ord($k[$i])) % 256; $rc4[$i] = $rc4[$j]; $rc4[$j] = $t; } @@ -5794,7 +5794,7 @@ if (!class_exists('TCPDF')) { $rc4[$a] = $rc4[$b]; $rc4[$b] = $t; $k = $rc4[($rc4[$a] + $rc4[$b]) % 256]; - $out .= chr(ord($text{$i}) ^ $k); + $out .= chr(ord($text[$i]) ^ $k); } return $out; } @@ -8642,7 +8642,7 @@ if (!class_exists('TCPDF')) { $cnt = count($lines); for ($i=0; $i < $cnt; $i++) { $line = $lines[$i]; - if (($line == '') OR ($line{0} == '%')) { + if (($line == '') OR ($line[0] == '%')) { continue; } $len = strlen($line); @@ -8693,7 +8693,7 @@ if (!class_exists('TCPDF')) { case 'V': case 'L': case 'C': { - $line{$len-1} = strtolower($cmd); + $line[$len-1] = strtolower($cmd); $this->_out($line); break; } @@ -9191,7 +9191,7 @@ if (!class_exists('TCPDF')) { // get tag name preg_match('/[\/]?([a-zA-Z0-9]*)/', $element, $tag); $dom[$key]['value'] = strtolower($tag[1]); - if ($element{0} == '/') { + if ($element[0] == '/') { // closing html tag $dom[$key]['opening'] = false; $dom[$key]['parent'] = end($level); @@ -9300,10 +9300,10 @@ if (!class_exists('TCPDF')) { } // font style $dom[$key]['fontstyle'] = ""; - if (isset($dom[$key]['style']['font-weight']) AND (strtolower($dom[$key]['style']['font-weight']{0}) == "b")) { + if (isset($dom[$key]['style']['font-weight']) AND (strtolower($dom[$key]['style']['font-weight'][0]) == "b")) { $dom[$key]['fontstyle'] .= "B"; } - if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style']{0}) == "i")) { + if (isset($dom[$key]['style']['font-style']) AND (strtolower($dom[$key]['style']['font-style'][0]) == "i")) { $dom[$key]['fontstyle'] .= "I"; } // font color @@ -9319,9 +9319,9 @@ if (!class_exists('TCPDF')) { $decors = explode(" ", strtolower($dom[$key]['style']['text-decoration'])); foreach ($decors as $dec) { $dec = trim($dec); - if ($dec{0} == "u") { + if ($dec[0] == "u") { $dom[$key]['fontstyle'] .= "U"; - } elseif ($dec{0} == "l") { + } elseif ($dec[0] == "l") { $dom[$key]['fontstyle'] .= "D"; } } @@ -9336,7 +9336,7 @@ if (!class_exists('TCPDF')) { } // check for text alignment if (isset($dom[$key]['style']['text-align'])) { - $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align']{0}); + $dom[$key]['align'] = strtoupper($dom[$key]['style']['text-align'][0]); } } // check for font tag @@ -9355,9 +9355,9 @@ if (!class_exists('TCPDF')) { // font size if (isset($dom[$key]['attribute']['size'])) { if ($key > 0) { - if ($dom[$key]['attribute']['size']{0} == "+") { + if ($dom[$key]['attribute']['size'][0] == "+") { $dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] + intval(substr($dom[$key]['attribute']['size'], 1)); - } elseif ($dom[$key]['attribute']['size']{0} == "-") { + } elseif ($dom[$key]['attribute']['size'][0] == "-") { $dom[$key]['fontsize'] = $dom[($dom[$key]['parent'])]['fontsize'] - intval(substr($dom[$key]['attribute']['size'], 1)); } else { $dom[$key]['fontsize'] = intval($dom[$key]['attribute']['size']); @@ -9384,8 +9384,8 @@ if (!class_exists('TCPDF')) { if (($dom[$key]['value'] == "em") OR ($dom[$key]['value'] == "i")) { $dom[$key]['fontstyle'] .= "I"; } - if (($dom[$key]['value']{0} == "h") AND (intval($dom[$key]['value']{1}) > 0) AND (intval($dom[$key]['value']{1}) < 7)) { - $headsize = (4 - intval($dom[$key]['value']{1})) * 2; + if (($dom[$key]['value'][0] == "h") AND (intval($dom[$key]['value'][1]) > 0) AND (intval($dom[$key]['value'][1]) < 7)) { + $headsize = (4 - intval($dom[$key]['value'][1])) * 2; $dom[$key]['fontsize'] = $dom[0]['fontsize'] + $headsize; $dom[$key]['fontstyle'] .= "B"; } @@ -9427,7 +9427,7 @@ if (!class_exists('TCPDF')) { } // check for text alignment if (isset($dom[$key]['attribute']['align']) AND (!empty($dom[$key]['attribute']['align'])) AND ($dom[$key]['value'] !== 'img')) { - $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align']{0}); + $dom[$key]['align'] = strtoupper($dom[$key]['attribute']['align'][0]); } } // end opening tag } else { diff --git a/sales/includes/ui/sales_order_ui.inc b/sales/includes/ui/sales_order_ui.inc index 311bc3f2..c47c5da5 100644 --- a/sales/includes/ui/sales_order_ui.inc +++ b/sales/includes/ui/sales_order_ui.inc @@ -625,7 +625,7 @@ function display_delivery_details(&$order) date_row($delname, 'delivery_date', $order->trans_type==ST_SALESORDER ? _('Enter requested day of delivery') - : $order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : ''); + : ($order->trans_type==ST_SALESQUOTE ? _('Enter Valid until Date') : '')); text_row(_("Deliver To:"), 'deliver_to', $order->deliver_to, 50, 60, _('Additional identifier for delivery e.g. name of receiving person'));