Magento Forum

   
Page 2 of 3
Extensie pentru adresa - persoana fizica si persoana juridica
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

Scoate <disabled>

<pfpj_cnp>
        <!--<
disabled>1</disabled>-->

Si `is_visible` trebuie sa fie 1.

 
Magento Community Magento Community
Magento Community
Magento Community
 
andru_san
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2009-09-06
Timisoara, Romania
 

Multam fain, da tot nu salveaza in baza de date :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

Voi testa si eu activarea cnp-ului.
Probabil maine o pot sa iti dau niste indicatii mai exacte.

 
Magento Community Magento Community
Magento Community
Magento Community
 
andru_san
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2009-09-06
Timisoara, Romania
 

Mersi mult smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
andru_san
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2009-09-06
Timisoara, Romania
 

Imi pare rau ca te bat la cap, imi dau seama ca ai treburi mai bune de facut, dar ai avut cumva ocazia sa te mai uiti peste cnp? :(

 
Magento Community Magento Community
Magento Community
Magento Community
 
andru_san
Jr. Member
 
Avatar
Total Posts:  13
Joined:  2009-09-06
Timisoara, Romania
 

Cu ajutorul lui Daniel am activat CNP-ul. Iata indicatiile lui:

SQL

UPDATE `eav_attribute`, `eav_entity_type`
    
SET `eav_attribute`.`is_visible`=1
WHERE
    
`eav_attribute`.`attribute_code`="pfpj_cnp"
    
AND (`eav_entity_type`.`entity_type_code`="customer_address"
        
OR `eav_entity_type`.`entity_type_code`="order_address")
    AND `
eav_attribute`.`entity_type_id`=`eav_entity_type`.`entity_type_id`;

app/code/community/PfpjRom/CustomerRom/etc/config.xml (atasat)
linia 134:

<pfpj_cnp>
    <
legality>
        <
show>1</show>
        <
required>1</required>
    </
legality>
    <!-- 
Daca CNP trebuie sa apara la ambele optiuni:
    <
natural>
        <
show>1</show>
        <
required>1</required>
    </
natural>
    -->
</
pfpj_cnp>
161:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}{{/if}}
190:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}{{/if}}<br />
211:
{{if pfpj_tip_pers == 2}}Cod Numeric Personal (CNP): {{var pfpj_cnp}}|{{/if}}

app/code/design/frontend/default/default/checkoutrom/onepage/billing.phtml (atasat)
app/code/design/frontend/default/modern/checkoutrom/onepage/billing.phtml
63:

<input type="text" id="billing:pfpj_banca" name="billing[pfpj_banca]" value="<?php echo $this->htmlEscape($this->getAddress()->getPfpjBanca()) ?>" title="<?php echo $this->__('Bank') ?>" class="input-text" /></div>
80:
<input type="text" id="billing:pfpj_cnp" name="billing[pfpj_cnp]" value="<?php echo $this->htmlEscape($this->getAddress()->getPfpjCnp()) ?>" title="<?php echo $this->__('Personal Identification Code') ?>" class="input-text" /></div>
191 (0 ascunde CNP la pers. fizica):
shipping.opcBillingAddressTippersBehaviour = new PfpjRom.AddressTippersBehaviour("<?php echo $this->getAddress()->getPfpjTipPers()?>"<?php echo $this->helper('customerrom/tippers')->getJsonConfig() ?>0falsefalse);

app/code/design/frontend/default/default/checkoutrom/onepage/shipping.phtml (atasat)
app/code/design/frontend/default/modern/checkoutrom/onepage/shipping.phtml
66:

<input type="text" id="shipping:pfpj_cnp" name="shipping[pfpj_cnp]" value="<?php echo $this->htmlEscape($this->getAddress()->getPfpjCnp()) ?>" title="<?php echo $this->__('Personal Identification Code') ?>" class="input-text" onchange="shipping.setSameAsBilling(false);" /></div>
145:
shipping.opcShippingAddressTippersBehaviour = new PfpjRom.AddressTippersBehaviour("<?php echo $this->getAddress()->getPfpjTipPers()?>"<?php echo $this->helper('customerrom/tippers')->getJsonConfig() ?>0falsefalse);

