<?xml version="1.0" encoding="UTF-8"?> <model package="memberdata" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" tablePrefix="mp_" phpdoc-package="memberdata" phpdoc-subpackage="model" version="1.1"> <object class="extUser" extends="modUser"> <composite alias="Data" local="id" class="membersProfiles" foreign="FK_user_id" cardinality="one" owner="local" /> </object> <object class="states" table="states" extends="xPDOSimpleObject"> <field key="id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" /> <field key="stateName" dbtype="varchar" precision="50" phptype="string" null="true" /> <field key="stateAbbreviation" dbtype="varchar" precision="2" phptype="string" null="true" /> <field key="stateISO" dbtype="varchar" precision="8" phptype="string" null="true" /> <composite alias="Members" local="id" class="memberProfiles" foreign="FK_state_id" cardinality="many" owner="local" /> <composite alias="Companies" local="id" class="companyProfiles" foreign="FK_state_id" cardinality="many" owner="local" /> <composite alias="Locations" local="id" class="companyLocations" foreign="FK_state_id" cardinality="many" owner="local" /> </object> <object class="markets" table="markets" extends="xPDOSimpleObject"> <field key="id" dbtype="int" precision="10" phptype="integer" null="false" index="pk" generated="native" /> <field key="FK_member_id" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="FK_companyprofile_id" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="FK_companycontact_id" dbtype="int" precision="10" phptype="integer" null="true" /> <field key="marketName" dbtype="varchar" precision="255" phptype="string" null="true" default="" /> <field key="category" dbtype="varchar" precision="255" phptype="string" null="true" default="" /> <field key="marketDescription" dbtype="text" phptype="string" null="true" /> <field key="minLimit" dbtype="int" precision="50" phptype="integer" null="true" /> <field key="maxLimit" dbtype="int" precision="50" phptype="integer" null="true" /> <field key="onlineQuoteURL" dbtype="varchar" precision="255" phptype="string" null="true" default="" /> <field key="admittedMarket" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="nonadmittedMarket" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="underwriteAuth" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="carrier" dbtype="varchar" precision="255" phptype="string" null="true" default="" /> <field key="appointment" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="underwriteAuth" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="tags" dbtype="text" phptype="string" null="true" /> <field key="statesAvail" dbtype="text" phptype="string" null="true" /> <field key="marketFiles" dbtype="text" phptype="string" null="true" /> <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /> <field key="createdon" dbtype="datetime" phptype="datetime" null="true" /> <aggregate alias="memberMarkets" local="FK_member_id" foreign="id" cardinality="one" owner="foreign" /> <aggregate alias="companyMarkets" local="FK_companyprofile_id" foreign="id" cardinality="one" owner="foreign" /> <aggregate alias="contactMarkets" local="FK_companycontact_id" foreign="id" cardinality="one" owner="foreign" /> </object> </model>
<?php $path = MODX_CORE_PATH . 'components/memberdata/'; $result = $modx->addPackage('memberdata',$path.'model/','mp_'); $output = ''; $states = $modx->getCollection('states'); foreach ($states as $state){ if(isset($state)) { $stateid = $state->get('id'); $statename = $state->get('stateName'); $stateabbreviation = $state->get('stateAbbreviation'); $stateiso = $state->get('stateISO'); } if(isset($state)){ $output.= '<li><input name="statesAvail[]" type="checkbox" class="selectedId" [[!+fi.statesAvail:FormItIsChecked=`' . $stateid . '`]] value="' . $stateid . '" />' . $statename . '</li>'; }} return $output;
[[!FormIt? &hooks=`spam,checkCompanyCreated,formit2fileMarketFiles,formit2db` &preHooks=`db2formit` &prefix=`mp_` &packagename=`memberdata` &tablename=`markets` &classname=`markets` &path = `assets/documents/marketfiles/` &extensions = `pdf,PDF` &maxsize = `20971520` &arrayFormat=`csv` &arrayFields = `["statesAvail"]` &validate=`marketDescription:allowTags` ]] <form class="full_contact_form" action="[[~[[*id]]]]" method="post" enctype="multipart/form-data"> <input name="nospam" type="hidden" /> <input name="FK_member_id" type="hidden" value="[[+modx.user.id]]" /> <input name="FK_companyprofile_id" type="hidden" value="[[!getCompanyID]]" /> <div class="form_row clearfix"> <label for="marketName"> <span class="hm_field_name">Market Name</span> <span class="hm_requires_star">*</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Enter a descriptive name for your new market. Please be sure that it's descriptive and utilizes keywords for our search feature. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="text" name="marketName" id="marketName" value="[[+fi.marketName]]" /> <span class="hm_requires_star">[[!+fi.error.marketName]]</span> </div> <div class="form_row clearfix"> <label for="marketDescription"> <span class="hm_field_name">Market Description</span> <span class="hm_requires_star">*</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Use this area to describe your market. Provide details about what's offered with the new market. Limited HTML formatting is available for this field. </span> </span> </label> <textarea class="form_fill_fields hm_input_text" name="marketDescription" value="[[+fi.marketDescription]]" id="marketDescription"></textarea> </div> <div class="form_row clearfix"> <div class="my_col_half"> <label for="minLimit"> <span class="hm_field_name">Minimum Premium</span> <span class="hm_requires_star">*</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Please enter the minimum premium amount for this market. This will be utilized in the advanced search options to narrow markets. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="text" name="minLimit" id="minLimit" value="[[+fi.minLimit]]" /> <span class="hm_requires_star">[[+fi.error.minLimit]]</span> </div> <div class="my_col_half"> <label for="maxLimit"> <span class="hm_field_name">Maximum Premium</span> <span class="hm_requires_star">*</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Please enter the maximum premium amount for this market. This will be utilized in the advanced search options to narrow markets. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="text" name="maxLimit" id="maxLimit" value="[[+fi.maxLimit]]" /> <span class="hm_requires_star">[[+fi.error.maxLimit]]</span> </div> </div> <div class="form_row clearfix"> <input type="hidden" name="admittedMarket[]" value="0" /> <input type="checkbox" name="admittedMarket[]" value="1" [[!+fi.admittedMarket:FormItIsChecked=`1`]] > Admitted Market <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Check only if an admitted market is available. </span> </span> <span class="hm_requires_star">[[+fi.error.admittedMarket]]</span> <input type="hidden" name="nonadmittedMarket[]" value="0" /> <input type="checkbox" name="nonadmittedMarket[]" value="1" [[!+fi.nonadmittedMarket:FormItIsChecked=`1`]] > Non-Admitted Market <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Check only if a non-admitted market is available. </span> </span> <span class="hm_requires_star">[[+fi.error.nonadmittedMarket]]</span> <input type="hidden" name="underwriteAuth[]" value="0" /> <input type="checkbox" name="underwriteAuth[]" value="1" [[!+fi.underwriteAuth:FormItIsChecked=`1`]] > Underwriting Authority <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Check only if you have underwriting authority for this market. </span> </span> <span class="hm_requires_star">[[+fi.error.underwriteAuth]]</span> <input type="hidden" name="appointment[]" value="0" /> <input type="checkbox" name="appointment[]" value="1" [[!+fi.appointment:FormItIsChecked=`1`]] > Appointment Required <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Check if appointment is required in order to submit, quote and/or bind for this market. </span> </span> <span class="hm_requires_star">[[+fi.error.appointment]]</span> </div> <div class="form_row clearfix"> <div class="my_col_third"> <label for="onlineQuoteURL"> <span class="hm_field_name">Online Quote URL</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>If online quoting is available provide the URL for the only quoting site. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="text" name="onlineQuoteURL" id="onlineQuoteURL" value="[[+fi.onlineQuoteURL]]" /> <span class="hm_requires_star">[[+fi.error.onlineQuoteURL]]</span> </div> <div class="my_col_third"> <label for="carrier"> <span class="hm_field_name">Carrier</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>If you would like to disclose the carrier for this market enter the name of the carrier. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="text" name="carrier" id="carrier" value="[[+fi.carrier]]" /> <span class="hm_requires_star">[[+fi.error.carrier]]</span> </div> <div class="my_col_third"> <label for="FK_companycontact_id"><span class="hm_field_name">Company Contact</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Please select a contact for this market from the dropdown. If there is no carrier selected there will be no direct contact listed for the market other than general company contact information. </span> </span></label> <select name="FK_companycontact_id" value="[[!+fi.FK_companycontact_id]]"> <option value="[[!+fi.FK_gender_id:FormItIsSelected=`[[!getUserID]]`]]">Select a contact...</option> [[!companyContactFormValues]] </select> </div> </div> <div class="form_row clearfix"> <label for="tags"> <span class="hm_field_name">Keywords</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Enter keywords for this market. Each keyword should be separated by a comma (,). Keep in mind these are descriptive keywords used in the search system. Examples might include: Workers' Compensation, General Liability, Flood, etc. </span> </span> </label> <input type="text" data-role="tagsinput" class="form_fill_fields hm_input_text" name="tags" value="[[+fi.tags]]" id="tags"/><span class="validation-message">Enter keyword tags separated by commas.</span> </div> <div class="form_row clearfix colList"> <label for="states"> <span class="hm_field_name">States & Territories</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Select all states and territories where this market is available. Note that by selecting all you are including Washington D.C., Puerto Rico and the Virgin Islands. </span> </span> </label> <ul class="selectallOption"> <li><input type="checkbox" id="selectall"><span style="color:green;">Select all </span></input> <span class="validation-message"> (Tick checkbox to select all states, uncheck to deselect all.)</span><li/> </ul> <ul id="quad" class="colList"> <input name="statesAvail[]" type="hidden" /> [[!stateFormValues]] </ul> </div> <div class=form_row clearfix"> <div class="my_col_half"> <label for="marketFiles"> <span class="hm_field_name">File</span> <span class="hm_tooltip1 tooltip-effect1-1"> <span class="hm_tooltip-item1">(?)</span> <span class="hm_tooltip-content1 clearfix"> <span class="hm_tooltip-text1"> <i class="ico-help" style="padding-left:10px;"> </i>Upload any marketing material you have related to this market in PDF format. </span> </span> </label> <input class="form_fill_fields hm_input_text" type="file" name="marketFiles" id="marketFiles" value="[[+fi.marketFiles]]" /> <span class="error">[[+fi.error.marketFiles]]</span> </div> <div class="my_col_half"> </div> </div> <div class="form_row clearfix"> <button type="submit" name="submit" id="submit" class="send_button large_btn" value="save"> <i class="ico-check3"></i> <span>Add Market</span> </button> </div> </form>
&arrayFormat=`csv` &arrayFields = `["statesAvail"]`
<?php $path = MODX_CORE_PATH . 'components/memberdata/'; $result = $modx->addPackage('memberdata',$path.'model/','mp_'); $output = ''; $markets = $modx->getCollection('markets'); foreach ($markets as $market){ if(isset($market)) { $marketName = $market->get('marketName'); $marketDesc = $market->get('marketDescription'); $states = $market->get('statesAvail'); } if(isset($market)){ $output.= '<p> Market Name:' . $marketName . '<br/>'; $output.= 'Market Desc:' . $marketDesc . '<br/>'; $output.= 'States:' . $states . '</p>'; }} return $output;
This question has been answered by BobRay. See the first response.
foreach ($markets as $market){ $marketName = $market->get('marketName'); $marketDesc = $market->get('marketDescription'); $states = $market->get('statesAvail'); $states = explode(',', $states); $stateNames = array(); foreach($states as $state) { $stateObj = $modx->getObject('States', $state); $stateNames[] = $stateObj->get('stateName'); } $output.= '<p> Market Name:' . $marketName . '<br/>'; $output.= 'Market Desc:' . $marketDesc . '<br/>'; $output.= 'States:' . implode(', ', $stateNames) . '</p>'; }
<?php $path = MODX_CORE_PATH . 'components/memberdata/'; $result = $modx->addPackage('memberdata',$path.'model/','mp_'); $output = ''; $markets = $modx->getCollection('markets'); foreach ($markets as $market){ $marketName = $market->get('marketName'); $marketDesc = $market->get('marketDescription'); $states = $market->get('statesAvail'); $states = explode(',', $states); $stateNames = array(); foreach($states as $state) { $stateObj = $modx->getObject('states',$state); $stateNames[] = $stateObj->get('stateName'); } $output.= '<p> Market Name:' . $marketName . '<br/>'; $output.= 'Market Desc:' . $marketDesc . '<br/>'; $output.= 'States:' . implode(', ', $stateNames) . '</p>'; }
$stateObj = $modx->getObject('States',$state);
<?php $path = MODX_CORE_PATH . 'components/memberdata/'; $result = $modx->addPackage('memberdata',$path.'model/','mp_'); $output = ''; $markets = $modx->getCollection('markets'); foreach ($markets as $market){ $marketName = $market->get('marketName'); $marketDesc = $market->get('marketDescription'); $states = $market->get('statesAvail'); $modx->log(modX::LOG_LEVEL_ERROR, 'Loading Markets'); $states = explode(',', $states); $stateNames = array(); foreach($states as $state) { $stateObj = $modx->getObject('states',$state); $stateNames[] = $stateObj->get('stateName'); $modx->log(modX::LOG_LEVEL_ERROR, 'Loading States'); } $output.= '<p> Market Name:' . $marketName . '<br/>'; $output.= 'Market Desc:' . $marketDesc . '<br/>'; $output.= 'States:' . implode(', ', $stateNames) . '</p>'; }
[2015-06-19 05:15:43] (ERROR @ /index.php) Loading Markets [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading Markets [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States [2015-06-19 05:15:44] (ERROR @ /index.php) Loading States
return $output;