Qual: Remove tons of codesniffer errors and warnings.

This commit is contained in:
Laurent Destailleur 2013-07-07 13:14:32 +02:00
parent cbc0570bc3
commit 2bc650bf61
17 changed files with 107 additions and 95 deletions

View File

@ -268,7 +268,7 @@ class Adherent extends CommonObject
// Clean parameters
$this->import_key = trim($this->import_key);
// Check parameters
if (! empty($conf->global->ADHERENT_MAIL_REQUIRED) && ! isValidEMail($this->email))
{
@ -1006,18 +1006,18 @@ class Adherent extends CommonObject
* Method to load member from its name
*
* @param string $firstname Firstname
** @param string $lastname Lastname
* @param string $lastname Lastname
* @return void
*/
function fetch_name($firstname,$lastname)
{
global $conf;
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."adherent";
$sql.= " WHERE firstname='".$this->db->escape($firstname)."'";
$sql.= " AND lastname='".$this->db->escape($lastname)."'";
$sql.= " AND entity = ".$conf->entity;
$resql=$this->db->query($sql);
if ($resql)
{
@ -1032,7 +1032,7 @@ class Adherent extends CommonObject
dol_print_error($this->db);
}
}
/**
* Load member from database
*
@ -1541,7 +1541,7 @@ class Adherent extends CommonObject
{
global $langs;
$langs->load("dict");
$code=(! empty($this->civilite_id)?$this->civilite_id:(! empty($this->civility_id)?$this->civility_id:''));
if (empty($code)) return '';
return $langs->getLabelFromKey($this->db, "Civility".$code, "c_civilite", "code", "civilite", $code);

View File

@ -2076,7 +2076,7 @@ class ContratLigne
/**
* Load elements linked to contract (only intervention for the moment)
*
* @param User $user Objet type
* @param string $type Object type
* @return array $elements array of linked elements
*/
function get_element_list($type)

View File

@ -289,6 +289,9 @@ abstract class CommonInvoice extends CommonObject
}
}
/**
* Parent class of all other business classes for details of elements (invoices, contracts, proposals, orders, ...)
*/
abstract class CommonInvoiceLine extends CommonObject
{
}

View File

