diff --git a/htdocs/comm/prospect/fiche.php b/htdocs/comm/prospect/fiche.php index 69c11c96804..b909a409cfd 100644 --- a/htdocs/comm/prospect/fiche.php +++ b/htdocs/comm/prospect/fiche.php @@ -19,11 +19,11 @@ */ /** - \file htdocs/comm/prospect/fiche.php - \ingroup prospect - \brief Page de la fiche prospect - \version $Id$ -*/ + \file htdocs/comm/prospect/fiche.php + \ingroup prospect + \brief Page de la fiche prospect + \version $Id$ + */ require_once("./pre.inc.php"); require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); @@ -46,23 +46,23 @@ $result = restrictedArea($user, 'societe',$socid,''); /* * Actions */ - + if ($_GET["action"] == 'cstc') { - $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; - $sql .= " WHERE rowid = ".$_GET["socid"]; - $db->query($sql); + $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_stcomm = ".$_GET["stcomm"]; + $sql .= " WHERE rowid = ".$_GET["socid"]; + $db->query($sql); } // set prospect level if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) { - + $societe = new Societe($db, $_GET["socid"]); - $societe->fk_prospectlevel=$_POST['prospect_level_id']; + $societe->fk_prospectlevel=$_POST['prospect_level_id']; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET fk_prospectlevel='".$_POST['prospect_level_id']; $sql.= "' WHERE rowid='".$_GET["socid"]."'"; - $result = $db->query($sql); - if (! $result) dolibarr_print_error($result); + $result = $db->query($sql); + if (! $result) dolibarr_print_error($result); } @@ -70,7 +70,7 @@ if ($_POST["action"] == 'setprospectlevel' && $user->rights->societe->creer) * * Mode fiche * - *********************************************************************************/ + *********************************************************************************/ llxHeader(); @@ -79,14 +79,14 @@ $formcompany=new FormCompany($db); if ($socid > 0) { - $actionstatic=new ActionComm($db); - $societe = new Prospect($db, $socid); - $result = $societe->fetch($socid); - if ($result < 0) - { - dolibarr_print_error($db); - exit; - } + $actionstatic=new ActionComm($db); + $societe = new Prospect($db, $socid); + $result = $societe->fetch($socid); + if ($result < 0) + { + dolibarr_print_error($db); + exit; + } /* * Affichage onglets @@ -95,14 +95,14 @@ if ($socid > 0) dolibarr_fiche_head($head, 'prospect', $langs->trans("ThirdParty")); - print "\n"; - print '\n"; - print '\n"; + print '"; - print "
'; + print ''; + print ''; + print ''; + print '
'; - print ''; - print ''; - print '"; + print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'; + print ''; + print '"; - print ''; + print ''; // Country print ''; - print ''; - print '"; + print ''; + print '"; - if ($societe->rubrique) - { - print ""; - } + if ($societe->rubrique) + { + print ""; + } - print ''; + print ''; // Level print '"; print ''; - - // Status - print ''; - print ''; - print '
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Address").''.nl2br($societe->adresse)."
'.$langs->trans('Zip').' / '.$langs->trans('Town').''.$societe->cp." ".$societe->ville.'
'.$langs->trans('Zip').' / '.$langs->trans('Town').''.$societe->cp." ".$societe->ville.'
'.$langs->trans("Country").''; @@ -110,15 +110,15 @@ if ($socid > 0) else print $societe->pays; print '
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'Fax'.dol_print_phone($societe->fax,$societe->pays_code).'
'.$langs->trans("Web")."url\">$societe->url
'.$langs->trans("Phone").''.dol_print_phone($societe->tel,$societe->pays_code,0,$societe->id,'AC_TEL').'Fax'.dol_print_phone($societe->fax,$societe->pays_code).'
'.$langs->trans("Web")."url\">$societe->url
Rubrique".$societe->rubrique."
Rubrique".$societe->rubrique."
'.$langs->trans('JuridicalStatus').''.$societe->forme_juridique.'
'.$langs->trans('JuridicalStatus').''.$societe->forme_juridique.'
'; @@ -139,134 +139,143 @@ if ($socid > 0) } print "
'.$langs->trans("Status").''.$societe->getLibStatut(4).''; - if ($societe->stcomm_id != -1) print ''.img_action(0,-1).''; - if ($societe->stcomm_id != 0) print ''.img_action(0,0).''; - if ($societe->stcomm_id != 1) print ''.img_action(0,1).''; - if ($societe->stcomm_id != 2) print ''.img_action(0,2).''; - if ($societe->stcomm_id != 3) print ''.img_action(0,3).''; - print '
'; + + // Status + print '
'.$langs->trans("Status").''.$societe->getLibStatut(4).''; + if ($societe->stcomm_id != -1) print ''.img_action(0,-1).''; + if ($societe->stcomm_id != 0) print ''.img_action(0,0).''; + if ($societe->stcomm_id != 1) print ''.img_action(0,1).''; + if ($societe->stcomm_id != 2) print ''.img_action(0,2).''; + if ($societe->stcomm_id != 3) print ''.img_action(0,3).''; + print '
'; - print "
'; + print "'; - // Nbre max d'éléments des petites listes - $MAXLIST=5; - $tableaushown=0; + // Nbre max d'éléments des petites listes + $MAXLIST=5; + $tableaushown=0; - - /* - * Dernieres propales - * - */ - if ($conf->propal->enabled) - { - $propal_static=new Propal($db); - - print ''; - $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; - $sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite,"; - $sql.= " c.label as statut, c.id as statutid"; - $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; - $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; - $sql.= " AND s.rowid = ".$societe->id; - $sql.= " ORDER BY p.datep DESC"; - - $resql=$db->query($sql); - if ($resql) - { - $var=true; - $i = 0; - $num = $db->num_rows($resql); - if ($num > 0) - { - $tableaushown=1; - print ''; - print ''; - print ''; - } - - $now = gmmktime(); - - while ($i < $num && $i < $MAXLIST) - { - $objp = $db->fetch_object($resql); - $var=!$var; - print ""; - print "\n"; - print "\n"; - print "\n"; - $i++; - } - $db->free(); - } - else - { - dolibarr_print_error($db); - } - - print "
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')
propalid\">"; - print img_object($langs->trans("ShowPropal"),"propal"); - print " ".$objp->ref."\n"; - if ( $objp->dp < ($now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1 ) - { - print " ".img_warning(); - } - print "".dolibarr_print_date($objp->dp,"day")."".price($objp->total_ht)."".$propal_static->LibStatut($objp->fk_statut,5)."
"; - } - - print "
\n\n"; - - - /* - * Barre d'action - * - */ - - print '
'; - - print ''.$langs->trans("AddContact").''; - - if ($conf->agenda->enabled) - { - // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-action-button-behaviour.html) - // Don't force the user to add a "todo action"; he could report an action that he did - print ''.$langs->trans("AddAction").''; - } - - if ($conf->propal->enabled && defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE && $user->rights->propale->creer) - { - print ''.$langs->trans("AddProp").''; - } - - if ($conf->projet->enabled && $user->rights->projet->creer) - { - print ''.$langs->trans("AddProject").''; - } - print '
'; - - print '
'; + // Lien recap + print ''; + print ''; + print ''; + print ''; + print '
'; + print '
'.$langs->trans("Summary").''.$langs->trans("ShowProspectPreview").'
'; + print '
'; /* - * Liste des contacts - */ + * Dernieres propales + * + */ + if ($conf->propal->enabled) + { + $propal_static=new Propal($db); + + print ''; + $sql = "SELECT s.nom, s.rowid as socid, p.rowid as propalid, p.fk_statut, p.total_ht, p.ref, p.remise, "; + $sql.= " ".$db->pdate("p.datep")." as dp, ".$db->pdate("p.fin_validite")." as datelimite,"; + $sql.= " c.label as statut, c.id as statutid"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".MAIN_DB_PREFIX."propal as p, ".MAIN_DB_PREFIX."c_propalst as c"; + $sql.= " WHERE p.fk_soc = s.rowid AND p.fk_statut = c.id"; + $sql.= " AND s.rowid = ".$societe->id; + $sql.= " ORDER BY p.datep DESC"; + + $resql=$db->query($sql); + if ($resql) + { + $var=true; + $i = 0; + $num = $db->num_rows($resql); + if ($num > 0) + { + $tableaushown=1; + print ''; + print ''; + print ''; + } + + $now = gmmktime(); + + while ($i < $num && $i < $MAXLIST) + { + $objp = $db->fetch_object($resql); + $var=!$var; + print ""; + print "\n"; + print "\n"; + print "\n"; + $i++; + } + $db->free(); + } + else + { + dolibarr_print_error($db); + } + + print "
'.$langs->trans("LastPropals",($num<=$MAXLIST?"":$MAXLIST)).''.$langs->trans("AllPropals").' ('.$num.')
propalid\">"; + print img_object($langs->trans("ShowPropal"),"propal"); + print " ".$objp->ref."\n"; + if ( $objp->dp < ($now - $conf->propal->cloture->warning_delay) && $objp->fk_statut == 1 ) + { + print " ".img_warning(); + } + print "".dolibarr_print_date($objp->dp,"day")."".price($objp->total_ht)."".$propal_static->LibStatut($objp->fk_statut,5)."
"; + } + + print ""; + print "\n\n"; + + + /* + * Barre d'action + * + */ + + print '
'; + + print ''.$langs->trans("AddContact").''; + + if ($conf->agenda->enabled) + { + // Updated by Matelli (See http://matelli.fr/showcases/patchs-dolibarr/add-action-button-behaviour.html) + // Don't force the user to add a "todo action"; he could report an action that he did + print ''.$langs->trans("AddAction").''; + } + + if ($conf->propal->enabled && defined("MAIN_MODULE_PROPALE") && MAIN_MODULE_PROPALE && $user->rights->propale->creer) + { + print ''.$langs->trans("AddProp").''; + } + + if ($conf->projet->enabled && $user->rights->projet->creer) + { + print ''.$langs->trans("AddProject").''; + } + print '
'; + + print '
'; + + + /* + * Liste des contacts + */ show_contacts($conf,$langs,$db,$societe); - - /* - * Listes des actions a faire - */ + + /* + * Listes des actions a faire + */ show_actions_todo($conf,$langs,$db,$societe); - - /* - * Listes des actions effectuees - */ + + /* + * Listes des actions effectuees + */ show_actions_done($conf,$langs,$db,$societe); } diff --git a/htdocs/comm/prospect/recap-prospect.php b/htdocs/comm/prospect/recap-prospect.php new file mode 100644 index 00000000000..fee032f93de --- /dev/null +++ b/htdocs/comm/prospect/recap-prospect.php @@ -0,0 +1,96 @@ + + * Copyright (C) 2004-2009 Laurent Destailleur + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + */ + +/** + \file htdocs/fourn/recap-fourn.php + \ingroup fournisseur + \brief Page de fiche recap fournisseur + \version $Id$ +*/ + +require("./pre.inc.php"); +require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php"); +require_once(DOL_DOCUMENT_ROOT."/facture.class.php"); + +$langs->load("companies"); +if ($conf->facture->enabled) $langs->load("bills"); + +// Sécurité accés client +$socid = $_GET["socid"]; +if ($user->societe_id > 0) +{ + $action = ''; + $socid = $user->societe_id; +} + + + +/* + * + * Mode fiche + * + */ + +llxHeader(); + +if ($socid > 0) +{ + $societe = new Societe($db); + $societe->fetch($socid, $to); // si $to='next' ajouter " AND s.rowid > $socid ORDER BY idp ASC LIMIT 1"; + + /* + * Affichage onglets + */ + $head = societe_prepare_head($societe); + + dolibarr_fiche_head($head, 'prospect', $langs->trans("ThirdParty")); + + + print "\n"; + print '
'; + + print ''; + + // Nom + print ''; + + // Prefix + print ''; + + print "
'.$langs->trans("Name").''.$societe->nom.'
'.$langs->trans("Prefix").''; + print ($societe->prefix_comm?$societe->prefix_comm:' '); + print '
"; + + print "
\n"; + + print ''; + + + print $langs->trans("FeatureNotYetAvailable"); +} +else +{ + dolibarr_print_error($db); +} + + +$db->close(); + +llxFooter('$Date$ - $Revision$'); +?> diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 67594579d08..37b9714a56c 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -15,16 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/compta/recap-compta.php \ingroup compta \brief Page de fiche recap compta - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -59,11 +56,11 @@ if ($socid > 0) * Affichage onglets */ $head = societe_prepare_head($societe); - - dolibarr_fiche_head($head, 'compta', $societe->nom); + + dolibarr_fiche_head($head, 'compta', $langs->trans("ThirdParty")); print "\n"; - print '
'; + print '
'; print ''; @@ -74,7 +71,7 @@ if ($socid > 0) print ''; - + print "
'.$langs->trans("Prefix").''; print ($societe->prefix_comm?$societe->prefix_comm:' '); print '
"; print "
\n"; @@ -86,9 +83,9 @@ if ($socid > 0) { // Factures print_fiche_titre($langs->trans("AccountancyPreview")); - + print ''; - + $sql = "SELECT s.nom, s.rowid as socid, f.facnumber, f.amount, ".$db->pdate("f.datef")." as df,"; $sql.= " f.paye as paye, f.fk_statut as statut, f.rowid as facid,"; $sql.= " u.login, u.rowid as userid"; @@ -96,7 +93,7 @@ if ($socid > 0) $sql.= " WHERE f.fk_soc = s.rowid AND s.rowid = ".$societe->id; $sql.= " AND f.fk_user_valid = u.rowid"; $sql.= " ORDER BY f.datef DESC"; - + $resql=$db->query($sql); if ($resql) { @@ -117,41 +114,41 @@ if ($socid > 0) { print ''; } - + $solde = 0; - + // Boucle sur chaque facture for ($i = 0 ; $i < $num ; $i++) { $objf = $db->fetch_object($resql); - + $fac = new Facture($db); $ret=$fac->fetch($objf->facid); - if ($ret < 0) + if ($ret < 0) { print $fac->error."
"; continue; } $totalpaye = $fac->getSommePaiement(); - + $var=!$var; print ""; - + print "\n"; print "\n"; - + print ''; print '\n"; $solde = $solde + $fac->total_ttc; - + print ''; print '\n"; // Auteur print ''; - + print "\n"; - + // Paiements $sql = "SELECT p.rowid,".$db->pdate("p.datep")." as dp, pf.amount, p.statut,"; $sql.= " p.fk_user_creat, u.login, u.rowid as userid"; @@ -160,13 +157,13 @@ if ($socid > 0) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."user as u ON p.fk_user_creat = u.rowid"; $sql.= " WHERE pf.fk_paiement = p.rowid"; $sql.= " AND pf.fk_facture = ".$fac->id; - + $resqlp = $db->query($sql); if ($resqlp) { $nump = $db->num_rows($resqlp); $j = 0; - + while ($j < $nump) { $objp = $db->fetch_object($resqlp); @@ -186,7 +183,7 @@ if ($socid > 0) print ''; print ''; - + $j++; } @@ -204,7 +201,7 @@ if ($socid > 0) } print "
'.$langs->trans("NoInvoice").'
".dolibarr_print_date($fac->date)."id\">".img_object($langs->trans("ShowBill"),"bill")." ".$fac->ref."'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." '.price($solde)."'.img_object($langs->trans("ShowUser"),'user').' '.$objf->login.'
'.img_object($langs->trans("ShowUser"),'user').' '.$objp->login.'
"; print "
"; - } + } } else { diff --git a/htdocs/fourn/recap-fourn.php b/htdocs/fourn/recap-fourn.php index a091907847b..4ee9981c5a0 100644 --- a/htdocs/fourn/recap-fourn.php +++ b/htdocs/fourn/recap-fourn.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2006 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * * 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 @@ -15,16 +15,13 @@ * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. - * - * $Id$ - * $Source$ */ /** \file htdocs/fourn/recap-fourn.php \ingroup fournisseur \brief Page de fiche recap fournisseur - \version $Revision$ + \version $Id$ */ require("./pre.inc.php"); @@ -61,12 +58,12 @@ if ($socid > 0) * Affichage onglets */ $head = societe_prepare_head($societe); - - dolibarr_fiche_head($head, 'supplier', $societe->nom); + + dolibarr_fiche_head($head, 'supplier', $langs->trans("ThirdParty")); print "\n"; - print '
'; + print '
'; print ''; diff --git a/htdocs/langs/en_US/errors.lang b/htdocs/langs/en_US/errors.lang index 792a907f791..f388cfc2f34 100644 --- a/htdocs/langs/en_US/errors.lang +++ b/htdocs/langs/en_US/errors.lang @@ -45,4 +45,4 @@ ErrorLDAPMakeManualTest=A .ldif file has been generated in directory %s. Try to ErrorCantSaveADoneUserWithZeroPercentage=Can't save an action with "statut not started" if field "done by" is also filled. ErrorBillRefAlreadyExists=Ref used for creation already exists. ErrorPleaseTypeBankTransactionReportName=Please type bank receipt name where transaction is reported (Format YYYYMM or YYYYMMDD) -ErrorRecordHasChildren=Failed to delete records since it has some childs. \ No newline at end of file +ErrorRecordHasChildren=Failed to delete records since it has some childs. diff --git a/htdocs/langs/en_US/main.lang b/htdocs/langs/en_US/main.lang index 69490bf0876..68b73c1232e 100644 --- a/htdocs/langs/en_US/main.lang +++ b/htdocs/langs/en_US/main.lang @@ -404,6 +404,7 @@ AccountancyPreview=Accountancy preview ShowCustomerPreview=Show customer preview ShowSupplierPreview=Show supplier preview ShowAccountancyPreview=Show accountancy preview +ShowProspectPreview=Show prospect preview RefCustomer=Ref. customer Currency=Currency InfoAdmin=Information for administrators diff --git a/htdocs/langs/fr_FR/main.lang b/htdocs/langs/fr_FR/main.lang index 2cd004a9bb3..2df909e6280 100644 --- a/htdocs/langs/fr_FR/main.lang +++ b/htdocs/langs/fr_FR/main.lang @@ -404,6 +404,7 @@ SupplierPreview=Aperçu fournisseur AccountancyPreview=Aperçu compta ShowCustomerPreview=Afficher aperçu client ShowSupplierPreview=Afficher aperçu fournisseur +ShowProspectPreview=Afficher aperçu prospect ShowAccountancyPreview=Afficher aperçu compta RefCustomer=Réf. client Currency=Devise diff --git a/htdocs/soc.php b/htdocs/soc.php index e119bb52ea1..91a891befbd 100644 --- a/htdocs/soc.php +++ b/htdocs/soc.php @@ -1,7 +1,7 @@ * Copyright (C) 2003 Brian Fraval - * Copyright (C) 2004-2008 Laurent Destailleur + * Copyright (C) 2004-2009 Laurent Destailleur * Copyright (C) 2005 Eric Seigne * Copyright (C) 2005-2007 Regis Houssin * Copyright (C) 2008 Patrick Raguin @@ -255,7 +255,8 @@ if ($_REQUEST["action"] == 'confirm_delete' && $_REQUEST["confirm"] == 'yes' && else { $reload = 0; - $mesg=$soc->error; + $langs->load("errors"); + $mesg=$langs->trans($soc->error); $_GET["action"]=''; } } diff --git a/htdocs/societe.class.php b/htdocs/societe.class.php index 1a337f452bb..dbd5932e301 100644 --- a/htdocs/societe.class.php +++ b/htdocs/societe.class.php @@ -45,7 +45,7 @@ class Societe extends CommonObject var $id; var $nom; - var $nom_particulier; + var $nom_particulier; var $prenom; var $particulier; var $adresse; @@ -137,7 +137,7 @@ class Societe extends CommonObject function create($user='') { global $langs,$conf; - + // clean parameters $this->nom=trim($this->nom); @@ -344,7 +344,7 @@ class Societe extends CommonObject $this->effectif_id=trim($this->effectif_id); $this->forme_juridique_code=trim($this->forme_juridique_code); - + //Gencod $this->gencod=trim($this->gencod); @@ -385,7 +385,7 @@ class Societe extends CommonObject $sql .= ",tva_intra = '" . addslashes($this->tva_intra) ."'"; $sql .= ",capital = '" . addslashes($this->capital) ."'"; - + $sql .= ",prefix_comm = ".($this->prefix_comm?"'".addslashes($this->prefix_comm)."'":"null"); $sql .= ",fk_effectif = ".($this->effectif_id?"'".$this->effectif_id."'":"null"); @@ -397,7 +397,7 @@ class Societe extends CommonObject $sql .= ",client = " . $this->client; $sql .= ",fournisseur = " . $this->fournisseur; $sql .= ",gencod = ".($this->gencod?"'".$this->gencod."'":"null"); - + if ($allowmodcodeclient) { @@ -427,7 +427,7 @@ class Societe extends CommonObject $sql .= ", fk_user_modif = ".($user->id > 0 ? "'".$user->id."'":"null"); $sql .= " WHERE rowid = '" . $id ."'"; - + dolibarr_syslog("Societe::update sql=".$sql); $resql=$this->db->query($sql); if ($resql) @@ -694,9 +694,27 @@ class Societe extends CommonObject dolibarr_syslog("Societe::Delete"); $sqr = 0; - // \Todo // Check if third party can be deleted - + $nbpropal=0; + $sql = "SELECT COUNT(*) as nb from ".MAIN_DB_PREFIX."propal"; + $sql.= " WHERE fk_soc = " . $id; + $resql=$this->db->query($sql); + if ($resql) + { + $obj=$this->db->fetch_object($resql); + $nbpropal=$obj->nb; + if ($nbpropal > 0) + { + $this->error="ErrorRecordHasChildren"; + return -1; + } + } + else + { + $this->error .= $this->db->lasterror(); + dolibarr_syslog("Societe::Delete erreur -1 ".$this->error); + return -1; + } @@ -705,20 +723,20 @@ class Societe extends CommonObject // Added by Matelli (see http://matelli.fr/showcases/patchs-dolibarr/fix-third-party-deleting.html) // Removing every "categorie" link with this company require_once(DOL_DOCUMENT_ROOT."/categories/categorie.class.php"); - + $static_cat = new Categorie($this->db); $toute_categs = array(); - + // Fill $toute_categs array with an array of (type => array of ("Categorie" instance)) if ($this->client || $this->prospect) { $toute_categs ['societe'] = $static_cat->containing($this->id,'societe',2); } if ($this->fournisseur) - { + { $toute_categs ['fournisseur'] = $static_cat->containing($this->id,'fournisseur',1); } - + // Remove each "Categorie" foreach ($toute_categs as $type => $categs_type) { @@ -727,7 +745,7 @@ class Societe extends CommonObject $cat->del_type($this, $type); } } - + // Remove contacts $sql = "DELETE from ".MAIN_DB_PREFIX."socpeople"; $sql.= " WHERE fk_soc = " . $id; @@ -956,7 +974,7 @@ class Societe extends CommonObject if ($this->id) { $this->db->begin(); - + // Positionne remise courante $sql = "UPDATE ".MAIN_DB_PREFIX."societe "; $sql.= " SET remise_client = '".$remise."'"; @@ -1052,7 +1070,7 @@ class Societe extends CommonObject if ($this->id) { require_once(DOL_DOCUMENT_ROOT.'/discount.class.php'); - + $discount = new DiscountAbsolute($this->db); $result=$discount->fetch($id); $result=$discount->delete(); @@ -1086,7 +1104,7 @@ class Societe extends CommonObject } } - + /** * Enter description here... * @@ -1198,7 +1216,7 @@ class Societe extends CommonObject $lien = ''; $lienfin=''; } - + if (empty($lien)) { $lien = ''; @@ -1411,7 +1429,7 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODECLIENT_ADDON.'.php'; $var = $conf->global->SOCIETE_CODECLIENT_ADDON; $mod = new $var; - + $this->code_client = $mod->getNextValue($objsoc,$type); $this->prefixCustomerIsRequired = $mod->prefixIsRequired; @@ -1431,10 +1449,10 @@ class Societe extends CommonObject require_once DOL_DOCUMENT_ROOT.'/includes/modules/societe/'.$conf->global->SOCIETE_CODEFOURNISSEUR_ADDON.'.php'; $var = $conf->global->SOCIETE_CODEFOURNISSEUR_ADDON; $mod = new $var; - + $this->code_fournisseur = $mod->getNextValue($objsoc,$type); $this->prefixSupplierIsRequired = $mod->prefixIsRequired; - + dolibarr_syslog("Societe::get_codefournisseur code_fournisseur=".$this->code_fournisseur." module=".$var); } } @@ -1567,7 +1585,7 @@ class Societe extends CommonObject // Defini code compta dans $mod->code $result = $mod->get_code($this->db, $this, $type); - + if ($type == 'customer') $this->code_compta = $mod->code; if ($type == 'supplier') $this->code_compta_fournisseur = $mod->code; @@ -1819,7 +1837,7 @@ class Societe extends CommonObject 'SI', // Slovenia 'ES', // Spain 'SE', // Sweden - 'CH', // Switzerland + 'CH', // Switzerland ); //print "dd".$this->pays_code; return in_array($this->pays_code,$country_code_in_EEC);