Hello. I have the next situation: i have the list of services (modResource) and the users (modUser) can put their prices for any service. For this i've created a new package (prices) with migxdb, here is the schema:
<?xml version="1.0" encoding="UTF-8"?>
<model package="prices" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
<object class="Price" table="prices" extends="xPDOSimpleObject">
<field key="user" dbtype="int" precision="4" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="service" dbtype="int" precision="4" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="from" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<field key="to" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
<aggregate alias="User" class="modUser" local="user" foreign="id" cardinality="one" owner="foreign" />
<aggregate alias="Service" class="modResource" local="service" foreign="id" cardinality="one" owner="foreign" />
</object>
</model>
to make the relation from Users to Prices i made a little trick - i've put this code
$this->map['modUser']['composites']['Prices'] = array(
'class' => 'Price',
'local' => 'id',
'foreign' => 'user',
'cardinality' => 'many',
'owner' => 'local',
);
in the end of core/components/prices/model/prices/metadata.mysql.php file. I've made like this because i don't what to lost this part in the case of modx update.
Now the task is to make a cmp in order to moderate the prices. For this i have two migxdb configurations. First one is getting the list of users:
{
"formtabs":[
{
"MIGX_id":7,
"caption":"\u0426\u0435\u043d\u044b",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":20,
"field":"Prices",
"caption":"\u0426\u0435\u043d\u044b",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"migxdb",
"validation":"",
"configs":"prices",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
}
],
"pos":1
}
],
"contextmenus":"update",
"actionbuttons":"",
"columnbuttons":"update",
"filters":"",
"extended":{
"migx_add":"",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"",
"update_win_title":"",
"win_id":"user_prices",
"maxRecords":"",
"addNewItemAt":"bottom",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"modx",
"classname":"modUser",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"sortconfig":"",
"gridpagesize":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":1,
"check_resid":1,
"check_resid_TV":"",
"join_alias":"Prices",
"has_jointable":"yes",
"getlistwhere":"",
"joins":[
{
"alias":"Prices"
}
],
"hooksnippets":"",
"cmpmaincaption":"",
"cmptabcaption":"",
"cmptabdescription":"",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":1,
"header":"Username",
"dataIndex":"username",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":2,
"header":"\u0426\u0435\u043d\u044b",
"dataIndex":"Prices",
"width":"",
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
]
}
When i click the edit button for each user the second one show up with the list of prices
{
"formtabs":[
{
"MIGX_id":6,
"caption":"\u0426\u0435\u043d\u0430",
"print_before_tabs":"0",
"fields":[
{
"MIGX_id":16,
"field":"user",
"caption":"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c",
"description":"",
"description_is_code":"0",
"inputTV":"price_user",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":1
},
{
"MIGX_id":17,
"field":"service",
"caption":"\u0423\u0441\u043b\u0443\u0433\u0430",
"description":"",
"description_is_code":"0",
"inputTV":"price_service",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":2
},
{
"MIGX_id":18,
"field":"from",
"caption":"\u0426\u0435\u043d\u0430 \u043e\u0442 ...",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":3
},
{
"MIGX_id":19,
"field":"to",
"caption":"\u0426\u0435\u043d\u0430 \u0434\u043e ...",
"description":"",
"description_is_code":"0",
"inputTV":"",
"inputTVtype":"",
"validation":"",
"configs":"",
"restrictive_condition":"",
"display":"",
"sourceFrom":"config",
"sources":"",
"inputOptionValues":"",
"default":"",
"useDefaultIfEmpty":"0",
"pos":4
}
],
"pos":1
}
],
"contextmenus":"update||remove",
"actionbuttons":"addItem",
"columnbuttons":"update||remove",
"filters":"",
"extended":{
"migx_add":"",
"disable_add_item":"",
"add_items_directly":"",
"formcaption":"",
"update_win_title":"",
"win_id":"prices",
"maxRecords":"",
"addNewItemAt":"bottom",
"multiple_formtabs":"",
"multiple_formtabs_label":"",
"multiple_formtabs_field":"",
"multiple_formtabs_optionstext":"",
"multiple_formtabs_optionsvalue":"",
"actionbuttonsperrow":4,
"winbuttonslist":"",
"extrahandlers":"",
"filtersperrow":4,
"packageName":"prices",
"classname":"Price",
"task":"",
"getlistsort":"",
"getlistsortdir":"",
"sortconfig":"",
"gridpagesize":"",
"use_custom_prefix":"0",
"prefix":"",
"grid":"",
"gridload_mode":1,
"check_resid":"0",
"check_resid_TV":"",
"join_alias":"",
"has_jointable":"yes",
"getlistwhere":"",
"joins":"",
"hooksnippets":{
"beforesave":"beforeSavePriceHook"
},
"cmpmaincaption":"\u0426\u0435\u043d\u044b",
"cmptabcaption":"\u0426\u0435\u043d\u044b",
"cmptabdescription":"\u0426\u0435\u043d\u044b",
"cmptabcontroller":"",
"winbuttons":"",
"onsubmitsuccess":"",
"submitparams":""
},
"columns":[
{
"MIGX_id":5,
"header":"ID",
"dataIndex":"id",
"width":50,
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":1,
"header":"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c",
"dataIndex":"user",
"width":200,
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderChunk",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"[[!UserInfo? &id=`[[+user]]` &field=`username`]]",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":2,
"header":"\u0423\u0441\u043b\u0443\u0433\u0430",
"dataIndex":"service",
"width":400,
"sortable":true,
"show_in_grid":1,
"customrenderer":"",
"renderer":"this.renderChunk",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"[[#[[+service]].pagetitle]]",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":3,
"header":"\u0426\u0435\u043d\u0430 \u043e\u0442 ...",
"dataIndex":"from",
"width":150,
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
},
{
"MIGX_id":4,
"header":"\u0426\u0435\u043d\u0430 \u0434\u043e ...",
"dataIndex":"to",
"width":150,
"sortable":"false",
"show_in_grid":1,
"customrenderer":"",
"renderer":"",
"clickaction":"",
"selectorconfig":"",
"renderchunktpl":"",
"renderoptions":"",
"editor":""
}
]
}
The problem is that this list of prices is not related to the user i choose and i can see all users and all prices. How to show the prices only for user i choose?
Thanks in advance.