@ -2746,7 +2746,7 @@ abstract class CommonObject
* @param string $seller Object of seller third party
* @param string $buyer Object of buyer third party
* @param string $selected Object line selected
* @param object $extrafieldline Object of extrafield line attribute
* @param object $extrafieldsline Object of extrafield line attribute
* @return void
*/
function printObjectLine($action,$line,$var,$num,$i,$dateSelector,$seller,$buyer,$selected=0,$extrafieldsline=0)
@ -3013,9 +3013,10 @@ abstract class CommonObject
/**
* get Margin info
*
* @param string $force_price
* @return multitype:number string NULL
* @param string $force_price True of not
* @return mixed Array with info
*/
function getMarginInfos($force_price=false) {
global $conf;

View File

@ -79,7 +79,7 @@ class dolprintIPP
/**
* Print selected file
*
*
* @param string $file file
* @param string $module module
*
@ -181,6 +181,8 @@ class dolprintIPP
/**
* Get printer detail
*
* @param string $uri URI
* @return array List of attributes
*/
function get_printer_detail($uri)
{

View File

@ -1372,7 +1372,7 @@ class Form
$objp->remise = $objp2->remise;
$objp->price_by_qty_rowid = $objp2->rowid;
$this->_construct_product_list_option($objp, $opt, $optJson, 0, $selected);
$this->constructProductListOption($objp, $opt, $optJson, 0, $selected);
$j++;
@ -1386,7 +1386,7 @@ class Form
}
else
{
$this->_construct_product_list_option($objp, $opt, $optJson, $price_level, $selected);
$this->constructProductListOption($objp, $opt, $optJson, $price_level, $selected);
// Add new entry
// "key" value of json key array is used by jQuery automatically as selected value
// "label" value of json key array is used by jQuery automatically as text for combo box
@ -1411,16 +1411,16 @@ class Form
}
/**
* _construct_product_list_option
* constructProductListOption
*
* @param resultset &$objp Resultset of fetch
* @param string $opt Option
* @param string $optJson Option
* @param resultset &$objp Resultset of fetch
* @param string &$opt Option
* @param string &$optJson Option
* @param int $price_level Price level
* @param string $selected Preselected value
* @return
* @return void
*/
private function _construct_product_list_option(&$objp, &$opt, &$optJson, $price_level, $selected)
private function constructProductListOption(&$objp, &$opt, &$optJson, $price_level, $selected)
{
global $langs,$conf,$user,$db;
@ -1475,7 +1475,7 @@ class Form
$sql.= " ORDER BY date_price";
$sql.= " DESC LIMIT 1";
dol_syslog(get_class($this)."::_construct_product_list_option search price for level '.$price_level.' sql=".$sql);
dol_syslog(get_class($this)."::constructProductListOption search price for level '.$price_level.' sql=".$sql);
$result2 = $this->db->query($sql);
if ($result2)
{

View File

@ -45,20 +45,22 @@ class FormProjets
/**
* Show a combo list with projects qualified for a third party
*
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id project preselected
* @param string $htmlname Nom de la zone html
* @param int $maxlength Maximum length of label
* @return int Nbre of project if OK, <0 if KO
* @param int $socid Id third party (-1=all, 0=only projects not linked to a third party, id=projects not linked or linked to third party id)
* @param int $selected Id project preselected
* @param string $htmlname Nom de la zone html
* @param int $maxlength Maximum length of label
* @param int $option_only Option only
* @param int $show_empty Add an empty line
* @return int Nber of project if OK, <0 if KO
*/
function select_projects($socid=-1, $selected='', $htmlname='projectid', $maxlength=16, $option_only=0, $show_empty=1)
{
{
global $user,$conf,$langs;
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
$out='';
$hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
@ -146,7 +148,7 @@ class FormProjets
$out.= '</select>';
}
print $out;
$this->db->free($resql);
return $num;
}
@ -156,16 +158,16 @@ class FormProjets
return -1;
}
}
/**
* Build Select List of element associable to a project
*
* @param TableName Table of the element to update
* @return string The HTML select list of element
* @param string $table_element Table of the element to update
* @return string The HTML select list of element
*/
function select_element($table_element)
{
$projectkey="fk_projet";
switch ($table_element)
{
@ -186,16 +188,16 @@ class FormProjets
$sql = "SELECT rowid, ref";
break;
}
$sql.= " FROM ".MAIN_DB_PREFIX.$table_element;
$sql.= " WHERE ".$projectkey." is null";
if (!empty($this->societe->id)) {
$sql.= " AND fk_soc=".$this->societe->id;
}
$sql.= " ORDER BY ref DESC";
dol_syslog(get_class($this).'::select_element sql='.$sql,LOG_DEBUG);
$resql=$this->db->query($sql);
if ($resql)
{
@ -213,10 +215,10 @@ class FormProjets
$sellist .='</select>';
}
return $sellist ;
$this->db->free($resql);
}
}
}

View File

@ -417,8 +417,7 @@ abstract class Stats
* Renvoie le montant moyen par mois pour une annee donnee
*
* @param int $year Year
* @param string $sql SQL
* @param int $format 0=Label of absiss is a translated text, 1=Label of absiss is a number
* @param string $sql SQL
* @return array
*/
function _getAverageByMonth($year, $sql)

View File

