[ 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/ -> addpropal.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: addpropal.php,v 1.38 2005/11/11 20:11:57 eldy Exp $
  20   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/comm/addpropal.php,v $
  21   */
  22  
  23  /**
  24          \file       htdocs/comm/addpropal.php
  25          \ingroup    propal
  26          \brief      Page d'ajout d'une proposition commmercial
  27          \version    $Revision: 1.38 $
  28  */
  29  
  30  require ("./pre.inc.php");
  31  include_once (DOL_DOCUMENT_ROOT.'/includes/modules/propale/modules_propale.php');
  32  if (defined("PROPALE_ADDON") && is_readable(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php"))
  33  {
  34      require_once(DOL_DOCUMENT_ROOT ."/includes/modules/propale/".PROPALE_ADDON.".php");
  35  }
  36  
  37  $langs->load("propal");
  38  $langs->load("projects");
  39  $langs->load("companies");
  40  
  41  $user->getrights('propale');
  42  $user->getrights('fichinter');
  43  $user->getrights('commande');
  44  $user->getrights('projet');
  45  
  46  
  47  
  48  llxHeader();
  49  
  50  print_titre($langs->trans("NewProp"));
  51  
  52  $form=new Form($db);
  53  
  54  
  55  /*
  56   *
  57   * Creation d'une nouvelle propale
  58   *
  59   */
  60  if ($_GET["action"] == 'create')
  61  {
  62      $soc = new Societe($db);
  63      $result=$soc->fetch($_GET["socidp"]);
  64      if ($result < 0)
  65      {
  66          dolibarr_print_error($db,$soc->error);
  67          exit;
  68      }
  69  
  70      $obj = PROPALE_ADDON;
  71      $modPropale = new $obj;
  72      $numpr = $modPropale->propale_get_num($soc);
  73      $sql = "SELECT count(*) FROM ".MAIN_DB_PREFIX."propal WHERE ref like '$numpr%'";
  74  
  75      if ( $db->query($sql) )
  76      {
  77          $num = $db->result(0, 0);
  78          $db->free();
  79          if ($num > 0)
  80          {
  81              $numpr .= "." . ($num + 1);
  82          }
  83      }
  84  
  85      print "<form action=\"propal.php?socidp=".$soc->id."\" method=\"post\">";
  86      print "<input type=\"hidden\" name=\"action\" value=\"add\">";
  87  
  88      print '<table class="border" width="100%">';
  89  
  90      print '<tr><td>'.$langs->trans("Ref").'</td><td><input name="ref" value="'.$numpr.'"></td>';
  91  
  92      print '<td valign="top" colspan="2">';
  93      print $langs->trans("Comments").'</td></tr>';
  94  
  95      print '<tr><td>'.$langs->trans("Company").'</td><td><a href="fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
  96      print '<td rowspan="5" colspan="2" valign="top">';
  97      print '<textarea name="note" wrap="soft" cols="40" rows="6"></textarea>';
  98      print '</tr>';
  99  
 100      print "<tr><td>".$langs->trans("Date")."</td><td>";
 101      $form->select_date();
 102      print "</td></tr>";
 103  
 104      print '<tr><td>'.$langs->trans("Author").'</td><td>'.$user->fullname.'</td></tr>';
 105      print '<tr><td>'.$langs->trans("ValidityDuration").'</td><td><input name="duree_validite" size="5" value="15"> '.$langs->trans("days").'</td></tr>';
 106  
 107      /*
 108      * Destinataire de la propale
 109      */
 110      print "<tr><td>".$langs->trans("Contact")."</td><td>\n";
 111      $sql = "SELECT p.idp, p.name, p.firstname, p.poste, p.phone, p.fax, p.email FROM ".MAIN_DB_PREFIX."socpeople as p";
 112      $sql .= " WHERE p.fk_soc = ".$soc->id;
 113  
 114      if ( $db->query($sql) )
 115      {
 116          $i = 0 ;
 117          $numdest = $db->num_rows();
 118  
 119          if ($numdest==0)
 120          {
 121              print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>';
 122              print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->id.'&amp;action=create&amp;backtoreferer=1">'.$langs->trans("AddContact").'</a>';
 123          }
 124          else
 125          {
 126              print "<select name=\"contactidp\">\n";
 127  
 128              while ($i < $numdest)
 129              {
 130                  $contact = $db->fetch_object();
 131                  print '<option value="'.$contact->idp.'"';
 132                  if ($contact->idp == $setcontact)
 133                  {
 134                      print ' selected="true"';
 135                  }
 136                  print '>'.$contact->firstname.' '.$contact->name;
 137                  if ($contact->email) { print ' &lt;'.$contact->email.'&gt;'; }
 138                  print '</option>';
 139                  $i++;
 140              }
 141              print '</select>';
 142          }
 143  
 144          $db->free();
 145      }
 146      else
 147      {
 148          dolibarr_print_error($db);
 149      }
 150  
 151      print '</td></tr>';
 152  
 153      print '<tr>';
 154      if ($conf->projet->enabled)
 155      {
 156          /*
 157           * Projet associ
 158           */
 159          print '<td valign="top">'.$langs->trans("Project").'</td><td>';
 160  
 161          $numprojet=$form->select_projects($soc->id,0,'projetidp');
 162          if ($numprojet==0)
 163          {
 164              print ' &nbsp; <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
 165          }
 166          print '</td>';
 167      }
 168      else {
 169          print '<td colspan="2">&nbsp;</td>';
 170      }
 171  
 172      print '<td>Modèle</td>';
 173      print '<td>';
 174      $model=new ModelePDFPropales();
 175      $liste=$model->liste_modeles($db);
 176      $form->select_array("modelpdf",$liste,$conf->global->PROPALE_ADDON_PDF);
 177      print "</td></tr></table>";
 178  
 179      print '<br>';
 180  
 181      if ($conf->produit->enabled || $conf->service->enabled)
 182      {
 183          $titre=$langs->trans("ProductsAndServices");
 184          $lib=$langs->trans("Product").'/'.$langs->trans("Services");
 185  
 186          print_titre($titre);
 187  
 188          print '<table class="border">';
 189          print '<tr><td>'.$lib.'</td><td>'.$langs->trans("Qty").'</td><td>'.$langs->trans("Discount").'</td></tr>';
 190          for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
 191          {
 192              print '<tr><td>';
 193              $form->select_produits('',"idprod".$i,'',$conf->produit->limit_size);
 194              print '</td>';
 195              print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
 196              print '<td><input type="text" size="3" name="remise'.$i.'" value="'.$soc->remise_client.'"> %</td></tr>';
 197          }
 198  
 199          print "</table>";
 200  
 201          print '<br>';
 202      }
 203  
 204      /*
 205      * Si il n'y a pas de contact pour la societe on ne permet pas la creation de propale
 206      */
 207      if ($numdest > 0)
 208      {
 209          $langs->load("bills");
 210          print '<center>';
 211          print '<input type="submit" class="button" value="'.$langs->trans("CreateDraft").'">';
 212          print '</center>';
 213      }
 214      print "</form>";
 215  }
 216  
 217  $db->close();
 218  llxFooter('$Date: 2005/11/11 20:11:57 $ - $Revision: 1.38 $');
 219  ?>


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