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 
22 if (!defined('ALLOWED'))
23  die('Appel direct ne sont pas permis');
24 
25 /**
26  * @file
27  * @brief search cards , accounting or analytic account
28  */
30 try
31 {
32  $query=$http->request("query","string","");
33  $target=$http->request("target");
34 }
35 catch (Exception $exc)
36 {
37  die ($exc->getMessage());
38 }
39 
40 echo HtmlInput::title_box(_("Résultat"), "search_account_div") ;
41 echo '<form method="GET" onsubmit="search_account_card(this);return false;"> ';
42 $search_query=new IText("query",$query);
43 echo $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);
52 echo _("Max")." ".$select_limit->input();
53 echo HtmlInput::hidden("op", "search_account_card");
54 echo HtmlInput::hidden("target",$target);
55 echo Dossier::hidden();
56 echo HtmlInput::submit(uniqid(), _("Cherche"));
57 echo '</form>';
58 echo '<p class="text-muted">';
59 echo _("Vous pouvez faire des opérations arithmétiques entre des postes comptables, des comptes analytiques et des fiches")
60 ;
61 echo '</p>';
62 $array=array();
63 if ($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 }
83 echo '<div id="search_account_card_result_div">';
84 printf("Résultat %s",count($array));
85 $max=$select_limit->selected;
86 $idx=0;
87 echo '<ul class="">';
88 $close=";document.getElementById('search_account_div').remove();";
89 foreach ($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 }
124 echo '</ul>';
125 echo '</div>';
126 ?>
127 <ul class="aligned-block">
128  <?=HtmlInput::button_close("search_account_div")?>
129 </ul>
$query
$query
Definition: ajax_add_concerned_card.php:91
h
h( $row[ 'oa_description'])
Definition: ajax_anc_detail_operation.php:46
$search_query
$search_query
Definition: ajax_search_account_card.php:42
Dossier\hidden
static hidden()
return a string to set gDossier into a FORM
Definition: dossier.class.php:190
$http
$http
Definition: ajax_search_account_card.php:29
IText
Html Input.
Definition: itext.class.php:29
HtmlInput\button_close
static button_close($div_name)
close button for the HTML popup
Definition: html_input.class.php:430
HttpInput
manage the http input (get , post, request) and extract from an array
Definition: http_input.class.php:37
$max
$max
Definition: ajax_search_account_card.php:85
HtmlInput\title_box
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".
Definition: html_input.class.php:838
$array
$array
Definition: ajax_search_account_card.php:62
HtmlInput\submit
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
Definition: html_input.class.php:199
$target
$target
Definition: ajax_search_account_card.php:33
$cn
$cn
Definition: ajax_anc_accounting.php:30
HtmlInput\hidden
static hidden($p_name, $p_value, $p_id="")
Definition: html_input.class.php:218
$close
$close
Definition: ajax_search_account_card.php:88
$idx
$idx
Definition: ajax_search_account_card.php:86
ISelect
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Definition: iselect.class.php:39
$js
$js
Definition: ajax_tag_list.php:32
$select_limit
$select_limit
Definition: ajax_search_account_card.php:44