@ -27,9 +27,10 @@
*
* @param string $url URL to call.
* @param string $postorget 'post' = POST, 'get='GET'
* @param string $param Paraemeters of URL (x=value1&y=value2)
* @return array returns an associtive array containing the response from the server.
*/
function getURLContent($url,$postorget='GET',$param)
function getURLContent($url,$postorget='GET',$param='')
{
//declaring of global variables
global $conf, $langs;
@ -58,7 +59,7 @@ function getURLContent($url,$postorget='GET',$param)
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, empty($conf->global->MAIN_USE_CONNECT_TIMEOUT)?5:$conf->global->MAIN_USE_CONNECT_TIMEOUT);
curl_setopt($ch, CURLOPT_TIMEOUT, empty($conf->global->MAIN_USE_RESPONSE_TIMEOUT)?30:$conf->global->MAIN_USE_RESPONSE_TIMEOUT);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
if ($postorget == 'POST') curl_setopt($ch, CURLOPT_POST, 1);
else curl_setopt($ch, CURLOPT_POST, 0);
@ -82,7 +83,7 @@ function getURLContent($url,$postorget='GET',$param)
$rep['content']=$response;
$rep['curl_error_no']='';
$rep['curl_error_msg']='';
dol_syslog("getURLContent response=".$response);
if (curl_errno($ch))

View File

