Использовали скрипт для добавления списка тарифных планов и платежей за них в xslt договора
Код:
import org.w3c.dom.*;
import bitel.billing.server.tariff.voice.calc.*;
import bitel.billing.server.task.bean.*;
import java.math.*;
import ru.bitel.bgbilling.kernel.network.radius.*;
import bitel.billing.server.npay.bean.*;
import bitel.billing.server.npay.*;
import bitel.billing.server.tariff.TariffTreeSet.TariffSetEntry;
import ru.bitel.bgbilling.modules.npay.server.*;
import java.util.ArrayList;
import java.util.Collections;
import java.math.BigDecimal;
import java.sql.*;
import java.util.*;
import java.lang.*;
import bitel.billing.server.contract.bean.*;
import bitel.billing.server.tariff.*;
import bitel.billing.server.util.*;
import bitel.common.Utils.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.ArrayList;
public Node getVoipPrice( String cid )
{
//Список тиарифных планов
String[] alltariffs = new String[]{
"Симферополь (специальный) 2 Мбит/с"
};
//Стоимость всего
String[] alltacosts= new String[]{
"120,00 грн."
};
//Стоимость NDS
String[] alltacostsnds= new String[]{
"20.00 грн."
};
//Стоимость
String[] alltacostsbeznds= new String[]{
"100.00 грн."
};
//Инсталяция
String[] instal= new String[]{
"100",
};
String[] instalnds= new String[]{
"16,67",
};
String[] instalbeznds= new String[]{
"83,33",
};
//Инсталяция
Connection conn = null;
int st3r = Utils.parseIntString(cid);
String[] al = new String[10];
String userName = "bill";
String password = "bgbilling";
String url = "jdbc:mysql://localhost/bgbilling";
Class.forName ("com.mysql.jdbc.Driver").newInstance ();
conn = DriverManager.getConnection (url, userName, password);
Statement s = conn.createStatement();
ResultSet rs = s.executeQuery("SELECT tpid FROM contract_tariff WHERE cid='" +cid+ "' AND date2 is NULL;");
int i = 0;
while (rs.next()) {
al[i]=rs.getString(1);
i++;
}
doc = Utils.createDocument();
result = doc.createElement( "price" );
Element section = null;
Element section2 = null;
section2 = Utils.createElement( result, "section2" );
for(int x = 0; x < al.length ; x++)
{
if(al[x] == "" || al[x] == null)
{
}
else
{
Statement s2 = conn.createStatement();
ResultSet rs2 = s2.executeQuery("SELECT title FROM tariff_plan WHERE id='" +al[x]+ "';");
while (rs2.next())
{
String xz = rs2.getString(1);
section = Utils.createElement( result, "section" );
section.setAttribute( "title", xz);
for(int z = 0; z < alltariffs.length; z++)
{
if(xz.equals(alltariffs[z]))
{
section.setAttribute( "cost", alltacosts[z]);
section.setAttribute( "costnds", alltacostsnds[z]);
section.setAttribute( "costbeznds", alltacostsbeznds[z]);
}
}
}
}
}
Statement s3 = conn.createStatement();
ResultSet rs3 = s3.executeQuery(" SELECT val FROM contract_parameter_type_1 WHERE pid=36 AND cid="+cid+";");
while (rs3.next())
{
String mz = rs3.getString(1);
for(int e = 0; e < instal.length; e++)
{
if(mz.equals(instal[e]))
{
section2.setAttribute( "instalnds", instalnds[e] + " грн." );
section2.setAttribute( "instalbeznds", instalbeznds[e] + " грн.");
section2.setAttribute( "instal", instal[e] + ".00 грн.");
}
}
}
conn.close ();
Utils.serializeXML( result, System.out, "windows-1251" );
return result;
}
Вызывали так;
Код:
<xsl:for-each select="script:invoke('payment','getVoipPrice', $cid)/section2">
<fo:table-row>
<fo:table-cell border="0.2pt solid black" height="0.4cm">
<fo:block xsl:use-attribute-sets="text_table" space-before="0.1cm" text-align="left">
Инсталляция порта Интернет
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.2pt solid black" height="0.4cm">
<fo:block xsl:use-attribute-sets="text_table" space-before="0.1cm" text-align="center">
<xsl:value-of select="@instalbeznds"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.2pt solid black" height="0.4cm">
<fo:block xsl:use-attribute-sets="text_table" space-before="0.1cm" text-align="center">
<xsl:value-of select="@instalnds"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="0.2pt solid black" height="0.4cm">
<fo:block xsl:use-attribute-sets="text_table" space-before="0.1cm" text-align="center">
<xsl:value-of select="@instal"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
Перестал выводить данные, кто может дать подсказку по этому поводу?