RealEstate - name field is street address

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • yuri
    commented on 's reply
    Letting know that it's highly advisable not to change files. One can suppress an existing hook and add a new custom one. The application allows it.

  • Macbereth
    replied
    i can edit /fix without break anything

    first in terminal

    nano /var/www/html/custom/Espo/Modules/RealEstate/Hooks/RealEstateProperty/SetValues.php

    and replace
    $name = '';
    if ($entity->get('addressStreet') || $entity->get('addressCity')) {
    if ($entity->get('addressStreet')) {
    $name .= str_replace("\n", ', ', $entity->get('addressStreet'));
    }
    if ($entity->get('addressCity')) {
    if ($name != '') {
    $name .= ", ";
    }
    $name .= $entity->get('addressCity');
    }
    }
    else {
    $name = "unknown-address";
    }
    $entity->set('name', $name);​


    To --------------------------------------------------------------
    if (empty($entity->get('name'))) {
    $name = '';

    if ($entity->get('addressStreet') || $entity->get('addressCity')) {
    if ($entity->get('addressStreet')) {
    $name .= str_replace("\n", ', ', $entity->get('addressStreet'));
    }

    if ($entity->get('addressCity')) {
    if ($name != '') {
    $name .= ", ";
    }
    $name .= $entity->get('addressCity');
    }
    }
    else {
    $name = "unknown-address";
    }

    $entity->set('name', $name);
    }​

    Finally only need to restart cache
    php /var/www/html/clear_cache.php


    Leave a comment:


  • punkyard
    commented on 's reply
    well .. that's a good recall to 'back up back up back up' ^^

  • esforim
    commented on 's reply
    Yes, unfortunately it. I wrote what I can (scatter through various post) on the extensions. But if it anything too complex in term of coding I have to shy away from trying it. I break the CRM too many time and panicked.

  • punkyard
    replied
    2 - How to give a custom name to the Properties?
    I looked in /application/Espo/Modules/RealEstate/repositories/RealEstateProperty.php :
    but i'm afraid to mess around in the whole entity :

    {
    $propertyType = $entity->get('type');
    $fieldList = $this->getMetadata()->get(['entityDefs', 'RealEstateProperty', 'propertyTypes', $propertyType, 'fieldList'], []);
    $fieldDefs = $this->getMetadata()->get(['entityDefs', 'RealEstateProperty', 'fields'], []);
    foreach ($fieldDefs as $field => $defs) {
    if (empty($defs['isMatching'])) continue;
    if (!in_array($field, $fieldList)) {
    $entity->set($field, null);
    }
    }
    $name = '';
    if ($entity->get('addressStreet') || $entity->get('addressCity')) {
    if ($entity->get('addressStreet')) {
    $name .= str_replace("\n", ', ', $entity->get('addressStreet'));
    }
    if ($entity->get('addressCity')) {
    if ($name != '') {
    $name .= ", ";
    }
    $name .= $entity->get('addressCity');
    }
    } else {
    $name = "unknown-address";
    }
    $entity->set('name', $name);
    return parent::beforeSave($entity, $options);
    }

    could I turn it into this: ? (without messing around with something else) :

    $name = $entity->get('name');

    $entity->set('name', $name);


    + I added the 'name' field into the layouts in order to give a data to that field ^^

    Thanks a lot
    Last edited by punkyard; 04-26-2021, 08:51 PM.

    Leave a comment:


  • punkyard
    replied
    if anyone can help, my questions would be :

    1 - could it be possible to display a custom format option panel for the automatic nomination format of the RealEstateRequest Name field (R 000001)?
    this could be useful to companies with their own formatting

    how to play with? : (adding the date for example?)

    if ($entity->isNew() && !$entity->get('name')) {

    $e = $this->get($entity->id);
    $name = strval($e->get('number'));
    $name = str_pad($name, 6, '0', STR_PAD_LEFT);
    $name = 'R' . $name;

    $e->set('name', $name);
    $this->save($e);
    $entity->set('name', $name);
    $entity->set('number', $e->get('number'));

    Though, It is possible to uncheck the "read only" option in the entity manager, and type your own.

    Leave a comment:


  • punkyard
    commented on 's reply
    thanks espcrm
    alas, there is no documentation on this extension, though the user experience of this extension could benefit from a extensive tutorial/documentation, I recon.

  • esforim
    replied
    I don't think too many people use the Real Estate extensions so you might have to figure this one out on your own by looking into the code. It not possible to do this through the GUI/admin.

    The "Name" field used the following field:
    Street Address, City

    I use this extensions too but never look into changing it with code, the only thing I added was "Duplicate check" so I don't create two same address

    Leave a comment:


  • punkyard
    started a topic RealEstate - name field is street address

    RealEstate - name field is street address

    hi
    in the real estate extension, the name of a Property is the first address line

    where is this stated in the entity settings?
    how to change the name of the Property (top of the page) for a new field (ex: buildingName)?

    thanks
    Last edited by punkyard; 04-26-2021, 08:54 PM.
Working...