issue with offline sending through gearmanClient
authorMark <mark@nirph.com>
Tue, 28 Feb 2017 12:27:53 +0000 (14:27 +0200)
committerMark <mark@nirph.com>
Tue, 28 Feb 2017 12:27:53 +0000 (14:27 +0200)
module/Auction/src/Auction/Service/Auction.php
module/Utility/src/Utility/Comms/Notification.php

index 22da77e..b2aca46 100644 (file)
@@ -560,9 +560,15 @@ class Auction extends \Auction\DataBin\Auction
                        $this->workflowNode->setJob($item);
                        try
                        {
                        $this->workflowNode->setJob($item);
                        try
                        {
+                               \Utility\Debug::errorLog('currentbid',$item->currentBid->amount);
+                               \Utility\Debug::errorLog('reserve',$item->reservePrice);
+
                                if (!is_null($item->currentBid) && $item->currentBid->amount > $item->reservePrice)
                                {
                                        #-> We have a winner.
                                if (!is_null($item->currentBid) && $item->currentBid->amount > $item->reservePrice)
                                {
                                        #-> We have a winner.
+                                       \Utility\Debug::errorLog('Winner',$item->id);
+
+
                                        $item->soldToCompany = $item->currentBid->company;
                                        $item->soldToProfile = $item->currentBid->profile;
                                        $this->workflowNode->changeState('This.Sold');
                                        $item->soldToCompany = $item->currentBid->company;
                                        $item->soldToProfile = $item->currentBid->profile;
                                        $this->workflowNode->changeState('This.Sold');
@@ -570,6 +576,7 @@ class Auction extends \Auction\DataBin\Auction
                                else
                                {
                                        #-> Each and every one a loser.
                                else
                                {
                                        #-> Each and every one a loser.
+                                       \Utility\Debug::errorLog('no winner',$item->id);
                                        $this->workflowNode->changeState('This.Relist');
                                }
                        }
                                        $this->workflowNode->changeState('This.Relist');
                                }
                        }
@@ -591,6 +598,7 @@ class Auction extends \Auction\DataBin\Auction
                {
                        try
                        {
                {
                        try
                        {
+                               \Utility\Debug::errorLog('setting data for mail',$item->id);
 
                                #-> General data prep.
                                $vehicle    = $item->stock->type->model->make->name
 
                                #-> General data prep.
                                $vehicle    = $item->stock->type->model->make->name
@@ -599,8 +607,15 @@ class Auction extends \Auction\DataBin\Auction
                                $currPrefix = \Utility\Definitions\Locale::getCurrencyPrefix() . ' ';
                                $oNotify    = new \Utility\Comms\Notification();
 
                                $currPrefix = \Utility\Definitions\Locale::getCurrencyPrefix() . ' ';
                                $oNotify    = new \Utility\Comms\Notification();
 
+                               \Utility\Debug::errorLog('jobstate',$item->jobState);
+                               \Utility\Debug::errorLog('currentbid',$item->currentBid->amount);
+                               \Utility\Debug::errorLog('reserve',$item->reservePrice);
+
                                if (!is_null($item->currentBid) && $item->currentBid->amount > $item->reservePrice && 'Sold' == $item->jobState)
                                {
                                if (!is_null($item->currentBid) && $item->currentBid->amount > $item->reservePrice && 'Sold' == $item->jobState)
                                {
+                                       \Utility\Debug::errorLog('sending mails',$item->jobState);
+
+
                                        #-> Update record to reflect winner.
                                        $item->soldToCompany = $item->currentBid->company;
                                        $item->soldToProfile = $item->currentBid->profile;
                                        #-> Update record to reflect winner.
                                        $item->soldToCompany = $item->currentBid->company;
                                        $item->soldToProfile = $item->currentBid->profile;
index 1b36c36..93be2c1 100644 (file)
@@ -404,58 +404,67 @@ class Notification
                $disableSms = false
        )
        {
                $disableSms = false
        )
        {
-               if (IS_BROCHURE)
-               {
-                       self::send(
+               //problem with GearmanClient so i'm just using normal send for now
+               self::send(
                                $fromCompanyId, $fromProfileId,
                                $toCompanyId, $toProfileId, $email, $mobile,
                                $subject, $emailTemplate, $smsTemplate,
                                $attachments, $complexAttachments, $disableSms
                        );
                                $fromCompanyId, $fromProfileId,
                                $toCompanyId, $toProfileId, $email, $mobile,
                                $subject, $emailTemplate, $smsTemplate,
                                $attachments, $complexAttachments, $disableSms
                        );
-               }
-               else
-               {
-                       $id = 'n' . microtime(true);
-                       while (\Utility\FileStore::existsJson($id))
-                       {
-                               time_nanosleep(0, 1000);
-                               $id = 'n' . microtime(true);
-                       };
-                       foreach ($attachments as $key => $data)
-                       {
-                               $attachments[$key] = utf8_encode($data);
-                       }
-                       foreach ($complexAttachments as $key => $data)
-                       {
-                               $complexAttachments[$key] = utf8_encode($data);
-                       }
-                       \Utility\FileStore::storeJson(
-                               $id,
-                               array(
-                                       'fromCompanyId'      => $fromCompanyId,
-                                       'fromProfileId'      => $fromProfileId,
-                                       'toCompanyId'        => $toCompanyId,
-                                       'toProfileId'        => $toProfileId,
-                                       'email'              => $email,
-                                       'mobile'             => $mobile,
-                                       'subject'            => $subject,
-                                       'emailTemplate'      => $emailTemplate,
-                                       'smsTemplate'        => $smsTemplate,
-                                       'attachments'        => $attachments,
-                                       'complexAttachments' => $complexAttachments,
-                                       'disableSms'         => $disableSms
-                               )
-                       );
-                       if (false === self::$_gearClient)
-                       {
-                               self::$_gearClient = new \GearmanClient();
-                               self::$_gearClient->addServer();
-                       }
-                       self::$_gearClient->doBackground(
-                               'Notify',
-                               $id
-                       );
-               }
+
+//             if (IS_BROCHURE)
+//             {
+//                     self::send(
+//                             $fromCompanyId, $fromProfileId,
+//                             $toCompanyId, $toProfileId, $email, $mobile,
+//                             $subject, $emailTemplate, $smsTemplate,
+//                             $attachments, $complexAttachments, $disableSms
+//                     );
+//             }
+//             else
+//             {
+//                     $id = 'n' . microtime(true);
+//                     while (\Utility\FileStore::existsJson($id))
+//                     {
+//                             time_nanosleep(0, 1000);
+//                             $id = 'n' . microtime(true);
+//                     };
+//                     foreach ($attachments as $key => $data)
+//                     {
+//                             $attachments[$key] = utf8_encode($data);
+//                     }
+//                     foreach ($complexAttachments as $key => $data)
+//                     {
+//                             $complexAttachments[$key] = utf8_encode($data);
+//                     }
+//                     \Utility\FileStore::storeJson(
+//                             $id,
+//                             array(
+//                                     'fromCompanyId'      => $fromCompanyId,
+//                                     'fromProfileId'      => $fromProfileId,
+//                                     'toCompanyId'        => $toCompanyId,
+//                                     'toProfileId'        => $toProfileId,
+//                                     'email'              => $email,
+//                                     'mobile'             => $mobile,
+//                                     'subject'            => $subject,
+//                                     'emailTemplate'      => $emailTemplate,
+//                                     'smsTemplate'        => $smsTemplate,
+//                                     'attachments'        => $attachments,
+//                                     'complexAttachments' => $complexAttachments,
+//                                     'disableSms'         => $disableSms
+//                             )
+//                     );
+//                     if (false === self::$_gearClient)
+//                     {
+//                             self::$_gearClient = new GearmanClient();
+//                             self::$_gearClient->addServer();
+//                     }
+//                     $job_handle=self::$_gearClient->doBackground(
+//                             'Notify',
+//                             $id
+//                     );
+//
+//             }
        }
 
 
        }