Example #1
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'])));
 }
Example #2
0
 public function note_recipient()
 {
     $oldy = $this->backend->GetY();
     $recipient = '<b>' . trans('Note recipient:') . '</b><br>';
     $recipient .= $this->data['name'] . '<br>';
     $recipient .= $this->data['address'] . '<br>';
     $recipient .= $this->data['zip'] . ' ' . $this->data['city'] . '<br>';
     if ($this->data['ten']) {
         $recipient .= trans('TEN') . ': ' . $this->data['ten'] . '<br>';
     } elseif ($this->data['ssn']) {
         $recipient .= trans('SSN') . ': ' . $this->data['ssn'] . '<br>';
     }
     $this->backend->SetFont('arial', '', 10);
     $this->backend->writeHTMLCell(80, '', 125, 50, $recipient, 0, 1, 0, true, 'L');
     $y = $this->backend->GetY();
     if (ConfigHelper::checkValue(ConfigHelper::getConfig('invoices.customer_bankaccount', true))) {
         $bankaccount = trans('Bank account:') . ' <b>' . format_bankaccount(bankaccount($this->data['customerid'], $this->data['account'])) . '</b>';
         $this->backend->SetFont('arial', 'B', 8);
         $this->backend->writeHTMLCell('', '', 125, $oldy + round(($y - $oldy - 8) / 2), $bankaccount, 0, 1, 0, true, 'L');
     }
     if (ConfigHelper::checkValue(ConfigHelper::getConfig('invoices.customer_credentials', true))) {
         $pin = '<b>' . trans('Customer ID: $a', sprintf('%04d', $this->data['customerid'])) . '</b><br>';
         $pin .= '<b>PIN: ' . sprintf('%04d', $this->data['customerpin']) . '</b><br>';
         $this->backend->SetFont('arial', 'B', 8);
         $this->backend->writeHTMLCell('', '', 125, $oldy + round(($y - $oldy) / 2), $pin, 0, 1, 0, true, 'L');
     }
     $this->backend->SetY($y);
 }
