[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 61/119: Search Card Paginate
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 61/119: Search Card Paginate |
Date: |
Mon, 26 Oct 2020 18:27:21 -0400 (EDT) |
sparkyx pushed a commit to branch master
in repository noalyss.
commit 13d44d5bdd3798bfe69aee2eebc382d91177112b
Author: Dany De Bontridder <danydb@noalyss.eu>
AuthorDate: Thu Oct 8 18:12:22 2020 +0200
Search Card Paginate
---
html/js/card.js | 6 ++++++
include/ajax/ajax_card.php | 43 ++++++++++++++++++++++++++++------------
include/template/card_result.php | 30 +++++++++++++++++++++++++++-
3 files changed, 65 insertions(+), 14 deletions(-)
diff --git a/html/js/card.js b/html/js/card.js
index ef115ce..aed90e9 100644
--- a/html/js/card.js
+++ b/html/js/card.js
@@ -325,6 +325,12 @@ function search_get_card(obj)
} else {
queryString+="&accvis=0";
}
+ if ( obj.elements['amount_from_type']) {
+
queryString+="&amount_from_type="+obj.elements['amount_from_type'].value;
+ }
+ if (obj.elements['page_card']) {
+ queryString+="&page_card="+obj.elements["page_card"].value;
+ }
queryString=encodeURI(queryString);
$('asearch').innerHTML=loading();
diff --git a/include/ajax/ajax_card.php b/include/ajax/ajax_card.php
index 199ca04..aa73b65 100644
--- a/include/ajax/ajax_card.php
+++ b/include/ajax/ajax_card.php
@@ -441,14 +441,24 @@ case 'fs':
$r.='</span>';
$r.=dossier::hidden().HtmlInput::hidden('op','fs');
$array=array();
- foreach (array('accvis','inp','jrn','label','typecard','price','tvaid') as
$i)
+
+ // to navigate
+ $page_card=$http->get("page_card","number",0);
+
+ // save previous info
+ $hidden="";
+ foreach
(array('accvis','inp','jrn','label','typecard','price','tvaid','amount_from_type')
as $i)
{
if (isset(${$i}) )
{
$r.=HtmlInput::hidden($i,${$i});
+ $hidden.=HtmlInput::hidden($i,${$i});
$sql_array[$i]=${$i};
}
}
+ $r.=$hidden;
+ $r.="</form>";
+
$sql_array["query"]=$query;
/* what is the type of the ledger */
$type="GL";
@@ -477,25 +487,32 @@ case 'fs':
break;
}
/* We limit the search to MAX_SEARCH_CARD records */
- $sql=$sql.' order by vw_name limit '.MAX_SEARCH_CARD;
- $a=$cn->get_array($sql);
- for($i=0;$i<count($a);$i++)
- {
- $array[$i]['quick_code']=$a[$i]['quick_code'];
- $array[$i]['name']=h($a[$i]['vw_name']);
- $array[$i]['accounting']=$a[$i]['accounting'];
- $array[$i]['first_name']=h($a[$i]['vw_first_name']);
- $array[$i]['description']=h($a[$i]['vw_description']);
+ $sql=$sql.' order by vw_name ';
+ $total_card=$cn->get_value("select count(*) from ($sql) as c");
+
+ $record_start=$page_card*MAX_SEARCH_CARD;
+ $sql.=' limit '.MAX_SEARCH_CARD.' offset '.$record_start;
+
+ $aFound=$cn->get_array($sql);
+ $nb_found=count($aFound);
+ for($i=0;$i<$nb_found;$i++)
+ {
+ $array[$i]['quick_code']=$aFound[$i]['quick_code'];
+ $array[$i]['name']=h($aFound[$i]['vw_name']);
+ $array[$i]['accounting']=$aFound[$i]['accounting'];
+ $array[$i]['first_name']=h($aFound[$i]['vw_first_name']);
+ $array[$i]['description']=h($aFound[$i]['vw_description']);
$array[$i]['javascript']=sprintf("set_value('%s','%s');",
$inp,$array[$i]['quick_code']);
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
-
$label,j(h(strip_tags($a[$i]['vw_name']))));
+ $label,j(h(strip_tags($aFound[$i]['vw_name']))));
+
/* if it is a ledger of sales we use vw_buy
if it is a ledger of purchase we use vw_sell*/
if ( $type=="ACH" ){
- $amount=(isNumber($a[$i]['vw_buy']) == 1 )?$a[$i]['vw_buy']:0;
+ $amount=(isNumber($aFound[$i]['vw_buy']) == 1
)?$aFound[$i]['vw_buy']:0;
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
$price,$amount);
}
@@ -505,7 +522,7 @@ case 'fs':
$price,$amount);
}
$array[$i]['javascript'].=sprintf("set_value('%s','%s');",
- $tvaid,$a[$i]['tva_id']);
+ $tvaid,$aFound[$i]['tva_id']);
$array[$i]['javascript'].="removeDiv('search_card');";
}//foreach
diff --git a/include/template/card_result.php b/include/template/card_result.php
index 6c38fad..466e7d7 100644
--- a/include/template/card_result.php
+++ b/include/template/card_result.php
@@ -5,6 +5,34 @@
<fieldset id="asearch" style="height:88%">
<legend><?php echo _('RĂ©sultats'); ?></legend>
<div style="height:88%;overflow:auto;">
+ <?php
+ // compute the url, $sql_array is defined in ajax_card.php
+ echo '<ul class="aligned-block" style="padding:1px;margin-top:
0px;margin-bottom: 0px;">';
+ if ( $page_card != 0 ) {
+ // show previous arrow to left
+ echo '<li style="padding:1px">';
+ echo '<form method="GET"
onsubmit="this.ctl=\'ipop_card\';search_get_card(this);return false;">';
+ $url=$sql_array;
+ $url["page_card"]=$page_card-1;
+ echo
HtmlInput::array_to_hidden(array('accvis','inp','jrn','label','typecard','price','tvaid','amount_from_type','page_card','query'),
$url);
+ echo HtmlInput::submit("previous","<");
+ echo '</form>';
+ echo '</li>';
+ }
+ if ( $record_start < $total_card && $nb_found >= MAX_SEARCH_CARD) {
+ echo '<li style="padding:1px">';
+ echo '<form method="GET"
onsubmit="this.ctl=\'ipop_card\';search_get_card(this);return false;">';
+ $url=$sql_array;
+ $url["page_card"]=$page_card+1;
+ echo
HtmlInput::array_to_hidden(array('accvis','inp','jrn','label','typecard','price','tvaid','amount_from_type','page_card','query'),
$url);
+
+ echo HtmlInput::submit("next",">");
+ echo '</form>';
+ echo '</li>';
+ }
+ echo '</ul>';
+ ?>
+
<table class="result" >
<?php for ($i=0;$i<sizeof($array);$i++) : ?>
<?php $class=($i%2==0)?'odd':'even';?>
@@ -40,7 +68,7 @@ if ( $accvis == 1 ) :
<?php endfor; ?>
</table>
<span style="font-style: italic;">
- <?php echo _("Nombre d'enregistrements:$i"); ?>
+ <?php echo _("Nombre d'enregistrements trouvé:$total_card"); ?>
</span>
<br>
</div>
- [Noalyss-commit] [noalyss] 45/119: ManageTable : add tbody and thead , fix javascript error, (continued)
- [Noalyss-commit] [noalyss] 45/119: ManageTable : add tbody and thead , fix javascript error, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 44/119: Fix: predefined operation with overflow for details, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 49/119: tag - cosmetic, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 47/119: Tag and Group Tag, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 53/119: NEW Security : add tag, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 56/119: Cosmetic for cells for tag and contact, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 55/119: not used anymore javascript:void(0), Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 58/119: Missing file, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 62/119: FOLLOWUP : generate doc. add new tag, DOCUMENT_ID, TITLE, DESCRIPTION, LABELOP, COMMENT, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 72/119: Tag Limit column size , replace input_switch by check_box, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 61/119: Search Card Paginate,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 64/119: InPlace_Switch : do not echo , return a string instead, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 68/119: Add new type of attribute : check, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 81/119: Search card :typo, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 90/119: select_box cosmetic font, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 92/119: Follow-Up create doc new Tags COMMENTS, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 93/119: Follow-up new column "Status", Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 98/119: Follow up add followup action, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 103/119: Improve : Quick filter on history, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 84/119: Merge extension-crm, Dany De Bontridder, 2020/10/26
- [Noalyss-commit] [noalyss] 96/119: Cosmetic, Dany De Bontridder, 2020/10/26