Beispiel #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'])));
 }
Beispiel #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);
 }
Beispiel #3
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'])));
}
Beispiel #4
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);
}
Beispiel #5
0
    function GetCustomer($id)
    {
        if ($result = $this->DB->GetRow('SELECT c.*, ' . $this->DB->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername
	                                FROM customers c WHERE c.id = ?', array($id))) {
            $result['balance'] = $this->GetCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id']);
            $result['messengers'] = $this->DB->GetAllByKey('SELECT uid, type FROM imessengers WHERE customerid = ? ORDER BY type', 'type', array($id));
            $result['contacts'] = $this->DB->GetAllByKey('SELECT id, phone, name FROM customercontacts WHERE customerid = ? ORDER BY id', 'id', array($id));
            return $result;
        } else {
            return NULL;
        }
    }
Beispiel #6
0
    public function GetCustomer($id, $short = false)
    {
        if ($result = $this->DB->GetRow('SELECT c.*, ' . $this->DB->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername
			FROM customers c WHERE c.id = ?', array($id))) {
            $result['balance'] = $this->GetCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id']);
            $result['messengers'] = $this->DB->GetAllByKey('SELECT uid, type FROM imessengers WHERE customerid = ? ORDER BY type', 'type', array($id));
            $result['contacts'] = $this->DB->GetAllByKey('SELECT id, contact AS phone, name
				FROM customercontacts WHERE customerid = ? AND type < ? ORDER BY id', 'id', array($id, CONTACT_MOBILE));
            $result['emails'] = $this->DB->GetAllByKey('SELECT id, contact AS email, name
				FROM customercontacts WHERE customerid = ? AND (type & ? > 0) ORDER BY id', 'id', array($id, CONTACT_EMAIL | CONTACT_INVOICES | CONTACT_NOTIFICATIONS));
            return $result;
        } else {
            return NULL;
        }
    }
Beispiel #7
0
    public function GetCustomer($id, $short = false)
    {
        if ($result = $this->DB->GetRow('SELECT c.*, ' . $this->DB->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername
			FROM customeraddressview c WHERE c.id = ?', array($id))) {
            $result['balance'] = $this->GetCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id']);
            $result['messengers'] = $this->DB->GetAllByKey('SELECT uid, type FROM imessengers WHERE customerid = ? ORDER BY type', 'type', array($id));
            $result['contacts'] = $this->DB->GetAllByKey('SELECT id, contact AS phone, name
				FROM customercontacts WHERE customerid = ? AND (type & ?) > 0 AND (type & ?) = 0
				ORDER BY id', 'id', array($id, CONTACT_MOBILE | CONTACT_FAX | CONTACT_LANDLINE, CONTACT_DISABLED));
            $result['emails'] = $this->DB->GetAllByKey('SELECT id, contact AS email, name
				FROM customercontacts WHERE customerid = ? AND (type & ?) > 0 AND (type & ?) = 0
				ORDER BY id', 'id', array($id, CONTACT_EMAIL | CONTACT_DISABLED, CONTACT_DISABLED));
            $result['accounts'] = $this->DB->GetAllByKey('SELECT id, contact AS account, name
				FROM customercontacts WHERE customerid = ? AND (type & ?) = ? ORDER BY id', 'id', array($id, CONTACT_BANKACCOUNT | CONTACT_INVOICES | CONTACT_DISABLED, CONTACT_BANKACCOUNT | CONTACT_INVOICES));
            return $result;
        } else {
            return NULL;
        }
    }
Beispiel #8
0
function simple_fill_mip($x,$y,$scale)
{
    global $pdf,$_NAME,$_ADDRESS,$_ZIP,$_CITY,$_SHORT_NAME,$control_lines,$invoice;

    if ($control_lines) {
        $pdf->line(7*$scale+$x,180*$scale+$y,7*$scale+$x,210*$scale+$y);
	$pdf->line(7*$scale+$x,180*$scale+$y,37*$scale+$x,180*$scale+$y);
        $pdf->line(370*$scale+$x,180*$scale+$y,370*$scale+$x,210*$scale+$y);
	$pdf->line(370*$scale+$x,180*$scale+$y,340*$scale+$x,180*$scale+$y);
        $pdf->line(7*$scale+$x,726*$scale+$y,7*$scale+$x,696*$scale+$y);
	$pdf->line(7*$scale+$x,726*$scale+$y,37*$scale+$x,726*$scale+$y);
        $pdf->line(370*$scale+$x,726*$scale+$y,370*$scale+$x,696*$scale+$y);
	$pdf->line(370*$scale+$x,726*$scale+$y,340*$scale+$x,726*$scale+$y);
    }
    $pdf->addtext(15*$scale+$x,560*$scale+$y,30*$scale, iconv('UTF-8', 'ISO-8859-2',$_SHORT_NAME));
    $pdf->addtext(15*$scale+$x,525*$scale+$y,30*$scale, iconv('UTF-8', 'ISO-8859-2',$_ADDRESS));
    $pdf->addtext(15*$scale+$x,490*$scale+$y,30*$scale, iconv('UTF-8', 'ISO-8859-2',$_ZIP." ".$_CITY));
    $pdf->addtext(15*$scale+$x,680*$scale+$y,30*$scale, substr(bankaccount($invoice['customerid'], $invoice['account']),0,17));
    $pdf->addtext(15*$scale+$x,620*$scale+$y,30*$scale, substr(bankaccount($invoice['customerid'], $invoice['account']),18,200));
    $pdf->addtext(15*$scale+$x,435*$scale+$y,30*$scale,'**'.number_format($invoice['total'],2,',','').'**');
    //$pdf->addtext(15*$scale+$x,310*$scale+$y,30*$scale,$invoice['name']);

    $font_size=30;
    while ($pdf->getTextWidth($font_size*$scale, iconv('UTF-8', 'ISO-8859-2',$invoice['name']))>135)
	$font_size=$font_size-1;    
    $pdf->addtext(15*$scale+$x,310*$scale+$y,$font_size*$scale, iconv('UTF-8', 'ISO-8859-2',$invoice['name']));
    $font_size=30;
    while ($pdf->getTextWidth($font_size*$scale, iconv('UTF-8', 'ISO-8859-2',$invoice['address']))>135)
	$font_size=$font_size-1;    
    $pdf->addtext(15*$scale+$x,275*$scale+$y,$font_size*$scale, iconv('UTF-8', 'ISO-8859-2',$invoice['address']));
    $pdf->addtext(15*$scale+$x,240*$scale+$y,30*$scale, iconv('UTF-8', 'ISO-8859-2',$invoice['zip']." ".$invoice['city']));

    $font_size=30;
    while ($pdf->getTextWidth($font_size*$scale,trans('Invoice No. $a', $invoice['t_number']))>135)
	$font_size=$font_size-1;    
    $pdf->addtext(15*$scale+$x,385*$scale+$y,$font_size*$scale,trans('Invoice No. $a', $invoice['t_number']));

}
 protected function simple_fill_mip($x, $y, $scale)
 {
     if (ConfigHelper::checkConfig('finances.control_lines')) {
         $this->backend->line(7 * $scale + $x, 180 * $scale + $y, 7 * $scale + $x, 210 * $scale + $y);
         $this->backend->line(7 * $scale + $x, 180 * $scale + $y, 37 * $scale + $x, 180 * $scale + $y);
         $this->backend->line(370 * $scale + $x, 180 * $scale + $y, 370 * $scale + $x, 210 * $scale + $y);
         $this->backend->line(370 * $scale + $x, 180 * $scale + $y, 340 * $scale + $x, 180 * $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(370 * $scale + $x, 726 * $scale + $y, 370 * $scale + $x, 696 * $scale + $y);
         $this->backend->line(370 * $scale + $x, 726 * $scale + $y, 340 * $scale + $x, 726 * $scale + $y);
     }
     $this->backend->addtext(15 * $scale + $x, 560 * $scale + $y, 30 * $scale, $this->data['d_shortname']);
     $this->backend->addtext(15 * $scale + $x, 525 * $scale + $y, 30 * $scale, $this->data['d_address']);
     $this->backend->addtext(15 * $scale + $x, 490 * $scale + $y, 30 * $scale, $this->data['d_zip'] . ' ' . $this->data['d_city']);
     $this->backend->addtext(15 * $scale + $x, 680 * $scale + $y, 30 * $scale, substr(bankaccount($this->data['id'], $this->data['account']), 0, 17));
     $this->backend->addtext(15 * $scale + $x, 620 * $scale + $y, 30 * $scale, substr(bankaccount($this->data['id'], $this->data['account']), 18, 200));
     $this->backend->addtext(15 * $scale + $x, 435 * $scale + $y, 30 * $scale, '**' . number_format($this->data['total'], 2, ',', '') . '**');
     //		$this->backend->addtext(15 * $scale + $x, 310 * $scale+$y, 30 * $scale, $this->data['name']);
     $font_size = 30;
     while ($this->backend->getTextWidth($font_size * $scale, $this->data['name']) > 135) {
         $font_size -= 1;
     }
     $this->backend->addtext(15 * $scale + $x, 310 * $scale + $y, $font_size * $scale, $this->data['name']);
     $font_size = 30;
     while ($this->backend->getTextWidth($font_size * $scale, $this->data['address']) > 135) {
         $font_size -= 1;
     }
     $this->backend->addtext(15 * $scale + $x, 275 * $scale + $y, $font_size * $scale, $this->data['address']);
     $this->backend->addtext(15 * $scale + $x, 240 * $scale + $y, 30 * $scale, $this->data['zip'] . ' ' . $this->data['city']);
     $font_size = 30;
     while ($this->backend->getTextWidth($font_size * $scale, trans('Invoice No. $a', $this->data['t_number'])) > 135) {
         $font_size -= 1;
     }
     $this->backend->addtext(15 * $scale + $x, 385 * $scale + $y, $font_size * $scale, trans('Invoice No. $a', $this->data['t_number']));
 }
    /**
     * Returns customer data
     * 
     * @global array $CONTACTTYPES
     * @param int $id Customer id
     * @param boolean $short Basic or expanded data
     * @return array|boolean Customer data or false on failure
     */
    public function GetCustomer($id, $short = false)
    {
        global $CONTACTTYPES;
        if ($result = $this->db->GetRow('SELECT c.*, ' . $this->db->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername,
			d.shortname AS division, d.account
			FROM customers' . (defined('LMS-UI') ? 'view' : '') . ' c 
			LEFT JOIN divisions d ON (d.id = c.divisionid)
			WHERE c.id = ?', array($id))) {
            if (!$short) {
                $user_manager = new LMSUserManager($this->db, $this->auth, $this->cache, $this->syslog);
                $result['createdby'] = $user_manager->getUserName($result['creatorid']);
                $result['modifiedby'] = $user_manager->getUserName($result['modid']);
                $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
                $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
                $result['consentdate'] = $result['consentdate'] ? date('Y/m/d', $result['consentdate']) : '';
                $result['up_logins'] = $this->db->GetRow('SELECT lastlogindate, lastloginip, 
					failedlogindate, failedloginip
					FROM up_customers WHERE customerid = ?', array($result['id']));
                // Get country name
                if ($result['countryid']) {
                    $result['country'] = $this->db->GetOne('SELECT name FROM countries WHERE id = ?', array($result['countryid']));
                    if ($result['countryid'] == $result['post_countryid']) {
                        $result['post_country'] = $result['country'];
                    } else {
                        if ($result['post_countryid']) {
                            $result['country'] = $this->db->GetOne('SELECT name FROM countries WHERE id = ?', array($result['post_countryid']));
                        }
                    }
                }
                // Get state name
                if ($cstate = $this->db->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['zip']))) {
                    $result['stateid'] = $cstate['id'];
                    $result['cstate'] = $cstate['name'];
                }
                if ($result['zip'] == $result['post_zip']) {
                    $result['post_stateid'] = $result['stateid'];
                    $result['post_cstate'] = $result['cstate'];
                } else {
                    if ($result['post_zip'] && ($cstate = $this->db->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['post_zip'])))) {
                        $result['post_stateid'] = $cstate['id'];
                        $result['post_cstate'] = $cstate['name'];
                    }
                }
            }
            $result['balance'] = $this->getCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id'], $result['account']);
            $result['messengers'] = $this->db->GetAllByKey('SELECT uid, type 
					FROM imessengers WHERE customerid = ? ORDER BY type', 'type', array($result['id']));
            $result['contacts'] = $this->db->GetAll('SELECT contact AS phone, name, type
					FROM customercontacts
					WHERE customerid = ? AND type < ? ORDER BY id', array($result['id'], CONTACT_EMAIL));
            $result['emails'] = $this->db->GetAll('SELECT contact AS email, name
					FROM customercontacts
					WHERE customerid = ? AND type = ? ORDER BY id', array($result['id'], CONTACT_EMAIL));
            if (is_array($result['contacts'])) {
                foreach ($result['contacts'] as $idx => $row) {
                    $types = array();
                    foreach ($CONTACTTYPES as $tidx => $tname) {
                        if ($row['type'] & $tidx) {
                            $types[] = $tname;
                        }
                    }
                    if ($types) {
                        $result['contacts'][$idx]['typestr'] = implode('/', $types);
                    }
                }
            }
            return $result;
        } else {
            return false;
        }
    }
Beispiel #11
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');
    }
}
Beispiel #12
0
    /**
     * Returns customer data
     *
     * @global array $CONTACTTYPES
     * @param int $id Customer id
     * @param boolean $short Basic or expanded data
     * @return array|boolean Customer data or false on failure
     */
    public function GetCustomer($id, $short = false)
    {
        global $CONTACTTYPES, $CUSTOMERCONTACTTYPES;
        require_once LIB_DIR . DIRECTORY_SEPARATOR . 'customercontacttypes.php';
        if ($result = $this->db->GetRow('SELECT c.*, ' . $this->db->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername,
			d.shortname AS division, d.account
			FROM customer' . (defined('LMS-UI') ? '' : 'address') . 'view c
			LEFT JOIN divisions d ON (d.id = c.divisionid)
			WHERE c.id = ?', array($id))) {
            if (!$short) {
                $user_manager = new LMSUserManager($this->db, $this->auth, $this->cache, $this->syslog);
                $result['createdby'] = $user_manager->getUserName($result['creatorid']);
                $result['modifiedby'] = $user_manager->getUserName($result['modid']);
                $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
                $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
                $result['consentdate'] = $result['consentdate'] ? date('Y/m/d', $result['consentdate']) : '';
                $result['up_logins'] = $this->db->GetRow('SELECT lastlogindate, lastloginip,
					failedlogindate, failedloginip
					FROM up_customers WHERE customerid = ?', array($result['id']));
                // Get country name
                if ($result['countryid']) {
                    $result['country'] = $this->db->GetOne('SELECT name FROM countries WHERE id = ?', array($result['countryid']));
                    if ($result['countryid'] == $result['post_countryid']) {
                        $result['post_country'] = $result['country'];
                    } else {
                        if ($result['post_countryid']) {
                            $result['country'] = $this->db->GetOne('SELECT name FROM countries WHERE id = ?', array($result['post_countryid']));
                        }
                    }
                }
                // Get state name
                if ($cstate = $this->db->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['zip']))) {
                    $result['stateid'] = $cstate['id'];
                    $result['cstate'] = $cstate['name'];
                }
                if ($result['zip'] == $result['post_zip']) {
                    $result['post_stateid'] = $result['stateid'];
                    $result['post_cstate'] = $result['cstate'];
                } else {
                    if ($result['post_zip'] && ($cstate = $this->db->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['post_zip'])))) {
                        $result['post_stateid'] = $cstate['id'];
                        $result['post_cstate'] = $cstate['name'];
                    }
                }
            }
            $result['balance'] = $this->getCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id'], $result['account']);
            foreach ($CUSTOMERCONTACTTYPES as $contacttype => $properties) {
                $result[$contacttype . 's'] = $this->db->GetAll('SELECT contact AS ' . $contacttype . ',
						contact, name, type
					FROM customercontacts
					WHERE customerid = ? AND type & ? > 0 ORDER BY id', array($result['id'], $properties['flagmask']));
            }
            $result['sendinvoices'] = false;
            foreach (array_keys($CUSTOMERCONTACTTYPES) as $ctype) {
                $customercontacttype = $CUSTOMERCONTACTTYPES[$ctype];
                $ctype .= 's';
                if (is_array($result[$ctype])) {
                    foreach ($result[$ctype] as $idx => $row) {
                        $types = array();
                        foreach ($CONTACTTYPES as $tidx => $tname) {
                            if ($row['type'] & $tidx && isset($customercontacttype['ui']['flags'][$row['type'] & $tidx])) {
                                $types[] = $tname;
                            }
                        }
                        if (isset($customercontacttype['ui']['typeselectors'])) {
                            $result[$ctype][$idx]['typeselector'] = $tidx;
                        }
                        if ($ctype == 'emails' && ($row['type'] & (CONTACT_INVOICES | CONTACT_DISABLED)) == CONTACT_INVOICES) {
                            $result['sendinvoices'] = true;
                        }
                        if ($types) {
                            $result[$ctype][$idx]['typestr'] = implode('/', $types);
                        }
                    }
                }
            }
            $result['contacts'] = $result['phones'];
            if (empty($result['invoicenotice'])) {
                $result['sendinvoices'] = false;
            }
            return $result;
        } else {
            return false;
        }
    }
Beispiel #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');
}
Beispiel #14
0
Datei: note.php Projekt: 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);
Beispiel #15
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');
	}
}
Beispiel #16
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");
         }
     }
 }
