Exemplo n.º 1
0
 function extractClientMail()
 {
     $stmt = $this->pdo->prepare("SELECT k.id,k.firma,k.email,k.land, kd.nummer,kdp.einzelpreis,kdp.menge FROM kontakte as k, kontakte_dokumente as kd, kontakte_dokumente_positionen as kdp WHERE k.land like '%%' and kdp.dokument_id = kd.id and kd.kontakte_id = k.id and kdp.dokument_id IN (SELECT kd.id FROM kontakte_dokumente as kd WHERE kd.typ = 7) ORDER BY k.land");
     try {
         $stmt->execute();
     } catch (Exception $e) {
         echo $e->getLine() . " : " . $e->getMessage();
     }
     $lineOrders = $stmt->fetchAll(PDO::FETCH_ASSOC);
     $this->orders = array();
     foreach ($lineOrders as $lineOrder) {
         $tag = $this->getIndex($lineOrder["nummer"]);
         if ($tag !== false) {
             $new_product = new product('', $lineOrder["einzelpreis"], $lineOrder["menge"]);
             $this->orders[$tag]->addProduct($new_product);
         } else {
             $new_order = new order($lineOrder['nummer'], '', $lineOrder['firma'], $lineOrder['id']);
             $new_order->setCC($lineOrder['land']);
             $new_order->setMail($lineOrder['email']);
             $new_product = new product('', $lineOrder["einzelpreis"], $lineOrder["menge"]);
             $new_order->addProduct($new_product);
             array_push($this->orders, $new_order);
         }
         $this->updatePrice();
     }
     $this->clients = array();
     foreach ($this->orders as $order) {
         if ($order->getCC() != 0 && $order->getCC() != NULL) {
             $tag = $this->getIndexofClient($order->getCustomer_name(), $this->clients);
             if ($tag !== false) {
                 $this->clients[$tag]->addOrder($order);
             } else {
                 $new_customer = new customer($order->getCustomer_name());
                 $new_customer->addOrder($order);
                 $new_customer->setId($order->getCustomer_id());
                 $new_customer->setCC($order->getCC());
                 $new_customer->setMail($order->getMail());
                 array_push($this->clients, $new_customer);
             }
         }
     }
     foreach ($this->clients as $client) {
         $client->calcAmount();
     }
     return $this->clients;
 }