Main Page | Namespace List | Class Hierarchy | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

central_inc.php File Reference

Concerns the centralization operations. More...

Go to the source code of this file.

Functions

 Centralise ($p_cn, $p_periode)
 Met les donnees centralisees dans la table centralize.
 isCentralize ($p_cn, $p_jrn_id)
 test if e jrn_jr.id is centralize or not


Detailed Description

Concerns the centralization operations.

Definition in file central_inc.php.


Function Documentation

Centralise p_cn,
p_periode
 

Met les donnees centralisees dans la table centralize.

Parameters:
p_cn connection
periode a centraliser
Returns:
code error

Definition at line 36 of file central_inc.php.

References $line, $MaxJrn, $MaxLine, $Res, $Res2, $Ret, $row, $sql, Commit(), EndSql(), ExecSql(), and StartSql().

Referenced by ShowMenuAdvanced().

00036                                       {
00037 $sql="insert into centralized( c_j_id,
00038             c_date ,
00039             c_internal,
00040             c_montant,
00041             c_debit,
00042             c_poste,
00043             c_description,
00044             c_grp,
00045             c_jrn_def,
00046             c_comment,
00047             c_rapt,
00048             c_periode) select j_id,
00049                                  j_date,
00050                                  jr_internal,
00051                                  j_montant,
00052                                  j_debit ,
00053                                  j_poste ,
00054                                  j_text ,
00055                                  j_grpt ,
00056                                  j_jrn_def,
00057                                  jr_comment,
00058                                  j_rapt, 
00059                                  j_tech_per 
00060             from jrnx left join jrn on jr_grpt_id=j_grpt 
00061             where  
00062             j_tech_per =".$p_periode." 
00063             order by j_date,j_grpt,j_debit desc ";
00064  $Res=StartSql($p_cn);
00065  $Res=ExecSql($p_cn,$sql);
00066  if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
00067  $Res=ExecSql($p_cn,"update jrnx set j_centralized='t' where j_tech_per=".$p_periode);
00068  if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
00069 // Set correctly the number of operation id (jr_opid) for each journal
00070 // get the existing jrn_def_id 
00071 //--
00072  $Res = ExecSql($p_cn,"select jrn_def_id from jrn_def");
00073  $MaxJrn=pg_NumRows($Res);
00074  // for each jrn_def_id
00075  for ( $i=0; $i < $MaxJrn;$i++) {
00076    $row=pg_fetch_array($Res,$i);
00077    // get the op related to that jrn_def_id
00078    $sql=sprintf("select jr_id from jrn 
00079          where
00080          jr_tech_per=%d
00081          and jr_def_id = %d
00082          order by jr_date,jr_grpt_id desc",
00083                 $p_periode,
00084                 $row['jrn_def_id']
00085                 );
00086 
00087    $Res2=ExecSql($p_cn,$sql);
00088    $MaxLine=pg_NumRows($Res2);
00089    for ($e=0;$e < $MaxLine;$e++) {
00090      // each line is updated with a sequence
00091      $line=pg_fetch_array($Res2,$e);
00092      $jr_id=$line['jr_id'];
00093      $sql=sprintf ("update jrn set 
00094                  jr_opid = (select nextval('s_jrn_%d'))
00095                  where jr_id =%d",
00096                    $row['jrn_def_id'],
00097                    $jr_id); 
00098      $Ret=ExecSql($p_cn,$sql);
00099      if ($Res==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
00100    }
00101  }
00102    // Put jr_c_opid in centralized                 
00103    // for each jrn_def_id
00104    // get the op related to that jrn_def_id
00105    $sql=sprintf("select jr_id from jrn 
00106          where
00107          jr_tech_per=%d
00108             order by jr_date,jr_grpt_id desc",
00109                 $p_periode
00110                 );
00111 
00112    $Res2=ExecSql($p_cn,$sql);
00113    $MaxLine=pg_NumRows($Res2);
00114    for ($e=0;$e < $MaxLine;$e++) {
00115      // each line is updated with a sequence
00116      $line=pg_fetch_array($Res2,$e);
00117      $jr_id=$line['jr_id'];
00118      $sql=sprintf ("update jrn set 
00119                  jr_c_opid = (select nextval('s_central'))
00120                  where jr_id =%d",
00121                    $jr_id); 
00122      $Ret=ExecSql($p_cn,$sql);
00123      if ($Ret==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
00124    }
00125    // Set the order of the jrn
00126    $Res=ExecSql($p_cn,"select c_id from centralized 
00127                  inner join jrn on c_grp = jr_grpt_id
00128                  order by jr_c_opid, c_debit desc");
00129    for ( $e=0;$e < pg_NumRows($Res);$e++) {
00130      $row=pg_fetch_array($Res,$e);
00131      $sql=sprintf ("update centralized set  
00132                  c_order = (select nextval('s_central_order'))
00133                  where c_id = %d",$row['c_id']);
00134      $Res2=ExecSql($p_cn,$sql); 
00135       if ($Res2==false) { rollback($p_cn); EndSql($p_cn); return ERROR;}
00136 
00137    }
00138    if ( ExecSql($p_cn,"update parm_periode set p_central=true where p_id=$p_periode") == false)
00139      { rollback($p_cn); EndSql($p_cn); return ERROR;}
00140 
00141  
00142  
00143  
00144  Commit($p_cn);
00145  EndSql($p_cn);
00146  return NOERROR;
00147 }

isCentralize p_cn,
p_jrn_id
 

test if e jrn_jr.id is centralize or not

parm :

  • p_cn

p_jnr_id jrn.jr_id gen :

  • none return: 0 if not centralized otherwise > 0

Definition at line 159 of file central_inc.php.

References $Res, and ExecSql().

00159                                        {
00160   $Res=ExecSql($p_cn,"select c_id from centralized where c_j_id=$p_jrn_id");
00161   return pg_NumRows($Res);
00162 }