New: Script export-bank-receipts should be ready for test.
This commit is contained in:
parent
f6dfcb756c
commit
3a11e0baad
@ -35,6 +35,7 @@ class ChargeSociales extends CommonObject
|
|||||||
public $table_element='chargesociales';
|
public $table_element='chargesociales';
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
|
var $ref;
|
||||||
var $date_ech;
|
var $date_ech;
|
||||||
var $lib;
|
var $lib;
|
||||||
var $type;
|
var $type;
|
||||||
|
|||||||
@ -380,6 +380,8 @@ class PaiementFourn extends Paiement
|
|||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'paiementfourn_facturefourn as pf, '.MAIN_DB_PREFIX.'facture_fourn as f';
|
||||||
$sql.= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id;
|
$sql.= ' WHERE pf.fk_facturefourn = f.rowid AND fk_paiementfourn = '.$this->id;
|
||||||
if ($filter) $sql.= ' AND '.$filter;
|
if ($filter) $sql.= ' AND '.$filter;
|
||||||
|
|
||||||
|
dol_syslog(get_class($this).'::getBillsArray sql='.$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -399,7 +401,7 @@ class PaiementFourn extends Paiement
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error();
|
||||||
dol_syslog('PaiementFourn::getBillsArray Error '.$this->error.' - sql='.$sql);
|
dol_syslog(get_class($this).'::getBillsArray Error '.$this->error);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -140,7 +140,7 @@ SellsJournal=Journal des ventes
|
|||||||
PurchasesJournal=Journal des achats
|
PurchasesJournal=Journal des achats
|
||||||
Journaux=Journaux
|
Journaux=Journaux
|
||||||
InvoiceRef=Réf facture
|
InvoiceRef=Réf facture
|
||||||
Piece=Piece compta
|
Piece=Pièce compta
|
||||||
DescSellsJournal=Journal des ventes
|
DescSellsJournal=Journal des ventes
|
||||||
DescPurchasesJournal=Journal des achats
|
DescPurchasesJournal=Journal des achats
|
||||||
JournalNum=Journal
|
JournalNum=Journal
|
||||||
|
|||||||
@ -43,6 +43,10 @@ require_once DOL_DOCUMENT_ROOT.'/compta/paiement/class/paiement.class.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/paiementfourn.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/tva/class/tva.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/paymentsocialcontribution.class.php';
|
||||||
|
|
||||||
// Global variables
|
// Global variables
|
||||||
$version=DOL_VERSION;
|
$version=DOL_VERSION;
|
||||||
@ -64,12 +68,15 @@ $model=$argv[3];
|
|||||||
$newlangid='en_EN'; // To force a new lang id
|
$newlangid='en_EN'; // To force a new lang id
|
||||||
|
|
||||||
|
|
||||||
|
$invoicestatic=new Facture($db);
|
||||||
|
$invoicesupplierstatic=new FactureFournisseur($db);
|
||||||
$societestatic=new Societe($db);
|
$societestatic=new Societe($db);
|
||||||
$chargestatic=new ChargeSociales($db);
|
$chargestatic=new ChargeSociales($db);
|
||||||
$memberstatic=new Adherent($db);
|
$memberstatic=new Adherent($db);
|
||||||
$paymentstatic=new Paiement($db);
|
$paymentstatic=new Paiement($db);
|
||||||
$paymentsupplierstatic=new PaiementFourn($db);
|
$paymentsupplierstatic=new PaiementFourn($db);
|
||||||
$paymentvatstatic=new TVA($db);
|
$paymentsocialcontributionstatic=new PaymentSocialContribution($db);
|
||||||
|
$paymentvatstatic=new Tva($db);
|
||||||
$bankstatic=new Account($db);
|
$bankstatic=new Account($db);
|
||||||
$banklinestatic=new AccountLine($db);
|
$banklinestatic=new AccountLine($db);
|
||||||
|
|
||||||
@ -100,7 +107,9 @@ if (! empty($newlangid))
|
|||||||
$outputlangs->load("main");
|
$outputlangs->load("main");
|
||||||
$outputlangs->load("bills");
|
$outputlangs->load("bills");
|
||||||
$outputlangs->load("companies");
|
$outputlangs->load("companies");
|
||||||
$outputlangs->load("banks");
|
$outputlangs->load("banks");
|
||||||
|
$outputlangs->load("members");
|
||||||
|
$outputlangs->load("compta");
|
||||||
|
|
||||||
|
|
||||||
$acct=new Account($db);
|
$acct=new Account($db);
|
||||||
@ -141,20 +150,23 @@ if ($result >= 0)
|
|||||||
$array_fields=array(
|
$array_fields=array(
|
||||||
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
'bankreceipt'=>$outputlangs->transnoentitiesnoconv("AccountStatementShort"), 'bankaccount'=>$outputlangs->transnoentitiesnoconv("BankAccount"),
|
||||||
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
'dateop'=>$outputlangs->transnoentitiesnoconv("DateOperationShort"),'dateval'=>$outputlangs->transnoentitiesnoconv("DateValueShort"),'type'=>$outputlangs->transnoentitiesnoconv("Type"),
|
||||||
'description'=>$outputlangs->transnoentitiesnoconv("Description"), 'thirdparty'=>$outputlangs->transnoentitiesnoconv("Tiers"), 'invoices'=>$outputlangs->transnoentitiesnoconv("Invoices"),
|
'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")
|
'debit'=>$outputlangs->transnoentitiesnoconv("Debit"), 'credit'=>$outputlangs->transnoentitiesnoconv("Credit"), 'sold'=>$outputlangs->transnoentitiesnoconv("Solde"),
|
||||||
|
'comment'=>$outputlangs->transnoentitiesnoconv("Comment")
|
||||||
);
|
);
|
||||||
$array_selected=array(
|
$array_selected=array(
|
||||||
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
'bankreceipt'=>'bankreceipt', 'bankaccount'=>'bankaccount',
|
||||||
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
'dateop'=>'dateop','dateval'=>'dateval','type'=>'type',
|
||||||
'description'=>'description', 'thirdparty'=>'thirdparty', 'invoices'=>'invoices',
|
'description'=>'description', 'thirdparty'=>'thirdparty', 'accountelem'=>'accountelem',
|
||||||
'debit'=>'debit', 'credit'=>'credit', 'sold'=>'sold', 'comment'=>'comment'
|
'debit'=>'debit', 'credit'=>'credit', 'sold'=>'sold',
|
||||||
|
'comment'=>'comment'
|
||||||
);
|
);
|
||||||
$array_export_TypeFields=array(
|
$array_export_TypeFields=array(
|
||||||
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
'bankreceipt'=>'Text', 'bankaccount'=>'Text',
|
||||||
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
'dateop'=>'Date','dateval'=>'Date','type'=>'Text',
|
||||||
'description'=>'Text', 'thirdparty'=>'Text', 'invoices'=>'Text',
|
'description'=>'Text', 'thirdparty'=>'Text', 'accountelem'=>'Text',
|
||||||
'debit'=>'Number', 'credit'=>'Number', 'sold'=>'Number', 'comment'=>'Text'
|
'debit'=>'Number', 'credit'=>'Number', 'sold'=>'Number',
|
||||||
|
'comment'=>'Text'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Genere en-tete
|
// Genere en-tete
|
||||||
@ -184,9 +196,12 @@ if ($result >= 0)
|
|||||||
$i=0;
|
$i=0;
|
||||||
while ($i < $numrows)
|
while ($i < $numrows)
|
||||||
{
|
{
|
||||||
print "Lines ".$i."\n";
|
//print "Lines ".($i+1)."\n";
|
||||||
|
$thirdparty='';
|
||||||
$objp = $db->fetch_object($result);
|
$accountelem='';
|
||||||
|
$comment='';
|
||||||
|
|
||||||
|
$objp = $db->fetch_object($resql);
|
||||||
$total = $total + $objp->amount;
|
$total = $total + $objp->amount;
|
||||||
|
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
@ -203,126 +218,148 @@ if ($result >= 0)
|
|||||||
// Libelle
|
// Libelle
|
||||||
$reg=array();
|
$reg=array();
|
||||||
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
preg_match('/\((.+)\)/i',$objp->label,$reg); // Si texte entoure de parenthese on tente recherche de traduction
|
||||||
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) $desc=$langs->trans($reg[1]);
|
if ($reg[1] && $langs->trans($reg[1])!=$reg[1]) $description=$langs->trans($reg[1]);
|
||||||
else $desc=$objp->label;
|
else $description=$objp->label;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Ajout les liens (societe, company...)
|
* Ajout les liens (societe, company...)
|
||||||
*/
|
*/
|
||||||
$newline=1;
|
|
||||||
$links = $acct->get_url($objp->rowid);
|
$links = $acct->get_url($objp->rowid);
|
||||||
foreach($links as $key=>$val)
|
foreach($links as $key=>$val)
|
||||||
{
|
{
|
||||||
if (! $newline) print ' - ';
|
|
||||||
else print '<br>';
|
|
||||||
if ($links[$key]['type']=='payment')
|
if ($links[$key]['type']=='payment')
|
||||||
{
|
{
|
||||||
$paymentstatic->id=$links[$key]['url_id'];
|
$paymentstatic->fetch($links[$key]['url_id']);
|
||||||
$paymentstatic->ref=$langs->trans("Payment");
|
$tmparray=$paymentstatic->getBillsArray('');
|
||||||
print ' '.$paymentstatic->getNomUrl(1);
|
foreach($tmparray as $key => $val)
|
||||||
$newline=0;
|
{
|
||||||
|
$invoicestatic->fetch($val);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$invoicestatic->ref;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='payment_supplier')
|
elseif ($links[$key]['type']=='payment_supplier')
|
||||||
{
|
{
|
||||||
$paymentsupplierstatic->id=$links[$key]['url_id'];
|
$paymentsupplierstatic->fetch($links[$key]['url_id']);
|
||||||
$paymentsupplierstatic->ref=$langs->trans("Payment");;
|
$tmparray=$paymentsupplierstatic->getBillsArray('');
|
||||||
print ' '.$paymentsupplierstatic->getNomUrl(1);
|
foreach($tmparray as $key => $val)
|
||||||
$newline=0;
|
{
|
||||||
|
$invoicesupplierstatic->fetch($val);
|
||||||
|
if ($accountelem) $accountelem.= ', ';
|
||||||
|
$accountelem.=$invoicesupplierstatic->ref;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='payment_sc')
|
elseif ($links[$key]['type']=='payment_sc')
|
||||||
{
|
{
|
||||||
print '<a href="'.DOL_URL_ROOT.'/compta/payment_sc/fiche.php?id='.$links[$key]['url_id'].'">';
|
$paymentsocialcontributionstatic->fetch($links[$key]['url_id']);
|
||||||
print ' '.img_object($langs->trans('ShowPayment'),'payment').' ';
|
if ($accountelem) $accountelem.= ', ';
|
||||||
print $langs->trans("SocialContributionPayment");
|
$accountelem.=$langs->trans("SocialContribution").' '.$paymentsocialcontributionstatic->ref;
|
||||||
print '</a>';
|
|
||||||
$newline=0;
|
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='payment_vat')
|
elseif ($links[$key]['type']=='payment_vat')
|
||||||
{
|
{
|
||||||
$paymentvatstatic->id=$links[$key]['url_id'];
|
$paymentvatstatic->fetch($links[$key]['url_id']);
|
||||||
$paymentvatstatic->ref=$langs->trans("Payment");
|
if ($accountelem) $accountelem.= ', ';
|
||||||
print ' '.$paymentvatstatic->getNomUrl(2);
|
$accountelem.=$langs->trans("VATPayments").' '.$paymentvatstatic->ref;
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='banktransfert') {
|
elseif ($links[$key]['type']=='banktransfert')
|
||||||
// Do not show link to transfer since there is no transfer card (avoid confusion). Can already be accessed from transaction detail.
|
{
|
||||||
|
$comment=$outputlangs->transnoentitiesnoconv("Transfer");
|
||||||
if ($objp->amount > 0)
|
if ($objp->amount > 0)
|
||||||
{
|
{
|
||||||
|
if ($comment) $comment.= ' ';
|
||||||
$banklinestatic->fetch($links[$key]['url_id']);
|
$banklinestatic->fetch($links[$key]['url_id']);
|
||||||
$bankstatic->id=$banklinestatic->fk_account;
|
$bankstatic->id=$banklinestatic->fk_account;
|
||||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||||
print ' ('.$langs->trans("from").' ';
|
$comment.= ' ('.$langs->trans("from").' ';
|
||||||
print $bankstatic->getNomUrl(1,'transactions');
|
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||||
print ' '.$langs->trans("toward").' ';
|
$comment.= ' '.$langs->trans("toward").' ';
|
||||||
$bankstatic->id=$objp->bankid;
|
$bankstatic->id=$objp->bankid;
|
||||||
$bankstatic->label=$objp->bankref;
|
$bankstatic->label=$objp->bankref;
|
||||||
print $bankstatic->getNomUrl(1,'');
|
$comment.= $bankstatic->getNomUrl(1,'');
|
||||||
print ')';
|
$comment.= ')';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
if ($comment) $comment.= ' ';
|
||||||
$bankstatic->id=$objp->bankid;
|
$bankstatic->id=$objp->bankid;
|
||||||
$bankstatic->label=$objp->bankref;
|
$bankstatic->label=$objp->bankref;
|
||||||
print ' ('.$langs->trans("from").' ';
|
$comment.= ' ('.$langs->trans("from").' ';
|
||||||
print $bankstatic->getNomUrl(1,'');
|
$comment.= $bankstatic->getNomUrl(1,'');
|
||||||
print ' '.$langs->trans("toward").' ';
|
$comment.= ' '.$langs->trans("toward").' ';
|
||||||
$banklinestatic->fetch($links[$key]['url_id']);
|
$banklinestatic->fetch($links[$key]['url_id']);
|
||||||
$bankstatic->id=$banklinestatic->fk_account;
|
$bankstatic->id=$banklinestatic->fk_account;
|
||||||
$bankstatic->label=$banklinestatic->bank_account_label;
|
$bankstatic->label=$banklinestatic->bank_account_label;
|
||||||
print $bankstatic->getNomUrl(1,'transactions');
|
$comment.= $bankstatic->getNomUrl(1,'transactions');
|
||||||
print ')';
|
$comment.= ')';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='company') {
|
elseif ($links[$key]['type']=='company')
|
||||||
print '<a href="'.DOL_URL_ROOT.'/societe/soc.php?socid='.$links[$key]['url_id'].'">';
|
{
|
||||||
print img_object($langs->trans('ShowCustomer'),'company').' ';
|
if ($thirdparty) $thirdparty.= ', ';
|
||||||
print dol_trunc($links[$key]['label'],24);
|
$thirdparty.= dol_trunc($links[$key]['label'],24);
|
||||||
print '</a>';
|
|
||||||
$newline=0;
|
$newline=0;
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='member') {
|
elseif ($links[$key]['type']=='member')
|
||||||
print '<a href="'.DOL_URL_ROOT.'/adherents/fiche.php?rowid='.$links[$key]['url_id'].'">';
|
{
|
||||||
print img_object($langs->trans('ShowMember'),'user').' ';
|
if ($thirdparty) $accountelem.= ', ';
|
||||||
print $links[$key]['label'];
|
$thirdparty.= $links[$key]['label'];
|
||||||
print '</a>';
|
|
||||||
$newline=0;
|
$newline=0;
|
||||||
}
|
}
|
||||||
elseif ($links[$key]['type']=='sc') {
|
/*elseif ($links[$key]['type']=='sc')
|
||||||
print '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
{
|
||||||
print img_object($langs->trans('ShowBill'),'bill').' ';
|
if ($accountelem) $accountelem.= ', ';
|
||||||
print $langs->trans("SocialContribution");
|
//$accountelem.= '<a href="'.DOL_URL_ROOT.'/compta/sociales/charges.php?id='.$links[$key]['url_id'].'">';
|
||||||
print '</a>';
|
//$accountelem.= img_object($langs->trans('ShowBill'),'bill').' ';
|
||||||
|
$accountelem.= $langs->trans("SocialContribution");
|
||||||
|
//$accountelem.= '</a>';
|
||||||
$newline=0;
|
$newline=0;
|
||||||
}
|
}
|
||||||
else {
|
else
|
||||||
print '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
{
|
||||||
print $links[$key]['label'];
|
if ($accountelem) $accountelem.= ', ';
|
||||||
print '</a>';
|
//$accountelem.= '<a href="'.$links[$key]['url'].$links[$key]['url_id'].'">';
|
||||||
|
$accountelem.= $links[$key]['label'];
|
||||||
|
//$accountelem.= '</a>';
|
||||||
$newline=0;
|
$newline=0;
|
||||||
}
|
}*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$debit=$credit='';
|
||||||
if ($objp->amount < 0)
|
if ($objp->amount < 0)
|
||||||
{
|
{
|
||||||
$totald = $totald + abs($objp->amount);
|
$totald = $totald + abs($objp->amount);
|
||||||
$debit=price($objp->amount * -1);
|
$debit=price2num($objp->amount * -1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$totalc = $totalc + abs($objp->amount);
|
$totalc = $totalc + abs($objp->amount);
|
||||||
$credit=price($objp->amount);
|
$credit=price2num($objp->amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
$i++;
|
$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
|
// end of special operation processing
|
||||||
$objmodel->write_record($array_selected,$objp,$outputlangs,$array_export_TypeFields);
|
$objmodel->write_record($array_selected,$rec,$outputlangs,$array_export_TypeFields);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else dol_print_error($db);
|
else dol_print_error($db);
|
||||||
|
|
||||||
print "Found ".$numrows." records\n";
|
print "Found ".$numrows." records for receipt ".$num."\n";
|
||||||
|
|
||||||
// Genere en-tete
|
// Genere en-tete
|
||||||
$objmodel->write_footer($outputlangs);
|
$objmodel->write_footer($outputlangs);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user