diff --git a/htdocs/facture.class.php b/htdocs/facture.class.php
index 0c6458f37ee..6e1a58dafe9 100644
--- a/htdocs/facture.class.php
+++ b/htdocs/facture.class.php
@@ -1923,7 +1923,7 @@ class Facture extends CommonObject
$idarray=array();
$sql = 'SELECT rowid';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' WHERE fk_facture_source = '.$this->id;
$sql.= ' AND type = 2';
$resql=$this->db->query($sql);
@@ -1953,7 +1953,7 @@ class Facture extends CommonObject
function getIdReplacingInvoice($option='')
{
$sql = 'SELECT rowid';
- $sql.= ' FROM '.MAIN_DB_PREFIX.'facture';
+ $sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element;
$sql.= ' WHERE fk_facture_source = '.$this->id;
$sql.= ' AND type < 2';
if ($option == 'validated') $sql.= ' AND fk_statut = 1';
diff --git a/htdocs/fourn/facture/fiche.php b/htdocs/fourn/facture/fiche.php
index 216f590c466..8ed19d42c45 100644
--- a/htdocs/fourn/facture/fiche.php
+++ b/htdocs/fourn/facture/fiche.php
@@ -515,6 +515,7 @@ else
print '
'.$langs->trans('NotePublic').' ';
print '';
+ // Ref
print ''.$langs->trans('Ref').' ';
print $fac->ref.' ';
@@ -594,7 +595,7 @@ else
else
{
/*
- *
+ * View card
*/
$head = facturefourn_prepare_head($fac);
$titre=$langs->trans('SupplierInvoice');
diff --git a/htdocs/fourn/fournisseur.facture.class.php b/htdocs/fourn/fournisseur.facture.class.php
index a76b56793dd..eceb7550eec 100644
--- a/htdocs/fourn/fournisseur.facture.class.php
+++ b/htdocs/fourn/fournisseur.facture.class.php
@@ -47,6 +47,8 @@ class FactureFournisseur extends Facture
var $ref;
var $ref_supplier;
var $socid;
+ //! 0=Standard invoice, 1=Replacement invoice, 2=Credit note invoice, 3=Deposit invoice, 4=Proformat invoice
+ var $type;
//! 0=draft,
//! 1=validated,
//! TODO Ce statut doit etre 2 et non 1 classee payee partiellement (close_code='discount_vat','badcustomer') ou completement (close_code=null),
@@ -231,6 +233,8 @@ class FactureFournisseur extends Facture
$this->ref = $this->id;
$this->ref_supplier = $obj->facnumber;
+ $this->type = 0;
+
$this->datep = $obj->df;
$this->date = $obj->df;
$this->date_echeance = $obj->de;
@@ -268,9 +272,9 @@ class FactureFournisseur extends Facture
}
else
{
- dol_syslog('FactureFournisseur::Fetch rowid='.$rowid.' numrows=0 sql='.$sql);
$this->error='Bill with id '.$rowid.' not found sql='.$sql;
- dol_print_error($this->db);
+ dol_syslog('FactureFournisseur::Fetch rowid='.$rowid.' numrows=0 sql='.$sql);
+ dol_print_error('',$sql);
return -2;
}
}
diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php
index 05bb19abc2c..3bc2e0b6385 100644
--- a/htdocs/html.form.class.php
+++ b/htdocs/html.form.class.php
@@ -451,13 +451,14 @@ class Form
* \param htmlname Name of field in form
* \param filter Optionnal filters criteras
* \param showempty Add an empty field
+ * \param showtype Show if third party is customer, prospect or supplier
*/
- function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0)
+ function select_societes($selected='',$htmlname='socid',$filter='',$showempty=0, $showtype=0)
{
- global $conf,$user;
+ global $conf,$user,$langs;
// On recherche les societes
- $sql = "SELECT s.rowid, s.nom, s.code_client, s.code_fournisseur";
+ $sql = "SELECT s.rowid, s.nom, s.client, s.fournisseur, s.code_client, s.code_fournisseur";
$sql.= " FROM ".MAIN_DB_PREFIX ."societe as s";
if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity = ".$conf->entity;
@@ -507,13 +508,22 @@ class Form
while ($i < $num)
{
$obj = $this->db->fetch_object($resql);
+ $label=$obj->nom;
+ if ($showtype)
+ {
+ if ($obj->client || $obj->fournisseur) $label.=' (';
+ if ($obj->client == 1) $label.=$langs->trans("Customer");
+ if ($obj->client == 2) $label.=$langs->trans("Prospect");
+ if ($obj->fournisseur) $label.=($obj->client?', ':'').$langs->trans("Supplier");
+ if ($obj->client || $obj->fournisseur) $label.=')';
+ }
if ($selected > 0 && $selected == $obj->rowid)
{
- print ''.$obj->nom.' ';
+ print ''.$label.' ';
}
else
{
- print ''.$obj->nom.' ';
+ print ''.$label.' ';
}
$i++;
}
diff --git a/htdocs/lib/project.lib.php b/htdocs/lib/project.lib.php
index b417fd50590..5cc8d16e060 100644
--- a/htdocs/lib/project.lib.php
+++ b/htdocs/lib/project.lib.php
@@ -97,11 +97,11 @@ function task_prepare_head($object)
*/
function select_projects($socid, $selected='', $htmlname='projectid')
{
- global $db;
+ global $db,$langs;
// On recherche les projets
- $sql = 'SELECT p.rowid, p.ref, p.title FROM ';
- $sql.= MAIN_DB_PREFIX .'projet as p';
+ $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc';
+ $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE (fk_soc='".$socid."' or fk_soc IS NULL)";
$sql.= " ORDER BY p.title ASC";
@@ -118,13 +118,15 @@ function select_projects($socid, $selected='', $htmlname='projectid')
while ($i < $num)
{
$obj = $db->fetch_object($resql);
+ $labeltoshow=dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12);
+ if (empty($obj->fk_soc)) $labeltoshow.=' ('.$langs->trans("SharedProject").')';
if (!empty($selected) && $selected == $obj->rowid)
{
- print ''.dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12).' ';
+ print ''.$labeltoshow.' ';
}
else
{
- print ''.dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12).' ';
+ print ''.$labeltoshow.' ';
}
$i++;
}
diff --git a/htdocs/projet/fiche.php b/htdocs/projet/fiche.php
index da7db1e8a75..fcf7702c5b7 100644
--- a/htdocs/projet/fiche.php
+++ b/htdocs/projet/fiche.php
@@ -166,7 +166,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Client
print ''.$langs->trans("Company").' ';
//print $_REQUEST["socid"];
- print $html->select_societes($_REQUEST["socid"],'socid','',1);
+ print $html->select_societes($_REQUEST["socid"],'socid','',1,1);
print ' ';
// Responsable du projet
@@ -232,7 +232,7 @@ else
// Client
print ''.$langs->trans("Company").' ';
- print $html->select_societes($projet->societe->id,'socid','',1);
+ print $html->select_societes($projet->societe->id,'socid','',1,1);
print ' ';
// Responsable du projet
diff --git a/mysql/migration/2.6.0-2.7.0.sql b/mysql/migration/2.6.0-2.7.0.sql
index 4d2d91b55b4..d6b7dfb7971 100644
--- a/mysql/migration/2.6.0-2.7.0.sql
+++ b/mysql/migration/2.6.0-2.7.0.sql
@@ -72,6 +72,8 @@ ALTER TABLE llx_adherent ADD UNIQUE INDEX uk_adherent_fk_soc (fk_soc);
alter table llx_facture add column tms timestamp after date_valid;
alter table llx_facture_fourn add column tms timestamp after datef;
+alter table llx_facture_fourn add column fk_facture_source integer after fk_user_valid;
+
update llx_facture set tms = datec where tms <= 0;
update llx_facture_fourn set tms = datec where tms <= 0;
diff --git a/mysql/tables/llx_facture_fourn.sql b/mysql/tables/llx_facture_fourn.sql
index 93a4ce35bab..c7ddcd98a7e 100644
--- a/mysql/tables/llx_facture_fourn.sql
+++ b/mysql/tables/llx_facture_fourn.sql
@@ -46,6 +46,7 @@ create table llx_facture_fourn
fk_user_author integer, -- createur de la facture
fk_user_valid integer, -- valideur de la facture
+ fk_facture_source integer, -- facture origine si facture avoir
fk_projet integer, -- projet auquel est associ�e la facture
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)