Improved add_edit-ing of users
This commit is contained in:
parent
10c14c1958
commit
9e10319687
|
|
@ -1,19 +1,26 @@
|
|||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$("#addContactUser").button();
|
||||
$("#addContact").button();
|
||||
});
|
||||
</script>
|
||||
|
||||
<?
|
||||
|
||||
echo $form->radio('Enquiry.contact_id', $contacts, array('legend'=>'Choose Contact'));
|
||||
|
||||
echo $form->radio('Enquiry.contact_id', $contacts, array('legend' => 'Choose Contact'));
|
||||
?>
|
||||
<button id="addContactUser">Add New Contact</button>
|
||||
<button id="addContact">Add New Contact</button>
|
||||
|
||||
<? echo $javascript->link('add_edit_user'); ?>
|
||||
<div id="addUserDiv">
|
||||
<?
|
||||
echo $form->input('first_name', array('class' => 'required'));
|
||||
echo $form->input('last_name', array('class' => ''));
|
||||
echo $form->input('email', array('class' => 'email'));
|
||||
echo $form->input('job_title');
|
||||
echo $form->input('phone');
|
||||
echo $form->input('phone_extension');
|
||||
echo $form->input('mobile');
|
||||
echo $form->input('fax');
|
||||
|
||||
|
||||
|
||||
echo $form->input('direct_phone');
|
||||
echo $form->input('notes');
|
||||
?>
|
||||
</div>
|
||||
|
|
@ -14,10 +14,10 @@
|
|||
|
||||
function processJson(data) {
|
||||
if(data.status == 'success') {
|
||||
|
||||
window.location.reload();
|
||||
}
|
||||
else {
|
||||
alert("Error while adding this Contact");
|
||||
alert("Error while adding/editing this Contact");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
<?php
|
||||
echo $form->input('first_name', array('class' => 'required'));
|
||||
echo $form->input('last_name', array('class' => ''));
|
||||
echo $form->input('email', array('class' => 'email'));
|
||||
echo $form->input('email', array('class' => 'required email'));
|
||||
echo $form->input('job_title');
|
||||
echo $form->input('phone');
|
||||
echo $form->input('phone_extension');
|
||||
|
|
|
|||
|
|
@ -20,58 +20,75 @@ $(function() {
|
|||
|
||||
//Style the Button
|
||||
$( "#addUser" ).button({
|
||||
text: true,
|
||||
icons: {
|
||||
primary: "ui-icon-plus"
|
||||
}
|
||||
text: true,
|
||||
icons: {
|
||||
primary: "ui-icon-plus"
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
//The diaglog box for Adding a contact.
|
||||
$("#addUserDiv").dialog({
|
||||
autoOpen: false,
|
||||
width: 300,
|
||||
modal: true,
|
||||
position: 'top'
|
||||
autoOpen: false,
|
||||
width: 300,
|
||||
modal: true,
|
||||
position: 'top'
|
||||
});
|
||||
|
||||
$("#addContactUser").live('click', function() { //Adding a Contact to a Customer.
|
||||
var userType = 'contact';
|
||||
var customer_id = $('.customer_id').attr('id');
|
||||
var thisAction = 'add'
|
||||
var userType = 'contact';
|
||||
var customer_id = $('.customer_id').attr('id');
|
||||
var thisAction = 'add'
|
||||
|
||||
$("#addUserDiv").dialog( "option", "title", 'Add Contact to Customer' );
|
||||
$("#addUserDiv").load('/users/add_edit/action:'+thisAction+'/type:'+userType+'/customer_id:'+customer_id);
|
||||
$("#addUserDiv").dialog('open');
|
||||
return false;
|
||||
$("#addUserDiv").dialog( "option", "title", 'Add Contact to Customer' );
|
||||
|
||||
|
||||
|
||||
|
||||
getForm('/users/add_edit/action:'+thisAction+'/type:'+userType+'/customer_id:'+customer_id);
|
||||
|
||||
|
||||
$("#addUserDiv").dialog('open');
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
$("#addPrincipleUser").click(function() {
|
||||
var userType = 'principle';
|
||||
var customer_id = $('.principle_id').attr('id');
|
||||
var thisAction = 'add'
|
||||
|
||||
$("#addUserDiv").dialog( "option", "title", 'Add Contact to Principle' );
|
||||
$("#addUserDiv").load('/users/add_edit/action:'+thisAction+'/type:'+userType+'/principle_id:'+customer_id);
|
||||
$("#addUserDiv").dialog('open');
|
||||
$("#addPrincipleUser").click(function() {
|
||||
var userType = 'principle';
|
||||
var customer_id = $('.principle_id').attr('id');
|
||||
var thisAction = 'add'
|
||||
|
||||
$("#addUserDiv").dialog( "option", "title", 'Add Contact to Principle' );
|
||||
getForm('/users/add_edit/action:'+thisAction+'/type:'+userType+'/principle_id:'+customer_id);
|
||||
$("#addUserDiv").dialog('open');
|
||||
|
||||
});
|
||||
|
||||
//Editing a Customer Contact
|
||||
$('.ViewEditButton').click(function() {
|
||||
var userType = $('#userType').html();
|
||||
var thisAction = 'edit';
|
||||
var user_id = $(this).attr('id');
|
||||
$("#addUserDiv").dialog( "option", "title", 'Edit Contact' );
|
||||
$("#addUserDiv").load('/users/add_edit/action:'+thisAction+'/type:'+userType+'/user_id:'+user_id);
|
||||
$("#addUserDiv").dialog('open');
|
||||
var userType = $('#userType').html();
|
||||
var thisAction = 'edit';
|
||||
var user_id = $(this).attr('id');
|
||||
$("#addUserDiv").dialog( "option", "title", 'Edit Contact' );
|
||||
getForm('/users/add_edit/action:'+thisAction+'/type:'+userType+'/user_id:'+user_id);
|
||||
$("#addUserDiv").dialog('open');
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
function getForm(url) {
|
||||
$.ajax({
|
||||
url: url,
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$("#addUserDiv").html(data);
|
||||
$("#addUserDiv").dialog('open');
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
|
|||
44
webroot/js/add_enquiry.js
Normal file
44
webroot/js/add_enquiry.js
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/**
|
||||
* file: add_enquiry.js
|
||||
*/
|
||||
|
||||
$(function() {
|
||||
|
||||
|
||||
$("#customer_autocomplete").autocomplete({
|
||||
source: "/customers/completeCustomer",
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
$("#customer_id").val(ui.item.id);
|
||||
|
||||
|
||||
$.ajax({
|
||||
url: '/customers/customerContacts/'+ui.item.id,
|
||||
cache: false,
|
||||
success: function(data) {
|
||||
$(".customer_id").attr('id', ui.item.id);
|
||||
$("#contacts").html(data);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
/*$.get('/addresses/customerAddresses/'+ui.item.id, function(data) {
|
||||
$("#address").html(data);
|
||||
$(".selectAddress", data).button();
|
||||
});*/
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$("#addContact").live('click', function(event) {
|
||||
event.preventDefault();
|
||||
$("#contacts").html("<h1>ADD CONTACT</h1>");
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
Loading…
Reference in a new issue