343 |
*/ |
*/ |
344 |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggerajouter($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
345 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
346 |
$this->f->module_manager->run_hooks('triggerajouter_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggerajouter_pre', $this, $data)) { |
347 |
|
return false; |
348 |
|
} |
349 |
|
|
350 |
$res = parent::triggerajouter($id, $dnu1, $val); |
$res = parent::triggerajouter($id, $dnu1, $val); |
351 |
|
|
352 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
353 |
$this->f->module_manager->run_hooks('triggerajouter_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggerajouter_post', $this, $data)) { |
354 |
|
return false; |
355 |
|
} |
356 |
return $res; |
return $res; |
357 |
} |
} |
358 |
|
|
371 |
} |
} |
372 |
|
|
373 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
374 |
$this->f->module_manager->run_hooks('triggerajouterapres_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggerajouterapres_pre', $this, $data)) { |
375 |
|
return false; |
376 |
|
} |
377 |
|
|
378 |
$res = parent::triggerajouterapres($id, $dnu1, $val); |
$res = parent::triggerajouterapres($id, $dnu1, $val); |
379 |
|
|
380 |
// Assigner les champs 'valF' à 'val' lorsque l'ajout a réussi; |
// Assigner les champs 'valF' à 'val' lorsque l'ajout a réussi; |
389 |
} |
} |
390 |
|
|
391 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
392 |
$this->f->module_manager->run_hooks('triggerajouterapres_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggerajouterapres_post', $this, $data)) { |
393 |
|
return false; |
394 |
|
} |
395 |
return $res; |
return $res; |
396 |
} |
} |
397 |
|
|
402 |
*/ |
*/ |
403 |
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggermodifier($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
404 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
405 |
$this->f->module_manager->run_hooks('triggermodifier_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggermodifier_pre', $this, $data)) { |
406 |
|
return false; |
407 |
|
} |
408 |
|
|
409 |
$res = parent::triggermodifier($id, $dnu1, $val); |
$res = parent::triggermodifier($id, $dnu1, $val); |
410 |
|
|
411 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
412 |
$this->f->module_manager->run_hooks('triggermodifier_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggermodifier_post', $this, $data)) { |
413 |
|
return false; |
414 |
|
} |
415 |
return $res; |
return $res; |
416 |
} |
} |
417 |
|
|
422 |
*/ |
*/ |
423 |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggermodifierapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
424 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
425 |
$this->f->module_manager->run_hooks('triggermodifierapres_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggermodifierapres_pre', $this, $data)) { |
426 |
|
return false; |
427 |
|
} |
428 |
|
|
429 |
$res = parent::triggermodifierapres($id, $dnu1, $val); |
$res = parent::triggermodifierapres($id, $dnu1, $val); |
430 |
|
|
431 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
432 |
$this->f->module_manager->run_hooks('triggermodifierapres_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggermodifierapres_post', $this, $data)) { |
433 |
|
return false; |
434 |
|
} |
435 |
return $res; |
return $res; |
436 |
} |
} |
437 |
|
|
442 |
*/ |
*/ |
443 |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimer($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
444 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
445 |
$this->f->module_manager->run_hooks('triggersupprimer_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggersupprimer_pre', $this, $data)) { |
446 |
|
return false; |
447 |
|
} |
448 |
|
|
449 |
$res = parent::triggersupprimer($id, $dnu1, $val); |
$res = parent::triggersupprimer($id, $dnu1, $val); |
450 |
|
|
451 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
452 |
$this->f->module_manager->run_hooks('triggersupprimer_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggersupprimer_post', $this, $data)) { |
453 |
|
return false; |
454 |
|
} |
455 |
return $res; |
return $res; |
456 |
} |
} |
457 |
|
|
462 |
*/ |
*/ |
463 |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
function triggersupprimerapres($id, &$dnu1 = null, $val = array(), $dnu2 = null) { |
464 |
$data = array('val' => &$val, 'id' => $id); |
$data = array('val' => &$val, 'id' => $id); |
465 |
$this->f->module_manager->run_hooks('triggersupprimerapres_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggersupprimerapres_pre', $this, $data)) { |
466 |
|
return false; |
467 |
|
} |
468 |
|
|
469 |
$res = parent::triggersupprimerapres($id, $dnu1, $val); |
$res = parent::triggersupprimerapres($id, $dnu1, $val); |
470 |
|
|
471 |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
$data = array('val' => &$val, 'id' => $id, 'result' => &$res); |
472 |
$this->f->module_manager->run_hooks('triggersupprimerapres_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('triggersupprimerapres_post', $this, $data)) { |
473 |
|
return false; |
474 |
|
} |
475 |
return $res; |
return $res; |
476 |
} |
} |
477 |
|
|
1590 |
* @param string $om_validite permet de définir si l'objet lié est affecté par une date de validité |
* @param string $om_validite permet de définir si l'objet lié est affecté par une date de validité |
1591 |
* @param string $multiple permet d'utiliser cette méthode pour configurer l'affichage de select_multiple (widget) |
* @param string $multiple permet d'utiliser cette méthode pour configurer l'affichage de select_multiple (widget) |
1592 |
* @param string $field_name traduction du champ |
* @param string $field_name traduction du champ |
1593 |
|
* @param bool $display_placeholder Permet d'afficher ou non le texte de remplacement de la valeur vide |
1594 |
*/ |
*/ |
1595 |
function init_select(&$form = null, &$dnu1 = null, $maj = null, $dnu2 = null, $field = "", $sql = "", |
function init_select(&$form = null, &$dnu1 = null, $maj = null, $dnu2 = null, $field = "", $sql = "", |
1596 |
$sql_by_id = "", $om_validite = false, $multiple = false, |
$sql_by_id = "", $om_validite = false, $multiple = false, |
1597 |
$field_name = '') { |
$field_name = '', $display_placeholder = true) { |
1598 |
|
|
1599 |
// Si aucune traduction du champ fournie |
// Si aucune traduction du champ fournie |
1600 |
if ($field_name === '') { |
if ($field_name === '') { |
1623 |
// Initialisation du select |
// Initialisation du select |
1624 |
$contenu = array(); |
$contenu = array(); |
1625 |
$contenu[0][0] = ''; |
$contenu[0][0] = ''; |
1626 |
$contenu[1][0] = __('choisir')." ".$field_name; |
$contenu[1][0] = $display_placeholder === true ? sprintf('%s %s', __('choisir'), $field_name) : ''; |
1627 |
// |
// |
1628 |
$k=1; |
$k=1; |
1629 |
while($row =& $res->fetchRow()){ |
while($row =& $res->fetchRow()){ |
2101 |
$res = parent::ajouter($val, $dnu1, $dnu2); |
$res = parent::ajouter($val, $dnu1, $dnu2); |
2102 |
|
|
2103 |
$data = array('val' => &$val, 'res' => &$res); |
$data = array('val' => &$val, 'res' => &$res); |
2104 |
$this->f->module_manager->run_hooks('ajouter_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('ajouter_post', $this, $data)) { |
2105 |
|
return false; |
2106 |
|
} |
2107 |
return $res; |
return $res; |
2108 |
} |
} |
2109 |
|
|
2112 |
*/ |
*/ |
2113 |
function modifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
function modifier($val = array(), &$dnu1 = null, $dnu2 = null) { |
2114 |
$data = array('val' => &$val); |
$data = array('val' => &$val); |
2115 |
$this->f->module_manager->run_hooks('modifier_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('modifier_pre', $this, $data)) { |
2116 |
|
return false; |
2117 |
|
} |
2118 |
|
|
2119 |
$res = parent::modifier($val, $dnu1, $dnu2); |
$res = parent::modifier($val, $dnu1, $dnu2); |
2120 |
|
|
2121 |
$data['res'] = &$res; |
$data['res'] = &$res; |
2122 |
$this->f->module_manager->run_hooks('modifier_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('modifier_post', $this, $data)) { |
2123 |
|
return false; |
2124 |
|
} |
2125 |
return $res; |
return $res; |
2126 |
} |
} |
2127 |
|
|
2130 |
*/ |
*/ |
2131 |
function supprimer($val = array(), &$dnu1 = null, $dnu2 = null) { |
function supprimer($val = array(), &$dnu1 = null, $dnu2 = null) { |
2132 |
$data = array('val' => &$val); |
$data = array('val' => &$val); |
2133 |
$this->f->module_manager->run_hooks('supprimer_pre', $this, $data); |
if (! $this->f->module_manager->run_hooks('supprimer_pre', $this, $data)) { |
2134 |
|
return false; |
2135 |
|
} |
2136 |
|
|
2137 |
$res = parent::supprimer($val, $dnu1, $dnu2); |
$res = parent::supprimer($val, $dnu1, $dnu2); |
2138 |
|
|
2139 |
$data['res'] = &$res; |
$data['res'] = &$res; |
2140 |
$this->f->module_manager->run_hooks('supprimer_post', $this, $data); |
if (! $this->f->module_manager->run_hooks('supprimer_post', $this, $data)) { |
2141 |
|
return false; |
2142 |
|
} |
2143 |
return $res; |
return $res; |
2144 |
} |
} |
2145 |
|
|
2436 |
*/ |
*/ |
2437 |
public function modify_edition_merge_fields_values($edition, array &$values) { |
public function modify_edition_merge_fields_values($edition, array &$values) { |
2438 |
$values_keys = array_keys($values); |
$values_keys = array_keys($values); |
2439 |
|
|
2440 |
|
// si on est dans le cadre d'une instruction |
2441 |
|
if (get_class($this) == 'instruction' |
2442 |
|
&& empty($this->getVal($this->clePrimaire)) === false |
2443 |
|
&& empty($this->getVal('evenement')) === false |
2444 |
|
&& empty($this->getVal('dossier')) === false) { |
2445 |
|
|
2446 |
|
// collecte les données supplémentaires de cet objet |
2447 |
|
$id = $this->getVal($this->clePrimaire); |
2448 |
|
$evt = $this->getVal('evenement'); |
2449 |
|
$dossier = $this->getVal('dossier'); |
2450 |
|
$xd_store = $this->f->get_extra_data_store(); |
2451 |
|
$mode = 'value'; |
2452 |
|
$use_champ_fusion = true; |
2453 |
|
$xd_kv_evenement = $xd_store->list_data( |
2454 |
|
'evenement', $mode, $evt, $use_champ_fusion); |
2455 |
|
if (! empty($xd_kv_evenement->error_message)) { |
2456 |
|
$err_msg = sprintf( |
2457 |
|
__("Échec de la récupération des données supplémentaires de l'évènement '%s'."), |
2458 |
|
$evt).' '. |
2459 |
|
__("Détail:").' '.$xd_kv_evenement->error_message; |
2460 |
|
$this->addToLog(__METHOD__."() ".var_export($err_msg, true), DEBUG_MODE); |
2461 |
|
$this->f->log(__METHOD__, $err_msg, 'ERROR'); |
2462 |
|
throw new RuntimeException($err_msg); |
2463 |
|
} |
2464 |
|
$xd_kv_instruction = $xd_store->list_data( |
2465 |
|
'instruction', $mode, $id, $use_champ_fusion); |
2466 |
|
if (! empty($xd_kv_instruction->error_message)) { |
2467 |
|
$err_msg = sprintf( |
2468 |
|
__("Échec de la récupération des données supplémentaires de l'instruction '%s'."), |
2469 |
|
$evt).' '. |
2470 |
|
__("Détail:").' '.$xd_kv_instruction->error_message; |
2471 |
|
$this->addToLog(__METHOD__."() ".var_export($err_msg, true), DEBUG_MODE); |
2472 |
|
$this->f->log(__METHOD__, $err_msg, 'ERROR'); |
2473 |
|
throw new RuntimeException($err_msg); |
2474 |
|
} |
2475 |
|
$xd_kv_dossier = $xd_store->list_data( |
2476 |
|
'dossier', $mode, $dossier, $use_champ_fusion); |
2477 |
|
if (! empty($xd_kv_dossier->error_message)) { |
2478 |
|
$err_msg = sprintf( |
2479 |
|
__("Échec de la récupération des données supplémentaires du dossier '%s'."), |
2480 |
|
$evt).' '. |
2481 |
|
__("Détail:").' '.$xd_kv_dossier->error_message; |
2482 |
|
$this->addToLog(__METHOD__."() ".var_export($err_msg, true), DEBUG_MODE); |
2483 |
|
$this->f->log(__METHOD__, $err_msg, 'ERROR'); |
2484 |
|
throw new RuntimeException($err_msg); |
2485 |
|
} |
2486 |
|
|
2487 |
|
$xd_kv = array_merge( |
2488 |
|
$xd_kv_evenement->items, |
2489 |
|
$xd_kv_instruction->items, |
2490 |
|
$xd_kv_dossier->items); |
2491 |
|
|
2492 |
|
$this->f->log(__METHOD__, "new extra data:".var_export($xd_kv, true)); |
2493 |
|
|
2494 |
|
// fusionnent les données supplémentaires avec les champs de fusion existants |
2495 |
|
foreach($xd_kv as $k => $v) { |
2496 |
|
$values[$k] = $v; |
2497 |
|
} |
2498 |
|
} |
2499 |
|
|
2500 |
$data = array('edition' => $edition, 'values' => &$values); |
$data = array('edition' => $edition, 'values' => &$values); |
2501 |
$this->f->module_manager->run_hooks('modify_edition_merge_fields_values_post', $this, $data); |
$this->f->module_manager->run_hooks('modify_edition_merge_fields_values_post', $this, $data); |
2502 |
|
|
2503 |
$new_values_keys = array_keys($values); |
$new_values_keys = array_keys($values); |
2504 |
$removed_values_keys = array_diff($values_keys, $new_values_keys); |
$removed_values_keys = array_diff($values_keys, $new_values_keys); |
2505 |
if (! empty($removed_values_keys)) { |
if (! empty($removed_values_keys)) { |