Permalink
Browse files

Merge branch 'sqftprice' into Development

  • Loading branch information...
2 parents 9b30fc8 + 7832f73 commit 8d1ff431543a0d0c81abb3fc6bdaaabffd7e474a @Dinesh-Ramakrishnan Dinesh-Ramakrishnan committed Apr 16, 2012
View
@@ -45,7 +45,7 @@
| 'ORIG_PATH_INFO' Uses the ORIG_PATH_INFO
|
*/
-$config['uri_protocol'] = 'PATH_INFO';
+$config['uri_protocol'] = 'AUTO';
/*
|--------------------------------------------------------------------------
@@ -225,7 +225,7 @@
| MUST set an encryption key. See the user guide for info.
|
*/
-$config['encryption_key'] = 'c07ad0c763b0b85b1c07254cb0da3feb';
+$config['encryption_key'] = '11bbc84d4b4512b7c738639b68113f16';
/*
|--------------------------------------------------------------------------
@@ -71,7 +71,8 @@ function form($id = null, $duplicate = false)
$data['track_stock'] = '';
$data['seo_title'] = '';
$data['meta'] = '';
- $data['shippable'] = '';
+ $data['costpersqft'] = 0;
+ $data['shippable'] = '';
$data['taxable'] = '';
$data['fixed_quantity'] = '';
$data['quantity'] = '';
@@ -121,6 +122,7 @@ function form($id = null, $duplicate = false)
$data['weight'] = $product->weight;
$data['track_stock'] = $product->track_stock;
$data['shippable'] = $product->shippable;
+ $data['costpersqft'] = $product->costpersqft;
$data['quantity'] = $product->quantity;
$data['taxable'] = $product->taxable;
$data['fixed_quantity'] = $product->fixed_quantity;
@@ -161,6 +163,7 @@ function form($id = null, $duplicate = false)
$this->form_validation->set_rules('weight', 'lang:weight', 'trim|numeric|floatval');
$this->form_validation->set_rules('track_stock', 'lang:track_stock', 'trim|numeric');
$this->form_validation->set_rules('quantity', 'lang:quantity', 'trim|numeric');
+ $this->form_validation->set_rules('costpersqft', 'lang:costpersqft', 'trim|numeric');
$this->form_validation->set_rules('shippable', 'lang:shippable', 'trim|numeric');
$this->form_validation->set_rules('taxable', 'lang:taxable', 'trim|numeric');
$this->form_validation->set_rules('fixed_quantity', 'lang:fixed_quantity', 'trim|numeric');
@@ -238,6 +241,7 @@ function form($id = null, $duplicate = false)
$save['fixed_quantity'] = $this->input->post('fixed_quantity');
$save['quantity'] = $this->input->post('quantity');
$save['shippable'] = $this->input->post('shippable');
+ $save['costpersqft'] = $this->input->post('costpersqft');
$save['taxable'] = $this->input->post('taxable');
$save['enabled'] = $this->input->post('enabled');
$post_images = $this->input->post('images');
@@ -32,6 +32,7 @@
$lang['do_not_track_stock'] = 'Do Not Track Stock';
$lang['out_of_stock'] = 'Out of Stock';
$lang['shippable'] = 'Shippable';
+$lang['costpersqft'] = 'Enable Cost Per SqFt';
$lang['taxable'] = 'Taxable';
$lang['fixed_quantity'] = 'Fixed Quantity';
$lang['quantity'] = 'Available Quantity';
@@ -162,7 +162,8 @@ function validate_product_options(&$product, $post_options)
// Get the list of options for the product
// We will check the submitted options against this to make sure required options were selected
$db_options = $this->get_product_options($product['id']);
-
+ $price_before_alteration = $product['price'];
+ $sqftprice = $price_before_alteration;
// Loop through the options from the database
foreach($db_options as $option)
{
@@ -208,7 +209,8 @@ function validate_product_options(&$product, $post_options)
{
$price = ' ('.format_currency($val->price).')';
}
- $product['price'] = $product['price'] + $val->price;
+
+ $product['price'] = $product['price'] + $val->price;
$product['weight'] = $product['weight'] + $val->weight;
array_push($opts, $val->value.$price);
@@ -239,8 +241,30 @@ function validate_product_options(&$product, $post_options)
$val = $option->values[0];
//add the weight and price to the product
- $product['price'] = $product['price'] + $val->price;
- $product['weight'] = $product['weight'] + $val->weight;
+
+ // Multiple Height and Widht for SqFt Product
+
+ /*if((1 == $product['costpersqft']) && ('WidthCPsqft' == $val->name ))
+ {
+ $sqftprice = $sqftprice * $val->value;
+ }
+
+ else if((1 == $product['costpersqft']) && ('HeightCPsqft' == $val->name ))
+ {
+ $sqftprice = $sqftprice * $val->value;
+ die;
+ echo $sqftprice;
+ }*/
+ if((1 == $product['costpersqft']) && (('WidthCPsqft' == $val->name) || ('HeightCPsqft' == $val->name)))
+ {
+ $sqftprice = $sqftprice * $option_value;
+ }
+ else
+ {
+ $product['price'] = $product['price'] + $val->price;
+ }
+
+ $product['weight'] = $product['weight'] + $val->weight;
//if there is additional cost, add it to the item description
$price = '';
@@ -283,9 +307,16 @@ function validate_product_options(&$product, $post_options)
$product['options'][$option->name] = $val->name.$price;
}
}
+
+
}
-
- if($error)
+ // Now add the Sqft Cost
+ if(($sqftprice - $price_before_alteration) > 0)
+ {
+ $product['price'] = $product['price'] + $sqftprice - $price_before_alteration;
+ }
+
+ if($error)
{
return( array( 'validated' => false,
'message' => $msg
@@ -265,6 +265,7 @@ function get_cart_ready_product($id, $quantity=false)
$product['excerpt'] = $db_product->excerpt;
$product['weight'] = $db_product->weight;
$product['shippable'] = $db_product->shippable;
+ $product['costpersqft'] = $db_product->costpersqft;
$product['taxable'] = $db_product->taxable;
$product['fixed_quantity'] = $db_product->fixed_quantity;
$product['track_stock'] = $db_product->track_stock;
@@ -11,7 +11,7 @@
$(".sortable").sortable();
$(".sortable > span").disableSelection();
//if the image already exists (phpcheck) enable the selector
-
+
<?php if($id) : ?>
//options related
var ct = $('#option_list').children().size();
@@ -31,6 +31,7 @@
photos_sortable();
});
+CostperSqftOption=<?php echo $costpersqft?> ;
function add_product_image(data)
{
p = data.split('.');
@@ -94,6 +95,68 @@ function add_option(type)
}
+function add_csqftoption()
+{
+
+ // Add Width
+ //increase option_count by 1
+ option_count++;
+
+ $('#options_accordion').append('<?php add_option('Width(in Inches)', "'+option_count+'", "textfield",'true');?>');
+
+
+ //eliminate the add button if this is a text based option
+ $('#add_item_'+option_count).remove();
+
+
+ add_csqftitem("Width","5" ,option_count);
+
+
+ // Add Height
+ //increase option_count by 1
+ option_count++;
+
+ $('#options_accordion').append('<?php add_option('Height(in Inches)', "'+option_count+'", "textfield",'true');?>');
+
+
+ //eliminate the add button if this is a text based option
+ $('#add_item_'+option_count).remove();
+
+ add_csqftitem("Height","6" ,option_count);
+
+ //reset the option_name field
+ $('#option_name').val('');
+ reset_accordion();
+
+}
+
+function add_csqftitem(name,val, id)
+{
+
+ var count = $('#option_items_'+id+'>li').size()+1;
+
+ append_html = '';
+
+ append_html += '<div style="margin:2px"><span><?php echo lang('name');?>: </span> <input class="req gc_tf2" type="text" name="option['+id+'][values]['+count+'][name]" value="'+name+'" /> '+
+ '<span><?php echo lang('value');?>: </span> <input class="req gc_tf2" type="text" name="option['+id+'][values]['+count+'][value]" value="'+val+'" /> '+
+ '<span><?php echo lang('weight');?>: </span> <input class="req gc_tf2" type="text" name="option['+id+'][values]['+count+'][weight]" value="" /> '+
+ '<span><?php echo lang('price');?>: </span> <input class="req gc_tf2" type="text" name="option['+id+'][values]['+count+'][price]" value="" />';
+
+ append_html += ' <span><?php echo lang('limit');?>: </span> <input class="req gc_tf2" type="text" name="option['+id+'][values]['+count+'][limit]" value="" />';
+
+ append_html += '</div> ';
+
+
+ $('#option_items_'+id).append(append_html);
+
+ $(".sortable").sortable();
+ $(".sortable > span").disableSelection();
+
+
+}
+
+
+
function add_item(type, id)
{
@@ -206,7 +269,7 @@ function delete_product_option(id)
<li><a href="#gc_product_categories"><?php echo lang('categories');?></a></li>
<li><a href="#gc_product_downloads"><?php echo lang('digital_content');?></a></li>
<li><a href="#gc_product_seo"><?php echo lang('seo');?></a></li>
- <li><a href="#gc_product_options"><?php echo lang('options');?></a></li>
+ <li><a href="#gc_product_options" onclick='{ if( 0 == CostperSqftOption){if( 1 == $("select[name=\"costpersqft\"]").val()){CostperSqftOption = 1;add_csqftoption();}}}'><?php echo lang('options');?></a></li>
<li><a href="#gc_product_related"><?php echo lang('related_products');?></a></li>
<li><a href="#gc_product_photos"><?php echo lang('images');?></a></li>
</ul>
@@ -266,7 +329,7 @@ function delete_product_option(id)
echo form_input($data);
?>
</div>
- <div class="gc_field2">
+ <div class="gc_field2">
<label for="slug"><?php echo lang('track_stock');?> </label>
<?php
$options = array( '1' => lang('track_stock')
@@ -283,6 +346,15 @@ function delete_product_option(id)
?><small><?php echo lang('quantity_in_stock_note');?></small>
</div>
<div class="gc_field2">
+ <label for="costpersqft"><?php echo lang('costpersqft');?> </label>
+ <?php
+ $options = array( '1' => lang('yes')
+ ,'0' => lang('no')
+ );
+ echo form_dropdown('costpersqft', $options, set_value('costpersqft',$costpersqft));
+ ?>
+ </div>
+ <div class="gc_field2">
<label for="slug"><?php echo lang('shippable');?> </label>
<?php
$options = array( '1' => lang('yes')
@@ -608,7 +680,7 @@ function add_image($photo_id, $filename, $alt, $caption, $primary=false)
echo replace_newline($stuff);
}
-function add_option($name, $option_id, $type)
+function add_option($name, $option_id, $type,$required='false')
{
ob_start();
?>
@@ -621,7 +693,7 @@ function add_option($name, $option_id, $type)
<a onclick="remove_option(<?php echo $option_id ?>)" class="ui-state-default ui-corner-all" style="float:right;"><span class="ui-icon ui-icon-circle-minus"></span></a></span>
<input class="input gc_tf1" type="text" name="option[<?php echo $option_id;?>][name]" value="<?php echo $name;?>"/>
<input type="hidden" name="option[<?php echo $option_id;?>][type]" value="<?php echo $type;?>" />
- <input class="checkbox" type="checkbox" name="option[<?php echo $option_id;?>][required]" value="1"/> <?php echo lang('required');?>
+ <input class="checkbox" type="checkbox" name="option[<?php echo $option_id;?>][required]" value="1" <?php if('true' == $required) echo 'checked="checked"'; ?>/> <?php echo lang('required');?>
<button id="add_item_<?php echo $option_id;?>" type="button" rel="<?php echo $type;?>"onclick="add_item($(this).attr(\'rel\'), <?php echo $option_id;?>);"><?php echo lang('add_item');?></button>
@@ -395,6 +395,9 @@
`seo_title` text,
`meta` text,
`enabled` tinyint(1) NOT NULL default '1',
+ `costpersqft` tinyint(1) NOT NULL DEFAULT '0',
+ `width` int(11) NOT NULL DEFAULT '0',
+ `height` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=MyISAM AUTO_INCREMENT=0 DEFAULT CHARSET=utf8;

0 comments on commit 8d1ff43

Please sign in to comment.