diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 5e1261b5b..e79e3b0f8 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -266,6 +266,8 @@ $path = array( "save_filter"=>"ajax_search_filter", // Load a search filter "load_filter"=>"ajax_search_filter", + // display a list of filter (alias saved search) + "display_list_filter"=>"ajax_search_filter", // display tag for filter 'display_filter_tag'=>'ajax_search_filter', // search operation to reconcile diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 6298d53ad..7ca3b0422 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -1672,6 +1672,28 @@ function reset_filter(p_div) { // By default , unpaid is uncked $(p_div + "operation_filter").value = "all"; } +function display_list_filter(p_dossier,access_code,ledger_type) +{ + new Ajax.Request("ajax_misc.php",{ + parameters:{"gDossier":p_dossier + ,"op":"display_list_filter" + ,"ac":access_code + ,'ledger_type':ledger_type + }, + method:'GET', + onSuccess: function (responseHtml) { + try { + var posy=calcy(250) + var div = create_div({"id":"display_list_filter_div", + 'cssclass': "inner_box", 'style': 'width:90%,right:5%;top:'+posy+"px"}); + div.update(responseHtml.responseText); + div.show(); + }catch (e) { + console.error(e.message); + } + } + }) +} /** * propose to duplicate an operation diff --git a/include/ajax/ajax_search_filter.php b/include/ajax/ajax_search_filter.php index 7301c4ba3..e895707ad 100644 --- a/include/ajax/ajax_search_filter.php +++ b/include/ajax/ajax_search_filter.php @@ -111,13 +111,7 @@ if ($op=="load_filter") $answer['filter_id']=0; $answer['message']=""; $filter=new User_filter_SQL($cn, $filter_id); - $record=$filter->to_array(); - - $record['desc']=$record['description']; - $record['r_jrn']=explode(",", $record['r_jrn']??""); - $record['tag']=explode(",",$record['uf_tag']??""); - $record['tag_option']=$record["uf_tag_option"]; - $record['p_currency_code']=$record['uf_currency_code']; + $record=Acc_Ledger_Search::build_array($filter); $result=array_merge($answer, $record); @@ -227,4 +221,25 @@ if ($op=='display_filter_tag') $tag_operation->update_search_cell($div); } } + return; +} +//--------------------------------------------------------------------------------------------------------------- +// display_list_filter : display a list of saved search alias filter +//---------------------------------------------------------------------------------------------------------------- +if ($op=='display_list_filter') +{ + echo \HtmlInput::title_box("Recherches sauvées",'display_list_filter_div'); + + $ledger_search=new Acc_Ledger_Search($http->request("ledger_type")); + $ledger_search->display_list_filter(); +?> + + + +getMessage(); throw $Ex; } @@ -437,7 +437,7 @@ class Acc_Bilan $zip->close(); } else { - echo __FILE__.":".__LINE__."cannot unzip model ".$filename; + echo __FILE__.":".__LINE__."cannot unzip model ".$file_base; } ob_end_clean(); @@ -738,7 +738,7 @@ class Acc_Bilan } else { - echo __FILE__.":".__LINE__."cannot unzip model ".$filename; + echo __FILE__.":".__LINE__."cannot unzip model ".$file_base; } // Remove the file we do not need anymore diff --git a/include/class/acc_ledger_search.class.php b/include/class/acc_ledger_search.class.php index 786c12914..f070b1248 100644 --- a/include/class/acc_ledger_search.class.php +++ b/include/class/acc_ledger_search.class.php @@ -42,7 +42,7 @@ class Acc_Ledger_Search /** * @brief return a HTML string with the form for the search * @param $p_type if the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase ! - * @param $all_type_ledger + * @param $all_type_ledger * values : * - 1 means all the ledger of this type * - 0 No have the "Tous les journaux" availables @@ -50,6 +50,8 @@ class Acc_Ledger_Search * @param type $p_type * @param type $p_all * @param type $p_div + * + * @todo the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales... */ function __construct($p_type, $p_all=1, $p_div="") @@ -279,7 +281,7 @@ class Acc_Ledger_Search function build_name_filter() { $name=new IText($this->div."filter_new"); - $name->placeholder=_("Nom du filtre"); + $name->placeholder=_("Nom de la recherche"); $r=$name->input(); $bt=new IButton($this->div."save_ok",_("Ajout")); $bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id()); @@ -724,7 +726,7 @@ class Acc_Ledger_Search $r.=HtmlInput::submit('search', _('Rechercher')); - $button_search=new IButton("{$this->div}button", _('Filtre')); + $button_search=new IButton("{$this->div}button", _('Recherches sauvées')); $button_search->javascript=$this->build_search_filter(); $r.=$button_search->input(); @@ -1313,4 +1315,48 @@ class Acc_Ledger_Search return $ret; } + /** + * @brief use a user_filter row and turns it into an array for + * javascript purpose + * @param User_Filter_SQL $user_filter_sql + * @return array + */ + static function build_array(User_Filter_SQL $user_filter_sql) + { + $record=$user_filter_sql->to_array(); + + $record['desc']=$record['description']; + $record['r_jrn']=explode(",", $record['r_jrn']??""); + $record['tag']=explode(",",$record['uf_tag']??""); + $record['tag_option']=$record["uf_tag_option"]; + $record['p_currency_code']=$record['uf_currency_code']; + return $record; + } + + /** + * @brief build an HTML string with a button to show the list of + * saved search + * @return string HTML button + * @throws Exception if $_REQUEST['ac'] is not set + */ + public function button_propose_filter() + { + $http=new HttpInput(); + $button=HtmlInput::button_action("Recherches sauvées", + sprintf("display_list_filter('%s','%s','%s')" + ,Dossier::id() + , $http->request("ac") + ,$this->type + ),uniqid(),'smallbutton'); + return $button; + } + + /** + * @brief display a list of saved search + */ + public function display_list_filter() + { + require_once NOALYSS_TEMPLATE."/acc_ledger_search-display_list_filter.php"; + + } } diff --git a/include/class/card_property.class.php b/include/class/card_property.class.php index 7a30159c7..58c7f73d0 100644 --- a/include/class/card_property.class.php +++ b/include/class/card_property.class.php @@ -494,11 +494,14 @@ class Card_Property } // Special traitement - // quickcode + // quickcode , if already used in ledger , it cannot be changed if ($value->ad_id==ATTR_DEF_QUICKCODE) { - $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text)); - $p_fiche->cn->exec_sql($sql); + $used = $p_fiche->cn->get_value("select count(*) from jrnx where j_qcode= $1",[$value->av_text]); + if ($used == 0) { + $sql=sprintf("select update_quick_code(%d,'%s')", $jft_id, sql_string($value->av_text)); + $p_fiche->cn->exec_sql($sql); + } continue; } // name diff --git a/include/class/extension.class.php b/include/class/extension.class.php index bf60cbdad..6f1cdacf5 100644 --- a/include/class/extension.class.php +++ b/include/class/extension.class.php @@ -253,7 +253,7 @@ class Extension extends Menu_Ref_sql } /** - * remove all the schema from the plugins + * @brief remove all the standard plugins schema * @param Database $p_cn */ static function clean(Database $p_cn) @@ -269,7 +269,7 @@ class Extension extends Menu_Ref_sql } /** - * compare the version of the plugin and the last version , propose to update it if a new version exists + * @brief compare the version of the plugin and the last version , propose to update it if a new version exists * @todo add a mechanism to check once a day * @global User $g_user * @global number $version_plugin @@ -327,6 +327,9 @@ class Extension extends Menu_Ref_sql throw new Exception(_('Manque répertoire racine'), 1); if (!isset($xml->plugin[$i]->file)) throw new Exception(_('Manque fichier à inclure'), 1); + if (!isset($xml->plugin[$i]->version)) + throw new Exception(_("Manque version de l'extension"), 1); + if (!isset($xml->plugin[$i]->depend)) $xml->plugin[$i]->depend="EXT"; if (!isset($xml->plugin[$i]->order)) @@ -340,8 +343,9 @@ class Extension extends Menu_Ref_sql } /** - * Parse a XML file to complete an array of extension objects - * @brief Create extension from XML. + * @brief Parse a XML file to complete an array of extension objects, in the plugin.xml file , you can find + * several plugins sharing some parts. + * * @param string $p_file filename * @return array array of Extension */ @@ -363,7 +367,7 @@ class Extension extends Menu_Ref_sql } catch (Exception $ex) { - echo_warning($e->getMessage()); + echo_warning($ex->getMessage()); if ($ex->getCode()==1) { continue; @@ -378,14 +382,46 @@ class Extension extends Menu_Ref_sql $extension->me_parameter='plugin_code='.trim($xml->plugin[$i]->code); $extension->depend=(isset($xml->plugin[$i]->depend))?trim($xml->plugin[$i]->depend):"EXT"; $extension->order=(isset($xml->plugin[$i]->order))?trim($xml->plugin[$i]->order):9000; + $extension->version=trim($xml->plugin[$i]->version); + $extension->noalyss_version=(isset($xml->plugin[$i]->noalyss_version))?trim($xml->plugin[$i]->noalyss_version):8000; $a_extension[]=clone $extension; } return $a_extension; } + /** + * @brief find the extension with the me_code = last part of access_code + * @param $a_extension + * @param $access_code find the ME_CODE (normally last part ) + * @return the extension or null + */ + public static function find_extension_code($a_extension,$access_code):Extension|null + { + $a_me_code=explode("/", $access_code); + if (empty($a_me_code ) ) return null; + $nb_me_code=count($a_me_code); + $me_code=$a_me_code[$nb_me_code-1]; + foreach ($a_extension as $extension) { + if ($extension->me_code==$me_code) return $extension; + } + return null; + } + public function __toString(): string { - return "Extension"; + $r = ""; + $r .= " me_code " . $this->me_code.PHP_EOL; + $r .= " me_menu.".$this->me_menu.PHP_EOL; + $r .= " version".$this->version.PHP_EOL; + $r .= " noalyss_version".$this->noalyss_version.PHP_EOL; + $r .= " me_file" . $this->me_file.PHP_EOL; + $r .= " me_url" . $this->me_url.PHP_EOL; + $r .= " me_description" . $this->me_description.PHP_EOL; + $r .= " me_parameter" . $this->me_parameter.PHP_EOL; + $r .= " me_javascript" . $this->me_javascript.PHP_EOL; + $r .= " me_type" . $this->me_type.PHP_EOL; + $r .= " me_descrition_etendue" . $this->me_description_etendue.PHP_EOL; + return "Extension $r"; } diff --git a/include/class/follow_up.class.php b/include/class/follow_up.class.php index 2821a1ee3..78ba17393 100644 --- a/include/class/follow_up.class.php +++ b/include/class/follow_up.class.php @@ -351,7 +351,7 @@ class Follow_Up $w->name='qcode_dest'; $w->value=($this->f_id_dest!=0)?$this->qcode_dest:""; $w->label=""; - $list_recipient=$this->db->make_list('select fd_id from fiche_def where frd_id in (14,25,8,9,16)'); + $list_recipient=$this->db->make_list('select fd_id from fiche_def'); $w->extra=$list_recipient; $w->set_attribute('typecard', $list_recipient); $w->set_dblclick("fill_ipopcard(this);"); diff --git a/include/constant.php b/include/constant.php index cc2868b6d..f05eb71f9 100644 --- a/include/constant.php +++ b/include/constant.php @@ -171,6 +171,7 @@ if (DEBUGNOALYSS == 0) { ini_set('log_errors', 1); ini_set('log_errors_max_len', 0); + } // Erreur define("NOERROR", 0); diff --git a/include/history_operation.inc.php b/include/history_operation.inc.php index 56b8ab3c2..a983cd50a 100644 --- a/include/history_operation.inc.php +++ b/include/history_operation.inc.php @@ -32,31 +32,33 @@ global $g_user,$cn,$http; $p_array = $_GET; $ledger_type=$http->get("ledger_type","string", 'ALL'); -$Ledger=new Acc_Ledger_Search($ledger_type,0,'search_op'); switch($ledger_type) { - case 'ACH': - $ask_pay=1; - $p_array['ledger_type']='ACH'; - break; - case 'ODS': - $ask_pay=0; - $p_array['ledger_type']='ODS'; - break; - case 'ALL': - $ask_pay=0; - $p_array['ledger_type']='ALL'; - break; - case 'VEN': - $ask_pay=1; - $p_array['ledger_type']='VEN'; - break; - case 'FIN': - $ask_pay=0; - $p_array['ledger_type']='FIN'; - break; + case 'ACH': + $ask_pay=1; + $p_array['ledger_type']='ACH'; + break; + case 'ODS': + $ask_pay=0; + $p_array['ledger_type']='ODS'; + break; + case 'ALL': + $ask_pay=0; + $p_array['ledger_type']='ALL'; + break; + case 'VEN': + $ask_pay=1; + $p_array['ledger_type']='VEN'; + break; + case 'FIN': + $ask_pay=0; + $p_array['ledger_type']='FIN'; + break; + default: + throw new \Exception("HO58 : ledger_type unknown"); } +$Ledger=new Acc_Ledger_Search($p_array['ledger_type'],0,'search_op'); echo '
'; // Check privilege $p_jrn=$http->request("p_jrn", "string",-1); @@ -113,8 +115,9 @@ $offset=(isNumber($offset)==0)?0:$offset; $bar = navigation_bar($offset, $max_line, $step, $page); echo $msg; -echo $Ledger->display_search_form(); +echo $Ledger->button_propose_filter(); echo HtmlInput::filter_table('history_operation_t', '0,1,2,3,4,5,6,7', 1); +echo $Ledger->display_search_form(); echo $bar; echo '
'; echo HtmlInput::hidden("ac", $http->request('ac')); diff --git a/include/template/acc_ledger_search-display_list_filter.php b/include/template/acc_ledger_search-display_list_filter.php new file mode 100644 index 000000000..879b3589d --- /dev/null +++ b/include/template/acc_ledger_search-display_list_filter.php @@ -0,0 +1,103 @@ +cn->get_array("select id,filter_name,description,ledger_type +from public.user_filter where login=$1 and ledger_type=$2", +[$g_user->getLogin(),$this->type]); +$nb_array=count($array); +$http=new HttpInput(); +$div="search_op"; +?> +

+ Cliquez sur un lien pour affiche le résultat de la recherche +

+ + + + diff --git a/include/template/follow_up-display.php b/include/template/follow_up-display.php index f90818fad..fe090fb2e 100644 --- a/include/template/follow_up-display.php +++ b/include/template/follow_up-display.php @@ -43,7 +43,7 @@ $dossier_id=Dossier::id(); - + search().$w->input(); diff --git a/include/template/follow_up_filter-display_list.php b/include/template/follow_up_filter-display_list.php index eb6373a79..4360109da 100644 --- a/include/template/follow_up_filter-display_list.php +++ b/include/template/follow_up_filter-display_list.php @@ -39,7 +39,7 @@ if (count($a_list) > 0) : ?>

- Cliquer sur un filtre pour chercher + Cliquez sur un lien pour affiche le résultat de la recherche

'._('Vérification des comptes' $bilan=new Acc_Bilan($cn); $periode=new Periode($cn); list ($start_periode,$end_periode)=$periode->get_limit($exercice); -$bilan->from=$start_periode->p_id; -$bilan->to=$end_periode->p_id; +global $g_parameter; +if ( $g_parameter->MY_REPORT=="Y") { + $bilan->from=$start_periode->p_id; + $bilan->to=$end_periode->p_id; + +} else { + $first_periode=$cn->get_value("select to_char(p_start,'YYYY-MM-DD') from parm_periode order by p_start limit 1"); + $bilan->from=format_date($first_periode,'YYYY-MM-DD','DD.MM.YYYY'); + $bilan->to=$end_periode->last_day(); +} $bilan->verify(); echo '

'; ?> @@ -167,9 +175,10 @@ having count(*) > 1