Fix: mélange entre result et resql.

This commit is contained in:
Laurent Destailleur 2005-09-04 21:30:05 +00:00
parent 923b66da74
commit bdfc81fd48

View File

@ -18,7 +18,6 @@
* *
* $Id$ * $Id$
* $Source$ * $Source$
*
*/ */
/** /**
@ -72,6 +71,12 @@ if ($socid > 0)
{ {
$societe = new Societe($db, $socid); $societe = new Societe($db, $socid);
$result = $societe->fetch($socid); $result = $societe->fetch($socid);
if ($result < 0)
{
dolibarr_print_error($db);
exit;
}
/* TODO Finir verification PagesJaunes /* TODO Finir verification PagesJaunes
* print '<form action="http://www.pagesjaunes.fr/pj.cgi" method="post" target="_blank">'; * print '<form action="http://www.pagesjaunes.fr/pj.cgi" method="post" target="_blank">';
@ -81,8 +86,6 @@ if ($socid > 0)
* print '</form>'; * print '</form>';
*/ */
if ($result)
{
$h=0; $h=0;
$head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$societe->id; $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$societe->id;
$head[$h][1] = $langs->trans("Company"); $head[$h][1] = $langs->trans("Company");
@ -107,7 +110,8 @@ if ($socid > 0)
$h++; $h++;
} }
if ($conf->compta->enabled) { if ($conf->compta->enabled)
{
$langs->load("compta"); $langs->load("compta");
$head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id; $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$societe->id;
$head[$h][1] = $langs->trans("Accountancy"); $head[$h][1] = $langs->trans("Accountancy");
@ -268,7 +272,9 @@ if ($socid > 0)
print '<td>'.$langs->trans("Fax").'</td><td>'.$langs->trans("EMail").'</td>'; print '<td>'.$langs->trans("Fax").'</td><td>'.$langs->trans("EMail").'</td>';
print '<td>&nbsp;</td>'; print '<td>&nbsp;</td>';
$sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note FROM ".MAIN_DB_PREFIX."socpeople as p WHERE p.fk_soc = $societe->id ORDER by p.datec"; $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email, p.note";
$sql.= " FROM ".MAIN_DB_PREFIX."socpeople as p";
$sql.= " WHERE p.fk_soc = $societe->id ORDER by p.datec";
$result = $db->query($sql); $result = $db->query($sql);
$i = 0 ; $num = $db->num_rows(); $tag = True; $i = 0 ; $num = $db->num_rows(); $tag = True;
while ($i < $num) while ($i < $num)
@ -279,7 +285,8 @@ if ($socid > 0)
print '<td>'; print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?action=create&amp;actionid=5&amp;contactid='.$obj->idp.'&amp;socid='.$societe->id.'">'.$obj->firstname.' '. $obj->name.'</a>&nbsp;'; print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$obj->idp.'">';
print img_object($langs->trans("ShowContact"),"contact").' '.$obj->firstname.' '. $obj->name.'</a>&nbsp;';
if ($obj->note) if ($obj->note)
{ {
@ -316,11 +323,11 @@ if ($socid > 0)
} }
print "</table>"; print "</table>";
print "<p />";
/* /*
* Listes des actions a faire * Listes des actions a faire
*/ */
$var=true;
print '<br>';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td colspan="8">'.$langs->trans("ActionsToDo").'</td></tr>'; print '<tr class="liste_titre"><td colspan="8">'.$langs->trans("ActionsToDo").'</td></tr>';
$sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid, a.note "; $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code as acode, c.libelle, u.code, a.propalrowid, a.fk_user_author, fk_contact, u.rowid, a.note ";
@ -330,15 +337,15 @@ if ($socid > 0)
$sql .= " AND c.id=a.fk_action AND a.percent < 100"; $sql .= " AND c.id=a.fk_action AND a.percent < 100";
$sql .= " ORDER BY a.datea DESC, a.id DESC"; $sql .= " ORDER BY a.datea DESC, a.id DESC";
if ( $db->query($sql) ) $resql=$db->query($sql);
if ($resql)
{ {
$i = 0 ; $num = $db->num_rows($resql);
$i = 0 ; $num = $db->num_rows();
while ($i < $num) while ($i < $num)
{ {
$var = !$var; $var = !$var;
$obj = $db->fetch_object(); $obj = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
@ -421,7 +428,7 @@ if ($socid > 0)
} }
print "</table>"; print "</table>";
$db->free(); $db->free($resql);
} }
else else
{ {
@ -437,14 +444,16 @@ if ($socid > 0)
$sql .= " AND u.rowid = a.fk_user_author"; $sql .= " AND u.rowid = a.fk_user_author";
$sql .= " AND c.id=a.fk_action AND a.percent = 100"; $sql .= " AND c.id=a.fk_action AND a.percent = 100";
$sql .= " ORDER BY a.datea DESC, a.id DESC"; $sql .= " ORDER BY a.datea DESC, a.id DESC";
if ( $db->query($sql) ) $resql=$db->query($sql);
if ($resql)
{ {
$i = 0 ; $i = 0 ;
$num = $db->num_rows(); $num = $db->num_rows($resql);
if ($num) if ($num)
{ {
print '<br>';
print '<table width="100%" class="noborder">'; print '<table width="100%" class="noborder">';
print '<tr class="liste_titre"><td><a href="action/index.php?socid='.$socid.'">'.$langs->trans("ActionsDone").'</a></td></tr>'; print '<tr class="liste_titre"><td><a href="action/index.php?socid='.$socid.'">'.$langs->trans("ActionsDone").'</a></td></tr>';
print '<tr>'; print '<tr>';
@ -458,7 +467,7 @@ if ($socid > 0)
{ {
$var = !$var; $var = !$var;
$obj = $db->fetch_object(); $obj = $db->fetch_object($resql);
print "<tr $bc[$var]>"; print "<tr $bc[$var]>";
if ($oldyear == strftime("%Y",$obj->da) ) if ($oldyear == strftime("%Y",$obj->da) )
@ -535,23 +544,6 @@ if ($socid > 0)
dolibarr_print_error($db); dolibarr_print_error($db);
} }
/*
*
* Notes sur la societe
*
*/
if (strlen(trim($societe->note)))
{
print '<table class="border" width="100%" bgcolor="#e0e0e0">';
print "<tr><td>".nl2br($societe->note)."</td></tr>";
print "</table>";
}
}
else
{
dolibarr_print_error($db);
}
} }
$db->close(); $db->close();