Carlos Eduardo
|
|
Good Day for all. Im with new problem. The connection parsed but i has this return message from system: Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_query() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1 Warning: sqlsrv_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\NetMake\v81\wwwroot\KoolPHPSuite\KoolControls\KoolPivotTable\koolpivottable.php on line 1
|
|
Carlos Eduardo
|
|
|
|
Peter
|
|
Hi Carlos, Could you please tell me: 1. What is your PHP version? 2. Have you tested the sqlsrv_connect() to see if can connect to your SQL Server. You may try to pull some data from the same connection to test if it work well. Please send us some code so we can reproduce issue.
|
|
Carlos Eduardo
|
|
Good day for you. Thank you so much. Version of PHP: 5.6.8 My complete code is: ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ <?php /* * This file is ready to run as standalone example. However, please do: * 1. Add tags <html><head><body> to make a complete page * 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder */ $KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder require $KoolControlsFolder."/KoolAjax/koolajax.php"; $koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax"; require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php"; if(isset($_POST["style_select"])) { $_SESSION["style_select"] = $_POST["style_select"]; } else { if (!$koolajax->isCallback) { //Page Init: show default style $_SESSION["style_select"] = "default"; } } $dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host $db = "IOCP"; #Nome do banco de dados $user = "sa"; #Nome do usuário $password = "INTELLITI"; #Senha do usuário // Dados da tabela $tabela = "nometabela"; #Nome da tabela $campo1 = "campo1tabela"; #Nome do campo da tabela $campo2 = "campo2tabela"; #Nome de outro campo da tabela $conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password); $db_con = sqlsrv_connect($dbhost, $conninfo); /*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/ $ds = new SQLSRVPivotDataSource($db_con); //$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php //$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO") // ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA"); $ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO") ->from("DM_ESTRUTURA_MERCADOLOGICA"); $pivot = new KoolPivotTable("pivot"); $pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable"; $pivot->styleFolder = $_SESSION["style_select"]; $pivot->DataSource = $ds; //Turn on ajax features. $pivot->AjaxEnabled = true; //Set the Width of pivot and use horizontal scrolling $pivot->Width = "900px"; $pivot->HorizontalScrolling = true; //Set the Height of pivot and use Vertical Scrolling $pivot->Height = "400px"; $pivot->VerticalScrolling = true; //Allow filtering $pivot->AllowFiltering = true; //Allow sorting $pivot->AllowSorting = true; //Allow reordering $pivot->AllowReorder = true; //Make the RowHeader wider. $pivot->Appearance->RowHeaderMinWidth = "250px"; //Use the Prev and Next Numneric Pager $pivot->Pager = new PivotPrevNextAndNumericPager(); $pivot->Pager->PageSize = 20; //Turn on caching to help pivot working faster. $pivot->AllowCaching = true; $pivot->CssClasses = array( 'data cell' => 'text-right', // 'field' => 'rtl', // 'column header' => 'text-right', // 'row header' => 'rtl', // 'filter panel' => 'rtl' ); //Data Field $field = new PivotSumField("PRECO_VENDA"); $field->Text = "Preço de Venda"; $field->FormatString = "\${n}"; $field->AllowReorder = false; $pivot->AddDataField($field); $field = new PivotSumField("PRECO_CUSTO"); $field->Text = "Preço de Custo"; $field->FormatString = "\${n}"; $field->AllowReorder = false; $pivot->AddDataField($field); //Row Fields $field = new PivotField("CANAL"); $field->Text = "Canal de Vendas"; $pivot->AddRowField($field); //Column Fields $field = new PivotField("NEM01"); $field->Text = "Hierarquia Nível 01"; $pivot->AddColumnField($field); $field = new PivotField("NEM02"); $field->Text = "Hierarquia Nível 02"; $pivot->AddColumnField($field); $field = new PivotField("NEM03"); $field->Text = "Hierarquia Nível 03"; $pivot->AddColumnField($field); //Process the pivot $pivot->Process(); ?> <form id="form1" method="post"> <?php echo $koolajax->Render();?> Select style: <select id="style_select" name="style_select" onchange="submit();"> <option value="default" <?php if ($_SESSION["style_select"]=="default") echo "selected" ?> >Default</option> <option value="office2007" <?php if ($_SESSION["style_select"]=="office2007") echo "selected" ?> >Office2007</option> </select> <div style="padding-top:10px;"> <?php echo $pivot->Render();?> </div> </form> ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
|
David
|
|
Hi Carlos, I think there was a problem with your sqlsrv connection so the query could not be processed. Please add the following lines to your code to see if you created a successful connection: $dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));
}
|
|
Carlos Eduardo
|
|
Tks for you answer. Connection could not be established. Array ( [0] => Array ( [0] => IMSSP [SQLSTATE] => IMSSP [1] => -49 [code] => -49 [2] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 [message] => This extension requires the Microsoft ODBC Driver 11 for SQL Server. Access the following URL to download the ODBC Driver 11 for SQL Server for x86: http://go.microsoft.com/fwlink/?LinkId=163712 ) [1] => Array ( [0] => IM002 [SQLSTATE] => IM002 [1] => 0 [code] => 0 [2] => [Microsoft][ODBC Driver Manager] Nome da fonte de dados n�o encontrado e nenhum driver padr�o especificado [message] => [Microsoft][ODBC Driver Manager] Nome da fonte de dados n�o encontrado e nenhum driver padr�o especificado ) ) But ... Im using a similar connection into the scriptcase that is a PHP framework ... and ... on the same server ...
|
|
Carlos Eduardo
|
|
I just update the version of Microsoft PHP Drive and work ... But I noticed that the pivot does not give the refresh when doing the drag and drop:
|
|
Carlos Eduardo
|
|
When do a drag and drop the php not show the pivot and show this message: Page 1 in 1, items 1 to 1 of 1. DoneLoading..
|
|
Peter
|
|
Could you please add the page elements such as <html><head> and <body>. One question: Have you been able to install our demo suite? It suppose to work the same as our example demo. The pivot refreshment is only ajax and it does not depend to MySQL or SQL Server. If the problem persist, please make the page online and send us the link.
|
|
Carlos Eduardo
|
|
My Server in just moment is only internal. The file example.php in /KoolPHPSuite/Examples/KoolPivotTable/Firstlook/Firstlook show the same problem Only works using the index (With call runexample.php) My font is: (I understand that would work fine this code). <?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
//include("../../../../Resources/runexample.php");
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
if(isset($_POST["style_select"]))
{
$_SESSION["style_select"] = $_POST["style_select"];
}
else
{
if (!$koolajax->isCallback)
{
//Page Init: show default style
$_SESSION["style_select"] = "default";
}
}
/*
$dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));*/
/*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/
//Getting MSSQL Database Credential from database.
$myServer = "win-oloebbm0t2n\intelliti";
$myUser = 'sa';
$myPass = 'INTELLITI';
$myDB = 'IOCP';
//connection to the database
$connectionOptions = array("Database"=>$myDB,"UID"=>$myUser, "PWD"=>$myPass);
//Creating Connection Object.
$db_con = sqlsrv_connect( $myServer, $connectionOptions);
//Checking Connectioin Object Status
if( $db_con === false ) die( print_r( sqlsrv_errors() ) );
else echo $db_con;
$ds = new SQLSRVPivotDataSource($db_con);
//$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
//$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO")
// ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA");
$ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO")
->from("DM_ESTRUTURA_MERCADOLOGICA");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = $_SESSION["style_select"];
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$pivot->Width = "1200px";
$pivot->HorizontalScrolling = true;
//Set the Height of pivot and use Vertical Scrolling
$pivot->Height = "500px";
$pivot->VerticalScrolling = true;
//Allow filtering
$pivot->AllowFiltering = true;
//Allow sorting
$pivot->AllowSorting = true;
//Allow reordering
$pivot->AllowReorder = true;
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("PRECO_VENDA");
$field->Text = "Preço de Venda";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotSumField("PRECO_CUSTO");
$field->Text = "Preço de Custo";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("CANAL");
$field->Text = "Canal de Vendas";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("NEM01");
$field->Text = "Hierarquia Nível 01";
$pivot->AddColumnField($field);
$field = new PivotField("NEM02");
$field->Text = "Hierarquia Nível 02";
$pivot->AddColumnField($field);
$field = new PivotField("NEM03");
$field->Text = "Hierarquia Nível 03";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
Select style:
<select id="style_select" name="style_select" onchange="submit();">
<option value="default" <?php if ($_SESSION["style_select"]=="default") echo "selected" ?> >Default</option>
<option value="office2007" <?php if ($_SESSION["style_select"]=="office2007") echo "selected" ?> >Office2007</option>
</select>
<div style="padding-top:10px;">
<?php echo $pivot->Render();?>
</div>
</form>
|
|
Peter
|
|
It work with the index with calling runexample.php because runexample.php contain <html> <head> and <body> tag. Please add those to your page.
|
|
Carlos Eduardo
|
|
Same problem ... <head></head>
<body class="page_bg">
<?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
//include("../../../../Resources/runexample.php");
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
if(isset($_POST["style_select"]))
{
$_SESSION["style_select"] = $_POST["style_select"];
}
else
{
if (!$koolajax->isCallback)
{
//Page Init: show default style
$_SESSION["style_select"] = "default";
}
}
/*
$dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));*/
/*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/
//Getting MSSQL Database Credential from database.
$myServer = "win-oloebbm0t2n\intelliti";
$myUser = 'sa';
$myPass = 'INTELLITI';
$myDB = 'IOCP';
//connection to the database
$connectionOptions = array("Database"=>$myDB,"UID"=>$myUser, "PWD"=>$myPass);
//Creating Connection Object.
$db_con = sqlsrv_connect( $myServer, $connectionOptions);
//Checking Connectioin Object Status
if( $db_con === false ) die( print_r( sqlsrv_errors() ) );
else echo $db_con;
$ds = new SQLSRVPivotDataSource($db_con);
//$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
//$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO")
// ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA");
$ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO")
->from("DM_ESTRUTURA_MERCADOLOGICA");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = $_SESSION["style_select"];
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$pivot->Width = "1200px";
$pivot->HorizontalScrolling = true;
//Set the Height of pivot and use Vertical Scrolling
$pivot->Height = "500px";
$pivot->VerticalScrolling = true;
//Allow filtering
$pivot->AllowFiltering = true;
//Allow sorting
$pivot->AllowSorting = true;
//Allow reordering
$pivot->AllowReorder = true;
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("PRECO_VENDA");
$field->Text = "Preço de Venda";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotSumField("PRECO_CUSTO");
$field->Text = "Preço de Custo";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("CANAL");
$field->Text = "Canal de Vendas";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("NEM01");
$field->Text = "Hierarquia Nível 01";
$pivot->AddColumnField($field);
$field = new PivotField("NEM02");
$field->Text = "Hierarquia Nível 02";
$pivot->AddColumnField($field);
$field = new PivotField("NEM03");
$field->Text = "Hierarquia Nível 03";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
</body>
</html>
<form id="form1" method="post">
<?php echo $koolajax->Render();?>
Select style:
<select id="style_select" name="style_select" onchange="submit();">
<option value="default" <?php if ($_SESSION["style_select"]=="default") echo "selected" ?> >Default</option>
<option value="office2007" <?php if ($_SESSION["style_select"]=="office2007") echo "selected" ?> >Office2007</option>
</select>
<div style="padding-top:10px;">
<?php echo $pivot->Render();?>
</div>
</form>
|
|
Peter
|
|
What I mean is you have to follow this standard: <?php
//Your server code is here
$KoolControlsFolder = "../../../../KoolControls";
...
...
?>
<html>
<head>
<title>My pivot</title>
</head>
<body>
<form id="form1" method="post">
<?php echo $koolajax->Render(); ?>
<?php echo $pivot->Render();?>
</form>
</body>
</html>
|
|
Carlos Eduardo
|
|
The same problem ... <?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
//include("../../../../Resources/runexample.php");
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
if(isset($_POST["style_select"]))
{
$_SESSION["style_select"] = $_POST["style_select"];
}
else
{
if (!$koolajax->isCallback)
{
//Page Init: show default style
$_SESSION["style_select"] = "default";
}
}
/*
$dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));*/
/*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/
//Getting MSSQL Database Credential from database.
$myServer = "win-oloebbm0t2n\intelliti";
$myUser = 'sa';
$myPass = 'INTELLITI';
$myDB = 'IOCP';
//connection to the database
$connectionOptions = array("Database"=>$myDB,"UID"=>$myUser, "PWD"=>$myPass);
//Creating Connection Object.
$db_con = sqlsrv_connect( $myServer, $connectionOptions);
//Checking Connectioin Object Status
if( $db_con === false ) die( print_r( sqlsrv_errors() ) );
else echo $db_con;
$ds = new SQLSRVPivotDataSource($db_con);
//$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
//$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO")
// ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA");
$ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO")
->from("DM_ESTRUTURA_MERCADOLOGICA");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = $_SESSION["style_select"];
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$pivot->Width = "1200px";
$pivot->HorizontalScrolling = true;
//Set the Height of pivot and use Vertical Scrolling
$pivot->Height = "500px";
$pivot->VerticalScrolling = true;
//Allow filtering
$pivot->AllowFiltering = true;
//Allow sorting
$pivot->AllowSorting = true;
//Allow reordering
$pivot->AllowReorder = true;
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("PRECO_VENDA");
$field->Text = "Preço de Venda";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotSumField("PRECO_CUSTO");
$field->Text = "Preço de Custo";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("CANAL");
$field->Text = "Canal de Vendas";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("NEM01");
$field->Text = "Hierarquia Nível 01";
$pivot->AddColumnField($field);
$field = new PivotField("NEM02");
$field->Text = "Hierarquia Nível 02";
$pivot->AddColumnField($field);
$field = new PivotField("NEM03");
$field->Text = "Hierarquia Nível 03";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
<html>
<head>
<title>My pivot</title>
</head>
<body>
<form id="form1" method="post">
<?php echo $koolajax->Render(); ?>
<?php echo $pivot->Render();?>
</form>
</body>
</html>
|
|
Carlos Eduardo
|
|
|
|
Peter
|
|
Could you please do this: 1. Right click on the page and choose View page source 2. Copy the code and send to me here.
|
|
Carlos Eduardo
|
|
Shure !
Resource id #1 <html>
<head>
<title>My pivot</title>
</head>
<body>
<form id="form1" method="post">
<!--KoolAjax version 3.0.0.0 - www.koolphp.net -->
<script type='text/javascript' src='../../../../KoolControls/KoolAjax/koolajax.php?32981a13284db7a021131df49e6cd203'> </script> <div id='pivot_updatepanel' class='_kup defaultKPT_UpdatePanel' style='position:relative;'><div><script type='text/javascript'>if (document.getElementById('__defaultKPT')==null){var _head = document.getElementsByTagName('head')[0];var _link = document.createElement('link'); _link.id = '__defaultKPT';_link.rel='stylesheet'; _link.href='../../../../KoolControls/KoolPivotTable/styles/default/default.css';_head.appendChild(_link);}</script>
<!--KoolPivotTable version 3.8.0.0 - www.koolphp.net -->
<div id='pivot' class='defaultKPT' style='position:relative;display:inline-block;width:1200px;height:500px;'><table class='kptTable kptHorizontalScrolling kptVerticalScrolling' cellspacing='0'><colgroup><col /><col /><col style='width:17px' /></colgroup><tbody><tr><td colspan='3' class='kptFilterZone'><div id='pivot_filterzone' class='kptFilterZoneDiv'><span class='kptDesc'>Drag the filter field here.</span></div></td></tr><tr><td colspan='1' class='kptDataZone'><div id='pivot_datazone' class='kptDataZoneDiv'><span id='pivot_1679091c5a880faf6fb5e6087eb1b2dc' class='kptFieldItem ' title=''>Preço de Venda<span class='kptFilterButton' title='Fitlering'></span></span><span id='pivot_8f14e45fceea167a5a36dedd4bea2543' class='kptFieldItem ' title=''>Preço de Custo<span class='kptFilterButton' title='Fitlering'></span></span></div></td><td class='kptColumnZone' colspan='2'><div id='pivot_columnzone' class='kptColumnZoneDiv'><span id='pivot_c4ca4238a0b923820dcc509a6f75849b' class='kptFieldItem kptDragable ' title='Drag to order'>Hierarquia Nível 01<span class='kptSortButton kptSortAscOn' title='Sorted asc' onclick='pivot_sort_toggle(this)'></span><span class='kptFilterButton' title='Fitlering'></span></span><span id='pivot_c81e728d9d4c2f636f067f89cc14862c' class='kptFieldItem kptDragable ' title='Drag to order'>Hierarquia Nível 02<span class='kptSortButton kptSortAscOn' title='Sorted asc' onclick='pivot_sort_toggle(this)'></span><span class='kptFilterButton' title='Fitlering'></span></span><span id='pivot_eccbc87e4b5ce2fe28308fd9f2a7baf3' class='kptFieldItem kptDragable ' title='Drag to order'>Hierarquia Nível 03<span class='kptSortButton kptSortAscOn' title='Sorted asc' onclick='pivot_sort_toggle(this)'></span><span class='kptFilterButton' title='Fitlering'></span></span></div></td></tr><tr><td colspan='1' class='kptRowZone' style='width:auto; min-width:auto'><div id='pivot_rowzone' class='kptRowZoneDiv'><table cellspacing='0'style='border:0px;'><tbody><td><span id='pivot_e4da3b7fbbce2345d7772b0674a318d5' class='kptFieldItem kptDragable ' title='Drag to order'>Canal de Vendas<span class='kptSortButton kptSortAscOn' title='Sorted asc' onclick='pivot_sort_toggle(this)'></span><span class='kptFilterButton' title='Fitlering'></span></span></td></tbody></table></div></td><td colspan='1' class='kptColumnHeaderZone'><div class='kptColumnHeaderDiv'><table class='kptTable' cellspacing='0' style='table-layout: auto;'><colgroup><col/><col/><col/><col/></colgroup><tbody><tr><td id='pivot_ca8ecc14e87cfc7dba28b90a10b411fe' class='kptColumnHeader ' colspan='2'><span class='kptCollapse' onclick='pivot_group_toggle(this)'></span>Quadrinhos</td><td id='pivot_8de874b777f89155b699522967e12262' class='kptColumnHeader kptColumnHeaderTotal ' colspan='2'><b>Grand Total</b></td></tr><tr><td id='pivot_ca8ecc14e87cfc7dba28b90a10b411feSum of Quadrinhos' class='kptColumnHeader '>Sum of Quadrinhos</td><td id='pivot_ca8ecc14e87cfc7dba28b90a10b411feSum of Quadrinhos' class='kptColumnHeader '>Sum of Quadrinhos</td><td id='pivot_8de874b777f89155b699522967e12262Sum of Grand Total' class='kptColumnHeader '>Sum of Grand Total</td><td id='pivot_8de874b777f89155b699522967e12262Sum of Grand Total' class='kptColumnHeader '>Sum of Grand Total</td></tr><tr class='kptDimensionRow'><td></td><td></td><td></td><td></td></tr></tbody></table></div></td><td rowspan='2' class='kptVerticalScrollingZone' style='width:17px'><div class='kptVerticalScrollDiv' style='width:17px;overflow-y: scroll; overflow-x: hidden;'><div style='width:17px'></div></div></td></tr><tr><td colspan='1' class='kptRowHeaderZone'><div class='kptRowHeaderDiv' style='min-width:250px'><table class='kptTable' cellspacing='0' ><colgroup><col/></colgroup><tbody><tr><td id='pivot_a39e3a10befae42aeeb73ea1aa63d220' class='kptRowHeader ' colspan='1'>Bancas</td></tr><tr><td id='pivot_887ffb4b4c3e450ed541a93a27ddda79' class='kptRowHeader kptRowHeaderGrandTotal ' scope='col' colspan='1'><b>Grand Total</b></td></tr></tbody></table></div></td><td colspan='1' class='kptContentZone'><div class='kptContentDiv'><table cellspacing='0' class='kptTable' style='table-layout: auto;'><colgroup><col /><col /><col /><col /></colgroup><tbody><tr><td class='kptDataCell text-right '>$21</td><td class='kptDataCell text-right '>$10</td><td class='kptDataCell text-right kptColumnGrandTotalDataCell'>$21</td><td class='kptDataCell text-right kptColumnGrandTotalDataCell'>$10</td></tr><tr><td class='kptDataCell text-right kptRowGrandTotalDataCell'>$21</td><td class='kptDataCell text-right kptRowGrandTotalDataCell'>$10</td><td class='kptDataCell text-right kptRowGrandTotalDataCell kptColumnGrandTotalDataCell'>$21</td><td class='kptDataCell text-right kptRowGrandTotalDataCell kptColumnGrandTotalDataCell'>$10</td></tr></tbody></table></div></td></tr><tr><td colspan='3' class='kptHorizontalScrollingZone'><div class='kptHorizontalScrollDiv' style='height:17px;overflow-x: scroll; overflow-y: hidden;'><div style='height:17px'></div></div></td></tr><tr><td colspan='3' class='kptPagerZone'><div class='kptPager kptNextPrevAndNumericPager'><div class='kptNav'><span class= 'kptFirst'><input type='button' onclick='' title='First Page' class='nodecor'/><a href='javascript:void 0' onclick='' title='First Page'>First</a></span> <span class= 'kptPrev'><input type='button' onclick='' title='Previous Page' class='nodecor'/><a href='javascript:void 0' onclick='' title='Previous Page'>Next</a></span> <a class='kptNum kptNumSelected' ><span>1</span></a> <span class= 'kptNext'><a href='javascript:void 0' onclick='' title='Next Page'>Next</a><input type='button' onclick='' title='Next Page' class='nodecor'/></span> <span class= 'kptLast'><a href='javascript:void 0' onclick='' title='Last Page'>Last</a><input type='button' onclick='' title='Last Page' class='nodecor'/></span></div><div class='kptInfo'>Page <strong>1</strong> in <strong>1</strong>, items <strong>1</strong> to <strong>1</strong> of <strong>1</strong>.</div><div style='clear:both'></div></div></td></tr><tr><td colspan='3' class='kptStatusZone'><div class='kptStatus'><span class='kptDoneText'>Done</span><span class='kptLoadingText'>Loading..</span></div></td></tr></tbody></table><input id='pivot_viewstate' name='pivot_viewstate' type='hidden' value='{"pivot_cfcd208495d565ef66e7dff9f98764da":{"FieldName":"%27grand%27","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":0},"pivot_c4ca4238a0b923820dcc509a6f75849b":{"FieldName":"NEM01","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":0},"pivot_c81e728d9d4c2f636f067f89cc14862c":{"FieldName":"NEM02","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":0},"pivot_eccbc87e4b5ce2fe28308fd9f2a7baf3":{"FieldName":"NEM03","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":0},"pivot_a87ff679a2f3e71d9181a67b7542122c":{"FieldName":"%27grand%27","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":1},"pivot_e4da3b7fbbce2345d7772b0674a318d5":{"FieldName":"CANAL","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":true,"FilterPanelOpen":false,"_field_type":1},"pivot_1679091c5a880faf6fb5e6087eb1b2dc":{"FieldName":"PRECO_VENDA","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":false,"FilterPanelOpen":false,"_field_type":3},"pivot_8f14e45fceea167a5a36dedd4bea2543":{"FieldName":"PRECO_CUSTO","Sort":"asc","ExceptionList":[],"IncludeAll":true,"filter":[],"AllowReorder":false,"FilterPanelOpen":false,"_field_type":3},"pivot_pg":{"PageIndex":0,"PageSize":20,"TotalRows":1,"TotalPages":1},"pivot":{"PVField_Ids":[["pivot_cfcd208495d565ef66e7dff9f98764da","pivot_c4ca4238a0b923820dcc509a6f75849b","pivot_c81e728d9d4c2f636f067f89cc14862c","pivot_eccbc87e4b5ce2fe28308fd9f2a7baf3"],["pivot_a87ff679a2f3e71d9181a67b7542122c","pivot_e4da3b7fbbce2345d7772b0674a318d5"],[],["pivot_1679091c5a880faf6fb5e6087eb1b2dc","pivot_8f14e45fceea167a5a36dedd4bea2543"]],"CacheID":"587f8c373ebc5","AllowReorder":true,"HorizontalScrolling":true,"VerticalScrolling":true,"ScrollTop":0,"ScrollLeft":0,"ClientEvents":[],"GroupsToSort":[],"sortState":"initSort"}}' autocomplete='off' /><input id='pivot_cmd' name='pivot_cmd' type='hidden' value='' /></div><script type='text/javascript'>if(typeof _libKPT=='undefined'){document.write(unescape("%3Cscript type='text/javascript' src='../../../../KoolControls/KoolPivotTable/koolpivottable.php?32981a13284db7a021131df49e6cd203'%3E %3C/script%3E"));_libKPT=1;}</script><script type='text/javascript'>var pivot; function pivot_init(){ pivot = new KoolPivotTable('pivot',1,'');}if (typeof(KoolPivotTable)=='function'){pivot_init();}else{if(typeof(__KPTInits)=='undefined'){__KPTInits=new Array();} __KPTInits.push(pivot_init);if(typeof(_libKPT)=='undefined'){var _head = document.getElementsByTagName('head')[0];var _script = document.createElement('script'); _script.type='text/javascript'; _script.src='../../../../KoolControls/KoolPivotTable/koolpivottable.php?32981a13284db7a021131df49e6cd203'; _head.appendChild(_script);_libKPT=1;}}</script></div></div><script type='text/javascript'>var pivot_updatepanel = new KoolUpdatePanel('pivot_updatepanel',0);</script> </form>
</body>
</html>
|
|
Peter
|
|
I want to ask that is the open <?php is the first character of your file or is there something else. I see the text "Resource id #1 ". Where is the text come from? I did not see in your source-code but see it in your page source-code
|
|
Peter
|
|
This code should work well: <?php
/*
* This file is ready to run as standalone example. However, please do:
* 1. Add tags <html><head><body> to make a complete page
* 2. Change relative path in $KoolControlFolder variable to correctly point to KoolControls folder
*/
$KoolControlsFolder = "../../../../KoolControls";//Relative path to "KoolPHPSuite/KoolControls" folder
//include("../../../../Resources/runexample.php");
require $KoolControlsFolder."/KoolAjax/koolajax.php";
$koolajax->scriptFolder = $KoolControlsFolder."/KoolAjax";
require $KoolControlsFolder."/KoolPivotTable/koolpivottable.php";
/*
$dbhost = "win-oloebbm0t2n\intelliti"; #Nome do host
$db = "IOCP"; #Nome do banco de dados
$user = "sa"; #Nome do usuário
$password = "INTELLITI"; #Senha do usuário
// Dados da tabela
$tabela = "nometabela"; #Nome da tabela
$campo1 = "campo1tabela"; #Nome do campo da tabela
$campo2 = "campo2tabela"; #Nome de outro campo da tabela
$conninfo = array("Database" => $db, "UID" => $user, "PWD" => $password);
$db_con = sqlsrv_connect($dbhost, $conninfo);
if( $db_con ) {
echo "Connection established.<br />";
}else{
echo "Connection could not be established.<br />";
die( print_r( sqlsrv_errors(), true));*/
/*$dbcon = sqlsvr_connect('win-oloebbm0t2n\intelliti', array( 'Database'=>'IOCP', 'UID'=>'sa', 'PWD'=>'INTELLITI'));*/
//Getting MSSQL Database Credential from database.
$myServer = "win-oloebbm0t2n\intelliti";
$myUser = 'sa';
$myPass = 'INTELLITI';
$myDB = 'IOCP';
//connection to the database
$connectionOptions = array("Database"=>$myDB,"UID"=>$myUser, "PWD"=>$myPass);
//Creating Connection Object.
$db_con = sqlsrv_connect( $myServer, $connectionOptions);
//Checking Connectioin Object Status
if( $db_con === false ) die( print_r( sqlsrv_errors() ) );
else echo $db_con;
$ds = new SQLSRVPivotDataSource($db_con);
//$ds = new SQLSVRPivotDataSource($dbcon);//This $db_con link has been created inside KoolPHPSuite/Resources/runexample.php
//$ds ->select("CANAL, NEM01, NEM02, NEM03 , PRECO_VENDA, PRECO_CUSTO")
// ->from("dbo.DM_ESTRUTURA_MERCADOLOGICA");
$ds->select("CANAL, NEM01, NEM02, NEM03, PRECO_VENDA, PRECO_CUSTO")
->from("DM_ESTRUTURA_MERCADOLOGICA");
$pivot = new KoolPivotTable("pivot");
$pivot->scriptFolder = $KoolControlsFolder."/KoolPivotTable";
$pivot->styleFolder = "default";
$pivot->DataSource = $ds;
//Turn on ajax features.
$pivot->AjaxEnabled = true;
//Set the Width of pivot and use horizontal scrolling
$pivot->Width = "1200px";
$pivot->HorizontalScrolling = true;
//Set the Height of pivot and use Vertical Scrolling
$pivot->Height = "500px";
$pivot->VerticalScrolling = true;
//Allow filtering
$pivot->AllowFiltering = true;
//Allow sorting
$pivot->AllowSorting = true;
//Allow reordering
$pivot->AllowReorder = true;
//Make the RowHeader wider.
$pivot->Appearance->RowHeaderMinWidth = "250px";
//Use the Prev and Next Numneric Pager
$pivot->Pager = new PivotPrevNextAndNumericPager();
$pivot->Pager->PageSize = 20;
//Turn on caching to help pivot working faster.
$pivot->AllowCaching = true;
$pivot->CssClasses = array(
'data cell' => 'text-right',
// 'field' => 'rtl',
// 'column header' => 'text-right',
// 'row header' => 'rtl',
// 'filter panel' => 'rtl'
);
//Data Field
$field = new PivotSumField("PRECO_VENDA");
$field->Text = "Preço de Venda";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
$field = new PivotSumField("PRECO_CUSTO");
$field->Text = "Preço de Custo";
$field->FormatString = "\${n}";
$field->AllowReorder = false;
$pivot->AddDataField($field);
//Row Fields
$field = new PivotField("CANAL");
$field->Text = "Canal de Vendas";
$pivot->AddRowField($field);
//Column Fields
$field = new PivotField("NEM01");
$field->Text = "Hierarquia Nível 01";
$pivot->AddColumnField($field);
$field = new PivotField("NEM02");
$field->Text = "Hierarquia Nível 02";
$pivot->AddColumnField($field);
$field = new PivotField("NEM03");
$field->Text = "Hierarquia Nível 03";
$pivot->AddColumnField($field);
//Process the pivot
$pivot->Process();
?>
<!DOCTYPE>
<html>
<head>
<title>My pivot</title>
</head>
<body>
<form id="form1" method="post">
<?php echo $koolajax->Render(); ?>
<?php echo $pivot->Render();?>
</form>
</body>
</html>
|
|
Carlos Eduardo
|
|
Very Nice ! Now i bellieve that this solution is good !
|
|
Peter
|
|
|
|
Carlos Eduardo
|
|
Is Possible create Fields with Average or only Sum ? //Data Field $field = new PivotSumField("PRECO_VENDA"); $field->Text = "Preço de Venda"; $field->FormatString = "\${n}"; $field->AllowReorder = false; $pivot->AddDataField($field);
|
|
Peter
|
|
It is $field = new PivotAverageField("field_name");
|
|
Carlos Eduardo
|
|
Hi Peter. Thaks ! Are there documentation about this features ? Tks so Mush again !
|
|
Peter
|
|
|
|