Browse Source

Fix phpcs

Laurent Destailleur 1 year ago
parent
commit
14d153923e

+ 58 - 20
dev/tools/apstats.php

@@ -110,7 +110,10 @@ exec($commandcheck, $output_arrtd, $resexectd);
 
 $arrayoflineofcode = array();
 $arraycocomo = array();
-$arrayofmetrics = array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0);
+$arrayofmetrics = array(
+	'proj'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0),
+	'dep'=>array('Bytes'=>0, 'Files'=>0, 'Lines'=>0, 'Blanks'=>0, 'Comments'=>0, 'Code'=>0, 'Complexity'=>0)
+);
 
 // Analyse $output_arrproj
 foreach (array('proj', 'dep') as $source) {
@@ -153,6 +156,15 @@ foreach (array('proj', 'dep') as $source) {
 			$arrayoflineofcode[$source][$reg[1]]['Complexity'] = $reg[7];
 		}
 	}
+
+	foreach ($arrayoflineofcode[$source] as $key => $val) {
+		$arrayofmetrics[$source]['Files'] += $val['Files'];
+		$arrayofmetrics[$source]['Lines'] += $val['Lines'];
+		$arrayofmetrics[$source]['Blanks'] += $val['Blanks'];
+		$arrayofmetrics[$source]['Comments'] += $val['Comments'];
+		$arrayofmetrics[$source]['Code'] += $val['Code'];
+		$arrayofmetrics[$source]['Complexity'] += $val['Complexity'];
+	}
 }
 
 
@@ -165,6 +177,8 @@ $html .= '
 <style>
 body {
 	margin: 10px;
+	margin-left: 50px;
+	margin-right: 50px;
 }
 
 h1 {
@@ -176,12 +190,24 @@ h1 {
 	margin-bottom: 5px;
 }
 
+header {
+	text-align: center;
+}
 header, section.chapter {
 	margin-top: 10px;
 	margin-bottom: 10px;
 	padding: 10px;
 }
 
+table {
+	border-collapse: collapse;
+}
+th,td {
+	padding-top: 5px;
+	padding-bottom: 5px;
+	padding-left: 10px;
+	padding-right: 10px;
+}
 .left {
 	text-align: left;
 }
@@ -191,6 +217,12 @@ header, section.chapter {
 .opacity {
 	opacity: 0.5;
 }
+.centpercent {
+	width: 100%;
+}
+.trgroup {
+	background-color: #EEE;
+}
 </style>';
 
 $html .= '<body>';
@@ -203,9 +235,10 @@ $html .= '</header>';
 
 $html .= '<section class="chapter">';
 $html .= '<h2>Lines of code</h2>';
-$html .= '<table>';
+$html .= '<table class="centpercent">';
 $html .= '<tr class="loc">';
 $html .= '<th class="left">Language</td>';
+$html .= '<th class="right">Bytes</th>';
 $html .= '<th class="right">Files</th>';
 $html .= '<th class="right">Lines</th>';
 $html .= '<th class="right">Blanks</th>';
@@ -214,42 +247,47 @@ $html .= '<th class="right">Code</th>';
 //$html .= '<td class="right">'.$val['Complexity'].'</td>';
 $html .= '</th>';
 foreach (array('proj', 'dep') as $source) {
+	$html .= '<tr class="trgroup" id="source'.$source.'">';
 	if ($source == 'proj') {
-		$html .= '<tr><td colspan="7">Written by project team only:</td></tr>';
+		$html .= '<td>All files from project only</td>';
 	} elseif ($source == 'dep') {
-		$html .= '<tr><td colspan="7">Dependencies:</td></tr>';
+		$html .= '<td>All files from dependencies</td>';
 	}
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Bytes'].'</td>';
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Files'].'</td>';
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Lines'].'</td>';
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Blanks'].'</td>';
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Comments'].'</td>';
+	$html .= '<td class="right">'.$arrayofmetrics[$source]['Code'].'</td>';
+	$html .= '<td>See detail per file type...</td>';
+	$html .= '</tr>';
 	foreach ($arrayoflineofcode[$source] as $key => $val) {
 		$html .= '<tr class="loc source'.$source.' language'.str_replace(' ', '', $key).'">';
 		$html .= '<td>'.$key.'</td>';
+		$html .= '<td class="right"></td>';
 		$html .= '<td class="right">'.$val['Files'].'</td>';
 		$html .= '<td class="right">'.$val['Lines'].'</td>';
 		$html .= '<td class="right">'.$val['Blanks'].'</td>';
 		$html .= '<td class="right">'.$val['Comments'].'</td>';
 		$html .= '<td class="right">'.$val['Code'].'</td>';
 		//$html .= '<td class="right">'.$val['Complexity'].'</td>';
+		$html .= '<td>graph here...</td>';
 		$html .= '</tr>';
-		$arrayofmetrics['Files'] += $val['Files'];
-		$arrayofmetrics['Lines'] += $val['Lines'];
-		$arrayofmetrics['Blanks'] += $val['Blanks'];
-		$arrayofmetrics['Comments'] += $val['Comments'];
-		$arrayofmetrics['Code'] += $val['Code'];
-		$arrayofmetrics['Complexity'] += $val['Complexity'];
 	}
 }
 
-$html .= '<tr>';
-$html .= '<tr><td colspan="7">Total:</td></tr>';
-$html .= '<tr>';
-$html .= '<td class="right">'.$arrayofmetrics['Bytes'].' octets</td>';
-$html .= '<td class="right">'.$arrayofmetrics['Files'].'</td>';
-$html .= '<td class="right">'.$arrayofmetrics['Lines'].'</td>';
-$html .= '<td class="right">'.$arrayofmetrics['Blanks'].'</td>';
-$html .= '<td class="right">'.$arrayofmetrics['Comments'].'</td>';
-$html .= '<td class="right">'.$arrayofmetrics['Code'].'</td>';
+$html .= '<tr class="trgroup">';
+$html .= '<td class="left">Total</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Bytes'] + $arrayofmetrics['dep']['Bytes']).'</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Files'] + $arrayofmetrics['dep']['Files']).'</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Lines'] + $arrayofmetrics['dep']['Lines']).'</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Blanks'] + $arrayofmetrics['dep']['Blanks']).'</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Comments'] + $arrayofmetrics['dep']['Comments']).'</td>';
+$html .= '<td class="right">'.($arrayofmetrics['proj']['Code'] + $arrayofmetrics['dep']['Code']).'</td>';
 //$html .= '<td>'.$arrayofmetrics['Complexity'].'</td>';
