Added PO sending fix from live server debug
This commit is contained in:
parent
c2649eb739
commit
93a24c6b62
|
|
@ -867,13 +867,17 @@ ENDINSTRUCTIONS;
|
||||||
$primary_contact = $this->Document->User->find('first', array('conditions'=>array('User.principle_id' => $document['PurchaseOrder']['principle_id'],'User.primary_contact' => 1)));
|
$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)) {
|
if(empty($primary_contact)) {
|
||||||
|
|
||||||
$this->Session->setFlash(__('Unable to sent. No primary Principle Contact', true));
|
$this->Session->setFlash(__('Unable to send. No primary Principle Contact', true));
|
||||||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
$this->Email->subject = 'CMC Technologies Purchase Order: '.$document['PurchaseOrder']['title'];
|
||||||
|
|
||||||
$this->Email->to = $primary_contact['User']['email'];
|
$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']))));
|
$this->Email->replyTo = null;
|
||||||
|
$this->Email->cc = null;
|
||||||
|
|
||||||
|
$this->set('job', $this->Document->PurchaseOrder->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||||
break;
|
break;
|
||||||
case 'orderAck':
|
case 'orderAck':
|
||||||
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
$this->set('job', $this->Document->OrderAcknowledgement->Job->find('first', array('conditions'=>array('Job.id'=>$document['OrderAcknowledgement']['job_id']))));
|
||||||
|
|
@ -894,6 +898,7 @@ ENDINSTRUCTIONS;
|
||||||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
print_r($this->Email->smtpError);
|
||||||
$this->set('smtp_errors', $this->Email->smtpError);
|
$this->set('smtp_errors', $this->Email->smtpError);
|
||||||
$this->Session->setFlash(__('The Email has NOT been sent. Something went wrong.', true));
|
$this->Session->setFlash(__('The Email has NOT been sent. Something went wrong.', true));
|
||||||
$this->redirect(array('action'=>'view/'.$id), null, false);
|
$this->redirect(array('action'=>'view/'.$id), null, false);
|
||||||
|
|
|
||||||
|
|
@ -1,168 +1,201 @@
|
||||||
<?php
|
<?php
|
||||||
class ProductsController extends AppController {
|
class ProductsController extends AppController {
|
||||||
|
|
||||||
var $name = 'Products';
|
var $name = 'Products';
|
||||||
var $components = array('RequestHandler');
|
var $components = array('RequestHandler');
|
||||||
var $helpers = array('Html', 'Form', 'Ajax', 'Number');
|
var $helpers = array('Html', 'Form', 'Ajax', 'Number');
|
||||||
|
|
||||||
function index() {
|
function index() {
|
||||||
/*$this->Product->recursive = 0;
|
/*$this->Product->recursive = 0;
|
||||||
$this->set('products', $this->paginate());
|
$this->set('products', $this->paginate());
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$this->set('principles', $this->Product->Principle->find('all', array('order' => 'Principle.name ASC')));
|
$this->set('principles', $this->Product->Principle->find('all', array('order' => 'Principle.name ASC')));
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function view_principle($id = null) {
|
|
||||||
if(!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid Principle ID', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
}
|
||||||
$this->set('products', $this->Product->find('all', array('conditions'=>array('Product.principle_id'=>$id),'order'=>'Product.title ASC')));
|
|
||||||
$this->set('principle', $this->Product->Principle->findById($id));
|
|
||||||
}
|
|
||||||
|
|
||||||
function view($id = null) {
|
function view_principle($id = null) {
|
||||||
if (!$id) {
|
if(!$id) {
|
||||||
$this->Session->setFlash(__('Invalid Product.', true));
|
$this->Session->setFlash(__('Invalid Principle ID', true));
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
$this->set('products', $this->Product->find('all', array('conditions'=>array('Product.principle_id'=>$id),'order'=>'Product.title ASC')));
|
||||||
|
$this->set('principle', $this->Product->Principle->findById($id));
|
||||||
}
|
}
|
||||||
$this->set('product', $this->Product->read(null, $id));
|
|
||||||
|
|
||||||
//$this->set('product', $this->Product->find('first', array('conditions' => array('Product.id'=>$id), 'recursive' => 1)));
|
function view($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid Product.', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
$this->set('product', $this->Product->read(null, $id));
|
||||||
|
|
||||||
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$id), 'order'=>'ProductOptionsCategory.location ASC')));
|
//$this->set('product', $this->Product->find('first', array('conditions' => array('Product.id'=>$id), 'recursive' => 1)));
|
||||||
|
|
||||||
$this->set('files', $this->Product->ProductAttachment->findAllByProductId($id));
|
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$id), 'order'=>'ProductOptionsCategory.location ASC')));
|
||||||
$this->set('number_of_files', $this->Product->ProductAttachment->find('count', array('conditions' => array('ProductAttachment.product_id'=>$id))));
|
|
||||||
}
|
|
||||||
|
|
||||||
function add() {
|
$this->set('files', $this->Product->ProductAttachment->findAllByProductId($id));
|
||||||
if (!empty($this->data)) {
|
$this->set('number_of_files', $this->Product->ProductAttachment->find('count', array('conditions' => array('ProductAttachment.product_id'=>$id))));
|
||||||
$this->Product->create();
|
|
||||||
|
|
||||||
if ($this->Product->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Product has been saved', true));
|
|
||||||
$id = $this->Product->id;
|
|
||||||
$this->redirect(array('action'=>'view/'.$id));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
$principles = $this->Product->Principle->find('list');
|
|
||||||
|
|
||||||
$this->set(compact('principles', 'product_categories'));
|
function add() {
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
$this->Product->create();
|
||||||
|
|
||||||
|
if ($this->Product->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Product has been saved', true));
|
||||||
|
$id = $this->Product->id;
|
||||||
|
$this->redirect(array('action'=>'view/'.$id));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$principles = $this->Product->Principle->find('list');
|
||||||
|
|
||||||
|
$this->set(compact('principles', 'product_categories'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function cloneProduct($id) {
|
function cloneProduct($id) {
|
||||||
|
|
||||||
if(!$id) {
|
if(!$id) {
|
||||||
$this->Session->setFlash('Invalid Product ID');
|
$this->Session->setFlash('Invalid Product ID');
|
||||||
$this->redirect(array('action'=>'index'));
|
$this->redirect(array('action'=>'index'));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$product = $this->Product->find('first',array('conditions'=>array('Product.id'=>$id)));
|
$product = $this->Product->find('first',array('conditions'=>array('Product.id'=>$id)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
$this->Product->create();
|
||||||
|
|
||||||
|
if ($this->Product->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Product has been saved', true));
|
||||||
|
$id = $this->Product->id;
|
||||||
|
$this->redirect(array('action'=>'view/'.$id));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->data['Product']['principle_id'] = $product['Product']['principle_id'];
|
||||||
|
$this->data['Product']['title'] = $product['Product']['title'];
|
||||||
|
$this->data['Product']['description'] = $product['Product']['description'];
|
||||||
|
$this->data['Product']['item_code'] = $product['Product']['item_code'];
|
||||||
|
$this->data['Product']['notes'] = $product['Product']['notes'];
|
||||||
|
$this->data['Product']['item_description'] = $product['Product']['item_description'];
|
||||||
|
|
||||||
|
|
||||||
|
$principles = $this->Product->Principle->find('list');
|
||||||
|
$this->set(compact('principles', 'product_categories'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function add_costing() {
|
||||||
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
$this->Product->create();
|
|
||||||
|
|
||||||
if ($this->Product->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Product has been saved', true));
|
|
||||||
$id = $this->Product->id;
|
|
||||||
$this->redirect(array('action'=>'view/'.$id));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$this->data['Product']['principle_id'] = $product['Product']['principle_id'];
|
|
||||||
$this->data['Product']['title'] = $product['Product']['title'];
|
|
||||||
$this->data['Product']['description'] = $product['Product']['description'];
|
|
||||||
$this->data['Product']['item_code'] = $product['Product']['item_code'];
|
|
||||||
$this->data['Product']['notes'] = $product['Product']['notes'];
|
|
||||||
$this->data['Product']['item_description'] = $product['Product']['item_description'];
|
|
||||||
|
|
||||||
|
|
||||||
$principles = $this->Product->Principle->find('list');
|
|
||||||
$this->set(compact('principles', 'product_categories'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function add_costing() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function edit($id = null) {
|
|
||||||
if (!$id && empty($this->data)) {
|
|
||||||
$this->Session->setFlash(__('Invalid Product', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if (!empty($this->data)) {
|
|
||||||
if ($this->Product->save($this->data)) {
|
|
||||||
$this->Session->setFlash(__('The Product has been saved', true));
|
|
||||||
$id = $this->Product->id;
|
|
||||||
$this->redirect(array('action'=>'view/'.$id));
|
|
||||||
} else {
|
|
||||||
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (empty($this->data)) {
|
|
||||||
$this->data = $this->Product->read(null, $id);
|
|
||||||
$this->set('description', $this->data['Product']['description']);
|
|
||||||
}
|
|
||||||
$principles = $this->Product->Principle->find('list');
|
|
||||||
$this->set(compact('principles'));
|
|
||||||
}
|
|
||||||
|
|
||||||
function delete($id = null) {
|
|
||||||
if (!$id) {
|
|
||||||
$this->Session->setFlash(__('Invalid id for Product', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
if ($this->Product->del($id)) {
|
|
||||||
$this->Session->setFlash(__('Product deleted', true));
|
|
||||||
$this->redirect(array('action'=>'index'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* Outputs a select box with the Products that belong to a particular principal. Perhaps will change to an autocomplete in the future.
|
|
||||||
*/
|
|
||||||
function getPrincipleProducts() {
|
|
||||||
|
|
||||||
|
|
||||||
if(empty($this->data)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
$this->set('products', $this->Product->find('list', array('conditions' =>
|
|
||||||
array('Product.principle_id'=> $this->data['LineItem']['principle_id']))));
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
function edit($id = null) {
|
||||||
function getProductOptions() {
|
if (!$id && empty($this->data)) {
|
||||||
if(empty($this->data)) {
|
$this->Session->setFlash(__('Invalid Product', true));
|
||||||
return;
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if (!empty($this->data)) {
|
||||||
|
if ($this->Product->save($this->data)) {
|
||||||
|
$this->Session->setFlash(__('The Product has been saved', true));
|
||||||
|
$id = $this->Product->id;
|
||||||
|
$this->redirect(array('action'=>'view/'.$id));
|
||||||
|
} else {
|
||||||
|
$this->Session->setFlash(__('The Product could not be saved. Please, try again.', true));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (empty($this->data)) {
|
||||||
|
$this->data = $this->Product->read(null, $id);
|
||||||
|
$this->set('description', $this->data['Product']['description']);
|
||||||
|
}
|
||||||
|
$principles = $this->Product->Principle->find('list');
|
||||||
|
$this->set(compact('principles'));
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
function delete($id = null) {
|
||||||
|
if (!$id) {
|
||||||
|
$this->Session->setFlash(__('Invalid id for Product', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
if ($this->Product->del($id)) {
|
||||||
|
$this->Session->setFlash(__('Product deleted', true));
|
||||||
|
$this->redirect(array('action'=>'index'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Outputs a select box with the Products that belong to a particular principal. Perhaps will change to an autocomplete in the future.
|
||||||
|
*/
|
||||||
|
function getPrincipleProducts() {
|
||||||
|
|
||||||
|
|
||||||
|
if(empty($this->data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
$this->set('products', $this->Product->find('list', array('conditions' =>
|
||||||
|
array('Product.principle_id'=> $this->data['LineItem']['principle_id']))));
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function getProductOptions() {
|
||||||
|
if(empty($this->data)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
|
||||||
|
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$this->data['LineItem']['product_id']), 'order'=>'ProductOptionsCategory.location ASC')));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
$this->set('options', $this->Product->ProductOptionsCategory->find('all', array('conditions' => array('ProductOptionsCategory.product_id'=>$this->data['LineItem']['product_id']), 'order'=>'ProductOptionsCategory.location ASC')));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
//Finish this maybe. This project has wasted years of my life.
|
||||||
|
function autocomplete() {
|
||||||
|
|
||||||
|
$query = strtolower($_GET["term"]);
|
||||||
|
|
||||||
|
if($query == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
App::import('Core', 'Sanitize');
|
||||||
|
|
||||||
|
$query = Sanitize::clean($query);
|
||||||
|
|
||||||
|
$products = $this->Product->find('list', array(
|
||||||
|
'conditions' => array(
|
||||||
|
'Product.title LIKE' => '%'.$query.'%'
|
||||||
|
),
|
||||||
|
'fields' => array('Product.title'),
|
||||||
|
'order' => array('Product.title ASC')
|
||||||
|
));
|
||||||
|
|
||||||
|
//Cakephp. You are awful. Past Karl was an idiot
|
||||||
|
|
||||||
|
$products_json = json_encode($products);
|
||||||
|
|
||||||
|
$this->set('products_json', $products_json);
|
||||||
|
|
||||||
|
$this->layout = 'ajax';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1 @@
|
||||||
<script type="text/javascript">
|
|
||||||
$('#productSelect').select2();
|
|
||||||
</script>
|
|
||||||
<?=$form->input('product', array('label'=>'Product', 'id'=>'productSelect', 'empty'=>'Choose Products', 'options'=>$products));?>
|
<?=$form->input('product', array('label'=>'Product', 'id'=>'productSelect', 'empty'=>'Choose Products', 'options'=>$products));?>
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,16 @@
|
||||||
<? echo $form->input('Product.principle_id', array('id'=>'principleSelect', 'label'=>'Principle','empty'=>'Select Principle'));?>
|
<? echo $form->input('Product.principle_id', array('id'=>'principleSelect', 'label'=>'Principle','empty'=>'Select Principle'));?>
|
||||||
<div id="productsDiv"></div>
|
<div id="productsDiv"></div>
|
||||||
<div id="productDetails"></div>
|
<div id="productDetails"></div>
|
||||||
|
<?php /*
|
||||||
|
FUCK
|
||||||
|
<br><br>
|
||||||
|
<div class="autocomplete">
|
||||||
|
<span>OR search for product</span>
|
||||||
|
<label for="productAutocomplete">Product title</label>
|
||||||
|
<input id="productAutocomplete"/>
|
||||||
|
|
||||||
|
</div> */
|
||||||
|
?>
|
||||||
|
|
||||||
<div id="lineItemDetails">
|
<div id="lineItemDetails">
|
||||||
<?
|
<?
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,6 @@ echo $javascript->link('global');
|
||||||
echo $javascript->link('search');
|
echo $javascript->link('search');
|
||||||
echo $javascript->link('jquery.jeditable.mini');
|
echo $javascript->link('jquery.jeditable.mini');
|
||||||
echo $javascript->link('jquery.validate');
|
echo $javascript->link('jquery.validate');
|
||||||
echo $javascript->link('select2');
|
|
||||||
|
|
||||||
echo $scripts_for_layout;
|
echo $scripts_for_layout;
|
||||||
?>
|
?>
|
||||||
|
|
|
||||||
|
|
@ -294,7 +294,11 @@ $(function() {
|
||||||
$("#productSelect").live('change',function() {
|
$("#productSelect").live('change',function() {
|
||||||
|
|
||||||
var productID = getSelectedID('#productSelect');
|
var productID = getSelectedID('#productSelect');
|
||||||
|
getProductDetails(productID);
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
function getProductDetails(productID) {
|
||||||
$.get('/documents/getProductDetails/'+productID, function(data) {
|
$.get('/documents/getProductDetails/'+productID, function(data) {
|
||||||
|
|
||||||
$("#lineItemDetails").show();
|
$("#lineItemDetails").show();
|
||||||
|
|
@ -319,8 +323,18 @@ $(function() {
|
||||||
|
|
||||||
|
|
||||||
}, "json");
|
}, "json");
|
||||||
});
|
}
|
||||||
|
|
||||||
|
//Autocomplete product title for adding lineItem
|
||||||
|
$( "#productAutocomplete" ).live('focus', function() {
|
||||||
|
$(this).autocomplete({
|
||||||
|
source: "/products/autocomplete",
|
||||||
|
minLength: 2,
|
||||||
|
select: function( event, ui ) {
|
||||||
|
console.log(ui);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Initialize the editor.
|
// Initialize the editor.
|
||||||
// Callback function can be passed and executed after full instance creation.
|
// Callback function can be passed and executed after full instance creation.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue