From: www-data Date: Sun, 9 Jan 2022 21:27:42 +0000 (+0100) Subject: Add mvc supplier (pay|bill). Still missing apply and cancel feature. X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=7069605954bbb8cb98e663504677b6807b66dae6;p=www%2Fsyndic.git Add mvc supplier (pay|bill). Still missing apply and cancel feature. --- diff --git a/app/compta/api_pcmn.php b/app/compta/api_pcmn.php index b2950d9..b9385a4 100644 --- a/app/compta/api_pcmn.php +++ b/app/compta/api_pcmn.php @@ -77,15 +77,17 @@ __EOF; } /** - * + * return account details based on account number. + * acc_desc, and others to be defined */ - function getAccount() { - error_log("Pcmn::getAccount TODO needs to be coded"); - return array( - 'acc_id' => '401001', - 'acc_desc' => 'test', - 'acc_type' => 'Charge', - ); + function getAccount($_id) { + $q =<<<_EOF +SELECT acc_id, acc_name FROM Account WHERE acc_id ="{$_id}"; +_EOF; + $this->logTransaction("Pcmn getAccount ",$q); + $res = $this->doQueryI($q); + $ident = $res['records'][0]; + return array('acc_id' => $_id,'acc_desc' => $ident[1]); } /** * @brief only delete an account that's closed !! and that's not used diff --git a/app/compta/controlers/supplier.php b/app/compta/controlers/supplier.php index 73db5cf..4d8d681 100644 --- a/app/compta/controlers/supplier.php +++ b/app/compta/controlers/supplier.php @@ -45,8 +45,8 @@ class Supplier extends controler */ public function account($_account_id) { - require_once(controler::$viewdir."/supplier_accout.php"); - $this->_model->getDetails($_id); + require_once(controler::$viewdir."/supplier_account.php"); + $this->_model->getDetails($_account_id); $page = new \compta\views\supplier\Account($this->_model); return $page; } @@ -59,7 +59,7 @@ class Supplier extends controler return $page; } - public function pay() + public function pay($_id) { require_once(controler::$viewdir."/supplier_pay.php"); $this->_model->getDetails($_id); @@ -67,10 +67,11 @@ class Supplier extends controler return $page; } - public function bill() + public function bill($_id) { require_once(controler::$viewdir."/supplier_bill.php"); $this->_model->getDetails($_id); + $this->_model->getAccount($_id); $page = new \compta\views\supplier\Bill($this->_model); return $page; } diff --git a/app/compta/models/supplier.php b/app/compta/models/supplier.php index 6ff61a6..88221d2 100644 --- a/app/compta/models/supplier.php +++ b/app/compta/models/supplier.php @@ -5,6 +5,7 @@ namespace compta\models\supplier; 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_syndic.php"); require_once(dirname(__FILE__)."/../api_retrieve.php"); /** @@ -18,6 +19,7 @@ class Model implements \JsonSerializable public $_mouvements = Array(); public $_solde = 0.0; public $_id = -1; // current entry. -1 no entry selected + public $_account = Array(); /** * Constructor */ @@ -31,6 +33,7 @@ class Model implements \JsonSerializable { return $this->_session; } + public function getDetails($_id) { $_cfg = $this->_auth_cfg; @@ -46,15 +49,57 @@ class Model implements \JsonSerializable $this->_solde = $r['solde']; } + /** + * Adapter method + */ public function getSuppliers() { $_cfg = $this->_auth_cfg; $pcmn = new \Pcmn( $this->getSession() , $_cfg - , $this->getSession()->getDb()); - return $pcmn->getFournisseur(""); + , $this->getSession()->getDb()); + return $pcmn->getFournisseur(""); + } + + /** + * Adapter method + */ + public function getAccount($_id) + { + $_cfg = $this->_auth_cfg; + $pcmn = new \Pcmn( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $this->_account= $pcmn->getAccount($_id); + return $this->_account; } + + /** + * Adapter method + */ + public function getChargeAccounts() + { + $_cfg = $this->_auth_cfg; + $pcmn = new \Pcmn( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + return $pcmn->getAccountList("6"); + } + + + /** + * Adapter method + */ + public function getKeysCharge() + { + $_cfg = $this->_auth_cfg; + $pcmn = new \Syndic( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + return $pcmn->getKeysCharge(); + + } /** * Required by JsonSerializable */ diff --git a/app/compta/services.php b/app/compta/services.php index 1fee6d3..59e126a 100644 --- a/app/compta/services.php +++ b/app/compta/services.php @@ -52,7 +52,10 @@ $r->get('/account/detail/?:id',"account#detail")->setRoot($ctrl_dir); /* Supplier services*/ $r->get('/supplier',"supplier#index")->setRoot($ctrl_dir); -$r->get('/supplier/detail/?:id',"supplier#detail")->setRoot($ctrl_dir); +$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); /* exercice */ $r->get('/exercice',"exercice#index")->setRoot($ctrl_dir); diff --git a/app/compta/views/supplier_account.php b/app/compta/views/supplier_account.php new file mode 100644 index 0000000..00bb97f --- /dev/null +++ b/app/compta/views/supplier_account.php @@ -0,0 +1,138 @@ + + + + + +Gestion comptable + + + + + + + + + +
+ +
+
+XML; +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Account extends \PageCompta + implements \IActionResult +{ + function __construct($model) + { + $this->_model = $model; + parent::__construct(SupplierAccount,true); + } + + public function render() + { + $this->show(); + } + + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $lSoldes = Array('supplierSoldeDebit','supplierSoldeCredit'); + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($this->fillTable()); + $f->appendChild($nel); + // Ok Handle soldes + $solde = $this->getElementById($xml,"supplierSoldeCompte"); + $el = $xml->createTextNode(" ".$this->_model->_solde[2]); + $solde->appendChild($el); + $count = 0; + foreach( $lSoldes as $s) + { + $solde = $this->getElementById($xml,$s); + $el = $xml->createTextNode(" ".$this->_model->_solde[$count++]); + $solde->appendChild($el); + } + /* Update menu */ + $tbody = $xml->getElementsByTagName('menu'); + $f = $tbody->item(0); + $items =<<<_EOF + + +_EOF; + $frag=sprintf($items + ,$this->_model->_id + ,$this->_model->_id); + $nel = $xml->createDocumentFragment(); + $nel->appendXML($frag); + $f->appendChild($nel); + } + + /** + * @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/supplier_bill.php b/app/compta/views/supplier_bill.php new file mode 100644 index 0000000..48db472 --- /dev/null +++ b/app/compta/views/supplier_bill.php @@ -0,0 +1,169 @@ + + + + + +Gestion comptable + + + + + + + + +
+ +
+
+XML; + +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Bill 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 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); + } + + /** + * @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 fillCharge() + { + + $template=<<<_EOF + +_EOF; + $frag = ""; + $count = 0; + $lst = $this->_model->getChargeAccounts(); + foreach( $lst as $row) + { + $frag.=sprintf($template + ,$row['acc_id'] + ,$row['acc_desc'] + ,$row['acc_id']); + } + return $frag; + + } + + + +} + + + +?> diff --git a/app/compta/views/supplier_index.php b/app/compta/views/supplier_index.php index aa815c7..c57e83b 100644 --- a/app/compta/views/supplier_index.php +++ b/app/compta/views/supplier_index.php @@ -21,7 +21,7 @@ const SupplierIndex =<< -