Fix phpcs

This commit is contained in:
Laurent Destailleur 2021-03-04 19:20:16 +01:00
parent 525d643915
commit c044b43b66
6 changed files with 614 additions and 676 deletions

View File

@ -1,4 +1,6 @@
#!/bin/sh #!/bin/sh
# To install this precommit file: TODO
# To run the fix manually: cd ~/git/dolibarr; phpcbf -s -p -d memory_limit=-1 --extensions=php --colors --tab-width=4 --standard=dev/setup/codesniffer/ruleset.xml --encoding=utf-8 --runtime-set ignore_warnings_on_exit true fileordir
PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"` PROJECT=`php -r "echo dirname(dirname(dirname(realpath('$0'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php` STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`

View File

@ -643,7 +643,6 @@ if ($id) {
print '<tr><td>'.$langs->trans("DateStartPeriod")."</td><td>"; print '<tr><td>'.$langs->trans("DateStartPeriod")."</td><td>";
print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1); print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
print "</td></tr>"; print "</td></tr>";
} else { } else {
print "<tr>"; print "<tr>";
print '<td>' . $langs->trans("DateStartPeriod") . '</td><td>'; print '<td>' . $langs->trans("DateStartPeriod") . '</td><td>';
@ -651,7 +650,6 @@ if ($id) {
print '</td></tr>'; print '</td></tr>';
} }
if ($action == 'edit') { if ($action == 'edit') {
print '<tr><td>'.$langs->trans("DateEndPeriod")."</td><td>"; print '<tr><td>'.$langs->trans("DateEndPeriod")."</td><td>";
print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1); print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1);
@ -801,8 +799,7 @@ if ($id) {
$totalpaye += $objp->amount; $totalpaye += $objp->amount;
$i++; $i++;
} }
} } else {
else {
print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>'; print '<tr class="oddeven"><td><span class="opacitymedium">'.$langs->trans("None").'</span></td>';
print '<td></td><td></td><td></td><td></td>'; print '<td></td><td></td><td></td><td></td>';
print '</tr>'; print '</tr>';
@ -821,8 +818,7 @@ if ($id) {
print '</div>'; print '</div>';
$db->free($resql); $db->free($resql);
} } else {
else {
dol_print_error($db); dol_print_error($db);
} }

View File

@ -126,8 +126,7 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
// Validate parametres // Validate parametres
if (!$this->datepaye) if (!$this->datepaye) {
{
$this->error = 'ErrorBadValueForParameterCreatePaymentSalary'; $this->error = 'ErrorBadValueForParameterCreatePaymentSalary';
return -1; return -1;
} }
@ -144,8 +143,7 @@ class PaymentSalary extends CommonObject
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
$totalamount = 0; $totalamount = 0;
foreach ($this->amounts as $key => $value) // How payment is dispatch foreach ($this->amounts as $key => $value) { // How payment is dispatch
{
$newvalue = price2num($value, 'MT'); $newvalue = price2num($value, 'MT');
$this->amounts[$key] = $newvalue; $this->amounts[$key] = $newvalue;
$totalamount += $newvalue; $totalamount += $newvalue;
@ -190,13 +188,11 @@ class PaymentSalary extends CommonObject
$remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
if ($remaintopay == 0) { if ($remaintopay == 0) {
$result = $contrib->set_paid($user); $result = $contrib->set_paid($user);
} } else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing.");
} }
} }
} }
} } else {
else {
$error++; $error++;
} }
} }

View File

