function getListJuegoDetalleFactura($condicion = null, $parametros = array())
 {
     if ($condicion === null) {
         $condicion = "";
     } else {
         $condicion = "where {$condicion}";
     }
     $sql = "select ju.*, de.*, fa.*, cl.* from detalle de \r\n                    left join juego ju on ju.id_juego = de.id_juego \r\n                    left join factura fa on fa.num_factura = de.num_factura \r\n                    left join cliente cl on fa.id_cliente = cl.id_cliente  \r\n                {$condicion} ORDER BY cl.email, fa.fecha desc ";
     $this->bd->send($sql, $parametros);
     $r = array();
     $contador = 0;
     while ($fila = $this->bd->getRow()) {
         $juego = new Game();
         $juego->set($fila);
         $detalle = new Detalle();
         $detalle->set($fila, 8);
         $factura = new Factura();
         $factura->set($fila, 13);
         $cliente = new User();
         $cliente->set($fila, 16);
         $r[$contador]["juego"] = $juego;
         $r[$contador]["factura"] = $factura;
         $r[$contador]["detalle"] = $detalle;
         $r[$contador]["cliente"] = $cliente;
         $contador++;
     }
     return $r;
 }
Пример #2
0
 function get($ID)
 {
     $parametros = array();
     $parametros['ID'] = $ID;
     $this->bd->select($this->tabla, "*", "id_juego=:ID", $parametros);
     $fila = $this->bd->getRow();
     $game = new Game();
     $game->set($fila);
     return $game;
 }
Пример #3
0
 /**
  * Schedule one set of games, using weighted field assignment
  *
  * Takes an array of teams and a datestamp.  From this:
  * 	- iterate over teams array pairwise and call add_teams_balanced() to create a game with balanced home/away
  * 	- iterate over all newly-created games, and assign fields based on region preference.
  * All of this is performed in a transaction and rolled back if any game fails.
  */
 function schedule_one_set($teams, $datestamp, $should_publish = true)
 {
     global $dbh;
     $dbh->beginTransaction();
     $games_list = array();
     for ($team_idx = 0; $team_idx < count($teams); $team_idx += 2) {
         $g = new Game();
         $g->set('league_id', $this->league_id);
         $g->add_teams_balanced($teams[$team_idx], $teams[$team_idx + 1]);
         $g->set('published', $should_publish);
         if (!$g->save()) {
             if (!$dbh->rollback()) {
                 $extra_errors = "<br />Also, failed to roll back transaction.  Please contact the system administrator";
             }
             return array(false, "Could not create the games you requested, during addition of opponents.{$extra_errors}");
         }
         $games_list[] = $g;
     }
     try {
         $this->assign_fields_by_preferences($games_list, $datestamp);
     } catch (Exception $e) {
         $extra_errors = $e->getMessage();
         if (!$dbh->rollback()) {
             $extra_errors .= "<br />Also, failed to roll back transaction.  Please contact the system administrator";
         }
         return array(false, "Failed to assign gameslots for requested games on " . strftime('%c', $datestamp) . ": {$extra_errors}");
     }
     $rc = $dbh->commit();
     if (!$rc) {
         return array(false, 'Transaction commit failed');
     }
     return array(true, '');
 }