diff --git a/dev/examples/git/pre-commit b/dev/examples/git/pre-commit
index f89d662ae65..790632dda9e 100644
--- a/dev/examples/git/pre-commit
+++ b/dev/examples/git/pre-commit
@@ -1,4 +1,6 @@
#!/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'))));"`
STAGED_FILES_CMD=`git diff --cached --name-only --diff-filter=ACMR HEAD | grep \\\\.php`
diff --git a/htdocs/salaries/card.php b/htdocs/salaries/card.php
index 58e82a5747c..e1d92a9daae 100755
--- a/htdocs/salaries/card.php
+++ b/htdocs/salaries/card.php
@@ -451,7 +451,7 @@ if ($action == 'create') {
print ' ';
print '';
- // Project
+ // Project
if (!empty($conf->projet->enabled)) {
$formproject = new FormProjets($db);
@@ -643,7 +643,6 @@ if ($id) {
print '
'.$langs->trans("DateStartPeriod")." ";
print $form->selectDate($object->datesp, 'datesp', 0, 0, 0, 'datesp', 1);
print " ";
-
} else {
print "";
print '' . $langs->trans("DateStartPeriod") . ' ';
@@ -651,7 +650,6 @@ if ($id) {
print ' ';
}
-
if ($action == 'edit') {
print ''.$langs->trans("DateEndPeriod")." ";
print $form->selectDate($object->dateep, 'dateep', 0, 0, 0, 'dateep', 1);
@@ -801,8 +799,7 @@ if ($id) {
$totalpaye += $objp->amount;
$i++;
}
- }
- else {
+ } else {
print ' '.$langs->trans("None").' ';
print ' ';
print ' ';
@@ -821,8 +818,7 @@ if ($id) {
print '';
$db->free($resql);
- }
- else {
+ } else {
dol_print_error($db);
}
diff --git a/htdocs/salaries/class/paymentsalary.class.php b/htdocs/salaries/class/paymentsalary.class.php
index 808e1071cad..0feefbfb076 100644
--- a/htdocs/salaries/class/paymentsalary.class.php
+++ b/htdocs/salaries/class/paymentsalary.class.php
@@ -49,8 +49,8 @@ class PaymentSalary extends CommonObject
public $picto = 'payment';
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_salary;
public $datec = '';
@@ -63,12 +63,12 @@ class PaymentSalary extends CommonObject
*/
public $total;
- public $amount; // Total amount of payment
- public $amounts = array(); // Array of amounts
+ public $amount; // Total amount of payment
+ public $amounts = array(); // Array of amounts
- /**
- * @var int ID
- */
+ /**
+ * @var int ID
+ */
public $fk_typepayment;
/**
@@ -83,18 +83,18 @@ class PaymentSalary extends CommonObject
public $num_payment;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_bank;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_author;
/**
- * @var int ID
- */
+ * @var int ID
+ */
public $fk_user_modif;
/**
@@ -109,8 +109,8 @@ class PaymentSalary extends CommonObject
/**
* Create payment of salary into database.
- * Use this->amounts to have list of lines for the payment
- *
+ * Use this->amounts to have list of lines for the payment
+ *
* @param User $user User making payment
* @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more
* @return int <0 if KO, id of payment if OK
@@ -121,13 +121,12 @@ class PaymentSalary extends CommonObject
$error = 0;
- $now = dol_now();
+ $now = dol_now();
dol_syslog(get_class($this)."::create", LOG_DEBUG);
// Validate parametres
- if (!$this->datepaye)
- {
+ if (!$this->datepaye) {
$this->error = 'ErrorBadValueForParameterCreatePaymentSalary';
return -1;
}
@@ -143,17 +142,16 @@ class PaymentSalary extends CommonObject
if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author;
if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif;
- $totalamount = 0;
- foreach ($this->amounts as $key => $value) // How payment is dispatch
- {
- $newvalue = price2num($value, 'MT');
- $this->amounts[$key] = $newvalue;
- $totalamount += $newvalue;
- }
- $totalamount = price2num($totalamount);
+ $totalamount = 0;
+ foreach ($this->amounts as $key => $value) { // How payment is dispatch
+ $newvalue = price2num($value, 'MT');
+ $this->amounts[$key] = $newvalue;
+ $totalamount += $newvalue;
+ }
+ $totalamount = price2num($totalamount);
- // Check parameters
- if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
+ // Check parameters
+ if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null
$this->db->begin();
@@ -190,13 +188,11 @@ class PaymentSalary extends CommonObject
$remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT');
if ($remaintopay == 0) {
$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++;
}
}
@@ -205,9 +201,9 @@ class PaymentSalary extends CommonObject
if ($result < 0) $error++;
if ($totalamount != 0 && !$error) {
- $this->amount = $totalamount;
- $this->total = $totalamount; // deprecated
- $this->db->commit();
+ $this->amount = $totalamount;
+ $this->total = $totalamount; // deprecated
+ $this->db->commit();
return $this->id;
} else {
$this->error = $this->db->error();
@@ -362,15 +358,15 @@ class PaymentSalary extends CommonObject
$this->db->begin();
- if ($this->bank_line > 0) {
- $accline = new AccountLine($this->db);
+ if ($this->bank_line > 0) {
+ $accline = new AccountLine($this->db);
$accline->fetch($this->bank_line);
$result = $accline->delete();
if ($result < 0) {
$this->errors[] = $accline->error;
$error++;
}
- }
+ }
if (!$error) {
$sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary";
@@ -444,11 +440,11 @@ class PaymentSalary extends CommonObject
/**
- * Initialise an instance with random values.
- * Used to build previews or test instances.
- * id must be 0 if object instance is a specimen.
- *
- * @return void
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @return void
*/
public function initAsSpecimen()
{
@@ -469,92 +465,92 @@ class PaymentSalary extends CommonObject
}
- /**
- * Add record into bank for payment with links between this bank record and invoices of payment.
- * All payment properties must have been set first like after a call to create().
- *
- * @param User $user Object of user making payment
- * @param string $mode 'payment_sc'
- * @param string $label Label to use in bank record
- * @param int $accountid Id of bank account to do link with
- * @param string $emetteur_nom Name of transmitter
- * @param string $emetteur_banque Name of bank
- * @return int <0 if KO, >0 if OK
- */
- public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
- {
- global $conf;
+ /**
+ * Add record into bank for payment with links between this bank record and invoices of payment.
+ * All payment properties must have been set first like after a call to create().
+ *
+ * @param User $user Object of user making payment
+ * @param string $mode 'payment_sc'
+ * @param string $label Label to use in bank record
+ * @param int $accountid Id of bank account to do link with
+ * @param string $emetteur_nom Name of transmitter
+ * @param string $emetteur_banque Name of bank
+ * @return int <0 if KO, >0 if OK
+ */
+ public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque)
+ {
+ global $conf;
// Clean data
- $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
+ $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement);
- $error = 0;
+ $error = 0;
- if (!empty($conf->banque->enabled)) {
- include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
+ if (!empty($conf->banque->enabled)) {
+ include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
- $acc = new Account($this->db);
- $acc->fetch($accountid);
+ $acc = new Account($this->db);
+ $acc->fetch($accountid);
- $total = $this->amount;
+ $total = $this->amount;
- // Insert payment into llx_bank
- $bank_line_id = $acc->addline(
- $this->datepaye,
- $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
- $label,
- -$total,
- $this->num_payment,
- '',
- $user,
- $emetteur_nom,
- $emetteur_banque,
+ // Insert payment into llx_bank
+ $bank_line_id = $acc->addline(
+ $this->datepaye,
+ $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example")
+ $label,
+ -$total,
+ $this->num_payment,
+ '',
+ $user,
+ $emetteur_nom,
+ $emetteur_banque,
'',
$this->datev
- );
+ );
- // Mise a jour fk_bank dans llx_paiement.
- // On connait ainsi le paiement qui a genere l'ecriture bancaire
- if ($bank_line_id > 0) {
- $result = $this->update_fk_bank($bank_line_id);
- if ($result <= 0) {
- $error++;
- dol_print_error($this->db);
- }
+ // Mise a jour fk_bank dans llx_paiement.
+ // On connait ainsi le paiement qui a genere l'ecriture bancaire
+ if ($bank_line_id > 0) {
+ $result = $this->update_fk_bank($bank_line_id);
+ if ($result <= 0) {
+ $error++;
+ dol_print_error($this->db);
+ }
- // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
- $url = '';
- if ($mode == 'payment_salary') $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
- if ($url) {
- $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
- if ($result <= 0) {
- $error++;
- dol_print_error($this->db);
- }
- }
+ // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction
+ $url = '';
+ if ($mode == 'payment_salary') $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id=';
+ if ($url) {
+ $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode);
+ if ($result <= 0) {
+ $error++;
+ dol_print_error($this->db);
+ }
+ }
- // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
- $linkaddedforthirdparty = array();
- foreach ($this->amounts as $key => $value) {
- if ($mode == 'payment_salary') {
- $salary = new Salary($this->db);
- $salary->fetch($key);
- $result = $acc->add_url_line($bank_line_id, $salary->id, DOL_URL_ROOT.'/salaries/card.php?id=', '('.$salary->label.')', 'salary');
- if ($result <= 0) dol_print_error($this->db);
- }
- }
- } else {
- $this->error = $acc->error;
- $error++;
- }
- }
+ // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment)
+ $linkaddedforthirdparty = array();
+ foreach ($this->amounts as $key => $value) {
+ if ($mode == 'payment_salary') {
+ $salary = new Salary($this->db);
+ $salary->fetch($key);
+ $result = $acc->add_url_line($bank_line_id, $salary->id, DOL_URL_ROOT.'/salaries/card.php?id=', '('.$salary->label.')', 'salary');
+ if ($result <= 0) dol_print_error($this->db);
+ }
+ }
+ } else {
+ $this->error = $acc->error;
+ $error++;
+ }
+ }
- if (!$error) {
- return 1;
- } else {
- return -1;
- }
- }
+ if (!$error) {
+ return 1;
+ } else {
+ return -1;
+ }
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
diff --git a/htdocs/salaries/class/salariesstats.class.php b/htdocs/salaries/class/salariesstats.class.php
index cb73b33f846..7d7f9a7b5f2 100644
--- a/htdocs/salaries/class/salariesstats.class.php
+++ b/htdocs/salaries/class/salariesstats.class.php
@@ -84,7 +84,7 @@ class SalariesStats extends Stats
$sql = "SELECT YEAR(datep) as dm, count(*)";
$sql .= " FROM ".$this->from;
$sql .= " GROUP BY dm DESC";
- //$sql .= " WHERE ".$this->where;
+ //$sql .= " WHERE ".$this->where;
return $this->_getNbByYear($sql);
}
@@ -102,7 +102,7 @@ class SalariesStats extends Stats
$sql = "SELECT MONTH(datep) as dm, count(*)";
$sql .= " FROM ".$this->from;
$sql .= " WHERE YEAR(datep) = ".$year;
- //$sql .= " AND ".$this->where;
+ //$sql .= " AND ".$this->where;
$sql .= " GROUP BY dm";
$sql .= $this->db->order('dm', 'DESC');
diff --git a/htdocs/salaries/class/salary.class.php b/htdocs/salaries/class/salary.class.php
index ccd3698bffd..b0973fab5fa 100644
--- a/htdocs/salaries/class/salary.class.php
+++ b/htdocs/salaries/class/salary.class.php
@@ -32,553 +32,524 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php';
*/
class Salary extends CommonObject
{
- /**
- * @var string ID to identify managed object
- */
- public $element = 'salary';
+ /**
+ * @var string ID to identify managed object
+ */
+ public $element = 'salary';
- /**
- * @var string Name of table without prefix where object is stored
- */
- public $table_element = 'salary';
+ /**
+ * @var string Name of table without prefix where object is stored
+ */
+ public $table_element = 'salary';
- /**
- * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
- */
- public $picto = 'payment';
+ /**
+ * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png
+ */
+ public $picto = 'payment';
- public $tms;
+ public $tms;
- /**
- * @var int User ID
- */
- public $fk_user;
+ /**
+ * @var int User ID
+ */
+ public $fk_user;
- public $datep;
- public $datev;
- public $amount;
+ public $datep;
+ public $datev;
+ public $amount;
- /**
- * @var int ID
- */
- public $fk_project;
+ /**
+ * @var int ID
+ */
+ public $fk_project;
- public $type_payment;
- public $num_payment;
+ public $type_payment;
+ public $num_payment;
- /**
- * @var string salary payments label
- */
- public $label;
+ /**
+ * @var string salary payments label
+ */
+ public $label;
- public $datesp;
- public $dateep;
+ public $datesp;
+ public $dateep;
- /**
- * @var int ID
- */
- public $fk_bank;
+ /**
+ * @var int ID
+ */
+ public $fk_bank;
- /**
- * @var int ID
- */
- public $fk_user_author;
+ /**
+ * @var int ID
+ */
+ public $fk_user_author;
- /**
- * @var int ID
- */
- public $fk_user_modif;
+ /**
+ * @var int ID
+ */
+ public $fk_user_modif;
const STATUS_UNPAID = 0;
const STATUS_PAID = 1;
- /**
- * Constructor
- *
- * @param DoliDB $db Database handler
- */
- public function __construct($db)
- {
- $this->db = $db;
- $this->element = 'salary';
- $this->table_element = 'salary';
- }
+ /**
+ * Constructor
+ *
+ * @param DoliDB $db Database handler
+ */
+ public function __construct($db)
+ {
+ $this->db = $db;
+ $this->element = 'salary';
+ $this->table_element = 'salary';
+ }
- /**
- * Update database
- *
- * @param User $user User that modify
- * @param int $notrigger 0=no, 1=yes (no update trigger)
- * @return int <0 if KO, >0 if OK
- */
- public function update($user = null, $notrigger = 0)
- {
- global $conf, $langs;
+ /**
+ * Update database
+ *
+ * @param User $user User that modify
+ * @param int $notrigger 0=no, 1=yes (no update trigger)
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update($user = null, $notrigger = 0)
+ {
+ global $conf, $langs;
- $error = 0;
+ $error = 0;
- // Clean parameters
- $this->amount = trim($this->amount);
- $this->label = trim($this->label);
- $this->note = trim($this->note);
+ // Clean parameters
+ $this->amount = trim($this->amount);
+ $this->label = trim($this->label);
+ $this->note = trim($this->note);
- // Check parameters
- if (empty($this->fk_user) || $this->fk_user < 0)
- {
- $this->error = 'ErrorBadParameter';
- return -1;
- }
+ // Check parameters
+ if (empty($this->fk_user) || $this->fk_user < 0) {
+ $this->error = 'ErrorBadParameter';
+ return -1;
+ }
- $this->db->begin();
+ $this->db->begin();
- // Update request
- $sql = "UPDATE ".MAIN_DB_PREFIX."salary SET";
+ // Update request
+ $sql = "UPDATE ".MAIN_DB_PREFIX."salary SET";
- $sql .= " tms='".$this->db->idate(dol_now())."',";
- $sql .= " fk_user=".$this->fk_user.",";
- /*$sql .= " datep='".$this->db->idate($this->datep)."',";
- $sql .= " datev='".$this->db->idate($this->datev)."',";*/
- $sql .= " amount=".price2num($this->amount).",";
- $sql .= " fk_projet=".((int) $this->fk_project).",";
- $sql .= " fk_typepayment=".$this->type_payment.",";
- $sql .= " num_payment='".$this->db->escape($this->num_payment)."',";
- $sql .= " label='".$this->db->escape($this->label)."',";
- $sql .= " datesp='".$this->db->idate($this->datesp)."',";
- $sql .= " dateep='".$this->db->idate($this->dateep)."',";
- $sql .= " note='".$this->db->escape($this->note)."',";
- $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").",";
- $sql .= " fk_user_author=".((int) $this->fk_user_author).",";
- $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null');
+ $sql .= " tms='".$this->db->idate(dol_now())."',";
+ $sql .= " fk_user=".$this->fk_user.",";
+ /*$sql .= " datep='".$this->db->idate($this->datep)."',";
+ $sql .= " datev='".$this->db->idate($this->datev)."',";*/
+ $sql .= " amount=".price2num($this->amount).",";
+ $sql .= " fk_projet=".((int) $this->fk_project).",";
+ $sql .= " fk_typepayment=".$this->type_payment.",";
+ $sql .= " num_payment='".$this->db->escape($this->num_payment)."',";
+ $sql .= " label='".$this->db->escape($this->label)."',";
+ $sql .= " datesp='".$this->db->idate($this->datesp)."',";
+ $sql .= " dateep='".$this->db->idate($this->dateep)."',";
+ $sql .= " note='".$this->db->escape($this->note)."',";
+ $sql .= " fk_bank=".($this->fk_bank > 0 ? (int) $this->fk_bank : "null").",";
+ $sql .= " fk_user_author=".((int) $this->fk_user_author).",";
+ $sql .= " fk_user_modif=".($this->fk_user_modif > 0 ? (int) $this->fk_user_modif : 'null');
- $sql .= " WHERE rowid=".$this->id;
+ $sql .= " WHERE rowid=".$this->id;
- dol_syslog(get_class($this)."::update", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->error = "Error ".$this->db->lasterror();
- return -1;
- }
+ dol_syslog(get_class($this)."::update", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ $this->error = "Error ".$this->db->lasterror();
+ return -1;
+ }
- // Update extrafield
- if (!$error)
- {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
- }
+ // Update extrafield
+ if (!$error) {
+ if (!$error) {
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ }
- if (!$notrigger)
- {
- // Call trigger
- $result = $this->call_trigger('salary_MODIFY', $user);
- if ($result < 0) $error++;
- // End call triggers
- }
+ if (!$notrigger) {
+ // Call trigger
+ $result = $this->call_trigger('salary_MODIFY', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ }
- if (!$error)
- {
- $this->db->commit();
- return 1;
- }
- else {
- $this->db->rollback();
- return -1;
- }
- }
+ if (!$error) {
+ $this->db->commit();
+ return 1;
+ } else {
+ $this->db->rollback();
+ return -1;
+ }
+ }
- /**
- * Load object in memory from database
- *
- * @param int $id id object
- * @param User $user User that load
- * @return int <0 if KO, >0 if OK
- */
- public function fetch($id, $user = null)
- {
- global $langs;
- $sql = "SELECT";
- $sql .= " s.rowid,";
+ /**
+ * Load object in memory from database
+ *
+ * @param int $id id object
+ * @param User $user User that load
+ * @return int <0 if KO, >0 if OK
+ */
+ public function fetch($id, $user = null)
+ {
+ global $langs;
+ $sql = "SELECT";
+ $sql .= " s.rowid,";
- $sql .= " s.tms,";
- $sql .= " s.fk_user,";
- $sql .= " s.datep,";
- $sql .= " s.datev,";
- $sql .= " s.amount,";
- $sql .= " s.fk_projet as fk_project,";
- $sql .= " s.fk_typepayment,";
- $sql .= " s.num_payment,";
- $sql .= " s.label,";
- $sql .= " s.datesp,";
- $sql .= " s.dateep,";
+ $sql .= " s.tms,";
+ $sql .= " s.fk_user,";
+ $sql .= " s.datep,";
+ $sql .= " s.datev,";
+ $sql .= " s.amount,";
+ $sql .= " s.fk_projet as fk_project,";
+ $sql .= " s.fk_typepayment,";
+ $sql .= " s.num_payment,";
+ $sql .= " s.label,";
+ $sql .= " s.datesp,";
+ $sql .= " s.dateep,";
$sql .= " s.note,";
$sql .= " s.paye,";
- $sql .= " s.fk_bank,";
- $sql .= " s.fk_user_author,";
- $sql .= " s.fk_user_modif,";
- $sql .= " s.fk_account";
- /*$sql .= " b.fk_type,";
- $sql .= " b.rappro";*/
+ $sql .= " s.fk_bank,";
+ $sql .= " s.fk_user_author,";
+ $sql .= " s.fk_user_modif,";
+ $sql .= " s.fk_account";
+ /*$sql .= " b.fk_type,";
+ $sql .= " b.rappro";*/
- $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
- $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
- $sql .= " WHERE s.rowid = ".$id;
+ $sql .= " FROM ".MAIN_DB_PREFIX."salary as s";
+ $sql .= " LEFT JOIN ".MAIN_DB_PREFIX."bank as b ON s.fk_bank = b.rowid";
+ $sql .= " WHERE s.rowid = ".$id;
- dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if ($resql)
- {
- if ($this->db->num_rows($resql))
- {
- $obj = $this->db->fetch_object($resql);
+ dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ 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->fk_user = $obj->fk_user;
- $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_payment = $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->id = $obj->rowid;
+ $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->amount = $obj->amount;
+ $this->fk_project = $obj->fk_project;
+ $this->type_payment = $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->paye = $obj->paye;
$this->fk_bank = $obj->fk_bank;
- $this->fk_user_author = $obj->fk_user_author;
- $this->fk_user_modif = $obj->fk_user_modif;
- $this->fk_account = $this->accountid = $obj->fk_account;
- $this->fk_type = $obj->fk_type;
- $this->rappro = $obj->rappro;
+ $this->fk_user_author = $obj->fk_user_author;
+ $this->fk_user_modif = $obj->fk_user_modif;
+ $this->fk_account = $this->accountid = $obj->fk_account;
+ $this->fk_type = $obj->fk_type;
+ $this->rappro = $obj->rappro;
- // Retreive all extrafield
- // fetch optionals attributes and labels
- $this->fetch_optionals();
- }
- $this->db->free($resql);
+ // Retreive all extrafield
+ // fetch optionals attributes and labels
+ $this->fetch_optionals();
+ }
+ $this->db->free($resql);
- return 1;
- }
- else {
- $this->error = "Error ".$this->db->lasterror();
- return -1;
- }
- }
+ return 1;
+ } else {
+ $this->error = "Error ".$this->db->lasterror();
+ return -1;
+ }
+ }
- /**
- * Delete object in database
- *
- * @param User $user User that delete
- * @return int <0 if KO, >0 if OK
- */
- public function delete($user)
- {
- global $conf, $langs;
+ /**
+ * Delete object in database
+ *
+ * @param User $user User that delete
+ * @return int <0 if KO, >0 if OK
+ */
+ public function delete($user)
+ {
+ global $conf, $langs;
- $error = 0;
+ $error = 0;
- // Call trigger
- $result = $this->call_trigger('salary_DELETE', $user);
- if ($result < 0) return -1;
- // End call triggers
+ // Call trigger
+ $result = $this->call_trigger('salary_DELETE', $user);
+ if ($result < 0) return -1;
+ // End call triggers
- // Delete extrafields
- /*if (!$error)
- {
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."salary_extrafields";
- $sql .= " WHERE fk_object=".$this->id;
+ // Delete extrafields
+ /*if (!$error)
+ {
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."salary_extrafields";
+ $sql .= " WHERE fk_object=".$this->id;
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->errors[] = $this->db->lasterror();
- $error++;
- }
- }*/
+ $resql = $this->db->query($sql);
+ if (!$resql)
+ {
+ $this->errors[] = $this->db->lasterror();
+ $error++;
+ }
+ }*/
- $sql = "DELETE FROM ".MAIN_DB_PREFIX."salary";
- $sql .= " WHERE rowid=".$this->id;
+ $sql = "DELETE FROM ".MAIN_DB_PREFIX."salary";
+ $sql .= " WHERE rowid=".$this->id;
- dol_syslog(get_class($this)."::delete", LOG_DEBUG);
- $resql = $this->db->query($sql);
- if (!$resql)
- {
- $this->error = "Error ".$this->db->lasterror();
- return -1;
- }
+ dol_syslog(get_class($this)."::delete", LOG_DEBUG);
+ $resql = $this->db->query($sql);
+ if (!$resql) {
+ $this->error = "Error ".$this->db->lasterror();
+ return -1;
+ }
- return 1;
- }
+ return 1;
+ }
- /**
- * Initialise an instance with random values.
- * Used to build previews or test instances.
- * id must be 0 if object instance is a specimen.
- *
- * @return void
- */
- public function initAsSpecimen()
- {
- $this->id = 0;
+ /**
+ * Initialise an instance with random values.
+ * Used to build previews or test instances.
+ * id must be 0 if object instance is a specimen.
+ *
+ * @return void
+ */
+ public function initAsSpecimen()
+ {
+ $this->id = 0;
- $this->tms = '';
- $this->fk_user = '';
- $this->datep = '';
- $this->datev = '';
- $this->amount = '';
- $this->label = '';
- $this->datesp = '';
- $this->dateep = '';
- $this->note = '';
- $this->fk_bank = '';
- $this->fk_user_author = '';
- $this->fk_user_modif = '';
- }
+ $this->tms = '';
+ $this->fk_user = '';
+ $this->datep = '';
+ $this->datev = '';
+ $this->amount = '';
+ $this->label = '';
+ $this->datesp = '';
+ $this->dateep = '';
+ $this->note = '';
+ $this->fk_bank = '';
+ $this->fk_user_author = '';
+ $this->fk_user_modif = '';
+ }
- /**
- * Create in database
- *
- * @param User $user User that create
- * @return int <0 if KO, >0 if OK
- */
- public function create($user)
- {
- global $conf, $langs;
+ /**
+ * Create in database
+ *
+ * @param User $user User that create
+ * @return int <0 if KO, >0 if OK
+ */
+ public function create($user)
+ {
+ global $conf, $langs;
- $error = 0;
- $now = dol_now();
+ $error = 0;
+ $now = dol_now();
- // Clean parameters
- $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);
+ // Clean parameters
+ $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->accountid = trim($this->accountid);
$this->paye = trim($this->paye);
- // Check parameters
- if (!$this->label)
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
- return -3;
- }
- if ($this->fk_user < 0 || $this->fk_user == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
- return -4;
- }
- if ($this->amount < 0 || $this->amount == '')
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Amount"));
- return -5;
- }
+ // Check parameters
+ if (!$this->label) {
+ $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Label"));
+ return -3;
+ }
+ if ($this->fk_user < 0 || $this->fk_user == '') {
+ $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("Employee"));
+ return -4;
+ }
+ if ($this->amount < 0 || $this->amount == '') {
+ $this->error = $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"));
- return -6;
- }
- if (!empty($conf->banque->enabled) && (empty($this->type_payment) || $this->type_payment <= 0))
- {
- $this->error = $langs->trans("ErrorFieldRequired", $langs->transnoentities("PaymentMode"));
- return -7;
- }*/
+ {
+ $this->error = $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"));
+ return -7;
+ }*/
- $this->db->begin();
+ $this->db->begin();
- // Insert into llx_salary
- $sql = "INSERT INTO ".MAIN_DB_PREFIX."salary (fk_user";
- //$sql .= ", datep";
- //$sql .= ", datev";
- $sql .= ", amount";
- $sql .= ", fk_projet";
- $sql .= ", salary";
+ // Insert into llx_salary
+ $sql = "INSERT INTO ".MAIN_DB_PREFIX."salary (fk_user";
+ //$sql .= ", datep";
+ //$sql .= ", datev";
+ $sql .= ", amount";
+ $sql .= ", fk_projet";
+ $sql .= ", salary";
$sql .= ", fk_typepayment";
$sql .= ", fk_account";
- $sql .= ", num_payment";
- if ($this->note) $sql .= ", note";
- $sql .= ", label";
- $sql .= ", datesp";
- $sql .= ", dateep";
- $sql .= ", fk_user_author";
- $sql .= ", datec";
- $sql .= ", fk_bank";
- $sql .= ", entity";
- $sql .= ") ";
- $sql .= " VALUES (";
- $sql .= "'".$this->db->escape($this->fk_user)."'";
- //$sql .= ", '".$this->db->idate($this->datep)."'";
- //$sql .= ", '".$this->db->idate($this->datev)."'";
- $sql .= ", ".$this->amount;
- $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
- $sql .= ", ".($this->salary > 0 ? $this->salary : "null");
+ $sql .= ", num_payment";
+ if ($this->note) $sql .= ", note";
+ $sql .= ", label";
+ $sql .= ", datesp";
+ $sql .= ", dateep";
+ $sql .= ", fk_user_author";
+ $sql .= ", datec";
+ $sql .= ", fk_bank";
+ $sql .= ", entity";
+ $sql .= ") ";
+ $sql .= " VALUES (";
+ $sql .= "'".$this->db->escape($this->fk_user)."'";
+ //$sql .= ", '".$this->db->idate($this->datep)."'";
+ //$sql .= ", '".$this->db->idate($this->datev)."'";
+ $sql .= ", ".$this->amount;
+ $sql .= ", ".($this->fk_project > 0 ? $this->fk_project : 0);
+ $sql .= ", ".($this->salary > 0 ? $this->salary : "null");
$sql .= ", ".($this->type_payment > 0 ? $this->type_payment : 0);
$sql .= ", ".($this->accountid > 0 ? $this->accountid : "null");
- $sql .= ", '".$this->db->escape($this->num_payment)."'";
- 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)."'";
- $sql .= ", '".$this->db->escape($user->id)."'";
- $sql .= ", '".$this->db->idate($now)."'";
- $sql .= ", NULL";
- $sql .= ", ".$conf->entity;
- $sql .= ")";
+ $sql .= ", '".$this->db->escape($this->num_payment)."'";
+ 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)."'";
+ $sql .= ", '".$this->db->escape($user->id)."'";
+ $sql .= ", '".$this->db->idate($now)."'";
+ $sql .= ", NULL";
+ $sql .= ", ".$conf->entity;
+ $sql .= ")";
- dol_syslog(get_class($this)."::create", LOG_DEBUG);
- $result = $this->db->query($sql);
- if ($result)
- {
- $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salary");
+ dol_syslog(get_class($this)."::create", LOG_DEBUG);
+ $result = $this->db->query($sql);
+ if ($result) {
+ $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."salary");
- if ($this->id > 0)
- {
- // Update extrafield
- if (!$error) {
- if (!$error)
- {
- $result = $this->insertExtraFields();
- if ($result < 0)
- {
- $error++;
- }
- }
- }
+ if ($this->id > 0) {
+ // Update extrafield
+ if (!$error) {
+ if (!$error) {
+ $result = $this->insertExtraFields();
+ if ($result < 0) {
+ $error++;
+ }
+ }
+ }
- // Call trigger
- $result = $this->call_trigger('salary_CREATE', $user);
- if ($result < 0) $error++;
- // End call triggers
- }
- else $error++;
+ // Call trigger
+ $result = $this->call_trigger('salary_CREATE', $user);
+ if ($result < 0) $error++;
+ // End call triggers
+ } else $error++;
- if (!$error)
- {
- $this->db->commit();
- return $this->id;
- }
- else {
- $this->db->rollback();
- return -2;
- }
- }
- else {
- $this->error = $this->db->error();
- $this->db->rollback();
- return -1;
- }
- }
+ if (!$error) {
+ $this->db->commit();
+ return $this->id;
+ } else {
+ $this->db->rollback();
+ return -2;
+ }
+ } else {
+ $this->error = $this->db->error();
+ $this->db->rollback();
+ return -1;
+ }
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
- /**
- * Update link between payment salary and line generate into llx_bank
- *
- * @param int $id_bank Id bank account
- * @return int <0 if KO, >0 if OK
- */
- public function update_fk_bank($id_bank)
- {
+ /**
+ * Update link between payment salary and line generate into llx_bank
+ *
+ * @param int $id_bank Id bank account
+ * @return int <0 if KO, >0 if OK
+ */
+ public function update_fk_bank($id_bank)
+ {
// phpcs:enable
- $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank;
- $sql .= ' WHERE rowid = '.$this->id;
- $result = $this->db->query($sql);
- if ($result)
- {
- return 1;
- }
- else {
- dol_print_error($this->db);
- return -1;
- }
- }
+ $sql = 'UPDATE '.MAIN_DB_PREFIX.'salary SET fk_bank = '.$id_bank;
+ $sql .= ' WHERE rowid = '.$this->id;
+ $result = $this->db->query($sql);
+ if ($result) {
+ return 1;
+ } else {
+ dol_print_error($this->db);
+ return -1;
+ }
+ }
- /**
- * Send name clicable (with possibly the picto)
- *
- * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
- * @param string $option link option
- * @param int $notooltip 1=Disable tooltip
- * @param string $morecss Add more css on link
- * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
- * @return string Chaine with URL
- */
- public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
- {
- global $db, $conf, $langs, $hookmanager;
- global $dolibarr_main_authentication, $dolibarr_main_demo;
- global $menumanager;
+ /**
+ * Send name clicable (with possibly the picto)
+ *
+ * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto
+ * @param string $option link option
+ * @param int $notooltip 1=Disable tooltip
+ * @param string $morecss Add more css on link
+ * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
+ * @return string Chaine with URL
+ */
+ public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $morecss = '', $save_lastsearch_value = -1)
+ {
+ global $db, $conf, $langs, $hookmanager;
+ 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 = '';
+ $result = '';
- $label = ''.$langs->trans("Salary").' ';
- $label .= ' ';
- $label .= ''.$langs->trans('Ref').': '.$this->ref;
+ $label = ''.$langs->trans("Salary").' ';
+ $label .= ' ';
+ $label .= ''.$langs->trans('Ref').': '.$this->ref;
- $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
+ $url = DOL_URL_ROOT.'/salaries/card.php?id='.$this->id;
- 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 ($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';
+ }
- $linkclose = '';
- if (empty($notooltip))
- {
- if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER))
- {
- $label = $langs->trans("ShowMyObject");
- $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
- }
- $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
- $linkclose .= ' class="classfortooltip'.($morecss ? ' '.$morecss : '').'"';
+ $linkclose = '';
+ if (empty($notooltip)) {
+ if (!empty($conf->global->MAIN_OPTIMIZEFORTEXTBROWSER)) {
+ $label = $langs->trans("ShowMyObject");
+ $linkclose .= ' alt="'.dol_escape_htmltag($label, 1).'"';
+ }
+ $linkclose .= ' title="'.dol_escape_htmltag($label, 1).'"';
+ $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 = ' ';
+ $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;
- $result .= $linkend;
- //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
+ $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;
+ $result .= $linkend;
+ //if ($withpicto != 2) $result.=(($addlabel && $this->label) ? $sep . dol_trunc($this->label, ($addlabel > 1 ? $addlabel : 0)) : '');
- global $action, $hookmanager;
- $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;
+ global $action, $hookmanager;
+ $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;
- return $result;
- }
+ return $result;
+ }
/**
* Return amount of payments already done
@@ -605,47 +576,42 @@ class Salary extends CommonObject
$this->db->free($resql);
return $amount;
- }
- else {
+ } else {
return -1;
}
}
- /**
- * Information on record
- *
- * @param int $id Id of record
- * @return void
- */
- public function info($id)
- {
- $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author';
- $sql .= ' FROM '.MAIN_DB_PREFIX.'salary as ps';
- $sql .= ' WHERE ps.rowid = '.$id;
+ /**
+ * Information on record
+ *
+ * @param int $id Id of record
+ * @return void
+ */
+ public function info($id)
+ {
+ $sql = 'SELECT ps.rowid, ps.datec, ps.fk_user_author';
+ $sql .= ' FROM '.MAIN_DB_PREFIX.'salary as ps';
+ $sql .= ' WHERE ps.rowid = '.$id;
- dol_syslog(get_class($this).'::info', LOG_DEBUG);
- $result = $this->db->query($sql);
+ dol_syslog(get_class($this).'::info', LOG_DEBUG);
+ $result = $this->db->query($sql);
- if ($result)
- {
- if ($this->db->num_rows($result))
- {
- $obj = $this->db->fetch_object($result);
- $this->id = $obj->rowid;
- if ($obj->fk_user_author)
- {
- $cuser = new User($this->db);
- $cuser->fetch($obj->fk_user_author);
- $this->user_creation = $cuser;
- }
- $this->date_creation = $this->db->jdate($obj->datec);
- }
- $this->db->free($result);
- }
- else {
- dol_print_error($this->db);
- }
- }
+ if ($result) {
+ if ($this->db->num_rows($result)) {
+ $obj = $this->db->fetch_object($result);
+ $this->id = $obj->rowid;
+ if ($obj->fk_user_author) {
+ $cuser = new User($this->db);
+ $cuser->fetch($obj->fk_user_author);
+ $this->user_creation = $cuser;
+ }
+ $this->date_creation = $this->db->jdate($obj->datec);
+ }
+ $this->db->free($result);
+ } else {
+ dol_print_error($this->db);
+ }
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
@@ -684,17 +650,17 @@ class Salary extends CommonObject
}
- /**
- * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
- *
- * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
- * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
- * @return string Libelle
- */
- public function getLibStatut($mode = 0, $alreadypaid = -1)
- {
- return $this->LibStatut($this->paye, $mode, $alreadypaid);
- }
+ /**
+ * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee)
+ *
+ * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto
+ * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommand to put here amount payed if you have it, 1 otherwise)
+ * @return string Libelle
+ */
+ public function getLibStatut($mode = 0, $alreadypaid = -1)
+ {
+ return $this->LibStatut($this->paye, $mode, $alreadypaid);
+ }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/**
@@ -717,8 +683,7 @@ class Salary extends CommonObject
$this->labelStatus = array();
$this->labelStatusShort = array();
- if (empty($this->labelStatus) || empty($this->labelStatusShort))
- {
+ if (empty($this->labelStatus) || empty($this->labelStatusShort)) {
global $langs;
//$langs->load("mymodule");
$this->labelStatus[self::STATUS_UNPAID] = $langs->trans('BillStatusNotPaid');
diff --git a/htdocs/salaries/payments.php b/htdocs/salaries/payments.php
index 8e1b3e8dbea..f87209eee52 100644
--- a/htdocs/salaries/payments.php
+++ b/htdocs/salaries/payments.php
@@ -77,12 +77,10 @@ $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];
}
@@ -100,15 +98,13 @@ $result = restrictedArea($user, 'salaries', '', '', '');
// Initialize array of search criterias
$search_all = GETPOST("search_all", 'alpha');
$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');
}
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array();
-foreach ($object->fields as $key => $val)
-{
+foreach ($object->fields as $key => $val) {
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
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 +140,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 +151,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
@@ -213,26 +205,22 @@ $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);
$resql = $db->query($sql);
- if (!$resql)
- {
+ if (!$resql) {
dol_print_error($db);
exit;
}
@@ -323,8 +311,7 @@ print '';
$form->select_types_paiements($search_type_id, 'search_type_id', '', 0, 1, 1, 16);
print ' ';
// Account
-if (!empty($conf->banque->enabled))
-{
+if (!empty($conf->banque->enabled)) {
print '';
$form->select_comptes($search_account, 'search_account', 0, '', 1);
print ' ';
@@ -371,10 +358,8 @@ print ''."\n";
// Detect if we need a fetch on each output line
$needToFetchEachLine = 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)
- {
+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) {
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;
$total = 0;
$totalarray = array();
-while ($i < ($limit ? min($num, $limit) : $num))
-{
+while ($i < ($limit ? min($num, $limit) : $num)) {
$obj = $db->fetch_object($resql);
if (empty($obj)) break; // Should not happen
@@ -432,18 +416,15 @@ while ($i < ($limit ? min($num, $limit) : $num))
if (!$i) $totalarray['nbfield']++;
// Account
- if (!empty($conf->banque->enabled))
- {
+ if (!empty($conf->banque->enabled)) {
print '';
- if ($obj->fk_bank > 0)
- {
+ if ($obj->fk_bank > 0) {
//$accountstatic->fetch($obj->fk_bank);
$accountstatic->id = $obj->bid;
$accountstatic->ref = $obj->bref;
$accountstatic->number = $obj->bnumber;
- if (!empty($conf->accounting->enabled))
- {
+ if (!empty($conf->accounting->enabled)) {
$accountstatic->account_number = $obj->account_number;
$accountingjournal = new AccountingJournal($db);
@@ -472,8 +453,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
print $hookmanager->resPrint;
// Action column
print ' ';
- 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;
if (in_array($object->id, $arrayofselected)) $selected = 1;
print ' ';
@@ -491,8 +471,7 @@ include DOL_DOCUMENT_ROOT.'/core/tpl/list_print_total.tpl.php';
// If no record found
-if ($num == 0)
-{
+if ($num == 0) {
$colspan = 1;
foreach ($arrayfields as $key => $val) { if (!empty($val['checked'])) $colspan++; }
print ' '.$langs->trans("NoRecordFound").' ';