Forgot to add files to last commit

This commit is contained in:
Karl Cordes 2010-01-31 00:58:22 -07:00
parent f7407e0e3e
commit deaea4a18e
7 changed files with 502 additions and 0 deletions

85
views/line_items/add.ctp Executable file
View file

@ -0,0 +1,85 @@
<div class="quoteProducts form">
<?php echo $form->create('LineItem');?>
<fieldset>
<legend><?php __('Add Product to this Quote');?></legend>
<?php
echo $form->input('quote_id', array('type' => 'hidden', 'value' => $quote['Quote']['id']));
echo $form->input('quantity', array('class' => 'required validate-number', 'title'=>'Please enter the quantity. It must be a number'));
echo $form->input('option', array('label' => 'This item is optional'));
echo $form->input('principle_id', array('empty' => 'Select a Principle'));
echo $ajax->observeField('LineItemPrincipleId', array(
'url' => 'principle_products',
'frequency' => 0.2,
'update' => 'products'
));
echo $form->input('product_id', array('type' => 'select', 'id'=>'products'));
echo $ajax->observeField('products', array(
'url' => 'product_options',
'frequency' => 0.2,
'update' => 'productoptions'
));
echo $ajax->div('productoptions');
echo $ajax->divEnd('productoptions');
//echo '<div id="productoptions"></div>';
//echo $form->select('QuoteProduct.product_id', null, null, array('id'=>'products'));
//*/
/*
echo $form->input('item_number');
echo $form->input('option');
echo $form->input('quantity');
echo $form->input('cost_price');
echo $form->input('currency_id');
echo $form->input('our_discount');
echo $form->input('packing');
echo $form->input('shipping_weight');
echo $form->input('shipping_cost');
echo $form->input('exchange_rate');
echo $form->input('duty');
echo $form->input('finance');
echo $form->input('misc');
echo $form->input('gross_sell_price');
echo $form->input('target_gp');
echo $form->input('title');
echo $form->input('description');
echo $form->input('quote_id');
echo $form->input('product_id');
echo $form->input('discount');
*/
?>
</fieldset>
<?php echo $form->end('Submit');
echo $javascript->codeBlock("new Validation('QuoteProductAddForm', {immediate : true, useTitles : true});", array('allowCache'=>true, 'safe'=>false));
?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('List QuoteProducts', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', '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 Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
</ul>
</div>

42
views/line_items/edit.ctp Executable file
View file

@ -0,0 +1,42 @@
<div class="quoteProducts form">
<?php echo $form->create('QuoteProduct');?>
<fieldset>
<legend><?php __('Edit QuoteProduct');?></legend>
<?php
echo $form->input('id');
echo $form->input('item_number');
echo $form->input('option');
echo $form->input('quantity');
echo $form->input('cost_price');
echo $form->input('currency_id');
echo $form->input('our_discount');
echo $form->input('packing');
echo $form->input('shipping_weight');
echo $form->input('shipping_cost');
echo $form->input('exchange_rate');
echo $form->input('duty');
echo $form->input('finance');
echo $form->input('misc');
echo $form->input('gross_sell_price');
echo $form->input('target_gp');
echo $form->input('title');
echo $form->input('description');
echo $form->input('quote_id');
echo $form->input('product_id');
echo $form->input('discount');
?>
</fieldset>
<?php echo $form->end('Submit');?>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Delete', true), array('action' => 'delete', $form->value('QuoteProduct.id')), null, sprintf(__('Are you sure you want to delete # %s?', true), $form->value('QuoteProduct.id'))); ?></li>
<li><?php echo $html->link(__('List QuoteProducts', true), array('action' => 'index'));?></li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', '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 Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
</ul>
</div>

84
views/line_items/index.ctp Executable file
View file

@ -0,0 +1,84 @@
<div class="quoteProducts index">
<h2><?php __('QuoteProducts');?></h2>
<p>
<?php
echo $paginator->counter(array(
'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true)
));
?></p>
<table cellpadding="0" cellspacing="0">
<tr>
<th><?php echo $paginator->sort('id');?></th>
<th><?php echo $paginator->sort('item_number');?></th>
<th><?php echo $paginator->sort('option');?></th>
<th><?php echo $paginator->sort('quantity');?></th>
<th><?php echo $paginator->sort('title');?></th>
<th><?php echo $paginator->sort('description');?></th>
<th><?php echo $paginator->sort('quote_id');?></th>
<th><?php echo $paginator->sort('product_id');?></th>
<th><?php echo $paginator->sort('costing_id');?></th>
<th class="actions"><?php __('Actions');?></th>
</tr>
<?php
$i = 0;
foreach ($quoteProducts as $quoteProduct):
$class = null;
if ($i++ % 2 == 0) {
$class = ' class="altrow"';
}
?>
<tr<?php echo $class;?>>
<td>
<?php echo $quoteProduct['QuoteProduct']['id']; ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['item_number']; ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['option']; ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['quantity']; ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['title']; ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['description']; ?>
</td>
<td>
<?php echo $html->link($quoteProduct['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $quoteProduct['Quote']['id'])); ?>
</td>
<td>
<?php echo $html->link($quoteProduct['Product']['title'], array('controller' => 'products', 'action' => 'view', $quoteProduct['Product']['id'])); ?>
</td>
<td>
<?php echo $quoteProduct['QuoteProduct']['costing_id']; ?>
</td>
<td class="actions">
<?php echo $html->link(__('View', true), array('action' => 'view', $quoteProduct['QuoteProduct']['id'])); ?>
<?php echo $html->link(__('Edit', true), array('action' => 'edit', $quoteProduct['QuoteProduct']['id'])); ?>
<?php echo $html->link(__('Delete', true), array('action' => 'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?>
</td>
</tr>
<?php endforeach; ?>
</table>
</div>
<div class="paging">
<?php echo $paginator->prev('<< '.__('previous', true), array(), null, array('class'=>'disabled'));?>
| <?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 QuoteProduct', true), array('action' => 'add')); ?></li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', '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 Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Costings', true), array('controller' => 'costings', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Costing', true), array('controller' => 'costings', 'action' => 'add')); ?> </li>
</ul>
</div>

View file

@ -0,0 +1,12 @@
<?php
echo '<option value="">Select a Product</option>';
if(!empty($products)) {
foreach($products as $k => $v) {
echo "<option value=\"$k\">$v</option>";
}
}
?>

View file

@ -0,0 +1,57 @@
<?
$i = 0;
foreach ($options as $opt) {
$default_option = '';
foreach($opt['ProductOption'] as $prodopt) {
/* Make it the default selected if it's the default option
* Logic that enforces only 1 default option to be added to the product_options controller
*/
if($prodopt['model_number'] != null) {
$drop_options[$prodopt['id']] = $prodopt['model_number'].": ".$prodopt['title'];
}
else {
$drop_options[$prodopt['id']] = $prodopt['title'];
}
if($prodopt['default'] == 1) {
$default_option = $prodopt['id'];
$drop_options[$prodopt['id']] .= " (Default)";
}
}
/**
* If it's an exclusive category, display a drop down box. Otherwise, check boxes
*/
if($opt['ProductOptionsCategory']['exclusive'] == 1) {
echo $form->input('ProductOption.'.$opt['ProductOptionsCategory']['name'],
array('label' => $opt['ProductOptionsCategory']['name'],
'options' => $drop_options, 'default' => $default_option));
}
else {
echo $form->input($opt['ProductOptionsCategory']['name'],
array('options' => $drop_options, 'default' => $default_option,
'multiple' => 'checkbox'));
}
unset($drop_options);
}
//print_r($categories);
print_r($options);
?>

163
views/line_items/view.ctp Executable file
View file

@ -0,0 +1,163 @@
<div class="quoteProducts view">
<h2><?php __('QuoteProduct');?></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 $quoteProduct['QuoteProduct']['id']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Item Number'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['item_number']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Option'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['option']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quantity'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['quantity']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Title'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['title']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Description'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['description']; ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quote'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($quoteProduct['Quote']['id'], array('controller' => 'quotes', 'action' => 'view', $quoteProduct['Quote']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Product'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $html->link($quoteProduct['Product']['title'], array('controller' => 'products', 'action' => 'view', $quoteProduct['Product']['id'])); ?>
&nbsp;
</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Costing Id'); ?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['QuoteProduct']['costing_id']; ?>
&nbsp;
</dd>
</dl>
</div>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit QuoteProduct', true), array('action' => 'edit', $quoteProduct['QuoteProduct']['id'])); ?> </li>
<li><?php echo $html->link(__('Delete QuoteProduct', true), array('action' => 'delete', $quoteProduct['QuoteProduct']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $quoteProduct['QuoteProduct']['id'])); ?> </li>
<li><?php echo $html->link(__('List QuoteProducts', true), array('action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New QuoteProduct', true), array('action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Currencies', true), array('controller' => 'currencies', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Currency', true), array('controller' => 'currencies', '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 Products', true), array('controller' => 'products', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Product', true), array('controller' => 'products', 'action' => 'add')); ?> </li>
<li><?php echo $html->link(__('List Costings', true), array('controller' => 'costings', 'action' => 'index')); ?> </li>
<li><?php echo $html->link(__('New Costing', true), array('controller' => 'costings', 'action' => 'add')); ?> </li>
</ul>
</div>
<div class="related">
<h3><?php __('Related Costings');?></h3>
<?php if (!empty($quoteProduct['Costing'])):?>
<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 $quoteProduct['Costing']['id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Created');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['created'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Product Id');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['product_id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quote Product Id');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['quote_product_id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Order Product Id');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['order_product_id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Invoice Product Id');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['invoice_product_id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Currency Id');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['currency_id'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Quantity');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['quantity'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Unit Cost Price');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['unit_cost_price'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Exchange Rate');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['exchange_rate'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Our Discount Percent');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['our_discount_percent'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Packing');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['packing'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Weight');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['shipping_weight'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Shipping Cost');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['shipping_cost'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Duty Percent');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['duty_percent'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Customs');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['customs'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Finance Percent');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['finance_percent'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Misc Costs');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['misc_costs'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Gross Sell Price');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['gross_sell_price'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Sale Discount Percent');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['sale_discount_percent'];?>
&nbsp;</dd>
<dt<?php if ($i % 2 == 0) echo $class;?>><?php __('Net Sell Price');?></dt>
<dd<?php if ($i++ % 2 == 0) echo $class;?>>
<?php echo $quoteProduct['Costing']['net_sell_price'];?>
&nbsp;</dd>
</dl>
<?php endif; ?>
<div class="actions">
<ul>
<li><?php echo $html->link(__('Edit Costing', true), array('controller' => 'costings', 'action' => 'edit', $quoteProduct['Costing']['id'])); ?></li>
</ul>
</div>
</div>

59
webroot/js/add_costing.js Normal file
View file

@ -0,0 +1,59 @@
function buildup() {
//Fetch all the relevent inputs from the form
quantity = +($F('CostingQuantity'));
costprice = +($F('CostingUnitCostPrice'));
ourdiscount_percentage = +($F('CostingOurDiscountPercent'));
packing_each = +($F('CostingPacking'));
exchange_rate = +($F('CostingExchangeRate'));
shipping_cost = +($F('CostingShippingCost'));
duty = +($F('CostingDutyPercent'));
sellprice_each = +($F('sellprice_each'));
customs = +($F('CostingCustoms'));
misc_cost = +($F('CostingMiscCosts'));
finance = +($F('CostingFinancePercent'));
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;
$F('CostingFobCountryOfExport').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);
}
//new Form.Observer('CostingAddForm', 0.5, buildup());
new Form.Element.EventObserver('CostingPacking', 0.5, buildup());