Merge branch 'ticket/14716-order-mobile' into develop

This commit is contained in:
Michael RICOIS 2017-12-15 15:55:23 +01:00
commit 3fcceacb79
4 changed files with 64 additions and 23 deletions

View File

@ -44,7 +44,7 @@ class AdminOrders extends AdminTab
os.`color`,
IF(
(SELECT COUNT(so.id_order) FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer) > 1
AND (SELECT so.id_order FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer ORDER BY so.date_add ASC LIMIT 1) != a.id_order
AND (SELECT so.id_order FROM `'._DB_PREFIX_.'orders` so WHERE so.id_customer = a.id_customer ORDER BY so.date_add ASC LIMIT 1) != a.id_order
, 0, 1) as new,
(SELECT COUNT(od.`id_order`) FROM `'._DB_PREFIX_.'order_detail` od WHERE od.`id_order` = a.`id_order` GROUP BY `id_order`) AS product_number,
a.id_order AS `mixed`,
@ -72,13 +72,16 @@ class AdminOrders extends AdminTab
foreach(Country::getCountries((int) $cookie->id_lang, TRUE) as $country) {
$country_array[(int) $country['id_country']] = $country['name'];
}
$appliArray = array(
$deviceList = array(
0 => 'Site',
1 => 'Appli'
1 => 'Appli',
2 => 'Mobile',
);
foreach ($states AS $state)
foreach ($states AS $state){
$statesArray[$state['id_order_state']] = $state['name'];
}
$carriers = Db::getInstance()->ExecuteS('
SELECT c.`id_carrier`, IF(c.`name` = "0", "'.Configuration::get('PS_SHOP_NAME').'", c.`name`) AS `name`'.($this->cursale !== NULL? ', (
@ -91,20 +94,22 @@ class AdminOrders extends AdminTab
foreach ($carriers as $row) {
$carriersArray[(int)$row['id_carrier']] = $row['name'];
}
$this->fieldsDisplay = array(
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 100, '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' => 80),
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 200, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'id_carrier' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 80, 'callback' => 'printCarrier', 'orderby' => false, 'type' => 'select', 'select' => $carriersArray, 'filter_key' => 'a!id_carrier', 'filter_type' => 'int'),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
//'mixed' => array('title' => $this->l('Mixed'), 'callback' => 'printMixedSale', 'orderby' => false, 'search' => false),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false),
'id_country' => array('title' => $this->l('Pays'), 'callback' => 'printCountry', 'orderby' => false, 'type' => 'select', 'select' => $country_array, 'filter_key' => 'x!id_country', 'filter_type' => 'int', 'width' => 35,),
'appli' => array('title' => $this->l('Appli'), 'width' => 25, 'align' => 'center', 'type' => 'select', 'select' => $appliArray, 'filter_key' => 'a!appli', 'callback' => 'printAppliIcons', 'orderby' => false),
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
'new' => array('title' => $this->l('New'), 'width' => 25, 'align' => 'center', 'type' => 'bool', 'filter_key' => 'new', 'tmpTableFilter' => true, 'icon' => array(0 => 'blank.gif', 1 => 'news-new.gif'), 'orderby' => false),
'customer' => array('title' => $this->l('Customer'), 'widthColumn' => 100, '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' => 80),
'osname' => array('title' => $this->l('Status'), 'widthColumn' => 200, 'type' => 'select', 'select' => $statesArray, 'filter_key' => 'os!id_order_state', 'filter_type' => 'int', 'width' => 200),
'id_carrier' => array('title' => $this->l('Carrier'), 'align' => 'center', 'width' => 80, 'callback' => 'printCarrier', 'orderby' => false, 'type' => 'select', 'select' => $carriersArray, 'filter_key' => 'a!id_carrier', 'filter_type' => 'int'),
'date_add' => array('title' => $this->l('Date'), 'width' => 35, 'align' => 'right', 'type' => 'datetime', 'filter_key' => 'a!date_add'),
//'mixed' => array('title' => $this->l('Mixed'), 'callback' => 'printMixedSale', 'orderby' => false, 'search' => false),
'id_pdf' => array('title' => $this->l('PDF'), 'callback' => 'printPDFIcons', 'orderby' => false, 'search' => false),
'id_country' => array('title' => $this->l('Pays'), 'callback' => 'printCountry', 'orderby' => false, 'type' => 'select', 'select' => $country_array, 'filter_key' => 'x!id_country', 'filter_type' => 'int', 'width' => 35,),
'appli' => array('title' => $this->l('Device'), 'width' => 25, 'align' => 'center', 'type' => 'select', 'select' => $deviceList, 'filter_key' => 'a!appli', 'callback' => 'printDeviceIcons', 'orderby' => false),
);
parent::__construct();
if(!isset($_POST['submitFilter']) && !isset($_POST['orderFilter_a!date_add'])) {

View File

@ -3,8 +3,11 @@ class Order extends OrderCore {
/** @var boolean True if the order comes from app */
public $appli = 0;
/** @var int 1 if the order comes from mobile domain */
public $mobile = 0;
protected $fieldsValidate = array(
protected $fieldsValidate = array(
'id_address_delivery' => 'isUnsignedId',
'id_address_invoice' => 'isUnsignedId',
'id_cart' => 'isUnsignedId',
@ -27,7 +30,8 @@ class Order extends OrderCore {
'total_wrapping' => 'isPrice',
'shipping_number' => 'isUrl',
'conversion_rate' => 'isFloat',
'appli' => 'isBool'
'appli' => 'isBool',
'mobile' => 'isBool',
);
public function getFields()
@ -63,6 +67,7 @@ class Order extends OrderCore {
$fields['delivery_date'] = pSQL($this->delivery_date);
$fields['valid'] = (int)($this->valid) ? 1 : 0;
$fields['appli'] = (int)($this->appli) ? 1 : 0;
$fields['mobile'] = (int)($this->mobile) ? 1 : 0;
$fields['date_add'] = pSQL($this->date_add);
$fields['date_upd'] = pSQL($this->date_upd);
@ -87,7 +92,25 @@ class Order extends OrderCore {
public function printAppliIcons($value, $params)
{
$name = ((int)$value?'mobile':'computer');
$name = ((int)$value?'mobile':'computer');
return '<img src="/img/'.$name.'.png" alt="" width="18px"/>';
}
public function printDeviceIcons($value, $params)
{
switch($value) {
default:
case 0:
$name = 'computer';
break;
case 1:
$name = 'application';
break;
case 2:
$name = 'mobile';
break;
}
return '<img src="/img/'.$name.'.png" alt="" width="18px"/>';
}
@ -103,7 +126,6 @@ class Order extends OrderCore {
}
}
public static function getTotalbyDate($date_start, $date_end, $state = 0){
if($state == 0){
if($date_start == $date_end){

View File

@ -18,10 +18,15 @@
$message = "Problème de sercure_key. A valider manuellement" . "\n\n" . $message;
Logger::addLog('Invalid secure_key', 4, '0000001', 'Cart', intval($id_cart));
}
// Copying data from cart
$order = new Order();
$order->appli = Tools::isApi()?1:0;
$order->appli = 0;
if (Tools::isApi()) {
$order->appli = 1;
} elseif (Tools::isMobile()) {
$order->appli = 2;
}
$order->id_carrier = (int)($cart->id_carrier);
$order->id_customer = (int)($cart->id_customer);
$order->id_address_invoice = (int)($cart->id_address_invoice);

View File

@ -129,6 +129,15 @@ class Tools extends ToolsCore {
return true;
}
public static function isMobile()
{
if (_PS_MOBILE_ == 1) {
return true;
}
return false;
}
public static function isApi()
{
$subdomain = substr($_SERVER['HTTP_HOST'], 0, strpos($_SERVER['HTTP_HOST'], '.'));