Changed jquery.get to jquery.ajax to solve caching issue in documents

This commit is contained in:
Karl Cordes 2011-06-28 14:30:41 +10:00
parent b1ca8b4524
commit 05cadcf644
4 changed files with 108 additions and 114 deletions

View file

@ -61,7 +61,6 @@ $class = ' class="altrow"';?>
<?php echo $enquiry['Enquiry']['comments']; ?> <?php echo $enquiry['Enquiry']['comments']; ?>
</span> </span>
&nbsp; &nbsp;
</dd> </dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Billing Address'); ?></dt> <dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Billing Address'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>> <dd<?php if ($i++ % 2 == 0) echo $class;?>>

View file

@ -1,48 +1,42 @@
<?php <?php /* Quotenik 1.2 - Default Layout. Some Markup retained from CakePHP Default
/* Quotenik 1.2 - Default Layout. Some Markup retained from CakePHP Default */ ?>
*/?>
<!DOCTYPE html> <!DOCTYPE html>
<html> <html>
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title> <title>
<?php __('CMC'); ?> <?php __('CMC'); ?>
<?php echo $title_for_layout; ?> <?php echo $title_for_layout; ?>
</title> </title>
<?php <?php
$debugLevel = Configure::read('debug'); $debugLevel = Configure::read('debug');
if($debugLevel > 0) { if ($debugLevel > 0) {
echo $html->meta('favicon.ico','/img/core.png', array('type'=>'icon')); echo $html->meta('favicon.ico', '/img/core.png', array('type' => 'icon'));
} } else {
else {
echo $html->meta('icon'); echo $html->meta('icon');
} }
echo $html->css('quotenik'); echo $html->css('quotenik');
echo $html->css('jquery-ui.custom.css'); echo $html->css('jquery-ui.custom.css');
//echo $javascript->link('ckeditor/ckeditor'); //echo $javascript->link('ckeditor/ckeditor');
echo $javascript->link('jquery'); echo $javascript->link('jquery');
echo $javascript->link('jquery-ui'); echo $javascript->link('jquery-ui');
echo $javascript->link('jquery.form'); echo $javascript->link('jquery.form');
echo $javascript->link('menu'); echo $javascript->link('menu');
echo $javascript->link('global'); echo $javascript->link('global');
echo $javascript->link('search'); echo $javascript->link('search');
echo $javascript->link('jquery.jeditable.mini'); echo $javascript->link('jquery.jeditable.mini');
//echo $javascript->link('ckeditor/adapters/jquery'); //echo $javascript->link('ckeditor/adapters/jquery');
echo $scripts_for_layout; echo $scripts_for_layout;
?>
?>
</head> </head>
@ -54,47 +48,46 @@
<div id="username"> <div id="username">
<?php <?php
if(isset($currentuser) == FALSE) { if (isset($currentuser) == FALSE) {
echo $html->link('Login', '/users/login'); echo $html->link('Login', '/users/login');
} } else {
else { $logoutlink = $html->link('Logout', '/users/logout');
$logoutlink = $html->link('Logout', '/users/logout'); echo $html->link($currentuser['User']['username'], '/users/view/' . $currentuser['User']['id']) . ' (' . $logoutlink . ')';
echo $html->link($currentuser['User']['username'], '/users/view/'. $currentuser['User']['id']). ' (' . $logoutlink.')'; }
} ?>
?>
</div> </div>
<div id="navdiv"> <div id="navdiv">
<ul id="nav"> <ul id="nav">
<li><?php echo $html->link('Enquiries', '/enquiries/index'); ?> <li><?php echo $html->link('Enquiries', '/enquiries/index'); ?>
<ul> <ul>
<li class="last"><?php echo $html->link('Enquiry Register', '/enquiries/index'); ?></li> <li class="last"><?php echo $html->link('Enquiry Register', '/enquiries/index'); ?></li>
</ul> </ul>
</li> </li>
<li><?php echo $html->link('Jobs', '/jobs/index'); ?> <li><?php echo $html->link('Jobs', '/jobs/index'); ?>
<ul> <ul>
<? <?
if($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin' ): if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['access_level'] == 'admin'):
?> ?>
<li><?=$html->link('Reports','/jobs/reports');?></li> <li><?= $html->link('Reports', '/jobs/reports'); ?></li>
<? endif;?> <? endif; ?>
<li class="last"><?php echo $html->link('Job List', '/jobs/index'); ?></li> <li class="last"><?php echo $html->link('Job List', '/jobs/index'); ?></li>
</ul> </ul>
</li> </li>
<li><?php echo $html->link('Shipments','/shipments/index');?> <li><?php echo $html->link('Shipments', '/shipments/index'); ?>
<ul> <ul>
<li class=""><?php echo $html->link('All Shipments', '/shipments/index');?></li> <li class=""><?php echo $html->link('All Shipments', '/shipments/index'); ?></li>
<li class=""><?php echo $html->link('Import Shipments', '/shipments/index/import');?></li> <li class=""><?php echo $html->link('Import Shipments', '/shipments/index/import'); ?></li>
<li class=""><?php echo $html->link('Direct Shipments', '/shipments/index/direct');?></li> <li class=""><?php echo $html->link('Direct Shipments', '/shipments/index/direct'); ?></li>
<li class=""><?php echo $html->link('Export Shipments', '/shipments/index/export');?></li> <li class=""><?php echo $html->link('Export Shipments', '/shipments/index/export'); ?></li>
<li class="last"><?php echo $html->link('Local Shipments', '/shipments/index/local');?></li> <li class="last"><?php echo $html->link('Local Shipments', '/shipments/index/local'); ?></li>
</ul> </ul>
</li> </li>
<li><?php echo $html->link('Customers', '/customers/index'); ?> <li><?php echo $html->link('Customers', '/customers/index'); ?>
<ul> <ul>
@ -115,7 +108,7 @@
<li><?php echo $html->link('Invoices', '/invoices/index'); ?> <li><?php echo $html->link('Invoices', '/invoices/index'); ?>
<ul> <ul>
<li class=""><?php echo $html->link('Invoices Index', '/invoices/index'); ?></li> <li class=""><?php echo $html->link('Invoices Index', '/invoices/index'); ?></li>
<li class="last"><?php echo $html->link('Print View', '/invoices/printView'); ?></li> <li class="last"><?php echo $html->link('Print View', '/invoices/printView'); ?></li>
</ul> </ul>
</li> </li>
@ -134,15 +127,14 @@
</ul> </ul>
</li> </li>
<?php /*<li> echo $html->link('Users', '/users/index'); ?> <?php /* <li> echo $html->link('Users', '/users/index'); ?>
<ul> <ul>
<li> echo $html->link('Users Index', '/users/index'); </li> <li> echo $html->link('Users Index', '/users/index'); </li>
<li class="last"><?php echo $html->link('Add User', '/users/add'); </li> <li class="last"><?php echo $html->link('Add User', '/users/add'); </li>
</ul> </ul>
</li>*/ </li> */ ?>
?>
<li><?php echo $html->link('Search', '/enquiries/search', array('id'=>'searchLink')); ?> <li><?php echo $html->link('Search', '/enquiries/search', array('id' => 'searchLink')); ?>
</li> </li>
<li><?php echo $html->link('Help', '/pages/help'); ?> <li><?php echo $html->link('Help', '/pages/help'); ?>
<ul> <ul>
@ -157,22 +149,21 @@
</div> </div>
<div id="content"> <div id="content">
<?php <?php
if ($session->check('Message.flash')): if ($session->check('Message.flash')):
$session->flash(); $session->flash();
endif; endif;
?> ?>
<div id="globalAjaxLoading"><?php echo $html->image('ajax-loader.gif'); ?></div> <div id="globalAjaxLoading"><?php echo $html->image('ajax-loader.gif'); ?></div>
<?php echo $content_for_layout; ?> <?php echo $content_for_layout; ?>
</div> </div>
<div id="footer"> <div id="footer">
<?php echo $html->link( <?php
$html->image('cake.power.gif', array('alt'=> __("CakePHP: the rapid development php framework", true), 'border'=>"0")), echo $html->link(
'http://www.cakephp.org/', $html->image('cake.power.gif', array('alt' => __("CakePHP: the rapid development php framework", true), 'border' => "0")), 'http://www.cakephp.org/', array('target' => '_new'), null, false
array('target'=>'_new'), null, false );
); ?>
?>
</div> </div>
</div> </div>
@ -180,50 +171,48 @@
<?php <?php
echo $form->create('Enquiry', array('default'=>false, 'id'=>'searchForm', 'default'=>'false')); echo $form->create('Enquiry', array('default' => false, 'id' => 'searchForm', 'default' => 'false'));
echo '<h2>Search'; echo '<h2>Search';
echo $html->image('system-search.png'); echo $html->image('system-search.png');
echo '</h2>'; echo '</h2>';
echo "<p>Search for: Enquiry Number, Job Number, Customer, Contact or Customer Order Number</p>"; echo "<p>Search for: Enquiry Number, Job Number, Customer, Contact or Customer Order Number</p>";
echo $form->input('Enquiry.search_string', array('label'=>false, 'id'=>'searchString')); echo $form->input('Enquiry.search_string', array('label' => false, 'id' => 'searchString'));
?>
?>
<div class ="ui-widget"> <div class ="ui-widget">
<button id="searchButton">Search</button> <button id="searchButton">Search</button>
</div> </div>
<? <?
echo $form->end(); echo $form->end();
?> ?>
<div id="ajaxLoading"><?php echo $html->image('ajax-loader.gif'); ?></div> <div id="ajaxLoading"><?php echo $html->image('ajax-loader.gif'); ?></div>
<div id="results"></div> <div id="results"></div>
</div> </div>
<?php <?php
$mem_usage = memory_get_usage(true); $mem_usage = memory_get_usage(true);
if ($mem_usage < 1024) if ($mem_usage < 1024)
echo $mem_usage." bytes"; echo $mem_usage . " bytes";
elseif ($mem_usage < 1048576) elseif ($mem_usage < 1048576)
echo round($mem_usage/1024,2)." kilobytes"; echo round($mem_usage / 1024, 2) . " kilobytes";
else else
echo round($mem_usage/1048576,2)." megabytes"; echo round($mem_usage / 1048576, 2) . " megabytes";
echo "<br/>"; echo "<br/>";
?>
?>
<?php // debug($currentuser); ?> <?php // debug($currentuser); ?>
<?php echo $cakeDebug; ?> <?php echo $cakeDebug; ?>
</body> </body>
</html> </html>

View file

@ -1093,9 +1093,8 @@ span.principle-emails {
span.enquiry-view-comments { span.enquiry-view-comments {
color: #000000; color: #000000;
font-size: 100%; font-size: 90%;
text-align: left; text-align: left;
line-height: 1;
white-space: pre-line; white-space: pre-line;
} }

View file

@ -38,8 +38,10 @@ $(function() {
$.post('/line_items/ajax_add', thisLineItemInputs, function(data) { $.post('/line_items/ajax_add', thisLineItemInputs, function(data) {
if(data == 'SUCCESS') { if(data == 'SUCCESS') {
loadLineItems();
$( "#addLineItemModal" ).dialog('close'); $( "#addLineItemModal" ).dialog('close');
} }
else { else {
alert("Line Item could not be saved") alert("Line Item could not be saved")
@ -50,13 +52,10 @@ $(function() {
}, },
Cancel: function() { Cancel: function() {
$( this ).dialog( "close" ); loadLineItems();
$( this ).dialog( "close" );
} }
},
close: function() {
loadLineItems();
} }
}); });
@ -410,8 +409,16 @@ function savePages() {
function loadLineItems() { function loadLineItems() {
var documentID = $("#documentID").html(); var documentID = $("#documentID").html();
$.get('/line_items/getTable/'+documentID, function(data) { /*$.get('/line_items/getTable/'+documentID, function(data) {
$("#lineItems").html(data); $("#lineItems").html(data);
});*/
$.ajax({
url: '/line_items/getTable/'+documentID,
cache: false,
success: function(data) {
$("#lineItems").html(data);
}
}); });
} }