Files
2019-11-20 07:44:43 +01:00

93 lines
3.3 KiB
PHP

<?php
/**
* 2007-2017 Decanet
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 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/afl-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.decanet.fr for more information.
*
* @author Decanet SA <contact@decanet.fr>
* @copyright 2007-2017 Decanet SA
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
if (!defined('_PS_VERSION_')) {
exit;
}
class PrevSepa extends ObjectModel
{
public $id_customer;
public $etat = 0;
public $rum = '';
public $name = '';
public $address = '';
public $iban = '';
public $bic = '';
public $sepa_type = '';
public $phone = '';
public $code = '';
public $datevalid = '';
public $html = '';
/**
* @see ObjectModel::$definition
*/
public static $definition = array(
'table' => 'prelevementsepa',
'primary' => 'id_sepa',
'multilang' => false,
'fields' => array(
'id_customer' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
'name' =>array('type' => self::TYPE_STRING),
'address' =>array('type' => self::TYPE_STRING),
'etat' =>array('type' => self::TYPE_BOOL),
'rum' =>array('type' => self::TYPE_STRING),
'iban' =>array('type' => self::TYPE_STRING),
'bic' =>array('type' => self::TYPE_STRING),
'sepa_type' =>array('type' => self::TYPE_STRING),
'phone' =>array('type' => self::TYPE_STRING),
'code' =>array('type' => self::TYPE_STRING),
'datevalid' =>array('type' => self::TYPE_STRING),
),
);
public static function existCustomer($id_customer)
{
$sql = 'SELECT id_sepa FROM `'._DB_PREFIX_.'prelevementsepa`
WHERE id_customer = '.(int)$id_customer.'';
$list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($list && is_array($list) && count($list)) {
return (int)$list[0]['id_sepa'];
}
return null;
}
public static function getAll()
{
$sql = 'SELECT * FROM `'._DB_PREFIX_.'prelevementsepa`';
$list = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
if ($list && is_array($list) && count($list)) {
return $list;
}
return array();
}
public static function updateUnTraitSepaIDByOids($sepa_id, $oid_list)
{
return Db::getInstance()->Execute('UPDATE `'._DB_PREFIX_.'prelevementsepa_detail` SET id_sepa='.$sepa_id
.' WHERE id_sepa=0 AND traite=0 AND id_order IN ('.implode(', ', $oid_list).')');
}
}