task #995 Amélioration ajout des journaux

Task #995 - CFGLED  paramètre=>journaux
This commit is contained in:
Dany De Bontridder 2014-07-12 21:52:47 +02:00
parent bd8c5972f8
commit 3f61097799
6 changed files with 149 additions and 23 deletions

View file

@ -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');

View file

@ -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;$i<count($result);$i++ )
{
$array[$i]=$result[$i]['fd_id'];
}
}
if ($p_side == 'D')
{
switch($p_ledger_type)
{
case 'VEN':
$array=$fiche_def_ref->get_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;$i<count($array);$i++ )
{
$return[$i]=$array[$i]['fd_id'];
}
return $return;
*
*/
}
/**
* @brief retrieve all the card for this type of ledger, make them
* into a string separated by comma
@ -3340,6 +3412,7 @@ class Acc_Ledger extends jrn_def_sql
$min_row->prec=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 */

View file

@ -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();

View file

@ -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;
}
}
?>

View file

@ -1,7 +1,13 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
?><?php require_once('template/ledger_detail_top.php'); ?>
?><?php require_once('ledger_detail_top.php'); ?>
<?php
$tab_account=$div."account";
$tab_rapprochement=$div."rapproch";
$tab_receipt=$div."receipt";
$tab_document=$div."document";
?>
<div class="content" style="padding:0;">
<?php
require_once('class_own.php');

View file

@ -1,7 +1,7 @@
<?php
//This file is part of NOALYSS and is under GPL
//see licence.txt
?><TABLE>
?><TABLE style="width: auto">
<TR>
<TD><?php echo _('Nom journal')?> </TD>
@ -86,20 +86,18 @@ echo $str_add_button;
</TR>
<TR>
<TD><?php echo _('Préfixe pièce justificative')?>
<?php echo HtmlInput::infobulle(39);?>
</TD>
<TD>
<?php echo $pj_pref; ?>
</TD>
<TD>
<span class="notice"><?php echo _('Le préfixe des pièces doit être différent pour chaque journal, on peut aussi utiliser l\'année')?></span><br>
<span class="notice"><?php echo _('Uniquement des chiffres')?></span>
</TD>
</TR>
<?php if ( $new == 0 ) : ?>
<TR>
<TD>
<?php echo _('Dernière pièce numérotée')?>
<?php echo HtmlInput::infobulle(40);?>
</TD>
<TD>
<?php echo $last_seq?>
@ -108,22 +106,19 @@ echo $str_add_button;
<tr>
<TD><?php echo _('N° pièce justificative')?>
<?php echo HtmlInput::infobulle(38);?>
</TD>
<TD>
<?php echo $pj_seq; ?>
</TD>
<TD>
<span class="notice" style="display:block"><?php echo _('La numérotation est propre à chaque journal')?></span>
<span class="notice" style="display:block"><?php echo _('Laissez à 0 pour ne pas changer le numéro')?></span>
<?php echo $pj_seq; ?>
</TD>
</tr>
<?php endif; ?>
<tr>
<td>
<td style="width: 200px">
<?php echo _('Description') ?>
</TD>
<td>
<td style="width: 500px">
<?php echo $str_description; ?>
</td>
</tr>
@ -137,10 +132,10 @@ echo $str_add_button;
<TABLE class="result" style="width:80%;margin-left:10%;">
<tr>
<th>
Services, fournitures ou biens achetés (C)
Services, fournitures ou biens achetés (D)
</th>
<th>
Fournisseurs (D)
Fournisseurs (C)
</th>
</tr>
@ -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";