Merge branch 'feature/PurchaseOrders' into develop
This commit is contained in:
commit
d900df8f1d
|
|
@ -25,7 +25,8 @@ class DocumentsController extends AppController {
|
|||
$this->Session->setFlash(__('Invalid Document.', true));
|
||||
$this->redirect(array('action'=>'index'));
|
||||
}
|
||||
$document = $this->Document->read(null,$id);
|
||||
//$document = $this->Document->read(null,$id);
|
||||
$document = $this->Document->find('first', array('conditions' => array('Document.id' => $id), 'recursive'=>1));
|
||||
|
||||
$this->set('document', $document);
|
||||
|
||||
|
|
@ -77,6 +78,12 @@ class DocumentsController extends AppController {
|
|||
case 'purchaseOrder':
|
||||
$docTypeElement = 'document_purchase_order_view';
|
||||
$this->set('currencies', $this->Document->PurchaseOrder->Currency->find('list'));
|
||||
$this->set('purchaseOrder', $this->Document->PurchaseOrder->find('first',
|
||||
array('conditions'=>
|
||||
array('PurchaseOrder.id' => $document['PurchaseOrder']['id'])
|
||||
)
|
||||
));
|
||||
|
||||
break;
|
||||
case 'orderAck':
|
||||
$this->set('currencies', $this->Document->OrderAcknowledgement->Currency->find('list'));
|
||||
|
|
@ -266,19 +273,42 @@ class DocumentsController extends AppController {
|
|||
|
||||
break;
|
||||
case "purchaseOrder":
|
||||
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
|
||||
//$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
|
||||
$count = $this->Document->PurchaseOrder->findCount();
|
||||
$count++;
|
||||
|
||||
$offset = 2060;
|
||||
$count += $offset;
|
||||
$newPOnumber = "CMCPO".$count;
|
||||
$this->data['PurchaseOrder']['title'] = $newPOnumber;
|
||||
$this->data['PurchaseOrder']['issue_date'] = date('Y-m-d');
|
||||
$this->data['Document']['user_id']= $enquiry['Enquiry']['user_id'];
|
||||
|
||||
$this->data['PurchaseOrder']['deliver_to'] = <<<ENDDELIVER
|
||||
CMC TECHNOLOGIES PTY LTD<br>
|
||||
Unit 19, 77 Bourke Road<br>
|
||||
Alexandria NSW 2015 AUSTRALIA<br>
|
||||
ENDDELIVER;
|
||||
|
||||
//Fuck it all.
|
||||
$this->data['PurchaseOrder']['shipping_instructions'] = <<<ENDINSTRUCTIONS
|
||||
|
||||
<b>PART SHIPMENT:</b> Not Acceptable - please advise ASAP if production of an Item will Delay the Dispatch of the Complete Order by the Date Required stated above.<br>
|
||||
<b>INSURANCE:</b> DO NOT INSURE - Insurance effected by CMC<br>
|
||||
<b>SECURITY:</b> It is essential that the cargo is prepared & handled so as not to compromise its security standing.<br>
|
||||
<b>SHIPMENT MARKINGS:</b><br>
|
||||
(Please put red fragile stickers on boxing)<br>
|
||||
CMC TECHNOLOGIES PTY LTD<br>
|
||||
UNIT 19, 77 BOURKE ROAD<br>
|
||||
ALEXANDRIA NSW 2015 AUSTRALIA<br>
|
||||
ENDINSTRUCTIONS;
|
||||
|
||||
|
||||
$currentuser = $this->Session->read('Auth.User');
|
||||
$this->data['Document']['user_id'] = $currentuser['id'];
|
||||
$this->data['Document']['revision'] = 0; //No revisions for POs. I have decreed it!
|
||||
$this->data['Document']['type'] = 'purchaseOrder';
|
||||
break;
|
||||
|
||||
|
||||
case "orderAck":
|
||||
$enquiry = $this->Document->OrderAcknowledgement->Enquiry->read(null, $enquiryid);
|
||||
$this->data['OrderAcknowledgement']['job_id'] = $jobid;
|
||||
|
|
@ -468,6 +498,31 @@ class DocumentsController extends AppController {
|
|||
$this->Document->DocPage->deleteAll(array('document_id'=>$docID));
|
||||
$this->Document->DocPage->updateCounterCache(array('document_id'=>$docID));
|
||||
|
||||
if(isset($this->data['PurchaseOrder'])) {
|
||||
//Delete all the existing JobPurchaseOrder relationships for this PO.
|
||||
//Fuck it. @TODO SQL injection potential here.
|
||||
$query = "DELETE FROM jobs_purchase_orders WHERE purchase_order_id =".$this->data['PurchaseOrder']['id'];
|
||||
$result = $this->Document->query($query);
|
||||
|
||||
}
|
||||
|
||||
if(isset($this->data['PurchaseOrder']['Job'])) {
|
||||
//Loop over the submitted Jobs and add them. Fuck CakePHP is a piece of shit.
|
||||
//This is easier than using the fucking built in crap that doesnt work.
|
||||
//Fuck everything about this.
|
||||
$po_id = $this->data['PurchaseOrder']['id'];
|
||||
foreach($this->data['PurchaseOrder']['Job'] as $job_id) {
|
||||
$query = "INSERT INTO `quotenik`.`jobs_purchase_orders` (`id`, `job_id`, `purchase_order_id`) VALUES (NULL, '{$job_id}', '{$po_id}');";
|
||||
$this->Document->query($query);
|
||||
}
|
||||
|
||||
$result = $this->Document->PurchaseOrder->saveAll($this->data['PurchaseOrder']);
|
||||
|
||||
|
||||
//die(print_r($this->data['PurchaseOrder']));
|
||||
//die(print_r($result));
|
||||
//die(print_r($this->data));
|
||||
}
|
||||
|
||||
if ($this->Document->saveAll($this->data)) {
|
||||
echo 'SUCCESS';
|
||||
|
|
@ -642,7 +697,21 @@ class DocumentsController extends AppController {
|
|||
break;
|
||||
|
||||
case "purchaseOrder":
|
||||
|
||||
$totalsDescText = array(
|
||||
'subtotal' => 'SUBTOTAL',
|
||||
'gst' => '',
|
||||
'total' => 'ORDER TOTAL'
|
||||
);
|
||||
//No GST for POs for now.
|
||||
$totals = $this->calculateTotals($document, 0);
|
||||
$this->set('totals',$totals);
|
||||
$this->set('totalsDescText',$totalsDescText);
|
||||
|
||||
$filename = $document['PurchaseOrder']['title'];
|
||||
|
||||
$issue_date = date('l, j F Y', strtotime($document['PurchaseOrder']['issue_date']));
|
||||
$this->set('issue_date', $issue_date);
|
||||
$template_name = 'pdf_po';
|
||||
break;
|
||||
|
||||
|
|
@ -813,6 +882,51 @@ class DocumentsController extends AppController {
|
|||
}
|
||||
|
||||
|
||||
function add_job_items_to_po($job_id, $document_id) {
|
||||
$this->layout = 'ajax';
|
||||
$job = $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id' => $job_id)));
|
||||
|
||||
$orderack = $this->Document->OrderAcknowledgement->find('first', array('conditions'=>array('OrderAcknowledgement.enquiry_id' => $job['Job']['enquiry_id']), 'recursive' => 1));
|
||||
|
||||
$oa_document = $this->Document->find('first',
|
||||
array('conditions'=>
|
||||
array('Document.id' => $orderack['Document']['id']
|
||||
)
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
$destination_document = $this->Document->find('first', array('conditions'=>array('Document.id' => $document_id)));
|
||||
|
||||
$new_items = $this->copy_related($oa_document, 'LineItem', array('id', 'document_id', 'costing_id'));
|
||||
|
||||
$last_item_number = 1.0;
|
||||
foreach($destination_document['LineItem'] as $item) {
|
||||
$last_item_number = $item['item_number'];
|
||||
}
|
||||
if($last_item_number != 1.0) { //Fuck knows
|
||||
$last_item_number++;
|
||||
}
|
||||
|
||||
foreach($new_items as $i => $item) {
|
||||
$item['item_number'] = $last_item_number++;
|
||||
$item['document_id'] = $document_id;
|
||||
$destination_document['LineItem'][] = $item;
|
||||
}
|
||||
|
||||
|
||||
|
||||
if ($this->Document->LineItem->saveAll($destination_document['LineItem'])) {
|
||||
echo 'SUCCESS';
|
||||
}
|
||||
else {
|
||||
echo 'FAILURE';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
function costing() {
|
||||
}
|
||||
|
||||
|
|
|
|||
5
app/migrations/15_6_2013_add_extra_po_fields.sql
Normal file
5
app/migrations/15_6_2013_add_extra_po_fields.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
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;
|
||||
|
||||
|
||||
0
app/views/documents/add_job_items_to_po.ctp
Normal file
0
app/views/documents/add_job_items_to_po.ctp
Normal file
|
|
@ -10,20 +10,17 @@ $pdfdoc->SetPrintFooter(false);
|
|||
$pdfdoc->AddPage();
|
||||
$pdfdoc->Page1Header();
|
||||
|
||||
$pageTitle = "<h1>PURCHASE ORDER</h1>";
|
||||
$pdfdoc->writeHTML($pageTitle, true, false, false, false, 'C');
|
||||
|
||||
$first_page = $this->element('pdf_po_first_page');
|
||||
$pdfdoc->pageContent($first_page);
|
||||
|
||||
$pdfdoc->SetTextColor(0);
|
||||
|
||||
$pageNo = $pdfdoc->PageNoFormatted();
|
||||
$totalCount = $pdfdoc->getAliasNbPages();
|
||||
|
||||
$pdfdoc->AddPage();
|
||||
|
||||
$shippingBillingBox = $this->element('pdf_shipping_billing_box', array('pageNo'=>$pageNo, 'totalCount'=>$totalCount));
|
||||
|
||||
$pdfdoc->writeHTML($shippingBillingBox, false);
|
||||
|
||||
$LineItemTable = $this->element('line_items_table_with_shipping');
|
||||
$LineItemTable = $this->element('line_items_table_po'); //Because fuck it.
|
||||
$pdfdoc->SetPrintHeader(true);
|
||||
|
||||
$pdfdoc->pageContent($LineItemTable);
|
||||
|
|
|
|||
|
|
@ -1,10 +1,8 @@
|
|||
<h2>Purchase Order: <?=$document['PurchaseOrder']['title']?></h2>
|
||||
<h2>Job: <?=$html->link($invoice['Job']['title'], array('controller'=>'jobs', 'action'=>'view', $invoice['Job']['id']));?></h2>
|
||||
|
||||
<div id="flashMessage" class="message">
|
||||
</div>
|
||||
<div class="docButtons">
|
||||
<button id="paymentReceived">Enter Payment Received</button>
|
||||
<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>
|
||||
</div>
|
||||
|
|
@ -22,22 +20,39 @@
|
|||
echo $form->input('PurchaseOrder.id');
|
||||
echo $form->input('PurchaseOrder.principle_id');
|
||||
echo $form->input('PurchaseOrder.principle_reference');
|
||||
?>
|
||||
<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>
|
||||
|
||||
<ul id="jobsList" class="habtmList">
|
||||
<?php foreach($purchaseOrder['Job'] as $job):?>
|
||||
<li id="JobID_<?=$job['id']?>">
|
||||
<button class="removeFromList">X</button>
|
||||
<?=$job['title'];?>
|
||||
<input type="hidden" name="data[PurchaseOrder][Job][]" value="<?=$job['id']?>">
|
||||
</li>
|
||||
<?php endforeach?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo $form->input('PurchaseOrder.currency_id');
|
||||
echo $form->input('PurchaseOrder.dispatch_date');
|
||||
echo $form->input('PurchaseOrder.date_arrived'); //ARGH. Really Karl?
|
||||
|
||||
echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Select Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio', 'class'=>'billing_address'));
|
||||
echo $form->input('Document.bill_to');
|
||||
|
||||
|
||||
echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Select Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio', 'class' => 'shipping_address'));
|
||||
echo $form->input('Document.ship_to');
|
||||
echo $form->input('PurchaseOrder.ordered_from');
|
||||
echo $form->input('PurchaseOrder.description');
|
||||
|
||||
echo $form->input('PurchaseOrder.dispatch_by');
|
||||
|
||||
echo $form->input('PurchaseOrder.deliver_to');
|
||||
echo $form->input('PurchaseOrder.shipping_instructions');
|
||||
|
||||
|
||||
|
||||
echo $form->input('PurchaseOrder.ship_via');
|
||||
echo $form->input('PurchaseOrder.fob');
|
||||
echo $form->input('Document.shipping_details', array('id'=>'shippingDetails'));
|
||||
echo $form->end(array('label'=>'Save PurchaseOrder Details', 'id'=>'savePurchaseOrderButton'));
|
||||
?>
|
||||
</fieldset>
|
||||
|
|
|
|||
123
app/views/elements/line_items_table_po.ctp
Executable file
123
app/views/elements/line_items_table_po.ctp
Executable file
|
|
@ -0,0 +1,123 @@
|
|||
<table border="1" cellpadding="2" cellspacing="0" >
|
||||
<thead>
|
||||
<tr bgcolor="#f2f2f2" nobr="true">
|
||||
<th width="<?=$colWidths['item'];?>" align="center">ITEM<br />NO.</th>
|
||||
<th width="<?=$colWidths['qty'];?>" align="center">QTY</th>
|
||||
<th width="<?=$colWidths['desc'];?>" align="center">DESCRIPTION</th>
|
||||
<th width="<?=$colWidths['unit'];?>" align="center">UNIT<br>PRICE</th>
|
||||
<th width="<?=$colWidths['total'];?>" align="center">TOTAL<br>PRICE</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th align="center"><?=$currencyCode?></th>
|
||||
<th align="center"><?=$currencyCode?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?
|
||||
$hasOptions = false;
|
||||
foreach($document['LineItem'] as $li):?>
|
||||
<tr>
|
||||
<td width="<?=$colWidths['item'];?>" align="center" valign="top">
|
||||
<? if($li['option'] == 1) {
|
||||
echo 'Option<br>';
|
||||
$hasOptions = true;
|
||||
}
|
||||
?>
|
||||
<?=$li['item_number'];?>
|
||||
</td>
|
||||
<td width="<?=$colWidths['qty'];?>" align="center" valign="top"><?=$decimal->formatDecimal($li['quantity']);?></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$li['title'];?><br>
|
||||
<?=$li['description'];?>
|
||||
</td>
|
||||
<td width="<?=$colWidths['unit'];?>" align="center" valign="top">
|
||||
<?
|
||||
if($li['has_text_prices']):
|
||||
echo $li['unit_price_string'];
|
||||
?>
|
||||
<?
|
||||
else:
|
||||
?>
|
||||
<?=$number->currency($li['gross_unit_price'], $currencyCode);?>
|
||||
<? if($li['discount_percent']):?>
|
||||
<br>less<br><?=$li['discount_percent']?>%<br>
|
||||
discount<br>
|
||||
(-<?=$number->currency($li['discount_amount_unit'], $currencyCode);?>)<br>
|
||||
=<br>
|
||||
<?=$number->currency($li['net_unit_price'], $currencyCode);?>
|
||||
<?endif;?>
|
||||
<?endif;?>
|
||||
</td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center" valign="top">
|
||||
<?
|
||||
if($li['has_text_prices']):
|
||||
echo $li['gross_price_string'];
|
||||
?>
|
||||
<?
|
||||
else:
|
||||
?>
|
||||
<?=$number->currency($li['gross_price'], $currencyCode);?>
|
||||
<? if($li['discount_percent']):?>
|
||||
<br>less<br><?=$li['discount_percent']?>%<br>
|
||||
discount*<br>
|
||||
(-<?=$number->currency($li['discount_amount_total'], $currencyCode);?>)<br>
|
||||
=<br>
|
||||
<?=$number->currency($li['net_price'], $currencyCode);?>
|
||||
<?endif;?>
|
||||
<?endif;?>
|
||||
</td>
|
||||
</tr>
|
||||
<?endforeach;?>
|
||||
</tbody>
|
||||
<tfoot nobr="true">
|
||||
|
||||
<tr nobr="true">
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['subtotal']?></td>
|
||||
<td width="<?=$colWidths['unit'];?>"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
<?
|
||||
if(!$hasOptions) {
|
||||
echo $number->currency($totals['subtotal'], $currencyCode);
|
||||
}
|
||||
else {
|
||||
echo $currencySymbol.'TBA';
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
<tr nobr="true">
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['gst'];?></td>
|
||||
<td width="<?=$colWidths['unit'];?>"></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
<?
|
||||
if(!$hasOptions) {
|
||||
}
|
||||
else {
|
||||
echo $currencySymbol.'TBA';
|
||||
}
|
||||
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<tr nobr="true">
|
||||
<td width="<?=$colWidths['item'];?>"></td>
|
||||
<td width="<?=$colWidths['qty'];?>"></td>
|
||||
<td width="<?=$colWidths['desc'];?>"><?=$totalsDescText['total'];?></td>
|
||||
<td width="<?=$colWidths['unit'];?>" align="center"><?=$currencyCode?></td>
|
||||
<td width="<?=$colWidths['total'];?>" align="center">
|
||||
<?
|
||||
if(!$hasOptions) {
|
||||
echo $number->currency($totals['total'], $currencyCode);
|
||||
}
|
||||
else {
|
||||
echo $currencySymbol.'TBA';
|
||||
}
|
||||
?></td>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
||||
72
app/views/elements/pdf_po_first_page.ctp
Normal file
72
app/views/elements/pdf_po_first_page.ctp
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<table style="font-size: 14px; font-weight: bold;">
|
||||
<tr>
|
||||
<td>PURCHASE ORDER NO:</td>
|
||||
<td><?= $document['PurchaseOrder']['title']; ?></td>
|
||||
<td style="font-size: 12px;">Date: <?= $issue_date ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br><br>
|
||||
<table style="font-size: 12px; font-weight: bold;">
|
||||
<tr>
|
||||
<td style="width: 30%;">ORDERED FROM:</td>
|
||||
<td style="font-size: 12px; width: 70%"><?=$document['PurchaseOrder']['ordered_from']; ?></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br><br><br>
|
||||
|
||||
<table style="font-size: 12px; font-weight: bold; text-align: center;">
|
||||
<tr>
|
||||
<td style="border: 1px solid black;">Reference</td>
|
||||
<td style="border: 1px solid black;">Description</td>
|
||||
<td style="border: 1px solid black;">Order Total <?= $currency['Currency']['iso4217']; ?></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="border: 1px solid black;"><?= $document['PurchaseOrder']['principle_reference']; ?></td>
|
||||
<td style="border: 1px solid black;"><?= $document['PurchaseOrder']['description']; ?></td>
|
||||
<td style="border: 1px solid black;">
|
||||
<?= $number->currency($totals['total'], $currencyCode); ?>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<br><br>
|
||||
<?php $col1 = '30%'; $col2 = '70%'; ?>
|
||||
|
||||
<table style="font-size: 11px; font-weight: bold;">
|
||||
|
||||
<tr>
|
||||
<td style="width: <?=$col1;?>;">DISPATCH EX-WORKS BY:</td>
|
||||
<td style="width: <?=$col2;?>"><?= $document['PurchaseOrder']['dispatch_by'];?></td>
|
||||
</tr>
|
||||
</table><br><br>
|
||||
<table style="font-size: 11px; font-weight: bold;">
|
||||
<tr>
|
||||
<td style="width: <?=$col1;?>;">DELIVER TO:</td>
|
||||
<td style="width: <?=$col2;?>"><?= $document['PurchaseOrder']['deliver_to'];?></td>
|
||||
</tr>
|
||||
</table><br><br>
|
||||
|
||||
<table style="font-size: 11px;">
|
||||
|
||||
<tr>
|
||||
<td style="width: <?=$col1;?>;"><u>SHIPPING INSTRUCTIONS:</u></td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td style="width: <?=$col2;?>">
|
||||
<br>
|
||||
<?= $document['PurchaseOrder']['shipping_instructions'];?></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br><br>
|
||||
<table style="font-size: 11px; font-weight: bold;">
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>I HEREBY CERTIFY THAT CMC TECHNOLOGIES IS REGISTERED FOR GST AND OUR REGISTRATION # IS 47 085 991 224. <br><br>
|
||||
CON CARPIS</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
|
||||
|
|
@ -106,8 +106,7 @@ if ($currentuser['User']['access_level'] == 'manager' || $currentuser['User']['a
|
|||
|
||||
<li><?php echo $html->link('POs', '/purchase_orders/index'); ?>
|
||||
<ul>
|
||||
<li><?php echo $html->link('PO Index', '/purchase_orders/index'); ?></li>
|
||||
<li class="last"><?php echo $html->link('New PO', '/purchase_orders/add'); ?></li>
|
||||
<li class="last"><?php echo $html->link('PO Index', '/purchase_orders/index'); ?></li>
|
||||
</ul>
|
||||
</li>
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ echo $javascript->link('edit_product');
|
|||
|
||||
echo $form->input('description');
|
||||
echo $form->input('notes');
|
||||
|
||||
echo $form->input('item_code');
|
||||
echo $form->input('item_description');
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
<div class="purchaseOrders index">
|
||||
<h2><?php __('PurchaseOrders');?></h2>
|
||||
|
||||
<div class="actions">
|
||||
<a href="/documents/newDocument/purchaseOrder">New Purchase Order</a>
|
||||
</div>
|
||||
<p>
|
||||
<?php
|
||||
echo $paginator->counter(array(
|
||||
|
|
@ -17,7 +21,7 @@ echo $paginator->counter(array(
|
|||
<th><?php echo $paginator->sort('principle_id');?></th>
|
||||
<th><?php echo $paginator->sort('principle_reference');?></th>
|
||||
<? /*<th><?php echo $paginator->sort('document_id');?></th> */?>
|
||||
<th class="actions"><?php __('Actions');?></th>
|
||||
<th>Document</th>
|
||||
</tr>
|
||||
<?php
|
||||
$i = 0;
|
||||
|
|
@ -58,11 +62,13 @@ foreach ($purchaseOrders as $purchaseOrder):
|
|||
<? /*<td>
|
||||
<?php echo $html->link($purchaseOrder['Document']['id'], array('controller' => 'documents', 'action' => 'view', $purchaseOrder['Document']['id'])); ?>
|
||||
</td>*/ ?>
|
||||
<td class="actions">
|
||||
<?php echo $html->link(__('View', true), array('action' => 'view', $purchaseOrder['PurchaseOrder']['id'])); ?>
|
||||
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $purchaseOrder['PurchaseOrder']['id'])); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<td>
|
||||
<?php if($purchaseOrder['PurchaseOrder']['document_id'] > 0) { ?>
|
||||
<a href="/documents/view/<?=$purchaseOrder['PurchaseOrder']['document_id']; ?>">View</a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
|
||||
</tr>
|
||||
<?php endforeach; ?>
|
||||
</table>
|
||||
</div>
|
||||
|
|
@ -71,18 +77,6 @@ foreach ($purchaseOrders as $purchaseOrder):
|
|||
| <?php echo $paginator->numbers();?>
|
||||
<?php echo $paginator->next(__('next', true).' >>', array(), null, array('class' => 'disabled'));?>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<ul>
|
||||
<li><?php echo $html->link(__('New PurchaseOrder', true), array('action' => 'add')); ?></li>
|
||||
<li><?php echo $html->link(__('List Principles', true), array('controller' => 'principles', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Principle', true), array('controller' => 'principles', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Documents', true), array('controller' => 'documents', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Document', true), array('controller' => 'documents', 'action' => 'add')); ?> </li>
|
||||
<li><?php echo $html->link(__('List Jobs', true), array('controller' => 'jobs', 'action' => 'index')); ?> </li>
|
||||
<li><?php echo $html->link(__('New Job', true), array('controller' => 'jobs', 'action' => 'add')); ?> </li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
|
||||
|
|
@ -96,4 +90,3 @@ function isEmptyDate($date) {
|
|||
}
|
||||
?>
|
||||
|
||||
<?php debug($purchaseOrders);?>
|
||||
|
|
@ -9,6 +9,44 @@
|
|||
|
||||
$(function() {
|
||||
|
||||
|
||||
/**
|
||||
* A more generic way of handling the HABTM <ul> <li>[REMOVE BUTTON] NAME [HIDDEN INPUT]</li> </ul>
|
||||
* Copypasta'd from add_edit_shipment.js.
|
||||
*/
|
||||
function addToList(modelName, id, value, ULelement) {
|
||||
var thisLI = $('<li></li>');
|
||||
var thisButton = $('<button>X</button>');
|
||||
thisButton.addClass('removeFromList');
|
||||
thisButton.button();
|
||||
|
||||
var thisHiddenInput = $('<input type="hidden">');
|
||||
|
||||
var modelString = '['+modelName+']';
|
||||
|
||||
thisHiddenInput.attr('name', 'data[PurchaseOrder]'+modelString+'[]');
|
||||
|
||||
thisHiddenInput.attr('value', id);
|
||||
|
||||
thisLI.attr('id', modelName+'ID_'+id);
|
||||
thisLI.html(value);
|
||||
thisLI.prepend(thisButton);
|
||||
thisLI.append(thisHiddenInput);
|
||||
ULelement.append(thisLI);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
//Remove X button clicked.
|
||||
$('.removeFromList').live('click', function() {
|
||||
$(this).parent().remove();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// var config defined in global.js
|
||||
loadLineItems();
|
||||
var docID = $('#documentID').html();
|
||||
|
|
@ -40,7 +78,7 @@ $(function() {
|
|||
}
|
||||
else {
|
||||
alert("Line Item could not be saved")
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
}
|
||||
|
||||
});
|
||||
|
|
@ -75,7 +113,7 @@ $(function() {
|
|||
}
|
||||
else {
|
||||
alert("Line Item could not be saved")
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
$('#LineItemDescription').ckeditor(config);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -353,12 +391,12 @@ $(function() {
|
|||
var confirmed = confirm("This will overwrite any changes you have made to the first page");
|
||||
}
|
||||
|
||||
if(confirmed) {
|
||||
$.get('/documents/generateFirstPage/'+docID, function(data) {
|
||||
$(".firstPage").val(data);
|
||||
savePages();
|
||||
});
|
||||
}
|
||||
if(confirmed) {
|
||||
$.get('/documents/generateFirstPage/'+docID, function(data) {
|
||||
$(".firstPage").val(data);
|
||||
savePages();
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
|
@ -386,21 +424,34 @@ $(function() {
|
|||
//OA View.
|
||||
$("#saveOAButton").click(function() {
|
||||
saveDocument('Order Acknowledgement');
|
||||
//if the job has changed, the create invoice button wont work properly.
|
||||
//if the job has changed, the create invoice button wont work properly.
|
||||
window.location.reload(true);
|
||||
$('.job-title').html($("#OrderAcknowledgementJobId :selected").text());
|
||||
});
|
||||
|
||||
|
||||
|
||||
//This is fucked beyond all words.
|
||||
$("#PurchaseOrderDeliverTo").ckeditor(config);
|
||||
$("#PurchaseOrderOrderedFrom").ckeditor(config);
|
||||
$("#PurchaseOrderShippingInstructions").ckeditor(config);
|
||||
$("#PurchaseOrderDescription").ckeditor(config);
|
||||
|
||||
//PackingList View. Damn you past Karl.
|
||||
$("#savePackingListButton").click(function() {
|
||||
saveDocument('Packing List');
|
||||
//if the job has changed, the create invoice button wont work properly.
|
||||
//if the job has changed, the create invoice button wont work properly.
|
||||
window.location.reload(true);
|
||||
$('.job-title').html($("#PackingListJobId :selected").text());
|
||||
});
|
||||
|
||||
|
||||
//PurchaseOrder View. Damn you past Karl.
|
||||
$("#savePurchaseOrderButton").click(function() {
|
||||
saveDocument('Purchase Order');
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
$("#createOA").click(function() {
|
||||
$("#addJobConfirmation").dialog('open');
|
||||
|
|
@ -420,6 +471,33 @@ $(function() {
|
|||
setAddress(address, '#DocumentShipTo', 'Ship To');
|
||||
});
|
||||
|
||||
|
||||
|
||||
//Fuck it. Copypaste. Autocompletion of jobs on PO document view
|
||||
$( "#job_autocomplete" ).autocomplete({
|
||||
source: "/jobs/autocomplete",
|
||||
minLength: 2,
|
||||
select: function( event, ui ) {
|
||||
|
||||
if($('#JobID_'+ui.item.id).length == 0) { //This Job is not already in the List.
|
||||
addToList('Job', ui.item.id, ui.item.value, $('#jobsList'));
|
||||
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();
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
|
@ -472,8 +550,8 @@ function saveDocument(documentName) {
|
|||
else {
|
||||
$("#flashMessage").html("Unable to save "+documentName);
|
||||
}
|
||||
$("#flashMessage").show();
|
||||
loadLineItems();
|
||||
$("#flashMessage").show();
|
||||
loadLineItems();
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -505,17 +583,24 @@ function showHideTextPrices() {
|
|||
}
|
||||
|
||||
|
||||
//I am a much better programmer now.
|
||||
//FUCK YEAH!!
|
||||
function updateTextFields() {
|
||||
$('#shippingDetails').ckeditor(function() {
|
||||
this.updateElement();
|
||||
});
|
||||
var fields = [
|
||||
'#shippingDetails',
|
||||
"#DocumentBillTo",
|
||||
"#DocumentShipTo",
|
||||
"#PurchaseOrderDeliverTo",
|
||||
"#PurchaseOrderOrderedFrom",
|
||||
"#PurchaseOrderShippingInstructions",
|
||||
"#PurchaseOrderDescription"
|
||||
];
|
||||
|
||||
$("#DocumentBillTo").ckeditor(function() {
|
||||
this.updateElement();
|
||||
});
|
||||
$("#DocumentShipTo").ckeditor(function() {
|
||||
this.updateElement();
|
||||
});
|
||||
for (i in fields) {
|
||||
$(fields[i]).ckeditor(function() {
|
||||
this.updateElement();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -670,4 +755,5 @@ function checkNaN(value) {
|
|||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue