From: www-data Date: Fri, 29 Jul 2022 21:28:38 +0000 (+0200) Subject: Improved controler views X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=4d3e02820b76ac0fc64eb9a855ddd573fd0ec0c3;p=www%2Fsyndic.git Improved controler views --- diff --git a/app/compta/api/recurrent.php b/app/compta/api/recurrent.php index 8b27042..d0f6ba1 100644 --- a/app/compta/api/recurrent.php +++ b/app/compta/api/recurrent.php @@ -41,6 +41,15 @@ class Recurrent extends Api { */ private function insertEntry($rec_id,$e) { + $tplt = ""; + if ($e['id'] == -1 ) + { + $tplt=<<<_EOF +INSERT INTO RecurrentEntry (re_rec_id,re_entry_type,re_acc,re_debit_credit,re_amount) + VALUES({$rec_id},"{$e['entry_type']}",{$e['acc_id']},"{$e['dc']}",{$e['amount']}) ; +_EOF; + } else + { $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']}) @@ -50,12 +59,6 @@ ON DUPLICATE KEY UPDATE , 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 { @@ -80,17 +83,17 @@ _EOF; 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']}) +INSERT INTO Recurrent (r_date,r_amount,r_desc,r_next,r_end) + VALUES("{$r['r_date']}",{$r['r_amount']},"{$r['r_desc']}","{$r['r_next']}","{$r['r_end']}") ; SELECT LAST_INSERT_ID() ; _EOF; try { - $res = $this->doQueryI($q); + $res = $this->doQueryI($tplt); } catch (Exception $e) { error_log("Recurrent::create ".$id." Failed ".$e->getMessage()); return Array(''); } - $r_id = $res['records'][0]; + $r_id = $res['records'][0][0]; error_log("Recurrent::create ".$id." created add entries"); foreach($entries as $entry) { diff --git a/app/compta/api_booking.php b/app/compta/api_booking.php index a715c0c..2474d47 100644 --- a/app/compta/api_booking.php +++ b/app/compta/api_booking.php @@ -174,14 +174,14 @@ _EOF; { $q =<<<_EOF SET sql_mode="NO_ENGINE_SUBSTITUTION"; -INSERT INTO Transactions (voucher_date,act_trans_date,trans_label) -VALUES ('{$transi['voucher_date']}','{$transi['act_trans_date']}','{$transi['trans_label']}'); +INSERT INTO Transactions (voucher_date,voucher_ref,act_trans_date,trans_label) +VALUES ('{$transi['voucher_date']}','{$transi['voucher_ref']}','{$transi['act_trans_date']}','{$transi['trans_label']}'); _EOF; $this->logTransaction("New Transaction ",$q); $res = $this->doQueryI($q); $qlid= "select LAST_INSERT_ID();"; $res = $this->doQueryI($qlid); - $trans_id = $res['records'][0]['0']; + $trans_id = $res['records'][0][0]; foreach($entries as $entry) { $this->newEntry($trans_id,$entry,$transi['act_trans_date']); @@ -203,6 +203,7 @@ UPDATE Transactions SET voucher_date='{$transi['voucher_date']}' ,act_trans_date='{$transi['act_trans_date']}' ,trans_label= '{$transi['trans_label']}' + ,voucher_ref= '{$transi['voucher_ref']}' WHERE trans_id= {$transi['trans_id']} ; _EOF; $this->logTransaction("Update Transaction ",$q); diff --git a/app/compta/api_budget.php b/app/compta/api_budget.php index e09f1a6..821ffd5 100644 --- a/app/compta/api_budget.php +++ b/app/compta/api_budget.php @@ -12,63 +12,102 @@ class Budget extends Api { /** * @brief - */ - function getAllAccounts($transInfo,$entries) { - } - - /** - * @brief + * return an array of array (bu_id,period,budget_desc) */ function getBudgets() { $q =<<<__EOF - select bu_id, p.per_string, bu_desc from Budget as b JOIN Period as p on b.bu_period_id = p.per_id order by p.per_string; +SELECT bu_id, p.per_string, bu_desc,COALESCE(SUM(be.buet_amount),0.0) from Budget as b + JOIN Period AS p ON b.bu_period_id = p.per_id + LEFT JOIN BudgetEntry as be ON b.bu_id = be.buet_budget_id or be.buet_budget_id IS NULL +WHERE be.buet_acc_id LIKE ('6%') or be.buet_acc_id IS NULL +GROUP BY p.per_string +ORDER by p.per_string +; __EOF; $res = $this->doQueryI($q); return $res['records']; } -/** - trans_id INTEGER AUTO_INCREMENT PRIMARY KEY, - voucher_ref VARCHAR(255), - voucher_date DATE, - act_trans_date DATE, - per_id INTEGER -Transaction Entry - trans_entry_id INTEGER AUTO_INCREMENT PRIMARY KEY, - trans_id INTEGER, - entry_date DATE, - entry_type VARCHAR(2), - acc_id VARCHAR(32), - orig_amount REAL, - amount DOUBLE PRECISION, - debit_credit enum ('d','c'), - description VARCHAR(255), - voucher_ref VARCHAR(255) - */ - function getTransaction($id) { - $q ='select trans_id,voucher_ref,voucher_date from Transaction where trans_id ='.$id.';'; - $transaction = $this->doQueryI($q); - $q ='select trans_entry_id,acc_id,voucher_ref,description,debit_credit,amount from TransactionEntry where trans_id ='.$id.';'; - $entries = $this->doQueryI($q); - return array( 'transaction' => $transaction['records'], 'entries' => $entries['records']); + /** + * @brief Get the budget entry from the database. If the entry does not yey + * exists, return an initialized array with the necessary parameter + * + * + * @param IN $bu_id The budget identifier + * @param IN $acc_nbr String identifing the account number. + * @return an array (buet_id,buet_budget_id,buet_acc_id,buet_amount,buet_pc_ic) + * + public $budget_id = -1; + public $entry_id = -1; + public $acc_id = -1; + public $amount = 0.0; + public $dc = "c"; // Debit or credit + public $pc = 1; // Post charge + */ + function getBudgetEntry($bu_id,$acc_nbr) { + $q =<<<__EOF +SELECT + buet_budget_id as budget_id + , COALESCE(buet_id,0) as entry_id + , buet_acc_id + , COALESCE(buet_amount,0.0) as amount + , buet_debit_credit + , buet_pc_id as pc +FROM BudgetEntry as b +WHERE buet_acc_id = "{$acc_nbr}" and buet_budget_id = {$bu_id} +; +__EOF; + $res = $this->doQueryI($q); + //if (sizeof($res['records'][0]) < 5) + if (! isset($res['records'][0]) ) + { + return Array($bu_id,-1,$acc_nbr,0.0,'c',1); + } + return $res['records'][0]; } - /** * @brief */ - function getBudgetEntries($cls,$anne) { + function getBudgetEntries($cls,$anne,$bu_id = -1) { $q=<< 0) + { + $q=<<doQueryI($q); return $res['records']; @@ -79,7 +118,7 @@ EOF; /** * @brief */ - function getEntriesByAccount($period,$acc) { + private function getEntriesByAccount($period,$acc) { $q = 'call detail_compte_sans_solde("'.$period.'",'.$acc.');'; $res = $this->doQueryI($q); if ($res['total_matches'] == 0) { @@ -94,7 +133,7 @@ EOF; /** * @brief */ - function getSoldeAccount($period,$acc) { + private function getSoldeAccount($period,$acc) { $q = 'CALL solde_compte("'.$period.'","'.$acc.'");'; $res = $this->doQueryI($q); return $res['records'][0]; @@ -112,9 +151,9 @@ EOF; error_log("Buget::addBudget ".$anne." desc=".$desc); $q = 'select per_id from Period where per_string = "'.$anne.'";'; $res = $this->doQueryI($q); - error_log("addBudget ".$anne." Called res= ".$res["records"][0][0]); - if ($res['records'][0][0] > 0) { - $pid = $res['records'][0][0]; + error_log("addBudget ".$anne." Called res= ".$res["records"][0][0]."\n"); + if ($res["records"][0][0] > 0) { + $pid = $res["records"][0][0]; $q = 'INSERT INTO Budget (bu_period_id,bu_desc) VALUES('.$pid.',"'.$desc.'");'; $res = $this->doQueryI($q); $this->logTransaction("Budget Create",$q); @@ -141,15 +180,49 @@ EOF; /** * @brief */ - function addBudgetEntry($buet_id,$bu_id,$acc,$amount,$chrg) { - if (!$this->in_groupe(COMPTA_SYNDIC)) { - throw new Exception(_("Only Syndic can add or replace a Budget entry")); - } + function addBudgetEntry($buet_id,$bu_id,$acc,$amount,$chrg) + { + if (!$this->in_groupe(COMPTA_SYNDIC)) { + throw new Exception(_("Only Syndic can add or replace a Budget entry")); + } $q = "REPLACE INTO BudgetEntry (buet_id,buet_budget_id,buet_acc_id,buet_amount,buet_pc_id) VALUES (".$buet_id.",".$bu_id.",'".$acc."',".$amount.",".$chrg.");"; + if ($buet_id == -1) + { // New entry + $q = "INSERT INTO BudgetEntry (buet_budget_id,buet_acc_id,buet_amount,buet_pc_id) VALUES (".$bu_id.",'".$acc."',".$amount.",".$chrg.");"; + } $res = $this->doQueryI($q); $this->logTransaction("Budget Add Entry",$q); return array(""); } + + /** + * @brief get Budget for all user account or a specific user account + * if given as parameter + */ + function getBudgetPerUser($bu_id,$user_acc = null) + { + $q =<<<_EOF +SELECT acc_id, acc_name,tant,tc,ROUND(tc * tant / 1000,2) as annuelle,ROUND(tc * tant / 1000 / 4,2) as trimestre, ROUND(tc*tant/1000 / 12,2) as mensuelle FROM + ( SELECT acc_id + , acc_name + , (SELECT sum(buet_amount) + FROM BudgetEntry as be + JOIN Budget as b on be.buet_budget_id = b.bu_id + JOIN Period as p on p.per_id = b.bu_period_id + WHERE be.buet_acc_id like '6%' AND p.per_string = "2022" + ) as tc + ,FctTantieme(acc_id,1) as tant + FROM `Account` + WHERE acc_id like '45%' and acc_right = acc_left + 1 + ) as n +WHERE tant != 0; +_EOF; + + $res = $this->doQueryI($q); + $this->logTransaction("getBudgetPerUser",$q); + return $res['records']; + + } } diff --git a/app/compta/controlers/account.php b/app/compta/controlers/account.php index 0f8848a..4c62973 100644 --- a/app/compta/controlers/account.php +++ b/app/compta/controlers/account.php @@ -40,10 +40,10 @@ class Account extends controler */ public function index() : \IActionResult { - //require_once(controler::$basedir."/view_bank_index.php"); - //$page = new \compta\views\account\Index(); - return new \HtmlResult("Account to be coded"); - //return $page; + require_once(controler::$viewdir."/account_index.php"); + $page = new \compta\views\account\Index($this->_model); + //return new \HtmlResult("Account to be coded"); + return $page; } /** @@ -70,6 +70,19 @@ class Account extends controler return $page; // return new \HtmlResult("Account ".$_id); } + /** + * @brief display a short list of all account + * categories 1 to 8 + * + */ + public function categorie($_id) + { + require_once(controler::$viewdir."/account_categorie.php"); + $this->_model->getDetails($_id); + $page = new \compta\views\account\Categorie($this->_model); + return $page; + // return new \HtmlResult("Account ".$_id); + } } diff --git a/app/compta/controlers/bilan.php b/app/compta/controlers/bilan.php index 499eea6..5207145 100644 --- a/app/compta/controlers/bilan.php +++ b/app/compta/controlers/bilan.php @@ -15,12 +15,13 @@ namespace compta\controlers; require_once(dirname(__FILE__)."/../controler_base.php"); require_once(controler::$basedir."/../../phplib/iface.ActionResult.php"); require_once(controler::$basedir."/../../phplib/class.ActionResults.php"); +require_once(controler::$modeldir."/bilan.php"); /** * * */ -class Bilan +class Bilan extends controler { /** @@ -28,6 +29,9 @@ class Bilan */ public function __construct() { + parent::__construct(); + $this->_model = new \compta\models\bilan\Model( + $this->getSession(),$this->getAuthConfig()); } /** * Get the details of the supplier account. @@ -39,6 +43,16 @@ class Bilan $page = new \compta\views\bilan\Index(); return $page; } + /** + * Get the details of the supplier account. + * @param string $_accout_id the supplier account + */ + public function charges() : \IActionResult + { + require_once(controler::$basedir."/views/bilan_charges.php"); + $page = new \compta\views\bilan\Charges($this->_model); + return $page; + } } ?> diff --git a/app/compta/controlers/budget.php b/app/compta/controlers/budget.php index 0399c02..29e9d01 100644 --- a/app/compta/controlers/budget.php +++ b/app/compta/controlers/budget.php @@ -49,14 +49,25 @@ class Budget $page = new \compta\views\budget\Index(); return $page; } + /** + * Get default budget main page. + */ + public function list() : \IActionResult + { + require_once(controler::$basedir."/views/budget_list.php"); + $page = new \compta\views\budget\BList($this->_model); + return $page; + } /** * Get the details of the supplier account. * @param string $_accout_id the supplier account */ public function detail($_id) : \IActionResult { + $model = $this->_model; + $model->current_budget_id = $_id; require_once(controler::$basedir."/views/budget_detail.php"); - $page = new \compta\views\budget\Index(); + $page = new \compta\views\budget\Detail($this->_model); return $page; } /** @@ -69,6 +80,54 @@ class Budget $page = new \compta\views\budget\Nouveau(); return $page; } + /** + * Get the details of the supplier account. + * @param string $_accout_id the supplier account + */ + public function update() : \IActionResult + { + require_once(controler::$basedir."/views/budget_update.php"); + $page = new \compta\views\budget\Update(); + return $page; + } + /** + * Get the details of the supplier account. + * TODO validate input parameters + * @param string $_accout_id the supplier account + */ + public function updateEntry($bu_id,$acc) : \IActionResult + { + $model = $this->_model; + require_once(controler::$basedir."/views/budget_updateEntry.php"); + $model->getBudgetEntry($bu_id,$acc); + $page = new \compta\views\budget\UpdateEntry($this->_model); + return $page; + } + /** + * Get the details of the supplier account. + * @param string $_accout_id the supplier account + */ + public function updatePost() : \IActionResult + { + $model = $this->_model; + require_once(controler::$basedir."/views/budget_nouveau.php"); + $page = new \compta\views\budget\Nouveau(); + return $page; + } + /** + * Get the details of the supplier account. + * @param string $_accout_id the supplier account + */ + public function updateEntryPost() : \IActionResult + { + $model = $this->_model; + if ($model->isFormValid()) + { + $model->setBudgetEntry(); + return $this->detail($model->entry->budget_id); + } + return $this->updateEntry($model->entry->budget_id,$model->entry->acc_id); + } } ?> diff --git a/app/compta/controlers/recurrent.php b/app/compta/controlers/recurrent.php index 2289983..ffb586b 100644 --- a/app/compta/controlers/recurrent.php +++ b/app/compta/controlers/recurrent.php @@ -132,8 +132,18 @@ class Recurrent */ public function nouveauPost() : \IActionResult { - require_once(controler::$basedir."/views/recurrent_nouveau.php"); - $page = new \compta\views\recurrent\Nouveau($this->_model); + $page = null; + $model = $this->_model; + if ($model->isFormValid()) + {// Create the entries and every + require_once(controler::$basedir."/views/recurrent_index.php"); + $model->create(); + $page = new \compta\views\recurrent\Index(); + } else + { + require_once(controler::$basedir."/views/recurrent_nouveau.php"); + $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 e8855d7..b02954e 100644 --- a/app/compta/controlers/supplier.php +++ b/app/compta/controlers/supplier.php @@ -105,6 +105,21 @@ class Supplier extends controler return new \compta\views\supplier\Bill($model); } + public function billPayPost() : \IActionResult + { + $model = $this->_model; + require_once(controler::$viewdir."/supplier_billpay.php"); + $model->getDetails($model->_id); + $model->getAccount($model->_id); + if ( $model->validePost()) + { + $model->newBillPay(); + return $this->account($model->_id); + } else + return new \compta\views\supplier\Billpay($model); + } + + public function payPost() : \IActionResult { $model = $this->_model; diff --git a/app/compta/models/bilan.php b/app/compta/models/bilan.php new file mode 100644 index 0000000..0484109 --- /dev/null +++ b/app/compta/models/bilan.php @@ -0,0 +1,82 @@ +_session = $_sess; + $this->_auth_cfg = $_auth; + $this->suppl_date = date("Y-m-d"); + } + + private function getSession() + { + return $this->_session; + } + + /** + * + * + */ + public function syntheseCharges() + { + $ex = $this->getSession()->getCurrentExercice(); + + $q=<<<_EOF +SELECT a.acc_id + ,a.acc_name + ,sum(COALESCE(amount,0)) + , + (SELECT count(p.acc_id) as level FROM Account as ap + JOIN Account as p on p.acc_left < ap.acc_left and p.acc_right > ap.acc_right + WHERE ap.acc_id = a.acc_id) as l + + FROM Account as a +JOIN Period as p on per_string = "{$ex}" +JOIN Account as son on a.acc_left <= son.acc_left and a.acc_right >= son.acc_right +LEFT JOIN TransactionEntry as te on son.acc_id = te.acc_id and te.debit_credit = 'd' + and te.entry_date BETWEEN p.per_begin AND p.per_end +LEFT JOIN PosteCharge as pc on te.tret_key_id = pc.pc_id +WHERE a.acc_id REGEXP ('^6.*') AND a.acc_left <= a.acc_right - 1 +GROUP BY a.acc_id +_EOF; + $_cfg = $this->_auth_cfg; + $pcmn = new \Retrieve( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $r = $pcmn->doQueryI($q); + return $r['records']; + } + + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'account' => $this->_summary + , 'charges' => $this->syntheseCharges() + ]; + } + + +} diff --git a/app/compta/models/budget.php b/app/compta/models/budget.php index 5063599..7714d37 100644 --- a/app/compta/models/budget.php +++ b/app/compta/models/budget.php @@ -6,6 +6,46 @@ require_once(dirname(__FILE__)."/../api_exercice.php"); require_once(dirname(__FILE__)."/../api_budget.php"); require_once(dirname(__FILE__)."/../api_booking.php"); + +class Entry implements \JsonSerializable +{ + /* Order is important don't change */ + public $budget_id = -1; + public $entry_id = -1; + public $acc_id = -1; + public $amount = 0.0; + public $dc = "c"; // Debit or credit + public $pc = 1; // Post charge + + public function __construct($c = null) + { + if ($c != null) + { + $i = 0; + foreach( get_object_vars($this) as $k => $v) + { + //error_log("Entry::ctor ".$k." (pos ".$i.") set to :".$c[$i]."\n"); + $this->{$k} = $c[$i++]; + } + } + } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ + 'budget_id' => $this->budget_id + , 'entry_id' => $this->entry_id + , 'acc_id' => $this->acc_id + , 'amount' => $this->amount + , 'dc' => $this->dc + , 'pc' => $this->pc]; + } +}; + + + /** * @brief Data model for a transaction. */ @@ -13,14 +53,19 @@ class Model implements \JsonSerializable { private $_session = null; private $_auth_cfg = null; + private $budget_db = null; + + private $updatePostParams = Array( "be_budget_id", "be_entry_id" ,"be_acc_id" ,"be_pc" + ,"be_amount"); + private $updatePostCheck = Array( "num_int", "num_int" ,"num_int" ,"num_int" + , "num_float",""); private $summary; private $_entries; - - public $id = -1; // current entry. -1 no entry selected - public $des; // description of recurrent entry - public $lst; // list of account operations + public $FormValid = false; + public $current_budget_id; + public $entry = null; // Current Budget entry /** * Constructor */ @@ -28,12 +73,110 @@ class Model implements \JsonSerializable { $this->_session = $_sess; $this->_auth_cfg = $_auth; + $this->budget_db = new \Budget( $this->getSession() + , $this->_auth_cfg + , $this->getSession()->getDb()); + if (\AEB::$REQUEST['btBERecord'] != null) + { + $this->entry = new Entry(); + $this->FormValid = $this->getUpdatePost(); + } } private function getSession() { return $this->_session; } + + /** + * @brief retrieve budget list from Database + * + */ + public function getBudgets() + { + $_cfg = $this->_auth_cfg; + $b = new \Budget( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + return $b->getBudgets(); + } + + /** + * @brief retrieve budger entry from database + * + */ + public function getBudgetEntry($bu_id,$acc_nbr) + { + $b = $this->budget_db; + $this->entry = new Entry($b->getBudgetEntry($bu_id,$acc_nbr)); + return $this->entry; + } + + /** + * @brief update/create budget entry in database + * + */ + public function setBudgetEntry() + { + $b = $this->budget_db; + $e = $this->entry; + //function addBudgetEntry($buet_id,$bu_id,$acc,$amount,$chrg) { + error_log("add Entry:".$e->entry_id." bu_id ".$e->budget_id." ".$e->acc_id." ".$e->amount); + $b->addBudgetEntry($e->entry_id,$e->budget_id,$e->acc_id,$e->amount,$e->pc); + return ; + } + + /** + * + * + */ + public function getBudgetEntries($bu_id,$categorie) + { + $b = $this->budget_db; + return $b->getBudgetEntries($categorie,"",$bu_id); + } + /** + * + */ + public function isFormValid() + { + return $this->FormValid; + } + /** + * Retrieve values from billPost request + */ + private function getUpdatePost() + { + $formValid = true; + $count = 0; + $valid = true; + $v = new \Validator(); + + // Check unique parameters + $f = reset($this->updatePostParams); + foreach ( $this->updatePostParams as $param) + { + $pv = \AEB::$REQUEST[$param]; + try + { + $ck = $this->updatePostCheck[$count++]; + if ($ck != "") + { + $v->{$ck}($pv,"Not valid ".$param." value=".$pv."\n"); + } + // TODO remove once solved + if ($this->entry != null) + $this->entry->{str_replace("be_","",$param)} = $pv; + } + catch (\Exception $e) + { + error_log("Parameter failure ".$e->getMessage()); + $formValid = false; + } + } + return $formValid; + } + /** * Required by JsonSerializable */ diff --git a/app/compta/models/recurrent.php b/app/compta/models/recurrent.php index 1952ab7..de87987 100644 --- a/app/compta/models/recurrent.php +++ b/app/compta/models/recurrent.php @@ -256,6 +256,7 @@ class Model implements \JsonSerializable , $this->getSession()->getDb()); $trans = Array("trans_label" => "Payement ".$lp[0][2] ,"voucher_date" => $lp[0][1] + ,"voucher_ref" => $lp[0][2]." ".$lp[0].[1] ,"act_trans_date" => $lp[0][1]); foreach($lp as $e ) { @@ -309,6 +310,17 @@ class Model implements \JsonSerializable , json_decode(json_encode($this->_entries),true)); } + + public function create() + { + $_cfg = $this->_auth_cfg; + $rec = new \Recurrent( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $rec->create( $this->summary->jsonSerialize() + , json_decode(json_encode($this->_entries),true)); + } + /** * @brief get the details of a recurrent entry. * diff --git a/app/compta/models/supplier.php b/app/compta/models/supplier.php index 0924206..b79fe70 100644 --- a/app/compta/models/supplier.php +++ b/app/compta/models/supplier.php @@ -26,8 +26,8 @@ class Model implements \JsonSerializable /* Bill parameters */ private $bValide = false; // is Bill from post valide private $billPostParams = Array("suppl_amount","suppl_date","suppl_voucher_date","suppl_voucher_ref" - ,"suppl_desc","suppl_charge_key","suppl_charge"); - private $billPostCheck = Array("num_float","str_date","str_date","str","str","",""); + ,"suppl_desc","suppl_charge_key","suppl_charge","suppl_charge"); + private $billPostCheck = Array("num_float","str_date","str_date","str","str","","",""); public $suppl_desc = ""; public $suppl_charge = ""; public $suppl_amount = 0.0; @@ -50,6 +50,11 @@ class Model implements \JsonSerializable if (\AEB::$REQUEST['btFFRecord'] != null) { $this->getBillPost(); + } else if (\AEB::$REQUEST['btFFPRecord'] != null) + { + $this->billPostParams[7] = "suppl_banque"; + // Ok handler pay bill + $this->getBillPost(); } else if (\AEB::$REQUEST['btFPRecord'] != null) { $this->billPostParams[6] = "suppl_banque"; @@ -165,6 +170,34 @@ class Model implements \JsonSerializable } + /** + * + */ + public function newBillPay() + { + $transi = Array( 'act_trans_date' => $this->suppl_date + , 'voucher_date' => $this->suppl_voucher_date + , 'voucher_ref' => $this->suppl_voucher_ref + , 'acc_supplier' => $this->_id + , 'acc_charge' => $this->suppl_charge + , 'amount' => $this->suppl_amount + , 'trans_label' => $this->suppl_desc + , 'key_charge' => $this->suppl_charge_key + ); + $_amount = $this->suppl_amount; + $_charge = $this->suppl_charge; + $entries = Array( + Array("acc_id" => $this->_id, "entry_type"=> "HA" ,"amount" => $_amount, "dc" => 'c', "key_charge" => "1") + ,Array("acc_id" => $_charge , "entry_type"=> "HA" ,"amount" => $_amount, "dc" => 'd', "key_charge" => "1") + ,Array("acc_id" => $this->_id , "entry_type"=> "BQ" ,"amount" => $_amount, "dc" => 'd', "key_charge" => "1") + ,Array("acc_id" => $this->suppl_banque , "entry_type"=> "BQ" ,"amount" => $_amount, "dc" => 'c', "key_charge" => "1") + ); + $_cfg = $this->_auth_cfg; + $pcmn = new \Booking( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + return $pcmn->postTransaction($transi,$entries); + } /** * */ @@ -186,6 +219,7 @@ class Model implements \JsonSerializable return $pcmn->newBill($transi,""); } + /** * */ diff --git a/app/compta/pages.php b/app/compta/pages.php index a4206e2..1644fe2 100644 --- a/app/compta/pages.php +++ b/app/compta/pages.php @@ -82,7 +82,8 @@ class PageCompta extends AppPage { { if ($value->nodeName == "ComboBox") { - $afor_value = $model->{$value->getAttribute("asp-for")}; + //$afor_value = $model->{$value->getAttribute("asp-for")}; + $afor_value = $this->getAspAttributeFromModel($value,$model); // Get and find right selection set selected foreach($value->childNodes as $child) { @@ -90,12 +91,33 @@ class PageCompta extends AppPage { ($child->nodeName == "Entry") &&($child->getAttribute("value") == $afor_value) ) { - error_log("Found Entry ".$afor_value."\n"); $child->setAttribute("selected","1"); } } } else - $value->setAttribute("value",$model->{$value->getAttribute("asp-for")}); + $value->setAttribute("value" + ,$this->getAspAttributeFromModel($value,$model)); + } + } + + /** + * @brief getting the attribute from model based on asp entry seems to + * be more complicated I thought + */ + private function getAspAttributeFromModel($value,$model) + { + $asp = $value->getAttribute("asp-for"); + $pos = strpos($asp,'.'); + if ($pos !== false) + { // Get child object to retrieve the parameter + $child = strstr($asp,".",1); + $entry = substr(strstr($asp,"."),1); + $mv = get_object_vars($model); + return $mv[$child]->{$entry}; + + } else + { // Get attribute directly from object model + return $model->{$value->getAttribute("asp-for")}; } } /** diff --git a/app/compta/services.php b/app/compta/services.php index b3cd3ad..4bc243a 100644 --- a/app/compta/services.php +++ b/app/compta/services.php @@ -49,6 +49,7 @@ $r->get('/chart/acount/?:id',"chart#account")->setRoot($ctrl_dir); /* Account services*/ $r->get('/account',"account#index")->setRoot($ctrl_dir); $r->get('/account/detail/?:id',"account#detail")->setRoot($ctrl_dir); +$r->get('/account/categorie/?:id',"account#categorie")->setRoot($ctrl_dir); /* Supplier services*/ $r->get('/supplier',"supplier#index")->setRoot($ctrl_dir); @@ -56,7 +57,9 @@ $r->get('/supplier/details/?:id',"supplier#details")->setRoot($ctrl_dir); $r->get('/supplier/account/?:id',"supplier#account")->setRoot($ctrl_dir); $r->get('/supplier/bill/?:id',"supplier#bill")->setRoot($ctrl_dir); $r->get('/supplier/pay/?:id',"supplier#pay")->setRoot($ctrl_dir); +$r->get('/supplier/billpay/?:id',"supplier#billpay")->setRoot($ctrl_dir); $r->post('/supplier/billPost',"supplier#billPost")->setRoot($ctrl_dir); +$r->post('/supplier/billPayPost',"supplier#billPayPost")->setRoot($ctrl_dir); $r->post('/supplier/payPost',"supplier#payPost")->setRoot($ctrl_dir); /* exercice */ @@ -86,6 +89,7 @@ $r->post('/recurrent/updatePost',"recurrent#updatePost" ) ->setRoot($ctrl_dir); $r->get('/recurrent/payer/?:id',"recurrent#payer")->setRoot($ctrl_dir); $r->get('/recurrent/nouveau',"recurrent#nouveau")->setRoot($ctrl_dir); $r->post('/recurrent/nouveauPost',"recurrent#nouveauPost" ) ->setRoot($ctrl_dir); +$r->get('/recurrent/remove/?:id',"recurrent#remove" ) ->setRoot($ctrl_dir); /* journal */ $r->get('/jrnx',"jrnx#index")->setRoot($ctrl_dir); @@ -106,14 +110,18 @@ $r->post('/transaction/updatePost',"transaction#updatePost")->setRoot($ctrl_dir) $r->get('/bilan',"bilan#index")->setRoot($ctrl_dir); $r->get('/bilan/index',"bilan#index")->setRoot($ctrl_dir); $r->get('/bilan/synthese',"bilan#synthese")->setRoot($ctrl_dir); +$r->get('/bilan/charges',"bilan#charges")->setRoot($ctrl_dir); /* Budget services*/ $r->get('/budget',"budget#index")->setRoot($ctrl_dir); $r->get('/budget/index',"budget#index")->setRoot($ctrl_dir); +$r->get('/budget/list',"budget#list")->setRoot($ctrl_dir); $r->get('/budget/detail/?:id',"budget#detail")->setRoot($ctrl_dir); $r->get('/budget/nouveau',"budget#nouveau")->setRoot($ctrl_dir); $r->get('/budget/update',"budget#update")->setRoot($ctrl_dir); +$r->get('/budget/updateEntry/?:id/?:acc',"budget#updateEntry")->setRoot($ctrl_dir); $r->post('/budget/updatePost',"budget#updatePost")->setRoot($ctrl_dir); +$r->post('/budget/updateEntryPost',"budget#updateEntryPost")->setRoot($ctrl_dir); /* Admin services*/ $r->get('/admin',"admin#index")->setRoot($ctrl_dir); diff --git a/app/compta/views/account_categorie.php b/app/compta/views/account_categorie.php new file mode 100644 index 0000000..6ff3558 --- /dev/null +++ b/app/compta/views/account_categorie.php @@ -0,0 +1,150 @@ + + + + + +Gestion comptable + + + + + + + + + +
+ +
+
+XML; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Detail extends \PageCompta + implements \IActionResult +{ + function __construct($model) + { + $this->_model = $model; + parent::__construct(XmlAccount,true); + } + + public function render() + { + $this->show(); + } + + /** + * @brief insert a script in the page to update menu link + * + */ + private function script() + { + $s=<<<_EOF + +_EOF; + echo $s; + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillTable()); + $f->appendChild($nel); + /* Update title from xml template */ + $title = $this->getElementById($xml,"title"); + $el = $xml->createTextNode("compte ".$this->_model->_id); + $title->appendChild($el); + // Update return link + $retour = $this->getElementById($xml,"btRetour"); + $retour->removeAttribute('link'); + $retour->setAttribute('link',"/app/compta/services.php/".\AEB::$REQUEST['b']); + // Ok Handle solde + $solde = $this->getElementById($xml,"accSoldeCompte"); + $el = $xml->createTextNode("compte ".$this->_model->_solde[2]); + $solde->appendChild($el); + } + + /** + * @brief Fill bilan table + */ + private function fillTable() + { + $template=<<<_EOF +%s%s +%s +%.2f +%.2f +_EOF; + $frag = ""; + $count = 0; + $lst = $this->_model->_mouvements; + foreach( $lst as $row) + { + $frag.=sprintf($template + ,++$count % 2?"odd":"even" ,$row[0],$row[1] ,$row[2] + ,$row[3] + ,$row[2] > $row[3] ? "red" : "black" + ,$row[4]); + } + return $frag; + } + +} + +?> diff --git a/app/compta/views/account_detail.php b/app/compta/views/account_detail.php index eea239b..e56945d 100644 --- a/app/compta/views/account_detail.php +++ b/app/compta/views/account_detail.php @@ -128,20 +128,22 @@ _EOF; $template=<<<_EOF %s%s %s -%.2f -%.2f +%s +%s _EOF; $frag = ""; $count = 0; $lst = $this->_model->_mouvements; foreach( $lst as $row) { + $debit = sprintf("%.2f",$row[3]); + $credit = sprintf("%.2f",$row[4]); $frag.=sprintf($template ,++$count % 2?"odd":"even" ,$row[0],$row[1] ,$row[2] - ,$row[3] + ,$row[3] == 0.0 ? "" : $debit ,$row[2] > $row[3] ? "red" : "black" - ,$row[4]); - } + ,$row[4] == 0.0? "" : $credit); + } return $frag; } diff --git a/app/compta/views/account_index.php b/app/compta/views/account_index.php new file mode 100644 index 0000000..ff6f755 --- /dev/null +++ b/app/compta/views/account_index.php @@ -0,0 +1,152 @@ + + + + + +Gestion comptable + + + + + + + + + +
+ +
+
+XML; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Index extends \PageCompta + implements \IActionResult +{ + function __construct($model) + { + $this->_model = $model; + parent::__construct(XmlAccount,true); + } + + public function render() + { + $this->show(); + } + + /** + * @brief insert a script in the page to update menu link + * + */ + private function script() + { + $s=<<<_EOF + +_EOF; + echo $s; + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillTable()); + $f->appendChild($nel); + /* Update title from xml template */ + //$title = $this->getElementById($xml,"title"); + //$el = $xml->createTextNode("compte ".$this->_model->_id); + //$title->appendChild($el); + // Update return link + $retour = $this->getElementById($xml,"btRetour"); + $retour->removeAttribute('link'); + $retour->setAttribute('link',"/app/compta/services.php/".\AEB::$REQUEST['b']); + } + + /** + * @brief Fill bilan table + */ + private function fillTable() + { + $template=<<<_EOF +%d%s + +_EOF; + $frag = ""; + $count = 0; + $lst = [1,2,3,4,5,6,7,8]; + $str = [ "-" + ,"DE CAPITAUX" + , "IMMOBILISATIONS" + , "D'IMMOBILISATIONS" + , "DE TIERS" + , "FINANCIERS" + , "DE CHARGES" + , "DE PROVISION" + , "SPECIAUX" + ]; + foreach( $lst as $row) + { + $frag.=sprintf($template + ,++$count % 2?"odd":"even" + ,$row + ,$row + ,$str[$row] + ); + } + return $frag; + } + +} + +?> + diff --git a/app/compta/views/admin_index.php b/app/compta/views/admin_index.php index e41cb45..586723d 100644 --- a/app/compta/views/admin_index.php +++ b/app/compta/views/admin_index.php @@ -7,26 +7,44 @@ require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_exercice.php"); require_once(dirname(__FILE__)."/../api_syndic.php"); -global $xmlAdminDocument; -$XmlAdminDocument = << -Gestion comptable +Administrate Gestion comptable + - -

Chargement ...

-
+ +

Aperçu de la configuration

+ + + + + + + + + + + + + +
ail compte
DescriptionValeur
+
@@ -42,10 +60,10 @@ class Index extends \PageCompta implements \IActionResult { - function __construct($b=true) + function __construct() { - global $xmlAdminDocument; - parent::__construct($XmlAdminDocument,$b); + parent::__construct(XmlAdminDocument,true); + //$this->_model = $model; } private function script() @@ -64,36 +82,65 @@ _EOF; { $this->show(); } - private function documents() + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillAccounting()); + // Append database config + $nel->appendXML($this->fillDatabase()); + + $f->appendChild($nel); + // Update return link + $retour = $this->getElementById($xml,"btRetour"); + $retour->removeAttribute('link'); + $retour->setAttribute('link',"/app/compta/services.php/".\AEB::$REQUEST['b']); + } + + private function fillAccounting() { + $frag = ""; + $template=<<<_EOF +%s%s +_EOF; $_cfg = $this->_auth_cfg; $syndic = new \Syndic( $this->getSession() , $_cfg , $this->getSession()->getDb()); $accounting = $syndic->baseType(); - echo ""; - echo ""; - echo ""; - echo ""; - echo ""; - $accounting = $syndic->baseVersion(); - echo ""; - $accounting = $syndic->baseCounter(); - echo ""; - echo "
DescriptionValeur
Type de compatbilite".$accounting."
Version".$accounting."
Compteur".$accounting."
"; - } + $fields = ["Type de compatibilite","Version","Compteur"]; + $fdata = [$accounting, $syndic->baseVersion(),$syndic->baseCounter()]; + for ($i = 0 ; $i < 3 ;$i++ ) + { + $frag.=sprintf($template,$fields[$i],$fdata[$i]); + } + return $frag; + } /** - * @brief Display The articles in flex mode - * Also revise menu + * @brief display Database settings */ - function main() { - $this->script(); - echo '
'; - echo "

Aperçu de la configuration

"; - $this->documents(); - echo '
'; + private function fillDatabase() + { + $frag =<<<_EOF +Base de Donne +_EOF; + $template=<<<_EOF +%s%s +_EOF; + $_cfg = $this->_auth_cfg; + + $frag.=sprintf($template,"Server",$_cfg[SQL_SERVER]); + $frag.=sprintf($template,"Base de donnee",$_cfg[SQL_DB]); + $frag.=sprintf($template,"Utilisateur",$_cfg[SQL_USER]); + return $frag; + } + } diff --git a/app/compta/views/bilan_charges.php b/app/compta/views/bilan_charges.php new file mode 100644 index 0000000..6173536 --- /dev/null +++ b/app/compta/views/bilan_charges.php @@ -0,0 +1,138 @@ + + + + + +Gestion comptable + + + + + + + + + + +

Bilan des charges

+ + + + + + + + + + + +
Bilan de L'exercice
CompteLibelleSolde
+
+
+ +
+
+XML; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Charges extends \PageCompta + implements \IActionResult +{ + + function __construct($model) + { + //$page = new PageBilan($XmlComptaBudget,true); + global $XmlComptaBudget; + parent::__construct($XmlComptaBudget,true); + $this->_model = $model; + } + + public function render() + { + $this->show(); + } + + /** + * @brief insert a script in the page to update menu link + * + */ + private function script() + { + $s=<<<_EOF + +_EOF; + echo $s; + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillTable()); + $f->appendChild($nel); + } + /** + * @brief Fill bilan table + */ + private function fillTable() + { + $template=<<<_EOF +%s + %s +%.2f +_EOF; +$frag = ""; + $lst = $this->_model->syntheseCharges(); + $count = 0; + foreach( $lst as $row) + { + $frag.=sprintf($template,++$count % 2?"odd":"even" + ,$row[0] + ,$row[0] + ,str_repeat("-",$row[3])." ".$row[1] + , "red" + ,$row[2]); + } + return $frag; + } + +} + diff --git a/app/compta/views/bilan_index.php b/app/compta/views/bilan_index.php index 5ca86ff..646ca67 100644 --- a/app/compta/views/bilan_index.php +++ b/app/compta/views/bilan_index.php @@ -25,6 +25,7 @@ $XmlComptaBudget = << + @@ -126,7 +127,8 @@ _EOF; private function fillTable() { $template=<<<_EOF -%s%s +%s + %s %.2f %.2f %.2f @@ -135,18 +137,21 @@ $frag = ""; $_cfg = $this->_auth_cfg; $pcmn = new \Pcmn( $this->getSession() , $_cfg - , $this->getSession()->getDb()); - $lst = $pcmn->getBilan( - $this->getSession()->getCurrentExercice() + , $this->getSession()->getDb()); + $lst = $pcmn->getBilan( + $this->getSession()->getCurrentExercice() ); - $count = 0; + $count = 0; foreach( $lst as $row) { - $frag.=sprintf($template,++$count % 2?"odd":"even",$row[0],$row[1] - ,$row[2] - ,$row[3] - ,$row[2] > $row[3] ? "red" : "black" - ,$row[4]); + $frag.=sprintf($template,++$count % 2?"odd":"even" + ,$row[0] + ,$row[0] + ,$row[1] + ,$row[2] + ,$row[3] + ,$row[2] > $row[3] ? "red" : "black" + ,$row[4]); } return $frag; } diff --git a/app/compta/views/budget_detail.php b/app/compta/views/budget_detail.php index de92529..e46bbff 100644 --- a/app/compta/views/budget_detail.php +++ b/app/compta/views/budget_detail.php @@ -3,8 +3,7 @@ namespace compta\views\budget; require_once(dirname(__FILE__)."/../pages.php"); require_once(dirname(__FILE__)."/../api_pcmn.php"); -global $XmlComptaBudget; -$XmlComptaBudget = << @@ -14,67 +13,29 @@ $XmlComptaBudget = << - - - - + + - - - - Nouveau - -
- - -
- - -
- - - - - - - - - - - - - - - - - - - -
AnnéeLibellé
- + + +

Détail des comptes pour le Budget

+ - + - - - - - + + + + + @@ -82,11 +43,12 @@ $XmlComptaBudget = << - +
CompteLibelléN-1N
CompteLibelléN-1N
Total:0.00.0
Total:0.0
-
-
+ +
+
@@ -103,13 +65,14 @@ $_default_file = "ledger_syndic.xml"; * documents available. All decomptes */ class Detail extends \PageCompta - implements \IActionResult + implements \IActionResult { + private $total = 0.0; - function __construct($b = true) + function __construct($model) { - global $XmlComptaBudget; - parent::__construct($XmlComptaBudget,$b); + $this->_model = $model; + parent::__construct(XmlComptaBudgetDetail,true); } public function render() @@ -117,6 +80,85 @@ class Detail extends \PageCompta $this->show(); } + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + // Update the title + $tbody = $xml->getElementsByTagName("tbody"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillBudgetEntries()); + $tbody->item(0)->appendChild($nel); + // Update total as well + $total = $this->getElementById($xml,"beTotalN"); + $el = $xml->createTextNode(" ".$this->total); + $total->appendChild($el); + // Update Menu + $this->updateMenu($xml); + } + + private function updateMenu(&$xml) + { + $str = ""; + $ids = Array('btBCharge','btBProduit','btBCapitaux'); + $labels = Array('Charges','Produit','Capitaux'); + $cat = Array(6,7,1); + $tplt =<<<_EOF + +_EOF; + $items =<<<_EOF + +_EOF; + $menu = $xml->getElementsByTagName("menu"); + $frag = $xml->createDocumentFragment(); + for( $i = 0 ; $i < 3 ; ++$i) + { + $str.=sprintf($tplt + ,$ids[$i] + ,$this->_model->current_budget_id + ,$cat[$i] + ,$labels[$i] + ); + } + $frag->appendXML($str); + $menu->item(0)->appendChild($frag); + } + + private function fillBudgetEntries() + { + $count = 0; + $total = 0.0; + $ret = ""; + $tplt =<<<_EOF + + %s + %s + %s + %s + %s + +_EOF; + $entries = $this->_model->getBudgetEntries($this->_model->current_budget_id,"6"); + foreach ($entries as $e) + { + $ret.=sprintf($tplt + ,++$count % 2?"odd":"even" + ,"" + ,$e[0] // Compte + ,$e[0] + ,$this->_model->current_budget_id // Libelle bu_id + ,$e[0] // Libelle account + ,$e[1] // Libelle message + ,$e[6] // N - 1 + ,$e[2] // N + ); + $total += $e[2]; + } + $this->total = $total; + return $ret; + } + } /** diff --git a/app/compta/views/budget_index.php b/app/compta/views/budget_index.php index e48a559..565cc87 100644 --- a/app/compta/views/budget_index.php +++ b/app/compta/views/budget_index.php @@ -19,7 +19,7 @@ $XmlComptaBudget = << - + diff --git a/app/compta/views/budget_list.php b/app/compta/views/budget_list.php new file mode 100644 index 0000000..171a8f1 --- /dev/null +++ b/app/compta/views/budget_list.php @@ -0,0 +1,119 @@ + + + + + +Gestion comptable + + + + + + + + + + + + + + + + + + + + + + + + +
AnnéeLibelléMontant
+ + + +
+
+
+ + +
+
+XML; + + +$_default_file = "ledger_syndic.xml"; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class BList extends \PageCompta + implements \IActionResult +{ + + function __construct($model) + { + parent::__construct(XmlComptaBudgetList,true); + $this->_model = $model; + } + + public function render() + { + $this->show(); + } + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + // Update the title + $tbody = $xml->getElementsByTagName("tbody"); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillBudgets()); + $tbody->item(0)->appendChild($nel); + } + + /** + * @brief complete the table with all available budgets + */ + private function fillBudgets() + { + $count=0; + $ret = ""; + $tplt =<<<_EOF + + %s%s + %s + +_EOF; + $budgets = $this->_model->getBudgets(); + foreach ($budgets as $budget) + { + $ret.=sprintf($tplt + ,++$count % 2?"odd":"even" + ,$budget[1] + ,$budget[0] + ,$budget[2] + ,$budget[3] + ); + } + return $ret; + } + +} + +/** + * Should I make the checks here ? I wonder + * if this is required + */ + +?> diff --git a/app/compta/views/budget_updateEntry.php b/app/compta/views/budget_updateEntry.php new file mode 100644 index 0000000..5d8f99f --- /dev/null +++ b/app/compta/views/budget_updateEntry.php @@ -0,0 +1,168 @@ + + + + + +Gestion comptable + + + + + + + + + + + +

Détail des comptes pour le Budget

+ + + Mettre à jour l'entrée du budget + +
+
+
+ + + + +
+ + + +
+ + + + + +
+
+
+ +
+
+ + +
+
+XML; + + +$_default_file = "ledger_syndic.xml"; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class UpdateEntry extends \PageCompta + implements \IActionResult +{ + private $total = 0.0; + + function __construct($model) + { + $this->_model = $model; + parent::__construct(XmlComptaBudgetUpdateEntry,true); + } + + public function render() + { + $this->show(); + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + // Update the title + // Update total as well + // Update Menu + //$this->updateMenu($xml); + $this->updateAspfor($xml,$this->_model); + } + + private function updateMenu(&$xml) + { + $str = ""; + $ids = Array('btBCharge','btBProduit','btBCapitaux'); + $labels = Array('Charges','Produit','Capitaux'); + $cat = Array(6,7,1); + $tplt =<<<_EOF + +_EOF; + $items =<<<_EOF + +_EOF; + $menu = $xml->getElementsByTagName("menu"); + $frag = $xml->createDocumentFragment(); + for( $i = 0 ; $i < 3 ; ++$i) + { + $str.=sprintf($tplt + ,$ids[$i] + ,$this->_model->current_budget_id + ,$cat[$i] + ,$labels[$i] + ); + } + $frag->appendXML($str); + $menu->item(0)->appendChild($frag); + } + + private function fillBudgetEntries() + { + $count = 0; + $total = 0.0; + $ret = ""; + $tplt =<<<_EOF + + %s + %s + %s + %s + %s + +_EOF; + $entries = $this->_model->getBudgetEntries($this->_model->current_budget_id,"6"); + foreach ($entries as $e) + { + $ret.=sprintf($tplt + ,++$count % 2?"odd":"even" + ,"" + ,$e[0] // Compte + ,$e[0] + ,$this->_model->current_budget_id // Libelle bu_id + ,$e[0] // Libelle account + ,$e[1] // Libelle message + ,$e[4] // N - 1 + ,$e[2] // N + ); + $total += $e[2]; + } + $this->total = $total; + return $ret; + } + +} + +/** + * Should I make the checks here ? I wonder + * if this is required + */ + +?> diff --git a/app/compta/views/recurrent_nouveau.php b/app/compta/views/recurrent_nouveau.php index 738f697..c3181ac 100644 --- a/app/compta/views/recurrent_nouveau.php +++ b/app/compta/views/recurrent_nouveau.php @@ -181,6 +181,7 @@ _EOF; $fe.=sprintf($tplt,"text",$count,$f,$e->{$f}); } $fe.=""; + error_log($fe."\n"); $frag.=$fe; $count++; } diff --git a/app/compta/views/supplier_account.php b/app/compta/views/supplier_account.php index 00bb97f..6fc7a1d 100644 --- a/app/compta/views/supplier_account.php +++ b/app/compta/views/supplier_account.php @@ -95,9 +95,11 @@ class Account extends \PageCompta $f = $tbody->item(0); $items =<<<_EOF + _EOF; $frag=sprintf($items + ,$this->_model->_id ,$this->_model->_id ,$this->_model->_id); $nel = $xml->createDocumentFragment(); diff --git a/app/compta/views/supplier_billpay.php b/app/compta/views/supplier_billpay.php index 0cf448f..6a15e02 100644 --- a/app/compta/views/supplier_billpay.php +++ b/app/compta/views/supplier_billpay.php @@ -31,10 +31,10 @@ const SupplierBill =<< Nouvelle Facture -
+
- +
@@ -52,8 +52,8 @@ const SupplierBill =<< - - + + @@ -95,7 +95,7 @@ class Billpay extends \PageCompta $nel->appendXML($this->fillKeys()); $tbody->appendChild($nel); // Ok Handle bank - $solde = $this->getElementById($xml,"suppl_bank"); + $solde = $this->getElementById($xml,"suppl_banque"); $nel = $xml->createDocumentFragment(); $nel->appendXML($this->fillBanque()); $solde->appendChild($nel); diff --git a/app/xsl b/app/xsl index b101666..84bbba5 160000 --- a/app/xsl +++ b/app/xsl @@ -1 +1 @@ -Subproject commit b1016666f5fd4264ce632b3e00126819a0f02084 +Subproject commit 84bbba5f0d444985b1b467a8677f370bc27e6927 diff --git a/css b/css index 83819fb..61a97d1 160000 --- a/css +++ b/css @@ -1 +1 @@ -Subproject commit 83819fb21391da8cfbfeba2fe8d16f654f554ffd +Subproject commit 61a97d1412591363baddfbbc591825765c79c4eb