[ 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/societe/notify/ -> fiche.php (source)

   1  <?php
   2  /* Copyright (C) 2003      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: fiche.php,v 1.29 2005/12/02 13:20:06 hregis Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/societe/notify/fiche.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/societe/notify/fiche.php
  25          \ingroup    societe
  26          \brief      Onglet notifications pour une societe
  27          \version    $Revision: 1.29 $
  28  */
  29  
  30  require ("pre.inc.php");
  31  
  32  $langs->load("companies");
  33  
  34  // Sécurité accés client
  35  $socid = $_GET["socid"];
  36  if ($user->societe_id > 0) 
  37  {
  38      $socid = $user->societe_id;
  39  }
  40  
  41  $sortorder=$_GET["sortorder"];
  42  $sortfield=$_GET["sortfield"];
  43  if (! $sortorder) $sortorder="ASC";
  44  if (! $sortfield) $sortfield="c.name";
  45  
  46  
  47  llxHeader();
  48  
  49  /*
  50   * Action ajout notification
  51   */
  52  if ($_POST["action"] == 'add')
  53  {
  54    $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def";
  55    $sql .= " WHERE fk_soc=".$socid." AND fk_contact=".$_POST["contactid"]." AND fk_action=".$_POST["actionid"];
  56    if ($db->query($sql))
  57     {
  58        $sql = "INSERT INTO ".MAIN_DB_PREFIX."notify_def (datec,fk_soc, fk_contact, fk_action)";
  59        $sql .= " VALUES (now(),$socid,".$_POST["contactid"].",".$_POST["actionid"].")";
  60        
  61        if ($db->query($sql))
  62      {
  63        
  64      }
  65        else
  66      {
  67        dolibarr_print_error($db);
  68      }
  69      }
  70    else
  71      {
  72        dolibarr_print_error($db);
  73      }
  74  }
  75  
  76  /*
  77   * Action suppression notification
  78   */
  79  if ($_GET["action"] == 'delete')
  80  {
  81   $sql = "DELETE FROM ".MAIN_DB_PREFIX."notify_def where rowid=".$_GET["actid"].";";
  82   $db->query($sql);
  83      
  84   // if ($db->query($sql))
  85     // {
  86        // TODO ajouter une sécu pour la suppression 
  87      //}
  88  }
  89  
  90  
  91  /*
  92   * Affichage notifications
  93   *
  94   */
  95  $soc = new Societe($db);
  96  $soc->id = $_GET["socid"];
  97  
  98  if ( $soc->fetch($soc->id) )
  99  {
 100      $html = new Form($db);
 101      $langs->load("other");
 102      
 103      $h=0;
 104      
 105      $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$soc->id;
 106      $head[$h][1] = $langs->trans("Company");
 107      $h++;
 108      
 109      if ($soc->client==1)
 110      {
 111          $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id;
 112          $head[$h][1] = $langs->trans("Customer");
 113          $h++;
 114      }
 115      
 116      if ($soc->client==2)
 117      {
 118          $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$soc->id;
 119          $head[$h][1] = $langs->trans("Prospect");
 120          $h++;
 121      }
 122      if ($soc->fournisseur)
 123      {
 124          $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
 125          $head[$h][1] = $langs->trans("Supplier");
 126          $h++;
 127      }
 128      
 129      if ($conf->compta->enabled) {
 130              $langs->load("compta");
 131          $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id;
 132          $head[$h][1] = $langs->trans("Accountancy");
 133          $h++;
 134      }
 135      
 136      $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$soc->id;
 137      $head[$h][1] = $langs->trans("Note");
 138      $h++;
 139      
 140      if ($user->societe_id == 0)
 141      {
 142          $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$soc->id;
 143          $head[$h][1] = $langs->trans("Documents");
 144          $h++;
 145      }
 146      
 147      $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$soc->id;
 148      $head[$h][1] = $langs->trans("Notifications");
 149      $hselected=$h;
 150      $h++;
 151  
 152      $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$soc->id;
 153      $head[$h][1] = $langs->trans("Info");
 154      $h++;
 155      
 156      dolibarr_fiche_head($head, $hselected, $soc->nom);
 157      
 158      /*
 159      *
 160      *
 161      */
 162      
 163      print '<table class="border"width="100%">';
 164      print '<tr><td width="20%">'.$langs->trans("Name").'</td><td colspan="3">'.$soc->nom.'</td></tr>';
 165      print '<tr><td width="30%">'.$langs->trans("NbOfActiveNotifications").'</td>';
 166      print '<td colspan="3">';
 167      $sql = "SELECT COUNT(n.rowid) as nb";
 168      $sql.= " FROM ".MAIN_DB_PREFIX."notify_def as n";
 169      $sql.= " WHERE fk_soc = ".$soc->id;
 170      $resql=$db->query($sql);
 171      if ($resql)
 172      {
 173          $num = $db->num_rows($resql);
 174          $i = 0;
 175          while ($i < $num)
 176          {
 177              $obj = $db->fetch_object($resql);
 178              $nb=$obj->nb;
 179              $i++;
 180          }
 181      }
 182      else {
 183          dolibarr_print_error($db);
 184      }
 185      print $nb;
 186      print '</td></tr>';
 187      print '</table>';
 188      
 189      print '</div>';
 190      
 191      print "\n";
 192      
 193      // Ligne de titres
 194      print '<table width="100%" class="noborder">';
 195      print '<tr class="liste_titre">';
 196      print_liste_field_titre($langs->trans("Contact"),"fiche.php","c.name","","&socid=$socid",'',$sortfield);
 197      print_liste_field_titre($langs->trans("Action"),"fiche.php","a.titre","","&socid=$socid",'',$sortfield);
 198      print '<td>&nbsp;</td>';
 199      print '</tr>';
 200      
 201      // Charge tableau $actions
 202      $sql = "SELECT a.rowid, a.code, a.titre";
 203      $sql.= " FROM ".MAIN_DB_PREFIX."action_def as a";
 204      
 205      $resql=$db->query($sql);
 206      if ($resql)
 207      {
 208          $num = $db->num_rows($resql);
 209          $i = 0;
 210          while ($i < $num)
 211          {
 212              $obj = $db->fetch_object($resql);
 213              $libelle=($langs->trans("Notify_".$obj->code)!="Notify_".$obj->code?$langs->trans("Notify_".$obj->code):$obj->titre);
 214              $actions[$obj->rowid] = $libelle;
 215      
 216              $i++;
 217          }
 218          $db->free($resql);
 219      }
 220      else
 221      {
 222          dolibarr_print_error($db);
 223      }
 224      
 225      $var=false;
 226      print '<form action="fiche.php?socid='.$socid.'" method="post">';
 227      print '<input type="hidden" name="action" value="add">';
 228      print '<tr '.$bc[$var].'><td>';
 229      $html->select_array("contactid",$soc->contact_email_array());
 230      print '</td>';
 231      print '<td>';
 232      $html->select_array("actionid",$actions);
 233      print '</td>';
 234      print '<td align="center"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
 235      print '</tr>';
 236      print '</form>';
 237      
 238      
 239      // Liste
 240      $sql = "SELECT c.name, c.firstname, a.titre,n.rowid";
 241      $sql.= " FROM ".MAIN_DB_PREFIX."socpeople as c, ".MAIN_DB_PREFIX."action_def as a, ".MAIN_DB_PREFIX."notify_def as n";
 242      $sql.= " WHERE n.fk_contact = c.idp AND a.rowid = n.fk_action AND n.fk_soc = ".$soc->id;
 243      
 244      $resql=$db->query($sql);
 245      if ($resql)
 246      {
 247          $num = $db->num_rows($resql);
 248          $i = 0;
 249          while ($i < $num)
 250          {
 251              $var = !$var;
 252  
 253              $obj = $db->fetch_object($resql);
 254      
 255              print '<tr '.$bc[$var].'><td>'.$obj->firstname . " ".$obj->name.'</td>';
 256              print '<td>'.$obj->titre.'</td>';
 257              print'<td align="center"><a href="fiche.php?socid='.$socid.'&action=delete&actid='.$obj->rowid.'">'.img_delete().'</a>';
 258              print '</tr>';
 259              $i++;
 260          }
 261          $db->free($resql);
 262      }
 263      else
 264      {
 265          dolibarr_print_error($db);
 266      }
 267      
 268      print '</table>';
 269  
 270  }
 271  
 272  $db->close();
 273  
 274  llxFooter('$Date: 2005/12/02 13:20:06 $ - $Revision: 1.29 $');
 275  
 276  ?>


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