New: Add if project is shared or not in project list

New: Add status of third party in some third parties list.
This commit is contained in:
Laurent Destailleur 2009-08-05 16:58:18 +00:00
parent 688950a08b
commit bd749f6748
8 changed files with 37 additions and 17 deletions

View File

@ -1923,7 +1923,7 @@ class Facture extends CommonObject
$idarray=array(); $idarray=array();
$sql = 'SELECT rowid'; $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.= ' WHERE fk_facture_source = '.$this->id;
$sql.= ' AND type = 2'; $sql.= ' AND type = 2';
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -1953,7 +1953,7 @@ class Facture extends CommonObject
function getIdReplacingInvoice($option='') function getIdReplacingInvoice($option='')
{ {
$sql = 'SELECT rowid'; $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.= ' WHERE fk_facture_source = '.$this->id;
$sql.= ' AND type < 2'; $sql.= ' AND type < 2';
if ($option == 'validated') $sql.= ' AND fk_statut = 1'; if ($option == 'validated') $sql.= ' AND fk_statut = 1';

View File

@ -515,6 +515,7 @@ else
print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</td>'; print '<td width="50%" valign="top">'.$langs->trans('NotePublic').'</td>';
print '</tr>'; print '</tr>';
// Ref
print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">'; print '<tr><td valign="top">'.$langs->trans('Ref').'</td><td valign="top">';
print $fac->ref.'</td>'; print $fac->ref.'</td>';
@ -594,7 +595,7 @@ else
else else
{ {
/* /*
* * View card
*/ */
$head = facturefourn_prepare_head($fac); $head = facturefourn_prepare_head($fac);
$titre=$langs->trans('SupplierInvoice'); $titre=$langs->trans('SupplierInvoice');

View File

@ -47,6 +47,8 @@ class FactureFournisseur extends Facture
var $ref; var $ref;
var $ref_supplier; var $ref_supplier;
var $socid; var $socid;
//! 0=Standard invoice, 1=Replacement invoice, 2=Credit note invoice, 3=Deposit invoice, 4=Proformat invoice
var $type;
//! 0=draft, //! 0=draft,
//! 1=validated, //! 1=validated,
//! TODO Ce statut doit etre 2 et non 1 classee payee partiellement (close_code='discount_vat','badcustomer') ou completement (close_code=null), //! 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 = $this->id;
$this->ref_supplier = $obj->facnumber; $this->ref_supplier = $obj->facnumber;
$this->type = 0;
$this->datep = $obj->df; $this->datep = $obj->df;
$this->date = $obj->df; $this->date = $obj->df;
$this->date_echeance = $obj->de; $this->date_echeance = $obj->de;
@ -268,9 +272,9 @@ class FactureFournisseur extends Facture
} }
else else
{ {
dol_syslog('FactureFournisseur::Fetch rowid='.$rowid.' numrows=0 sql='.$sql);
$this->error='Bill with id '.$rowid.' not found 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; return -2;
} }
} }

View File

@ -451,13 +451,14 @@ class Form
* \param htmlname Name of field in form * \param htmlname Name of field in form
* \param filter Optionnal filters criteras * \param filter Optionnal filters criteras
* \param showempty Add an empty field * \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 // 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"; $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"; if (!$user->rights->societe->client->voir && !$user->societe_id) $sql .= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc";
$sql.= " WHERE s.entity = ".$conf->entity; $sql.= " WHERE s.entity = ".$conf->entity;
@ -507,13 +508,22 @@ class Form
while ($i < $num) while ($i < $num)
{ {
$obj = $this->db->fetch_object($resql); $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) if ($selected > 0 && $selected == $obj->rowid)
{ {
print '<option value="'.$obj->rowid.'" selected="true">'.$obj->nom.'</option>'; print '<option value="'.$obj->rowid.'" selected="true">'.$label.'</option>';
} }
else else
{ {
print '<option value="'.$obj->rowid.'">'.$obj->nom.'</option>'; print '<option value="'.$obj->rowid.'">'.$label.'</option>';
} }
$i++; $i++;
} }

View File

@ -97,11 +97,11 @@ function task_prepare_head($object)
*/ */
function select_projects($socid, $selected='', $htmlname='projectid') function select_projects($socid, $selected='', $htmlname='projectid')
{ {
global $db; global $db,$langs;
// On recherche les projets // On recherche les projets
$sql = 'SELECT p.rowid, p.ref, p.title FROM '; $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc';
$sql.= MAIN_DB_PREFIX .'projet as p'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE (fk_soc='".$socid."' or fk_soc IS NULL)"; $sql.= " WHERE (fk_soc='".$socid."' or fk_soc IS NULL)";
$sql.= " ORDER BY p.title ASC"; $sql.= " ORDER BY p.title ASC";
@ -118,13 +118,15 @@ function select_projects($socid, $selected='', $htmlname='projectid')
while ($i < $num) while ($i < $num)
{ {
$obj = $db->fetch_object($resql); $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) if (!empty($selected) && $selected == $obj->rowid)
{ {
print '<option value="'.$obj->rowid.'" selected="true">'.dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12).'</option>'; print '<option value="'.$obj->rowid.'" selected="true">'.$labeltoshow.'</option>';
} }
else else
{ {
print '<option value="'.$obj->rowid.'">'.dol_trunc($obj->ref,12).' - '.dol_trunc($obj->title,12).'</option>'; print '<option value="'.$obj->rowid.'">'.$labeltoshow.'</option>';
} }
$i++; $i++;
} }

View File

@ -166,7 +166,7 @@ if ($_GET["action"] == 'create' && $user->rights->projet->creer)
// Client // Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
//print $_REQUEST["socid"]; //print $_REQUEST["socid"];
print $html->select_societes($_REQUEST["socid"],'socid','',1); print $html->select_societes($_REQUEST["socid"],'socid','',1,1);
print '</td></tr>'; print '</td></tr>';
// Responsable du projet // Responsable du projet
@ -232,7 +232,7 @@ else
// Client // Client
print '<tr><td>'.$langs->trans("Company").'</td><td>'; print '<tr><td>'.$langs->trans("Company").'</td><td>';
print $html->select_societes($projet->societe->id,'socid','',1); print $html->select_societes($projet->societe->id,'socid','',1,1);
print '</td></tr>'; print '</td></tr>';
// Responsable du projet // Responsable du projet

View File

@ -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 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 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 set tms = datec where tms <= 0;
update llx_facture_fourn set tms = datec where tms <= 0; update llx_facture_fourn set tms = datec where tms <= 0;

View File

@ -46,6 +46,7 @@ create table llx_facture_fourn
fk_user_author integer, -- createur de la facture fk_user_author integer, -- createur de la facture
fk_user_valid integer, -- valideur 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<63>e la facture fk_projet integer, -- projet auquel est associ<63>e la facture
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...) fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)