Ejemplo n.º 1
0
 protected function runAction()
 {
     $translate = $this->application->getBootstrap()->getResource('translate');
     $view = $this->application->getBootstrap()->getResource('view');
     $acl = Zend_Controller_Front::getInstance()->getParam('bootstrap')->getResource('formacl');
     $view->setScriptPath(APPLICATION_PATH . '/views/scripts');
     $logic = new Logic_MailerQueque();
     $model = new MailerQueque();
     $data = array();
     $data = $logic->getMailsValidToSend();
     $sendCounter['success'] = 0;
     $sendCounter['error'] = 0;
     $sendCounter['overall'] = 0;
     foreach ($data as $mail) {
         $mailer = new Logic_Mailer($view, $translate);
         $sendCounter['overall']++;
         try {
             $mailerStatus = $mailer->userRemindMeeting($mail['id_contact'], $mail['id'], $mail['mail_template_type']);
             $sendCounter['success']++;
         } catch (Exception $e) {
             //$logicMailerQueque = new Logic_MailerQueque();
             //$logicMailerQueque->markAsGhost($mail['id_contact'],$mail['id']);
             echo $e . ' Nie wysłano maila do kontaktu o id: ' . $mail['id_contact'] . "\n";
             $sendCounter['error']++;
         }
         echo $mailerStatus . "\n";
     }
     echo "\n <<<< PODSUMOWANIE WYSYŁKI E-MAILI >>>> ";
     echo "\n";
     echo "\n Ilość maili pobranych do wysyłki: " . $sendCounter['overall'];
     echo "\n";
     echo "\n Wysłanych poprawnie wiadomości: " . $sendCounter['success'];
     echo "\n Nie wysłanych wiadomości: " . $sendCounter['error'];
     echo "\n";
     echo "\n <<<< PODSUMOWANIE WYSYŁKI E-MAILI >>>> ";
 }
