public function __construct($spec = '', $options = '')
 {
     parent::__construct($spec, $options);
     $table = new Expertise();
     $select = $table->select();
     $select->order(Expertise::COL_SPECIES);
     $rowset = $table->fetchAll($select);
     $array = $rowset->toArray();
     $optArray = array();
     foreach ($array as $value) {
         $merged = $value[Expertise::COL_ID] . ',' . $value[Expertise::COL_AREA] . ',' . $value[Expertise::COL_SPECIES] . ',' . $value[Expertise::COL_SUBJECT];
         $optArray = $optArray + array($value[Expertise::COL_ID] => $merged);
     }
     $this->setMultiOptions($optArray);
 }
 public function storeExpertise()
 {
     $expertise = new Expertise();
     $expertise->title = Input::get('title');
     $expertise->notes = Input::get('notes');
     $expertise->save();
     return Redirect::intended('advisor.dashboard');
 }
 public function updateAction()
 {
     $this->form->addElement('hidden', Expertise::COL_ID, array('required' => true));
     $expertiseTable = new Expertise();
     if ($this->getRequest()->isPost()) {
         if ($this->form->isValid($this->getRequest()->getParams())) {
             $data = array(Expertise::COL_AREA => $this->form->getValue(Expertise::COL_AREA), Expertise::COL_SPECIES => $this->form->getValue(Expertise::COL_SPECIES), Expertise::COL_SUBJECT => $this->form->getValue(Expertise::COL_SUBJECT));
             $expertiseTable->update($data, $expertiseTable->getAdapter()->quoteInto(Expertise::COL_ID . '=?', $this->form->getValue(Expertise::COL_ID)));
             $this->redirectTo('list');
         }
     } else {
         $expArray = $expertiseTable->find($this->getRequest()->getParam(Expertise::COL_ID))->toArray();
         $this->form->populate($expArray[0]);
     }
     $this->view->form = $this->form;
     $this->render('index');
 }
Example #4
0
 public function createAction()
 {
     $expId = intval($this->getRequest()->getParam(Expertise::COL_ID));
     $keyId = intval($this->getRequest()->getParam(KeyTable::COL_ID));
     $expTable = new Expertise();
     $expRow = $expTable->find($expId);
     $keyTable = new KeyTable();
     $keyRow = $keyTable->find($keyId);
     if ($keyRow->count() != 0 || $expRow->count() != 0) {
         $keyArray = $keyRow->toArray();
         $expArray = $expRow->toArray();
         // create CE row
         $ceTable = new CalibrationExercise();
         $ceName = $expArray[0][Expertise::COL_SPECIES] . ' / ' . AuthQuery::getUserName();
         //TODO \r in der Datenbank
         $ceDescription = 'Area: ' . $expArray[0][Expertise::COL_AREA] . '\\r' . 'Subject: ' . $expArray[0][Expertise::COL_SUBJECT] . '\\r' . 'KeyName: ' . $keyArray[0][KeyTable::COL_NAME];
         $ceData = array(CalibrationExercise::COL_NAME => $ceName, CalibrationExercise::COL_DESCRIPTION => $ceDescription, CalibrationExercise::COL_KEY_TABLE_ID => $keyArray[0][KeyTable::COL_ID], CalibrationExercise::COL_EXPERTISE_ID => $expArray[0][Expertise::COL_ID], CalibrationExercise::COL_COMPAREABLE => 1, CalibrationExercise::COL_IS_STOPPED => 0, CalibrationExercise::COL_TRAINING => 1);
         $ceId = $ceTable->insert($ceData);
         // create participant row
         $partTable = new Participant();
         $partData = array(Participant::COL_CE_ID => $ceId, Participant::COL_USER_ID => AuthQuery::getUserId(), Participant::COL_NUMBER => 1);
         $partId = $partTable->insert($partData);
         // add all possible shown attributes
         $dbAdapter = $ceTable->getAdapter();
         $selectAttr = $dbAdapter->select();
         $selectAttr->from(AttributeDescriptor::TABLE_NAME);
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'fish');
         $selectAttr->orWhere(AttributeDescriptor::COL_GROUP . '=?', 'image');
         $attrArray = $dbAdapter->fetchAll($selectAttr);
         $ceHasAttrTable = new CeHasAttributeDescriptor();
         foreach ($attrArray as $attr) {
             $attrData = array(CeHasAttributeDescriptor::COL_ATDE_ID => $attr[AttributeDescriptor::COL_ID], CeHasAttributeDescriptor::COL_CAEX_ID => $ceId);
             $ceHasAttrTable->insert($attrData);
         }
         //get images for exp/key
         $refQuery = new Default_ReferenceQuery();
         $images = $refQuery->getImages($expId, $keyId);
         // create imageset
         //			$selectImages = $dbAdapter->select();
         //			$imagesArray = $dbAdapter->fetchAll($selectImages);
         $imageSetTable = new CeHasImage();
         foreach ($images as $image) {
             $data = array(CeHasImage::COL_IMAGE_ID => $image, CeHasImage::COL_CALIBRATION_EXERCISE_ID => $ceId);
             $imageSetTable->insert($data);
         }
         //$this->render('form');
         $Redirect = new Zend_Controller_Action_Helper_Redirector();
         $Redirect->setGotoSimple('index', 'make', 'annotation', array(CalibrationExercise::COL_ID => $ceId));
     } else {
         throw new Zend_Controller_Exception('Error at craeting a new training Calibration Exercise.', 505);
     }
 }
