Improved add_edit-ing of users
This commit is contained in:
parent
10c14c1958
commit
9e10319687
|
|
@ -1,19 +1,26 @@
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#addContactUser").button();
|
$("#addContact").button();
|
||||||
});
|
});
|
||||||
</script>
|
</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">
|
<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>
|
</div>
|
||||||
|
|
@ -14,10 +14,10 @@
|
||||||
|
|
||||||
function processJson(data) {
|
function processJson(data) {
|
||||||
if(data.status == 'success') {
|
if(data.status == 'success') {
|
||||||
|
window.location.reload();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
alert("Error while adding this Contact");
|
alert("Error while adding/editing this Contact");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
<?php
|
<?php
|
||||||
echo $form->input('first_name', array('class' => 'required'));
|
echo $form->input('first_name', array('class' => 'required'));
|
||||||
echo $form->input('last_name', array('class' => ''));
|
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('job_title');
|
||||||
echo $form->input('phone');
|
echo $form->input('phone');
|
||||||
echo $form->input('phone_extension');
|
echo $form->input('phone_extension');
|
||||||
|
|
|
||||||
|
|
@ -20,58 +20,75 @@ $(function() {
|
||||||
|
|
||||||
//Style the Button
|
//Style the Button
|
||||||
$( "#addUser" ).button({
|
$( "#addUser" ).button({
|
||||||
text: true,
|
text: true,
|
||||||
icons: {
|
icons: {
|
||||||
primary: "ui-icon-plus"
|
primary: "ui-icon-plus"
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
//The diaglog box for Adding a contact.
|
//The diaglog box for Adding a contact.
|
||||||
$("#addUserDiv").dialog({
|
$("#addUserDiv").dialog({
|
||||||
autoOpen: false,
|
autoOpen: false,
|
||||||
width: 300,
|
width: 300,
|
||||||
modal: true,
|
modal: true,
|
||||||
position: 'top'
|
position: 'top'
|
||||||
});
|
});
|
||||||
|
|
||||||
$("#addContactUser").live('click', function() { //Adding a Contact to a Customer.
|
$("#addContactUser").live('click', function() { //Adding a Contact to a Customer.
|
||||||
var userType = 'contact';
|
var userType = 'contact';
|
||||||
var customer_id = $('.customer_id').attr('id');
|
var customer_id = $('.customer_id').attr('id');
|
||||||
var thisAction = 'add'
|
var thisAction = 'add'
|
||||||
|
|
||||||
$("#addUserDiv").dialog( "option", "title", 'Add Contact to Customer' );
|
$("#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;
|
|
||||||
|
|
||||||
|
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' );
|
$("#addPrincipleUser").click(function() {
|
||||||
$("#addUserDiv").load('/users/add_edit/action:'+thisAction+'/type:'+userType+'/principle_id:'+customer_id);
|
var userType = 'principle';
|
||||||
$("#addUserDiv").dialog('open');
|
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
|
//Editing a Customer Contact
|
||||||
$('.ViewEditButton').click(function() {
|
$('.ViewEditButton').click(function() {
|
||||||
var userType = $('#userType').html();
|
var userType = $('#userType').html();
|
||||||
var thisAction = 'edit';
|
var thisAction = 'edit';
|
||||||
var user_id = $(this).attr('id');
|
var user_id = $(this).attr('id');
|
||||||
$("#addUserDiv").dialog( "option", "title", 'Edit Contact' );
|
$("#addUserDiv").dialog( "option", "title", 'Edit Contact' );
|
||||||
$("#addUserDiv").load('/users/add_edit/action:'+thisAction+'/type:'+userType+'/user_id:'+user_id);
|
getForm('/users/add_edit/action:'+thisAction+'/type:'+userType+'/user_id:'+user_id);
|
||||||
$("#addUserDiv").dialog('open');
|
$("#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