protected static function makeSqlQuery($searchAttributeData)
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     $where = null;
     $selectDistinct = false;
     $autoresponderTableName = Autoresponder::getTableName('Autoresponder');
     $autoresponderItemTableName = AutoresponderItem::getTableName('AutoresponderItem');
     $emailMessageTableName = EmailMessage::getTableName('EmailMessage');
     $sentDateTimeColumnName = EmailMessage::getColumnNameByAttribute('sentDateTime');
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Autoresponder');
     $selectQueryAdapter = new RedBeanModelSelectQueryAdapter($selectDistinct);
     $queuedEmailsSelectPart = "sum(CASE WHEN {$quote}{$emailMessageTableName}{$quote}.{$quote}{$sentDateTimeColumnName}" . $quote . " = '0000-00-00 00:00:00' OR {$quote}{$emailMessageTableName}{$quote}" . ".{$quote}{$sentDateTimeColumnName}{$quote} IS NULL THEN 1 ELSE 0 END)";
     // Not Coding Standard
     $sentEmailsSelectPart = "sum(CASE WHEN {$quote}{$emailMessageTableName}{$quote}.{$quote}{$sentDateTimeColumnName}" . $quote . " > '0000-00-00 00:00:00' THEN 1 ELSE 0 END)";
     $uniqueOpensSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_OPEN);
     $uniqueClicksSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_CLICK);
     $bouncedSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_BOUNCE);
     $optedOutSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_UNSUBSCRIBE);
     static::addEmailMessageDayDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     static::addEmailMessageFirstDayOfWeekDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     static::addEmailMessageFirstDayOfMonthDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     $selectQueryAdapter->addNonSpecificCountClause();
     $selectQueryAdapter->addClauseByQueryString($queuedEmailsSelectPart, static::QUEUED);
     $selectQueryAdapter->addClauseByQueryString($sentEmailsSelectPart, static::SENT);
     $selectQueryAdapter->addClauseByQueryString("count((" . $uniqueOpensSelectPart . "))", static::UNIQUE_OPENS);
     $selectQueryAdapter->addClauseByQueryString("count((" . $uniqueClicksSelectPart . "))", static::UNIQUE_CLICKS);
     $selectQueryAdapter->addClauseByQueryString("count((" . $bouncedSelectPart . "))", static::BOUNCED);
     $selectQueryAdapter->addClauseByQueryString("count((" . $optedOutSelectPart . "))", static::UNSUBSCRIBED);
     $joinTablesAdapter->addLeftTableAndGetAliasName($autoresponderItemTableName, 'id', $autoresponderTableName, 'autoresponder_id');
     $joinTablesAdapter->addLeftTableAndGetAliasName($emailMessageTableName, 'emailmessage_id', $autoresponderItemTableName, 'id');
     $where = RedBeanModelDataProvider::makeWhere('Autoresponder', $searchAttributeData, $joinTablesAdapter);
     $sql = SQLQueryUtil::makeQuery($autoresponderTableName, $selectQueryAdapter, $joinTablesAdapter, null, null, $where);
     return $sql;
 }
 public static function populateAutoresponderItem($processed, $processDateTime, $autoresponder = null, $contact = null)
 {
     assert('is_string($processed) || is_int($processed)');
     assert('is_string($processDateTime)');
     assert('is_object($autoresponder) || $autoresponder === null');
     assert('is_object($contact) || $contact === null');
     if (empty($autoresponder)) {
         $autoresponders = Autoresponder::getAll();
         if (!empty($autoresponders)) {
             $autoresponder = RandomDataUtil::getRandomValueFromArray($autoresponders);
         }
     }
     if (empty($contact)) {
         $contacts = Contact::getAll();
         if (!empty($contacts)) {
             $contact = RandomDataUtil::getRandomValueFromArray($contacts);
         }
     }
     $autoresponderItem = new AutoresponderItem();
     $autoresponderItem->processed = $processed;
     $autoresponderItem->processDateTime = $processDateTime;
     $autoresponderItem->autoresponder = $autoresponder;
     $autoresponderItem->contact = $contact;
     return $autoresponderItem;
 }
 /**
  * @param DemoDataHelper $demoDataHelper
  */
 public function makeAll(&$demoDataHelper)
 {
     assert('$demoDataHelper instanceof DemoDataHelper');
     assert('$demoDataHelper->isSetRange("Contact")');
     assert('$demoDataHelper->isSetRange("Autoresponder")');
     $items = array();
     if ($this->loadMagnitude >= 100) {
         foreach (Autoresponder::getAll() as $autoresponder) {
             foreach ($autoresponder->marketingList->marketingListMembers as $marketingListMember) {
                 $item = new AutoresponderItem();
                 $item->autoresponder = $autoresponder;
                 $item->contact = $marketingListMember->contact;
                 $this->populateModel($item);
                 $saved = $item->unrestrictedSave();
                 assert('$saved');
                 $items[] = $item->id;
             }
         }
     } else {
         for ($i = 0; $i < $this->resolveQuantityToLoad(); $i++) {
             $item = new AutoresponderItem();
             $item->autoresponder = $demoDataHelper->getRandomByModelName('Autoresponder');
             $item->contact = $demoDataHelper->getRandomByModelName('Contact');
             $this->populateModel($item);
             $saved = $item->unrestrictedSave();
             assert('$saved');
             $items[] = $item->id;
         }
     }
     $demoDataHelper->setRangeByModelName('AutoresponderItem', $items[0], $items[count($items) - 1]);
 }
 protected static function renderExtraInfoContent(Autoresponder $autoresponder)
 {
     $operationValuesAndLabels = Autoresponder::getOperationTypeDropDownArray();
     if (!isset($operationValuesAndLabels[$autoresponder->operationType])) {
         return;
     }
     $intervalValuesAndLabels = Autoresponder::getIntervalDropDownArray();
     if (!isset($intervalValuesAndLabels[$autoresponder->secondsFromOperation])) {
         return;
     }
     $content = null;
     $content .= Zurmo::t('AutorespondersModule', 'Send {timeFrame} after {operation}', array('{timeFrame}' => $intervalValuesAndLabels[$autoresponder->secondsFromOperation], '{operation}' => $operationValuesAndLabels[$autoresponder->operationType]));
     return $content;
 }
 protected static function renderExtraInfoContent(Autoresponder $autoresponder)
 {
     $operationValuesAndLabels = Autoresponder::getOperationTypeDropDownArray();
     $durationTypeValueAndLabels = TimeDurationUtil::getValueAndLabels();
     if (!isset($operationValuesAndLabels[$autoresponder->operationType])) {
         return;
     }
     if (!isset($durationTypeValueAndLabels[$autoresponder->fromOperationDurationType])) {
         return;
     }
     if ($autoresponder->fromOperationDurationInterval == 0) {
         return Zurmo::t('AutorespondersModule', 'Send immediately after {operation}', array('{operation}' => $operationValuesAndLabels[$autoresponder->operationType]));
     } else {
         $content = Zurmo::t('AutorespondersModule', 'Send {interval} {type} after {operation}', array('{interval}' => $autoresponder->fromOperationDurationInterval, '{type}' => $durationTypeValueAndLabels[$autoresponder->fromOperationDurationType], '{operation}' => $operationValuesAndLabels[$autoresponder->operationType]));
         return $content;
     }
 }
 public static function fillAutoresponderItem($processed, $processDateTime, $autoresponder = null, $contact = null)
 {
     if (empty($autoresponder)) {
         $autoresponders = Autoresponder::getAll();
         if (!empty($autoresponders)) {
             $autoresponder = RandomDataUtil::getRandomValueFromArray($autoresponders);
         }
     }
     if (empty($contact)) {
         $contacts = Contact::getAll();
         if (!empty($contacts)) {
             $contact = RandomDataUtil::getRandomValueFromArray($contacts);
         }
     }
     $autoresponderItem = new AutoresponderItem();
     $autoresponderItem->processed = $processed;
     $autoresponderItem->processDateTime = $processDateTime;
     $autoresponderItem->autoresponder = $autoresponder;
     $autoresponderItem->contact = $contact;
     return $autoresponderItem;
 }
