Exemplo n.º 1
0
 /**
  * get custom field data
  *
  * @internal
  * @param string $infoType
  * @param string $productId
  * @return array
  */
 private function getCustomFieldData($infoType, $productId)
 {
     $data = array();
     $fields = FieldConfig::model()->findAllByAttributes(array('product_id' => $productId, 'is_dropped' => false, 'type' => ucfirst($infoType)));
     foreach ($fields as $field) {
         switch ($field->field_type) {
             case FieldConfig::FIELD_TYPE_SINGLESELECT:
             case FieldConfig::FIELD_TYPE_SINGLEUSER:
                 $data[] = array('title' => Yii::t('Report', '{type} per {group}', array('{type}' => ucfirst($infoType), '{group}' => $field->field_label)), 'type' => Report::TYPE_BAR, 'group' => $field->field_name, 'infoType' => $infoType);
                 break;
             case FieldConfig::FIELD_TYPE_DATE:
                 $data[] = array('title' => Yii::t('Report', '{type} {group} per day', array('{type}' => ucfirst($infoType), '{group}' => $field->field_label)), 'type' => Report::TYPE_COLUMN, 'where' => $field->field_name . ' IS NOT NULL', 'group' => 'DATE_FORMAT(' . $field->field_name . ', "%Y-%m-%d")', 'order' => Report::GROUP_LABEL, 'asc' => false, 'limit' => 90, 'showOther' => false, 'showTable' => false, 'reverse' => true, 'infoType' => $infoType);
                 $data[] = array('title' => Yii::t('Report', '{type} {group} per week', array('{type}' => ucfirst($infoType), '{group}' => $field->field_label)), 'type' => Report::TYPE_COLUMN, 'where' => $field->field_name . ' IS NOT NULL', 'group' => 'DATE_FORMAT(DATE_SUB(' . $field->field_name . ', INTERVAL (if(DATE_FORMAT(' . $field->field_name . ', "%w") = 0,7,DATE_FORMAT(' . $field->field_name . ', "%w")))-1 DAY), "%Y-%m-%d")', 'order' => Report::GROUP_LABEL, 'asc' => true, 'limit' => 0, 'showTable' => false, 'infoType' => $infoType);
                 $data[] = array('title' => Yii::t('Report', '{type} {group} per month', array('{type}' => ucfirst($infoType), '{group}' => $field->field_label)), 'type' => Report::TYPE_COLUMN, 'where' => $field->field_name . ' IS NOT NULL', 'group' => 'DATE_FORMAT(' . $field->field_name . ', "%Y-%m")', 'order' => Report::GROUP_LABEL, 'asc' => true, 'limit' => 0, 'showTable' => false, 'infoType' => $infoType);
                 break;
             default:
                 break;
         }
     }
     return $data;
 }
Exemplo n.º 2
0
 private static function checkSingleField($fieldInfo, $sourceFieldArr)
 {
     $checkResultStr = '';
     $sourceMatchedInfo = array();
     foreach ($sourceFieldArr as $souceFieldInfo) {
         if ($souceFieldInfo['field_name'] == $fieldInfo['field_name']) {
             $sourceMatchedInfo = $souceFieldInfo;
             break;
         }
     }
     if (empty($sourceMatchedInfo)) {
         $checkResultStr = "[{$fieldInfo['field_name']}]" . Yii::t('Common', 'is not existed') . "\n";
     } else {
         $compareAttributeArr = array('field_type', 'edit_in_result', 'validate_rule');
         foreach ($compareAttributeArr as $attribute) {
             if (trim($sourceMatchedInfo[$attribute]) != trim($fieldInfo[$attribute])) {
                 $checkResultStr .= '[' . $fieldInfo['field_name'] . '][' . FieldConfig::model()->getAttributeLabel($attribute) . '] ' . Yii::t('Common', 'is different') . "\n";
             }
         }
         if (0 < count(array_diff(CommonService::splitStringToArray(',', $sourceMatchedInfo['field_value']), CommonService::splitStringToArray(',', $fieldInfo['field_value'])))) {
             $checkResultStr .= '[' . $fieldInfo['field_name'] . '][' . FieldConfig::model()->getAttributeLabel('field_value') . '] ' . Yii::t('Common', 'is different') . "\n";
         }
         if (FieldConfig::VALIDATION_RULE_MATCH == $fieldInfo['validate_rule']) {
             if ($fieldInfo['match_expression'] != $sourceMatchedInfo['match_expression']) {
                 $checkResultStr .= '[' . $fieldInfo['field_name'] . '][' . FieldConfig::model()->getAttributeLabel('match_expression') . '] ' . Yii::t('Common', 'is different') . "\n";
             }
         }
     }
     return $checkResultStr;
 }