From 72557437ef22a6176c495f25c5ef3af12385f084 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 10 Sep 2013 13:45:39 +0200 Subject: [PATCH] Checkstyle --- dev/codesniffer/ruleset.xml | 2 +- htdocs/comm/propal/class/propal.class.php | 5 +- .../class/bonprelevement.class.php | 4 +- htdocs/contact/class/contact.class.php | 20 +- htdocs/contact/fiche.php | 8 +- htdocs/core/class/commonobject.class.php | 11 +- htdocs/core/class/dolgraph.class.php | 2 +- htdocs/product/stock/replenish.php | 379 +++++++++--------- htdocs/product/stock/replenishorders.php | 266 ++++++------ 9 files changed, 350 insertions(+), 347 deletions(-) diff --git a/dev/codesniffer/ruleset.xml b/dev/codesniffer/ruleset.xml index 1f213782024..24cc4b46e7b 100755 --- a/dev/codesniffer/ruleset.xml +++ b/dev/codesniffer/ruleset.xml @@ -219,7 +219,7 @@ 0 - + 0 diff --git a/htdocs/comm/propal/class/propal.class.php b/htdocs/comm/propal/class/propal.class.php index df29aae8021..9b7ee59df98 100644 --- a/htdocs/comm/propal/class/propal.class.php +++ b/htdocs/comm/propal/class/propal.class.php @@ -287,7 +287,6 @@ class Propal extends CommonObject * par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,'',produit) * et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue) * - * @param int $propalid Id de la propale * @param string $desc Description de la ligne * @param double $pu_ht Prix unitaire * @param double $qty Quantite @@ -1603,9 +1602,7 @@ class Propal extends CommonObject $sql = "UPDATE ".MAIN_DB_PREFIX."propal"; $sql.= " SET fk_statut = ".$this->statut.","; - if (! empty ( $note )) { - $sql .= " note_private = '" . $this->db->escape ( $note ) . "',"; - } + if (! empty($note)) $sql.= " note_private = '".$this->db->escape($note)."',"; $sql.= " date_cloture=NULL, fk_user_cloture=NULL"; $sql.= " WHERE rowid = ".$this->id; diff --git a/htdocs/compta/prelevement/class/bonprelevement.class.php b/htdocs/compta/prelevement/class/bonprelevement.class.php index 54439aea9a3..0cae3d545f7 100644 --- a/htdocs/compta/prelevement/class/bonprelevement.class.php +++ b/htdocs/compta/prelevement/class/bonprelevement.class.php @@ -576,8 +576,8 @@ class BonPrelevement extends CommonObject /** * Get invoice list * - * @param $amounts If you want to get the amount of the order for each invoice - * @return array id of invoices + * @param int $amounts If you want to get the amount of the order for each invoice + * @return array Id of invoices */ private function getListInvoices($amounts=0) { diff --git a/htdocs/contact/class/contact.class.php b/htdocs/contact/class/contact.class.php index ae167593a52..9dcedd75daa 100644 --- a/htdocs/contact/class/contact.class.php +++ b/htdocs/contact/class/contact.class.php @@ -906,21 +906,16 @@ class Contact extends CommonObject } /** - * Retourne le libelle du statut du contact + * Return label of contact status * - * @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 + * @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 Label of contact status */ function getLibStatut($mode) { return $this->LibStatut($this->statut,$mode); } - function getLibStatutcontact() - { - return $this->LibStatutcontact($this->statut); - } - /** * Renvoi le libelle d'un statut donne * @@ -928,7 +923,7 @@ class Contact extends CommonObject * @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 */ - function LibStatut($statut) + function LibStatut($statut,$mode) { global $langs; @@ -977,12 +972,7 @@ class Contact extends CommonObject } - function LibStatutcontact($statut) - { - global $langs; - if ($statut==0) return ''.$langs->trans('Disabled').' '.img_picto($langs->trans('StatusContactDraftShort'),'statut0'); - else return ''.$langs->trans('Enabled').' '.img_picto($langs->trans('StatusContactValidatedShort'),'statut1'); - } + /** * Return translated label of Public or Private * diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index a4389294fb1..e044676a3bf 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2004 Benoit Mortier * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Franky Van Liedekerke @@ -739,7 +739,7 @@ else // Statut print ''.$langs->trans("Status").''; print ''; - print $object->getLibStatutcontact(); + print $object->getLibStatut(5); print ''; // Other attributes @@ -946,10 +946,10 @@ else print nl2br($object->note); print ''; - // Statut + // Statut print ''.$langs->trans("Status").''; print ''; - print $object->getLibStatutcontact(); + print $object->getLibStatut(5); print ''; print ''."\n"; // Other attributes diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index 43ddd03ae3d..9beabb153fd 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2006-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2010-2013 Juanjo Menent * Copyright (C) 2012 Christophe Battarel @@ -3223,16 +3223,23 @@ abstract class CommonObject print ''; } + /** + * Overwrite magic function to solve problem of cloning object that are kept as references + * + * @return void + */ function __clone() { // Force a copy of this->lines, otherwise it will point to same object. if (isset($this->lines) && is_array($this->lines)) { - for($i=0; $i < count($this->lines); $i++) + $nboflines=count($this->lines); + for($i=0; $i < $nboflines; $i++) { $this->lines[$i] = dol_clone($this->lines[$i]); } } } + } ?> diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index aa626fdb893..a0d63eea2fa 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -1,6 +1,6 @@ - * Copyright (c) 2004-2012 Laurent Destailleur + * Copyright (c) 2004-2013 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 diff --git a/htdocs/product/stock/replenish.php b/htdocs/product/stock/replenish.php index fbb6edf3bae..189e1d7ce70 100644 --- a/htdocs/product/stock/replenish.php +++ b/htdocs/product/stock/replenish.php @@ -235,37 +235,40 @@ if ($resql) { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&sall=' . $sall; $filters .= '&salert=' . $salert; - print_barre_liste($texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num - ); + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num + ); } else { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&fourn_id=' . $fourn_id; $filters .= (isset($type)?'&type=' . $type:''); $filters .= '&salert=' . $salert; - print_barre_liste($texte, - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num); + print_barre_liste( + $texte, + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num + ); } - echo '
', - '', - '', - '', - '', - '', - '', + print ''. + ''. + ''. + ''. + ''. + ''. + ''. ''; @@ -274,115 +277,128 @@ if ($resql) { $param .= '&sref=' . $sref; // Lignes des titres - echo '', + print ''. ''; - print_liste_field_titre($langs->trans('Ref'), - 'replenish.php', - 'p.ref', - $param, - '', - '', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Label'), - 'replenish.php', - 'p.label', - $param, - '', - '', - $sortfield, - $sortorder - ); - if (!empty($conf->service->enabled) && $type == 1) { - print_liste_field_titre($langs->trans('Duration'), - 'replenish.php', - 'p.duration', - $param, - '', - 'align="center"', - $sortfield, - $sortorder - ); + print_liste_field_titre( + $langs->trans('Ref'), + 'replenish.php', + 'p.ref', + $param, + '', + '', + $sortfield, + $sortorder + ); + print_liste_field_titre( + $langs->trans('Label'), + 'replenish.php', + 'p.label', + $param, + '', + '', + $sortfield, + $sortorder + ); + if (!empty($conf->service->enabled) && $type == 1) + { + print_liste_field_titre( + $langs->trans('Duration'), + 'replenish.php', + 'p.duration', + $param, + '', + 'align="center"', + $sortfield, + $sortorder + ); } - print_liste_field_titre($langs->trans('DesiredStock'), - 'replenish.php', - 'p.desiredstock', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - if ($conf->global->USE_VIRTUAL_STOCK) { + print_liste_field_titre( + $langs->trans('DesiredStock'), + 'replenish.php', + 'p.desiredstock', + $param, + '', + 'align="right"', + $sortfield, + $sortorder + ); + if ($conf->global->USE_VIRTUAL_STOCK) + { $stocklabel = $langs->trans('VirtualStock'); - } else { + } + else + { $stocklabel = $langs->trans('PhysicalStock'); } - print_liste_field_titre($stocklabel, - 'replenish.php', - 'stock_physique', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Ordered'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('StockToBuy'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - print_liste_field_titre($langs->trans('Supplier'), - 'replenish.php', - '', - $param, - '', - 'align="right"', - $sortfield, - $sortorder - ); - echo '', - '', + print_liste_field_titre( + $stocklabel, + 'replenish.php', + 'stock_physique', + $param, + '', + 'align="right"', + $sortfield, + $sortorder + ); + print_liste_field_titre( + $langs->trans('Ordered'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder + ); + print_liste_field_titre( + $langs->trans('StockToBuy'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder + ); + print_liste_field_titre( + $langs->trans('Supplier'), + 'replenish.php', + '', + $param, + '', + 'align="right"', + $sortfield, + $sortorder + ); + print ''. + ''. - // Lignes des champs de filtre - '', - '', - '', - ''. + ''. + ''. + ''; - if (!empty($conf->service->enabled) && $type == 1) { - echo ''; } - echo '', - '', - '', - '', - '', - ''. + ''. + ''. + ''. + ''. + '', + src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/searchclear.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'. + ''. ''; $prod = new Product($db); @@ -452,12 +468,12 @@ if ($resql) { } else { $picto = img_picto('', './img/no', '', 1); } - echo '', - '', - '', - '', + print ''. + ''. + ''. + ''. ''; if (!empty($conf->service->enabled) && $type == 1) { @@ -470,80 +486,81 @@ if ($resql) { } else { $duration = $objp->duration; } - echo ''; } - echo '', - '', - '', - ''. + ''. + ''. + '', - '', - '', + '" value="' . $stocktobuy . '" ' . $disabled . '>'. + ''. + ''. + ''. ''; } $i++; } $value = $langs->trans("CreateOrders"); - echo '
 
 
 ', - '', - '', - '', + // Lignes des champs de filtre + '
 '. + ''. + ''. + ''. '', - ' ', + if (!empty($conf->service->enabled) && $type == 1) + { + print ''. + ' '. ' ' . $langs->trans('AlertOnly') . '    ', - '', + print ' ' . $langs->trans('AlertOnly') . '    '. + ''. '', - '
', - $prod->getNomUrl(1, '', 16), - '' . $objp->label . '
'. + $prod->getNomUrl(1, '', 16). + '' . $objp->label . '', - $duration, + print ''. + $duration. '' . $objp->desiredstock . '', - $warning, $stock, - '', - '', - $ordered, ' ', $picto, - '', + print '' . $objp->desiredstock . ''. + $warning . $stock. + ''. + ''. + $ordered . ' ' . $picto. + ''. '', - '', - $form->select_product_fourn_price($prod->id, - 'fourn' . $i, - 1 - ), - ' '. + $form->select_product_fourn_price($prod->id, 'fourn'.$i, 1). + ' 
', - '', - '', - '
', - '', - '
', + print ''. + ''. + ''. + '
'. + ''. + '
'. '
'; - if ($num > $conf->liste_limit) { - if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) { + if ($num > $conf->liste_limit) + { + if ($sref || $snom || $sall || $salert || GETPOST('search', 'alpha')) + { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&sall=' . $sall; $filters .= '&salert=' . $salert; - print_barre_liste('', - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num, - 0, - '' - ); + print_barre_liste( + '', + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + 0, + '' + ); } else { $filters = '&sref=' . $sref . '&snom=' . $snom; $filters .= '&fourn_id=' . $fourn_id; $filters .= (isset($type)? '&type=' . $type : ''); $filters .= '&salert=' . $salert; - print_barre_liste('', - $page, - 'replenish.php', - $filters, - $sortfield, - $sortorder, - '', - $num, - 0, - '' - ); + print_barre_liste( + '', + $page, + 'replenish.php', + $filters, + $sortfield, + $sortorder, + '', + $num, + 0, + '' + ); } } $db->free($resql); -echo '