Exemplo n.º 1
0
function main_form($x, $y, $data)
{
    global $pdf;
    global $_TITLE, $_LMARGIN, $_BMARGIN;
    $balance = $data['balance'] < 0 ? -$data['balance'] : $data['balance'];
    $font_size = 14;
    $lineh = 25;
    $x += $_LMARGIN;
    $y += $_BMARGIN;
    $y += 275;
    $pdf->addtext($x, $y, $font_size, $data['d_name']);
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trim($data['d_zip'] . ' ' . $data['d_city'] . ' ' . $data['d_address']));
    $y -= $lineh;
    //    for($i=0; $i<26; $i++)
    //    {
    //	    $pdf->addtext($x+$i*14.6,$y,$font_size,$_ACCOUNT[$i]);
    //    }
    $pdf->addtext($x, $y, $font_size, bankaccount($data['id'], $data['account']));
    $y -= $lineh;
    $pdf->addtext($x + 220, $y, $font_size, sprintf('%.2f', $balance));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trans('$a dollars $b cents', to_words(floor($balance)), to_words(round(($balance - floor($balance)) * 100))));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, truncate($data['customername']));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, truncate(trim($data['zip'] . ' ' . $data['city'] . ' ' . $data['address'])));
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, $_TITLE);
    $y -= $lineh;
    $pdf->addtext($x, $y, $font_size, trans('Customer ID: $a', sprintf('%04d', $data['id'])));
}
Exemplo n.º 2
0
 protected function main_form($x, $y)
 {
     $balance = $this->data['balance'] < 0 ? -$this->data['balance'] : $this->data['balance'];
     $font_size = 14;
     $lineh = 25;
     $x += ConfigHelper::getConfig('finances.leftmargin', 0, true);
     $y += ConfigHelper::getConfig('finances.bottommargin', 0, true);
     $y += 275;
     $this->backend->addText($x, $y, $font_size, $this->data['d_name']);
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trim($this->data['d_zip'] . ' ' . $this->data['d_city'] . ' ' . $this->data['d_address']));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, format_bankaccount(bankaccount($this->data['id'], $this->data['account'])));
     $y -= $lineh;
     $this->backend->addText($x + 220, $y, $font_size, sprintf('%.2f', $balance));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trans('$a dollars $b cents', to_words(floor($balance)), to_words(round(($balance - floor($balance)) * 100))));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, $this->truncate($this->data['customername']));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, $this->truncate(trim($this->data['zip'] . ' ' . $this->data['city'] . ' ' . $this->data['address'])));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, ConfigHelper::getConfig('finances.pay_title', trans('Not set')));
     $y -= $lineh;
     $this->backend->addText($x, $y, $font_size, trans('Customer ID: $a', sprintf('%04d', $this->data['id'])));
 }
Exemplo n.º 3
0
$CURR = 'PLN';
// oznaczenie waluty
$SHORT_TO_WORDS = 0;
// 1 - krótki format kwoty słownej 'jed dwa trz 15/100'
// 0 - długi format kwoty słownej 'sto dwadzieścia trzy 15/100 zł'
/************** Koniec konfiguracji ****************/
$KWOTA = trim(isset($_GET['ILE']) ? $_GET['ILE'] : 0);
$USER_OD = trim(strip_tags(isset($_GET['OD']) ? $_GET['OD'] : ''));
$KWOTA_NR = str_replace(',', '.', $KWOTA);
// na wszelki wypadek
$KWOTA_GR = sprintf('%02d', round(($KWOTA_NR - floor($KWOTA_NR)) * 100));
if ($SHORT_TO_WORDS) {
    $KWOTA_ZL = to_words(floor($KWOTA_NR), 0, '', 1);
    $KWOTA_X = $KWOTA_ZL . ' ' . $KWOTA_GR . '/100';
} else {
    $KWOTA_ZL = to_words(floor($KWOTA_NR));
    $KWOTA_X = $KWOTA_ZL . ' ' . $KWOTA_GR . '/100 złotych';
}
?>

<HTML>
<HEAD>

<META http-equiv="Content-Type" content="text/html;charset=utf-8">
</HEAD>
<BODY>

<FORM><P style="font-family: Arial, Helvetica; font-size: 12pt; font-weight: bold;">W zależności od poczty/banku wpisz 1 lub 2 kopie. <input type="button" value="Drukuj" onClick="top.print();"></FORM>

