// AdminController refactoring

This commit is contained in:
tDidierjean
2011-11-03 11:12:18 +00:00
parent f0b150df71
commit 4d6975727c
11 changed files with 68 additions and 66 deletions
@@ -56,7 +56,7 @@ class AdminAddressesControllerCore extends AdminController
'address1' => array('title' => $this->l('Address'), 'width' => 200),
'postcode' => array('title' => $this->l('Postcode/ Zip Code'), 'align' => 'right', 'width' => 50),
'city' => array('title' => $this->l('City'), 'width' => 150),
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'select' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
'country' => array('title' => $this->l('Country'), 'width' => 100, 'type' => 'select', 'list' => $this->countriesArray, 'filter_key' => 'cl!id_country'));
parent::__construct();
}
@@ -67,7 +67,7 @@ class AdminCustomersControllerCore extends AdminController
'icon' => $genders_icon,
'orderby' => false,
'type' => 'select',
'select' => $genders,
'list' => $genders,
'filter_key' => 'a!id_gender',
),
'lastname' => array(
@@ -60,7 +60,7 @@ class AdminEmployeesControllerCore extends AdminController
'lastname' => array('title' => $this->l('Last name'), 'width' => 130),
'firstname' => array('title' => $this->l('First name'), 'width' => 130),
'email' => array('title' => $this->l('E-mail address'), 'width' => 180),
'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'select' => $this->profiles_array, 'filter_key' => 'pl!name'),
'profile' => array('title' => $this->l('Profile'), 'width' => 90, 'type' => 'select', 'list' => $this->profiles_array, 'filter_key' => 'pl!name'),
'active' => array('title' => $this->l('Can log in'), 'align' => 'center', 'active' => 'status', 'type' => 'bool'),
);
+1 -1
View File
@@ -68,7 +68,7 @@ class AdminGendersController extends AdminController
'width' => 100,
'orderby' => false,
'type' => 'select',
'select' => array(
'list' => array(
0 => $this->l('Male'),
1 => $this->l('Female'),
2 => $this->l('Neutral')
@@ -175,7 +175,7 @@ class AdminGroupShopControllerCore extends AdminController
'name' => 'useImportData',
'value' => 1
),
'select' => array(
'list' => array(
'type' => 'select',
'name' => 'importFromShop',
'options' => array(
@@ -171,7 +171,7 @@ class AdminManufacturersControllerCore extends AdminController
'title' => $this->l('Country'),
'width' => 100,
'type' => 'select',
'select' => $this->countries_array,
'list' => $this->countries_array,
'filter_key' => 'cl!id_country'
)
);
+12 -12
View File
@@ -66,7 +66,7 @@ class AdminOrdersControllerCore extends AdminController
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 160, 'width' => 140, 'filter_key' => 'customer', 'tmpTableFilter' => true),
'total_paid' => array('title' => $this->l('Total'), 'width' => 70, 'align' => 'right', 'prefix' => '<b>', 'suffix' => '</b>', 'price' => true, 'currency' => true),
'payment' => array('title' => $this->l('Payment'), 'width' => 100),
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 230, 'type' => 'select', 'list' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false));
$this->shopLinkType = 'shop';
@@ -74,7 +74,7 @@ class AdminOrdersControllerCore extends AdminController
parent::__construct();
}
public function initForm()
{
parent::initForm();
@@ -438,18 +438,18 @@ class AdminOrdersControllerCore extends AdminController
{
$order = new Order((int)(Tools::getValue('id_order')));
$pcc = new PaymentCC((int)Tools::getValue('id_payment_cc'));
$pcc->id_order = $order->id;
$pcc->transaction_id = (string)Tools::getValue('transaction_id');
$pcc->id_currency = $order->id_currency;
$pcc->amount = $order->total_paid;
$pcc->save();
unset($order, $pcc);
}
elseif (Tools::isSubmit('submitAddOrder') == 1 && ($id_cart = Tools::getValue('id_cart')) && ($module_name = pSQL(Tools::getValue('payment_module_name'))) && ($id_order_state = Tools::getValue('id_order_state')))
{
if ($this->tabAccess['edit'] === '1')
{
$payment_module = Module::getInstanceByName($module_name);
@@ -511,7 +511,7 @@ class AdminOrdersControllerCore extends AdminController
if (Validate::isLoadedObject($addressDelivery) AND $addressDelivery->id_state)
$deliveryState = new State((int)($addressDelivery->id_state));
}
// Smarty assign
$this->context->smarty->assign(array(
'order' => $order,
@@ -562,7 +562,7 @@ class AdminOrdersControllerCore extends AdminController
$this->content = Tools::jsonEncode($to_return);
}
public function ajaxProcessSearchProducts()
{
$currency = new Currency((int)Tools::getValue('id_currency'));
@@ -584,10 +584,10 @@ class AdminOrdersControllerCore extends AdminController
$combinations[$attribute['id_product_attribute']]['default_on'] = $attribute['default_on'];
if (!isset($combinations[$attribute['id_product_attribute']]['price']))
$combinations[$attribute['id_product_attribute']]['price'] = Tools::displayPrice(Tools::convertPrice(Product::getPriceStatic((int)$product['id_product'], true, $attribute['id_product_attribute']), $currency), $currency);
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
if (!isset($combinations[$attribute['id_product_attribute']]['qty_in_stock']))
$combinations[$attribute['id_product_attribute']]['qty_in_stock']= StockAvailable::getStockAvailableForProduct((int)$product['id_product'], $attribute['id_product_attribute'], (int)$this->context->shop->getID());
}
foreach ($combinations AS &$combination)
$combination['attributes'] = rtrim($combination['attributes'], ' - ');
$product['combinations'] = $combinations;
@@ -597,13 +597,13 @@ class AdminOrdersControllerCore extends AdminController
}
else
$to_return = array('found' => false);
$this->content = Tools::jsonEncode($to_return);
}
public function ajaxProcessSendMailValidateOrder()
{
$errors = array();
$errors = array();
$cart = new Cart((int)Tools::getValue('id_cart'));
if (Validate::isLoadedObject($cart))
{
+18 -17
View File
@@ -1712,42 +1712,42 @@ if (false)
if($this->tabAccess['delete'])
$this->toolbar_btn['delete'] = array(
'short' => 'Delete',
'href' => $this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id.'&amp;deleteproduct',
'href' => $this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id.'&amp;deleteproduct',
'desc' => $this->l('Delete this product'),
'confirm' => 1);
if($this->tabAccess['add'])
$this->toolbar_btn['duplicate'] = array(
'short' => 'Duplicate',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Duplicate'),
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Duplicate'),
'confirm' => 1
);
// @TODO navigation
$this->toolbar_btn['preview'] = array(
'short' => 'Preview',
'href' => '', 'desc' => 'prevdesc',
'short' => 'Preview',
'href' => '', 'desc' => 'prevdesc',
'class' => 'previewUrl',
);
if (file_exists(_PS_MODULE_DIR_.'statsproduct/statsproduct.php'))
$this->toolbar_btn['stats'] = array(
'short' => 'Statistics',
'href' => $this->context->link->getAdminLink('AdminStats').'&amp;module=statsproduct&amp;id_product='.$product->id,
'desc' => $this->l('View product sales'),
'href' => $this->context->link->getAdminLink('AdminStats').'&amp;module=statsproduct&amp;id_product='.$product->id,
'desc' => $this->l('View product sales'),
);
$this->toolbar_btn['cancel'] = array(
'short' => 'Close',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Cancel'),
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Cancel'),
'confirm' => 1);
if($this->tabAccess['add'])
$this->toolbar_btn['new'] = array(
'short' => 'Create',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Create'),
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Create'),
);
if($this->tabAccess['edit'])
$this->toolbar_btn['save'] = array(
'short' => 'Save',
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Save'),
'href' => '#todo'.$this->context->link->getAdminLink('AdminProducts').'&amp;id_product='.$product->id, 'desc' => $this->l('Save'),
);
}
parent::initToolbar();
@@ -2378,7 +2378,7 @@ switch ($this->action)
'uploadable_files', 'text_fields'
);
// prices
array_push($product_props,
array_push($product_props,
'price', 'wholesale_price', 'id_tax_rules_group', 'unit_price_ratio', 'on_sale',
'unity'
);
@@ -3795,21 +3795,22 @@ $product->supplier_name = Supplier::getNameById($product->id_supplier);
{
if ($id = (int)(Tools::getValue($this->identifier)) AND Validate::isUnsignedId($id))
{
if (!$this->_object)
$this->_object = new $this->className($id);
if (Validate::isLoadedObject($this->_object))
return $this->_object;
if (!$this->object)
$this->object = new $this->className($id);
if (Validate::isLoadedObject($this->object))
return $this->object;
$this->_errors[] = Tools::displayError('Object cannot be loaded (not found)');
}
else if ($opt)
{
$this->_object = new $this->className();
return $this->_object;
$this->object = new $this->className();
return $this->object;
}
else
$this->_errors[] = Tools::displayError('Object cannot be loaded (identifier missing or invalid)');
$this->displayErrors();
return $this->object;
}
public function displayInitInformationAndAttachment()
@@ -52,7 +52,7 @@ class AdminStockMvtControllerCore extends AdminController
'align' => 'center',
'type' => 'select',
'filter_key' => 'a!sign',
'select' => array(
'list' => array(
'1' => $this->l('Increment'),
'-1' => $this->l('Decrement'),
),