function getFournisseur($opt)
{
+ $period = $this->getCurrentExercice();
$q1=<<<_EOF
SELECT res.Compte,res.Description,res.Debit, res.Credit, res.Debit - res.Credit as Solde
FROM (SELECT a.acc_id as Compte ,a.acc_name as Description
, ROUND (SUM(CASE WHEN te.debit_credit = 'd' THEN te.amount ELSE 0.0 END),2) As Debit
, ROUND(SUM(CASE WHEN te.debit_credit = 'c' THEN te.amount ELSE 0.0 END),2) As Credit
- FROM Account as a JOIN Period as p on p.per_string = "2021"
+ FROM Account as a JOIN Period as p on p.per_string = "{$period}"
LEFT JOIN Transactions as t on t.act_trans_date BETWEEN p.per_begin and p.per_end
LEFT JOIN TransactionEntry as te ON te.trans_id = t.trans_id AND te.acc_id = a.acc_id
WHERE a.acc_id like "401%" or a.acc_id like "460%" and te.entry_type != 'AN'
--- /dev/null
+<?php
+
+/* vim: set expandtab sw=4 ts=4 sts=4 list: */
+/**
+ * This file contains the controler class for Lot Owners.
+ * it's main goal is to implement the actions based on requests
+ * Current actions for the Owners are:
+ * my_documents (returns the details of the bank account)
+ * index (default presentation)
+ * list (default presentation)
+ * details (default presentation)
+ * postUpdate (default presentation)
+ * @author Andre Ebersold <andre.ebersold@free.fr>
+ * @version 1.0
+ * @package Compta
+ */
+
+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."/owner.php");
+
+/**
+ *
+ *
+ */
+class Owner extends controler
+{
+
+ /**
+ * Constructor
+ */
+ public function __construct()
+ {
+ parent::__construct();
+ $this->_model = new \compta\models\owner\Model(
+ $this->getSession(),$this->getAuthConfig());
+ }
+ /**
+ * Get the details of the supplier account.
+ * @param string $_accout_id the supplier account
+ */
+ public function index() : \IActionResult
+ {
+ require_once(controler::$basedir."/views/owner_index.php");
+ $page = new \compta\views\Owner\Index();
+ return $page;
+ }
+ /**
+ * Get the details of the supplier account.
+ * @param string $_accout_id the supplier account
+ */
+ public function decomptes() : \IActionResult
+ {
+ require_once(controler::$basedir."/views/owner_decomptes.php");
+ $page = new \compta\views\Owner\Decomptes();
+ return $page;
+ }
+}
+
+?>
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."/supplier.php");
-class Supplier
+class Supplier extends controler
{
/**
*/
public function __construct()
{
+ parent::__construct();
+ $this->_model = new \compta\models\supplier\Model(
+ $this->getSession(),$this->getAuthConfig());
+ }
+
+ /**
+ * Get the details of the supplier account.
+ */
+ public function index() : \IActionResult
+ {
+ require_once(controler::$viewdir."/supplier_index.php");
+ $page = new \compta\views\supplier\Index($this->_model);
+ return $page;
}
/**
* Get the details of the supplier account.
*/
public function account($_account_id)
{
+ require_once(controler::$viewdir."/supplier_accout.php");
+ $this->_model->getDetails($_id);
+ $page = new \compta\views\supplier\Account($this->_model);
+ return $page;
}
- public function details()
+ public function details($_supplier_id)
{
+ require_once(controler::$viewdir."/supplier_details.php");
+ $this->_model->getDetails($_id);
+ $page = new \compta\views\supplier\Details($this->_model);
+ return $page;
}
public function pay()
{
+ require_once(controler::$viewdir."/supplier_pay.php");
+ $this->_model->getDetails($_id);
+ $page = new \compta\views\supplier\Pay($this->_model);
+ return $page;
}
public function bill()
{
+ require_once(controler::$viewdir."/supplier_bill.php");
+ $this->_model->getDetails($_id);
+ $page = new \compta\views\supplier\Bill($this->_model);
+ return $page;
}
}
--- /dev/null
+<?php
+
+namespace compta\models\owner;
+
+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_retrieve.php");
+require_once(dirname(__FILE__)."/../../../phplib/class.ofx.php");
+
+/**
+ * @brief Data model for owner. Must provide all information
+ * related to the owner.
+ * The decomptes de charges
+ * It's personal information address phone number etc.
+ * If it's lot is rented
+ * Who is his renter. In case he has a renter, the charges for the renter
+ *
+ *
+ */
+class Model implements \JsonSerializable
+{
+ private $_session = null;
+ private $_auth_cfg = null;
+
+ /**
+ * Constructor
+ */
+ function __construct($_sess,$_auth)
+ {
+ $this->_session = $_sess;
+ $this->_auth_cfg = $_auth;
+ }
+
+ private function getSession()
+ {
+ return $this->_session;
+ }
+
+}
+?>
--- /dev/null
+<?php
+
+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_retrieve.php");
+
+/**
+ * @brief Data model for a transaction.
+ */
+class Model implements \JsonSerializable
+{
+ private $_session = null;
+ private $_auth_cfg = null;
+
+ public $_mouvements = Array();
+ public $_solde = 0.0;
+ public $_id = -1; // current entry. -1 no entry selected
+ /**
+ * Constructor
+ */
+ function __construct($_sess,$_auth)
+ {
+ $this->_session = $_sess;
+ $this->_auth_cfg = $_auth;
+ }
+
+ private function getSession()
+ {
+ return $this->_session;
+ }
+ public function getDetails($_id)
+ {
+ $_cfg = $this->_auth_cfg;
+ $pcmn = new \Retrieve( $this->getSession()
+ , $_cfg
+ , $this->getSession()->getDb());
+ $r = $pcmn->getEntriesByAccount(
+ $this->getSession()->getCurrentExercice()
+ , $_id
+ , ""); // Get Banks accounts
+ $this->_id = $_id;
+ $this->_mouvements = $r['entries'];
+ $this->_solde = $r['solde'];
+ }
+
+ public function getSuppliers()
+ {
+ $_cfg = $this->_auth_cfg;
+ $pcmn = new \Pcmn( $this->getSession()
+ , $_cfg
+ , $this->getSession()->getDb());
+ return $pcmn->getFournisseur("");
+ }
+
+ /**
+ * Required by JsonSerializable
+ */
+ public function jsonSerialize()
+ {
+ return [
+ 'account' => $this->_summary
+ , 'entries' => $this->_mouvements];
+ }
+
+}
+?>
$r->get('/account',"account#index")->setRoot($ctrl_dir);
$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);
+
/* exercice */
$r->get('/exercice',"exercice#index")->setRoot($ctrl_dir);
$r->get('/exercice/',"exercice#index")->setRoot($ctrl_dir);
$r->get('/admin',"admin#index")->setRoot($ctrl_dir);
$r->get('/admin/index',"admin#index")->setRoot($ctrl_dir);
+/* Onwer services*/
+$r->get('/owner',"owner#index")->setRoot($ctrl_dir);
+$r->get('/owner/decomptes',"owner#decomptes")->setRoot($ctrl_dir);
+
/**
* Run router
*/
--- /dev/null
+<?php
+namespace compta\views\owner;
+require_once(dirname(__FILE__)."/../pages.php");
+require_once(dirname(__FILE__)."/../api_exercice.php");
+require_once(dirname(__FILE__)."/../api_syndic.php");
+require_once(dirname(__FILE__)."/../api_retrieve.php");
+
+global $xmlComptaDocuments;
+$xmlComptaDocuments = <<<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</title>
+<content>
+ <script>
+/* */
+ </script>
+ <script data-main="/app/compta/coproBootstrap.js" src="/js/require.js"></script>
+
+
+<menu>
+ <item id="btRetour" link="page_ledger.php" class="" title="Retour" />
+</menu>
+<!-- Start Main Panel-->
+
+<!-- -->
+ <panel class="" style="padding:0px 0px 0px 0px;display:block;min-height:150px;" id="mydocuments">
+ <h3>Chargement ...</h3>
+ </panel>
+
+<!-- End Main Panel -->
+ <script>
+ </script>
+ </content>
+</gui>
+XML;
+
+
+/**
+ * @brief Update GUI with the list of
+ * documents available. All decomptes
+ */
+class Decomptes extends \PageCompta
+ implements \IActionResult
+{
+
+ function __construct()
+ {
+ global $xmlComptaDocuments;
+ parent::__construct($xmlComptaDocuments,true);
+ GLOBAL $conf;
+ $this->conf_auth = $conf['auth']['mysql'];
+ $this->_retrieve = new \Retrieve( $this->session
+ , $this->conf_auth
+ , $this->session->getDb());
+ }
+ /**
+ * @implement IActionResult render method
+ */
+ public function render()
+ {
+ $this->show();
+ }
+
+ private function decompte($period,$cpt)
+ {
+ $_scheme = $this->request->getScheme();
+ $root = $_scheme."".$this->request->getServerHost()."/".$this->alias."/app/compta/reports/syndic_builder_decompte.php?period=";
+ echo '<li><a href="'.$root.$period.'&compte='.$cpt.'">Décompte de charge '.$period.'</a></li>';
+ }
+ private function documents()
+ {
+ $_cfg = $this->_auth_cfg;
+ $ex = new \Exercice( $this->getSession()
+ , $_cfg
+ , $this->getSession()->getDb());
+ $syndic = new \Syndic( $this->getSession()
+ , $_cfg
+ , $this->getSession()->getDb());
+ $retrieve = $this->_retrieve;
+ $res = $retrieve->getSoldeCharge();
+ $compte = $retrieve->getAccount($this->session->id());
+ $acc = $syndic->getCoproprietaires(0);
+ $p = $ex->getClosed(false);
+ echo "<ul>";
+ foreach ($p as $doc)
+ {
+ $this->decompte($doc[3],$compte[0]);
+ }
+ echo "</ul>";
+ }
+
+ /**
+ * @brief Display The articles in flex mode
+ * Also revise menu
+ */
+ function main() {
+ echo '<div class="content" style="display:flex;flex-wrap:wrap">';
+ echo "<h3 class='h3'>Vos décomptes de charges</h3>";
+ $this->documents();
+ echo '</div>';
+ }
+}
+
+
+
+?>
--- /dev/null
+<?php
+
+namespace compta\views\supplier;
+
+require_once(dirname(__FILE__)."/../pages.php");
+
+const SupplierIndex =<<<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</title>
+<content>
+ <script>
+ </script>
+ <script>
+ </script>
+
+<menu>
+ <item id="btRetour" link="/app/compta/services.php/" class="" title="Retour" />
+</menu>
+
+ <panel id="pAccount" class="col-12 pg-account" style="min-height:150px;">
+ <h2 id="title" style="width:100%">Mes fournisseurs</h2>
+ <div id="supplier-list" style="width:98%;" class="panel dcol-container">
+ <div id="supplier-list-c1" class="panel dcol">
+ </div>
+ <div id="supplier-list-c2" class="panel dcol">
+ </div>
+ </div>
+
+ </panel>
+ <div class="clearfix"></div>
+ <!-- Script Section -->
+ </content>
+</gui>
+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(SupplierIndex,true);
+ }
+
+ public function render()
+ {
+ $this->show();
+ }
+
+ /**
+ * @brief insert a script in the page to update menu link
+ *
+ */
+ private function script()
+ {
+ $s=<<<_EOF
+<script>
+(function() {
+ var mh1a = $('mh1').firstChild;
+ mh1a.href = "page_ledger.php";
+})();
+(function() {
+ var h, a, f;
+ a = document.getElementsByTagName('link');
+ for (h = 0; h < a.length; h++) {
+ f = a[h];
+ if (f.rel.toLowerCase().match(/stylesheet/) && f.href) {
+ var g = f.href.replace(/(&|\?)rnd=\d+/, '');
+ f.href = g + (g.match(/\?/) ? '&' : '?');
+ f.href += 'rnd=' + (new Date().valueOf());
+ }
+ } // for
+})()
+
+</script>
+_EOF;
+ echo $s;
+ }
+
+ /**
+ * @brief allow sub classes to modify xml file
+ */
+ protected function _updateXML(&$xml)
+ {
+ $c1 = "";
+ $c2 = "";
+ $lc1 = $this->getElementById($xml,"supplier-list-c1");
+ $lc2 = $this->getElementById($xml,"supplier-list-c2");
+ $frag1 = $xml->createDocumentFragment();
+ $frag2 = $xml->createDocumentFragment();
+ $this->fillTable($c1,$c2);
+ $frag1->appendXML($c1);
+ $frag2->appendXML($c2);
+ $lc1->appendChild($frag1);
+ $lc2->appendChild($frag2);
+ }
+
+ /**
+ * @brief Fill bilan table
+ */
+ private function fillTable(&$c1,&$c2)
+ {
+ $template=<<<_EOF
+<span class="user-card" >
+<p>
+<link href="/app/compta/services.php/supplier/details/%s">%s %s</link>
+<span style="float: right; padding-right: 10x;">
+Solde <b>%.2f</b>
+</span>
+</p>
+<hr/>
+</span>
+_EOF;
+ $frag = "";
+ $count = 0;
+ $lst = $this->_model->getSuppliers();
+ foreach( $lst as $row)
+ {
+ if (++$count % 2)
+ {
+ $c1.=sprintf($template
+ ,$row['acc_id'] ,$row['acc_id']
+ ,$row['acc_desc']
+ ,$row['solde']);
+ } else
+ {
+ $c2.=sprintf($template
+ ,$row['acc_id'] ,$row['acc_id']
+ ,$row['acc_desc']
+ ,$row['solde']);
+ }
+ }
+ return $frag;
+ }
+
+}
+
+
+?>