method fusion documentation in bbn\Entities\People

function($ids) { $args = is_array($ids) ? $ids : func_get_args(); $fonction_lien = $this->options->fromCode('fonction', 'LIENS'); if (count($args) > 1) { $id = array_shift($args); $creation = [$this->db->selectOne( 'bbn_history', 'tst', [ 'uid' => $id, 'opr' => 'INSERT' ] )]; foreach ($args as $a){ if ($fn = $this->get_info($a)) { $creation[] = $this->db->getOne( " SELECT tst FROM bbn_history WHERE uid = ? AND opr LIKE 'INSERT'", hex2bin($a) ); $cols = $this->db->getFieldsList('apst_liens'); $cols['creation'] = 'tst'; $links = $this->db->rselectAll( [ 'tables' => ['apst_liens'], 'fields' => $cols, 'join' => [ [ 'table' => 'bbn_history', 'on' => [ 'conditions' => [ [ 'field' => 'bbn_history.uid', 'operator' => 'eq', 'exp' => 'apst_liens.id' ] ], 'logic' => 'AND' ] ] ], 'where' => [ 'id_tiers' => $a ] ] ); foreach ($links as $link){ $link_update = ['id_tiers' => $id]; // Si les liens sont de type `Fonction` on les fusionne aussi de la même manière que les tiers if (($link['link_type'] === $fonction_lien) && ($autre = $this->db->getRow( " SELECT apst_liens.id, apst_liens.id_adherent, apst_liens.cfg, h.tst AS creation FROM apst_liens JOIN bbn_history AS h ON h.uid = apst_liens.id AND h.opr LIKE 'INSERT' JOIN bbn_history_uids ON bbn_history_uids.bbn_uid = apst_liens.id AND bbn_history_uids.bbn_active = 1 WHERE apst_liens.id_tiers = ? AND apst_liens.id_adherent = ? AND apst_liens.link_type = ?", hex2bin($a), $link['id_adherent'], hex2bin($fonction_lien) ) ) ) { $link_cfg = json_decode($link['cfg'], 1); // On met la date de création la plus ancienne if (strtotime($autre['creation']) < strtotime($link['creation'])) { $this->db->query( " UPDATE bbn_history SET tst = ? WHERE uid = ? AND opr LIKE 'INSERT'", $autre['creation'], hex2bin($link['id']) ); } $this->db->query( " UPDATE bbn_history SET uid = ? WHERE uid = ? AND opr LIKE 'UPDATE'", hex2bin($link['id']), hex2bin($autre['id']) ); $this->db->query( " DELETE FROM bbn_history WHERE uid = ?", hex2bin($autre['id']) ); $autre_cfg = json_decode($autre['cfg'], 1); if ($autre_cfg && $link_cfg && isset($autre_cfg['fonctions'], $link_cfg['fonctions'])) { $link_update['cfg'] = json_encode( [ 'fonctions' => array_unique(\bbn\X::mergeArrays($autre_cfg['fonctions'], $link_cfg['fonctions'])) ] ); } $this->db->query("DELETE FROM bbn_history_uids WHERE uid = ?", hex2bin($autre['id'])); } $this->db->update('apst_liens', $link_update, ['id' => $link['id']]); } $this->db->query( " UPDATE bbn_history SET uid = ? WHERE uid = ? AND opr LIKE 'UPDATE'", hex2bin($id), hex2bin($a) ); $this->db->query( " DELETE FROM bbn_history WHERE uid = ?", hex2bin($a) ); $this->db->query( " DELETE FROM bbn_people WHERE id = ?", hex2bin($a) ); } } $this->db->query( " UPDATE bbn_history SET tst = ? WHERE uid = ? AND opr LIKE 'INSERT'", min($creation), hex2bin($id) ); } return 1; }

BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way

This website uses cookies to ensure you get the best experience on our website.