Enquiry Comment JS. Fixed user Enquiry view order. Enquiry In-Place-Select Looks prettier

This commit is contained in:
Karl Cordes 2009-02-23 13:22:19 +11:00
parent 7fcb18c0ea
commit ebfced738a
27 changed files with 514 additions and 101 deletions

View file

@ -23,6 +23,13 @@ class ContactsController extends AppController {
//$enquiries = $this->Contact->Enquiry->findAllByContactId($id);
$this->set('enquiries', $this->paginate('Enquiry', array('Enquiry.contact_id' => $id)));
//$this->set('enquiries', $this->paginate($enquiries));
$statuses = $this->Contact->Enquiry->Status->find('all');
$status_list = array();
foreach ($statuses as $status) {
$status_list[] = array($status['Status']['id'], $status['Status']['name']);
}
$this->set('status_list', $status_list);
}

View file

@ -8,7 +8,7 @@ class CustomersController extends AppController {
'Customer' => array('order' => array('Customer.name' => 'asc'),
'limit' => 200
),
'Enquiry' => array('order' => array('Enquiry.id' => 'asc'))
'Enquiry' => array('order' => array('Enquiry.id' => 'desc'))
);
function index() {

View file

@ -297,6 +297,7 @@ class EnquiriesController extends AppController {
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Enquiry->save($this->data)) {
$this->Session->setFlash(__('The Enquiry has been saved', true));
$this->redirect(array('action'=>'index'));

View file

@ -0,0 +1,46 @@
<?php class ProductAttachmentsController extends AppController {
var $name = 'ProductAttachments';
var $helpers = array('Html', 'Form', 'Time');
function add($enquiryid = null) {
if(isset($this->params['named']['productid'])) {
$productid = $this->params['named']['productid'];
$this->set('product', $this->ProductAttachment->Product->findById($productid));
}
if (!$productid && empty($this->data)) {
$this->Session->setFlash(__('Invalid Product ID', true));
$this->redirect(array('controller'=>'Products', 'action'=>'index'));
}
if (!empty($this->data) &&
is_uploaded_file($this->data['ProductAttachment']['File']['tmp_name'])) {
$fileData = fread(fopen($this->data['ProductAttachment']['File']['tmp_name'], "r"),
$this->data['ProductAttachment']['File']['size']);
$this->data['ProductAttachment']['name'] = $this->data['ProductAttachment']['File']['name'];
$this->data['ProductAttachment']['type'] = $this->data['ProductAttachment']['File']['type'];
$this->data['ProductAttachment']['size'] = $this->data['ProductAttachment']['File']['size'];
$this->data['ProductAttachment']['data'] = $fileData;
$this->ProductAttachment->save($this->data);
$this->redirect(array('controller' => 'products', 'action' => 'view/'.$productid));
}
}
function download($id) {
Configure::write('debug', 0);
$file = $this->ProductAttachment->findById($id);
header('Content-type: ' . $file['ProductAttachment']['type']);
header('Content-length: ' . $file['ProductAttachment']['size']);
header('Content-Disposition: attachment; filename="'.$file['ProductAttachment']['name'].'"');
echo $file['ProductAttachment']['data'];
exit();
}
}

View file

@ -2,7 +2,8 @@
class ProductsController extends AppController {
var $name = 'Products';
var $helpers = array('Html', 'Form');
var $components = array('RequestHandler');
var $helpers = array('Html', 'Form', 'Ajax', 'Number');
function index() {
$this->Product->recursive = 0;
@ -15,6 +16,8 @@ class ProductsController extends AppController {
$this->redirect(array('action'=>'index'));
}
$this->set('product', $this->Product->read(null, $id));
$this->set('files', $this->Product->ProductAttachment->findAllByProductId($id));
$this->set('number_of_files', $this->Product->ProductAttachment->find('count', array('conditions' => array('ProductAttachment.product_id'=>$id))));
}
function add() {

View file

@ -4,7 +4,7 @@ class Product extends AppModel {
var $name = 'Product';
var $hasMany = array('ProductOption');
var $hasMany = array('ProductOption', 'ProductAttachment');
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(

View file

@ -0,0 +1,17 @@
<?php
class ProductAttachment extends AppModel {
var $name = 'ProductAttachment';
//The Associations below have been created with all possible keys, those that are not needed can be removed
var $belongsTo = array(
'Product' => array('className' => 'Product',
'foreignKey' => 'product_id',
'conditions' => '',
'fields' => '',
'order' => ''
)
);
}
?>

View file

@ -41,37 +41,44 @@ class VaultShell extends Shell {
$this->data['Email']['body'] = "";
$this->data['Email']['plainbody'] = "";
$structure = imap_fetchstructure($mbox, $i);
$attachments = 1;
if (empty($structure->parts)) { /* A single part message. No attachments and is plain text */
$this->data['Email']['body'] = imap_body($mbox, $i);
}
else {
$attachments = $this->fetchBodyAttachments($mbox, $i, $temp_filename, $email_dir);
foreach ($attachments as $attachment) {
if($attachment['type'] == 'text/html') { //Assuming All HTML attachments are the body of the email
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
$this->data['Email']['body'] .= $filecontents;
$attachments = $this->fetchBodyAttachments($mbox, $i, $temp_filename, $email_dir);
if($attachments != 1) {
foreach ($attachments as $attachment) {
if($attachment['type'] == 'text/html') { //Assuming All HTML attachments are the body of the email
if(file_exists($email_dir.'/'.$attachment['name'])) {
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
$this->data['Email']['body'] .= $filecontents;
}
}
if($attachment['type'] == 'text/plain') { //Found plain text
if(file_exists($email_dir.'/'.$attachment['name'])) {
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
$this->data['Email']['plainbody'] .= $filecontents;
}
}
}
}
if($attachment['type'] == 'text/plain') { //Found plain text
$filecontents = file_get_contents($email_dir.'/'.$attachment['name']);
$size = filesize($email_dir.'/'.$attachment['name']);
$this->data['Email']['plainbody'] .= $filecontents;
}
}
}
//Sanitize::clean($this->data);
if( ($this->data['Email']['body'] != "") || ($this->data['Email']['plainbody'] != "") ) {
if($this->Email->save($this->data)) {
$email_id = $this->Email->id;
if(isset($attachments)) {
if($attachments != 1) {
foreach ($attachments as $attachment) {
if(file_exists($email_dir.'/'.$attachment['name']) != FALSE) {
if( ($attachment['type'] != 'text/html') && ($attachment['type'] != 'multipart/mixed') &&
($attachment['type'] != 'multipart/alternative') ) {
$this->EmailAttachment->create();
@ -89,6 +96,7 @@ class VaultShell extends Shell {
}
}
}
}
echo "Email stored in the DB under enquiry ".$enquiry['Enquiry']['title']." Will be moved to the stored folder\n";
if($testing == 0) { //Testing Mode. Don't actually move these emails unless we're in production.
@ -97,19 +105,24 @@ class VaultShell extends Shell {
if(isset($attachments)) {
if($attachments != 1) {
$this->clearEmailAttachmentDirs($email_dir, $temp_filename, $attachments);
}
}
else {
echo 'Unable to save the Email\n';
}
} else {
echo "Unable to find either HTML or Plaintext body to this email. Ignoring it";
}
} else {
/* Can't find a valid-looking CMC Enquiry Number. Move the message to the discarded folder
* I may change this to simply delete the emails. This will do for now, but it's doubling up on the storage for useless files.
* */
@ -142,22 +155,28 @@ function fetchBodyAttachments($mailbox, $msg_number, $filename, $email_dir) {
$email_file = $email_dir.'/'.$filename;
imap_savebody($mailbox, $email_file, $msg_number);
$command = "ripmime -i $email_file -d $email_dir -v --verbose-contenttype --paranoid --prefix $msg_number";
$command = "/usr/local/bin/ripmime -i $email_file -d $email_dir -v --verbose-contenttype --paranoid --prefix $msg_number";
$output = array();
exec($command, $output);
exec($command, $output, $status);
/* Check the $output array and find the filenames of the attachments */
$attachments = array();
for($i=0, $j=0; $i< count($output); $i++, $j++) {
$words = explode(' ', $output[$i]);
$type = explode('=', $words[1]);
$name = explode('=', $words[2]);
$attachments[$j]['type'] = $type[1];
$attachments[$j]['name'] = $name[1];
echo "in message number $msg_number: found attachment ".$attachments[$j]['name'].' '.$attachments[$j]['type']."\n";
}
return $attachments;
if($status == 0) {
$attachments = array();
for($i=0, $j=0; $i< count($output); $i++, $j++) {
$words = explode(' ', $output[$i]);
$type = explode('=', $words[1]);
$name = explode('=', $words[2]);
$attachments[$j]['type'] = $type[1];
$attachments[$j]['name'] = $name[1];
echo "in message number $msg_number: found attachment ".$attachments[$j]['name'].' '.$attachments[$j]['type']."\n";
}
return $attachments;
}
else {
return 1;
}
}

View file

@ -105,10 +105,10 @@ foreach ($enquiries as $enquiry):
<td>
<?php echo $html->link($enquiry['Country']['name'], array('controller'=> 'countries', 'action'=>'view', $enquiry['Country']['id'])); ?>
</td>
<td><div id="statusupdate_<?php echo $i;?>"><?php echo $enquiry['Status']['name']; ?></div>
<td class="status"><div id="statusupdate_<?php echo $i;?>"><?php echo $enquiry['Status']['name']; ?></div>
<?php
echo $ajax->editor("statusupdate_$i", array('controller'=>'Enquiries', 'action'=>'update_status', $enquiry['Enquiry']['id']), array('update' => "statusupdate_$i", 'collection' => $status_list, 'okText'=>'Change Status', 'savingText' => 'Saving..', 'formId' => 'EnquiryStatusId'));
echo $ajax->editor("statusupdate_$i", array('controller'=>'Enquiries', 'action'=>'update_status', $enquiry['Enquiry']['id']), array('update' => "statusupdate_$i", 'collection' => $status_list, 'okText'=>'Change Status', 'savingText' => 'Saving..', 'formId' => 'EnquiryStatusId',
'formClassName' => 'MER-inplace-select'));
?>
</td>
<td class = "comments">

View file

@ -0,0 +1,59 @@
<?php if (!empty($files)):?>
<table cellpadding = "0" cellspacing = "0" class="filetable">
<tr>
<th><?php __('Date Added'); ?></th>
<th><?php __('Name'); ?></th>
<th><?php __('Type'); ?></th>
<th><?php __('Size'); ?></th>
<th><?php __('Description'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($files as $file):
$class = null;
if ($i % 2 == 0) {
$class = ' class="altrow"';
}
$i++;
?>
<tr<?php echo $class;?>>
<td><?php echo $time->nice($file['ProductAttachment']['created']);?></td>
<td><?php echo $html->link($file['ProductAttachment']['name'], array('controller'=>'product_attachments', 'action' => 'download/', $file['ProductAttachment']['id']));?></td>
<td><?php
if($file['ProductAttachment']['type'] == 'application/pdf') {
echo $html->image('pdf_type.png');
}
else if($file['ProductAttachment']['type'] == 'application/msword') {
echo $html->image('document_type.png');
}
else if($file['ProductAttachment']['type'] == 'message/rfc822') {
echo $html->image('message_type.png');
}
else if($file['ProductAttachment']['type'] == 'application/vnd.ms-excel') {
echo $html->image('spreadsheet_document_type.png');
}
else if($file['EnquiryFile']['type'] == 'image/jpeg') {
echo $html->image('image_type.png');
}
else {
echo $html->image('unknown_type.png');
}
?></td>
<td><?php echo $number->toReadableSize($file['ProductAttachment']['size']);?></td>
<td><?php echo $file['ProductAttachment']['description'];?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'product_attachments', 'action'=>'download/', $file['ProductAttachment']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Add An Attachment to this Enquiry', true), array('controller'=> 'product_attachments', 'action'=>'add/productid:'.$product['Product']['id']));?> </li>
</ul>
</div>

View file

@ -39,7 +39,13 @@
$cleanbody = str_replace(array('a:link', 'a:visited'), '', $email['Email']['body']);
?>
<?php echo $cleanbody; ?>
<?php echo $cleanbody;
if($cleanbody == "") {
echo '<pre>';
echo $email['Email']['plainbody'];
echo '</pre>';
}
?>
</div>
</div>

View file

@ -1,8 +1,11 @@
<div class="enquiries form">
<?php echo $form->create('Enquiry');?>
<fieldset>
<legend><?php __("Edit Enquiry: ".$enquiry['Enquiry']['title']);?></legend>
<?php
$initials = $currentuser['User']['first_name'][0].$currentuser['User']['last_name'][0]; //Used for adding initials to Comments.
echo $form->input('id');
echo $form->input('user_id', array('label'=>'Assigned to User'));
echo $form->input('principle_id');
@ -15,8 +18,14 @@
echo $form->input('billing_address_id', array('div' => 'addressradio', 'legend' => 'Billing Address', 'options' => $billing_addresses_list, 'type' => 'radio'));
echo $form->input('shipping_address_id', array('div' => 'addressradio','legend' => 'Shipping Address', 'options' => $shipping_addresses_list, 'type' => 'radio'));
echo $form->input('status_id');
echo $form->input('comments');
echo $form->input('comments', array('id'=>'comments'));
?>
<input type="BUTTON" onClick="datetime('<?php echo "$initials"; ?>');" value="Edit Comments" class="dateButton" id="datebutton"/>
<?
echo $javascript->link('quotenik/add_datetime.js', true);
echo $form->input('posted', array('label' => 'This quote been sent hard copy via Post'));
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -1,2 +1,20 @@
<h1>About this Software</h1>
<h3>About this Software</h3>
<p>Developed by Karl Cordes</p>
<br>
<pre>Copyright (c) 2009 Karl Cordes
CMC Technologies Pty Ltd (CMC), and any future CMC subsidiary companies, have a licence to use this software.
Modifications are permitted for internal CMC use only.
Redistribution of any part of the software is strictly prohibited.
This software uses other software packages: CakePHP and mySQL. These software packages have their own licence and redistribution terms that are not affected by this licence.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
</pre>

View file

@ -0,0 +1,14 @@
<?php
echo $form->create('ProductAttachment', array('action' => 'add/productid:'.$product['Product']['id'], 'type' => 'file'));
echo '<fieldset>';
echo'<legend>';
__('Add File to '.$product['Principle']['name'].' '.$product['Product']['title']);
echo '</legend>';
echo $form->file('File');
echo $form->input('description');
echo $form->input('product_id', array('type'=>'hidden', 'value' => $product['Product']['id']));
//echo $form->submit('Upload');
echo $form->end('Upload');
echo '</fieldset>';
?>
<?php print_r($product); ?>

View file

@ -7,6 +7,12 @@
echo $form->input('title');
echo $form->input('description');
echo $form->input('cost_price');
echo $form->input('our_discount');
echo $form->input('packing_each');
echo $form->input('shipping_weight_each');
echo $form->input('shipping_cost_each');
echo $form->input('duty');
echo $form->input('sell_price_each');
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -8,6 +8,12 @@
echo $form->input('title');
echo $form->input('description');
echo $form->input('cost_price');
echo $form->input('our_discount');
echo $form->input('packing_each');
echo $form->input('shipping_weight_each');
echo $form->input('shipping_cost_each');
echo $form->input('duty');
echo $form->input('sell_price_each');
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -13,6 +13,12 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('title');?></th>
<th><?php echo $paginator->sort('description');?></th>
<th><?php echo $paginator->sort('cost_price');?></th>
<th><?php echo $paginator->sort('our_discount');?></th>
<th><?php echo $paginator->sort('packing_each');?></th>
<th><?php echo $paginator->sort('shipping_weight_each');?></th>
<th><?php echo $paginator->sort('shipping_cost_each');?></th>
<th><?php echo $paginator->sort('duty');?></th>
<th><?php echo $paginator->sort('sell_price_each');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -39,6 +45,24 @@ foreach ($productOptions as $productOption):
<td>
<?php echo $productOption['ProductOption']['cost_price']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['our_discount']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['packing_each']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['shipping_weight_each']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['shipping_cost_each']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['duty']; ?>
</td>
<td>
<?php echo $productOption['ProductOption']['sell_price_each']; ?>
</td>
<td class="actions">
<?php echo $html->link(__('View', true), array('action'=>'view', $productOption['ProductOption']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('action'=>'edit', $productOption['ProductOption']['id'])); ?>

View file

@ -26,6 +26,36 @@
<?php echo $productOption['ProductOption']['cost_price']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Our Discount'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['our_discount']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Packing Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['packing_each']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Weight Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['shipping_weight_each']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Cost Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['shipping_cost_each']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Duty'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['duty']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Sell Price Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $productOption['ProductOption']['sell_price_each']; ?>
&nbsp;
</dd>
</dl>
</div>
<div class="actions">

View file

@ -1,21 +1,49 @@
<div class="products form">
<?php echo $form->create('Product');?>
<?php echo $javascript->link('quotenik/product_buildup.js', false); ?>
<div class="addproduct">
<?php echo $form->create('Product', array('id'=>'productaddform', 'class'=>'addproduct'));?>
<fieldset>
<legend><?php __('Add Product');?></legend>
<?php
echo $form->input('principle_id');
echo $form->input('title');
echo $form->input('description');
echo $form->input('principle_part_number');
echo $form->input('cmc_part_number');
echo $form->input('costprice_each');
echo $form->input('our_discount');
echo $form->input('packing_each');
echo $form->input('shipping_weight_each');
echo $form->input('shipping_cost_each');
echo $form->input('duty');
echo $form->input('target_gp');
echo $form->input('sellprice_each');
echo $form->input('part_number');
echo $form->input('exchange_rate', array('id'=>'exchange_rate'));
echo $form->input('cost_price_each', array('id'=>'costprice'));
echo $form->input('our_discount', array('label'=>'Our Discount %', 'id' => 'ourdiscount'));
echo $form->input('packing_each', array('id'=>'packing'));
echo '<div class="input text">';
echo $form->label('fob_country_of_export', 'F.O.B Country of Export');
echo $form->text('fob_country_of_export', array('readonly'=>'readonly', 'id'=>'fob_country_of_export'));
echo '</div>';
echo '<div class="input text">';
echo $form->label('convert_to_aud', 'Convert to A$');
echo $form->text('convert_to_aud', array('readonly'=>'readonly', 'id'=>'convert_to_aud'));
echo '</div>';
echo $form->input('duty', array('label' => 'Duty %', 'id'=>'duty'));
echo $form->input('shipping_weight_each', array('id'=>'shippingweight_each'));
echo $form->input('shipping_cost_each', array('id'=>'shippingcost_each'));
echo $form->input('customs', array('id'=>'customs'));
echo $form->input('misc_cost', array('label' => 'Misc. Costs', 'id'=>'misc_cost'));
echo $form->input('finance', array('label' => 'Finance %', 'id'=>'finance', 'after'=>'<p id="financeamount"> </p>'));
echo '<div class="input text">';
echo $form->label('total_landed_cost', 'Total Landed Cost');
echo $form->text('total_landed_cost', array('readonly'=>'readonly', 'id'=>'total_landed_cost'));
echo '</div>';
echo $form->input('sellprice_each', array('label' => 'Sell Price Each', 'id'=>'sellprice_each'));
echo '<div class="input text">';
echo $form->label('gross_profit_dollars', 'Gross Profit $');
echo $form->text('gross_profit_dollars', array('readonly'=>'readonly', 'id'=>'gross_profit_dollars'));
echo '</div>';
echo '<div class="input text">';
echo $form->label('gross_profit_percent', 'Gross Profit %');
echo $form->text('gross_profit_prercent', array('readonly'=>'readonly', 'id'=>'gross_profit_percent'));
echo '</div>';
echo $form->input('notes');
echo $ajax->observeForm('productaddform', array('frequency' => 0.5, 'complete'=>'buildup()'));
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -7,16 +7,15 @@
echo $form->input('principle_id');
echo $form->input('title');
echo $form->input('description');
echo $form->input('principle_part_number');
echo $form->input('cmc_part_number');
echo $form->input('costprice_each');
echo $form->input('part_number');
echo $form->input('cost_price_each');
echo $form->input('our_discount');
echo $form->input('packing_each');
echo $form->input('shipping_weight_each');
echo $form->input('shipping_cost_each');
echo $form->input('duty');
echo $form->input('target_gp');
echo $form->input('sellprice_each');
echo $form->input('notes');
?>
</fieldset>
<?php echo $form->end('Submit');?>

View file

@ -12,16 +12,15 @@ echo $paginator->counter(array(
<th><?php echo $paginator->sort('principle_id');?></th>
<th><?php echo $paginator->sort('title');?></th>
<th><?php echo $paginator->sort('description');?></th>
<th><?php echo $paginator->sort('principle_part_number');?></th>
<th><?php echo $paginator->sort('cmc_part_number');?></th>
<th><?php echo $paginator->sort('costprice_each');?></th>
<th><?php echo $paginator->sort('part_number');?></th>
<th><?php echo $paginator->sort('cost_price_each');?></th>
<th><?php echo $paginator->sort('our_discount');?></th>
<th><?php echo $paginator->sort('packing_each');?></th>
<th><?php echo $paginator->sort('shipping_weight_each');?></th>
<th><?php echo $paginator->sort('shipping_cost_each');?></th>
<th><?php echo $paginator->sort('duty');?></th>
<th><?php echo $paginator->sort('target_gp');?></th>
<th><?php echo $paginator->sort('sellprice_each');?></th>
<th><?php echo $paginator->sort('notes');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -46,13 +45,10 @@ foreach ($products as $product):
<?php echo $product['Product']['description']; ?>
</td>
<td>
<?php echo $product['Product']['principle_part_number']; ?>
<?php echo $product['Product']['part_number']; ?>
</td>
<td>
<?php echo $product['Product']['cmc_part_number']; ?>
</td>
<td>
<?php echo $product['Product']['costprice_each']; ?>
<?php echo $product['Product']['cost_price_each']; ?>
</td>
<td>
<?php echo $product['Product']['our_discount']; ?>
@ -70,10 +66,10 @@ foreach ($products as $product):
<?php echo $product['Product']['duty']; ?>
</td>
<td>
<?php echo $product['Product']['target_gp']; ?>
<?php echo $product['Product']['sellprice_each']; ?>
</td>
<td>
<?php echo $product['Product']['sellprice_each']; ?>
<?php echo $product['Product']['notes']; ?>
</td>
<td class="actions">
<?php echo $html->link(__('View', true), array('action'=>'view', $product['Product']['id'])); ?>

View file

@ -1,11 +1,7 @@
<div class="products view">
<h2><?php __('Product');?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($product['Principle']['name'], array('controller'=> 'principles', 'action'=>'view', $product['Principle']['id'])); ?>
@ -21,19 +17,14 @@
<?php echo $product['Product']['description']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Principle Part Number'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Part Number'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['principle_part_number']; ?>
<?php echo $product['Product']['part_number']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Cmc Part Number'); ?></dt>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Cost Price Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['cmc_part_number']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Costprice Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['costprice_each']; ?>
<?php echo $product['Product']['cost_price_each']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Our Discount'); ?></dt>
@ -61,40 +52,42 @@
<?php echo $product['Product']['duty']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Target Gp'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['target_gp']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Sellprice Each'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['sellprice_each']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Notes'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $product['Product']['notes']; ?>
&nbsp;
</dd>
</dl>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Product', true), array('action'=>'edit', $product['Product']['id'])); ?> </li>
<li><?php echo $html->link(__('Delete Product', true), array('action'=>'delete', $product['Product']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $product['Product']['id'])); ?> </li>
<li><?php echo $html->link(__('List Products', true), array('action'=>'index')); ?> </li>
<li><?php echo $html->link(__('New Product', 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 Product Options', true), array('controller'=> 'product_options', 'action'=>'index')); ?> </li>
<li><?php echo $html->link(__('New Product Option', true), array('controller'=> 'product_options', 'action'=>'add')); ?> </li>
</ul>
</div>
<div class="related">
<h3><?php __('Related Product Options');?></h3>
<h3><?php __('Product Options');?></h3>
<?php if (!empty($product['ProductOption'])):?>
<table cellpadding = "0" cellspacing = "0">
<tr>
<th><?php __('Id'); ?></th>
<th><?php __('Product Id'); ?></th>
<th><?php __('Title'); ?></th>
<th><?php __('Description'); ?></th>
<th><?php __('Cost Price'); ?></th>
<th><?php __('Our Discount'); ?></th>
<th><?php __('Packing Each'); ?></th>
<th><?php __('Shipping Weight Each'); ?></th>
<th><?php __('Shipping Cost Each'); ?></th>
<th><?php __('Duty'); ?></th>
<th><?php __('Sell Price Each'); ?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
@ -106,11 +99,15 @@
}
?>
<tr<?php echo $class;?>>
<td><?php echo $productOption['id'];?></td>
<td><?php echo $productOption['product_id'];?></td>
<td><?php echo $productOption['title'];?></td>
<td><?php echo $productOption['description'];?></td>
<td><?php echo $productOption['cost_price'];?></td>
<td><?php echo $productOption['our_discount'];?></td>
<td><?php echo $productOption['packing_each'];?></td>
<td><?php echo $productOption['shipping_weight_each'];?></td>
<td><?php echo $productOption['shipping_cost_each'];?></td>
<td><?php echo $productOption['duty'];?></td>
<td><?php echo $productOption['sell_price_each'];?></td>
<td class="actions">
<?php echo $html->link(__('View', true), array('controller'=> 'product_options', 'action'=>'view', $productOption['id'])); ?>
<?php echo $html->link(__('Edit', true), array('controller'=> 'product_options', 'action'=>'edit', $productOption['id'])); ?>
@ -127,3 +124,15 @@
</ul>
</div>
</div>
<div class="related">
<h3><?php if($number_of_files == 1) {
__($number_of_files.' Attachment in this Product');
}
else {
__($number_of_files.' Attachments in this Product');
}
?>
<?php echo $html->image('document.png'); ?></h3>
<?php echo $this->element('product_attachment_table', $files); ?>
</div>

View file

@ -1,11 +1,6 @@
<div class="users view">
<h2><?php __('User: '.$user['User']['username'] );?></h2>
<dl><?php $i = 0; $class = ' class="altrow"';?>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $user['User']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Username'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $user['User']['username']; ?>

View file

@ -99,7 +99,8 @@ ul, li {
background: #366FA4;
color: #fff;
font-size: 200%;
padding: 0px 10px;
padding: 0;
padding-bottom: 0.2em;
}
#header h1 a {
color: #fff;
@ -134,6 +135,10 @@ ul, li {
font-weight: bold;
color:#FFFFFF;
background: #366FA4;
padding-left: 0.1em;
padding-top: 0;
padding-right: 0;
padding-bottom: 0;
}
#nav h3 a{
@ -157,9 +162,12 @@ ul, li {
}
#nav a {
padding-left: 0.5em;
padding-bottom:0.5em;
display: block;
width: 10em;
background: #E5E5E5;
}
#nav a:hover {
@ -168,7 +176,7 @@ ul, li {
#nav li { /* all list items */
float: left;
width: 10em; /* width needed or else Opera goes nuts */
width: 8em; /* width needed or else Opera goes nuts */
}
@ -388,6 +396,10 @@ table.mer tr td.comments {
text-align: left;
}
table.mer tr td.status {
padding-right: 0;
}
table.quotetable tr.mostrecent td {
background: #ADD8E6;
}
@ -505,6 +517,18 @@ form div.submit {
margin-left: 140px;
}
form.MER-inplace-select {
float: left;
position: relative;
padding-right: 0;
margin: 0;
width: 100px;
}
select.MER-inplace-select {
width: 100px;
}
label {
display: block;
font-size: 110%;
@ -550,6 +574,30 @@ input[type=submit] {
vertical-align: bottom;
}
input[type=button].dateButton {
display: inline;
font-size: 110%;
padding: 2px 5px;
width: 20%;
vertical-align: bottom;
}
/* Costing Forms */
div.addproduct {
font-size: 80%;
}
form.addproduct {
margin-right: 20px;
padding: 0;
width: 30%;
}
div.address-radio {
}

BIN
webroot/img/ajax-loader.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View file

@ -0,0 +1,23 @@
/* Adds Date/Timestamp to a comments field when it's selected for modifiying. */
Event.observe(window, 'load', function() {
$('comments').disable();
});
function datetime(userinitials) {
$('comments').enable();
$('datebutton').disable();
var currentTime = new Date();
month = currentTime.getMonth() + 1;
day = currentTime.getDate();
year = currentTime.getFullYear();
hour = currentTime.getHours();
minute = currentTime.getMinutes();
if(minute < 10) {
minute = '0'+minute;
}
$('comments').value = '[' + day + '-' + month + '-' + year + ' @' + hour + ':' + minute +' '+ userinitials +']' + '\n' + $('comments').value;
}

View file

@ -0,0 +1,50 @@
function buildup() {
//Fetch all the relevent inputs from the form
costprice = +($F('costprice'));
ourdiscount_percentage = +($F('ourdiscount'));
packing_each = +($F('packing'));
exchange_rate = +($F('exchange_rate'));
shipping_cost = +($F('shippingcost_each'));
duty = +($F('duty'));
sellprice_each = +($F('sellprice_each'));
customs = +($F('customs'));
misc_cost = +($F('misc_cost'));
finance = +($F('finance'));
if(ourdiscount_percentage != 0) {
discount = ourdiscount_percentage / 100;
}
else {
discount = 0;
}
discountamount = discount * costprice;
net_foreign_price = costprice - discountamount;
total_foreign_price = net_foreign_price + packing_each;
$('fob_country_of_export').value = total_foreign_price;
domestic_cost = total_foreign_price / exchange_rate;
$('convert_to_aud').value = domestic_cost.toFixed(2);
dutyamount = (duty / 100) * domestic_cost;
total_landed_cost = domestic_cost + dutyamount + customs + misc_cost + shipping_cost;
financeamount = (finance / 100) * domestic_cost;
financeamount = financeamount.toFixed(2);
$('financeamount').update('Finance amount: ' + financeamount);
total_landed_cost += (+financeamount);
total_landed_cost = total_landed_cost.toFixed(2);
$('total_landed_cost').value = total_landed_cost;
gross_profit_dollars = sellprice_each - total_landed_cost
$('gross_profit_dollars').value = gross_profit_dollars;
$('gross_profit_percent').value = ((gross_profit_dollars / sellprice_each)*100).toFixed(2);
}