task #1438 Remplacement de HtmlInput par Http_Input
Clean code and improve doc
This commit is contained in:
parent
3a199f1906
commit
5735be5c7c
3 changed files with 89 additions and 40 deletions
|
|
@ -39,6 +39,7 @@ def usage():
|
|||
-x generate a extra large sql for a huge database test
|
||||
-y year
|
||||
-p first periode of the year (parm_periode.p_id)
|
||||
-n number of year
|
||||
"""
|
||||
sys.exit(-1)
|
||||
|
||||
|
|
@ -89,12 +90,33 @@ def Creation_fiche (p_seq_f_id,p_seq_jft_id,p_fd_id,p_type,p_base_poste,p_nbfich
|
|||
|
||||
|
||||
|
||||
def Create_year(pn_year,pn_nb_year):
|
||||
print "delete from parm_periode;"
|
||||
nb_id=1
|
||||
print "\\echo insert into tmp_pcmn"
|
||||
print "copy parm_periode (p_id,p_start,p_end,p_exercice,p_closed,p_central) from stdin;"
|
||||
for i in range (0,pn_nb_year):
|
||||
for m in range (1,13):
|
||||
nb_day=30
|
||||
if m in [1,3,5,7,8,10,12]: nb_day=31
|
||||
if m == 2 and (i+pn_year)%4 == 0 : nb_day=29
|
||||
if m == 2 and (i+pn_year)%4 != 0 : nb_day=28
|
||||
print ("%d,'%s-%02d-%02d','%s-%02d-%02d','%s'")%(nb_id,i+pn_year,m,1,i+pn_year,m,nb_day,i+pn_year)
|
||||
nb_id=nb_id+1
|
||||
print "\."
|
||||
|
||||
|
||||
|
||||
jrn_id=1
|
||||
jrnx_id=1
|
||||
|
||||
def Creation_operation(p_base,p_type,p_year):
|
||||
global jrnx_id
|
||||
global jrn_id
|
||||
#jrn="insert into jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_grpt_id,jr_internal,jr_tech_per)"
|
||||
jrn="%d\t%.2f\t%s\t%02d.%02d.%d\t%d\t%s\t%d"
|
||||
jrn="%d\t%d\t%.2f\t%s\t%02d.%02d.%d\t%d\t%s\t%d"
|
||||
#jrnx="insert into jrnx (j_date,j_montant,j_poste,j_grpt,j_jrn_def,j_debit,j_tech_user,j_tech_per)"
|
||||
jrnx="%02d.%02d.%d\t%.2f\t%s\t%d\t%d\t%s\tSIMULATION\t%d"
|
||||
jrnx="%d\t%02d.%02d.%d\t%.2f\t%s\t%d\t%d\t%s\tSIMULATION\t%d"
|
||||
array_jrnx=[]
|
||||
array_jrn=[]
|
||||
start_periode=periode
|
||||
|
|
@ -109,57 +131,71 @@ def Creation_operation(p_base,p_type,p_year):
|
|||
j_internal='1VEN-01-%d' % (p_base)
|
||||
j_client='400%04d' % (random.randrange(1,nb_fiche)+100)
|
||||
#jrnx1=jrnx % (loop_day,loop_periode-39,j_montant,j_client,p_base,2,'true',loop_periode)
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,j_montant,j_client,p_base,2,'true',loop_periode))
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,j_montant,j_client,p_base,2,'true',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,j_tva,'4511',p_base,2,'true',loop_periode))
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,j_tva,'4511',p_base,2,'true',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
total=j_montant+j_tva
|
||||
array_jrnx.append( jrnx % (loop_day,month,p_year,total,'700',p_base,2,'false',loop_periode))
|
||||
array_jrnx.append( jrnx % (jrnx_id,loop_day,month,p_year,total,'700',p_base,2,'false',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrn.append(jrn%(2,total,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
array_jrn.append(jrn%(jrn_id,2,total,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
jrn_id=jrn_id+1
|
||||
#print jrn1
|
||||
p_base+=1
|
||||
if p_type== 'A':
|
||||
j_internal='1ACH-01-%d' % (p_base)
|
||||
j_fournisseur='440%04d' % (random.randrange(0,nb_fiche)+100)
|
||||
j_charge='61%04d' % (random.randrange(0,nb_charge)+100)
|
||||
array_jrnx.append(jrnx%(loop_day,month,p_year,j_montant,j_fournisseur,p_base,3,'false',loop_periode))
|
||||
array_jrnx.append(jrnx%(jrnx_id,loop_day,month,p_year,j_montant,j_fournisseur,p_base,3,'false',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,j_tva,'4111',p_base,3,'false',loop_periode))
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,j_tva,'4111',p_base,3,'false',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
total=j_montant+j_tva
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,total,j_charge,p_base,3,'true',loop_periode))
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,total,j_charge,p_base,3,'true',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrn.append(jrn%(3,total,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
array_jrn.append(jrn%(jrn_id,3,total,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
jrn_id=jrn_id
|
||||
##print jrn1
|
||||
p_base+=1
|
||||
if p_type== 'O':
|
||||
j_internal='4ODS-01-%d' % (p_base)
|
||||
j_banque='400'
|
||||
j_charge='440'
|
||||
array_jrnx.append(jrnx%(loop_day,month,p_year,j_montant,j_banque,p_base,4,'false',loop_periode))
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,j_montant,j_charge,p_base,4,'true',loop_periode))
|
||||
array_jrnx.append(jrnx%(jrnx_id,loop_day,month,p_year,j_montant,j_banque,p_base,4,'false',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,j_montant,j_charge,p_base,4,'true',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrn.append(jrn%(4,j_montant,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
array_jrn.append(jrn%(jrn_id,4,j_montant,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
jrn_id=jrn_id+1
|
||||
##print jrn1
|
||||
p_base+=1
|
||||
if p_type== 'F':
|
||||
j_internal='1FIN-01-%d' % (p_base)
|
||||
j_banque='550'
|
||||
j_charge='400'
|
||||
array_jrnx.append(jrnx%(loop_day,month,p_year,j_montant,j_banque,p_base,1,'false',loop_periode))
|
||||
array_jrnx.append(jrnx % (loop_day,month,p_year,j_montant,j_charge,p_base,1,'true',loop_periode))
|
||||
array_jrnx.append(jrnx%(jrnx_id,loop_day,month,p_year,j_montant,j_banque,p_base,1,'false',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
array_jrnx.append(jrnx % (jrnx_id,loop_day,month,p_year,j_montant,j_charge,p_base,1,'true',loop_periode))
|
||||
jrnx_id=jrnx_id+1
|
||||
#print jrnx1
|
||||
array_jrn.append(jrn%(1,j_montant,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
array_jrn.append(jrn%(jrn_id,1,j_montant,j_internal,loop_day,month,p_year,p_base,j_internal,loop_periode))
|
||||
jrn_id=jrn_id+1
|
||||
##print jrn1
|
||||
p_base+=1
|
||||
|
||||
print "\\echo insert into jrnx"
|
||||
print "copy jrnx (j_date,j_montant,j_poste,j_grpt,j_jrn_def,j_debit,j_tech_user,j_tech_per) from stdin;"
|
||||
print "copy jrnx (j_id,j_date,j_montant,j_poste,j_grpt,j_jrn_def,j_debit,j_tech_user,j_tech_per) from stdin;"
|
||||
for e in array_jrnx: print e
|
||||
print "\."
|
||||
print "\\echo insert into jrn"
|
||||
print """copy jrn (jr_def_id,jr_montant,jr_comment,jr_date,jr_grpt_id,jr_internal,jr_tech_per) from stdin;"""
|
||||
print """copy jrn (jr_id,jr_def_id,jr_montant,jr_comment,jr_date,jr_grpt_id,jr_internal,jr_tech_per) from stdin;"""
|
||||
for e in array_jrn: print e
|
||||
print "\."
|
||||
|
||||
|
|
@ -173,18 +209,20 @@ is_year=0
|
|||
is_periode=0
|
||||
cmd_line=sys.argv[1:]
|
||||
try :
|
||||
a1,a2=getopt.getopt(cmd_line,"slxhy:p:",['small','large','extra-large','help','year','periode'])
|
||||
a1,a2=getopt.getopt(cmd_line,"slxhy:p:n:",['small','large','extra-large','help','year','periode','nbexercice'])
|
||||
except getopt.GetoptError,msg:
|
||||
print "ERROR "
|
||||
print msg.msg
|
||||
usage()
|
||||
|
||||
nb_year=1
|
||||
for option,value in a1:
|
||||
if option in ('-h','--help'):
|
||||
usage()
|
||||
if option in ('-s','--small'):
|
||||
nb_fiche=12000
|
||||
nb_charge=1800
|
||||
nb_per_day=2000
|
||||
nb_fiche=120
|
||||
nb_charge=18
|
||||
nb_per_day=5
|
||||
if option in ('-l','--large'):
|
||||
nb_fiche=5000
|
||||
nb_charge=350
|
||||
|
|
@ -199,6 +237,10 @@ for option,value in a1:
|
|||
if option in ('-p','--periode'):
|
||||
periode=int(value)
|
||||
is_periode=1
|
||||
if option in ('-n','--nbexercice'):
|
||||
nb_year=int(value)
|
||||
|
||||
|
||||
|
||||
if is_year == 0 :
|
||||
print "Erreur l'annee est obligatoire"
|
||||
|
|
@ -240,19 +282,21 @@ type='Charge '
|
|||
f_id+=nb_fiche+100
|
||||
jft_id+=20*nb_fiche
|
||||
base_poste='61'
|
||||
tot_op=nb_per_day*365
|
||||
|
||||
Creation_fiche(f_id,jft_id,fd_id,type,base_poste,nb_charge)
|
||||
|
||||
#Creation_operation Vente
|
||||
Creation_operation(1000,'V',year)
|
||||
for i in range(0,nb_year):
|
||||
#Creation_operation Vente
|
||||
Creation_operation(1000,'V',year+i)
|
||||
|
||||
#Creation_operation Achat
|
||||
Creation_operation(17000,'A',year)
|
||||
#Creation_operation Achat
|
||||
Creation_operation((1+i)*2*tot_op+10000,'A',year+1)
|
||||
|
||||
#Creation_operation FIN
|
||||
Creation_operation(34000,'F',year)
|
||||
#Creation_operation FIN
|
||||
Creation_operation((1+i)*3*tot_op+10000,'F',year+1)
|
||||
|
||||
#Creation_operation ODS
|
||||
Creation_operation(51000,'O',year)
|
||||
#Creation_operation ODS
|
||||
Creation_operation((1+i)*4*tot_op+10000,'O',year+1)
|
||||
|
||||
print "commit;"
|
||||
|
|
|
|||
|
|
@ -75,9 +75,10 @@ class HttpInput
|
|||
/**
|
||||
* Retrieve from $this->array the variable
|
||||
* @param $p_name name of the variable
|
||||
* @param $p_type type of the variable
|
||||
* @param $p_type type of the variable (number,string,date('dd.mm.yyyy'),array)
|
||||
* @param $p_default default value is variable
|
||||
* @throws Exception if invalid
|
||||
* @see check_type
|
||||
*/
|
||||
function get_value($p_name, $p_type="string", $p_default="")
|
||||
{
|
||||
|
|
|
|||
|
|
@ -31,9 +31,10 @@
|
|||
if ( ! defined ('ALLOWED') ) die('Appel direct ne sont pas permis');
|
||||
require_once NOALYSS_INCLUDE.'/lib/iselect.class.php';
|
||||
require_once NOALYSS_INCLUDE.'/class/acc_ledger.class.php';
|
||||
|
||||
$http=new HttpInput();
|
||||
$p_mesg="";
|
||||
|
||||
$sa=$http->request("sa","string","");
|
||||
$sa = (isset($_REQUEST['sa'])) ? $_REQUEST['sa'] : '';
|
||||
$g_user->Check();
|
||||
|
||||
|
|
@ -42,7 +43,8 @@ require_once NOALYSS_INCLUDE.'/lib/user_menu.php';
|
|||
// Correct (last step)
|
||||
if (isset($_POST['correct']))
|
||||
{
|
||||
$ledger = new Acc_Ledger($cn, $_REQUEST['p_jrn']);
|
||||
$p_jrn=$http->request("p_jrn", "number");
|
||||
$ledger = new Acc_Ledger($cn, $p_jrn);
|
||||
require_once NOALYSS_INCLUDE.'/operation_ods_new.inc.php';
|
||||
return;
|
||||
}
|
||||
|
|
@ -51,7 +53,8 @@ if (isset($_POST['correct']))
|
|||
if ( isset($_POST['summary']))
|
||||
{
|
||||
try {
|
||||
$ledger = new Acc_Ledger($cn, $_REQUEST['p_jrn']);
|
||||
$p_jrn=$http->request("p_jrn", "number");
|
||||
$ledger = new Acc_Ledger($cn, $p_jrn);
|
||||
$ledger->with_concerned=false;
|
||||
$ledger->verify($_POST);
|
||||
require_once NOALYSS_INCLUDE.'/operation_ods_confirm.inc.php';
|
||||
|
|
@ -67,15 +70,16 @@ if ( isset($_POST['summary']))
|
|||
// record
|
||||
if (isset($_POST['save']))
|
||||
{
|
||||
$p_jrn=$http->request("p_jrn", "number");
|
||||
$array = $_POST;
|
||||
$ledger = new Acc_Ledger($cn, $_REQUEST['p_jrn']);
|
||||
$ledger = new Acc_Ledger($cn, $p_jrn);
|
||||
$ledger->with_concerned=false;
|
||||
try
|
||||
{
|
||||
$ledger->save($array);
|
||||
$jr_id = $cn->get_value('select jr_id from jrn where jr_internal=$1', array($ledger->internal));
|
||||
|
||||
echo '<h2> Opération enregistrée Piece ' . h($ledger->pj) . '</h2>';
|
||||
echo '<h2>'._("Opération enregistrée")." "._("Piece ") . h($ledger->pj) . '</h2>';
|
||||
if (strcmp($ledger->pj, $_POST['e_pj']) != 0)
|
||||
{
|
||||
echo '<h3 class="notice">' . _('Attention numéro pièce existante, elle a du être adaptée') . '</h3>';
|
||||
|
|
@ -104,7 +108,7 @@ if ($sa == '')
|
|||
|
||||
echo '<h1 class="legend"> Etape 1 </h1>';
|
||||
|
||||
echo 'Choisissez le dossier où sont les soldes à importer';
|
||||
echo _('Choisissez le dossier où sont les soldes à importer');
|
||||
$avail = $g_user->get_available_folder();
|
||||
|
||||
if (empty($avail))
|
||||
|
|
@ -139,14 +143,14 @@ if ($sa == '')
|
|||
/* --------------------------------------------------
|
||||
* Step 2 choose now the exercice of this folder
|
||||
*/
|
||||
$back = 'do.php?ac=' . $_REQUEST['ac'] . '&' . dossier::get();
|
||||
$back = 'do.php?ac=' . $http->request("ac"). '&' . dossier::get();
|
||||
if ($sa == 'step2')
|
||||
{
|
||||
echo '<div class="content">' .
|
||||
'<div><h1 class="legend">Etape 2</h1>' .
|
||||
'<h2 class="info">' . dossier::name($_REQUEST['f']) . '</h2>' .
|
||||
'<form class="print" method="post">' .
|
||||
' Choisissez l\'exercice du dossier ';
|
||||
_("Choisissez l'exercice du dossier à reporter pour les a-nouveaux");
|
||||
echo dossier::hidden();
|
||||
echo HtmlInput::hidden('ac', $_REQUEST['ac']);
|
||||
echo HtmlInput::hidden('sa', 'step3');
|
||||
|
|
@ -159,7 +163,7 @@ if ($sa == 'step2')
|
|||
$w->readonly = false;
|
||||
$w->value = $periode;
|
||||
$w->name = "p_periode";
|
||||
echo 'Période : ' . $w->input();
|
||||
echo _('Période').' : ' . $w->input();
|
||||
echo HtmlInput::submit('ok', _('Continuer'));
|
||||
echo dossier::hidden();
|
||||
echo "</form>";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue