/** * returns all relations for the given act * * @param string $type 'all', 'from', 'to' * @return array of OppRelazioneAtto * @author Guglielmo Celata */ public function getRelazioni($type = 'all') { $c = new Criteria(); if ($type == 'all') { $c0 = $c->getNewCriterion(OppRelazioneAttoPeer::ATTO_FROM_ID, $this->getId()); $c1 = $c->getNewCriterion(OppRelazioneAttoPeer::ATTO_TO_ID, $this->getId()); $c0->addOr($c1); $c->add($c0); } else { if ($type == 'from') { $c->add(OppRelazioneAttoPeer::FROM_ID, $this->getId()); } else { if ($type == 'to') { $c->add(OppRelazioneAttoPeer::FROM_ID, $this->getId()); } else { throw new Exception("Wrong parameter value: use all, from or to."); } } } return OppRelazioneAttoPeer::doSelect($c); }
public static function getRelazioni($id) { $relazioni = array(); // testo unificato o assorbito $c = new Criteria(); $c->add(OppRelazioneAttoPeer::ATTO_FROM_ID, $id); $c->add(OppRelazioneAttoPeer::TIPO_RELAZIONE_ID, array(1, 2, 4), Criteria::IN); $unificati = OppRelazioneAttoPeer::doSelect($c); foreach ($unificati as $unificato) { array_push($relazioni, array($unificato->getAttoToId(), $unificato->getOppTipoRelazione()->getDenominazione(), $unificato->getDescrizione(), 0)); } // stralcio FROM $c = new Criteria(); $c->add(OppRelazioneAttoPeer::ATTO_FROM_ID, $id); $c->add(OppRelazioneAttoPeer::TIPO_RELAZIONE_ID, 3); $from_stralci = OppRelazioneAttoPeer::doSelect($c); foreach ($from_stralci as $from_stralcio) { array_push($relazioni, array($from_stralcio->getAttoToId(), $from_stralcio->getOppTipoRelazione()->getDenominazione(), $from_stralcio->getDescrizione(), 1)); } // stralcio TO $c = new Criteria(); $c->add(OppRelazioneAttoPeer::ATTO_TO_ID, $id); $c->add(OppRelazioneAttoPeer::TIPO_RELAZIONE_ID, 3); $to_stralci = OppRelazioneAttoPeer::doSelect($c); foreach ($to_stralci as $to_stralcio) { $c = new Criteria(); $c->add(OppAttoPeer::ID, $to_stralcio->getAttoFromId()); $rs = OppAttoPeer::doSelectOne($c); $sigla = $rs->getRamo() . "." . $rs->getNumfase(); array_push($relazioni, array($to_stralcio->getAttoFromId(), $to_stralcio->getOppTipoRelazione()->getDenominazione(), $sigla, 2)); } // abbinato FROM $c = new Criteria(); $c->add(OppRelazioneAttoPeer::ATTO_FROM_ID, $id); $c->add(OppRelazioneAttoPeer::TIPO_RELAZIONE_ID, 5); $from_abbs = OppRelazioneAttoPeer::doSelect($c); foreach ($from_abbs as $from_abb) { array_push($relazioni, array($from_abb->getAttoToId(), $from_abb->getOppTipoRelazione()->getDenominazione(), $from_abb->getDescrizione(), 0)); } return $relazioni; }