| Server IP : 54.36.91.62 / Your IP : 216.73.217.112 Web Server : Apache System : Linux webm013.cluster127.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : coopiak ( 151928) PHP Version : 8.3.23 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/coopiak/amisdesseniors-fr/catalog/administrator/components/com_djcatalog2/models/ |
Upload File : |
<?php
/**
* @package DJ-Catalog2
* @copyright Copyright (C) DJ-Extensions.com, All rights reserved.
* @license http://www.gnu.org/licenses GNU/GPL
* @author url: http://dj-extensions.com
* @author email contact@dj-extensions.com
*/
// No direct access.
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Table\Table;
use Joomla\CMS\MVC\Model\AdminModel;
class Djcatalog2ModelPayment extends AdminModel
{
protected $text_prefix = 'COM_DJCATALOG2';
public function __construct($config = array()) {
parent::__construct($config);
}
public function getTable($type = 'Payments', $prefix = 'Djcatalog2Table', $config = array())
{
return Table::getInstance($type, $prefix, $config);
}
public function getForm($data = array(), $loadData = true)
{
// Initialise variables.
$app = Factory::getApplication();
// Get the form.
$form = $this->loadForm('com_djcatalog2.payment', 'payment', array('control' => 'jform', 'load_data' => $loadData));
if (empty($form)) {
return false;
}
return $form;
}
protected function loadFormData()
{
$data = Factory::getApplication()->getUserState('com_djcatalog2.edit.payment.data', array());
if (empty($data)) {
$data = $this->getItem();
}
return $data;
}
protected function preprocessForm(Joomla\CMS\Form\Form $form, $data, $group = 'djcatalog2payment')
{
return parent::preprocessForm($form, $data, $group);
}
public function getItem($pk = null) {
if ($item = parent::getItem($pk)) {
if ((!isset($item->deliveries) || !is_array($item->deliveries)) && isset($item->id)){
$this->_db->setQuery('SELECT delivery_id FROM #__djc2_deliveries_payments WHERE payment_id=\''.$item->id.'\'');
$item->deliveries = $this->_db->loadColumn();
}
if ((!isset($item->currencies) || !is_array($item->currencies)) && isset($item->id)){
$this->_db->setQuery('SELECT currency_id FROM #__djc2_payments_currencies WHERE payment_id=\''.$item->id.'\'');
$item->currencies = $this->_db->loadColumn();
}
if (is_string($item->countries)) {
$item->countries = explode(',', $item->countries);
}
return $item;
} else {
return false;
}
}
protected function prepareTable($table)
{
jimport('joomla.filter.output');
$db = Factory::getDbo();
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
$table->name = htmlspecialchars_decode($table->name, ENT_QUOTES);
$table->price = floatval($table->price);
$table->tax_rule_id = (int)$table->tax_rule_id;
$table->additional_fee = floatval($table->additional_fee);
$table->free_amount = floatval($table->free_amount);
if (empty($table->id)) {
if (empty($table->ordering)) {
$db->setQuery('SELECT MAX(ordering) FROM #__djc2_payment_methods');
$max = $db->loadResult();
$table->ordering = $max+1;
}
}
}
protected function getReorderConditions($table = null)
{
$condition = array();
return $condition;
}
public function delete(&$cid) {
if (parent::delete($cid)) {
if (count( $cid )) {
$cids = implode(',', $cid);
$this->_db->setQuery("DELETE FROM #__djc2_deliveries_payments WHERE payment_id IN ( ".$cids." )");
if (!$this->_db->execute()) {
$this->setError($this->_db->getErrorMsg());
return false;
}
}
return true;
}
return false;
}
/**
* Method to test whether a record can be deleted.
*
* @param object $record A record object.
*
* @return boolean True if allowed to delete the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canDelete($record)
{
return Factory::getUser()->authorise('core.delete', $this->option) || Factory::getUser()->authorise('djcatalog2.admin.catalogue', $this->option);
}
/**
* Method to test whether a record can have its state changed.
*
* @param object $record A record object.
*
* @return boolean True if allowed to change the state of the record. Defaults to the permission for the component.
*
* @since 1.6
*/
protected function canEditState($record)
{
return Factory::getUser()->authorise('core.edit.state', $this->option) || Factory::getUser()->authorise('djcatalog2.admin.catalogue', $this->option);
}
}