public function registra_cliente($data)
 {
     $err = 0;
     $id_user = $this->is_new_user($data['email']->val);
     if ($id_user == -1) {
         $id_user = parent::create_id('cliente');
         if ($this->db->Execute("INSERT INTO cliente VALUES(?,?,?,'',?,?,?,?,CURDATE(),0)", array($id_user, ucwords(strtolower($this->purifica($data['nome']->val))), ucwords(strtolower($this->purifica($data['cognome']->val))), strtolower($this->purifica($data['sonoun']->val)), strtolower($this->purifica($data['email']->val)), $this->purifica($data['telefono']->val), $_SERVER['REMOTE_ADDR']))) {
         } else {
             $err = -1;
         }
     } else {
         if ($this->db->Execute("UPDATE cliente SET nome=?,cognome=?,tipo=?,tel=? WHERE id=?", array(ucwords(strtolower($this->purifica($data['nome']->val))), ucwords(strtolower($this->purifica($data['cognome']->val))), strtolower($this->purifica($data['sonoun']->val)), $this->purifica($data['telefono']->val), $id_user))) {
         } else {
             $err = -2;
         }
     }
     //Registrazione dati spedizione
     if (isset($data['nazione'])) {
         $this->registra_spedizione($id_user, $data);
     }
     //Registrazione della fatturazione
     if (isset($data['ragsoc'])) {
         $this->registra_fatturazione($id_user, $data);
     }
     return array('err' => $err, 'id_usr' => $id_user);
 }
예제 #2
0
 public function registra($id_cliente, $cart, $type = '0', $payment = '0')
 {
     $err = 0;
     $id_order = parent::create_id('ordine');
     $token = parent::randomStr(40);
     $seed = sha1(md5($id_order . $token));
     if ($this->db->Execute("INSERT INTO ordine VALUES(?,?,?,?,?,NOW(),0,?,0,?)", array($id_order, $type, $token, $id_cliente, $cart->getTotal(), $payment, $this->lang))) {
         $this->registra_prodotti($id_cliente, $cart, $id_order);
     } else {
         $err = -1;
     }
     return array('err' => $err, 'seed' => $seed);
 }