';
-/* Analyse ce qui est demandé */
-/* Effacement d'une ligne */
-if (isset ($_GET['action']))
-{
-//-----------------------------------------------------
-// Action == remove a line
- if ( $_GET['action']=="del" )
- {
- if ( isset ($_GET['l']) )
- {
- /* Ligne a enfant*/
- $R=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val_parent=$1",array($_GET['l']));
- if ( Database::num_row($R) != 0 )
- {
- alert("Ne peut pas effacer le poste: d'autres postes en dépendent");
- }
- else
- {
- /* Vérifier que le poste n'est pas utilisé qq part dans les journaux */
- $Res=$cn->exec_sql("select * from jrnx where j_poste=$1",array($_GET['l']));
- if ( Database::num_row($Res) != 0 )
- {
- alert("Ne peut pas effacer le poste: il est utilisé dans les journaux");
- }
- else
- {
- $Del=$cn->exec_sql("delete from tmp_pcmn where pcm_val=$1",array($_GET['l']));
- } // if Database::num_row
- } // if Database::num_row
- } // isset ($l)
- } //$action == del
-} // isset action
-//----------------------------------------------------------------------
-// Modification
-//----------------------------------------------------------------------
-if ( isset ($_POST['update']))
-{
- $p_val=trim($_POST["p_valu"]);
- $p_lib=trim($_POST["p_libu"]);
- $p_parent=trim($_POST["p_parentu"]);
- $old_line=trim($_POST["p_oldu"]);
- $p_type=htmlentities($_POST['p_typeu']);
- $acc=new Acc_Account($cn);
- $acc->set_parameter('libelle',$p_lib);
- $acc->set_parameter('value',$p_val);
- $acc->set_parameter('parent',$p_parent);
- $acc->set_parameter('type',$p_type);
- // Check if the data are correct
- try
- {
- $acc->check() ;
- }
- catch (Exception $e)
- {
- $message="Valeurs invalides, pas de changement \n ".
- $e->getMessage();
- echo '';
- }
- if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 && strlen($old_line)!=0 )
- {
- if (strlen ($p_val) == 1 )
- {
- $p_parent=0;
- }
- else
- {
- if ( strlen($p_parent)==0 )
- {
- $p_parent=substr($p_val,0,strlen($p_val)-1);
- }
- }
- /* Parent existe */
- $Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1",array($p_parent));
- if ( ($p_parent != 0 && Database::num_row($Ret) == 0) || $p_parent==$old_line )
- {
- echo '';
- }
- else
- {
- try
- {
- $acc->update($old_line);
- }
- catch(Exception $e)
- {
- alert($e->getMessage());
- }
- }
- }
- else
- {
- echo '';
- }
-}
-//-----------------------------------------------------
-/* Ajout d'une ligne */
-if ( isset ( $_POST["Ajout"] ) )
-{
- extract ($_POST);
- $p_val=trim($p_val);
- $p_parent=trim($p_parent);
-
- if ( isset ( $p_val) && isset ( $p_lib ) )
- {
- $p_val=trim($p_val);
- $p_parent=$_POST["p_parent"];
- if ( strlen ($p_val) != 0 && strlen ($p_lib) != 0 )
- {
- if (strlen ($p_val) == 1 )
- {
- $p_parent=0;
- }
- else
- {
- if ( strlen(trim($p_parent))==0 &&
- (string) $p_parent != (string)(int) $p_parent)
- {
- $p_parent=substr($p_val,0,strlen($p_val)-1);
- }
- }
- /* Parent existe */
- $Ret=$cn->exec_sql("select pcm_val from tmp_pcmn where pcm_val=$1",array($p_parent));
- if ( $p_parent != 0 && Database::num_row($Ret) == 0 )
- {
- alert(" Ne peut pas modifier; aucun poste parent");
- }
- else
- {
- // Check if the account already exists
-
- $Count=$cn->get_value("select count(*) from tmp_pcmn where pcm_val=$1",array($p_val));
- if ( $Count != 0 )
- {
- // Alert message account already exists
- alert(" Ce poste existe déjà ");
-
- }
- else
- {
- $Ret=$cn->exec_sql("insert into tmp_pcmn (pcm_val,pcm_lib,pcm_val_parent,pcm_type) values ($1,$2,$3,$4)",array($p_val,$p_lib,$p_parent,$p_type));
- }
- }
- }
- else
- {
- echo '
Valeurs invalides ';
- }
- }
-}
$Ret=$cn->exec_sql("select pcm_val,pcm_lib,pcm_val_parent,pcm_type,array_to_string(array_agg(j_qcode) , ',') as acode
- from tmp_pcmn left join vw_poste_qcode on (j_poste=pcm_val) where substr(pcm_val::text,1,1)='".$_SESSION['g_start']."'".
+ from tmp_pcmn left join vw_poste_qcode on (j_poste=pcm_val) where substr(pcm_val::text,1,1)='".$g_start."'".
" group by pcm_val,pcm_lib,pcm_val_parent, pcm_type order by pcm_val::text");
$MaxRow=Database::num_row($Ret);
?>
-
+
+
+
+