From: www-data Date: Mon, 6 Nov 2023 22:20:42 +0000 (+0100) Subject: Improved Update DB, supplier account, owner mvc X-Git-Url: https://git.ebersold.fr/?a=commitdiff_plain;h=edbbad43f1b17921b4be34cc0c74bfbed893b796;p=www%2Fsyndic.git Improved Update DB, supplier account, owner mvc --- diff --git a/app/compta/controlers/admin.php b/app/compta/controlers/admin.php index 07ac578..504b05a 100644 --- a/app/compta/controlers/admin.php +++ b/app/compta/controlers/admin.php @@ -15,28 +15,55 @@ 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."/admin.php"); + + /** * * */ -class Admin +class Admin extends controler { + private $_model; /** * Constructor */ public function __construct() { + parent::__construct(); + $this->_model = new \compta\models\admin\Model( + $this->getSession(),$this->getAuthConfig()); } /** - * Get the details of the supplier account. - * @param string $_accout_id the supplier account + * Get the details of the accounting system. */ public function index() : \IActionResult { require_once(controler::$basedir."/views/admin_index.php"); - $page = new \compta\views\admin\Index(); + $page = new \compta\views\admin\Index($this->_model); + return $page; + } + + /** + * Display the Update database view + * @param string $_accout_id the supplier account + */ + public function update() : \IActionResult + { + require_once(controler::$basedir."/views/admin_update.php"); + $page = new \compta\views\admin\Update($this->_model); + return $page; + } + /** + * Display the Update database view + * @param string $_accout_id the supplier account + */ + public function updateRequest($_entry) : \IActionResult + { + require_once(controler::$basedir."/views/admin_update.php"); + $page = new \compta\views\admin\Update($this->_model); return $page; } } diff --git a/app/compta/controlers/owner.php b/app/compta/controlers/owner.php index e3bd348..44da737 100644 --- a/app/compta/controlers/owner.php +++ b/app/compta/controlers/owner.php @@ -38,7 +38,9 @@ class Owner extends controler $this->getSession(),$this->getAuthConfig()); } /** - * Get the details of the supplier account. + * Display the list of owners, there financial situation + * If logged in user is not the syndic, the simply display + * the owner information not more * @param string $_accout_id the supplier account */ public function index() : \IActionResult @@ -48,7 +50,28 @@ class Owner extends controler return $page; } /** - * Get the details of the supplier account. + * Get the details of the owner (address account association etc... ) + * @param string $_accout_id the supplier account + */ + public function detail() : \IActionResult + { + require_once(controler::$basedir."/views/owner_index.php"); + $page = new \compta\views\Owner\Index(); + return $page; + } + /** + * Détail du compte de copropriétaire + * @param string $_owner_id + */ + public function compte($_ownerid) : \IActionResult + { + require_once(controler::$basedir."/views/owner_index.php"); + $page = new \compta\views\Owner\Index(); + return $page; + } + + /** + * Return the list of all available reports * @param string $_accout_id the supplier account */ public function decomptes() : \IActionResult diff --git a/app/compta/models/admin.php b/app/compta/models/admin.php new file mode 100644 index 0000000..d918f76 --- /dev/null +++ b/app/compta/models/admin.php @@ -0,0 +1,85 @@ +_session = $_sess; + $this->_auth_cfg = $_auth; + $this->loadDbSchema(); + } + + private function getSession() + { + return $this->_session; + } + + private function loadDbSchema() + { + GLOBAL $Xml_Compta_Schema; + $this->_db_schema = new \DomDocument(); + $this->_db_schema->loadXML($Xml_Compta_Schema); + } + + private function getStatement($_id) + { + $xpath = new \DOMXPath($this->_db_schema); + return $xpath->query("//statement[@count='$id' and mode='update']")->item(0); + } + + private function getStatementCount() + { + $xpath = new \DOMXPath($this->_db_schema); + return $xpath->query("/sql/statement[last() ]/@count")->item(0)->value; + } + + /** + * Compare the index in schema and the one in the + * data base. If the Schema index is higher than + * the one in the database, return true. Otherwise + * return false + */ + public function isDbUpdateRequired() + { + $_cfg = $this->_auth_cfg; + $syndic = new \Syndic( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + return $syndic->baseCounter() < $this->getStatementCount() ; + } + + public function getStatementsToExecute() + { + $_cfg = $this->_auth_cfg; + $syndic = new \Syndic( $this->getSession() + , $_cfg + , $this->getSession()->getDb()); + $xpath = new \DOMXPath($this->_db_schema); + return $xpath->query("/sql/statement[@count>".$syndic->baseCounter()." and @mode='update']"); + } + /** + * Required by JsonSerializable + */ + public function jsonSerialize() + { + return [ ]; + } +} +?> diff --git a/app/compta/services.php b/app/compta/services.php index 66a2dbb..55af739 100644 --- a/app/compta/services.php +++ b/app/compta/services.php @@ -62,6 +62,13 @@ $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); +/* Tax services*/ +$r->get('/tax',"tax#index")->setRoot($ctrl_dir); +/* Tenant services*/ +$r->get('/tenant',"tenant#index")->setRoot($ctrl_dir); +/* Income services*/ +$r->get('/income',"income#index")->setRoot($ctrl_dir); + /* exercice */ $r->get('/exercice',"exercice#index")->setRoot($ctrl_dir); $r->get('/exercice/',"exercice#index")->setRoot($ctrl_dir); @@ -130,6 +137,8 @@ $r->post('/budget/updateEntryPost',"budget#updateEntryPost")->setRoot($ctrl_dir) /* Admin services*/ $r->get('/admin',"admin#index")->setRoot($ctrl_dir); $r->get('/admin/index',"admin#index")->setRoot($ctrl_dir); +$r->get('/admin/update',"admin#update")->setRoot($ctrl_dir); +$r->get('/admin/updateRequest/?:id',"admin#updateRequest")->setRoot($ctrl_dir); /* Onwer services*/ $r->get('/owner',"owner#index")->setRoot($ctrl_dir); diff --git a/app/compta/views/admin_index.php b/app/compta/views/admin_index.php index 586723d..d11a44c 100644 --- a/app/compta/views/admin_index.php +++ b/app/compta/views/admin_index.php @@ -59,11 +59,12 @@ XML; class Index extends \PageCompta implements \IActionResult { + private $_model; - function __construct() + function __construct($model) { parent::__construct(XmlAdminDocument,true); - //$this->_model = $model; + $this->_model = $model; } private function script() @@ -136,7 +137,13 @@ _EOF; $frag.=sprintf($template,"Server",$_cfg[SQL_SERVER]); $frag.=sprintf($template,"Base de donnee",$_cfg[SQL_DB]); - $frag.=sprintf($template,"Utilisateur",$_cfg[SQL_USER]); + $frag.=sprintf($template,"Utilisateur",$_cfg[SQL_USER]); + if ($this->_model->isDbUpdateRequired()) + { + $frag.=<<<_EOF +Update Required +_EOF; + } return $frag; } diff --git a/app/compta/views/admin_update.php b/app/compta/views/admin_update.php new file mode 100644 index 0000000..e0d4909 --- /dev/null +++ b/app/compta/views/admin_update.php @@ -0,0 +1,122 @@ + + + + + +Gestion comptable Mise a jour de la DB + + + + + + + + + +

