* Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005-2011 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ /** * \file htdocs/societe/lien.php * \ingroup societe * \brief Page of links to other third parties */ require '../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php'; $langs->load("companies"); $langs->load("customers"); $langs->load("suppliers"); $langs->load("banks"); // Security check $socid = GETPOST('socid','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'societe','',''); /* * Actions */ // Positionne companie parente if ($socid && $_GET["select"]) { if ($user->rights->societe->creer) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); $soc->set_parent($_GET["select"]); header("Location: lien.php?socid=".$soc->id); exit; } else { header("Location: lien.php?socid=".$_GET["socid"]); exit; } } // Supprime companie parente if ($socid && $_GET["delsocid"]) { if ($user->rights->societe->creer) { $soc = new Societe($db); $soc->id = $_GET["socid"]; $soc->fetch($_GET["socid"]); $soc->remove_parent($_GET["delsocid"]); header("Location: lien.php?socid=".$soc->id); exit; } else { header("Location: lien.php?socid=".$_GET["socid"]); exit; } } /* * View */ $help_url='EN:Module_Third_Parties|FR:Module_Tiers|ES:Empresas'; llxHeader('',$langs->trans("ThirdParty"),$help_url); $form = new Form($db); $formcompany = new FormCompany($db); if ($socid) { $soc = new Societe($db); $soc->fetch($socid); $head=societe_prepare_head2($soc); dol_fiche_head($head, 'links', $langs->trans("ThirdParty"),0,'company'); /* * Fiche societe en mode visu */ print ''; print ''; print ''; print ''; print 'global->SOCIETE_USEPREFIX)?' colspan="3"':'').'>'; print $soc->code_client; if ($soc->check_codeclient() <> 0) print ' '.$langs->trans("WrongCustomerCode"); print ''; if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field { print ''; } print ''; print ""; print ""; print ""; print ""; print ''; print ''; print ''; $object=$soc; print ''; // IdProf1 (SIREN for France) $idprof=$langs->transcountry('ProfId1',$object->country_code); if ($idprof!='-') { print ''; } else print ''; // IdProf2 (SIRET for France) $idprof=$langs->transcountry('ProfId2',$object->country_code); if ($idprof!='-') { print ''; } else print ''; print ''; print ''; // IdProf3 (APE for France) $idprof=$langs->transcountry('ProfId3',$object->country_code); if ($idprof!='-') { print ''; } else print ''; // IdProf4 (NU for France) $idprof=$langs->transcountry('ProfId4',$object->country_code); if ($idprof!='-') { print ''; } else print ''; print ''; // Capital print ''; // Societe mere print ''; print '
'.$langs->trans('ThirdPartyName').''; print $form->showrefnav($soc,'socid','',($user->societe_id?0:1),'rowid','nom'); print '
'.$langs->trans('CustomerCode').''.$langs->trans('Prefix').''.$soc->prefix_comm.'
".$langs->trans('Address')."".nl2br($soc->address)."
".$langs->trans('Zip').''.$soc->zip."".$langs->trans('Town')."".$soc->town."
".$langs->trans('Country')."".$soc->country."
'.$langs->trans('Phone').''.dol_print_phone($soc->tel,$soc->country_code,0,$soc->id,'AC_TEL').''.$langs->trans('Fax').''.dol_print_phone($soc->fax,$soc->country_code,0,$soc->id,'AC_FAX').'
'.$langs->trans('Web').''; if ($soc->url) { print 'http://'.$soc->url.''; } print '
'.$idprof.''; print $formcompany->get_input_id_prof(1,'idprof1',$object->idprof1,$object->country_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(2,'idprof2',$object->idprof2,$object->paycountry_codes_code); print '  
'.$idprof.''; print $formcompany->get_input_id_prof(3,'idprof3',$object->idprof3,$object->country_code); print '  '.$idprof.''; print $formcompany->get_input_id_prof(4,'idprof4',$object->idprof4,$object->country_code); print '  
'.$langs->trans("Capital").''.$soc->capital.' '.$langs->trans("Currency".$conf->currency).'
'.$langs->trans("ParentCompany").''; if ($soc->parent) { $socm = new Societe($db); $socm->fetch($soc->parent); print ''.img_object($langs->trans("ShowCompany"),'company').' '.$socm->nom.''.($socm->code_client?" (".$socm->code_client.")":""); print ($socm->ville?' - '.$socm->ville:''); print ' '; print img_delete(); print '
'; } else { print $langs->trans("NoParentCompany"); } print '
'; print "\n"; if ($_GET["select"] > 0) { $socm = new Societe($db); $socm->id = $_GET["select"]; $socm->fetch($_GET["select"]); } else { if ($user->rights->societe->creer) { $page=$_GET["page"]; if ($page == -1) { $page = 0 ; } $offset = $conf->liste_limit * $page ; $pageprev = $page - 1; $pagenext = $page + 1; /* * Liste * */ $title=$langs->trans("CompanyList"); $sql = "SELECT s.rowid as socid, s.nom, s.ville, s.prefix_comm, s.client, s.fournisseur,"; $sql.= " te.code, te.libelle"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= ", ".MAIN_DB_PREFIX."c_typent as te"; if (! $user->rights->societe->client->voir) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE s.fk_typent = te.id"; $sql.= " AND s.entity IN (".getEntity('societe', 1).")"; if (! $user->rights->societe->client->voir) $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; if (dol_strlen(trim($_GET["search_nom"]))) $sql.= " AND s.nom LIKE '%".$_GET["search_nom"]."%'"; $sql.= $db->order("s.nom","ASC"); $sql.= $db->plimit($conf->liste_limit+1, $offset); $resql = $db->query($sql); if ($resql) { $num = $db->num_rows($resql); $i = 0; $params = "&socid=".$_GET["socid"]; print_barre_liste($title, $page, "lien.php",$params,$sortfield,$sortorder,'',$num,0,''); // Lignes des titres print ''; print ''; print ''; print ''; print ''; print "\n"; // Lignes des champs de filtre print ''; print ''; print ''; print ''; print "\n"; print ''; $var=True; while ($i < min($num,$conf->liste_limit)) { $obj = $db->fetch_object($resql); $var=!$var; print "\n"; print "\n"; print "\n"; print ''; // Lien S�lectionner print ''; print ''."\n"; $i++; } print "
'.$langs->trans("Company").''.$langs->trans("Town").''.$langs->trans("ThirdPartyType").''; print ' 
'; print ''; print ''; print ''; print '
"; print $obj->nom."".$obj->ville." ".$langs->getLabelFromKey($db,$obj->code,'c_typent','code','libelle')."'; if ($obj->client==1) { print $langs->trans("Customer")."\n"; } elseif ($obj->client==2) { print $langs->trans("Prospect")."\n"; } else { print " "; } print ""; if ($obj->fournisseur) { print $langs->trans("Supplier"); } else { print " "; } print ''.$langs->trans("Select").''; print '
"; print '
'; $db->free($resql); } else { dol_print_error($db); } } } } $db->close(); llxFooter(); ?>