Rajout du module de gestion des avoirs

This commit is contained in:
2020-06-10 10:26:45 +02:00
parent d3e8302015
commit 4e01079f72
115 changed files with 52849 additions and 0 deletions

View File

@@ -0,0 +1,26 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Helper;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
class CreditNoteHelper
{
const STATUS_PROPOSED = 'proposed';
const STATUS_REFUSED = 'refused';
const STATUS_ACCEPTED = 'accepted';
const STATUS_USED = 'used';
const TYPE_ORDER_FULL_REFUND = 'order_full_refund';
const TYPE_BACK_PRODUCT = 'back_product';
const TYPE_BILLING_ERROR = 'billing_error';
const TYPE_REBATE = 'rebate';
const TYPE_DISCOUNT = 'discount';
}

View File

@@ -0,0 +1,57 @@
<?php
/*************************************************************************************/
/* This file is part of the module CreditNote */
/* */
/* For the full copyright and license information, please view the LICENSE.txt */
/* file that was distributed with this source code. */
/*************************************************************************************/
namespace CreditNote\Helper;
use Propel\Runtime\ActiveQuery\ModelCriteria;
/**
* @author Gilles Bourgeat >gilles.bourgeat@gmail.com>
*/
trait CriteriaSearchHelper
{
/**
* @param string $q
* @return string
*/
public function getRegex($q)
{
$q = explode(' ', $q);
$words = array();
foreach ($q as $v) {
$v = trim($v);
if (strlen($v) > 2 && preg_match('/^[a-z0-9]+$/i', $v)) {
$words[] = $v;
}
}
if (!count($words)) {
return null;
}
$regex = array();
$regex[] = '.*' . implode('.+', $words) . '.*';
if (count($words) > 1) {
$regex[] = '.*' . implode('.+', array_reverse($words)) . '.*';
}
return implode('|', $regex);
}
/**
* @param ModelCriteria $query
* @param array $columns
* @param string $q
*/
public function whereConcatRegex(ModelCriteria $query, array $columns, $q)
{
$query->where("CONCAT_WS(' ', " . implode(',', $columns). ") REGEXP ?", self::getRegex($q), \PDO::PARAM_STR);
}
}