<?php 
$SHIFT = 394;
Exemplo n.º 4
0
    imagettftext($img, 18, 0, 355 + $i * 30, 155, $black, $fontb, format_bankaccount($customer['bankaccount'][$i]));
}
$_GET['v'] = str_replace(',', '.', $_GET['v']);
$value = moneyf($_GET['v']);
$width = 0;
for ($i = 0; $i < strlen($value); $i++) {
    $tmp = imagettfbbox(20, 0, $fontb, substr($value, $i, 1));
    $width += $tmp[2];
}
imageline($img, 810, 200, 1180 - $width - 10, 200, $black);
imagettftext($img, 20, 0, 1180 - $width, 207, $black, $fontb, $value);
$width = 0;
for ($i = 0; $i < strlen($value); $i++) {
    $tmp = imagettfbbox(12, 0, $fontb, substr($value, $i, 1));
    $width += $tmp[2];
}
imageline($img, 50, 224, 300 - $width - 10, 224, $black);
imagettftext($img, 12, 0, 300 - $width, 230, $black, $fontb, $value);
$value = $_GET['v'];
$value = to_words(floor($value)) . ' ' . to_words(round(($value - floor($value)) * 100));
imagettftext($img, 16, 0, 353, 255, $black, $fontb, $value . ' gr');
imagettftext($img, 11, 0, 50, 305, $black, $font, $customer['customername']);
imagettftext($img, 11, 0, 50, 322, $black, $font, $customer['address']);
imagettftext($img, 11, 0, 50, 340, $black, $font, $customer['zip'] . ' ' . $customer['city']);
imagettftext($img, 14, 0, 353, 305, $black, $font, $customer['customername']);
imagettftext($img, 14, 0, 353, 358, $black, $font, $customer['address'] . ' ' . $customer['zip'] . ' ' . $customer['city']);
imagettftext($img, 14, 0, 353, 410, $black, $font, $_GET['title'] . ' ID:' . $_GET['cid']);
imagettftext($img, 10, 0, 50, 375, $black, $font, $_GET['title']);
header("Content-type: image/png");
imagepng($img);
imagedestroy($img);
Exemplo n.º 5
0
function invoice_to_pay()
{
    global $pdf, $invoice;
    $pdf->Ln(-9);
    $pdf->SetFont('arial', 'B', 14);
    if (isset($invoice['rebate'])) {
        $pdf->writeHTMLCell(0, 0, '', '', trans('To repay:') . ' ' . moneyf($invoice['value']), 0, 1, 0, true, 'L');
    } else {
        $pdf->writeHTMLCell(0, 0, '', '', trans('To pay:') . ' ' . moneyf($invoice['value']), 0, 1, 0, true, 'L');
    }
    $pdf->SetFont('arial', '', 10);
    $pdf->writeHTMLCell(0, 6, '', '', trans('In words:') . ' ' . trans('$a dollars $b cents', to_words(floor($invoice['value'])), to_words(round(($invoice['value'] - floor($invoice['value'])) * 100))), 0, 1, 0, true, 'L');
}
Exemplo n.º 6
0
Arquivo: ui.php Projeto: kornelek/lms
function to_words($num, $power = 0, $powsuffix = '', $short_version = 0)
{
    // Extracted from lang.lt.php by Piotr Klaban <makler at man dot torun dot pl>
    // from PEAR package Number_Words-0.15
    // added leading space trim's by alec
    $ret = '';
    $_sep = ' ';
    $_minus = 'minus';
    $_digits = array(0 => 'nulis', 'vienas', 'du', 'trys', 'keturi', 'penki', 'šeši', 'septyni', 'aštuoni', 'devyni');
    $_exponent = array(0 => array(''), 3 => array('tūkstantis', 'tūkstančiai', 'tūkstančių'), 6 => array('milijonas', 'milijonai', 'milijonų'), 9 => array('bilijonas', 'bilijonai', 'bilijonų'), 12 => array('trilijonas', 'trilijonai', 'trilijonų'), 15 => array('kvadrilijonas', 'kvadrilijonai', 'kvadrilijonų'), 18 => array('kvintilijonas', 'kvintilijonai', 'kvintilijonų'));
    if (substr($num, 0, 1) == '-') {
        $ret = $_minus;
        $num = substr($num, 1);
    }
    // strip excessive zero signs and spaces
    $num = trim($num);
    $num = preg_replace('/^0+/', '', $num);
    if (strlen($num) > 3) {
        $maxp = strlen($num) - 1;
        $curp = $maxp;
        for ($p = $maxp; $p > 0; --$p) {
            // power
            // check for highest power
            if (isset($_exponent[$p])) {
                // send substr from $curp to $p
                $snum = substr($num, $maxp - $curp, $curp - $p + 1);
                $snum = preg_replace('/^0+/', '', $snum);
                if ($snum !== '') {
                    $cursuffix = $_exponent[$power][count($_exponent[$power]) - 1];
                    if ($powsuffix != '') {
                        $cursuffix .= $_sep . $powsuffix;
                    }
                    $ret .= to_words($snum, $p, $cursuffix);
                }
                $curp = $p - 1;
                continue;
            }
        }
        $num = substr($num, $maxp - $curp, $curp - $p + 1);
        if ($num == 0) {
            return $ret;
        }
    } elseif ($num == 0 || $num == '') {
        return $_sep . $_digits[0];
    }
    $h = $t = $d = 0;
    switch (strlen($num)) {
        case 3:
            $h = (int) substr($num, -3, 1);
        case 2:
            $t = (int) substr($num, -2, 1);
        case 1:
            $d = (int) substr($num, -1, 1);
            break;
        case 0:
            return;
            break;
    }
    if ($h > 1) {
        $ret .= $_sep . $_digits[$h] . $_sep . 'šimtai';
    } elseif ($h) {
        $ret .= $_sep . 'šimtas';
    }
    // ten, twenty etc.
    switch ($t) {
        case 9:
            $ret .= $_sep . 'devyniasdešimt';
            break;
        case 8:
            $ret .= $_sep . 'aštuoniasdešimt';
            break;
        case 7:
            $ret .= $_sep . 'septyniasdešimt';
            break;
        case 6:
            $ret .= $_sep . 'šešiasdešimt';
            break;
        case 5:
            $ret .= $_sep . 'penkiasdešimt';
            break;
        case 4:
            $ret .= $_sep . 'keturiasdešimt';
            break;
        case 3:
            $ret .= $_sep . 'trisdešimt';
            break;
        case 2:
            $ret .= $_sep . 'dvidešimt';
            break;
        case 1:
            switch ($d) {
                case 0:
                    $ret .= $_sep . 'dešimt';
                    break;
                case 1:
                    $ret .= $_sep . 'vienuolika';
                    break;
                case 2:
                    $ret .= $_sep . 'dvylika';
                    break;
                case 3:
                    $ret .= $_sep . 'trylika';
                    break;
                case 4:
                    $ret .= $_sep . 'keturiolika';
                    break;
                case 5:
                    $ret .= $_sep . 'penkiolika';
                    break;
                case 6:
                    $ret .= $_sep . 'šešiolika';
                    break;
                case 7:
                    $ret .= $_sep . 'septyniolika';
                    break;
                case 8:
                    $ret .= $_sep . 'aštuoniolika';
                    break;
                case 9:
                    $ret .= $_sep . 'devyniolika';
                    break;
            }
            break;
    }
    if ($t != 1 && $d > 0) {
        // add digits only in <0>,<1,9> and <21,inf>
        if ($d > 1 || !$power || $t) {
            $ret .= $_sep . $_digits[$d];
        }
    }
    if ($power > 0) {
        if (isset($_exponent[$power])) {
            $lev = $_exponent[$power];
        }
        if (!isset($lev) || !is_array($lev)) {
            return null;
        }
        //echo " $t $d  <br>";
        if ($t == 1 || $t > 0 && $d == 0) {
            $ret .= $_sep . $lev[2];
        } elseif ($d > 1) {
            $ret .= $_sep . $lev[1];
        } else {
            $ret .= $_sep . $lev[0];
        }
    }
    if ($powsuffix != '') {
        $ret .= $_sep . $powsuffix;
    }
    return trim($ret);
}
Exemplo n.º 7
0
 public function table(array $map, array $data, $config = array(), $totals = array())
 {
     $defaults = array('caption' => false, 'caption_right' => false, 'caption_right_size' => 3, 'caption_right_bold' => true, 'page_break_text' => false, 'page_break_margin' => 0, 'margin_left' => 5, 'margin_right' => 5, 'multiline' => false, 'border' => 1, 'color' => array(0, 0, 0), 'label_bold' => true, 'label_align' => 'C', 'label_height' => 8, 'cell_bold' => false, 'cell_align' => 'C', 'cell_height' => 5, 'hide_empty' => true, 'style' => 'awery', 'totals_label' => 'TOTAL:', 'totals_label_align' => 'R', 'totals_height' => 6, 'totals_towords' => false, 'totals_format' => array());
     $config = $config + $defaults;
     $this->_tableHeader($map, $config);
     if (isset($config['style']) && $config['style'] == 'awery') {
         $this->Ln(1);
         $this->SetDrawColor(136, 136, 136);
     }
     $font_style = '';
     if (@$config['cell_bold'] && @$config['bold']) {
         $font_style .= 'B';
     }
     if (@$config['underline']) {
         $font_style .= 'U';
     }
     $this->SetFont($this->FontFamily, $font_style, $this->FontSizePt);
     $footer_height = $this->GetFooterHeight();
     $count_fields = count($map);
     $totals_val = $complited = array();
     $lineheight = $config['cell_height'];
     if ($config['multiline']) {
         $ii = 0;
         foreach ($data as $row_index => $row_data) {
             $kk = 0;
             $ii++;
             foreach ($map as $row_field => $row_params) {
                 $kk++;
                 if (isset($row_params['value'])) {
                     eval('$row_data[$row_field] = ' . str_replace('$row', '$row_data', $row_params['value']) . ';');
                 }
                 if (isset($row_params['format'])) {
                     $string_code = str_replace(array('$i', '__VAL__'), array('$ii', '$row_data[$row_field]'), $row_params['format']) . ';';
                     eval('$value = ' . $string_code . ';');
                 } else {
                     $value = isset($row_data[$row_field]) ? $row_data[$row_field] : '';
                 }
                 if (isset($row_params['exec'])) {
                     eval(str_replace('__VAL__', '$row_data[$row_field]', $row_params['exec']) . ';');
                 }
                 $cellH = $this->getStringHeight($value, $row_params['width'], $config['cell_height'] - 0.5);
                 $lineheight = $cellH > $lineheight ? $cellH : $lineheight;
             }
         }
     }
     $i = 0;
     foreach ($data as $row) {
         $k = 0;
         $i++;
         foreach ($map as $field => $params) {
             $k++;
             if ($this->GetY() > $this->h - ($footer_height + 10)) {
                 $current_margin_left = $this->lMargin;
                 $current_margin_right = $this->rMargin;
                 $this->SetLeftMargin($config['margin_left']);
                 $this->SetRightMargin($config['margin_right']);
                 $this->AddPage();
                 if ($config['page_break_text']) {
                     $this->SetY($this->y + $config['page_break_margin']);
                     $def_size = $this->FontSizePt;
                     $this->SetFont($this->FontFamily, 'B', $this->FontSizePt + 3);
                     $this->Cell(0, 6, $config['page_break_text'], 0, 1, 'C');
                     $this->SetFont($this->FontFamily, '', $def_size);
                 }
                 $this->SetLeftMargin($current_margin_left);
                 $this->SetRightMargin($current_margin_right);
                 $this->SetDrawColor(0, 0, 0);
                 $this->_tableHeader($map, $config);
                 if ($config['style'] == 'awery') {
                     $this->Ln(1);
                     $this->SetDrawColor(136, 136, 136);
                 }
             }
             $font_style = '';
             if (@$config['cell_bold'] and @$params['bold']) {
                 $font_style .= 'B';
             }
             if (@$params['underline']) {
                 $font_style .= 'U';
             }
             $this->SetFont($this->FontFamily, $font_style, $this->FontSizePt);
             $this->SetTextColor($config['color'][0], $config['color'][1], $config['color'][2]);
             //                if (!isset($complited[$field])) {
             if (isset($params['value'])) {
                 if (!preg_match('~\\$row~', $params['value'])) {
                     $row[$field] = $params['value'];
                 } else {
                     eval('$row[$field] = ' . $params['value'] . ';');
                 }
             }
             if (isset($params['format'])) {
                 $string_code = str_replace('__VAL__', '$row[$field]', $params['format']) . ';';
                 eval('$value = ' . $string_code . ';');
             } else {
                 $value = isset($row[$field]) ? $row[$field] : '';
             }
             if (isset($params['exec'])) {
                 eval(str_replace('__VAL__', '$row[$field]', $params['exec']) . ';');
             }
             //                } else {
             //                    $value = $complited[$field];
             //                }
             if (in_array($field, $totals)) {
                 if (!isset($totals_val[$field])) {
                     $totals_val[$field] = 0;
                 }
                 $cur_total_val = isset($row[$field]) ? $row[$field] : $value;
                 if (!isset($config['totals_format'][$field])) {
                     $totals_val[$field] = $totals_val[$field] + $cur_total_val;
                 } else {
                     eval('$totals_val[$field] = ' . $config['totals_format'][$field] . ';');
                 }
             }
             $align = $params['align'] ? $params['align'] : $config['label_align'];
             if (!$config['multiline']) {
                 $this->Cell($params['width'], $config['cell_height'], $value, $config['border'], $k == $count_fields ? 1 : 0, $align);
             } else {
                 $this->MultilineCell($params['width'], array($config['cell_height'] - 0.5, $lineheight), $value, $config['border'], $k == $count_fields ? 1 : 0, $align);
             }
         }
     }
     if (!empty($totals_val)) {
         $this->Ln(1);
         $this->SetDrawColor(0, 0, 0);
         $this->SetFont($this->FontFamily, $config['label_bold'] ? 'B' : '', $this->FontSizePt);
         $this->SetTextColor($config['color'][0], $config['color'][1], $config['color'][2]);
         $totals_width = array();
         $count_fields = count($map);
         $map_keys = array_keys($map);
         foreach ($map as $field => $params) {
             if (!isset($current_field)) {
                 $current_field = $field;
             }
             if (!in_array($field, $totals)) {
                 if (!isset($totals_width[$current_field])) {
                     $totals_width[$current_field] = 0;
                 }
                 $totals_width[$current_field] += $map[$field]['width'];
             } else {
                 $cur_index = array_search($field, $map_keys);
                 $totals_width[$map_keys[$cur_index]] = $map[$field]['width'];
                 $current_field = @$map_keys[$cur_index + 1];
             }
         }
         $count_totals = count($totals_width);
         $ik = 0;
         foreach ($totals_width as $tf => $width) {
             $ik++;
             if (isset($map[$tf]['exec'])) {
                 eval(str_replace('__VAL__', '$row[$field]', $map[$tf]['exec']) . ';');
             }
             if ($ik == 1 and !isset($totals_val[$tf])) {
                 $txt = $config['totals_label'];
                 if (is_array($config['totals_towords'])) {
                     $txt .= ' ' . to_words($totals_val[$config['totals_towords'][0]], $config['totals_towords'][1]);
                 }
                 $align = $config['totals_label_align'];
             } else {
                 $txt = @$totals_val[$tf];
                 if (isset($map[$tf]['format']) && !isset($map[$tf]['skip_format_for_total'])) {
                     $string_code = str_replace('__VAL__', '$txt', $map[$tf]['format']) . ';';
                     eval('$txt = ' . $string_code . ';');
                 }
                 $align = @$map[$tf]['align'] ? $map[$tf]['align'] : $config['label_align'];
             }
             $this->Cell($width, $config['totals_height'], $txt, $config['border'], $ik == $count_totals ? 1 : 0, $align);
         }
     }
 }
