From 4e565fc166c6e264a23b46e7ef23301ef4cc31d4 Mon Sep 17 00:00:00 2001 From: www-data Date: Sun, 3 Apr 2022 01:16:37 +0200 Subject: [PATCH] MVC improvements. Upload ofx now creates entries in the DB. --- app/compta/api/bank.php | 46 ++ .../{api_recurrent.php => api/recurrent.php} | 105 ++++- app/compta/controlers/recurrent.php | 39 +- app/compta/controlers/supplier.php | 9 + app/compta/models/anah.php | 292 +++++++++++++ app/compta/models/bank.php | 44 +- app/compta/models/loan.php | 1 - app/compta/models/owner.php | 17 +- app/compta/models/recurrent.php | 252 ++++++++++- app/compta/views/bank_index.php | 6 +- app/compta/views/recurrent_detail.php | 7 +- app/compta/views/recurrent_index.php | 42 +- app/compta/views/recurrent_nouveau.php | 399 ++++++------------ app/compta/views/recurrent_payer.php | 2 +- app/compta/views/recurrent_remove.php | 115 +++++ app/compta/views/recurrent_update.php | 226 +++++++--- app/compta/views/supplier_bill.php | 6 +- app/compta/views/supplier_billpay.php | 203 +++++++++ 18 files changed, 1414 insertions(+), 397 deletions(-) rename app/compta/{api_recurrent.php => api/recurrent.php} (53%) create mode 100644 app/compta/models/anah.php create mode 100644 app/compta/views/recurrent_remove.php create mode 100644 app/compta/views/supplier_billpay.php diff --git a/app/compta/api/bank.php b/app/compta/api/bank.php index 9a50292..ba9a55d 100644 --- a/app/compta/api/bank.php +++ b/app/compta/api/bank.php @@ -50,6 +50,52 @@ class Bank extends Api { } return $res['records']; } + + /** + * \brief lookup for bank account id defined by the parameter. + * if not found return 0. + * + */ + public function lookupBank($codeBanque,$codeGuichet,$codeCompte) + { + $period = $this->getCurrentExercice(); + $q =<<<_EOF +SELECT ba_id FROM BankAccounts +WHERE ba_code_bank = {$codeBanque} and ba_code_branch = "{$codeGuichet}" and ba_num_account= "{$codeCompte}"; +_EOF; + try + { + $res = $this->doQueryI($q); + } catch (Exception $e) + { + error_log("Bank::lookup Failed ".$period." ".$e->getMessage()); + } + if (is_array($res['records'])) + { + return $res['records'][0][0]; + } else + return 0; + } + + /** + * + */ + public function bookMvmt($bank_id,$type,$date,$montant,$mvmt_id,$libelle,$info) + { + $q=<<<_EOF +INSERT IGNORE INTO BankMvmts (bm_bank_id,bm_type,bm_date,bm_amount,bm_mvmt_id,bm_name,bm_info) +VALUES({$bank_id},"{$type}","${date}",{$montant},"${mvmt_id}","{$libelle}","{$info}"); +_EOF; + try + { + $res = $this->doQueryI($q); + } catch (Exception $e) + { + error_log("Bank::bookMvmt Failed ".$period." ".$e->getMessage()); + } + return $res['records']; + } + } ?> diff --git a/app/compta/api_recurrent.php b/app/compta/api/recurrent.php similarity index 53% rename from app/compta/api_recurrent.php rename to app/compta/api/recurrent.php index 481588e..8b27042 100644 --- a/app/compta/api_recurrent.php +++ b/app/compta/api/recurrent.php @@ -3,8 +3,8 @@ /** * This file contains the Pret API for the general ledger system. * It shall provide all function for the ledger system - * - create a loan - * - list all loans + * - create a recurrent operation + * - list all recurrent transaction * - loan summary (monthly payment, payment du date, left interest, left capital, 6 next ) * - updating a Transaction previously retrieved by the retrieve api. * @@ -13,8 +13,8 @@ * @package Compta */ -require_once(dirname(__FILE__)."/../common.php"); -require_once(dirname(__FILE__)."/api_base.php"); +require_once(dirname(__FILE__)."/../../common.php"); +require_once(dirname(__FILE__)."/../api_base.php"); /** * Api to retrieve information from the ledger books @@ -34,11 +34,106 @@ class Recurrent extends Api { parent::__construct($_session,$auth_cfg,$db); } + /** + * Insert or update a recurrent Entry. + * When id is -1 create a new entry or else perform an update. + * + */ + private function insertEntry($rec_id,$e) + { + $tplt=<<<_EOF +INSERT INTO RecurrentEntry (re_id,re_rec_id,re_entry_type,re_acc,re_debit_credit,re_amount) + VALUES({$e['id']},{$rec_id},"{$e['entry_type']}","{$e['acc_id']}","{$e['dc']}",{$e['amount']}) +ON DUPLICATE KEY UPDATE + re_entry_type = "{$e['entry_type']}" + , re_acc = "{$e['acc_id']}" + , re_amount = {$e['amount']} + , re_debit_credit = "{$e['dc']}" +; +_EOF; + if ($e['id'] == -1 ) + { + $tplt=<<<_EOF +INSERT INTO RecurrentEntry (re_rec_id,re_enty_type,re_acc,re_debit_credit,re_amount) + VALUES({$rec_id},{$e['entry_type']},{$e['acc_id']},{$e['dc']},{$e['amount']}) ; +_EOF; + } + try { + $res = $this->doQueryI($tplt); + } catch (Exception $e) { + error_log("Recurrent::insertEntry ".$id." Failed ".$e->getMessage()); + } + return $res['records']; + } + + /** + * Create a new recurrent entry + * Proceed in two steps. First create the summary of the transaction, + * Then create the entries belonging to the recurreny transaction + * $r_id = -1; + * $r_date = ""; + * $r_amount = 0.0; + * $r_desc = ""; + * $r_next = ""; + * $r_end = ""; + */ + public function create($r,$entries) + { + $tplt=<<<_EOF +INSERT INTO Recurrent (r_date,r_amount,r_desc,r_next,r_amount,r_end) + VALUES({$r['r_date']},{$r['r_amount']},{$r['r_desc']},{$r['r_next']},{$r['r_amount']},{$r['r_end']}) +; SELECT LAST_INSERT_ID() ; +_EOF; + try { + $res = $this->doQueryI($q); + } catch (Exception $e) { + error_log("Recurrent::create ".$id." Failed ".$e->getMessage()); + return Array(''); + } + $r_id = $res['records'][0]; + error_log("Recurrent::create ".$id." created add entries"); + foreach($entries as $entry) + { + $this->insertEntry($r_id,$entry); + } + } + /** + * @brief Update recurrent entry + */ + public function update($r,$entries) + { + $tplt=<<<_EOF +UPDATE Recurrent +SET +r_date ="{$r['r_date']}" +,r_amount ={$r['r_amount']} +,r_desc ="{$r['r_desc']}" +,r_next ="{$r['r_next']}" +,r_amount ={$r['r_amount']} +,r_end ="{$r['r_end']}" +WHERE r_id = {$r['r_id']}; +_EOF; + try { + $res = $this->doQueryI($tplt); + error_log("Recurrent::update ".$tplt."\n"); + } catch (Exception $e) { + error_log("Recurrent::update ".$r['r_id']." Failed ".$e->getMessage()); + return Array(''); + } + $r_id = $r['r_id']; + error_log("Recurrent::update ".$r_id." update add entries ".$r['r_next']."\n"); + foreach($entries as $entry) + { + $this->insertEntry($r_id,$entry); + } + } + + /** * \brief, return the list of loans * TODO: Not sure if it's the right place */ - function getList() + public function getList() { $q =<<<_EOF SELECT r_id,r_date,r_amount,r_desc,r_next,r_end from `Recurrent` as l diff --git a/app/compta/controlers/recurrent.php b/app/compta/controlers/recurrent.php index 06d54e4..2289983 100644 --- a/app/compta/controlers/recurrent.php +++ b/app/compta/controlers/recurrent.php @@ -70,6 +70,27 @@ class Recurrent $page = new \compta\views\recurrent\Update($this->_model); return $page; } + /** + * Handle post of update recurrent operation + * @param string $_accout_id + */ + public function updatePost() : \IActionResult + { + $page = null; + $model = $this->_model; + require_once(controler::$basedir."/views/recurrent_update.php"); + if ($this->_model->isFormValid() == true) + { + // Here I should commit the changes of the operation + $model->update(); + // Alright read back and display + return $this->detail($model->id); + } else + { + $page = new \compta\views\recurrent\Update($this->_model); + } + return $page; + } /** * Get the details of the supplier account. * @param string $_accout_id the supplier account @@ -81,6 +102,20 @@ class Recurrent $page = new \compta\views\recurrent\Payer($this->_model); return $page; } + /** + * @brief Remove a recurrent record and its entries + * @param string $_id the recurrent entry to remove + */ + public function remove($_id) : \IActionResult + { + require_once(controler::$basedir."/views/recurrent_remove.php"); + $this->_model->get($_id); + if (\AEB::$REQUEST['confirm'] == 'yes') + { + return new \compta\views\recurrent\Remove($this->_model); + } else; + return new \compta\views\recurrent\Remove($this->_model); + } /** * Get the details of the supplier account. * @param string $_accout_id the supplier account @@ -88,7 +123,7 @@ class Recurrent public function nouveau() : \IActionResult { require_once(controler::$basedir."/views/recurrent_nouveau.php"); - $page = new \compta\views\recurrent\Nouveau(); + $page = new \compta\views\recurrent\Nouveau($this->_model); return $page; } /** @@ -98,7 +133,7 @@ class Recurrent public function nouveauPost() : \IActionResult { require_once(controler::$basedir."/views/recurrent_nouveau.php"); - $page = new \compta\views\recurrent\Nouveau(); + $page = new \compta\views\recurrent\Nouveau($this->_model); return $page; } } diff --git a/app/compta/controlers/supplier.php b/app/compta/controlers/supplier.php index c986129..e8855d7 100644 --- a/app/compta/controlers/supplier.php +++ b/app/compta/controlers/supplier.php @@ -82,6 +82,15 @@ class Supplier extends controler return $page; } + public function billpay($_id) : \IActionResult + { + require_once(controler::$viewdir."/supplier_billpay.php"); + $this->_model->getDetails($_id); + $this->_model->getAccount($_id); + $page = new \compta\views\supplier\Billpay($this->_model); + return $page; + } + public function billPost() : \IActionResult { $model = $this->_model; diff --git a/app/compta/models/anah.php b/app/compta/models/anah.php new file mode 100644 index 0000000..dc4c963 --- /dev/null +++ b/app/compta/models/anah.php @@ -0,0 +1,292 @@ + $v) + { $this->{$k} = $c[$i++]; } + } + } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'numImmatriculationCopropriete' => $this->numImmatriculationCopropriete + , 'nomCopropriete' => $this->nomCopropriete + , 'dateReglementCopropriete' => $this->dateReglementCopropriete + , 'Siret' => $this->Siret + , 'addressPrincipale' => $this->addressPrincipale + , 'addressSecondaire' => $this->addressSecondaire + , 'parcelle' => $this->parcelle + , 'residenceService' => $this->residenceService + , 'syndicCooperatif' => $this->syndicCooperatif + , 'syndicPrincipal' => $this->syndicPrincipal + , 'numImmatriculationCopropritePrincipale' => $this->numImmatriculationCopropritePrincipale + , 'nbAsl' => $this->nbAsl + , 'nbAful' => $this->nbAful + , 'nbUnionsSyndicats' => $this->nbUnionsSyndicats + , 'nbLots' => $this->nbLots + , 'nbLotsHabBurCom' => $this->nbLotsHabBurCom + , 'nbLotsHab' => $this->nbLotsHab + , 'nbLotsStationnement' => $this->nbLotsStationnement + ] + } +} + + +class Procedures implements \JSonSerializable +{ + public $Arrete = Array(); // Tableau d'objet + public $Type = ""; // [INSALUBRITE_PARTIES_COM,PERIL_PARTIES_COM,EQUIPEMENTS_COM] + public $dateArrete =""; + public $dateMainLevee =""; + public $mandatAdHoc =""; + public $dateNomination =""; + public $dateFinMission =""; + public $ordonnanceCarence = null; // Objet + public $dateOrdonnance = ""; + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * + */ +class DonneesTechniques implements \JSonSerializable +{ + public $classementEnergetique = Array(); // Tableau d'objets + public $etiquetteEnergetique = ""; // String ETIQ_[A-G,NOM_DETERMINE] + public $nbBatiments = 1; + public $periodeConstruction = ""; // Enum [AVANT_1949,DE_1949_A_1960, .. NON_CONNUE] + public $anneeConstruction = 0; // 0 - 9999 + public $typeChauffage = ""; // Enum [COLLECTIF,INDIVIDUEL,MIXTE,SANS_CHAUFFAGE] + public $chauffageCollectifUrbain = false; + public $energieChauffageCollectifNonUrbain = ""; // Enum [BOIS_DE_CHAUFFAGE,GAZ_NATUEL,GAZ_PROPANE_BUTANE + // CHARBON, ELECTRICITE,AUTRE] + public $nbAscenseurs = 0; + + + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + +/** + * + */ +class DonneesFinancieres implements \JSonSerializable +{ + public $premierExerciceComptable = false; // Boolean + public $dateDebutExerciceComtable = ""; // Format DD/MM/AAAA + public $dateClotureComtpes = ""; // Format DD/MM/AAAA + public $dateAg = ""; + public $chargesOperationsCourantes = 0.0; + public $chargesOperationsExceptionnelles = 0.0; + public $montantImpayesCoproprietaires = 0.0 + public $presenceEmployes = false; + public $nbCoproprietairesImpayes = 0; + public $montantDettes = 0.0; + public $montantFondTravaux = 0.0; + public $dateReference = ""; // Format DD/MM/AAAA + public $comptesNomApprouves = false; + + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} +/** + * + */ +class Address implements \JSonSerializable +{ + public $voie = ""; + public $lieuDit = ""; + public $codePostal = ""; + public $commun = ""; + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * + */ +class Parcelle implements \JSonSerializable +{ + public $codeInsee = ""; // String Mandatory 5 chiffres + public $Prefixe = ""; // Optionnel + public $section = ""; // + public $numParcelle = ""; + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * + */ +class Attestation implements \JSonSerializable +{ + public $Type = ""; // String Mandatory [IMMATRICULATION,MISE_A_JOUR_STANDARD,MISE_A_JOUR_ANNUELLE] + public $nomFichier = ""; // String Mandatory + public $pdfAttestation = ""; // String Mandatory base64 encoded + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * + */ +class FicheSynthetique implements \JSonSerializable +{ + public $nomFichier = ""; // String Mandatory + public $pdfFicheSynthetique = ""; // String Mandatory + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * + */ +class InfoRattachement implements \JSonSerializable +{ + public $adminProvisoire = ""; // String Mandatory + public $typeJustifMandat = ""; // String Mandatory [CONTRAT_SYNDIC,PV_AG,ORDO_NOMINATION] + public $nomFichierJustifMandat = ""; + public $justifMandat = ""; + public $dateDebutMandat = ""; // DD/MM/AAAA + public $dateFinMandat = ""; // DD/MM/AAAA + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + + +/** + * @brief + * + * TODO figure out why we have two time numTeledeclarant + */ +class InfoSuccesseur implements \JSonSerializable +{ + public $numTeledeclarant = false; // Boolean Mandatory + public $typeTeledeclarant = ""; // String (13) [PROFESSIONNEL / BENEVOLE] Mandatory + public $siret = ""; // String Mandatory + public $pdfFicheSynthetique = ""; // String Mandatory + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + +/** + * + */ +class InfosUtilisateur implements \JSonSerializable +{ + public $numTeledeclarant = ""; // String (12) Mandatory + public $adresseEmailUtilisateur = ""; // String (320) Mandatory + public $numImmatriculationCopropriete = ""; // String (9) Mandatory + + public function __construct($c = null) + { + } + public function jsonSerialize() + { + return [ + ]; + } +} + diff --git a/app/compta/models/bank.php b/app/compta/models/bank.php index 7727c8e..6ea0ede 100644 --- a/app/compta/models/bank.php +++ b/app/compta/models/bank.php @@ -5,6 +5,7 @@ namespace compta\models\bank; require_once(dirname(__FILE__)."/../api_exercice.php"); require_once(dirname(__FILE__)."/../api_booking.php"); require_once(dirname(__FILE__)."/../api_pcmn.php"); +require_once(dirname(__FILE__)."/../api/bank.php"); require_once(dirname(__FILE__)."/../../../phplib/class.ofx.php"); /** @@ -15,8 +16,12 @@ class Model extends \Ofx implements \JsonSerializable private $_session = null; private $_auth_cfg = null; + private $bank_id = 0; // Bank ID <> 0 when found during ofx parsing + + private $api_bank = null; public $mouvements = Array(); public $id = -1; // current entry. -1 no entry selected + /** * Constructor */ @@ -25,24 +30,51 @@ class Model extends \Ofx implements \JsonSerializable $this->_session = $_sess; $this->_auth_cfg = $_auth; } + public function onAccount($codeBanque,$codeGuichet,$codeCompte) + { + $_cfg = $this->_auth_cfg; + $api_bank = new \Bank( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + if ($api_bank != null) + { + $this->api_bank = $api_bank; + } + $this->bank_id = $api_bank->lookupBank($codeBanque,$codeGuichet,$codeCompte); + error_log("Got bank_id:".$this->bank_id." for account=".$codeCompte."\n"); + } - public function onMouvement($type,$date,$montant,$reste,$libelle,$info) + public function onMouvement($type,$date,$montant,$mvmt_id,$libelle,$info) { - // error_log("Mvment: ".$type." ".$date." ".$montant."\n"); + $api_bank = $this->api_bank; + // error_log("Mvment: ".$type." ".$date." ".$montant."\n"); + if ($this->bank_id != 0 && $this->api_bank != null) + { + $api_bank->bookMvmt($this->bank_id,$type,$date,$montant,$mvmt_id,$libelle,$info); + } else + { + error_log("Not Looged :".$montant." for account=".$type."\n"); + } } + + public function onEnd() + { + $this->bank_id = 0; + } + private function getSession() { - return $this->_session; + return $this->_session; } public function getAccounts() { $_cfg = $this->_auth_cfg; $pcmn = new \Pcmn( $this->getSession() - , $_cfg - , $this->getSession()->getDb()); - $pcmn->getAccountList("51"); // Get Banks accounts + , $_cfg + , $this->getSession()->getDb()); + $pcmn->getAccountList("51"); // Get Banks accounts } /** * Required by JsonSerializable diff --git a/app/compta/models/loan.php b/app/compta/models/loan.php index 16afa35..70d1aa9 100644 --- a/app/compta/models/loan.php +++ b/app/compta/models/loan.php @@ -3,7 +3,6 @@ namespace compta\models\loan; require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); require_once(dirname(__FILE__)."/../api_loan.php"); diff --git a/app/compta/models/owner.php b/app/compta/models/owner.php index 2480671..1a28728 100644 --- a/app/compta/models/owner.php +++ b/app/compta/models/owner.php @@ -20,9 +20,11 @@ require_once(dirname(__FILE__)."/../../../phplib/class.ofx.php"); */ class Model implements \JsonSerializable { - private $_session = null; - private $_auth_cfg = null; + private $_session = null; + private $_auth_cfg = null; + private $_summary = ""; + private $_decomptes = Array(); /** * Constructor */ @@ -37,5 +39,16 @@ class Model implements \JsonSerializable return $this->_session; } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'info' => $this->_summary + , 'decomptes' => $this->_decomptes]; + } + + } ?> diff --git a/app/compta/models/recurrent.php b/app/compta/models/recurrent.php index f83d64b..1952ab7 100644 --- a/app/compta/models/recurrent.php +++ b/app/compta/models/recurrent.php @@ -3,9 +3,80 @@ namespace compta\models\recurrent; require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); +require_once(dirname(__FILE__)."/../../../phplib/class.validator.php"); + + + +class Recurrent implements \JSonSerializable +{ + public $r_id = -1; + public $r_date = ""; + public $r_amount = 0.0; + public $r_desc = ""; + public $r_next = ""; + public $r_end = ""; + + public function __construct($c = null) + { + if ($c != null) + { + $i = 0; + foreach( get_object_vars($this) as $k => $v) + { $this->{$k} = $c[$i++]; } + } + } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'r_id' => $this->r_id + , 'r_date' => $this->r_date + , 'r_amount' => $this->r_amount + , 'r_desc' => $this->r_desc + , 'r_next' => $this->r_next + , 'r_end' => $this->r_end]; + } +} + +class Entry implements \JsonSerializable +{ + /* Order is important don't change */ + public $id = -1; + public $entry_type = "BQ"; // Could be HA, AN, what ever + public $acc_id = -1; + public $amount = 0.0; + public $dc = "d"; // Debit or credit + public $acc_name = ""; // Account name + + public function __construct($c = null) + { + if ($c != null) + { + $i = 0; + foreach( get_object_vars($this) as $k => $v) + { $this->{$k} = $c[$i++]; } + } + } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'id' => $this->id + , 'entry_type' => $this->entry_type + , 'acc_id' => $this->acc_id + , 'amount' => $this->amount + , 'dc' => $this->dc + , 'acc_name' => $this->acc_name]; + } +}; + /** * @brief Data model for a transaction. */ @@ -14,14 +85,25 @@ class Model implements \JsonSerializable private $_session = null; private $_auth_cfg = null; - private $summary; - - private $_entries; + private $FormValid = false; + private $summary = null; // Recurrent Object filled when validating inputs + private $updatePostParams = Array( "id", "rec_date" ,"rec_amount" ,"rec_desc" + , "rec_next" ,"rec_end"); + private $updatePostCheck = Array( "", "str_date" ,"num_float" ,"str" + , "str_date","str_date"); + public $_entries = Array(); // Array of entries private $_payer = false; public $id = -1; // current entry. -1 no entry selected - public $des; // description of recurrent entry - public $lst; // list of account operations + // TODO update view accordingly + public $des; // Deprecated description of recurrent entry + public $lst; // Deprecated list of account operations public $lp; // Payed transaction info + /* New way. Heuuu not sure. summary entry should be the winner */ + public $rec_desc = ""; + public $rec_date = ""; + public $rec_next = ""; + public $rec_end = ""; + public $rec_amount = 0.0; /** * Constructor */ @@ -29,17 +111,138 @@ class Model implements \JsonSerializable { $this->_session = $_sess; $this->_auth_cfg = $_auth; + $this->summary = new Recurrent(); + if (\AEB::$REQUEST['btRURecord'] != null) + { + $this->FormValid = $this->getUpdatePost(); + } + if (\AEB::$REQUEST['btRNRecord'] != null) + { + $this->FormValid = $this->getUpdatePost(); + } } private function getSession() { - return $this->_session; + return $this->_session; } public function isPayed() { return $this->_payer; } + + public function isFormValid() + { + return $this->FormValid; + } + /** + * Retrieve values from billPost request + */ + private function getUpdatePost() + { + $formValid = true; + $count = 0; + $valid = true; + $v = new \Validator(); + $this->id = \AEB::$REQUEST['rec_id']; + $this->summary->r_id = $this->id; + + // Check unique parameters + $f = reset($this->updatePostParams); + foreach ( $this->updatePostParams as $param) + { + if ($f == $param ) + { + $count++; + continue; // skip first element. + } + $pv = \AEB::$REQUEST[$param]; + try + { + $ck = $this->updatePostCheck[$count++]; + if ($ck != "") + { + $v->{$ck}($pv,"Not valid ".$param." value=".$pv."\n"); + } + // TODO remove once solved + $this->{$param} = $pv; + $this->summary->{str_replace("rec_","r_",$param)} = $pv; + } + catch (\Exception $e) + { + error_log("Parameter failure ".$e->getMessage()); + $formValid = false; + } + } + // Get Through post Entries + $count = 0; + for ( ; $count < 15 ; $count++) + { + $k = 'entry'.$count.'_id'; // Check if that key exists + if ( \AEB::$REQUEST->offsetExists($k) == true) + { + if ( ! $this->getEntryPost(\AEB::$REQUEST[$k],$count,$v) ) + { + $formValid = false; + } + } + else + { + break; + } + } + return $formValid; + } + + /** + * Retrieve the parameters from one line. + */ + private function getEntryPost($id,$line,$v) + { + $fvalid = true; // Form entry is valid + $k = "entry".$line.'_'; // Check if that key exists + $arr = Array("acc_id","acc_name","entry_type","amount_debit","amount_credit"); + $check = Array("num_int","","","num_float","num_float"); + $e = new Entry(); + $e->id = $id; + $count = 0; + // Check unique parameters + foreach ( $arr as $param) + { + $p = $k.$param; + $pv = \AEB::$REQUEST[$p]; + try { + $ck = $check[$count++]; + if ($ck != "") + { + $v->{$ck}($pv,"Not valid ".$param." va=".$pv."\n"); + } + if ($param == 'amount_debit' and $pv != 0.0 ) + { + $e->amount = $pv; + $e->dc = 'd'; + } else if ($param == 'amount_credit' and $pv != 0.0) + { + $e->amount = $pv; + $e->dc = 'c'; + } else + $e->{$param} = $pv; + } + catch (\Exception $exp) + { + error_log("Parameter failure:".$exp->getMessage()); + $fvalid = false; + } + } + // Only add Entries with an amount not equal to à. + if ($e->amount != 0.0 and ($e->acc_id != -1)) + { + $this->_entries[] = $e; + } + return $fvalid; + } + /** * @brief pay a recurrent entry for this month * @return Array('trans_id') in case of success or empty Array() in case of failure @@ -81,14 +284,31 @@ class Model implements \JsonSerializable { // Success book the entry $rec->markBooked($id); $this->_payer = true; - $this->lp = $lp; - $this->id = $id; + $this->lp = $lp; + $this->id = $id; } else { error_log("Failed payer : unknown reason"); } } + /** + * @brief called on updatePost when post + * parameters are all valid + * + * The model must contain valid parameters or else, + * it should fail + */ + public function update() + { + $_cfg = $this->_auth_cfg; + $rec = new \Recurrent( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $rec->update( $this->summary->jsonSerialize() + , json_decode(json_encode($this->_entries),true)); + } + /** * @brief get the details of a recurrent entry. * @@ -101,7 +321,16 @@ class Model implements \JsonSerializable , $this->getSession()->getDb()); $this->id = $id; $this->des = $rec->get($id); + $this->summary = new Recurrent($this->des); + $count = 0; + foreach ($this->updatePostParams as $p) + { $this->{$p} = $this->des[$count++]; } + $this->lst = $rec->getSummary($id); + foreach($this->lst as $e) + { + $this->_entries[] = new Entry($e); + } return [ 'des' => $this->des, 'lst' => $this->lst]; } @@ -111,8 +340,9 @@ class Model implements \JsonSerializable public function jsonSerialize() { return [ - 'transi' => $this->_summary - , 'entries' => $this->_entries]; + 'transi' => $this->summary + , 'entries' => $this->_entries + ]; } } diff --git a/app/compta/views/bank_index.php b/app/compta/views/bank_index.php index 2754565..e363665 100644 --- a/app/compta/views/bank_index.php +++ b/app/compta/views/bank_index.php @@ -6,8 +6,7 @@ require_once(dirname(__FILE__)."/../api_pcmn.php"); require_once(dirname(__FILE__)."/../api/bank.php"); require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); -global $xmlBankIndex; -$xmlBankIndex = << @@ -71,8 +70,7 @@ class Index extends \PageCompta function __construct($model, $b = true) { $this->_model = $model; - global $xmlBankIndex; - parent::__construct($xmlBankIndex,$b); + parent::__construct(xmlBankIndex,$b); } public function render() diff --git a/app/compta/views/recurrent_detail.php b/app/compta/views/recurrent_detail.php index 8d98a3b..6afc306 100644 --- a/app/compta/views/recurrent_detail.php +++ b/app/compta/views/recurrent_detail.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); @@ -92,6 +92,7 @@ _EOF; EOF; echo $res; @@ -104,9 +105,11 @@ EOF; function main() { $this->script("/app/compta/services.php/"); - echo '
'; + echo '
'; + echo '
'; $this->document(); echo '
'; + echo '
'; } } diff --git a/app/compta/views/recurrent_index.php b/app/compta/views/recurrent_index.php index 5c01365..cc31e58 100644 --- a/app/compta/views/recurrent_index.php +++ b/app/compta/views/recurrent_index.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); $XmlComptaDocuments = <<"; - /* - echo "

Prochaine échéance

"; - $lp = $rec->getNextPayement($id); - $date_apayer = new DateTime($lp[6]); - $date_today = new DateTime("now"); - $p = ""; - if ($date_apayer > $date_today) { - $p.= "en attente"; - } else { - $p.=<< - - - - -EOF; - } - - $res =<<<_EOF -Date - annuite - interet - ammorti -   - -{$lp[6]} - {$lp[7]} € - {$lp[8]} € - {$lp[9]} € - {$p} - - -_EOF; - echo $res; - */ } /** @@ -196,6 +161,7 @@ _EOF; $rec->markBooked($id); } echo "

Règlement échéance terminé

"; + echo "
"; echo ""; $res =<<<_EOF @@ -215,6 +181,7 @@ _EOF; _EOF; echo $res; echo "
Date
"; + echo "
"; } /** * @brief main page that will list all loans @@ -227,6 +194,7 @@ _EOF; , $_cfg , $this->getSession()->getDb()); $lst = $rec->getList(); + echo "
"; echo ""; echo ""; echo ""; @@ -262,6 +230,7 @@ EOF; $res.=""; echo $res; echo "
DateDescriptionMontantFinProchaine échéance
"; + echo "
"; } /** * @@ -298,7 +267,6 @@ EOF; $this->script("/app/compta/services.php/"); } else { - error_log("to pag_ledger"); $this->script(); } echo '
'; diff --git a/app/compta/views/recurrent_nouveau.php b/app/compta/views/recurrent_nouveau.php index 7816d02..738f697 100644 --- a/app/compta/views/recurrent_nouveau.php +++ b/app/compta/views/recurrent_nouveau.php @@ -5,10 +5,10 @@ require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); -$XmlComptaDocuments = << @@ -16,24 +16,81 @@ $XmlComptaDocuments = << Gestion comptable - - - - - + + + - - -

Chargement ...

-
+ + - - + +
+
XML; + + /** * @brief Update GUI with the list of * documents available. All decomptes @@ -42,268 +99,92 @@ class Nouveau extends \PageCompta implements \IActionResult { - function __construct($s = "" ,$b = true) + function __construct($_m ) { - parent::__construct($s,$b); + $this->_model = $_m; + parent::__construct(xmlRecurrentNouveau,true); } public function render() { $this->show(); } - /** - * @brief insert a script in the page to update menu link - * - */ - private function script($loc = "/app/compta/services.php/") - { - $s=<<<_EOF - -_EOF; - echo $s; - } - /** - * @brief main page that will list all loans - * - */ - private function docRecurrentDetails($id) - { - $tpl =<<<_EOF -%s - %s € - %s € - - -_EOF; - $_cfg = $this->_auth_cfg; - $rec = new \Recurrent( $this->getSession() - , $_cfg - , $this->getSession()->getDb()); - $des = $rec->get($id); - $lst = $rec->getSummary($id); - echo "

Détail ".$des[3]."

"; - echo ""; - echo ""; - echo ""; - echo ""; - echo "
Date de début : ".$des[1]."
Prochaine échéance:".$des[4]."
Montant : ".$des[2]."€
"; - echo "

Ecritures

"; - /* acc | debit | credit */ - echo ""; - $res =<<<_EOF - - - - - - -_EOF; - echo $res; - foreach( $lst as $k => $acc) - { - if ($acc[4] == 'd') - { - echo sprintf($tpl,$acc[2]." - ".$acc[5],$acc[3],"0.0"); - } else - { - echo sprintf($tpl,$acc[2]." - ".$acc[5],"0.0",$acc[3]); - } - } - echo "
AccountDébitCrédit
"; - /* - echo "

Prochaine échéance

"; - $lp = $rec->getNextPayement($id); - $date_apayer = new DateTime($lp[6]); - $date_today = new DateTime("now"); - $p = ""; - if ($date_apayer > $date_today) { - $p.= "en attente"; - } else { - $p.=<< - - - - -EOF; - } - - $res =<<<_EOF -Date - annuite - interet - ammorti -   - -{$lp[6]} - {$lp[7]} € - {$lp[8]} € - {$lp[9]} € - {$p} - - -_EOF; - echo $res; + /** + * @brief allow sub classes to modify xml file */ - } - - /** - * @brief pay the loan for this month - * @return Array('trans_id') in case of success or empty Array() in case of failure - */ - private function pay($id,$lp) + protected function _updateXML(&$xml) { - $_cfg = $this->_auth_cfg; - $entries = array(); - $book = new Booking( $this->getSession() - , $_cfg - , $this->getSession()->getDb()); - $trans = Array("trans_label" => "Payement ".$lp[0][2] - ,"voucher_date" => $lp[0][1] - ,"act_trans_date" => $lp[0][1]); - foreach($lp as $e ) - { - $entries[] = Array("acc_id" => $e[5] , "entry_type"=> $e[3] ,"amount" => $e[6], "dc" => $e[4], "key_charge" => "1"); - } - try { - return $book->postTransaction($trans,$entries); - } catch (Exception $e) - { - error_log("Failed pay:".$e->message()); - return Array(); - } - - } - /** - * @brief main page that will list all loans - * - */ - private function docRecurrentPayer($id) - { - $_cfg = $this->_auth_cfg; - $rec = new \Recurrent( $this->getSession() - , $_cfg - , $this->getSession()->getDb()); - $lp = $rec->getNextPayement($id); - $result = $this->pay($id,$lp); - if (isset($result['trans_id'])) - { // Success book the entry - $rec->markBooked($id); - } - echo "

Règlement échéance terminé

"; - echo ""; - $res =<<<_EOF - - - - - - - - - - - - + // Update the title + $tbody = $xml->getElementsByTagName("tbody"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillEntries()); + $tbody->item(0)->appendChild($nel); + /* Update menu */ + $tbody = $xml->getElementsByTagName('menu'); + $f = $tbody->item(0); + $items =<<<_EOF + _EOF; - echo $res; - echo "
Dateannuiteinteretammorti 
{$lp[6]}{$lp[7]} €{$lp[8]} €{$lp[9]} € - Retour -
"; - } - /** - * @brief main page that will list all loans - * - */ - private function docRecurrents() - { - $_cfg = $this->_auth_cfg; - $rec = new \Recurrent( $this->getSession() - , $_cfg - , $this->getSession()->getDb()); - $lst = $rec->getList(); - echo ""; - echo ""; - echo ""; - echo ""; - $date_today = new \DateTime("now"); - foreach ($lst as $l) - { - $res=""; - $prochaine_echeance = ""; - $date_apayer = new \DateTime($l[4]); - if ($date_apayer < $date_today) - { - $prochaine_echeance .= " ".$l[4]." a régler"; - } else - { - $prochaine_echeance .= $l[4]." en attente"; - } - $res.=<<{$l[3]} -EOF; - $res.=""; // Description - $res.=""; // Find - $res.=""; // Prochaine Echéance - $res.=""; - echo $res; - } - // Alright, add the last row that will allow you to add a recurrent entry - $res=""; - $res.=""; // Description - $res.=""; // Find - $res.=""; // Find - $res.=""; // Find - $res.=""; - echo $res; - echo "
DateDescriptionMontantFinProchaine échéance
".$l[1]."".$l[2]."".$l[5]."".$prochaine_echeance."
--.--.-- Ajouter une opération récurrente------
"; - } - /** - * - * - */ - private function documents() - { - if (isset($_GET['id']) ) - { - $this->docRecurrentDetails($_GET['id']); - } - else if (isset($_GET['regler']) ) - { - $this->docRecurrentPayer($_GET['regler']); - } - else - { - echo "

Les opération récurrentes

"; - $this->docRecurrents(); + $frag=sprintf($items + ,$this->_model->id); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($frag); + $f->appendChild($nel); + // Update asp for fields + $this->updateAspfor($xml,$this->_model); } - } - /** - * @brief Display The articles in flex mode - * Also revise menu - */ - function main() + private function fillEntries() { - if ( (isset($_POST) && isset($_POST['submit']) ) - || isset($_GET['regler']) - || isset($_GET['id'])) + $model = $this->_model; + $count = 0; + $frag = ""; + $arr = Array("id","acc_id","acc_name","entry_type","amount_debit","amount_credit"); + $tplt =<<<_EOF + +_EOF; + // Add some empty entries to fill the gap. + $entries = $model->_entries; + $count = count($model->_entries); + if ($count < 8 ) { - error_log("to ledger_recurrent"); - $this->script("/app/compta/services.php/"); - } else + for ($i = 8 - $count ; $i > 0 ; $i--) + { $entries[] = new \compta\models\recurrent\Entry(); } + + } + foreach($entries as $e) { - error_log("to pag_ledger"); - $this->script(); + $i = 0; + $fe = ""; + foreach($arr as $f) + { + if ($f == "amount_debit" ) + { + if ($e->dc == 'd') + { + $fe.=sprintf($tplt,"text",$count,$f,$e->amount); + } else { + $fe.=sprintf($tplt,"text",$count,$f,"0.0"); + } + } else if ($f == "id") + { + $fe.=sprintf($tplt,"hidden",$count,$f,$e->{$f}); + } else if ($f == "amount_credit") + { + if ($e->dc == 'c') + { + $fe.=sprintf($tplt,"text",$count,$f,$e->amount); + } else { + $fe.=sprintf($tplt,"text",$count,$f,"0.0"); + } + } else + $fe.=sprintf($tplt,"text",$count,$f,$e->{$f}); + } + $fe.=""; + $frag.=$fe; + $count++; } - echo '
'; - $this->documents(); - echo '
'; + return $frag; } } diff --git a/app/compta/views/recurrent_payer.php b/app/compta/views/recurrent_payer.php index 9bd54ea..eb9141d 100644 --- a/app/compta/views/recurrent_payer.php +++ b/app/compta/views/recurrent_payer.php @@ -5,7 +5,7 @@ require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); require_once(dirname(__FILE__)."/../models/recurrent.php"); diff --git a/app/compta/views/recurrent_remove.php b/app/compta/views/recurrent_remove.php new file mode 100644 index 0000000..139779c --- /dev/null +++ b/app/compta/views/recurrent_remove.php @@ -0,0 +1,115 @@ + + + + + +Gestion comptable + + + + + + + + +
+ +
+
+XML; + + + + +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Remove extends \PageCompta + implements \IActionResult +{ + + function __construct($_m ) + { + $this->_model = $_m; + parent::__construct(xmlRecurrentRemove,true); + } + public function render() + { + $this->show(); + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + // Update buttons + $bts = $xml->getElementsByTagName('button'); + foreach($bts as $bt) + { + if ($bt->getAttribute("id") == "btRRemove") + { + $bt->setAttribute("href","/app/compta/services.php/recurrent/remove/".$this->_model->id."?confirm=true"); + } + if ($bt->getAttribute("id") == "btRCancel") + { + $bt->setAttribute("href","/app/compta/services.php/recurrent/detail/".$this->_model->id.""); + } + } + /* Update menu */ + $tbody = $xml->getElementsByTagName('menu'); + $f = $tbody->item(0); + $items =<<<_EOF + +_EOF; + $frag=sprintf($items + ,$this->_model->id); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($frag); + $f->appendChild($nel); + // Update asp for fields + $this->updateAspfor($xml,$this->_model); + } + +} + +?> diff --git a/app/compta/views/recurrent_update.php b/app/compta/views/recurrent_update.php index f40f476..656f0af 100644 --- a/app/compta/views/recurrent_update.php +++ b/app/compta/views/recurrent_update.php @@ -5,9 +5,93 @@ require_once(dirname(__FILE__)."/../../../phplib/iface.ActionResult.php"); require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); -require_once(dirname(__FILE__)."/../api_recurrent.php"); +require_once(dirname(__FILE__)."/../api/recurrent.php"); require_once(dirname(__FILE__)."/../api_booking.php"); +const xmlRecurrentUpdate =<< + + + + +Gestion comptable + + + + + + + + + +
+ +
+
+XML; + /** * @brief Update GUI with the list of @@ -21,8 +105,9 @@ class Update extends \PageCompta function __construct($model) { $this->_model = $model; - parent::__construct("",true); + parent::__construct(xmlRecurrentUpdate,true); } + public function render() { $this->show(); @@ -44,75 +129,88 @@ class Update extends \PageCompta _EOF; echo $s; } - /** - * @brief main page that will list all loans - * - */ - private function document() + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) { - $tpl =<<<_EOF -%s - %s € - %s € - - -_EOF; - $des = $this->_model->des; - $lst = $this->_model->lst; - $res=<<<_EOF -

Détail {$des[3]}

-
- - - - - -
Montant : €
-

Ecritures

- - + // Update the title + $tbody = $xml->getElementsByTagName("tbody"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillEntries()); + $tbody->item(0)->appendChild($nel); + /* Update menu */ + $tbody = $xml->getElementsByTagName('menu'); + $f = $tbody->item(0); + $items =<<<_EOF + _EOF; + $frag=sprintf($items + ,$this->_model->id); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($frag); + $f->appendChild($nel); + // Update asp for fields + $this->updateAspfor($xml,$this->_model); + } - $res.=<<<_EOF - - - - - - -_EOF; - echo $res; - foreach( $lst as $k => $acc) + private function fillEntries() { - if ($acc[4] == 'd') + $model = $this->_model; + $count = 0; + $frag = ""; + $arr = Array("id","acc_id","acc_name","entry_type","amount_debit","amount_credit"); + $tplt =<<<_EOF + +_EOF; + $tplt_ro =<<<_EOF + +_EOF; + // Add some empty entries to fill the gap. + $entries = $model->_entries; + $ce = count($model->_entries); + if ($count < 8 ) { - echo sprintf($tpl,$acc[2]." - ".$acc[5],$acc[3],"0.0"); - } else + for ($i = 8 - $ce ; $i > 0 ; $i--) + { $entries[] = new \compta\models\recurrent\Entry(); } + + } + foreach($entries as $e) { - echo sprintf($tpl,$acc[2]." - ".$acc[5],"0.0",$acc[3]); + $i = 0; + $fe = ""; + foreach($arr as $f) + { + if ($f == "amount_debit" ) + { + if ($e->dc == 'd') + { + $fe.=sprintf($tplt,"text",$count,$f,$e->amount); + } else { + $fe.=sprintf($tplt,"text",$count,$f,"0.0"); + } + } else if ($f == "id") + { + $fe.=sprintf($tplt,"hidden",$count,$f,$e->{$f}); + } else if ($f == "amount_credit") + { + if ($e->dc == 'c') + { + $fe.=sprintf($tplt,"text",$count,$f,$e->amount); + } else { + $fe.=sprintf($tplt,"text",$count,$f,"0.0"); + } + } else if ($f == "acc_name") + { + $fe.=sprintf($tplt_ro,"text",$count,$f,$e->{$f}); + } else + $fe.=sprintf($tplt,"text",$count,$f,$e->{$f}); + } + $fe.=""; + $frag.=$fe; + $count++; } - } - echo "
AccountDébitCrédit
"; - $res=<< - -EOF; - echo $res; - } - - /** - * @brief Display The articles in flex mode - * Also revise menu - */ - function main() - { - $this->script("/app/compta/services.php/"); - echo '
'; - $this->document(); - echo '
'; + return $frag; } } diff --git a/app/compta/views/supplier_bill.php b/app/compta/views/supplier_bill.php index 8797921..d6a6ee6 100644 --- a/app/compta/views/supplier_bill.php +++ b/app/compta/views/supplier_bill.php @@ -114,9 +114,9 @@ _EOF; ,$this->_model->_id); $nel = $xml->createDocumentFragment(); $nel->appendXML($frag); - $f->appendChild($nel); - // Update asp for fields - $this->updateAspfor($xml,$this->_model); + $f->appendChild($nel); + // Update asp for fields + $this->updateAspfor($xml,$this->_model); } /** diff --git a/app/compta/views/supplier_billpay.php b/app/compta/views/supplier_billpay.php new file mode 100644 index 0000000..0cf448f --- /dev/null +++ b/app/compta/views/supplier_billpay.php @@ -0,0 +1,203 @@ + + + + + +Gestion comptable + + + + + + + + +
+ +
+
+XML; + +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Billpay extends \PageCompta + implements \IActionResult +{ + function __construct($model) + { + $this->_model = $model; + parent::__construct(SupplierBill,true); + } + + public function render() + { + $this->show(); + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $this->getElementById($xml,"suppl_charge_key"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillKeys()); + $tbody->appendChild($nel); + // Ok Handle bank + $solde = $this->getElementById($xml,"suppl_bank"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillBanque()); + $solde->appendChild($nel); + // Ok Handle Charges + $solde = $this->getElementById($xml,"suppl_charge"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillCharge()); + $solde->appendChild($nel); + // Update supplier ID + $tbody = $this->getElementById($xml,"suppl_id"); + $nel = $xml->createDocumentFragment(); + $frag =<<<_EOF + +_EOF; + $nel->appendXML($frag); + $tbody->appendChild($nel); + /* Update menu */ + $tbody = $xml->getElementsByTagName('menu'); + $f = $tbody->item(0); + $items =<<<_EOF + +_EOF; + $frag=sprintf($items + ,$this->_model->_id); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($frag); + $f->appendChild($nel); + // Update asp for fields + $this->updateAspfor($xml,$this->_model); + } + + /** + * @brief Fill key Charge + */ + private function fillKeys() + { + + $template=<<<_EOF + +_EOF; + $frag = ""; + $count = 0; + $lst = $this->_model->getKeysCharge(); + foreach( $lst as $row) + { + $frag.=sprintf($template + ,$row[1] + ,$row[2],$row[0]); + } + return $frag; + + } + + /** + * @brief Fill key Charge + */ + private function fillBanque() + { + + $template=<<<_EOF + +_EOF; + $frag = ""; + $count = 0; + $lst = $this->_model->getListAccounts("5"); + foreach( $lst as $row) + { + $frag.=sprintf($template + ,$row['acc_id'] + ,$row['acc_desc'] + ,$row['acc_id']); + } + return $frag; + + } + /** + * @brief Fill key Charge + */ + private function fillCharge() + { + + $template=<<<_EOF + +_EOF; + $frag = ""; + $count = 0; + $lst = $this->_model->getListAccounts("6"); + foreach( $lst as $row) + { + $frag.=sprintf($template + ,$row['acc_id'] + ,$row['acc_desc'] + ,$row['acc_id']); + } + return $frag; + + } + + + +} + + + +?> -- 2.30.2