@ -58,7 +58,7 @@ $(document).ready(function () {
<input type="hidden" name="dol_no_mouse_hover" id="dol_no_mouse_hover" value="<?php echo $dol_no_mouse_hover; ?>" />
<input type="hidden" name="dol_use_jmobile" id="dol_use_jmobile" value="<?php echo $dol_use_jmobile; ?>" />
<table class="login_table_title" summary="<?php echo dol_escape_htmltag($title); ?>" cellpadding="0" cellspacing="0" border="0" align="center">
<table class="login_table_title" summary="<?php echo dol_escape_htmltag($title); ?>" align="center">
<tr class="vmenu"><td align="center"><?php echo $title; ?></td></tr>
</table>
<br>

View File

@ -45,7 +45,7 @@ $(document).ready(function () {
<input type="hidden" name="token" value="<?php echo $_SESSION['newtoken']; ?>">
<input type="hidden" name="action" value="buildnewpassword">
<table class="login_table_title" summary="<?php echo dol_escape_htmltag($title); ?>" cellpadding="0" cellspacing="0" border="0" align="center">
<table class="login_table_title" summary="<?php echo dol_escape_htmltag($title); ?>" align="center">
<tr class="vmenu"><td align="center"><?php echo $title; ?></td></tr>
</table>
<br>

View File

@ -533,8 +533,9 @@ class Fichinter extends CommonObject
/**
* Return clicable name (with picto eventually)
*
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @return string String with URL
* @param int $withpicto 0=_No picto, 1=Includes the picto in the linkn, 2=Picto only
* @param string $option Options
* @return string String with URL
*/
function getNomUrl($withpicto=0,$option='')
{
@ -659,8 +660,9 @@ class Fichinter extends CommonObject
/**
* Delete intervetnion
*
* @param User $user Object user who delete
* @return int <0 if KO, >0 if OK
* @param User $user Object user who delete
* @param int $notrigger Disable trigger
* @return int <0 if KO, >0 if OK
*/
function delete($user, $notrigger=0)
{
@ -830,8 +832,8 @@ class Fichinter extends CommonObject
* Define the label of the contract
*
* @param User $user Object user who modify
* @param string $description description
* @return int <0 if ko, >0 if ok
* @param int $contractid Description
* @return int <0 if ko, >0 if ok
*/
function set_contrat($user, $contratid)
{

View File

@ -33,6 +33,9 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
<input type="hidden" name="action" value="add">
<input type="hidden" name="type" value="0">
<input type="hidden" name="canvas" value="<?php echo $canvas; ?>">
<?php if (empty($conf->stock->enabled)) { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
<?php } ?>
<table class="border allwidth">
@ -61,8 +64,6 @@ $statutarray=array('1' => $langs->trans("OnSell"), '0' => $langs->trans("NotOnSe
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
<input name="seuil_stock_alerte" size="4" value="<?php echo $object->seuil_stock_alerte; ?>">
</td></tr>
<?php } else { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
<?php } ?>
<tr><td><?php echo $langs->trans("Nature"); ?></td><td>

View File

@ -33,6 +33,9 @@ dol_htmloutput_errors($object->error,$object->errors);
<input type="hidden" name="action" value="update">
<input type="hidden" name="id" value="<?php echo $object->id; ?>">
<input type="hidden" name="canvas" value="<?php echo $object->canvas; ?>">
<?php if (empty($conf->stock->enabled)) { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
<?php } ?>
<table class="border allwidth">
@ -61,8 +64,6 @@ dol_htmloutput_errors($object->error,$object->errors);
<tr><td><?php echo $langs->trans("StockLimit"); ?></td><td>
<input name="seuil_stock_alerte" size="4" value="<?php echo $object->seuil_stock_alerte; ?>">
</td></tr>
<?php } else { ?>
<input name="seuil_stock_alerte" type="hidden" value="0">
<?php } ?>
<tr><td><?php echo $langs->trans("Nature"); ?></td><td>

View File

@ -53,7 +53,7 @@ class Project extends CommonObject
var $statuts_short;
var $statuts;
var $oldcopy;
/**
* Constructor
@ -147,7 +147,7 @@ class Project extends CommonObject
dol_syslog(get_class($this)."::create error -2 " . $this->error, LOG_ERR);
$error++;
}
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@ -225,7 +225,7 @@ class Project extends CommonObject
}
// End call triggers
}
//Update extrafield
if (!$error) {
if (empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) // For avoid conflicts if trigger used
@ -478,10 +478,10 @@ class Project extends CommonObject
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task_extrafields";
$sql.= " WHERE fk_object IN (SELECT rowid FROM " . MAIN_DB_PREFIX . "projet_task WHERE fk_projet=" . $this->id . ")";
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_task";
$sql.= " WHERE fk_projet=" . $this->id;
@ -493,13 +493,13 @@ class Project extends CommonObject
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
$sql = "DELETE FROM " . MAIN_DB_PREFIX . "projet_extrafields";
$sql.= " WHERE fk_object=" . $this->id;
dol_syslog(get_class($this) . "::delete sql=" . $sql, LOG_DEBUG);
$resql = $this->db->query($sql);
if ($resql)
{
// We remove directory
@ -1277,20 +1277,19 @@ class Project extends CommonObject
}
return $result;
}
/**
* Clean task not linked to a parent
*
* @param DoliDB $db Database handler
* @return int Nb of records deleted
*/
function clean_orphelins()
{
$nb=0;
// There is orphelins. We clean that
$listofid=array();
// Get list of id in array listofid
$sql='SELECT rowid FROM '.MAIN_DB_PREFIX.'projet_task';
$resql = $this->db->query($sql);
@ -1309,22 +1308,22 @@ class Project extends CommonObject
{
dol_print_error($this->db);
}
if (count($listofid))
{
// Removed orphelins records
print 'Some orphelins were found and restored to be parents so records are visible again: ';
print join(',',$listofid);
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task";
$sql.= " SET fk_task_parent = 0";
$sql.= " WHERE fk_task_parent NOT IN (".join(',',$listofid).")";
$resql = $this->db->query($sql);
if ($resql)
{
$nb=$this->db->affected_rows($sql);
return $nb;
}
else
@ -1333,19 +1332,19 @@ class Project extends CommonObject
}
}
}
/**
* Associate element to a project
*
* @param TableName Table of the element to update
* @param ElementSelectId Key-rowid of the line of the element to update
* @return int 1 if OK or < 0 if KO
* @param string $TableName Table of the element to update
* @param int $ElementSelectId Key-rowid of the line of the element to update
* @return int 1 if OK or < 0 if KO
*/
function update_element($TableName, $ElementSelectId)
{
$sql="UPDATE ".MAIN_DB_PREFIX.$TableName;
if ($TableName=="actioncomm")
{
$sql.= " SET fk_project=".$this->id;
@ -1356,17 +1355,17 @@ class Project extends CommonObject
$sql.= " SET fk_projet=".$this->id;
$sql.= " WHERE rowid=".$ElementSelectId;
}
dol_syslog(get_class($this)."::update_element sql=" . $sql, LOG_DEBUG);
$resql=$this->db->query($sql);
if (!$resql) {
$this->error=$this->db->lasterror();
$this->error=$this->db->lasterror();
dol_syslog(get_class($this)."::update_element error : " . $this->error, LOG_ERR);
return -1;
}else {
return 1;
}
}
}

View File

@ -139,12 +139,13 @@ class AdherentTest extends PHPUnit_Framework_TestCase
return $localobject->id;
}
/**
* testAdherentCreate
*
* @return void
*
* @param int $fk_adherent_type Id type of member
* @return int
*
* @depends testAdherentTypeCreate
* The depends says test is run only if previous is ok
*/

View File

@ -221,8 +221,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$facid=$localobject1a->create($user);
$localobject1a->addline($facid, 'Line 1', 6.36, 15, 21); // This include update_price
print __METHOD__." id=".$facid." total_ttc=".$localobject1a->total_ttc."\n";
$this->assertEquals( 95.40, $localobject1a->total_ht);
$this->assertEquals( 20.03, $localobject1a->total_tva);
$this->assertEquals(95.40, $localobject1a->total_ht);
$this->assertEquals(20.03, $localobject1a->total_tva);
$this->assertEquals(115.43, $localobject1a->total_ttc);
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
@ -233,8 +233,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$facid=$localobject1b->create($user);
$localobject1b->addline($facid, 'Line 1', 6.36, 15, 21); // This include update_price
print __METHOD__." id=".$facid." total_ttc=".$localobject1b->total_ttc."\n";
$this->assertEquals( 95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht');
$this->assertEquals( 20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva');
$this->assertEquals(95.40, $localobject1b->total_ht, 'testFactureAddLine1 total_ht');
$this->assertEquals(20.03, $localobject1b->total_tva, 'testFactureAddLine1 total_tva');
$this->assertEquals(115.43, $localobject1b->total_ttc, 'testFactureAddLine1 total_ttc');
}
@ -264,8 +264,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$localobject2->addline($facid, 'Line 2', 6.36, 5, 21);
$localobject2->addline($facid, 'Line 3', 6.36, 5, 21);
print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
$this->assertEquals( 95.40, $localobject2->total_ht);
$this->assertEquals( 20.04, $localobject2->total_tva);
$this->assertEquals(95.40, $localobject2->total_ht);
$this->assertEquals(20.04, $localobject2->total_tva);
$this->assertEquals(115.44, $localobject2->total_ttc);
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
@ -278,8 +278,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$localobject2->addline($facid, 'Line 2', 6.36, 5, 21);
$localobject2->addline($facid, 'Line 3', 6.36, 5, 21);
print __METHOD__." id=".$facid." total_ttc=".$localobject2->total_ttc."\n";
$this->assertEquals( 95.40, $localobject2->total_ht);
$this->assertEquals( 20.03, $localobject2->total_tva);
$this->assertEquals(95.40, $localobject2->total_ht);
$this->assertEquals(20.03, $localobject2->total_tva);
$this->assertEquals(115.43, $localobject2->total_ttc);
}
@ -311,8 +311,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$localobject3->addline($facid, 'Line 4', 6.36, 3, 21);
$localobject3->addline($facid, 'Line 5', 6.36, 3, 21);
print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
$this->assertEquals( 95.40, $localobject3->total_ht);
$this->assertEquals( 20.05, $localobject3->total_tva);
$this->assertEquals(95.40, $localobject3->total_ht);
$this->assertEquals(20.05, $localobject3->total_tva);
$this->assertEquals(115.45, $localobject3->total_ttc);
// With option MAIN_ROUNDOFTOTAL_NOT_TOTALOFROUND = 1
@ -327,8 +327,8 @@ class FactureTestRounding extends PHPUnit_Framework_TestCase
$localobject3->addline($facid, 'Line 4', 6.36, 3, 21);
$localobject3->addline($facid, 'Line 5', 6.36, 3, 21);
print __METHOD__." id=".$facid." total_ttc=".$localobject3->total_ttc."\n";
$this->assertEquals( 95.40, $localobject3->total_ht);
$this->assertEquals( 20.03, $localobject3->total_tva);
$this->assertEquals(95.40, $localobject3->total_ht);
$this->assertEquals(20.03, $localobject3->total_tva);
$this->assertEquals(115.43, $localobject3->total_ttc);
}