Wooot. Finishing this today
This commit is contained in:
parent
ea47dcf30e
commit
f691abc6db
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -14,3 +14,4 @@ emails/*
|
||||||
nbproject/*
|
nbproject/*
|
||||||
processed_vaultmsgs/*
|
processed_vaultmsgs/*
|
||||||
vaultmsgs/*
|
vaultmsgs/*
|
||||||
|
cake_eclipse_helper.php
|
||||||
|
|
|
||||||
|
|
@ -44,4 +44,7 @@ Router::connect('/', array('controller' => 'enquiries', 'action' => 'index'));
|
||||||
* developement.
|
* developement.
|
||||||
*/
|
*/
|
||||||
Router::connect('/tests', array('controller' => 'tests', 'action' => 'index'));
|
Router::connect('/tests', array('controller' => 'tests', 'action' => 'index'));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ class DocPagesController extends AppController {
|
||||||
|
|
||||||
var $name = 'DocPages';
|
var $name = 'DocPages';
|
||||||
var $helpers = array('Html', 'Form');
|
var $helpers = array('Html', 'Form');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,18 @@ class DocumentsController extends AppController {
|
||||||
|
|
||||||
$this->data = $document;
|
$this->data = $document;
|
||||||
$this->set('docType',$docType);
|
$this->set('docType',$docType);
|
||||||
|
$this->set('principles', $this->Document->LineItem->Product->Principle->find('list'));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
function getProducts($principleID = null) {
|
||||||
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
|
if($principleID == null) {
|
||||||
|
echo "INVALID PRINCIPLE ID";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -112,23 +124,9 @@ class DocumentsController extends AppController {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* function add() {
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
$this->Document->create();
|
|
||||||
if ($this->Document->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Document has been saved', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Document could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$customers = $this->Document->Customer->find('list');
|
|
||||||
$enquiries = $this->Document->Enquiry->find('list');
|
|
||||||
$jobs = $this->Document->Job->find('list');
|
|
||||||
$users = $this->Document->User->find('list');
|
|
||||||
$contacts = $this->Document->Contact->find('list');
|
|
||||||
$this->set(compact('customers', 'enquiries', 'jobs', 'users', 'contacts'));
|
|
||||||
}*/
|
|
||||||
|
|
||||||
function edit($id = null) {
|
function edit($id = null) {
|
||||||
if (!$id && empty($this->data)) {
|
if (!$id && empty($this->data)) {
|
||||||
|
|
@ -136,6 +134,11 @@ class DocumentsController extends AppController {
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
if (!empty($this->data)) {
|
if (!empty($this->data)) {
|
||||||
|
$docID = $this->data['Document']['id'];
|
||||||
|
|
||||||
|
$this->Document->DocPage->deleteAll(array('document_id'=>$docID));
|
||||||
|
|
||||||
|
$this->Document->DocPage->updateCounterCache(array('document_id'=>$docID));
|
||||||
if ($this->Document->saveAll($this->data)) {
|
if ($this->Document->saveAll($this->data)) {
|
||||||
$this->Session->setFlash(__('The Document has been saved', true));
|
$this->Session->setFlash(__('The Document has been saved', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
|
|
|
||||||
|
|
@ -10,13 +10,11 @@ class DocPage extends AppModel {
|
||||||
'foreignKey' => 'document_id',
|
'foreignKey' => 'document_id',
|
||||||
'conditions' => '',
|
'conditions' => '',
|
||||||
'fields' => '',
|
'fields' => '',
|
||||||
'order' => ''
|
'order' => '',
|
||||||
|
'counterCache' => 'doc_page_count'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
var $order = 'page_number ASC';
|
||||||
|
|
||||||
var $order = 'DocPage.page_number ASC';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
@ -25,7 +25,8 @@ class Document extends AppModel {
|
||||||
|
|
||||||
'DocPage' => array(
|
'DocPage' => array(
|
||||||
'className'=> 'DocPage',
|
'className'=> 'DocPage',
|
||||||
'foreignKey' => 'document_id'
|
'foreignKey' => 'document_id',
|
||||||
|
'order' => 'DocPage.page_number ASC'
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ echo $paginator->counter(array(
|
||||||
<tr>
|
<tr>
|
||||||
<th><?php echo $paginator->sort('id');?></th>
|
<th><?php echo $paginator->sort('id');?></th>
|
||||||
<th><?php echo $paginator->sort('created');?></th>
|
<th><?php echo $paginator->sort('created');?></th>
|
||||||
|
<th>#Pages</th>
|
||||||
<th><?php echo $paginator->sort('user_id');?></th>
|
<th><?php echo $paginator->sort('user_id');?></th>
|
||||||
<th class="actions"><?php __('Actions');?></th>
|
<th class="actions"><?php __('Actions');?></th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
@ -28,13 +29,16 @@ foreach ($documents as $document):
|
||||||
<td>
|
<td>
|
||||||
<?php echo $document['Document']['created']; ?>
|
<?php echo $document['Document']['created']; ?>
|
||||||
</td>
|
</td>
|
||||||
|
<td>
|
||||||
|
<?=$document['Document']['doc_page_count'];?>
|
||||||
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<?php echo $html->link($document['User']['username'], array('controller' => 'users', 'action' => 'view', $document['User']['id'])); ?>
|
<?php echo $html->link($document['User']['username'], array('controller' => 'users', 'action' => 'view', $document['User']['id'])); ?>
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td class="actions">
|
<td class="actions">
|
||||||
<?php echo $html->link(__('View', true), array('action' => 'view', $document['Document']['id'])); ?>
|
<?php echo $html->link(__('View', true), array('action' => 'view', $document['Document']['id'])); ?>
|
||||||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $document['Document']['id'])); ?>
|
|
||||||
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $document['Document']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $document['Document']['id'])); ?>
|
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
@ -45,18 +49,3 @@ foreach ($documents as $document):
|
||||||
| <?php echo $paginator->numbers();?>
|
| <?php echo $paginator->numbers();?>
|
||||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||||
</div>
|
</div>
|
||||||
<div class="actions">
|
|
||||||
<ul>
|
|
||||||
<li><?php echo $html->link(__('New Document', true), array('action' => 'add')); ?></li>
|
|
||||||
<li><?php echo $html->link(__('List Users', true), array('controller' => 'users', 'action' => 'index')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('New User', true), array('controller' => 'users', 'action' => 'add')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('List Invoices', true), array('controller' => 'invoices', 'action' => 'index')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('New Invoice', true), array('controller' => 'invoices', 'action' => 'add')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('List Quotes', true), array('controller' => 'quotes', 'action' => 'index')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('New Quote', true), array('controller' => 'quotes', 'action' => 'add')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('List Purchase Orders', true), array('controller' => 'purchase_orders', 'action' => 'index')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('New Purchase Order', true), array('controller' => 'purchase_orders', 'action' => 'add')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('List Line Items', true), array('controller' => 'line_items', 'action' => 'index')); ?> </li>
|
|
||||||
<li><?php echo $html->link(__('New Line Item', true), array('controller' => 'line_items', 'action' => 'add')); ?> </li>
|
|
||||||
</ul>
|
|
||||||
</div>
|
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,16 @@ switch($docType) {
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<div id="pageContentFactory">
|
||||||
|
<?
|
||||||
|
echo $form->input("DocPage.content", array('class'=>'page', 'label'=>'Page', 'between'=>'<button class="removePage">X</button>'));
|
||||||
|
?>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div id="lineItemModal">
|
||||||
|
<? echo $form->input('Product.principle_id', array('id'=>'principleSelect', 'label'=>'Principle','empty'=>'Select Principle'));?>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
@ -1,4 +1,9 @@
|
||||||
<h2>Quote: <?=$enquiry['Enquiry']['title']?></h2>
|
<h2>Quote: <?=$enquiry['Enquiry']['title']?> <?
|
||||||
|
if($document['Quote']['revision'] > 0) {
|
||||||
|
echo "Revision {$document['Quote']['revision']}";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</h2>
|
||||||
<?
|
<?
|
||||||
|
|
||||||
echo $form->create('Document',array('type'=>'post','action'=>'edit'));
|
echo $form->create('Document',array('type'=>'post','action'=>'edit'));
|
||||||
|
|
@ -6,27 +11,27 @@ echo $form->input('Document.id');
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="docButtons">
|
<div class="docButtons">
|
||||||
<button id="addPage">Add Page</button>
|
<button id="addPage">Add Content Page</button>
|
||||||
<button id="addLineItem">Add Line Item</button>
|
<button id="addLineItem">Add Line Item</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="pages">
|
||||||
<?php foreach($document['DocPage'] as $key => $page):?>
|
<?php foreach($document['DocPage'] as $key => $page):?>
|
||||||
|
|
||||||
<div class="docPage">
|
<div class="docPage">
|
||||||
|
|
||||||
<?=$form->input("DocPage.{$key}.id");?>
|
<?=$form->input("DocPage.{$key}.id");?>
|
||||||
<?=$form->input("DocPage.{$key}.content", array('class'=>'page', 'label'=>'Page'));?>
|
<?=$form->input("DocPage.{$key}.content", array('class'=>'page', 'label'=>'Page '.$page['page_number'], 'between'=>'<button class="removePage">X</button>'));?>
|
||||||
<?=$form->input("DocPage.{$key}.document_id", array('type'=>'hidden'));?>
|
<?=$form->input("DocPage.{$key}.document_id", array('type'=>'hidden'));?>
|
||||||
|
<?=$form->input("DocPage.{$key}.page_number", array('type'=>'hidden'));?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?endforeach?>
|
<?endforeach?>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?=$form->end('Save');?>
|
<?=$form->end('Save');?>
|
||||||
|
|
||||||
|
|
||||||
<? debug($this->data);?>
|
<? //debug($this->data);?>
|
||||||
<? debug($enquiry);?>
|
<? //debug($enquiry);?>
|
||||||
<?php debug($document);?>
|
<?php debug($document);?>
|
||||||
<?php debug($docType);?>
|
<?php //debug($docType);?>
|
||||||
|
|
|
||||||
|
|
@ -1496,3 +1496,12 @@ div.address span {
|
||||||
top: 50%;
|
top: 50%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.pages {
|
||||||
|
width: 50%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.pages label {
|
||||||
|
display: inline;
|
||||||
|
padding-right: 0.2em;
|
||||||
|
}
|
||||||
|
|
@ -282,22 +282,8 @@ $(function() {
|
||||||
|
|
||||||
newInvoiceForm.prepend(closeButton);
|
newInvoiceForm.prepend(closeButton);
|
||||||
$("#invoices").append(newInvoiceForm);
|
$("#invoices").append(newInvoiceForm);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getCakeID(model, count, field) {
|
|
||||||
return model+count+capitalizeFirstLetter(field);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getCakeName(model, count, field) {
|
|
||||||
return 'data['+model+']['+count+']['+field+']';
|
|
||||||
}
|
|
||||||
|
|
||||||
function capitalizeFirstLetter(string) {
|
|
||||||
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -325,23 +311,6 @@ $(function() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function getSelectedID(elementID) {
|
|
||||||
var id;
|
|
||||||
$(elementID+" :selected").each(function(i, selected) {
|
|
||||||
id = this.value;
|
|
||||||
});
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getSelectedText(elementID) {
|
|
||||||
var text;
|
|
||||||
$(elementID+" :selected").each(function(i, selected) {
|
|
||||||
text = $(selected).text();
|
|
||||||
});
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Resets the Form to its default site
|
* Resets the Form to its default site
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,133 @@
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
$("#addPage").button().click(function() {
|
|
||||||
alert("LETS ADD STUFFFF");
|
|
||||||
return false;
|
|
||||||
|
$( "#lineItemModal" ).dialog({
|
||||||
|
autoOpen: false,
|
||||||
|
height: 900,
|
||||||
|
width: 600,
|
||||||
|
modal: true,
|
||||||
|
buttons: {
|
||||||
|
"Add Line Item": function() {
|
||||||
|
//var thisShipmentInputs = $('#ShipmentAddForm').find('input,select,textarea');
|
||||||
|
|
||||||
|
$.post('/line_items/ajax_add', null, function(data) {
|
||||||
|
$( "#lineItemModal" ).dialog('close');
|
||||||
|
//window.location.reload(); //Change this to fetch a new copy of the table and update a <div>.
|
||||||
|
});
|
||||||
|
|
||||||
|
},
|
||||||
|
Cancel: function() {
|
||||||
|
$( this ).dialog( "close" );
|
||||||
|
//$("#ShipmentAddForm")[0].reset();
|
||||||
|
$("#principlesList").empty();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
close: function() {
|
||||||
|
|
||||||
|
$("#importFields").hide();
|
||||||
|
$("#principle").hide();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//Setup CKEditor toolbars
|
||||||
|
var config = {
|
||||||
|
toolbar:[
|
||||||
|
|
||||||
|
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Scayt'],
|
||||||
|
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
|
||||||
|
['Image','Table','HorizontalRule','SpecialChar'],
|
||||||
|
'/',
|
||||||
|
['Styles','Format'],
|
||||||
|
['Bold','Italic','Strike'],
|
||||||
|
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote'],
|
||||||
|
['Link','Unlink'],
|
||||||
|
['Maximize','-','About']
|
||||||
|
]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
$("#pageContentFactory").hide();
|
||||||
|
|
||||||
|
|
||||||
|
//Add a new Page Element.
|
||||||
|
$("#addPage").button().click(function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
|
||||||
|
|
||||||
|
$('.page').ckeditor(function() {
|
||||||
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var newPage = $('#pageContentFactory').clone();
|
||||||
|
newPage.removeAttr('id');
|
||||||
|
newPage.show();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
var pageCount = $('.docPage').length;
|
||||||
|
|
||||||
|
//alert(pageCount);
|
||||||
|
|
||||||
|
pageCount++;
|
||||||
|
var model = 'DocPage';
|
||||||
|
var field = 'content';
|
||||||
|
var ID = getCakeID(model,pageCount, field);
|
||||||
|
var name = getCakeName(model, pageCount, field);
|
||||||
|
|
||||||
|
newPage.find('label').attr('for', ID);
|
||||||
|
|
||||||
|
newPage.find('textarea').attr('id', ID).attr('name', name);
|
||||||
|
newPage.addClass('docPage');
|
||||||
|
|
||||||
|
var hiddenName = getCakeName(model, pageCount, 'page_number');
|
||||||
|
|
||||||
|
newPage.append('<input type="hidden" name="'+hiddenName+'" value="'+pageCount+'">');
|
||||||
|
$('.pages').append(newPage);
|
||||||
|
|
||||||
|
$('.page').ckeditor(config);
|
||||||
|
return false;
|
||||||
|
});
|
||||||
|
|
||||||
|
//Open the LineItem dialog
|
||||||
$("#addLineItem").button().click(function() {
|
$("#addLineItem").button().click(function() {
|
||||||
|
|
||||||
|
$( "#lineItemModal" ).dialog('open');
|
||||||
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
$('.page').ckeditor();
|
$("#principleSelect").change(function() {
|
||||||
|
alert("OH YEAH LETS DO THIS");
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// Initialize the editor.
|
||||||
|
// Callback function can be passed and executed after full instance creation.
|
||||||
|
$('.page').ckeditor(config);
|
||||||
|
|
||||||
|
|
||||||
|
//Remove this Page
|
||||||
|
$(".removePage").live('click',function() {
|
||||||
|
|
||||||
|
$('.page').ckeditor(function() {
|
||||||
|
this.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(this).parents(".docPage").remove();
|
||||||
|
|
||||||
|
$('.page').ckeditor(config);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
@ -14,7 +14,38 @@ $(function() {
|
||||||
})
|
})
|
||||||
.ajaxStop(function() {
|
.ajaxStop(function() {
|
||||||
$(this).hide();
|
$(this).hide();
|
||||||
})
|
});
|
||||||
;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function getCakeID(model, count, field) {
|
||||||
|
return model+count+capitalizeFirstLetter(field);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCakeName(model, count, field) {
|
||||||
|
return 'data['+model+']['+count+']['+field+']';
|
||||||
|
}
|
||||||
|
|
||||||
|
function capitalizeFirstLetter(string) {
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedID(elementID) {
|
||||||
|
var id;
|
||||||
|
$(elementID+" :selected").each(function(i, selected) {
|
||||||
|
id = this.value;
|
||||||
|
});
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
function getSelectedText(elementID) {
|
||||||
|
var text;
|
||||||
|
$(elementID+" :selected").each(function(i, selected) {
|
||||||
|
text = $(selected).text();
|
||||||
|
});
|
||||||
|
return text;
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue