function saveSubscriber()
 {
     //region SAVE_PARAMS
     $getResponse = new Getresponse();
     if (isset($_GET['CONTACT_ID'])) {
         $getResponse->setContact_id(urldecode($_GET['CONTACT_ID']));
     } else {
         $getResponse->setContact_id('-');
     }
     if (isset($_GET['ACCOUNT_ID'])) {
         $getResponse->setAccount_id(urldecode($_GET['ACCOUNT_ID']));
     } else {
         $getResponse->setAccount_id('-');
     }
     if (isset($_GET['account_login'])) {
         $getResponse->setAccount_login(urldecode($_GET['account_login']));
     } else {
         $getResponse->setAccount_id('-');
     }
     if (isset($_GET['contact_name'])) {
         $getResponse->setContact_name(urldecode($_GET['contact_name']));
     } else {
         $getResponse->setContact_name('-');
     }
     if (isset($_GET['campaign_name'])) {
         $getResponse->setCampaign_name(urldecode($_GET['campaign_name']));
     } else {
         $getResponse->setCampaign_name('-');
     }
     if (isset($_GET['contact_ip'])) {
         $getResponse->setContact_ip(urldecode($_GET['contact_ip']));
     } else {
         $getResponse->setContact_ip('-');
     }
     if (isset($_GET['CAMPAIGN_ID'])) {
         $getResponse->setCampaign_id(urldecode($_GET['CAMPAIGN_ID']));
     } else {
         $getResponse->setCampaign_id('-');
     }
     if (isset($_GET['contact_email'])) {
         $getResponse->setContact_email(urldecode($_GET['contact_email']));
     } else {
         $getResponse->setContact_email('-');
     }
     if (isset($_GET['contact_origin'])) {
         $getResponse->setContact_origin(urldecode($_GET['contact_origin']));
     } else {
         $getResponse->setContact_origin('-');
     }
     if (isset($_GET['action'])) {
         $getResponse->setAction(urldecode($_GET['action']));
     } else {
         $getResponse->setAction('-');
     }
     $timeZone = new DateTimeZone("Europe/Vilnius");
     $time = new DateTime("now", $timeZone);
     $getResponse->setA_date($time->format("Y-m-d H:i:s"));
     if (!$this->storeParams($getResponse)) {
         $getResponse->setId(99999);
     }
     //endregion
     //var_dump($getResponse);
     //region CHECK_POJECT
     $criteriaOr = new OrStatement();
     $field = $this->projectDao->getQCampaignName();
     $criteriaOr->addStatement($field . "='" . addslashes($getResponse->getCampaign_name()) . "'");
     $field = $this->projectDao->getQSuspendingName();
     $criteriaOr->addStatement($field . "='" . addslashes($getResponse->getCampaign_name()) . "'");
     $field = $this->projectDao->getQEndingName();
     $criteriaOr->addStatement($field . "='" . addslashes($getResponse->getCampaign_name()) . "'");
     $projects = $this->projectDao->find($criteriaOr, null, 1000);
     if (!is_array($projects)) {
         $this->setParamPoz($getResponse->getId(), 2, "Nepavyko nustatyti projekto");
         return false;
     } else {
         if (count($projects) == 0) {
             $this->setParamPoz($getResponse->getId(), 2, "Nepavyko nustatyti projekto");
             return false;
         }
     }
     //$project = reset($projects);
     //endregion
     //var_dump($project);
     foreach ($projects as $project) {
         $campaignType = -1;
         switch ($getResponse->getCampaign_name()) {
             case $project->getCampaign():
                 $campaignType = 1;
                 break;
             case $project->getSuspending():
                 $campaignType = 0;
                 break;
             case $project->getEnding():
                 $campaignType = 3;
                 break;
         }
         if ($campaignType == -1) {
             $this->setParamPoz($getResponse->getId(), 2, "Nepavyko nustatyti kampanijos tipo");
             return FALSE;
         }
         $newClient = FALSE;
         //Aktyvavimo kampanija
         if ($campaignType == 1) {
             // Patikrinam ar neegzistuoja toks klientas
             $criteria = new AndStatement();
             $field = $this->clientDaol->getQPidName();
             $criteria->addStatement($field . "='" . addslashes($project->getId()) . "'");
             $field = $this->clientDaol->getQEmailName();
             $criteria->addStatement($field . "='" . addslashes($getResponse->getContact_email()) . "'");
             $clients = $this->clientDaol->find($criteria, NULL, 1000);
             if (is_null($clients)) {
                 $this->setParamPoz($getResponse->getId(), 2, "Nepavyko patikrinti ar toks klientas jau uzregistruotas [1]");
                 return FALSE;
             } else {
                 if (is_string($clients)) {
                     $this->setParamPoz($getResponse->getId(), 2, "Nepavyko patikrinti ar toks klientas jau uzregistruotas [2]");
                     return FALSE;
                 } else {
                     if (!is_array($clients)) {
                         $this->setParamPoz($getResponse->getId(), 2, "Nepavyko patikrinti ar toks klientas jau uzregistruotas [3]");
                         return FALSE;
                     }
                 }
             }
             if (count($clients) == 0) {
                 //Jei neradome kliento - kuriame nauaja
                 $client = new Client();
                 $client->setPid($project->getId());
                 $client->setEmail($getResponse->getContact_email());
                 $client->setTelephone($getResponse->getContact_name());
                 $client->setActive(TRUE);
                 $newClient = TRUE;
             } else {
                 $client = reset($clients);
                 if (!$client->isActive() && !$client->isEnded()) {
                     $client->setActive(TRUE);
                     $this->saveEventHistory($client, "Aktyvuotas GetResponse sistemos");
                 } else {
                     $this->setParamPoz($getResponse->getId(), 2, "Klientas jau yra sukurtas projekte ir yra aktyvus arba pabaigtas");
                     return FALSE;
                 }
             }
         }
         //Suspendavimo kampanija
         if ($campaignType == 0) {
             $criteria = new AndStatement();
             $field = $this->clientDaol->getQPidName();
             $criteria->addStatement($field . "='" . addslashes($project->getId()) . "'");
             $field = $this->clientDaol->getQEmailName();
             $criteria->addStatement($field . "='" . addslashes($getResponse->getContact_email()) . "'");
             $field = $this->clientDaol->getQActiveName();
             $criteria->addStatement($field . "='1'");
             $clients = $this->clientDaol->find($criteria, NULL, 1000);
             if (is_null($clients)) {
                 $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [1]");
                 return FALSE;
             } else {
                 if (is_string($clients)) {
                     $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [2]");
                     return FALSE;
                 } else {
                     if (!is_array($clients)) {
                         $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [3]");
                         return FALSE;
                     } else {
                         if (count($clients) == 0) {
                             $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [4]");
                             return FALSE;
                         }
                     }
                 }
             }
             var_dump($clients);
             $client = reset($clients);
             if (!$client->isActive()) {
                 $this->setParamPoz($getResponse->getId(), 2, "Klientas jau suspenduotas");
                 return FALSE;
             }
             if ($client->isEnded()) {
                 $this->setParamPoz($getResponse->getId(), 2, "Klientas jau pabaigtas");
                 return FALSE;
             }
             $client->setActive(FALSE);
             $this->saveEventHistory($client, "Atsisakyta per GetResponse sistemÄ…");
         }
         //Pabaigos kampanija
         if ($campaignType == 3) {
             $criteria = new AndStatement();
             $field = $this->clientDaol->getQPidName();
             $criteria->addStatement($field . "='" . addslashes($project->getId()) . "'");
             $field = $this->clientDaol->getQEmailName();
             $criteria->addStatement($field . "='" . addslashes($getResponse->getContact_email()) . "'");
             $field = $this->clientDaol->getQActiveName();
             $criteria->addStatement($field . "='1'");
             $clients = $this->clientDaol->find($criteria, NULL, 1000);
             if (is_null($clients)) {
                 $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [1]");
                 return FALSE;
             } else {
                 if (is_string($clients)) {
                     $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [2]");
                     return FALSE;
                 } else {
                     if (!is_array($clients)) {
                         $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [3]");
                         return FALSE;
                     } else {
                         if (count($clients) == 0) {
                             $this->setParamPoz($getResponse->getId(), 2, "Nerastas klientas [4]");
                             return FALSE;
                         }
                     }
                 }
             }
             var_dump($clients);
             $client = reset($clients);
             if ($client->isEnded()) {
                 $this->setParamPoz($getResponse->getId(), 2, "Klientas jau pabaigtas");
                 return FALSE;
             }
             $client->setEnded(TRUE);
             $this->saveEventHistory($client, "Pabaigtas GetResponse sistemos");
         }
         $timeZone = new DateTimeZone("Europe/Vilnius");
         $time = new DateTime("now", $timeZone);
         $client->setR_date($time->format("Y-m-d H:i:s"));
         $client->setR_user(9999);
         $store = $this->storeClient($client, $getResponse);
         if (!$store) {
             return FALSE;
         }
         if ($newClient) {
             $this->saveEventHistory($client, "Sukurtas GetResponse sistemos");
         }
         $this->setParamPoz($getResponse->getId(), 1);
     }
     return true;
 }
