Skip to content

Commit

Permalink
Added UI(new tab) for adding, deleting and updating alias for individ…
Browse files Browse the repository at this point in the history
…ual products in product edit page.
  • Loading branch information
rasseljandavid committed Jul 21, 2011
1 parent e63f1a5 commit b311e45
Show file tree
Hide file tree
Showing 3 changed files with 100 additions and 10 deletions.
53 changes: 50 additions & 3 deletions framework/modules/ecommerce/controllers/storeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,12 @@ class storeController extends expController {
'_validUTF'=>'isValid UTF products',
'_onlyreadables'=>'Process only readables format',
'uploadModelAliases'=>'Upload model aliases',
'processModelAliases'=>'Process model aliases',
'saveModelAliases'=>'Save model aliases',
'deleteProcessedModelAliases'=>'Delete model aliases'
'processModelAliases'=>'Process uploaded model aliases',
'saveModelAliases'=>'Save uploaded model aliases',
'deleteProcessedModelAliases'=>'Delete processed uploaded model aliases',
'delete_model_alias'=>'Process model aliases',
'update_model_alias'=>'Save model aliases',
'edit_model_alias'=>'Delete model aliases'
);

function name() { return $this->displayname(); } //for backwards compat with old modules
Expand Down Expand Up @@ -2011,6 +2014,7 @@ function _validUTF($content) {
return true;
}

//This function is being used in the uploadModelaliases page for showing the form upload
function uploadModelAliases() {
global $db;
set_time_limit(0);
Expand Down Expand Up @@ -2067,6 +2071,7 @@ function uploadModelAliases() {
}
}

// This function process the uploading of the model aliases in the uploadModelAliases page
function processModelAliases($index = 0, $error = '') {
global $db;

Expand Down Expand Up @@ -2156,6 +2161,7 @@ function processModelAliases($index = 0, $error = '') {
assign_to_template(array('count' => $count, 'alias' => $res, 'index' => $index, 'product_id' => $product_id, 'autocomplete' => $autocomplete, 'error' => $error));
}

// This function save the uploaded processed model aliases in the uploadModelAliases page
function saveModelAliases() {
global $db;
$index = $this->params['index'];
Expand Down Expand Up @@ -2191,12 +2197,53 @@ function saveModelAliases() {
}
}

// This function delete all the already processed model aliases in the uploadModelAliases page
function deleteProcessedModelAliases() {
global $db;
$db->delete('model_aliases_tmp','is_processed=1');
redirect_to(array('controller' => 'store','action' => 'processModelAliases'));
}

// This function show the form of model alias to be edit or add in the product edit page
function edit_model_alias() {
global $db;

if(isset($this->params['id'])) {
$model_alias = $db->selectObject('model_aliases', 'id =' .$this->params['id']);
assign_to_template(array('model_alias'=>$model_alias));
} else {
assign_to_template(array('product_id'=>$this->params['product_id']));
}
}

// This function update or add the model alias in the product edit page
function update_model_alias() {
global $db;

if(empty($this->params['id'])) {
$obj->model = $this->params['model'];
$obj->product_id = $this->params['product_id'];
$db->insertObject($obj,'model_aliases');

} else {
$model_alias = $db->selectObject('model_aliases', 'id =' .$this->params['id']);
$model_alias->model = $this->params['model'];
$db->updateObject($model_alias, 'model_aliases');
}

expHistory::back();
}

// This function delete the model alias in the product edit page
function delete_model_alias() {
global $db;

if (empty($this->params['id'])) return false;
$db->delete('model_aliases', 'id =' .$this->params['id']);

expHistory::back();
}

function _onlyreadables($string) {
for ($i=0;$i<strlen($string);$i++) {
$chr = $string{$i};
Expand Down
33 changes: 26 additions & 7 deletions framework/modules/ecommerce/products/views/product/edit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -513,13 +513,32 @@

<div id="skus">
<h2>Product SKUS / Model</h2>
<ul>
{foreach from=$record->model_alias item=item}
<li>
{$item->model}{br}
</li>
{/foreach}
</ul>
<a href='{link controller="store" action="edit_model_alias" product_id=`$record->id`}' class="add">Add Model Alias</a>
<table border="0" cellspacing="0" cellpadding="0" class="exp-skin-table">
<thead>
<tr>
<th style="width:50px">
&nbsp;
</th>
<th>
Alias
</th>
</tr>
</thead>
<tbody>
{foreach from=$record->model_alias item=model_alias key=key name=model_aliases}
<tr class="{cycle values='odd,even'}">
<td>
{icon action=edit_model_alias record=$model_alias img="edit.png"}
{icon action=delete_model_alias record=$model_alias img="delete.png"}
</td>
<td>
{$model_alias->model}
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>

<div id="misc">
Expand Down
24 changes: 24 additions & 0 deletions framework/modules/ecommerce/views/store/edit_model_alias.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{*
* Copyright (c) 2007-2008 OIC Group, Inc.
* Written and Designed by Adam Kessler
*
* This file is part of Exponent
*
* Exponent is free software; you can redistribute
* it and/or modify it under the terms of the GNU
* General Public License as published by the Free
* Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* GPL: http://www.gnu.org/licenses/gpl.txt
*
*}

{form action=update_model_alias}

{control type="hidden" name="product_id" value=$product_id}
{control type="hidden" name="id" value=$model_alias->id}
{control type="text" name="model" label="Model Alias:" value=$model_alias->model}

{control type="buttongroup" submit="Submit" cancel="Cancel"}
{/form}

0 comments on commit b311e45

Please sign in to comment.