Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions application/configs/migrations/1364484670_version18.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Version18 extends Doctrine_Migration_Base
{
public function up()
{
$this->addColumn('products', 'uuid', 'varbinary', '16', array(
));
$this->addColumn('products', 'sku', 'string', '25', array(
));
}

public function down()
{
$this->removeColumn('products', 'uuid');
$this->removeColumn('products', 'sku');
}
}
17 changes: 17 additions & 0 deletions application/configs/migrations/1364487102_version19.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php
/**
* This class has been auto-generated by the Doctrine ORM Framework
*/
class Version19 extends Doctrine_Migration_Base
{
public function up()
{
$this->changeColumn('products', 'uuid', 'string', '40', array(
));
}

public function down()
{

}
}
4 changes: 4 additions & 0 deletions application/configs/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2177,6 +2177,10 @@ Products:
unsigned: false
primary: true
autoincrement: true
uuid:
type: string(40)
sku:
type: string(25)
uri:
type: string(150)
notnull: true
Expand Down
2 changes: 1 addition & 1 deletion application/models/Navigation.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public static function CreateMenu($items, $parent_id = 0, $level = 0) {
* GetItems
* Get all the childs reading the main array
*/
private function GetItems($items, $parent_id) {
public static function GetItems($items, $parent_id) {
$tmp_array = array ();
for($i = 0; $i < count ( $items ); $i ++) {
if ($items [$i] ['parent_id'] == $parent_id) {
Expand Down
2 changes: 1 addition & 1 deletion application/models/OrdersItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -625,7 +625,7 @@ public static function CheckIfProductExist($product_id) {
* Get all the orders where the product has been selected.
* @return array
*/
public function ProductsInOrdersItems($product_id) {
public static function ProductsInOrdersItems($product_id) {
if (is_numeric ( $product_id )) {
$records = Doctrine_Query::create ()->select ( 'DATE_FORMAT(oi.date_start, "%d/%m/%Y") as date, CONCAT(c.firstname, " ", c.lastname, " - ", c.company) as customer, oi.quantity, oi.order_id as orderid, s.status as status' )
->from ( 'OrdersItems oi' )
Expand Down
59 changes: 35 additions & 24 deletions application/models/Products.php
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,11 @@ public static function saveAll($id, $params, $locale = 1) {
}else{
$products->inserted_at = date('Y-m-d H:i:s');
}

// Product UUID is missing, generate a new one
if ( empty($products->uuid) ) {
$products->uuid = Shineisp_Commons_Uuid::generate();
}

try {
if(!empty($_FILES ['attachments'])){
Expand All @@ -190,43 +195,49 @@ public static function saveAll($id, $params, $locale = 1) {
}
}
if(is_array($params)){
$products->updated_at = date('Y-m-d H:i:s');
$products->categories = ! empty ( $params ['categories'] ) ? $params ['categories'] : null;
$products->uri = ! empty ( $params ['uri'] ) ? Shineisp_Commons_UrlRewrites::format ( $params ['uri'] ) : Shineisp_Commons_UrlRewrites::format ( $params ['name'] );
$products->cost = $params ['cost'];
$products->price_1 = $params ['price_1'];
$products->setupfee = $params ['setupfee'];
$products->enabled = $params ['enabled'] == 1 ? 1 : 0;
$products->iscomparable = !empty($params ['iscomparable']) ? 1 : 0;
$products->tax_id = !empty($params ['tax_id']) ? $params ['tax_id'] : NULL;
$products->type = !empty($params ['type']) ? $params ['type'] : "generic";
$products->blocks = !empty($params ['blocks']) ? $params ['blocks'] : NULL;
$products->group_id = !empty($params ['group_id']) ? $params ['group_id'] : NULL;
$products->position = !empty($params ['position']) ? $params ['position'] : NULL;
$products->setup = !empty($params ['setup']) ? $params ['setup'] : NULL;
$products->updated_at = date('Y-m-d H:i:s');
$products->categories = ! empty ( $params ['categories'] ) ? $params ['categories'] : null;
$products->uri = ! empty ( $params ['uri'] ) ? Shineisp_Commons_UrlRewrites::format ( $params ['uri'] ) : Shineisp_Commons_UrlRewrites::format ( $params ['name'] );
$products->sku = ! empty ( $params ['sku'] ) ? $params ['sku'] : '';
$products->cost = $params ['cost'];
$products->price_1 = $params ['price_1'];
$products->setupfee = $params ['setupfee'];
$products->enabled = $params ['enabled'] == 1 ? 1 : 0;
$products->iscomparable = !empty($params ['iscomparable']) ? 1 : 0;
$products->tax_id = !empty($params ['tax_id']) ? $params ['tax_id'] : NULL;
$products->type = !empty($params ['type']) ? $params ['type'] : "generic";
$products->blocks = !empty($params ['blocks']) ? $params ['blocks'] : NULL;
$products->group_id = !empty($params ['group_id']) ? $params ['group_id'] : NULL;
$products->position = !empty($params ['position']) ? $params ['position'] : NULL;
$products->setup = !empty($params ['setup']) ? $params ['setup'] : NULL;
$products->ishighlighted = !empty($params ['ishighlighted']) ? 1 : 0;
$products->showonrss = !empty($params ['showonrss']) ? 1 : 0;
$products->external_id = !empty($params ['external_id']) ? $params ['external_id'] : NULL;
$products->showonrss = !empty($params ['showonrss']) ? 1 : 0;
$products->external_id = !empty($params ['external_id']) ? $params ['external_id'] : NULL;

// Save the data
$products->save ();
$product_id = $products->product_id;

// Save the product attributes
ProductsAttributesIndexes::saveAll ( $params, $product_id );

$Pdata = ProductsData::findbyProductID ( $product_id, $locale );
if (empty ( $Pdata )) {
$Pdata = new ProductsData ();
$Pdata = new ProductsData ();
}

//* Product name can not be changed if product is sold
if ( ! (bool)OrdersItems::CheckIfProductExist($product_id) ) {
$Pdata->name = $params ['name'];
}

$Pdata->name = $params ['name'];
$Pdata->nickname = $params ['nickname'];
$Pdata->nickname = $params ['nickname'];
$Pdata->shortdescription = $params ['shortdescription'];
$Pdata->description = $params ['description'];
$Pdata->metakeywords = $params ['metakeywords'];
$Pdata->metadescription = $params ['metadescription'];
$Pdata->product_id = $product_id;
$Pdata->language_id = $locale;
$Pdata->description = $params ['description'];
$Pdata->metakeywords = $params ['metakeywords'];
$Pdata->metadescription = $params ['metadescription'];
$Pdata->product_id = $product_id;
$Pdata->language_id = $locale;
$Pdata->save ();

// Create the price tranches
Expand Down
4 changes: 2 additions & 2 deletions application/models/ProductsCategories.php
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ public static function pager($dq, $rows=10){
* $categories = 1/2/5
* @params string $categories
*/
public function getGoogleCategories($categories) {
public static function getGoogleCategories($categories) {
$cats = array ();
$i = 0;
$categories = explode ( "/", $categories );
Expand All @@ -348,7 +348,7 @@ public function getGoogleCategories($categories) {
* get all the categories information by categories ID
* $categories = 1/2/5
*/
public function getCategoriesInfo($categories) {
public static function getCategoriesInfo($categories) {
$cats = array ();
$i = 0;
$categories = explode ( "/", $categories );
Expand Down
10 changes: 10 additions & 0 deletions application/models/generated/BaseProducts.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
* This class has been auto-generated by the Doctrine ORM Framework
*
* @property integer $product_id
* @property string $uuid
* @property string $sku
* @property string $uri
* @property timestamp $inserted_at
* @property timestamp $updated_at
Expand Down Expand Up @@ -58,6 +60,14 @@ public function setTableDefinition()
'autoincrement' => true,
'length' => '4',
));
$this->hasColumn('uuid', 'string', 40, array(
'type' => 'string',
'length' => '40',
));
$this->hasColumn('sku', 'string', 25, array(
'type' => 'string',
'length' => '25',
));
$this->hasColumn('uri', 'string', 150, array(
'type' => 'string',
'notnull' => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,8 @@ private function servicesGrid() {
try {
if (isset ( $request->id ) && is_numeric ( $request->id )) {
// In order to select only the fields interested we have to add an alias to all the fields. If the aliases are not created Doctrine will require an index field for each join created.
$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' );
//$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, pd.name as productname' );
$rs = Products::getAllServicesByCustomerID ( $request->id, 'oi.detail_id as detail_id, oi.order_id as orderid, oi.date_start as datestart, oi.date_end as dateend, pd.name as productname' );
if ($rs) {
return array ('name' => 'services', 'records' => $rs, 'edit' => array ('controller' => 'services', 'action' => 'edit' ), 'pager' => true );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,6 @@ public function editAction() {
$rs = $this->products->getAllInfo ( $id, $this->session->langid );

if (! empty ( $rs )) {

// Join the translated data information to populate the form
$data = !empty($rs['ProductsData'][0]) ? $rs['ProductsData'][0] : array();
$rs = array_merge($rs, $data);
Expand Down Expand Up @@ -267,6 +266,7 @@ public function editAction() {
$this->view->mex = $this->getRequest ()->getParam ( 'mex' );
$this->view->mexstatus = $this->getRequest ()->getParam ( 'status' );
$this->view->orders = $orders;
$this->view->isSold = (bool)OrdersItems::CheckIfProductExist($id);

$this->view->form = $form;
$this->render ( 'applicantform' );
Expand Down
7 changes: 7 additions & 0 deletions application/modules/admin/forms/ProductsForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ public function init()
'decorators' => array('Composite'),
'class' => 'text-input large-input'
));

$this->addElement('text', 'sku', array(
'filters' => array('StringTrim'),
'label' => 'SKU',
'decorators' => array('Composite'),
'class' => 'text-input large-input'
));

$this->addElement('textarea', 'shortdescription', array(
'filters' => array('StringTrim'),
Expand Down
79 changes: 76 additions & 3 deletions application/modules/admin/views/helpers/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,37 @@ public function menu() {

if($identity){
if(AdminPermissions::isAllowed($identity, "admin", "settings")){
/* JAY - 20130328 GUEST
* Add class 'showall' to active item on reload of page.
* *****/
$request = Zend_Controller_Front::getInstance()->getRequest();
$linkActive = $request->getRequestUri();

$configuration = SettingsGroups::getlist ();
$data .= "<li class=\"item config\">";
$data .= "<a href=\"\">".$this->translation->translate('Configuration')."</a>";
$data .= "<ul class=\"subnav\">";
$showall = "";
foreach ($configuration as $id => $item){
$data .= "<li class=\"item\"><a href=\"/admin/settings/index/groupid/".$id."\">" . $this->translation->translate($item) . "</a></li>";
$showall = "";
$tryLink = '/admin/settings';
$path = explode('/',$linkActive);
$cpath = count($path);
if( $cpath > 1 ) {
if( $cpath > 2 ) {
for( $i=3; $i < $cpath; $i++) {
array_pop($path);
}
}


$tryLinkActive = implode('/',$path);
if( $tryLinkActive == $tryLink ) {
$showall = "showall";
}
}

$data .= "<li class=\"item {$showall}\"><a href=\"/admin/settings/index/groupid/".$id."\">" . $this->translation->translate($item) . "</a></li>";
}
$data .= "</li>";
$data .= "</ul>";
Expand All @@ -59,20 +84,68 @@ public function menu() {
/**
* createMenu
* Create the menu
*
* @param unknown_type $parent
*/
private function createMenu($parent) {
$children = Navigation::getParent ( $parent );
$items = array ();

/* JAY - 20130328 - GUEST
* Get the RequestURI to show item
* ***/
$request = Zend_Controller_Front::getInstance()->getRequest();
$linkActive = $request->getRequestUri();
// END

if (is_array ( $children )) {
foreach ( $children as $row ) {
if($row['parent_id']){
$link = ! empty ( $row ['url'] ) ? $row ['url'] : "/";
$link = ! empty ( $row ['url'] ) ? $row ['url'] : "/";
}else{
$link = "#";
}
$items [] = "<li class=\"item\"><a href=\"" . $link . "\">" . $this->translation->translate($row ['label']) . "</a>" . $this->createMenu ( $row ['id'] ) . "</li>";

/* JAY - 20130328 GUEST
* Add class 'showall' to active item on reload of page.
* *****/
$showall = "";
if( $linkActive == $link ) {
$showall = "showall";
} else {
//Try to remove action
$pathLink = explode('/',$link);
$cpathLink = count( $pathLink );
if( $cpathLink > 3 ) {
for( $i=4; $i<=$cpathLink; $i++){
array_pop($pathLink);
}

}
$tryLink = implode('/',$pathLink);
$path = explode('/',$linkActive);
$cpath = count($path);
if( $cpath > 1 ) {
if( $cpath > 2 ) {
for( $i=3; $i < $cpath; $i++) {
array_pop($path);
}
}


$tryLinkActive = implode('/',$path);
if( $tryLinkActive == $tryLink ) {
$showall = "showall";
}
}
}

$items [] = '
<li class="item '.$showall.'">
<a href="'.$link.'">
'.$this->translation->translate($row ['label']).'
</a>'.$this->createMenu ( $row ['id'] ).'
</li>';
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@

<div class="ui-tabs-hide default-tab" id="tab1">
<fieldset class=column-left>
<?php echo $form->sku->render()?>
<?php echo $form->type->render()?>
<?php echo $form->group_id->render() ?>
<?php echo $form->name->render() ?>
Expand Down Expand Up @@ -164,5 +165,9 @@

<script type="text/javascript">
var data = <?php echo $this->categories ?>;

$(document).ready(function() {
$('#name').attr('readonly', <?=$this->isSold?>);
});
</script>
</div>
Loading