Gestion du contact facture
This commit is contained in:
parent
d5ab0df63d
commit
bd8ef9fd38
@ -1,5 +1,5 @@
|
|||||||
<?PHP
|
<?PHP
|
||||||
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
/* Copyright (C) 2004-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -84,16 +84,29 @@ if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
|
|||||||
|
|
||||||
if ($_POST["action"] == 'addcontact')
|
if ($_POST["action"] == 'addcontact')
|
||||||
{
|
{
|
||||||
$ligne = new LigneTel($db);
|
$contrat = new TelephonieContrat($db);
|
||||||
$ligne->id = $_GET["id"];
|
$contrat->id = $_GET["id"];
|
||||||
|
|
||||||
if ( $ligne->add_contact($_POST["contact_id"]) )
|
if ( $contrat->add_contact_facture($_POST["contact_id"]) )
|
||||||
{
|
{
|
||||||
Header("Location: fiche.php?id=".$ligne->id);
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_GET["action"] == 'delcontact')
|
||||||
|
{
|
||||||
|
$contrat = new TelephonieContrat($db);
|
||||||
|
$contrat->id = $_GET["id"];
|
||||||
|
|
||||||
|
if ( $contrat->del_contact_facture($_GET["contact_id"]) )
|
||||||
|
{
|
||||||
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'delete')
|
if ($_GET["action"] == 'delete')
|
||||||
{
|
{
|
||||||
$contrat = new TelephonieContrat($db);
|
$contrat = new TelephonieContrat($db);
|
||||||
@ -104,17 +117,6 @@ if ($_GET["action"] == 'delete')
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ($_GET["action"] == 'delcontact')
|
|
||||||
{
|
|
||||||
$ligne = new LigneTel($db);
|
|
||||||
$ligne->id = $_GET["id"];
|
|
||||||
|
|
||||||
if ( $ligne->del_contact($_GET["contact_id"]) )
|
|
||||||
{
|
|
||||||
Header("Location: fiche.php?id=".$ligne->id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
llxHeader("","","Fiche Contrat");
|
llxHeader("","","Fiche Contrat");
|
||||||
|
|
||||||
@ -488,11 +490,13 @@ else
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/* Contacts
|
/* Contacts */
|
||||||
|
print '<tr><td valign="top" width="20%">Contact facture</td>';
|
||||||
|
print '<td valign="top" colspan="2">';
|
||||||
|
|
||||||
$sql = "SELECT c.idp, c.name, c.firstname, c.email ";
|
$sql = "SELECT c.idp, c.name, c.firstname, c.email ";
|
||||||
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
|
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||||
$sql .= ",".MAIN_DB_PREFIX."telephonie_contact_facture as cf";
|
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf";
|
||||||
$sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name ";
|
$sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_contrat = ".$contrat->id." ORDER BY name ";
|
||||||
if ( $db->query( $sql) )
|
if ( $db->query( $sql) )
|
||||||
{
|
{
|
||||||
@ -504,8 +508,7 @@ else
|
|||||||
{
|
{
|
||||||
$row = $db->fetch_row($i);
|
$row = $db->fetch_row($i);
|
||||||
|
|
||||||
print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>';
|
print $row[1] . " " . $row[2] . " <".$row[3]."><br />";
|
||||||
print '<td valign="top" colspan="2">'.$row[1] . " " . $row[2] . " <".$row[3]."></td></tr>";
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -516,8 +519,8 @@ else
|
|||||||
{
|
{
|
||||||
print $sql;
|
print $sql;
|
||||||
}
|
}
|
||||||
|
print '</td></tr>';
|
||||||
Fin Contacts */
|
/* Fin Contacts */
|
||||||
|
|
||||||
print "</table><br />";
|
print "</table><br />";
|
||||||
|
|
||||||
@ -792,16 +795,17 @@ else
|
|||||||
{
|
{
|
||||||
print_fiche_titre('Ajouter un contact', $mesg);
|
print_fiche_titre('Ajouter un contact', $mesg);
|
||||||
|
|
||||||
print "<form action=\"fiche.php?id=$ligne->id\" method=\"post\">\n";
|
print '<form action="fiche.php?id='.$contrat->id.'" method="post">';
|
||||||
print '<input type="hidden" name="action" value="addcontact">';
|
print '<input type="hidden" name="action" value="addcontact">';
|
||||||
|
|
||||||
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
|
||||||
|
|
||||||
|
|
||||||
$sql = "SELECT c.idp, c.name, c.firstname, c.email ";
|
$sql = "SELECT c.idp, c.name, c.firstname, c.email ";
|
||||||
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
|
$sql .= "FROM ".MAIN_DB_PREFIX."socpeople as c";
|
||||||
$sql .= ",".MAIN_DB_PREFIX."telephonie_contact_facture as cf";
|
$sql .= ",".MAIN_DB_PREFIX."telephonie_contrat_contact_facture as cf";
|
||||||
$sql .= " WHERE c.idp = cf.fk_contact AND cf.fk_ligne = ".$ligne->id." ORDER BY name ";
|
$sql .= " WHERE c.idp = cf.fk_contact ";
|
||||||
|
$sql .= " AND cf.fk_contrat = ".$contrat->id." ORDER BY name ";
|
||||||
|
|
||||||
if ( $db->query( $sql) )
|
if ( $db->query( $sql) )
|
||||||
{
|
{
|
||||||
$num = $db->num_rows();
|
$num = $db->num_rows();
|
||||||
@ -815,7 +819,7 @@ else
|
|||||||
print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>';
|
print '<tr><td valign="top" width="20%">Contact facture '.$i.'</td>';
|
||||||
print '<td valign="top">'.$row[1] . " " . $row[2] . " <".$row[3].">";
|
print '<td valign="top">'.$row[1] . " " . $row[2] . " <".$row[3].">";
|
||||||
print '</td><td>';
|
print '</td><td>';
|
||||||
print '<a href="fiche.php?id='.$ligne->id.'&action=delcontact&contact_id='.$row[0].'">';
|
print '<a href="fiche.php?id='.$contrat->id.'&action=delcontact&contact_id='.$row[0].'">';
|
||||||
print img_delete();
|
print img_delete();
|
||||||
print "</a></td></tr>";
|
print "</a></td></tr>";
|
||||||
$i++;
|
$i++;
|
||||||
@ -832,7 +836,11 @@ else
|
|||||||
|
|
||||||
print '<tr><td valign="top" width="20%">Contact</td><td valign="top" colspan="2">';
|
print '<tr><td valign="top" width="20%">Contact</td><td valign="top" colspan="2">';
|
||||||
|
|
||||||
$sql = "SELECT idp, name, firstname, email FROM ".MAIN_DB_PREFIX."socpeople WHERE fk_soc = ".$ligne->client_facture_id." ORDER BY name ";
|
$sql = "SELECT idp, name, firstname, email ";
|
||||||
|
$sql .= " FROM ".MAIN_DB_PREFIX."socpeople ";
|
||||||
|
$sql .= " WHERE fk_soc in (".$contrat->client_facture_id.",".$contrat->client_id.")";
|
||||||
|
$sql .= " ORDER BY name ";
|
||||||
|
|
||||||
if ( $db->query( $sql) )
|
if ( $db->query( $sql) )
|
||||||
{
|
{
|
||||||
print '<select name="contact_id">';
|
print '<select name="contact_id">';
|
||||||
@ -858,7 +866,7 @@ else
|
|||||||
|
|
||||||
print '<p>Contact auquel est envoyé la facture par email</p></td></tr>';
|
print '<p>Contact auquel est envoyé la facture par email</p></td></tr>';
|
||||||
|
|
||||||
print '<tr><td> </td><td>';
|
print '<tr><td colspan="3" align="center">';
|
||||||
if ($num > 0)
|
if ($num > 0)
|
||||||
{
|
{
|
||||||
print '<input type="submit" value="Ajouter">';
|
print '<input type="submit" value="Ajouter">';
|
||||||
|
|||||||
@ -47,7 +47,7 @@ class TelephonieContrat {
|
|||||||
* Creation du contrat
|
* Creation du contrat
|
||||||
* Le commercial qui fait le suivi est par defaut le commercial qui a signe
|
* Le commercial qui fait le suivi est par defaut le commercial qui a signe
|
||||||
*/
|
*/
|
||||||
function create($user)
|
function create($user, $isfacturable='oui', $mode_paiement='pre')
|
||||||
{
|
{
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat";
|
||||||
$sql .= " (ref, fk_soc, fk_client_comm, fk_soc_facture, note";
|
$sql .= " (ref, fk_soc, fk_client_comm, fk_soc_facture, note";
|
||||||
@ -64,6 +64,8 @@ class TelephonieContrat {
|
|||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat";
|
||||||
$sql .= " SET ref='".substr("00000000".$this->id,-8)."'";
|
$sql .= " SET ref='".substr("00000000".$this->id,-8)."'";
|
||||||
|
$sql .= " , isfacturable = '".$isfacturable."'";
|
||||||
|
$sql .= " , mode_paiement = '".$mode_paiement."'";
|
||||||
$sql .= " WHERE rowid=".$this->id;
|
$sql .= " WHERE rowid=".$this->id;
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
|
|
||||||
@ -97,8 +99,7 @@ class TelephonieContrat {
|
|||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_contrat";
|
||||||
$sql .= " SET ";
|
$sql .= " SET ";
|
||||||
$sql .= " fk_client_comm = ".$this->client_comm;
|
$sql .= " fk_soc = ".$this->client ;
|
||||||
$sql .= ", fk_soc = ".$this->client ;
|
|
||||||
$sql .= ", fk_soc_facture = ".$this->client_facture;
|
$sql .= ", fk_soc_facture = ".$this->client_facture;
|
||||||
$sql .= ", fk_commercial_suiv = ".$this->commercial_suiv_id;
|
$sql .= ", fk_commercial_suiv = ".$this->commercial_suiv_id;
|
||||||
$sql .= ", mode_paiement = '".$this->mode_paiement."'";
|
$sql .= ", mode_paiement = '".$this->mode_paiement."'";
|
||||||
@ -118,7 +119,10 @@ class TelephonieContrat {
|
|||||||
{
|
{
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."telephonie_societe_ligne";
|
||||||
$sql .= " SET ";
|
$sql .= " SET ";
|
||||||
$sql .= " mode_paiement = '".$this->mode_paiement."'";
|
$sql .= " fk_soc = ".$this->client ;
|
||||||
|
$sql .= ", fk_soc_facture = ".$this->client_facture;
|
||||||
|
$sql .= ", fk_commercial_suiv = ".$this->commercial_suiv_id;
|
||||||
|
$sql .= ", mode_paiement = '".$this->mode_paiement."'";
|
||||||
$sql .= " WHERE fk_contrat = ".$this->id;
|
$sql .= " WHERE fk_contrat = ".$this->id;
|
||||||
|
|
||||||
|
|
||||||
@ -224,6 +228,34 @@ class TelephonieContrat {
|
|||||||
|
|
||||||
$this->db->query($sql);
|
$this->db->query($sql);
|
||||||
}
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function add_contact_facture($cid)
|
||||||
|
{
|
||||||
|
|
||||||
|
$this->del_contact_facture($cid);
|
||||||
|
|
||||||
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_contrat_contact_facture";
|
||||||
|
$sql .= " (fk_contrat, fk_contact) ";
|
||||||
|
$sql .= " VALUES ($this->id, $cid )";
|
||||||
|
|
||||||
|
$this->db->query($sql);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
function del_contact_facture($cid)
|
||||||
|
{
|
||||||
|
|
||||||
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."telephonie_contrat_contact_facture";
|
||||||
|
$sql .= " WHERE fk_contrat=".$this->id." AND fk_contact=".$cid;
|
||||||
|
|
||||||
|
return $this->db->query($sql);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user