'ACCOUNTID', 'callback' => 'text', 'required' => true, 'length' => 0, 'default' => null ], [ 'name' => 'CONTACTID', 'callback' => 'text', 'required' => true, 'length' => 0, 'default' => null ], [ 'name' => 'Deal Name', 'callback' => 'text', 'required' => true, 'length' => 100, 'default' => null ], [ 'name' => 'Typ' /*Type*/, 'callback' => 'entry_type', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Partner gewählt', 'callback' => 'partners', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Spezialgründung', 'callback' => 'special_foundation', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Betrag' /*Amount*/, 'callback' => 'amount', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Abschlussdatum' /*Closing Date*/, 'callback' => 'date', 'required' => true, 'length' => 0, 'default' => null ], [ 'name' => 'Stufe' /*Stage*/, 'callback' => 'text', 'required' => true, 'length' => 0, 'default' => 'Bestellung eingegangen' ], [ 'name' => 'Abschluss-Name' /*Firmenname*/, 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Firma Strasse' /*Firmenadresse*/, 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Firma PLZ', 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Firma Ort', 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Firma Gegenstand' /*Firmenzweck*/, 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Gründungskapital', 'callback' => 'decimal', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'davon Sacheinlage', 'callback' => 'decimal', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Wert pro Anteil', 'callback' => 'decimal', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Bankangaben', 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Beschreibung' /*Description*/, 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => 'Anzahl Anteile', 'callback' => 'number', 'required' => false, 'length' => 0, 'default' => null ], ]; protected static $person_fields = [ [ 'name' => '%d-Anrede', 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => '%d-Vorname', 'callback' => 'text', 'required' => false, 'length' => 40, 'default' => null ], [ 'name' => '%d-Nachname', 'callback' => 'text', 'required' => false, 'length' => 40, 'default' => null ], [ 'name' => '%d-Strasse', 'callback' => 'text', 'required' => false, 'length' => 250, 'default' => null ], [ 'name' => '%d-Ort', 'callback' => 'text', 'required' => false, 'length' => 30, 'default' => null ], [ 'name' => '%d-PLZ', 'callback' => 'text', 'required' => false, 'length' => 30, 'default' => null ], [ 'name' => '%d-Nationalität', 'callback' => 'text', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => '%d-Geburtsdatum', 'callback' => 'date', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => '%d-Funktion Firma', 'callback' => 'function_in_company', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => '%d-Zeichnungsberechtigung', 'callback' => 'signature_authorization', 'required' => false, 'length' => 0, 'default' => null ], [ 'name' => '%d-Gehaltene Anteile', 'callback' => 'number', 'required' => false, 'length' => 0, 'default' => null ], ]; protected static $fields_map = [ // Bestellung 'ACCOUNTID' => 'zoho_account_id', 'CONTACTID' => 'zoho_contact_id', 'Deal Name' => 'company_name', 'Typ' => 'entry_type', // Type 'Partner gewählt' => 'partners', 'Spezialgründung' => 'persons', 'Betrag' => 'price', // Amount 'Abschlussdatum' => 'added', // Closing Date 'Stufe' => '', // Stage // Bestellinformationen 'Abschluss-Name' => 'company_name', // Firmenname 'Firma Strasse' => 'company_street', // Firmenadresse 'Firma PLZ' => 'company_zip', 'Firma Ort' => 'company_city', 'Firma Gegenstand' => 'company_purpose', // Firmenzweck 'Gründungskapital' => 'equity_capital', 'davon Sacheinlage' => 'in_kind', 'Wert pro Anteil' => 'share_price', 'Bankangaben' => 'bank_details', 'Beschreibung' => 'comment', // Description // залишив це поле (в документі з полями що дали фасунівці його не було) 'Anzahl Anteile' => '_shares_number', ]; protected static $person_fields_map = [ '%d-Anrede' => 'prefix', '%d-Vorname' => 'first_name', '%d-Nachname' => 'last_name', '%d-Strasse' => 'street', '%d-Ort' => 'city', '%d-PLZ' => 'zip', '%d-Nationalität' => 'nationality', '%d-Geburtsdatum' => 'birth_date', '$d-Funktion Firma' => 'function_in_company', '%d-Zeichnungsberechtigung' => 'signature_authorization_ID', '%d-Gehaltene Anteile' => 'shares_number', ]; protected static function get_xml_data( array $data ) { $xml_data = parent::get_xml_data( $data ); if ( ! empty( $data['persons'] ) ) { $index = 1; foreach ( $data['persons'] as $person ) { foreach ( static::$person_fields as $specs ) { $key = @static::$person_fields_map[$specs['name']]; if ( $key ) { $value = ( $key ) ? @$person[ $key ] : null; } else { $value = @$specs['default']; } $xml_data[ sprintf( $specs['name'], $index ) ] = call_user_func_array( [ static::get_module_class(), $specs['callback'] ], [ $value, $specs, $person ] ); } ++$index; } $xml_data = array_filter( $xml_data ); } return $xml_data; } public static function entry_type( $value, array $specs, array $data ) { static $entry_types; static $backing_types; if ( null === $entry_types ) { $entry_types = DB::get_entry_types( 'de', true ); } if ( null === $backing_types ) { $backing_types = DB::get_backing_types( 'de', true ); } $value = $entry_types[$data['entry_type_ID']]['title']; if ( ! empty( $data['backing_type_ID'] ) ) { $value .= " {$backing_types[$data['backing_type_ID']]['title']}"; } $value = str_replace( [ 'Sacheinlage', 'Bareinlage' ], [ 'Sach', 'Bar' ], $value ); return $value; } public static function amount( $value, array $specs, array $data ) { $price = $data['price']; if ( ! empty( $data['partners'] ) ) { foreach ( $data['partners'] as $partner ) { $price = bcsub( $price, $partner['discount'], 2 ); } } return $price; } public static function partners( $value ) { $value = (array) $value; $partners = array_column( $value, 'title' ); return ( $partners ) ? implode( ';', $partners ) : ''; } public static function special_foundation( $value ) { return ( is_array( $value ) && count( $value ) > 4 ) ? 'JA' : 'nein'; } public static function function_in_company( $value, $spec, $person ) { static $functions, $vr_functions; if ( $person['vr_function_in_company_ID'] ) { if ( null === $vr_functions ) { $vr_functions = DB::get_vr_function_in_company( 'de', true ); } $value = $vr_functions[$person['vr_function_in_company_ID']]; $value = static::umlaut( $value ); return $value; } if ( $person['function_in_company_ID'] ) { if ( null === $functions ) { $functions = DB::get_function_in_company( 'de', true ); } $value = $functions[$person['function_in_company_ID']]; $value = static::umlaut( $value ); return $value; } return null; } public static function signature_authorization( $signature_authorization_ID ) { if ( ! $signature_authorization_ID ) { return null; } static $signature; if ( null === $signature ) { $signature = DB::get_signature_authorization( 'de', true ); } $value = $signature[$signature_authorization_ID]; $value = static::umlaut( $value ); return $value; } }