Ejemplo n.º 7
0
 public static function add_message()
 {
     $autoresponder_id = intval($_GET['id']);
     $autoresponderObject = Autoresponder::getAutoresponder($autoresponder_id);
     $custom_fields = $autoresponderObject->getNewsletter()->getCustomFieldKeyLabelPair();
     self::enqueue_wysiwyg();
     //TODO: THIS METHOD DEF SHOULDN'T BE WHERE IT IS RIGHT NOW
     _wpr_set("custom_fields", $custom_fields);
     _wpr_set("autoresponder", $autoresponderObject);
     _wpr_setview("autoresponder_add_message");
 }
 /**
  * @depends testSuperUserCreateActionWithParameters
  */
 public function testSuperUserDeleteAction()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(3, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $this->setGetArray(array('id' => $autoresponderId));
     $content = $this->runControllerWithNoExceptionsAndGetContent('autoresponders/default/delete', true);
     $this->assertEmpty($content);
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(2, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $redirectUrl = 'http://www.zurmo.com/';
     $this->setGetArray(array('id' => $autoresponderId, 'redirectUrl' => $redirectUrl));
     $resolvedRedirectUrl = $this->runControllerWithRedirectExceptionAndGetUrl('autoresponders/default/delete');
     $this->assertEquals($redirectUrl, $resolvedRedirectUrl);
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders);
     $this->assertCount(1, $autoresponders);
 }
Ejemplo n.º 9
0
 public function testDeleteAutoresponderMessageDeletesOnlyItsOwnFromQueue()
 {
     global $wpdb;
     $addAutoresponderQuery = sprintf("INSERT INTO %swpr_autoresponders (nid, name) VALUES (%d,'%s' )", $wpdb->prefix, $this->newsletterId, md5(microtime()));
     $results = $wpdb->query($addAutoresponderQuery);
     $autoresponder = Autoresponder::getAutoresponder($wpdb->insert_id);
     $autoresponder_message = array('textbody' => 'This is a test', 'htmlbody' => 'This is a <test>body</test>', 'subject' => 'Test Subject', 'offset' => 3);
     try {
         $message = $autoresponder->addMessage($autoresponder_message);
     } catch (Exception $exc) {
         throw new BadFunctionCallException();
     }
     //add 10 of these messages in the queue.
     for ($iter = 0; $iter < 10; $iter++) {
         $addMessageToQueueQuery = sprintf("INSERT INTO %swpr_queue (`to`, `meta_key`, `sent`, `hash`) VALUES ('%s','AR-%d-%d-%d-%d', 0, '%s')", $wpdb->prefix, 'test' . microtime() . '@test.com', $autoresponder->getId(), $iter, $message->getId(), $iter, md5(microtime()));
         $wpdb->query($addMessageToQueueQuery);
     }
     $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=0 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, $message->getId());
     $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage);
     $numOfUnsentMessages = $resultSet[0]->num;
     $this->assertEquals(10, $numOfUnsentMessages);
     //add 10 of these messages in the queue.
     for ($iter = 10; $iter < 20; $iter++) {
         $addMessageToQueueQuery = sprintf("INSERT INTO %swpr_queue (`to`, `meta_key`, `sent`, `hash`) VALUES ('%s','AR-%d-%d-%d-%d', 1, '%s')", $wpdb->prefix, 'test' . microtime() . '@test.com', $autoresponder->getId(), $iter, 9801, $iter, md5(microtime()));
         $wpdb->query($addMessageToQueueQuery);
     }
     $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=1 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, 9801);
     $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage);
     $numOfUnsentMessages = $resultSet[0]->num;
     $this->assertEquals(10, $numOfUnsentMessages);
     $autoresponder->deleteMessage($message);
     $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=0 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, $message->getId());
     $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage);
     $numOfUnsentMessages = $resultSet[0]->num;
     $this->assertEquals(0, $numOfUnsentMessages);
     $getNumberOfUnsentMessagesForMessage = sprintf("SELECT COUNT(*) num FROM %swpr_queue WHERE sent=1 AND meta_key LIKE 'AR-%%%%-%%%%-%d-%%';", $wpdb->prefix, 9801);
     $resultSet = $wpdb->get_results($getNumberOfUnsentMessagesForMessage);
     $numOfUnsentMessages = $resultSet[0]->num;
     $this->assertEquals(10, $numOfUnsentMessages);
 }
 /**
  * @param array $searchAttributeData
  * @param string $groupBy
  * @return string
  */
 protected static function makeAutorespondersSqlQuery($searchAttributeData, $groupBy)
 {
     $quote = DatabaseCompatibilityUtil::getQuote();
     $where = null;
     $selectDistinct = false;
     $marketingListTableName = MarketingList::getTableName();
     $autoresponderTableName = Autoresponder::getTableName();
     $autoresponderItemTableName = AutoresponderItem::getTableName();
     $emailMessageTableName = EmailMessage::getTableName();
     $sentDateTimeColumnName = EmailMessage::getColumnNameByAttribute('sentDateTime');
     $joinTablesAdapter = new RedBeanModelJoinTablesQueryAdapter('Autoresponder');
     $selectQueryAdapter = new RedBeanModelSelectQueryAdapter($selectDistinct);
     $uniqueOpensSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_OPEN);
     $uniqueClicksSelectPart = static::resolveAutoresponderTypeSubQuery(EmailMessageActivity::TYPE_CLICK);
     static::addEmailMessageDayDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     static::addEmailMessageFirstDayOfWeekDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     static::addEmailMessageFirstDayOfMonthDateClause($selectQueryAdapter, $sentDateTimeColumnName);
     $selectQueryAdapter->addNonSpecificCountClause();
     $selectQueryAdapter->addClauseByQueryString("count((" . $uniqueOpensSelectPart . "))", static::UNIQUE_OPENS);
     $selectQueryAdapter->addClauseByQueryString("count((" . $uniqueClicksSelectPart . "))", static::UNIQUE_CLICKS);
     $joinTablesAdapter->addFromTableAndGetAliasName($marketingListTableName, 'marketinglist_id');
     $joinTablesAdapter->addLeftTableAndGetAliasName($autoresponderItemTableName, 'id', $autoresponderTableName, 'autoresponder_id');
     $joinTablesAdapter->addLeftTableAndGetAliasName($emailMessageTableName, 'emailmessage_id', $autoresponderItemTableName, 'id');
     $where = RedBeanModelDataProvider::makeWhere('Autoresponder', $searchAttributeData, $joinTablesAdapter);
     MarketingList::resolveReadPermissionsOptimizationToSqlQuery(Yii::app()->user->userModel, $joinTablesAdapter, $where, $selectDistinct);
     $sql = SQLQueryUtil::makeQuery($autoresponderTableName, $selectQueryAdapter, $joinTablesAdapter, null, null, $where, null, $groupBy);
     return $sql;
 }
 protected function getDropDownArray()
 {
     return Autoresponder::getIntervalDropDownArray();
 }
 public static function getMessage($message_id)
 {
     global $wpdb;
     if ("integer" != gettype($message_id)) {
         throw new InvalidArgumentException();
     }
     $getAutoresponderMessageRecordQuery = sprintf("SELECT * FROM {$wpdb->prefix}wpr_autoresponder_messages WHERE id=%d", $message_id);
     $results = $wpdb->get_results($getAutoresponderMessageRecordQuery);
     if (0 == count($results)) {
         throw new NonExistentMessageException();
     }
     $autoresponderId = $results[0]->aid;
     if (!Autoresponder::whetherAutoresponderExists(intval($autoresponderId))) {
         throw new NonExistentAutoresponderException();
     }
     $message = new AutoresponderMessage($results[0]);
     return $message;
 }
Ejemplo n.º 13
0
 public function sendConfirmation($orderId)
 {
     $order = ORM::factory('order', $orderId);
     $db = new Database();
     $res = $db->query('SELECT oa.* FROM orders_addresses oa JOIN orders o ON (oa.id = o.orders_address_id) WHERE o.id="' . $orderId . '"');
     // call autoresponder handlers
     $shippingInfo = $res[0]->shipping_first_name . ' ' . $res[0]->shipping_last_name . '<br/>' . $res[0]->shipping_address1 . '<br/>' . $res[0]->shipping_address2 . '<br/>' . $res[0]->shipping_city . ' ' . $res[0]->shipping_state . '<br/>' . $res[0]->shipping_zip . '<br/>' . $res[0]->shipping_country;
     $billingInfo = $res[0]->billing_first_name . ' ' . $res[0]->billing_last_name . '<br/>' . $res[0]->billing_address1 . '<br/>' . $res[0]->billing_address2 . '<br/>' . $res[0]->billing_city . ' ' . $res[0]->billing_state . '<br/>' . $res[0]->billing_zip . '<br/>' . $res[0]->billing_country;
     $dateTime = date('Y-m-d H:i:s');
     $res = $db->query('SELECT p.name, ob.qty, ob.subtotal FROM products p JOIN orders_baskets ob ON (ob.product_id=p.id) WHERE ob.order_id="' . $orderId . '"');
     $order_basket = new Orders_basket_Model();
     $description = '';
     $subtotal = 0;
     foreach ($res as $item) {
         $description .= $item->name . '  ' . $item->qty . ' x ' . format::dollar($item->subtotal) . '<br/>';
         $subtotal += $item->subtotal;
     }
     if (!empty($order->comment)) {
         $description .= 'Comment:' . $order->comment . '<br/>';
     }
     $total = 'Subtotal: ' . format::dollar($subtotal) . '<br/>Shipping:' . format::dollar($order->shipping_total);
     $total .= '<br/>Total:' . format::dollar($order->payment_total);
     Autoresponder::sendEmail('order.confirmation', $order->email, $order, array('shipping_info' => $shippingInfo, 'billing_info' => $billingInfo, 'date_time' => $dateTime, 'description' => $description, 'total' => $total));
 }
Ejemplo n.º 14
0
 public static function registerAutoresponderItemsByAutoresponderOperation($operation, $marketingListId, $contact)
 {
     $autoresponders = Autoresponder::getByOperationTypeAndMarketingListId($operation, $marketingListId);
     $now = time();
     foreach ($autoresponders as $autoresponder) {
         $processTimestamp = $now + $autoresponder->secondsFromOperation;
         $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime($processTimestamp);
         $processed = false;
         static::addNewItem($processed, $processDateTime, $contact, $autoresponder);
     }
 }
Ejemplo n.º 15
0
 function beforeDelete()
 {
     $criteria = new CDbCriteria();
     $criteria->condition = 'wlabel_id=:wlabel_id';
     $criteria->params = array(':wlabel_id' => $this->wlabel_id);
     Autoresponder::model()->deleteAll($criteria);
     return parent::beforeDelete();
 }
 /**
  * @depends testCreateAndGetMarketingListById
  */
 public function testDeleteMarketingList()
 {
     $marketingLists = MarketingList::getAll();
     $this->assertCount(2, $marketingLists);
     $marketingListId = $marketingLists[0]->id;
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingLists[0]);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingLists[0]);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingLists[1]);
     MarketingListMemberTestHelper::createMarketingListMember(0, $marketingLists[1]);
     AutoresponderTestHelper::createAutoresponder('subject 01', 'text content', 'html content', 1, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingLists[0]);
     AutoresponderTestHelper::createAutoresponder('subject 02', 'text content', 'html content', 1, Autoresponder::OPERATION_SUBSCRIBE, true, $marketingLists[1]);
     $autoresponders = Autoresponder::getByOperationTypeAndMarketingListId(Autoresponder::OPERATION_SUBSCRIBE, $marketingListId);
     $this->assertCount(1, $autoresponders);
     $this->assertEquals(2, Autoresponder::getCount());
     $marketingListMembersCount = MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingListId, 0);
     $this->assertEquals(2, $marketingListMembersCount);
     $marketingLists[0]->forgetAll();
     $marketingLists = MarketingList::getAll();
     $marketingLists[0]->delete();
     $marketingLists = MarketingList::getAll();
     $this->assertCount(1, $marketingLists);
     $autoresponders = Autoresponder::getByOperationTypeAndMarketingListId(Autoresponder::OPERATION_SUBSCRIBE, $marketingListId);
     $this->assertCount(0, $autoresponders);
     $this->assertEquals(1, Autoresponder::getCount());
     $marketingListMembersCount = MarketingListMember::getCountByMarketingListIdAndUnsubscribed($marketingListId, 0);
     $this->assertEquals(0, $marketingListMembersCount);
     $this->assertEquals(2, MarketingListMember::getCount());
 }
