, ident_mobile, ident_email1
, case when joa.jia_acc != 'NULL' then joa.jia_acc else 0 end as compte
FROM Owners as o
-LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id where o.ident_id = {$this->session->id()};
+LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id and joa.jia_actu = 1 where o.ident_id = {$this->session->id()};
__EOF;
} else {
//error_log("Syndic::getCorproprietaires syndic ".$_uid);
, ident_mobile, ident_email1
, case when joa.jia_acc != 'NULL' then joa.jia_acc else 0 end as compte
FROM Owners as o
-LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id where o.ident_id = {$_uid};
+LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id and joa.jia_actu = 1 where o.ident_id = {$_uid};
__EOF;
} else {
$q =<<<__EOF
, ident_mobile, ident_email1
, case when joa.jia_acc != 'NULL' then joa.jia_acc else 0 end as compte
FROM Owners as o
-LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id;
+LEFT JOIN JoinIdentityAccount as joa on joa.jia_ident = o.ident_id and joa.jia_actu = 1;
__EOF;
}
}
*
*/
function getUserIdFromAccount($account) {
- $q = "select jia_ident from JoinIdentityAccount WHERE jia_acc = ".$account.";";
- $res = $this->doQueryImpr($q);
+ $q = "select jia_ident from JoinIdentityAccount WHERE jia_acc = ".$account.";";
+ $res = $this->doQueryI($q);
+ error_log("For ".$account." Got= ".$res['records'][0][0]." ");
return $res['records'][0][0];
}
+
+ /**
+ * \brief get the accounts except the CHRG account.
+ */
+ public function getAvances($period,$account,&$total)
+ {
+ $uid = $this->getUserIdFromAccount($account);
+ $q =<<<_EOF
+SELECT jia_acc,act.actu_abrevation,act.actu_title from JoinIdentityAccount
+ JOIN AccountTypeUser as act on jia_actu = act.actu_id
+WHERE jia_ident = {$uid} AND jia_acc != "{$account}";
+_EOF;
+ $res = $this->doQueryI($q);
+ // Put account list in an array
+ $result = Array();
+ foreach ($res['records'] as $entry)
+ {
+ $compte = $entry[0];
+ $q = "call solde_compte_where('".$period."','t.acc_id like \"".$compte."%\"');";
+ $res = $this->doQueryI($q);
+ $result[$compte] = array($entry[1],$entry[2],$res['records'][0][2]);
+ $total += ($result[$compte][2]);
+ }
+ return $result;
+ }
/**
*
*/
// Exercice Clos
if ($exercice[1] == 0) {
$this->Detail($period,$compte);
+ $this->Avances($period,$compte);
} else {
$pdf->Cell(50,5,"Exercice Clos.");
$pdf->Ln();
$this->Detail($period,$compte);
+ $this->Avances($period,$compte);
}
} catch (Exception $e) {
$pdf->Cell(50,5,"Failed :".$e->getMessage());
_EOF;
$pdf->writeHTMLCell($w=0, $h=0, $x='', $y= '', $tcharge, $border=0, $ln=1, $fill=0, $reseth=true, $align='', $autopadding=false);
- //$this->Titre("Total appels de fonds ".$result['total_appel']." €");
- $this->Titre("Vos avances");
+ //$this->Titre("Total appels de fonds ".$result['total_appel']." €");
+ }
+ /**
+ * \brief compute avance for user
+ */
+ private function Avances($period,$compte) {
+ $fragment =<<<_EOF
+<tr><td class="title">%s</td><td class="result">%.2f €</td></tr>
+_EOF;
+ $pdf = $this->pdf;
+ $total = 0.0;
+ error_log("Before enter getAvances");
+ $avances= $this->data->getAvances($period,$compte,$total);
+ $this->Titre("Vos avances");
+ $avance_str="";
+ foreach($avances as $entry)
+ {
+ $avance_str.=sprintf($fragment,$entry[1],$entry[2]);
+ }
+ error_log("".$avance_str);
$avance =<<<_EOF
<style>
.title {width:212px;}
.result { width:100px;text-align:right;}
</style>
<table>
+<!--
<tr><td class="title">Avance de trésorerie</td><td class="result">0.00 €</td></tr>
<tr><td class="title">Avance de travaux art 14.2</td><td class="result">0.00 €</td></tr>
<tr><td class="title">Avance fond de travaux</td><td class="result">0.00 €</td></tr>
+-->
+{$avance_str}
<tr>
-<td style="width:212px;"><b>Total avance</b></td><td style="width:100px;text-align:right;"><b>0.0 €</b></td></tr>
+<td style="width:212px;"><b>Total avance</b></td><td style="width:100px;text-align:right;"><b>{$total} €</b></td></tr>
</table>
<br/>
_EOF;
END IF;
IF tant > 0 THEN
INSERT INTO TransactionEntry (trans_id,entry_type,entry_date,voucher_ref,acc_id,amount,debit_credit,description) VALUES
- (@last_id,"OD",ed,vouch,a,am*tant,'c',des);
+ (@last_id,"OD",ed,vouch,a,ROUND(am*tant),'c',des);
END IF;
END LOOP;