Correction du champ info "contact facturation" pour récupérer les données dans la bonne table.
This commit is contained in:
parent
c4984ac65f
commit
368eaa8d37
@ -58,6 +58,11 @@ class Contact
|
|||||||
var $email;
|
var $email;
|
||||||
var $birthday;
|
var $birthday;
|
||||||
|
|
||||||
|
var $ref_facturation; // Nb de reference facture pour lequel il est contact
|
||||||
|
var $ref_contrat; // Nb de reference contrat pour lequel il est contact
|
||||||
|
var $ref_commande; // Nb de reference commande pour lequel il est contact
|
||||||
|
var $ref_propal; // Nb de reference propal pour lequel il est contact
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructeur de l'objet contact
|
* \brief Constructeur de l'objet contact
|
||||||
* \param DB Habler d'accès base
|
* \param DB Habler d'accès base
|
||||||
@ -428,13 +433,13 @@ class Contact
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Charge l'objet contact
|
* \brief Charge l'objet contact
|
||||||
* \param id id du contact
|
* \param id id du contact
|
||||||
* \param user Utilisateur lié au contact pour une alerte
|
* \param user Utilisateur lié au contact pour une alerte
|
||||||
* \return int 1 si ok, -1 si erreur
|
* \return int 1 si ok, -1 si erreur
|
||||||
*/
|
*/
|
||||||
function fetch($id, $user=0)
|
function fetch($id, $user=0)
|
||||||
{
|
{
|
||||||
$sql = "SELECT c.idp, c.fk_soc, c.civilite civilite_id, c.name, c.firstname,";
|
$sql = "SELECT c.idp, c.fk_soc, c.civilite civilite_id, c.name, c.firstname,";
|
||||||
$sql.= " c.address, c.cp, c.ville,";
|
$sql.= " c.address, c.cp, c.ville,";
|
||||||
@ -494,6 +499,7 @@ class Contact
|
|||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
|
|
||||||
|
// Recherche le user Dolibarr lié à ce contact
|
||||||
$sql = "SELECT u.rowid ";
|
$sql = "SELECT u.rowid ";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
$sql .= " FROM ".MAIN_DB_PREFIX."user as u";
|
||||||
$sql .= " WHERE u.fk_socpeople = ". $id;
|
$sql .= " WHERE u.fk_socpeople = ". $id;
|
||||||
@ -516,32 +522,7 @@ class Contact
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Charge alertes du user
|
||||||
$sql = "SELECT count(*) as nb";
|
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."contact_facture";
|
|
||||||
$sql .= " WHERE fk_contact = ". $id;
|
|
||||||
|
|
||||||
$resql=$this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$obj=$this->db->fetch_object($resql);
|
|
||||||
if ($obj->nb)
|
|
||||||
{
|
|
||||||
$this->facturation = 1;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->facturation = 0;
|
|
||||||
}
|
|
||||||
$this->db->free($resql);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_syslog("Error in Contact::fetch() selectcontactfacture sql=$sql");
|
|
||||||
$this->error="Error in Contact::fetch() selectcontactfacture - ".$this->db->error()." - ".$sql;
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($user)
|
if ($user)
|
||||||
{
|
{
|
||||||
$sql = "SELECT fk_user";
|
$sql = "SELECT fk_user";
|
||||||
@ -578,6 +559,45 @@ class Contact
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* \brief Charge le nombre d'elements auquel est lié ce contact
|
||||||
|
* ref_facturation
|
||||||
|
* ref_contrat
|
||||||
|
* ref_commande
|
||||||
|
* ref_propale
|
||||||
|
* \return int 1 si ok, -1 si erreur
|
||||||
|
*/
|
||||||
|
function load_ref_elements()
|
||||||
|
{
|
||||||
|
// Compte les elements pour lesquels il est contact
|
||||||
|
$sql ="SELECT tc.element, count(ec.rowid) as nb";
|
||||||
|
$sql.=" FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as tc";
|
||||||
|
$sql.=" WHERE ec.fk_c_type_contact = tc.rowid";
|
||||||
|
$sql.=" AND element_id = ". $id;
|
||||||
|
$sql.=" GROUP BY tc.element";
|
||||||
|
|
||||||
|
$resql=$this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj=$this->db->fetch_object($resql);
|
||||||
|
if ($obj->nb)
|
||||||
|
{
|
||||||
|
if ($obj->element=='facture') $this->ref_facturation = $obj->nb;
|
||||||
|
if ($obj->element=='contrat') $this->ref_contrat = $obj->nb;
|
||||||
|
if ($obj->element=='commande') $this->ref_commande = $obj->nb;
|
||||||
|
if ($obj->element=='propal') $this->ref_propal = $obj->nb;
|
||||||
|
}
|
||||||
|
$this->db->free($resql);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_syslog("Error in Contact::fetch() selectcontactfacture sql=$sql");
|
||||||
|
$this->error="Error in Contact::fetch() selectcontactfacture - ".$this->db->error()." - ".$sql;
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
|
* \brief Efface le contact de la base et éventuellement de l'annuaire LDAP
|
||||||
* \param id id du contact a effacer
|
* \param id id du contact a effacer
|
||||||
|
|||||||
@ -276,10 +276,6 @@ if ($_GET["action"] == 'create')
|
|||||||
|
|
||||||
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="note"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.$contact->note.'</textarea></td></tr>';
|
print '<tr><td valign="top">'.$langs->trans("Note").'</td><td colspan="3" valign="note"><textarea name="note" cols="70" rows="'.ROWS_3.'">'.$contact->note.'</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("BillingContact").'</td><td colspan="3">';
|
|
||||||
print $form->selectyesno("facturation",$contact->facturation);
|
|
||||||
print '</td></tr>';
|
|
||||||
|
|
||||||
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td></tr>';
|
||||||
print "</table><br>";
|
print "</table><br>";
|
||||||
|
|
||||||
@ -365,9 +361,21 @@ elseif ($_GET["action"] == 'edit' && $_GET["id"])
|
|||||||
print $contact->note;
|
print $contact->note;
|
||||||
print '</textarea></td></tr>';
|
print '</textarea></td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("BillingContact").'</td><td colspan="3">';
|
$contact->load_ref_elements();
|
||||||
print $form->selectyesno("facturation",$contact->facturation);
|
|
||||||
print '</td></tr>';
|
if ($conf->facture->enabled)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
|
||||||
|
print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf->contrat->enabled)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
|
||||||
|
print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
||||||
if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
|
if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
|
||||||
@ -454,9 +462,21 @@ elseif ($_GET["id"])
|
|||||||
print nl2br($contact->note);
|
print nl2br($contact->note);
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("BillingContact").'</td><td colspan="3">';
|
$contact->load_ref_elements();
|
||||||
print yn($contact->facturation);
|
|
||||||
print '</td></tr>';
|
if ($conf->facture->enabled)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("ContactForInvoices").'</td><td colspan="3">';
|
||||||
|
print $contact->ref_facturation?$contact->ref_facturation:$langs->trans("NoContactForAnyInvoice");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($conf->contrat->enabled)
|
||||||
|
{
|
||||||
|
print '<tr><td>'.$langs->trans("ContactForContracts").'</td><td colspan="3">';
|
||||||
|
print $contact->ref_contrat?$contact->ref_contrat:$langs->trans("NoContactForAnyContract");
|
||||||
|
print '</td></tr>';
|
||||||
|
}
|
||||||
|
|
||||||
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("DolibarrLogin").'</td><td colspan="3">';
|
||||||
if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
|
if ($contact->user_id) print '<a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$contact->user_id.'">'.$contact->user_login.'</a>';
|
||||||
|
|||||||
@ -85,6 +85,10 @@ ShowCompany=Show company
|
|||||||
ShowContact=Show contact
|
ShowContact=Show contact
|
||||||
ContactsAllShort=All
|
ContactsAllShort=All
|
||||||
ContactType=Contact type
|
ContactType=Contact type
|
||||||
|
ContactForInvoices=Invoices' contact
|
||||||
|
ContactForContracts=Contracts' contact
|
||||||
|
NoContactForAnyInvoice=This contact is not contact for any invoice
|
||||||
|
NoContactForAnyContract=This contact is not contact for any contract
|
||||||
NewContact=New contact
|
NewContact=New contact
|
||||||
LastContacts=Last contacts
|
LastContacts=Last contacts
|
||||||
MyContacts=My contacts
|
MyContacts=My contacts
|
||||||
|
|||||||
@ -85,6 +85,10 @@ ShowCompany=Afficher soci
|
|||||||
ShowContact=Afficher contact
|
ShowContact=Afficher contact
|
||||||
ContactsAllShort=Tous
|
ContactsAllShort=Tous
|
||||||
ContactType=Type de contact
|
ContactType=Type de contact
|
||||||
|
ContactForInvoices=Contact de factures
|
||||||
|
ContactForContracts=Contact de contrats
|
||||||
|
NoContactForAnyInvoice=Ce contact n'est contact d'aucune facture
|
||||||
|
NoContactForAnyContract=Ce contact n'est contact d'aucun contrat
|
||||||
NewContact=Nouveau contact
|
NewContact=Nouveau contact
|
||||||
LastContacts=Derniers contacts
|
LastContacts=Derniers contacts
|
||||||
MyContacts=Mes contacts
|
MyContacts=Mes contacts
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user