Hi,
I have a form in a modal window and use
<cms:if k_success >
<cms:redirect "<cms:show k_page_link />" />
</cms:if>
Somehow on submitting the form I have to reload the page again to have the new data available. Is my code correct ?
The form :
The page :
Thanks
I have a form in a modal window and use
<cms:if k_success >
<cms:redirect "<cms:show k_page_link />" />
</cms:if>
Somehow on submitting the form I have to reload the page again to have the new data available. Is my code correct ?
The form :
- Code: Select all
<div id="nworderline" class="reveal-modal" data-reveal aria-hidden="true" role="dialog">
<!-- start form -->
<cms:form
masterpage='sales-transactions.php'
mode='create'
enctype='multipart/form-data'
method='post'
anchor='0'
>
<cms:set my_action="create_page_k_template_id"/>
<cms:if k_success >
<cms:validate_nonce my_action />
<cms:set line_price = "<cms:show frm_price/>"/>
<cms:set line_amount = "<cms:show frm_amount/>"/>
<cms:set total_price = "<cms:mul line_price line_amount/>"/>
<cms:db_persist_form
_invalidate_cache='0'
k_page_title="<cms:show sa/><cms:show sa_no/>-<cms:show frm_item/>"
invoice_no="<cms:show sa_no/>"
total="<cms:show total_price/>"
invoice="<cms:show k_page_id/>"
/>
<cms:redirect "<cms:show k_page_link />" />
<!-- Delete this <cms:redirect "<cms:link k_page_link />" />
<cms:redirect "<cms:login_link />" />
FIXME: @reload [how to] try to solve refresh page only the first time page shows new line direct
<script>parent.location.reload(true)</script> -->
</cms:if>
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">Description</span>
</div>
<div class="small-9 large-10 columns">
<cms:input type="bound" name="item" placeholder="Like: Russell t-shirts blue size M" />
</div>
</div>
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">Amount</span>
</div>
<div class="small-9 large-10 columns">
<cms:input type="bound" name="amount" placeholder="Like: 5000" />
</div>
</div>
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">Price</span>
</div>
<div class="small-9 large-10 columns">
<cms:input type="bound" name="price" placeholder="Like: 5" />
</div>
</div>
<cms:if (my_user_team=='Accounting') || (my_user_team=='Management') >
<div class="row collapse">
<div class="small-3 large-2 columns">
<span class="prefix">VAT</span>
</div>
<div class="small-9 large-10 columns">
<cms:input type="bound" name="vat" placeholder="24" />
</div>
</div>
<br/>
</cms:if>
<cms:input name='nonce' type='hidden' value="<cms:create_nonce my_action />" />
<input type="submit" name="submit" class="button small" value="Submit"/>
</cms:form>
<a class="close-reveal-modal">×</a>
</div>
The page :
- Code: Select all
<?php require_once( 'couch/cms.php' );
/**
* Page template crm project.
* CRM Based on [CouchCMS](http://www.couchcms.com/)
*/
?>
<!-- TODO: @Print [as PDF or send Mail] for Quote and Invoices -->
<cms:template title='Sales' clonable='1' commentable='1' dynamic_folders='1'>
<cms:editable name='system' label='System' type='group' order='1'/>
<cms:editable name='sa' label='Prefix' type='text' required='1' group='system'>SA-</cms:editable>
<cms:editable name='sa_no' label='Sales Number' type='text' validator='non_negative_integer' search_type='integer' required='1' group='system'></cms:editable>
<cms:editable name='owner' label='Owner' type='text' required='1' group='system' search_type='integer' ></cms:editable>
<cms:editable type='relation' name='company' masterpage='companies.php' has='one' />
<cms:editable name='info' label='Order info' type='group' order='3'/>
<cms:editable name='order_note' label='Extra info' type='richtext' group='info'></cms:editable>
<cms:editable name='terms' label='Terms' type='group' order='3'/>
<cms:editable name="payment" label="Payment Terms" desc="Select one from these"
opt_values='prepay=0 | 7 days=7 | 30 days=30'
opt_selected = '7 days'
type='dropdown'
search_type='integer'
required='1'
group='terms'
/>
<cms:editable name='note' label='Note' type='textarea' group='terms'></cms:editable>
<cms:editable name='due_date' label='Date due' type='text'></cms:editable>
<cms:editable name='invoice_date' label='Invoice date' type='text'></cms:editable>
<cms:editable name='invoice_number' label='Invoice Number' type='text' search_type='integer'></cms:editable>
</cms:template>
<!DOCTYPE html>
<html>
<head>
<cms:embed 'head.html'/>
</head>
<cms:embed 'topbar.html'/>
<body>
<cms:embed 'banner.html'/>
<div class="row"> <!-- main row -->
<div class="large-12 columns">
<div class="space"></div>
<cms:if k_logged_in && (my_user_team=='Sales') || (my_user_team=='Management') >
<cms:set cur_status = "<cms:show sa/>" 'global' />
<!-- cur_status is used to for checking status invoice or quote -->
<!-- NOTE: @cookie [set for edit_order.php] see cheesypoof solution -->
<cms:set_cookie name='linked_page' value=k_page_link expire='0'/>
<cms:if k_is_home >
<cms:embed 'list-view/sales-list.html'/>
</cms:if>
<cms:if k_is_page >
<cms:embed 'page-view/sales-order.html'/>
</cms:if>
<cms:dump />
<cms:else />
<div class="panel callout">You should be logged in to view this page !</div>
</cms:if>
</div><!-- end large-12 columns -->
</div> <!-- end main row -->
<cms:embed 'footer.html' />
</body>
</html>
<?php COUCH::invoke(); ?>
- Code: Select all
<div class="row">
<div class="small-12 medium-12 large-4 columns">
<cms:set cur_date="<cms:date format='Y-m-d H:i:s'/>" 'global'/>
<cms:set alert_date="<cms:date due_date format='Y-m-d H:i:s'/>" 'global'/>
<cms:if (alert_date lt cur_date) && (cur_status=='In')>
<p class='panel-red'>Invoice overdue since: <cms:date due_date format='d-m-Y'/><p>
</cms:if>
</div>
<div class="small-12 medium-12 large-4 columns">
<p><small>Date Posted: <cms:date k_page_date format='d-m-Y'/></small></p>
</div>
</div>
<fieldset>
<legend><cms:if k_page_foldername='quote'>Quote: <cms:show sa/><cms:show sa_no/><cms:else/>Invoice: <cms:show sa/><cms:show invoice_number/></cms:if></legend>
<br/>
<cms:related_pages 'company' masterpage='companies.php' > <!-- All variables of 'companies.php' are available here -->
<div class="small-12 medium-4 large-4 columns">
<h5 class="l-title"><a href="<cms:show k_page_link/>"><cms:show k_page_title /></a></h5>
<p><cms:show company_street /> <cms:show company_streetno /><br/><cms:show company_town /> <cms:show company_postcode /><br/><cms:show company_country /> </p>
</div>
</cms:related_pages>
<hr/>
<table width="100%">
<tr>
<th>Description</th>
<th style="text-align:right">Amount</th>
<th style="text-align:right">Price</th>
<th style="text-align:right">Total</th>
<th>VAT</th>
<cms:if k_page_foldername='quote'>
<th></th>
<th></th>
</cms:if>
</tr>
<cms:set total_price_count='0' scope='global' />
<cms:set total_vat_count='0' scope='global' />
<cms:pages masterpage='sales-transactions.php' limit='50' paginate='1' custom_field="invoice_no==<cms:show sa_no/>" order='asc'>
<tr>
<td><cms:show item /></td>
<td style="text-align:right"><cms:show amount /></td>
<td style="text-align:right"><cms:show price /></td>
<td style="text-align:right">
<cms:embed 'blocks/calc-totalPrice-orderline.html'/>
</td>
<!-- calculate invoice total -->
<cms:set invoice_line-price = "<cms:show total_price/>"/><cms:set total_price_count="<cms:add total_price_count invoice_line-price />" scope='global' />
<cms:set invoice_line-vat = "<cms:show total_vat_price/>"/><cms:set total_vat_count="<cms:add total_vat_count invoice_line-vat />" scope='global' />
<!-- calculate invoice total -->
<td><cms:show vat />%</td>
<td><i class="fi-page-edit alert"></i></td>
<td><i class="fi-trash alert"></i></td>
</tr>
</cms:pages>
</table>
<!-- here total ordercalc -->
<div align="right">
<table>
<td>Total ex VAT: <cms:number_format total_price_count decimal_precision='2' decimal_character=',' thousands_separator='.'/></td>
<td>VAT
<cms:set total_ex_vat = "<cms:show total_price_count/>" />
<cms:set total_incl_vat = "<cms:show total_vat_count/>" />
<cms:set vat_calc="<cms:sub total_incl_vat total_ex_vat />" scope='global' /><cms:number_format vat_calc decimal_precision='2' decimal_character=',' thousands_separator='.'/>
</td>
<td><b>Total <cms:number_format total_vat_count decimal_precision='2' decimal_character=',' thousands_separator='.'/> €<b/></td>
</table>
<p align="right"><small>Payment Terms: <cms:show payment/> Days</small></p>
<cms:set payday="<cms:show payment/>" 'global' search_type='integer'/><!-- for invoice date settings -->
</div>
<!-- end here total ordercalc -->
<cms:if k_page_foldername='quote'>
<p class='button tiny success' data-reveal-id="nworderline" data-reveal-ajax="true">Add Row</p>
</cms:if>
</fieldset>
<cms:embed 'forms/nworderline.html' />
Thanks