Skip to content

Commit

Permalink
Merge branch 'master' of github.com:lmsgit/lms
Browse files Browse the repository at this point in the history
  • Loading branch information
chilek committed Mar 3, 2017
2 parents aec9e25 + 716e36e commit 88da850
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 12 deletions.
2 changes: 1 addition & 1 deletion img/lms-ui-iconselectmenu.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2016 LMS Developers
* (C) Copyright 2001-2017 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
Expand Down
19 changes: 17 additions & 2 deletions lib/LMSManagers/LMSFinanceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -517,6 +517,19 @@ public function AddInvoice($invoice)
account, inv_header, inv_footer, inv_author, inv_cplace
FROM vdivisions WHERE id = ? ;', array($invoice['customer']['divisionid']));

// if isset invoice recipient address then make copy of selected address
if ( !empty($invoice['invoice']['recipient_address_id']) ) {
$addr = $this->db->GetRow('SELECT * FROM addresses WHERE id = ?;', array($invoice['invoice']['recipient_address_id']));
unset($addr['id']);

$copy_address_query = "INSERT INTO addresses (" . implode(",", array_keys($addr)) . ") VALUES (" . implode(",", array_fill(0, count($addr), '?')) . ")";
$this->db->Execute( $copy_address_query, $addr );

$invocie['invoice']['recipient_address_id'] = $this->db->GetLastInsertID('addresses');
} else {
$invocie['invoice']['recipient_address_id'] = null;
}

$args = array(
'number' => $number,
SYSLOG::RES_NUMPLAN => $invoice['invoice']['numberplanid'] ? $invoice['invoice']['numberplanid'] : 0,
Expand Down Expand Up @@ -549,14 +562,16 @@ public function AddInvoice($invoice)
'div_inv_author' => ($division['inv_author'] ? $division['inv_author'] : ''),
'div_inv_cplace' => ($division['inv_cplace'] ? $division['inv_cplace'] : ''),
'fullnumber' => $fullnumber,
'recipient_address_id' => $invocie['invoice']['recipient_address_id']
);