Ejemplo n.º 17
0
 public function deleteOldItems($model, $itemsPk)
 {
     $criteria = new CDbCriteria();
     $criteria->compare('wlabel_id', Yii::app()->user->getWhiteLabelId());
     Autoresponder::model()->deleteAll($criteria);
 }
Ejemplo n.º 18
0
 public function getMessages($start = 0, $length = -1)
 {
     global $wpdb;
     $start = 0 == intval($start) ? 0 : intval($start);
     $limitClause = Autoresponder::getLimitClauseForRecordSetFetch($start, $length);
     $getMessagesQuery = sprintf('SELECT * FROM %swpr_autoresponder_messages WHERE aid=%d ORDER BY `sequence` %s', $wpdb->prefix, $this->id, $limitClause);
     $messages = $wpdb->get_results($getMessagesQuery);
     $messageObjects = array();
     foreach ($messages as $message) {
         $messageObjects[] = AutoresponderMessage::getMessage(intval($message->id));
     }
     return $messageObjects;
 }
Ejemplo n.º 19
0
function _wpr_import_second_step()
{
    global $importExportSessionName;
    session_name($importExportSessionName);
    session_start();
    if (isset($_SESSION['wpr_import_newsletter'])) {
        $nid = $_SESSION['wpr_import_newsletter'];
        $autoresponders = Autoresponder::getAllAutoresponders();
        _wpr_set("autoresponderList", $autoresponders);
        $postSeries = _wpr_postseries_get_all();
        _wpr_set("postseriesList", $postSeries);
        _wpr_set("_wpr_view", "import.secondstep");
    } else {
        wp_redirect("admin.php?page=_wpr/importexport");
    }
}
 public function testWhetherAutoresponderIsAdded()
 {
     $_POST['nid'] = 1;
     $responderName = 'Test Autoresponder 5432';
     $_POST['autoresponder_name'] = $responderName;
     try {
         AutorespondersController::add_post_handler();
     } catch (Exception $e) {
         //until the day I figure out what to do with that wp_redirect call failing every test...
     }
     $autoresponders = Autoresponder::getAllAutoresponders();
     $found = false;
     foreach ($autoresponders as $responder) {
         $name = $responder->getName();
         if ($name == $responderName) {
             $found = true;
         }
     }
     $this->assertEquals(true, $found);
 }
Ejemplo n.º 21
0
 public function test()
 {
     $id = $this->uri->segment(3);
     $order = ORM::factory('order')->find($id);
     // call autoresponder handler
     $order_address = ORM::factory('orders_address')->find($order->orders_address_id);
     $shippingInfo = $order_address->shipping_first_name . ' ' . $order_address->shipping_last_name . '<br/>' . $order_address->shipping_address1 . '<br/>' . $order_address->shipping_city . ' ' . $order_address->shipping_state . '<br/>' . $order_address->shipping_zip . '<br/>' . $order_address->shipping_country;
     $billingInfo = $order_address->billing_first_name . ' ' . $order_address->billing_last_name . '<br/>' . $order_address->billing_address1 . '<br/>' . $order_address->billing_city . ' ' . $order_address->billing_state . '<br/>' . $order_address->billing_zip . '<br/>' . $order_address->billing_country;
     $dateTime = date('Y-m-d H:i:s');
     $db = new Database();
     $res = $db->query('SELECT p.name, ob.qty FROM products p JOIN orders_baskets ob ON (ob.product_id=p.id) WHERE ob.order_id="' . $order->id . '"');
     $order_basket = new Orders_basket_Model();
     $description = '';
     foreach ($res as $item) {
         $description .= $item->name . ' x ' . $item->qty . '<br/>';
     }
     Autoresponder::sendEmail('order.status.changed', 'erlan@polardesign.com', $order, array('shipping_info' => $shippingInfo, 'billing_info' => $billingInfo, 'date_time' => $dateTime, 'description' => $description, 'total' => format::dollar($order->payment_total)));
 }
