Example #1
0
 public function findAllByOptionValue($value_id, $customer_id)
 {
     $tmp_cards = $this->getTable()->findAllByOptionValue($value_id, $customer_id);
     $cards = array();
     $remove_cards = false;
     if (!empty($tmp_cards)) {
         foreach ($tmp_cards as $tmp_card) {
             $card = new self();
             $card->setData($tmp_card->getData());
             $is_locked = false;
             if (!is_null($card->getLastError())) {
                 $now = $this->formatDate(null, 'y-MM-dd HH:mm:ss');
                 $date = new Zend_Date($card->getLastError());
                 $last_error = $date->addDay(1)->toString('y-MM-dd HH:mm:ss');
                 $is_locked = $last_error > $now && $card->getNumberOfError() >= 3;
                 if (!$last_error > $now) {
                     $card->setNumberOfError(0);
                 }
             }
             $card->setIsLocked($is_locked)->setId($card->getCustomerCardId());
             // Si la carte est bloquée, on ne conserve que celle là, on supprime les autres et on stop le traitement
             if ($is_locked) {
                 $cards = array($card);
                 break;
             } else {
                 $cards[] = $card;
             }
         }
     }
     return $cards;
 }