$this->db->Execute('INSERT INTO documents (number, numberplanid, type,
cdate, sdate, paytime, paytype, userid, customerid, name, address,
ten, ssn, zip, city, countryid, divisionid,
div_name, div_shortname, div_address, div_city, div_zip, div_countryid, div_ten, div_regon,
div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
div_account, div_inv_header, div_inv_footer, div_inv_author, div_inv_cplace, fullnumber,
recipient_address_id)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)', array_values($args));
$iid = $this->db->GetLastInsertID('documents');
if ($this->syslog) {
unset($args[SYSLOG::RES_USER]);
Expand Down
1 change: 1 addition & 0 deletions lib/locale/pl/strings.php
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,7 @@
$_LANG['billing address'] = 'adres klienta';
$_LANG['default location address'] = 'domyślny adres lokalizacyjny';
$_LANG['location/recipient'] = 'lokalizacja/odbiorca';
$_LANG['Recipient address:'] = 'Adres odbiorcy';
$_LANG['Add assignment'] = 'Dodaj powiązanie';
$_LANG['Add promotion'] = 'Dodaj promocję';
$_LANG['Are you sure, you want to delete this assignment?'] = 'Czy na pewno chcesz usunąć to powiązanie?';
Expand Down
2 changes: 1 addition & 1 deletion modules/documentgen.php
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;',array($gencust['divisionid']));
FROM vdivisions WHERE id = ? ;',array($gencust['divisionid']));

if ($customernumtemplate)
$document['number'] = $LMS->GetNewDocumentNumber(array(
Expand Down
2 changes: 1 addition & 1 deletion modules/invoiceedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;',array($customer['divisionid']));
FROM vdivisions WHERE id = ? ;',array($customer['divisionid']));

if (!$invoice['number'])
$invoice['number'] = $LMS->GetNewDocumentNumber(array(
Expand Down
2 changes: 1 addition & 1 deletion modules/invoicenew.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
/*
* LMS version 1.11-git
*
* (C) Copyright 2001-2016 LMS Developers
* (C) Copyright 2001-2017 LMS Developers
*
* Please, see the doc/AUTHORS for more information about authors!
*
Expand Down
2 changes: 1 addition & 1 deletion modules/invoicenote.php
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ?',
FROM vdivisions WHERE id = ?',
array(!empty($cnote['use_current_division']) ? $invoice['current_divisionid'] : $invoice['divisionid']));

if ($cnote['numberplanid'])
Expand Down
2 changes: 1 addition & 1 deletion modules/invoicenoteedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ?', array($customer['divisionid']));
FROM vdivisions WHERE id = ?', array($customer['divisionid']));

$args = array(
'cdate' => $cdate,
Expand Down
2 changes: 1 addition & 1 deletion modules/noteadd.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;',array($customer['divisionid']));
FROM vdivisions WHERE id = ? ;',array($customer['divisionid']));

if ($note['numberplanid'])
$fullnumber = docnumber(array(
Expand Down
2 changes: 1 addition & 1 deletion modules/noteedit.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@

$division = $DB->GetRow('SELECT name, shortname, address, city, zip, countryid, ten, regon,
account, inv_header, inv_footer, inv_author, inv_cplace
FROM divisions WHERE id = ? ;',array($customer['divisionid']));
FROM vdivisions WHERE id = ? ;',array($customer['divisionid']));

if ($note['numberplanid'])
$fullnumber = docnumber(array(
Expand Down
56 changes: 54 additions & 2 deletions templates/default/invoice/invoicenew.html
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,15 @@ <H1>{$layout.pagetitle}</H1>
{trans("Customer:")}
</TD>
<TD class="nobr">
{customerlist form="setcustomer" customers=$customers selected=$customerid selectname="customer" inputname="customerid" customOnChange="GetNumberPlans()"}
{customerlist form="setcustomer" customers=$customers selected=$customerid selectname="customer" inputname="customerid" customOnChange="GetNumberPlans()" select_id="ownerid_select" input_id="ownerid_input"}
</TD>
</TR>
<tr>
<td class="bold">{trans("Recipient address:")}</td>
<td>
<select id="customer_addresses" name="invoice[recipient_address_id]"></select>
</td>
</tr>
<TR>
<TD class="text-right" colspan="2">
<A href="javascript:saveheader();">{trans("Submit")} <IMG src="img/save.gif" alt=""></A>
Expand Down Expand Up @@ -416,10 +422,56 @@ <H1>{$layout.pagetitle}</H1>
</FORM>
{/if}

<script type="text/javascript" src="img/lms-ui-iconselectmenu.js"></script>
<SCRIPT type="text/javascript">
<!--
$(function() {
$('form[name="setcustomer"] [name="invoice[number]"]').focus();
var customer_addresses = new LmsUiIconSelectMenu( "#customer_addresses" );
var timer;

$('form[name="setcustomer"] [name="invoice[number]"]').focus();

/*!
* \brief Update customer addresses list on input change.
*/
$( '#ownerid_input' ).on('keyup input paste', function() {
var id = $(this).val();

if ( id != 'undefined' && id > 0 ) {
// delay for send request, 250ms
clearTimeout( timer );
timer = setTimeout( function() { customer_addresses.setAddressList( getCustomerAddresses(id) ); }, 250);
}
});

/*!
* \brief On keydown, clear the countdown.
*/
$( '#ownerid_input' ).on('keydown', function () {
clearTimeout(timer);
});

{if !ConfigHelper::checkConfig('phpui.big_networks')}
/*!
* \brief Update customer addresses list on select change.
* Using when big_networks is set as false.
*/
$( '#ownerid_select' ).change( function() {
var id = $(this).val();

if ( id != 'undefined' && id > 0 ) {
customer_addresses.setAddressList( getCustomerAddresses(id) );
}
});
{/if}

customer_addresses.setAddressList( getCustomerAddresses( {intval($invoice.customerid)} ) );

{if $invoice.customerid && $invoice.recipient_address_id }
$( '#customer_addresses' ).val( {$invoice.recipient_address_id} );
{/if}

customer_addresses.init();
});
//-->
</SCRIPT>
Expand Down

0 comments on commit 88da850

Please sign in to comment.