<text x="15" y="250" style="font-size:1.8pt;">Please note: You can file a complaint regarding this issue within 3 months of receiption of this invoice in written form.</text>
<text x="15" y="255">More details can be found online at www.sipwise.net in My Account.</text>
foreachmy$provider_contract(@{$dbh->selectall_arrayref('select contracts.*,resellers.id as reseller_core_id from resellers inner join contracts on resellers.contract_id=contracts.id where resellers.status != "terminated"',{Slice=>{}})}){
foreachmy$provider_contract(@{$dbh->selectall_arrayref('select contracts.*,resellers.id as reseller_core_id from resellers inner join contracts on resellers.contract_id=contracts.id where resellers.status != "terminated"'.ify('and resellers.id',@{$opt->{reseller_id}}),{Slice=>{}},@{$opt->{reseller_id}})}){
my$provider_contact=$dbh->selectrow_hashref('select * from contacts where id=?',undef,$provider_contract->{contact_id});
foreachmy$client_contact(@{$dbh->selectall_arrayref('select contacts.* from contacts where reseller_id = ?',{Slice=>{}},$provider_contract->{reseller_core_id})}){
foreachmy$client_contact(@{$dbh->selectall_arrayref('select contacts.* from contacts where reseller_id = ?'.ify(' and contacts.id',@{$opt->{client_contact_id}}),{Slice=>{}},$provider_contract->{reseller_core_id},@{$opt->{client_contact_id}})}){
my$client_contract=$dbh->selectrow_hashref('select contracts.* from contracts where contracts.contact_id=? ',undef,$client_contact->{id});
if(!(my$contract_balance=$dbh->selectrow_hashref('select * from contract_balances where contract_id=? and date(start)=? and date(end)=?',undef,$client_contract->{id},$stime->ymd,$etime->ymd))){
$contract_balance=$dbh->selectrow_hashref('select * from contract_balances where id=?',undef,$dbh->last_insert_id(undef,'billing','contract_balances','id'));
}else{
if(!$contract_balance->{invoice_id}||!($invoice=$dbh->selectrow_hashref('select * from invoices where id=?',undef,$contract_balance->{invoice_id}))){
@ -146,24 +127,40 @@ foreach my $provider_contract( @{$dbh->selectall_arrayref('select contracts.*,re
invoice_details_calls=>$invoice_details_calls,
};
my$svg=$dbh->selectrow_array('select base64_saved from invoice_templates where is_active = 1 and type = "svg" and reseller_id=?',undef,$provider_contract->{reseller_core_id});
if(!($contract_balance=$dbh->selectrow_hashref('select * from contract_balances where contract_id=? and date(start)=? and date(end)=?',undef,$client_contract->{id},$stime->ymd,$etime->ymd))){
$contract_balance=$dbh->selectrow_hashref('select * from contract_balances where id=?',undef,$dbh->last_insert_id(undef,'billing','contract_balances','id'));
}else{
if(!$contract_balance->{invoice_id}||!($invoice=$dbh->selectrow_hashref('select * from invoices where id=?',undef,$contract_balance->{invoice_id}))){