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});
#according to /reseller/ajax_reseller_filter
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}})}){
foreachmy$client_contract(@{$dbh->selectall_arrayref('select contracts.* from contracts where contracts.contact_id=? ',{Slice=>{}},$client_contact->{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))){
@ -212,29 +225,36 @@ sub ify{
subemail{
#todo: repeat my old function based on templates and store into utils