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

document_modele.inc.php

Go to the documentation of this file.
00001 <?
00002 /*
00003  *   This file is part of PhpCompta.
00004  *
00005  *   PhpCompta is free software; you can redistribute it and/or modify
00006  *   it under the terms of the GNU General Public License as published by
00007  *   the Free Software Foundation; either version 2 of the License, or
00008  *   (at your option) any later version.
00009  *
00010  *   PhpCompta is distributed in the hope that it will be useful,
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  *   GNU General Public License for more details.
00014  *
00015  *   You should have received a copy of the GNU General Public License
00016  *   along with PhpCompta; if not, write to the Free Software
00017  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 */
00019 /* $Revision: 1.3 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00025 require_once("class_document_modele.php");
00026 $sub_action=(isset ($_REQUEST['sa']))?$_REQUEST['sa']:"";
00027 
00028 echo "<hr>";
00029 // show the form for adding a template
00030 //
00031 $doc=new Document_modele($cn);
00032 
00033 echo $doc->form('parametre.php?p_action=document');
00034 
00035 //-----------------------------------------------------
00036 // Document     add a template
00037 //-----------------------------------------------------
00038 if ( $sub_action=='add_document') 
00039 {
00040   require_once("class_document_modele.php");
00041   $doc=new Document_modele($cn);
00042   $doc->md_name=$_POST['md_name'];
00043   $doc->md_id=-1; // because it is a new model
00044   $doc->md_type=$_POST['md_type'];
00045   $doc->start=$_POST['start_seq'];
00046   $doc->Save();
00047   }
00048 //-----------------------------------------------------
00049 // Document remove a template
00050 //-----------------------------------------------------
00051 if ( $sub_action=='rm_template') {
00052   echo_debug (__FILE__,__LINE__,'Remove some templates');
00053   require_once("class_document_modele.php");
00054   // Get all the document to remove
00055 
00056   foreach ( $_POST as $name=>$value )
00057     {
00058       echo_debug(__FILE__,__LINE__,"name = ".$name);
00059       echo_debug(__FILE__,__LINE__,"value = ".$value);
00060       list ($id) = sscanf ($name,"dm_remove_%d");
00061       echo_debug(__FILE__,__LINE__,"id = ".$id);
00062       if ( $id == null ) continue;
00063       // a document has to be removed
00064       $doc=new Document_modele($cn);
00065       $doc->md_id=$id;
00066       echo_debug (__FILE__,__LINE__,'Removing');
00067       $doc->Delete();
00068     }
00069 
00070 }
00071 
00072 //-----------------------------------------------------
00073 // Default action : Show the list
00074 //-----------------------------------------------------
00075 echo $doc->myList();
00076 ?>