111 lines
3.3 KiB
PHP
111 lines
3.3 KiB
PHP
<?php
|
|
/**
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* This source file is subject to a commercial license.
|
|
* Use, copy, modification or distribution of this source file without written
|
|
* license agreement is strictly forbidden.
|
|
* In order to obtain a license, please contact us: simon@daig.re
|
|
* ...........................................................................
|
|
* INFORMATION SUR LA LICENCE D'UTILISATION
|
|
*
|
|
* L'utilisation de ce fichier source est soumise a une licence commerciale.
|
|
* Toute utilisation, reproduction, modification ou distribution du present
|
|
* fichier source sans contrat de licence ecrit est expressement interdite.
|
|
* Pour obtenir une licence, veuillez nous contacter a l'adresse: simon@daig.re
|
|
*
|
|
* @package Courrier suivi Tracking
|
|
* @author Agencya
|
|
* @copyright Copyright(c) 2015-2018
|
|
* @license See Readme.md
|
|
* Contact by Email : simon@daig.re
|
|
*/
|
|
|
|
/**
|
|
* Class CsuiviTrackingModel
|
|
*/
|
|
class CsuiviTrackingModel extends ObjectModel
|
|
{
|
|
/** @var int */
|
|
public $id_order;
|
|
|
|
/** @var string */
|
|
public $tracking;
|
|
|
|
/** @var string */
|
|
public $status;
|
|
|
|
/** @var bool */
|
|
public $delivered;
|
|
|
|
/** @var DateTime */
|
|
public $date;
|
|
|
|
/** @var DateTime */
|
|
public $date_add;
|
|
|
|
/** @var DateTime */
|
|
public $date_upd;
|
|
|
|
/** @var array */
|
|
public static $definition = array(
|
|
'table' => 'csuivi_tracking',
|
|
'primary' => 'id_csuivi_tracking',
|
|
'multilang' => false,
|
|
'fields' => array(
|
|
'id_order' => array('type' => self::TYPE_INT, 'validate' => 'isUnsignedId', 'required' => true),
|
|
'tracking' => array('type' => self::TYPE_STRING, 'validate' => 'isTrackingNumber', 'required' => true, 'size' => 13),
|
|
'status' => array('type' => self::TYPE_STRING, 'validate' => 'isString'),
|
|
'delivered' => array('type' => self::TYPE_BOOL, 'validate' => 'isBool'),
|
|
'date' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
|
'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
|
'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate'),
|
|
),
|
|
);
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getTrackingUrl()
|
|
{
|
|
return 'https://www.laposte.fr/particulier/outils/suivre-vos-envois?code='.$this->tracking;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getTrackingFormatted()
|
|
{
|
|
return Tools::substr($this->tracking, 0, 2).' '.Tools::substr($this->tracking, 2, 3).' '.Tools::substr($this->tracking, 5, 3).' '.Tools::substr($this->tracking, 8, 4).' '.Tools::substr($this->tracking, 12);
|
|
}
|
|
|
|
/**
|
|
* @param int $id_order
|
|
* @return int
|
|
*/
|
|
public static function getIdByOrderId($id_order)
|
|
{
|
|
return (int)Db::getInstance()->getValue('
|
|
SELECT ct.`id_csuivi_tracking`
|
|
FROM `'._DB_PREFIX_.'csuivi_tracking` ct
|
|
WHERE ct.`id_order` = '.(int)$id_order
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @return array|false
|
|
*/
|
|
public static function getAll()
|
|
{
|
|
$date = new DateTime();
|
|
$date->sub(new DateInterval('P1M'));
|
|
|
|
return Db::getInstance()->executeS('
|
|
SELECT ct.`id_csuivi_tracking`
|
|
FROM `'._DB_PREFIX_.'csuivi_tracking` ct
|
|
WHERE ct.`delivered` = 0
|
|
AND ct.`date_upd` > \''.$date->format('Y-m-d H:i:s').'\''
|
|
);
|
|
}
|
|
}
|