Fix indent ++

This commit is contained in:
BuildTools 2019-11-03 17:51:31 +01:00
parent d45f81a515
commit 541c5820bc
16 changed files with 415 additions and 417 deletions

View file

@ -41,7 +41,7 @@ class Client
{
throw new UserException('Le champs '.$key.' doit être renseigné.');
}
if($key == 'ville')
{
$data[$key] = mb_strtoupper($data[$key]);
@ -50,7 +50,7 @@ class Client
{
if($this->config['validate_cp'] && !preg_match('/^(F-)?((2[A|B])|[0-9]{2})(\s)?[0-9]{3}$/', $data[$key]))
{
throw new UserException('Le code postal est erroné.');
throw new UserException('Le code postal est erroné.');
}
}
elseif ($key == "telephone")
@ -80,26 +80,26 @@ class Client
$this->_checkFields($data);
if($this->config['unique_client_name'] && isset($data['nom']) && $db->test('plugin_facturation_clients', 'nom = ? COLLATE NOCASE', $data['nom']))
{
throw new UserException('La valeur du champ nom est déjà utilisée, hors ce champ doit être unique à chaque client.');
}
if($this->config['unique_client_name'] && isset($data['nom']) && $db->test('plugin_facturation_clients', 'nom = ? COLLATE NOCASE', $data['nom']))
{
throw new UserException('La valeur du champ nom est déjà utilisée, hors ce champ doit être unique à chaque client.');
}
$db->insert('plugin_facturation_clients', $data);
$db->insert('plugin_facturation_clients', $data);
return $db->lastInsertRowId();
}
public function get($id)
{
$db = DB::getInstance();
{
$db = DB::getInstance();
return $db->first('SELECT *, strftime(\'%s\', date_creation) AS date_creation
FROM plugin_facturation_clients WHERE id = ? LIMIT 1;', (int)$id);
}
return $db->first('SELECT *, strftime(\'%s\', date_creation) AS date_creation
FROM plugin_facturation_clients WHERE id = ? LIMIT 1;', (int)$id);
}
public function listAll()
{
return DB::getInstance()->get('SELECT *, strftime(\'%s\', date_creation) AS date_creation FROM plugin_facturation_clients');
return DB::getInstance()->get('SELECT *, strftime(\'%s\', date_creation) AS date_creation FROM plugin_facturation_clients');
}
public function edit($id, $data = [])
@ -108,10 +108,10 @@ class Client
$this->_checkFields($data);
if($this->config['unique_client_name'] && isset($data['nom']) && $db->test('plugin_facturation_clients', 'nom = ? COLLATE NOCASE AND id != ?', $data['nom'], (int)$id))
{
throw new UserException('La valeur du champ nom est déjà utilisée, hors ce champ doit être unique à chaque client.');
}
if($this->config['unique_client_name'] && isset($data['nom']) && $db->test('plugin_facturation_clients', 'nom = ? COLLATE NOCASE AND id != ?', $data['nom'], (int)$id))
{
throw new UserException('La valeur du champ nom est déjà utilisée, hors ce champ doit être unique à chaque client.');
}
return $db->update('plugin_facturation_clients', $data, $db->where('id', (int)$id));
}
@ -128,7 +128,7 @@ class Client
{
return false;
}
return DB::getInstance()->delete('plugin_facturation_clients', 'id = '. (int)$id);
}
}

View file

