phpcompta-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Phpcompta-dev] r4983 - in phpcompta/trunk: html html/js include include


From: phpcompta-dev
Subject: [Phpcompta-dev] r4983 - in phpcompta/trunk: html html/js include include/template
Date: Sun, 24 Jun 2012 17:46:44 +0200 (CEST)

Author: danydb
Date: 2012-06-24 17:46:43 +0200 (Sun, 24 Jun 2012)
New Revision: 4983

Added:
   phpcompta/trunk/include/ajax_fiche_def_detail.php
   phpcompta/trunk/include/template/fiche_def_list.php
   phpcompta/trunk/include/template/fiche_list.php
Modified:
   phpcompta/trunk/html/ajax_misc.php
   phpcompta/trunk/html/js/scripts.js
   phpcompta/trunk/include/cfgfiche.inc.php
   phpcompta/trunk/include/class_fiche_def.php
   phpcompta/trunk/include/class_tool_uos.php
Log:
0000577: Remplacer FICHE par PRINTCARD

Modified: phpcompta/trunk/html/ajax_misc.php
===================================================================
--- phpcompta/trunk/html/ajax_misc.php  2012-06-23 00:45:16 UTC (rev 4982)
+++ phpcompta/trunk/html/ajax_misc.php  2012-06-24 15:46:43 UTC (rev 4983)
@@ -557,6 +557,9 @@
        case 'view_mod_stock':
                require_once 'ajax_view_mod_stock.php';
                break;
+       case 'fddetail':
+               require_once 'ajax_fiche_def_detail.php';
+               break;
        default:
                var_dump($_GET);
 }

Modified: phpcompta/trunk/html/js/scripts.js
===================================================================
--- phpcompta/trunk/html/js/scripts.js  2012-06-23 00:45:16 UTC (rev 4982)
+++ phpcompta/trunk/html/js/scripts.js  2012-06-24 15:46:43 UTC (rev 4983)
@@ -1592,20 +1592,36 @@
        }
 }
 /**
- * <a href="javascript:void(0)" class="line" 
onclick="profile_show('profile_gen_div')"><?=_('Nom')?></a>&nbsp;
-<a href="javascript:void(0)" class="line" 
onclick="profile_show('profile_menu_div')"><?=_('Détail Menus')?></a>&nbsp;
-<a href="javascript:void(0)" class="line" 
onclick="profile_show('profile_print_div')"><?=_('Détail 
Impressions')?></a>&nbsp;
-<a href="javascript:void(0)" class="line" style="" 
onclick="profile_show('profile_gestion_div')"><?=_('Action Gestion')?> 
</a>&nbsp;
-<a href="javascript:void(0)" class="line" 
onclick="profile_show('profile_repo_div')"><?=_('Dépôts')?></a>&nbsp;
+ * tab menu for the profile parameter
  */
 function profile_show(p_div)
 {
        try{
                var 
div=['profile_gen_div','profile_menu_div','profile_print_div','profile_gestion_div','profile_repo_div'];
-               for (var r =0;r<div.length;r++ ) {$(div[r]).hide();  }
+               for (var r =0;r<div.length;r++ ) {$(div[r]).hide();}
                $(p_div).show();
        } catch(e)
        {
                alert(e.message)
        }
+}
+function detail_category_show(p_div,p_dossier,p_id)
+{
+       $(p_div).show();
+       waiting_box();
+       var queryString="gDossier="+p_dossier+"&id="+p_id+"&op=fddetail";
+       var action = new Ajax.Request(
+                                 "ajax_misc.php" ,
+                                 {
+                                     method:'get', parameters:queryString,
+                                     onFailure:ajax_misc_failure,
+                                     onSuccess:function(req){
+                                               remove_waiting_box();
+                                               $('list_cat_div').hide();
+                                               
$('detail_category_div').innerHTML=req.responseText;
+                                               $('detail_category_div').show();
+                                               req.responseText.evalScripts();
+                                     }
+                                 }
+                                 );
 }
\ No newline at end of file

Added: phpcompta/trunk/include/ajax_fiche_def_detail.php
===================================================================
--- phpcompta/trunk/include/ajax_fiche_def_detail.php                           
(rev 0)
+++ phpcompta/trunk/include/ajax_fiche_def_detail.php   2012-06-24 15:46:43 UTC 
(rev 4983)
@@ -0,0 +1,43 @@
+<?php
+
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief show detail of a fiche_def (category of card) + Attribut
+ *
+ */
+require_once('class_fiche_def.php');
+require_once 'class_tool_uos.php';
+$fd=new Fiche_Def($cn,$_GET['id']);
+if ( $_GET['id'] > 0 )
+{
+
+       echo $fd->input_detail();
+       echo HtmlInput::button("retour_b", "Retour à la liste", 
"onclick=\"$('detail_category_div').hide();$('list_cat_div').show()\"");
+}
+else
+{
+       $fd->input_new();
+       
+}
+?>

