}
/**
- *
+ * 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
*/
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;
}
return $page;
}
- public function pay()
+ public function pay($_id)
{
require_once(controler::$viewdir."/supplier_pay.php");
$this->_model->getDetails($_id);
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;
}
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");
/**
public $_mouvements = Array();
public $_solde = 0.0;
public $_id = -1; // current entry. -1 no entry selected
+ public $_account = Array();
/**
* Constructor
*/
{
return $this->_session;
}
+
public function getDetails($_id)
{
$_cfg = $this->_auth_cfg;
$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
*/
/* 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);
--- /dev/null
+<?php
+
+namespace compta\views\supplier;
+
+require_once(dirname(__FILE__)."/../pages.php");
+
+const SupplierAccount =<<<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/supplier" class="" title="Retour" />
+</menu>
+
+ <panel id="pAccount" class="col-11 pg-account" style="min-height:150px;">
+ <h2 id="title" style="width:100%">Mes fournisseurs</h2>
+
+ <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>
+ <thead resp-width="100%" >
+ <tr style="">
+ <th resp-width='10%'>Date</th>
+ <th resp-width="30%">Réf</th>
+ <th resp-width="30%" >Désignation</th>
+ <th resp-width="15%">Débit</th>
+ <th resp-width="15%">Crédit</th></tr>
+ </thead>
+ <tbody style="overflow:auto;">
+ </tbody>
+ <tfoot>
+ <tr><td id="supplierSoldeCompte" colspan="3">Solde:</td><td style="text-align:right;" id="supplierSoldeDebit"></td><td style="text-align:right;" id="supplierSoldeCredit"></td></tr>
+ </tfoot>
+ </table>
+</panel>
+
+
+ </panel>
+ <div class="clearfix"></div>
+ <!-- Script Section -->
+ </content>
+</gui>
+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
+ <item id="btFacture" link="/app/compta/services.php/supplier/bill/%s" fa-icon="fa-file-invoice" title="Facture" />
+ <item id="btPayer" link="/app/compta/services.php/supplier/pay/%s" fa-icon="fa-coins" title="Payer" />
+_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
+<tr class="%s"><td>%s</td><td>%s</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>
+_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;
+
+ }
+
+}
+
+
+?>
--- /dev/null
+<?php
+
+namespace compta\views\supplier;
+
+require_once(dirname(__FILE__)."/../pages.php");
+
+const SupplierBill =<<<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>
+ (function() {
+ console.log("Try to update mh1a");
+ var mh1a = $('mh1').firstChild;
+ mh1a.href = "/fr/app/compta/services.php/supplier";
+ })();
+ </script>
+ <script>
+ </script>
+
+<menu>
+</menu>
+
+ <panel id="pAccount" class="col-11 pg-account" style="min-height:150px;">
+ <h2 id="title" style="width:100%">Nouvelle facture fournisseur</h2>
+
+ <group id="group">
+<grouptitle>Nouvelle Facture</grouptitle>
+<groupcontent>
+ <FieldSet labelWidth="95" style="border:none 0px;">
+ <TextField width="253" id="suppl_desc" style=""><Label style="">Intitule</Label></TextField><br/>
+ <ComboBox width="259" id="suppl_id" style="margin-right:10px;"><Label>Fournisseur</Label>
+ </ComboBox>
+ <TextField width="190" id="suppl_date" style=""><Label style=""> Date Saisie</Label></TextField><br/>
+ <ComboBox width="259" id="suppl_charge" style="margin-right:10px;"><Label>Charge</Label>
+ </ComboBox>
+ <TextField width="190" id="suppl_voucher_date" style=""><Label style=""> Date Facture</Label></TextField><br/>
+ <TextField width="253" id="suppl_voucher_ref" style="margin-right:9px;"><Label style="">Référence</Label></TextField>
+ <TextField width="190" id="suppl_amount" style=""><Label style=""> Montant</Label></TextField><br/>
+ <TextField width="253" id="suppl_voucher_file" type="file" style="margin-right:10px;"><Label style="">Fichier</Label></TextField>
+ <ComboBox width="199" id="suppl_charge_key" style=""><Label>Clé Charge</Label>
+ </ComboBox>
+ </FieldSet>
+ <panel resp-width="98%" style="min-height:14px;">
+ <!--
+ -->
+ <button id='btFFRecord' href="#" style="float:left;">Enregistrer</button>
+ <button id='btFFCancel' style="float:left;" href="#">Annuler</button>
+ </panel>
+</groupcontent>
+</group>
+
+
+ </panel>
+ <div class="clearfix"></div>
+ <!-- Script Section -->
+ </content>
+</gui>
+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
+<Entry key="{$this->_model->_id} {$this->_model->_account['acc_desc']}" value="{$this->_model->_id}"></Entry>
+_EOF;
+ $nel->appendXML($frag);
+ $tbody->appendChild($nel);
+ /* Update menu */
+ $tbody = $xml->getElementsByTagName('menu');
+ $f = $tbody->item(0);
+ $items =<<<_EOF
+ <item id="btRetour" link="/app/compta/services.php/supplier/account/%s" class="" title="Retour" />
+_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
+<Entry key="%s - %s" value="%s"></Entry>
+_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
+<Entry key="%s - %s" value="%s"></Entry>
+_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;
+
+ }
+
+
+
+}
+
+
+
+?>
<item id="btRetour" link="/app/compta/services.php/" class="" title="Retour" />
</menu>
- <panel id="pAccount" class="col-12 pg-account" style="min-height:150px;">
+ <panel id="pAccount" class="col-11 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">
$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
*/
$template=<<<_EOF
<span class="user-card" >
<p>
-<link href="/app/compta/services.php/supplier/details/%s">%s %s</link>
+<link href="/app/compta/services.php/supplier/account/%s">%s %s</link>
<span style="float: right; padding-right: 10x;">
Solde <b>%.2f</b>
</span>
--- /dev/null
+<?php
+
+namespace compta\views\supplier;
+
+require_once(dirname(__FILE__)."/../pages.php");
+
+
+const SupplierPay =<<<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>
+ (function() {
+ console.log("Try to update mh1a");
+ var mh1a = $('mh1').firstChild;
+ mh1a.href = "/fr/app/compta/services.php/supplier";
+ })();
+ </script>
+ <script>
+ </script>
+
+<menu>
+</menu>
+
+ <panel id="pAccount" class="col-11 pg-account" style="min-height:150px;">
+ <h2 id="title" style="width:100%">Payer facture fournisseur</h2>
+
+ <group id="group">
+<grouptitle>Payer Facture</grouptitle>
+<groupcontent>
+ <FieldSet labelWidth="95" style="border:none 0px;">
+ <TextField width="243" id="suppl_desc" style=""><Label style="">Intitule</Label></TextField><br/>
+ <ComboBox width="220" id="suppl_id" style="margin-right:10px;"><Label>Fournisseur</Label>
+ <Entry key="401001-" value="401001"></Entry>
+ <Entry key="401002-BOLLORE" value="401002"></Entry>
+ </ComboBox>
+ <TextField width="75" id="suppl_date" style=""><Label style=""> Date Saisie</Label></TextField><br/>
+ <ComboBox width="220" id="suppl_banque" style="margin-right:10px;"><Label>Banque</Label>
+ <Entry key="512001-Banque postale" value="512001"></Entry>
+ </ComboBox>
+ <TextField width="75" id="suppl_voucher_date" style=""><Label style=""> Date Facture</Label></TextField><br/>
+ <TextField width="220" id="suppl_voucher_ref" value="CHEQUE N°" style="margin-right:9px;"><Label style="">Reference</Label></TextField>
+ <TextField width="73" id="suppl_amount" style=""><Label style=""> Montant</Label></TextField>
+ </FieldSet>
+ <panel class="col-md-10 col-sm-12" style="min-height:14px;">
+ <button id='btFPRecord' href="#" style="float:left;">Enregistrer</button>
+ <button id='btFPCancel' style="float:left;" href="#">Annuler</button>
+ <!--
+ -->
+ </panel>
+</groupcontent>
+</group>
+
+
+ </panel>
+ <div class="clearfix"></div>
+ <!-- Script Section -->
+ </content>
+</gui>
+XML;
+
+
+/**
+ * @brief Update GUI with the list of
+ * documents available. All decomptes
+ */
+class Pay extends \PageCompta
+ implements \IActionResult
+{
+ function __construct($model)
+ {
+ $this->_model = $model;
+ parent::__construct(SupplierPay,true);
+ }
+
+ public function render()
+ {
+ $this->show();
+ }
+
+ /**
+ * @brief allow sub classes to modify xml file
+ */
+ protected function _updateXML(&$xml)
+ {
+ // Ok Handle Charges
+ $solde = $this->getElementById($xml,"suppl_banque");
+ $nel = $xml->createDocumentFragment();
+ $nel->appendXML($this->fillCharge());
+ $solde->appendChild($nel);
+ // Update supplier ID
+ $tbody = $this->getElementById($xml,"suppl_id");
+ $nel = $xml->createDocumentFragment();
+ $frag =<<<_EOF
+<Entry key="{$this->_model->_id} {$this->_model->_account['acc_desc']}" value="{$this->_model->_id}"></Entry>
+_EOF;
+ $nel->appendXML($frag);
+ $tbody->appendChild($nel);
+ /* Update menu */
+ $tbody = $xml->getElementsByTagName('menu');
+ $f = $tbody->item(0);
+ $items =<<<_EOF
+ <item id="btRetour" link="/app/compta/services.php/supplier/account/%s" class="" title="Retour" />
+_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
+<Entry key="%s - %s" value="%s"></Entry>
+_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
+<Entry key="%s - %s" value="%s"></Entry>
+_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;
+
+ }
+
+
+
+}
+
+
+?>