<?php
defined('_JEXEC') or die;
function regularlabs_php_b3071efecd3a48e8f8e7ead0da9b54ba($src_variables){
$app = $mainframe = RegularLabs\Library\Condition\Php::getApplication();
$document = $doc = RegularLabs\Library\Condition\Php::getDocument();
$database = $db = JFactory::getDbo();
$user = JFactory::getApplication()->getIdentity() ?: JFactory::getUser();
$Itemid = $app->input->getInt('Itemid');
if (is_array($src_variables)) {foreach ($src_variables as $src_key => $src_value) {${$src_key} = $src_value;}}
// EXTRAI OS LOTES NO QUAL JA SE VERIFICARAM MORTES 

 
$user = JFactory::getUser(); //gets user object 
$db = JFactory::getDbo(); 
// Create a new query object. 
$query = $db->getQuery(true); 
$query->select(array('porcos_mortes.id', 'porcos_mortes.produtor','porcos_lote.lote' )); 
$query->from($db->quoteName(array('porcos_mortes','porcos_lote'))); 
 $query->where('porcos_mortes.lote=porcos_lote.id and '.$db->quoteName('porcos_mortes.produtor').'='.$user->id); 
$query->group('porcos_mortes.lote'); 
$query->order('porcos_mortes.id asc'); 

 
// Reset the query using our newly populated query object. 
$db->setQuery($query); 

 
// Load the results as a list of stdClass objects (see later for more options on retrieving data). 
$results = $db->loadObjectList(); 
print_r($user->id); 
echo('<hr>'); 
print_r($results); ?> 

 
<!-- 

 
Div that will hold the chart 

 
Grafico da extracao de informacao das tabelas 

 
O div é alterado em var chart = new google.visualization.BarChart(document.getElementById('grafico_tabela')); na funcao drawChart 

 
--> 
<div id="grafico_tabela"></div> 

 
<!-- Selecao do Lote --> 

 
<?php 

 
// constroi o select com a informacao obtida na querie anterior  

 
if(sizeof($results)==0 || $results == nil ){ 
echo "PRODUTOR SEM INFORMACAO RELEVANTE" 

 
return "" ; 
} 

 
echo '<select id="selectLote"> <option>Selectione um Lote</option> </select>'; 

 
print_r($results[2]->lote); ?> 

 
  

 
<div id="demo"> 
<h1>The XMLHttpRequest Object</h1> 

 
<button type="button" onclick="loadDoc()">Change Content</button> 
</div> 

 
  

 
<?php 

 
// inclusao das bibliotecas js 

 
$document = JFactory::getDocument(); 
 
// J3.x:Adding JavaScript and CSS to the page - Joomla! Documentation 

 
$document->addScript('https://www.gstatic.com/charts/loader.js'); 

 
//print_r($document);;
return get_defined_vars();
;}