<?php $response = array(); $response[] = array( 'policy_id' => $policy['Policy']['id'], 'letter_send_date' => $this->JobsLetter->getLetterSendDate($policy['AccountItem']['relation_id']) ); $this->set([ 'response' => $response, '_serialize' => ['response'] ]); ?> <js> (function (angular) { "use strict"; angular.module('coreApp') .directive('peterCoxRenewals', function () { return { restrict: 'E', templateUrl: '/partials/petercox-renewals.html', }; }) .filter ( 'policyLetterAmount', function() { return function (p) { return p.amount_inc_tax; } } ) .controller( 'PeterCoxIndexCtrl', ['$scope', '$http', 'pagination', function ($scope, $http, pagination) { } ] ) .controller( 'PeterCoxRenewalsCtrl', ['$scope', '$http', 'pagination', '$window', function ($scope, $http, pagination) { pagination.init($scope, '/peterCox/getRenewals.json'); $scope.limits = ['100', '500', '1000', '1300']; $scope.processSelected = function() { $scope.processSaving = true; $http.post('/peterCox/processRenewals.json', {id: $scope.getSelectedIds()}) .then(function (amounts) { angular.forEach($scope.items, function (item) { if (item.selected) { item.already_processed = true; } angular.forEach(amounts.data.new_amounts_inc_tax, function(k) { if (k.policy_id == item.id) { item.amount_inc_tax = k.amount_inc_tax; item.letter_send_date = k.letter_send_date; } }); }); $scope.processSaving = false; //window.location.reload(); return true; }, function () { return false; } ); } } ] ) ; }(angular)); And in HTML we have <tr ng-repeat="p in items" ng-if="!paginatorLoading"> <td ng-if="!hideProcess"><input type="checkbox" ng-change="select(p)" ng-model="p.selected" ng-if="itemSelectable(p)"></td> <td><a ng-href="/policy/get/{{p.id}}/{{p.scheme_prefix}}{{p.policy_id | lpad:6}}.pdf" target="_blank">{{::p.alpha_id}}</a></td> <td>{{::p.next_renewal_date}}</td> <td><a href="/core#/jobs/{{::p.job_id}}">{{::p.job_id}}</a></td> <!-- <td>{{::p.amount_inc_tax | coreCurrency:'£'}}</td> --> <td ng-bind-html="p | policyLetterAmount"></td> <!-- <td>{{::p.letter_send_date}}</td> --> <td ng-bind-html="p | policyLetterSendDate"></td> <td>{{::p.address}}</td> <td ng-bind-html="p | policyLetterStatus"></td> </tr>