@ -124,8 +124,7 @@ class Salary extends CommonObject
$this->note = trim($this->note); $this->note = trim($this->note);
// Check parameters // Check parameters
if (empty($this->fk_user) || $this->fk_user < 0) if (empty($this->fk_user) || $this->fk_user < 0) {
{
$this->error = 'ErrorBadParameter'; $this->error = 'ErrorBadParameter';
return -1; return -1;
} }
@ -155,39 +154,32 @@ class Salary extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG); dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
// Update extrafield // Update extrafield
if (!$error) if (!$error) {
{ if (!$error) {
if (!$error)
{
$result = $this->insertExtraFields(); $result = $this->insertExtraFields();
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
} }
} }
} }
if (!$notrigger) if (!$notrigger) {
{
// Call trigger // Call trigger
$result = $this->call_trigger('salary_MODIFY', $user); $result = $this->call_trigger('salary_MODIFY', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} }
if (!$error) if (!$error) {
{
$this->db->commit(); $this->db->commit();
return 1; return 1;
} } else {
else {
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
} }
@ -233,10 +225,8 @@ class Salary extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG); dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if ($resql) if ($resql) {
{ if ($this->db->num_rows($resql)) {
if ($this->db->num_rows($resql))
{
$obj = $this->db->fetch_object($resql); $obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid; $this->id = $obj->rowid;
@ -268,8 +258,7 @@ class Salary extends CommonObject
$this->db->free($resql); $this->db->free($resql);
return 1; return 1;
} } else {
else {
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
@ -312,8 +301,7 @@ class Salary extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG); dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
if (!$resql) if (!$resql) {
{
$this->error = "Error ".$this->db->lasterror(); $this->error = "Error ".$this->db->lasterror();
return -1; return -1;
} }
@ -371,18 +359,15 @@ class Salary extends CommonObject
$this->paye = trim($this->paye); $this->paye = trim($this->paye);
// Check parameters // Check parameters
if (!$this->label) if (!$this->label) {
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3; return -3;
} }
if ($this->fk_user < 0 || $this->fk_user == '') if ($this->fk_user < 0 || $this->fk_user == '') {
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4; return -4;
} }
if ($this->amount < 0 || $this->amount == '') if ($this->amount < 0 || $this->amount == '') {
{
$this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount")); $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5; return -5;
} }
@ -440,19 +425,15 @@ class Salary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG); dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salary"); $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salary");
if ($this->id > 0) if ($this->id > 0) {
{
// Update extrafield // Update extrafield
if (!$error) { if (!$error) {
if (!$error) if (!$error) {
{
$result = $this->insertExtraFields(); $result = $this->insertExtraFields();
if ($result < 0) if ($result < 0) {
{
$error++; $error++;
} }
} }
@ -462,20 +443,16 @@ class Salary extends CommonObject
$result = $this->call_trigger('salary_CREATE', $user); $result = $this->call_trigger('salary_CREATE', $user);
if ($result < 0) $error++; if ($result < 0) $error++;
// End call triggers // End call triggers
} } else $error++;
else $error++;
if (!$error) if (!$error) {
{
$this->db->commit(); $this->db->commit();
return $this->id; return $this->id;
} } else {
else {
$this->db->rollback(); $this->db->rollback();
return -2; return -2;
} }
} } else {
else {
$this->error = $this->db->error(); $this->error = $this->db->error();
$this->db->rollback(); $this->db->rollback();
return -1; return -1;
@ -495,11 +472,9 @@ class Salary extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank; $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id; $sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{
return 1; return 1;
} } else {
else {
dol_print_error($this->db); dol_print_error($this->db);
return -1; return -1;
} }
@ -532,8 +507,7 @@ class Salary extends CommonObject
$url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id; $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
if ($option != 'nolink') if ($option != 'nolink') {
{
// Add param to save lastsearch_values or not // Add param to save lastsearch_values or not
$add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0);
if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1; if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) $add_save_lastsearch_values = 1;
@ -541,10 +515,8 @@ class Salary extends CommonObject
} }
$linkclose = ''; $linkclose = '';
if (empty($notooltip)) if (empty($notooltip)) {
{ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
{
$label = $langs->trans("ShowMyObject"); $label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"'; $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
} }
@ -557,8 +529,7 @@ class Salary extends CommonObject
$reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('getnomurltooltip',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook > 0) $linkclose = $hookmanager->resPrint; if ($reshook > 0) $linkclose = $hookmanager->resPrint;
*/ */
} } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
$linkstart = '<a href="'.$url.'"'; $linkstart = '<a href="'.$url.'"';
$linkstart .= $linkclose.'>'; $linkstart .= $linkclose.'>';
@ -605,8 +576,7 @@ class Salary extends CommonObject
$this->db->free($resql); $this->db->free($resql);
return $amount; return $amount;
} } else {
else {
return -1; return -1;
} }
} }
@ -626,14 +596,11 @@ class Salary extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG); dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql); $result = $this->db->query($sql);
if ($result) if ($result) {
{ if ($this->db->num_rows($result)) {
if ($this->db->num_rows($result))
{
$obj = $this->db->fetch_object($result); $obj = $this->db->fetch_object($result);
$this->id = $obj->rowid; $this->id = $obj->rowid;
if ($obj->fk_user_author) if ($obj->fk_user_author) {
{
$cuser = new User($this->db); $cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author); $cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser; $this->user_creation = $cuser;
@ -641,8 +608,7 @@ class Salary extends CommonObject
$this->date_creation = $this->db->jdate($obj->datec); $this->date_creation = $this->db->jdate($obj->datec);
} }
$this->db->free($result); $this->db->free($result);
} } else {
else {
dol_print_error($this->db); dol_print_error($this->db);
} }
} }
@ -717,8 +683,7 @@ class Salary extends CommonObject
$this->labelStatus = array(); $this->labelStatus = array();
$this->labelStatusShort = array(); $this->labelStatusShort = array();
if (empty($this->labelStatus) || empty($this->labelStatusShort)) if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
{
global $langs; global $langs;
//$langs->load("mymodule"); //$langs->load("mymodule");
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid'); $this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid');