Nota
Copiati app/code/community/PfpjRom/CustomerRom/etc/config.xml pe app/code/local/PfpjRom/CustomerRom/etc/config.xml sa nu-l modificati la fiecare update (local “suprascrie” restul, inclusiv core).

File Attachments
config.xml  (File Size: 13KB - Downloads: 363)
billing.phtml  (File Size: 15KB - Downloads: 255)
shipping.phtml  (File Size: 12KB - Downloads: 246)
 
Magento Community Magento Community
Magento Community
Magento Community
 
smlaci
Sr. Member
 
Avatar
Total Posts:  122
Joined:  2008-04-15
Bacau
 

Din cate stiu eu, nu e obligatoriu nici serie nici numar nici cnp pe facturile catre persoane fizice.

 
Magento Community Magento Community
Magento Community
Magento Community
 
peteror
Jr. Member
 
Total Posts:  17
Joined:  2009-05-16
 

Salut and Happy New Year!,

sorry for posting in English here, but the Pfpjrom extension is the only one I could find for handling different types of customers with different data sets. and only here I could find a related discussion
My question is whether it’s possible to add more customer types (like educational institutions)? I’ve tried in the config,

<options>
<natural><const>natural_person</const><default>1</default></natural>
<legality><const>legal_entity</const></legality>
<educational><const>educational</const></educational>
</options>

but got the error below

thanks
peter

Warning: constant() [function.constant]: Couldn’t find constant PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers::EDUCATIONAL in /var/www/test.webshop/app/code/community/PfpjRom/CustomerRom/Model/Address/Config.php on line 98

#0 [internal function]: mageCoreErrorHandler(2, ‘constant() [getOptions()
#3 /var/www/test.webshop/app/code/core/Mage/Core/Model/Config.php(1086): PfpjRom_CustomerRom_Model_Address_Config->__construct(Array)
#4 /var/www/test.webshop/app/Mage.php(319): Mage_Core_Model_Config->getModelInstance(’customer/addres...’, Array)
#5 /var/www/test.webshop/app/Mage.php(333): Mage::getModel(’customer/addres...’, Array)
#6 /var/www/test.webshop/app/code/community/PfpjRom/CustomerRom/Model/Address.php(62): Mage::getSingleton(’customer/addres...’)
#7 /var/www/test.webshop/app/code/community/PfpjRom/CustomerRom/Block/Address/Edit.php(66): PfpjRom_CustomerRom_Model_Address->getConfig()
#8 /var/www/test.webshop/app/design/frontend/default/modern/template/customerrom/address/edit.phtml(93): PfpjRom_CustomerRom_Block_Address_Edit->getConfig()
#9 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(144): include(’/var/www/test.w...’)
#10 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(176): Mage_Core_Block_Template->fetchView(’frontend/defaul...’)
#11 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(193): Mage_Core_Block_Template->renderView()
#12 /var/www/test.webshop/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Template->_toHtml()
#13 /var/www/test.webshop/app/code/core/Mage/Core/Block/Text/List.php(43): Mage_Core_Block_Abstract->toHtml()
#14 /var/www/test.webshop/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Text_List->_toHtml()
#15 /var/www/test.webshop/app/code/core/Mage/Core/Block/Abstract.php(503): Mage_Core_Block_Abstract->toHtml()
#16 /var/www/test.webshop/app/code/core/Mage/Core/Block/Abstract.php(454): Mage_Core_Block_Abstract->_getChildHtml(’content’, true)
#17 /var/www/test.webshop/app/design/frontend/default/modern/template/page/2columns-left.phtml(66): Mage_Core_Block_Abstract->getChildHtml(’content’)
#18 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(144): include(’/var/www/test.w...’)
#19 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(176): Mage_Core_Block_Template->fetchView(’frontend/defaul...’)
#20 /var/www/test.webshop/app/code/core/Mage/Core/Block/Template.php(193): Mage_Core_Block_Template->renderView()
#21 /var/www/test.webshop/app/code/core/Mage/Core/Block/Abstract.php(643): Mage_Core_Block_Template->_toHtml()
#22 /var/www/test.webshop/app/code/core/Mage/Core/Model/Layout.php(526): Mage_Core_Block_Abstract->toHtml()
#23 /var/www/test.webshop/app/code/core/Mage/Core/Controller/Varien/Action.php(347): Mage_Core_Model_Layout->getOutput()
#24 /var/www/test.webshop/app/code/core/Mage/Customer/controllers/AddressController.php(96): Mage_Core_Controller_Varien_Action->renderLayout()
#25 /var/www/test.webshop/app/code/core/Mage/Core/Controller/Varien/Action.php(376): Mage_Customer_AddressController->formAction()
#26 /var/www/test.webshop/app/code/core/Mage/Core/Controller/Varien/Router/Standard.php(248): Mage_Core_Controller_Varien_Action->dispatch(’form’)
#27 /var/www/test.webshop/app/code/core/Mage/Core/Controller/Varien/Front.php(158): Mage_Core_Controller_Varien_Router_Standard->match(Object(Mage_Core_Controller_Request_Http))
#28 /var/www/test.webshop/app/Mage.php(459): Mage_Core_Controller_Varien_Front->dispatch()
#29 /var/www/test.webshop/index.php(65): Mage::run()
#30 {main}

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

