noalyss Version-9
Functions
user_common.php File Reference

Common functions. More...

Go to the source code of this file.

Functions

 check_parameter ($p_array, $p_needed)
 Check that all the index are in the array, used by function to check if the array contains the needed variables before an extract. More...
 
 clean_filename ($p_filename)
 sanitize the filename remove character which could be a problem, More...
 
 CleanUrl ()
 Clean the url, remove the $_GET offset,step, page and size. More...
 
 isValid_deprecrated ($p_cn, $p_grpt_id)
 test if a jrn op is valid More...
 
 navigation_bar ($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
 Create a navigation_bar (pagesize) More...
 
 redirect ($p_string, $p_time=0)
 
 toNumber ($p_num)
 remove the useless space, change comma by period and try to return a number More...
 

Detailed Description

Common functions.

Definition in file user_common.php.

Function Documentation

◆ check_parameter()

check_parameter (   $p_array,
  $p_needed 
)

Check that all the index are in the array, used by function to check if the array contains the needed variables before an extract.

Parameters
type$p_arrayarray to check
type$neededstring containing variable separated by comma
Exceptions
Exception

Definition at line 209 of file user_common.php.

210{
211 $needed =explode(',',$p_needed);
212 for ($e=0;$e<count($needed);$e++) {
213 if ( ! isset($p_array[$needed[$e]])) {
214 throw new Exception (_('Paramètre manquant')." ".$needed[$e]);
215 }
216 }
217}

References $e, and $p_array.

Referenced by Acc_Ledger_Fin\verify_operation(), Acc_Ledger_Purchase\verify_operation(), and Acc_Ledger_Sale\verify_operation().

◆ clean_filename()

clean_filename (   $p_filename)

sanitize the filename remove character which could be a problem,

Parameters
string$p_filenamethe filename to clean
Returns
string Filename without bad char.

Definition at line 223 of file user_common.php.

224{
225 $filename=$p_filename;
226 foreach (array('/','*','<','>',';',',','\\',':','(',')',' ','[',']') as $i) {
227 $filename= noalyss_str_replace($i, "-",$filename);
228 }
229 return $filename;
230
231}
noalyss_str_replace($search, $replace, $string)
Definition: ac_common.php:1553

References $i, and noalyss_str_replace().

Referenced by Document_Export\export_receipt().

+ Here is the call graph for this function:

◆ CleanUrl()

CleanUrl ( )

Clean the url, remove the $_GET offset,step, page and size.

Parameters
none
Returns
the cleaned url

Definition at line 175 of file user_common.php.

176{
177 // Compute the url
178 $url=http_build_query($_GET);
179 return $url;
180}
$url
$_GET['qcode']

References $_GET, and $url.

◆ isValid_deprecrated()

isValid_deprecrated (   $p_cn,
  $p_grpt_id 
)

test if a jrn op is valid

Parameters
$p_cndb
$p_grpt_id
Returns
:
  • 1 is valid
  • 0 is not valid

Definition at line 39 of file user_common.php.

40{
41 $Res=$p_cn->exec_sql("select jr_valid from jrn where jr_grpt_id=$p_grpt_id");
42
43 if ( ( $M = Database::num_row($Res)) == 0 ) return 0;
44
46
47 if ( $a['jr_valid'] == 't') return 1;
48 if ( $a['jr_valid'] == 'f') return 0;
49
50 echo_error ("Invalid result = ".$a['result']);
51
52
53}
echo_error($p_log, $p_line="", $p_message="")
log error into the /tmp/noalyss_error.log it doesn't work on windows
Definition: ac_common.php:169
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
$Res

References $a, $Res, echo_error(), DatabaseCore\fetch_array(), and DatabaseCore\num_row().

+ Here is the call graph for this function:

◆ navigation_bar()

navigation_bar (   $p_offset,
  $p_line,
  $p_size = 0,
  $p_page = 1,
  $p_javascript = "" 
)

Create a navigation_bar (pagesize)

Parameters
$p_offsetfirst record number
$p_linetotal of returned row
$p_sizecurrent g_pagesize user's preference
$p_pagenumber of the page where the user is
$p_javascriptjavascript code to add
Note
example :
   $step=$_SESSION[SESSION_KEY.'g_pagesize'];
   $page=(isset($_GET['offset']))?$_GET['page']:1;
   $offset=(isset($_GET['offset']))?$_GET['offset']:0;

   list ($max_ligne,$list)=ListJrn($cn,$_GET['p_jrn'],$sql,null,$offset,1);
   $bar=navigation_bar($offset,$max_ligne,$step,$page);
Returns
string with the nav. bar

Definition at line 76 of file user_common.php.

77{
78 // if the pagesize is unlimited return ""
79 // in that case there is no nav. bar
80 if ( $_SESSION[SESSION_KEY.'g_pagesize'] == -1 ) return "";
81 if ( $p_size==0)
82 {
83 $p_size= $_SESSION[SESSION_KEY.'g_pagesize'];
84 }
85 // if there is no row return an empty string
86 if ( $p_line == 0 ) return "";
87
88 // Clean url, cut away variable coming frm here
89 $url=cleanUrl();
90 // action to clean
91 $url=noalyss_str_replace('&p_action=delete','',$url);
92
93 // compute max of page
94 $nb_page=($p_line-($p_line%$p_size))/$p_size;
95 // if something remains
96 if ( $p_line % $p_size != 0 ) $nb_page+=1;
97
98 // if max page == 1 then return a empty string
99 if ( $nb_page == 1) return "";
100
101 // restore the sort
102 if ( isset($_GET['o']))
103 $url=$url.'&o='.$_GET['o'];
104
105 $r="";
106 // previous
107 if ($p_page !=1)
108 {
109 $e=$p_page-1;
110 $step=$p_size;
111 $offset=($e-1)*$step;
112
113 $r='<A class="mtitle" href="'.basename($_SERVER['PHP_SELF'])."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'" '.$p_javascript.'>';
114 $r.=" &larr;";
115 // $r.='<INPUT TYPE="IMAGE" width="12" SRC="image/go-previous.png">';
116 $r.="</A>&nbsp;&nbsp;";
117 }
118 //----------------------------------------------------------------------
119 // Create a partial bar
120 // if current page < 11 show 1 to 20
121 // otherwise show $p_page -10 to $p_page + 10
122 //----------------------------------------------------------------------
123 $start_bar=($p_page < 11 )?1:$p_page-10;
124 $end_bar =($p_page < 11 )?20:$p_page+10;
125 $end_bar =($end_bar > $nb_page )?$nb_page:$end_bar;
126
127 $sep="";
128 // Create the bar
129 for ($e=$start_bar;$e<=$end_bar;$e++)
130 {
131 // do not included current page
132 if ( $e != $p_page )
133 {
134 $step=$p_size;
135 $offset=($e-1)*$step;
136
137 $go=$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step";
138 $r.=$sep;
139 $r.=sprintf('<A class="nav" HREF="%s" %s >%d</A>&nbsp;',$go,$p_javascript,$e);
140 $sep=" &#8231; ";
141 }
142 else
143 {
144 $r.=$sep;
145 $r.="<b> [ $e ] </b>";
146 $sep=" &#8231; ";
147 } //else
148 } //for
149 // next
150
151 if ($p_page !=$nb_page)
152 {
153 // If we are not at the last page show the button next
154 $e=$p_page+1;
155 $step=$p_size;
156 $offset=($e-1)*$step;
157
158 $r.='&nbsp;<A class="mtitle" href="'.$_SERVER['PHP_SELF']."?".$url."&offset=$offset&step=$step&page=$e&size=$step".'" '.$p_javascript.' >';
159 $r.="&rarr;";
160 //$r.='<INPUT TYPE="IMAGE" width="12" SRC="image/go-next.png">';
161 $r.="</A>";
162 }
163
164
165 return $r;
166}
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...

References $_GET, $e, $offset, $r, $sep, $step, $url, if, and noalyss_str_replace().

Referenced by Stock\history(), Anc_Operation\html_table(), Follow_Up\myList(), Fiche_Def\myList(), Acc_Ledger_Purchase\show_unpaid_deprecated(), Fiche\Summary(), and contact\Summary().

+ Here is the call graph for this function:

◆ redirect()

redirect (   $p_string,
  $p_time = 0 
)

Definition at line 181 of file user_common.php.

182{
183 if (strpos( $p_string,'?') == 0 ) {
184 $p_string = $p_string.'?v='.microtime(true);
185 }
186 echo '<HTML><head><META HTTP-EQUIV="REFRESH" content="'.$p_time.'; url='.$p_string.'"></head><body> Connecting... </body></html>';
187}

Referenced by Noalyss_User\connect_user().

◆ toNumber()

toNumber (   $p_num)

remove the useless space, change comma by period and try to return a number

Parameters
$p_numnumber to format
Returns
the formatted number

Definition at line 194 of file user_common.php.

195{
196 $p_num=trim($p_num);
197 if ($p_num=='') return 0;
198 $p_num=noalyss_str_replace("'",'',$p_num);
199 $p_num=noalyss_str_replace(',','.',$p_num);
200 return $p_num;
201}

References noalyss_str_replace().

Referenced by Acc_Ledger_Search\build_search_sql().

+ Here is the call graph for this function: