Skip to content
Snippets Groups Projects
Commit 09d877bc authored by Rodolphe Quiedeville's avatar Rodolphe Quiedeville
Browse files

Modif syslogs et autres

parent e2233fb0
No related branches found
No related tags found
No related merge requests found
...@@ -30,17 +30,53 @@ class FactureDetailTableurOne { ...@@ -30,17 +30,53 @@ class FactureDetailTableurOne {
$this->db = $DB; $this->db = $DB;
} }
Function GenerateFile($ligne, $year, $month) Function GenerateFile($ligne_id, $year, $month)
{ {
$this->ligne = $ligne; $this->ligne = new LigneTel($db);
$this->ligne->id = $ligne_id;
$dir = "/tmp"; $dir = "/tmp";
$error = 0; $error = 0;
$dir = FAC_OUTPUTDIR . "/" . $fac->ref . "/" ; $sql = "SELECT rowid";
$fname = $dir . $fac->ref . "-$ligne-$objlignetel->code_analytique-detail.xls"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_facture";
$sql .= " WHERE fk_ligne = '".$this->ligne->id."'";
$sql .= " AND date = '".$year."-".$month."-01';";
dolibarr_syslog("Open $fname"); $resql = $this->db->query($sql);
if ($resql)
{
if ($row = $this->db->fetch_row($resql))
{
$facid = substr('0000'.$row[0], -4);
}
else
{
//dolibarr_syslog("Pas de facture pour ".$this->ligne->id);
}
}
else
{
dolibarr_syslog("Error");
}
if ($facid > 0)
{
$dir = DOL_DATA_ROOT.'/telephonie/facture/';
$dir .= substr($facid,0,1)."/";
$dir .= substr($facid,1,1)."/";
$dir .= substr($facid,2,1)."/";
$dir .= substr($facid,3,1)."/";
create_exdir($dir);
$fname = $dir . $facid . "-detail.xls";
dolibarr_syslog("Open ".$facid."-detail.xls");
$workbook = &new writeexcel_workbook($fname); $workbook = &new writeexcel_workbook($fname);
...@@ -71,12 +107,13 @@ class FactureDetailTableurOne { ...@@ -71,12 +107,13 @@ class FactureDetailTableurOne {
$page->write(0, 1, "Date", $format_titre); $page->write(0, 1, "Date", $format_titre);
$page->write(0, 2, "Numero", $format_titre); $page->write(0, 2, "Numero", $format_titre);
$page->write(0, 3, "Destination", $format_titre); $page->write(0, 3, "Destination", $format_titre);
$page->write(0, 4, "Dure", $format_titre); $page->write(0, 4, "Duree", $format_titre);
$page->write(0, 5, "Cout", $format_titre); $page->write(0, 5, "Cout", $format_titre);
$sql = "SELECT ligne, date, numero, dest, dureetext, duree, cout_vente"; $sql = "SELECT ligne, date, numero, dest, dureetext, duree, cout_vente";
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details"; $sql .= " FROM ".MAIN_DB_PREFIX."telephonie_communications_details";
$sql .= " WHERE ligne = '".$this->ligne."'"; $sql .= " WHERE fk_ligne = '".$this->ligne->id."'";
$sql .= " AND fk_telephonie_facture = ".$facid;
$sql .= " ORDER BY date ASC"; $sql .= " ORDER BY date ASC";
$resql = $this->db->query($sql); $resql = $this->db->query($sql);
...@@ -86,7 +123,7 @@ class FactureDetailTableurOne { ...@@ -86,7 +123,7 @@ class FactureDetailTableurOne {
$i = 0; $i = 0;
$numsql = $this->db->num_rows($resql); $numsql = $this->db->num_rows($resql);
dolibarr_syslog($this->ligne . " : ".$numsql); dolibarr_syslog("Ligne : ".$this->ligne->id . " : ".$numsql);
while ($i < $numsql) while ($i < $numsql)
{ {
...@@ -101,7 +138,6 @@ class FactureDetailTableurOne { ...@@ -101,7 +138,6 @@ class FactureDetailTableurOne {
$page->write($xx, 4, $obj->duree, $fnb); $page->write($xx, 4, $obj->duree, $fnb);
$page->write($xx, 5, $obj->cout_vente, $fp); $page->write($xx, 5, $obj->cout_vente, $fp);
$i++; $i++;
} }
$this->db->free($resql); $this->db->free($resql);
...@@ -112,10 +148,10 @@ class FactureDetailTableurOne { ...@@ -112,10 +148,10 @@ class FactureDetailTableurOne {
} }
$workbook->close(); $workbook->close();
dolibarr_syslog("Close $fname"); //dolibarr_syslog("Close $fname");
}
return $error; return $error;
} }
} }
?> ?>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment