[ Index ]
 

Code source de Dolibarr 2.0.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/htdocs/comm/prospect/ -> index.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   4   *
   5   * This program is free software; you can redistribute it and/or modify
   6   * it under the terms of the GNU General Public License as published by
   7   * the Free Software Foundation; either version 2 of the License, or
   8   * (at your option) any later version.
   9   *
  10   * This program is distributed in the hope that it will be useful,
  11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13   * GNU General Public License for more details.
  14   *
  15   * You should have received a copy of the GNU General Public License
  16   * along with this program; if not, write to the Free Software
  17   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  18   *
  19   * $Id: index.php,v 1.23 2005/08/31 22:21:58 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/prospect/index.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/comm/prospect/index.php
  25          \ingroup    commercial
  26          \brief      Page accueil de la zone prospection
  27          \version    $Revision: 1.23 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  
  32  $langs->load("propal");
  33  
  34  $user->getrights('propale');
  35  
  36  
  37  if ($user->societe_id > 0)
  38  {
  39    $socidp = $user->societe_id;
  40  }
  41  
  42  
  43  llxHeader();
  44  
  45  function valeur($sql) 
  46  {
  47    global $db;
  48    if ( $db->query($sql) ) 
  49      {
  50        if ( $db->num_rows() ) 
  51      {
  52        $valeur = $db->result(0,0);
  53      }
  54        $db->free();
  55      }
  56    return $valeur;
  57  }
  58  
  59  /*
  60   *
  61   */
  62  
  63  print_fiche_titre($langs->trans("ProspectionArea"));
  64  
  65  print '<table border="0" width="100%" class="notopnoleftnoright">';
  66  
  67  print '<tr><td valign="top" width="30%" class="notopnoleft">';
  68  
  69  if ($conf->propal->enabled) 
  70  {
  71    $var=false;
  72    print '<table class="noborder" width="100%">';
  73    print '<form method="post" action="'.DOL_URL_ROOT.'/comm/propal.php">';
  74    print '<tr class="liste_titre"><td colspan="3">'.$langs->trans("SearchAProposal").'</td></tr>';
  75    print '<tr '.$bc[$var].'><td>';
  76    print $langs->trans("Ref").':</td><td><input type="text" class="flat" name="sf_ref" size="18"></td><td rowspan="2"><input type="submit" value="'.$langs->trans("Search").'" class="button"></td></tr>';
  77    print '<tr '.$bc[$var].'><td nowrap>'.$langs->trans("Other").':</td><td><input type="text" class="flat" name="sall" size="18"></td>';
  78    print '</tr>';
  79    print "</form></table><br>\n";
  80  }
  81  
  82  /*
  83   * Prospects par status
  84   *
  85   */  
  86  
  87  $sql = "SELECT count(*) as cc, st.libelle, st.id";
  88  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."c_stcomm as st ";
  89  $sql .= " WHERE s.fk_stcomm = st.id AND s.client=2";
  90  $sql .= " GROUP BY st.id";
  91  $sql .= " ORDER BY st.id";
  92  
  93  $resql=$db->query($sql);
  94  if ($resql)
  95  {
  96    $num = $db->num_rows($resql);
  97    $i = 0;
  98    if ($num > 0 )
  99      {
 100        $var=true;
 101  
 102        print '<table class="noborder" width="100%">';
 103        print '<tr class="liste_titre">';
 104        print '<td colspan="2">'.$langs->trans("ProspectsByStatus").'</td></tr>';
 105        while ($i < $num)
 106      {
 107        $obj = $db->fetch_object($resql);
 108        $var=!$var;
 109        print "<tr $bc[$var]><td><a href=\"prospects.php?page=0&amp;stcomm=".$obj->id."\">";
 110        print img_action($langs->trans("Show"),$obj->id).' ';
 111        print $langs->trans("StatusProspect".$obj->id);
 112        print "</a></td><td>".$obj->cc."</td></tr>";
 113        $i++;
 114      }
 115        print "</table><br>";
 116      }
 117  }
 118  
 119  
 120  /*
 121   * Liste des propal brouillons
 122   */
 123  if ($conf->propal->enabled && $user->rights->propale->lire)
 124  {
 125      $sql = "SELECT p.rowid, p.ref, p.price, s.nom";
 126      $sql .= " FROM ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."societe as s";
 127      $sql .= " WHERE p.fk_statut = 0 and p.fk_soc = s.idp";
 128  
 129      $resql=$db->query($sql);
 130      if ($resql)
 131      {
 132          $var=true;
 133  
 134          $total=0;
 135          $num = $db->num_rows($resql);
 136          $i = 0;
 137          if ($num > 0)
 138          {
 139              print '<table class="noborder"" width="100%">';
 140              print '<tr class="liste_titre">';
 141              print '<td colspan="2">'.$langs->trans("ProposalsDraft").'</td></tr>';
 142  
 143              while ($i < $num)
 144              {
 145                  $obj = $db->fetch_object($resql);
 146                  $var=!$var;
 147                  print '<tr '.$bc[$var].'><td>';
 148                  print '<a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$obj->rowid.'">'.img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'</a>';
 149                  print '</td><td align="right">';
 150                  print price($obj->price);
 151                  print "</td></tr>";
 152                  $i++;
 153                  $total += $obj->price;
 154              }
 155              if ($total>0) {
 156                  $var=!$var;
 157                  print '<tr class="liste_total"><td>'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
 158              }
 159              print "</table><br>";
 160          }
 161          $db->free($resql);
 162      }
 163  }
 164  
 165  /*
 166   * Actions commerciales a faire
 167   *
 168   */
 169  print '</td><td valign="top" width="70%" class="notopnoleftnoright">';
 170  
 171  $sql = "SELECT a.id, ".$db->pdate("a.datea")." as da, c.code, c.libelle, a.fk_user_author, s.nom as sname, s.idp";
 172  $sql .= " FROM ".MAIN_DB_PREFIX."actioncomm as a, ".MAIN_DB_PREFIX."c_actioncomm as c, ".MAIN_DB_PREFIX."societe as s";
 173  $sql .= " WHERE c.id=a.fk_action AND a.percent < 100 AND s.idp = a.fk_soc AND a.fk_user_action = $user->id";
 174  $sql .= " ORDER BY a.datea DESC";
 175  
 176  $resql=$db->query($sql);
 177  if ($resql) 
 178  {
 179    $num = $db->num_rows($resql);
 180    if ($num > 0)
 181      {
 182        $var=true;
 183  
 184        print '<table class="noborder" width="100%">';
 185        print '<tr class="liste_titre">';
 186        print '<td colspan="4">'.$langs->trans("ActionsToDo").'</td>';
 187        print "</tr>\n";
 188        
 189        $i = 0;
 190        while ($i < $num ) 
 191      {
 192        $obj = $db->fetch_object($resql);
 193        $var=!$var;
 194        
 195        print "<tr $bc[$var]><td>".dolibarr_print_date($obj->da)."</td>";
 196  
 197        $transcode=$langs->trans("Action".$obj->code);
 198        $libelle=($transcode!="Action".$obj->code?$transcode:$obj->libelle);
 199        print '<td><a href="'.DOL_URL_ROOT.'/comm/action/fiche.php?id='.$obj->id."\">".img_object($langs->trans("ShowAction"),"task").' '.$libelle.'</a></td>';
 200  
 201        print '<td><a href="'.DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->idp.'">'.img_object($langs->trans("ShowCompany"),"company").' '.$obj->sname.'</a></td>';
 202        $i++;
 203      }
 204        print "</table><br>";
 205      }
 206    $db->free($resql);
 207  } 
 208  else
 209  {
 210    dolibarr_print_error($db);
 211  }
 212  
 213  /*
 214   * Dernières propales ouvertes
 215   *
 216   */
 217  if ($conf->propal->enabled && $user->rights->propale->lire)
 218  {
 219      $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";
 220      $sql .= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c";
 221      $sql .= " WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND p.fk_statut = 1";
 222      if ($socidp) $sql .= " AND s.idp = $socidp";
 223      $sql .= " ORDER BY p.rowid DESC";
 224      $sql .= $db->plimit(5, 0);
 225      
 226      $resql=$db->query($sql);
 227      if ($resql)
 228      {
 229          $total = 0;
 230          $num = $db->num_rows($resql);
 231          $i = 0;
 232          if ($num > 0)
 233          {
 234              $var=true;
 235      
 236              print '<table class="noborder" width="100%">';
 237              print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProposalsOpened").'</td></tr>';
 238      
 239              while ($i < $num)
 240              {
 241                  $obj = $db->fetch_object($resql);
 242                  $var=!$var;
 243                  print "<tr $bc[$var]><td><a href=\"../propal.php?propalid=".$obj->rowid."\">";
 244                  print img_object($langs->trans("ShowPropal"),"propal").' '.$obj->ref.'</a></td>';
 245      
 246                  print "<td><a href=\"fiche.php?id=$obj->idp\">".img_object($langs->trans("ShowCompany"),"company").' '.$obj->nom."</a></td>\n";
 247                  print "<td align=\"right\">";
 248                  print dolibarr_print_date($obj->dp)."</td>\n";
 249                  print "<td align=\"right\">".price($obj->price)."</td></tr>\n";
 250                  $i++;
 251                  $total += $obj->price;
 252              }
 253              if ($total>0) {
 254                  print '<tr class="liste_total"><td colspan="3" align="right">'.$langs->trans("Total")."</td><td align=\"right\">".price($total)."</td></tr>";
 255              }
 256              print "</table><br>";
 257          }
 258      }
 259  }
 260  
 261  /*
 262   * Sociétés à contacter
 263   *
 264   */
 265  $sql = "SELECT s.nom, s.idp";
 266  $sql .= " FROM ".MAIN_DB_PREFIX."societe as s";
 267  $sql .= " WHERE s.fk_stcomm = 1";
 268  $sql .= " ORDER BY s.tms ASC";
 269  $sql .= $db->plimit(15, 0);
 270  
 271  if ( $db->query($sql) )
 272  {
 273    $num = $db->num_rows();
 274    $i = 0;
 275    if ($num > 0 )
 276      {
 277        $var=true;
 278  
 279        print '<table class="noborder" width="100%">';
 280        print '<tr class="liste_titre"><td colspan="4">'.$langs->trans("ProspectToContact").'</td></tr>';
 281        
 282        while ($i < $num)
 283      {
 284        $obj = $db->fetch_object();
 285        $var=!$var;
 286        print "<tr $bc[$var]><td width=\"12%\"><a href=\"".DOL_URL_ROOT."/comm/prospect/fiche.php?id=".$obj->idp."\">";
 287        print img_object($langs->trans("ShowCompany"),"company");
 288        print ' '.$obj->nom.'</a></td></tr>';
 289        $i++;
 290      }
 291        print "</table><br>";
 292      }
 293  }
 294  
 295  
 296  print '</td></tr>';
 297  print '</table>';
 298  
 299  $db->close();
 300   
 301  
 302  llxFooter('$Date: 2005/08/31 22:21:58 $ - $Revision: 1.23 $');
 303  ?>


Généré le : Mon Nov 26 12:29:37 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics