noalyss Version-9
ajax_search_account_card.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2002-2021) Author Dany De Bontridder <danydb@noalyss.eu>
21
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24
25/**
26 * @file
27 * @brief search cards , accounting or analytic account
28 */
30try
31{
32 $query=$http->request("query","string","");
33 $target=$http->request("target");
34}
35catch (Exception $exc)
36{
37 die ($exc->getMessage());
38}
39
40echo HtmlInput::title_box(_("Résultat"), "search_account_div") ;
41echo '<form method="GET" onsubmit="search_account_card(this);return false;"> ';
43echo $search_query->input();
44$select_limit=new ISelect("select_limit");
45$select_limit->value=array(
46 array("label"=>"25","value"=>25),
47 array("label"=>"50","value"=>50),
48 array("label"=>"100","value"=>100),
49 array("label"=>_("Tout"),"value"=>-1)
50);
51$select_limit->selected=$http->request('select_limit',"number",25);
52echo _("Max")." ".$select_limit->input();
53echo HtmlInput::hidden("op", "search_account_card");
54echo HtmlInput::hidden("target",$target);
55echo Dossier::hidden();
56echo HtmlInput::submit(uniqid(), _("Cherche"));
57echo '</form>';
58echo '<p class="text-muted">';
59echo _("Vous pouvez faire des opérations arithmétiques entre des postes comptables, des comptes analytiques et des fiches")
60;
61echo '</p>';
62$array=array();
63if ($query != "") {
64
65 $array=$cn->get_array("
66 select quick_code as s_code,vw_name||' '
67 ||coalesce(vw_first_name,'') ||' '
68 ||coalesce(vw_description,'') as s_name,'C' as s_type from vw_fiche_attr vfa
69 where quick_code like upper('%'||$1||'%') or lower(vw_name) like '%'||$1||'%'
70 union all
71 select pcm_val, pcm_lib ,'A' from tmp_pcmn tp
72 where pcm_val like '%'||$1||'%'
73 or lower(pcm_lib) like '%'||$1||'%'
74 union all
75 select po_name ,po_description , 'N' from poste_analytique pa
76 where
77 po_name like '%'||$1||'%'
78 or po_description like '%'||$1||'%'
79 order by 1
80
81",[$query]);
82}
83echo '<div id="search_account_card_result_div">';
84printf("Résultat %s",count($array));
87echo '<ul class="">';
88$close=";document.getElementById('search_account_div').remove();";
89foreach ($array as $item) {
90
91 if ($max <> -1 && $idx >= $max) {
92 break;
93 }
94 $idx++;
95 echo '<li class="list-group-item">';
96 switch ($item['s_type'])
97 {
98 case 'N':
99 // analytic account
100 $js=sprintf('onclick="document.getElementById(\'%s\').value+=\'{{%s}}\' ;%s"',$target,$item['s_code'],$close);
101
102 break;
103 case 'A':
104 // Accounting
105 $js=sprintf('onclick="document.getElementById(\'%s\').value+=\'[%s]\' ;%s"',$target,$item['s_code'],$close);
106
107
108 break;
109 case 'C':
110 // card
111 $js=sprintf('onclick="document.getElementById(\'%s\').value+=\'{%s}\' ;%s"',$target,$item['s_code'],$close);
112
113 break;
114 default:
115 throw Exception ("Invalid result");
116 }
117
118 echo '<input type="checkbox" '.$js.'>';
119 echo h($item['s_code']);
120 echo " ";
121 echo h($item['s_name']);
122 echo '</li>';
123}
124echo '</ul>';
125echo '</div>';
126?>
127<ul class="aligned-block">
128 <?=HtmlInput::button_close("search_account_div")?>
129</ul>
h( $row[ 'oa_description'])
static hidden()
return a string to set gDossier into a FORM
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static hidden($p_name, $p_value, $p_id="")
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
manage the http input (get , post, request) and extract from an array
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Html Input.
Definition: itext.class.php:30