Utilización del Plugin AnyChart Actualización

En el Foro de XlineSoft y correos que he recibido, hay usuarios que desean que en la página LIST se pueda facilitar un gráfico en cada línea.

He tomado este ejemplo para explicar cómo se puede hacer con el Plugin de AnyChart.

Ese campo nuevo de la tabla “Factura” es un duplicado del “idfactura” y lo utilizaremos con el plugin para crear el gráficos.

Y el código escrito para producir el gráfico está en el fichero (anychart_3.php):

<?php
/*
Variables passed by the Plugin:

$field_value .- Field what show screen
$DataValue  .- Valor del campo que se utiliza en el plugin
$javascript  .- File of Javascript of Anychart
$theme .- File of Theme of Anychart
$language  .- File Javscript of language
$decimalsCount .-  Parameter
$zeroFillDecimals .-  Parameter
$decimalPoint .-  Parameter
$groupsSeparator .-  Parameter
$license .- License of ANYCHART  for PHPRunner
$id_field .-  Field occurrence identification number used to identify the "container".
*/

global $conn;

$chartData='';

$idfactura = $DataValue;

$strSQLExists = "SELECT
factura.idfactura, factura.Nif, factura.NombreRazonSocial, factura.FechaFactura, factura.TotalFactura,
linea_factura.idlinea_factura, linea_factura.factura_idfactura, linea_factura.producto_idproducto, linea_factura.Nombre, linea_factura.Valor
FROM factura
left join linea_factura on (factura.idfactura = linea_factura.factura_idfactura)
WHERE idfactura = $idfactura ";

$rsExists = db_query($strSQLExists,$conn);

  while ($Row = db_fetch_array($rsExists)) {
    $idFactura='Factura: '.$Row["idfactura"].' Producto: '.$Row["Nombre"];
    $TotalValor=$Row["Valor"];
    $FechaFactura=$Row["FechaFactura"];
    $chartData.="['$idFactura', $TotalValor, $FechaFactura] \n,";
  }
$chartData = substr($chartData, 0, -1);
 
$graphicDefinition= <<<EOT

// create pie chart with passed data
var data = anychart.data.set([ 
// add data of the Client
 $chartData 
    ]);

var wealth = data.mapAs({'x': 0, 'value': 1});

var chart = anychart.pie(wealth);

// License, out logo
$license

// apply coffee theme
// anychart.theme(anychart.themes.coffee);

// turn on chart animation
chart.animation(true);

// set chart title text settings
chart.title('Facturas del Cliente');
// Special 
chart.title().enabled(false);


// Tooltip
var tooltip = chart.tooltip();
tooltip.titleFormat("{%x}");

tooltip.format("Valor:{%value}{groupsSeparator:.,decimalPoint:\\\\,,decimalsCount:2}({%yPercentOfTotal}{decimalPoint:\\\\,,decimalsCount:2}%)");

// URL Format in:  https://docs.anychart.com/Common_Settings/Text_Formatters

chart.labels().format('{%Value}{decimalsCount:0} ({%yPercentOfTotal}{decimalsCount:2}%)');

// set legend title text settings
var legend = chart.legend();
// set legend position and items layout
legend.position("center");
legend.align("Bottom");
legend.fontSize(10);
legend.itemsLayout("vertical");

// Special 
legend.enabled(false);

// set container id for the chart
chart.container('container_$id_field');
// initiate chart drawing
chart.draw();
});
</script>
EOT;

$field_value .= $graphicDefinition;
?>

La nueva versión está programada en PHPRunner 10.7

Si te interesa este artículo, sigue leyéndolo en este link.

Crear informes con phpSpreadsheet, Actualización

He actualizado el artículo, a petición de Rubén, para que se disponga de un tipo de informe con formato ficha (una hoja de información por cada artículo).

 

El nuevo informe está en la opción de Provincia, en un botón naranja y que produce una salida con este tipo de formato:

Espero que os sea útil.

Si deseas ver todo el artículo, haz clic en este enlace.

 

Call to undefined function curl_init(), al cambiar versión de PHP

Al menos en mi caso, cuando cambie a la versión de PHP 8.2.13, vi que no se cargaba la librería de CURL y que los ejemplos que la utiliza me daba este mensaje “Call to undefined function curl_init()“.

Si revisáis este error, te indica que hay que poner unas DLL’s en el directorio de “bin” de Apache, pero no indica de dónde sacar esos ficheros. Además, en unos mensajes poner unos ficheros y en otros, pone otros.

Al final me he dado cuenta que esa versión de PHP y otras mayos, requieren una actualización del software de Apache. Resumiendo, hay que actualizar tu versión de Apache.

Ahora estoy ejecutando Apache 2.4.58 y PHP 8.2.15

Tenedlo en cuenta si tienes este mismo error.