Ajout des logs de retour fournisseur

This commit is contained in:
Rodolphe Quiedeville 2005-01-04 11:06:41 +00:00
parent 97b4e23405
commit 249aa6811d

View File

@ -1,5 +1,5 @@
<?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
* it under the terms of the GNU General Public License as published by
@ -22,120 +22,9 @@
require("./pre.inc.php");
$mesg = '';
if ($_POST["action"] == 'add')
{
$ligne = new LigneTel($db);
$ligne->numero = $_POST["numero"];
$ligne->client = $_POST["client"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->remise = $_POST["remise"];
$ligne->note = $_POST["note"];
if ( $ligne->create($user) )
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_POST["action"] == 'addcontact')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->add_contact($_POST["contact_id"]) )
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
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);
}
}
if ($_GET["action"] == 'active')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->set_statut($user, 3) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'resilier')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->set_statut($user, 4) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_GET["action"] == 'annuleresilier')
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
if ( $ligne->set_statut($user, 3) == 0)
{
Header("Location: fiche.php?id=".$ligne->id);
}
}
if ($_POST["action"] == 'update' && $_POST["cancel"] <> $langs->trans("Cancel"))
{
$ligne = new LigneTel($db);
$ligne->id = $_GET["id"];
$ligne->numero = $_POST["numero"];
$ligne->client = $_POST["client"];
$ligne->client_facture = $_POST["client_facture"];
$ligne->fournisseur = $_POST["fournisseur"];
$ligne->commercial = $_POST["commercial"];
$ligne->remise = $_POST["remise"];
$ligne->note = $_POST["note"];
if ( $ligne->update($user) )
{
$action = '';
$mesg = 'Fiche mise à jour';
}
else
{
$action = 're-edit';
$mesg = 'Fiche non mise à jour !' . "<br>" . $entrepot->mesg_error;
}
}
llxHeader("","","Fiche Ligne");
llxHeader("","","Historique Ligne");
if ($cancel == $langs->trans("Cancel"))
{
@ -145,125 +34,7 @@ if ($cancel == $langs->trans("Cancel"))
* Affichage
*
*/
/*
* Création
*
*/
if ($_GET["action"] == 'create')
{
$ligne = new LigneTel($db);
print "<form action=\"fiche.php\" method=\"post\">\n";
print '<input type="hidden" name="action" value="add">';
print '<input type="hidden" name="type" value="'.$type.'">'."\n";
print_titre("Nouvelle ligne");
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Numéro</td><td><input name="numero" size="12" value=""></td></tr>';
print '<tr><td width="20%">Client</td><td colspan="2">';
print '<select name="client">';
$sql = "SELECT idp, nom FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print '<option value="'.$row[0].'">'.$row[1];
$i++;
}
}
$db->free();
}
print '</select></td></tr>';
print '<tr><td width="20%">Client à facturer</td><td colspan="2">';
print '<select name="client_facture">';
$sql = "SELECT idp, nom FROM ".MAIN_DB_PREFIX."societe WHERE client=1 ORDER BY nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print '<option value="'.$row[0].'">'.$row[1];
$i++;
}
}
$db->free();
}
print '</select></td></tr>';
print '<tr><td width="20%">Fournisseur</td><td colspan="2">';
print '<select name="fournisseur">';
$sql = "SELECT rowid, nom FROM ".MAIN_DB_PREFIX."telephonie_fournisseur ORDER BY nom ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print '<option value="'.$row[0].'">'.$row[1];
$i++;
}
}
$db->free();
}
print '</select></td></tr>';
print '<tr><td width="20%">Commercial</td><td colspan="2">';
print '<select name="commercial">';
$sql = "SELECT rowid, name, firstname FROM ".MAIN_DB_PREFIX."user ORDER BY name ";
if ( $db->query( $sql) )
{
$num = $db->num_rows();
if ( $num > 0 )
{
$i = 0;
while ($i < $num)
{
$row = $db->fetch_row($i);
print '<option value="'.$row[0].'">'.$row[1] . " " . $row[2];
$i++;
}
}
$db->free();
}
print '</select></td></tr>';
print '<tr><td width="20%">Remise</td><td><input name="remise" size="3" maxlength="2" value="">&nbsp;%</td></tr>';
print '<tr><td width="20%" valign="top">Note</td><td>';
print '<textarea name="note" rows="4" cols="50">';
print "</textarea></td></tr>";
print '<tr><td>&nbsp;</td><td><input type="submit" value="Créer"></td></tr>';
print '</table>';
print '</form>';
}
else
{
if ($_GET["id"] or $_GET["numero"])
{
if ($_GET["action"] <> 're-edit')
@ -288,6 +59,10 @@ else
$head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/fiche.php?id=".$ligne->id;
$head[$h][1] = $langs->trans("Ligne");
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/factures.php?id=".$ligne->id;
$head[$h][1] = $langs->trans('Factures');
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/infoc.php?id=".$ligne->id;
$head[$h][1] = $langs->trans('Infos');
@ -302,32 +77,40 @@ else
$head[$h][1] = $langs->trans('Conso');
$h++;
$head[$h][0] = DOL_URL_ROOT."/telephonie/ligne/stat.php?id=".$ligne->id;
$head[$h][1] = $langs->trans('Stats');
$h++;
dolibarr_fiche_head($head, $hselected, 'Ligne : '.$ligne->numero);
print_fiche_titre('Fiche Ligne', $mesg);
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr><td width="20%">Numéro</td><td>'.dolibarr_print_phone($ligne->numero).'</td>';
print '<td>Facturée : '.$ligne->facturable.'</td><td>&nbsp;</td></tr>';
print '<tr><td width="20%">Numéro</td><td colspan="2">'.dolibarr_print_phone($ligne->numero).'</td></tr>';
$client = new Societe($db, $ligne->client_id);
$client->fetch($ligne->client_id);
print '<tr><td width="20%">Client</td><td>'.$client->nom.'</td>';
$client_comm = new Societe($db, $ligne->client_comm_id);
$client_comm->fetch($ligne->client_comm_id);
$client_facture = new Societe($db);
$client_facture->fetch($ligne->client_facture_id);
print '<tr><td width="20%">Client</td><td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/telephonie/client/fiche.php?id='.$client_comm->id.'">';
print $client_comm->nom.'</a></td></tr>';
print '<td width="20%">Client Facturé</td><td>'.$client_facture->nom.'</td></tr>';
print '<tr><td width="20%">Statut</td><td colspan="3">';
print '<tr><td width="20%">Statut actuel</td><td colspan="2">';
print '<img src="./graph'.$ligne->statut.'.png">&nbsp;';
print $ligne->statuts[$ligne->statut];
print '</td></tr>';
/* Contacts */
print '<tr class="liste_titre">';
print '<td>Date</td>';
print '<td>Statut</td>';
print '<td>Rapporteur</td>';
print '</tr>';
/* historique */
$sql = "SELECT ".$db->pdate("l.tms").", l.statut, l.fk_user, u.name, u.firstname, l.comment";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne_statut as l";
@ -353,7 +136,7 @@ else
print '<br />'.$row[5];
}
print '</td><td colspan="2">'.$row[4] . " " . $row[3] . "</td></tr>";
print '</td><td>'.$row[4] . " " . $row[3] . "</td></tr>";
$i++;
}
}
@ -364,44 +147,65 @@ else
print $sql;
}
/* Fin Contacts */
if ($_GET["action"] <> 'edit' && 0)
{
print '<tr><td width="20%">Point de rentabilité</td><td colspan="2">';
print '<img src="./graphrent.php?remise='.$ligne->remise.'">';
print '</td></tr>';
}
print "</table>";
}
}
/*
*
*/
print '<br />';
print_titre("Retours Fournisseurs");
$sql = "SELECT ";
$sql .= " cli,mode,situation,date_mise_service,date_resiliation,motif_resiliation,commentaire,fichier, traite ";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_commande_retour";
$sql .= " WHERE cli = ".$ligne->numero;
$sql .= " ORDER BY rowid DESC " . $db->plimit($conf->liste_limit+1, $offset);
if ($db->query($sql))
{
$num = $db->num_rows();
$i = 0;
print '<table class="border" width="100%" cellspacing="0" cellpadding="4">';
print '<tr class="liste_titre"><td>Mode</td><td>Resultat</td>';
print '<td align="center">Date</td><td>Commentaire</td><td>Fichier</td>';
print "</tr>\n";
$var=True;
while ($i < $num)
{
$obj = $db->fetch_object();
$var=!$var;
print "<tr $bc[$var]>";
print '<td>'.$obj->mode."</td>\n";
print '<td>'.$obj->situation."</td>\n";
print '<td align="center">'.$obj->date_mise_service."</td>\n";
print '<td>'.$obj->commentaire."</td>\n";
print '<td>'.$obj->fichier."</td>\n";
print "</tr>\n";
$i++;
}
print "</table>";
$db->free();
}
else
{
print $db->error() . ' ' . $sql;
}
/*
*
*
*
*/
}
else
{
print "Error";
}
}
/* ************************************************************************** */
/* */
/* Barre d'action */
/* */
/* ************************************************************************** */
$db->close();