Ejemplo n.º 2
0
 /**
  * @todo przepiąć to na createEvent, bo w sumie to właśnie to się chyba będzie działo
  * @todo pomyśleć co zrobić z poprzednim eventem, żeby się nie pokazywał w kalendarzu
  * @todo tworzenie spotkania do eventu
  */
 public function updateMeeting($form, $id, $type, $id_meeting, $registered = 0)
 {
     //        return $this->execute(__METHOD__, func_get_args(), array('logger' => array('writer' => 'contact','changes'=>false), 'parent' => array('id' => $id, 'class' => 'Contact')));
     //    }
     //
     //    public function _updateMeeting($form, $id, $type, $id_meeting, $registered = 0) {
     $eventModel = new Event();
     $contactModel = new Contact();
     $meetingModel = new Meeting();
     $values = $form->getValues();
     $contact = $contactModel->findOne($id);
     $contact->changeGuardian(($contact->cc_status[0] == 1 || $contact->cc_status[0] == 2) && Zend_Auth::getInstance()->getIdentity()->id_branch == 1);
     $contact->cc_status = '{4,0,0}';
     /**
      * Jezeli przekladamy na spotkanie poza oddzialem ze spotkania w oddziale,
      * usuwamy wysztkie maile i smsy z powiadomieniem o spotkaniu w oddziale,
      * jesli jeszcze nie zostaly one wyslane.
      */
     $nextEvent = $contact->getNextEvent();
     if ($type == 'out' && $nextEvent->id_event_type == 3) {
         $logicMailerQueque = new Logic_MailerQueque();
         $logicMailerQueque->resetMailerQuequeTime($id);
         //$sms_content = $this->getSmsDataForContent($id,$type=1);
         $logicSmsQueque = new Logic_SmsQueque();
         $logicSmsQueque->resetSmsQuequeTime($id, null);
     }
     if ($registered) {
         $contact->is_comeback = false;
     }
     $eventData = $values;
     $time_min = strtotime($eventData['event_at'] . ' - 6 hours');
     $time_max = strtotime($eventData['event_at'] . ' - 1 hour');
     //        if ($registered || ( ($time_min <= time() ) && ($time_max >= time()) ) )
     //            $confirmation_required = 0;
     //        else
     //            $confirmation_required = 1;
     /**
      * jakieś dziwne rozwiązanie specjanie dla TC
      */
     $confirmation_required = 0;
     if (!$registered && !$visit && time() < $time_max && Zend_Auth::getInstance()->getIdentity()->jednostka['type'] == 3 && $type != 'out') {
         $confirmation_required = 1;
     }
     $lastEvent = $contact->getNextEvent();
     $event = $eventModel->createRow();
     $meeting = $meetingModel->findOne($id_meeting);
     $eventData['cc_meeting_title'] = $meeting->cc_meeting_title;
     $eventData['id_meeting'] = $id_meeting;
     $eventData['id_contact'] = $id;
     $eventData['created_by'] = Zend_Auth::getInstance()->getIdentity()->id;
     $eventData['id_event_type'] = $type == 'out' ? 4 : 3;
     $eventData['confirmed'] = 0;
     $eventData['confirmation_required'] = $confirmation_required;
     $eventData['meeting_registered'] = 0;
     $eventData['registrant_branch'] = Zend_Auth::getInstance()->getIdentity()->id_branch;
     $eventData['id_branch'] = $eventData['responsible_branch'];
     $eventData['contact_type'] = $contact->type;
     //        if($lastEvent->id_event_type == $eventData['id_event_type']) {
     $eventData['moved'] = ++$meeting->moved;
     //        }
     $eventData['contacts'] = ++$meeting->contacts;
     if (!$eventData['responsible_adviser']) {
         unset($eventData['responsible_adviser']);
     }
     if ($contact->id_company != null) {
         $eventData['id_company'] = $contact->id_company;
     }
     $meetingData = array();
     $meetingData['id_contact'] = $id;
     $meetingData['cc_meeting_title'] = $meeting->cc_meeting_title;
     $meetingData['meeting_title'] = $eventData['meeting_title'];
     $meetingData['id_branch'] = $eventData['responsible_branch'];
     $meetingData['meeting_at'] = $eventData['event_at'];
     $meetingData['confirmed'] = 0;
     $meetingData['confirmation_required'] = $confirmation_required;
     $meetingData['registered'] = (int) $registered;
     $meetingData['length'] = $eventData['meeting_length'];
     $meetingData['money_amount'] = $eventData['money_amount'];
     $meetingData['id_meeting_type'] = $type == 'out' ? 4 : 3;
     $meetingData['moved'] = $meeting->moved;
     $meetingData['contacts'] = $meeting->contacts;
     if (isset($eventData['responsible_adviser'])) {
         $meetingData['id_user'] = $eventData['responsible_adviser'];
     }
     //        $lc = new Logic_Contact();
     //        $lc->saveClassification(array("classification_{$eventData['interest_point']}" => $eventData['classification']), $id, true);
     //        unset($eventData['classification']);
     $event->setFromArray($eventData);
     $lastEveteDate = strtotime($lastEvent->event_at);
     $nextEveteDate = strtotime($eventData['event_at']);
     $lastEventAt = new DateTime(date('Y-m-d H:i:s', mktime(0, 0, 0, date('m', $lastEveteDate), date('d', $lastEveteDate), date('Y', $lastEveteDate))));
     $nextEventAt = new DateTime(date('Y-m-d H:i:s', mktime(0, 0, 0, date('m', $nextEveteDate), date('d', $nextEveteDate), date('Y', $nextEveteDate))));
     if ($lastEventAt->diff($nextEventAt)->format('%r') == 0) {
         $lastEvent->is_latest_this_day = 0;
     }
     $lastEvent->moved_days = new Zend_Db_Expr((int) $lastEventAt->diff($nextEventAt)->format('%r%a'));
     try {
         $eventModel->getAdapter()->beginTransaction();
         $lastEvent->save();
         $event_id = $event->save();
         $meetingData['id_event'] = $event_id;
         $meeting->setFromArray($meetingData);
         $meeting->save();
         if ($type == 'out') {
             $contact->after_meeting_out = true;
         } else {
             $contact->after_meeting_out = 0;
         }
         if ($registered) {
             $contact->type = 2;
         }
         $ret = $contact->save();
         $eventModel->getAdapter()->commit();
         //if ($time <= time() && $contact->cell_phone != null) {
         //    $this->sendsms($id);
         //}
     } catch (Exception $e) {
         $eventModel->getAdapter()->rollBack();
         throw $e;
     }
     $message['messages']['Contact'][$id] = 'Meeting was updated.';
     $logger = Zend_Registry::get('logger');
     Zend_Registry::set('logger', array_merge($logger, $message));
     return $ret;
 }