diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php
index 6aee986396b..83371cd6f24 100644
--- a/htdocs/salaries/class/paymentsalary.class.php
+++ b/htdocs/salaries/class/paymentsalary.class.php
@@ -88,6 +88,10 @@ class PaymentSalary extends CommonObject
*/
public $fk_user_modif;
+ /**
+ * @var array Array with all fields and their property. Do not use it as a static var. It may be modified by constructor.
+ */
+ public $fields = array();
/**
* Constructor
@@ -120,8 +124,7 @@ class PaymentSalary extends CommonObject
$this->note = trim($this->note);
// Check parameters
- if (empty($this->fk_user) || $this->fk_user < 0)
- {
+ if (empty($this->fk_user) || $this->fk_user < 0) {
$this->error = 'ErrorBadParameter';
return -1;
}
@@ -151,35 +154,29 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::update", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
// Update extrafield
- if (!$error)
- {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ if (!$error) {
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
}
}
- if (!$notrigger)
- {
+ if (!$notrigger) {
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_MODIFY', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
}
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return 1;
} else {
@@ -227,26 +224,24 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
$resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
+ if ($resql) {
+ if ($this->db->num_rows($resql)) {
$obj = $this->db->fetch_object($resql);
$this->id = $obj->rowid;
- $this->ref = $obj->rowid;
- $this->tms = $this->db->jdate($obj->tms);
+ $this->ref = $obj->rowid;
+ $this->tms = $this->db->jdate($obj->tms);
$this->fk_user = $obj->fk_user;
- $this->datep = $this->db->jdate($obj->datep);
- $this->datev = $this->db->jdate($obj->datev);
+ $this->datep = $this->db->jdate($obj->datep);
+ $this->datev = $this->db->jdate($obj->datev);
$this->amount = $obj->amount;
$this->fk_project = $obj->fk_project;
$this->type_payement = $obj->fk_typepayment;
$this->num_payment = $obj->num_payment;
- $this->label = $obj->label;
- $this->datesp = $this->db->jdate($obj->datesp);
- $this->dateep = $this->db->jdate($obj->dateep);
- $this->note = $obj->note;
+ $this->label = $obj->label;
+ $this->datesp = $this->db->jdate($obj->datesp);
+ $this->dateep = $this->db->jdate($obj->dateep);
+ $this->note = $obj->note;
$this->fk_bank = $obj->fk_bank;
$this->fk_user_author = $obj->fk_user_author;
$this->fk_user_modif = $obj->fk_user_modif;
@@ -282,18 +277,18 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_DELETE', $user);
- if ($result < 0) return -1;
+ if ($result < 0) {
+ return -1;
+ }
// End call triggers
// Delete donation
- if (!$error)
- {
+ if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary_extrafields";
$sql .= " WHERE fk_object=".$this->id;
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->errors[] = $this->db->lasterror();
$error++;
}
@@ -304,8 +299,7 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::delete", LOG_DEBUG);
$resql = $this->db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
$this->error = "Error ".$this->db->lasterror();
return -1;
}
@@ -326,7 +320,7 @@ class PaymentSalary extends CommonObject
$this->id = 0;
$this->tms = '';
- $this->fk_user = '';
+ $this->fk_user = 1;
$this->datep = '';
$this->datev = '';
$this->amount = '';
@@ -335,8 +329,8 @@ class PaymentSalary extends CommonObject
$this->dateep = '';
$this->note = '';
$this->fk_bank = '';
- $this->fk_user_author = '';
- $this->fk_user_modif = '';
+ $this->fk_user_author = 1;
+ $this->fk_user_modif = 1;
}
/**
@@ -356,34 +350,29 @@ class PaymentSalary extends CommonObject
$this->amount = price2num(trim($this->amount));
$this->label = trim($this->label);
$this->note = trim($this->note);
- $this->fk_bank = trim($this->fk_bank);
- $this->fk_user_author = trim($this->fk_user_author);
- $this->fk_user_modif = trim($this->fk_user_modif);
+ $this->fk_bank = (int) $this->fk_bank;
+ $this->fk_user_author = (int) $this->fk_user_author;
+ $this->fk_user_modif = (int) $this->fk_user_modif;
// Check parameters
- if (!$this->label)
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
+ if (!$this->label) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
return -3;
}
- if ($this->fk_user < 0 || $this->fk_user == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
+ if ($this->fk_user <= 0 || $this->fk_user == '') {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
return -4;
}
- if ($this->amount < 0 || $this->amount == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
+ if ($this->amount < 0 || $this->amount == '') {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
return -5;
}
- if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0))
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
+ if (!empty($conf->banque->enabled) && (empty($this->accountid) || $this->accountid <= 0)) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Account"));
return -6;
}
- if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
+ if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0)) {
+ $this->errors[] = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
return -7;
}
@@ -398,7 +387,9 @@ class PaymentSalary extends CommonObject
$sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", num_payment";
- if ($this->note) $sql .= ", note";
+ if ($this->note) {
+ $sql .= ", note";
+ }
$sql .= ", label";
$sql .= ", datesp";
$sql .= ", dateep";
@@ -416,7 +407,9 @@ class PaymentSalary extends CommonObject
$sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".$this->db->escape($this->type_payment);
$sql .= ", '".$this->db->escape($this->num_payment)."'";
- if ($this->note) $sql .= ", '".$this->db->escape($this->note)."'";
+ if ($this->note) {
+ $sql .= ", '".$this->db->escape($this->note)."'";
+ }
$sql .= ", '".$this->db->escape($this->label)."'";
$sql .= ", '".$this->db->idate($this->datesp)."'";
$sql .= ", '".$this->db->idate($this->dateep)."'";
@@ -428,30 +421,25 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this)."::create", LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary");
- if ($this->id > 0)
- {
- if (!empty($conf->banque->enabled) && !empty($this->amount))
- {
+ if ($this->id > 0) {
+ if (!empty($conf->banque->enabled) && !empty($this->amount)) {
// Insert into llx_bank
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
$acc = new Account($this->db);
$result = $acc->fetch($this->accountid);
- if ($result <= 0) dol_print_error($this->db);
+ if ($result <= 0) {
+ dol_print_error($this->db);
+ }
// Update extrafield
if (!$error) {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
}
}
@@ -473,22 +461,19 @@ class PaymentSalary extends CommonObject
// Update fk_bank into llx_paiement.
// So we know the payment which has generate the banking ecriture
- if ($bank_line_id > 0)
- {
+ if ($bank_line_id > 0) {
$this->update_fk_bank($bank_line_id);
} else {
$this->error = $acc->error;
$error++;
}
- if (!$error)
- {
+ if (!$error) {
// Add link 'payment_salary' in bank_url between payment and bank transaction
$url = DOL_URL_ROOT.'/salaries/card.php?id=';
$result = $acc->add_url_line($bank_line_id, $this->id, $url, "(SalaryPayment)", "payment_salary");
- if ($result <= 0)
- {
+ if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@@ -507,8 +492,7 @@ class PaymentSalary extends CommonObject
'user'
);
- if ($result <= 0)
- {
+ if ($result <= 0) {
$this->error = $acc->error;
$error++;
}
@@ -516,12 +500,15 @@ class PaymentSalary extends CommonObject
// Call trigger
$result = $this->call_trigger('PAYMENT_SALARY_CREATE', $user);
- if ($result < 0) $error++;
+ if ($result < 0) {
+ $error++;
+ }
// End call triggers
- } else $error++;
+ } else {
+ $error++;
+ }
- if (!$error)
- {
+ if (!$error) {
$this->db->commit();
return $this->id;
} else {
@@ -548,8 +535,7 @@ class PaymentSalary extends CommonObject
$sql = 'UPDATE '.MAIN_DB_PREFIX.'payment_salary SET fk_bank = '.$id_bank;
$sql .= ' WHERE rowid = '.$this->id;
$result = $this->db->query($sql);
- if ($result)
- {
+ if ($result) {
return 1;
} else {
dol_print_error($this->db);
@@ -574,7 +560,9 @@ class PaymentSalary extends CommonObject
global $dolibarr_main_authentication, $dolibarr_main_demo;
global $menumanager;
- if (!empty($conf->dol_no_mouse_hover)) $notooltip = 1; // Force disable tooltips
+ if (!empty($conf->dol_no_mouse_hover)) {
+ $notooltip = 1; // Force disable tooltips
+ }
$result = '';
@@ -583,10 +571,11 @@ class PaymentSalary extends CommonObject
if (!empty($this->label)) {
$labeltoshow = $this->label;
$reg = array();
- if (preg_match('/^\((.*)\)$/i', $this->label, $reg))
- {
+ if (preg_match('/^\((.*)\)$/i', $this->label, $reg)) {
// Label generique car entre parentheses. On l'affiche en le traduisant
- if ($reg[1] == 'paiement') $reg[1] = 'Payment';
+ if ($reg[1] == 'paiement') {
+ $reg[1] = 'Payment';
+ }
$labeltoshow = $langs->trans($reg[1]);
}
$label .= '
'.$langs->trans('Label').': '.$labeltoshow;
@@ -594,19 +583,20 @@ class PaymentSalary extends CommonObject
$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_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 ($add_save_lastsearch_values) $url .= '&save_lastsearch_values=1';
+ if ($save_lastsearch_value == -1 && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) {
+ $add_save_lastsearch_values = 1;
+ }
+ if ($add_save_lastsearch_values) {
+ $url .= '&save_lastsearch_values=1';
+ }
}
$linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
$label = $langs->trans("ShowMyObject");
$linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
}
@@ -614,20 +604,26 @@ class PaymentSalary extends CommonObject
$linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
/*
- $hookmanager->initHooks(array('myobjectdao'));
- $parameters=array('id'=>$this->id);
- $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;
- */
- } else $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ $hookmanager->initHooks(array('myobjectdao'));
+ $parameters=array('id'=>$this->id);
+ $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;
+ */
+ } else {
+ $linkclose = ($morecss ? ' class="'.$morecss.'"' : '');
+ }
$linkstart = '';
$linkend = '';
$result .= $linkstart;
- if ($withpicto) $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
- if ($withpicto != 2) $result .= $this->ref;
+ if ($withpicto) {
+ $result .= img_object(($notooltip ? '' : $label), ($this->picto ? $this->picto : 'generic'), ($notooltip ? (($withpicto != 2) ? 'class="paddingright"' : '') : 'class="'.(($withpicto != 2) ? 'paddingright ' : '').'classfortooltip"'), 0, 0, $notooltip ? 0 : 1);
+ }
+ if ($withpicto != 2) {
+ $result .= $this->ref;
+ }
$result .= $linkend;
//if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
@@ -635,8 +631,11 @@ class PaymentSalary extends CommonObject
$hookmanager->initHooks(array('salarypayment'));
$parameters = array('id'=>$this->id, 'getnomurl'=>$result);
$reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks
- if ($reshook > 0) $result = $hookmanager->resPrint;
- else $result .= $hookmanager->resPrint;
+ if ($reshook > 0) {
+ $result = $hookmanager->resPrint;
+ } else {
+ $result .= $hookmanager->resPrint;
+ }
return $result;
}
@@ -656,14 +655,11 @@ class PaymentSalary extends CommonObject
dol_syslog(get_class($this).'::info', LOG_DEBUG);
$result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
+ if ($result) {
+ if ($this->db->num_rows($result)) {
$obj = $this->db->fetch_object($result);
$this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
+ if ($obj->fk_user_author) {
$cuser = new User($this->db);
$cuser->fetch($obj->fk_user_author);
$this->user_creation = $cuser;
@@ -703,40 +699,40 @@ class PaymentSalary extends CommonObject
$langs->load('compta');
/*if ($mode == 0)
- {
- if ($status == 0) return $langs->trans('ToValidate');
- if ($status == 1) return $langs->trans('Validated');
- }
- if ($mode == 1)
- {
- if ($status == 0) return $langs->trans('ToValidate');
- if ($status == 1) return $langs->trans('Validated');
- }
- if ($mode == 2)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
- }
- if ($mode == 3)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
- }
- if ($mode == 4)
- {
- if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
- if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
- }
- if ($mode == 5)
- {
- if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
- }
- if ($mode == 6)
- {
- if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
- if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
- }*/
+ {
+ if ($status == 0) return $langs->trans('ToValidate');
+ if ($status == 1) return $langs->trans('Validated');
+ }
+ if ($mode == 1)
+ {
+ if ($status == 0) return $langs->trans('ToValidate');
+ if ($status == 1) return $langs->trans('Validated');
+ }
+ if ($mode == 2)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
+ }
+ if ($mode == 3)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4');
+ }
+ if ($mode == 4)
+ {
+ if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate');
+ if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated');
+ }
+ if ($mode == 5)
+ {
+ if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
+ }
+ if ($mode == 6)
+ {
+ if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1');
+ if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4');
+ }*/
return '';
}
}
diff --git a/htdocs/salaries/list.php b/htdocs/salaries/list.php
index b8a0ba69ef7..8d253e6799a 100644
--- a/htdocs/salaries/list.php
+++ b/htdocs/salaries/list.php
@@ -26,7 +26,9 @@
require '../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/salaries/class/paymentsalary.class.php';
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
-if (!empty($conf->accounting->enabled)) require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+if (!empty($conf->accounting->enabled)) {
+ require_once DOL_DOCUMENT_ROOT.'/accountancy/class/accountingjournal.class.php';
+}
// Load translation files required by the page
$langs->loadLangs(array("compta", "salaries", "bills", "hrm"));
@@ -46,12 +48,18 @@ $limit = GETPOST('limit', 'int') ?GETPOST('limit', 'int') : $conf->liste_limit;
$sortfield = GETPOST('sortfield', 'aZ09comma');
$sortorder = GETPOST('sortorder', 'aZ09comma');
$page = GETPOSTISSET('pageplusone') ? (GETPOST('pageplusone') - 1) : GETPOST("page", 'int');
-if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) { $page = 0; } // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
+if (empty($page) || $page == -1 || GETPOST('button_search', 'alpha') || GETPOST('button_removefilter', 'alpha') || (empty($toselect) && $massaction === '0')) {
+ $page = 0;
+} // If $page is not defined, or '' or -1 or if we click on clear filters or if we select empty mass action
$offset = $limit * $page;
$pageprev = $page - 1;
$pagenext = $page + 1;
-if (!$sortfield) $sortfield = "s.datep,s.rowid";
-if (!$sortorder) $sortorder = "DESC,DESC";
+if (!$sortfield) {
+ $sortfield = "s.datep,s.rowid";
+}
+if (!$sortorder) {
+ $sortorder = "DESC,DESC";
+}
// Initialize technical objects
$object = new PaymentSalary($db);
@@ -64,8 +72,12 @@ $extrafields->fetch_name_optionals_label($object->table_element);
$search_array_options = $extrafields->getOptionalsFromPost($object->table_element, '', 'search_');
-if (!$sortfield) $sortfield = "s.datep,s.rowid";
-if (!$sortorder) $sortorder = "DESC,DESC";
+if (!$sortfield) {
+ $sortfield = "s.datep,s.rowid";
+}
+if (!$sortorder) {
+ $sortorder = "DESC,DESC";
+}
$search_ref = GETPOST('search_ref', 'int');
$search_user = GETPOST('search_user', 'alpha');
@@ -77,14 +89,14 @@ $search_account = GETPOST('search_account', 'int');
$filtre = GETPOST("filtre", 'restricthtml');
-if (!GETPOST('search_type_id', 'int'))
-{
+if (!GETPOST('search_type_id', 'int')) {
$newfiltre = str_replace('filtre=', '', $filtre);
$filterarray = explode('-', $newfiltre);
- foreach ($filterarray as $val)
- {
+ foreach ($filterarray as $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];
+ }
}
} else {
$search_type_id = GETPOST('search_type_id', 'int');
@@ -94,22 +106,27 @@ $childids = $user->getAllChildIds(1);
// Security check
$socid = GETPOST("socid", "int");
-if ($user->socid) $socid = $user->socid;
+if ($user->socid) {
+ $socid = $user->socid;
+}
$result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$search = array();
-foreach ($object->fields as $key => $val)
-{
- if (GETPOST('search_'.$key, 'alpha') !== '') $search[$key] = GETPOST('search_'.$key, 'alpha');
+var_dump($object->fields);
+foreach ($object->fields as $key => $val) {
+ if (GETPOST('search_'.$key, 'alpha') !== '') {
+ $search[$key] = GETPOST('search_'.$key, 'alpha');
+ }
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
-foreach ($object->fields as $key => $val)
-{
- if ($val['searchall']) $fieldstosearchall['t.'.$key] = $val['label'];
+foreach ($object->fields as $key => $val) {
+ if ($val['searchall']) {
+ $fieldstosearchall['t.'.$key] = $val['label'];
+ }
}
$permissiontoread = $user->rights->salaries->read;
@@ -121,21 +138,25 @@ $permissiontodelete = $user->rights->salaries->delete;
* Actions
*/
-if (GETPOST('cancel', 'alpha')) { $action = 'list'; $massaction = ''; }
-if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') { $massaction = ''; }
+if (GETPOST('cancel', 'alpha')) {
+ $action = 'list'; $massaction = '';
+}
+if (!GETPOST('confirmmassaction', 'alpha') && $massaction != 'presend' && $massaction != 'confirm_presend') {
+ $massaction = '';
+}
$parameters = array();
$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
include DOL_DOCUMENT_ROOT.'/core/actions_changeselectedfields.inc.php';
// 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_user = "";
$search_label = "";
@@ -146,8 +167,7 @@ if (empty($reshook))
$search_type_id = "";
}
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
}
@@ -158,8 +178,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
// Validate records
- if (!$error && $massaction == 'buildsepa' && $permissiontoadd)
- {
+ if (!$error && $massaction == 'buildsepa' && $permissiontoadd) {
$objecttmp = new $objectclass($db);
// TODO
@@ -192,16 +211,32 @@ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank_account as ba ON b.fk_account = ba.ro
$sql .= " ".MAIN_DB_PREFIX."user as u";
$sql .= " WHERE u.rowid = s.fk_user";
$sql .= " AND s.entity IN (".getEntity('payment_salaries').")";
-if (empty($user->rights->salaries->readall)) $sql .= " AND s.fk_user IN (".join(',', $childids).")";
+if (empty($user->rights->salaries->readall)) {
+ $sql .= " AND s.fk_user IN (".join(',', $childids).")";
+}
// Search criteria
-if ($search_ref) $sql .= " AND s.rowid=".((int) $search_ref);
-if ($search_user) $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
-if ($search_label) $sql .= natural_search(array('s.label'), $search_label);
-if ($search_date_start) $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
-if ($search_date_end) $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
-if ($search_amount) $sql .= natural_search("s.amount", $search_amount, 1);
-if ($search_account > 0) $sql .= " AND b.fk_account=".((int) $search_account);
+if ($search_ref) {
+ $sql .= " AND s.rowid=".((int) $search_ref);
+}
+if ($search_user) {
+ $sql .= natural_search(array('u.login', 'u.lastname', 'u.firstname', 'u.email'), $search_user);
+}
+if ($search_label) {
+ $sql .= natural_search(array('s.label'), $search_label);
+}
+if ($search_date_start) {
+ $sql .= " AND s.datep >= '".$db->idate($search_date_start)."'";
+}
+if ($search_date_end) {
+ $sql .= " AND s.datep <= '".$db->idate($search_date_end)."'";
+}
+if ($search_amount) {
+ $sql .= natural_search("s.amount", $search_amount, 1);
+}
+if ($search_account > 0) {
+ $sql .= " AND b.fk_account=".((int) $search_account);
+}
if ($filtre) {
$filtre = str_replace(":", "=", $filtre);
$sql .= " AND ".$filtre;
@@ -213,26 +248,24 @@ $sql .= $db->order($sortfield, $sortorder);
// Count total nb of records
$nbtotalofrecords = '';
-if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
-{
+if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
$resql = $db->query($sql);
$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;
$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 (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit)))
-{
+if (is_numeric($nbtotalofrecords) && ($limit > $nbtotalofrecords || empty($limit))) {
$num = $nbtotalofrecords;
} else {
- if ($limit) $sql .= $db->plimit($limit + 1, $offset);
+ if ($limit) {
+ $sql .= $db->plimit($limit + 1, $offset);
+ }
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
exit;
}
@@ -248,16 +281,36 @@ llxHeader('', $title, $help_url);
$arrayofselected = is_array($toselect) ? $toselect : array();
$param = '';
-if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param .= '&contextpage='.urlencode($contextpage);
-if ($limit > 0 && $limit != $conf->liste_limit) $param .= '&limit='.urlencode($limit);
-if ($search_type_id) $param .= '&search_type_id='.urlencode($search_type_id);
-if ($optioncss != '') $param .= '&optioncss='.urlencode($optioncss);
-if ($search_ref) $param .= '&search_ref='.urlencode($search_ref);
-if ($search_user > 0) $param .= '&search_user='.urlencode($search_user);
-if ($search_label) $param .= '&search_label='.urlencode($search_label);
-if ($search_account) $param .= '&search_account='.urlencode($search_account);
-if ($search_date_start) $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
-if ($search_date_end) $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
+if (!empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) {
+ $param .= '&contextpage='.urlencode($contextpage);
+}
+if ($limit > 0 && $limit != $conf->liste_limit) {
+ $param .= '&limit='.urlencode($limit);
+}
+if ($search_type_id) {
+ $param .= '&search_type_id='.urlencode($search_type_id);
+}
+if ($optioncss != '') {
+ $param .= '&optioncss='.urlencode($optioncss);
+}
+if ($search_ref) {
+ $param .= '&search_ref='.urlencode($search_ref);
+}
+if ($search_user > 0) {
+ $param .= '&search_user='.urlencode($search_user);
+}
+if ($search_label) {
+ $param .= '&search_label='.urlencode($search_label);
+}
+if ($search_account) {
+ $param .= '&search_account='.urlencode($search_account);
+}
+if ($search_date_start) {
+ $param .= '&search_date_startday='.urlencode(GETPOST('search_date_startday', 'int')).'&search_date_startmonth='.urlencode(GETPOST('search_date_startmonth', 'int')).'&search_date_startyear='.urlencode(GETPOST('search_date_startyear', 'int'));
+}
+if ($search_date_end) {
+ $param .= '&search_date_endday='.urlencode(GETPOST('search_date_endday', 'int')).'&search_date_endmonth='.urlencode(GETPOST('search_date_endmonth', 'int')).'&search_date_endyear='.urlencode(GETPOST('search_date_endyear', 'int'));
+}
// Add $param from extra fields
include DOL_DOCUMENT_ROOT.'/core/tpl/extrafields_list_search_param.tpl.php';
@@ -267,11 +320,15 @@ $arrayofmassactions = array(
//'buildsepa'=>$langs->trans("BuildSepa"), // TODO
);
//if ($permissiontodelete) $arrayofmassactions['predelete'] = ''.$langs->trans("Delete");
-if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) $arrayofmassactions = array();
+if (GETPOST('nomassaction', 'int') || in_array($massaction, array('presend', 'predelete'))) {
+ $arrayofmassactions = array();
+}
$massactionbutton = $form->selectMassAction('', $arrayofmassactions);
print '