function find($criteria = null, $order = null, $limit = 1000, $from = 0)
 {
     $result = $this->database->query($this->buildFindQuery($criteria, $order, $limit, $from));
     if (!is_null($result->getError())) {
         return $result->getError();
     }
     $getresponse_sends = array();
     while ($row = $result->fetchRow()) {
         $getresponse_send = new Getresponse_send();
         $value = $row[0];
         $getresponse_send->setId($value);
         $value = $row[1];
         $getresponse_send->setPid($value);
         $value = $row[2];
         $getresponse_send->setCid($value);
         $value = $row[3];
         $getresponse_send->setSid($value);
         $value = $row[4];
         $getresponse_send->setEid($value);
         $value = $row[5];
         $getresponse_send->setApi($value);
         $value = $row[6];
         $getresponse_send->setCampaign($value);
         $value = $row[7];
         $getresponse_send->setReturn_string($value);
         $value = $row[8];
         $getresponse_send->setR_date($value);
         if ($order != null) {
             array_push($getresponse_sends, $getresponse_send);
         } else {
             $getresponse_sends[$getresponse_send->getId()] = $getresponse_send;
         }
     }
     return $getresponse_sends;
 }
 function sendClientToGetResponse($event)
 {
     //TODO padaryti informavima del feilo
     $stage = $this->stageDao->get($event->getSid());
     if (is_null($stage)) {
         return false;
     } else {
         if (is_string($stage)) {
             return false;
         }
     }
     if (!$stage->isSend()) {
         return true;
     }
     $client = $this->clientDaol->get($event->getCid());
     if (is_null($client)) {
         return false;
     } else {
         if (is_string($client)) {
             return false;
         }
     }
     $apiType = "contacts";
     $apiKey = "X-Auth-Token: api-key " . $stage->getApi();
     $url = $this->getResponseApiUrl . $apiType;
     $ch = curl_init($url);
     $campaignID = $this->getResponseCampaignId($stage->getApi(), $stage->getCampaign());
     if (!$campaignID) {
         $campaignID = $stage->getCampaign();
     }
     $jsonData = array("name" => $client->getTelephone(), "email" => $client->getEmail(), "dayOfCycle" => "0", "campaign" => array("campaignId" => $campaignID));
     /*$customFieldId = $this->getResonseCustomFieldId($stage->getApi(),"phone");
       if(!is_null($customFieldId)){
           $jsonData["customFieldValues"] = array(array(
                                                      "customFieldId" => $customFieldId,
                                                      "value" => array($client->getTelephone())
                                                  ));
       }*/
     $jsonDataEncoded = json_encode($jsonData);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonDataEncoded);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($ch, CURLOPT_VERBOSE, 0);
     curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json', $apiKey));
     $result = curl_exec($ch);
     $getResponseSend = new Getresponse_send();
     $getResponseSend->setPid($event->getPid());
     $getResponseSend->setCid($event->getCid());
     $getResponseSend->setSid($event->getSid());
     $getResponseSend->setEid($event->getId());
     $getResponseSend->setApi($stage->getApi());
     $getResponseSend->setCampaign($stage->getCampaign());
     $getResponseSend->setReturn_string($result);
     $getResponseSend->setR_date(Date::getCurrentDatr());
     $this->getResponseSendDao->Insert($getResponseSend, true);
 }