Exemplo n.º 8
0
 protected function invoice_to_pay()
 {
     $this->backend->Ln(-9);
     $this->backend->SetFont('arial', 'B', 14);
     if (isset($this->data['rebate'])) {
         $this->backend->writeHTMLCell(0, 0, '', '', trans('To repay:') . ' ' . moneyf($this->data['value']), 0, 1, 0, true, 'L');
     } else {
         $this->backend->writeHTMLCell(0, 0, '', '', trans('To pay:') . ' ' . moneyf($this->data['value']), 0, 1, 0, true, 'L');
     }
     $this->backend->SetFont('arial', '', 10);
     $this->backend->writeHTMLCell(0, 6, '', '', trans('In words:') . ' ' . trans('$a dollars $b cents', to_words(floor($this->data['value'])), to_words(round(($this->data['value'] - floor($this->data['value'])) * 100))), 0, 1, 0, true, 'L');
 }
Exemplo n.º 9
0
function smarty_modifier_to_words($num, $power = 0, $powsuffix = '', $short_version = 0)
{
    return to_words($num, $power, $powsuffix, $short_version);
}
Exemplo n.º 10
0
function invoice_to_pay($x, $y)
{
    global $pdf, $invoice;
    if (isset($invoice['rebate'])) {
        $y = $y - text_align_left($x, $y, 14, trans('To repay:') . ' ' . moneyf($invoice['value']));
    } else {
        $y = $y - text_align_left($x, $y, 14, trans('To pay:') . ' ' . moneyf($invoice['value']));
    }
    $y = $y - text_align_left($x, $y, 10, trans('In words:') . ' ' . trans('$a dollars $b cents', to_words(floor($invoice['value'])), to_words(round(($invoice['value'] - floor($invoice['value'])) * 100))));
    return $y;
}
Exemplo n.º 11
0
    imagettftext($img, 9, 0, 243, 50, $black, $fontb, $division['address'] . ', ' . $division['zip'] . ' ' . $division['city']);
    $con = substr($customer['bankaccount'], 0, 2);
    for ($i = 0; $i < strlen($con); $i++) {
        imagettftext($img, 12, 0, 241 + $i * 17, 76, $black, $fontb, format_bankaccount($con[$i]));
    }
    $con = substr($customer['bankaccount'], 2, 8);
    for ($i = 0; $i < strlen($con); $i++) {
        imagettftext($img, 12, 0, 277 + $i * 17, 76, $black, $fontb, format_bankaccount($con[$i]));
    }
    $con = substr($customer['bankaccount'], 10, 8);
    for ($i = 0; $i < strlen($con); $i++) {
        imagettftext($img, 12, 0, 417 + $i * 17, 76, $black, $fontb, format_bankaccount($con[$i]));
    }
    $con = substr($customer['bankaccount'], 18, 8);
    for ($i = 0; $i < strlen($con); $i++) {
        imagettftext($img, 12, 0, 557 + $i * 17, 76, $black, $fontb, format_bankaccount($con[$i]));
    }
    $width = mb_strlen($value) * 17;
    for ($i = 0; $i < mb_strlen($value); $i++) {
        imagettftext($img, 12, 0, 710 - $width + $i * 17, 101, $black, $fontb, $value[$i]);
    }
    imageline($img, 502, 95, 710 - $width - 12, 95, $black);
    $value = trans('$a dollars $b cents', to_words(floor($value)), to_words(round(($value - floor($value)) * 100)));
    imagettftext($img, 11, 0, 243, 126, $black, $fontb, $value);
    imagettftext($img, 9, 0, 243, 152, $black, $fontb, $name1 . ' ' . $name2);
    imagettftext($img, 9, 0, 243, 177, $black, $fontb, $address . ', ' . $city);
    imagettftext($img, 9, 0, 243, 202, $black, $fontb, 'Abonament za ' . $msc[intval($_GET['month'])] . ' ' . $_GET['year'] . ', ' . ' ID:' . $customer['id']);
    header("Content-type: image/jpeg");
    imagejpeg($img);
    imagedestroy($img);
}
Exemplo n.º 12
0
Arquivo: ui.php Projeto: repcio/lms
function to_words($num, $power = 0, $powsuffix = '', $short_version = 0)
{
    // Extracted from lang.pl.php by Piotr Klaban <makler at man dot torun dot pl>
    if ($short_version) {
        $patterns[0] = "/0/";
        $patterns[1] = "/1/";
        $patterns[2] = "/2/";
        $patterns[3] = "/3/";
        $patterns[4] = "/4/";
        $patterns[5] = "/5/";
        $patterns[6] = "/6/";
        $patterns[7] = "/7/";
        $patterns[8] = "/8/";
        $patterns[9] = "/9/";
        $replacements[0] = 'zer ';
        $replacements[1] = 'unu ';
        $replacements[2] = 'doi ';
        $replacements[3] = 'tre ';
        $replacements[4] = 'pat ';
        $replacements[5] = 'cin ';
        $replacements[6] = 'şas ';
        $replacements[7] = 'şap ';
        $replacements[8] = 'opt ';
        $replacements[9] = 'nou ';
        return trim(preg_replace($patterns, $replacements, $num));
    }
    $ret = '';
    $_sep = ' ';
    $_minus = 'minus';
    $_digits = array(0 => 'zero', 'unu', 'doi', 'trei', 'patru', 'cinci', 'şase', 'şapte', 'opt', 'nouă');
    $_exponent = array(0 => array(''), 3 => array('mii'), 6 => array('milioane'), 9 => array('bilioane'), 12 => array('trillioane'), 15 => array('quadrillion'), 18 => array('quintillion'), 21 => array('sextillion'), 24 => array('septillion'), 27 => array('octillion'), 30 => array('nonillion'), 33 => array('decillion'), 36 => array('undecillion'), 39 => array('duodecillion'), 42 => array('tredecillion'), 45 => array('quattuordecillion'), 48 => array('quindecillion'), 51 => array('sexdecillion'), 54 => array('septendecillion'), 57 => array('octodecillion'), 60 => array('novemdecillion'), 63 => array('vigintillion'), 66 => array('unvigintillion'), 69 => array('duovigintillion'), 72 => array('trevigintillion'), 75 => array('quattuorvigintillion'), 78 => array('quinvigintillion'), 81 => array('sexvigintillion'), 84 => array('septenvigintillion'), 87 => array('octovigintillion'), 90 => array('novemvigintillion'), 93 => array('trigintillion'), 96 => array('untrigintillion'), 99 => array('duotrigintillion'), 102 => array('trestrigintillion'), 105 => array('quattuortrigintillion'), 108 => array('quintrigintillion'), 111 => array('sextrigintillion'), 114 => array('septentrigintillion'), 117 => array('octotrigintillion'), 120 => array('novemtrigintillion'), 123 => array('quadragintillion'), 126 => array('unquadragintillion'), 129 => array('duoquadragintillion'), 132 => array('trequadragintillion'), 135 => array('quattuorquadragintillion'), 138 => array('quinquadragintillion'), 141 => array('sexquadragintillion'), 144 => array('septenquadragintillion'), 147 => array('octoquadragintillion'), 150 => array('novemquadragintillion'), 153 => array('quinquagintillion'), 156 => array('unquinquagintillion'), 159 => array('duoquinquagintillion'), 162 => array('trequinquagintillion'), 165 => array('quattuorquinquagintillion'), 168 => array('quinquinquagintillion'), 171 => array('sexquinquagintillion'), 174 => array('septenquinquagintillion'), 177 => array('octoquinquagintillion'), 180 => array('novemquinquagintillion'), 183 => array('sexagintillion'), 186 => array('unsexagintillion'), 189 => array('duosexagintillion'), 192 => array('tresexagintillion'), 195 => array('quattuorsexagintillion'), 198 => array('quinsexagintillion'), 201 => array('sexsexagintillion'), 204 => array('septensexagintillion'), 207 => array('octosexagintillion'), 210 => array('novemsexagintillion'), 213 => array('septuagintillion'), 216 => array('unseptuagintillion'), 219 => array('duoseptuagintillion'), 222 => array('treseptuagintillion'), 225 => array('quattuorseptuagintillion'), 228 => array('quinseptuagintillion'), 231 => array('sexseptuagintillion'), 234 => array('septenseptuagintillion'), 237 => array('octoseptuagintillion'), 240 => array('novemseptuagintillion'), 243 => array('octogintillion'), 246 => array('unoctogintillion'), 249 => array('duooctogintillion'), 252 => array('treoctogintillion'), 255 => array('quattuoroctogintillion'), 258 => array('quinoctogintillion'), 261 => array('sexoctogintillion'), 264 => array('septoctogintillion'), 267 => array('octooctogintillion'), 270 => array('novemoctogintillion'), 273 => array('nonagintillion'), 276 => array('unnonagintillion'), 279 => array('duononagintillion'), 282 => array('trenonagintillion'), 285 => array('quattuornonagintillion'), 288 => array('quinnonagintillion'), 291 => array('sexnonagintillion'), 294 => array('septennonagintillion'), 297 => array('octononagintillion'), 300 => array('novemnonagintillion'), 303 => array('centillion'), 309 => array('duocentillion'), 312 => array('trecentillion'), 366 => array('primo-vigesimo-centillion'), 402 => array('trestrigintacentillion'), 603 => array('ducentillion'), 624 => array('septenducentillion'), 2421 => array('sexoctingentillion'), 3003 => array('millillion'), 3000003 => array('milli-millillion'));
    if (substr($num, 0, 1) == '-') {
        $ret = $_sep . $_minus;
        $num = substr($num, 1);
    }
    // strip excessive zero signs and spaces
    $num = trim($num);
    $num = preg_replace('/^0+/', '', $num);
    if (strlen($num) > 3) {
        $maxp = strlen($num) - 1;
        $curp = $maxp;
        for ($p = $maxp; $p > 0; --$p) {
            // check for highest power
            if (isset($_exponent[$p])) {
                // send substr from $curp to $p
                $snum = substr($num, $maxp - $curp, $curp - $p + 1);
                $snum = preg_replace('/^0+/', '', $snum);
                if ($snum !== '') {
                    $cursuffix = $_exponent[$power][count($_exponent[$power]) - 1];
                    if ($powsuffix != '') {
                        $cursuffix .= $this->_sep . $powsuffix;
                    }
                    $ret .= to_words($snum, $p, $cursuffix);
                }
                $curp = $p - 1;
                continue;
            }
        }
        $num = substr($num, $maxp - $curp, $curp - $p + 1);
        $ret = trim($ret);
        if ($num == 0) {
            return $ret;
        }
    } elseif ($num == 0 || $num == '') {
        return $_digits[0];
    }
    $h = $t = $d = 0;
    switch (strlen($num)) {
        case 3:
            $h = (int) substr($num, -3, 1);
        case 2:
            $t = (int) substr($num, -2, 1);
        case 1:
            $d = (int) substr($num, -1, 1);
            break;
        case 0:
            return;
            break;
    }
    if ($h) {
        $ret .= $_sep . $_digits[$h] . $_sep . 'hundred';
        // in English only - add ' and' for [1-9]01..[1-9]99
        // (also for 1001..1099, 10001..10099 but it is harder)
        // for now it is switched off, maybe some language purists
        // can force me to enable it, or to remove it completely
        // if (($t + $d) > 0)
        //   $ret .= $_sep . 'and';
    }
    // ten, twenty etc.
    switch ($t) {
        case 9:
        case 8:
        case 7:
        case 5:
        case 4:
        case 3:
            $ret .= $_sep . $_digits[$t] . 'zeci';
            break;
        case 6:
            $ret .= $_sep . 'şaizeci';
            break;
        case 2:
            $ret .= $_sep . 'douăzeci';
            break;
        case 1:
            switch ($d) {
                case 0:
                    $ret .= $_sep . 'zece';
                    break;
                case 1:
                    $ret .= $_sep . 'unsprezece';
                    break;
                case 9:
                case 8:
                case 7:
                case 5:
                case 3:
                case 2:
                    $ret .= $_sep . $_digits[$d] . 'sprezece';
                    break;
                case 6:
                    $ret .= $_sep . 'şaisprezece';
                    break;
                case 4:
                    $ret .= $_sep . 'paisprezece';
                    break;
            }
            break;
    }
    if ($t != 1 && $d > 0) {
        // add minus sign between [2-9] and digit
        if ($t > 1) {
            $ret .= '-' . $_digits[$d];
        } else {
            $ret .= $_sep . $_digits[$d];
        }
    }
    if ($power > 0) {
        if (isset($_exponent[$power])) {
            $lev = $_exponent[$power];
        }
        if (!isset($lev) || !is_array($lev)) {
            return null;
        }
        $ret .= $_sep . $lev[0];
    }
    if ($powsuffix != '') {
        $ret .= $_sep . $powsuffix;
    }
    return trim($ret);
}
Exemplo n.º 13
0
$USER_TY = str_replace($Before, $After, $USER_T1);
$KWOTA = trim($customer['balance'] * -1);
$ISP1_DO = iconv('UTF-8', 'ISO-8859-2', $ISP1_DO);
$ISP2_DO = iconv('UTF-8', 'ISO-8859-2', $ISP2_DO);
$USER_OD = trim(iconv('UTF-8', 'ISO-8859-2', $customer['customername']));
$USER_ADDR = trim(iconv('UTF-8', 'ISO-8859-2', $customer['zip'] . ' ' . $customer['city'] . ' ' . $customer['address']));
$KWOTA_NR = str_replace(',', '.', $KWOTA);
// na wszelki wypadek
$KWOTA_GR = sprintf('%02d', round(($KWOTA_NR - floor($KWOTA_NR)) * 100));
if ($SHORT_TO_WORDS) {
    $KWOTA_ZL = to_words(floor($KWOTA_NR), 0, '', 1);
    $KWOTA_ZL = iconv('UTF-8', 'ISO-8859-2', $KWOTA_ZL);
    $KWOTA_X = $KWOTA_ZL . ' ' . $KWOTA_GR . '/100';
} else {
    $KWOTA_ZL = to_words(floor($KWOTA_NR));
    $KWOTA_GR = to_words($KWOTA_GR);
    $KWOTA_X = iconv('UTF-8', 'ISO-8859-2', trans('$a dollars $b cents', $KWOTA_ZL, $KWOTA_GR));
}
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 //EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pl">
<head>
  <meta content="text/html; charset=ISO-8859-2" http-equiv="content-type" />
  <title>Wirtualne Biuro Obs³ugi Klienta</title>
</head>
<body>

<?php 
$SHIFT = 394;
// drugi druczek przesuniêcie o 394
Exemplo n.º 14
0
function invoice_to_pay($x, $y)
{
    global $pdf, $invoice;
    $y = $y - text_align_left($x, $y, 14, iconv("UTF-8", "ISO-8859-2", trans('To pay:')) . ' ' . iconv("UTF-8", "ISO-8859-2", moneyf($invoice['total'])));
    $y = $y - text_align_left($x, $y, 10, iconv("UTF-8", "ISO-8859-2", trans('In words:')) . ' ' . iconv("UTF-8", "ISO-8859-2", trans('$a dollars $b cents', to_words(floor($invoice['total'])), to_words(round(($invoice['total'] - floor($invoice['total'])) * 100)))));
    return $y;
}
Exemplo n.º 15
0
Arquivo: ui.php Projeto: kornelek/lms
function to_words($num, $power = 0, $powsuffix = '', $short_version = 0)
{
    if ($short_version) {
        $patterns[0] = "/0/";
        $patterns[1] = "/1/";
        $patterns[2] = "/2/";
        $patterns[3] = "/3/";
        $patterns[4] = "/4/";
        $patterns[5] = "/5/";
        $patterns[6] = "/6/";
        $patterns[7] = "/7/";
        $patterns[8] = "/8/";
        $patterns[9] = "/9/";
        $replacements[0] = "nul ";
        $replacements[1] = "jed ";
        $replacements[2] = "dva ";
        $replacements[3] = "tři ";
        $replacements[4] = "čty ";
        $replacements[5] = "pět ";
        $replacements[6] = "šes ";
        $replacements[7] = "sed ";
        $replacements[8] = "osm ";
        $replacements[9] = "dev ";
        return trim(preg_replace($patterns, $replacements, $num));
    }
    $ret = '';
    $_sep = ' ';
    $_minus = 'mínus';
    $_digits = array(0 => 'nula', 'jedna', 'dva', 'tři', 'čtyři', 'pět', 'šest', 'sedm', 'osm', 'devět');
    $_exponent = array(0 => array('', '', ''), 3 => array('tisíc', 'tisíce', 'tisíc'), 6 => array('milión', 'milióny', 'miliónov'), 9 => array('miliarda', 'miliardy', 'miliárd'), 12 => array('bilión', 'bilióy', 'biliónov'), 15 => array('biliarda', 'biliardy', 'biliárd'), 18 => array('trylión', 'trylióny', 'tryliónov'), 21 => array('tryliarda', 'tryliardy', 'tryliard'), 24 => array('kvadrylión', 'kvadrylióny', 'kvadryliónov'), 27 => array('kwadryliard', 'kwadryliardy', 'kwadryliardów'), 30 => array('kwintylion', 'kwintyliony', 'kwintylionów'), 33 => array('kwintyliiard', 'kwintyliardy', 'kwintyliardów'), 36 => array('sekstylion', 'sekstyliony', 'sekstylionów'), 39 => array('sekstyliard', 'sekstyliardy', 'sekstyliardów'), 42 => array('septylion', 'septyliony', 'septylionów'), 45 => array('septyliard', 'septyliardy', 'septyliardów'), 48 => array('oktylion', 'oktyliony', 'oktylionów'), 51 => array('oktyliard', 'oktyliardy', 'oktyliardów'), 54 => array('nonylion', 'nonyliony', 'nonylionów'), 57 => array('nonyliard', 'nonyliardy', 'nonyliardów'), 60 => array('decylion', 'decyliony', 'decylionów'), 63 => array('decyliard', 'decyliardy', 'decyliardów'), 100 => array('centylion', 'centyliony', 'centylionów'), 103 => array('centyliard', 'centyliardy', 'centyliardów'), 120 => array('wicylion', 'wicylion', 'wicylion'), 123 => array('wicyliard', 'wicyliardy', 'wicyliardów'), 180 => array('trycylion', 'trycylion', 'trycylion'), 183 => array('trycyliard', 'trycyliardy', 'trycyliardów'), 240 => array('kwadragilion', 'kwadragilion', 'kwadragilion'), 243 => array('kwadragiliard', 'kwadragiliardy', 'kwadragiliardów'), 300 => array('kwinkwagilion', 'kwinkwagilion', 'kwinkwagilion'), 303 => array('kwinkwagiliard', 'kwinkwagiliardy', 'kwinkwagiliardów'), 360 => array('seskwilion', 'seskwilion', 'seskwilion'), 363 => array('seskwiliard', 'seskwiliardy', 'seskwiliardów'), 420 => array('septagilion', 'septagilion', 'septagilion'), 423 => array('septagiliard', 'septagiliardy', 'septagiliardów'), 480 => array('oktogilion', 'oktogilion', 'oktogilion'), 483 => array('oktogiliard', 'oktogiliardy', 'oktogiliardów'), 540 => array('nonagilion', 'nonagilion', 'nonagilion'), 543 => array('nonagiliard', 'nonagiliardy', 'nonagiliardów'), 600 => array('centylion', 'centyliony', 'centylionów'), 603 => array('centyliard', 'centyliardy', 'centyliardów'), 6000018 => array('milinilitrylion', 'milinilitryliony', 'milinilitrylionów'));
    if (substr($num, 0, 1) == '-') {
        $ret = $_minus;
        $num = substr($num, 1);
    }
    // strip excessive zero signs and spaces
    $num = trim($num);
    $num = preg_replace('/^0+/', '', $num);
    if (strlen($num) > 3) {
        $maxp = strlen($num) - 1;
        $curp = $maxp;
        for ($p = $maxp; $p > 0; --$p) {
            // power
            // check for highest power
            if (isset($_exponent[$p])) {
                // send substr from $curp to $p
                $snum = substr($num, $maxp - $curp, $curp - $p + 1);
                $snum = preg_replace('/^0+/', '', $snum);
                if ($snum !== '') {
                    $cursuffix = $_exponent[$power][count($_exponent[$power]) - 1];
                    if ($powsuffix != '') {
                        $cursuffix .= $_sep . $powsuffix;
                    }
                    $ret .= to_words($snum, $p, $cursuffix);
                    $ret .= ' ';
                }
                $curp = $p - 1;
                continue;
            }
        }
        $num = substr($num, $maxp - $curp, $curp - $p + 1);
        $ret = trim($ret);
        if ($num == 0) {
            return $ret;
        }
    } elseif ($num == 0 || $num == '') {
        return $_digits[0];
    }
    $h = $t = $d = 0;
    switch (strlen($num)) {
        case 3:
            $h = (int) substr($num, -3, 1);
        case 2:
            $t = (int) substr($num, -2, 1);
        case 1:
            $d = (int) substr($num, -1, 1);
            break;
        case 0:
            return;
            break;
    }
    switch ($h) {
        case 9:
            $ret .= $_sep . 'devětset';
            break;
        case 8:
            $ret .= $_sep . 'osmset';
            break;
        case 7:
            $ret .= $_sep . 'sedmset';
            break;
        case 6:
            $ret .= $_sep . 'šestset';
            break;
        case 5:
            $ret .= $_sep . 'pětset';
            break;
        case 4:
            $ret .= $_sep . 'čtyřista';
            break;
        case 3:
            $ret .= $_sep . 'třista';
            break;
        case 2:
            $ret .= $_sep . 'dvěstě';
            break;
        case 1:
            $ret .= $_sep . 'sto';
            break;
    }
    switch ($t) {
        case 9:
        case 8:
        case 7:
        case 6:
        case 5:
            $ret .= $_sep . $_digits[$t] . 'padesát';
            break;
        case 4:
            $ret .= $_sep . 'čtyřicet';
            break;
        case 3:
            $ret .= $_sep . 'třicet';
            break;
        case 2:
            $ret .= $_sep . 'dvacet';
            break;
        case 1:
            switch ($d) {
                case 0:
                    $ret .= $_sep . 'deset';
                    break;
                case 1:
                    $ret .= $_sep . 'jedenáct';
                    break;
                case 2:
                case 3:
                case 6:
                case 7:
                case 8:
                    $ret .= $_sep . $_digits[$d] . 'náct';
                    break;
                case 4:
                    $ret .= $_sep . 'čtrnáct';
                    break;
                case 5:
                    $ret .= $_sep . 'patnáct';
                    break;
                case 9:
                    $ret .= $_sep . 'devatenáct';
                    break;
            }
            break;
    }
    if ($t != 1 && $d > 0) {
        $ret .= $_sep . $_digits[$d];
    }
    if ($t == 1) {
        $d = 0;
    }
    if ($h + $t > 0 && $d == 1) {
        $d = 0;
    }
    if ($power > 0) {
        if (isset($_exponent[$power])) {
            $lev = $_exponent[$power];
        }
        if (!isset($lev) || !is_array($lev)) {
            return null;
        }
        switch ($d) {
            case 1:
                $suf = $lev[0];
                break;
            case 2:
            case 3:
            case 4:
                $suf = $lev[1];
                break;
            case 0:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
                $suf = $lev[2];
                break;
        }
        $ret .= $_sep . $suf;
    }
    if ($powsuffix != '') {
        $ret .= $_sep . $powsuffix;
    }
    return trim($ret);
}
Exemplo n.º 16
0
function receipt_data($x, $y)
{
    global $receipt, $pdf;
    $font_size = 12;
    $yy = $y;
    $xmax = $x + 420;
    $pdf->line($x, $y, $xmax, $y);
    $y -= 8;
    text_align_center($x + 140, $y, 8, iconv("UTF-8", "ISO-8859-2", trans('For what')));
    text_align_center($x + 315, $y, 8, iconv("UTF-8", "ISO-8859-2", trans('Value')));
    text_align_center($x + 385, $y, 8, iconv("UTF-8", "ISO-8859-2", trans('Number')));
    $y -= 2;
    $pdf->line($x, $y, $xmax, $y);
    $y -= $font_size;
    $i = 0;
    if ($receipt['contents']) {
        foreach ($receipt['contents'] as $item) {
            $i++;
            text_align_left($x + 2, $y, $font_size - 2, '<b>' . $i . '.</b>');
            $y = text_wrap($x + 15, $y, 270, $font_size - 2, iconv("UTF-8", "ISO-8859-2", $item['description']), '');
            text_align_right($x + 345, $y + $font_size, $font_size - 2, iconv("UTF-8", "ISO-8859-2", moneyf($item['value'])));
        }
    }
    $y += $font_size / 2;
    $pdf->line($x, $y, $xmax, $y);
    $y -= $font_size;
    text_align_right($x + 275, $y - 6, $font_size - 2, '<b>' . iconv("UTF-8", "ISO-8859-2", trans('Total:')) . '</b>');
    text_align_right($x + 345, $y - 6, $font_size - 2, '<b>' . iconv("UTF-8", "ISO-8859-2", moneyf($receipt['total'])) . '</b>');
    $y -= text_align_center($x + 385, $y, 8, 'Symbole');
    $y -= text_align_center($x + 385, $y, 8, 'PL. KAS. Nr');
    $pdf->line($x, $yy, $x, $y);
    $pdf->line($x + 280, $yy, $x + 280, $y);
    $pdf->line($x + 350, $yy, $x + 350, $y);
    $pdf->line($xmax, $yy, $xmax, $y);
    $pdf->line($x, $y, $xmax, $y);
    $y -= 16;
    text_align_left($x + 2, $y, 8, iconv("UTF-8", "ISO-8859-2", trans('In words:')));
    $y = text_wrap($x + 40, $y, 300, $font_size - 2, iconv("UTF-8", "ISO-8859-2", trans('$a dollars $b cents', to_words(floor($receipt['total'])), to_words($receipt['totalg']))), '');
    $y -= 8;
    $y += $font_size / 2;
    $pdf->line($x, $yy, $x, $y);
    $pdf->line($x + 350, $yy, $x + 350, $y);
    $pdf->line($xmax, $yy, $xmax, $y);
    $pdf->line($x, $y, $xmax, $y);
    return $y;
}
Exemplo n.º 17
0
function invoice_to_pay($x, $y)
{
    global $pdf, $invoice;
    if (isset($invoice['rebate'])) {
        $y = $y - text_align_left($x, $y, 14, iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('To repay:')) . ' ' . iconv("UTF-8", "ISO-8859-2//TRANSLIT", moneyf($invoice['value'])));
    } else {
        $y = $y - text_align_left($x, $y, 14, iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('To pay:')) . ' ' . iconv("UTF-8", "ISO-8859-2//TRANSLIT", moneyf($invoice['value'])));
    }
    $y = $y - text_align_left($x, $y, 10, iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('In words:')) . ' ' . iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('$a dollars $b cents', to_words(floor($invoice['value'])), to_words(round(($invoice['value'] - floor($invoice['value'])) * 100)))));
    return $y;
}
Exemplo n.º 18
0
 protected function receipt_data($x, $y)
 {
     $font_size = 12;
     $yy = $y;
     $xmax = $x + 420;
     $this->backend->line($x, $y, $xmax, $y);
     $y -= 8;
     $this->backend->text_align_center($x + 140, $y, 8, trans('For what'));
     $this->backend->text_align_center($x + 315, $y, 8, trans('Value'));
     $this->backend->text_align_center($x + 385, $y, 8, trans('Number'));
     $y -= 2;
     $this->backend->line($x, $y, $xmax, $y);
     $y -= $font_size;
     $i = 0;
     if ($this->data['contents']) {
         foreach ($this->data['contents'] as $item) {
             $i++;
             $this->backend->text_align_left($x + 2, $y, $font_size - 2, '<b>' . $i . '.</b>');
             $y = $this->backend->text_wrap($x + 15, $y, 270, $font_size - 2, $item['description'], '');
             $this->backend->text_align_right($x + 345, $y + $font_size, $font_size - 2, moneyf($item['value']));
         }
     }
     $y += $font_size / 2;
     $this->backend->line($x, $y, $xmax, $y);
     $y -= $font_size;
     $this->backend->text_align_right($x + 275, $y - 6, $font_size - 2, '<b>' . trans('Total:') . '</b>');
     $this->backend->text_align_right($x + 345, $y - 6, $font_size - 2, '<b>' . moneyf($this->data['total']) . '</b>');
     $y -= $this->backend->text_align_center($x + 385, $y, 8, 'Symbole');
     $y -= $this->backend->text_align_center($x + 385, $y, 8, 'PL. KAS. Nr');
     $this->backend->line($x, $yy, $x, $y);
     $this->backend->line($x + 280, $yy, $x + 280, $y);
     $this->backend->line($x + 350, $yy, $x + 350, $y);
     $this->backend->line($xmax, $yy, $xmax, $y);
     $this->backend->line($x, $y, $xmax, $y);
     $y -= 16;
     $this->backend->text_align_left($x + 2, $y, 8, trans('In words:'));
     $y = $this->backend->text_wrap($x + 40, $y, 300, $font_size - 2, trans('$a dollars $b cents', to_words(floor($this->data['total'])), to_words($this->data['totalg'])), '');
     $y -= 8;
     $y += $font_size / 2;
     $this->backend->line($x, $yy, $x, $y);
     $this->backend->line($x + 350, $yy, $x + 350, $y);
     $this->backend->line($xmax, $yy, $xmax, $y);
     $this->backend->line($x, $y, $xmax, $y);
     return $y;
 }
