diff --git a/html/commercial.php b/html/commercial.php
index 9b465acbb..eb7c80c72 100644
--- a/html/commercial.php
+++ b/html/commercial.php
@@ -76,6 +76,7 @@ echo ShowItem(array(
array('?p_action=client','Client'),
array('?p_action=facture','Facture'),
array('?p_action=fournisseur','Fournisseur'),
+ array('?p_action=depense','Dépense'),
array('?p_action=contact','Contact'),
array('?p_action=suivi_courrier','Suivi courrier'),
array('?p_action=pref','Préférence'),
@@ -109,7 +110,7 @@ if ( $p_action == "client" )
// Fournisseur
if ( $p_action == 'fournisseur')
{
- require_once("fournisseur.inc.php");
+ require_once("supplier.inc.php");
}
////////////////////////////////////////////////////////////////////////////////
// action
@@ -130,3 +131,9 @@ if ( $p_action == 'contact')
{
require_once("contact.inc.php");
}
+////////////////////////////////////////////////////////////////////////////////
+// Expense
+if ( $p_action == 'depense')
+{
+ require_once("depense.inc.php");
+}
diff --git a/include/class_document.php b/include/class_document.php
index b2239631f..648ff20b6 100644
--- a/include/class_document.php
+++ b/include/class_document.php
@@ -593,7 +593,7 @@ class Document
$sql='delete from document where d_id='.$this->d_id;
ExecSql($this->db,$sql);
}
- /*!\brief Copy a document from the table document into the concerned row
+ /*!\brief Move a document from the table document into the concerned row
* the document is not copied : it is only a link
*
* \param $p_internal internal code
diff --git a/include/class_supplier.php b/include/class_supplier.php
new file mode 100644
index 000000000..8eb819637
--- /dev/null
+++ b/include/class_supplier.php
@@ -0,0 +1,158 @@
+
+/*
+ * 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 ddebontridder@yahoo.fr
+require_once("constant.php");
+require_once("postgres.php");
+require_once("class_parm_code.php");
+require_once("class_widget.php");
+
+require_once('class_fiche.php');
+require_once('class_poste.php');
+require_once('user_common.php');
+/*! \file
+ * \brief Derived from class fiche Supplier are a specific kind of card
+ */
+/*!
+ * \brief class Supplier are a specific kind of card
+ */
+
+// Use the view vw_supplier
+//
+class Supplier extends fiche{
+
+ var $poste; /*! \enum $poste poste comptable */
+ var $name; /*! \enum $name name of the company */
+ var $street; /*! \enum $street Street */
+ var $country; /*! \enum $country Country */
+ var $cp; /*! \enum $cp Zip code */
+ var $vat_number; /*! \enum $vat_number vat number */
+
+ /*! \brief Constructor
+ /* only a db connection is needed */
+ function Supplier($p_cn,$p_id=0) {
+ $this->fiche_def_ref=FICHE_TYPE_FOURNISSEUR;
+ fiche::fiche($p_cn,$p_id) ;
+
+ }
+ /*! \brief Get all info contains in the view
+ * thanks to the poste elt (account)
+ */
+ function GetFromPoste($p_poste=0) {
+ $this->poste=($p_poste==0)?$this->poste:$p_poste;
+ $sql="select * from vw_supplier where poste_comptable=".$this->poste;
+ $Res=ExecSql($this->cn,$sql);
+ if ( pg_NumRows($Res) == 0) return null;
+ // There is only _one_ row by supplier
+ $row=pg_fetch_array($Res,0);
+ $this->name=$row['name'];
+ $this->id=$row['f_id'];
+ $this->street=$row['rue'];
+ $this->cp=$row['code_postal'];
+ $this->country=$row['pays'];
+ $this->vat_number=$row['tva_num'];
+
+ }
+
+/*! \function Summary
+ **************************************************
+ \Brief show the default screen
+ *
+ * parm :
+ * - p_search (filter)
+ * gen :
+ * -
+ * return: string to display
+ */
+ function Summary($p_search)
+ {
+ $p_search=FormatString($p_search);
+ $url=urlencode($_SERVER['REQUEST_URI']);
+ $script=$_SERVER['SCRIPT_NAME'];
+ // Creation of the nav bar
+ // Get the max numberRow
+ $all_supplier=$this->CountByDef($this->fiche_def_ref,$p_search);
+ // Get offset and page variable
+ $offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
+ $page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
+ $bar=jrn_navigation_bar($offset,$all_supplier,$_SESSION['g_pagesize'],$page);
+ // set a filter ?
+ $search="";
+ if ( trim($p_search) != "" )
+ {
+ $search=" and f_id in
+(select f_id from jnt_fic_att_value
+ join fiche using (f_id)
+ join attr_value using (jft_id)
+ where
+ ad_id=1 and av_text ~* '$p_search')";
+ }
+ // Get The result Array
+ $step_supplier=$this->GetAll($offset,$search);
+ if ( $all_supplier == 0 ) return "";
+ $r=$bar;
+ $r.='
";
+ $r.=$bar;
+ return $r;
+ }
+
+}
+
+?>
diff --git a/include/contact.inc.php b/include/contact.inc.php
index 965c7cb34..78d5ca669 100644
--- a/include/contact.inc.php
+++ b/include/contact.inc.php
@@ -77,6 +77,7 @@ if ( isset ($_POST['mod']))
$contact=new contact($cn,$f_id);
$contact->Save();
+ $sub_action="list";
}
// by default open liste
if ( $sub_action == "" )
diff --git a/include/depense.inc.php b/include/depense.inc.php
new file mode 100644
index 000000000..283695e5e
--- /dev/null
+++ b/include/depense.inc.php
@@ -0,0 +1,236 @@
+
+/*
+ * 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 ddebontridder@yahoo.fr
+require_once('class_jrn.php');
+require_once('user_form_ach.php');
+require_once('jrn.php');
+require_once("class_document.php");
+require_once("class_fiche.php");
+/*!\brief the purpose off this file encode expense and to record them
+ *
+ */
+
+var_dump($_REQUEST);
+// First we show the menu
+// If nothing is asked the propose a blank form
+// to enter a new invoice
+if ( ! isset ($_REQUEST['p_jrn'])) {
+ // no journal are selected so we select the first one
+ $p_jrn=GetFirstJrnIdForJrnType($_SESSION['g_dossier'],'ACH');
+
+} else
+{
+ $p_jrn=$_REQUEST['p_jrn'];
+}
+// for the back button
+$retour="";
+$h_url="";
+
+if ( isset ($_REQUEST['url']))
+{
+ $retour=sprintf('',urldecode($_REQUEST['url']));
+ $h_url=sprintf('',urldecode($_REQUEST['url']));
+}
+
+$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
+////////////////////////////////////////////////////////////////////////////////
+// If a list of depense is asked
+//
+if ( $sub_action == "list")
+{
+
+ // show the menu with the list item selected
+ echo '
';
+ // Ask to update payment
+ if ( isset ( $_GET['paid']))
+ {
+ // reset all the paid flag because the checkbox is post only
+ // when checked
+ foreach ($_GET as $name=>$paid)
+ {
+ list($ad) = sscanf($name,"set_jr_id%d");
+ if ( $ad == null ) continue;
+ $sql="update jrn set jr_rapt='' where jr_id=$ad";
+ $Res=ExecSql($cn,$sql);
+
+ }
+ // set a paid flag for the checked box
+ foreach ($_GET as $name=>$paid)
+ {
+ list ($id) = sscanf ($name,"rd_paid%d");
+
+ if ( $id == null ) continue;
+ // echo "Mise à jour $id";
+ $paid=($paid=='on')?'paid':'';
+ $sql="update jrn set jr_rapt='$paid' where jr_id=$id";
+ $Res=ExecSql($cn,$sql);
+ }
+
+ }
+
+ echo '
';
+////////////////////////////////////////////////////////////////////////////////
+// if we request to add an item
+// the $_POST['add_item'] is set
+// or if we ask to correct the invoice
+if ( isset ($_POST['add_item']) || isset ($_POST["correct_new_invoice"]) )
+{
+ $nb_item=$_POST['nb_item'];
+ $nb_item++;
+ // Submit button in the form
+ $submit='
+ ';
+
+ $form=FormAchInput($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,$submit,false,$nb_item);
+ echo '
';
+ echo $form;
+ echo '
';
+ exit();
+}
+////////////////////////////////////////////////////////////////////////////////
+// we want to save the invoice and to generate a invoice
+//
+if ( isset($_POST['save']))
+{
+ // we save the expense
+ list ($internal,$c)=RecordSell($cn,$_POST,$User,$p_jrn);
+
+
+ $form=FormAchView($cn,$_GET['p_jrn'],$User->GetPeriode(),$_POST,"",$_POST['nb_item'],false);
+
+ echo '
';
+ echo '
Opération '.$internal.' enregistré
';
+ echo $form;
+ echo '';
+ echo '';
+ echo '
+ ';
+ exit();
+}
+////////////////////////////////////////////////////////////////////////////////
+// we show the confirmation screen
+//
+if ( isset ($_POST['view_invoice']) )
+{
+ $nb_number=$_POST["nb_item"];
+ $submit='';
+ $submit.='';
+ if ( form_verify_input ($cn,$p_jrn,$User->GetPeriode(),$_POST,$nb_number) == true ) {
+ // Should use a read only view instead of FormAch
+ // where we can check
+ $form=FormAchView($cn,$p_jrn,$User->GetPeriode(),$_POST,$submit,$nb_number);
+ } else {
+ // if something goes wrong, correct it
+ $submit='
+ ';
+ $form=FormAchInput($cn,$p_jrn,$User->GetPeriode(),$_POST,$submit, false, $nb_number);
+ }
+
+ echo '
';
+ echo $form;
+ echo '
';
+ exit();
+
+}
+
+
+
+////////////////////////////////////////////////////////////////////////////////
+// By default we add a new invoice
+if ( $p_jrn != -1 )
+{
+ $jrn=new jrn($cn, $p_jrn);
+ echo_debug('depense.inc.php',__LINE__,"Blank form");
+ // Submit button in the form
+ $submit='
+ ';
+ // Show an empty form of invoice
+ $form=FormAchInput($cn,$p_jrn,$User->GetPeriode(),null,$submit,false,$jrn->getDefLine('cred'));
+ echo '
';
+ echo $form;
+ echo '
';
+}
diff --git a/include/facture.inc.php b/include/facture.inc.php
index f20c13596..b6773d820 100644
--- a/include/facture.inc.php
+++ b/include/facture.inc.php
@@ -26,13 +26,6 @@ require_once("class_fiche.php");
/*!\brief the purpose off this file is to create invoices, to record them and to generate
* them, and of course to save them into the database
*
- * \note we update also the jrn.
- * jr_pj oid
- * jr_pj_name text
- * jr_pj_type text
- * \todo link the table document and jrn, remove those field to make it cleaner and to permit to
- * several operation for one document. For that we should have a new item in the menu (link
- * document and operation) To be analyzed
*/
var_dump($_REQUEST);
@@ -40,24 +33,22 @@ var_dump($_REQUEST);
// If nothing is asked the propose a blank form
// to enter a new invoice
if ( ! isset ($_REQUEST['p_jrn'])) {
- // no journal are selected so we select the first one
- // $p_jrn=GetFirstJrnIdForJrnType($_SESSION['g_dossier'],'VEN');
- $p_jrn=-1;
+ // no journal are selected so we select the first one
+ $p_jrn=GetFirstJrnIdForJrnType($_SESSION['g_dossier'],'VEN');
+ // $p_jrn=-1;
} else
{
$p_jrn=$_REQUEST['p_jrn'];
}
// for the back button
+$retour="";
+$h_url="";
+
if ( isset ($_REQUEST['url']))
{
$retour=sprintf('',urldecode($_REQUEST['url']));
$h_url=sprintf('',urldecode($_REQUEST['url']));
}
-else
-{
- $retour="";
- $h_url="";
-}
$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
////////////////////////////////////////////////////////////////////////////////
@@ -68,7 +59,7 @@ if ( $sub_action == "list")
// show the menu with the list item selected
echo '
';
// Ask to update payment
if ( isset ( $_GET['paid']))
@@ -127,7 +118,7 @@ if ( $sub_action == "list")
$qcode=(isset($_GET['qcode']))?$_GET['qcode']:"";
printf ('Tiers QuickCode: ',
$qcode);
- echo $retour;
+
// Show list of sell
// Date - date of payment - Customer - amount
$sql=SQL_LIST_ALL_INVOICE." and jr_tech_per=".$current." and jr_def_type='VEN'" ;
@@ -153,6 +144,7 @@ if ( $sub_action == "list")
if ( $max_line !=0 )
echo $hid->Submit('paid','Mise à jour paiement');
echo '';
+ echo $retour;
echo '
';
@@ -238,9 +230,9 @@ if ( isset ($_POST['view_invoice']) )
if ( $p_jrn != -1 )
{
$jrn=new jrn($cn, $p_jrn);
- echo_debug('user_action_ven.php',__LINE__,"Blank form");
+ echo_debug('facture.inc.php.php',__LINE__,"Blank form");
// Show an empty form of invoice
- $form=FormVenInput($cn,$_GET['p_jrn'],$User->GetPeriode(),null,false,$jrn->GetDefLine('cred'));
+ $form=FormVenInput($cn,$p_jrn,$User->GetPeriode(),null,false,$jrn->GetDefLine('cred'));
echo '
';
echo $form;
echo '
';
diff --git a/include/supplier.inc.php b/include/supplier.inc.php
new file mode 100644
index 000000000..6fe46d9cc
--- /dev/null
+++ b/include/supplier.inc.php
@@ -0,0 +1,173 @@
+
+/*
+ * 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 ddebontridder@yahoo.fr
+require_once("class_supplier.php");
+$sub_action=(isset($_REQUEST['sa']))?$_REQUEST['sa']:"";
+var_dump($_REQUEST);
+/*! \file
+ * \brief Called from the module "Gestion" to manage the customer
+ */
+
+?>
+
+
+// Menu
+// Remove a card
+if ( isset ($_POST['delete']) )
+{
+ echo 'delete';
+ $f_id=$_REQUEST['f_id'];
+
+ $fiche=new Supplier($cn,$f_id);
+ $fiche->remove();
+ $sub_action="list";
+}
+////////////////////////////////////////////////////////////////////////////////
+// Add card
+if ( $sub_action=="insert" )
+{
+ $retour=sprintf('',
+ urldecode($_REQUEST['url']));
+
+ $supplier=new Supplier($cn);
+ $supplier->Save($_REQUEST['fd_id']);
+ echo $retour;
+ echo "
";
+ echo $supplier->Display(true);
+ echo "
";
+ echo $retour;
+
+}
+////////////////////////////////////////////////////////////////////////////////
+// Save modification
+if ( isset ($_POST['mod']))
+{
+ // modification is asked
+ $f_id=$_REQUEST['f_id'];
+
+ $sup=new Supplier($cn,$f_id);
+ $sup->Save();
+}
+// by default open liste
+if ( $sub_action == "" )
+ $sub_action="list";
+////////////////////////////////////////////////////////////////////////////////
+//Display a blank card
+if ( $sub_action=="blank")
+{
+ $retour=sprintf('',
+ "commercial.php?p_action=fournisseur");
+ echo '