New: Add balance before and after column
This commit is contained in:
parent
229ea064e9
commit
85eac29925
@ -277,8 +277,8 @@ else
|
|||||||
$sql.= " AND b.fk_account = ba.rowid";
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||||
|
|
||||||
|
dol_syslog("sql=".$sql);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$var=True;
|
$var=True;
|
||||||
|
|||||||
@ -20,6 +20,8 @@ SavingAccount=Savings account
|
|||||||
SavingAccounts=Savings accounts
|
SavingAccounts=Savings accounts
|
||||||
ErrorBankLabelAlreadyExists=Financial account label already exists
|
ErrorBankLabelAlreadyExists=Financial account label already exists
|
||||||
BankBalance=Balance
|
BankBalance=Balance
|
||||||
|
BankBalanceBefore=Balance before
|
||||||
|
BankBalanceAfter=Balance after
|
||||||
BalanceMinimalAllowed=Minimum allowed balance
|
BalanceMinimalAllowed=Minimum allowed balance
|
||||||
BalanceMinimalDesired=Minimum desired balance
|
BalanceMinimalDesired=Minimum desired balance
|
||||||
InitialBankBalance=Initial balance
|
InitialBankBalance=Initial balance
|
||||||
|
|||||||
@ -20,6 +20,8 @@ SavingAccount=Compte épargne
|
|||||||
SavingAccounts=Comptes épargne/placements
|
SavingAccounts=Comptes épargne/placements
|
||||||
ErrorBankLabelAlreadyExists=Libellé de compte financier déjà existant
|
ErrorBankLabelAlreadyExists=Libellé de compte financier déjà existant
|
||||||
BankBalance=Solde
|
BankBalance=Solde
|
||||||
|
BankBalanceBefore=Solde avant
|
||||||
|
BankBalanceAfter=Solde après
|
||||||
BalanceMinimalAllowed=Solde minimum autorisé
|
BalanceMinimalAllowed=Solde minimum autorisé
|
||||||
BalanceMinimalDesired=Solde minimum désiré
|
BalanceMinimalDesired=Solde minimum désiré
|
||||||
InitialBankBalance=Solde initial
|
InitialBankBalance=Solde initial
|
||||||
|
|||||||
@ -119,9 +119,14 @@ $acct=new Account($db);
|
|||||||
$result=$acct->fetch('',$bankref);
|
$result=$acct->fetch('',$bankref);
|
||||||
if ($result <= 0)
|
if ($result <= 0)
|
||||||
{
|
{
|
||||||
print "Failed to find bank account with ref ".$bankref."\n";
|
print "Failed to find bank account with ref ".$bankref.".\n";
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "Export for bank account ".$acct->ref." (".$acct->label.").\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Creation de la classe d'export du model ExportXXX
|
// Creation de la classe d'export du model ExportXXX
|
||||||
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
|
$dir = DOL_DOCUMENT_ROOT . "/core/modules/export/";
|
||||||
@ -141,248 +146,297 @@ $dirname = $conf->banque->dir_temp;
|
|||||||
$filename = 'export-bank-receipts-'.$bankref.'-'.$num.'.'.$objmodel->extension;
|
$filename = 'export-bank-receipts-'.$bankref.'-'.$num.'.'.$objmodel->extension;
|
||||||
|
|
||||||
|
|
||||||
// Open file
|
$array_fields=array(
|
||||||
print 'Create file '.$filename.' into directory '.$dirname."\n";
|
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
||||||
dol_mkdir($dirname);
|
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
||||||
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
'description'=>$outputlangs->transnoentitiesnoconv("Description"), 'thirdparty'=>$outputlangs->transnoentitiesnoconv("Tiers"), 'accountelem'=>$outputlangs->transnoentitiesnoconv("Piece"),
|
||||||
|
'debit'=>$outputlangs->transnoentitiesnoconv("Debit"), 'credit'=>$outputlangs->transnoentitiesnoconv("Credit"),
|
||||||
if ($result >= 0)
|
'soldbefore'=>$outputlangs->transnoentitiesnoconv("BankBalanceBefore"), 'soldafter'=>$outputlangs->transnoentitiesnoconv("BankBalanceAfter"),
|
||||||
|
'comment'=>$outputlangs->transnoentitiesnoconv("Comment")
|
||||||
|
);
|
||||||
|
$array_selected=array(
|
||||||
|
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
||||||
|
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
||||||
|
'description'=>'description', 'thirdparty'=>'thirdparty', 'accountelem'=>'accountelem',
|
||||||
|
'debit'=>'debit', 'credit'=>'credit',
|
||||||
|
'soldbefore'=>'soldbefore','soldafter'=>'soldafter',
|
||||||
|
'comment'=>'comment'
|
||||||
|
);
|
||||||
|
$array_export_TypeFields=array(
|
||||||
|
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
||||||
|
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
||||||
|
'description'=>'Text', 'thirdparty'=>'Text', 'accountelem'=>'Text',
|
||||||
|
'debit'=>'Number', 'credit'=>'Number',
|
||||||
|
'soldbefore'=>'Number','soldafter'=>'Number',
|
||||||
|
'comment'=>'Text'
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
|
// Recherche les ecritures pour le releve
|
||||||
|
$listofnum="'";
|
||||||
|
$arraynum=explode(',',$num);
|
||||||
|
foreach($arraynum as $val)
|
||||||
{
|
{
|
||||||
$numrows=0;
|
if ($listofnum != "'") $listofnum.="','";
|
||||||
|
$listofnum.=$val;
|
||||||
|
}
|
||||||
|
$listofnum.="'";
|
||||||
|
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
||||||
|
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
||||||
|
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
||||||
|
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
||||||
|
$sql.= " WHERE b.num_releve IN (".$listofnum.")";
|
||||||
|
if (!isset($num)) $sql.= " OR b.num_releve is null";
|
||||||
|
$sql.= " AND b.fk_account = ".$acct->id;
|
||||||
|
$sql.= " AND b.fk_account = ba.rowid";
|
||||||
|
$sql.= $db->order("b.num_releve, b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
||||||
|
//print $sql;
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$balancebefore=array();
|
||||||
|
|
||||||
$array_fields=array(
|
$numrows = $db->num_rows($resql);
|
||||||
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
|
||||||
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
|
||||||
'description'=>$outputlangs->transnoentitiesnoconv("Description"), 'thirdparty'=>$outputlangs->transnoentitiesnoconv("Tiers"), 'accountelem'=>$outputlangs->transnoentitiesnoconv("Piece"),
|
|
||||||
'debit'=>$outputlangs->transnoentitiesnoconv("Debit"), 'credit'=>$outputlangs->transnoentitiesnoconv("Credit"), 'sold'=>$outputlangs->transnoentitiesnoconv("Solde"),
|
|
||||||
'comment'=>$outputlangs->transnoentitiesnoconv("Comment")
|
|
||||||
);
|
|
||||||
$array_selected=array(
|
|
||||||
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
|
||||||
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
|
||||||
'description'=>'description', 'thirdparty'=>'thirdparty', 'accountelem'=>'accountelem',
|
|
||||||
'debit'=>'debit', 'credit'=>'credit', 'sold'=>'sold',
|
|
||||||
'comment'=>'comment'
|
|
||||||
);
|
|
||||||
$array_export_TypeFields=array(
|
|
||||||
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
|
||||||
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
|
||||||
'description'=>'Text', 'thirdparty'=>'Text', 'accountelem'=>'Text',
|
|
||||||
'debit'=>'Number', 'credit'=>'Number', 'sold'=>'Number',
|
|
||||||
'comment'=>'Text'
|
|
||||||
);
|
|
||||||
|
|
||||||
// Genere en-tete
|
if ($numrows > 0)
|
||||||
$objmodel->write_header($outputlangs);
|
|
||||||
|
|
||||||
// Genere ligne de titre
|
|
||||||
$objmodel->write_title($array_fields,$array_selected,$outputlangs,$array_export_TypeFields);
|
|
||||||
|
|
||||||
|
|
||||||
// Recherche les ecritures pour le releve
|
|
||||||
$sql = "SELECT b.rowid, b.dateo as do, b.datev as dv,";
|
|
||||||
$sql.= " b.amount, b.label, b.rappro, b.num_releve, b.num_chq, b.fk_type,";
|
|
||||||
$sql.= " ba.rowid as bankid, ba.ref as bankref, ba.label as banklabel";
|
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."bank_account as ba";
|
|
||||||
$sql.= ", ".MAIN_DB_PREFIX."bank as b";
|
|
||||||
$sql.= " WHERE b.num_releve IN (".$db->escape($num).")";
|
|
||||||
if (!isset($num)) $sql.= " OR b.num_releve is null";
|
|
||||||
//$sql.= " AND b.fk_account = ".$acct->id;
|
|
||||||
$sql.= " AND b.fk_account = ba.rowid";
|
|
||||||
$sql.= $db->order("b.datev, b.datec", "ASC"); // We add date of creation to have correct order when everything is done the same day
|
|
||||||
|
|
||||||
$resql=$db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
{
|
||||||
$numrows = $db->num_rows($resql);
|
// Open file
|
||||||
|
print 'Open file '.$filename.' into directory '.$dirname."\n";
|
||||||
|
dol_mkdir($dirname);
|
||||||
|
$result=$objmodel->open_file($dirname."/".$filename, $outputlangs);
|
||||||
|
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
print 'Failed to create file '.$filename.' into dir '.$dirname.'.'."\n";
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Genere en-tete
|
||||||
|
$objmodel->write_header($outputlangs);
|
||||||
|
|
||||||
|
// Genere ligne de titre
|
||||||
|
$objmodel->write_title($array_fields,$array_selected,$outputlangs,$array_export_TypeFields);
|
||||||
|
}
|
||||||
|
|
||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $numrows)
|
while ($i < $numrows)
|
||||||
|
{
|
||||||
|
$thirdparty='';
|
||||||
|
$accountelem='';
|
||||||
|
$comment='';
|
||||||
|
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
|
|
||||||
|
// Calculate start balance
|
||||||
|
if (! isset($balancebefore[$objp->num_releve]))
|
||||||
{
|
{
|
||||||
//print "Lines ".($i+1)."\n";
|
print 'Calculate start balance for receipt '.$objp->num_releve."\n";
|
||||||
$thirdparty='';
|
|
||||||
$accountelem='';
|
|
||||||
$comment='';
|
|
||||||
|
|
||||||
$objp = $db->fetch_object($resql);
|
|
||||||
$total = $total + $objp->amount;
|
|
||||||
|
|
||||||
$var=!$var;
|
|
||||||
|
|
||||||
// Date operation
|
|
||||||
$dateop=$db->jdate($objp->do);
|
|
||||||
|
|
||||||
// Date de valeur
|
|
||||||
$datevalue=$db->jdate($objp->dv);
|
|
||||||
|
|
||||||
// Num cheque
|
|
||||||
$numchq=($objp->num_chq?$objp->num_chq:'');
|
|
||||||
|
|
||||||
// Libelle
|
|
||||||
$reg=array();
|
|
||||||
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
|
||||||
if ($reg[1] && $langs->transnoentitiesnoconv($reg[1])!=$reg[1]) $description=$langs->transnoentitiesnoconv($reg[1]);
|
|
||||||
else $description=$objp->label;
|
|
||||||
|
|
||||||
/*
|
$sql2 = "SELECT sum(b.amount) as amount";
|
||||||
* Ajout les liens (societe, company...)
|
$sql2.= " FROM ".MAIN_DB_PREFIX."bank as b";
|
||||||
*/
|
$sql2.= " WHERE b.num_releve < '".$db->escape($objp->num_releve)."'";
|
||||||
$links = $acct->get_url($objp->rowid);
|
$sql2.= " AND b.fk_account = ".$objp->bankid;
|
||||||
foreach($links as $key=>$val)
|
$resql2=$db->query($sql2);
|
||||||
|
if ($resql2)
|
||||||
{
|
{
|
||||||
if ($links[$key]['type']=='payment')
|
$obj2=$db->fetch_object($resql2);
|
||||||
{
|
$balancebefore[$objp->num_releve] = ($obj2->amount?$obj2->amount:0);
|
||||||
$paymentstatic->fetch($links[$key]['url_id']);
|
$db->free($resql2);
|
||||||
$tmparray=$paymentstatic->getBillsArray('');
|
}
|
||||||
foreach($tmparray as $key => $val)
|
else
|
||||||
{
|
{
|
||||||
$invoicestatic->fetch($val);
|
dol_print_error($db);
|
||||||
if ($accountelem) $accountelem.= ', ';
|
exit;
|
||||||
$accountelem.=$invoicestatic->ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='payment_supplier')
|
|
||||||
{
|
|
||||||
$paymentsupplierstatic->fetch($links[$key]['url_id']);
|
|
||||||
$tmparray=$paymentsupplierstatic->getBillsArray('');
|
|
||||||
foreach($tmparray as $key => $val)
|
|
||||||
{
|
|
||||||
$invoicesupplierstatic->fetch($val);
|
|
||||||
if ($accountelem) $accountelem.= ', ';
|
|
||||||
$accountelem.=$invoicesupplierstatic->ref;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='payment_sc')
|
|
||||||
{
|
|
||||||
$paymentsocialcontributionstatic->fetch($links[$key]['url_id']);
|
|
||||||
if ($accountelem) $accountelem.= ', ';
|
|
||||||
$accountelem.=$langs->transnoentitiesnoconv("SocialContribution").' '.$paymentsocialcontributionstatic->ref;
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='payment_vat')
|
|
||||||
{
|
|
||||||
$paymentvatstatic->fetch($links[$key]['url_id']);
|
|
||||||
if ($accountelem) $accountelem.= ', ';
|
|
||||||
$accountelem.=$langs->transnoentitiesnoconv("VATPayments").' '.$paymentvatstatic->ref;
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='banktransfert')
|
|
||||||
{
|
|
||||||
$comment=$outputlangs->transnoentitiesnoconv("Transfer");
|
|
||||||
if ($objp->amount > 0)
|
|
||||||
{
|
|
||||||
if ($comment) $comment.= ' ';
|
|
||||||
$banklinestatic->fetch($links[$key]['url_id']);
|
|
||||||
$bankstatic->id=$banklinestatic->fk_account;
|
|
||||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
|
||||||
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
|
||||||
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
|
||||||
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
|
||||||
$bankstatic->id=$objp->bankid;
|
|
||||||
$bankstatic->label=$objp->bankref;
|
|
||||||
$comment.= $bankstatic->getNomUrl(1,'');
|
|
||||||
$comment.= ')';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($comment) $comment.= ' ';
|
|
||||||
$bankstatic->id=$objp->bankid;
|
|
||||||
$bankstatic->label=$objp->bankref;
|
|
||||||
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
|
||||||
$comment.= $bankstatic->getNomUrl(1,'');
|
|
||||||
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
|
||||||
$banklinestatic->fetch($links[$key]['url_id']);
|
|
||||||
$bankstatic->id=$banklinestatic->fk_account;
|
|
||||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
|
||||||
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
|
||||||
$comment.= ')';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='company')
|
|
||||||
{
|
|
||||||
if ($thirdparty) $thirdparty.= ', ';
|
|
||||||
$thirdparty.= dol_trunc($links[$key]['label'],24);
|
|
||||||
$newline=0;
|
|
||||||
}
|
|
||||||
elseif ($links[$key]['type']=='member')
|
|
||||||
{
|
|
||||||
if ($thirdparty) $accountelem.= ', ';
|
|
||||||
$thirdparty.= $links[$key]['label'];
|
|
||||||
$newline=0;
|
|
||||||
}
|
|
||||||
/*elseif ($links[$key]['type']=='sc')
|
|
||||||
{
|
|
||||||
if ($accountelem) $accountelem.= ', ';
|
|
||||||
//$accountelem.= '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
|
||||||
//$accountelem.= img_object($langs->transnoentitiesnoconv('ShowBill'),'bill').' ';
|
|
||||||
$accountelem.= $langs->transnoentitiesnoconv("SocialContribution");
|
|
||||||
//$accountelem.= '</a>';
|
|
||||||
$newline=0;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ($accountelem) $accountelem.= ', ';
|
|
||||||
//$accountelem.= '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
|
||||||
$accountelem.= $links[$key]['label'];
|
|
||||||
//$accountelem.= '</a>';
|
|
||||||
$newline=0;
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$debit=$credit='';
|
$total = $balancebefore[$objp->num_releve];
|
||||||
if ($objp->amount < 0)
|
|
||||||
{
|
|
||||||
$totald = $totald + abs($objp->amount);
|
|
||||||
$debit=price2num($objp->amount * -1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$totalc = $totalc + abs($objp->amount);
|
|
||||||
$credit=price2num($objp->amount);
|
|
||||||
}
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
|
|
||||||
$rec=new stdClass();
|
|
||||||
$rec->bankreceipt=$objp->num_releve;
|
|
||||||
$rec->bankaccount=$objp->banklabel;
|
|
||||||
$rec->dateop=dol_print_date($dateop,'dayrfc');
|
|
||||||
$rec->dateval=dol_print_date($datevalue,'dayrfc');
|
|
||||||
$rec->type=$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'');
|
|
||||||
$rec->description=$description;
|
|
||||||
$rec->thirdparty=$thirdparty;
|
|
||||||
$rec->accountelem=$accountelem;
|
|
||||||
$rec->debit=$debit;
|
|
||||||
$rec->credit=$credit;
|
|
||||||
$rec->sold=$sold;
|
|
||||||
$rec->comment=$comment;
|
|
||||||
|
|
||||||
// end of special operation processing
|
|
||||||
$objmodel->write_record($array_selected,$rec,$outputlangs,$array_export_TypeFields);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$totalbefore = $total;
|
||||||
|
$total = $total + $objp->amount;
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
|
||||||
|
// Date operation
|
||||||
|
$dateop=$db->jdate($objp->do);
|
||||||
|
|
||||||
|
// Date de valeur
|
||||||
|
$datevalue=$db->jdate($objp->dv);
|
||||||
|
|
||||||
|
// Num cheque
|
||||||
|
$numchq=($objp->num_chq?$objp->num_chq:'');
|
||||||
|
|
||||||
|
// Libelle
|
||||||
|
$reg=array();
|
||||||
|
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
||||||
|
if ($reg[1] && $langs->transnoentitiesnoconv($reg[1])!=$reg[1]) $description=$langs->transnoentitiesnoconv($reg[1]);
|
||||||
|
else $description=$objp->label;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Ajout les liens (societe, company...)
|
||||||
|
*/
|
||||||
|
$links = $acct->get_url($objp->rowid);
|
||||||
|
foreach($links as $key=>$val)
|
||||||
|
{
|
||||||
|
if ($links[$key]['type']=='payment')
|
||||||
|
{
|
||||||
|
$paymentstatic->fetch($links[$key]['url_id']);
|
||||||
|
$tmparray=$paymentstatic->getBillsArray('');
|
||||||
|
foreach($tmparray as $key => $val)
|
||||||
|
{
|
||||||
|
$invoicestatic->fetch($val);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$invoicestatic->ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='payment_supplier')
|
||||||
|
{
|
||||||
|
$paymentsupplierstatic->fetch($links[$key]['url_id']);
|
||||||
|
$tmparray=$paymentsupplierstatic->getBillsArray('');
|
||||||
|
foreach($tmparray as $key => $val)
|
||||||
|
{
|
||||||
|
$invoicesupplierstatic->fetch($val);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$invoicesupplierstatic->ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='payment_sc')
|
||||||
|
{
|
||||||
|
$paymentsocialcontributionstatic->fetch($links[$key]['url_id']);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$langs->transnoentitiesnoconv("SocialContribution").' '.$paymentsocialcontributionstatic->ref;
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='payment_vat')
|
||||||
|
{
|
||||||
|
$paymentvatstatic->fetch($links[$key]['url_id']);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$langs->transnoentitiesnoconv("VATPayments").' '.$paymentvatstatic->ref;
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='banktransfert')
|
||||||
|
{
|
||||||
|
$comment=$outputlangs->transnoentitiesnoconv("Transfer");
|
||||||
|
if ($objp->amount > 0)
|
||||||
|
{
|
||||||
|
if ($comment) $comment.= ' ';
|
||||||
|
$banklinestatic->fetch($links[$key]['url_id']);
|
||||||
|
$bankstatic->id=$banklinestatic->fk_account;
|
||||||
|
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||||
|
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
||||||
|
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||||
|
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
||||||
|
$bankstatic->id=$objp->bankid;
|
||||||
|
$bankstatic->label=$objp->bankref;
|
||||||
|
$comment.= $bankstatic->getNomUrl(1,'');
|
||||||
|
$comment.= ')';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($comment) $comment.= ' ';
|
||||||
|
$bankstatic->id=$objp->bankid;
|
||||||
|
$bankstatic->label=$objp->bankref;
|
||||||
|
$comment.= ' ('.$langs->transnoentitiesnoconv("from").' ';
|
||||||
|
$comment.= $bankstatic->getNomUrl(1,'');
|
||||||
|
$comment.= ' '.$langs->transnoentitiesnoconv("toward").' ';
|
||||||
|
$banklinestatic->fetch($links[$key]['url_id']);
|
||||||
|
$bankstatic->id=$banklinestatic->fk_account;
|
||||||
|
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||||
|
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||||
|
$comment.= ')';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='company')
|
||||||
|
{
|
||||||
|
if ($thirdparty) $thirdparty.= ', ';
|
||||||
|
$thirdparty.= dol_trunc($links[$key]['label'],24);
|
||||||
|
$newline=0;
|
||||||
|
}
|
||||||
|
elseif ($links[$key]['type']=='member')
|
||||||
|
{
|
||||||
|
if ($thirdparty) $accountelem.= ', ';
|
||||||
|
$thirdparty.= $links[$key]['label'];
|
||||||
|
$newline=0;
|
||||||
|
}
|
||||||
|
/*elseif ($links[$key]['type']=='sc')
|
||||||
|
{
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
//$accountelem.= '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
||||||
|
//$accountelem.= img_object($langs->transnoentitiesnoconv('ShowBill'),'bill').' ';
|
||||||
|
$accountelem.= $langs->transnoentitiesnoconv("SocialContribution");
|
||||||
|
//$accountelem.= '</a>';
|
||||||
|
$newline=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
//$accountelem.= '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
||||||
|
$accountelem.= $links[$key]['label'];
|
||||||
|
//$accountelem.= '</a>';
|
||||||
|
$newline=0;
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
|
$debit=$credit='';
|
||||||
|
if ($objp->amount < 0)
|
||||||
|
{
|
||||||
|
$totald = $totald + abs($objp->amount);
|
||||||
|
$debit=price2num($objp->amount * -1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$totalc = $totalc + abs($objp->amount);
|
||||||
|
$credit=price2num($objp->amount);
|
||||||
|
}
|
||||||
|
|
||||||
|
$i++;
|
||||||
|
|
||||||
|
$rec=new stdClass();
|
||||||
|
$rec->bankreceipt=$objp->num_releve;
|
||||||
|
$rec->bankaccount=$objp->banklabel;
|
||||||
|
$rec->dateop=dol_print_date($dateop,'dayrfc');
|
||||||
|
$rec->dateval=dol_print_date($datevalue,'dayrfc');
|
||||||
|
$rec->type=$objp->fk_type.' '.($objp->num_chq?$objp->num_chq:'');
|
||||||
|
$rec->description=$description;
|
||||||
|
$rec->thirdparty=$thirdparty;
|
||||||
|
$rec->accountelem=$accountelem;
|
||||||
|
$rec->debit=$debit;
|
||||||
|
$rec->credit=$credit;
|
||||||
|
$rec->sold=$sold;
|
||||||
|
$rec->comment=$comment;
|
||||||
|
$rec->soldbefore=price2num($totalbefore);
|
||||||
|
$rec->soldafter=price2num($total);
|
||||||
|
|
||||||
|
// end of special operation processing
|
||||||
|
$objmodel->write_record($array_selected,$rec,$outputlangs,$array_export_TypeFields);
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
|
||||||
|
|
||||||
print "Found ".$numrows." records for receipt ".$num."\n";
|
if ($numrows > 0)
|
||||||
|
{
|
||||||
|
print "Found ".$numrows." records for receipt ".$num."\n";
|
||||||
|
|
||||||
// Genere en-tete
|
// Genere en-tete
|
||||||
$objmodel->write_footer($outputlangs);
|
$objmodel->write_footer($outputlangs);
|
||||||
|
|
||||||
// Close file
|
// Close file
|
||||||
$objmodel->close_file();
|
$objmodel->close_file();
|
||||||
|
|
||||||
print 'File '.$filename.' was generated into dir '.$dirname.'.'."\n";
|
print 'File '.$filename.' was generated into dir '.$dirname.'.'."\n";
|
||||||
|
|
||||||
$ret=0;
|
$ret=0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print "No records found for receipt ".$num."\n";
|
||||||
|
|
||||||
|
$ret=0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print 'Failed to create file '.$filename.' into dir '.$dirname.'.'."\n";
|
dol_print_error($db);
|
||||||
|
|
||||||
$ret=-1;
|
$ret=-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$db->close();
|
$db->close();
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user