public static function addNameToModel(\Gems_Model_JoinModel $model, $label)
    {
        $nameExpr[]  = "COALESCE(grs_last_name, '-')";
        $fieldList[] = 'grs_last_name';
        if ($model->has('grs_partner_last_name')) {
            if ($model->has('grs_partner_surname_prefix')) {
                $nameExpr[]  = "COALESCE(CONCAT(' ', grs_partner_surname_prefix), '')";
                $fieldList[] = 'grs_partner_surname_prefix';
            }

            $nameExpr[]  = "COALESCE(CONCAT(' ', grs_partner_last_name), '')";
            $fieldList[] = 'grs_partner_last_name';
        }
        $nameExpr[] = "', '";

        if ($model->has('grs_first_name')) {
            if ($model->has('grs_initials_name')) {
                $nameExpr[]  = "COALESCE(grs_first_name, grs_initials_name, '')";
                $fieldList[] = 'grs_first_name';
                $fieldList[] = 'grs_initials_name';
            } else {
                $nameExpr[]  = "COALESCE(grs_first_name, '')";
                $fieldList[] = 'grs_first_name';
            }
        } elseif ($model->has('grs_initials_name')) {
            $nameExpr[]  = "COALESCE(grs_initials_name, '')";
            $fieldList[] = 'grs_initials_name';
        }
        if ($model->has('grs_surname_prefix')) {
            $nameExpr[]  = "COALESCE(CONCAT(' ', grs_surname_prefix), '')";
            $fieldList[] = 'grs_surname_prefix';
        }
        $model->set('name',
                'label', $label,
                'column_expression', new \Zend_Db_Expr("CONCAT(" . implode(', ', $nameExpr) . ")"),
                'fieldlist', $fieldList);
   }
public static function addNameToModel(\Gems_Model_JoinModel $model, $label)
    {
        $nameExpr[]  = "COALESCE(grs_last_name, '-')";
        $fieldList[] = 'grs_last_name';
        if ($model->has('grs_partner_last_name')) {
            if ($model->has('grs_partner_surname_prefix')) {
                $nameExpr[]  = "COALESCE(CONCAT(' ', grs_partner_surname_prefix), '')";
                $fieldList[] = 'grs_partner_surname_prefix';
            }

            $nameExpr[]  = "COALESCE(CONCAT(' ', grs_partner_last_name), '')";
            $fieldList[] = 'grs_partner_last_name';
        }
        $nameExpr[] = "', '";

        if ($model->has('grs_first_name')) {
            if ($model->has('grs_initials_name')) {
                $nameExpr[]  = "COALESCE(grs_first_name, grs_initials_name, '')";
                $fieldList[] = 'grs_first_name';
                $fieldList[] = 'grs_initials_name';
            } else {
                $nameExpr[]  = "COALESCE(grs_first_name, '')";
                $fieldList[] = 'grs_first_name';
            }
        } elseif ($model->has('grs_initials_name')) {
            $nameExpr[]  = "COALESCE(grs_initials_name, '')";
            $fieldList[] = 'grs_initials_name';
        }
        if ($model->has('grs_surname_prefix')) {
            $nameExpr[]  = "COALESCE(CONCAT(' ', grs_surname_prefix), '')";
            $fieldList[] = 'grs_surname_prefix';
        }
        $model->set('name',
                'label', $label,
                'column_expression', new \Zend_Db_Expr("CONCAT(" . implode(', ', $nameExpr) . ")"),
                'fieldlist', $fieldList);
   }
public static function addNameToModel ( \ Gems_Model_JoinModel $ model , $ label ) { $ nameExpr [ ] = "COALESCE(grs_last_name, '-')" ; $ fieldList [ ] = 'grs_last_name' ; if ( $ model -> has ( 'grs_partner_last_name' ) ) { if ( $ model -> has ( 'grs_partner_surname_prefix' ) ) { $ nameExpr [ ] = "COALESCE(CONCAT(' ', grs_partner_surname_prefix), '')" ; $ fieldList [ ] = 'grs_partner_surname_prefix' ; } $ nameExpr [ ] = "COALESCE(CONCAT(' ', grs_partner_last_name), '')" ; $ fieldList [ ] = 'grs_partner_last_name' ; } $ nameExpr [ ] = "', '" ; if ( $ model -> has ( 'grs_first_name' ) ) { if ( $ model -> has ( 'grs_initials_name' ) ) { $ nameExpr [ ] = "COALESCE(grs_first_name, grs_initials_name, '')" ; $ fieldList [ ] = 'grs_first_name' ; $ fieldList [ ] = 'grs_initials_name' ; } else { $ nameExpr [ ] = "COALESCE(grs_first_name, '')" ; $ fieldList [ ] = 'grs_first_name' ; } } elseif ( $ model -> has ( 'grs_initials_name' ) ) { $ nameExpr [ ] = "COALESCE(grs_initials_name, '')" ; $ fieldList [ ] = 'grs_initials_name' ; } if ( $ model -> has ( 'grs_surname_prefix' ) ) { $ nameExpr [ ] = "COALESCE(CONCAT(' ', grs_surname_prefix), '')" ; $ fieldList [ ] = 'grs_surname_prefix' ; } $ model -> set ( 'name' , 'label' , $ label , 'column_expression' , new \ Zend_Db_Expr ( "CONCAT(" . implode ( ', ' , $ nameExpr ) . ")" ) , 'fieldlist' , $ fieldList ) ; }
Add the respondent name as a caclulated field to the model
@param \Gems_Model_JoinModel $model
@param string $label
Add the respondent name as a caclulated field to the model