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

supplier.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.4 $ */
00020 // Copyright Author Dany De Bontridder ddebontridder@yahoo.fr
00021 require_once("class_supplier.php");
00022 $sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
00023 
00028 $User->AccessRequest($cn,SUPPL);
00029 ?>
00030 
00031 <?
00032 // Menu
00033 // Remove a card
00034 if ( isset ($_POST['delete']) ) 
00035 {
00036   echo 'delete';
00037   $f_id=$_REQUEST['f_id'];
00038 
00039   $fiche=new Supplier($cn,$f_id);
00040   $fiche->remove();
00041   $sub_action="list";
00042 }
00043 //-----------------------------------------------------
00044 // Add card
00045 if ( $sub_action=="insert" )
00046 {
00047   $retour=sprintf('<A class="two" HREF="%s"><input type="button" value="Retour"></A>',
00048                   urldecode($_REQUEST['url']));
00049 
00050   $supplier=new Supplier($cn);
00051   $supplier->Save($_REQUEST['fd_id']);
00052   echo $retour;
00053   echo "<table>";
00054   echo $supplier->Display(true);
00055   echo "</table>";
00056   echo $retour;
00057 
00058 }
00059 //-----------------------------------------------------
00060 // Save modification
00061 if ( isset ($_POST['mod'])) 
00062 {
00063   // modification is asked
00064   $f_id=$_REQUEST['f_id'];
00065 
00066   $sup=new Supplier($cn,$f_id);
00067   $sup->Save();
00068 }
00069 // by default open liste
00070 if ( $sub_action  == "" ) 
00071       $sub_action="list";
00072 //-----------------------------------------------------
00073 //Display a blank card 
00074 if ( $sub_action=="blank") 
00075 {
00076   $retour=sprintf('<A class="two" HREF="%s"><input type="button" value="Retour"></A>',
00077                   "commercial.php?p_action=fournisseur");
00078   echo '<div class="u_redcontent">';
00079 
00080   echo $retour;
00081   $c=new Supplier($cn);
00082   echo '<form method="post" action="commercial.php"';
00083   echo '<input type="hidden" name="p_action" value="fournisseur">';
00084   echo '<input type="hidden" name="sa" value="insert">';
00085   echo '<input type="hidden" name="fd_id" value="'.$_GET['fd_id'].'">';
00086   echo '<input type="hidden" name="url" value="'.$_GET['url'].'">';
00087   echo $c->blank($_GET['fd_id']);
00088   echo '<input type="Submit" value="Sauve">';
00089   echo '</form>';
00090   echo $retour;
00091   echo '</div>';
00092 }
00093 //-----------------------------------------------------
00094 // list
00095 if ( $sub_action == "list" )
00096 {
00097 ?>
00098 <div class="u_content">
00099 <span>
00100 <form method="get" action="commercial.php">
00101 <?
00102    $a=(isset($_GET['query']))?$_GET['query']:"";
00103    printf ('<input type="text" name="query" value="%s">',
00104            $a);
00105 ?>
00106 <input type="submit" name="submit_query" value="recherche">
00107 <input type="hidden" name="p_action" value="fournisseur">
00108 </form>
00109 </span>
00110 <span>
00111 <form method="get" action="commercial.php">
00112 <input type="hidden" name="url" <?      $url=urlencode($_SERVER['REQUEST_URI']);echo 'value="'.$url.'"'; ?>
00113 <input type="hidden" name="p_action" value="fournisseur">
00114 
00115 <?
00116  $w=new widget("select");
00117  $w->name="fd_id";
00118  $w->value= make_array($cn,"select fd_id,fd_label from fiche_def where ".
00119              " frd_id=".FICHE_TYPE_FOURNISSEUR);
00120  echo $w->IOValue();
00121 ?>
00122 <input type="hidden" name="sa" value="blank">
00123 <input type="submit" name="submit_query" value="Ajout Sup">
00124 
00125 </form>
00126 </span>
00127 <?
00128    $sup=new Supplier($cn);
00129  $search=(isset($_GET['query']))?$_GET['query']:"";
00130  // echo '<div style="position:absolute;left:15%;width:67%;margin-top:20px;">';
00131  echo '<div class="u_redcontent">';
00132  echo $sup->Summary($search);
00133  echo '</div>';
00134  echo '</div>';
00135 
00136 }
00137 //-----------------------------------------------------
00138 // Show Detail
00139 if ( $sub_action == 'detail' )
00140 {
00141   $f_id=$_REQUEST['f_id'];
00142   echo '<div class="u_redcontent">';
00143   $sup=new Supplier($cn,$f_id);
00144   $retour=sprintf('<A class="two" HREF="%s"><input type="button" value="Retour"></A>',
00145                   urldecode($_REQUEST['url']));
00146   echo $retour;
00147   echo '<form action="'.$_REQUEST['url'].'" method="post">'; 
00148   echo $sup->Display(false);
00149   $w=new widget("hidden");
00150   $w->name="p_action";
00151   $w->value="fournisseur";
00152   echo $w->IOValue();
00153   $w->name="f_id";
00154   $w->value=$f_id;
00155   echo $w->IOValue();
00156 
00157   echo $w->Submit('mod','Sauver les modifications');
00158   echo $w->Reset("Annuler");
00159   echo $w->Submit('delete','Effacer cette fiche');
00160   echo '</form>';
00161   echo $retour;
00162   echo '<div>';
00163 }
00164 html_page_stop();
00165 ?>