Added primary contact to send emails to
This commit is contained in:
parent
d900df8f1d
commit
fbfc0a9543
|
|
@ -16,7 +16,6 @@ class DocumentsController extends AppController {
|
|||
function index() {
|
||||
$this->Document->recursive = 0;
|
||||
$this->set('documents', $this->paginate());
|
||||
|
||||
$this->set('users', $this->Document->User->getUsersList());
|
||||
}
|
||||
|
||||
|
|
@ -697,14 +696,27 @@ ENDINSTRUCTIONS;
|
|||
break;
|
||||
|
||||
case "purchaseOrder":
|
||||
$principle = $this->Document->LineItem->Product->Principle->find('first', array('conditions'=>array('Principle.id' => $document['PurchaseOrder']['principle_id'])));
|
||||
|
||||
$this->set('principle', $principle);
|
||||
$purchase_order = $this->Document->PurchaseOrder->find('first',
|
||||
array('conditions'=>array('PurchaseOrder.id' => $document['PurchaseOrder']['id'])));
|
||||
$this->set('purchase_order', $purchase_order);
|
||||
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUBTOTAL',
|
||||
'gst' => '',
|
||||
'gst' => 'GST',
|
||||
'total' => 'ORDER TOTAL'
|
||||
);
|
||||
//No GST for POs for now.
|
||||
$totals = $this->calculateTotals($document, 0);
|
||||
if($principle['Country']['id'] == 1) {
|
||||
$totals = $this->calculateTotals($document, 1);
|
||||
}
|
||||
else {
|
||||
$totalsDescText['gst'] = '';
|
||||
$totals = $this->calculateTotals($document, 0);
|
||||
}
|
||||
|
||||
$this->set('totals',$totals);
|
||||
$this->set('totalsDescText',$totalsDescText);
|
||||
|
||||
|
|
@ -852,7 +864,16 @@ ENDINSTRUCTIONS;
|
|||
$this->set('invoice', $this->Document->Invoice->find('first', array('conditions'=>array('Invoice.id'=>$document['Invoice']['id']))));
|
||||
break;
|
||||
case 'purchaseOrder':
|
||||
$this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
$primary_contact = $this->Document->User->find('first', array('conditions'=>array('User.principle_id' => $document['PurchaseOrder']['principle_id'],'User.primary_contact' => 1)));
|
||||
if(empty($primary_contact)) {
|
||||
|
||||
$this->Session->setFlash(__('Unable to sent. No primary Principle Contact', true));
|
||||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||
return;
|
||||
}
|
||||
|
||||
$this->Email->to = $primary_contact['User']['email'];
|
||||
$this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
break;
|
||||
case 'orderAck':
|
||||
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||
|
|
|
|||
|
|
@ -2,4 +2,4 @@ ALTER TABLE `purchase_orders` ADD `currency_id` INT NOT NULL;
|
|||
|
||||
ALTER TABLE `purchase_orders` ADD `ordered_from` TEXT NOT NULL, ADD `description` TEXT NOT NULL, ADD `dispatch_by` VARCHAR(255) NOT NULL, ADD `deliver_to` TEXT NOT NULL, ADD `shipping_instructions` TEXT NOT NULL;
|
||||
|
||||
|
||||
ALTER TABLE `purchase_orders` ADD `jobs_text` VARCHAR( 512 ) NOT NULL
|
||||
|
|
|
|||
8
app/vendors/pdfdoc.php
vendored
8
app/vendors/pdfdoc.php
vendored
|
|
@ -15,11 +15,11 @@ class PDFDOC extends FPDI {
|
|||
|
||||
function pageContent($content) {
|
||||
|
||||
$this->SetTextColor(0);
|
||||
$this->SetFontSize(11); //Changed from 12
|
||||
$this->SetFont('times', '');
|
||||
$this->SetTextColor(0);
|
||||
$this->SetFontSize(11); //Changed from 12
|
||||
$this->SetFont('times', '');
|
||||
|
||||
$this->writeHTML($content, true, false, false, false, '');
|
||||
$this->writeHTML($content, true, false, false, false, '');
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ $pdfdoc = new PDFDOC();
|
|||
$pdfdoc->SetPrintHeader(false);
|
||||
$pdfdoc->SetPrintFooter(false);
|
||||
|
||||
$pdfdoc->SetPrintHeader(true);
|
||||
|
||||
$pdfdoc->AddPage();
|
||||
$pdfdoc->Page1Header();
|
||||
|
|
@ -19,9 +20,7 @@ $pageNo = $pdfdoc->PageNoFormatted();
|
|||
$totalCount = $pdfdoc->getAliasNbPages();
|
||||
|
||||
$pdfdoc->AddPage();
|
||||
|
||||
$LineItemTable = $this->element('line_items_table_po'); //Because fuck it.
|
||||
$pdfdoc->SetPrintHeader(true);
|
||||
|
||||
$pdfdoc->pageContent($LineItemTable);
|
||||
|
||||
|
|
|
|||
|
|
@ -4,28 +4,25 @@
|
|||
</div>
|
||||
<div class="docButtons">
|
||||
<button id="pdfDocButton" data-url="/documents/pdf/<?= $document['Document']['id']; ?>">Generate PDF</button>
|
||||
<button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email PurchaseOrder to customer</button>
|
||||
<button id="emailDocButton" data-url="/documents/email_pdf/<?= $document['Document']['id']; ?>">Email PurchaseOrder to Principle</button>
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div id="invoiceDetails" class="documentDetails">
|
||||
<fieldset>
|
||||
<? //TO DO: Copy fields from CMC PO PDF. Wack them here
|
||||
// MAKE HTML TABLE ON PDF TEMPLATE IF NECESSARY.
|
||||
// ADD MANY JOBS TO THIS FORM WITH JS/CHECKBOXES/ETC
|
||||
// ?>
|
||||
<? echo $form->create('Document',array('type'=>'post','action'=>'edit', 'default'=>false));
|
||||
echo $form->input('Document.id');
|
||||
echo $form->input('PurchaseOrder.id');
|
||||
echo $form->input('PurchaseOrder.principle_id');
|
||||
echo $form->input('PurchaseOrder.principle_reference');
|
||||
echo $form->input('PurchaseOrder.description', array('type'=>'text'));
|
||||
?>
|
||||
<div id="job" class="hiddenDefault">
|
||||
<?
|
||||
echo $form->input('job', array('id'=>'job_autocomplete', array('label'=>'Job (start typing and select from the list)')));
|
||||
?>
|
||||
<span class="moreInfo">Items from the OA for this Job will be added automatically to the PO.</span>
|
||||
<span class="moreInfo">All Items from the OA for this Job will be added automatically to the PO.</span>
|
||||
|
||||
<ul id="jobsList" class="habtmList">
|
||||
<?php foreach($purchaseOrder['Job'] as $job):?>
|
||||
|
|
@ -39,7 +36,9 @@
|
|||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo $form->input('PurchaseOrder.jobs_text');?>
|
||||
<span class="moreInfo">Jobs added above will appear in this field automatically.<br>You can add other things like CMC STOCK.</span>
|
||||
<?php
|
||||
echo $form->input('PurchaseOrder.currency_id');
|
||||
echo $form->input('PurchaseOrder.dispatch_date');
|
||||
echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl?
|
||||
|
|
|
|||
|
|
@ -1,3 +1,20 @@
|
|||
<p style="text-align: center;">
|
||||
<span style="font-size: 1.5em; font-weight: bold;">CONTRACT SUMMARY</span>
|
||||
<br><br>
|
||||
<span style="font-size: 1.2em; color: red; font-weight: bold;">
|
||||
<?= $principle['Principle']['name']; ?>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<table border="0" cellpadding="2" cellspacing="0">
|
||||
<tr>
|
||||
<td width="10%">CMC REF:</td>
|
||||
<td width="90%">
|
||||
<?= $purchase_order['PurchaseOrder']['jobs_text'];?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table border="1" cellpadding="2" cellspacing="0" >
|
||||
<thead>
|
||||
<tr bgcolor="#f2f2f2" nobr="true">
|
||||
|
|
@ -96,6 +113,10 @@
|
|||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
<?
|
||||
if(!$hasOptions) {
|
||||
if($principle['Country']['id'] == 1) {
|
||||
|
||||
echo $number->currency($totals['gst'], $currencyCode);
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo $currencySymbol.'TBA';
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
echo $form->input('phone');
|
||||
echo $form->input('fax');
|
||||
echo $form->input('notes');
|
||||
echo $form->input('email_purchase_orders');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
echo $form->input('phone');
|
||||
echo $form->input('fax');
|
||||
echo $form->input('notes');
|
||||
echo $form->input('email_purchase_orders');
|
||||
?>
|
||||
</fieldset>
|
||||
<?php echo $form->end('Submit');?>
|
||||
|
|
|
|||
|
|
@ -52,8 +52,9 @@ switch ($type) {
|
|||
break;
|
||||
|
||||
case 'principle':
|
||||
echo $form->input('principle_id', array('type' => 'hidden', 'value' => $principle_id));
|
||||
echo $form->input('principle_id', array('type' => 'hidden', 'value' => $principle_id));
|
||||
$buttonStr = 'Principle Contact';
|
||||
echo $form->input('primary_contact');
|
||||
|
||||
case 'user':
|
||||
$buttonStr = 'User';
|
||||
|
|
@ -77,4 +78,4 @@ switch ($action) {
|
|||
|
||||
|
||||
echo $form->submit($actionStr . ' ' . $buttonStr, array('id' => 'submitUserButton'));
|
||||
?>
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -481,12 +481,17 @@ $(function() {
|
|||
|
||||
if($('#JobID_'+ui.item.id).length == 0) { //This Job is not already in the List.
|
||||
addToList('Job', ui.item.id, ui.item.value, $('#jobsList'));
|
||||
|
||||
var jobs_val = $("#PurchaseOrderJobsText").val();
|
||||
|
||||
$("#PurchaseOrderJobsText").val(jobs_val +', '+ ui.item.value)
|
||||
console.log(ui.item.id);
|
||||
console.log(ui.item.value);
|
||||
//POST the job ID to a method on the documents controller to add the LineItems
|
||||
$.post('/documents/add_job_items_to_po/'+ui.item.id+'/'+$("#DocumentId").val(), function(data) {
|
||||
|
||||
loadLineItems();
|
||||
saveDocument('Purchase Order');
|
||||
|
||||
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue