Exemplo n.º 1
0
 public function getModuleFields()
 {
     $moduleFields = $this->meta->getModuleFields();
     $module = $this->getModule();
     if ($module == 'Calendar') {
         $eventmoduleMeta = $this->getMeta('Events');
         $eventModuleFieldList = $eventmoduleMeta->getModuleFields();
         $moduleFields = array_merge($moduleFields, $eventModuleFieldList);
     }
     return $moduleFields;
 }
Exemplo n.º 2
0
 public function addUserSearchConditions($input)
 {
     global $log, $default_charset;
     if ($input['searchtype'] == 'advance') {
         $json = new Zend_Json();
         $advft_criteria = $_REQUEST['advft_criteria'];
         if (!empty($advft_criteria)) {
             $advft_criteria = $json->decode($advft_criteria);
         }
         $advft_criteria_groups = $_REQUEST['advft_criteria_groups'];
         if (!empty($advft_criteria_groups)) {
             $advft_criteria_groups = $json->decode($advft_criteria_groups);
         }
         if (empty($advft_criteria) || count($advft_criteria) <= 0) {
             return;
         }
         $advfilterlist = getAdvancedSearchCriteriaList($advft_criteria, $advft_criteria_groups, $this->getModule());
         if (empty($advfilterlist) || count($advfilterlist) <= 0) {
             return;
         }
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         foreach ($advfilterlist as $groupindex => $groupcolumns) {
             $filtercolumns = $groupcolumns['columns'];
             if (count($filtercolumns) > 0) {
                 $this->startGroup('');
                 foreach ($filtercolumns as $index => $filter) {
                     $name = explode(':', $filter['columnname']);
                     if (empty($name[2]) && $name[1] == 'crmid' && $name[0] == 'vtiger_crmentity') {
                         $name = $this->getSQLColumn('id');
                     } else {
                         $name = $name[2];
                     }
                     $this->addCondition($name, $filter['value'], $filter['comparator']);
                     $columncondition = $filter['column_condition'];
                     if (!empty($columncondition)) {
                         $this->addConditionGlue($columncondition);
                     }
                 }
                 $this->endGroup();
                 $groupConditionGlue = $groupcolumns['condition'];
                 if (!empty($groupConditionGlue)) {
                     $this->addConditionGlue($groupConditionGlue);
                 }
             }
         }
         $this->endGroup();
     } elseif ($input['type'] == 'dbrd') {
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         $allConditionsList = $this->getDashBoardConditionList();
         $conditionList = $allConditionsList['conditions'];
         $relatedConditionList = $allConditionsList['relatedConditions'];
         $noOfConditions = count($conditionList);
         $noOfRelatedConditions = count($relatedConditionList);
         foreach ($conditionList as $index => $conditionInfo) {
             $this->addCondition($conditionInfo['fieldname'], $conditionInfo['value'], $conditionInfo['operator']);
             if ($index < $noOfConditions - 1 || $noOfRelatedConditions > 0) {
                 $this->addConditionGlue(self::$AND);
             }
         }
         foreach ($relatedConditionList as $index => $conditionInfo) {
             $this->addRelatedModuleCondition($conditionInfo['relatedModule'], $conditionInfo['conditionModule'], $conditionInfo['finalValue'], $conditionInfo['SQLOperator']);
             if ($index < $noOfRelatedConditions - 1) {
                 $this->addConditionGlue(self::$AND);
             }
         }
         $this->endGroup();
     } else {
         if (isset($input['search_field']) && $input['search_field'] != "") {
             $fieldName = vtlib_purify($input['search_field']);
         } else {
             return;
         }
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         $moduleFields = $this->meta->getModuleFields();
         $field = $moduleFields[$fieldName];
         $type = $field->getFieldDataType();
         if (isset($input['search_text']) && $input['search_text'] != "") {
             // search other characters like "|, ?, ?" by jagi
             $value = $input['search_text'];
             $stringConvert = function_exists(iconv) ? @iconv("UTF-8", $default_charset, $value) : $value;
             if (!$this->isStringType($type)) {
                 $value = trim($stringConvert);
             }
             if ($type == 'picklist') {
                 global $mod_strings;
                 // Get all the keys for the for the Picklist value
                 $mod_keys = array_keys($mod_strings, $value);
                 if (sizeof($mod_keys) >= 1) {
                     // Iterate on the keys, to get the first key which doesn't start with LBL_      (assuming it is not used in PickList)
                     foreach ($mod_keys as $mod_idx => $mod_key) {
                         $stridx = strpos($mod_key, 'LBL_');
                         // Use strict type comparision, refer strpos for more details
                         if ($stridx !== 0) {
                             $value = $mod_key;
                             break;
                         }
                     }
                 }
             }
             if ($type == 'currency') {
                 // Some of the currency fields like Unit Price, Total, Sub-total etc of Inventory modules, do not need currency conversion
                 if ($field->getUIType() == '72') {
                     $value = CurrencyField::convertToDBFormat($value, null, true);
                 } else {
                     $currencyField = new CurrencyField($value);
                     $value = $currencyField->getDBInsertedValue();
                 }
             }
         }
         if (!empty($input['operator'])) {
             $operator = $input['operator'];
         } elseif (trim(strtolower($value)) == 'null') {
             $operator = 'e';
         } else {
             if (!$this->isNumericType($type) && !$this->isDateType($type)) {
                 $operator = 'c';
             } else {
                 $operator = 'h';
             }
         }
         $this->addCondition($fieldName, $value, $operator);
         $this->endGroup();
     }
 }
