Skip to content

Commit

Permalink
Correction bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
benjamin committed May 31, 2016
1 parent 1c1376f commit 68fc6e0
Show file tree
Hide file tree
Showing 31 changed files with 562 additions and 665 deletions.
2 changes: 1 addition & 1 deletion classes/controllers/LengowController.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public function display()
$path = $lengowMain->fromCamelCase(Tools::substr($className, 0, Tools::strlen($className) - 10));
echo $module->display(
_PS_MODULE_LENGOW_DIR_,
'views/templates/admin/' . $path . '/helpers/view/view.tpl'
'views/templates/admin/'.$path.'/helpers/view/view.tpl'
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion classes/controllers/LengowFeedController.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function display()
$lengowExport = new LengowExport(array(
"shop_id" => $shop->id
));
$shopCollection[]= array(
$shopCollection[] = array(
'shop' => $shop,
'link' => LengowMain::getExportUrl($shop->id),
'total_product' => $lengowExport->getTotalProduct(),
Expand Down
54 changes: 42 additions & 12 deletions classes/controllers/LengowHelpController.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,24 +27,54 @@ class LengowHelpController extends LengowController
*/
public function postProcess()
{
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : false;
if ($action) {
switch ($action) {
case 'get_help_data':
$data = array();
$data['function'] = 'sync';
$data['parameters'] = LengowSync::getSyncData();
echo Tools::jsonEncode($data);
break;
}
exit();
}
}

public function display()
{
$lengowLink = new LengowLink();
$this->context->smarty->assign('mailto', $this->getMailTo());
$this->context->smarty->assign('lengow_ajax_link', $lengowLink->getAbsoluteAdminLink('AdminLengowHelp', true));
parent::display();
}

/**
* Generate mailto for help page
*/
public function getMailTo()
{
$mailto = LengowSync::getSyncData();
$mail = 'support.lengow.zendesk@lengow.com';
$subject = $this->locale->t('help.screen.mailto_subject');
$result = LengowConnector::queryApi('get', '/v3.0/cms');
$body = '%0D%0A%0D%0A%0D%0A%0D%0A%0D%0A'
. $this->locale->t('help.screen.mail_lengow_support_title').'%0D%0A';
if (isset($result->cms)) {
$body .= 'commun_account : '.$result->cms->common_account.'%0D%0A';
}
foreach ($mailto as $key => $value) {
if ($key == 'domain_name' || $key == 'token' || $key == 'return_url' || $key == 'shops') {
continue;
}
$body .= $key.' : '.$value.'%0D%0A';
}
$shops = $mailto['shops'];
$i = 1;
foreach ($shops as $shop) {
foreach ($shop as $item => $value) {
if ($item == 'name') {
$body .= 'Store '.$i.' : '.$value.'%0D%0A';
} elseif ($item == 'feed_url') {
$body .= $value . '%0D%0A';
}
}
$i++;
}
$html = '<a href="mailto:'. $mail;
$html.= '?subject='. $subject;
$html.= '&body='. $body .'" ';
$html.= 'title="'. $this->locale->t('help.screen.need_some_help').'" target="_blank">';
$html.= $this->locale->t('help.screen.mail_lengow_support');
$html.= '</a>';
return $html;
}
}
1 change: 1 addition & 0 deletions classes/controllers/LengowHomeController.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public function display()
if (!$this->isNewMerchant) {
$this->context->smarty->assign('stats', LengowStatistic::get());
}

$lengowLink = new LengowLink();
$this->context->smarty->assign('lengow_ajax_link', $lengowLink->getAbsoluteAdminLink('AdminLengowHome', true));
parent::display();
Expand Down
1 change: 1 addition & 0 deletions classes/controllers/LengowLegalsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function postProcess()

public function display()
{
$this->context->smarty->assign('iso_code', Context::getContext()->language->iso_code);
parent::display();
}
}
10 changes: 3 additions & 7 deletions classes/controllers/LengowOrderController.php
Original file line number Diff line number Diff line change
Expand Up @@ -362,11 +362,6 @@ public function loadTable()
'display_callback' => 'LengowOrderController::displayLengowExtra'
);
}
/*$fields_list['search'] = array(
'title' => '',
'width' => '10%',
'button_search' => true
);*/
$select = array(
'lo.id',
'lo.marketplace_sku',
Expand Down Expand Up @@ -555,7 +550,7 @@ public static function displayLogStatus($key, $value, $item)
$message = '<ul>'.join('', $errorMessage).'</ul>';
if ($item[$key] == '2') {
$message = LengowMain::decodeLogMessage('order.screen.action_sent_not_work')
.join('<br/>', $errorMessage);
.'<br/>'.join('<br/>', $errorMessage);
$value = '<a href="#"
class="lengow_re_send lengow_link_tooltip lgw-btn lgw-btn-white"
data-href="'.$link->getAbsoluteAdminLink('AdminLengowOrder', true).'"
Expand All @@ -566,7 +561,8 @@ class="lengow_re_send lengow_link_tooltip lgw-btn lgw-btn-white"
data-original-title="'.$message.'"
>'.LengowMain::decodeLogMessage('order.screen.not_sent').' <i class="fa fa-refresh"></i></a>';
} else {
$message = LengowMain::decodeLogMessage('order.screen.order_not_imported').join('<br/>', $errorMessage);
$message = LengowMain::decodeLogMessage('order.screen.order_not_imported')
.'<br/>'.join('<br/>', $errorMessage);
$value = '<a href="#"
class="lengow_re_import lengow_link_tooltip lgw-btn lgw-btn-white"
data-href="'.$link->getAbsoluteAdminLink('AdminLengowOrder', true).'"
Expand Down
8 changes: 1 addition & 7 deletions classes/models/LengowConfiguration.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,12 +152,6 @@ public static function getKeys()
'label' => $locale->t('lengow_setting.lengow_import_preprod_enabled_title'),
'legend' => $locale->t('lengow_setting.lengow_import_preprod_enabled_legend'),
),
'LENGOW_IMPORT_FAKE_EMAIL' => array(
'type' => 'checkbox',
'label' => $locale->t('lengow_setting.lengow_import_fake_mail_title'),
'legend' => $locale->t('lengow_setting.lengow_import_fake_mail_legend'),
'default_value' => true,
),
'LENGOW_IMPORT_SHIP_MP_ENABLED' => array(
'type' => 'checkbox',
'label' => $locale->t('lengow_setting.lengow_import_ship_mp_enabled_title'),
Expand Down Expand Up @@ -277,7 +271,7 @@ public static function updateValue($key, $values, $html = false, $id_shop_group

public static function getReportEmailAddress()
{
$emails = explode(',', self::get('LENGOW_REPORT_MAIL_ADDRESS'));
$emails = explode(';', self::get('LENGOW_REPORT_MAIL_ADDRESS'));
if ($emails[0] == '') {
$emails[0] = self::get('PS_SHOP_EMAIL');
}
Expand Down
1 change: 1 addition & 0 deletions classes/models/LengowHook.php
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,7 @@ public function hookAdminOrder($args)
'tracking_method' => $lengow_order->lengow_method,
'tracking' => $lengow_order->lengow_tracking,
'tracking_carrier' => $lengow_order->lengow_carrier,
'customer_email' => $lengow_order->lengow_customer_email,
'sent_markeplace' => $sent_markeplace,
'message' => $lengow_order->lengow_message,
'action_synchronize' => $action_synchronize,
Expand Down
31 changes: 16 additions & 15 deletions classes/models/LengowImportOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,8 @@ public function importOrder()
LengowMain::log(
'Import',
LengowMain::setLogMessage('log.import.error_already_created', array(
'decoded_message' => $decoded_message,
'date_message' => $import_log['date']
'decoded_message' => $decoded_message,
'date_message' => $import_log['date']
)),
$this->log_output,
$this->marketplace_sku
Expand Down Expand Up @@ -303,13 +303,18 @@ public function importOrder()
$this->loadTrackingData();
// get customer name
$customer_name = $this->getCustomerName();
$customer_email = (!is_null($this->order_data->billing_address->email)
? (string)$this->order_data->billing_address->email
: (string)$this->package_data->delivery->email
);
// update Lengow order with new informations
LengowOrder::updateOrderLengow(
$this->id_order_lengow,
array(
'total_paid' => $this->order_amount,
'order_item' => $this->order_items,
'customer_name' => pSQL($customer_name),
'customer_email' => pSQL($customer_email),
'carrier' => pSQL($this->carrier_name),
'method' => pSQL($this->carrier_method),
'tracking' => pSQL($this->tracking_number),
Expand Down Expand Up @@ -748,19 +753,15 @@ protected function getCartData()
// get billing datas
$billing_data = LengowAddress::extractAddressDataFromAPI($this->order_data->billing_address);
// create customer based on billing data
if (LengowConfiguration::getGlobalValue('LENGOW_IMPORT_FAKE_EMAIL')
|| $this->preprod_mode
|| empty($billing_data['email'])
) {
$domain = !LengowMain::getHost() ? 'prestashop.shop' : LengowMain::getHost();
$billing_data['email'] = 'generated-email+'.$this->marketplace_sku.'@'.$domain;
LengowMain::log(
'Import',
LengowMain::setLogMessage('log.import.generate_unique_email', array('email' => $billing_data['email'])),
$this->log_output,
$this->marketplace_sku
);
}
// generation of fictitious email
$domain = !LengowMain::getHost() ? 'prestashop.shop' : LengowMain::getHost();
$billing_data['email'] = $this->marketplace_sku.'-'.$this->marketplace->name.'@'.$domain;
LengowMain::log(
'Import',
LengowMain::setLogMessage('log.import.generate_unique_email', array('email' => $billing_data['email'])),
$this->log_output,
$this->marketplace_sku
);
// update Lengow order with customer name
$customer = $this->getCustomer($billing_data);
if (!$customer->id) {
Expand Down
16 changes: 8 additions & 8 deletions classes/models/LengowList.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,10 @@ public function __construct($params)
*/
public function displayHeader($order)
{
if (count($this->collection) == 0) {
$tableClass="table_no_result";
}
$tableClass = (count($this->collection) == 0 ? 'table_no_result' : '');
$newOrder = ( empty($this->orderValue) || $this->orderValue == "ASC" ) ? 'DESC' : "ASC";
$html ='<table class="lengow_table table table-bordered table-striped table-hover '.$tableClass.'" id="table_'.$this->id.'">';
$html ='<table class="lengow_table table table-bordered table-striped table-hover '.$tableClass.'"
id="table_'.$this->id.'">';
$html.='<thead>';
$html.='<tr>';

Expand All @@ -94,7 +93,8 @@ public function displayHeader($order)
}
$html.='<th>';
if (isset($values['filter_order']) && $values['filter_order']) {
$html.='<a href="#" class="table_order '.$orderClass.'" data-order="'.$newOrder.'" data-column="'.$values['filter_key'].'">'.$values['title'].'</a>';
$html.='<a href="#" class="table_order '.$orderClass.'" data-order="'.$newOrder.'"
data-column="'.$values['filter_key'].'">'.$values['title'].'</a>';
} else {
$html.=$values['title'];
}
Expand Down Expand Up @@ -142,7 +142,8 @@ class="lengow_select_all lengow_link_tooltip"/></th>';
break;
}
} elseif (isset($values['button_search']) && $values['button_search']) {
$html.= '<input type="submit" value="'.$this->locale->t('product.screen.button_search').'" class="lgw-btn lgw-btn-white">';
$html.= '<input type="submit" value="'.$this->locale->t('product.screen.button_search').'"
class="lgw-btn lgw-btn-white">';
}
$html.= '</th>';
}
Expand All @@ -163,8 +164,7 @@ public function displayContent()
if (count($this->collection) == 0) {
$html.= '<tr><td colspan="100%" align="center"><div id="lengow_no_result_message">
<span class="img_no_result"></span>
<h2 class="title_no_result">'.htmlspecialchars_decode($this->locale->t('product.screen.no_result_found_title')).'</h2>
<p class="description_no_result">'.htmlspecialchars_decode($this->locale->t('product.screen.no_result_found_description')).'</p>
<h2 class="title_no_result">'.$this->locale->t('product.screen.no_result_found_title').'</h2>
</div></td></tr>';
} else {
foreach ($this->collection as $item) {
Expand Down
7 changes: 7 additions & 0 deletions classes/models/LengowOrder.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ class LengowOrder extends Order
*/
public $lengow_customer_name;

/**
* @var string email of the customer
*/
public $lengow_customer_email;

/**
* @var string current lengow state
*/
Expand Down Expand Up @@ -220,6 +225,7 @@ protected function loadLengowFields()
lo.`delivery_address_id`,
lo.`delivery_country_iso`,
lo.`customer_name`,
lo.`customer_email`,
lo.`order_lengow_state`,
lo.`order_item`
FROM `'._DB_PREFIX_.'lengow_orders` lo
Expand All @@ -244,6 +250,7 @@ protected function loadLengowFields()
$this->lengow_delivery_address_id = (int)$result['delivery_address_id'];
$this->lengow_delivery_country_iso = $result['delivery_country_iso'];
$this->lengow_customer_name = $result['customer_name'];
$this->lengow_customer_email = $result['customer_email'];
$this->lengow_state = $result['order_lengow_state'];
$this->lengow_order_item = (int)$result['order_item'];
return true;
Expand Down
1 change: 0 additions & 1 deletion toolbox/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@
'LENGOW_IMPORT_FORCE_PRODUCT',
'LENGOW_IMPORT_PROCESSING_FEE',
'LENGOW_IMPORT_DAYS',
'LENGOW_IMPORT_FAKE_EMAIL',
'LENGOW_IMPORT_SHIP_MP_ENABLED',
'LENGOW_IMPORT_STOCK_SHIP_MP',
'LENGOW_IMPORT_SINGLE_ENABLED'
Expand Down
Loading

0 comments on commit 68fc6e0

Please sign in to comment.