Ejemplo n.º 1
0
 /**
  * Restituisce la lista dei metodi di pagamento (carte di credito) 
  * di uno specifico cliente
  * @param Cliente $cliente
  * @return array una lista di metodi pagamenti
  */
 public function &getListaPagamentiPerCliente(Cliente $cliente)
 {
     $pagamenti = array();
     $query = "select \n            pagamenti.id, \n            pagamenti.saldo, \n            pagamenti.num_carta, \n            pagamenti.cod_carta, \n            pagamenti.scadenza_carta, \n            pagamenti.titolare_carta, \n            pagamenti.tipo_carta\n        from \n            clienti_pagamenti join pagamenti\n        on \n            clienti_pagamenti.pagamenti_id = pagamenti.id\n        where \n            clienti_pagamenti.clienti_id = ?";
     $mysqli = Db::getInstance()->connectDb();
     if (!isset($mysqli)) {
         error_log("[caricaPagamentoPerId] impossibile inizializzare il database");
         $mysqli->close();
         return null;
     }
     $stmt = $mysqli->stmt_init();
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[getListaPagamentiPerCliente] impossibile" . " inizializzare il prepared statement");
         $mysqli->close();
         return null;
     }
     if (!$stmt->bind_param('i', $cliente->getId())) {
         error_log("[getListaPagamentiPerCliente] impossibile" . " effettuare il binding in input");
         $mysqli->close();
         return null;
     }
     $pagamenti = self::caricaPagamentiDaStmt($stmt, 2);
     $mysqli->close();
     return $pagamenti;
 }
Ejemplo n.º 2
0
 /**
  * Rende persistenti le modifiche all'anagrafica di un cliente sul db
  * @param Cliente $c il cliente considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaCliente(Cliente $c, mysqli_stmt $stmt)
 {
     $query = " update clienti set \n                    username = ?,\n                    password = ?,\n                    email = ?,\n                    nome = ?,\n                    cognome = ?\n                    where clienti.id = ?\n                 ";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaCliente] impossibile" . " inizializzare il prepared statement");
         echo 'impossibile" .
                 " inizializzare il prepared statement';
         return 0;
     }
     if (!$stmt->bind_param('sssssi', $c->getUsername(), $c->getPassword(), $c->getEmail(), $c->getNome(), $c->getCognome(), $c->getId())) {
         error_log("[salvaCliente] impossibile" . " effettuare il binding in input");
         echo 'impossibile" .
                 " effettuare il binding in input';
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaRegistrati] impossibile" . " eseguire lo statement");
         echo 'impossibile" .
                 " eseguire lo statement';
         return 0;
     }
     return $stmt->affected_rows;
 }
Ejemplo n.º 3
0
 /**
  * Rende persistenti le modifiche all'anagrafica di uno studente sul db
  * @param Cliente $s lo studente considerato
  * @param mysqli_stmt $stmt un prepared statement
  * @return int il numero di righe modificate
  */
 private function salvaCliente(Cliente $c, mysqli_stmt $stmt)
 {
     $query = " UPDATE clienti SET \n                    password = ?,\n                    nome = ?,\n                    cognome = ?,\n                    via = ?,\n                    civico = ?,\n                    citta = ?,\n                    cap = ?,\n                    telefono = ?\n                    WHERE clienti.id = ?";
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[salvaCliente] impossibile" . " inizializzare il prepared statement");
         return 0;
     }
     if (!$stmt->bind_param('ssssissii', $c->getPassword(), $c->getNome(), $c->getCognome(), $c->getVia(), $c->getCivico(), $c->getCitta(), $c->getCap(), $c->getTelefono(), $c->getId())) {
         error_log("[salvaCliente] impossibile" . " effettuare il binding in input 2");
         return 0;
     }
     if (!$stmt->execute()) {
         error_log("[caricaIscritti] impossibile" . " eseguire lo statement");
         return 0;
     }
     return $stmt->affected_rows;
 }
Ejemplo n.º 4
0
 /**
  * Declares an association between this object and a Cliente object.
  *
  * @param             Cliente $v
  * @return Movimiento The current object (for fluent API support)
  * @throws PropelException
  */
 public function setCliente(Cliente $v = null)
 {
     if ($v === null) {
         $this->setClienteId(NULL);
     } else {
         $this->setClienteId($v->getId());
     }
     $this->aCliente = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the Cliente object, it will not be re-added.
     if ($v !== null) {
         $v->addMovimiento($this);
     }
     return $this;
 }
Ejemplo n.º 5
0
 /**
  * Filter the query by a related Cliente object
  *
  * @param   Cliente|PropelObjectCollection $cliente The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return   TransaccionQuery The current query, for fluid interface
  * @throws   PropelException - if the provided filter is invalid.
  */
 public function filterByCliente($cliente, $comparison = null)
 {
     if ($cliente instanceof Cliente) {
         return $this->addUsingAlias(TransaccionPeer::CLIENTE_ID, $cliente->getId(), $comparison);
     } elseif ($cliente instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(TransaccionPeer::CLIENTE_ID, $cliente->toKeyValue('PrimaryKey', 'Id'), $comparison);
     } else {
         throw new PropelException('filterByCliente() only accepts arguments of type Cliente or PropelCollection');
     }
 }
Ejemplo n.º 6
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param      Cliente $obj A Cliente object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getId();
         }
         // if key === null
         ClientePeer::$instances[$key] = $obj;
     }
 }
Ejemplo n.º 7
0
 /**
  * Exclude object from result
  *
  * @param   Cliente $cliente Object to remove from the list of results
  *
  * @return ClienteQuery The current query, for fluid interface
  */
 public function prune($cliente = null)
 {
     if ($cliente) {
         $this->addUsingAlias(ClientePeer::ID, $cliente->getId(), Criteria::NOT_EQUAL);
     }
     return $this;
 }
Ejemplo n.º 8
0
 /**
  * Restituisce la lista degli ordini effettuati da uno specifico cliente
  * @param Cliente $cliente
  * @param boolean $flag true -> ordini attivi | false -> ordini chiusi
  * @return array una lista di ordini
  */
 public function &getListaOrdiniPerCliente(Cliente $cliente, $flag = false)
 {
     $ordini = array();
     $query = "select \n            ordini.id, \n            ordini.data_conclusione, \n            ordini.data_creazione,\n            ordini.subtotale\n        from \n            ordini join clienti\n        on \n            ordini.cliente_id = clienti.id\n        where \n            ordini.cliente_id = ?";
     if ($flag) {
         $query .= ' && ordini.data_conclusione = 0';
     } else {
         $query .= ' && ordini.data_conclusione <> 0';
     }
     $mysqli = Db::getInstance()->connectDb();
     if (!isset($mysqli)) {
         error_log("[getListaOrdiniPerCliente] impossibile inizializzare il database");
         $mysqli->close();
         return null;
     }
     $stmt = $mysqli->stmt_init();
     $stmt->prepare($query);
     if (!$stmt) {
         error_log("[getListaOrdiniPerCliente] impossibile" . " inizializzare il prepared statement");
         $mysqli->close();
         return null;
     }
     if (!$stmt->bind_param('i', $cliente->getId())) {
         error_log("[getListaOrdiniPerCliente] impossibile" . " effettuare il binding in input");
         $mysqli->close();
         return null;
     }
     $ordini = self::caricaOrdiniDaStmt($stmt);
     $mysqli->close();
     return $ordini;
 }