Example #5
0
 public function expertiseNotContainedByAdvisor($advisor_id)
 {
     if ($this->expertiseContainedByAdvisor($advisor_id) == null) {
         $expertiseNotContainedByAdvisor = Expertise::lists('title', 'id');
         return $expertiseNotContainedByAdvisor;
     }
     $expertiseNotContainedByAdvisor = Expertise::whereNotIn('id', $this->expertiseContainedByAdvisor($advisor_id, 1))->where('requested', '!=', true)->orderBy('title')->lists('title', 'id');
     return $expertiseNotContainedByAdvisor;
 }
Example #6
0
 public function actionExpertise()
 {
     $this->layout = '//layouts/blank';
     $model = new Expertise('search');
     $model->unsetAttributes();
     // clear any default values
     if (isset($_GET['Expertise'])) {
         $model->attributes = $_GET['Expertise'];
     }
     $this->render('expertise', array('model' => $model));
 }
 public function actionZhuanye()
 {
     $todo = array();
     $i = 0;
     $filename = './public/zhuanye.txt';
     $result = file($filename);
     $result = array_map('check', $result);
     $keys = array();
     $keys[0] = null;
     $values = array();
     $values[0] = null;
     foreach ($result as $item) {
         $zhuanye = explode('=', $item);
         $keys[] = $zhuanye[0];
         $values[] = $zhuanye[1];
     }
     //		echo array_search('0101', $keys);
     for ($t = 1; $t <= count($keys); $t++) {
         //			$zhuanyedaima = strlen($zhuanye[0]);
         //			$zhuanyedaima = chunk_split($zhuanye[0],2);
         preg_match_all('/(\\d{2})(\\d{2})?(\\d{2})?/i', $keys[$t], $zhuanyedaima);
         $todo[$t] = array('id' => $t, 'daima' => $zhuanyedaima[0][0], 'name' => $values[$t]);
         if (intval($zhuanyedaima[1][0]) && !intval($zhuanyedaima[2][0])) {
             $todo[$t]['pid'] = 0;
             //array_search($zhuanyedaima[1][0], $keys);
         }
         if (intval($zhuanyedaima[2][0]) && !intval($zhuanyedaima[3][0])) {
             $todo[$t]['pid'] = array_search(strval($zhuanyedaima[1][0]), $keys);
             //				echo '2'.$zhuanyedaima[1][0]."\n\r";
         }
         if (intval($zhuanyedaima[2][0]) && intval($zhuanyedaima[3][0])) {
             $todo[$t]['pid'] = array_search($zhuanyedaima[1][0] . $zhuanyedaima[2][0], $keys);
         }
     }
     $todo[1]['pid'] = 0;
     $todo[2]['pid'] = 1;
     array_pop($todo);
     //		UtilHelper::dump($todo);
     foreach ($todo as $item) {
         //			echo "id:".$item['id']."\t pid:".$item['pid']."\t name:".$item['name']."\tdaima:".$item['daima']."<br />";
         $expertise = new Expertise();
         $expertise->id = $item['id'];
         $expertise->pid = $item['pid'];
         $expertise->name = $item['name'];
         if ($expertise->save()) {
             echo 'ok' . $expertise->id;
         } else {
             echo CHtml::errorSummary($expertise);
         }
     }
 }