Modified: phpcompta/trunk/include/cfgfiche.inc.php
===================================================================
--- phpcompta/trunk/include/cfgfiche.inc.php    2012-06-23 00:45:16 UTC (rev 
4982)
+++ phpcompta/trunk/include/cfgfiche.inc.php    2012-06-24 15:46:43 UTC (rev 
4983)
@@ -28,477 +28,112 @@
 require_once('class_database.php');
 include_once ("user_menu.php");
 require_once('class_dossier.php');
-require_once('class_ipopup.php');
-// Necessaire ???
-/*echo IPoste::ipopup('ipop_account');
-echo ICard::ipopup('ipop_card');*/
+require_once 'class_sort_table.php';
+require_once 'class_fiche_def.php';
+require_once 'class_tool_uos.php';
 
-$str_dossier=dossier::get();
-global $g_user,$cn;
+$retour=HtmlInput::button_anchor("Retour à la liste", 
HtmlInput::get_to_string(array("gDossier","ac")));
 
-$pop_tva=new IPopup('popup_tva');
-$pop_tva->title=_('Choix TVA');
-$pop_tva->value='';
-echo $pop_tva->input();
-
-
-// Security check
-$write=$g_user->check_action(FICADD);
-if ($write == 0 )
+/*******************************************************************************************/
+// Add an attribut
+/*******************************************************************************************/
+if ( isset($_POST['add_line']))
 {
-    /* Cannot Access */
-    NoAccess();
+        $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
+     $fiche_def->InsertAttribut($_REQUEST['ad_id']);
+     echo $fiche_def->input_detail();
+        echo $retour;
+        exit();
 }
-
-function ShowRecherche()
+/*******************************************************************************************/
+// Remove an attribut
+/*******************************************************************************************/
+if ( isset ($_POST['remove_line']))
 {
-    echo '<form method="GET" action="?">';
-    echo dossier::hidden();
-      echo HtmlInput::hidden('ac',$_REQUEST['ac']);
-    $w=new IText();
-    $search_text=(isset($_REQUEST['search_text']))?$_REQUEST['search_text']:"";
-    $h=new IHidden();
-    echo $h->input('p_action','fiche');
-    echo $h->input('action','search');
-    echo $h->input('ac',$_REQUEST['ac']);
-
-    echo _("Recherche :").$w->input('search_text',$search_text);
-    echo HtmlInput::submit('submit',_('Rechercher'));
-    echo '</form>';
+       $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
+       $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
+       $fiche_def->RemoveAttribut($_REQUEST['chk_remove']);
+    echo $fiche_def->input_detail();
+       echo $retour;
+       exit();
 }
