| Total Complexity | 92 |
| Total Lines | 653 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like PaymentSalary often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use PaymentSalary, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 34 | class PaymentSalary extends CommonObject |
||
| 35 | { |
||
| 36 | /** |
||
| 37 | * @var string ID to identify managed object |
||
| 38 | */ |
||
| 39 | public $element = 'payment_salary'; |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @var string Name of table without prefix where object is stored |
||
| 43 | */ |
||
| 44 | public $table_element = 'payment_salary'; |
||
| 45 | |||
| 46 | /** |
||
| 47 | * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png |
||
| 48 | */ |
||
| 49 | public $picto = 'payment'; |
||
| 50 | |||
| 51 | /** |
||
| 52 | * @var int ID |
||
| 53 | */ |
||
| 54 | public $fk_salary; |
||
| 55 | |||
| 56 | public $datec = ''; |
||
| 57 | public $tms = ''; |
||
| 58 | public $datep = ''; |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @deprecated |
||
| 62 | * @see $amount |
||
| 63 | */ |
||
| 64 | public $total; |
||
| 65 | |||
| 66 | public $amount; // Total amount of payment |
||
| 67 | public $amounts = array(); // Array of amounts |
||
| 68 | |||
| 69 | /** |
||
| 70 | * @var int ID |
||
| 71 | */ |
||
| 72 | public $fk_typepayment; |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @var string |
||
| 76 | * @deprecated |
||
| 77 | */ |
||
| 78 | public $num_paiement; |
||
| 79 | |||
| 80 | /** |
||
| 81 | * @var string |
||
| 82 | */ |
||
| 83 | public $num_payment; |
||
| 84 | |||
| 85 | /** |
||
| 86 | * @var int ID |
||
| 87 | */ |
||
| 88 | public $fk_bank; |
||
| 89 | |||
| 90 | /** |
||
| 91 | * @var int ID |
||
| 92 | */ |
||
| 93 | public $fk_user_author; |
||
| 94 | |||
| 95 | /** |
||
| 96 | * @var int ID |
||
| 97 | */ |
||
| 98 | public $fk_user_modif; |
||
| 99 | |||
| 100 | /** |
||
| 101 | * Constructor |
||
| 102 | * |
||
| 103 | * @param DoliDB $db Database handler |
||
| 104 | */ |
||
| 105 | public function __construct($db) |
||
| 106 | { |
||
| 107 | $this->db = $db; |
||
| 108 | } |
||
| 109 | |||
| 110 | /** |
||
| 111 | * Create payment of salary into database. |
||
| 112 | * Use this->amounts to have list of lines for the payment |
||
| 113 | * |
||
| 114 | * @param User $user User making payment |
||
| 115 | * @param int $closepaidcontrib 1=Also close payed contributions to paid, 0=Do nothing more |
||
| 116 | * @return int <0 if KO, id of payment if OK |
||
| 117 | */ |
||
| 118 | public function create($user, $closepaidcontrib = 0) |
||
| 119 | { |
||
| 120 | global $conf, $langs; |
||
| 121 | |||
| 122 | $error = 0; |
||
| 123 | |||
| 124 | $now = dol_now(); |
||
| 125 | |||
| 126 | dol_syslog(get_class($this)."::create", LOG_DEBUG); |
||
| 127 | |||
| 128 | // Validate parametres |
||
| 129 | if (!$this->datepaye) |
||
|
|
|||
| 130 | { |
||
| 131 | $this->error = 'ErrorBadValueForParameterCreatePaymentSalary'; |
||
| 132 | return -1; |
||
| 133 | } |
||
| 134 | |||
| 135 | // Clean parameters |
||
| 136 | if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary; |
||
| 137 | if (isset($this->amount)) $this->amount = trim($this->amount); |
||
| 138 | if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; |
||
| 139 | if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated |
||
| 140 | if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); |
||
| 141 | if (isset($this->note)) $this->note = trim($this->note); |
||
| 142 | if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; |
||
| 143 | if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author; |
||
| 144 | if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; |
||
| 145 | |||
| 146 | $totalamount = 0; |
||
| 147 | foreach ($this->amounts as $key => $value) // How payment is dispatch |
||
| 148 | { |
||
| 149 | $newvalue = price2num($value, 'MT'); |
||
| 150 | $this->amounts[$key] = $newvalue; |
||
| 151 | $totalamount += $newvalue; |
||
| 152 | } |
||
| 153 | $totalamount = price2num($totalamount); |
||
| 154 | |||
| 155 | // Check parameters |
||
| 156 | if ($totalamount == 0) return -1; // On accepte les montants negatifs pour les rejets de prelevement mais pas null |
||
| 157 | |||
| 158 | |||
| 159 | $this->db->begin(); |
||
| 160 | |||
| 161 | if ($totalamount != 0) { |
||
| 162 | $sql = "INSERT INTO ".MAIN_DB_PREFIX."payment_salary (fk_salary, datec, datep, amount,"; |
||
| 163 | $sql .= " fk_typepayment, num_payment, note, fk_user_author, fk_bank)"; |
||
| 164 | $sql .= " VALUES ($this->chid, '".$this->db->idate($now)."',"; |
||
| 165 | $sql .= " '".$this->db->idate($this->datepaye)."',"; |
||
| 166 | $sql .= " ".$totalamount.","; |
||
| 167 | $sql .= " ".$this->paiementtype.", '".$this->db->escape($this->num_payment)."', '".$this->db->escape($this->note)."', ".$user->id.","; |
||
| 168 | $sql .= " 0)"; |
||
| 169 | |||
| 170 | $resql = $this->db->query($sql); |
||
| 171 | if ($resql) { |
||
| 172 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."payment_salary"); |
||
| 173 | |||
| 174 | // Insere tableau des montants / factures |
||
| 175 | foreach ($this->amounts as $key => $amount) { |
||
| 176 | $contribid = $key; |
||
| 177 | if (is_numeric($amount) && $amount <> 0) { |
||
| 178 | $amount = price2num($amount); |
||
| 179 | |||
| 180 | // If we want to closed payed invoices |
||
| 181 | if ($closepaidcontrib) { |
||
| 182 | $contrib = new Salary($this->db); |
||
| 183 | $contrib->fetch($contribid); |
||
| 184 | $paiement = $contrib->getSommePaiement(); |
||
| 185 | //$creditnotes=$contrib->getSumCreditNotesUsed(); |
||
| 186 | $creditnotes = 0; |
||
| 187 | //$deposits=$contrib->getSumDepositsUsed(); |
||
| 188 | $deposits = 0; |
||
| 189 | $alreadypayed = price2num($paiement + $creditnotes + $deposits, 'MT'); |
||
| 190 | $remaintopay = price2num($contrib->amount - $paiement - $creditnotes - $deposits, 'MT'); |
||
| 191 | if ($remaintopay == 0) { |
||
| 192 | $result = $contrib->set_paid($user); |
||
| 193 | } |
||
| 194 | else dol_syslog("Remain to pay for conrib ".$contribid." not null. We do nothing."); |
||
| 195 | } |
||
| 196 | } |
||
| 197 | } |
||
| 198 | } |
||
| 199 | else { |
||
| 200 | $error++; |
||
| 201 | } |
||
| 202 | } |
||
| 203 | |||
| 204 | $result = $this->call_trigger('PAYMENTSALARY_CREATE', $user); |
||
| 205 | if ($result < 0) $error++; |
||
| 206 | |||
| 207 | if ($totalamount != 0 && !$error) { |
||
| 208 | $this->amount = $totalamount; |
||
| 209 | $this->total = $totalamount; // deprecated |
||
| 210 | $this->db->commit(); |
||
| 211 | return $this->id; |
||
| 212 | } else { |
||
| 213 | $this->error = $this->db->error(); |
||
| 214 | $this->db->rollback(); |
||
| 215 | return -1; |
||
| 216 | } |
||
| 217 | } |
||
| 218 | |||
| 219 | /** |
||
| 220 | * Load object in memory from database |
||
| 221 | * |
||
| 222 | * @param int $id Id object |
||
| 223 | * @return int <0 if KO, >0 if OK |
||
| 224 | */ |
||
| 225 | public function fetch($id) |
||
| 282 | } |
||
| 283 | } |
||
| 284 | |||
| 285 | |||
| 286 | /** |
||
| 287 | * Update database |
||
| 288 | * |
||
| 289 | * @param User $user User that modify |
||
| 290 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
| 291 | * @return int <0 if KO, >0 if OK |
||
| 292 | */ |
||
| 293 | public function update($user = null, $notrigger = 0) |
||
| 294 | { |
||
| 295 | global $conf, $langs; |
||
| 296 | $error = 0; |
||
| 297 | |||
| 298 | // Clean parameters |
||
| 299 | |||
| 300 | if (isset($this->fk_salary)) $this->fk_salary = (int) $this->fk_salary; |
||
| 301 | if (isset($this->amount)) $this->amount = trim($this->amount); |
||
| 302 | if (isset($this->fk_typepayment)) $this->fk_typepayment = (int) $this->fk_typepayment; |
||
| 303 | if (isset($this->num_paiement)) $this->num_paiement = trim($this->num_paiement); // deprecated |
||
| 304 | if (isset($this->num_payment)) $this->num_payment = trim($this->num_payment); |
||
| 305 | if (isset($this->note)) $this->note = trim($this->note); |
||
| 306 | if (isset($this->fk_bank)) $this->fk_bank = (int) $this->fk_bank; |
||
| 307 | if (isset($this->fk_user_author)) $this->fk_user_author = (int) $this->fk_user_author; |
||
| 308 | if (isset($this->fk_user_modif)) $this->fk_user_modif = (int) $this->fk_user_modif; |
||
| 309 | |||
| 310 | // Check parameters |
||
| 311 | // Put here code to add control on parameters values |
||
| 312 | |||
| 313 | // Update request |
||
| 314 | $sql = "UPDATE ".MAIN_DB_PREFIX."payment_salary SET"; |
||
| 315 | $sql .= " fk_salary=".(isset($this->fk_salary) ? $this->fk_salary : "null").","; |
||
| 316 | $sql .= " datec=".(dol_strlen($this->datec) != 0 ? "'".$this->db->idate($this->datec)."'" : 'null').","; |
||
| 317 | $sql .= " tms=".(dol_strlen($this->tms) != 0 ? "'".$this->db->idate($this->tms)."'" : 'null').","; |
||
| 318 | $sql .= " datep=".(dol_strlen($this->datep) != 0 ? "'".$this->db->idate($this->datep)."'" : 'null').","; |
||
| 319 | $sql .= " amount=".(isset($this->amount) ? $this->amount : "null").","; |
||
| 320 | $sql .= " fk_typepayment=".(isset($this->fk_typepayment) ? $this->fk_typepayment : "null").","; |
||
| 321 | $sql .= " num_payment=".(isset($this->num_payment) ? "'".$this->db->escape($this->num_payment)."'" : "null").","; |
||
| 322 | $sql .= " note=".(isset($this->note) ? "'".$this->db->escape($this->note)."'" : "null").","; |
||
| 323 | $sql .= " fk_bank=".(isset($this->fk_bank) ? $this->fk_bank : "null").","; |
||
| 324 | $sql .= " fk_user_author=".(isset($this->fk_user_author) ? $this->fk_user_author : "null").","; |
||
| 325 | $sql .= " fk_user_modif=".(isset($this->fk_user_modif) ? $this->fk_user_modif : "null").""; |
||
| 326 | $sql .= " WHERE rowid=".$this->id; |
||
| 327 | |||
| 328 | $this->db->begin(); |
||
| 329 | |||
| 330 | dol_syslog(get_class($this)."::update", LOG_DEBUG); |
||
| 331 | $resql = $this->db->query($sql); |
||
| 332 | if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
||
| 333 | |||
| 334 | // Commit or rollback |
||
| 335 | if ($error) { |
||
| 336 | foreach ($this->errors as $errmsg) { |
||
| 337 | dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR); |
||
| 338 | $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
||
| 339 | } |
||
| 340 | $this->db->rollback(); |
||
| 341 | return -1 * $error; |
||
| 342 | } else { |
||
| 343 | $this->db->commit(); |
||
| 344 | return 1; |
||
| 345 | } |
||
| 346 | } |
||
| 347 | |||
| 348 | |||
| 349 | /** |
||
| 350 | * Delete object in database |
||
| 351 | * |
||
| 352 | * @param User $user User that delete |
||
| 353 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
| 354 | * @return int <0 if KO, >0 if OK |
||
| 355 | */ |
||
| 356 | public function delete($user, $notrigger = 0) |
||
| 357 | { |
||
| 358 | global $conf, $langs; |
||
| 359 | $error = 0; |
||
| 360 | |||
| 361 | dol_syslog(get_class($this)."::delete"); |
||
| 362 | |||
| 363 | $this->db->begin(); |
||
| 364 | |||
| 365 | if ($this->bank_line > 0) { |
||
| 366 | $accline = new AccountLine($this->db); |
||
| 367 | $accline->fetch($this->bank_line); |
||
| 368 | $result = $accline->delete(); |
||
| 369 | if ($result < 0) { |
||
| 370 | $this->errors[] = $accline->error; |
||
| 371 | $error++; |
||
| 372 | } |
||
| 373 | } |
||
| 374 | |||
| 375 | if (!$error) { |
||
| 376 | $sql = "DELETE FROM ".MAIN_DB_PREFIX."payment_salary"; |
||
| 377 | $sql .= " WHERE rowid=".$this->id; |
||
| 378 | |||
| 379 | dol_syslog(get_class($this)."::delete", LOG_DEBUG); |
||
| 380 | $resql = $this->db->query($sql); |
||
| 381 | if (!$resql) { $error++; $this->errors[] = "Error ".$this->db->lasterror(); } |
||
| 382 | } |
||
| 383 | |||
| 384 | // Commit or rollback |
||
| 385 | if ($error) { |
||
| 386 | foreach ($this->errors as $errmsg) { |
||
| 387 | dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR); |
||
| 388 | $this->error .= ($this->error ? ', '.$errmsg : $errmsg); |
||
| 389 | } |
||
| 390 | $this->db->rollback(); |
||
| 391 | return -1 * $error; |
||
| 392 | } else { |
||
| 393 | $this->db->commit(); |
||
| 394 | return 1; |
||
| 395 | } |
||
| 396 | } |
||
| 397 | |||
| 398 | |||
| 399 | |||
| 400 | /** |
||
| 401 | * Load an object from its id and create a new one in database |
||
| 402 | * |
||
| 403 | * @param User $user User making the clone |
||
| 404 | * @param int $fromid Id of object to clone |
||
| 405 | * @return int New id of clone |
||
| 406 | */ |
||
| 407 | public function createFromClone(User $user, $fromid) |
||
| 408 | { |
||
| 409 | $error = 0; |
||
| 410 | |||
| 411 | $object = new PaymentSalary($this->db); |
||
| 412 | |||
| 413 | $this->db->begin(); |
||
| 414 | |||
| 415 | // Load source object |
||
| 416 | $object->fetch($fromid); |
||
| 417 | $object->id = 0; |
||
| 418 | $object->statut = 0; |
||
| 419 | |||
| 420 | // Clear fields |
||
| 421 | // ... |
||
| 422 | |||
| 423 | // Create clone |
||
| 424 | $object->context['createfromclone'] = 'createfromclone'; |
||
| 425 | $result = $object->create($user); |
||
| 426 | |||
| 427 | // Other options |
||
| 428 | if ($result < 0) { |
||
| 429 | $this->error = $object->error; |
||
| 430 | $error++; |
||
| 431 | } |
||
| 432 | |||
| 433 | unset($object->context['createfromclone']); |
||
| 434 | |||
| 435 | // End |
||
| 436 | if (!$error) { |
||
| 437 | $this->db->commit(); |
||
| 438 | return $object->id; |
||
| 439 | } else { |
||
| 440 | $this->db->rollback(); |
||
| 441 | return -1; |
||
| 442 | } |
||
| 443 | } |
||
| 444 | |||
| 445 | |||
| 446 | /** |
||
| 447 | * Initialise an instance with random values. |
||
| 448 | * Used to build previews or test instances. |
||
| 449 | * id must be 0 if object instance is a specimen. |
||
| 450 | * |
||
| 451 | * @return void |
||
| 452 | */ |
||
| 453 | public function initAsSpecimen() |
||
| 454 | { |
||
| 455 | $this->id = 0; |
||
| 456 | |||
| 457 | $this->fk_salary = ''; |
||
| 458 | $this->datec = ''; |
||
| 459 | $this->tms = ''; |
||
| 460 | $this->datep = ''; |
||
| 461 | $this->amount = ''; |
||
| 462 | $this->fk_typepayment = ''; |
||
| 463 | $this->num_payment = ''; |
||
| 464 | $this->note_private = ''; |
||
| 465 | $this->note_public = ''; |
||
| 466 | $this->fk_bank = ''; |
||
| 467 | $this->fk_user_author = ''; |
||
| 468 | $this->fk_user_modif = ''; |
||
| 469 | } |
||
| 470 | |||
| 471 | |||
| 472 | /** |
||
| 473 | * Add record into bank for payment with links between this bank record and invoices of payment. |
||
| 474 | * All payment properties must have been set first like after a call to create(). |
||
| 475 | * |
||
| 476 | * @param User $user Object of user making payment |
||
| 477 | * @param string $mode 'payment_sc' |
||
| 478 | * @param string $label Label to use in bank record |
||
| 479 | * @param int $accountid Id of bank account to do link with |
||
| 480 | * @param string $emetteur_nom Name of transmitter |
||
| 481 | * @param string $emetteur_banque Name of bank |
||
| 482 | * @return int <0 if KO, >0 if OK |
||
| 483 | */ |
||
| 484 | public function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) |
||
| 485 | { |
||
| 486 | global $conf; |
||
| 487 | |||
| 488 | // Clean data |
||
| 489 | $this->num_payment = trim($this->num_payment ? $this->num_payment : $this->num_paiement); |
||
|
1 ignored issue
–
show
|
|||
| 490 | |||
| 491 | $error = 0; |
||
| 492 | |||
| 493 | if (!empty($conf->banque->enabled)) { |
||
| 494 | include_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; |
||
| 495 | |||
| 496 | $acc = new Account($this->db); |
||
| 497 | $acc->fetch($accountid); |
||
| 498 | |||
| 499 | $total = $this->amount; |
||
| 500 | |||
| 501 | // Insert payment into llx_bank |
||
| 502 | $bank_line_id = $acc->addline( |
||
| 503 | $this->datepaye, |
||
| 504 | $this->paiementtype, // Payment mode id or code ("CHQ or VIR for example") |
||
| 505 | $label, |
||
| 506 | -$total, |
||
| 507 | $this->num_payment, |
||
| 508 | '', |
||
| 509 | $user, |
||
| 510 | $emetteur_nom, |
||
| 511 | $emetteur_banque, |
||
| 512 | '', |
||
| 513 | $this->datev |
||
| 514 | ); |
||
| 515 | |||
| 516 | // Mise a jour fk_bank dans llx_paiement. |
||
| 517 | // On connait ainsi le paiement qui a genere l'ecriture bancaire |
||
| 518 | if ($bank_line_id > 0) { |
||
| 519 | $result = $this->update_fk_bank($bank_line_id); |
||
| 520 | if ($result <= 0) { |
||
| 521 | $error++; |
||
| 522 | dol_print_error($this->db); |
||
| 523 | } |
||
| 524 | |||
| 525 | // Add link 'payment', 'payment_supplier', 'payment_sc' in bank_url between payment and bank transaction |
||
| 526 | $url = ''; |
||
| 527 | if ($mode == 'payment_salary') $url = DOL_URL_ROOT.'/salaries/payment_salary/card.php?id='; |
||
| 528 | if ($url) { |
||
| 529 | $result = $acc->add_url_line($bank_line_id, $this->id, $url, '(paiement)', $mode); |
||
| 530 | if ($result <= 0) { |
||
| 531 | $error++; |
||
| 532 | dol_print_error($this->db); |
||
| 533 | } |
||
| 534 | } |
||
| 535 | |||
| 536 | // Add link 'company' in bank_url between invoice and bank transaction (for each invoice concerned by payment) |
||
| 537 | $linkaddedforthirdparty = array(); |
||
| 538 | foreach ($this->amounts as $key => $value) { |
||
| 539 | if ($mode == 'payment_salary') { |
||
| 540 | $salary = new Salary($this->db); |
||
| 541 | $salary->fetch($key); |
||
| 542 | $result = $acc->add_url_line($bank_line_id, $salary->id, DOL_URL_ROOT.'/salaries/card.php?id=', '('.$salary->label.')', 'salary'); |
||
| 543 | if ($result <= 0) dol_print_error($this->db); |
||
| 544 | } |
||
| 545 | } |
||
| 546 | } else { |
||
| 547 | $this->error = $acc->error; |
||
| 548 | $error++; |
||
| 549 | } |
||
| 550 | } |
||
| 551 | |||
| 552 | if (!$error) { |
||
| 553 | return 1; |
||
| 554 | } else { |
||
| 555 | return -1; |
||
| 556 | } |
||
| 557 | } |
||
| 558 | |||
| 559 | |||
| 560 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 561 | /** |
||
| 562 | * Mise a jour du lien entre le paiement de salaire et la ligne dans llx_bank generee |
||
| 563 | * |
||
| 564 | * @param int $id_bank Id if bank |
||
| 565 | * @return int >0 if OK, <=0 if KO |
||
| 566 | */ |
||
| 567 | public function update_fk_bank($id_bank) |
||
| 579 | } |
||
| 580 | } |
||
| 581 | |||
| 582 | |||
| 583 | /** |
||
| 584 | * Retourne le libelle du statut d'une facture (brouillon, validee, abandonnee, payee) |
||
| 585 | * |
||
| 586 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
||
| 587 | * @return string Libelle |
||
| 588 | */ |
||
| 589 | public function getLibStatut($mode = 0) |
||
| 592 | } |
||
| 593 | |||
| 594 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 595 | /** |
||
| 596 | * Renvoi le libelle d'un statut donne |
||
| 597 | * |
||
| 598 | * @param int $status Statut |
||
| 599 | * @param int $mode 0=libelle long, 1=libelle court, 2=Picto + Libelle court, 3=Picto, 4=Picto + Libelle long, 5=Libelle court + Picto |
||
| 600 | * @return string Libelle du statut |
||
| 601 | */ |
||
| 602 | public function LibStatut($status, $mode = 0) |
||
| 603 | { |
||
| 604 | // phpcs:enable |
||
| 605 | global $langs; // TODO Renvoyer le libelle anglais et faire traduction a affichage |
||
| 606 | |||
| 607 | $langs->load('compta'); |
||
| 608 | /*if ($mode == 0) |
||
| 609 | { |
||
| 610 | if ($status == 0) return $langs->trans('ToValidate'); |
||
| 611 | if ($status == 1) return $langs->trans('Validated'); |
||
| 612 | } |
||
| 613 | if ($mode == 1) |
||
| 614 | { |
||
| 615 | if ($status == 0) return $langs->trans('ToValidate'); |
||
| 616 | if ($status == 1) return $langs->trans('Validated'); |
||
| 617 | } |
||
| 618 | if ($mode == 2) |
||
| 619 | { |
||
| 620 | if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); |
||
| 621 | if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); |
||
| 622 | } |
||
| 623 | if ($mode == 3) |
||
| 624 | { |
||
| 625 | if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1'); |
||
| 626 | if ($status == 1) return img_picto($langs->trans('Validated'),'statut4'); |
||
| 627 | } |
||
| 628 | if ($mode == 4) |
||
| 629 | { |
||
| 630 | if ($status == 0) return img_picto($langs->trans('ToValidate'),'statut1').' '.$langs->trans('ToValidate'); |
||
| 631 | if ($status == 1) return img_picto($langs->trans('Validated'),'statut4').' '.$langs->trans('Validated'); |
||
| 632 | } |
||
| 633 | if ($mode == 5) |
||
| 634 | { |
||
| 635 | if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); |
||
| 636 | if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); |
||
| 637 | } |
||
| 638 | if ($mode == 6) |
||
| 639 | { |
||
| 640 | if ($status == 0) return $langs->trans('ToValidate').' '.img_picto($langs->trans('ToValidate'),'statut1'); |
||
| 641 | if ($status == 1) return $langs->trans('Validated').' '.img_picto($langs->trans('Validated'),'statut4'); |
||
| 642 | }*/ |
||
| 643 | return ''; |
||
| 644 | } |
||
| 645 | |||
| 646 | /** |
||
| 647 | * Return clicable name (with picto eventually) |
||
| 648 | * |
||
| 649 | * @param int $withpicto 0=No picto, 1=Include picto into link, 2=Only picto |
||
| 650 | * @param int $maxlen Longueur max libelle |
||
| 651 | * @return string Chaine avec URL |
||
| 652 | */ |
||
| 653 | public function getNomUrl($withpicto = 0, $maxlen = 0) |
||
| 687 | } |
||
| 688 | } |
||
| 689 |