diff --git a/html/export.php b/html/export.php index 6393d3161..1e70f720b 100644 --- a/html/export.php +++ b/html/export.php @@ -69,6 +69,8 @@ if ( LOGINPUT) fwrite($file_loginput,"\n"); fwrite($file_loginput,' $_REQUEST=array_merge($_GET,$_POST);'); fwrite($file_loginput,"\n"); + fwrite($file_loginput,' require_once NOALYSS_INCLUDE."/export/$prfile";'); + fwrite($file_loginput,"\n"); fclose($file_loginput); } diff --git a/html/test.php b/html/test.php index 3025d438e..8bae03bfa 100644 --- a/html/test.php +++ b/html/test.php @@ -24,7 +24,9 @@ * * - first do not forget to create the authorized_debug file in the html folder * - secund the test must be adapted to this page : if you do a post (or get) from a test, you won't get any result - * if the $_REQUEST[test_select] is not set, so set it . + * if the $_REQUEST[test_select] is not set, so set it . + * + * */ @@ -33,6 +35,7 @@ include_once("../include/constant.php"); include_once("lib/ac_common.php"); + html_page_start(); global $http; define ('TEST_UNIT',1); @@ -63,6 +66,25 @@ if (!file_exists('authorized_debug')) exit(); } define('ALLOWED', 1); + +global $aAvaible_module; + +/* + * Find all the folder + */ +$directory=NOALYSS_BASE."/scenario"; +$folder=scandir($directory); +$nb_folder=count($folder); + +for ($i=0; $i<$nb_folder;$i++) +{ + if (is_dir("{$directory}/".$folder[$i]) && $folder[$i] != '.' && $folder[$i] !='..') + { + $aAvaible_module[]=$folder[$i]; + + } +} + load_all_script(); // To enable assert , set "zend.assertions" in the php.ini file /******************************************************************************************************************/ @@ -116,10 +138,48 @@ function retrieve_files($directory) :array } return $scenario; } +function display_test($title,$gDossierLogInput,$aHtml_files) +{ + + echo h1($title); + + $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts",'module'=>$title)); + + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + $nb_html=count($aHtml_files); + for ($e=0; $e<$nb_html; $e++) + { + + $get='test.php?'.http_build_query(array('script'=>$aHtml_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$aHtml_files[$e]['desc'])); + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + } + echo '
'; + echo ''; + echo "Tous les tests du module $title "; + echo ''; + echo ''; + echo ''; + echo 'Tous les scripts'; + echo ''; + echo '
'; + echo $e; + echo ''; + echo ''; + echo basename($aHtml_files[$e]['file']); + echo ''; + echo ''.$aHtml_files[$e]['desc'].'
'; +} + -$html_files=retrieve_files(NOALYSS_BASE.'/scenario/HTML'); -$xml_files=retrieve_files(NOALYSS_BASE.'/scenario/XML'); -$lib_files=retrieve_files(NOALYSS_BASE.'/scenario/LIB'); $script=$http->request('script', "string",''); $min=$cn->get_value("select p_id from parm_periode order by p_start asc limit 1"); @@ -134,117 +194,65 @@ if ($script=="") * avec une description */ - echo h1('HTML'); - - echo ''; $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'description'=>"Tous les scripts")); - echo ''; - echo ''; - echo ''; - echo ''; - $nb_html=count($html_files); - for ($e=0; $e<$nb_html; $e++) - { - - $get='test.php?'.http_build_query(array('script'=>$html_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$html_files[$e]['desc'])); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; + print '

'; + printf( ' Tous les test ',$get); + print '

'; + foreach ($aAvaible_module as $mod) { + $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod); + display_test($mod,$gDossierLogInput,$html_files); } - echo '
'; - echo ''; - echo "Tous "; - echo ''; - echo 'Tous les scripts
'; - echo $e; - echo ''; - echo ''; - echo basename($html_files[$e]['file']); - echo ''; - echo ''.$html_files[$e]['desc'].'
'; - - echo h1('XML'); - echo ''; - - $nb_xml=count($xml_files); - for ($e=0; $e<$nb_xml; $e++) - { - - $get='test.php?'.http_build_query(array('script'=>$xml_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$xml_files[$e]['desc'])); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - } - echo '
'; - echo $e; - echo ''; - echo ''; - echo basename($xml_files[$e]['file']); - echo ''; - echo ''.$xml_files[$e]['desc'].'
'; - echo h1('Libraries'); - echo ''; - - $nb_lib=count($lib_files); - for ($e=0; $e<$nb_lib; $e++) - { - - $get='test.php?'.http_build_query(array('script'=>$lib_files[$e]['file'], 'gDossier'=>$gDossierLogInput, 'description'=>$lib_files[$e]['desc'])); - echo ''; - echo ''; - echo ''; - echo ''; - echo ''; - - } - echo '
'; - echo $e; - echo ''; - echo ''; - echo basename($lib_files[$e]['file']); - echo ''; - echo ''.$lib_files[$e]['desc'].'
'; } else if ($script=='all') { - $nb=$http->get('nb_script', "number",0); - + $nb=$http->get('nb_script', "number",1); + $start_mem=memory_get_usage(); $start_time=microtime(true); - $script=noalyss_str_replace('../', '', $script); - - echo '

