244 $led_id=$cn->get_value(
'select jrn_def_id
245 from importbank.format_bank as fb
246 join importbank.import as imp on (format_bank_id = fb.id)
247 where imp.id=$1', array($p_array[
'id']));
249 $fin_ledger=
new Acc_Ledger_Fin($cn, $led_id);
250 $card_bank=$fin_ledger->get_bank();
251 $quickcode_bank=$cn->get_value(
'select ad_value from fiche_detail where f_id=$1 and ad_id=$2',
252 array($card_bank, ATTR_DEF_QUICKCODE));
253 $account_bank=$cn->get_value(
'select ad_value from fiche_detail where f_id=$1 and ad_id=$2',
254 array($card_bank, ATTR_DEF_ACCOUNT));
255 $bank_name=$fin_ledger->get_name();
259 $sql=
"select id from importbank.temp_bank where import_id=$1 and status='W'";
261 $ResAll=$cn->exec_sql(
$sql, array($p_array[
'id']));
262 $Max=Database::num_row($ResAll);
264 for ($i=0; $i<$Max; $i++)
266 $val=Database::fetch_array($ResAll, $i);
268 $row=
new Temp_Bank_Sql($cn, $val[
'id']);
270 if (
$row->f_id==null||
$row->f_id==
'')
273 self::transfert_error(
$row->id,
'Aucune fiche donnée');
278 $f=
new Fiche($cn,
$row->f_id);
279 $poste_comptable=
$f->strAttribut(ATTR_DEF_ACCOUNT);
280 $quick_code=
$f->strAttribut(ATTR_DEF_QUICKCODE);
283 if ($poste_comptable==NOTFOUND||strlen(trim($poste_comptable))==0)
286 self::transfert_error(
$row->id,
287 _(
'Poste comptable de la fiche est incorrecte'));
290 if (self::check_date(
$row->tp_date)==
false)
293 self::transfert_error(
$row->id, _(
'Date hors des limites'));
296 $err=self::is_closed(
$row->tp_date, $led_id);
299 self::transfert_error(
$row->id,
300 $err._(
' - Date hors des journaux'));
304 if ( strpos($poste_comptable,
',') != 0 ) {
305 list($poste_debit,$poste_credit) =explode(
',',$poste_comptable);
306 $poste_comptable=(
$row->amount > 0 ) ? $poste_debit: $poste_credit;
310 $seq=$cn->get_next_seq(
's_grpt');
311 $p_user=$_SESSION[
'g_user'];
313 $acc_op=
new Acc_Operation($cn);
314 $acc_op->amount=
$row->amount;
317 $acc_op->date=
$row->tp_date;
318 $acc_op->user=$p_user;
319 $acc_op->poste=$account_bank;
321 $acc_op->jrn=$led_id;
323 $acc_op->f_id=$card_bank;
324 $acc_op->qcode=$quickcode_bank;
325 $acc_op->mt=microtime(
true);
326 $r=$acc_op->insert_jrnx();
330 $acc_op->poste=$poste_comptable;
331 $acc_op->amount=
$row->amount;
332 $acc_op->f_id=
$row->f_id;
333 $acc_op->qcode=$quick_code;
334 $r=$acc_op->insert_jrnx();
336 $acc_op->desc=
$row->tp_third.
" ".
$row->libelle.
" ".
$row->tp_extra;
337 $jr_id=$acc_op->insert_jrn();
339 $internal=$fin_ledger->compute_internal_code($seq);
341 $Res=$cn->exec_sql(
"update jrn set jr_internal=$1 where jr_id = $2",
342 array($internal, $jr_id));
344 $fin_ledger->insert_quant_fin($card_bank, $jr_id,
$row->f_id,
348 if (trim(
$row->tp_rec)!=
'')
350 $acc_reconc=
new Acc_Reconciliation($cn);
351 $acc_reconc->set_jr_id($jr_id);
352 $acc_reconc->insert(
$row->tp_rec);
355 $sql2=
"update importbank.temp_bank set status = 'T',tp_error_msg=null where id=$1";
356 $Res2=$cn->exec_sql($sql2, array(
$row->id));
362 echo
'<span class="error">'.
363 'Erreur dans '.__FILE__.
':'.__LINE__.
364 ' Message = '.$e->getMessage().
for($i=0;$i< Database::num_row($ret);$i++) $row