model() публичный статический Метод

Returns the static model of the specified AR class.
public static model ( $className = __CLASS__ ) : SiteSubspecialtyDrug
Результат SiteSubspecialtyDrug the static model class
 public function actionList()
 {
     $admin = new AdminListAutocomplete(SiteSubspecialtyDrug::model(), $this);
     $admin->setListFields(array('id', 'drugs.name', 'drugs.dose_unit'));
     $admin->setCustomDeleteURL('/OphDrPrescription/admin/commondrugsdelete');
     $admin->setCustomSaveURL('/OphDrPrescription/admin/commondrugsadd');
     $admin->setModelDisplayName('Common Drugs List');
     $admin->setFilterFields(array(array('label' => 'Site', 'dropDownName' => 'site_id', 'defaultValue' => Yii::app()->session['selected_site_id'], 'listModel' => Site::model(), 'listIdField' => 'id', 'listDisplayField' => 'short_name'), array('label' => 'Subspecialty', 'dropDownName' => 'subspecialty_id', 'defaultValue' => Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])->serviceSubspecialtyAssignment->subspecialty_id, 'listModel' => Subspecialty::model(), 'listIdField' => 'id', 'listDisplayField' => 'name')));
     // we set default search options
     if ($this->request->getParam('search') == '') {
         $admin->getSearch()->initSearch(array('filterid' => array('site_id' => Yii::app()->session['selected_site_id'], 'subspecialty_id' => Firm::model()->findByPk(Yii::app()->session['selected_firm_id'])->serviceSubspecialtyAssignment->subspecialty_id)));
     }
     $admin->setAutocompleteField(array('fieldName' => 'drug_id', 'jsonURL' => '/OphDrPrescription/default/DrugList', 'placeholder' => 'search for drugs'));
     //$admin->searchAll();
     $admin->listModel();
 }
Пример #2
0
 /**
  * @description Deletes a drug from the site_subspecialty_drug table - AJAX call only
  *
  * @param $itemId
  *
  * @return html
  */
 public function actionCommonDrugsDelete($itemId)
 {
     /*
      * We make sure to not allow deleting directly with the URL, user must come from the commondrugs list page
      */
     if (!Yii::app()->request->isAjaxRequest) {
         $this->render('errorpage', array('errorMessage' => 'notajaxcall'));
     } else {
         if ($site_subspec_drug = SiteSubspecialtyDrug::model()->findByPk($itemId)) {
             $site_subspec_drug->delete();
             echo 'success';
         } else {
             $this->render('errorpage', array('errormessage' => 'recordmissing'));
         }
     }
 }
 /**
  * Get the drug list for a specified site and subspecialty.
  *
  * @param $site_id
  * @param $subspecialty_id
  *
  * @return SiteSubspecialtyDrug[]
  */
 public function commonDrugsBySiteAndSpec($site_id, $subspecialty_id)
 {
     $params = array(':subSpecialtyId' => $subspecialty_id, ':siteId' => $site_id);
     return SiteSubspecialtyDrug::model()->with('drugs')->findAll(array('condition' => 't.subspecialty_id = :subSpecialtyId AND t.site_id = :siteId', 'order' => 'name', 'params' => $params));
 }