Example #2
0
 function getEventList($date, $state)
 {
     $criteria = new AndStatement();
     $field = $this->eventDao->getQStateName();
     $criteria->addStatement($field . "='" . addslashes($state) . "'");
     $field = $this->eventDao->getQValid_DateName();
     if (is_array($date)) {
         $criteriaOr = new OrStatement();
         foreach ($date as $dt) {
             $criteriaOr->addStatement($field . " like'" . addslashes($dt) . "%'");
         }
         $criteria->addStatement($criteriaOr);
     } else {
         $criteria->addStatement($field . " like '" . addslashes($date) . "%'");
     }
     /*$criteriaOr = new OrStatement();
       $criteriaOr->addStatement($field ."='". addslashes($date) ."'");
       $criteriaOr->addStatement($field ."='". addslashes($this->minusDaysFromGetDate(1)) ."'");
       $criteriaOr->addStatement($field ."='". addslashes($this->minusDaysFromGetDate(2)) ."'");
       $criteria->addStatement($criteriaOr);*/
     $eventList = $this->eventDao->find($criteria, null, 1000);
     if (is_string($eventList)) {
         return false;
     } else {
         if (!is_array($eventList)) {
             return false;
         }
     }
     return $eventList;
 }
Example #3
0
 function checkCampaignUnique($campaign)
 {
     $criteriaOr = new OrStatement();
     $field = $this->projectDao->getQCampaignName();
     $criteriaOr->addStatement($field . "='" . addslashes($campaign) . "'");
     $field = $this->projectDao->getQSuspendingName();
     $criteriaOr->addStatement($field . "='" . addslashes($campaign) . "'");
     $field = $this->projectDao->getQEndingName();
     $criteriaOr->addStatement($field . "='" . addslashes($campaign) . "'");
     $projects = $this->projectDao->find($criteriaOr, null, 1);
     //            var_dump($projects);
     //            exit;
     /*if (!$projects){
           return false;
       } else */
     if (count($projects) > 0) {
         return false;
     }
     return true;
 }