View File

@ -77,12 +77,10 @@ $search_account = GETPOST('search_account', 'int');
$filtre = GETPOST("filtre", 'restricthtml'); $filtre = GETPOST("filtre", 'restricthtml');
if (!GETPOST('search_type_id', 'int')) if (!GETPOST('search_type_id', 'int')) {
{
$newfiltre = str_replace('filtre=', '', $filtre); $newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre); $filterarray = explode('-', $newfiltre);
foreach ($filterarray as $val) foreach ($filterarray as $val) {
{
$part = explode(':', $val); $part = explode(':', $val);
if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1]; if ($part[0] == 's.fk_typepayment') $search_type_id = $part[1];
} }
@ -100,15 +98,13 @@ $result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias // Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha'); $search_all = GETPOST("search_all", 'alpha');
$search = array(); $search = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha'); if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
} }
// List of fields to search into when doing a "search in all" // List of fields to search into when doing a "search in all"
$fieldstosearchall = array(); $fieldstosearchall = array();
foreach ($object->fields as $key => $val) foreach ($object->fields as $key => $val) {
{
if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label']; if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
} }
@ -128,14 +124,12 @@ $parameters = array();
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
if (empty($reshook)) if (empty($reshook)) {
{
// Selection of new fields // Selection of new fields
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// Purge search criteria // Purge search criteria
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) // All test are required to be compatible with all browsers if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')) { // All test are required to be compatible with all browsers
{
$search_ref = ""; $search_ref = "";
$search_user = ""; $search_user = "";
$search_label = ""; $search_label = "";
@ -146,8 +140,7 @@ if (empty($reshook))
$search_type_id = ""; $search_type_id = "";
} }
if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha') if (GETPOST('button_removefilter_x', 'alpha') || GETPOST('button_removefilter.x', 'alpha') || GETPOST('button_removefilter', 'alpha')
|| GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) || GETPOST('button_search_x', 'alpha') || GETPOST('button_search.x', 'alpha') || GETPOST('button_search', 'alpha')) {
{
$massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation $massaction = ''; // Protection to avoid mass action if we force a new search during a mass action confirmation
} }
@ -158,8 +151,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php'; include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Validate records // Validate records
if (!$error && $massaction == 'buildsepa' && $permissiontoadd) if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
{
$objecttmp = new $objectclass($db); $objecttmp = new $objectclass($db);
// TODO // TODO
@ -213,26 +205,22 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records // Count total nb of records
$nbtotalofrecords = ''; $nbtotalofrecords = '';
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
{
$resql = $db->query($sql); $resql = $db->query($sql);
$nbtotalofrecords = $db->num_rows($resql); $nbtotalofrecords = $db->num_rows($resql);
if (($page * $limit) > $nbtotalofrecords) // if total of record found is smaller than page * limit, goto and load page 0 if (($page * $limit) > $nbtotalofrecords) { // if total of record found is smaller than page * limit, goto and load page 0
{
$page = 0; $page = 0;
$offset = 0; $offset = 0;
} }
} }
// if total of record found is smaller than limit, no need to do paging and to restart another select with limits set. // if total of record found is smaller than limit, no need to do paging and to restart another select with limits set.
if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
{
$num = $nbtotalofrecords; $num = $nbtotalofrecords;
} else { } else {
if ($limit) $sql .= $db->plimit($limit + 1, $offset); if ($limit) $sql .= $db->plimit($limit + 1, $offset);
$resql = $db->query($sql); $resql = $db->query($sql);
if (!$resql) if (!$resql) {
{
dol_print_error($db); dol_print_error($db);
exit; exit;
} }
@ -323,8 +311,7 @@ print '<td class="liste_titre left">';
$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16); $form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
print '</td>'; print '</td>';
// Account // Account
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
print '<td class="liste_titre">'; print '<td class="liste_titre">';
$form->select_comptes($search_account, 'search_account', 0, '', 1); $form->select_comptes($search_account, 'search_account', 0, '', 1);
print '</td>'; print '</td>';
@ -371,10 +358,8 @@ print '</tr>'."\n";
// Detect if we need a fetch on each output line // Detect if we need a fetch on each output line
$needToFetchEachLine = 0; $needToFetchEachLine = 0;
if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) if (is_array($extrafields->attributes[$object->table_element]['computed']) && count($extrafields->attributes[$object->table_element]['computed']) > 0) {
{ foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val) {
foreach ($extrafields->attributes[$object->table_element]['computed'] as $key => $val)
{
if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object if (preg_match('/\$object/', $val)) $needToFetchEachLine++; // There is at least one compute field that use $object
} }
} }
@ -384,8 +369,7 @@ if (is_array($extrafields->attributes[$object->table_element]['computed']) && co
$i = 0; $i = 0;
$total = 0; $total = 0;
$totalarray = array(); $totalarray = array();
while ($i < ($limit ? min($num, $limit) : $num)) while ($i < ($limit ? min($num, $limit) : $num)) {
{
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen if (empty($obj)) break; // Should not happen
@ -432,18 +416,15 @@ while ($i < ($limit ? min($num, $limit) : $num))
if (!$i) $totalarray['nbfield']++; if (!$i) $totalarray['nbfield']++;
// Account // Account
if (!empty($conf->banque->enabled)) if (!empty($conf->banque->enabled)) {
{
print '<td>'; print '<td>';
if ($obj->fk_bank > 0) if ($obj->fk_bank > 0) {
{
//$accountstatic->fetch($obj->fk_bank); //$accountstatic->fetch($obj->fk_bank);
$accountstatic->id = $obj->bid; $accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref; $accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber; $accountstatic->number = $obj->bnumber;
if (!empty($conf->accounting->enabled)) if (!empty($conf->accounting->enabled)) {
{
$accountstatic->account_number = $obj->account_number; $accountstatic->account_number = $obj->account_number;
$accountingjournal = new AccountingJournal($db); $accountingjournal = new AccountingJournal($db);
@ -472,8 +453,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint; print $hookmanager->resPrint;
// Action column // Action column
print '<td class="nowrap center">'; print '<td class="nowrap center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined if ($massactionbutton || $massaction) { // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
{
$selected = 0; $selected = 0;
if (in_array($object->id, $arrayofselected)) $selected = 1; if (in_array($object->id, $arrayofselected)) $selected = 1;
print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>'; print '<input id="cb'.$object->id.'" class="flat checkforselect" type="checkbox" name="toselect[]" value="'.$object->id.'"'.($selected ? ' checked="checked"' : '').'>';
@ -491,8 +471,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found // If no record found
if ($num == 0) if ($num == 0) {
{
$colspan = 1; $colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; } foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>'; print '<tr><td colspan="'.$colspan.'" class="opacitymedium">'.$langs->trans("NoRecordFound").'</td></tr>';