'.$nb." ".$scenario[$nb]['file']."

"; - echo '

description = '.$scenario[$nb]["desc"].'

'; - include '../scenario/'.$scenario[$nb]['file']; - echo ''; - echo ''; - $end_mem=memory_get_usage(); - $end_time=microtime(true); + $module=$http->get('module','string','all'); + $scenario=[]; + if ($module=='all') { + foreach ($aAvaible_module as $mod) { + $html_files = retrieve_files(NOALYSS_BASE . '/scenario/' . $mod); + $scenario = array_merge($html_files, $scenario); + } + } elseif (in_array($module, $aAvaible_module) ) { + $scenario=retrieve_files(NOALYSS_BASE.'/scenario/'.$module); - echo "

start mem : ".$start_mem; - echo '

'; - echo "

end mem : ".$end_mem; - echo '

'; - echo "

Diff = ".($end_mem-$start_mem)." bytes "; - echo "

Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes "; - echo "

Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes "; - echo '

'; - echo "

Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes

"; - $nb++; - if ( $nb == $maxscan ) { - echo "Dernier test"; - } else { - $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb)); - echo ''; - echo $scenario[$nb]['file']; + } + + $maxscan=$http->get('nb_script', "number",count($scenario)-1); + $maxscan++; + for ($i=$nb;$i< $maxscan;$i++) { + echo '

'.$nb." ".$scenario[$nb]['file']."

"; + echo '

description = '.$scenario[$nb]["desc"].'

'; + include $scenario[$nb]['file']; + echo ''; + echo ''; + $end_mem=memory_get_usage(); + $end_time=microtime(true); + + echo "

start mem : ".$start_mem; + echo '

'; + echo "

end mem : ".$end_mem; + echo '

'; + echo "

Diff = ".($end_mem-$start_mem)." bytes "; + echo "

Diff = ".(round(($end_mem-$start_mem)/1024, 2))." kbytes "; + echo "

Diff = ".(round(($end_mem-$start_mem)/1024/1024, 2))." Mbytes "; + echo '

'; + echo "

Execution script ".$script." time = ".(round(($end_time-$start_time), 4))." secondes

"; + $nb++; + if ( $nb == $maxscan ) { + echo "Dernier test"; + } else { + $get='test.php?'.http_build_query(array('script'=>"all", 'gDossier'=>$gDossierLogInput, 'nb_script'=>$nb)); + echo '
'; + echo $scenario[$nb]['file']; + echo ''; + } } } else diff --git a/include/lib/ac_common.php b/include/lib/ac_common.php index 9b5a2a87a..cda7915af 100644 --- a/include/lib/ac_common.php +++ b/include/lib/ac_common.php @@ -36,9 +36,9 @@ function h($p_string) { return ( $p_string === null)?"":htmlspecialchars($p_string,ENT_QUOTES|ENT_HTML5,'UTF-8',true); } -function p($p_string) +function p($p_string, $p_extra='') { - return '

'.$p_string."

"; + return '