Example #3
0
function invoice_main_form_fill($x, $y, $scale)
{
    global $pdf, $invoice;
    $pdf->setlinestyle(1);
    $pdf->line(7 * $scale + $x, 724 * $scale + $y, 7 * $scale + $x, 694 * $scale + $y);
    $pdf->line(7 * $scale + $x, 724 * $scale + $y, 37 * $scale + $x, 724 * $scale + $y);
    $pdf->line(970 * $scale + $x, 724 * $scale + $y, 970 * $scale + $x, 694 * $scale + $y);
    $pdf->line(970 * $scale + $x, 724 * $scale + $y, 940 * $scale + $x, 724 * $scale + $y);
    $pdf->line(7 * $scale + $x, 172 * $scale + $y, 7 * $scale + $x, 202 * $scale + $y);
    $pdf->line(7 * $scale + $x, 172 * $scale + $y, 37 * $scale + $x, 172 * $scale + $y);
    $name = $invoice['division_name'];
    $address = $invoice['division_address'];
    $zip = $invoice['division_zip'];
    $city = $invoice['division_city'];
    $account = bankaccount($invoice['customerid'], $invoice['account']);
    text_autosize(15 * $scale + $x, 680 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", $name), 950 * $scale);
    text_autosize(15 * $scale + $x, 617 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", $address . " " . $zip . " " . $city), 950 * $scale);
    text_autosize(15 * $scale + $x, 555 * $scale + $y, 30 * $scale, format_bankaccount($account), 950 * $scale);
    $pdf->addtext(330 * $scale + $x, 495 * $scale + $y, 30 * $scale, 'X');
    text_autosize(550 * $scale + $x, 495 * $scale + $y, 30 * $scale, "*" . number_format($invoice['total'], 2, ',', '') . "*", 400 * $scale);
    text_autosize(15 * $scale + $x, 434 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('$a dollars $b cents', to_words(floor($invoice['total'])), to_words(round(($invoice['total'] - floor($invoice['total'])) * 100)))), 950 * $scale);
    text_autosize(15 * $scale + $x, 372 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", $invoice['name']), 950 * $scale);
    text_autosize(15 * $scale + $x, 312 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", $invoice['address'] . " " . $invoice['zip'] . " " . $invoice['city']), 950 * $scale);
    $tmp = docnumber($invoice['number'], $invoice['template'], $invoice['cdate']);
    text_autosize(15 * $scale + $x, 250 * $scale + $y, 30 * $scale, iconv("UTF-8", "ISO-8859-2//TRANSLIT", trans('Payment for invoice No. $a', $tmp)), 950 * $scale);
}
Example #4
0
 protected function main_fill($x, $y, $scale)
 {
     if (ConfigHelper::checkConfig('finances.control_lines')) {
         $this->backend->line(7 * $scale + $x, 115 * $scale + $y, 7 * $scale + $x, 145 * $scale + $y);
         $this->backend->line(7 * $scale + $x, 115 * $scale + $y, 37 * $scale + $x, 115 * $scale + $y);
         $this->backend->line(978 * $scale + $x, 115 * $scale + $y, 978 * $scale + $x, 145 * $scale + $y);
         $this->backend->line(978 * $scale + $x, 115 * $scale + $y, 948 * $scale + $x, 115 * $scale + $y);
         $this->backend->line(7 * $scale + $x, 726 * $scale + $y, 7 * $scale + $x, 696 * $scale + $y);
         $this->backend->line(7 * $scale + $x, 726 * $scale + $y, 37 * $scale + $x, 726 * $scale + $y);
         $this->backend->line(978 * $scale + $x, 726 * $scale + $y, 978 * $scale + $x, 696 * $scale + $y);
         $this->backend->line(978 * $scale + $x, 726 * $scale + $y, 948 * $scale + $x, 726 * $scale + $y);
     }
     $this->backend->addtext(15 * $scale + $x, 680 * $scale + $y, 30 * $scale, $this->data['d_name']);
     $this->backend->addtext(15 * $scale + $x, 617 * $scale + $y, 30 * $scale, $this->data['d_address'] . ' ' . $this->data['d_zip'] . ' ' . $this->data['d_city']);
     $this->backend->addtext(15 * $scale + $x, 555 * $scale + $y, 30 * $scale, format_bankaccount(bankaccount($this->data['id'], $this->data['account'])));
     $this->backend->addtext(550 * $scale + $x, 497 * $scale + $y, 30 * $scale, number_format($this->data['total'], 2, ',', ''));
     $this->backend->addtext(15 * $scale + $x, 375 * $scale + $y, 30 * $scale, $this->data['customername']);
     $this->backend->addtext(15 * $scale + $x, 315 * $scale + $y, 30 * $scale, $this->data['address'] . '; ' . $this->data['zip'] . ' ' . $this->data['city']);
     $this->backend->addtext(15 * $scale + $x, 250 * $scale + $y, 30 * $scale, trans('Payment for invoice No. $a', $this->data['t_number']));
 }
Example #5
0
function format_customer_account($contact)
{
    return format_bankaccount($contact['contact']);
}
Example #6
0
File: note.php Project: itav/lms
			WHERE e.userid = lms_current_user() AND a.customerid = d.customerid)' . ' ORDER BY CEIL(d.cdate/86400), d.id', array($_GET['from'], $_GET['to'], DOC_DNOTE));
    if (!$ids) {
        $SESSION->close();
        die;
    }
    $count = sizeof($ids);
    $i = 0;
    foreach ($ids as $idx => $noteid) {
        $note = $LMS->GetNoteContent($noteid);
        if ($count == 1) {
            $docnumber = docnumber($note['number'], $note['template'], $note['cdate']);
        }
        $note['division_header'] = str_replace('%bankaccount', format_bankaccount(bankaccount($note['customerid'], $note['account'])), $note['division_header']);
        $document->Draw($note);
    }
} elseif ($note = $LMS->GetNoteContent($_GET['id'])) {
    $docnumber = $number = docnumber($note['number'], $note['template'], $note['cdate']);
    $layout['pagetitle'] = trans('Debit Note No. $a', $number);
    $note['last'] = TRUE;
    $note['division_header'] = str_replace('%bankaccount', format_bankaccount(bankaccount($note['customerid'], $note['account'])), $note['division_header']);
    $document->Draw($note);
} else {
    $SESSION->redirect('?m=notelist');
}
if (!is_null($attachment_name) && isset($docnumber)) {
    $attachment_name = str_replace('%number', $docnumber, $attachment_name);
    $attachment_name = preg_replace('/[^[:alnum:]_\\.]/i', '_', $attachment_name);
} else {
    $attachment_name = 'invoices.' . ($note_type == 'pdf' ? 'pdf' : 'html');
}
$document->WriteToBrowser($attachment_name);
Example #7
0
 protected function invoice_footnote($x, $y, $width, $font_size)
 {
     if (!empty($this->data['division_footer'])) {
         $y = $y - $this->backend->getFontHeight($font_size);
         //$y = $y - $this->backend->text_align_left($x, $y, $font_size, '<b>' . trans('Notes:') . '</b>');
         $tmp = $this->data['division_footer'];
         $accounts = array(bankaccount($this->data['customerid'], $this->data['account']));
         if (ConfigHelper::checkConfig('invoices.show_all_accounts')) {
             $accounts = array_merge($accounts, $this->data['bankaccounts']);
         }
         foreach ($accounts as &$account) {
             $account = format_bankaccount($account);
         }
         $tmp = str_replace('%bankaccount', implode("\n", $accounts), $tmp);
         $tmp = preg_split('/\\r?\\n/', $tmp);
         foreach ($tmp as $line) {
             $y = $this->backend->text_wrap($x, $y, $width, $font_size, $line, "full");
         }
     }
 }
Example #8
0
 protected function invoice_footnote()
 {
     if (!empty($this->data['division_footer'])) {
         $this->backend->Ln(7);
         //$this->backend->SetFont('arial', 'B', 10);
         //$this->backend->Write(0, trans('Notes:'), '', 0, 'L', true, 0, false, false, 0);
         $tmp = $this->data['division_footer'];
         $accounts = array(bankaccount($this->data['customerid'], $this->data['account']));
         if (ConfigHelper::checkConfig('invoices.show_all_accounts')) {
             $accounts = array_merge($accounts, $this->data['bankaccounts']);
         }
         foreach ($accounts as &$account) {
             $account = format_bankaccount($account);
         }
         $tmp = str_replace('%bankaccount', implode("\n", $accounts), $tmp);
         $this->backend->SetFont('arial', '', 8);
         $h = $this->backend->getStringHeight(0, $tmp);
         $tmp = mb_ereg_replace('\\r?\\n', '<br>', $tmp);
         $this->backend->writeHTMLCell(0, 0, '', 188 - $h, $tmp, 0, 1, 0, true, 'C');
     }
 }
Example #9
0
imagefilledrectangle($img, 0, 0, 1200, 630, $white);
$FT0100A = imagecreatefrompng('img/FT0100A.png');
$FT0100B = imagecreatefrompng('img/FT0100B.png');
imagecopy($img, $FT0100A, 0, 10, 0, 0, imagesx($FT0100A), imagesy($FT0100A));
imagecopy($img, $FT0100B, 310, 10, 0, 0, imagesx($FT0100B), imagesy($FT0100B));
//odbiorca
imagettftext($img, 8, 0, 47, 135, $black, $font, $division['name']);
imagettftext($img, 8, 0, 47, 155, $black, $font, $division['address']);
imagettftext($img, 8, 0, 47, 175, $black, $font, $division['zip'] . ' ' . $division['city']);
imagettftext($img, 14, 0, 353, 48, $black, $font, $division['name']);
imagettftext($img, 14, 0, 353, 100, $black, $font, $division['address'] . ' ' . $division['zip'] . ' ' . $division['city']);
//numerkonta
imagettftext($img, 11, 0, 48, 44, $black, $fontb, format_bankaccount($customer['bankaccount']));
$count = strlen($customer['bankaccount']);
for ($i = 0; $i < $count; $i++) {
    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];
}
Example #10
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);
}
Example #11
0
function BodyVars(&$body, $data)
{
    global $LMS, $LANGDEFS;
    $body = str_replace('%customer', $data['customername'], $body);
    $body = str_replace('%balance', $data['balance'], $body);
    $body = str_replace('%cid', $data['id'], $body);
    $body = str_replace('%pin', $data['pin'], $body);
    if (strpos($body, '%bankaccount') !== false) {
        $body = str_replace('%bankaccount', format_bankaccount(bankaccount($data['id'])), $body);
    }
    if (!(strpos($body, '%last_10_in_a_table') === FALSE)) {
        $last10 = '';
        if ($last10_array = $LMS->DB->GetAll('SELECT comment, time, value 
			FROM cash WHERE customerid = ?
			ORDER BY time DESC LIMIT 10', array($data['id']))) {
            foreach ($last10_array as $r) {
                $last10 .= date("Y/m/d | ", $r['time']);
                $last10 .= sprintf("%20s | ", sprintf($LANGDEFS[$LMS->ui_lang]['money_format'], $r['value']));
                $last10 .= $r['comment'] . "\n";
            }
        }
        $body = str_replace('%last_10_in_a_table', $last10, $body);
    }
}
Example #12
0
        if ($customerinfo['messengers']) {
            foreach ($customerinfo['messengers'] as $idx => $val) {
                $customerinfo['uid'][$idx] = $val['uid'];
            }
        }
        if (empty($customerinfo['contacts'])) {
            $customerinfo['contacts'][] = array();
        }
        if (empty($customerinfo['emails'])) {
            $customerinfo['emails'][] = array();
        }
        if (empty($customerinfo['accounts'])) {
            $customerinfo['accounts'][] = array();
        } else {
            foreach ($customerinfo['accounts'] as &$account) {
                $account['account'] = format_bankaccount($account['account']);
            }
        }
    }
    $layout['pagetitle'] = trans('Customer Edit: $a', $customerinfo['customername']);
    $SESSION->save('backto', $_SERVER['QUERY_STRING']);
    $customerid = $customerinfo['id'];
    include MODULES_DIR . '/customer.inc.php';
}
$LMS->InitXajax();
$hook_data = $LMS->executeHook('customeredit_before_display', array('customerinfo' => $customerinfo, 'smarty' => $SMARTY));
$customerinfo = $hook_data['customerinfo'];
$SMARTY->assign('xajax', $LMS->RunXajax());
$SMARTY->assign('customerinfo', $customerinfo);
$SMARTY->assign('cstateslist', $LMS->GetCountryStates());
$SMARTY->assign('countrieslist', $LMS->GetCountries());
Example #13
0
function module_main()
{
    global $DB, $LMS, $SESSION, $SMARTY;
    if (isset($_GET['ar'])) {
        $archiwum = true;
    } else {
        $archiwum = false;
    }
    if (isset($_GET['p'])) {
        $id = (int) $_GET['p'];
        $DB->Execute('UPDATE messageitems SET isread = ? WHERE id = ?;', array(1, $id));
    }
    $message = $DB->GetAll('SELECT mi.id, m.subject, m.body, m.cdate, mi.isread , mi.firstread 
		FROM messageitems mi, messages m
		WHERE m.id = mi.messageid AND m.type=? AND mi.customerid = ? AND mi.status = ? ' . (!$archiwum ? ' AND mi.isread=\'0\'' : '') . ' ORDER BY m.cdate DESC ;', array(MSG_USERPANEL, $SESSION->id, MSG_SENT));
    if ($message) {
        $czas = time();
        for ($i = 0; $i < sizeof($message); $i++) {
            if (!$message[$i]['isread']) {
                $DB->Execute('UPDATE messageitems SET ' . (!$message[$i]['firstread'] ? ' firstread=\'' . $czas . '\', ' : '') . ' lastread=\'' . $czas . '\' WHERE id = ?;', array($message[$i]['id']));
            }
        }
    }
    if ($message) {
        $data = $LMS->DB->GetRow('SELECT c.id, email, pin, ' . $LMS->DB->Concat('c.lastname', "' '", 'c.name') . ' AS customername, ' . $LMS->DB->Concat('c.address', "' '", 'c.zip', "' '", 'c.city') . ' AS address, ' . $LMS->DB->Concat('c.post_address', "' '", 'c.post_zip', "' '", 'c.post_city') . ' AS postaddress, ' . 'COALESCE(b.value, 0) AS balance
		FROM customers c 
		LEFT JOIN (
			SELECT SUM(value) AS value, customerid
			FROM cash GROUP BY customerid
		) b ON (b.customerid = c.id) 
		WHERE c.id = ? LIMIT 1', array($SESSION->id));
        for ($i = 0; $i < sizeof($message); $i++) {
            if (!empty($data['customername'])) {
                $message[$i]['body'] = str_replace('%customer', $data['customername'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%customer', '', $message[$i]['body']);
            }
            if (!empty($data['balance'])) {
                $message[$i]['body'] = str_replace('%balance', $data['balance'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%balance', '', $message[$i]['body']);
            }
            if (!empty($data['id'])) {
                $message[$i]['body'] = str_replace('%cid', $data['id'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%cid', '', $message[$i]['body']);
            }
            if (!empty($data['pin'])) {
                $message[$i]['body'] = str_replace('%pin', $data['pin'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%pin', '', $message[$i]['body']);
            }
            if (!empty($data['address'])) {
                $message[$i]['body'] = str_replace('%address', $data['address'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%address', '', $message[$i]['body']);
            }
            if (!empty($data['postaddress'])) {
                $message[$i]['body'] = str_replace('%postaddress', $data['postaddress'], $message[$i]['body']);
            } else {
                $message[$i]['body'] = str_replace('%postaddress', '', $message[$i]['body']);
            }
            if (bankaccount($data['id']) != '') {
                if (strpos($message[$i]['body'], '%bankaccount') !== false) {
                    $message[$i]['body'] = str_replace('%bankaccount', format_bankaccount(bankaccount($data['id'])), $message[$i]['body']);
                }
            } else {
                $message[$i]['body'] = str_replace('%bankaccount', '', $message[$i]['body']);
            }
            if (!(strpos($message[$i]['body'], '%last_3_in_a_table') === FALSE)) {
                $last3 = '';
                if ($last3_array = $LMS->DB->GetAll('SELECT comment, time, value 
			FROM cash WHERE customerid = ?
			ORDER BY time DESC LIMIT 3', array($data['id']))) {
                    foreach ($last3_array as $r) {
                        $last3 .= date("Y/m/d | ", $r['time']);
                        $last3 .= sprintf("%20s | ", sprintf($LANGDEFS[$LMS->ui_lang]['money_format'], $r['value']));
                        $last3 .= $r['comment'] . "\n";
                    }
                }
                $message[$i]['body'] = str_replace('%last_3_in_a_table', $last3, $message[$i]['body']);
            }
            if (!(strpos($message[$i]['body'], '%last_10_in_a_table') === FALSE)) {
                $last10 = '';
                if ($last10_array = $LMS->DB->GetAll('SELECT comment, time, value 
			FROM cash WHERE customerid = ?
			ORDER BY time DESC LIMIT 10', array($data['id']))) {
                    foreach ($last10_array as $r) {
                        $last10 .= date("Y/m/d | ", $r['time']);
                        $last10 .= sprintf("%20s | ", sprintf($LANGDEFS[$LMS->ui_lang]['money_format'], $r['value']));
                        $last10 .= $r['comment'] . "\n";
                    }
                }
                $message[$i]['body'] = str_replace('%last_10_in_a_table', $last10, $message[$i]['body']);
            }
        }
    }
    $count = count($message);
    //    if ($count!==0) for ($i=0;$i<$count;$i++) $message[$i]['body'] = base64_decode($message[$i]['body']);
    $SMARTY->assign('archiwum', $archiwum);
    $SMARTY->assign('message', $message);
    $SMARTY->display('module:wiadomosci.html');
}
Example #14
0
function invoice_footnote()
{
    global $pdf, $invoice;
    if (!empty($invoice['division_footer'])) {
        $pdf->Ln(7);
        //$pdf->SetFont('arial', 'B', 10);
        //$pdf->Write(0, trans('Notes:'), '', 0, 'L', true, 0, false, false, 0);
        $tmp = $invoice['division_footer'];
        $account = format_bankaccount(bankaccount($invoice['customerid'], $invoice['account']));
        $tmp = str_replace('%bankaccount', $account, $tmp);
        $pdf->SetFont('arial', '', 8);
        $h = $pdf->getStringHeight(0, $tmp);
        $tmp = mb_ereg_replace('\\r?\\n', '<br>', $tmp);
        $pdf->writeHTMLCell(0, 0, '', 188 - $h, $tmp, 0, 1, 0, true, 'C');
    }
}
Example #15
0
    function GetInvoiceContent($invoiceid)
    {
        global $PAYTYPES;
        $result = $this->DB->GetRow('SELECT d.id, d.number, d.name, d.customerid, d.type, 
				d.userid, d.address, d.zip, d.city, d.countryid, cn.name AS country,
				d.ten, d.ssn, d.cdate, d.sdate, d.paytime, d.paytype, d.numberplanid,
				d.closed, d.reference, d.reason, d.divisionid, 
				(SELECT name FROM users WHERE id = d.userid) AS user, n.template,
				d.div_name AS division_name, d.div_name AS division_shortname, d.div_shortname AS division_shortnames,
				d.div_address AS division_address, d.div_zip AS division_zip,
				d.div_city AS division_city, d.div_countryid AS division_countryid, 
				d.div_ten AS division_ten, d.div_regon AS division_regon, d.div_account AS account,
				d.div_inv_header AS division_header, d.div_inv_footer AS division_footer,
				d.div_inv_author AS division_author, d.div_inv_cplace AS division_cplace,
				d.fullnumber AS fullnumber,d.version, d.templatetype, d.templatefile, d.sdateview, d.urllogofile, d.print_balance_info, 
				c.pin AS customerpin, c.divisionid AS current_divisionid,
				d.post_name, d.post_address, d.post_zip, d.post_city,
				c.invoice_name, c.invoice_address, c.invoice_zip, c.invoice_city, c.invoice_countryid, c.invoice_ten 
				FROM documents d
				JOIN customers c ON (c.id = d.customerid)
				LEFT JOIN countries cn ON (cn.id = d.countryid) 
				LEFT JOIN numberplans n ON (d.numberplanid = n.id)
				WHERE d.id = ? AND (d.type = ? OR d.type = ? OR d.type = ?)', array($invoiceid, DOC_INVOICE, DOC_CNOTE, DOC_INVOICE_PRO));
        if ($result) {
            $result['pdiscount'] = 0;
            $result['vdiscount'] = 0;
            $result['totalbase'] = 0;
            $result['totaltax'] = 0;
            $result['total'] = 0;
            if ($result['version'] != '2' && ($firma = $this->DB->getrow('SELECT shortname,name,address,city,zip,ten,account,inv_header,inv_footer,inv_author,inv_cplace 
				FROM divisions WHERE id = ? LIMIT 1;', array($result['divisionid'])))) {
                if (empty($result['division_name'])) {
                    $result['division_name'] = $firma['name'];
                }
                if (empty($result['division_shortname'])) {
                    $result['division_shortname'] = $firma['name'];
                }
                if (empty($result['division_address'])) {
                    $result['division_address'] = $firma['address'];
                }
                if (empty($result['division_zip'])) {
                    $result['division_zip'] = $firma['zip'];
                }
                if (empty($result['division_city'])) {
                    $result['division_city'] = $firma['city'];
                }
                if (empty($result['division_ten'])) {
                    $result['division_ten'] = $firma['ten'];
                }
                if (empty($result['account'])) {
                    $result['account'] = $firma['account'];
                }
                if (empty($result['division_header'])) {
                    $result['division_header'] = $firma['inv_header'];
                }
                if (empty($result['division_footer'])) {
                    $result['division_footer'] = $firma['inv_footer'];
                }
                if (empty($result['division_author'])) {
                    $result['division_author'] = $firma['inv_author'];
                }
                if (empty($result['division_cplace'])) {
                    $result['division_cplace'] = $firma['inv_cplace'];
                }
            }
            if ($result['reference'] && $result['type'] != DOC_INVOICE_PRO) {
                $result['invoice'] = $this->GetInvoiceContent($result['reference']);
            }
            if (!$result['division_header']) {
                $result['division_header'] = $result['division_name'] . "\n" . $result['division_address'] . "\n" . $result['division_zip'] . ' ' . $result['division_city'] . ($result['division_countryid'] && $result['countryid'] && $result['division_countryid'] != $result['countryid'] ? "\n" . trans($this->GetCountryName($result['division_countryid'])) : '') . ($result['division_ten'] != '' ? "\n" . trans('TEN') . ' ' . $result['division_ten'] : '') . ($result['account'] != '' ? "\n" . "Nr konta: " . format_bankaccount(bankaccount($result['customerid'], $result['account'])) : '');
            }
            if ($result['content'] = $this->DB->GetAll('SELECT invoicecontents.value AS value, 
						itemid, taxid, taxes.value AS taxvalue, taxes.label AS taxlabel, 
						prodid, content, count, invoicecontents.description AS description, 
						tariffid, itemid, pdiscount, vdiscount 
						FROM invoicecontents 
						LEFT JOIN taxes ON taxid = taxes.id 
						WHERE docid=? 
						ORDER BY itemid', array($invoiceid))) {
                foreach ($result['content'] as $idx => $row) {
                    if (isset($result['invoice'])) {
                        $row['value'] += $result['invoice']['content'][$idx]['value'];
                        $row['count'] += $result['invoice']['content'][$idx]['count'];
                    }
                    $result['content'][$idx]['basevalue'] = round($row['value'] / (100 + $row['taxvalue']) * 100, 2);
                    $result['content'][$idx]['total'] = round($row['value'] * $row['count'], 2);
                    $result['content'][$idx]['totalbase'] = round($result['content'][$idx]['total'] / (100 + $row['taxvalue']) * 100, 2);
                    $result['content'][$idx]['totaltax'] = round($result['content'][$idx]['total'] - $result['content'][$idx]['totalbase'], 2);
                    $result['content'][$idx]['value'] = $row['value'];
                    $result['content'][$idx]['count'] = $row['count'];
                    if (isset($result['taxest'][$row['taxvalue']])) {
                        $result['taxest'][$row['taxvalue']]['base'] += $result['content'][$idx]['totalbase'];
                        $result['taxest'][$row['taxvalue']]['total'] += $result['content'][$idx]['total'];
                        $result['taxest'][$row['taxvalue']]['tax'] += $result['content'][$idx]['totaltax'];
                    } else {
                        $result['taxest'][$row['taxvalue']]['base'] = $result['content'][$idx]['totalbase'];
                        $result['taxest'][$row['taxvalue']]['total'] = $result['content'][$idx]['total'];
                        $result['taxest'][$row['taxvalue']]['tax'] = $result['content'][$idx]['totaltax'];
                        $result['taxest'][$row['taxvalue']]['taxlabel'] = $row['taxlabel'];
                    }
                    $result['totalbase'] += $result['content'][$idx]['totalbase'];
                    $result['totaltax'] += $result['content'][$idx]['totaltax'];
                    $result['total'] += $result['content'][$idx]['total'];
                    // for backward compatybility
                    $result['taxest'][$row['taxvalue']]['taxvalue'] = $row['taxvalue'];
                    $result['content'][$idx]['pkwiu'] = $row['prodid'];
                    $result['pdiscount'] += $row['pdiscount'];
                    $result['vdiscount'] += $row['vdiscount'];
                }
            }
            $result['pdate'] = $result['cdate'] + $result['paytime'] * 86400;
            $result['value'] = $result['total'] - (isset($result['invoice']) ? $result['invoice']['value'] : 0);
            if ($result['value'] < 0) {
                $result['value'] = abs($result['value']);
                $result['rebate'] = true;
            }
            $result['valuep'] = round(($result['value'] - floor($result['value'])) * 100);
            // NOTE: don't waste CPU/mem when printing history is not set:
            if (chkconfig($this->CONFIG['invoices']['print_balance_history']) && $result['type'] != DOC_INVOICE_PRO) {
                if (isset($this->CONFIG['invoices']['print_balance_history_save']) && chkconfig($this->CONFIG['invoices']['print_balance_history_save'])) {
                    $result['customerbalancelist'] = $this->GetCustomerBalanceList($result['customerid'], $result['cdate']);
                } else {
                    $result['customerbalancelist'] = $this->GetCustomerBalanceList($result['customerid']);
                }
                $result['customerbalancelistlimit'] = $this->CONFIG['invoices']['print_balance_history_limit'];
            }
            $result['paytypename'] = $PAYTYPES[$result['paytype']];
            // for backward compat.
            $result['totalg'] = round(($result['value'] - floor($result['value'])) * 100);
            $result['year'] = date('Y', $result['cdate']);
            $result['month'] = date('m', $result['cdate']);
            $result['pesel'] = $result['ssn'];
            $result['nip'] = $result['ten'];
            if ($result['post_name'] || $result['post_address']) {
                $reulst['serviceaddr'] = $result['post_name'];
                if ($result['post_address']) {
                    $result['serviceaddr'] .= "\n" . $result['post_address'];
                }
                if ($result['post_zip'] && $result['post_city']) {
                    $result['serviceaddr'] .= "\n" . $result['post_zip'] . ' ' . $result['post_city'];
                }
            }
            return $result;
        } else {
            return FALSE;
        }
    }
Example #16
0
function parse_data($id, $tresc, $customer)
{
    global $LMS, $LANGDEFS;
    $tresc = preg_replace("/\\%dzis/", date("d/m/Y"), $tresc);
    $tresc = preg_replace("/\\%balance/", sprintf("%6.2f", $customer['balance']), $tresc);
    $tresc = preg_replace("/\\%bankaccount/", format_bankaccount($customer['bankaccount']), $tresc);
    if (!(strpos($tresc, '%last_10_in_a_table') === FALSE)) {
        $last10 = '';
        if ($last10_array = $LMS->DB->GetAll('SELECT comment, time, value
                        FROM cash WHERE customerid = ?
                        ORDER BY time DESC LIMIT 10', array($customer['id']))) {
            foreach ($last10_array as $r) {
                $last10 .= date("Y/m/d | ", $r['time']);
                $last10 .= sprintf("%20s | ", sprintf($LANGDEFS[$LMS->ui_lang]['money_format'], $r['value']));
                $last10 .= $r['comment'] . "\n";
            }
        }
        $tresc = str_replace('%last_10_in_a_table', $last10, $tresc);
    }
    return $tresc;
}
Example #17
0
    } else {
        $customerinfo = $LMS->GetCustomer($_GET['id']);
        $customerinfo['cutoffstopindefinitely'] = 0;
        if ($customerinfo['cutoffstop']) {
            if ($customerinfo['cutoffstop'] == intval(pow(2, 31) - 1)) {
                $customerinfo['cutoffstop'] = 0;
                $customerinfo['cutoffstopindefinitely'] = 1;
            } else {
                $customerinfo['cutoffstop'] = strftime('%Y/%m/%d', $customerinfo['cutoffstop']);
            }
        } else {
            $customerinfo['cutoffstop'] = 0;
        }
        if (!empty($customerinfo['accounts'])) {
            foreach ($customerinfo['accounts'] as &$account) {
                $account['contact'] = format_bankaccount($account['contact']);
            }
        }
    }
    $layout['pagetitle'] = trans('Customer Edit: $a', $customerinfo['customername']);
    $SESSION->save('backto', $_SERVER['QUERY_STRING']);
    $customerid = $customerinfo['id'];
    include MODULES_DIR . '/customer.inc.php';
}
$LMS->InitXajax();
$hook_data = $LMS->executeHook('customeredit_before_display', array('customerinfo' => $customerinfo, 'smarty' => $SMARTY));
$customerinfo = $hook_data['customerinfo'];
$SMARTY->assign('xajax', $LMS->RunXajax());
$SMARTY->assign('customerinfo', $customerinfo);
$SMARTY->assign('cstateslist', $LMS->GetCountryStates());
$SMARTY->assign('countrieslist', $LMS->GetCountries());
Example #18
0
function invoice_footnote($x, $y, $width, $font_size)
{
    global $pdf, $invoice;
    if (!empty($invoice['division_footer'])) {
        $y = $y - $pdf->getFontHeight($font_size);
        //$y = $y - text_align_left($x, $y, $font_size, '<b>'.iconv("UTF-8","ISO-8859-2//TRANSLIT", trans('Notes:')).'</b>');
        $tmp = iconv("UTF-8", "ISO-8859-2//TRANSLIT", $invoice['division_footer']);
        $account = format_bankaccount(bankaccount($invoice['customerid'], $invoice['account']));
        $tmp = str_replace('%bankaccount', $account, $tmp);
        $tmp = preg_split('/\\r?\\n/', $tmp);
        foreach ($tmp as $line) {
            $y = text_wrap($x, $y, $width, $font_size, $line, "full");
        }
    }
}
Example #19
0
function invoice_footnote_v2() {
	global $pdf, $invoice;
	if (!empty($invoice['division_footer'])) {
		$pdf->Ln(5);
		$tmp = $invoice['division_footer'];
		
		$account = format_bankaccount(bankaccount($invoice['customerid'], $invoice['account']));
		$tmp = str_replace('%bankaccount', $account, $tmp);

		$pdf->SetFont('arial', '', 7);
		$h = $pdf->getStringHeight(0, $tmp);
		$tmp = mb_ereg_replace('\r?\n', '<br>', $tmp);
		if ($invoice['templatefile']=='standard')
		    $pdf->writeHTMLCell(0, 0, '', '', $tmp, 0, 1, 0, true, 'C');
		else
		    $pdf->writeHTMLCell(0, 0, '', 188 - $h, $tmp, 0, 1, 0, true, 'C');
	}
}
Example #20
0
function parse_customer_data($data, $row)
{
    global $DB;
    $amount = -$row['balance'];
    $data = preg_replace("/\\%bankaccount/", format_bankaccount(bankaccount($row['id'], $row['account'])), $data);
    $data = preg_replace("/\\%b/", $amount, $data);
    $data = preg_replace("/\\%date-y/", strftime("%Y"), $data);
    $data = preg_replace("/\\%date-m/", strftime("%m"), $data);
    $data = preg_replace("/\\%date_month_name/", strftime("%B"), $data);
    $deadline = $row['cdate'] + $row['paytime'] * 86400;
    $data = preg_replace("/\\%deadline-y/", strftime("%Y", $deadline), $data);
    $data = preg_replace("/\\%deadline-m/", strftime("%m", $deadline), $data);
    $data = preg_replace("/\\%deadline-d/", strftime("%d", $deadline), $data);
    $data = preg_replace("/\\%B/", $row['balance'], $data);
    $data = preg_replace("/\\%saldo/", moneyf($row['balance']), $data);
    $data = preg_replace("/\\%pin/", $row['pin'], $data);
    $data = preg_replace("/\\%cid/", $row['id'], $data);
    if (preg_match("/\\%abonament/", $data)) {
        $saldo = $DB->GetOne("SELECT SUM(value)\n\t\t\tFROM assignments, tariffs\n\t\t\tWHERE tariffid = tariffs.id AND customerid = ?\n\t\t\t\tAND (datefrom <= {$currtime} OR datefrom = 0)\n\t\t\t\tAND (dateto > {$currtime} OR dateto = 0)\n\t\t\t\tAND ((datefrom < dateto) OR (datefrom = 0 AND datefrom = 0))", array($row['id']));
        $data = preg_replace("/\\%abonament/", $saldo, $data);
    }
    // invoices, debit notes
    $data = preg_replace("/\\%invoice/", $row['doc_number'], $data);
    $data = preg_replace("/\\%number/", $row['doc_number'], $data);
    $data = preg_replace("/\\%value/", $row['value'], $data);
    $data = preg_replace("/\\%cdate-y/", strftime("%Y", $row['cdate']), $data);
    $data = preg_replace("/\\%cdate-m/", strftime("%m", $row['cdate']), $data);
    $data = preg_replace("/\\%cdate-d/", strftime("%d", $row['cdate']), $data);
    list($now_y, $now_m) = explode('/', strftime("%Y/%m", time()));
    $data = preg_replace("/\\%lastday/", strftime("%d", mktime(12, 0, 0, $now_m + 1, 0, $now_y)), $data);
    return $data;
}
Example #21
0
function parse_customer_data($data, $row)
{
    $DB = LMSDB::getInstance();
    $amount = -$row['balance'];
    $totalamount = -$row['totalbalance'];
    $data = preg_replace("/\\%bankaccount/", format_bankaccount(bankaccount($row['id'], $row['account'])), $data);
    $data = preg_replace("/\\%b/", $amount, $data);
    $data = preg_replace("/\\%totalb/", $totalamount, $data);
    $data = preg_replace("/\\%date-y/", strftime("%Y"), $data);
    $data = preg_replace("/\\%date-m/", strftime("%m"), $data);
    $data = preg_replace("/\\%date_month_name/", strftime("%B"), $data);
    $deadline = $row['cdate'] + $row['paytime'] * 86400;
    $data = preg_replace("/\\%deadline-y/", strftime("%Y", $deadline), $data);
    $data = preg_replace("/\\%deadline-m/", strftime("%m", $deadline), $data);
    $data = preg_replace("/\\%deadline-d/", strftime("%d", $deadline), $data);
    $data = preg_replace("/\\%B/", $row['balance'], $data);
    $data = preg_replace("/\\%totalB/", $row['totalbalance'], $data);
    $data = preg_replace("/\\%saldo/", moneyf($row['balance']), $data);
    $data = preg_replace("/\\%totalsaldo/", moneyf($row['totalbalance']), $data);
    $data = preg_replace("/\\%pin/", $row['pin'], $data);
    $data = preg_replace("/\\%cid/", $row['id'], $data);
    if (preg_match("/\\%abonament/", $data)) {
        $saldo = $DB->GetOne("SELECT SUM(value)\n\t\t\tFROM assignments, tariffs\n\t\t\tWHERE tariffid = tariffs.id AND customerid = ?\n\t\t\t\tAND datefrom <= {$currtime} AND (dateto > {$currtime} OR dateto = 0)\n\t\t\t\tAND ((datefrom < dateto) OR (datefrom = 0 AND datefrom = 0))", array($row['id']));
        $data = preg_replace("/\\%abonament/", $saldo, $data);
    }
    if (preg_match("/\\%last_10_in_a_table/", $data)) {
        $last10 = $DB->GetAll("SELECT comment, value, time FROM cash WHERE\n\t\t\tcustomerid = ? ORDER BY time DESC LIMIT 10", array($row['id']));
        // ok, now we are going to rise up system's load
        $l10 = "-----------+-----------+----------------------------------------------------\n";
        foreach ($last10 as $row_s) {
            $op_time = strftime("%Y/%m/%d", $row_s['time']);
            $op_amount = sprintf("%9.2f", $row_s['value']);
            $for_what = sprintf("%-52s", $row_s['comment']);
            $l10 = $l10 . "{$op_time} | {$op_amount} | {$for_what}\n";
        }
        $l10 = $l10 . "-----------+-----------+----------------------------------------------------\n";
        $data = preg_replace("/\\%last_10_in_a_table/", $l10, $data);
    }
    // invoices, debit notes
    $data = preg_replace("/\\%invoice/", $row['doc_number'], $data);
    $data = preg_replace("/\\%number/", $row['doc_number'], $data);
    $data = preg_replace("/\\%value/", $row['value'], $data);
    $data = preg_replace("/\\%cdate-y/", strftime("%Y", $row['cdate']), $data);
    $data = preg_replace("/\\%cdate-m/", strftime("%m", $row['cdate']), $data);
    $data = preg_replace("/\\%cdate-d/", strftime("%d", $row['cdate']), $data);
    list($now_y, $now_m) = explode('/', strftime("%Y/%m", time()));
    $data = preg_replace("/\\%lastday/", strftime("%d", mktime(12, 0, 0, $now_m + 1, 0, $now_y)), $data);
    return $data;
}