ChronoEngine.com homepage

Forums

Please write a review for the extension you are using on the Joomla extensions directory before posting a new question as we are being spammed by many negative reviews.

Thank you for your support!

data filter datamin and data max doesn't work

esposito84 16 Oct, 2015
Hi everyone,
I'm loocking for ad in my chronoform a filter beetwen data a i find different tutorial but in my case doesn't work.
I start to my model (the name is dogan and the field is data in Y/m/d format):
- i add in the model condition this code:
<?php 
 if(\GCore\Libs\Request::data("min") || \GCore\Libs\Request::data("max")){
return array("dogan.data >=" => \GCore\Libs\Request::data("min"), "dogan.data <=" => \GCore\Libs\Request::data("max"));
}
?>
- next i add in the frontList setting filter dogan.data
- next i add in the header of custom code:
--before in the start of the header this code:
<?php
$document = \GCore\Libs\Document::getInstance();
$document->_('jquery');
$document->_('gdatetimepicker');
$document->addJsCode('jQuery(document).ready(function($){
 $("#min").gdatetimepicker();
 $("#max").gdatetimepicker();
});');
?>
--and after in the filter field:
</tr>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="min" name="min" placeholder="da...(data)" class="form-control A"   />
</td>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="max" name="max" placeholder="fino a...(data)" class="form-control A"   />
</td>
</tr>
--> Now there is two problem: The filter doesn't serch how i set it, and another proble when i made search the datapicher field doesn't return empty but stay the value before reserched.
I tryed for more time to change the condition in the model condition or another change but it doesn't work very well. for completely i stamp all my header do:
<?php
$document = \GCore\Libs\Document::getInstance();
$document->_('jquery');
$document->_('gdatetimepicker');
$document->addJsCode('jQuery(document).ready(function($){
 $("#min").gdatetimepicker();
 $("#max").gdatetimepicker();
});');
?>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2"
cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" name="srch" placeholder="cliente (ricerca)" class="form-control A" />
</td>
<td style="vertical-align: top; width: 50%;"><br>
<select  name="fltr[dogan][motivo]" placeholder="" class="form-control A" />
<option value="">motivo (filtro)</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT  `motivo`
 FROM `sinc_tabelle_personalizzate_visualizza_controllo_doganale`
ORDER BY `motivo`";
$db->setQuery($query);
$nomes = $db->loadObjectList();
foreach ( $nomes as $v ) {
echo '<option value="'.$v->motivo.'">'.$v->motivo.'</option> '; 
}
?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="min" name="min" placeholder="da...(data)" class="form-control A"   />
</td>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="max" name="max" placeholder="fino a...(data)" class="form-control A"   />
</td>
</tr>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<select  name="fltr[dogan][dog]" placeholder="" class="form-control A" />
<option value="">dogana (filtro)</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT  `dog`
 FROM `sinc_tabelle_personalizzate_visualizza_controllo_doganale`
ORDER BY `dog`";
$db->setQuery($query);
$nomes = $db->loadObjectList();
foreach ( $nomes as $v ) {
echo '<option value="'.$v->dog.'">'.$v->dog.'</option> '; 
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<br>
<input type="submit" name="submit" value="Cerca" />
<script type="text/javascript">
function printDiv()
{
 var a = window.open('',"b", "height=500,width=600,menubar=yes,scrollbars=yes,resizable=yes,,left=10,top=10");
 a.document.open("text/html");
 a.document.write(document.getElementById('foo').innerHTML);
 a.document.close();
 a.print();
}
</script>
<div style="text-align: right;">
<input onclick="printDiv();" type="image" src="<?php echo JURI::base().'images/printButton.png';?>" title="Stampa" alt="Stampa"/></div>
<div id="foo">
<br>

--> in the footer close the div
GreyHead 16 Oct, 2015
Hi esposito84,

It looks as though the query ought to work - but I'm not expert with CCv5. Please turn the Debugger on, that should show you the MySQL query / error message - if you copy and paste that here it should help see exactly what is happening.

Bob
esposito84 16 Oct, 2015
i don't know how insert debug in CC, but there isn't error the report is show normally, but when i go to use filters, they don't working alway
GreyHead 16 Oct, 2015
Hi esposito84,

There is a Display Debug setting near the bottom of the Front List > Settings tab.

Bob
esposito84 16 Oct, 2015
thank you bob,
My wrong is the format of data the filter use d-m-Y but the field is Y-m-d.
the another problem is how can set value of datapicher empty after i have done a reseach.
GreyHead 16 Oct, 2015
Hi esposito84,

I think I'd use JavaScript in the header box to clear any entry.
$("#min").val('');
$("#min").gdatetimepicker();
Bob
GreyHead 16 Oct, 2015
Hi esposito84,

Please post a link to the listing so I can take a quick look.

Bob
esposito84 16 Oct, 2015
header
<?php
$document = \GCore\Libs\Document::getInstance();
$document->_('jquery');
$document->_('gdatetimepicker');
$document->addJsCode('jQuery(document).ready(function($){
 $("#min").gdatetimepicker();
 $("#max").gdatetimepicker();
});');
?>
<table style="text-align: left; width: 100%;" border="0" cellpadding="2"
cellspacing="2">
<tbody>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" name="srch" placeholder="cliente (ricerca)" class="form-control A" />
</td>
<td style="vertical-align: top; width: 50%;"><br>
<select  name="fltr[dogan][motivo]" placeholder="" class="form-control A" />
<option value="">motivo (filtro)</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT  `motivo`
 FROM `sinc_tabelle_personalizzate_visualizza_controllo_doganale`