'.$p_string.""; } function span($p_string, $p_extra='') { @@ -1800,4 +1800,34 @@ function sanitize_filename($filename) $new_filename=strtolower($filename_no)."-".date("Ymd-Hi").$filename_suff; return $new_filename; +} + +/** + * @brief convert some csv string (content of a file) into HTML table, + * @param $string CSV files + * @return void + */ +function csv2table ($string) +{ + $a_field=[';',',']; + $sep_field=$a_field[$_SESSION[SESSION_KEY.'csv_fieldsep']]; + $a_field=['.',',']; + $sep_dec=$a_field[$_SESSION[SESSION_KEY.'csv_decimal']]; + $encoding=$_SESSION[SESSION_KEY.'csv_encoding']; + + $aRow=explode("\r\n", $string); + + echo ''; + foreach ($aRow as $row) { + echo ''; + $aCol=explode($sep_field, $row); + foreach ($aCol as $col) { + echo ''; + } + echo ''; + + } + echo '
'; + echo h($col); + echo '
'; } \ No newline at end of file diff --git a/include/lib/manage_table_sql.class.php b/include/lib/manage_table_sql.class.php index e0f2b6b39..fbce42565 100644 --- a/include/lib/manage_table_sql.class.php +++ b/include/lib/manage_table_sql.class.php @@ -218,7 +218,7 @@ class Manage_Table_SQL */ function send_header() { - header('Content-type:text/xml;charset="UTF-8"'); + @header('Content-type:text/xml;charset="UTF-8"'); } /** diff --git a/include/lib/noalyss_csv.class.php b/include/lib/noalyss_csv.class.php index 0ac94699f..f7b448264 100644 --- a/include/lib/noalyss_csv.class.php +++ b/include/lib/noalyss_csv.class.php @@ -77,11 +77,16 @@ class Noalyss_Csv } /*** - *@brief Send an header for CSV , the filename is corrected + *@brief Send an header for CSV , the filename is corrected. If TEST_UNIT is defined, the function is called + * from a test file (located in scenario , see manual )and no header are requested */ function send_header() { $this->correct_name(); + if ( defined('TEST_UNIT')) { + + return; + } header('Pragma: public'); header('Content-type: application/csv'); header("Content-Disposition: attachment;filename=\"{$this->filename}\"", diff --git a/scenario/EXPORT/export-export_histo_csv.php-1730456264.php b/scenario/EXPORT/export-export_histo_csv.php-1730456264.php new file mode 100644 index 000000000..ec6a53623 --- /dev/null +++ b/scenario/EXPORT/export-export_histo_csv.php-1730456264.php @@ -0,0 +1,70 @@ + '25', + 'ledger_type' => 'ALL', + 'tag_option' => '0', + 'act' => 'CSV:histo', + 'viewsearch' => 'Export vers CSV', + 'qcode' => '', +); +$_POST=array ( +); +$_POST['gDossier']=$gDossierLogInput; +$_GET['gDossier']=$gDossierLogInput; + $_REQUEST=array_merge($_GET,$_POST); +ob_start(); +include NOALYSS_INCLUDE."/export/export_histo_csv.php"; +$result=ob_get_contents(); +ob_end_clean(); +html_page_start(); +if (trim($result) != '') { + echo p('result ok','class="alert-success"'); +} else { + echo p('result failed','class="notice"'); +} +echo h1('Tous les journaux'); +csv2table($result); + + +echo h1('Achat 01.01.2019 - 31.12.2019'); + +$_GET=array ( + 'date_paid_start' => '', + 'date_paid_end' => '', + 'date_start' => '01.01.2019', + 'date_end' => '31.12.2019', + 'desc' => '', + 'amount_min' => '0', + 'amount_max' => '0', + 'operation_filter' => 'all', + 'accounting' => '', + 'gDossier' => '25', + 'ledger_type' => 'ACH', + 'search_optag_option' => '0', + 'p_currency_code' => '-1', + 'tva_id_search' => '', + 'tag_option' => '0', + 'act' => 'CSV:histo', + 'viewsearch' => 'Export vers CSV', + 'qcode' => '', +); + +$_POST=array ( +); +$_POST['gDossier']=$gDossierLogInput; +$_GET['gDossier']=$gDossierLogInput; +$_REQUEST=array_merge($_GET,$_POST); +ob_start(); +include NOALYSS_INCLUDE."/export/export_histo_csv.php"; +$result=ob_get_contents(); +ob_end_clean(); +html_page_start(); +if (trim($result) != '') { + echo p('result ok','class="alert-success"'); +} else { + echo p('result failed','class="notice"'); +} +csv2table($result); + + diff --git a/scenario/document_type.php b/scenario/HTML/document_type.php similarity index 100% rename from scenario/document_type.php rename to scenario/HTML/document_type.php diff --git a/scenario/HTML/package_repository.test.php b/scenario/HTML/package_repository.test.php index 870015437..a173477e0 100644 --- a/scenario/HTML/package_repository.test.php +++ b/scenario/HTML/package_repository.test.php @@ -73,11 +73,16 @@ $core=$package_repository->make_object("core", ""); $core->download(); //download fake plugin -echo h1("Plugin : download and install "); -$plugin=$package_repository->make_object("plugin","COPRO"); -$plugin->download(); -echo h2("Install in noalyss/include/ext/copro-fake"); -$plugin->install(); +try { + echo h1("Plugin : download and install "); + $plugin=$package_repository->make_object("plugin","COPRO"); + $plugin->download(); + echo h2("Install in noalyss/include/ext/copro-fake"); + $plugin->install(); + +} catch (\Exception $e) { + echo $e->getMessage(); +} echo h1("Available template"); diff --git a/scenario/LIB/HtmlInput.test.php b/scenario/LIB/HtmlInput.test.php index bc8425cac..bda146273 100644 --- a/scenario/LIB/HtmlInput.test.php +++ b/scenario/LIB/HtmlInput.test.php @@ -63,7 +63,10 @@ $http=new HttpInput(); $input_switch->readOnly=TRUE; echo $input_switch->input(); ?> -

InputCheckBox (Check Box)

+

EXPERIMENTAL InputCheckBox (Check Box)

+