Beispiel #17
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;
        }
    }
Beispiel #18
0
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
 *  USA.
 *
 *  $Id$
 */
global $LMS, $CONFIG, $SESSION;
$customer = $LMS->GetCustomer($SESSION->id);
$division = $LMS->DB->GetRow('SELECT account, name, address, zip, city
	FROM divisions WHERE id = ?', array($customer['divisionid']));
//  NRB 26 cyfr: 2 kontrolne, 8 nr banku, 16 nr konta
$KONTO_DO = bankaccount($customer['id'], $division['account']);
if ($division) {
    list($division['name']) = explode("\n", $division['name']);
    $ISP1_DO = $division['name'];
    $ISP2_DO = trim($division['zip'] . ' ' . $division['city'] . ' ' . $division['address']);
} else {
    if (!empty($CONFIG['finances']['line_1'])) {
        $ISP1_DO = $CONFIG['finances']['line_1'];
    }
    if (!empty($CONFIG['finances']['line_2'])) {
        $ISP2_DO = $CONFIG['finances']['line_2'];
    }
}
$USER_T1 = !isset($CONFIG['finances']['pay_title']) ? 'Abonament - ID:%CID% %LongCID%' : iconv('UTF-8', 'ISO-8859-2', $CONFIG['finances']['pay_title']);
$CURR = 'PLN';
$SHORT_TO_WORDS = check_conf('phpui.to_words_short_version');
Beispiel #19
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;
}
Beispiel #20
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");
        }
    }
}
Beispiel #21
0
    function GetCustomer($id, $short = false)
    {
        global $CONTACTTYPES;
        if ($result = $this->DB->GetRow('SELECT c.*, ' . $this->DB->Concat('UPPER(c.lastname)', "' '", 'c.name') . ' AS customername,
			(SELECT co.name FROM customerorigin co WHERE co.id = c.origin) AS originname, 
			d.shortname AS division, d.account
			FROM customers' . (defined('LMS-UI') ? 'view' : '') . ' c 
			LEFT JOIN divisions d ON (d.id = c.divisionid)
			WHERE c.id = ?', array($id))) {
            if (!$short) {
                $result['createdby'] = $this->GetUserName($result['creatorid']);
                $result['modifiedby'] = $this->GetUserName($result['modid']);
                $result['creationdateh'] = date('Y/m/d, H:i', $result['creationdate']);
                $result['moddateh'] = date('Y/m/d, H:i', $result['moddate']);
                $result['consentdate'] = $result['consentdate'] ? date('Y/m/d', $result['consentdate']) : '';
                $result['up_logins'] = $this->DB->GetRow('SELECT lastlogindate, lastloginip, 
					failedlogindate, failedloginip
					FROM up_customers WHERE customerid = ?', array($result['id']));
                // Get country name
                if ($result['countryid']) {
                    $result['country'] = $this->DB->GetOne('SELECT name FROM countries WHERE id = ?', array($result['countryid']));
                    if ($result['countryid'] == $result['post_countryid']) {
                        $result['post_country'] = $result['country'];
                    } else {
                        if ($result['post_countryid']) {
                            $result['post_country'] = $this->DB->GetOne('SELECT name FROM countries WHERE id = ?', array($result['post_countryid']));
                        }
                    }
                    if ($result['countryid'] == $result['invoice_countryid']) {
                        $result['invoice_country'] = $result['country'];
                    } else {
                        if ($result['invoice_countryid']) {
                            $result['invoice_country'] = $this->DB->GetOne('SELECT name FROM countries WHERE id = ?', array($result['invoice_countryid']));
                        }
                    }
                }
                // Get state name
                if ($cstate = $this->DB->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['zip']))) {
                    $result['stateid'] = $cstate['id'];
                    $result['cstate'] = $cstate['name'];
                }
                if ($result['zip'] == $result['post_zip']) {
                    $result['post_stateid'] = $result['stateid'];
                    $result['post_cstate'] = $result['cstate'];
                } else {
                    if ($result['post_zip'] && ($cstate = $this->DB->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['post_zip'])))) {
                        $result['post_stateid'] = $cstate['id'];
                        $result['post_cstate'] = $cstate['name'];
                    }
                }
                if ($result['zip'] == $result['invoice_zip']) {
                    $result['invoice_stateid'] = $result['stateid'];
                    $result['invoice_cstate'] = $result['cstate'];
                } else {
                    if ($result['invoice_zip'] && ($cstate = $this->DB->GetRow('SELECT s.id, s.name
					FROM states s, zipcodes
					WHERE zip = ? AND stateid = s.id', array($result['invoice_zip'])))) {
                        $result['invoice_stateid'] = $cstate['id'];
                        $result['invoice_cstate'] = $cstate['name'];
                    }
                }
            }
            $result['balance'] = $this->GetCustomerBalance($result['id']);
            $result['bankaccount'] = bankaccount($result['id'], $result['account']);
            $result['messengers'] = $this->DB->GetAllByKey('SELECT uid, type 
					FROM imessengers WHERE customerid = ? ORDER BY type', 'type', array($result['id']));
            $result['contacts'] = $this->DB->GetAll('SELECT phone, name, type
					FROM customercontacts WHERE customerid = ? ORDER BY id', array($result['id']));
            if (is_array($result['contacts'])) {
                foreach ($result['contacts'] as $idx => $row) {
                    $types = array();
                    foreach ($CONTACTTYPES as $tidx => $tname) {
                        if ($row['type'] & $tidx) {
                            $types[] = $tname;
                        }
                    }
                    if ($types) {
                        $result['contacts'][$idx]['typestr'] = implode('/', $types);
                    }
                }
            }
            if (get_conf('voip.enabled', '0') && $this->DB->GetOne('SELECT 1 FROM v_exportedusers WHERE lmsid = ?', array($result['id']))) {
                $result['isvoip'] = 1;
            }
            return $result;
        } else {
            return FALSE;
        }
    }
Beispiel #22
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');
     }
 }
Beispiel #23
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);
    }
}
Beispiel #24
0
function smarty_function_bankaccount($params, $template)
{
    return bankaccount($params['id'], $params['account']);
}
Beispiel #25
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;
}