diff --git a/html/admin/sql/patch/upgrade106.sql b/html/admin/sql/patch/upgrade106.sql index b4338f7eb..0ad762b74 100644 --- a/html/admin/sql/patch/upgrade106.sql +++ b/html/admin/sql/patch/upgrade106.sql @@ -11,6 +11,8 @@ update fiche_def set fd_description='Catégorie qui contient la liste des compte update fiche_def set fd_description='Catégorie qui contient la liste des fournisseurs' where fd_id=4; update fiche_def set fd_label='Services & Biens Divers',fd_description='Catégorie qui contient la liste des charges diverses' where fd_id=5; update fiche_def set fd_description='Catégorie qui contient la liste des prestations, marchandises... que l''on vend ' where fd_id=6; + +update jrn_def set jrn_deb_max_line=5 where jrn_deb_max_line is null; update version set val=107; commit; diff --git a/html/ajax_misc.php b/html/ajax_misc.php index 6850ad7d2..4f0bb4a52 100644 --- a/html/ajax_misc.php +++ b/html/ajax_misc.php @@ -569,6 +569,9 @@ EOF; case 'vw_action': require_once 'ajax_view_action.php'; break; + case 'minrow': + require_once 'ajax_min_row.php'; + break; default: var_dump($_GET); } diff --git a/html/js/acc_ledger.js b/html/js/acc_ledger.js index 172d10c2b..c3ea47c7d 100644 --- a/html/js/acc_ledger.js +++ b/html/js/acc_ledger.js @@ -140,6 +140,66 @@ function update_bank() ); } +/** + *ask the name, quick_code of the bank for the ledger + */ +function update_row(ctl) +{ + try + { + var jrn=g('p_jrn').value; + var dossier=g('gDossier').value; + var qs='gDossier='+dossier+'&op=minrow&j='+jrn+'&ctl='+ctl; + console.log(qs); + var action=new Ajax.Request( + "ajax_misc.php", + { + method:'get', + parameters:qs, + onFailure:null, + onSuccess:function(request,json) + { + try { + var answer=request.responseText.evalJSON(true); + var row=parseFloat(answer.row); + var current_row=parseFloat($('nb_item').value); + info_message("avant "+$('nb_item').value+"Maintenant "+row); + if ( current_row > row ) { + // Too many row + var delta=$('nb_item').value-row; + var idx=$('nb_item').value; + console.log("delta "+delta); + console.log("idx"+idx); + for (var i=0;icheck_jrn($_GET['j'])=='X' ) { echo '{"row":"0"}';exit();} + +$row=$cn->get_value('select jrn_deb_max_line from jrn_def where jrn_def_id=$1',array($_GET['j'])); + +echo '{"row":"'.$row.'"}'; + +?> diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index a7ad8eb77..ab2973014 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -1527,7 +1527,11 @@ class Acc_Ledger extends jrn_def_sql $ret.=''; return $ret; } - + function get_min_row() + { + $row=$this->db->get_value("select jrn_deb_max_line from jrn_def where jrn_def_id=$1",array($this->id)); + return $row; + } /** * @brief Show the form to encode your operation * @param$p_array if you correct or use a predef operation (default = null) @@ -1539,7 +1543,7 @@ class Acc_Ledger extends jrn_def_sql function input($p_array = null, $p_readonly = 0) { global $g_parameter, $g_user; - + $this->nb=$this->get_min_row(); if ($p_readonly == 1) return $this->confirm($p_array); @@ -1554,6 +1558,7 @@ class Acc_Ledger extends jrn_def_sql { $add_js.='get_last_date();'; } + $add_js.='update_row("quick_item");'; $ret = ""; if ($g_user->check_action(FICADD) == 1) { @@ -3271,6 +3276,9 @@ class Acc_Ledger extends jrn_def_sql $hidden.=HtmlInput::hidden('p_ech_lib', 'echeance'); $hidden.=HtmlInput::hidden('p_jrn_type', $type); + $min_row = new INum("min_row",$this->jrn_deb_max_line); + $min_row->prec=0; + /* Load the card */ $card = $this->get_fiche_def(); $rdeb = explode(',', $card['deb']); @@ -3365,6 +3373,7 @@ class Acc_Ledger extends jrn_def_sql $this->jrn_def_type = $p_jrn_type; $this->jrn_def_pj_pref = $jrn_def_pj_pref; $this->jrn_def_fiche_deb = (isset($FICHEDEB)) ? join($FICHEDEB, ',') : ""; + $this->jrn_deb_max_line=$min_row; switch ($this->jrn_def_type) { case 'ACH': @@ -3458,7 +3467,8 @@ class Acc_Ledger extends jrn_def_sql echo HtmlInput::hidden('sa', 'add'); $cn = $this->db; - + $min_row = new INum("min_row",MAX_ARTICLE); + $min_row->prec=0; require_once('template/param_jrn.php'); } @@ -3478,6 +3488,7 @@ class Acc_Ledger extends jrn_def_sql $this->jrn_def_type = $p_jrn_type; $this->jrn_def_pj_pref = $jrn_def_pj_pref; $this->jrn_def_fiche_deb = (isset($FICHEDEB)) ? join($FICHEDEB, ',') : ""; + $this->jrn_deb_max_line=$min_row; $this->jrn_def_code = sprintf("%s%02d", trim(substr($this->jrn_def_type, 0, 1)), Acc_Ledger::next_number($this->db, $this->jrn_def_type)); switch ($this->jrn_def_type) diff --git a/include/class_acc_ledger_fin.php b/include/class_acc_ledger_fin.php index 5a578b397..f6bec4b85 100644 --- a/include/class_acc_ledger_fin.php +++ b/include/class_acc_ledger_fin.php @@ -237,6 +237,8 @@ class Acc_Ledger_Fin extends Acc_Ledger $pview_only = false; + $min_article=$this->get_min_row(); + $f_add_button = new IButton('add_card'); $f_add_button->label = _('Créer une nouvelle fiche'); $f_add_button->set_attribute('ipopup', 'ipop_newcard'); @@ -291,7 +293,7 @@ class Acc_Ledger_Fin extends Acc_Ledger // Ledger (p_jrn) //-- - $onchange="update_bank();ajax_saldo('first_sold');update_name();"; + $onchange="update_bank();ajax_saldo('first_sold');update_name();update_row('fin_item');"; if ($g_parameter->MY_DATE_SUGGEST == 'Y') $onchange .= 'get_last_date();'; @@ -344,7 +346,7 @@ class Acc_Ledger_Fin extends Acc_Ledger $wLast = new INum('last_sold', $last_sold); - $max = (isset($nb_item)) ? $nb_item : MAX_ARTICLE; + $max = (isset($nb_item)) ? $nb_item : $min_article; $r.= HtmlInput::hidden('nb_item', $max); //-------------------------------------------------- diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index dd2ed7dc8..afea8abf1 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -982,7 +982,8 @@ class Acc_Ledger_Purchase extends Acc_Ledger $add_js.='get_last_date();'; } $add_js.='update_name();'; - $add_js.='update_pay_method()'; + $add_js.='update_pay_method();'; + $add_js.='update_row("sold_item");'; $wLedger=$this->select_ledger('ACH',2); if ($wLedger == null) exit (_('Pas de journal disponible')); diff --git a/include/class_acc_ledger_sold.php b/include/class_acc_ledger_sold.php index 2d271b7bc..35ea08433 100644 --- a/include/class_acc_ledger_sold.php +++ b/include/class_acc_ledger_sold.php @@ -1119,7 +1119,8 @@ class Acc_Ledger_Sold extends Acc_Ledger $add_js.='get_last_date();'; } $add_js.='update_name();'; - $add_js.='update_pay_method()'; + $add_js.='update_pay_method();'; + $add_js.='update_row("sold_item");'; $wLedger=$this->select_ledger('VEN',2); if ( $wLedger == null ) diff --git a/include/constant.php b/include/constant.php index f65b24e82..a7ba52f9e 100644 --- a/include/constant.php +++ b/include/constant.php @@ -62,9 +62,9 @@ $g_failed=""; $g_succeed=""; /*set to none for production */ /* uncomment for production */ -//define ('SVNINFO',5900); +define ('SVNINFO',5900); $version_phpcompta=SVNINFO; -define ("DEBUG",false); +define ("DEBUG",true); /* define ('SVNINFO',5015); * $version_phpcompta=SVNINFO; * define ("DEBUG",true); @@ -81,7 +81,7 @@ define ("DBVERSIONREPO",14); define ('NOTFOUND','--not found--'); define ("MAX_COMPTE",4); -define ('MAX_ARTICLE',12); +define ('MAX_ARTICLE',5); define ('MAX_CAT',15); define ('MAX_CARD_SEARCH',550); define ('MAX_FORECAST_ITEM',10); diff --git a/include/template/param_jrn.php b/include/template/param_jrn.php index 2d68521bd..cdfc93dbf 100644 --- a/include/template/param_jrn.php +++ b/include/template/param_jrn.php @@ -4,7 +4,7 @@ - @@ -18,10 +18,10 @@ if ($new || $type=='ODS' ): utiliser le * pour indiquer 'tous les postes qui en dépendent' exemple: 4*")?> - - @@ -37,7 +37,7 @@ if ( $new || $type=='FIN') { -name='bank'; $card->extra=$cn->make_list('select fd_id from fiche_def where frd_id=4'); @@ -55,12 +55,13 @@ echo $card->input(); - - + Minimum de lignes à afficher +input()?> @@ -116,12 +117,12 @@ echo $card->input();

Fiches

- -