-function ShowFicheDefInput($p_fiche_def)
+/*******************************************************************************************/
+// Try to remove a category
+/*******************************************************************************************/
+if ( isset ($_POST['remove_cat']))
 {
-    $r="";
-    // Save the label
-
-    $p_fiche_def->Get();
-    $p_fiche_def->GetAttribut();
-
-    /*  we change the main attribute */
-    if (isset ($_REQUEST['label']) )
-    {
-        $p_fiche_def->SaveLabel($_REQUEST['label']);
-        if ( isset($_REQUEST['create']))
-        {
-            $p_fiche_def->set_autocreate(true);
-        }
-        else
-        {
-            $p_fiche_def->set_autocreate(false);
-        }
-        $p_fiche_def->save_class_base($_REQUEST['class_base']);
-    }
-    $p_fiche_def->Get();
-    $r.= '<H2 class="info">'.$p_fiche_def->id." 
".h($p_fiche_def->label).'</H2>';
-    $r.='<fieldset><legend>Données générales</legend>';
-
-    /* show the values label class_base and create account */
-    $r.='<form method="post">';
-    $r.= HtmlInput::hidden('ac',$_REQUEST['ac']);
-    $r.=dossier::hidden();
-    $r.=HtmlInput::hidden("fd_id",$p_fiche_def->id);
-    $r.=HtmlInput::hidden("ac",$_REQUEST['ac']);
-    $r.=HtmlInput::hidden("p_action","fiche");
-    $r.= $p_fiche_def->input_base();
-    $r.='<hr>';
-    $r.=HtmlInput::submit('change_name',_('Sauver'));
-    $r.='</form>';
-    $r.='</fieldset>';
-    /* attributes */
-    $r.='<fieldset><legend>Détails</legend>';
-
-    $r.= '<FORM action="do.php" method="POST">';
-    $r.=dossier::hidden();
-    $r.= HtmlInput::hidden('ac',$_REQUEST['ac']);
-    $r.=HtmlInput::hidden("fd_id",$p_fiche_def->id);
-    $r.=HtmlInput::hidden("ac",$_REQUEST['ac']);
-    $r.= $p_fiche_def->DisplayAttribut("remove");
-    $r.= HtmlInput::submit('add_line',_('Ajoutez cet élément'));
-    $r.= HtmlInput::submit("save_line",_("Sauvez"));
-    $r.=HtmlInput::submit('remove_cat',_('Effacer cette 
catégorie'),'onclick="return confirm(\''._('Vous confirmez ?').'\')"');
-    // if there is nothing to remove then hide the button
-    if ( strpos ($r,"chk_remove") != 0 )
-    {
-        $r.=HtmlInput::submit('remove_line',_("Enleve les éléments 
cochés"),"onclick=\"return confirm('Vous confirmez?')\"" );
-    }
-    $r.= "</form>";
-    $r.=" <p class=\"notice\"> "._("Attention : il n'y aura pas de demande de 
confirmation pour enlever les
-                                   attributs sélectionnés. Il ne sera pas 
possible de revenir en arrière")."</p>";
-    $r.='</fieldset>';
-
-    return $r;
-}
-
-$recherche=true;
-// Creation of a new model of card
-// in the database
-if ( isset($_POST['add_modele'])    )
-{
-    $g_user->can_request(FICCAT);
-    // insert the model of card in database
-    $fiche_def=new Fiche_Def($cn);
-    $fiche_def->Add($_POST);
-}
-$r="";
-
-if ( isset ($_POST['remove_cat'] )  )
-{
-    $g_user->can_request(FICCAT);
-
-    $fd_id=new Fiche_Def($cn,$_POST['fd_id']);
+       $fd_id=new Fiche_Def($cn,$_POST['fd_id']);
     $remains=$fd_id->remove();
     if ( $remains != 0 )
         /* some card are not removed because it is used */
         alert('Impossible d\'enlever cette catégorie, certaines fiches sont 
encore utilisées'."\n".
               'Les fiches non utilisées ont cependant été effacées');
 }
-// Add a line in the card model
-if ( isset ($_POST["add_line"])  )
+/*******************************************************************************************/
+// Change some basis info
+/*******************************************************************************************/
+if ( isset ($_POST['change_name']))
 {
-    $g_user->can_request(FIC);
-
-    $r= '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        $r.= "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
+        if (isset ($_REQUEST['label']) )
     {
-        $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
-        // Insert Line
-        $fiche_def->InsertAttribut($_REQUEST['ad_id']);
-
-        $r.=ShowFicheDefInput($fiche_def);
-
-    }
-    $r.= '</DIV>';
-    $recherche=false;
-}
-/* ------------------------------------------------- */
-/* SAVE ORDER */
-/* ------------------------------------------------- */
-
-if ( isset($_POST['save_line']))
-{
-    $g_user->can_request(FICCAT);
-    $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
-    $fiche_def->save_order($_POST);
-    $r= '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        $r.= "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
-    {
-        $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
-        // Insert Line
-        $r.=ShowFicheDefInput($fiche_def);
-
-    }
-    $r.= '</DIV>';
-    $recherche=false;
-
-}
-// Remove lines from a card model
-if ( isset ($_POST['remove_line'])   )
-{
-    $g_user->can_request(FICCAT);
-    $r= '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        $r.= "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
-    {
-        if ( isset($_REQUEST['chk_remove']))
+                $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
+        $fiche_def->SaveLabel($_REQUEST['label']);
+        if ( isset($_REQUEST['create']))
         {
-            $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
-            // Insert Line
-            // demander confirmation
-
-            $fiche_def->RemoveAttribut($_REQUEST['chk_remove']);
-            $r.=ShowFicheDefInput($fiche_def);
+            $fiche_def->set_autocreate(true);
         }
-
-    }
-    $r.= '</DIV>';
-    $recherche=false;
-}
-// Change the name of the card  model
-if ( isset ($_POST["change_name"] )   )
-{
-    $g_user->can_request(FICCAT);
-    $r= '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        $r.= "<h2 class=\"error\"> "._("Pas d'accès")." </h2>";
-    else
-    {
-        $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
-        $r.=ShowFicheDefInput($fiche_def);
-    }
-    $r.= '</DIV>';
-    $recherche=false;
-    ShowMenuFiche(Dossier::id());
-    echo $r;
-    exit();
-}
-
-ShowMenuFiche(Dossier::id());
-echo $r;
-
-//------------------------------------------------------------------------------
-// Get action
-if ( isset ( $_GET["action"]) )
-{
-    $action=$_GET["action"];
-    // View the details of the selected cat. of cards
-    if ( isset ($_GET["fiche"]) && $action=="vue"
-            && ! isset ($_POST['add_fiche'])
-            && ! isset ($_POST['update_fiche'])
-            && ! isset ($_POST['move'])
-            && ! isset ($_POST['delete']))
-    {
-        $g_user->can_request(FICADD);
-
-        echo '<DIV class="redcontent" style="width:auto">';
-        $fiche_def=new Fiche_Def($cn,$_GET['fiche']);
-        $fiche_def->myList();
-
-        echo '</DIV>';
-
-        $recherche=false;
-    }
-    //_________________________________________________________________________
-    // Display the detail of a card
-    if ($action== "detail" )
-    {
-        echo '<DIV class="redcontent" style="width:auto">';
-        $t=false;
-        if ( $g_user->check_action(FICADD)==0)
-        {
-            echo '<H2 class="info"> Vos changements ne seront pas sauvés</h2>';
-            $t=true;
-        }
-        $str="&".dossier::get();
-        $fiche=new Fiche($cn,$_GET["fiche_id"]);
-        $fiche->get_categorie();
-        $fiche_def=new Fiche_Def($cn,$fiche->fd_id);
-        $fiche_def->Get();
-        echo '<h2 class="info">'.$fiche_def->label.'</h2>';
-
-        if ( $_SESSION['g_pagesize'] != -1 )
-        {
-            // retrieve value
-            // with offet &offset=15&step=15&page=2&size=15
-            if ( isset($_GET['offset']) && $_SESSION['g_pagesize'] != -1)
-            {
-                $str=sprintf("&offset=%s&step=%s&page=%s&size=%s",
-                             $_GET['offset'],
-                             $_GET['step'],
-                             $_GET['page'],
-                             $_GET['size']);
-            }
-
-
-        }
-        if ( $write != 0 )
-            echo '<form method="post" 
action="?p_action=fiche&action=vue&fiche='.$_GET['fiche'].$str.'">';
-        echo dossier::hidden();
-        echo $fiche->Display($t);
-       echo HtmlInput::hidden('ac',$_REQUEST['ac']);
-        echo HtmlInput::hidden("f_id",$_GET['fiche_id']);
-        if ( $write != 0 )
-        {
-            $iselect=new ISelect('move_to');
-            $iselect->value=$cn->make_array('select fd_id,fd_label from 
fiche_def order by fd_label'); //where frd_id='.$fiche->get_fiche_def_ref_id());
-
-            echo HtmlInput::submit("update_fiche","Mise &agrave; jour");
-            echo HtmlInput::submit("delete" ,"Effacer cette 
fiche","onclick=\"return confirm('"._('Vous confirmez ?')."');\"");
-           echo 
HtmlInput::history_card_button($_GET['fiche_id'],_('Historique'));
-            echo HtmlInput::submit('move',_('Déplacer vers'),"onclick=\"return 
confirm('"._('Attention, certains attributs pourraient être ajoutés à la 
catégorie de destination, vous confirmez ?')."');\"");
-            echo $iselect->input();
-        }
-        $str="";
-        echo 
HtmlInput::button_anchor(_('Retour'),'?p_action=fiche&action=vue&'.$str_dossier.'&fiche='.$fiche->fiche_def.$str.
-               "&ac=".$_REQUEST['ac']);
-
-        if ( $write != 0 ) echo '</form>';
-        echo '</DIV>';
-        $recherche=false;
-    }
-    //_________________________________________________________________________
-    // Display the form where you can enter
-    // the property of the card model
-    if ($action == "add_modele" )
-    {
-        $g_user->can_request(FICCAT);
-        echo '<DIV class="redcontent" style="width:auto">';
-        echo '<form method="post">';
-       echo HtmlInput::hidden('ac',$_REQUEST['ac']);
-        $oFiche_Def=new Fiche_Def($cn);
-        echo HtmlInput::hidden("p_action","fiche");
-        echo dossier::hidden();
-        echo $oFiche_Def->input(); //    CreateCategory($cn,$search);
-        echo HtmlInput::submit("add_modele" ,"Sauve");
-
-        echo '</form>';
-        echo '</DIV>';
-        $recherche=false;
-    }
-    //_________________________________________________________________________
-    // Modify a card Model
-    if ($action == "modifier" )
-    {
-        $g_user->can_request(FICCAT);
-        echo '<DIV class="redcontent" style="width:auto">';
-        $fiche_def=new Fiche_Def($cn,$_GET['fiche']);
-
-        echo ShowFicheDefInput($fiche_def);
-        echo '</DIV>';
-        $recherche=false;
-    }
-    //_________________________________________________________________________
-    // Search a card
-    if ( $action == "search" )
-    {
-        echo '<DIV class="redcontent" style="width:auto;">';
-        ShowRecherche();
-        $sql="select distinct f_id,fd_id from fiche join fiche_detail using 
(f_id)
-                 where
-             upper(ad_value) like 
upper('%".sql_string($_GET["search_text"])."%') order by f_id";
-
-        $all=$cn->get_array($sql);
-        // test on the size
-        //
-        if ( sizeof($all) != 0 )
-        {
-
-            echo "<b>Résultat : ".sizeof($all).'éléments trouvés </b><br>';
-            foreach ($all as $f_id)
-            {
-                $fiche=new Fiche($cn,$f_id['f_id']);
-                echo '<A  
href="?p_action=fiche&'.$str_dossier.'&action=detail&fiche_id='.$f_id['f_id'].
-                '&fiche='.$f_id['fd_id']."&ac=".$_REQUEST['ac'].'">'.
-                $fiche->getName().'</A>';
-            }
-        }
         else
         {
-            echo '<DIV class="redcontent" style="width:auto">';
-            echo "Aucun résultat trouvé";
-
+            $fiche_def->set_autocreate(false);
         }
-        echo '</div>';
+        $fiche_def->save_class_base($_REQUEST['class_base']);
 
-
     }
-    $recherche=false;
+       echo $fiche_def->input_detail();
+       echo $retour;
+       exit();
 }
-// Display a blank  card from the selected category
-if ( isset ($_POST["fiche"]) && isset ($_POST["add"] ) )
+/*******************************************************************************************/
+// Save order of the attributes
+/*******************************************************************************************/
+if ( isset($_POST['save_line']))
 {
-    $g_user->can_request(FICADD);
-
-    echo '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        echo "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
-    {
-        $fiche_def=new Fiche_Def($cn,$_POST['fiche']);
-        $fiche_def->Get();
-        echo '<h2 class="info">'.$fiche_def->label.'</h2>';
-        $fiche=new Fiche($cn,0);
-        echo '<form method="post" >';
-        echo dossier::hidden();
-               echo HtmlInput::hidden('ac',$_REQUEST['ac']);
-               echo HtmlInput::hidden('fiche',$_POST['fiche']);
-        echo $fiche->blank($_POST['fiche']);
-        echo HtmlInput::submit("add_fiche","Ajout");
-
-
-        echo '</form>';
-    }
-    echo '</DIV>';
-    $recherche=false;
-    exit();
+    $fiche_def=new Fiche_Def($cn,$_REQUEST['fd_id']);
+    $fiche_def->save_order($_POST);
+       echo $fiche_def->input_detail();
+       echo $retour;
+       exit();
 }
-//------------------------------------------------------------------------------
-// delete a card
-if (isset($_POST['delete']) )
+/*******************************************************************************************/
+// Save a new category of card
+/*******************************************************************************************/
+if ( isset($_POST['add_modele']))
 {
-    $g_user->can_request(FICADD);
-    ShowRecherche();
-    echo '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        echo "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
-    {
-        $fiche=new Fiche($cn,$_POST["f_id"]);
-        $fiche->remove();
-    }
-    $fiche_def=new Fiche_Def($cn,$_GET['fiche']);
-    $fiche_def->myList();
-
-    echo "</DIV>";
-    exit();
+       $single=new Tool_Uos("dup");
+       if ($single->get_count()==0)
+       {
+               $single->save();
+               $fiche_def=new Fiche_Def($cn);
+               if ( $fiche_def->Add($_POST) == 0 )
+               {
+                       echo $fiche_def->input_detail();
+                       echo $retour;
+                       exit();
+               }
+               else
+               {
+                       $fiche_def->input_new();
+                       echo $retour;
+                       exit();
+               }
+       }
+       else
+       {
+               alert('Doublon');
+       }
 }
-//------------------------------------------------------------------------------
-// Add the data (attribute) of the card
-if ( isset ($_POST["add_fiche"]) )
-{
-    $g_user->can_request(FICADD);
-    if ( $write ==0)
-    {
-        echo '<DIV class="redcontent" style="width:auto">';
-        echo "<h2 class=\"error\"> Pas d'accès </h2>";
-    }
-    else
-    {
-        ShowRecherche();
-        echo '<DIV class="redcontent" style="width:auto">';
-        $fiche=new Fiche($cn);
-        $fiche->Save($_REQUEST['fiche']);
-        $fiche_def=new Fiche_Def($cn,$_REQUEST['fiche']);
-        $fiche_def->myList();
+$fiche_def=new Fiche_def($cn);
 
-
-    }
-    echo '</DIV>';
-    $recherche=false;
-}
-//------------------------------------------------------------------------------
-// Update a card
-if ( isset ($_POST["update_fiche"])  )
-{
-    $g_user->can_request(FIC);
-    echo '<DIV class="redcontent" style="width:auto">';
-    if ( $write ==0)
-        echo "<h2 class=\"error\"> Pas d'accès </h2>";
-    else
-    {
-        $fiche=new Fiche($cn,$_POST['f_id']);
-        $fiche->Save();
-
-    }
-    $fiche_def=new Fiche_Def($cn,$_GET['fiche']);
-    $fiche_def->myList();
-
-
-
-
-
-    echo '</DIV>';
-    $recherche=false;
-}
-//--------------------------------------------------------------------------------
-// Move a card to a new category
-if ( isset($_POST['move']))
-{
-    echo '<DIV class="redcontent" style="width:auto">';
-    $fiche=new Fiche($cn,$_POST['f_id']);
-    $fiche->move_to($_POST['move_to']);
-    $fiche_def=new Fiche_Def($cn,$_GET['fiche']);
-    $fiche_def->myList();
-    echo '</div>';
-}
-//--Search menu
-if ( $recherche==true)
-{
-    ShowRecherche();
-}
-html_page_stop();
+$fiche_def->Display();
+$dossier=Dossier::id();
 ?>

Modified: phpcompta/trunk/include/class_fiche_def.php
===================================================================
--- phpcompta/trunk/include/class_fiche_def.php 2012-06-23 00:45:16 UTC (rev 
4982)
+++ phpcompta/trunk/include/class_fiche_def.php 2012-06-24 15:46:43 UTC (rev 
4983)
@@ -156,19 +156,30 @@
     }
     /*!
      **************************************************
-     * \brief  Display a fiche_def object into a table
+     * \brief  Display category into a table
      *
      * \return HTML row
      */
     function Display()
     {
+               $tab = new Sort_Table();
 
-        $r=sprintf("<TD>%s</TD>",$this->id);
-        $r.=sprintf("<TD>%s</TD>",$this->label);
-        $r.=sprintf("<TD>%s</TD>",$this->class_base);
-        $r.=sprintf("<TD>%s</TD>",$this->fiche_def);
-        return $r;
-    }
+               $url = HtmlInput::get_to_string(array('ac', 'gDossier'));
+               $tab->add("Nom de fiche", $url, "order by fd_label asc", "order 
by fd_label desc", "na", "nd");
+               $tab->add("Basé sur le poste comptable", $url, "order by 
fd_class_base asc", "order by fd_class_base desc", "pa", "pd");
+               $tab->add("Calcul automatique du poste comptable", $url, "order 
by fd_create_account asc", "order by fd_create_account desc", "ca", "cd");
+               $tab->add("Basé sur le modèle", $url, "order by frd_text asc", 
"order by frd_text  desc", "ma", "md");
+
+               $order = (isset($_GET['ord'])) ? 
$tab->get_sql_order($_GET["ord"]) : $tab->get_sql_order("na");
+
+
+               $res = $this->cn->exec_sql("SELECT fd_id, fd_class_base, 
fd_label, fd_create_account, fiche_def_ref.frd_id,
+frd_text  FROM fiche_def join fiche_def_ref on 
(fiche_def.frd_id=fiche_def_ref.frd_id)
+$order
+");
+
+               require_once 'template/fiche_def_list.php';
+       }
     /*!\brief Add a fiche category thanks the element from the array
      * you cannot add twice the same cat. name
      * table : insert into fiche_def
@@ -191,13 +202,15 @@
 
         // Name can't be empty
         if ( strlen(trim($p_nom_mod)) == 0 )
-            return;
-
+               {
+                       alert (_('Le nom de la catégorie ne peut pas être 
vide'));
+            return 1;
+               }
         // $p_FICHE_REF cannot be null !!! (== fiche_def_ref.frd_id
         if (! isset ($p_FICHE_REF) || strlen($p_FICHE_REF) == 0 )
         {
             echo alert (_('Vous devez choisir une categorie'));
-            return;
+            return 1;
         }
         $fiche_Def_ref=new Fiche_Def_Ref($this->cn,$p_FICHE_REF);
         $fiche_Def_ref->Get();
@@ -215,7 +228,10 @@
         $sql="select count(*) from fiche_Def where upper(fd_label)=upper($1)";
         $count=$this->cn->get_value($sql,array(trim($p_nom_mod)));
 
-        if ($count != 0 ) return -1;
+        if ($count != 0 ) {
+                        echo alert (_('Catégorie existante'));
+                       return 1;
+               }
         // Set the value of fiche_def.fd_create_account
         // automatic creation for 'poste comptable'
         if ( isset($p_create) && strlen(trim($p_class_base)) != 0)
@@ -269,15 +285,17 @@
         if (sizeof($def_attr) != 0 )
         {
             // insert all the mandatory fields into jnt_fiche_attr
+            $jnt_order=10;
             foreach ( $def_attr as $i=>$v)
             {
-                $jnt_order=10;
+                               $order=$jnt_order;
                 if ( $v['ad_id'] == ATTR_DEF_NAME )
-                    $jnt_order=0;
+                    $order=0;
                 $sql=sprintf("insert into jnt_fic_Attr(fd_id,ad_id,jnt_order)
                              values (%d,%s,%d)",
-                             $fd_id,$v['ad_id'],$jnt_order);
+                             $fd_id,$v['ad_id'],$order);
                 $this->cn->exec_sql($sql);
+                               $jnt_order+=10;
             }
         }
         $this->id=$fd_id;
@@ -717,8 +735,58 @@
         $ret=$this->cn->count_sql("select fd_id from fiche_def where 
frd_id=$1",array($p_frd_id));
         return $ret;
     }
+       function input_detail()
+       {
+               $r = "";
+               // Save the label
 
+               $this->Get();
+               $this->GetAttribut();
+               $r.= '<H2 class="info">' . $this->id . " " . h($this->label) . 
'</H2>';
+               $r.='<fieldset><legend>Données générales</legend>';
 
+               /* show the values label class_base and create account */
+               $r.='<form method="post">';
+               $r.=dossier::hidden();
+               $r.=HtmlInput::hidden("fd_id", $this->id);
+               $r.=HtmlInput::hidden("p_action", "fiche");
+               $r.= $this->input_base();
+               $r.='<hr>';
+               $r.=HtmlInput::submit('change_name', _('Sauver'));
+               $r.='</form>';
+               $r.='</fieldset>';
+               /* attributes */
+               $r.='<fieldset><legend>Détails</legend>';
 
+               $r.= '<FORM  method="POST">';
+               $r.=dossier::hidden();
+               $r.=HtmlInput::hidden("fd_id", $this->id);
+               $r.= $this->DisplayAttribut("remove");
+               $r.= HtmlInput::submit('add_line', _('Ajoutez cet élément'));
+               $r.= HtmlInput::submit("save_line", _("Sauvez"));
+               $r.=HtmlInput::submit('remove_cat', _('Effacer cette 
catégorie'), 'onclick="return confirm(\'' . _('Vous confirmez ?') . '\')"');
+               // if there is nothing to remove then hide the button
+               if (strpos($r, "chk_remove") != 0)
+               {
+                       $r.=HtmlInput::submit('remove_line', _("Enleve les 
éléments cochés"), "onclick=\"return confirm('Vous confirmez?')\"");
+               }
+               $r.= "</form>";
+               $r.=" <p class=\"notice\"> " . _("Attention : il n'y aura pas 
de demande de confirmation pour enlever les
+                                   attributs sélectionnés. Il ne sera pas 
possible de revenir en arrière") . "</p>";
+               $r.='</fieldset>';
+               return $r;
+       }
+       function input_new()
+       {
+               $single=new Tool_Uos("dup");
+               echo '<form method="post" style="display:inline">';
+               echo $single->hidden();
+               echo HtmlInput::hidden("p_action","fiche");
+               echo dossier::hidden();
+               echo $this->input(); //    CreateCategory($cn,$search);
+               echo HtmlInput::submit("add_modele" ,"Sauve");
+               echo '</FORM>';
+       }
+
 }
 ?>

Modified: phpcompta/trunk/include/class_tool_uos.php
===================================================================
--- phpcompta/trunk/include/class_tool_uos.php  2012-06-23 00:45:16 UTC (rev 
4982)
+++ phpcompta/trunk/include/class_tool_uos.php  2012-06-24 15:46:43 UTC (rev 
4983)
@@ -19,7 +19,7 @@
 /* $Revision: $Revision $ */
 /**
  * @file
- * Objec to check a double insert into the database, this duplicate occurs 
after 
+ * Objec to check a double insert into the database, this duplicate occurs 
after
  * a refresh of the web page
  */
 // Copyright Author Dany De Bontridder address@hidden
@@ -32,35 +32,34 @@
      * Constructor $p_name will be set to $this->name, it is also the name
      * of the tag hidden in a form
      * @global $cn Db connxion
-     * @param $p_name 
+     * @param $p_name
      */
     function __construct($p_name)
     {
-          global $cn;
         $this->name=$p_name;
-        $this->id=$cn->get_next_seq('uos_pk_seq');
     }
     /**
-     * @brief return a string with a tag hidden and a uniq value 
+     * @brief return a string with a tag hidden and a uniq value
      * @param $hHidden is the name of the tag hidden
      * @return string : tag hidden
      */
-    function hidden($hHidden)
+    function hidden()
     {
-        return HtmlInput::hidden($hHidden,$this->id);
+               global $cn;
+        $this->id=$cn->get_next_seq('uos_pk_seq');
+        return HtmlInput::hidden($this->name,$this->id);
     }
     /**
      * @brief Try to insert into the table tool_uos
      * @global $cn Database connx
-     * @param $p_id integer is the value of hidden
      * @throws Exception if the value $p_id is not unique
      */
-    function save($p_id)
+    function save()
     {
         global $cn;
         $sql="insert into tool_uos(uos_value) values ($1)";
         try {
-            $cn->exec_sql($sql,array($this->id));   
+            $cn->exec_sql($sql,array($this->id));
         } catch (Exception $e)
         {
             throw new Exception('Duplicate value','CODE_EXCP_DUPLICATE',$e);
@@ -79,7 +78,7 @@
         if ( $p_array == null ) $p_array=$_POST;
         $this->id=$p_array[$this->name];
         $count=$cn->get_value('select count(*) from tool_uos where 
uos_value=$1',
-                array($p_id));
+                array($this->id));
         return $count;
     }
     function check ($p_array=null)
@@ -87,7 +86,7 @@
         global $cn;
         if ( $p_array == null ) $p_array=$_POST;
         $this->id=$p_array[$this->name];
-        try 
+        try
         {
             $count=$cn->get_value('select count(*) from tool_uos where 
uos_value=$1',
                     array($p_id));

Added: phpcompta/trunk/include/template/fiche_def_list.php
===================================================================
--- phpcompta/trunk/include/template/fiche_def_list.php                         
(rev 0)
+++ phpcompta/trunk/include/template/fiche_def_list.php 2012-06-24 15:46:43 UTC 
(rev 4983)
@@ -0,0 +1,81 @@
+<?php
+
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief show all the categories of card fiche_def
+ *
+ */
+$max=Database::num_row($res);
+?>
+<div id="list_cat_div" class="content">
+<table class="result">
+       <tR>
+               <th>
+                       <?=$tab->get_header(0)?>
+               </th>
+               <th>
+                       <?=$tab->get_header(1)?>
+               </th>
+               <th>
+                       <?=$tab->get_header(2)?>
+               </th>
+               <th>
+                       <?=$tab->get_header(3)?>
+               </th>
+       </tR>
+<?
+$dossier=Dossier::id();
+for ($i=0;$i<$max;$i++):
+       $row=Database::fetch_array($res, $i);
+?>
+       <tr>
+               <td>
+               <?=HtmlInput::anchor(h($row['fd_label']), "javascript:void(0)", 
"onclick=\"detail_category_show('detail_category_div','".$dossier."','".$row['fd_id']."')\"")?>
+               </td>
+               <td>
+                       <?=h($row['fd_class_base'])?>
+               </td>
+               <td>
+                       <?
+                        
$v=($row['fd_create_account']=='t')?"Automatique":"Manuel";
+                        echo $v;
+                       ?>
+               </td>
+               <td>
+                       <?=$row['frd_text']?>
+               </td>
+       </tr>
+
+
+<?
+endfor;
+?>
+</table>
+<?
+echo HtmlInput::button("cat_fiche_def_add","Ajout d'une nouvelle catégorie", 
"onclick=\"detail_category_show('detail_category_div','".$dossier."','-1')\"");
+?>
+</div>
+<div id="detail_category_div" style="display:none"">
+
+</div>
\ No newline at end of file

Added: phpcompta/trunk/include/template/fiche_list.php
===================================================================
--- phpcompta/trunk/include/template/fiche_list.php                             
(rev 0)
+++ phpcompta/trunk/include/template/fiche_list.php     2012-06-24 15:46:43 UTC 
(rev 4983)
@@ -0,0 +1,77 @@
+<?php
+/*
+ *   This file is part of PhpCompta.
+ *
+ *   PhpCompta is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   PhpCompta is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with PhpCompta; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+/* $Revision$ */
+
+// Copyright Author Dany De Bontridder address@hidden
+
+/**
+ * @file
+ * @brief Show a list of card
+ *
+ */
+?>
+<?= $bar?>
+<form method="POST" class="print" style="display:inline" onsubmit="return 
confirm('Vous confirmez ?')">
+       <table>
+               <tr>
+                       <th>
+                               Quick Code
+                       </th>
+                       <th>
+                               Nom
+
+                       </th>
+                       <th>
+                               Selection
+                       </th>
+               </tr>
+               <? for ($i = 0; $i < $nb_line; $i++) :?>
+                       <? $row = Database::fetch_array($res, $i);?>
+                       <tr>
+                               <td>
+                                       <?= 
HtmlInput::card_detail($row['qcode'], "", ' class="line" ')?>
+
+                               </td>
+                               <td>
+                                       <?= h($row['name'])?>
+                               </td>
+                               <td>
+                                       <?
+                                       if ($write == 1)
+                                       {
+                                               $ck = new ICheckBox('f_id[]', 
$row['f_id']);
+                                               echo $ck->input();
+                                       }
+                                       ?>
+                               </td>
+                       </tr>
+               <? endfor;?>
+
+
+       </table>
+<?=HtmlInput::hidden('action',"1");?>
+<?=HtmlInput::submit('delete','Effacer la sélection ')?>
+<?=HtmlInput::submit('move','Déplacer la sélection  vers')?>
+<?
+$iselect=new ISelect('move_to');
+$iselect->value=$cn->make_array("select fd_id,fd_label from fiche_def order by 
2");
+echo $iselect->input();
+?>
+</form>
+<?= $bar?>
\ No newline at end of file



---
PhpCompta est un logiciel de comptabilité libre en ligne (full web)
Projet opensource http://www.phpcompta.eu



reply via email to

[Prev in Thread] Current Thread [Next in Thread]