Exemplo n.º 19
0
Arquivo: ui.php Projeto: kornelek/lms
function to_words($num, $power = 0, $powsuffix = '', $short_version = 0)
{
    // Extracted from lang.pl.php by Piotr Klaban <makler at man dot torun dot pl>
    // from PEAR package Number_Words-0.3.1
    // 'short_version' added by alec/kubatyszko
    // added leading space trim's by alec
    if ($short_version) {
        $patterns[0] = "/0/";
        $patterns[1] = "/1/";
        $patterns[2] = "/2/";
        $patterns[3] = "/3/";
        $patterns[4] = "/4/";
        $patterns[5] = "/5/";
        $patterns[6] = "/6/";
        $patterns[7] = "/7/";
        $patterns[8] = "/8/";
        $patterns[9] = "/9/";
        $replacements[0] = "nul ";
        $replacements[1] = "jed ";
        $replacements[2] = "dva ";
        $replacements[3] = "tri ";
        $replacements[4] = "šty ";
        $replacements[5] = "päť ";
        $replacements[6] = "šes ";
        $replacements[7] = "sed ";
        $replacements[8] = "ose ";
        $replacements[9] = "dev ";
        return trim(preg_replace($patterns, $replacements, $num));
    }
    $ret = '';
    $_sep = ' ';
    $_minus = 'mínus';
    $_digits = array(0 => 'nula', 'jedna', 'dva', 'tri', 'štyri', 'päť', 'šesť', 'sedem', 'osem', 'deveť');
    $_exponent = array(0 => array('', '', ''), 3 => array('tisíc', 'tisíce', 'tisíc'), 6 => array('milión', 'milióny', 'miliónov'), 9 => array('miliarda', 'miliardy', 'miliárd'), 12 => array('bilión', 'bilióy', 'biliónov'), 15 => array('biliarda', 'biliardy', 'biliárd'), 18 => array('trylión', 'trylióny', 'tryliónov'), 21 => array('tryliarda', 'tryliardy', 'tryliard'), 24 => array('kvadrylión', 'kvadrylióny', 'kvadryliónov'), 27 => array('kwadryliard', 'kwadryliardy', 'kwadryliardów'), 30 => array('kwintylion', 'kwintyliony', 'kwintylionów'), 33 => array('kwintyliiard', 'kwintyliardy', 'kwintyliardów'), 36 => array('sekstylion', 'sekstyliony', 'sekstylionów'), 39 => array('sekstyliard', 'sekstyliardy', 'sekstyliardów'), 42 => array('septylion', 'septyliony', 'septylionów'), 45 => array('septyliard', 'septyliardy', 'septyliardów'), 48 => array('oktylion', 'oktyliony', 'oktylionów'), 51 => array('oktyliard', 'oktyliardy', 'oktyliardów'), 54 => array('nonylion', 'nonyliony', 'nonylionów'), 57 => array('nonyliard', 'nonyliardy', 'nonyliardów'), 60 => array('decylion', 'decyliony', 'decylionów'), 63 => array('decyliard', 'decyliardy', 'decyliardów'), 100 => array('centylion', 'centyliony', 'centylionów'), 103 => array('centyliard', 'centyliardy', 'centyliardów'), 120 => array('wicylion', 'wicylion', 'wicylion'), 123 => array('wicyliard', 'wicyliardy', 'wicyliardów'), 180 => array('trycylion', 'trycylion', 'trycylion'), 183 => array('trycyliard', 'trycyliardy', 'trycyliardów'), 240 => array('kwadragilion', 'kwadragilion', 'kwadragilion'), 243 => array('kwadragiliard', 'kwadragiliardy', 'kwadragiliardów'), 300 => array('kwinkwagilion', 'kwinkwagilion', 'kwinkwagilion'), 303 => array('kwinkwagiliard', 'kwinkwagiliardy', 'kwinkwagiliardów'), 360 => array('seskwilion', 'seskwilion', 'seskwilion'), 363 => array('seskwiliard', 'seskwiliardy', 'seskwiliardów'), 420 => array('septagilion', 'septagilion', 'septagilion'), 423 => array('septagiliard', 'septagiliardy', 'septagiliardów'), 480 => array('oktogilion', 'oktogilion', 'oktogilion'), 483 => array('oktogiliard', 'oktogiliardy', 'oktogiliardów'), 540 => array('nonagilion', 'nonagilion', 'nonagilion'), 543 => array('nonagiliard', 'nonagiliardy', 'nonagiliardów'), 600 => array('centylion', 'centyliony', 'centylionów'), 603 => array('centyliard', 'centyliardy', 'centyliardów'), 6000018 => array('milinilitrylion', 'milinilitryliony', 'milinilitrylionów'));
    if (substr($num, 0, 1) == '-') {
        $ret = $_minus;
        $num = substr($num, 1);
    }
    // strip excessive zero signs and spaces
    $num = trim($num);
    $num = preg_replace('/^0+/', '', $num);
    if (strlen($num) > 3) {
        $maxp = strlen($num) - 1;
        $curp = $maxp;
        for ($p = $maxp; $p > 0; --$p) {
            // power
            // check for highest power
            if (isset($_exponent[$p])) {
                // send substr from $curp to $p
                $snum = substr($num, $maxp - $curp, $curp - $p + 1);
                $snum = preg_replace('/^0+/', '', $snum);
                if ($snum !== '') {
                    $cursuffix = $_exponent[$power][count($_exponent[$power]) - 1];
                    if ($powsuffix != '') {
                        $cursuffix .= $_sep . $powsuffix;
                    }
                    $ret .= to_words($snum, $p, $cursuffix);
                    $ret .= ' ';
                }
                $curp = $p - 1;
                continue;
            }
        }
        $num = substr($num, $maxp - $curp, $curp - $p + 1);
        $ret = trim($ret);
        if ($num == 0) {
            return $ret;
        }
    } elseif ($num == 0 || $num == '') {
        return $_digits[0];
    }
    $h = $t = $d = 0;
    switch (strlen($num)) {
        case 3:
            $h = (int) substr($num, -3, 1);
        case 2:
            $t = (int) substr($num, -2, 1);
        case 1:
            $d = (int) substr($num, -1, 1);
            break;
        case 0:
            return;
            break;
    }
    switch ($h) {
        case 9:
            $ret .= $_sep . 'deveťsto';
            break;
        case 8:
            $ret .= $_sep . 'osemsto';
            break;
        case 7:
            $ret .= $_sep . 'sedemsto';
            break;
        case 6:
            $ret .= $_sep . 'šesťsto';
            break;
        case 5:
            $ret .= $_sep . 'päťsto';
            break;
        case 4:
            $ret .= $_sep . 'štyristo';
            break;
        case 3:
            $ret .= $_sep . 'tristo';
            break;
        case 2:
            $ret .= $_sep . 'dvesto';
            break;
        case 1:
            $ret .= $_sep . 'sto';
            break;
    }
    switch ($t) {
        case 9:
        case 8:
        case 7:
        case 6:
        case 5:
            $ret .= $_sep . $_digits[$t] . 'päťdesiat';
            break;
        case 4:
            $ret .= $_sep . 'štyridsať';
            break;
        case 3:
            $ret .= $_sep . 'tridsať';
            break;
        case 2:
            $ret .= $_sep . 'dvadsať';
            break;
        case 1:
            switch ($d) {
                case 0:
                    $ret .= $_sep . 'desať';
                    break;
                case 1:
                    $ret .= $_sep . 'jedenásť';
                    break;
                case 2:
                case 3:
                case 7:
                case 8:
                    $ret .= $_sep . $_digits[$d] . 'násť';
                    break;
                case 4:
                    $ret .= $_sep . 'štrnásť';
                    break;
                case 5:
                    $ret .= $_sep . 'pätnásť';
                    break;
                case 6:
                    $ret .= $_sep . 'šestnásť';
                    break;
                case 9:
                    $ret .= $_sep . 'devetnásť';
                    break;
            }
            break;
    }
    if ($t != 1 && $d > 0) {
        $ret .= $_sep . $_digits[$d];
    }
    if ($t == 1) {
        $d = 0;
    }
    if ($h + $t > 0 && $d == 1) {
        $d = 0;
    }
    if ($power > 0) {
        if (isset($_exponent[$power])) {
            $lev = $_exponent[$power];
        }
        if (!isset($lev) || !is_array($lev)) {
            return null;
        }
        switch ($d) {
            case 1:
                $suf = $lev[0];
                break;
            case 2:
            case 3:
            case 4:
                $suf = $lev[1];
                break;
            case 0:
            case 5:
            case 6:
            case 7:
            case 8:
            case 9:
                $suf = $lev[2];
                break;
        }
        $ret .= $_sep . $suf;
    }
    if ($powsuffix != '') {
        $ret .= $_sep . $powsuffix;
    }
    return trim($ret);
}
Exemplo n.º 20
0
 protected function invoice_to_pay($x, $y)
 {
     if (isset($this->data['rebate'])) {
         $y = $y - $this->backend->text_align_left($x, $y, 14, trans('To repay:') . ' ' . moneyf($this->data['value']));
     } else {
         $y = $y - $this->backend->text_align_left($x, $y, 14, trans('To pay:') . ' ' . moneyf($this->data['value']));
     }
     $y = $y - $this->backend->text_align_left($x, $y, 10, trans('In words:') . ' ' . trans('$a dollars $b cents', to_words(floor($this->data['value'])), to_words(round(($this->data['value'] - floor($this->data['value'])) * 100))));
     return $y;
 }