Fix bug in annulation, add check to validate number and card
This commit is contained in:
parent
dd6b037a47
commit
c2179cab14
10 changed files with 249 additions and 70 deletions
26
Changelog
26
Changelog
|
|
@ -1,5 +1,31 @@
|
||||||
|
2004-04-02 sparkyx <sparkyx@july.summer>
|
||||||
|
|
||||||
|
* html/annulation.php, include/central_inc.php:
|
||||||
|
Change cancel an op : j_internal=='ANNULE' and jr_internal of the cancel operation = 'ANNULE'
|
||||||
|
|
||||||
|
* html/annulation.php, include/central_inc.php, include/jrn.php:
|
||||||
|
Change centralize and jr_internal rule
|
||||||
|
|
||||||
|
* html/modify_op.php, include/jrn.php: Payment
|
||||||
|
|
||||||
|
* include/stock_inc.php: Stock include file
|
||||||
|
|
||||||
|
* html/annulation.php, html/fiche_new.php, html/fiche_search.php, html/jrn_search.php, html/login.php, html/print_balance.php, html/stock.php, html/user_login.php, include/constant.php, include/form_input.php, include/jrn.php, include/postgres.php, include/user_common.php, include/user_menu.php, sql/account_repository.sql, sql/demo.sql, sql/mod-be.sql, FAQ-fr.txt, doc/FAQ-fr.txt, doc/manuel-fr.sgml, html/admin_repo.php, style-light.css:
|
||||||
|
Many little Bugs fixed
|
||||||
|
|
||||||
2004-04-01 sparkyx <sparkyx@july.summer>
|
2004-04-01 sparkyx <sparkyx@july.summer>
|
||||||
|
|
||||||
|
* include/form_input.php, include/user_action_fin.php, include/user_action_ods.php:
|
||||||
|
Improve appearance in user interface for ach, ven, fin and ods
|
||||||
|
|
||||||
|
* include/compta_menu.php, include/fiche_inc.php, include/form_input.php, include/jrn.php, include/user_common.php:
|
||||||
|
code cleaning
|
||||||
|
|
||||||
|
* include/form_inc.php, html/enc_jrn.php, html/jrn_add.php, html/jrn_detail.php, html/jrn_search.php, html/poste_search.php, html/win_detail_jrn.js, html/win_search_jrn.js, html/win_search_poste.js:
|
||||||
|
remove javascript file, the javascript are now in include/constant.php (define JS_)
|
||||||
|
|
||||||
|
* Changelog: Update
|
||||||
|
|
||||||
* sql/dump-db.sql: script for creating db files
|
* sql/dump-db.sql: script for creating db files
|
||||||
|
|
||||||
* include/jrn.php: Adapt for new features (ODS, UpdateJrn...)
|
* include/jrn.php: Adapt for new features (ODS, UpdateJrn...)
|
||||||
|
|
|
||||||
|
|
@ -176,15 +176,51 @@ passe pas par des comptes d
|
||||||
|
|
||||||
</sect2>
|
</sect2>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
<sect1> Fiscalité, TVA
|
||||||
|
<p> tous les requalifications des montants doivent
|
||||||
|
se faire par le journal des opérations diverses
|
||||||
|
|
||||||
|
<sect2> Belgique
|
||||||
|
<sect3> TVA & impôt
|
||||||
|
<p> Pour faire votre déclaration tva, vous pouvez utilisez les
|
||||||
|
balances des comptes ou les formulaires.
|
||||||
|
|
||||||
|
<p>
|
||||||
|
Attention NE PAS REPRENDRE LES
|
||||||
|
MONTANTS AINSI !!!. Avant de faire votre déclaration, vous devez d'abord
|
||||||
|
rectifier les montants. Par exemple, 50% de la tva sur la voiture ne
|
||||||
|
sont pas récupérable par la tva mais par l'impôt des société.
|
||||||
|
Il faut "déplacer" 50% de cette tva dans un poste comptable tva non
|
||||||
|
admises,
|
||||||
|
cela devrait être un compte de la classe 6 (donc 6xxxx à 411xxx), les charges
|
||||||
|
augmentent mais la tva à récupérer diminue, ce qui est logique puisque
|
||||||
|
cette tva est à récupérer par l'impôt des sociétés.
|
||||||
|
|
||||||
|
<p> Idem pour les frais de restaurant, ne pas oublier pendant les
|
||||||
|
travaux de fin d'exercice,d'imputer 50% du total de vos frais de
|
||||||
|
restaurant à un compte de dépense non admise. Il n'est pas dans le
|
||||||
|
PCMN donc créer le poste vous-même (classe 67).
|
||||||
|
|
||||||
|
<p>De plus si vous utilisez la voiture pour votre usage personnel, 2/7
|
||||||
|
doivent être mis sur le compte exploitant dans le cas d'une
|
||||||
|
sprl. C'est-à-dire qu'il
|
||||||
|
faut diminuer les charges 6xxxx frais de voiture à 41xxx Compte de
|
||||||
|
l'exploitant. Et de la même manière, diminuer la tva de vos frais de
|
||||||
|
voiture de 2/7.
|
||||||
|
</sect3>
|
||||||
|
|
||||||
|
<sect2> France
|
||||||
|
<p> Pas reçu de doc ni d'aide sur ce sujet désolé
|
||||||
|
</sect2>
|
||||||
|
</sect1>
|
||||||
|
|
||||||
|
|
||||||
</sect>
|
</sect>
|
||||||
<sect> Les profils
|
<sect> Les modes
|
||||||
<p>
|
<p>
|
||||||
Dans le menu préférence, il existe deux sortes d'interface que vous pouvez utiliser,
|
Dans le menu préférence, il existe deux sortes d'interface que vous pouvez utiliser,
|
||||||
</p>
|
</p>
|
||||||
<sect1>Le profil comptable
|
<sect1>Le mode comptable
|
||||||
<p>
|
<p>
|
||||||
Dans ce cas, vous verrez votre comptabilité comme un comptable s'attend à la voir
|
Dans ce cas, vous verrez votre comptabilité comme un comptable s'attend à la voir
|
||||||
avec des postes comptables, des écritures comptables impliquant des
|
avec des postes comptables, des écritures comptables impliquant des
|
||||||
|
|
@ -196,7 +232,7 @@ r
|
||||||
mal encodé, vous devez introduire l'écriture comptable inverse pour
|
mal encodé, vous devez introduire l'écriture comptable inverse pour
|
||||||
corriger, pensez à mettre la mention "correction d'erreur"
|
corriger, pensez à mettre la mention "correction d'erreur"
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1>Le profil utilisateur
|
<sect1>Le mode utilisateur
|
||||||
<p>
|
<p>
|
||||||
Dans ce cas, vous verrez votre comptabilité comme un utilisateur, facture à payer, facture à encoder...
|
Dans ce cas, vous verrez votre comptabilité comme un utilisateur, facture à payer, facture à encoder...
|
||||||
|
|
||||||
|
|
@ -246,6 +282,12 @@ exemple :
|
||||||
Ceux qui terminent par une étoile reprennent les comptes qui commence
|
Ceux qui terminent par une étoile reprennent les comptes qui commence
|
||||||
par l'expression ainsi 411* reprendra 411, 4111, 4112,4113 et
|
par l'expression ainsi 411* reprendra 411, 4111, 4112,4113 et
|
||||||
4114. Vous séparez les différents comptes par un espace.
|
4114. Vous séparez les différents comptes par un espace.
|
||||||
|
|
||||||
|
Il vaut mieux ne pas créer plus de 4 journaux par types, c'est-à-dire
|
||||||
|
16 au total, il y a à cela deux raisons : la première est que cela
|
||||||
|
devient ingérable, la seconde est que l'affichage en mode utilisateur
|
||||||
|
serait euh... atroce. Quatre journaux en tout est largement suffisant
|
||||||
|
pour les besoins d'une entreprise.
|
||||||
<sect1> Journal des Achats
|
<sect1> Journal des Achats
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1> Journal des Ventes
|
<sect1> Journal des Ventes
|
||||||
|
|
@ -288,7 +330,10 @@ vous devrez mettre manuellement le poste comptable
|
||||||
</sect1>
|
</sect1>
|
||||||
<sect1>Création d'une fiche
|
<sect1>Création d'une fiche
|
||||||
<p>
|
<p>
|
||||||
Quelques attributs à expliquer : Gestion Poste, Prix Achat, Prix de vente, Poste Comptable
|
Quelques attributs à expliquer : Gestion Poste, Prix Achat, Prix de
|
||||||
|
vente, Poste Comptable. Vous n'êtes pas obligé de créer une fiche pour
|
||||||
|
tout, par exemple pour les restaurants, vous pouvez encodez une seule
|
||||||
|
et unique fiche appelée restaurant.
|
||||||
|
|
||||||
</p>
|
</p>
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
@ -507,6 +552,5 @@ encoder dans le journal financier, ne pas oublier le rapprochement
|
||||||
Banque : le client nous a payé pour la facture du 21
|
Banque : le client nous a payé pour la facture du 21
|
||||||
encoder dans le journal financier, ne pas oublier le rapprochement
|
encoder dans le journal financier, ne pas oublier le rapprochement
|
||||||
</sect1>
|
</sect1>
|
||||||
|
|
||||||
</sect>
|
</sect>
|
||||||
</article>
|
</article>
|
||||||
|
|
|
||||||
|
|
@ -55,9 +55,10 @@ if ( isset ($annul) ) {
|
||||||
if ( isset ($_POST['p_id'])) {
|
if ( isset ($_POST['p_id'])) {
|
||||||
// Get the current periode
|
// Get the current periode
|
||||||
$period=GetUserPeriode($cn,$g_user);
|
$period=GetUserPeriode($cn,$g_user);
|
||||||
|
$p_id=$_POST['p_id'];
|
||||||
// Check if it a centralize operation
|
// Check if it a centralize operation
|
||||||
if ( isCentralize($cn,$p_id) == 0 ) {
|
if ( isCentralize($cn,$p_id) == 0 and
|
||||||
|
isValid($cn,$p_id) == 1 ) {
|
||||||
|
|
||||||
// get the next op id
|
// get the next op id
|
||||||
$seq=GetNextId($cn,'j_grpt')+1;
|
$seq=GetNextId($cn,'j_grpt')+1;
|
||||||
|
|
@ -69,33 +70,35 @@ if ( isset ($annul) ) {
|
||||||
)
|
)
|
||||||
select
|
select
|
||||||
j_montant, j_poste, $seq, j_jrn_def, case when j_debit=false then true else false end,
|
j_montant, j_poste, $seq, j_jrn_def, case when j_debit=false then true else false end,
|
||||||
j_text,'ANNULE,'$g_user',$period
|
j_text,'ANNULE','$g_user',$period
|
||||||
from jrnx where j_grpt=".$_POST['p_id'];
|
from jrnx where j_grpt=".$_POST['p_id'];
|
||||||
$Res=ExecSql($cn,$sql);
|
$Res=ExecSql($cn,$sql);
|
||||||
|
|
||||||
|
|
||||||
// build the sql stmt for jrn
|
// build the sql stmt for jrn
|
||||||
$sql= "insert into jrn (
|
$sql= "insert into jrn (
|
||||||
jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per
|
jr_def_id,jr_montant,jr_comment, jr_date,jr_grpt_id,jr_internal ,jr_tech_per,
|
||||||
|
jr_valid
|
||||||
) select
|
) select
|
||||||
jr_def_id,jr_montant,'Annulation '||jr_comment,jr_date,$seq ,'ANNULE', $period
|
jr_def_id,jr_montant,'Annulation '||jr_comment,jr_date,$seq ,'ANNULE', $period,
|
||||||
|
false
|
||||||
from
|
from
|
||||||
jrn
|
jrn
|
||||||
where jr_grpt_id=".$_POST['p_id'];
|
where jr_grpt_id=".$_POST['p_id'];
|
||||||
$Res=ExecSql($cn,$sql);
|
$Res=ExecSql($cn,$sql);
|
||||||
|
|
||||||
// also in the stock table
|
// also in the stock table
|
||||||
$sql="insert into stock_goods (
|
$sql="delete from stock_goods where sg_id = any ( select sg_id
|
||||||
j_id,f_id,sg_quantity,sg_type
|
from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'].")";
|
||||||
) select
|
|
||||||
j_id,f_id,sg_quantity, case when sg_type='c' then 'd' else 'c' end
|
|
||||||
from stock_goods natural join jrnx where j_grpt=".$_POST['p_id'];
|
|
||||||
$Res=ExecSql($cn,$sql);
|
$Res=ExecSql($cn,$sql);
|
||||||
|
// Update jr_valid
|
||||||
|
$Res=ExecSql($cn,"update jrn set jr_valid=false where jr_grpt_id=$p_id");
|
||||||
|
echo '<h2 class="info"> Opération annulée</h2>';
|
||||||
}
|
}
|
||||||
echo '<h2 class="info"> Opération annulée</h2>';
|
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
window.close();
|
window.close();
|
||||||
self.opener.RefreshMe();
|
self.opener.RefreshMe();
|
||||||
</script>
|
</script>
|
||||||
<?
|
<?
|
||||||
|
|
|
||||||
|
|
@ -279,7 +279,7 @@ function cal()
|
||||||
);
|
);
|
||||||
// Sql string
|
// Sql string
|
||||||
define ("SQL_LIST_ALL_INVOICE","");
|
define ("SQL_LIST_ALL_INVOICE","");
|
||||||
define ("SQL_LIST_UNPAID_INVOICE"," where (jr_rapt is null or jr_rapt = '')");
|
define ("SQL_LIST_UNPAID_INVOICE"," where (jr_rapt is null or jr_rapt = '') and jr_valid = true ");
|
||||||
define ("SQL_LIST_UNPAID_INVOICE_DATE_LIMIT" ," where (jr_rapt is null or jr_rapt = '')
|
define ("SQL_LIST_UNPAID_INVOICE_DATE_LIMIT" ," where (jr_rapt is null or jr_rapt = '')
|
||||||
and to_date(to_char(jr_ech,'DD.MM.YYYY'),'DD.MM.YYYY') < to_date(to_char(now(),'DD.MM.YYYY'),'DD.MM.YYYY')");
|
and to_date(to_char(jr_ech,'DD.MM.YYYY'),'DD.MM.YYYY') < to_date(to_char(now(),'DD.MM.YYYY'),'DD.MM.YYYY') and jr_valid = true" );
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -737,7 +737,6 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
|
|
||||||
// Save old value and set a new one
|
// Save old value and set a new one
|
||||||
$e_client=( isset ($e_client) )?$e_client:"";
|
$e_client=( isset ($e_client) )?$e_client:"";
|
||||||
// $r.='<TR>'.InputType("Fournisseur","SELECT","e_client",$customer,$view_only,$fiche).'</TR>';
|
|
||||||
|
|
||||||
$e_client_label="";
|
$e_client_label="";
|
||||||
|
|
||||||
|
|
@ -790,6 +789,7 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
echo_error($msg); echo_error($msg);
|
echo_error($msg); echo_error($msg);
|
||||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||||
$march_buy=0;
|
$march_buy=0;
|
||||||
|
if ( $view_only ) return null;
|
||||||
}
|
}
|
||||||
$march_tva_label="";
|
$march_tva_label="";
|
||||||
$march_label="";
|
$march_label="";
|
||||||
|
|
@ -801,6 +801,7 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
echo_error($msg); echo_error($msg);
|
echo_error($msg); echo_error($msg);
|
||||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||||
$march="";
|
$march="";
|
||||||
|
if ( $view_only ) return null;
|
||||||
} else {
|
} else {
|
||||||
// retrieve the tva label and name
|
// retrieve the tva label and name
|
||||||
$a_fiche=GetFicheAttribut($p_cn, $march);
|
$a_fiche=GetFicheAttribut($p_cn, $march);
|
||||||
|
|
@ -809,6 +810,13 @@ function FormAch($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
$march_label=$a_fiche['vw_name'];
|
$march_label=$a_fiche['vw_name'];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if ( $view_only ) {
|
||||||
|
$msg="Fiche inexistante !!! ";
|
||||||
|
echo_error($msg); echo_error($msg);
|
||||||
|
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
$r.='<TR>'.InputType("","js_search","e_march".$i,$march,$view_only,'deb');
|
$r.='<TR>'.InputType("","js_search","e_march".$i,$march,$view_only,'deb');
|
||||||
$r.=InputType("","span", "e_march".$i."_label", $march_label,$view_only);
|
$r.=InputType("","span", "e_march".$i."_label", $march_label,$view_only);
|
||||||
|
|
@ -923,7 +931,7 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn)
|
||||||
$j_id=InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste,$e_date,$a_price[$i]*$a_quant[$i],$seq,$periode);
|
$j_id=InsertJrnx($p_cn,'d',$p_user,$p_jrn,$poste,$e_date,$a_price[$i]*$a_quant[$i],$seq,$periode);
|
||||||
// if ( withStock($p_cn,$a_good[$i]) == true )
|
// if ( withStock($p_cn,$a_good[$i]) == true )
|
||||||
// always save quantity but in withStock we can find what card need a stock management
|
// always save quantity but in withStock we can find what card need a stock management
|
||||||
InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'c');
|
InsertStockGoods($p_cn,$j_id,$a_good[$i],$a_quant[$i],'d');
|
||||||
}
|
}
|
||||||
// Insert Vat
|
// Insert Vat
|
||||||
if (sizeof($a_vat) != 0 ) // no vat
|
if (sizeof($a_vat) != 0 ) // no vat
|
||||||
|
|
@ -934,14 +942,16 @@ function RecordAchat($p_cn,$p_array,$p_user,$p_jrn)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
echo_debug("echeance = $e_ech");
|
echo_debug("echeance = $e_ech");
|
||||||
InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"",$amount+$sum_vat,$seq,$periode);
|
if ( ($amount+$sum_vat) != 0 ){
|
||||||
// Set Internal code and Comment
|
InsertJrn($p_cn,$e_date,$e_ech,$p_jrn,"",$amount+$sum_vat,$seq,$periode);
|
||||||
$comment=SetInternalCode($p_cn,$seq,$p_jrn)." client : ".GetFicheName($p_cn,$e_client);
|
// Set Internal code and Comment
|
||||||
if ( $e_comment=="" ) {
|
$comment=SetInternalCode($p_cn,$seq,$p_jrn)." client : ".GetFicheName($p_cn,$e_client);
|
||||||
// Update comment if comment is blank
|
if ( $e_comment=="" ) {
|
||||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
// Update comment if comment is blank
|
||||||
|
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||||
|
}
|
||||||
|
return $comment;
|
||||||
}
|
}
|
||||||
return $comment;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function FormFin($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_item=1)
|
/* function FormFin($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_item=1)
|
||||||
|
|
@ -1007,16 +1017,25 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
|
|
||||||
// retrieve e_bank_account_label
|
// retrieve e_bank_account_label
|
||||||
if ( isNumber($e_bank_account) == 1 ) {
|
if ( isNumber($e_bank_account) == 1 ) {
|
||||||
if ( isFicheOfJrn($p_cn,$p_jrn,$e_bank_account,'cred') == 0 ) {
|
if ( isFicheOfJrn($p_cn,$p_jrn,$e_bank_account,'deb') == 0 ) {
|
||||||
$msg="Fiche inexistante !!! ";
|
$msg="Fiche inexistante !!! ";
|
||||||
echo_error($msg); echo_error($msg);
|
echo_error($msg); echo_error($msg);
|
||||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||||
$e_bank_account="";
|
$e_bank_account="";
|
||||||
|
echo_debug("FormFin returns NULL the bank account is not valid");
|
||||||
|
return null;
|
||||||
} else {
|
} else {
|
||||||
$a_client=GetFicheAttribut($p_cn,$e_bank_account);
|
$a_client=GetFicheAttribut($p_cn,$e_bank_account);
|
||||||
if ( $a_client != null)
|
if ( $a_client != null)
|
||||||
$e_bank_account_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp'];
|
$e_bank_account_label=$a_client['vw_name']." adresse ".$a_client['vw_addr']." ".$a_client['vw_cp'];
|
||||||
}
|
}
|
||||||
|
}else {
|
||||||
|
|
||||||
|
if ( $view_only ==true) {
|
||||||
|
return null;
|
||||||
|
echo_debug("FormFin returns NULL the bank account is not valid");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$r.='<TR>'.InputType("Banque","js_search","e_bank_account",$e_bank_account,$view_only,FICHE_TYPE_FIN).'</TR>';
|
$r.='<TR>'.InputType("Banque","js_search","e_bank_account",$e_bank_account,$view_only,FICHE_TYPE_FIN).'</TR>';
|
||||||
|
|
@ -1062,7 +1081,7 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
$tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:"";
|
$tiers_comment=(isset (${"e_other$i"."_comment"}))?${"e_other$i"."_comment"}:"";
|
||||||
// If $tiers has a value
|
// If $tiers has a value
|
||||||
if ( isNumber($tiers) == 1 ) {
|
if ( isNumber($tiers) == 1 ) {
|
||||||
if ( isFicheOfJrn($p_cn,$p_jrn,$tiers,'deb') == 0 ) {
|
if ( isFicheOfJrn($p_cn,$p_jrn,$tiers,'cred') == 0 ) {
|
||||||
$msg="Fiche inexistante !!! ";
|
$msg="Fiche inexistante !!! ";
|
||||||
echo_error($msg); echo_error($msg);
|
echo_error($msg); echo_error($msg);
|
||||||
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
echo "<SCRIPT>alert('$msg');</SCRIPT>";
|
||||||
|
|
@ -1078,7 +1097,7 @@ function FormFin($p_cn,$p_jrn,$p_user,$p_submit,$p_array=null,$view_only=true,$p
|
||||||
${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;
|
${"e_other$i"."_amount"}=(isset (${"e_other$i"."_amount"}))?${"e_other$i"."_amount"}:0;
|
||||||
// Compute the string to pass to InputType
|
// Compute the string to pass to InputType
|
||||||
$f=FICHE_TYPE_CLIENT.",".FICHE_TYPE_FOURNISSEUR.",".FICHE_TYPE_ADM_TAX.",".FICHE_TYPE_FIN;
|
$f=FICHE_TYPE_CLIENT.",".FICHE_TYPE_FOURNISSEUR.",".FICHE_TYPE_ADM_TAX.",".FICHE_TYPE_FIN;
|
||||||
$r.='<TR>'.InputType("","js_search","e_other".$i,$tiers,$view_only,$f);
|
$r.='<TR>'.InputType("","js_search","e_other".$i,$tiers,$view_only,'cred');
|
||||||
$r.=InputType("","span", "e_other$i"."_label", $tiers_label,$view_only);
|
$r.=InputType("","span", "e_other$i"."_label", $tiers_label,$view_only);
|
||||||
// Comment
|
// Comment
|
||||||
$r.=InputType("","Text","e_other$i"."_comment",$tiers_comment,$view_only);
|
$r.=InputType("","Text","e_other$i"."_comment",$tiers_comment,$view_only);
|
||||||
|
|
@ -1123,7 +1142,7 @@ return $r;
|
||||||
* true on success
|
* true on success
|
||||||
*/
|
*/
|
||||||
function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
||||||
|
echo_debug("RecordFin");
|
||||||
foreach ( $p_array as $v => $e)
|
foreach ( $p_array as $v => $e)
|
||||||
{
|
{
|
||||||
${"$v"}=$e;
|
${"$v"}=$e;
|
||||||
|
|
@ -1186,7 +1205,7 @@ function RecordFin($p_cn,$p_array,$p_user,$p_jrn) {
|
||||||
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
$Res=ExecSql($p_cn,"update jrn set jr_comment='".$comment."' where jr_grpt_id=".$seq);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $comment;
|
|
||||||
}
|
}
|
||||||
/* function FormODS($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_article=1)
|
/* function FormODS($p_cn,$p_jrn,$p_user,$p_array=null,$view_only=true,$p_article=1)
|
||||||
* Purpose : Display the miscellaneous operation
|
* Purpose : Display the miscellaneous operation
|
||||||
|
|
|
||||||
|
|
@ -968,7 +968,7 @@ function NextJrn($p_cn,$p_type)
|
||||||
*/
|
*/
|
||||||
function SetInternalCode($p_cn,$p_grpt,$p_jrn)
|
function SetInternalCode($p_cn,$p_grpt,$p_jrn)
|
||||||
{
|
{
|
||||||
$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn where jr_internal != 'ANNULE'");
|
$num=CountSql($p_cn,"select * from jrn where jr_def_id=$p_jrn and jr_internal != 'ANNULE'");
|
||||||
$atype=GetJrnProperty($p_cn,$p_jrn);
|
$atype=GetJrnProperty($p_cn,$p_jrn);
|
||||||
$type=$atype['jrn_def_code'];
|
$type=$atype['jrn_def_code'];
|
||||||
$internal_code=sprintf("%s-%05d",$type,$num);
|
$internal_code=sprintf("%s-%05d",$type,$num);
|
||||||
|
|
|
||||||
|
|
@ -31,29 +31,23 @@
|
||||||
* return: string containing the table
|
* return: string containing the table
|
||||||
*/
|
*/
|
||||||
function ViewStock($p_cn,$p_year) {
|
function ViewStock($p_cn,$p_year) {
|
||||||
|
// build sql
|
||||||
// build sql
|
$sql=" select C.sg_code,sum(deb) as deb_sum,sum(cred) as cred_sum
|
||||||
$sql= 'select C.sg_code,sum(deb) as deb_sum,sum(cred) as cred_sum
|
from jrnx
|
||||||
from jrnx
|
|
||||||
join stock_goods using (j_id)
|
join stock_goods using (j_id)
|
||||||
join
|
join
|
||||||
( select sg_code,
|
( select sg_code,j_id,
|
||||||
case when sg_type=\'d\' then sg_quantity else 0 end as deb,
|
case when sg_type='d' then sg_quantity else 0 end as deb,
|
||||||
case when sg_type=\'c\' then sg_quantity else 0 end as cred
|
case when sg_type='c' then sg_quantity else 0 end as cred
|
||||||
from stock_goods
|
from stock_goods
|
||||||
where sg_code is not null
|
where sg_code is not null
|
||||||
) as C on (stock_goods.sg_code=C.sg_code)
|
and sg_code != 'null'
|
||||||
left outer join (select f_id,av_text as name
|
) as C on (jrnx.j_id=C.j_id)
|
||||||
from jnt_fic_att_value join attr_value using (jft_id) where ad_id='.ATTR_DEF_NAME.'
|
where
|
||||||
) as B on stock_goods.f_id=B.f_id
|
to_char(j_date,'YYYY') = '$p_year'
|
||||||
|
group by c.sg_code";
|
||||||
|
|
||||||
|
|
||||||
where
|
|
||||||
|
|
||||||
to_char(j_date,\'YYYY\') = \''.$p_year.'\'
|
|
||||||
group by c.sg_code
|
|
||||||
';
|
|
||||||
|
|
||||||
// send the sql
|
// send the sql
|
||||||
$Res=ExecSql($p_cn,$sql);
|
$Res=ExecSql($p_cn,$sql);
|
||||||
|
|
||||||
|
|
@ -61,7 +55,8 @@ group by c.sg_code
|
||||||
// store it in a HTLM table
|
// store it in a HTLM table
|
||||||
$result="<table>";
|
$result="<table>";
|
||||||
$result.="<tr>";
|
$result.="<tr>";
|
||||||
$result.='<th>Nom</th>';
|
$result.='<th>Code</th>';
|
||||||
|
$result.='<th>Noms</th>';
|
||||||
$result.='<th>Entrée</th>';
|
$result.='<th>Entrée</th>';
|
||||||
$result.='<th>Sortie</th>';
|
$result.='<th>Sortie</th>';
|
||||||
$result.='<th>Solde</th>';
|
$result.='<th>Solde</th>';
|
||||||
|
|
@ -71,23 +66,41 @@ group by c.sg_code
|
||||||
for ($i = 0; $i < $M ; $i++ ) {
|
for ($i = 0; $i < $M ; $i++ ) {
|
||||||
$r=pg_fetch_array($Res,$i);
|
$r=pg_fetch_array($Res,$i);
|
||||||
$result.="<TR>";
|
$result.="<TR>";
|
||||||
// name and link to details
|
|
||||||
/* $result.="<td>".'<a class="one"
|
// sg_code and link to details
|
||||||
HREF="stock.php?action=detail&f_id='.$r['f_id'].'&year='.$p_year.'">'.
|
$result.="<td>".'<a class="one"
|
||||||
$r['name']."</A></td>";
|
HREF="stock.php?action=detail&sg_code='.$r['sg_code'].'&year='.$p_year.'">'.
|
||||||
*/
|
$r['sg_code']."</A></td>";
|
||||||
|
|
||||||
|
// name
|
||||||
|
$a_name=getFicheNameCode($p_cn,$r['sg_code']);
|
||||||
|
$name="";
|
||||||
|
if ( $a_name != null ) {
|
||||||
|
foreach ($a_name as $key=>$element) {
|
||||||
|
$name.=$element['av_text'].",";
|
||||||
|
}
|
||||||
|
}// if ( $a_name
|
||||||
|
$result.="<td> $name </td>";
|
||||||
|
|
||||||
|
// Debit (in)
|
||||||
$result.="<td>".$r['deb_sum']."</td>";
|
$result.="<td>".$r['deb_sum']."</td>";
|
||||||
|
|
||||||
|
// Credit (out)
|
||||||
$result.="<td>".$r['cred_sum']."</td>";
|
$result.="<td>".$r['cred_sum']."</td>";
|
||||||
$result.="<td>".$r['deb_sum']-$r['cred_sum']."</td>";
|
|
||||||
|
|
||||||
|
// diff
|
||||||
|
$diff=$r['deb_sum']-$r['cred_sum'];
|
||||||
|
$result.="<td>".$diff."</td>";
|
||||||
$result.="</tr>";
|
$result.="</tr>";
|
||||||
|
|
||||||
}
|
}
|
||||||
$result.="</table>";
|
$result.="</table>";
|
||||||
|
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
/* function ViewDetailStock ($p_cn,$p_f_id,$p_year)
|
/* function ViewDetailStock ($p_cn,$p_f_id,$p_year)
|
||||||
**************************************************
|
************************************************************
|
||||||
* Purpose : return all the stock movement
|
* Purpose : return all the stock movement
|
||||||
*
|
*
|
||||||
* parm :
|
* parm :
|
||||||
|
|
@ -102,4 +115,41 @@ function ViewDetailStock($p_cn,$p_f_id,$p_year) {
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
/* function getFicheNameCode ($p_cn,$p_sg_code)
|
||||||
|
************************************************************
|
||||||
|
* Purpose : return an array of f_id and f_name
|
||||||
|
*
|
||||||
|
* parm :
|
||||||
|
* - p_cn database connection
|
||||||
|
* - stock_goods.sg_code
|
||||||
|
* gen :
|
||||||
|
* - none
|
||||||
|
* return:
|
||||||
|
* - array (f_id, f_label) or null if nothing is found
|
||||||
|
*/
|
||||||
|
function getFicheNameCode ($p_cn,$p_sg_code) {
|
||||||
|
// Sql stmt
|
||||||
|
$sql="select f_id,av_text
|
||||||
|
from stock_goods
|
||||||
|
join jnt_fic_att_value using (f_id )
|
||||||
|
join attr_value using (jft_id)
|
||||||
|
where
|
||||||
|
ad_id=".ATTR_DEF_NAME."
|
||||||
|
and sg_code='$p_sg_code'
|
||||||
|
and sg_code != null ";
|
||||||
|
// Execute
|
||||||
|
$Res=ExecSql($p_cn,$sql);
|
||||||
|
if ( ( $M=pg_NumRows($Res)) == 0 ) return null;
|
||||||
|
|
||||||
|
// Store in an array
|
||||||
|
for ( $i=0; $i<$M;$i++) {
|
||||||
|
$r=pg_fetch_array($Res,$i);
|
||||||
|
$a['f_id']=$r['f_id'];
|
||||||
|
$a['av_text']=$r['av_text'];
|
||||||
|
$result[$i]=$a;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return $result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -93,6 +93,8 @@ if ( $action == 'new' ) {
|
||||||
|
|
||||||
// if something goes wrong, correct it
|
// if something goes wrong, correct it
|
||||||
if ( $r == null ) {
|
if ( $r == null ) {
|
||||||
|
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||||
|
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
|
||||||
$r=FormAch($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number);
|
$r=FormAch($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number);
|
||||||
}
|
}
|
||||||
echo '<div class="u_redcontent">';
|
echo '<div class="u_redcontent">';
|
||||||
|
|
|
||||||
|
|
@ -90,6 +90,10 @@ if ( $action == 'new' ) {
|
||||||
|
|
||||||
// if something goes wrong correct it
|
// if something goes wrong correct it
|
||||||
if ( $r == null ) {
|
if ( $r == null ) {
|
||||||
|
// submit button in the form
|
||||||
|
$submit='<INPUT TYPE="SUBMIT" NAME="add_item" VALUE="Ajout article">
|
||||||
|
<INPUT TYPE="SUBMIT" NAME="view_invoice" VALUE="Sauver">';
|
||||||
|
|
||||||
$r=FormFin($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number);
|
$r=FormFin($cn,$g_jrn,$g_user,$submit,$HTTP_POST_VARS,false, $nb_number);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -219,7 +219,8 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null)
|
||||||
jrn_def_id,
|
jrn_def_id,
|
||||||
jrn_def_name,
|
jrn_def_name,
|
||||||
jrn_def_ech,
|
jrn_def_ech,
|
||||||
jrn_def_type
|
jrn_def_type,
|
||||||
|
jr_valid
|
||||||
from
|
from
|
||||||
jrn join jrn_def on jrn_def_id=jr_def_id
|
jrn join jrn_def on jrn_def_id=jr_def_id
|
||||||
$p_where
|
$p_where
|
||||||
|
|
@ -242,7 +243,8 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null)
|
||||||
jrn_def_id,
|
jrn_def_id,
|
||||||
jrn_def_name,
|
jrn_def_name,
|
||||||
jrn_def_ech,
|
jrn_def_ech,
|
||||||
jrn_def_type
|
jrn_def_type,
|
||||||
|
jr_valid
|
||||||
from
|
from
|
||||||
jrn join jrn_def on jrn_def_id=jr_def_id where jrn_def_id=$p_jrn";
|
jrn join jrn_def on jrn_def_id=jr_def_id where jrn_def_id=$p_jrn";
|
||||||
$l_and=" and ";
|
$l_and=" and ";
|
||||||
|
|
@ -331,13 +333,14 @@ function ListJrn($p_cn,$p_jrn,$p_where="",$p_array=null)
|
||||||
}// if ( $a != null ) {
|
}// if ( $a != null ) {
|
||||||
$r.="</TD>";
|
$r.="</TD>";
|
||||||
//$l=user_jrn.php?action=update&line=91
|
//$l=user_jrn.php?action=update&line=91
|
||||||
// TODO Add print
|
if ( $row['jr_valid'] == 't' ) {
|
||||||
$r.="<TD>";
|
// TODO Add print
|
||||||
// cancel operation
|
$r.="<TD>";
|
||||||
$r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="cancelOperation(\'%s\',\'%s\')">',
|
// cancel operation
|
||||||
"Annulation",$row['jr_grpt_id'],$l_sessid);
|
$r.=sprintf('<input TYPE="BUTTON" VALUE="%s" onClick="cancelOperation(\'%s\',\'%s\')">',
|
||||||
$r.="</TD>";
|
"Annulation",$row['jr_grpt_id'],$l_sessid);
|
||||||
|
$r.="</TD>";
|
||||||
|
}
|
||||||
// end row
|
// end row
|
||||||
$r.="</tr>";
|
$r.="</tr>";
|
||||||
|
|
||||||
|
|
@ -595,3 +598,31 @@ function UpdateComment ($p_cn,$p_jr_id,$p_comment) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* function isValid ($p_cn, $p_grpt_id
|
||||||
|
**************************************************
|
||||||
|
* Purpose : test if a jrn op is valid
|
||||||
|
*
|
||||||
|
* parm :
|
||||||
|
* - db connection
|
||||||
|
* - p_grpt_id
|
||||||
|
* gen :
|
||||||
|
* - none
|
||||||
|
* return:
|
||||||
|
* 1 is valid
|
||||||
|
* 0 is not valid
|
||||||
|
*/
|
||||||
|
function isValid ($p_cn,$p_grpt_id) {
|
||||||
|
$Res=ExecSql($p_cn,"select jr_valid from jrn where jr_grpt_id=$p_grpt_id");
|
||||||
|
|
||||||
|
if ( ( $M = pg_NumRows($Res)) == 0 ) return 0;
|
||||||
|
|
||||||
|
$a=pg_fetch_array($Res,0);
|
||||||
|
|
||||||
|
if ( $a['jr_valid'] == 't') return 1;
|
||||||
|
if ( $a['jr_valid'] == 'f') return 0;
|
||||||
|
|
||||||
|
echo_error ("Invalid result = ".$a['result']);
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue