<?php

/**
 * Subclass for performing query and update operations on the 'TARIFAS_DESTINO' table.
 *
 * 
 *
 * @package lib.model
 */ 
class TarifasDestinoPeer extends BaseTarifasDestinoPeer
{
	public static function getTaxisComisionado($nitocc, $idComision, $vigencia) {
		$c = new Criteria();
		$c->add(TarifasDestinoPeer::NITOCC, $nitocc);
		$c->add(TarifasDestinoPeer::ID_COMISION, $idComision);
		$c->add(TarifasDestinoPeer::VIGENCIA, $vigencia);
		
		return TarifasDestinoPeer::doSelectJoinTarifasTaxis($c);
	}
	
	public static function doSelectJoinAll(Criteria $c, $con = null)
	{
		$c = clone $c;

				if ($c->getDbName() == Propel::getDefaultDB()) {
			$c->setDbName(self::DATABASE_NAME);
		}

		TarifasDestinoPeer::addSelectColumns($c);
		$startcol2 = (TarifasDestinoPeer::NUM_COLUMNS - TarifasDestinoPeer::NUM_LAZY_LOAD_COLUMNS) + 1;

		TercerosPeer::addSelectColumns($c);
		$startcol3 = $startcol2 + TercerosPeer::NUM_COLUMNS;

		TarifasTaxisPeer::addSelectColumns($c);
		$startcol4 = $startcol3 + TarifasTaxisPeer::NUM_COLUMNS;

		ComisionesPeer::addSelectColumns($c);
		$startcol5 = $startcol4 + ComisionesPeer::NUM_COLUMNS;

		$c->addJoin(TarifasDestinoPeer::NITOCC, TercerosPeer::NITOCC);

		$c->addJoin(TarifasDestinoPeer::ID_TARIFA, TarifasTaxisPeer::ID);

		$c->addJoin(TarifasDestinoPeer::ID_COMISION, ComisionesPeer::ID);

//		$c->addJoin(TarifasDestinoPeer::VIGENCIA, ComisionesPeer::VIGENCIA);
//
//		$c->addJoin(TarifasDestinoPeer::ID_COMISION, ComisionesPeer::VIGENCIA);

		$c->addJoin(TarifasDestinoPeer::VIGENCIA, ComisionesPeer::VIGENCIA);

		$rs = BasePeer::doSelect($c, $con);
		$results = array();

		while($rs->next()) {

			$omClass = TarifasDestinoPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj1 = new $cls();
			$obj1->hydrate($rs);


					
			$omClass = TercerosPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj2 = new $cls();
			$obj2->hydrate($rs, $startcol2);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj2 = $temp_obj1->getTerceros(); 				if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) {
					$newObject = false;
					$temp_obj2->addTarifasDestino($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj2->initTarifasDestinos();
				$obj2->addTarifasDestino($obj1);
			}


					
			$omClass = TarifasTaxisPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj3 = new $cls();
			$obj3->hydrate($rs, $startcol3);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj3 = $temp_obj1->getTarifasTaxis(); 				if ($temp_obj3->getPrimaryKey() === $obj3->getPrimaryKey()) {
					$newObject = false;
					$temp_obj3->addTarifasDestino($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj3->initTarifasDestinos();
				$obj3->addTarifasDestino($obj1);
			}


					
			$omClass = ComisionesPeer::getOMClass();


			$cls = sfPropel::import($omClass);
			$obj4 = new $cls();
			$obj4->hydrate($rs, $startcol4);

			$newObject = true;
			for ($j=0, $resCount=count($results); $j < $resCount; $j++) {
				$temp_obj1 = $results[$j];
				$temp_obj4 = $temp_obj1->getComisiones(); 				if ($temp_obj4->getPrimaryKey() === $obj4->getPrimaryKey()) {
					$newObject = false;
					$temp_obj4->addTarifasDestino($obj1); 					break;
				}
			}

			if ($newObject) {
				$obj4->initTarifasDestinos();
				$obj4->addTarifasDestino($obj1);
			}

			$results[] = $obj1;
		}
		return $results;
	}
}
