示例#1
0
 /**
  * Ajax request to submit data
  * @param array $request   the request
  * @return array           ajax format status
  */
 public function submitFormData($request)
 {
     $errors = array();
     $data = R3EcoGisHelper::getBuildingData($this->bu_id);
     $this->mu_id = $data['mu_id'];
     $request = array_merge(array('us_id' => ''), $request);
     $request['em_id'] = forceInteger($request['id'], 0, false, '.');
     if ($this->act != 'del') {
         // Change required fields
         if ($request['em_is_production'] == 'T') {
             $request['up_id'] = null;
             $this->setFieldAttrib('esu_id', array('required' => true));
         } else {
             if ($request['us_id'] == '') {
                 $this->setFieldAttrib('esu_id', array('required' => true));
             } else {
                 $this->setFieldAttrib('up_id', array('required' => true));
             }
         }
         if ($request['us_id'] == '') {
             $request['esu_id'] = R3EcoGisHelper::getEnergySourceUdmID($this->do_id, $request['es_id'], $request['udm_id'], $this->mu_id);
         } else {
             $request['esu_id'] = '';
         }
         $request['emo_id'] = R3EcoGisHelper::getEnergyMeterObjectIdByCode('BUILDING');
         $request['em_object_id'] = $request['bu_id'];
         $errors = $this->checkFormData($request);
     }
     if (count($errors) > 0) {
         return $this->getAjaxErrorResult($errors);
     } else {
         $id = $this->applyData($request);
         R3EcoGisEventNotifier::notifyDataChanged($this, array('data_changed' => true));
         return array('status' => R3_AJAX_NO_ERROR, 'js' => "submitFormDataDoneMeter({$id})");
     }
 }