[ 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/ -> remx.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: remx.php,v 1.6 2005/09/07 21:27:33 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/remx.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/comm/remx.php
  25          \ingroup    commercial
  26          \brief      Onglet de définition des avoirs
  27          \version    $Revision: 1.6 $
  28  */
  29  
  30  require_once ("./pre.inc.php");
  31  
  32  $user->getrights('propale');
  33  $user->getrights('commande');
  34  $user->getrights('projet');
  35  
  36  
  37  $langs->load("orders");
  38  $langs->load("bills");
  39  $langs->load("companies");
  40  
  41  
  42  if ($_POST["action"] == 'setremise')
  43  {
  44    $soc = New Societe($db);
  45    $soc->fetch($_GET["id"]);
  46    $soc->set_remise_except($_POST["remise"],$user);
  47  
  48    Header("Location: remx.php?id=".$_GET["id"]);
  49  }
  50  
  51  
  52  llxHeader();
  53  
  54  $_socid = $_GET["id"];
  55  
  56  // Sécurité si un client essaye d'accéder à une autre fiche que la sienne
  57  if ($user->societe_id > 0) 
  58  {
  59    $_socid = $user->societe_id;
  60  }
  61  
  62  
  63  /*********************************************************************************
  64   *
  65   * Mode fiche
  66   *
  67   *
  68   *********************************************************************************/  
  69  if ($_socid > 0)
  70  {
  71    // On recupere les donnees societes par l'objet
  72    $objsoc = new Societe($db);
  73    $objsoc->id=$_socid;
  74    $objsoc->fetch($_socid,$to);
  75    
  76    $dac = strftime("%Y-%m-%d %H:%M", time());
  77    if ($errmesg)
  78      {
  79        print "<b>$errmesg</b><br>";
  80      }
  81    
  82    /*
  83     * Affichage onglets
  84     */
  85    $h = 0;
  86    
  87    $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$objsoc->id;
  88    $head[$h][1] = $langs->trans("Company");
  89    $h++;
  90    
  91    if ($objsoc->client==1)
  92      {
  93        $hselected=$h;
  94        $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$objsoc->id;
  95        $head[$h][1] = $langs->trans("Customer");
  96        $h++;
  97      }
  98    if ($objsoc->client==2)
  99      {
 100        $hselected=$h;
 101        $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$obj->socid;
 102        $head[$h][1] = $langs->trans("Prospect");
 103        $h++;
 104      }
 105    if ($objsoc->fournisseur)
 106      {
 107        $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$objsoc->id;
 108        $head[$h][1] = $langs->trans("Supplier");
 109        $h++;
 110      }
 111    
 112    if ($conf->compta->enabled) {
 113      $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$objsoc->id;
 114      $head[$h][1] = $langs->trans("Accountancy");
 115      $h++;
 116    }
 117  
 118      $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$objsoc->id;
 119      $head[$h][1] = $langs->trans("Note");
 120      $h++;
 121  
 122      if ($user->societe_id == 0)
 123      {
 124          $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$objsoc->id;
 125          $head[$h][1] = $langs->trans("Documents");
 126          $h++;
 127      }
 128  
 129      $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$objsoc->id;
 130      $head[$h][1] = $langs->trans("Notifications");
 131      $h++;
 132      
 133      if ($user->societe_id == 0)
 134        {
 135      $head[$h][0] = DOL_URL_ROOT."/comm/index.php?socidp=$objsoc->id&action=add_bookmark";
 136      $head[$h][1] = img_object($langs->trans("BookmarkThisPage"),'bookmark');
 137      $head[$h][2] = 'image';
 138        }
 139        
 140      dolibarr_fiche_head($head, $hselected, $objsoc->nom);
 141  
 142      /*
 143       *
 144       *
 145       */
 146      print '<form method="POST" action="remx.php?id='.$objsoc->id.'">';
 147      print '<input type="hidden" name="action" value="setremise">';
 148  
 149      print '<table class="border" width="100%">';
 150  
 151      $remise_all=$remise_user=0;
 152      $sql  = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, rc.fk_user";
 153      $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
 154      $sql .= " WHERE rc.fk_soc =". $objsoc->id;
 155      $sql .= " AND fk_facture IS NULL";
 156      $resql=$db->query($sql);
 157      if ($resql)
 158      {
 159          $obj = $db->fetch_object($resql);
 160          $remise_all+=$obj->amount_ht;
 161          if ($obj->fk_user == $user->id) $remise_user+=$obj->amount_ht;
 162      }
 163  
 164      print '<tr><td width="33%">'.$langs->trans("CustomerAbsoluteDiscountAllUsers").'</td>';
 165      print '<td>'.$remise_all.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 166  
 167      print '<tr><td width="33%">'.$langs->trans("CustomerAbsoluteDiscountMy").'</td>';
 168      print '<td>'.$remise_user.'&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 169      print '<tr><td>'.$langs->trans("NewValue").'</td>';
 170      print '<td><input type="text" size="5" name="remise" value="'.$remise_user.'">&nbsp;'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 171      
 172      print '<tr><td align="center" colspan="2">&nbsp;<input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
 173          
 174      print "</table></form>";
 175  
 176      print "</td>\n";    
 177      print "</div>\n";    
 178  
 179      print '<br>';        
 180  
 181      /*
 182       * Liste
 183       */
 184      $sql  = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code, u.rowid as user_id";
 185      $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
 186      $sql .= " , ".MAIN_DB_PREFIX."user as u";
 187      $sql .= " WHERE rc.fk_soc =". $objsoc->id;
 188      $sql .= " AND u.rowid = rc.fk_user AND fk_facture IS NULL";
 189      $sql .= " ORDER BY rc.datec DESC";
 190  
 191      $resql=$db->query($sql);
 192      if ($resql)
 193      {
 194          print_titre($langs->trans("Ristournes restant dues"));
 195          print '<table width="100%" class="noborder">';
 196          print '<tr class="liste_titre"><td width="80">'.$langs->trans("Date").'</td>';
 197          print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td><td>&nbsp;</td><td width="100">'.$langs->trans("Accordée par").'</td></tr>';
 198  
 199          $var = true;
 200          $i = 0 ;
 201          $num = $db->num_rows($resql);
 202          while ($i < $num)
 203          {
 204              $obj = $db->fetch_object($resql);
 205              $var = !$var;
 206              print "<tr $bc[$var]>";
 207              print '<td>'.dolibarr_print_date($obj->dc).'</td>';
 208              print '<td align="right">'.price($obj->amount_ht).'</td>';
 209              print '<td>&nbsp;</td>';
 210              print '<td><a href="'.DOL_URL_ROOT.'/user/fiche.php?id='.$obj->user_id.'">'.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.'</td></tr>';
 211      
 212              $i++;
 213          }
 214          $db->free($resql);
 215          print "</table>";
 216      }
 217      else
 218      {
 219          dolibarr_print_error($db);
 220      }
 221  
 222      print '<br />';
 223  
 224      /*
 225       * Liste ristournes appliquées
 226       */
 227      $sql  = "SELECT rc.amount_ht,".$db->pdate("rc.datec")." as dc, u.code, u.rowid as user_id,";
 228      $sql.= " rc.fk_facture, f.facnumber";
 229      $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise_except as rc";
 230      $sql.= " , ".MAIN_DB_PREFIX."user as u";
 231      $sql.= " , ".MAIN_DB_PREFIX."facture as f";
 232      $sql.= " WHERE rc.fk_soc =". $objsoc->id;
 233      $sql.= " AND fk_facture = f.rowid";
 234      $sql.= " AND u.rowid = rc.fk_user AND fk_facture IS NOT NULL";
 235      $sql.= " ORDER BY rc.datec DESC";
 236  
 237      $resql=$db->query($sql);
 238      if ($resql)
 239      {
 240          print_titre($langs->trans("Ristournes appliquées"));
 241          print '<table class="noborder" width="100%">';
 242          print '<tr class="liste_titre"><td width="80">'.$langs->trans("Date").'</td>';
 243          print '<td width="120" align="right">'.$langs->trans("AmountTTC").'</td><td align="center">'.$langs->trans("Bill").'</td><td width="100">'.$langs->trans("Author").'</td></tr>';
 244  
 245          $var = true;
 246          $i = 0 ;
 247          $num = $db->num_rows($resql);
 248          while ($i < $num )
 249          {
 250              $obj = $db->fetch_object($resql);
 251              $var = !$var;
 252              print "<tr $bc[$var]>";
 253              print '<td>'.dolibarr_print_date($obj->dc).'</td>';
 254              print '<td align="right">'.price($obj->amount_ht).'</td>';
 255              print '<td align="center"><a href="'.DOL_URL_ROOT.'/compta/facture.php?facid='.$obj->fk_facture.'">'.img_object($langs->trans("ShowBill"),'bill').' '.$obj->facnumber.'</a></td>';
 256              print '<td>'.$obj->code.'</td></tr>';
 257      
 258              $i++;
 259          }
 260          $db->free($resql);
 261          print "</table>";
 262      }
 263      else
 264      {
 265          print dolibarr_print_error($db);
 266      }
 267  
 268  }
 269  
 270  $db->close();
 271  
 272  llxFooter('$Date: 2005/09/07 21:27:33 $ - $Revision: 1.6 $');
 273  ?>


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