|
|
@@ -41,6 +41,7 @@ namespace common\forms; |
|
|
|
use common\logic\Product\Product\Model\Product; |
|
|
|
use common\logic\Subscription\ProductSubscription\Model\ProductSubscription; |
|
|
|
use common\logic\Subscription\Subscription\Model\Subscription; |
|
|
|
use common\logic\Subscription\Subscription\Wrapper\SubscriptionManager; |
|
|
|
use Yii; |
|
|
|
use yii\base\Model; |
|
|
|
|
|
|
@@ -115,11 +116,13 @@ class SubscriptionForm extends Model |
|
|
|
*/ |
|
|
|
public function save() |
|
|
|
{ |
|
|
|
$subscriptionManager = SubscriptionManager::getInstance(); |
|
|
|
|
|
|
|
if ($this->id) { |
|
|
|
$subscription = Subscription::searchOne(['id' => $this->id]) ; |
|
|
|
} |
|
|
|
else { |
|
|
|
$subscription = new Subscription ; |
|
|
|
$subscription = $subscriptionManager->instanciateSubscription() ; |
|
|
|
} |
|
|
|
|
|
|
|
if ($subscription) { |
|
|
@@ -147,7 +150,10 @@ class SubscriptionForm extends Model |
|
|
|
$subscription->saturday = $this->saturday; |
|
|
|
$subscription->sunday = $this->sunday; |
|
|
|
$subscription->week_frequency = $this->week_frequency; |
|
|
|
$subscription->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED; |
|
|
|
$subscription->auto_payment = $this->auto_payment; |
|
|
|
if(is_null($subscription->auto_payment)) { |
|
|
|
$subscription->auto_payment = Subscription::AUTO_PAYMENT_DEDUCTED; |
|
|
|
} |
|
|
|
$subscription->comment = $this->comment; |
|
|
|
|
|
|
|
$subscription->save(); |