git-svn-id: file:///svn-source/pmgr/branches/v0.3_work@995 97e9348a-65ac-dc4b-aefc-98561f571b83
177 lines
5.3 KiB
PHP
177 lines
5.3 KiB
PHP
<?php /* -*- mode:PHP -*- */ ?>
|
|
|
|
<div class="customer merge">
|
|
<?php
|
|
; // Editor alignment
|
|
|
|
/**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
**********************************************************************
|
|
* Javascript
|
|
*/
|
|
|
|
// Warnings _really_ screw up javascript
|
|
$saved_debug_state = Configure::read('debug');
|
|
Configure::write('debug', '0');
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
|
|
// pre-submit callback
|
|
function verifyRequest() {
|
|
if (!$("#src-customer-id").val()) {
|
|
alert("Must select source customer");
|
|
return false;
|
|
}
|
|
|
|
rows = $('#<?php echo "contacts-jqGrid"; ?>').getGridParam('selarrrow');
|
|
$('#<?php echo "contact-ids"; ?>').val(serialize(rows));
|
|
|
|
// return false to prevent the form from being submitted;
|
|
// anything other than false will allow submission.
|
|
return true;
|
|
}
|
|
|
|
function updateContacts() {
|
|
$('#contacts-jqGrid').clearGridData();
|
|
|
|
var filter = new Array();
|
|
filter['ContactsCustomer.customer_id'] = $("#src-customer-id").val();
|
|
|
|
var dynamic_post = new Array();
|
|
dynamic_post['filter'] = filter;
|
|
|
|
$('#contacts-jqGrid').setPostDataItem('dynamic_post_replace', serialize(dynamic_post));
|
|
$('#contacts-jqGrid')
|
|
.setGridParam({ page: 1 })
|
|
.trigger("reloadGrid");
|
|
}
|
|
|
|
function onRowSelect(grid_id, customer_id) {
|
|
//$('#output-debug').append("select: "+grid_id+"; "+customer_id+"<BR>\n");
|
|
|
|
// Set the item id that will be returned with the form
|
|
$("#src-customer-id").val(customer_id);
|
|
|
|
// Get the item name from the grid
|
|
$("#src-customer-name").html($(grid_id).getCell(customer_id, "Customer-name"));
|
|
|
|
updateContacts();
|
|
|
|
$("#customers-list .HeaderButton").click();
|
|
}
|
|
|
|
function onGridState(grid_id, state) {
|
|
//$('#output-debug').append("state: "+grid_id+"; "+state+"<BR>\n");
|
|
|
|
if (state == 'visible') {
|
|
$(".customer-selection-invalid").hide();
|
|
$(".customer-selection-valid").hide();
|
|
}
|
|
else {
|
|
if ($("#src-customer-id").val() > 0) {
|
|
$(".customer-selection-invalid").hide();
|
|
$(".customer-selection-valid").show();
|
|
} else {
|
|
$(".customer-selection-invalid").show();
|
|
$(".customer-selection-valid").hide();
|
|
}
|
|
}
|
|
}
|
|
|
|
--></script>
|
|
|
|
<?php
|
|
; // align
|
|
// Re-Enable warnings
|
|
Configure::write('debug', $saved_debug_state);
|
|
|
|
echo $form->create(null, array('id' => 'customer-merge-form',
|
|
'onsubmit' => 'return verifyRequest();',
|
|
'url' => array('controller' => 'customers',
|
|
'action' => 'mergeFinal')))."\n";
|
|
|
|
|
|
echo '<input type="hidden" id="src-customer-id" name="src-id" value="0" />'."\n";
|
|
echo '<input type="hidden" id="dst-customer-id" name="dst-id" value="'.$dst_id.'" />'."\n";
|
|
|
|
echo $this->element('customers', array
|
|
('config' => array
|
|
('grid_div_id' => 'customers-list',
|
|
'grid_div_class' => 'text-below',
|
|
'caption' => ('<A HREF="#" ONCLICK="$(\'#customers-list .HeaderButton\').click();'.
|
|
' return false;">Select Customer</A>'),
|
|
'grid_events' => array('onSelectRow' =>
|
|
array('ids' =>
|
|
'if (ids != null){onRowSelect("#"+$(this).attr("id"), ids);}'),
|
|
'onHeaderClick' =>
|
|
array('gridstate' =>
|
|
'onGridState("#"+$(this).attr("id"), gridstate)'),
|
|
),
|
|
'filter' => array('Customer.id !=' => $dst_id),
|
|
//'nolinks' => true,
|
|
'limit' => 10,
|
|
)));
|
|
|
|
echo ('<DIV CLASS="customer-merge grid-selection-text">' .
|
|
|
|
'<DIV CLASS="customer-selection-valid" style="display:none">' .
|
|
'Destination Customer: <SPAN id="src-customer-name"></SPAN>' .
|
|
'</DIV>' .
|
|
|
|
'<DIV CLASS="customer-selection-invalid" style="display:none">' .
|
|
'Please select customer to merge into' .
|
|
'</DIV>' .
|
|
|
|
'</DIV>' . "\n");
|
|
|
|
echo $this->element('contacts', array
|
|
(// Grid configuration
|
|
'config' => array
|
|
(
|
|
'grid_div_id' => 'contacts',
|
|
'grid_setup' => array('multiselect' => true),
|
|
'caption' => 'Source contacts to keep',
|
|
'filter' => array('ContactsCustomer.customer_id' => 0),
|
|
'include' => array('Relationship', 'License', 'Comment'),
|
|
),
|
|
));
|
|
|
|
// Add a hidden item to hold the jqGrid selection,
|
|
// which we'll populate prior to form submission.
|
|
echo "\n";
|
|
echo '<input type="hidden" id="contact-ids" name="contact-ids" value="" />'."\n";
|
|
|
|
?>
|
|
|
|
<H3>WARNING!</H3>
|
|
The above selected customer is about to be deleted, and all related data (leases, transactions, etc) will be merged into customer #<?php echo $dst_id ?>: <?php echo $dst_name ?>. This process is NOT reversible, so please ensure the selections are correct before proceeding.<BR>
|
|
|
|
<?php
|
|
echo $form->end('Merge Customers') . "\n";
|
|
?>
|
|
|
|
<div id="output-debug" style="display:none"></div>
|
|
|
|
<?php
|
|
// Warnings _really_ screw up javascript
|
|
Configure::write('debug', '0');
|
|
?>
|
|
|
|
<script type="text/javascript"><!--
|
|
$(document).ready(function(){
|
|
|
|
$("#src-customer-id").val(0);
|
|
$("#src-customer-name").html("INTERNAL ERROR");
|
|
//onGridState(null, 'visible');
|
|
|
|
<?php if ($this->params['dev']): ?>
|
|
$('#output-debug').show();
|
|
<?php endif; ?>
|
|
|
|
});
|
|
--></script>
|
|
|
|
</div>
|