Exemplo n.º 3
0
 public function addUserSearchConditions($input)
 {
     global $log, $default_charset;
     if ($input['searchtype'] == 'advance') {
         if (empty($input['search_cnt'])) {
             return;
         }
         $noOfConditions = vtlib_purify($input['search_cnt']);
         if ($input['matchtype'] == 'all') {
             $matchType = self::$AND;
         } else {
             $matchType = self::$OR;
         }
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         for ($i = 0; $i < $noOfConditions; $i++) {
             $fieldInfo = 'Fields' . $i;
             $condition = 'Condition' . $i;
             $value = 'Srch_value' . $i;
             list($fieldName, $typeOfData) = split("::::", str_replace('\'', '', stripslashes($input[$fieldInfo])));
             $moduleFields = $this->meta->getModuleFields();
             $field = $moduleFields[$fieldName];
             $type = $field->getFieldDataType();
             $operator = str_replace('\'', '', stripslashes($input[$condition]));
             $searchValue = $input[$value];
             $searchValue = function_exists(iconv) ? @iconv("UTF-8", $default_charset, $searchValue) : $searchValue;
             if ($type == 'picklist') {
                 global $mod_strings;
                 // Get all the keys for the for the Picklist value
                 $mod_keys = array_keys($mod_strings, $searchValue);
                 if (sizeof($mod_keys) >= 1) {
                     // Iterate on the keys, to get the first key which doesn't start with LBL_      (assuming it is not used in PickList)
                     foreach ($mod_keys as $mod_idx => $mod_key) {
                         $stridx = strpos($mod_key, 'LBL_');
                         // Use strict type comparision, refer strpos for more details
                         if ($stridx !== 0) {
                             $searchValue = $mod_key;
                             break;
                         }
                     }
                 }
             }
             $this->addCondition($fieldName, $searchValue, $operator);
             if ($i + 1 < $noOfConditions) {
                 $this->addConditionGlue($matchType);
             }
         }
         $this->endGroup();
     } elseif ($input['type'] == 'dbrd') {
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         $allConditionsList = $this->getDashBoardConditionList();
         $conditionList = $allConditionsList['conditions'];
         $relatedConditionList = $allConditionsList['relatedConditions'];
         $noOfConditions = count($conditionList);
         $noOfRelatedConditions = count($relatedConditionList);
         foreach ($conditionList as $index => $conditionInfo) {
             $this->addCondition($conditionInfo['fieldname'], $conditionInfo['value'], $conditionInfo['operator']);
             if ($index < $noOfConditions - 1 || $noOfRelatedConditions > 0) {
                 $this->addConditionGlue(self::$AND);
             }
         }
         foreach ($relatedConditionList as $index => $conditionInfo) {
             $this->addRelatedModuleCondition($conditionInfo['relatedModule'], $conditionInfo['conditionModule'], $conditionInfo['finalValue'], $conditionInfo['SQLOperator']);
             if ($index < $noOfRelatedConditions - 1) {
                 $this->addConditionGlue(self::$AND);
             }
         }
         $this->endGroup();
     } else {
         if (isset($input['search_field']) && $input['search_field'] != "") {
             $fieldName = vtlib_purify($input['search_field']);
         } else {
             return;
         }
         if ($this->conditionInstanceCount > 0) {
             $this->startGroup(self::$AND);
         } else {
             $this->startGroup('');
         }
         $moduleFields = $this->meta->getModuleFields();
         $field = $moduleFields[$fieldName];
         $type = $field->getFieldDataType();
         if (isset($input['search_text']) && $input['search_text'] != "") {
             // search other characters like "|, ?, ?" by jagi
             $value = $input['search_text'];
             $stringConvert = function_exists(iconv) ? @iconv("UTF-8", $default_charset, $value) : $value;
             if (!$this->isStringType($type)) {
                 $value = trim($stringConvert);
             }
             if ($type == 'picklist') {
                 global $mod_strings;
                 // Get all the keys for the for the Picklist value
                 $mod_keys = array_keys($mod_strings, $value);
                 if (sizeof($mod_keys) >= 1) {
                     // Iterate on the keys, to get the first key which doesn't start with LBL_      (assuming it is not used in PickList)
                     foreach ($mod_keys as $mod_idx => $mod_key) {
                         $stridx = strpos($mod_key, 'LBL_');
                         // Use strict type comparision, refer strpos for more details
                         if ($stridx !== 0) {
                             $value = $mod_key;
                             break;
                         }
                     }
                 }
             }
         }
         if (!empty($input['operator'])) {
             $operator = $input['operator'];
         } elseif (trim(strtolower($value)) == 'null') {
             $operator = 'e';
         } else {
             if (!$this->isNumericType($type) && !$this->isDateType($type)) {
                 $operator = 'c';
             } else {
                 $operator = 'h';
             }
         }
         $this->addCondition($fieldName, $value, $operator);
         $this->endGroup();
     }
 }