| Total Complexity | 127 |
| Total Lines | 735 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
Complex classes like ReceptionLineBatch 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 ReceptionLineBatch, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 40 | class ReceptionLineBatch extends CommonObjectLine |
||
| 41 | { |
||
| 42 | /** |
||
| 43 | * @var DoliDB Database handler. |
||
|
|
|||
| 44 | */ |
||
| 45 | public $db; |
||
| 46 | |||
| 47 | /** |
||
| 48 | * @var string ID to identify managed object |
||
| 49 | */ |
||
| 50 | public $element = 'receptionlinebatch'; |
||
| 51 | |||
| 52 | /** |
||
| 53 | * @var string Name of table without prefix where object is stored |
||
| 54 | */ |
||
| 55 | public $table_element = 'receptiondet_batch'; //!< Name of table without prefix where object is stored |
||
| 56 | public $lines = array(); |
||
| 57 | |||
| 58 | /** |
||
| 59 | * @var int ID |
||
| 60 | */ |
||
| 61 | public $id; |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @var int ID of reception |
||
| 65 | */ |
||
| 66 | public $fk_reception; |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @var int ID Duplicate of origin_id (using origin_id is better) |
||
| 70 | */ |
||
| 71 | public $fk_element; |
||
| 72 | |||
| 73 | /** |
||
| 74 | * @var int ID Duplicate of fk_element |
||
| 75 | */ |
||
| 76 | public $origin_id; |
||
| 77 | |||
| 78 | /** |
||
| 79 | * @var int ID Duplicate of origin_line_id |
||
| 80 | */ |
||
| 81 | public $fk_elementdet; |
||
| 82 | |||
| 83 | /** |
||
| 84 | * @var int ID Duplicate of fk_elementdet |
||
| 85 | */ |
||
| 86 | public $origin_line_id; |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @var string Type of object the fk_element refers to. Example: 'supplier_order'. |
||
| 90 | */ |
||
| 91 | public $element_type; |
||
| 92 | |||
| 93 | /** |
||
| 94 | * @var int ID |
||
| 95 | */ |
||
| 96 | public $fk_product; |
||
| 97 | |||
| 98 | /** |
||
| 99 | * @var float Quantity |
||
| 100 | */ |
||
| 101 | public $qty; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @var float Quantity asked |
||
| 105 | */ |
||
| 106 | public $qty_asked; |
||
| 107 | |||
| 108 | public $libelle; |
||
| 109 | public $label; |
||
| 110 | public $desc; |
||
| 111 | public $tva_tx; |
||
| 112 | public $vat_src_code; |
||
| 113 | public $ref_supplier; |
||
| 114 | |||
| 115 | /** |
||
| 116 | * @var int ID |
||
| 117 | */ |
||
| 118 | public $fk_entrepot; |
||
| 119 | |||
| 120 | /** |
||
| 121 | * @var int User ID |
||
| 122 | */ |
||
| 123 | public $fk_user; |
||
| 124 | |||
| 125 | public $datec = ''; |
||
| 126 | public $comment; |
||
| 127 | |||
| 128 | /** |
||
| 129 | * @var int Status |
||
| 130 | */ |
||
| 131 | public $status; |
||
| 132 | |||
| 133 | public $batch; |
||
| 134 | public $eatby = ''; |
||
| 135 | public $sellby = ''; |
||
| 136 | public $cost_price = 0; |
||
| 137 | |||
| 138 | |||
| 139 | |||
| 140 | |||
| 141 | /** |
||
| 142 | * Constructor |
||
| 143 | * |
||
| 144 | * @param DoliDB $db Database handler |
||
| 145 | */ |
||
| 146 | public function __construct($db) |
||
| 157 | } |
||
| 158 | |||
| 159 | |||
| 160 | /** |
||
| 161 | * Create object into database |
||
| 162 | * |
||
| 163 | * @param User $user User that creates |
||
| 164 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
| 165 | * @return int Return integer <0 if KO, Id of created object if OK |
||
| 166 | */ |
||
| 167 | public function create($user, $notrigger = 0) |
||
| 168 | { |
||
| 169 | $error = 0; |
||
| 170 | |||
| 171 | // Clean parameters |
||
| 172 | if (isset($this->fk_element)) { |
||
| 173 | $this->fk_element = (int) $this->fk_element; |
||
| 174 | } |
||
| 175 | if (isset($this->fk_product)) { |
||
| 176 | $this->fk_product = (int) $this->fk_product; |
||
| 177 | } |
||
| 178 | if (isset($this->fk_elementdet)) { |
||
| 179 | $this->fk_elementdet = (int) $this->fk_elementdet; |
||
| 180 | } |
||
| 181 | if (isset($this->qty)) { |
||
| 182 | $this->qty = (float) $this->qty; |
||
| 183 | } |
||
| 184 | if (isset($this->fk_entrepot)) { |
||
| 185 | $this->fk_entrepot = (int) $this->fk_entrepot; |
||
| 186 | } |
||
| 187 | if (isset($this->fk_user)) { |
||
| 188 | $this->fk_user = (int) $this->fk_user; |
||
| 189 | } |
||
| 190 | if (isset($this->comment)) { |
||
| 191 | $this->comment = trim($this->comment); |
||
| 192 | } |
||
| 193 | if (isset($this->status)) { |
||
| 194 | $this->status = (int) $this->status; |
||
| 195 | } |
||
| 196 | if (isset($this->batch)) { |
||
| 197 | $this->batch = trim($this->batch); |
||
| 198 | } |
||
| 199 | if (empty($this->datec)) { |
||
| 200 | $this->datec = dol_now(); |
||
| 201 | } |
||
| 202 | |||
| 203 | // Check parameters |
||
| 204 | if (empty($this->fk_product)) { |
||
| 205 | $this->error = 'Error, property ->fk_product must not be empty to create a line of reception'; |
||
| 206 | return -1; |
||
| 207 | } |
||
| 208 | if (empty($this->fk_reception)) { |
||
| 209 | $this->error = 'Error, property ->fk_reception must not be empty to create a line of reception'; |
||
| 210 | return -1; |
||
| 211 | } |
||
| 212 | |||
| 213 | // Insert request |
||
| 214 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . $this->table_element . "("; |
||
| 215 | $sql .= "fk_product,"; |
||
| 216 | $sql .= "fk_element,"; |
||
| 217 | $sql .= "fk_elementdet,"; |
||
| 218 | $sql .= "element_type,"; |
||
| 219 | $sql .= "qty,"; |
||
| 220 | $sql .= "fk_entrepot,"; |
||
| 221 | $sql .= "fk_user,"; |
||
| 222 | $sql .= "datec,"; |
||
| 223 | $sql .= "comment,"; |
||
| 224 | $sql .= "status,"; |
||
| 225 | $sql .= "batch,"; |
||
| 226 | $sql .= "eatby,"; |
||
| 227 | $sql .= "sellby,"; |
||
| 228 | $sql .= "fk_reception,"; |
||
| 229 | $sql .= "cost_price"; |
||
| 230 | $sql .= ") VALUES ("; |
||
| 231 | $sql .= " " . (!isset($this->fk_product) ? 'NULL' : (int) $this->fk_product) . ","; |
||
| 232 | $sql .= " " . (!isset($this->fk_element) ? 'NULL' : (int) $this->fk_element) . ","; |
||
| 233 | $sql .= " " . (!isset($this->fk_elementdet) ? 'NULL' : (int) $this->fk_elementdet) . ","; |
||
| 234 | $sql .= " '" . (!isset($this->element_type) ? "supplier_order" : $this->db->escape($this->element_type)) . "',"; |
||
| 235 | $sql .= " " . (!isset($this->qty) ? 'NULL' : (float) $this->qty) . ","; |
||
| 236 | $sql .= " " . (!isset($this->fk_entrepot) ? 'NULL' : (int) $this->fk_entrepot) . ","; |
||
| 237 | $sql .= " " . (!isset($this->fk_user) ? 'NULL' : (int) $this->fk_user) . ","; |
||
| 238 | $sql .= " " . (!isset($this->datec) || dol_strlen($this->datec) == 0 ? 'NULL' : "'" . $this->db->idate($this->datec) . "'") . ","; |
||
| 239 | $sql .= " " . (!isset($this->comment) ? 'NULL' : "'" . $this->db->escape($this->comment) . "'") . ","; |
||
| 240 | $sql .= " " . (!isset($this->status) ? 'NULL' : (int) $this->status) . ","; |
||
| 241 | $sql .= " " . (!isset($this->batch) ? 'NULL' : "'" . $this->db->escape($this->batch) . "'") . ","; |
||
| 242 | $sql .= " " . (!isset($this->eatby) || dol_strlen($this->eatby) == 0 ? 'NULL' : "'" . $this->db->idate($this->eatby) . "'") . ","; |
||
| 243 | $sql .= " " . (!isset($this->sellby) || dol_strlen($this->sellby) == 0 ? 'NULL' : "'" . $this->db->idate($this->sellby) . "'") . ","; |
||
| 244 | $sql .= " " . ((int) $this->fk_reception) . ","; |
||
| 245 | $sql .= " " . (!isset($this->cost_price) ? '0' : (float) $this->cost_price); |
||
| 246 | $sql .= ")"; |
||
| 247 | |||
| 248 | $this->db->begin(); |
||
| 249 | |||
| 250 | dol_syslog(__METHOD__, LOG_DEBUG); |
||
| 251 | $resql = $this->db->query($sql); |
||
| 252 | if (!$resql) { |
||
| 253 | $error++; |
||
| 254 | $this->errors[] = "Error " . $this->db->lasterror(); |
||
| 255 | } |
||
| 256 | |||
| 257 | if (!$error) { |
||
| 258 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . $this->table_element); |
||
| 259 | |||
| 260 | if (!$notrigger) { |
||
| 261 | // Call triggers |
||
| 262 | $result = $this->call_trigger('LINERECEPTION_CREATE', $user); |
||
| 263 | if ($result < 0) { |
||
| 264 | $error++; |
||
| 265 | } |
||
| 266 | // End call triggers |
||
| 267 | } |
||
| 268 | } |
||
| 269 | |||
| 270 | // Create extrafields |
||
| 271 | if (!$error) { |
||
| 272 | $result = $this->insertExtraFields(); |
||
| 273 | if ($result < 0) { |
||
| 274 | $error++; |
||
| 275 | } |
||
| 276 | } |
||
| 277 | |||
| 278 | // Commit or rollback |
||
| 279 | if ($error) { |
||
| 280 | foreach ($this->errors as $errmsg) { |
||
| 281 | dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); |
||
| 282 | $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
||
| 283 | } |
||
| 284 | $this->db->rollback(); |
||
| 285 | return -1 * $error; |
||
| 286 | } else { |
||
| 287 | $this->db->commit(); |
||
| 288 | return $this->id; |
||
| 289 | } |
||
| 290 | } |
||
| 291 | |||
| 292 | |||
| 293 | /** |
||
| 294 | * Load object in memory from the database |
||
| 295 | * |
||
| 296 | * @param int $id Id object |
||
| 297 | * @param string $ref Ref |
||
| 298 | * @return int Return integer <0 if KO, >0 if OK |
||
| 299 | */ |
||
| 300 | public function fetch($id, $ref = '') |
||
| 301 | { |
||
| 302 | $sql = "SELECT"; |
||
| 303 | $sql .= " t.rowid,"; |
||
| 304 | $sql .= " t.fk_element,"; |
||
| 305 | $sql .= " t.fk_elementdet,"; |
||
| 306 | $sql .= " t.element_type,"; |
||
| 307 | $sql .= " t.fk_product,"; |
||
| 308 | $sql .= " t.qty,"; |
||
| 309 | $sql .= " t.fk_entrepot,"; |
||
| 310 | $sql .= " t.fk_user,"; |
||
| 311 | $sql .= " t.datec,"; |
||
| 312 | $sql .= " t.comment,"; |
||
| 313 | $sql .= " t.status,"; |
||
| 314 | $sql .= " t.tms,"; |
||
| 315 | $sql .= " t.batch,"; |
||
| 316 | $sql .= " t.eatby,"; |
||
| 317 | $sql .= " t.sellby,"; |
||
| 318 | $sql .= " t.fk_reception"; |
||
| 319 | $sql .= " FROM " . MAIN_DB_PREFIX . $this->table_element . " as t"; |
||
| 320 | if ($ref) { |
||
| 321 | $sql .= " WHERE t.ref = '" . $this->db->escape($ref) . "'"; |
||
| 322 | } else { |
||
| 323 | $sql .= " WHERE t.rowid = " . ((int) $id); |
||
| 324 | } |
||
| 325 | |||
| 326 | dol_syslog(get_class($this) . "::fetch"); |
||
| 327 | $resql = $this->db->query($sql); |
||
| 328 | if ($resql) { |
||
| 329 | if ($this->db->num_rows($resql)) { |
||
| 330 | $obj = $this->db->fetch_object($resql); |
||
| 331 | |||
| 332 | $this->id = $obj->rowid; |
||
| 333 | |||
| 334 | $this->fk_element = $obj->fk_element; |
||
| 335 | $this->origin_id = $obj->fk_element; |
||
| 336 | $this->fk_elementdet = $obj->fk_elementdet; |
||
| 337 | $this->origin_line_id = $obj->fk_elementdet; |
||
| 338 | $this->element_type = $obj->element_type; |
||
| 339 | $this->origin_type = $obj->element_type; |
||
| 340 | |||
| 341 | $this->fk_product = $obj->fk_product; |
||
| 342 | $this->qty = $obj->qty; |
||
| 343 | $this->fk_entrepot = $obj->fk_entrepot; |
||
| 344 | $this->fk_user = $obj->fk_user; |
||
| 345 | $this->datec = $this->db->jdate($obj->datec); |
||
| 346 | $this->comment = $obj->comment; |
||
| 347 | $this->status = $obj->status; |
||
| 348 | $this->tms = $this->db->jdate($obj->tms); |
||
| 349 | $this->batch = $obj->batch; |
||
| 350 | $this->eatby = $this->db->jdate($obj->eatby); |
||
| 351 | $this->sellby = $this->db->jdate($obj->sellby); |
||
| 352 | $this->fk_reception = $obj->fk_reception; |
||
| 353 | |||
| 354 | $this->fetch_optionals(); |
||
| 355 | } |
||
| 356 | $this->db->free($resql); |
||
| 357 | |||
| 358 | return 1; |
||
| 359 | } else { |
||
| 360 | $this->error = "Error " . $this->db->lasterror(); |
||
| 361 | return -1; |
||
| 362 | } |
||
| 363 | } |
||
| 364 | |||
| 365 | |||
| 366 | /** |
||
| 367 | * Update object into database |
||
| 368 | * |
||
| 369 | * @param User $user User that modifies |
||
| 370 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
| 371 | * @return int Return integer <0 if KO, >0 if OK |
||
| 372 | */ |
||
| 373 | public function update($user, $notrigger = 0) |
||
| 374 | { |
||
| 375 | $error = 0; |
||
| 376 | |||
| 377 | // Clean parameters |
||
| 378 | |||
| 379 | if (isset($this->fk_element)) { |
||
| 380 | $this->fk_element = (int) $this->fk_element; |
||
| 381 | } |
||
| 382 | if (isset($this->fk_product)) { |
||
| 383 | $this->fk_product = (int) $this->fk_product; |
||
| 384 | } |
||
| 385 | if (isset($this->fk_elementdet)) { |
||
| 386 | $this->fk_elementdet = (int) $this->fk_elementdet; |
||
| 387 | } |
||
| 388 | if (isset($this->qty)) { |
||
| 389 | $this->qty = (float) $this->qty; |
||
| 390 | } |
||
| 391 | if (isset($this->fk_entrepot)) { |
||
| 392 | $this->fk_entrepot = (int) $this->fk_entrepot; |
||
| 393 | } |
||
| 394 | if (isset($this->fk_user)) { |
||
| 395 | $this->fk_user = (int) $this->fk_user; |
||
| 396 | } |
||
| 397 | if (isset($this->comment)) { |
||
| 398 | $this->comment = trim($this->comment); |
||
| 399 | } |
||
| 400 | if (isset($this->status)) { |
||
| 401 | $this->status = (int) $this->status; |
||
| 402 | } |
||
| 403 | if (isset($this->batch)) { |
||
| 404 | $this->batch = trim($this->batch); |
||
| 405 | } |
||
| 406 | |||
| 407 | |||
| 408 | |||
| 409 | // Check parameters |
||
| 410 | // Put here code to add a control on parameters values |
||
| 411 | |||
| 412 | // Update request |
||
| 413 | $sql = "UPDATE " . MAIN_DB_PREFIX . $this->table_element . " SET"; |
||
| 414 | $sql .= " fk_element=" . (isset($this->fk_element) ? $this->fk_element : "null") . ","; |
||
| 415 | $sql .= " fk_product=" . (isset($this->fk_product) ? $this->fk_product : "null") . ","; |
||
| 416 | $sql .= " fk_elementdet=" . (isset($this->fk_elementdet) ? $this->fk_elementdet : "null") . ","; |
||
| 417 | $sql .= " qty=" . (isset($this->qty) ? $this->qty : "null") . ","; |
||
| 418 | $sql .= " fk_entrepot=" . (isset($this->fk_entrepot) ? $this->fk_entrepot : "null") . ","; |
||
| 419 | $sql .= " fk_user=" . (isset($this->fk_user) ? $this->fk_user : "null") . ","; |
||
| 420 | $sql .= " datec=" . (dol_strlen($this->datec) != 0 ? "'" . $this->db->idate($this->datec) . "'" : 'null') . ","; |
||
| 421 | $sql .= " comment=" . (isset($this->comment) ? "'" . $this->db->escape($this->comment) . "'" : "null") . ","; |
||
| 422 | $sql .= " status=" . (isset($this->status) ? $this->status : "null") . ","; |
||
| 423 | $sql .= " tms=" . (dol_strlen($this->tms) != 0 ? "'" . $this->db->idate($this->tms) . "'" : 'null') . ","; |
||
| 424 | $sql .= " batch=" . (isset($this->batch) ? "'" . $this->db->escape($this->batch) . "'" : "null") . ","; |
||
| 425 | $sql .= " eatby=" . (dol_strlen($this->eatby) != 0 ? "'" . $this->db->idate($this->eatby) . "'" : 'null') . ","; |
||
| 426 | $sql .= " sellby=" . (dol_strlen($this->sellby) != 0 ? "'" . $this->db->idate($this->sellby) . "'" : 'null'); |
||
| 427 | $sql .= " WHERE rowid=" . ((int) $this->id); |
||
| 428 | |||
| 429 | $this->db->begin(); |
||
| 430 | |||
| 431 | dol_syslog(__METHOD__); |
||
| 432 | $resql = $this->db->query($sql); |
||
| 433 | if (!$resql) { |
||
| 434 | $error++; |
||
| 435 | $this->errors[] = "Error " . $this->db->lasterror(); |
||
| 436 | } |
||
| 437 | |||
| 438 | if (!$error) { |
||
| 439 | if (empty($this->id) && !empty($this->rowid)) { |
||
| 440 | $this->id = $this->rowid; |
||
| 441 | } |
||
| 442 | $result = $this->insertExtraFields(); |
||
| 443 | if ($result < 0) { |
||
| 444 | $error++; |
||
| 445 | } |
||
| 446 | |||
| 447 | if (!$notrigger) { |
||
| 448 | // Call triggers |
||
| 449 | $result = $this->call_trigger('LINERECEPTION_MODIFY', $user); |
||
| 450 | if ($result < 0) { |
||
| 451 | $error++; |
||
| 452 | } |
||
| 453 | // End call triggers |
||
| 454 | } |
||
| 455 | } |
||
| 456 | |||
| 457 | // Commit or rollback |
||
| 458 | if ($error) { |
||
| 459 | foreach ($this->errors as $errmsg) { |
||
| 460 | dol_syslog(__METHOD__ . " " . $errmsg, LOG_ERR); |
||
| 461 | $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
||
| 462 | } |
||
| 463 | $this->db->rollback(); |
||
| 464 | return -1 * $error; |
||
| 465 | } else { |
||
| 466 | $this->db->commit(); |
||
| 467 | return 1; |
||
| 468 | } |
||
| 469 | } |
||
| 470 | |||
| 471 | |||
| 472 | /** |
||
| 473 | * Delete object in database |
||
| 474 | * |
||
| 475 | * @param User $user User that deletes |
||
| 476 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
| 477 | * @return int Return integer <0 if KO, >0 if OK |
||
| 478 | */ |
||
| 479 | public function delete($user, $notrigger = 0) |
||
| 528 | } |
||
| 529 | } |
||
| 530 | |||
| 531 | |||
| 532 | /** |
||
| 533 | * Load an object from its id and create a new one in database |
||
| 534 | * |
||
| 535 | * @param User $user User making the clone |
||
| 536 | * @param int $fromid Id of object to clone |
||
| 537 | * @return int New id of clone |
||
| 538 | */ |
||
| 539 | public function createFromClone(User $user, $fromid) |
||
| 577 | } |
||
| 578 | } |
||
| 579 | |||
| 580 | |||
| 581 | |||
| 582 | /** |
||
| 583 | * Return label of the status of object |
||
| 584 | * |
||
| 585 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto |
||
| 586 | * @return string Label |
||
| 587 | */ |
||
| 588 | public function getLibStatut($mode = 0) |
||
| 589 | { |
||
| 590 | return $this->LibStatut($this->status, $mode); |
||
| 591 | } |
||
| 592 | |||
| 593 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
| 594 | /** |
||
| 595 | * Return label of a status |
||
| 596 | * |
||
| 597 | * @param int $status Id status |
||
| 598 | * @param int $mode 0=Long label, 1=Short label, 2=Picto + Short label, 3=Picto, 4=Picto + Long label, 5=Short label + Picto |
||
| 599 | * @return string Label of status |
||
| 600 | */ |
||
| 601 | public function LibStatut($status, $mode = 0) |
||
| 602 | { |
||
| 603 | // phpcs:enable |
||
| 604 | global $langs; |
||
| 605 | $langs->load('orders'); |
||
| 606 | |||
| 607 | if ($mode == 0) { |
||
| 608 | return $langs->trans($this->labelStatus[$status]); |
||
| 609 | } elseif ($mode == 1) { |
||
| 610 | return $langs->trans($this->labelStatusShort[$status]); |
||
| 611 | } elseif ($mode == 2) { |
||
| 612 | return $langs->trans($this->labelStatus[$status]); |
||
| 613 | } elseif ($mode == 3) { |
||
| 614 | if ($status == 0) { |
||
| 615 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut0'); |
||
| 616 | } elseif ($status == 1) { |
||
| 617 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut4'); |
||
| 618 | } elseif ($status == 2) { |
||
| 619 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut8'); |
||
| 620 | } |
||
| 621 | } elseif ($mode == 4) { |
||
| 622 | if ($status == 0) { |
||
| 623 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut0') . ' ' . $langs->trans($this->labelStatus[$status]); |
||
| 624 | } elseif ($status == 1) { |
||
| 625 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut4') . ' ' . $langs->trans($this->labelStatus[$status]); |
||
| 626 | } elseif ($status == 2) { |
||
| 627 | return img_picto($langs->trans($this->labelStatus[$status]), 'statut8') . ' ' . $langs->trans($this->labelStatus[$status]); |
||
| 628 | } |
||
| 629 | } elseif ($mode == 5) { |
||
| 630 | if ($status == 0) { |
||
| 631 | return '<span class="hideonsmartphone">' . $langs->trans($this->labelStatusShort[$status]) . ' </span>' . img_picto($langs->trans($this->labelStatus[$status]), 'statut0'); |
||
| 632 | } elseif ($status == 1) { |
||
| 633 | return '<span class="hideonsmartphone">' . $langs->trans($this->labelStatusShort[$status]) . ' </span>' . img_picto($langs->trans($this->labelStatus[$status]), 'statut4'); |
||
| 634 | } elseif ($status == 2) { |
||
| 635 | return '<span class="hideonsmartphone">' . $langs->trans($this->labelStatusShort[$status]) . ' </span>' . img_picto($langs->trans($this->labelStatus[$status]), 'statut8'); |
||
| 636 | } |
||
| 637 | } |
||
| 638 | return ""; |
||
| 639 | } |
||
| 640 | |||
| 641 | |||
| 642 | /** |
||
| 643 | * Initialise object with example values |
||
| 644 | * Id must be 0 if object instance is a specimen |
||
| 645 | * |
||
| 646 | * @return int |
||
| 647 | */ |
||
| 648 | public function initAsSpecimen() |
||
| 667 | } |
||
| 668 | |||
| 669 | /** |
||
| 670 | * Load object in memory from the database |
||
| 671 | * |
||
| 672 | * @param string $sortorder Sort Order |
||
| 673 | * @param string $sortfield Sort field |
||
| 674 | * @param int $limit limit |
||
| 675 | * @param int $offset offset limit |
||
| 676 | * @param string|array $filter filter array |
||
| 677 | * @param string $filtermode filter mode (AND or OR) |
||
| 678 | * @return int Return integer <0 if KO, >0 if OK |
||
| 679 | */ |
||
| 680 | public function fetchAll($sortorder = '', $sortfield = '', $limit = 0, $offset = 0, $filter = '', $filtermode = 'AND') |
||
| 775 | } |
||
| 776 | } |
||
| 777 | } |
||
| 778 |