This commit is contained in:
2025-04-01 00:38:54 +02:00
parent d4d4c0c09d
commit 87da06293a
22351 changed files with 5168854 additions and 7538 deletions

View File

@@ -0,0 +1,110 @@
<?php
/**
* 2007-2016 PrestaShop
*
* 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-2015 PrestaShop SA
* @license http://addons.prestashop.com/en/content/12-terms-and-conditions-of-use
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminAjaxPsgdprController extends ModuleAdminController
{
/**
* This function allow to delete users
*
* @param id $id_customer id of the user to delete
* @return array $log log of the process
*/
public function ajaxProcessDeleteCustomer()
{
$delete = Tools::getValue('delete');
$value = Tools::getValue('value');
$this->module->deleteCustomer($delete, $value);
}
/**
* Return all customers matches for the search
*
* @param string input value of the search
* @return array customers list
*/
public function ajaxProcessSearchCustomers()
{
$searches = explode(' ', Tools::getValue('customer_search'));
$customers = array();
$searches = array_unique($searches);
foreach ($searches as $search) {
if (!empty($search) && $results = Customer::searchByName($search, 50)) {
foreach ($results as $result) {
if ($result['active']) {
$result['fullname_and_email'] = $result['firstname'].' '.$result['lastname'].' - '.$result['email'];
$customers[$result['id_customer']] = $result;
}
}
}
}
if (count($customers) && !Tools::getValue('sf2')) {
$customerList = array();
foreach ($customers as $customer) {
array_push($customerList, array(
'id_customer' => $customer['id_customer'],
'firstname' => $customer['firstname'],
'lastname' => $customer['lastname'],
'email' => $customer['email'],
'birthday' => $customer['birthday'],
'nb_orders' => Order::getCustomerNbOrders($customer['id_customer']),
'customerData' => array(),
));
}
$to_return = array(
'customers' => $customerList,
'found' => true
);
} else {
$to_return = Tools::getValue('sf2') ? array() : array('found' => false);
}
die(json_encode($to_return));
}
/**
* Return all collected for the giver customer
*
* @param int $id_customer
* @return array customers data
*/
public function ajaxProcessGetCustomerData()
{
$delete = Tools::getValue('delete');
$value = Tools::getValue('value');
$return = $this->module->getCustomerData($delete, $value);
die(json_encode($return['data']));
}
/**
* check if there are orders associated to the customer
*
* @param id $id_customer
* redirect to the invoices controller
*/
public function ajaxProcessDownloadInvoicesByCustomer()
{
$id_customer = Tools::getValue('id_customer');
$order_invoice_list = Db::getInstance()->executeS('SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
WHERE o.id_customer ='.(int)$id_customer.'
AND oi.number > 0');
die(json_encode(count($order_invoice_list)));
}
}

View File

@@ -0,0 +1,65 @@
<?php
/**
* 2007-2016 PrestaShop
*
* 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-2015 PrestaShop SA
* @license http://addons.prestashop.com/en/content/12-terms-and-conditions-of-use
* International Registered Trademark & Property of PrestaShop SA
*/
class AdminDownloadInvoicesPsgdprController extends ModuleAdminController
{
public function postProcess()
{
$id_customer = (int)Tools::getValue('id_customer');
if (isset($id_customer)) {
$this->downloadInvoices($id_customer);
}
}
/**
* download all invoices from specific customer into one .pdf file
*
* @param int $id_customer
*/
public function downloadInvoices($id_customer)
{
$order_invoice_collection = $this->getCustomerInvoiceList($id_customer);
if (!count($order_invoice_collection)) {
return;
}
$this->generatePDF($order_invoice_collection, PDF::TEMPLATE_INVOICE);
}
/**
* get all the invoices from specific customer into a list
*
* @param int $id_customer
* @return array collection of orders
*/
public function getCustomerInvoiceList($id_customer)
{
$order_invoice_list = Db::getInstance()->executeS('SELECT oi.*
FROM `'._DB_PREFIX_.'order_invoice` oi
LEFT JOIN `'._DB_PREFIX_.'orders` o ON (o.`id_order` = oi.`id_order`)
WHERE o.id_customer ='.(int)$id_customer.'
AND oi.number > 0');
return ObjectModel::hydrateCollection('OrderInvoice', $order_invoice_list);
}
/**
* generate a .pdf file
*/
public function generatePDF($object, $template)
{
$pdf = new PDF($object, $template, Context::getContext()->smarty);
$pdf->render(true);
}
}

View File

@@ -0,0 +1,25 @@
<?php
/**
* 2007-2014 PrestaShop
*
* 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-2014 PrestaShop SA
* @license http://addons.prestashop.com/en/content/12-terms-and-conditions-of-use
* International Registered Trademark & Property of PrestaShop SA
*/
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
header('Location: ../');
exit;