Qual: Removed checkstyle errors and dead code

This commit is contained in:
Laurent Destailleur 2012-03-13 01:43:13 +01:00
parent 3f001e3938
commit 4f23be1b50
4 changed files with 84 additions and 170 deletions

View File

@ -85,11 +85,6 @@ if ($action == 'setcustomeraccountancycode')
$action=""; $action="";
} }
if ($action == 'attribute_prefix' && $user->rights->societe->creer)
{
$object->fetch($id);
$object->attribute_prefix($db, $id);
}
// conditions de reglement // conditions de reglement
if ($action == 'setconditions' && $user->rights->societe->creer) if ($action == 'setconditions' && $user->rights->societe->creer)
{ {

View File

@ -64,13 +64,6 @@ llxHeader();
$thirdpartystatic=new Societe($db); $thirdpartystatic=new Societe($db);
if ($action == 'attribute_prefix')
{
$societe = new Societe($db);
$societe->fetch($socid);
$societe->attribute_prefix($db, $socid);
}
if ($action == 'note') if ($action == 'note')
{ {
$sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid; $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET note='".$note."' WHERE rowid=".$socid;

View File

@ -96,7 +96,7 @@ abstract class ActionsCardCommon
/** /**
* Load data control * Load data control
* *
* @param int $socid Id of third party * @param int &$action Action code
* @return void * @return void
*/ */
function doActions(&$action) function doActions(&$action)

View File

@ -932,7 +932,7 @@ class Societe extends CommonObject
// Delete directory // Delete directory
$docdir = $conf->societe->dir_output . "/" . $id; $docdir = $conf->societe->dir_output . "/" . $id;
if (file_exists ($docdir)) if (file_exists($docdir))
{ {
dol_delete_dir_recursive($docdir); dol_delete_dir_recursive($docdir);
} }
@ -948,106 +948,10 @@ class Societe extends CommonObject
} }
/** /**
* Update record to set prefix * Define third party as a customer
* *
* @return void * @return int <0 if KO, >0 if OK
*/
function attribute_prefix()
{
global $conf;
$sql = "SELECT nom as name FROM ".MAIN_DB_PREFIX."societe WHERE rowid = '".$this->id."'";
$resql=$this->db->query($sql);
if ($resql)
{
if ($this->db->num_rows($resql))
{
$obj=$this->db->fetch_object($resql);
$nom = preg_replace("/[[:punct:]]/","",$obj->name);
$this->db->free();
$prefix = $this->genprefix($nom,4);
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE prefix_comm = '".$prefix."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
$obj=$this->db->fetch_object($resql);
$this->db->free($resql);
if (! $obj->nb)
{
$sql = "UPDATE ".MAIN_DB_PREFIX."societe set prefix_comm='".$prefix."' WHERE rowid='".$this->id."'";
if ( $this->db->query($sql) )
{
}
else
{
dol_print_error($this->db);
}
}
}
else
{
dol_print_error($this->db);
}
}
}
else
{
dol_print_error($this->db);
}
return $prefix;
}
/**
* Genere le prefix de la societe
*
* @param nom nom de la societe
* @param taille taille du prefix a retourner
* @param mot l'indice du mot a utiliser
*/
function genprefix($nom, $taille=4, $mot=0)
{
$retour = "";
$tab = explode(" ",$nom);
if ($mot < count($tab))
{
$prefix = strtoupper(substr($tab[$mot],0,$taille));
// On verifie que ce prefix n'a pas deja ete pris ...
$sql = "SELECT count(*) as nb FROM ".MAIN_DB_PREFIX."societe";
$sql.= " WHERE prefix_comm = '".$prefix."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
$obj=$this->db->fetch_object($resql);
if ($obj->nb)
{
$this->db->free();
$retour = $this->genprefix($nom,$taille,$mot+1);
}
else
{
$retour = $prefix;
}
}
}
return $retour;
}
/**
* \brief Define third party as a customer
* \return int <0 if KO, >0 if OK
*/ */
function set_as_client() function set_as_client()
{ {
@ -1071,11 +975,12 @@ class Societe extends CommonObject
} }
/** /**
* \brief Definit la societe comme un client * Definit la societe comme un client
* \param remise Valeur en % de la remise *
* \param note Note/Motif de modification de la remise * @param float $remise Valeur en % de la remise
* \param user Utilisateur qui definie la remise * @param string $note Note/Motif de modification de la remise
* \return int <0 si ko, >0 si ok * @param User $user Utilisateur qui definie la remise
* @return int <0 if KO, >0 if OK
*/ */
function set_remise_client($remise, $note, $user) function set_remise_client($remise, $note, $user)
{ {
@ -1210,6 +1115,7 @@ class Societe extends CommonObject
/** /**
* Return array of sales representatives * Return array of sales representatives
* *
* @param User $user Object user
* @return array Array of sales representatives of third party * @return array Array of sales representatives of third party
*/ */
function getSalesRepresentatives($user='') function getSalesRepresentatives($user='')
@ -1249,6 +1155,7 @@ class Societe extends CommonObject
* *
* @param int $price_level Level of price * @param int $price_level Level of price
* @param User $user Use making change * @param User $user Use making change
* @return int <0 if KO, >0 if OK
*/ */
function set_price_level($price_level, $user) function set_price_level($price_level, $user)
{ {
@ -1277,34 +1184,38 @@ class Societe extends CommonObject
} }
/** /**
* Add link to sales representative
* *
* * @param User $user Object user
* @param int $commid Id of user
* @return void
*/ */
function add_commercial($user, $commid) function add_commercial($user, $commid)
{ {
if ($this->id > 0 && $commid > 0) if ($this->id > 0 && $commid > 0)
{ {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux "; $sql = "DELETE FROM ".MAIN_DB_PREFIX."societe_commerciaux";
$sql .= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid; $sql.= " WHERE fk_soc = ".$this->id." AND fk_user =".$commid;
$this->db->query($sql); $this->db->query($sql);
$sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux "; $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_commerciaux";
$sql .= " ( fk_soc, fk_user )"; $sql.= " ( fk_soc, fk_user )";
$sql .= " VALUES (".$this->id.",".$commid.")"; $sql.= " VALUES (".$this->id.",".$commid.")";
if (! $this->db->query($sql) ) if (! $this->db->query($sql) )
{ {
dol_syslog(get_class($this)."::add_commercial Erreur"); dol_syslog(get_class($this)."::add_commercial Erreur");
} }
} }
} }
/** /**
* Add link to sales representative
* *
* * @param User $user Object user
* * @param int $commid Id of user
* @return void
*/ */
function del_commercial($user, $commid) function del_commercial($user, $commid)
{ {
@ -1317,7 +1228,6 @@ class Societe extends CommonObject
{ {
dol_syslog(get_class($this)."::del_commercial Erreur"); dol_syslog(get_class($this)."::del_commercial Erreur");
} }
} }
} }
@ -1325,9 +1235,9 @@ class Societe extends CommonObject
/** /**
* Return a link on thirdparty (with picto) * Return a link on thirdparty (with picto)
* *
* @param withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only) * @param int $withpicto Add picto into link (0=No picto, 1=Include picto with link, 2=Picto only)
* @param option Target of link ('', 'customer', 'prospect', 'supplier') * @param string $option Target of link ('', 'customer', 'prospect', 'supplier')
* @param maxlen Max length of text * @param int $maxlen Max length of text
* @return string String with URL * @return string String with URL
*/ */
function getNomUrl($withpicto=0,$option='',$maxlen=0) function getNomUrl($withpicto=0,$option='',$maxlen=0)
@ -1377,7 +1287,8 @@ class Societe extends CommonObject
/** /**
* Return label of status (activity, closed) * Return label of status (activity, closed)
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long *
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long
* @return string Libelle * @return string Libelle
*/ */
function getLibStatut($mode=0) function getLibStatut($mode=0)
@ -1387,8 +1298,9 @@ class Societe extends CommonObject
/** /**
* Renvoi le libelle d'un statut donne * Renvoi le libelle d'un statut donne
* @param statut Id statut *
* @param mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto * @param int $statut Id statut
* @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
* @return string Libelle du statut * @return string Libelle du statut
*/ */
function LibStatut($statut,$mode=0) function LibStatut($statut,$mode=0)
@ -1504,7 +1416,7 @@ class Societe extends CommonObject
/** /**
* Return list of contacts emails or mobile existing for third party * Return list of contacts emails or mobile existing for third party
* *
* @param mode 'email' or 'mobile' * @param string $mode 'email' or 'mobile'
* @return array Array of contacts emails or mobile * @return array Array of contacts emails or mobile
*/ */
function contact_property_array($mode='email') function contact_property_array($mode='email')
@ -1575,8 +1487,8 @@ class Societe extends CommonObject
/** /**
* Return property of contact from its id * Return property of contact from its id
* *
* @param rowid id of contact * @param int $rowid id of contact
* @param mode 'email' or 'mobile' * @param string $mode 'email' or 'mobile'
* @return string email of contact * @return string email of contact
*/ */
function contact_get_property($rowid,$mode) function contact_get_property($rowid,$mode)
@ -1637,6 +1549,8 @@ class Societe extends CommonObject
/** /**
* Load this->bank_account attribut * Load this->bank_account attribut
*
* @return int 1
*/ */
function load_ban() function load_ban()
{ {
@ -1649,7 +1563,11 @@ class Societe extends CommonObject
return 1; return 1;
} }
/**
* Check bank numbers
*
* @return int <0 if KO, >0 if OK
*/
function verif_rib() function verif_rib()
{ {
$this->load_ban(); $this->load_ban();
@ -1857,7 +1775,7 @@ class Societe extends CommonObject
* Peut etre identique a celui saisit ou genere automatiquement. * Peut etre identique a celui saisit ou genere automatiquement.
* A ce jour seule la generation automatique est implementee * A ce jour seule la generation automatique est implementee
* *
* @param type Type of thirdparty ('customer' or 'supplier') * @param string $type Type of thirdparty ('customer' or 'supplier')
* @return string Code compta si ok, 0 si aucun, <0 si ko * @return string Code compta si ok, 0 si aucun, <0 si ko
*/ */
function get_codecompta($type) function get_codecompta($type)
@ -1896,8 +1814,8 @@ class Societe extends CommonObject
/** /**
* Defini la societe mere pour les filiales * Defini la societe mere pour les filiales
* *
* @param id id compagnie mere a positionner * @param int $id id compagnie mere a positionner
* @return int <0 si ko, >0 si ok * @return int <0 if KO, >0 if OK
*/ */
function set_parent($id) function set_parent($id)
{ {
@ -1919,9 +1837,10 @@ class Societe extends CommonObject
} }
/** /**
* \brief Supprime la societe mere * Supprime la societe mere
* \param id id compagnie mere a effacer *
* \return int <0 si ko, >0 si ok * @param int $id id compagnie mere a effacer
* @return int <0 if KO, >0 if KO
*/ */
function remove_parent($id) function remove_parent($id)
{ {
@ -1944,7 +1863,8 @@ class Societe extends CommonObject
/** /**
* Returns if a profid sould be verified * Returns if a profid sould be verified
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) *
* @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* @return boolean true , false * @return boolean true , false
*/ */
function id_prof_verifiable($idprof) function id_prof_verifiable($idprof)
@ -2021,8 +1941,9 @@ class Societe extends CommonObject
/** /**
* Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...) * Verifie la validite d'un identifiant professionnel en fonction du pays de la societe (siren, siret, ...)
* @param idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm) *
* @param soc Objet societe * @param int $idprof 1,2,3,4 (Exemple: 1=siren,2=siret,3=naf,4=rcs/rm)
* @param Societe $soc Objet societe
* @return int <=0 if KO, >0 if OK * @return int <=0 if KO, >0 if OK
* TODO not in business class * TODO not in business class
*/ */
@ -2233,6 +2154,7 @@ class Societe extends CommonObject
/** /**
* Return if third party is a company (Business) or an end user (Consumer) * Return if third party is a company (Business) or an end user (Consumer)
*
* @return boolean true=is a company, false=a and user * @return boolean true=is a company, false=a and user
*/ */
function isACompany() function isACompany()
@ -2251,6 +2173,7 @@ class Societe extends CommonObject
/** /**
* Return if a country is inside the EEC (European Economic Community) * Return if a country is inside the EEC (European Economic Community)
*
* @return boolean true = pays inside EEC, false= pays outside EEC * @return boolean true = pays inside EEC, false= pays outside EEC
*/ */
function isInEEC() function isInEEC()
@ -2295,6 +2218,7 @@ class Societe extends CommonObject
/** /**
* Charge la liste des categories fournisseurs * Charge la liste des categories fournisseurs
*
* @return int 0 if success, <> 0 if error * @return int 0 if success, <> 0 if error
*/ */
function LoadSupplierCateg() function LoadSupplierCateg()
@ -2321,6 +2245,8 @@ class Societe extends CommonObject
/** /**
* Charge la liste des categories fournisseurs * Charge la liste des categories fournisseurs
*
* @param int $categorie_id Id of category
* @return int 0 if success, <> 0 if error * @return int 0 if success, <> 0 if error
*/ */
function AddFournisseurInCategory($categorie_id) function AddFournisseurInCategory($categorie_id)
@ -2343,8 +2269,8 @@ class Societe extends CommonObject
/** /**
* Create a third party into database from a member object * Create a third party into database from a member object
* *
* @param member Object member * @param Member $member Object member
* @param socname Name of third party to force * @param string $socname Name of third party to force
* @return int <0 if KO, id of created account if OK * @return int <0 if KO, id of created account if OK
*/ */
function create_from_member($member,$socname='') function create_from_member($member,$socname='')