forked from Wavyzz/dolibarr
Synchro
This commit is contained in:
@@ -28,15 +28,19 @@ class ComptaExport
|
||||
$this->db = $DB;
|
||||
$this->user = $USER;
|
||||
$this->classe_export = $classe;
|
||||
$this->error_message = '';
|
||||
}
|
||||
|
||||
function ReadLines()
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT f.rowid as facid, f.facnumber, ".$this->db->pdate("f.datef")." as datef";
|
||||
$sql .= " , f.total_ttc, f.tva ";
|
||||
$sql .= " ,s.nom, s.code_client";
|
||||
$sql .= " ,s.nom, s.code_compta";
|
||||
$sql .= " , l.price, l.tva_taux";
|
||||
$sql .= " , c.numero";
|
||||
$sql .= " , c.numero, f.increment";
|
||||
$sql .= " , l.rowid as lrowid";
|
||||
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."facturedet as l";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
|
||||
@@ -46,13 +50,15 @@ class ComptaExport
|
||||
$sql .= " WHERE f.rowid = l.fk_facture ";
|
||||
$sql .= " AND s.idp = f.fk_soc";
|
||||
$sql .= " AND f.fk_statut = 1 ";
|
||||
|
||||
$sql .= " AND l.fk_code_ventilation <> 0 ";
|
||||
|
||||
$sql .= " AND l.fk_export_compta = 0";
|
||||
|
||||
$sql .= " AND c.rowid = l.fk_code_ventilation";
|
||||
|
||||
$sql .= " ORDER BY f.rowid ASC, l.rowid ASC";
|
||||
|
||||
print $sql;
|
||||
|
||||
$sql .= " ORDER BY f.rowid ASC, l.fk_code_ventilation ASC";
|
||||
// print $sql;
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
@@ -65,37 +71,109 @@ class ComptaExport
|
||||
|
||||
$this->linec[$i][0] = $obj->datef;
|
||||
$this->linec[$i][1] = $obj->facid;
|
||||
$this->linec[$i][2] = $obj->code_client;
|
||||
$this->linec[$i][2] = $obj->code_compta;
|
||||
$this->linec[$i][3] = $obj->nom;
|
||||
$this->linec[$i][4] = $obj->numero;
|
||||
$this->linec[$i][5] = $obj->facnumber;
|
||||
$this->linec[$i][6] = $obj->tva;
|
||||
$this->linec[$i][7] = $obj->total_ttc;
|
||||
$this->linec[$i][8] = $obj->price;
|
||||
$this->linec[$i][9] = $obj->increment;
|
||||
$this->linec[$i][10] = $obj->lrowid;
|
||||
|
||||
if ($obj->code_compta == '')
|
||||
{
|
||||
$this->error_message .= "Code compta non valide pour $obj->nom<br>";
|
||||
$error++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
/*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function ReadLinesPayment()
|
||||
{
|
||||
$error = 0;
|
||||
|
||||
$sql = "SELECT p.rowid as paymentid, f.facnumber";
|
||||
$sql .= " ,".$this->db->pdate("p.datep")." as datep";
|
||||
$sql .= " , pf.amount";
|
||||
$sql .= " ,s.nom, s.code_compta";
|
||||
$sql .= " , cp.libelle, f.increment";
|
||||
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."paiement as p";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."paiement_facture as pf";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."c_paiement as cp";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql .= " , ".MAIN_DB_PREFIX."societe as s";
|
||||
|
||||
$sql .= " WHERE p.fk_export_compta = 0";
|
||||
$sql .= " AND p.rowid = pf.fk_paiement";
|
||||
$sql .= " AND cp.id = p.fk_paiement";
|
||||
$sql .= " AND f.rowid = pf.fk_facture";
|
||||
$sql .= " AND f.fk_soc = s.idp";
|
||||
$sql .= " AND p.statut = 1 ";
|
||||
|
||||
$sql .= " ORDER BY f.rowid ASC, p.rowid ASC";
|
||||
|
||||
// print $sql."<br><br>";
|
||||
|
||||
if ($this->db->query($sql))
|
||||
{
|
||||
$num = $this->db->num_rows();
|
||||
$i = 0;
|
||||
$this->linep = array();
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object();
|
||||
|
||||
$this->linep[$i][0] = $obj->datep;
|
||||
$this->linep[$i][1] = $obj->paymentid;
|
||||
$this->linep[$i][2] = $obj->code_compta;
|
||||
$this->linep[$i][3] = $obj->nom;
|
||||
$this->linep[$i][4] = $obj->facnumber;
|
||||
$this->linep[$i][5] = $obj->amount;
|
||||
$this->linep[$i][6] = $obj->libelle;
|
||||
$this->linep[$i][7] = $obj->increment;
|
||||
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
return $error;
|
||||
}
|
||||
/**
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function Export()
|
||||
{
|
||||
$this->ReadLines();
|
||||
$error = 0;
|
||||
|
||||
$error += $this->ReadLines();
|
||||
$error += $this->ReadLinesPayment();
|
||||
|
||||
if (sizeof($this->linec) > 0 )
|
||||
if (!$error && sizeof($this->linec) > 0)
|
||||
{
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/compta/export/modules/compta.export.'.strtolower($this->classe_export).'.class.php';
|
||||
|
||||
|
||||
|
||||
$objexport_name = "ComptaExport".$this->classe_export;
|
||||
|
||||
$objexport = new $objexport_name();
|
||||
|
||||
$objexport->Export($this->linec);
|
||||
$objexport = new $objexport_name($this->db);
|
||||
|
||||
$objexport->Export($this->linec, $this->linep);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user