Total Complexity | 106 |
Total Lines | 770 |
Duplicated Lines | 0 % |
Changes | 0 |
Complex classes like ChargeSociales 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 ChargeSociales, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
41 | class ChargeSociales extends CommonObject |
||
42 | { |
||
43 | /** |
||
44 | * @var string ID to identify managed object |
||
45 | */ |
||
46 | public $element = 'chargesociales'; |
||
47 | |||
48 | public $table = 'chargesociales'; |
||
49 | |||
50 | /** |
||
51 | * @var string Name of table without prefix where object is stored |
||
52 | */ |
||
53 | public $table_element = 'chargesociales'; |
||
54 | |||
55 | /** |
||
56 | * @var string String with name of icon for myobject. Must be the part after the 'object_' into object_myobject.png |
||
57 | */ |
||
58 | public $picto = 'bill'; |
||
59 | |||
60 | /** |
||
61 | * {@inheritdoc} |
||
62 | */ |
||
63 | protected $table_ref_field = 'ref'; |
||
64 | |||
65 | /** |
||
66 | * @var integer|string $date_ech |
||
67 | */ |
||
68 | public $date_ech; |
||
69 | |||
70 | |||
71 | public $label; |
||
72 | public $type; |
||
73 | public $type_label; |
||
74 | |||
75 | public $amount; |
||
76 | public $paye; |
||
77 | /** |
||
78 | * @deprecated |
||
79 | */ |
||
80 | public $periode; |
||
81 | public $period; |
||
82 | |||
83 | /** |
||
84 | * @var integer|string date_creation |
||
85 | */ |
||
86 | public $date_creation; |
||
87 | |||
88 | /** |
||
89 | * @var integer|string $date_modification |
||
90 | */ |
||
91 | public $date_modification; |
||
92 | |||
93 | /** |
||
94 | * @var integer|string $date_validation |
||
95 | */ |
||
96 | public $date_validation; |
||
97 | |||
98 | /** |
||
99 | * @deprecated Use label instead |
||
100 | */ |
||
101 | public $lib; |
||
102 | |||
103 | /** |
||
104 | * @var int account ID |
||
105 | */ |
||
106 | public $fk_account; |
||
107 | |||
108 | /** |
||
109 | * @var int account ID (identical to fk_account) |
||
110 | */ |
||
111 | public $accountid; |
||
112 | |||
113 | /** |
||
114 | * @var int payment type (identical to mode_reglement_id in commonobject class) |
||
115 | */ |
||
116 | public $paiementtype; |
||
117 | |||
118 | public $mode_reglement_id; |
||
119 | public $mode_reglement_code; |
||
120 | public $mode_reglement; |
||
121 | |||
122 | /** |
||
123 | * @var int ID |
||
124 | */ |
||
125 | public $fk_project; |
||
126 | |||
127 | /** |
||
128 | * @var int ID |
||
129 | */ |
||
130 | public $fk_user; |
||
131 | |||
132 | /** |
||
133 | * @var double total |
||
134 | */ |
||
135 | public $total; |
||
136 | |||
137 | public $totalpaid; |
||
138 | |||
139 | |||
140 | const STATUS_UNPAID = 0; |
||
141 | const STATUS_PAID = 1; |
||
142 | |||
143 | |||
144 | /** |
||
145 | * Constructor |
||
146 | * |
||
147 | * @param DoliDB $db Database handler |
||
148 | */ |
||
149 | public function __construct(DoliDB $db) |
||
150 | { |
||
151 | $this->db = $db; |
||
152 | } |
||
153 | |||
154 | /** |
||
155 | * Retrouve et charge une charge sociale |
||
156 | * |
||
157 | * @param int $id Id |
||
158 | * @param string $ref Ref |
||
159 | * @return int Return integer <0 KO >0 OK |
||
160 | */ |
||
161 | public function fetch($id, $ref = '') |
||
162 | { |
||
163 | $sql = "SELECT cs.rowid, cs.date_ech"; |
||
164 | $sql .= ", cs.libelle as label, cs.fk_type, cs.amount, cs.fk_projet as fk_project, cs.paye, cs.periode as period, cs.import_key"; |
||
165 | $sql .= ", cs.fk_account, cs.fk_mode_reglement, cs.fk_user, note_public, note_private"; |
||
166 | $sql .= ", c.libelle as type_label"; |
||
167 | $sql .= ', p.code as mode_reglement_code, p.libelle as mode_reglement_libelle'; |
||
168 | $sql .= " FROM " . MAIN_DB_PREFIX . "chargesociales as cs"; |
||
169 | $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "c_chargesociales as c ON cs.fk_type = c.id"; |
||
170 | $sql .= ' LEFT JOIN ' . MAIN_DB_PREFIX . 'c_paiement as p ON cs.fk_mode_reglement = p.id'; |
||
171 | $sql .= ' WHERE cs.entity IN (' . getEntity('tax') . ')'; |
||
172 | if ($ref) { |
||
173 | $sql .= " AND cs.ref = '" . $this->db->escape($ref) . "'"; |
||
174 | } else { |
||
175 | $sql .= " AND cs.rowid = " . ((int) $id); |
||
176 | } |
||
177 | |||
178 | dol_syslog(get_class($this) . "::fetch", LOG_DEBUG); |
||
179 | $resql = $this->db->query($sql); |
||
180 | if ($resql) { |
||
181 | if ($this->db->num_rows($resql)) { |
||
182 | $obj = $this->db->fetch_object($resql); |
||
183 | |||
184 | $this->id = $obj->rowid; |
||
185 | $this->ref = $obj->rowid; |
||
186 | $this->date_ech = $this->db->jdate($obj->date_ech); |
||
187 | $this->lib = $obj->label; |
||
|
|||
188 | $this->label = $obj->label; |
||
189 | $this->type = $obj->fk_type; |
||
190 | $this->type_label = $obj->type_label; |
||
191 | $this->fk_account = $obj->fk_account; |
||
192 | $this->mode_reglement_id = $obj->fk_mode_reglement; |
||
193 | $this->mode_reglement_code = $obj->mode_reglement_code; |
||
194 | $this->mode_reglement = $obj->mode_reglement_libelle; |
||
195 | $this->amount = $obj->amount; |
||
196 | $this->fk_project = $obj->fk_project; |
||
197 | $this->fk_user = $obj->fk_user; |
||
198 | $this->note_public = $obj->note_public; |
||
199 | $this->note_private = $obj->note_private; |
||
200 | $this->paye = $obj->paye; |
||
201 | $this->periode = $this->db->jdate($obj->period); |
||
202 | $this->period = $this->db->jdate($obj->period); |
||
203 | $this->import_key = $obj->import_key; |
||
204 | |||
205 | $this->db->free($resql); |
||
206 | |||
207 | return 1; |
||
208 | } else { |
||
209 | return 0; |
||
210 | } |
||
211 | } else { |
||
212 | $this->error = $this->db->lasterror(); |
||
213 | return -1; |
||
214 | } |
||
215 | } |
||
216 | |||
217 | /** |
||
218 | * Check if a social contribution can be created into database |
||
219 | * |
||
220 | * @return boolean True or false |
||
221 | */ |
||
222 | public function check() |
||
223 | { |
||
224 | $newamount = price2num($this->amount, 'MT'); |
||
225 | |||
226 | // Validation of parameters |
||
227 | if ($newamount == 0 || empty($this->date_ech) || (empty($this->period) && empty($this->periode))) { |
||
228 | return false; |
||
229 | } |
||
230 | |||
231 | return true; |
||
232 | } |
||
233 | |||
234 | /** |
||
235 | * Create a social contribution into database |
||
236 | * |
||
237 | * @param User $user User making creation |
||
238 | * @return int Return integer <0 if KO, id if OK |
||
239 | */ |
||
240 | public function create($user) |
||
241 | { |
||
242 | global $conf; |
||
243 | $error = 0; |
||
244 | |||
245 | $now = dol_now(); |
||
246 | |||
247 | // Nettoyage parameters |
||
248 | $newamount = price2num($this->amount, 'MT'); |
||
249 | |||
250 | if (!$this->check()) { |
||
251 | $this->error = "ErrorBadParameter"; |
||
252 | return -2; |
||
253 | } |
||
254 | |||
255 | $this->db->begin(); |
||
256 | |||
257 | $sql = "INSERT INTO " . MAIN_DB_PREFIX . "chargesociales (fk_type, fk_account, fk_mode_reglement, libelle, date_ech, periode, amount, fk_projet, entity, fk_user_author, fk_user, date_creation)"; |
||
258 | $sql .= " VALUES (" . ((int) $this->type); |
||
259 | $sql .= ", " . ($this->fk_account > 0 ? ((int) $this->fk_account) : 'NULL'); |
||
260 | $sql .= ", " . ($this->mode_reglement_id > 0 ? ((int) $this->mode_reglement_id) : "NULL"); |
||
261 | $sql .= ", '" . $this->db->escape($this->label ? $this->label : $this->lib) . "'"; |
||
262 | $sql .= ", '" . $this->db->idate($this->date_ech) . "'"; |
||
263 | $sql .= ", '" . $this->db->idate($this->periode) . "'"; |
||
264 | $sql .= ", '" . price2num($newamount) . "'"; |
||
265 | $sql .= ", " . ($this->fk_project > 0 ? ((int) $this->fk_project) : 'NULL'); |
||
266 | $sql .= ", " . ((int) $conf->entity); |
||
267 | $sql .= ", " . ((int) $user->id); |
||
268 | $sql .= ", " . ($this->fk_user > 0 ? ((int) $this->fk_user) : 'NULL'); |
||
269 | $sql .= ", '" . $this->db->idate($now) . "'"; |
||
270 | $sql .= ")"; |
||
271 | |||
272 | dol_syslog(get_class($this) . "::create", LOG_DEBUG); |
||
273 | $resql = $this->db->query($sql); |
||
274 | if ($resql) { |
||
275 | $this->id = $this->db->last_insert_id(MAIN_DB_PREFIX . "chargesociales"); |
||
276 | |||
277 | //dol_syslog("ChargesSociales::create this->id=".$this->id); |
||
278 | $result = $this->call_trigger('SOCIALCONTRIBUTION_CREATE', $user); |
||
279 | if ($result < 0) { |
||
280 | $error++; |
||
281 | } |
||
282 | |||
283 | if (empty($error)) { |
||
284 | $this->db->commit(); |
||
285 | return $this->id; |
||
286 | } else { |
||
287 | $this->db->rollback(); |
||
288 | return -1 * $error; |
||
289 | } |
||
290 | } else { |
||
291 | $this->error = $this->db->error(); |
||
292 | $this->db->rollback(); |
||
293 | return -1; |
||
294 | } |
||
295 | } |
||
296 | |||
297 | |||
298 | /** |
||
299 | * Delete a social contribution |
||
300 | * |
||
301 | * @param User $user Object user making delete |
||
302 | * @return int Return integer <0 if KO, >0 if OK |
||
303 | */ |
||
304 | public function delete($user) |
||
353 | } |
||
354 | } |
||
355 | |||
356 | |||
357 | /** |
||
358 | * Update social or fiscal contribution |
||
359 | * |
||
360 | * @param User $user User that modify |
||
361 | * @param int $notrigger 0=launch triggers after, 1=disable triggers |
||
362 | * @return int Return integer <0 if KO, >0 if OK |
||
363 | */ |
||
364 | public function update($user, $notrigger = 0) |
||
365 | { |
||
366 | $error = 0; |
||
367 | $this->db->begin(); |
||
368 | |||
369 | $sql = "UPDATE " . MAIN_DB_PREFIX . "chargesociales"; |
||
370 | $sql .= " SET libelle='" . $this->db->escape($this->label ? $this->label : $this->lib) . "'"; |
||
371 | $sql .= ", date_ech='" . $this->db->idate($this->date_ech) . "'"; |
||
372 | $sql .= ", periode='" . $this->db->idate($this->periode) . "'"; |
||
373 | $sql .= ", amount='" . price2num($this->amount, 'MT') . "'"; |
||
374 | $sql .= ", fk_projet=" . ($this->fk_project > 0 ? $this->db->escape($this->fk_project) : "NULL"); |
||
375 | $sql .= ", fk_user=" . ($this->fk_user > 0 ? $this->db->escape($this->fk_user) : "NULL"); |
||
376 | $sql .= ", fk_user_modif=" . $user->id; |
||
377 | $sql .= " WHERE rowid=" . ((int) $this->id); |
||
378 | |||
379 | dol_syslog(get_class($this) . "::update", LOG_DEBUG); |
||
380 | $resql = $this->db->query($sql); |
||
381 | |||
382 | if (!$resql) { |
||
383 | $error++; |
||
384 | $this->errors[] = "Error " . $this->db->lasterror(); |
||
385 | } |
||
386 | |||
387 | if (!$error) { |
||
388 | if (!$notrigger) { |
||
389 | // Call trigger |
||
390 | $result = $this->call_trigger('SOCIALCONTRIBUTION_MODIFY', $user); |
||
391 | if ($result < 0) { |
||
392 | $error++; |
||
393 | } |
||
394 | // End call triggers |
||
395 | } |
||
396 | } |
||
397 | |||
398 | // Commit or rollback |
||
399 | if ($error) { |
||
400 | foreach ($this->errors as $errmsg) { |
||
401 | dol_syslog(get_class($this) . "::update " . $errmsg, LOG_ERR); |
||
402 | $this->error .= ($this->error ? ', ' . $errmsg : $errmsg); |
||
403 | } |
||
404 | $this->db->rollback(); |
||
405 | return -1 * $error; |
||
406 | } else { |
||
407 | $this->db->commit(); |
||
408 | return 1; |
||
409 | } |
||
410 | } |
||
411 | |||
412 | /** |
||
413 | * Calculate amount remaining to pay by year |
||
414 | * |
||
415 | * @param int $year Year |
||
416 | * @return int|float Returns -1 when error (Note: could be mistaken with an amount) |
||
417 | */ |
||
418 | public function solde($year = 0) |
||
419 | { |
||
420 | global $conf; |
||
421 | |||
422 | $sql = "SELECT SUM(f.amount) as amount"; |
||
423 | $sql .= " FROM " . MAIN_DB_PREFIX . "chargesociales as f"; |
||
424 | $sql .= " WHERE f.entity = " . $conf->entity; |
||
425 | $sql .= " AND paye = 0"; |
||
426 | |||
427 | if ($year) { |
||
428 | $sql .= " AND f.datev >= '" . ((int) $year) . "-01-01' AND f.datev <= '" . ((int) $year) . "-12-31' "; |
||
429 | } |
||
430 | |||
431 | $result = $this->db->query($sql); |
||
432 | if ($result) { |
||
433 | if ($this->db->num_rows($result)) { |
||
434 | $obj = $this->db->fetch_object($result); |
||
435 | $this->db->free($result); |
||
436 | return $obj->amount; |
||
437 | } else { |
||
438 | return 0; |
||
439 | } |
||
440 | } else { |
||
441 | print $this->db->error(); |
||
442 | return -1; |
||
443 | } |
||
444 | } |
||
445 | |||
446 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
447 | /** |
||
448 | * Tag social contribution as paid completely |
||
449 | * |
||
450 | * @deprecated |
||
451 | * @see setPaid() |
||
452 | * @param User $user Object user making change |
||
453 | * @return int Return integer <0 if KO, >0 if OK |
||
454 | */ |
||
455 | public function set_paid($user) |
||
456 | { |
||
457 | // phpcs:enable |
||
458 | dol_syslog(get_class($this) . "::set_paid is deprecated, use setPaid instead", LOG_NOTICE); |
||
459 | return $this->setPaid($user); |
||
460 | } |
||
461 | |||
462 | /** |
||
463 | * Tag social contribution as paid completely |
||
464 | * |
||
465 | * @param User $user Object user making change |
||
466 | * @return int Return integer <0 if KO, >0 if OK |
||
467 | */ |
||
468 | public function setPaid($user) |
||
469 | { |
||
470 | $sql = "UPDATE " . MAIN_DB_PREFIX . "chargesociales SET"; |
||
471 | $sql .= " paye = 1"; |
||
472 | $sql .= " WHERE rowid = " . ((int) $this->id); |
||
473 | |||
474 | $return = $this->db->query($sql); |
||
475 | |||
476 | if ($return) { |
||
477 | $this->paye = 1; |
||
478 | |||
479 | return 1; |
||
480 | } else { |
||
481 | return -1; |
||
482 | } |
||
483 | } |
||
484 | |||
485 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
486 | /** |
||
487 | * Remove tag paid on social contribution |
||
488 | * |
||
489 | * @deprecated |
||
490 | * @see setUnpaid() |
||
491 | * @param User $user Object user making change |
||
492 | * @return int Return integer <0 if KO, >0 if OK |
||
493 | */ |
||
494 | public function set_unpaid($user) |
||
495 | { |
||
496 | // phpcs:enable |
||
497 | dol_syslog(get_class($this) . "::set_unpaid is deprecated, use setUnpaid instead", LOG_NOTICE); |
||
498 | return $this->setUnpaid($user); |
||
499 | } |
||
500 | |||
501 | /** |
||
502 | * Remove tag paid on social contribution |
||
503 | * |
||
504 | * @param User $user Object user making change |
||
505 | * @return int Return integer <0 if KO, >0 if OK |
||
506 | */ |
||
507 | public function setUnpaid($user) |
||
508 | { |
||
509 | $sql = "UPDATE " . MAIN_DB_PREFIX . "chargesociales SET"; |
||
510 | $sql .= " paye = 0"; |
||
511 | $sql .= " WHERE rowid = " . ((int) $this->id); |
||
512 | |||
513 | $return = $this->db->query($sql); |
||
514 | |||
515 | if ($return) { |
||
516 | $this->paye = 0; |
||
517 | |||
518 | return 1; |
||
519 | } else { |
||
520 | return -1; |
||
521 | } |
||
522 | } |
||
523 | |||
524 | /** |
||
525 | * Retourne le libelle du statut d'une charge (impaye, payee) |
||
526 | * |
||
527 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
||
528 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommend to put here amount paid if you have it, 1 otherwise) |
||
529 | * @return string Label |
||
530 | */ |
||
531 | public function getLibStatut($mode = 0, $alreadypaid = -1) |
||
532 | { |
||
533 | return $this->LibStatut($this->paye, $mode, $alreadypaid); |
||
534 | } |
||
535 | |||
536 | // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps |
||
537 | /** |
||
538 | * Renvoi le libelle d'un statut donne |
||
539 | * |
||
540 | * @param int $status Id status |
||
541 | * @param int $mode 0=long label, 1=short label, 2=Picto + short label, 3=Picto, 4=Picto + long label, 5=short label + picto, 6=Long label + picto |
||
542 | * @param double $alreadypaid 0=No payment already done, >0=Some payments were already done (we recommend to put here amount paid if you have it, 1 otherwise) |
||
543 | * @return string Label |
||
544 | */ |
||
545 | public function LibStatut($status, $mode = 0, $alreadypaid = -1) |
||
581 | } |
||
582 | |||
583 | |||
584 | /** |
||
585 | * Return a link to the object card (with optionally the picto) |
||
586 | * |
||
587 | * @param int $withpicto Include picto in link (0=No picto, 1=Include picto into link, 2=Only picto) |
||
588 | * @param string $option On what the link point to ('nolink', ...) |
||
589 | * @param int $notooltip 1=Disable tooltip |
||
590 | * @param int $short 1=Return just URL |
||
591 | * @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking |
||
592 | * @return string String with link |
||
593 | */ |
||
594 | public function getNomUrl($withpicto = 0, $option = '', $notooltip = 0, $short = 0, $save_lastsearch_value = -1) |
||
595 | { |
||
596 | global $langs, $conf, $user, $form, $hookmanager; |
||
597 | |||
598 | if (!empty($conf->dol_no_mouse_hover)) { |
||
599 | $notooltip = 1; // Force disable tooltips |
||
600 | } |
||
601 | |||
602 | $result = ''; |
||
603 | |||
604 | $url = constant('BASE_URL') . '/compta/sociales/card.php?id=' . $this->id; |
||
605 | |||
606 | if ($short) { |
||
607 | return $url; |
||
608 | } |
||
609 | |||
610 | if ($option !== 'nolink') { |
||
611 | // Add param to save lastsearch_values or not |
||
612 | $add_save_lastsearch_values = ($save_lastsearch_value == 1 ? 1 : 0); |
||
613 | if ($save_lastsearch_value == -1 && isset($_SERVER["PHP_SELF"]) && preg_match('/list\.php/', $_SERVER["PHP_SELF"])) { |
||
614 | $add_save_lastsearch_values = 1; |
||
615 | } |
||
616 | if ($add_save_lastsearch_values) { |
||
617 | $url .= '&save_lastsearch_values=1'; |
||
618 | } |
||
619 | } |
||
620 | |||
621 | if (empty($this->ref)) { |
||
622 | $this->ref = $this->label; |
||
623 | } |
||
624 | |||
625 | $label = img_picto('', $this->picto, 'class="pictofixedwidth"') . '<u class="paddingrightonly">' . $langs->trans("SocialContribution") . '</u>'; |
||
626 | if (isset($this->paye)) { |
||
627 | $label .= ' ' . $this->getLibStatut(5); |
||
628 | } |
||
629 | if (!empty($this->ref)) { |
||
630 | $label .= '<br><b>' . $langs->trans('Ref') . ':</b> ' . $this->ref; |
||
631 | } |
||
632 | if (!empty($this->label)) { |
||
633 | $label .= '<br><b>' . $langs->trans('Label') . ':</b> ' . $this->label; |
||
634 | } |
||
635 | if (!empty($this->type_label)) { |
||
636 | $label .= '<br><b>' . $langs->trans('Type') . ':</b> ' . $this->type_label; |
||
637 | } |
||
638 | |||
639 | $linkclose = ''; |
||
640 | if (empty($notooltip) && $user->hasRight("facture", "read")) { |
||
641 | if (getDolGlobalString('MAIN_OPTIMIZEFORTEXTBROWSER')) { |
||
642 | $label = $langs->trans("SocialContribution"); |
||
643 | $linkclose .= ' alt="' . dol_escape_htmltag($label, 1) . '"'; |
||
644 | } |
||
645 | $linkclose .= ' title="' . dol_escape_htmltag($label, 1) . '"'; |
||
646 | $linkclose .= ' class="classfortooltip"'; |
||
647 | } |
||
648 | |||
649 | $linkstart = '<a href="' . $url . '"'; |
||
650 | $linkstart .= $linkclose . '>'; |
||
651 | $linkend = '</a>'; |
||
652 | |||
653 | $result .= $linkstart; |
||
654 | if ($withpicto) { |
||
655 | $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); |
||
656 | } |
||
657 | if ($withpicto != 2) { |
||
658 | $result .= $this->ref; |
||
659 | } |
||
660 | $result .= $linkend; |
||
661 | global $action; |
||
662 | $hookmanager->initHooks(array($this->element . 'dao')); |
||
663 | $parameters = array('id' => $this->id, 'getnomurl' => &$result); |
||
664 | $reshook = $hookmanager->executeHooks('getNomUrl', $parameters, $this, $action); // Note that $action and $object may have been modified by some hooks |
||
665 | if ($reshook > 0) { |
||
666 | $result = $hookmanager->resPrint; |
||
667 | } else { |
||
668 | $result .= $hookmanager->resPrint; |
||
669 | } |
||
670 | return $result; |
||
671 | } |
||
672 | |||
673 | /** |
||
674 | * Return amount of payments already done |
||
675 | * |
||
676 | * @return int Amount of payment already done, <0 if KO |
||
677 | */ |
||
678 | public function getSommePaiement() |
||
701 | } |
||
702 | } |
||
703 | |||
704 | /** |
||
705 | * Charge l'information d'ordre info dans l'objet entrepot |
||
706 | * |
||
707 | * @param int $id Id of social contribution |
||
708 | * @return int Return integer <0 if KO, >0 if OK |
||
709 | */ |
||
710 | public function info($id) |
||
711 | { |
||
712 | $sql = "SELECT e.rowid, e.tms as datem, e.date_creation as datec, e.date_valid as datev, e.import_key,"; |
||
713 | $sql .= " e.fk_user_author, e.fk_user_modif, e.fk_user_valid"; |
||
714 | $sql .= " FROM " . MAIN_DB_PREFIX . "chargesociales as e"; |
||
715 | $sql .= " WHERE e.rowid = " . ((int) $id); |
||
716 | |||
717 | dol_syslog(get_class($this) . "::info", LOG_DEBUG); |
||
718 | $result = $this->db->query($sql); |
||
719 | if ($result) { |
||
720 | if ($this->db->num_rows($result)) { |
||
721 | $obj = $this->db->fetch_object($result); |
||
722 | |||
723 | $this->id = $obj->rowid; |
||
724 | |||
725 | $this->user_creation_id = $obj->fk_user_author; |
||
726 | $this->user_modification_id = $obj->fk_user_modif; |
||
727 | $this->user_validation_id = $obj->fk_user_valid; |
||
728 | $this->date_creation = $this->db->jdate($obj->datec); |
||
729 | $this->date_modification = $this->db->jdate($obj->datem); |
||
730 | $this->date_validation = $this->db->jdate($obj->datev); |
||
731 | $this->import_key = $obj->import_key; |
||
732 | } |
||
733 | |||
734 | $this->db->free($result); |
||
735 | return 1; |
||
736 | } else { |
||
737 | dol_print_error($this->db); |
||
738 | return -1; |
||
739 | } |
||
740 | } |
||
741 | |||
742 | /** |
||
743 | * Initialise an instance with random values. |
||
744 | * Used to build previews or test instances. |
||
745 | * id must be 0 if object instance is a specimen. |
||
746 | * |
||
747 | * @return int |
||
748 | */ |
||
749 | public function initAsSpecimen() |
||
750 | { |
||
751 | // Initialize parameters |
||
752 | $this->id = 0; |
||
753 | $this->ref = 'SPECIMEN'; |
||
754 | $this->specimen = 1; |
||
755 | $this->paye = 0; |
||
756 | $this->date_creation = dol_now(); |
||
757 | $this->date_ech = $this->date_creation + 3600 * 24 * 30; |
||
758 | $this->periode = $this->date_creation + 3600 * 24 * 30; |
||
759 | $this->period = $this->date_creation + 3600 * 24 * 30; |
||
760 | $this->amount = 100; |
||
761 | $this->label = 'Social contribution label'; |
||
762 | $this->type = 1; |
||
763 | $this->type_label = 'Type of social contribution'; |
||
764 | |||
765 | return 1; |
||
766 | } |
||
767 | |||
768 | /** |
||
769 | * Return clicable link of object (with eventually picto) |
||
770 | * |
||
771 | * @param string $option Where point the link (0=> main card, 1,2 => shipment, 'nolink'=>No link) |
||
772 | * @param array $arraydata Array of data |
||
773 | * @return string HTML Code for Kanban thumb. |
||
774 | */ |
||
775 | public function getKanbanView($option = '', $arraydata = null) |
||
811 | } |
||
812 | } |
||
813 |
This property has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.