@ -78,113 +78,112 @@ class Config
}
public function save()
{
if (empty($this->modified))
return true;
{
if (empty($this->modified))
return true;
$values = [];
$db = DB::getInstance();
// $db->begin();
$values = [];
$db = DB::getInstance();
// $db->begin();
foreach ($this->modified as $key=>$modified)
{
$value = $this->config[$key];
var_dump($value);
foreach ($this->modified as $key=>$modified)
{
$value = $this->config[$key];
if (is_array($value))
{
$value = implode(',', $value);
}
elseif (is_object($value))
{
$value = (string) $value;
}
if (is_array($value))
{
$value = implode(',', $value);
}
elseif (is_object($value))
{
$value = (string) $value;
}
$db->exec('INSERT OR REPLACE INTO plugin_facturation_config (cle, valeur) VALUES (\''.$key.'\', \''.$value.'\');');
$db->exec('INSERT OR REPLACE INTO plugin_facturation_config (cle, valeur) VALUES (\''.$key.'\', \''.$value.'\');');
}
// $db->commit();
$this->modified = [];
// $db->commit();
return true;
$this->modified = [];
return true;
}
public function set($key, $value)
{
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (is_array($this->fields_types[$key]))
{
$value = !empty($value) ? (array) $value : [];
}
elseif (is_int($this->fields_types[$key]))
{
$value = (int) $value;
}
elseif (is_float($this->fields_types[$key]))
{
$value = (float) $value;
}
elseif (is_bool($this->fields_types[$key]))
{
$value = (bool) $value;
}
elseif (is_string($this->fields_types[$key]))
{
$value = (string) $value;
}
if (is_array($this->fields_types[$key]))
{
$value = !empty($value) ? (array) $value : [];
}
elseif (is_int($this->fields_types[$key]))
{
$value = (int) $value;
}
elseif (is_float($this->fields_types[$key]))
{
$value = (float) $value;
}
elseif (is_bool($this->fields_types[$key]))
{
$value = (bool) $value;
}
elseif (is_string($this->fields_types[$key]))
{
$value = (string) $value;
}
// switch ($key)
// {
// case 'siret_asso':
// {
// if (!trim($value))
// {
// throw new UserException('Le nom de l\'association ne peut rester vide.');
// }
// break;
// }
// case 'footer':
// break;
// default:
// break;
// }
// switch ($key)
// {
// case 'siret_asso':
// {
// if (!trim($value))
// {
// throw new UserException('Le nom de l\'association ne peut rester vide.');
// }
// break;
// }
// case 'footer':
// break;
// default:
// break;
// }
if (!isset($this->config[$key]) || $value !== $this->config[$key])
{
$this->config[$key] = $value;
$this->modified[$key] = true;
}
if (!isset($this->config[$key]) || $value !== $this->config[$key])
{
$this->config[$key] = $value;
$this->modified[$key] = true;
}
return true;
return true;
}
public function get($key)
{
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->config))
{
return null;
}
return $this->config[$key];
if (!array_key_exists($key, $this->fields_types))
{
throw new \OutOfBoundsException('Ce champ est inconnu.');
}
if (!array_key_exists($key, $this->config))
{
return null;
}
return $this->config[$key];
}
public function getFieldsTypes()
{
return $this->fields_types;
return $this->fields_types;
}
public function getConfig()
{
return $this->config;
return $this->config;
}
}
}

View file

