From 7d2b11aff5c70f06ea1c99b55c1d66fe57dbf91e Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 8 Apr 2013 19:26:45 +0200 Subject: [PATCH] Qual: Remove a deprecated page, replaced by a more direct combo box. --- htdocs/core/class/html.form.class.php | 2 +- htdocs/core/lib/company.lib.php | 8 - .../canvas/company/tpl/card_view.tpl.php | 4 - htdocs/societe/class/societe.class.php | 44 +-- htdocs/societe/lien.php | 342 ------------------ htdocs/societe/soc.php | 46 +-- 6 files changed, 35 insertions(+), 411 deletions(-) delete mode 100644 htdocs/societe/lien.php diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 9e58dfe4e5c..7911ba18a80 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -660,7 +660,7 @@ class Form * * @param string $selected Preselected type * @param string $htmlname Name of field in form - * @param string $filter Optionnal filters criteras + * @param string $filter Optionnal filters criteras (example: 's.rowid <> x') * @param int $showempty Add an empty field * @param int $showtype Show third party type in combolist (customer, prospect or supplier) * @param int $forcecombo Force to use combo box diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index 9b74e999fbe..cb701a07c8d 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -148,14 +148,6 @@ function societe_prepare_head2($object) $h++; } - if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) - { - $head[$h][0] = 'lien.php?socid='.$object->id; - $head[$h][1] = $langs->trans("ParentCompany"); - $head[$h][2] = 'links'; - $h++; - } - $head[$h][0] = 'commerciaux.php?socid='.$object->id; $head[$h][1] = $langs->trans("SalesRepresentative"); $head[$h][2] = 'salesrepresentative'; diff --git a/htdocs/societe/canvas/company/tpl/card_view.tpl.php b/htdocs/societe/canvas/company/tpl/card_view.tpl.php index 9e0c04d017b..2beb21e3430 100644 --- a/htdocs/societe/canvas/company/tpl/card_view.tpl.php +++ b/htdocs/societe/canvas/company/tpl/card_view.tpl.php @@ -195,11 +195,7 @@ for ($i=1; $i<=4; $i++) { trans('ParentCompany'); ?> - rights->societe->creer) { ?> - control->tpl['image_edit']; ?> -   - diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index 3c4e1d657b8..97291206ad4 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -129,6 +129,7 @@ class Societe extends CommonObject var $date_update; var $commercial_id; // Id of sales representative to link (used for thirdparty creation). Not filled by a fetch, because we can have several sales representatives. + var $parent; var $default_lang; var $ref_int; @@ -1975,53 +1976,30 @@ class Societe extends CommonObject } /** - * Defini la societe mere pour les filiales + * Define parent commany of current company * - * @param int $id id compagnie mere a positionner + * @param int $id Id of thirdparty to set or '' to remove * @return int <0 if KO, >0 if OK */ function set_parent($id) { if ($this->id) { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET parent = ".$id; - $sql .= " WHERE rowid = " . $this->id .";"; - - if ( $this->db->query($sql) ) + $sql = "UPDATE ".MAIN_DB_PREFIX."societe"; + $sql.= " SET parent = ".($id > 0 ? $id : "null"); + $sql.= " WHERE rowid = " . $this->id; + dol_syslog(get_class($this).'::set_parent sql='.$sql); + $resql=$this->db->query($sql); + if ($resql) { return 1; } else - { - return -1; - } - } - } - - /** - * Supprime la societe mere - * - * @param int $id id compagnie mere a effacer - * @return int <0 if KO, >0 if KO - */ - function remove_parent($id) - { - if ($this->id) - { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; - $sql .= " SET parent = null"; - $sql .= " WHERE rowid = " . $this->id .";"; - - if ( $this->db->query($sql) ) - { - return 1; - } - else - { + { return -1; } } + else return -1; } /** diff --git a/htdocs/societe/lien.php b/htdocs/societe/lien.php deleted file mode 100644 index efee8444dea..00000000000 --- a/htdocs/societe/lien.php +++ /dev/null @@ -1,342 +0,0 @@ - - * Copyright (C) 2004-2013 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 $object->idprof1; - print '  '.$idprof.''; - print $object->idprof2; - print '  
'.$idprof.''; - print $object->idprof3; - print '  '.$idprof.''; - print $object->idprof4; - 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->town?' - '.$socm->town:''); - 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.town, 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 ''; - print "\n"; - print ''; - - $societestatic=new Societe($db); - - $var=True; - while ($i < min($num,$conf->liste_limit)) - { - $obj = $db->fetch_object($resql); - $var=!$var; - print ""; - 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 '
"; - $societestatic->name=$obj->nom; - $societestatic->id=$obj->socid; - print $societestatic->getNomUrl(1); - print "".$obj->town." "; - $s=$langs->getLabelFromKey($db,$obj->code,'c_typent','code','libelle'); - if ($s != '-') print $s; - print "'; - $x=0; - if ($obj->client==1 || $obj->client==3) - { - print $langs->trans("Customer"); - $x++; - } - if ($obj->client==2) - { - if ($x) print '/'; - print $langs->trans("Prospect"); - $x++; - } - if ($obj->fournisseur) - { - if ($x) print '/'; - print $langs->trans("Supplier"); - $x++; - } - print ''.$langs->trans("Add").''; - print '
"; - print '
'; - $db->free($resql); - } - else - { - dol_print_error($db); - } - } - } -} - - -$db->close(); - -llxFooter(); -?> diff --git a/htdocs/societe/soc.php b/htdocs/societe/soc.php index cfa128bc184..772e1b24497 100644 --- a/htdocs/societe/soc.php +++ b/htdocs/societe/soc.php @@ -442,6 +442,11 @@ if (empty($reshook)) } } + // Set parent company + if ($action == 'set_thirdparty' && $user->rights->societe->creer) + { + $result = $object->set_parent(GETPOST('editparentcompany','int')); + } /* * Generate document @@ -515,7 +520,6 @@ $formcompany = new FormCompany($db); $countrynotdefined=$langs->trans("ErrorSetACountryFirst").' ('.$langs->trans("SeeAbove").')'; - if (is_object($objcanvas) && $objcanvas->displayCanvasExists($action)) { // ----------------------------------------- @@ -1724,28 +1728,24 @@ else // Parent company if (empty($conf->global->SOCIETE_DISABLE_PARENTCOMPANY)) { - print ''; - print '
'; - print $langs->trans('ParentCompany'); - print ''; - if ($user->rights->societe->creer) - print ''.img_edit() .''; - else - print ' '; - print '
'; - print ''; - print ''; - if ($object->parent) - { - $socm = new Societe($db); - $socm->fetch($object->parent); - print $socm->getNomUrl(1).' '.($socm->code_client?"(".$socm->code_client.")":""); - print $socm->town?' - '.$socm->town:''; - } - else { - print $langs->trans("NoParentCompany"); - } - print ''; + // Payment term + print ''; + print ''; + if ($action != 'editparentcompany') print ''; + print '
'; + print $langs->trans('ParentCompany'); + print 'id.'">'.img_edit($langs->transnoentitiesnoconv('Edit'),1).'
'; + print ''; + if ($action == 'editparentcompany') + { + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'editparentcompany','s.rowid <> '.$object->id,1); + } + else + { + $form->form_thirdparty($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->parent,'none','s.rowid <> '.$object->id,1); + } + print ''; + print ''; } // Sales representative