From 3f61097799077aac1a73ee223799a26367ef9095 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Sat, 12 Jul 2014 21:52:47 +0200 Subject: [PATCH] =?UTF-8?q?task=20#995=20Am=C3=A9lioration=20ajout=20des?= =?UTF-8?q?=20journaux=20Task=20#995=20-=20CFGLED=20=20param=C3=A8tre=3D>j?= =?UTF-8?q?ournaux?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- html/js/infobulle.js | 3 + include/class_acc_ledger.php | 93 +++++++++++++++++++++++++- include/class_acc_ledger_purchase.php | 2 +- include/class_fiche_def_ref.php | 15 +++++ include/template/ledger_detail_ven.php | 8 ++- include/template/param_jrn.php | 51 +++++++++----- 6 files changed, 149 insertions(+), 23 deletions(-) diff --git a/html/js/infobulle.js b/html/js/infobulle.js index 3aa510847..77bd8bbaf 100644 --- a/html/js/infobulle.js +++ b/html/js/infobulle.js @@ -65,6 +65,9 @@ content[34]='Cliquez sur le code AD pour ouvrir le menu dans un nouvel onglet'; content[35]='Cliquez sur le chemin pour ouvrir le menu'; content[36]='En utilisant les dates d\'échéance ou de paiement, seuls les journaux de type ACH et VEN seront utilisés ,vous excluez d\'office les autres journaux'; content[37]='Les dates sont en format DD.MM.YYYY'; +content[38]='La numérotation est propre à chaque journal. Laissez à 0 pour ne pas changer le numéro'; +content[39]='Le préfixe des pièces doit être différent pour chaque journal, on peut aussi utiliser l\'année'; +content[40]='Laissez à 0 pour ne pas changer le numéro'; function showBulle(p_ctl){ d=document.getElementById('bulle'); diff --git a/include/class_acc_ledger.php b/include/class_acc_ledger.php index 8b9281d80..f5c7868f2 100644 --- a/include/class_acc_ledger.php +++ b/include/class_acc_ledger.php @@ -2198,7 +2198,79 @@ class Acc_Ledger extends jrn_def_sql $Res = $this->db->exec_sql("update jrn set jr_internal='" . $p_internal . "' where " . " jr_grpt_id = " . $this->grpt_id); } - + /** + * Return an array of default card for the ledger type given + * + * @param $p_ledger_type VEN ACH ODS or FIN + * @param $p_side D for Debit or C for credit or NA No Applicable + */ + function get_default_card($p_ledger_type,$p_side) + { + $array=array(); + $fiche_def_ref=new Fiche_Def_Ref($this->db); + // ----- for FINANCIAL ---- + if ($p_ledger_type =='FIN') + { + $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_CLIENT); + $array=array_merge ( $array , $fiche_def_ref->get_by_modele(FICHE_TYPE_FOURNISSEUR)); + $array=array_merge ( $array , $fiche_def_ref->get_by_modele(FICHE_TYPE_FIN)); + $array=array_merge ( $array , $fiche_def_ref->get_by_modele(FICHE_TYPE_ADM_TAX)); + $array=array_merge ( $array , $fiche_def_ref->get_by_modele(FICHE_TYPE_EMPL)); + + } + // --- for miscellaneous ---- + if ($p_ledger_type == 'ODS') + { + $result=$this->db->get_array('select fd_id from fiche_def'); + for ($i = 0;$iget_by_modele(FICHE_TYPE_CLIENT); + break; + case 'ACH': + $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_SER); + $array=array_merge ($array, $fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_MAR)); + $array=array_merge ($array,$fiche_def_ref->get_by_modele(FICHE_TYPE_ACH_MAT)); + break; + default : + throw new Exception(_('get_default_card p_ledger_side is invalide ['.$p_ledger_type.']')); + + } + } elseif ($p_side == 'C') + { + switch($p_ledger_type) + { + case 'VEN': + $array=$fiche_def_ref->get_by_modele(FICHE_TYPE_VENTE); + break; + case 'ACH': + $array= array_merge($array, $fiche_def_ref->get_by_modele(FICHE_TYPE_ADM_TAX)); + $array= array_merge($array, $fiche_def_ref->get_by_modele(FICHE_TYPE_FOURNISSEUR)); + break; + default : + throw new Exception(_('get_default_card p_ledger_side is invalide ['.$p_ledger_type.']')); + + } + } + return $array; + /* + $return=array(); + $return = array_values($array); + for ($i = 0;$iprec=0; $description=new ITextarea('p_description'); + $description->style='class="itextarea" style="margin:0px;"'; $description->value=$this->jrn_def_description; $str_description=$description->input(); @@ -3508,7 +3581,20 @@ class Acc_Ledger extends jrn_def_sql $wSearch->size = 20; $search = $wSearch->input(); - + // default for ACH + $default_deb_purchase = $this->get_default_card('ACH', 'D'); + $default_cred_purchase = $this->get_default_card('ACH', 'C'); + + // default for VEN + $default_deb_sale = $this->get_default_card('VEN', 'D'); + $default_cred_sale = $this->get_default_card('VEN', 'C'); + + // default for FIN + $default_fin = $this->get_default_card("FIN", ""); + + //default ods + $default_ods = $this->get_default_card("ODS", ""); + /* construct all the hidden */ $hidden = HtmlInput::hidden('p_jrn', -1); $hidden.= HtmlInput::hidden('p_action', 'jrn'); @@ -3529,13 +3615,14 @@ class Acc_Ledger extends jrn_def_sql $wType->javascript=' onchange="show_ledger_div()"'; $type = $wType->input(); $rcred = $rdeb = array(); - $wPjPref = new IText(); + $wPjPref = new IText(); $wPjPref->name = 'jrn_def_pj_pref'; $pj_pref = $wPjPref->input(); $pj_seq = ''; $last_seq = 0; $new = 1; $description=new ITextarea('p_description'); + $description->style='class="itextarea" style="margin:0px;"'; $description->value=""; $str_description=$description->input(); /* bank card */ diff --git a/include/class_acc_ledger_purchase.php b/include/class_acc_ledger_purchase.php index a0875f0d9..0c50e416a 100644 --- a/include/class_acc_ledger_purchase.php +++ b/include/class_acc_ledger_purchase.php @@ -274,7 +274,7 @@ class Acc_Ledger_Purchase extends Acc_Ledger $p_nd_amount->amount_nd_rate = $p_fiche->strAttribut(ATTR_DEF_DEPENSE_NON_DEDUCTIBLE); $p_nd_amount->compute_nd(); } - if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE) && $tva_both == 0) + if (!$p_fiche->empty_attribute(ATTR_DEF_TVA_NON_DEDUCTIBLE) && $p_tva_both == 0) { $p_nd_amount->nd_vat_rate = $p_fiche->strAttribut(ATTR_DEF_TVA_NON_DEDUCTIBLE); $p_nd_amount->compute_nd_vat(); diff --git a/include/class_fiche_def_ref.php b/include/class_fiche_def_ref.php index 49aa5aa0c..dad66407c 100644 --- a/include/class_fiche_def_ref.php +++ b/include/class_fiche_def_ref.php @@ -133,6 +133,21 @@ class Fiche_Def_Ref $this->frd_text=$r['frd_text']; $this->frd_class_base=$r['frd_class_base']; } + /** + * get category of cards by model + * @param $p_modele if the FRD_ID + * @return array of category (fd_id) + */ + function get_by_modele($p_modele) + { + $array = array(); + $result = $this->db->get_array('select fd_id from fiche_def where frd_id=$1', array($p_modele)); + for ($i = 0; $i < count($result); $i++) + { + $array[$i] = $result[$i]['fd_id']; + } + return $array; + } } ?> diff --git a/include/template/ledger_detail_ven.php b/include/template/ledger_detail_ven.php index f5f4f4343..c4ec3370f 100644 --- a/include/template/ledger_detail_ven.php +++ b/include/template/ledger_detail_ven.php @@ -1,7 +1,13 @@ +?> +
+?>
@@ -86,20 +86,18 @@ echo $str_add_button; - - - - - @@ -137,10 +132,10 @@ echo $str_add_button;
+ -
- -
+ @@ -108,22 +106,19 @@ echo $str_add_button;
+ - - - - + +
+ +
@@ -149,7 +144,13 @@ echo $str_add_button; // Show the fiche in deb section $Res=$cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label"); $num=$cn->size(); - + // default card for ACH + if ($new == 1) + { + $rdeb=$default_deb_purchase; + $rcred=$default_cred_purchase; + } + for ($i=0;$i<$num;$i++) { $res=$cn->fetch($i); $CHECKED=" unchecked"; @@ -201,6 +202,12 @@ echo $str_add_button; // Show the fiche in deb section $Res=$cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label"); $num=$cn->size(); + // default card for VEN + if ($new == 1) + { + $rdeb=$default_deb_sale; + $rcred=$default_cred_sale; + } for ($i=0;$i<$num;$i++) { $res=$cn->fetch($i); @@ -250,7 +257,11 @@ echo $str_add_button; // Show the fiche in deb section $Res=$cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label"); $num=$cn->size(); - + // default card for ODS + if ($new == 1) + { + $rdeb=$default_ods; + } for ($i=0;$i<$num;$i++) { $res=$cn->fetch($i); $CHECKED=" unchecked"; @@ -297,7 +308,11 @@ echo $str_add_button; // Show the fiche in deb section $Res=$cn->exec_sql("select fd_id,fd_label from fiche_def order by fd_label"); $num=$cn->size(); - + // default card for ACH + if ($new == 1) + { + $rdeb=$default_fin; + } for ($i=0;$i<$num;$i++) { $res=$cn->fetch($i); $CHECKED=" unchecked";
- Services, fournitures ou biens achetés (C) + Services, fournitures ou biens achetés (D) - Fournisseurs (D) + Fournisseurs (C)