Mettre à jour la base de donnée

+ + + + + + + + + + +
ail compte
DescriptionValeur
+ +
+ + +
+
+XML; + + +/** + * @brief Update GUI with the list of + * documents available. All decomptes + */ +class Update extends \PageCompta + implements \IActionResult +{ + private $_model; + + function __construct($model) + { + parent::__construct(XmlAdminUpdateDocument,true); + $this->_model = $model; + } + + private function script() + { + $s=<<<_EOF + +_EOF; + echo $s; + } + public function render() + { + $this->show(); + } + /** + * @brief allow sub classes to modify xml file + */ + protected function _updateXML(&$xml) + { + $tbody = $xml->getElementsByTagName('tbody'); + $f = $tbody->item(0); + $nel = $xml->createDocumentFragment(); + // 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']); + } + /** + * @brief display Database settings + */ + private function fillDatabase() + { + $frag =<<<_EOF +Base de Donne +_EOF; + $template=<<<_EOF +%s +_EOF; + + foreach(iterator_to_array($this->_model->getStatementsToExecute()) as $_statement) + { + $frag.=sprintf($template + , $_statement->attributes->item(0)->value + , $_statement->nodeValue); + } + return $frag; + + } + +} + + +?> diff --git a/app/compta/views/compta_index.php b/app/compta/views/compta_index.php index 742577f..bc9dc05 100644 --- a/app/compta/views/compta_index.php +++ b/app/compta/views/compta_index.php @@ -99,9 +99,10 @@ EOF; */ private function fournisseurs() { $_content =<< -les factures,
-les règlements.
+Gérer vos fournisseurs, +les locataires
+les impôts, +les revenus
EOF; $this->article(_("Fournisseurs"),"iu-fournisseur.jpg",$_content); diff --git a/app/compta/views/owner_index.php b/app/compta/views/owner_index.php new file mode 100644 index 0000000..62a2de0 --- /dev/null +++ b/app/compta/views/owner_index.php @@ -0,0 +1,3 @@ + diff --git a/app/compta/views/supplier_account.php b/app/compta/views/supplier_account.php index 6fc7a1d..0eebca8 100644 --- a/app/compta/views/supplier_account.php +++ b/app/compta/views/supplier_account.php @@ -22,8 +22,48 @@ const SupplierAccount =<<