2002-04-29 20:01:16 +02:00
|
|
|
|
<?PHP
|
2003-05-25 18:23:14 +02:00
|
|
|
|
/* Copyright (C) 2001-2003 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
2002-04-29 20:01:16 +02:00
|
|
|
|
*
|
|
|
|
|
|
* 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
|
|
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
|
*
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
*
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|
|
|
|
|
*
|
2002-12-12 17:11:54 +01:00
|
|
|
|
* $Id$
|
|
|
|
|
|
* $Source$
|
|
|
|
|
|
*
|
2002-04-29 20:01:16 +02:00
|
|
|
|
*/
|
2003-09-11 22:18:51 +02:00
|
|
|
|
require("./pre.inc.php");
|
2002-04-30 12:44:42 +02:00
|
|
|
|
|
2003-08-10 21:12:08 +02:00
|
|
|
|
$user->getrights('propale');
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2003-10-14 13:02:31 +02:00
|
|
|
|
if ($user->societe_id > 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
$socidp = $user->societe_id;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2003-08-10 21:12:08 +02:00
|
|
|
|
llxHeader();
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2002-12-12 17:11:54 +01:00
|
|
|
|
function valeur($sql)
|
|
|
|
|
|
{
|
2002-05-10 14:28:10 +02:00
|
|
|
|
global $db;
|
2002-12-12 17:11:54 +01:00
|
|
|
|
if ( $db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
if ( $db->num_rows() )
|
|
|
|
|
|
{
|
|
|
|
|
|
$valeur = $db->result(0,0);
|
|
|
|
|
|
}
|
|
|
|
|
|
$db->free();
|
2002-05-10 14:28:10 +02:00
|
|
|
|
}
|
|
|
|
|
|
return $valeur;
|
|
|
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
2003-05-25 18:23:14 +02:00
|
|
|
|
if ($action == 'add_bookmark')
|
|
|
|
|
|
{
|
2003-06-28 21:23:30 +02:00
|
|
|
|
$sql = "DELETE FROM llx_bookmark WHERE fk_soc = ".$socidp." AND fk_user=".$user->id;
|
|
|
|
|
|
if (! $db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$sql = "INSERT INTO llx_bookmark (fk_soc, dateb, fk_user) VALUES ($socidp, now(),".$user->id.");";
|
2003-06-28 21:23:30 +02:00
|
|
|
|
if (! $db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2002-05-10 14:28:10 +02:00
|
|
|
|
}
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2003-05-25 18:23:14 +02:00
|
|
|
|
if ($action == 'del_bookmark')
|
|
|
|
|
|
{
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$sql = "DELETE FROM llx_bookmark WHERE rowid=$bid";
|
|
|
|
|
|
$result = $db->query($sql);
|
|
|
|
|
|
}
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
|
|
|
|
|
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print_titre("Espace commercial");
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print '<table border="0" width="100%" cellspacing="0" cellpadding="4">';
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print '<tr><td valign="top" width="30%">';
|
2002-05-09 16:57:48 +02:00
|
|
|
|
|
2003-09-11 22:18:51 +02:00
|
|
|
|
print '<form method="post" action="propal.php">';
|
2003-10-14 17:13:36 +02:00
|
|
|
|
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="2">Rechercher une proposition</td></tr>';
|
2003-09-03 15:50:00 +02:00
|
|
|
|
print "<tr $bc[1]><td>";
|
2003-09-03 16:03:06 +02:00
|
|
|
|
print 'Num. : <input type="text" name="sf_ref"><input type="submit" value="Rechercher" class="flat"></td></tr>';
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print "</table></form>\n";
|
2003-09-03 15:50:00 +02:00
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT p.rowid, p.ref";
|
|
|
|
|
|
$sql .= " FROM llx_propal as p";
|
|
|
|
|
|
$sql .= " WHERE p.fk_statut = 0";
|
|
|
|
|
|
|
|
|
|
|
|
if ( $db->query($sql) )
|
2003-05-25 18:23:14 +02:00
|
|
|
|
{
|
2003-09-03 15:50:00 +02:00
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
if ($num > 0 )
|
|
|
|
|
|
{
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print '<br><table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
2003-09-03 15:50:00 +02:00
|
|
|
|
print "<TR class=\"liste_titre\">";
|
|
|
|
|
|
print "<td colspan=\"2\">Propositions commerciales brouillons</td></tr>";
|
|
|
|
|
|
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object( $i);
|
|
|
|
|
|
$var=!$var;
|
2003-09-11 22:18:51 +02:00
|
|
|
|
print "<tr $bc[$var]><td><a href=\"propal.php?propalid=".$obj->rowid."\">".$obj->ref."</a></td></tr>";
|
2003-09-03 15:50:00 +02:00
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</table><br>";
|
|
|
|
|
|
}
|
2002-04-29 20:01:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
/*
|
|
|
|
|
|
* Commandes <EFBFBD> valider
|
|
|
|
|
|
*/
|
|
|
|
|
|
$sql = "SELECT c.rowid, c.ref, s.nom, s.idp FROM llx_commande as c, llx_societe as s";
|
|
|
|
|
|
$sql .= " WHERE c.fk_soc = s.idp AND c.fk_statut = 0";
|
2003-10-14 13:02:31 +02:00
|
|
|
|
if ($socidp)
|
2003-11-09 16:37:14 +01:00
|
|
|
|
{
|
|
|
|
|
|
$sql .= " AND c.fk_soc = $socidp";
|
2003-10-14 13:02:31 +02:00
|
|
|
|
}
|
2003-09-03 15:50:00 +02:00
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
if ( $db->query($sql) )
|
2003-05-25 18:23:14 +02:00
|
|
|
|
{
|
2003-09-03 15:50:00 +02:00
|
|
|
|
$num = $db->num_rows();
|
2003-11-09 16:37:14 +01:00
|
|
|
|
if ($num)
|
2003-09-03 15:50:00 +02:00
|
|
|
|
{
|
2003-11-09 16:37:14 +01:00
|
|
|
|
$i = 0;
|
|
|
|
|
|
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre">';
|
|
|
|
|
|
print '<td colspan="2">'.translate("Commandes <20> valider").'</td></tr>';
|
2003-09-03 15:50:00 +02:00
|
|
|
|
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$var=!$var;
|
2003-11-09 16:37:14 +01:00
|
|
|
|
$obj = $db->fetch_object($i);
|
|
|
|
|
|
print "<tr $bc[$var]><td width=\"20%\"><a href=\"../commande/fiche.php?id=$obj->rowid\">$obj->ref</a></td>";
|
|
|
|
|
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td></tr>';
|
2003-09-03 15:50:00 +02:00
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</table><br>";
|
|
|
|
|
|
}
|
2002-04-29 20:01:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
*
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
2002-05-10 14:28:10 +02:00
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT s.idp, s.nom,b.rowid as bid";
|
2003-05-25 18:23:14 +02:00
|
|
|
|
$sql .= " FROM llx_societe as s, llx_bookmark as b";
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$sql .= " WHERE b.fk_soc = s.idp AND b.fk_user = ".$user->id;
|
|
|
|
|
|
$sql .= " ORDER BY lower(s.nom) ASC";
|
|
|
|
|
|
|
2003-05-25 18:23:14 +02:00
|
|
|
|
if ( $db->query($sql) )
|
|
|
|
|
|
{
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print "<table border=\"0\" width=\"100%\" cellspacing=\"0\" cellpadding=\"4\">";
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print "<TR class=\"liste_titre\">";
|
|
|
|
|
|
print "<TD colspan=\"2\">Bookmark</td>";
|
|
|
|
|
|
print "</TR>\n";
|
|
|
|
|
|
|
2003-05-25 18:23:14 +02:00
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object( $i);
|
|
|
|
|
|
$var = !$var;
|
|
|
|
|
|
print "<tr $bc[$var]>";
|
2003-09-11 22:18:51 +02:00
|
|
|
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->nom.'</a></td>';
|
2003-08-25 12:38:18 +02:00
|
|
|
|
print '<td align="right"><a href="index.php?action=del_bookmark&bid='.$obj->bid.'">';
|
2003-07-12 10:20:48 +02:00
|
|
|
|
print '<img src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/editdelete.png" border="0"></a></td>';
|
2003-05-25 18:23:14 +02:00
|
|
|
|
print '</tr>';
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print '</table>';
|
2002-04-29 20:01:16 +02:00
|
|
|
|
}
|
|
|
|
|
|
/*
|
2002-12-12 17:11:54 +01:00
|
|
|
|
* Actions commerciales a faire
|
2002-04-29 20:01:16 +02:00
|
|
|
|
*
|
|
|
|
|
|
*
|
2002-05-10 14:28:10 +02:00
|
|
|
|
*/
|
|
|
|
|
|
print '</td><td valign="top" width="70%">';
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
2003-08-03 15:06:29 +02:00
|
|
|
|
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.libelle, a.fk_user_author, s.nom as sname, s.idp";
|
|
|
|
|
|
$sql .= " FROM llx_actioncomm as a, c_actioncomm as c, llx_societe as s";
|
|
|
|
|
|
$sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc AND a.fk_user_action = $user->id";
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$sql .= " ORDER BY a.datea DESC";
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
2002-12-12 17:11:54 +01:00
|
|
|
|
if ( $db->query($sql) )
|
|
|
|
|
|
{
|
2003-11-09 16:37:14 +01:00
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
if ($num > 0)
|
2002-12-12 17:11:54 +01:00
|
|
|
|
{
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print '<TABLE border="0" cellspacing="0" cellpadding="3" width="100%">';
|
|
|
|
|
|
print '<TR class="liste_titre">';
|
|
|
|
|
|
print '<td colspan="4">Actions <20> faire</td>';
|
|
|
|
|
|
print "</TR>\n";
|
2002-12-12 17:11:54 +01:00
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
$i = 0;
|
|
|
|
|
|
while ($i < $num )
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object($i);
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
|
|
|
|
|
|
print "<tr $bc[$var]><td>".strftime("%d %b %Y",$obj->da)."</td>";
|
|
|
|
|
|
print "<td><a href=\"action/fiche.php?id=$obj->id\">$obj->libelle $obj->label</a></td>";
|
|
|
|
|
|
print '<td><a href="fiche.php?socid='.$obj->idp.'">'.$obj->sname.'</a></td>';
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</table><br>";
|
2002-12-12 17:11:54 +01:00
|
|
|
|
}
|
2002-05-10 14:28:10 +02:00
|
|
|
|
$db->free();
|
2002-12-12 17:11:54 +01:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print $db->error();
|
|
|
|
|
|
}
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
$sql = "SELECT s.nom, s.idp, p.rowid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
|
|
|
|
|
|
$sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1";
|
|
|
|
|
|
if ($socidp)
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql .= " AND s.idp = $socidp";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " ORDER BY p.rowid DESC";
|
|
|
|
|
|
$sql .= $db->plimit(5, 0);
|
|
|
|
|
|
|
|
|
|
|
|
if ( $db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
if ($num > 0 )
|
|
|
|
|
|
{
|
|
|
|
|
|
print '<table border="0" cellspacing="0" cellpadding="3" width="100%">';
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="4">Propositions commerciales ouvertes</td></tr>';
|
|
|
|
|
|
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$obj = $db->fetch_object( $i);
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr $bc[$var]><td><a href=\"propal.php?propalid=".$obj->rowid."\">".$obj->ref."</a></td>";
|
|
|
|
|
|
print "<td><a href=\"fiche.php?socid=$obj->idp\">$obj->nom</a></TD>\n";
|
|
|
|
|
|
print "<td align=\"right\">";
|
|
|
|
|
|
print strftime("%d %B %Y",$obj->dp)."</td>\n";
|
|
|
|
|
|
print "<td align=\"right\">".price($obj->price)."</td></tr>\n";
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
print "</table><br>";
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-10-14 11:40:54 +02:00
|
|
|
|
/*
|
|
|
|
|
|
* Derni<EFBFBD>res propales
|
|
|
|
|
|
*
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
$sql = "SELECT s.nom, s.idp, p.rowid as propalid, p.price, p.ref,".$db->pdate("p.datep")." as dp, c.label as statut, c.id as statutid";
|
2003-10-14 13:02:31 +02:00
|
|
|
|
$sql .= " FROM llx_societe as s, llx_propal as p, c_propalst as c WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut > 1";
|
2003-10-14 11:40:54 +02:00
|
|
|
|
if ($socidp)
|
|
|
|
|
|
{
|
|
|
|
|
|
$sql .= " AND s.idp = $socidp";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
$sql .= " ORDER BY p.rowid DESC";
|
|
|
|
|
|
$sql .= $db->plimit(5, 0);
|
|
|
|
|
|
|
|
|
|
|
|
if ( $db->query($sql) )
|
|
|
|
|
|
{
|
|
|
|
|
|
$num = $db->num_rows();
|
|
|
|
|
|
|
|
|
|
|
|
$i = 0;
|
|
|
|
|
|
print '<table class="noborder" width="100%" cellspacing="0" cellpadding="4">';
|
|
|
|
|
|
print '<tr class="liste_titre"><td colspan="6">Derni<6E>res propositions commerciales</td></tr>';
|
|
|
|
|
|
$var=True;
|
|
|
|
|
|
|
|
|
|
|
|
while ($i < $num)
|
|
|
|
|
|
{
|
|
|
|
|
|
$objp = $db->fetch_object( $i);
|
|
|
|
|
|
|
|
|
|
|
|
$var=!$var;
|
|
|
|
|
|
print "<tr $bc[$var]>";
|
|
|
|
|
|
print "<td><a href=\"propal.php?propalid=$objp->propalid\">$objp->ref</a></TD>\n";
|
|
|
|
|
|
print "<td><a href=\"fiche.php?socid=$objp->idp\">$objp->nom</a></TD>\n";
|
|
|
|
|
|
|
|
|
|
|
|
$now = time();
|
|
|
|
|
|
$lim = 3600 * 24 * 15 ;
|
|
|
|
|
|
|
|
|
|
|
|
if ( ($now - $objp->dp) > $lim && $objp->statutid == 1 )
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<td><b> > 15 jours</b></td>";
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
print "<td> </td>";
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "<td align=\"right\">";
|
|
|
|
|
|
print strftime("%d %B %Y",$objp->dp)."</td>\n";
|
|
|
|
|
|
print "<td align=\"right\">".price($objp->price)."</TD>\n";
|
|
|
|
|
|
print "<td align=\"center\">$objp->statut</TD>\n";
|
|
|
|
|
|
print "</tr>\n";
|
|
|
|
|
|
$i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
print "</table>";
|
|
|
|
|
|
$db->free();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
2003-11-09 16:37:14 +01:00
|
|
|
|
print '</td></tr>';
|
2002-05-10 14:28:10 +02:00
|
|
|
|
print '</table>';
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
|
|
|
|
|
$db->close();
|
2002-05-10 14:28:10 +02:00
|
|
|
|
|
|
|
|
|
|
|
2002-04-29 20:01:16 +02:00
|
|
|
|
|
2002-04-30 12:44:42 +02:00
|
|
|
|
llxFooter("<em>Dernière modification $Date$ révision $Revision$</em>");
|
2002-04-29 20:01:16 +02:00
|
|
|
|
?>
|