[ 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/ -> soc.php (source)

   1  <?php
   2  /* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
   3   * Copyright (C) 2003      Brian Fraval         <brian@fraval.org>
   4   * Copyright (C) 2004-2005 Laurent Destailleur  <eldy@users.sourceforge.net>
   5   * Copyright (C) 2005      Eric Seigne          <eric.seigne@ryxeo.com>
   6   * Copyright (C) 2005      Regis Houssin        <regis.houssin@cap-networks.com>
   7   *
   8   * This program is free software; you can redistribute it and/or modify
   9   * it under the terms of the GNU General Public License as published by
  10   * the Free Software Foundation; either version 2 of the License, or
  11   * (at your option) any later version.
  12   *
  13   * This program is distributed in the hope that it will be useful,
  14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16   * GNU General Public License for more details.
  17   *
  18   * You should have received a copy of the GNU General Public License
  19   * along with this program; if not, write to the Free Software
  20   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  21   *
  22   * $Id: soc.php,v 1.136 2005/12/02 19:03:36 hregis Exp $
  23   * $Source: /cvsroot/dolibarr/dolibarr/htdocs/soc.php,v $
  24   */
  25  
  26  /**
  27          \file       htdocs/soc.php
  28          \ingroup    societe
  29          \brief      Onglet societe d'une societe
  30          \version    $Revision: 1.136 $
  31  */
  32  
  33  require ("pre.inc.php");
  34  $user->getrights('societe');
  35  $langs->load("companies");
  36  $langs->load("commercial");
  37   
  38  if (! $user->rights->societe->creer)
  39  {
  40      if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
  41      {
  42          accessforbidden();
  43      }
  44  }
  45  
  46  // Sécurité accés client
  47  if ($user->societe_id > 0) 
  48  {
  49    $_GET["action"] = '';
  50    $_POST["action"] = '';
  51    $_GET["socid"] = $user->societe_id;
  52  }
  53  
  54  $soc = new Societe($db);
  55  
  56  
  57  
  58  /*
  59   * Actions
  60   */
  61  if ($_POST["action"] == 'add' || $_POST["action"] == 'update')
  62  {
  63      $soc->nom                   = $_POST["nom"];
  64      $soc->adresse               = $_POST["adresse"];
  65      $soc->cp                    = $_POST["cp"];
  66      $soc->ville                 = $_POST["ville"];
  67      $soc->pays_id               = $_POST["pays_id"];
  68      $soc->departement_id        = $_POST["departement_id"];
  69      $soc->tel                   = $_POST["tel"];
  70      $soc->fax                   = $_POST["fax"];
  71      $soc->url                   = ereg_replace( "http://", "", $_POST["url"] );
  72      $soc->siren                 = $_POST["siren"];
  73      $soc->siret                 = $_POST["siret"];
  74      $soc->ape                   = $_POST["ape"];
  75      $soc->prefix_comm           = $_POST["prefix_comm"];
  76      $soc->code_client           = $_POST["code_client"];
  77      $soc->code_fournisseur      = $_POST["code_fournisseur"];
  78      $soc->codeclient_modifiable = $_POST["codeclient_modifiable"];
  79      $soc->codefournisseur_modifiable = $_POST["codefournisseur_modifiable"];
  80      $soc->capital               = $_POST["capital"];
  81      $soc->tva_intra_code        = $_POST["tva_intra_code"];
  82      $soc->tva_intra_num         = $_POST["tva_intra_num"];
  83      $soc->tva_intra             = $_POST["tva_intra_code"] . $_POST["tva_intra_num"];
  84      $soc->forme_juridique_code  = $_POST["forme_juridique_code"];
  85      $soc->effectif_id           = $_POST["effectif_id"];
  86      $soc->typent_id             = $_POST["typent_id"];
  87      $soc->client                = $_POST["client"];
  88      $soc->fournisseur           = $_POST["fournisseur"];
  89      
  90      if ($_POST["action"] == 'update')
  91      {
  92          $result = $soc->update($_GET["socid"],$user);
  93          if ($result <= 0)
  94          {
  95              $soc->id = $_GET["socid"];
  96              // doublon sur le prefix comm
  97              $reload = 0;
  98              $mesg = $soc->error;      //"Erreur, le prefix '".$soc->prefix_comm."' existe déjà vous devez en choisir un autre";
  99              $_GET["action"]= "edit";
 100          }
 101          else
 102          {
 103              Header("Location: soc.php?socid=".$_GET["socid"]);
 104              exit;
 105          }
 106      
 107      }
 108      
 109      if ($_POST["action"] == 'add')
 110      {
 111          $result = $soc->create($user);
 112      
 113          if ($result >= 0)
 114          {
 115              Header("Location: soc.php?socid=".$soc->id);
 116              exit;
 117          }
 118          else
 119          {
 120              $_GET["action"]='create';
 121              //dolibarr_print_error($db);
 122          }
 123      }
 124  }
 125  
 126  if ($_POST["action"] == 'confirm_delete' && $_POST["confirm"] == 'yes' && $user->rights->societe->creer)
 127  {
 128    $soc = new Societe($db);
 129    $soc->fetch($_GET["socid"]);
 130    $result = $soc->delete($_GET["socid"]);
 131   
 132    if ($result == 0)
 133      {
 134        llxHeader();
 135        print '<div class="ok">'.$langs->trans("CompanyDeleted",$soc->nom).'</div>';
 136        llxFooter();
 137        exit ;
 138      }
 139    else
 140      {
 141        $reload = 0;
 142        $_GET["action"]='';
 143      }
 144  }
 145  
 146  /**
 147   *
 148   *
 149   */
 150  
 151  llxHeader();
 152  
 153  $form = new Form($db);
 154  $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')';
 155  
 156  
 157  if ($_GET["action"] == 'create' || $_POST["action"] == 'create')
 158  {
 159      if ($user->rights->societe->creer)
 160      {
 161          /*
 162           * Fiche societe en mode création
 163           */
 164          $soc->fournisseur=0;
 165          if ($_GET["type"]=='f') { $soc->fournisseur=1; }
 166          if ($_GET["type"]=='c') { $soc->client=1; }
 167          if ($_GET["type"]=='p') { $soc->client=2; }
 168          if ($_POST["nom"])
 169          {
 170              $soc->nom=$_POST["nom"];
 171              $soc->prefix_comm=$_POST["prefix_comm"];
 172              $soc->client=$_POST["client"];
 173              $soc->code_client=$_POST["code_client"];
 174              $soc->fournisseur=$_POST["fournisseur"];
 175              $soc->code_fournisseur=$_POST["code_fournisseur"];
 176              $soc->adresse=$_POST["adresse"];
 177              $soc->cp=$_POST["cp"];
 178              $soc->ville=$_POST["ville"];
 179              $soc->departement_id=$_POST["departement_id"];
 180              $soc->tel=$_POST["tel"];
 181              $soc->fax=$_POST["fax"];
 182              $soc->url=$_POST["url"];
 183              $soc->capital=$_POST["capital"];
 184              $soc->siren=$_POST["siren"];
 185              $soc->siret=$_POST["siret"];
 186              $soc->ape=$_POST["ape"];
 187              $soc->typent_id=$_POST["typent_id"];
 188              $soc->effectif_id=$_POST["effectif_id"];
 189              $soc->tva_intra_code=$_POST["tva_intra_code"];
 190              $soc->tva_intra_num=$_POST["tva_intra_num"];
 191          }
 192  
 193          // On positionne pays_id, pays_code et libelle du pays choisi
 194          $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
 195          if ($soc->pays_id)
 196          {
 197              $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id;
 198              $resql=$db->query($sql);
 199              if ($resql)
 200              {
 201                  $obj = $db->fetch_object($resql);
 202              }
 203              else
 204              {
 205                  dolibarr_print_error($db);
 206              }
 207              $soc->pays_code=$obj->code;
 208              $soc->pays=$obj->libelle;
 209          }
 210      
 211          print_titre($langs->trans("NewCompany"));
 212          print "<br>\n";
 213      
 214          if ($soc->error)
 215          {
 216              print '<div class="error">';
 217              print nl2br($soc->error);
 218              print '</div>';
 219          }
 220      
 221          print '<form action="soc.php" method="post" name="formsoc">';
 222      
 223          print '<input type="hidden" name="action" value="add">';
 224          print '<input type="hidden" name="codeclient_modifiable" value="1">';
 225          print '<input type="hidden" name="codefournisseur_modifiable" value="1">';
 226      
 227          print '<table class="border" width="100%">';
 228      
 229          print '<tr><td>'.$langs->trans('Name').'</td><td><input type="text" size="30" name="nom" value="'.$soc->nom.'"></td>';
 230          print '<td>'.$langs->trans('Prefix').'</td><td><input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'"></td></tr>';
 231      
 232          // Client / Prospect
 233          print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">';
 234          print '<option value="2"'.($soc->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>';
 235          print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
 236          print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>';
 237          print '</select></td>';
 238          print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
 239          print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
 240          print '</td></tr>';
 241  
 242          // Fournisseur
 243          print '<tr>';
 244          print '<td>'.$langs->trans('Supplier').'</td><td>';
 245          $form->selectyesnonum("fournisseur",$soc->fournisseur);
 246          print '</td>';
 247          print '<td>'.$langs->trans('SupplierCode').'</td><td>';
 248          print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
 249          print '</td></tr>';
 250  
 251          print '<tr><td>'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
 252          print $soc->adresse;
 253          print '</textarea></td></tr>';
 254  
 255          print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
 256          if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
 257          print '>';
 258          if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
 259          print '</td>';
 260          print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
 261  
 262          print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
 263          $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_create()"':'');
 264          print '</td></tr>';
 265  
 266          print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
 267          if ($soc->pays_id)
 268          {
 269              $form->select_departement($soc->departement_id,$soc->pays_code);
 270          }
 271          else
 272          {
 273              print $countrynotdefined;
 274          }
 275          print '</td></tr>';
 276  
 277          print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
 278          print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
 279  
 280          print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
 281  
 282          print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 283  
 284          print '<tr><td>'.($langs->transcountry("ProfId1",$soc->pays_code) != '-'?$langs->transcountry('ProfId1',$soc->pays_code):'').'</td><td>';
 285          if ($soc->pays_id)
 286          {
 287              if ($langs->transcountry("ProfId1",$soc->pays_code) != '-') print '<input type="text" name="siren" size="15" maxlength="9" value="'.$soc->siren.'">';
 288              else print '&nbsp;';
 289          }
 290          else
 291          {
 292              print $countrynotdefined;
 293          }
 294          print '</td>';
 295          print '<td>'.($langs->transcountry("ProfId2",$soc->pays_code) != '-'?$langs->transcountry('ProfId2',$soc->pays_code):'').'</td><td>';
 296          if ($soc->pays_id)
 297          {
 298              if ($langs->transcountry("ProfId2",$soc->pays_code) != '-') print '<input type="text" name="siret" size="15" maxlength="14" value="'.$soc->siret.'">';
 299              else print '&nbsp;';
 300          }
 301          else
 302          {
 303              print $countrynotdefined;
 304          }
 305          print '</td></tr>';
 306          print '<tr><td>'.($langs->transcountry("ProfId3",$soc->pays_code) != '-'?$langs->transcountry('ProfId3',$soc->pays_code):'').'</td><td>';
 307          if ($soc->pays_id)
 308          {
 309              if ($langs->transcountry("ProfId3",$soc->pays_code) != '-') print '<input type="text" name="ape" size="5" maxlength="4" value="'.$soc->ape.'">';
 310              else print '&nbsp;';
 311          }
 312          else
 313          {
 314              print $countrynotdefined;
 315          }
 316          print '</td><td colspan="2">&nbsp;</td></tr>';
 317  
 318          print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
 319          if ($soc->pays_id)
 320          {
 321              $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
 322          }
 323          else
 324          {
 325              print $countrynotdefined;
 326          }
 327          print '</td></tr>';
 328  
 329          print '<tr><td>'.$langs->trans("Type").'</td><td>';
 330          $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id);
 331          print '</td>';
 332          print '<td>'.$langs->trans("Staff").'</td><td>';
 333          $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
 334          print '</td></tr>';
 335  
 336          print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">';
 337  
 338          print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->tva_intra_code.'">';
 339          print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->tva_intra_num.'">';
 340          print '  '.$langs->trans("VATIntraCheckableOnEUSite");
 341          print '</td></tr>';
 342  
 343          print '<tr><td colspan="4" align="center">';
 344          print '<input type="submit" class="button" value="'.$langs->trans('AddCompany').'"></td></tr>'."\n";
 345      
 346          print '</table>'."\n";
 347          print '</form>'."\n";
 348      
 349      }
 350  }
 351  elseif ($_GET["action"] == 'edit' || $_POST["action"] == 'edit')
 352  {
 353      /*
 354       * Fiche societe en mode edition
 355       */
 356  
 357      print_titre($langs->trans("EditCompany"));
 358  
 359      if ($_GET["socid"])
 360      {
 361          if ($reload || ! $_POST["nom"])
 362          {
 363              $soc = new Societe($db);
 364              $soc->id = $_GET["socid"];
 365              $soc->fetch($_GET["socid"]);
 366          }
 367          else
 368          {
 369              $soc->id=$_POST["socid"];
 370              $soc->nom=$_POST["nom"];
 371              $soc->prefix_comm=$_POST["prefix_comm"];
 372              $soc->client=$_POST["client"];
 373              $soc->code_client=$_POST["code_client"];
 374              $soc->fournisseur=$_POST["fournisseur"];
 375              $soc->code_fournisseur=$_POST["code_fournisseur"];
 376              $soc->adresse=$_POST["adresse"];
 377              $soc->zip=$_POST["zip"];
 378              $soc->ville=$_POST["ville"];
 379              $soc->pays_id=$_POST["pays_id"]?$_POST["pays_id"]:$conf->global->MAIN_INFO_SOCIETE_PAYS;
 380              $soc->departement_id=$_POST["departement_id"];
 381              $soc->tel=$_POST["tel"];
 382              $soc->fax=$_POST["fax"];
 383              $soc->url=$_POST["url"];
 384              $soc->capital=$_POST["capital"];
 385              $soc->siren=$_POST["siren"];
 386              $soc->siret=$_POST["siret"];
 387              $soc->ape=$_POST["ape"];
 388              $soc->typent_id=$_POST["typent_id"];
 389              $soc->effectif_id=$_POST["effectif_id"];
 390              $soc->tva_intra_code=$_POST["tva_intra_code"];
 391              $soc->tva_intra_num=$_POST["tva_intra_num"];
 392  
 393              // On positionne pays_id, pays_code et libelle du pays choisi
 394              if ($soc->pays_id)
 395              {
 396                  $sql = "SELECT code, libelle from ".MAIN_DB_PREFIX."c_pays where rowid = ".$soc->pays_id;
 397                  $resql=$db->query($sql);
 398                  if ($resql)
 399                  {
 400                      $obj = $db->fetch_object($resql);
 401                  }
 402                  else
 403                  {
 404                      dolibarr_print_error($db);
 405                  }
 406                  $soc->pays_code=$obj->code;
 407                  $soc->pays=$langs->trans("Country".$obj->code)?$langs->trans("Country".$obj->code):$obj->libelle;
 408              }
 409          }
 410  
 411          if ($soc->error)
 412          {
 413              print '<div class="error">';
 414              print $soc->error;
 415              print '</div>';
 416          }
 417  
 418          print '<form action="soc.php?socid='.$soc->id.'" method="post" name="formsoc">';
 419          print '<input type="hidden" name="action" value="update">';
 420          print '<input type="hidden" name="socid" value="'.$soc->id.'">';
 421          print '<input type="hidden" name="codeclient_modifiable" value="'.$soc->codeclient_modifiable.'">';
 422          print '<input type="hidden" name="codefournisseur_modifiable" value="'.$soc->codefournisseur_modifiable.'">';
 423  
 424          print '<table class="border" width="100%">';
 425  
 426          print '<tr><td>'.$langs->trans('Name').'</td><td colspan="3"><input type="text" size="40" name="nom" value="'.$soc->nom.'"></td></tr>';
 427  
 428          print '<td>'.$langs->trans("Prefix").'</td><td colspan="3">';
 429          print '<input type="text" size="5" name="prefix_comm" value="'.$soc->prefix_comm.'">';
 430          print '</td>';
 431  
 432          // Client / Prospect
 433          print '<tr><td width="25%">'.$langs->trans('ProspectCustomer').'</td><td width="25%"><select class="flat" name="client">';
 434          print '<option value="2"'.($soc->client==2?' selected="true"':'').'>'.$langs->trans('Prospect').'</option>';
 435          print '<option value="1"'.($soc->client==1?' selected="true"':'').'>'.$langs->trans('Customer').'</option>';
 436          print '<option value="0"'.($soc->client==0?' selected="true"':'').'>Ni client, ni prospect</option>';
 437          print '</select></td>';
 438          print '<td width="25%">'.$langs->trans('CustomerCode').'</td><td width="25%">';
 439          if ($soc->codeclient_modifiable == 1)
 440          {
 441              print '<input type="text" name="code_client" size="16" value="'.$soc->code_client.'" maxlength="15">';
 442          }
 443          else
 444          {
 445              print $soc->code_client;
 446          }
 447          print '</td></tr>';
 448  
 449          // Fournisseur
 450          print '<tr>';
 451          print '<td>'.$langs->trans('Supplier').'</td><td>';
 452          $form->selectyesnonum("fournisseur",$soc->fournisseur);
 453          print '</td>';
 454          print '<td>'.$langs->trans('SupplierCode').'</td><td>';
 455          if ($soc->codefournisseur_modifiable == 1)
 456          {
 457              print '<input type="text" name="code_fournisseur" size="16" value="'.$soc->code_fournisseur.'" maxlength="15">';
 458          }
 459          else
 460          {
 461              print $soc->code_fournisseur;
 462          }
 463          print '</td></tr>';
 464  
 465          print '<tr><td valign="top">'.$langs->trans('Address').'</td><td colspan="3"><textarea name="adresse" cols="40" rows="3" wrap="soft">';
 466          print $soc->adresse;
 467          print '</textarea></td></tr>';
 468  
 469          print '<tr><td>'.$langs->trans('Zip').'</td><td><input size="6" type="text" name="cp" value="'.$soc->cp.'"';
 470          if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' onChange="autofilltownfromzip_PopupPostalCode(cp.value,ville)"';
 471          print '>';
 472          if ($conf->use_javascript && $conf->global->MAIN_AUTO_FILLTOWNFROMZIP) print ' <input class="button" type="button" name="searchpostalcode" value="'.$langs->trans('FillTownFromZip').'" onclick="autofilltownfromzip_PopupPostalCode(cp.value,ville)">';
 473          print '</td>';
 474  
 475          print '<td>'.$langs->trans('Town').'</td><td><input type="text" name="ville" value="'.$soc->ville.'"></td></tr>';
 476  
 477          print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
 478          $form->select_pays($soc->pays_id,'pays_id',$conf->use_javascript?' onChange="autofilltownfromzip_save_refresh_edit()"':'');
 479          print '</td></tr>';
 480  
 481          print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">';
 482          $form->select_departement($soc->departement_id,$soc->pays_code);
 483          print '</td></tr>';
 484  
 485          print '<tr><td>'.$langs->trans('Phone').'</td><td><input type="text" name="tel" value="'.$soc->tel.'"></td>';
 486          print '<td>'.$langs->trans('Fax').'</td><td><input type="text" name="fax" value="'.$soc->fax.'"></td></tr>';
 487  
 488          print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3"><input type="text" name="url" size="40" value="'.$soc->url.'"></td></tr>';
 489  
 490          print '<tr>';
 491          // IdProf1
 492          $idprof=$langs->transcountry('ProfId1',$soc->pays_code);
 493          if ($idprof!='-')
 494          {
 495              print '<td>'.$idprof.'</td><td>';
 496              $form->id_prof(1,$soc,'siren',$soc->siren);
 497              print '</td>';
 498          }
 499          else print '<td>&nbsp;</td><td>&nbsp;</td>';
 500          // IdProf2
 501          $idprof=$langs->transcountry('ProfId2',$soc->pays_code);
 502          if ($idprof!='-')
 503          {
 504              print '<td>'.$idprof.'</td><td>';
 505              $form->id_prof(2,$soc,'siret',$soc->siret);
 506              print '</td>';
 507          }
 508          else print '<td>&nbsp;</td><td>&nbsp;</td>';
 509          print '</tr>';
 510          print '<tr>';
 511          // IdProf3
 512          $idprof=$langs->transcountry('ProfId3',$soc->pays_code);
 513          if ($idprof!='-')
 514          {
 515              print '<td>'.$idprof.'</td><td>';
 516              $form->id_prof(3,$soc,'ape',$soc->ape);
 517              print '</td>';
 518          }
 519          else print '<td>&nbsp;</td><td>&nbsp;</td>';
 520          // IdProf4
 521          //        $idprof=$langs->transcountry('ProfId4',$soc->pays_code);
 522          $idprof='-';    // L'identifiant 4 n'est pas encore géré
 523          if ($idprof!='-')
 524          {
 525              print '<td>'.$idprof.'</td><td>';
 526              $form->id_prof(4,$soc,'rcs',$soc->rcs);
 527              print '</td>';
 528          }
 529          else print '<td>&nbsp;</td><td>&nbsp;</td>';
 530          print '</tr>';
 531  
 532          print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">';
 533          print '<input type="text" name="tva_intra_code" size="3" maxlength="2" value="'.$soc->tva_intra_code.'">';
 534          print '<input type="text" name="tva_intra_num" size="18" maxlength="18" value="'.$soc->tva_intra_num.'">';
 535          print '  '.$langs->trans("VATIntraCheckableOnEUSite");
 536          print '</td></tr>';
 537  
 538          print '<tr><td>'.$langs->trans("Capital").'</td><td colspan="3"><input type="text" name="capital" size="10" value="'.$soc->capital.'"> '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 539  
 540          print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">';
 541          $form->select_forme_juridique($soc->forme_juridique_code,$soc->pays_code);
 542          print '</td></tr>';
 543  
 544          print '<tr><td>'.$langs->trans("Type").'</td><td>';
 545          $form->select_array("typent_id",$soc->typent_array(), $soc->typent_id);
 546          print '</td>';
 547          print '<td>'.$langs->trans("Staff").'</td><td>';
 548          $form->select_array("effectif_id",$soc->effectif_array(), $soc->effectif_id);
 549          print '</td></tr>';
 550  
 551          print '<tr><td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td></tr>';
 552  
 553          print '</table>';
 554          print '</form>';
 555      }
 556  }
 557  else
 558  {
 559      /*
 560       * Fiche société en mode visu
 561       */
 562      $soc = new Societe($db);
 563      $soc->id = $_GET["socid"];
 564      $result=$soc->fetch($_GET["socid"]);
 565      if ($result < 0)
 566      {
 567          dolibarr_print_error($db,$soc->error);
 568          exit;
 569      }
 570  
 571      $h=0;
 572      
 573      $head[$h][0] = DOL_URL_ROOT.'/soc.php?socid='.$soc->id;
 574      $head[$h][1] = $langs->trans("Company");
 575      $hselected=$h;
 576      $h++;
 577  
 578      if ($soc->client==1)
 579      {
 580          $head[$h][0] = DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id;
 581          $head[$h][1] = $langs->trans("Customer");
 582          $h++;
 583      }
 584      if ($soc->client==2)
 585      {
 586          $head[$h][0] = DOL_URL_ROOT.'/comm/prospect/fiche.php?id='.$soc->id;
 587          $head[$h][1] = $langs->trans("Prospect");
 588          $h++;
 589      }
 590      if ($soc->fournisseur)
 591      {
 592          $head[$h][0] = DOL_URL_ROOT.'/fourn/fiche.php?socid='.$soc->id;
 593          $head[$h][1] = $langs->trans("Supplier");;
 594          $h++;
 595      }
 596  
 597      if ($conf->compta->enabled) {
 598          $langs->load("compta");
 599          $head[$h][0] = DOL_URL_ROOT.'/compta/fiche.php?socid='.$soc->id;
 600          $head[$h][1] = $langs->trans("Accountancy");
 601          $h++;
 602      }
 603  
 604      $head[$h][0] = DOL_URL_ROOT.'/socnote.php?socid='.$soc->id;
 605      $head[$h][1] = $langs->trans("Note");
 606      $h++;
 607  
 608      if ($user->societe_id == 0)
 609      {
 610          $head[$h][0] = DOL_URL_ROOT.'/docsoc.php?socid='.$soc->id;
 611          $head[$h][1] = $langs->trans("Documents");
 612          $h++;
 613      }
 614  
 615      $head[$h][0] = DOL_URL_ROOT.'/societe/notify/fiche.php?socid='.$soc->id;
 616      $head[$h][1] = $langs->trans("Notifications");
 617      $h++;
 618  
 619      $head[$h][0] = DOL_URL_ROOT.'/societe/info.php?socid='.$soc->id;
 620      $head[$h][1] = $langs->trans("Info");
 621      $h++;
 622  
 623      dolibarr_fiche_head($head, $hselected, $soc->nom);
 624  
 625  
 626      // Confirmation de la suppression de la facture
 627      if ($_GET["action"] == 'delete')
 628      {
 629          $html = new Form($db);
 630          $html->form_confirm("soc.php?socid=".$soc->id,$langs->trans("DeleteACompany"),$langs->trans("ConfirmDeleteCompany"),"confirm_delete");
 631          print "<br />\n";
 632      }
 633  
 634  
 635      if ($soc->error)
 636      {
 637          print '<div class="error">';
 638          print $soc->error;
 639          print '</div>';
 640      }
 641  
 642      print '<table class="border" width="100%">';
 643  
 644      print '<tr><td width="20%">'.$langs->trans('Name').'</td><td colspan="3">'.$soc->nom.'</td></tr>';
 645  
 646      print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$soc->prefix_comm.'</td></tr>';
 647  
 648      if ($soc->client) {
 649          print '<tr><td>';
 650          print $langs->trans('CustomerCode').'</td><td colspan="3">';
 651          print $soc->code_client;
 652          if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode");
 653          print '</td></tr>';
 654      }
 655  
 656      if ($soc->fournisseur) {
 657          print '<tr><td>';
 658          print $langs->trans('SupplierCode').'</td><td colspan="3">';
 659          print $soc->code_fournisseur;
 660          if ($soc->check_codefournisseur() <> 0) print ' '.$langs->trans("WrongSupplierCode");
 661          print '</td></tr>';
 662      }
 663      
 664      print "<tr><td valign=\"top\">".$langs->trans('Address')."</td><td colspan=\"3\">".nl2br($soc->adresse)."</td></tr>";
 665  
 666      print '<tr><td width="25%">'.$langs->trans('Zip').'</td><td width="25%">'.$soc->cp."</td>";
 667      print '<td width="25%">'.$langs->trans('Town').'</td><td width="25%">'.$soc->ville."</td></tr>";
 668  
 669      print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">'.$soc->pays.'</td>';
 670      print '</td></tr>';
 671  
 672      print '<tr><td>'.$langs->trans('State').'</td><td colspan="3">'.$soc->departement.'</td>';
 673  
 674      print '<tr><td>'.$langs->trans('Phone').'</td><td>'.dolibarr_print_phone($soc->tel).'</td>';
 675      print '<td>'.$langs->trans('Fax').'</td><td>'.dolibarr_print_phone($soc->fax).'</td></tr>';
 676  
 677      print '<tr><td>'.$langs->trans('Web').'</td><td colspan="3">';
 678      if ($soc->url) { print '<a href="http://'.$soc->url.'" target="_blank">http://'.$soc->url.'</a>'; }
 679      print '</td></tr>';
 680  
 681      // ProfId1
 682      $profid=$langs->transcountry('ProfId1',$soc->pays_code);
 683      if ($profid!='-')
 684      {
 685          print '<tr><td>'.$profid.'</td><td>';
 686          print $soc->siren;
 687          if ($soc->siren)
 688          {
 689              if ($soc->id_prof_check(1,$soc) > 0) print ' &nbsp; '.$soc->id_prof_url(1,$soc);
 690              else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
 691          }
 692          print '</td>';
 693      }
 694      else print '<tr><td>&nbsp;</td><td>&nbsp;</td>';
 695      // ProfId2
 696      $profid=$langs->transcountry('ProfId2',$soc->pays_code);
 697      if ($profid!='-')
 698      {
 699          print '<td>'.$profid.'</td><td>';
 700          print $soc->siret;
 701          if ($soc->siret)
 702          {
 703              if ($soc->id_prof_check(2,$soc) > 0) print ' &nbsp; '.$soc->id_prof_url(2,$soc);
 704              else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
 705          }
 706          print '</td></tr>';
 707      }
 708      else print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
 709  
 710      // ProfId3
 711      $profid=$langs->transcountry('ProfId3',$soc->pays_code);
 712      if ($profid!='-')
 713      {
 714          print '<tr><td>'.$profid.'</td><td>';
 715          print $soc->ape;
 716          if ($soc->ape)
 717          {
 718              if ($soc->id_prof_check(3,$soc) > 0) print ' &nbsp; '.$soc->id_prof_url(3,$soc);
 719              else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
 720          }
 721          print '</td>';
 722      }
 723      else print '<tr><td>&nbsp;</td><td>&nbsp;</td>';
 724      // ProfId4
 725      //    $profid=$langs->transcountry('ProfId4',$soc->pays_code);
 726      $profid='-';    // L'identifiant 4 n'est pas encore géré
 727      if ($profid!='-')
 728      {
 729          print '<td>'.$profid.'</td><td>';
 730          print $soc->rcs;
 731          if ($soc->rcs)
 732          {
 733              if ($soc->id_prof_check(4,$soc) > 0) print ' &nbsp; '.$soc->id_prof_url(4,$soc);
 734              else print ' <font class="error">('.$langs->trans("ErrorWrongValue").')</font>';
 735          }
 736          print '</td></tr>';
 737      }
 738      else print '<td>&nbsp;</td><td>&nbsp;</td></tr>';
 739  
 740      // TVA
 741      print '<tr><td nowrap>'.$langs->trans('VATIntraShort').'</td><td colspan="3">';
 742      print $soc->tva_intra;
 743      print '</td></tr>';
 744  
 745      print '<tr><td>'.$langs->trans('Capital').'</td><td colspan="3">'.$soc->capital.' '.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
 746  
 747      // Statut juridique
 748      print '<tr><td>'.$langs->trans('JuridicalStatus').'</td><td colspan="3">'.$soc->forme_juridique.'</td></tr>';
 749  
 750      // Type + Staff
 751      $arr = $soc->typent_array($soc->typent_id);
 752      $soc->typent= $arr[$soc->typent_id];
 753      print '<tr><td>'.$langs->trans("Type").'</td><td>'.$soc->typent.'</td><td>'.$langs->trans("Staff").'</td><td>'.$soc->effectif.'</td></tr>';
 754  
 755      // RIB
 756      print '<tr><td>';
 757      print '<table width="100%" class="nobordernopadding"><tr><td>';
 758      print $langs->trans('RIB');
 759      print '<td><td align="right">';
 760      if ($user->rights->societe->creer)
 761          print '<a href="'.DOL_URL_ROOT.'/societe/rib.php?socid='.$soc->id.'">'.img_edit().'</a>';
 762      else
 763          print '&nbsp;';
 764      print '</td></tr></table>';
 765      print '</td>';
 766      print '<td colspan="3">';
 767      print $soc->display_rib();
 768      print '</td></tr>';
 769  
 770      // Maison mère
 771      print '<tr><td>';
 772      print '<table width="100%" class="nobordernopadding"><tr><td>';
 773      print $langs->trans('ParentCompany');
 774      print '<td><td align="right">';
 775      if ($user->rights->societe->creer)
 776          print '<a href="'.DOL_URL_ROOT.'/societe/lien.php?socid='.$soc->id.'">'.img_edit() .'</a>';
 777      else
 778          print '&nbsp;';
 779      print '</td></tr></table>';
 780      print '</td>';
 781      print '<td colspan="3">';
 782      if ($soc->parent)
 783      {
 784          $socm = new Societe($db);
 785          $socm->fetch($soc->parent);
 786          print '<a href="'.DOL_URL_ROOT.'/soc.php?socid='.$socm->idp.'">'.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.'</a>'.($socm->code_client?"(".$socm->code_client.")":"").' - '.$socm->ville;
 787      }
 788      else {
 789          print $langs->trans("NoParentCompany");
 790      }
 791      print '</td></tr>';
 792  
 793      // Commerciaux
 794      print '<tr><td>';
 795      print '<table width="100%" class="nobordernopadding"><tr><td>';
 796      print $langs->trans('SalesRepresentatives');
 797      print '<td><td align="right">';
 798      if ($user->rights->societe->creer)
 799          print '<a href="'.DOL_URL_ROOT.'/societe/commerciaux.php?socid='.$soc->id.'">'.img_edit().'</a>';
 800      else
 801          print '&nbsp;';
 802      print '</td></tr></table>';
 803      print '</td>';
 804      print '<td colspan="3">';
 805  
 806      $sql = "SELECT count(sc.rowid) as nb";
 807      $sql.= " FROM ".MAIN_DB_PREFIX."societe_commerciaux as sc";
 808      $sql.= " WHERE sc.fk_soc =".$soc->id;
 809  
 810      $resql = $db->query($sql);
 811      if ($resql)
 812      {
 813          $num = $db->num_rows($resql);
 814          $obj = $db->fetch_object($resql);
 815          print $obj->nb?($obj->nb):$langs->trans("NoSalesRepresentativeAffected");
 816      }
 817      else {
 818          dolibarr_print_error($db);
 819      }
 820      print '</td></tr>';
 821  
 822  
 823      print '</table>';
 824      print "</div>\n";
 825      /*
 826      *
 827      */
 828      if ($_GET["action"] == '')
 829      {
 830          print '<div class="tabsAction">';
 831  
 832          if ($user->rights->societe->creer)
 833          {
 834              print '<a class="butAction" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->id.'&amp;action=edit">'.$langs->trans("Edit").'</a>';
 835          }
 836          
 837          if ($conf->projet->enabled && $user->rights->projet->creer)
 838          {
 839              $langs->load("projects");
 840              print '<a class="butAction" href="'.DOL_URL_ROOT.'/projet/fiche.php?socidp='.$soc->id.'&action=create">'.$langs->trans("AddProject").'</a>';
 841          }
 842  
 843          if ($user->rights->societe->contact->creer)
 844          {
 845              print '<a class="butAction" href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$soc->id.'&amp;action=create">'.$langs->trans("AddContact").'</a>';
 846          }
 847          
 848          if ($user->rights->societe->supprimer)
 849          {
 850              print '<a class="butActionDelete" href="'.DOL_URL_ROOT.'/soc.php?socid='.$soc->id.'&amp;action=delete">'.$langs->trans("Delete").'</a>';
 851          }
 852  
 853          print '</div>';
 854      }
 855      
 856  }
 857  
 858  $db->close();
 859  
 860  
 861  llxFooter('$Date: 2005/12/02 19:03:36 $ - $Revision: 1.136 $');
 862  ?>
 863  


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