Ejemplo n.º 22
0
function _wpr_subscriptionform_form($parameters = array(), $errors = array())
{
    $parameters = (object) $parameters;
    if (!empty($parameters->custom_fields)) {
        $fieldsToSelect = explode(",", $parameters->custom_fields);
    }
    global $wpdb;
    ?>
<div class="wrap">
  <h2>Create Subscription Form</h2>
</div>

<script>
function Autoresponder(id,name)
{
	this.id=id;
	this.name=name;
}
var AutorespondersOfNewsletters=new Array();

<?php 
    $listOfAutorespondersOfNewsletters = _wpr_get_newsletters();
    foreach ($listOfAutorespondersOfNewsletters as $count => $news) {
        ?>
AutorespondersOfNewsletters['<?php 
        echo $news->id;
        ?>
'] = new Array();
	<?php 
        $autoresponders = Autoresponder::getAutorespondersOfNewsletter($news->id);
        foreach ($autoresponders as $autoresponder) {
            $aid = $autoresponder->getId();
            $name = $autoresponder->getName();
            if ($aid == 0 || empty($name)) {
                continue;
            }
            ?>
AutorespondersOfNewsletters['<?php 
            echo $news->id;
            ?>
'].push(new Autoresponder(<?php 
            echo $aid;
            ?>
,"<?php 
            echo $name;
            ?>
"));
		<?php 
        }
    }
    ?>
function autoresponderDropDownBox()
{
	return document.getElementById('autoresponders_list');
}



function updateAutorespondersOption(currentNid)
{
	 if (AutorespondersOfNewsletters[currentNid]!=undefined)
	 {
		 
		 var listOfResponders = AutorespondersOfNewsletters[currentNid];

		 if (listOfResponders.length!=0)
		 {
			 //remove the options in the autoresponder series drop down box.
			 emptyAutoresponderFields();
			 
			 var countOfOptions=0;
			 for (var newopt in listOfResponders)
			 {
				 var theOpt = document.createElement("option");
				 theOpt.setAttribute("value","autoresponder_"+listOfResponders[newopt].id);
				 theOpt.innerHTML = listOfResponders[newopt].name;
				 autoresponderDropDownBox().appendChild(theOpt);
			 }
		 }
		 else
		 {
			 emptyAutoresponderFields();			 		 
		 }
		 
	 }
	 else
	 {
  		 emptyAutoresponderFields();
		 return false;
	 }
}


function _wpr_validate_subform_form_fields()
{
	var titleField =document.getElementById('formnamefield');	
	if (titleField.value.length==0)
	{
		alert("A name is required for this form. Please enter a name.");
		titleField.focus();
		return false;
	}
	
	
	var newsletterField = document.getElementById('newsletterlist');
	if (newsletterField.value=="")
	{
		alert("You must select a newsletter to which this subscription form will add subscribers.");
		newsletterField.focus();
		return false;
	}
	
	var confirmS = document.getElementById('confirms');
	if (jQuery.trim(confirmS.value).length==0)
	{
		alert("You must enter a subject for the confirm subscription e-mail.");
		confirmS.value='';
		confirmS.focus();
		return false;
	}
	
	
	var confirmB = document.getElementById('confirmb');
	if (jQuery.trim(confirmB.value).length==0)
	{
		alert("You must enter a body for the confirm subscription e-mail.");
		confirmB.value='';
		confirmB.focus();
		return false;
	}
	
	var confirmedS = document.getElementById('confirmeds');
	if (jQuery.trim(confirmedS.value).length==0)
	{
		alert("You must enter a subject for the confirmed subscription e-mail.");
		confirmedS.value='';
		confirmedS.focus();
		return false;
	}
	
	var confirmedB = document.getElementById('confirmedb');
	if (jQuery.trim(confirmedB.value).length==0)
	{
		alert("You must enter a body for the confirmed subscription e-mail.");
		confirmedB.value='';
		confirmedB.focus();
		return false;
	}
	
	var returnurlf = document.getElementById('returnurlfield');
	returnurl = returnurlf.value;
	if (jQuery.trim(returnurl).length !=0 && !checkURL(returnurl))
	{
		alert("The value in the return URL field should be a HTTP url. Please correct it or leave the field empty.");
		returnurlf.value='';
		returnurlf.focus();
		return false;	
	}
	
	return true;
	
	
	
	
}


function checkURL(value) 
{
  var urlregex = new RegExp(
        "^(http:\/\/www.|https:\/\/www.|ftp:\/\/www.|www.|http:\/\/){1}([0-9A-Za-z]+\.)");
  if(urlregex.test(value))
  {
    return(true);
  }
  return(false);
}


function emptyAutoresponderFields()
{
        jQuery("#autoresponders_list").children().each( function () 
													{
				jQuery(this).remove();										
														
		});
}

function Field(id,name,type,label,choices)

{

	this.name = name;
	this.id = id;
	this.type = type;
	this.label = label;
	this.choices = choices;

}




var Fields = new Array();

<?php 
    $query = "SELECT * FROM " . $wpdb->prefix . "wpr_custom_fields";
    $customfields = $wpdb->get_results($query);
    $count = 0;
    $newsletterlist = array();
    foreach ($customfields as $field) {
        $newsletterlist[] = $field->nid;
    }
    if (count($newsletterlist)) {
        $newsletterlist = array_unique($newsletterlist);
    }
    ?>
var NewsletterFields = Array();
	<?php 
    foreach ($newsletterlist as $newsletter) {
        ?>
NewsletterFields['<?php 
        echo $newsletter;
        ?>
'] = new Array();
	<?php 
    }
    foreach ($customfields as $field) {
        ?>
		
NewsletterFields['<?php 
        echo $field->nid;
        ?>
'].push(new Field('<?php 
        echo $field->id;
        ?>
','<?php 
        echo addslashes($field->name);
        ?>
','<?php 
        echo addslashes($field->type);
        ?>
','<?php 
        echo addslashes($field->label);
        ?>
','<?php 
        echo addslashes($field->enum);
        ?>
'));
<?php 
    }
    ?>
var customFieldList = new Array();
function showFields(elements)
{
	var fieldsCode;
	if (elements && elements.length > 0)
		document.getElementById('customfields').innerHTML = '';			
	else
		return;
	for (element in elements)
	{
		field = elements[element];
		var element = document.createElement("div");
		customFieldList.push(element);
		element.setAttribute("style","border: 1px solid #ccc; padding: 10px;");



		var formelement;

		    var check = document.createElement("input");

			check.setAttribute("type","checkbox");

			check.setAttribute("name","custom_fields[]");

			check.setAttribute("value",field.id);

			check.setAttribute("id","custom_"+field.id);

			element.appendChild(check);

			element.innerHTML += " "+field.name+"<br />";

			preview = document.createElement("div");

			preview.innerHTML += field.label +":";		

			preview.setAttribute("style","background-color: #ddd; border: 1px solid #eee; padding: 10px;");

			if (field.type == "text")

			{

				element.innerHTML += "Type: One Line Text <br /><strong>Preview: <br />";

				formelement = document.createElement("input");

				formelement.setAttribute("type","text");

			}

			else

			{

				formelement = document.createElement("select");

				

				var choices = field.choices.split(",");

				element.innerHTML += "Type: Multiple Choice<br /><strong>Preview: <br />";

				for (option in choices)

				{

					optionElement = document.createElement("option");

					optionElement.text = choices[option];

					formelement.add(optionElement,null);

				}

			}

			preview.appendChild(formelement);

			element.appendChild(preview);			

			element.innerHTML += "<br>";



		document.getElementById('customfields').appendChild(element);			

	}



}

var autoresponderToBeSelected = '<?php 
    echo @$parameters->followup_type == "postseries" ? "postseries_" : "autoresponder_";
    echo @$parameters->followup_id;
    ?>
';


function setValueOfAutoresponderField()
{
	document.getElementById('followup_field').value=autoresponderToBeSelected;
}
function load(id)
{
	document.getElementById('customfields').innerHTML="<div align=\"center\">--None--</div>";
	showFields(NewsletterFields[id]);
}

var toSelect = new Array(); //custom field ids to select.

<?php 
    if (isset($fieldsToSelect) && count($fieldsToSelect) > 0) {
        ?>
	<?php 
        foreach ($fieldsToSelect as $num => $field) {
            ?>

toSelect[<?php 
            echo $num;
            ?>
] = <?php 
            echo $field;
            ?>
;



<?php 
        }
    }
    function loadFollowUpAutoresponderList()
    {
    }
    ?>
jQuery(document).ready(function() {

    

	var selectedNewsletter = document.getElementById('newsletterlist').options[document.getElementById('newsletterlist').selectedIndex].value;

	showFields(NewsletterFields[selectedNewsletter]);
	updateAutorespondersOption(selectedNewsletter);
	setValueOfAutoresponderField();
	
	//if this form is being used to edit, then select the fields that were saved..
	for (var i in toSelect)
	{
		document.getElementById('custom_'+toSelect[i]).checked=true;
	}

});

</script>
<?php 
    if (count($errors) > 0) {
        ?>
<div class="updated fade">
  <ul>
    <?php 
        foreach ($errors as $error) {
            echo '<li>' . $error . '</li>';
        }
        ?>
  </ul>
</div>
<?php 
    }
    ?>
<div style="display:none">
  <?php 
    $query = sprintf("SELECT id from %swpr_newsletters", $wpdb->prefix);
    $newsletters = $wpdb->get_results($query);
    foreach ($newsletters as $newsletter) {
        $nid = $newsletter->id;
        ?>
  <div id="fields-<?php 
        echo $nid;
        ?>
">
    <?php 
        $query = sprintf("SELECT * FROM %swpr_custom_fields where nid = {$nid}", $wpdb->prefix);
        $customFields = $wpdb->get_results($query);
        foreach ($customFields as $field) {
            ?>
    <div class="field"> Name Of Field: <?php 
            echo $field->name;
            ?>
<br />
      Field Label: <?php 
            echo $field->label;
            ?>
<br />
      <?php 
            switch ($field->type) {
                case 'text':
                    ?>
      Type: One Line Text
      
      Preview:
      <input type="text" size="30" />
      <?php 
                    break;
                case 'enum':
                    $choices = $field->enum;
                    $choices = explode(",", $choices);
                    ?>
      Type: Multiple Choice<br />
      Preview:
      <select>
        <?php 
                    foreach ($choices as $choice) {
                        ?>
        <option><?php 
                        echo $choice;
                        ?>
</option>
        <?php 
                    }
                    ?>
      </select>
      <?php 
                    break;
                case 'hidden':
                    ?>
      Type: Hidden<br />
      Preview: Hidden fields aren't visible on the page.
      <?php 
                    break;
            }
            ?>
    </div>
    <?php 
        }
        ?>
  </div>
  <?php 
    }
    ?>
</div>
<form action="<?php 
    print $_SERVER['REQUEST_URI'];
    ?>
" method="post">
  <table width="700">
    <tr>
      <td><strong>Name:</strong>
        <p><small>This form's settings will be saved. This name will be used to identify the settings.</small></p></td>
      <td><input type="text" id="formnamefield" name="name" size="60" value="<?php 
    echo isset($parameters->name) ? $parameters->name : '';
    ?>
" /></td>
    </tr>
    <tr>
      <td><strong>Newsletter:</strong>
        <p><small>Select the newsletter to which subscribers will be subscribed when filling this form.</small></p></td>
      <td><select name="newsletter" id="newsletterlist" onchange="load(this.options[this.selectedIndex].value);updateAutorespondersOption(this.options[this.selectedIndex].value);">
          <?php 
    $query = "SELECT * FROM " . $wpdb->prefix . "wpr_newsletters";
    $newsletters = $wpdb->get_results($query);
    if (count($newsletters) > 0) {
        ?>
          <option></option>
          <?php 
        foreach ($newsletters as $newsletter) {
            ?>
          <option value="<?php 
            echo $newsletter->id;
            ?>
" <?php 
            if (isset($parameters->nid) && $parameters->nid == $newsletter->id) {
                echo 'selected="selected"';
            }
            ?>
><?php 
            echo $newsletter->name;
            ?>
</option>
          <?php 
        }
    }
    ?>
        </select>
    </tr>
    <tr>
      <td width="300"><strong>Return URL:</strong>
        <p><small> The subscriber is sent to this url after entering their name and email address in the subscription form. </small></p></td>
      <td><input type="text" id="returnurlfield" name="return_url" size="60" value="<?php 
    echo !empty($parameters->return_url) ? $parameters->return_url : '';
    ?>
" /></td>
    </tr>
    <tr>
      <td><strong>Blog Subscription</strong>:
        <p> <small> Specify what kind of blog subscription will those who use this form will have:</small></p></td>
      <td>
      <select name="blogsubscription">
          <option value="none" <?php 
    if (!empty($parameters->blogsubscription_type) && $parameters->blogsubscription_type == "none") {
        echo 'selected="selected"';
    }
    ?>
>None</option>
          <option value="all" <?php 
    if (!empty($parameters->blogsubscription_type) && $parameters->blogsubscription_type == "all") {
        echo 'selected="selected"';
    }
    ?>
>Subscribe to all new posts on
          <?php 
    bloginfo("name");
    ?>
          </option>
          <optgroup label="Particular Blog Category:">
          <?php 
    $args = array('type' => 'post', 'child_of' => 0, 'orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false, 'hierarchical' => 0);
    $categories = get_categories($args);
    foreach ($categories as $category) {
        ?>
          <option value="category_<?php 
        echo $category->term_id;
        ?>
" <?php 
        if (!empty($parameters->blogsubscription_type) && $parameters->blogsubscription_type == "cat" && $parameters->blogsubscription_id == $category->term_id) {
            echo 'selected="selected"';
        }
        ?>
><?php 
        echo $category->name;
        ?>
</option>
          <?php 
    }
    ?>
          </optgroup>
        </select></td>
    </tr>
    <tr>
      <td><strong>Follow Up Subscription:</strong>
        <p> <small>Select what content should follow-up a successful subscription.</small></p></td>
      <?php 
    //construction of options for the followup subscriptions field.
    $types['Autoresponders'] = array();
    $types['Selected'] = null;
    //repeat the same with post series
    $getPostSeriesList = sprintf("SELECT * FROM %swpr_blog_series", $wpdb->prefix);
    $listOfPostSeries = $wpdb->get_results($getPostSeriesList);
    $types['Post Series'] = array();
    foreach ($listOfPostSeries as $post_series) {
        $item = array("name" => $post_series->name, "id" => "postseries_" . $post_series->id);
        $types['Post Series'][] = $item;
        //TODO: remove this code entirely once we can get to the point where we are phasing out post series.
        if (@($parameters->followup_type = "postseries" && @$parameters->followup_id == $post_series->id)) {
            $indexOfThisItem = count($types['Post Series']) - 1;
            $types['Post Series'][$indexOfThisItem]['selected'] = true;
            $types['Selected'] =& $types['Post Series'][$indexOfThisItem];
        }
    }
    $types = apply_filters("_wpr_subscription_form_followup_options", $types);
    $whetherInvalidFollowupSeries = false;
    if (!empty($parameters->followup_id) && $parameters->followup_id != 0 && $types['Selected'] == null) {
        $whetherInvalidFollowupSeries = true;
    }
    ?>
      <td><select name="followup" id="followup_field">
      <?php 
    //if the selected option is a null then set the none option as the selected item
    ?>
      <option value="0" <?php 
    if ($types['Selected'] == null) {
        ?>
 selected="selected" <?php 
    }
    ?>
>None</option>
      <optgroup id="autoresponders_list" label="Autoresponders"></optgroup>
      <?php 
    foreach ($types as $group => $options) {
        if ($group == "Selected" || $group == "Autoresponders") {
            continue;
        }
        ?>
	      <optgroup label="<?php 
        echo $group;
        ?>
">
	      <?php 
        if (count($options)) {
            foreach ($options as $option) {
                ?>
<option <?php 
                if ($types['Selected'] == $option) {
                    ?>
selected="selected" <?php 
                }
                ?>
 value="<?php 
                echo $option['id'];
                ?>
"><?php 
                echo $option['name'];
                ?>
</option>
		      <?php 
            }
        } else {
            ?>
		<option disabled="disabled">None defined</option><?php 
        }
        ?>
	      </optgroup>
	      <?php 
    }
    ?>
        </select></td>
    </tr>
    <tr>
      <td><strong>Submit Button Text:</strong>
      <p>
      <small>The label that will be used for the subscription form submit button</small></p>
      </td>
      <td><input type="text" size="60" name="submit_value" value="<?php 
    echo !empty($parameters->submit_button) ? $parameters->submit_button : "Subscribe";
    ?>
" ></td>
    </tr>
	<?php 
    if (empty($parameters->id)) {
        do_action("_wpr_subscriptionform_form_field", 0);
    } else {
        do_action("_wpr_subscriptionform_form_field", $parameters->id);
    }
    ?>
    <tr>
      <td colspan="2"><div class="wrap">
          <h3>More Form Fields</h3>
          <hr size="1" color="black">
          <p>Select the custom fields that should be added to the in the opt-in form.</p>
        </div>
        <div id="customfields"> </div></td>
    </tr>
    <tr>
      <td><h3> Confirmation E-Mail:</h3>
        <table>
          <tr>
            <td>Subject:</td>
            <td><input type="text" id="confirms" name="confirm_subject" size="70" value="<?php 
    if (empty($parameters->confirm_subject)) {
        $confirm_subject = get_option('wpr_confirm_subject');
        echo $confirm_subject;
    } else {
        echo $parameters->confirm_subject;
    }
    ?>
" /></td>
          </tr>
          <tr>
            <td colspan="2"> Message Body:<br />
              <textarea id="confirmb" name="confirm_body" rows="10" cols="100"><?php 
    if (empty($parameters->confirm_body)) {
        $confirm_email = get_option('wpr_confirm_body');
        echo $confirm_email;
    } else {
        echo $parameters->confirm_body;
    }
    ?>
</textarea></td>
          </tr>
        </table>
        <h3>Subscription Confirmed E-Mail:</h3>
        <table>
          <tr>
            <td>Subject:</td>
            <td><input id="confirmeds" type="text" name="confirmed_subject" value="<?php 
    echo !empty($parameters->confirmed_subject) ? $parameters->confirmed_subject : get_option("wpr_confirmed_subject");
    ?>
" size="60" /></td>
          </tr>
          <tr>
            <td colspan="2"> Message Body:<br />
              <textarea id="confirmedb" name="confirmed_body" rows="10" cols="100"><?php 
    echo !empty($parameters->confirmed_body) ? $parameters->confirmed_body : get_option("wpr_confirmed_body");
    ?>
</textarea></td>
          </tr>
        </table></td>
    </tr>
    <tr>
      <td colspan="2">
<?php 
    if (isset($parameters->id)) {
        ?>
  <input type="hidden" name="fid" value="<?php 
        echo $parameters->id;
        ?>
"/>
<?php 
    }
    ?>


          <input class="button" type="submit" onclick="return _wpr_validate_subform_form_fields()" value="Create Form And Get Code" />
        &nbsp;<a class="button" href="admin.php?page=wpresponder/subscriptionforms.php">Cancel</a></td>
    </tr>
  </table>
</form>
<?php 
}
Ejemplo n.º 23
0
 public function forgot_password()
 {
     if (User_Model::logged_in()) {
         url::redirect('/customers/my_account');
         return;
     }
     $this->template->content = new View('customers/forgot_password');
     $this->template->content->email = '';
     $this->template->content->errors = '';
     if (request::method() == 'post') {
         $post = new Validation($_POST);
         $post->add_rules('email', 'required');
         $this->template->content->email = $post->email;
         if ($post->validate()) {
             $user = ORM::factory('user')->where('email', $post->email)->find();
             if ($user->id != 0) {
                 $user->password_recovery_hash = md5((string) $user);
                 $user->save();
                 $this->template->content->email_sent = TRUE;
                 $url = 'http://' . $_SERVER['SERVER_NAME'] . '/customers/new_password?hash=' . $user->password_recovery_hash;
                 Autoresponder::sendEmail('user.forgot_password', $user->email, $user, array('here_link' => '<a href="' . $url . '">here</a>', 'url' => $url));
             } else {
                 $this->template->content->errors = 'The email doesn\'t exists in our database.';
             }
         } else {
             $this->template->content->errors = 'Email is required.';
         }
     }
     $this->template->metaDescription = $this->description;
     $this->template->metaKeywords = $this->keywords;
     $this->template->metaTitle = $this->title;
     $this->template->title = $this->title;
 }
Ejemplo n.º 24
0
 public function paypal_ok()
 {
     $trans_id = $this->input->get('token');
     // In Kohana, all views are loaded and treated as objects.
     $this->template->content = new View('paypal_status');
     $postvars = $_POST;
     $db = new Database();
     $result = $db->query('SELECT * FROM orders WHERE trans_id = \'' . $trans_id . '\'');
     $order = $result[0];
     $this->template->content->_order = ORM::factory('order', $order->id);
     //CREATE PAYMENT
     $result = $db->query('INSERT INTO payments (transaction_number, statusID, transaction_date) VALUES (\'' . $trans_id . '\', 3, ' . time() . ')');
     $paymentid = mysql_insert_id();
     //CREATE Order ID Entry
     $_res = $db->query('SELECT id FROM order_ids WHERE order_id="' . $order->id . '"');
     if (!$_res[0] || !$_res[0]->id) {
         //CREATE Order ID Entry
         $_res = $db->query('INSERT INTO order_ids (order_id) VALUES (' . $order->id . ')');
         $new_order_id = mysql_insert_id();
     } else {
         $new_order_id = $_res[0]->id;
     }
     //UPDATE THE ORDER TABLE
     $result = $db->query('UPDATE orders SET paymentID = ' . $paymentid . ', payment_method = "PayPal", statusID = 2, order_total= ' . $order->subtotal . ', shipping_total = ' . $order->shipping_total . ', order_date = \'' . date("Y-m-d H:i:s", time()) . '\', date_modified = ' . time() . ' WHERE id = ' . $order->id . '');
     $result = $db->query('SELECT orders.*, users.email, user_billing_infos.firstname as billfname, user_billing_infos.lastname as billlname, user_billing_infos.address1 as billaddress, user_billing_infos.city as billcity, user_billing_infos.state as billstate, user_billing_infos.zip as billzip, user_billing_infos.country as billcountry, user_billing_infos.phone1 as billphone, user_shipping_infos.firstname as shipfname, user_shipping_infos.lastname as shiplname, user_shipping_infos.address1 as shipaddress, user_shipping_infos.city as shipcity, user_shipping_infos.state as shipstate, user_shipping_infos.zip as shipzip, user_shipping_infos.country as shipcountry FROM orders LEFT JOIN user_billing_infos ON orders.billingID = user_billing_infos.id LEFT JOIN user_shipping_infos ON orders.shippingID = user_shipping_infos.id LEFT JOIN users ON orders.user_id = users.id WHERE orders.id = ' . $order->id . '');
     $order = $result[0];
     $shippingInfo = $order->shipfname . ' ' . $order->shiplname . '<br/>' . $order->shipaddress . '<br/>' . $order->shipcity . ' ' . $order->shipstate . '<br/>' . $order->shipzip . '<br/>' . $order->shipcountry;
     $billingInfo = $order->billfname . ' ' . $order->billlname . '<br/>' . $order->billaddress . '<br/>' . $order->billcity . ' ' . $order->billstate . '<br/>' . $order->billzip . '<br/>' . $order->billcountry;
     $dateTime = date('Y-m-d H:i:s');
     $res = $db->query('SELECT p.name, ob.qty, ob.subtotal, ob.id as ob_id FROM products p JOIN orders_baskets ob ON (ob.product_id=p.id) WHERE ob.order_id="' . $order->id . '"');
     $description = '';
     $subtotal = 0;
     foreach ($res as $item) {
         $basket = ORM::factory('orders_basket', $item->ob_id);
         $product_name = $item->name;
         if ($basket->packaging_id != 0) {
             $product_name .= ' - ' . $basket->packaging->name;
         }
         $description .= '' . $item->qty . ' x ' . $product_name . ' = ' . money_format('%.2n', $item->subtotal) . '<br/>';
         $subtotal += $item->subtotal;
     }
     if (!empty($order->comment)) {
         $description .= 'Comment:' . $order->comment . '<br/>';
     }
     $total = 'Subtotal: ' . money_format('%.2n', $subtotal) . '<br/>Shipping:' . money_format('%.2n', $order->shipping_total);
     $total .= '<br/>Total:' . money_format('%.2n', $order->order_total);
     $emailAddr = $order->email;
     $res = $db->query('SELECT id FROM order_ids WHERE order_id = ' . $order->id . '');
     $orderid = $res[0]->id;
     $order->id = $orderid;
     $new_order_id = 'MCH' . $orderid;
     $to = array($emailAddr, 'info@mychocolatecoins.com', 'freddyfalck@hotmail.com', 'info@deligance.com', 'contact@polardesign.com');
     foreach ($to as $address) {
         Autoresponder::sendEmail('order.status.changed', $address, $order, array('shipping_info' => $shippingInfo, 'billing_info' => $billingInfo, 'date_time' => $dateTime, 'description' => $description, 'total' => $total, 'order_id' => $new_order_id));
     }
     $this->template->content->status = 'Your paypal paymeny was successful!';
     $this->template->content->trans_id = $trans_id;
     $this->template->content->order_id = $order->id;
     $user_id = FALSE;
     if (User_Model::logged_in()) {
         $user_id = User_Model::logged_user()->id;
     }
     Session::instance()->regenerate();
     if ($user_id) {
         ORM::factory('user')->find($user_id)->forceLogin();
     }
     // Meta Description and Meta Keywords for individual pages are, at this point, hard coded.
     $this->template->metaDescription = $this->description;
     $this->template->metaKeywords = $this->keywords;
     $this->template->metaTitle = $this->title;
     // You can assign anything variable to a view by using standard OOP
     // methods. In my welcome view, the $title variable will be assigned
     // the value I give it here.
     $this->template->title = $this->title;
 }
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(7, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $contact = ContactTestHelper::createContactByNameForOwner('autoresponderContact', Yii::app()->user->userModel);
     $saved = AutoresponderItem::addNewItem(0, $processDateTime, $contact, $autoresponders[0]);
     $this->assertTrue($saved);
     $autoresponderItems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertNotEmpty($autoresponderItems);
     $this->assertCount(1, $autoresponderItems);
     $fileNames = array('testImage.png', 'testZip.zip', 'testPDF.pdf');
     $files = array();
     foreach ($fileNames as $index => $fileName) {
         $file = ZurmoTestHelper::createFileModel($fileName);
         $files[$index]['name'] = $fileName;
         $files[$index]['type'] = $file->type;
         $files[$index]['size'] = $file->size;
         $files[$index]['contents'] = $file->fileContent->content;
         $autoresponders[0]->files->add($file);
     }
     $this->assertTrue($autoresponders[0]->save());
     $autoresponders = Autoresponder::getAll();
     $this->assertNotEmpty($autoresponders[0]->files);
     $this->assertCount(count($files), $autoresponders[0]->files);
     $this->assertEquals(count($files), FileModel::getCount());
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(6, count($autoresponders));
     $autoresponderitems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertEquals(0, count($autoresponderitems));
     $this->assertEquals(0, FileModel::getCount());
 }
Ejemplo n.º 26
0
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(5, $autoresponders);
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(4, count($autoresponders));
 }
Ejemplo n.º 27
0
 /**
  * @depends testCreateAndGetAutoresponderById
  */
 public function testDeleteAutoresponder()
 {
     $autoresponders = Autoresponder::getAll();
     $this->assertCount(7, $autoresponders);
     $autoresponderId = $autoresponders[0]->id;
     $processDateTime = DateTimeUtil::convertTimestampToDbFormatDateTime(time());
     $contact = ContactTestHelper::createContactByNameForOwner('autoresponderContact', Yii::app()->user->userModel);
     $saved = AutoresponderItem::addNewItem(0, $processDateTime, $contact, $autoresponders[0]);
     $this->assertTrue($saved);
     $autoresponderItems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     //print_r($autoresponderItems[0]->id);
     $this->assertNotEmpty($autoresponderItems);
     $this->assertCount(1, $autoresponderItems);
     $autoresponderItemActivity = new AutoresponderItemActivity();
     $autoresponderItemActivity->type = AutoresponderItemActivity::TYPE_OPEN;
     $autoresponderItemActivity->quantity = 10;
     $autoresponderItemActivity->latestSourceIP = '10.11.12.13';
     $autoresponderItemActivity->autoresponderItem = $autoresponderItems[0];
     $this->assertTrue($autoresponderItemActivity->save());
     //print_r($autoresponderItemActivity->id);
     $autoresponderItemActivities = AutoresponderItemActivity::getAll();
     $this->assertCount(1, $autoresponderItemActivities);
     $autoresponders[0]->delete();
     $autoresponders = Autoresponder::getAll();
     $this->assertEquals(6, count($autoresponders));
     $autoresponderitems = AutoresponderItem::getByProcessedAndAutoresponderId(0, $autoresponderId);
     $this->assertEquals(0, count($autoresponderitems));
     $autoresponderItemActivities = AutoresponderItemActivity::getAll();
     $this->assertCount(0, $autoresponderItemActivities);
 }
 protected function getDropDownArray()
 {
     return Autoresponder::getOperationTypeDropDownArray();
 }
Ejemplo n.º 29
0
 public function actionDelete($id, $redirectUrl = null)
 {
     $autoresponder = Autoresponder::getById(intval($id));
     ControllerSecurityUtil::resolveAccessCanCurrentUserReadModel($autoresponder->marketingList);
     $autoresponder->delete();
     if ($redirectUrl) {
         $this->redirect($redirectUrl);
     }
 }