/** * Delete requests */ public function actionDelete() { $model = ProductNotifications::model()->findByPk(Yii::app()->request->getParam('id')); if ($model) { ProductNotifications::model()->deleteAllByAttributes(array('product_id' => $model->product_id)); } }
public function afterUninstall() { Yii::app()->settings->clear($this->id); //Yii::app()->unintallComponent('cart'); $db = Yii::app()->db; $tablesArray = array(Order::model()->tableName(), OrderHistory::model()->tableName(), OrderProduct::model()->tableName(), OrderStatus::model()->tableName(), OrderProductHistroy::model()->tableName(), ShopPaymentMethod::model()->tableName(), ShopPaymentMethodTranslate::model()->tableName(), ShopDeliveryMethod::model()->tableName(), ShopDeliveryMethodTranslate::model()->tableName(), ShopDeliveryPayment::model()->tableName(), ProductNotifications::model()->tableName()); foreach ($tablesArray as $table) { $db->createCommand()->dropTable($table); } return parent::afterInstall(); }
public function actionGetCounters() { Yii::import('mod.cart.models.Order'); Yii::import('mod.cart.models.ProductNotifications'); Yii::import('mod.support.models.TicketMessage'); $json = array(); if (Yii::app()->hasModule('comments')) { $json['comments'] = (int) Comments::model()->waiting()->count(); } $json['orders'] = (int) Order::model()->new()->count(); $json['notify'] = (int) ProductNotifications::model()->count(); $json['support'] = (int) TicketMessage::model()->count(); echo CJSON::encode($json); }
public function actionSend() { $record = ProductNotifications::model()->findAllByAttributes(array('product_id' => $_GET['product_id'])); $tplMail = TplMail::model()->findByAttributes(array('formkey' => 'PRODUCT_NOTIFY')); if (!$tplMail) { throw new CHttpException(404, 'Не могу найти шаблон письма.'); } foreach ($record as $row) { if (!$row->product) { continue; } $tplMail->setEmails($row->email); $tplMail->sendEmail($this->replaceArray($row->product), $this->replaceArray($row->product)); $row->delete(); } Yii::app()->user->setFlash('success', Yii::t('CartModule.admin', 'Сообщения успешно отправлены.')); $this->redirect('index'); }
/** * Check if email exists in list for current product */ public function hasEmail() { return ProductNotifications::model()->countByAttributes(array('email' => $this->email, 'product_id' => $this->product_id)) > 0; }