X-Git-Url: https://delta.frontaccounting.com/gitweb/?a=blobdiff_plain;f=includes%2Freferences.inc;h=69f6806ecb2491d3096d7ce5bb84285f8c88cb21;hb=48589f9ce6c51bb25e2fa8ed83c57d9dfa485e44;hp=a5e872d703e0dcee08afefff37dae24e039c29c0;hpb=19dce8c7be29e4cc8e7be92d044259348373d456;p=fa-stable.git diff --git a/includes/references.inc b/includes/references.inc index a5e872d7..69f6806e 100644 --- a/includes/references.inc +++ b/includes/references.inc @@ -10,6 +10,8 @@ See the License here . ***********************************************************************/ include_once($path_to_root . "/includes/db/class.reflines_db.inc"); +include_once($path_to_root . "/admin/db/fiscalyears_db.inc"); +include_once($path_to_root . "/includes/types.inc"); //--------------------------------------------------------------------------------------------- // 2.4 - further changes toward removing refs table introduced: // . all transactions now have references stored in trans table. @@ -49,12 +51,15 @@ $refline_options = array( ST_WORKORDER => array('date', 'location', 'user'), ST_MANUISSUE => array('date', 'location', 'user'), ST_MANURECEIVE => array('date', 'user'), + ST_DIMENSION => array('date','user'), ); $refline_placeholders = array( 'MM' => 'date', 'YY' => 'date', 'YYYY' => 'date', + 'FF' => 'date', // fiscal year + 'FFFF' => 'date', 'UU' => 'user', 'P' => 'pos', // FIXME: for placeholders below all the code should work, but as the ref length is variable, @@ -69,7 +74,7 @@ class references { var $reflines; - function references() + function __construct() { $this->reflines = new reflines_db(); } @@ -120,6 +125,11 @@ class references list($day, $month, $year) = explode_date_to_dmy($context['date']); $out .= $ph == 'MM' ? sprintf('%02d', $month) : ($ph == 'YY' ? sprintf('%02d', $year%100): sprintf('%04d', $year)); break; + case 'FF': + case 'FFFF': + list($day, $month, $year) = explode_date_to_dmy(get_fiscalyear_begin_for_date($context['date'])); + $out .= $ph == 'FF' ? sprintf('%02d', $year%100): sprintf('%04d', $year); + break; case 'C': $out .= sprintf('%d', $context['customer']); break; @@ -150,6 +160,7 @@ class references } } + $out .= $template; // add postfix if (!preg_match('/^([^\{]*)?\{([^\}]*)\}(.*)/', $out, $match)) { // parse index display_error(_("Missing numeric placeholder in refline definition.")); return $out; @@ -163,6 +174,7 @@ class references $type_fld = $db_info[1]; $tno_fld = $db_info[2]; $ref_fld = $db_info[3]; + $type = db_escape($type); // retrieve last ref number in the refline from original transaction table $sql = "SELECT MAX(CAST(SUBSTR($ref_fld, ".(strlen($prefix)+1).",LENGTH($ref_fld)-".(strlen($postfix)+strlen($prefix)).") AS UNSIGNED))" @@ -213,7 +225,7 @@ class references return false; $result = db_fetch_row($result); - return $result[0]; + return $result == false ? false : $result[0]; } function is_new_reference($ref, $type, $trans_no=0) @@ -283,11 +295,16 @@ class references { list($year4, $month, $day) = explode("-", date2sql($context['date'])); $year2 = substr($year4, 2); + $f_year = explode("-", date2sql(get_fiscalyear_begin_for_date($context['date']))); + $f_year2 = substr($f_year[0], 2); + $f_year4 = $f_year[0]; } else { $month = '\d{2,}'; $year2 = '\d{2,}'; $year4 = '\d{4,}'; + $f_year2 = '\d{2,}'; + $f_year4 = '\d{4,}'; } $cust = @$context['customer'] ? $context['customer'] : '\d+'; $supp = @$context['supplier'] ? $context['supplier'] : '\d+'; @@ -303,6 +320,8 @@ class references '/\{MM\}/', '/\{YY\}/', '/\{YYYY\}/', + '/\{FF\}/', + '/\{FFFF\}/', '/\{C\}/', '/\{B\}/', '/\{S\}/', @@ -317,6 +336,8 @@ class references $month, $year2, $year4, + $f_year2, + $f_year4, $cust, $branch, $supp,