function GetSepaContent($debit_id, $debit_type_asked) { $Invoice = new Facture(); $Client = new Client(); # Fetch direct debit transactions $res = mysql_query("SELECT id, invoice_id, bank_account_id\n\tFROM direct_debit_row\n\tWHERE debit_id = {$debit_id}") or die(mysql_error()); if (mysql_num_rows($res) == 0) { error_log(__FUNCTION__ . "(): No transaction found for debit_id {$debit_id}"); return FALSE; } $total_ttc = 0; $invoice_client = array(); $total = array(); while ($invoice = mysql_fetch_assoc($res)) { $info = $Invoice->getInfos($invoice['invoice_id']); if (!isset($total[$info->nom_client])) { $total[$info->nom_client] = array(); } if (!isset($total[$info->nom_client]['TTC'])) { $total[$info->nom_client]['TTC'] = 0; } $total[$info->nom_client]['TTC'] += $info->total_ttc; // On enlève les caractères génants $iban = str_replace(",", "", $info->iban); $bic = str_replace(",", "", $info->bic); $client_iban = preg_replace('/\\s+/', '', $iban); $client_bic = preg_replace('/\\s+/', '', $bic); $client_name = iconv('utf-8', 'ascii//TRANSLIT', $info->nom_client); $mandat_date = GetMandateDate($info->id_client); $debit_type = GetDebitType($info->id_client, $debit_id, $invoice['bank_account_id']); // On définit les variables de la remise de virement $ref_paiement = "F:" . $info->num_facture; $Client->Client($info->id_client); // Formatage du montant $montant = round($info->total_ttc, 2); $montant_centimes = round($info->total_ttc * 100, 0); if (array_key_exists($info->id_client, $invoice_client)) { $invoice_client[$info->id_client]['montant'] = $invoice_client[$info->id_client]['montant'] + $montant_centimes; $invoice_client[$info->id_client]['ref'] = $invoice_client[$info->id_client]['ref'] . "-" . $ref_paiement; } else { if (isset($debit_type)) { if ($debit_type == $debit_type_asked) { $invoice_client[$info->id_client] = array('id' => $info->id_client, 'montant' => $montant_centimes, 'ref' => $ref_paiement, 'client_sepaid' => $Client->sepa_mndtid, 'iban' => $client_iban, 'bic' => $client_bic, 'name' => $client_name, 'mandat_date' => $mandat_date, 'debit_type' => $debit_type); } } } } if (count($invoice_client) === 0) { error_log(__FUNCTION__ . "(): No transaction found for debit_id {$debit_id} and type {$debit_type_asked}"); return FALSE; } return $invoice_client; }
function ClientSession($email, $id) { parent::Client($email, $id); $this->session = new UserSession($email); }
function ClientSession($var) { parent::Client($var); $this->session = new VisitorSession($var); }