Exemple #1
0
 public function SwitchSearchFieldForm($switchForm, $fieldName, $fieldValue)
 {
     include_once OPENBIZ_BIN . "/easy/SearchHelper.php";
     $this->switchForm($switchForm);
     $listFormObj = BizSystem::getObject($switchForm);
     QueryStringParam::reset();
     $searchRule = inputValToRule($fieldName, $fieldValue, $this);
     $searchRuleBindValues = QueryStringParam::getBindValues();
     $listFormObj->setSearchRule($searchRule, $searchRuleBindValues);
     $listFormObj->rerender();
 }
Exemple #2
0
 /**
  * Insert record using given input record array
  *
  * @param array $recArr - associated array whose keys are field names of this BizDataObj
  * @return boolean - if return false, the caller can call getErrorMessage to get the error.
  **/
 public function insertRecord($recArr)
 {
     if ($this->_isNeedGenerateId($recArr)) {
         $recArr["Id"] = $this->generateId();
     }
     // for certain cases, id is generated before insert
     $this->m_BizRecord->setInputRecord($recArr);
     if (!$this->validateInput()) {
         return false;
     }
     $db = $this->getDBConnection();
     try {
         $sql = $this->getSQLHelper()->buildInsertSQL($this, $joinValues);
         if ($sql) {
             $bindValues = QueryStringParam::getBindValues();
             $bindValueString = QueryStringParam::getBindValueString();
             BizSystem::log(LOG_DEBUG, "DATAOBJ", "Insert Sql = {$sql}" . "; BIND: {$bindValueString}");
             QueryStringParam::reset();
             $db->query($sql, $bindValues);
         }
         //$mainId = $db->lastInsertId();
         if ($this->_isNeedGenerateId($recArr)) {
             $mainId = $this->generateId(false);
             $recArr["Id"] = $mainId;
         }
         BizSystem::log(LOG_DEBUG, "DATAOBJ", "New record Id is " . $recArr["Id"]);
     } catch (Exception $e) {
         BizSystem::log(LOG_ERR, "DATAOBJ", "Query Error : " . $e->getMessage());
         $this->m_ErrorMessage = $this->getMessage("DATA_ERROR_QUERY") . ": " . $sql . ". " . $e->getMessage();
         throw new BDOException($this->m_ErrorMessage);
         return null;
     }
     $this->m_BizRecord->setInputRecord($recArr);
     if ($this->_postUpdateLobFields($recArr) === false) {
         $this->m_ErrorMessage = $db->ErrorMsg();
         return false;
     }
     $this->cleanCache();
     $this->m_RecordId = $recArr["Id"];
     $this->m_CurrentRecord = null;
     $this->_postInsertRecord($recArr);
     return true;
 }
Exemple #3
0
 protected function getDOFromList($selectFrom)
 {
     $pos0 = strpos($selectFrom, "[");
     $pos1 = strpos($selectFrom, "]");
     if ($pos0 > 0 && $pos1 > $pos0) {
         // select from bizObj
         // support BizObjName[BizFieldName] or
         // BizObjName[BizFieldName4Text:BizFieldName4Value] or
         // BizObjName[BizFieldName4Text:BizFieldName4Value:BizFieldName4Pic]
         $bizObjName = substr($selectFrom, 0, $pos0);
         $pos3 = strpos($selectFrom, ":");
         if ($pos3 > $pos0 && $pos3 < $pos1) {
             $fieldName = substr($selectFrom, $pos0 + 1, $pos3 - $pos0 - 1);
             $fieldName_v = substr($selectFrom, $pos3 + 1, $pos1 - $pos3 - 1);
         } else {
             $fieldName = substr($selectFrom, $pos0 + 1, $pos1 - $pos0 - 1);
             $fieldName_v = $fieldName;
         }
         $pos4 = strpos($fieldName_v, ":");
         if ($pos4) {
             $fieldName_v_mixed = $fieldName_v;
             $fieldName_v = substr($fieldName_v_mixed, 0, $pos4);
             $fieldName_p = substr($fieldName_v_mixed, $pos4 + 1, strlen($fieldName_v_mixed) - $pos4 - 1);
             unset($fieldName_v_mixed);
         }
         $commaPos = strpos($selectFrom, ",", $pos1);
         if ($commaPos > $pos1) {
             $searchRule = trim(substr($selectFrom, $commaPos + 1));
         }
         /* @var $bizObj BizDataObj */
         $bizObj = BizSystem::getObject($bizObjName);
         if (!$bizObj) {
             return false;
         }
         $recList = array();
         $oldAssoc = $bizObj->m_Association;
         $bizObj->m_Association = null;
         QueryStringParam::reset();
         $recList = $bizObj->directFetch($searchRule);
         $bizObj->m_Association = $oldAssoc;
         foreach ($recList as $rec) {
             $list[$i]['val'] = $rec[$fieldName_v];
             $list[$i]['txt'] = $rec[$fieldName];
             $list[$i]['pic'] = $rec[$fieldName_p];
             $i++;
         }
         return $list;
     }
     return false;
 }