public function actionCreateDelivery() { $this->topButtons = false; $model = new DeliveryForm(); $delivery = Delivery::model()->findAll(); $mails = array(); $users = User::model()->subscribe()->findAll(); $render = 'create'; if (isset($_POST['DeliveryForm'])) { $model->attributes = $_POST['DeliveryForm']; //$this->performAjaxValidation($model); if ($model->validate()) { if ($model->from == 'all') { foreach ($users as $user) { $mails[] = $user->email; } //if (isset($delivery)) { foreach ($delivery as $subscriber) { $mails[] = $subscriber->email; } //} else { // $mails_subscriber = array(); //} // $mails = array_merge($mails_users, $mails_subscriber); } elseif ($model->from == 'users') { foreach ($users as $user) { $mails[] = $user->email; } } else { foreach ($delivery as $subscriber) { $mails[] = $subscriber->email; } } if (Yii::app()->request->isAjaxRequest) { $render = 'send'; } else { $render = 'create'; } } else { if (Yii::app()->request->isAjaxRequest) { $render = 'form'; } else { $render = 'create'; } //Stops the request from being sent. //throw new CHttpException(404, 'Model has not been saved'); } } $this->breadcrumbs = array(Yii::t('deliveryModule.default', 'MODULE_NAME') => array('index'), Yii::t('deliveryModule.default', 'CREATE_DELIVERY')); $this->render($render, array('users' => $users, 'deliveryRecord' => $deliveryRecord, 'delivery' => $delivery, 'model' => $model, 'mails' => $mails)); }
public function deleteForm($id) { $form = DeliveryForm::where('id', '=', $id); $form->delete(); //return Redirect::to('/profile/forms'); return Redirect::back()->withErrors(['msg' => ['Форма удалена!']]); }
public function unreviewed() { $forms = DeliveryForm::where('admin_confirmed', '=', '0')->get(); $order = $this->order->where('viewed', '=', '0')->get(); return '{"orders":"' . count($order) . '", "forms":"' . count($forms) . '"}'; }