/** * @description Adds new drug into the site_subspecialty_drug table - AJAX call only * * @return string */ public function actionCommonDrugsAdd() { $drugId = $this->request->getParam('drug_id'); $siteId = $this->request->getParam('site_id'); $subspecialtyId = $this->request->getParam('subspecialty_id'); if (!Yii::app()->request->isAjaxRequest) { $this->render('errorpage', array('errormessage' => 'notajaxcall')); } else { if (!is_numeric($drugId) || !is_numeric($siteId) || !is_numeric($subspecialtyId)) { echo 'error'; } else { $newSSD = new SiteSubspecialtyDrug(); $newSSD->site_id = $siteId; $newSSD->subspecialty_id = $subspecialtyId; $newSSD->drug_id = $drugId; if ($newSSD->save()) { echo 'success'; } else { echo 'error'; } } } }