+$html .= '<td></td>';
 $html .= '</tr>';
-$html .= '<table>';
+$html .= '</table>';
 
 $html .= '</section>';
 

+ 1 - 1
htdocs/langs/en_US/main.lang

@@ -949,7 +949,7 @@ BulkActions=Bulk actions
 ClickToShowHelp=Click to show tooltip help
 WebSite=Website
 WebSites=Websites
-WebSiteAccounts=Website accounts
+WebSiteAccounts=Web access accounts
 ExpenseReport=Expense report
 ExpenseReports=Expense reports
 HR=HR

+ 10 - 4
htdocs/resource/class/dolresource.class.php

@@ -71,12 +71,19 @@ class Dolresource extends CommonObject
 	public $element_type;
 	public $busy;
 	public $mandatory;
+	public $fulldayevent;
+
 	/**
 	 * @var int ID
 	 */
 	public $fk_user_create;
 	public $tms = '';
 
+	/**
+	 * Used by fetch_element_resource() to return an object
+	 */
+	public $objelement;
+
 	/**
 	 * @var array	Cache of type of resources. TODO Use $conf->cache['type_of_resources'] instead
 	 */
@@ -361,7 +368,7 @@ class Dolresource extends CommonObject
 
 	// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
 	/**
-	 *    Load data of link in memory from database
+	 *    Load data of resource links in memory from database
 	 *
 	 *    @param      int	$id         Id of link element_resources
 	 *    @return     int         		<0 if KO, >0 if OK
@@ -369,7 +376,6 @@ class Dolresource extends CommonObject
 	public function fetch_element_resource($id)
 	{
 		// phpcs:enable
-		global $langs;
 		$sql = "SELECT";
 		$sql .= " t.rowid,";
 		$sql .= " t.resource_id,";
@@ -398,9 +404,9 @@ class Dolresource extends CommonObject
 				$this->mandatory = $obj->mandatory;
 				$this->fk_user_create = $obj->fk_user_create;
 
-				if ($obj->resource_id && $obj->resource_type) {
+				/*if ($obj->resource_id && $obj->resource_type) {
 					$this->objresource = fetchObjectByElement($obj->resource_id, $obj->resource_type);
-				}
+				}*/
 				if ($obj->element_id && $obj->element_type) {
 					$this->objelement = fetchObjectByElement($obj->element_id, $obj->element_type);
 				}

+ 1 - 1
htdocs/stripe/class/stripe.class.php

@@ -1093,7 +1093,7 @@ class Stripe extends CommonObject
 						}
 					} catch (Exception $e) {
 						$sepa = null;
-						$this->error = 'Stripe error: '.getMessage().'. Check the BAN information.';
+						$this->error = 'Stripe error: '.$e->getMessage().'. Check the BAN information.';
 						dol_syslog($this->error, LOG_WARNING);	// Error from Stripe, so a warning on Dolibarr
 					}
 				}