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;
}
}
$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
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
--- /dev/null
+<?php
+
+namespace compta\models\admin;
+
+require_once(dirname(__FILE__)."/../api_syndic.php");
+require_once(dirname(__FILE__)."/../api_booking.php");
+require_once(dirname(__FILE__)."/../api_retrieve.php");
+require_once(dirname(__FILE__)."/../schema_mysql.php");
+
+/**
+ * @brief Data model for a transaction.
+ */
+class Model implements \JsonSerializable
+{
+ private $_session = null;
+ private $_auth_cfg = null;
+ private $_db_schema = null;
+
+ /**
+ * Constructor
+ */
+ function __construct($_sess,$_auth)
+ {
+ $this->_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 [ ];
+ }
+}
+?>
$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);
/* 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);
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()
$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
+<tr><td colspan="2"><link href="/app/compta/services.php/admin/update">Update Required</link></td></tr>
+_EOF;
+ }
return $frag;
}
--- /dev/null
+<?php
+
+namespace compta\views\admin;
+
+
+require_once(dirname(__FILE__)."/../pages.php");
+require_once(dirname(__FILE__)."/../api_exercice.php");
+require_once(dirname(__FILE__)."/../api_syndic.php");
+
+const XmlAdminUpdateDocument = <<<XML
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<?xslt-param name='alias' value='/andre/'?>
+<?xml-stylesheet type="text/xsl" href="xsl/gui.xsl?alias='/andre/'"?>
+<gui langue='fr' style="padding: 0;">
+<liens/>
+<title langue='fr'>Gestion comptable Mise a jour de la DB </title>
+<content>
+ <!--
+ <script data-main="/app/compta/coproBootstrap.js" src="/js/require.js"></script>
+ -->
+ <menu>
+ <item id="btRetour" link="/app/compta/services.php/admin" class="" title="Retour" />
+ </menu>
+<!-- Start Main Panel-->
+
+<!-- -->
+ <panel class="" style="padding:0px 60px 15px 15px;display:block;min-height:150px;" id="mydocuments">
+ <h3>Mettre à jour la base de donnée</h3>
+
+ <table id="tStatemens" min-height="400" width="100%" style="margin:15px 30px 15px 15px; " >
+ <caption>ail compte </caption>
+ <thead resp-width="100%">
+ <tr>
+ <th resp-width="60%">Description</th>
+ <th resp-width="50%">Valeur</th></tr>
+ </thead>
+ <tbody style="overflow:auto;">
+ </tbody>
+ </table>
+
+ </panel>
+<!-- End Main Panel -->
+ <script></script>
+ </content>
+</gui>
+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
+<script>
+(function() {
+ var mh1a = $('mh1').firstChild;
+ mh1a.href = "/fr/app/compta/services.php/";
+})();
+</script>
+_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
+<tr class="odd"><td colspan="2" >Base de Donne</td> </tr>
+_EOF;
+ $template=<<<_EOF
+<tr><td style="text-align: center;"><button style="float:none;" id="update" href="/app/compta/services.php/admin/updateRequest/%s">Update</button></td><td>%s</td></tr>
+_EOF;
+
+ foreach(iterator_to_array($this->_model->getStatementsToExecute()) as $_statement)
+ {
+ $frag.=sprintf($template
+ , $_statement->attributes->item(0)->value
+ , $_statement->nodeValue);
+ }
+ return $frag;
+
+ }
+
+}
+
+
+?>
*/
private function fournisseurs() {
$_content =<<<EOF
-Gérer vos fournisseurs, <br>
-les factures,<br>
-les règlements.<br>
+Gérer vos <a href="/app/compta/services.php/supplier">fournisseurs</a>,
+les <a href="/app/compta/sercices.php/tenant">locataires</a><br>
+les <a href="/app/compta/services.php/tax">impôts</a>,
+les <a href="/app/compta/sercices.php/income">revenus</a><br>
EOF;
$this->article(_("Fournisseurs"),"iu-fournisseur.jpg",$_content);
--- /dev/null
+<?php
+
+?>
</menu>
<panel id="pAccount" class="col-11 pg-account" style="min-height:150px;">
- <h2 id="title" style="width:100%">Mes fournisseurs</h2>
+ <h2 id="title" style="width:100%"></h2>
+ <table autoScroll='false' id="per_month" height="50" style="margin:0 10px auto;">
+ <caption>Summary</caption>
+<!--
+ <thead resp-width="100%" >
+ <tr style="">
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Jan</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Fév</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Mars</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Avril</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Mai</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Juin</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Juil</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Aout</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Sept</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Oct</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Nov</link></th>
+ <th resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Déc</link></th>
+ </tr>
+ </thead>
+-->
+ <tbody >
+ <tr style="">
+ <td resp-width='8.3%'></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Jan</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Fév</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Mars</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Avril</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Mai</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Juin</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Juil</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Aout</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Sept</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Oct</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Nov</link></td>
+ <td resp-width='8.3%'><link href="/app/compta/services.php/supplier/month">Déc</link></td>
+ </tr>
+ </tbody>
+ <tfoot>
+ </tfoot>
+ </table>
<panel style="margin-top:10px;min-height:15px;" resp-width="100%" >
<table autoScroll='true' id="supplier_table_account" height="200" style="margin:0 10px auto;">
<caption>Compte</caption>
{
$lSoldes = Array('supplierSoldeDebit','supplierSoldeCredit');
$tbody = $xml->getElementsByTagName('tbody');
- $f = $tbody->item(0);
+ $f = $tbody->item(1);
$nel = $xml->createDocumentFragment();
$nel->appendXML($this->fillTable());
$f->appendChild($nel);
$solde = $this->getElementById($xml,"supplierSoldeCompte");
$el = $xml->createTextNode(" ".$this->_model->_solde[2]);
$solde->appendChild($el);
+ // Title
+ $title = $this->getElementById($xml,"title");
+ if ($title != null)
+ {
+ $_acc =$this->_model->getAccount($this->_model->_id);
+
+ $el = $xml->createTextNode("Fournisseur ".$_acc['acc_desc']." (".$_acc['acc_id'].")");
+ $title->appendChild($el);
+ }
$count = 0;
foreach( $lSoldes as $s)
{
{
$template=<<<_EOF
-<tr class="%s"><td>%s</td><td>%s</td>
+<tr class="%s"><td>%s</td><td><link href="/app/compta/services.php/transaction/detail/%s">%s</link></td>
<td style="text-align:right">%s</td>
<td style="text-align:right">%.2f</td>
<td style="text-align:right;color:%s">%.2f</td></tr>
foreach( $lst as $row)
{
$frag.=sprintf($template
- ,++$count % 2?"odd":"even" ,$row[0],$row[1] ,$row[2]
+ ,++$count % 2?"odd":"even" ,$row[0],$row[5],$row[1] ,$row[2]
,$row[3]
,$row[2] > $row[3] ? "red" : "black"
,$row[4]);