[+] Project : B2B Features
This commit is contained in:
@@ -375,6 +375,93 @@ class AdminCustomersControllerCore extends AdminController
|
||||
);
|
||||
}
|
||||
|
||||
if (Configuration::get('PS_B2B_ENABLE')) {
|
||||
$risks = Risk::getRisks();
|
||||
|
||||
$list_risks = array();
|
||||
foreach ($risks as $key => $risk)
|
||||
{
|
||||
$list_risks[$key]['id_risk'] = (int) $risk->id;
|
||||
$list_risks[$key]['name'] = $risk->name;
|
||||
}
|
||||
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Company:'),
|
||||
'name' => 'company',
|
||||
'size' => 33
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('SIRET:'),
|
||||
'name' => 'siret',
|
||||
'size' => 14
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('APE:'),
|
||||
'name' => 'ape',
|
||||
'size' => 5
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Website:'),
|
||||
'name' => 'website',
|
||||
'size' => 33
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Outstanding allow:'),
|
||||
'name' => 'outstanding_allow_amount',
|
||||
'size' => 10,
|
||||
'hint' => $this->l('Valid characters:').' 0-9',
|
||||
'suffix' => '¤'
|
||||
);
|
||||
/*
|
||||
@todo RC Version
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'radio',
|
||||
'label' => $this->l('Show public prices:'),
|
||||
'name' => 'show_public_prices',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'is_bool' => true,
|
||||
'values' => array(
|
||||
array(
|
||||
'id' => 'show_public_prices_on',
|
||||
'value' => 1,
|
||||
'label' => $this->l('Enabled')
|
||||
),
|
||||
array(
|
||||
'id' => 'show_public_prices_off',
|
||||
'value' => 0,
|
||||
'label' => $this->l('Disabled')
|
||||
)
|
||||
),
|
||||
'desc' => $this->l('Show public prices on the front office if specific prices have been set ')
|
||||
);
|
||||
*/
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'text',
|
||||
'label' => $this->l('Max payment days:'),
|
||||
'name' => 'max_payment_days',
|
||||
'size' => 10,
|
||||
'hint' => $this->l('Valid characters:').' 0-9'
|
||||
);
|
||||
$this->fields_form['input'][] = array(
|
||||
'type' => 'select',
|
||||
'label' => $this->l('Risk:'),
|
||||
'name' => 'id_risk',
|
||||
'required' => false,
|
||||
'class' => 't',
|
||||
'options' => array(
|
||||
'query' => $list_risks,
|
||||
'id' => 'id_risk',
|
||||
'name' => 'name'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields_form['submit'] = array(
|
||||
'title' => $this->l(' Save '),
|
||||
'class' => 'button'
|
||||
|
||||
@@ -62,6 +62,13 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
'type' => 'textareaLang',
|
||||
'cols' => 40,
|
||||
'rows' => 8
|
||||
),
|
||||
'PS_INVOICE_MODEL' => array(
|
||||
'title' => $this->l('Invoice model:'),
|
||||
'desc' => $this->l('Choose an invoice model'),
|
||||
'type' => 'select',
|
||||
'identifier' => 'value',
|
||||
'list' => $this->getInvoicesModels()
|
||||
)
|
||||
),
|
||||
'submit' => array()
|
||||
@@ -240,4 +247,21 @@ class AdminInvoicesControllerCore extends AdminController
|
||||
if ((int)Tools::getValue('PS_INVOICE_START_NUMBER') != 0 && (int)Tools::getValue('PS_INVOICE_START_NUMBER') <= Order::getLastInvoiceNumber())
|
||||
$this->_errors[] = $this->l('Invalid invoice number (must be > ').Order::getLastInvoiceNumber().')';
|
||||
}
|
||||
|
||||
protected function getInvoicesModels()
|
||||
{
|
||||
$models = array(array('value'=>'invoice', 'name'=>'invoice'));
|
||||
$d = dir(_PS_THEME_DIR_.'/pdf/');
|
||||
while (false !== ($entry = $d->read()))
|
||||
{
|
||||
if (preg_match('`^(invoice-[a-z0-9]+)\.tpl$`', $entry, $matches)) {
|
||||
$models[] = array(
|
||||
'value' => $matches[1],
|
||||
'name' => $matches[1]
|
||||
);
|
||||
}
|
||||
}
|
||||
$d->close();
|
||||
return $models;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,175 @@
|
||||
<?php
|
||||
/*
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Open Software License (OSL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/osl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA
|
||||
* @version Release: $Revision: 6844 $
|
||||
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*/
|
||||
|
||||
class AdminOutstandingController extends AdminController
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
$this->table = 'order_invoice';
|
||||
$this->className = 'OrderInvoice';
|
||||
$this->addRowAction('view');
|
||||
|
||||
$this->context = Context::getContext();
|
||||
|
||||
$this->_select = '`id_order_invoice` AS `id_invoice`,
|
||||
`id_order_invoice` AS `outstanding`,
|
||||
CONCAT(LEFT(c.`firstname`, 1), \'. \', c.`lastname`) AS `customer`,
|
||||
c.`outstanding_allow_amount`,
|
||||
r.`color`,
|
||||
rl.`name` AS `risk`';
|
||||
$this->_join = 'LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = a.`id_order`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'customer` c ON (c.`id_customer` = o.`id_customer`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'risk` r ON (r.`id_risk` = c.`id_risk`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'risk_lang` rl ON (r.`id_risk` = rl.`id_risk` AND rl.`id_lang` = '.(int)$this->context->language->id.')';
|
||||
|
||||
$risks = array();
|
||||
foreach (Risk::getRisks() as $risk)
|
||||
{
|
||||
$risks[$risk->id] = $risk->name;
|
||||
}
|
||||
|
||||
$this->fieldsDisplay = array(
|
||||
'number' => array(
|
||||
'title' => $this->l('Invoice Number'),
|
||||
'align' => 'center',
|
||||
'width' => 20
|
||||
),
|
||||
'date_add' => array(
|
||||
'title' => $this->l('Date'),
|
||||
'width' => 150,
|
||||
'type' => 'date',
|
||||
'align' => 'right'
|
||||
),
|
||||
'customer' => array(
|
||||
'title' => $this->l('Customer'),
|
||||
'filter_key' => 'customer',
|
||||
'tmpTableFilter' => true
|
||||
),
|
||||
'company' => array(
|
||||
'title' => $this->l('Company'),
|
||||
'align' => 'center',
|
||||
'width' => 20
|
||||
),
|
||||
'risk' => array(
|
||||
'title' => $this->l('Risk'),
|
||||
'align' => 'center',
|
||||
'width' => 100,
|
||||
'orderby' => false,
|
||||
'type' => 'select',
|
||||
'color' => 'color',
|
||||
'list' => $risks,
|
||||
'filter_key' => 'r!id_risk',
|
||||
'filter_type' => 'int'
|
||||
),
|
||||
'outstanding_allow_amount' => array(
|
||||
'title' => $this->l('Outstanding Allow'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'prefix' => '<b>',
|
||||
'suffix' => '</b>',
|
||||
'type' => 'price'
|
||||
),
|
||||
'outstanding' => array(
|
||||
'title' => $this->l('Current Outstanding'),
|
||||
'align' => 'center',
|
||||
'width' => 50,
|
||||
'callback' => 'printOutstandingCalculation',
|
||||
'orderby' => false,
|
||||
'search' => false
|
||||
),
|
||||
'id_invoice' => array(
|
||||
'title' => $this->l('PDF'),
|
||||
'width' => 35,
|
||||
'align' => 'center',
|
||||
'callback' => 'printPDFIcons',
|
||||
'orderby' => false,
|
||||
'search' => false
|
||||
)
|
||||
);
|
||||
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toolbar initialisation
|
||||
* @return bool Force true (Hide New button)
|
||||
*/
|
||||
public function initToolbar()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Column callback for print PDF incon
|
||||
* @param $id_invoice integer Invoice ID
|
||||
* @param $tr array Row data
|
||||
* @return string HTML content
|
||||
*/
|
||||
public function printPDFIcons($id_invoice, $tr)
|
||||
{
|
||||
$this->context->smarty->assign(array(
|
||||
'id_invoice' => $id_invoice
|
||||
));
|
||||
|
||||
return $this->context->smarty->fetch('outstanding/_print_pdf_icon.tpl');
|
||||
}
|
||||
|
||||
public function printOutstandingCalculation($id_invoice, $tr)
|
||||
{
|
||||
$order_invoice = new OrderInvoice($id_invoice);
|
||||
if (!Validate::isLoadedObject($order_invoice))
|
||||
throw new PrestashopException('object OrderInvoice can\'t be loaded');
|
||||
$order = new Order($order_invoice->id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
throw new PrestashopException('object Order can\'t be loaded');
|
||||
$customer = new Customer((int)$order->id_customer);
|
||||
if (!Validate::isLoadedObject($order_invoice))
|
||||
throw new PrestashopException('object Customer can\'t be loaded');
|
||||
|
||||
return '<b>'.$customer->getOutstanding().'</b>';
|
||||
}
|
||||
|
||||
/**
|
||||
* View render
|
||||
* @throws PrestashopException Invalid objects
|
||||
*/
|
||||
public function renderView()
|
||||
{
|
||||
$order_invoice = new OrderInvoice((int) Tools::getValue('id_order_invoice'));
|
||||
if (!Validate::isLoadedObject($order_invoice))
|
||||
throw new PrestashopException('object OrderInvoice can\'t be loaded');
|
||||
$order = new Order($order_invoice->id_order);
|
||||
if (!Validate::isLoadedObject($order))
|
||||
throw new PrestashopException('object Order can\'t be loaded');
|
||||
|
||||
$link = $this->context->link->getAdminLink('AdminOrders');
|
||||
$link .= '&vieworder&id_order='.$order->id;
|
||||
$this->redirect_after = $link;
|
||||
$this->redirect();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -156,6 +156,13 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
'default' => '480',
|
||||
'visibility' => Shop::CONTEXT_ALL
|
||||
),
|
||||
'PS_B2B_ENABLE' => array(
|
||||
'title' => $this->l('Enable B2B mode'),
|
||||
'desc' => $this->l('Activate or deactivate B2B mode. When this option is enable some features about B2B appear.'),
|
||||
'validation' => 'isBool',
|
||||
'cast' => 'intval',
|
||||
'type' => 'bool'
|
||||
),
|
||||
'PS_ORDER_PROCESS_TYPE' => array(
|
||||
'title' => $this->l('Order process type'),
|
||||
'desc' => $this->l('You can choose the order process type as either standard (5 steps) or One Page Checkout'),
|
||||
@@ -389,4 +396,25 @@ class AdminPreferencesControllerCore extends AdminController
|
||||
$value = ($max_size < Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE')) ? $max_size : Tools::getValue('PS_ATTACHMENT_MAXIMUM_SIZE');
|
||||
Configuration::update('PS_ATTACHMENT_MAXIMUM_SIZE', $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update PS_B2B_ENABLE and enables / disables the associated tabs
|
||||
* @param $value integer Value of option
|
||||
*/
|
||||
public function updateOptionPsB2bEnable($value)
|
||||
{
|
||||
$value = (int)$value;
|
||||
|
||||
$tabs_class_name = array('AdminOutstanding');
|
||||
if (!empty($tabs_class_name)) {
|
||||
foreach ($tabs_class_name as $tab_class_name) {
|
||||
$tab = Tab::getInstanceFromClassName($tab_class_name);
|
||||
if (Validate::isLoadedObject($tab)) {
|
||||
$tab->active = $value;
|
||||
$tab->save();
|
||||
}
|
||||
}
|
||||
}
|
||||
Configuration::updateValue('PS_B2B_ENABLE', $value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user