@ -34,7 +34,7 @@ class Facture
{
throw new UserException("Clé inattendue : $k.");
}
if(!is_array($data)){
$datas[$k] = trim($data);
}
@ -46,49 +46,49 @@ class Facture
switch($k)
{
case 'type_facture':
case 'receveur_membre':
case 'reglee':
case 'archivee':
if ($datas[$k] != 1 && $datas[$k] != 0)
{
throw new UserException("$k est de valeur non-attendue ($data).");
case 'type_facture':
case 'receveur_membre':
case 'reglee':
case 'archivee':
if ($datas[$k] != 1 && $datas[$k] != 0)
{
throw new UserException("$k est de valeur non-attendue ($data).");
}
break;
case 'receveur_id':
if (!is_numeric($datas[$k]) || $datas[$k] < 0 )
{
throw new UserException("L'id du receveur est non-attendu ($data).");
case 'receveur_id':
if (!is_numeric($datas[$k]) || $datas[$k] < 0 )
{
throw new UserException("L'id du receveur est non-attendu ($data).");
}
break;
case 'date_emission':
if (!strtotime($datas[$k]))
{
throw new UserException("La date d'émission est non-attendue ($data).");
case 'date_emission':
if (!strtotime($datas[$k]))
{
throw new UserException("La date d'émission est non-attendue ($data).");
}
break;
case 'date_echeance':
if (!strtotime($datas[$k]))
{
throw new UserException("La date d'émission est non-attendue ($data).");
case 'date_echeance':
if (!strtotime($datas[$k]))
{
throw new UserException("La date d'émission est non-attendue ($data).");
}
if (isset($datas['date_emission']) && (strtotime($datas[$k]) <= strtotime($datas['date_emission']) ) )
{
throw new UserException("La date d'échéance est antérieure ou égale à la date d'émission ($data).");
}
break;
case 'moyen_paiement':
$cats = new \Garradin\Compta\Categories;
if(!array_key_exists($datas[$k], $cats->listMoyensPaiement()))
{
throw new UserException("Le moyen de paiement ne correspond pas à la liste interne ($data).");
case 'moyen_paiement':
$cats = new \Garradin\Compta\Categories;
if(!array_key_exists($datas[$k], $cats->listMoyensPaiement()))
{
throw new UserException("Le moyen de paiement ne correspond pas à la liste interne ($data).");
}
unset($cats);
break;
case 'contenu':
if(!is_array($datas[$k]) || empty($datas[$k]))
{
throw new UserException("Le contenu du document est vide ($data).");
case 'contenu':
if(!is_array($datas[$k]) || empty($datas[$k]))
{
throw new UserException("Le contenu du document est vide ($data).");
}
$total = 0;
$vide = 1;
@ -110,10 +110,10 @@ class Facture
}
$datas[$k] = serialize($datas[$k]);
break;
case 'total':
if(!isset($datas['contenu']))
{
throw new UserException("Pas de contenu fourni pour vérifier le total.");
case 'total':
if(!isset($datas['contenu']))
{
throw new UserException("Pas de contenu fourni pour vérifier le total.");
}
if ($total != $datas[$k])
{
@ -132,15 +132,15 @@ class Facture
if(isset($data['numero']) && $db->test('plugin_facturation_factures', 'numero = ? COLLATE NOCASE', $data['numero']))
{
throw new UserException('Une facture avec ce numéro existe déjà, hors le numéro doit être unique.');
throw new UserException('Une facture avec ce numéro existe déjà, hors le numéro doit être unique.');
}
$db->insert('plugin_facturation_factures', $data);
return $db->lastInsertRowId();
}
public function get($id)
{
$db = DB::getInstance();
{
$db = DB::getInstance();
$r = $db->first('SELECT *, strftime(\'%s\', date_emission) AS date_emission,
strftime(\'%s\', date_echeance) AS date_echeance
@ -150,7 +150,7 @@ class Facture
{
throw new UserException("Pas de facture retournée avec cet id.");
}
$r->contenu = unserialize($r->contenu);
return $r;
@ -161,7 +161,7 @@ class Facture
$r = (array)DB::getInstance()->get('SELECT *, strftime(\'%s\', date_emission) AS date_emission,
strftime(\'%s\', date_echeance) AS date_echeance
FROM plugin_facturation_factures');
foreach ($r as $e)
{
$e->contenu = unserialize((string)$e->contenu);
@ -178,7 +178,7 @@ class Facture
if(isset($data['numero']) && $db->test('plugin_facturation_factures', 'numero = ? COLLATE NOCASE AND id != ?', $data['numero'], (int)$id))
{
throw new UserException('Une facture avec ce numéro existe déjà, hors le numéro doit être unique.');
throw new UserException('Une facture avec ce numéro existe déjà, hors le numéro doit être unique.');
}
return $db->update('plugin_facturation_factures', $data, $db->where('id', (int)$id));
}
@ -200,15 +200,15 @@ class Facture
}
$r = (array)DB::getInstance()->get('SELECT *, strftime(\'%s\', date_emission) AS date_emission,
strftime(\'%s\', date_echeance) AS date_echeance
FROM plugin_facturation_factures
WHERE receveur_membre = ? AND receveur_id = ?', (int)$base, (int)$id);
strftime(\'%s\', date_echeance) AS date_echeance
FROM plugin_facturation_factures
WHERE receveur_membre = ? AND receveur_id = ?', (int)$base, (int)$id);
foreach ($r as $e)
{
$e->contenu = unserialize((string)$e->contenu);
}
return empty($r)?false:$r;
}