Hi Peter,

I understand you want to add a third option, if not just rename an old one.
Yes first thing you should declare in that class `PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers` another constant named `EDUCATIONAL` with a value = 3 is ok.
You should modify PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers, especially method:

public function getAllOptions()
{
    
if (!$this->_options{
        $this
->_options = array(=> array('value' => self::NATURAL_PERSON,
                                           
'label' => Mage::helper('customerrom')->__('Natural Person')),
                                
=> array('value' => self::LEGAL_ENTITY,
                                           
'label' => Mage::helper('customerrom')->__('Legal Entity')),
                                
/* educational option: */
                                
=> array('value' => self::EDUCATIONAL,
                                           
'label' => Mage::helper('customerrom')->__('Educational institution')));
    
}
    
return $this->_options;
}

Good, you already have:

<options>
<
natural><const>natural_person</const><default>1</default></natural>
<
legality><const>legal_entity</const></legality>
<
educational><const>educational</const></educational>
</
options>

Before it gets more complex you should try yo add the third option in database.
Field named `pfpj_tip_pers` is a combination of radio inputs (in Magento uses renderer lib/Varien/Data/Form/Element/Radios.php - actually CustomerRom/Block/Address/Renderer/Tippers.php). What i’m trying to say, options have almost same implementation as dropdown fields.
In table `eav_attribute_option` and `eav_attribute_option_value` add the third option. To do this first you need `attribute_id` from table `eav_attribute`:

SELECT *
FROM `eav_attribute`
WHERE `attribute_codeLIKE 'pfpj_tip_pers'
`entity_id` == 2 is for customer address entity and `entity_id` == 12 is for order address entity (because customer address is quoted in order at checkout time).

Now check on frontend at MyAccount -> Edit Address if you got the third option.
If didn’t worked look in CustomerRom/sql/customerrom_setup/mysql4-install-0.1.0.php and SalesRom/sql/salesrom_setup/mysql4-install-0.1.0.php.

Next, i think you will need your own fields instead of `pfpj_cui`, `pfpj_reg_com`, `pfpj_banca`, `pfpj_iban`, `pfpj_cnp` and `pfpj_serienr_buletin`. You also could rename the labels to reuse a part of them. To add a new field in database just duplicate, for example, `pfpj_cui` in `eav_attribute` table ( don’t forget to put your own attribute_code). The fields above are input text fields. To add other types you should study yourself to have more insight on Magento’s EAV attribute implementation. But for now just keep it simple.
In CustomerRom/etc/config.xml declare also which fields should apear on a selected option:

<fields>
    <
pfpj_tip_pers>
        <
natural>
            <
show>1</show>
            <
required>1</required>
        </
natural>
        <
legality>
            <
show>1</show>
            <
required>1</required>
        </
legality>
        
        <!-- 
this is mandatory to work:-->
        <
educational>
            <
show>1</show>
            <
required>1</required>
        </
educational>
    </
pfpj_tip_pers>
    
    
    <
company>
        <
legality>
            <
show>1</show>
            <
required>1</required>
        </
legality>
        
        <
educational>
            <
show>1</show> <!-- show(==1the field when Educational Insititution is selected -->
            <
required>1</required> <!-- required 1 or 0(if not)-->
        </
educational>
    </
company>
    
    
    <!-- 
an example of possible new field:--->
    <
pfpj_school>
        <
natural>
            <
show>0</show> <!-- show is 0 anyway by default -->
        </
natural>
        
        <
legality> <!-- not mandatory if show is 0 -->
            <
show>0</show>
        </
legality>
        
        <
educational>
            <
show>1</show>
            <
required>0</required>
        </
educational>
    </
pfpj_school>
    
    
    <!-- 
another example of possible new field:--->
    <
pfpj_field_in_all_options>
        <
natural>
            <
show>1</show>
            <
required>1</required>
        </
natural>
        
        <
legality>
            <
show>1</show>
        </
legality>
        
        <
educational>
            <
show>1</show>
            <
required>1</required>
        </
educational>
    </
pfpj_field_in_all_options>
...
</
fields>
The piece of config above is most used by js/pfpjrom/core.js, triggered on edit address pages(frontend and admin).

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

previous post continued:

Until now you added in database fields and configured a part of it, and most important, saw if something happened.

More configurations, which extends Magento default configs:
1. CustomerRom/etc/config.xml:

a) edit this part, depend of your fields:

<admin>
    <
fieldsets>
        <
customer_dataflow>
            ...
        </
customer_dataflow>
    </
fieldsets>
</
admin>

b) the 4 <formats> - The address is formated for text/html/pdf/online pices of strings; you can see one of them at checkout on the progress sidebar. For this feature only, you should edit the columns of table `sales_flat_quote_address`. There are already pfpjrom columns added.

2. SalesRom/etc/config.xml:
a) Modify <global> <fieldsets> part, depending on your fields.

3. check again all config.xml for pfpj_ fields, i might missed here something.

Before seeing some results, you still to add/modify in templates the html for your input fields.
First look through app/frontend/yourpachage/yourtheme/template/customerrom/address/edit.phtml.
Test it, see if it saves and loads addresses correctly.
Than modify app/frontend/yourpachage/yourtheme/template/checkoutrom/checkoutrom/onepage/billing.phtml and shipping.phtml templates.

Admin should go smoothly. All javascripts used by this extension should work well too, becouse it implements some degree of generalisation.

Post your progress if you got stuck.

Let me know if it worked.

PS: this post should work with the version 0.1.4 of the extension. Future releases will implement custom behaviour that depends of billing and shipping on MyAccount -> Edit Address page. Also it will have some configuration in admin for fields.

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

Forgot to mention,
PfpjRom_CustomerRom_Model_Address->validate() method should be customized too.

 
Magento Community Magento Community
Magento Community
Magento Community
 
peteror
Jr. Member
 
Total Posts:  17
Joined:  2009-05-16
 

Hi Daniel,

Thanks a lot, I’ve managed to do it after I’ve figured the database part out…

I’ve had some difficulties understanding how the fields that I set in the config to show / not show are actually shown but I’ve figured it out:

When I do this:

<li>
    <
div class="input-box">
    ...
input field
    
</div>
</
li>
<
li>
    <
div class="input-box">
    .... 
input field
    
</div>
</
li>

the input fields can be switched on / off separately from the config.xml But when they are in the same <li> tag like this

<li>
    <
div class="input-box">
    ...
input field
    
</div>
    <
div class="input-box">
    .... 
input field
    
</div>
</
li>

.. they will show up or be hidden only together.

Also, I’m not sure whether I need a function

public function getLegalEntityValue()
    
{
        
return self::LEGAL_ENTITY;
    
}

in PfpjRom_CustomerRom_Model_Entity_Address_Attribute_Source_Tippers, but I’ve added it just in case..

So far everything seems to work.

Thanks again for your help! smile

 
Magento Community Magento Community
Magento Community
Magento Community
 
naujasdizainas
Sr. Member
 
Avatar
Total Posts:  128
Joined:  2007-11-04
Lithuania, Vilnius
 

Last relase 0.2.0 In IE 7,8 get error

Line:256
Char:73
Code:0
Error:Expected identifier
URL:http://www.site.com/js/pfpjrom/core.js

Sitax error

defaultValue addr.fieldsConfig[fieldName][tippers_value][state].default;

remove ...

.default
all get OK and work normal. But I dont test detailed.

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 
naujasdizainas.lt - 09 January 2010 10:15 PM

Last relase 0.2.0 In IE 7,8 get error

Line:256
Char:73
Code:0
Error:Expected identifier
URL:http://www.site.com/js/pfpjrom/core.js

Sitax error

defaultValue addr.fieldsConfig[fieldName][tippers_value][state].default;

AND id remove ...
.default
all get OK and fork normal. But I dont test detailed.

Thank you for your feedback.

The bug was fixed in 0.2.1.

 
Magento Community Magento Community
Magento Community
Magento Community
 
danielifrim7
Member
 
Avatar
Total Posts:  63
Joined:  2009-04-29
Bucuresti
 

Pentru ca am fost intrebat cum se dezinstaleaza extensia:

Dupa ce ati dat uninstall din ‘magento connect’, raman totusi niste inregistrari in baza de date.

Query de uninstall:

DELETE *
FROM `eav_attribute`
WHERE `attribute_codeLIKE 'pfpj_%';

ALTER TABLE `sales_flat_quote_address`
    
DROP `pfpj_tip_pers`, 
    
DROP `pfpj_cui`, 
    
DROP `pfpj_reg_com`, 
    
DROP `pfpj_banca`,
    
DROP `pfpj_iban`, 
    
DROP `pfpj_cnp`,
    
DROP `pfpj_serienr_buletin`,
    
DROP `pfpj_for_billing`,
    
DROP `pfpj_for_shipping`;
Engine-ul la db este InnoDb,
asa ca vor fi sterse si celelalte inregistrari din tabele relationate cu foreign key (folosite de extensie).

In caz ca extensia a instalat si judetele Romaniei si se vor si ele a fi sterse,
puteti gasi inregistrarile in tabelele:

`directory_country_region`
`
directory_country_region_name`

In caz ca va razganditi si doriti sa reinstalati pe viitor extensia:

DELETE FROM `core_resourceWHERE `core_resource`.`code` = 'checkoutrom_setup' LIMIT 1;
DELETE FROM `core_resourceWHERE `core_resource`.`code` = 'customerrom_setup' LIMIT 1;
DELETE FROM `core_resourceWHERE `core_resource`.`code` = 'directoryrom_setup' LIMIT 1;
DELETE FROM `core_resourceWHERE `core_resource`.`code` = 'romanianregions_setup' LIMIT 1;
DELETE FROM `core_resourceWHERE `core_resource`.`code` = 'salesrom_setup' LIMIT 1;
Toate modulele sunt pastrate in `core_resource` impreuna cu versiunea lor.Se pastreaza un fel de versioning la versiunea deja instalata odata. Asa nu apar inregistrari duplicate in tabele la reinstall.

Toate insert-urile de la instalarea extensiei sunt generate in app/code/community/PfpjRom/NumeModulRom/sql/.../mysql4-install(sau upgrade)-*.php

Tin sa mentionez ca extensia functioneaza bine pe Magento 1.3.2.4 (ultima versiune de 1.3.x).

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
    Back to top
Page 2 of 3