From b282f2846b3db2b2e5c2762888c938da0d6e238d Mon Sep 17 00:00:00 2001 From: sparkyx Date: Sat, 14 Dec 2024 17:45:38 +0100 Subject: [PATCH] Code improve Todo List to finish , allow a empty date --- html/js/acc_ledger.js | 4 +- html/js/noalyss_script.js | 2 +- html/test.php | 6 +-- include/class/acc_ledger_search.class.php | 6 +-- include/class/lettering.class.php | 13 +++++- include/class/todo_list.class.php | 20 +++++++-- include/lettering.gestion.inc.php | 36 ++++++++++++---- include/sql/mod1/data.sql | 20 +-------- include/sql/mod1/make-sql | 2 +- include/sql/mod1/schema.sql | 36 ++++++++-------- include/sql/mod2/make-sql | 4 +- include/template/ledger_search.php | 41 ++++++++++++++----- sql/upgrade.sql | 1 + ...acc_letter.Test.php => acc_letterTest.php} | 2 +- 14 files changed, 123 insertions(+), 70 deletions(-) rename unit-test/include/class/{acc_letter.Test.php => acc_letterTest.php} (99%) diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index c4891fa53..ecfd2f19e 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1210,13 +1210,13 @@ function success_dsp_letter(req) { try { code_html.evalScripts(); } catch (e) { - alert_box("DSPLETTER:" + content[48] + e.message); + alert_box("DSPLETTER1:" + content[48] + e.message); } } function error_dsp_letter(req) { - alert_box("DSPLETTER:" + content[48]); + alert_box("DSPLETTER2:" + content[48]); } function search_letter(obj) { diff --git a/html/js/noalyss_script.js b/html/js/noalyss_script.js index e4d4e7070..438f58cd4 100644 --- a/html/js/noalyss_script.js +++ b/html/js/noalyss_script.js @@ -3555,7 +3555,7 @@ var Periode = function (p_ledger) { } } if (count == 0) { - smoke.signal("Sélectionner au moins une période", function () { + smoke.signal("Sélectionner au moins une période", function () { }, {duration: 1500}); return; } diff --git a/html/test.php b/html/test.php index e5eeb9adc..6637b69f9 100644 --- a/html/test.php +++ b/html/test.php @@ -67,8 +67,8 @@ define('ALLOWED', 1); load_all_script(); // To enable assert , set "zend.assertions" in the php.ini file ini_set("assert.active",1); -assert_options(ASSERT_ACTIVE, 1); -assert_options(ASSERT_WARNING, 1); +// assert_options(ASSERT_ACTIVE, 1); +//assert_options(ASSERT_WARNING, 1); //removed in PHP8 assert_options(ASSERT_QUIET_EVAL, 1); function my_assert_handler($file, $line, $code) { @@ -77,7 +77,7 @@ function my_assert_handler($file, $line, $code) Line '$line'
Code '$code'

"; } -assert_options(ASSERT_CALLBACK, 'my_assert_handler'); +//assert_options(ASSERT_CALLBACK, 'my_assert_handler'); /******************************************************************************************************************/ /* Utilities /******************************************************************************************************************/ diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index d94dd2a37..1e1bc1ac3 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -47,9 +47,9 @@ class Acc_Ledger_Search * - 1 means all the ledger of this type * - 0 No have the "Tous les journaux" availables * @param $div is the div (for reconciliation) - * @param type $p_type - * @param type $p_all - * @param type $p_div + * @param string $p_type ACH, VEN , ODS or FIN + * @param int $p_all 1 means all the ledger + * @param string $p_div prefix of the DOM ID * * @todo the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales... */ diff --git a/include/class/lettering.class.php b/include/class/lettering.class.php index 33b1fc1c1..3c17143ad 100644 --- a/include/class/lettering.class.php +++ b/include/class/lettering.class.php @@ -32,7 +32,13 @@ * - "start"=>"start", => date of the first day * - "end"=>"end", => date of the last day * - "sql_ledger"=>"sql_ledger" => the sql clause to filter on the available ledgers + * + * @see unit-test/include/class/acc_letterTest.php */ + + + + class Lettering { @@ -50,6 +56,7 @@ class Lettering var $sql_ledger; var $object_type; var $content; + /** * constructor * @param $p_init resource to database @@ -479,8 +486,12 @@ class Lettering } /** - * only for operation retrieved thanks a account (jrnx.j_poste) + *@class + * @brief only for operation retrieved thanks a account (jrnx.j_poste) * manage the accounting entries for a given account + * + * @see unit-test/include/class/acc_letterTest.php + * */ class Lettering_Account extends Lettering { diff --git a/include/class/todo_list.class.php b/include/class/todo_list.class.php index af3928e89..94e6bf507 100644 --- a/include/class/todo_list.class.php +++ b/include/class/todo_list.class.php @@ -79,7 +79,8 @@ class Todo_List } if ( strcmp ($p_idx, 'tl_date') == 0 ) { - if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) return false; + if ( noalyss_strlentrim($p_value) ==0 ||strlen($p_value) > 12 || isDate ($p_value) == false) + { $p_value = null;return true;} } if ( strcmp ($p_idx, 'tl_title') == 0 ) { @@ -113,7 +114,7 @@ class Todo_List { if ( isDate($this->tl_date) == false ) { - $this->tl_date=date('d.m.Y'); + $this->tl_date=null; } return 0; } @@ -129,7 +130,7 @@ class Todo_List { if ( $this->verify() != 0 ) return; if (trim($this->tl_title)=='') - $this->tl_title=mb_substr(trim($this->tl_desc),0,30); + $this->tl_title=mb_substr(trim($this->tl_desc??""),0,30); if (trim($this->tl_title)=='') { @@ -142,6 +143,12 @@ class Todo_List $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ". " values (to_date($1,'DD.MM.YYYY'),$2,$3,$4,$5) returning tl_id"; + + if ($this->tl_date == null) { + $sql="insert into todo_list (tl_date,tl_title,tl_desc,use_login,is_public) ". + " values ($1,$2,$3,$4,$5) returning tl_id"; + + } $res=$this->cn->exec_sql( $sql, array($this->tl_date, @@ -172,6 +179,11 @@ class Todo_List $sql="update todo_list set tl_title=$1,tl_date=to_date($2,'DD.MM.YYYY'),tl_desc=$3,is_public=$5 ". " where tl_id = $4"; + + if ($this->tl_date == null) { + $sql="update todo_list set tl_title=$1,tl_date=$2,tl_desc=$3,is_public=$5 ". + " where tl_id = $4"; + } $res=$this->cn->exec_sql( $sql, array($this->tl_title, @@ -296,7 +308,7 @@ class Todo_List } /** - * Display the note + * @brief Display the note * @return html string */ function display() diff --git a/include/lettering.gestion.inc.php b/include/lettering.gestion.inc.php index e3251389c..ac201118d 100644 --- a/include/lettering.gestion.inc.php +++ b/include/lettering.gestion.inc.php @@ -1,7 +1,29 @@ '; @@ -22,13 +44,13 @@ $periode=new Periode($cn); list($first_per,$last_per)=$periode->get_limit($exercice); $start=new IDate('start'); -$start->value=(isset($_GET['start']))?$http->get('start'):$first_per->first_day(); +$start->value=(isset($_GET['start']))?$http->get('start','date'):$first_per->first_day(); $r=td(_('Date début')); $r.=td($start->input()); echo tr($r); $end=new IDate('end'); -$end->value=(isset($_GET['end']))?$_GET['end']:$last_per->last_day(); +$end->value=(isset($_GET['end']))?$http->get('end','date'):$last_per->last_day(); $r=td(_('Date fin')); $r.=td($end->input()); echo tr($r); @@ -52,7 +74,7 @@ echo '
'; echo HtmlInput::submit("seek",_('Recherche')); echo ''; echo ''; -//if (! isset($_REQUEST['seek'])) exit; + echo '
'; //-------------------------------------------------------------------------------- // record the data @@ -74,7 +96,7 @@ if ( isset($_GET['start']) && isset($_GET['end'])) } } echo '
'; -$fiche=new Fiche($cn,$_REQUEST['f_id']); +$fiche=new Fiche($cn, $http->request('f_id',"number")); $quick_code=$fiche->get_quick_code(); $letter=new Lettering_Card($cn); $letter->set_parameter('quick_code',$quick_code); diff --git a/include/sql/mod1/data.sql b/include/sql/mod1/data.sql index f15f5c971..8c0ae4780 100644 --- a/include/sql/mod1/data.sql +++ b/include/sql/mod1/data.sql @@ -4,6 +4,7 @@ set search_path = public,comptaproc,pg_catalog ; SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); @@ -14,36 +15,17 @@ SET row_security = off; SELECT pg_catalog.lo_create('2346174'); - - - SELECT pg_catalog.lo_create('2346176'); - - - SELECT pg_catalog.lo_create('2346177'); - - - SELECT pg_catalog.lo_create('2346178'); - - - SELECT pg_catalog.lo_create('2346179'); - - - SELECT pg_catalog.lo_create('2346181'); - - - SELECT pg_catalog.lo_create('2346476'); - INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (800, 'Ajout de fiche', 'fiche', 'FICADD'); INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (805, 'Création, modification et effacement de fiche', 'fiche', 'FIC'); INSERT INTO public.action (ac_id, ac_description, ac_module, ac_code) VALUES (910, 'création, modification et effacement de catégorie de fiche', 'fiche', 'FICCAT'); diff --git a/include/sql/mod1/make-sql b/include/sql/mod1/make-sql index 8b725ae28..f7116ea34 100755 --- a/include/sql/mod1/make-sql +++ b/include/sql/mod1/make-sql @@ -9,7 +9,7 @@ export TEMPLATE=${DOMAIN}mod1 psql -X $TEMPLATE -c "delete from user_local_pref" psql -X $TEMPLATE -c "delete from user_local_pref" -pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql +pg_dump -Ox -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql sed -i -e "/COMMENT ON EXTENSION/d" schema.sql sed -i -e "/CREATE EXTENSION/d" schema.sql sed -ne '0,/ADD CONSTRAINT/p' schema.sql > tmpSchema.sql diff --git a/include/sql/mod1/schema.sql b/include/sql/mod1/schema.sql index fdabc9401..7e74cc61e 100644 --- a/include/sql/mod1/schema.sql +++ b/include/sql/mod1/schema.sql @@ -3,6 +3,7 @@ SET statement_timeout = 0; SET lock_timeout = 0; SET idle_in_transaction_session_timeout = 0; +SET transaction_timeout = 0; SET client_encoding = 'UTF8'; SET standard_conforming_strings = on; SELECT pg_catalog.set_config('search_path', '', false); @@ -16,6 +17,9 @@ CREATE SCHEMA comptaproc; + + + CREATE SCHEMA tva_belge; @@ -6516,8 +6520,8 @@ CREATE VIEW public.v_contact AS JOIN public.fiche_def fd ON ((f.fd_id = fd.fd_id))) WHERE (fd.frd_id = 16) ) - SELECT cd.f_id, - cd.f_enable, + SELECT f_id, + f_enable, ( SELECT fiche_detail.ad_value FROM public.fiche_detail WHERE ((fiche_detail.ad_id = 32) AND (fiche_detail.f_id = cd.f_id))) AS contact_fname, @@ -6542,7 +6546,7 @@ CREATE VIEW public.v_contact AS ( SELECT fiche_detail.ad_value FROM public.fiche_detail WHERE ((fiche_detail.ad_id = 26) AND (fiche_detail.f_id = cd.f_id))) AS contact_fax, - cd.fd_id AS card_category + fd_id AS card_category FROM contact_data cd; @@ -6642,10 +6646,10 @@ COMMENT ON VIEW public.vw_fiche_attr IS 'Some attribute for all cards'; CREATE VIEW public.vw_fiche_name AS - SELECT fiche_detail.f_id, - fiche_detail.ad_value AS name + SELECT f_id, + ad_value AS name FROM public.fiche_detail - WHERE (fiche_detail.ad_id = 1); + WHERE (ad_id = 1); @@ -7036,16 +7040,16 @@ CREATE VIEW public.v_quant_detail AS CREATE VIEW public.v_tva_rate AS - SELECT tva_rate.tva_id, - tva_rate.tva_rate, - tva_rate.tva_code, - tva_rate.tva_label, - tva_rate.tva_comment, - split_part(tva_rate.tva_poste, ','::text, 1) AS tva_purchase, - split_part(tva_rate.tva_poste, ','::text, 2) AS tva_sale, - tva_rate.tva_both_side, - tva_rate.tva_payment_purchase, - tva_rate.tva_payment_sale + SELECT tva_id, + tva_rate, + tva_code, + tva_label, + tva_comment, + split_part(tva_poste, ','::text, 1) AS tva_purchase, + split_part(tva_poste, ','::text, 2) AS tva_sale, + tva_both_side, + tva_payment_purchase, + tva_payment_sale FROM public.tva_rate; diff --git a/include/sql/mod2/make-sql b/include/sql/mod2/make-sql index 5adf3172e..eec26117c 100755 --- a/include/sql/mod2/make-sql +++ b/include/sql/mod2/make-sql @@ -9,7 +9,7 @@ export TEMPLATE=${DOMAIN}mod2 psql -X $TEMPLATE -c "delete from user_local_pref" psql -X $TEMPLATE -c "delete from user_local_pref" -pg_dump -O -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql +pg_dump -Ox -U dany -s $TEMPLATE|grep -v "COMMENT ON SCHEMA public IS 'Standard public schema';" |sed "/^--/d" > schema.sql sed -i -e "/COMMENT ON EXTENSION/d" schema.sql sed -i -e "/CREATE EXTENSION/d" schema.sql sed -ne '0,/ADD CONSTRAINT/p' schema.sql > tmpSchema.sql @@ -17,5 +17,5 @@ sed -ne '/ADD CONSTRAINT/,$p' schema.sql |sed -e '1d' > constraint.sql cp tmpSchema.sql schema.sql echo "set search_path = public,comptaproc,pg_catalog ;" > data.sql -pg_dump -O -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql +pg_dump -Ox -U dany --data-only --column-inserts -O ${TEMPLATE}|sed "/^--/d" | sed -e "/SET search_path/d" >> data.sql diff --git a/include/template/ledger_search.php b/include/template/ledger_search.php index 6a8010f03..7aca0e803 100644 --- a/include/template/ledger_search.php +++ b/include/template/ledger_search.php @@ -1,10 +1,31 @@ + - + - + - + diff --git a/sql/upgrade.sql b/sql/upgrade.sql index e69de29bb..0b72f6745 100644 --- a/sql/upgrade.sql +++ b/sql/upgrade.sql @@ -0,0 +1 @@ +ALTER TABLE public.todo_list ALTER COLUMN tl_date drop NOT NULL; \ No newline at end of file diff --git a/unit-test/include/class/acc_letter.Test.php b/unit-test/include/class/acc_letterTest.php similarity index 99% rename from unit-test/include/class/acc_letter.Test.php rename to unit-test/include/class/acc_letterTest.php index 410a5a9b1..f6be39006 100644 --- a/unit-test/include/class/acc_letter.Test.php +++ b/unit-test/include/class/acc_letterTest.php @@ -33,7 +33,7 @@ use PHPUnit\Framework\TestCase; */ require DIRTEST.'/global.php'; -class Acc_Letter extends TestCase +class Acc_LetterTest extends TestCase { /** * @var Fiche