ORDER BY `motivo`";
$db->setQuery($query);
$nomes = $db->loadObjectList();
foreach ( $nomes as $v ) {
echo '<option value="'.$v->motivo.'">'.$v->motivo.'</option> '; 
}
?>
</select>
</td>
</tr>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="min" name="min" data-gdatetimepicker-format="d/m/Y" placeholder="da...(data)" class="form-control A"   />
</td>
<td style="vertical-align: top; width: 50%;"><br>
<input type="text" id="max" name="max" data-gdatetimepicker-format="d/m/Y" placeholder="fino a...(data)" class="form-control A"   />
</td>
</tr>
<tr>
<td style="vertical-align: top; width: 50%;"><br>
<select  name="fltr[dogan][dog]" placeholder="" class="form-control A" />
<option value="">dogana (filtro)</option>
<?php
$db =& JFactory::getDBO();
$query = "SELECT DISTINCT  `dog`
 FROM `sinc_tabelle_personalizzate_visualizza_controllo_doganale`
ORDER BY `dog`";
$db->setQuery($query);
$nomes = $db->loadObjectList();
foreach ( $nomes as $v ) {
echo '<option value="'.$v->dog.'">'.$v->dog.'</option> '; 
}
?>
</select>
</td>
</tr>
</tbody>
</table>
<br>
<input type="submit" name="submit" value="Cerca" />

<script type="text/javascript">
function printDiv()
{
 var a = window.open('',"b", "height=500,width=600,menubar=yes,scrollbars=yes,resizable=yes,,left=10,top=10");
 a.document.open("text/html");
 a.document.write(document.getElementById('foo').innerHTML);
 a.document.close();
 a.print();
}
</script>
<div style="text-align: right;">
<input onclick="printDiv();" type="image" src="<?php echo JURI::base().'images/printButton.png';?>" title="Stampa" alt="Stampa"/></div>
<div id="foo">
<br>

body

{_EDIT_}              {_DELETE_}<br>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2"
cellspacing="2">
<tbody>
<tr align="center">
<td colspan="3" rowspan="1"
style="vertical-align: top; width: 33%;">{dogan.descr}<br>
</td>
</tr>
<tr>
<td style="vertical-align: top; width: 33%; text-align: center;">ufficio
doganale: <span style="font-weight: bold;">{dogan.dog}</span><br>
</td>
<td style="vertical-align: top; width: 34%; text-align: center;">motivo:
<span style="font-weight: bold;">{dogan.motivo}</span><br>
</td>
<td style="vertical-align: top; width: 33%; text-align: center;">data:
<span style="font-weight: bold;">{dogan.dat}</span><br>
</td>
</tr>
<tr align="center">
<td colspan="3" rowspan="1" style="vertical-align: top;">Allegati:<span
style="font-weight: bold;"><a href="components/com_chronoforms5/chronoforms/uploads/controllo_doganale/{dogan.verbale}" target=”_blank” title=”{dogan.verbale}”>{dogan.verbale}</a></span><br>
</td>
</tr>
<tr>
<td colspan="3" rowspan="1" style="vertical-align: top;">nota: <span
style="font-weight: bold;">{dogan.nota}</span><br>
</td>
</tr>
</tbody>
</table>

footer

</div>
GreyHead 16 Oct, 2015
Hi esposito84,

I don't see this line anywhere?
$("#min").val('');
Bob
esposito84 16 Oct, 2015
i deleted it becouse blocked chronoconnectivity windows. i put it under:
$document = \GCore\Libs\Document::getInstance();
$document->_('jquery');
$document->_('gdatetimepicker');
$document->addJsCode('jQuery(document).ready(function($){
$("#min").gdatetimepicker();
$("#max").gdatetimepicker();
$("#min").val('');
esposito84 16 Oct, 2015
i put it after this code:
<?php
$document = \GCore\Libs\Document::getInstance();
$document->_('jquery');
$document->_('gdatetimepicker');
$document->addJsCode('jQuery(document).ready(function($){
$("#min").gdatetimepicker();
$("#max").gdatetimepicker();

but block the header of report, for this reason i delete it
This topic is locked and no more replies can be posted.

2Checkout.com

2CheckOut.com Inc. (Ohio, USA) is an authorized retailer for goods and services provided by ChronoEngine.com