Utilisation de methode.commande.class.php
This commit is contained in:
parent
a8b2d3563f
commit
ede78b3e90
@ -23,10 +23,11 @@
|
|||||||
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php";
|
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_workbook.inc.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php";
|
require_once DOL_DOCUMENT_ROOT."/includes/php_writeexcel/class.writeexcel_worksheet.inc.php";
|
||||||
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/telephonie/fournisseur/commande/methode.commande.class.php";
|
||||||
|
|
||||||
define ('COMMANDETABLEUR_NOEMAIL', -3);
|
define ('COMMANDETABLEUR_NOEMAIL', -3);
|
||||||
|
|
||||||
class CommandeMethodeTableur
|
class CommandeMethodeTableur extends CommandeMethode
|
||||||
{
|
{
|
||||||
|
|
||||||
function CommandeMethodeTableur ($DB, $USER=0, $fourn=0)
|
function CommandeMethodeTableur ($DB, $USER=0, $fourn=0)
|
||||||
@ -54,7 +55,9 @@ class CommandeMethodeTableur
|
|||||||
|
|
||||||
$this->datef = "commande-".strftime("%d%b%y-%HH%M", $this->date);
|
$this->datef = "commande-".strftime("%d%b%y-%HH%M", $this->date);
|
||||||
|
|
||||||
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->datef.".xls";
|
$this->filename = $this->datef.".xls";
|
||||||
|
|
||||||
|
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->filename;
|
||||||
|
|
||||||
if (strlen(trim($this->fourn->email_commande)) == 0)
|
if (strlen(trim($this->fourn->email_commande)) == 0)
|
||||||
{
|
{
|
||||||
@ -96,7 +99,7 @@ class CommandeMethodeTableur
|
|||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = "Commande de Lignes";
|
$subject = "Commande de Lignes N° ".$this->commande_id;
|
||||||
|
|
||||||
$sendto = $this->fourn->email_commande;
|
$sendto = $this->fourn->email_commande;
|
||||||
|
|
||||||
@ -135,22 +138,10 @@ class CommandeMethodeTableur
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function LogSql()
|
/*
|
||||||
{
|
* Création du fichier
|
||||||
|
*
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commande";
|
*/
|
||||||
$sql .= " (datec, fk_user_creat, fk_fournisseur, filename)";
|
|
||||||
$sql .= " VALUES (now(),".$this->user->id.",".$this->fourn->id.",'".$this->datef.".xls')";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function CreateFile($fname)
|
function CreateFile($fname)
|
||||||
{
|
{
|
||||||
@ -194,7 +185,7 @@ class CommandeMethodeTableur
|
|||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
|
|
||||||
$ligneids = array();
|
$this->ligneids = array();
|
||||||
|
|
||||||
$sqlall = "SELECT s.nom, s.idp as socid, f.nom as fournisseur";
|
$sqlall = "SELECT s.nom, s.idp as socid, f.nom as fournisseur";
|
||||||
$sqlall .= ", l.ligne, l.statut, l.rowid, l.remise";
|
$sqlall .= ", l.ligne, l.statut, l.rowid, l.remise";
|
||||||
@ -270,7 +261,7 @@ class CommandeMethodeTableur
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
array_push($ligneids, $obj->rowid);
|
array_push($this->ligneids, $obj->rowid);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -339,7 +330,7 @@ class CommandeMethodeTableur
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach ($ligneids as $lid)
|
foreach ($this->ligneids as $lid)
|
||||||
{
|
{
|
||||||
$lint = new LigneTel($this->db);
|
$lint = new LigneTel($this->db);
|
||||||
$lint->fetch_by_id($lid);
|
$lint->fetch_by_id($lid);
|
||||||
@ -354,8 +345,6 @@ class CommandeMethodeTableur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -23,10 +23,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/telephonie/fournisseur/commande/methode.commande.class.php";
|
||||||
|
|
||||||
define ('COMMANDETEXT_NOEMAIL', -3);
|
define ('COMMANDETEXT_NOEMAIL', -3);
|
||||||
|
|
||||||
class CommandeMethodeText
|
class CommandeMethodeText extends CommandeMethode
|
||||||
{
|
{
|
||||||
|
|
||||||
function CommandeMethodeText ($DB, $USER=0, $fourn=0)
|
function CommandeMethodeText ($DB, $USER=0, $fourn=0)
|
||||||
@ -34,7 +35,7 @@ class CommandeMethodeText
|
|||||||
$this->nom = "Méthode texte";
|
$this->nom = "Méthode texte";
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->user = $USER;
|
$this->user = $USER;
|
||||||
$this->fournisseur = $fourn;
|
$this->fourn = $fourn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function info()
|
function info()
|
||||||
@ -48,9 +49,11 @@ class CommandeMethodeText
|
|||||||
|
|
||||||
$this->datef = "ndi-".strftime("%d%b%y-%HH%M", $this->date);
|
$this->datef = "ndi-".strftime("%d%b%y-%HH%M", $this->date);
|
||||||
|
|
||||||
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->datef.".txt";
|
$this->filename = $this->datef.".txt";
|
||||||
|
|
||||||
if (strlen(trim($this->fournisseur->email_commande)) == 0)
|
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->filename;
|
||||||
|
|
||||||
|
if (strlen(trim($this->fourn->email_commande)) == 0)
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -81,7 +84,7 @@ class CommandeMethodeText
|
|||||||
$sql = "SELECT l.ligne";
|
$sql = "SELECT l.ligne";
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
|
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
|
||||||
$sql .= " WHERE l.statut = 2";
|
$sql .= " WHERE l.statut = 2";
|
||||||
$sql .= " AND l.fk_fournisseur =".$this->fournisseur->id;
|
$sql .= " AND l.fk_fournisseur =".$this->fourn->id;
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$result = $this->db->query($sql);
|
||||||
|
|
||||||
@ -90,9 +93,9 @@ class CommandeMethodeText
|
|||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows();
|
||||||
}
|
}
|
||||||
|
|
||||||
$subject = "Commande de Lignes";
|
$subject = "Commande de Lignes N° ".$this->commande_id;
|
||||||
|
|
||||||
$sendto = $this->fournisseur->email_commande;
|
$sendto = $this->fourn->email_commande;
|
||||||
|
|
||||||
$from = TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC;
|
$from = TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC;
|
||||||
|
|
||||||
@ -120,25 +123,7 @@ class CommandeMethodeText
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function LogSql()
|
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commande";
|
|
||||||
$sql .= " (datec, fk_user_creat, fk_fournisseur, filename)";
|
|
||||||
$sql .= " VALUES (now(),".$this->user->id.",".$this->fournisseur->id.",'".$this->datef.".txt')";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Creation du fichier
|
* Creation du fichier
|
||||||
*
|
*
|
||||||
@ -154,7 +139,7 @@ class CommandeMethodeText
|
|||||||
fwrite ($fp, "nomclient;");
|
fwrite ($fp, "nomclient;");
|
||||||
fwrite ($fp, "NDI\n");
|
fwrite ($fp, "NDI\n");
|
||||||
|
|
||||||
$ligneids = array();
|
$this->ligneids = array();
|
||||||
|
|
||||||
$sqlall = "SELECT s.nom, s.idp as socid, l.ligne, l.statut, l.rowid";
|
$sqlall = "SELECT s.nom, s.idp as socid, l.ligne, l.statut, l.rowid";
|
||||||
$sqlall .= " , comm.name, comm.firstname";
|
$sqlall .= " , comm.name, comm.firstname";
|
||||||
@ -167,7 +152,7 @@ class CommandeMethodeText
|
|||||||
$sqlall .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid";
|
$sqlall .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid";
|
||||||
|
|
||||||
$sqlall .= " AND l.fk_commercial = comm.rowid ";
|
$sqlall .= " AND l.fk_commercial = comm.rowid ";
|
||||||
$sqlall .= " AND f.rowid =".$this->fournisseur->id;
|
$sqlall .= " AND f.rowid =".$this->fourn->id;
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -192,14 +177,14 @@ class CommandeMethodeText
|
|||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->fetch($obj->socid);
|
$soc->fetch($obj->socid);
|
||||||
|
|
||||||
fwrite ($fp, $this->fournisseur->num_client);
|
fwrite ($fp, $this->fourn->num_client);
|
||||||
fwrite ($fp, ";");
|
fwrite ($fp, ";");
|
||||||
fwrite ($fp, $obj->nom);
|
fwrite ($fp, $obj->nom);
|
||||||
fwrite ($fp, ";");
|
fwrite ($fp, ";");
|
||||||
fwrite ($fp, $obj->ligne);
|
fwrite ($fp, $obj->ligne);
|
||||||
fwrite ($fp, "\n");
|
fwrite ($fp, "\n");
|
||||||
|
|
||||||
array_push($ligneids, $obj->rowid);
|
array_push($this->ligneids, $obj->rowid);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
@ -218,7 +203,7 @@ class CommandeMethodeText
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach ($ligneids as $lid)
|
foreach ($this->ligneids as $lid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$lint = new LigneTel($this->db);
|
$lint = new LigneTel($this->db);
|
||||||
|
|||||||
@ -23,10 +23,11 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
require_once DOL_DOCUMENT_ROOT."/lib/dolibarrmail.class.php";
|
||||||
|
require_once DOL_DOCUMENT_ROOT."/telephonie/fournisseur/commande/methode.commande.class.php";
|
||||||
|
|
||||||
define ('COMMANDETEXT_NOEMAIL', -3);
|
define ('COMMANDETEXT_NOEMAIL', -3);
|
||||||
|
|
||||||
class CommandeMethodeTextP
|
class CommandeMethodeTextP extends CommandeMethode
|
||||||
{
|
{
|
||||||
|
|
||||||
function CommandeMethodeTextP ($DB, $USER=0, $fourn=0)
|
function CommandeMethodeTextP ($DB, $USER=0, $fourn=0)
|
||||||
@ -34,7 +35,7 @@ class CommandeMethodeTextP
|
|||||||
$this->nom = "Méthode texte, variante sur le nom de fichier";
|
$this->nom = "Méthode texte, variante sur le nom de fichier";
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
$this->user = $USER;
|
$this->user = $USER;
|
||||||
$this->fournisseur = $fourn;
|
$this->fourn = $fourn;
|
||||||
}
|
}
|
||||||
|
|
||||||
function info()
|
function info()
|
||||||
@ -48,9 +49,11 @@ class CommandeMethodeTextP
|
|||||||
|
|
||||||
$this->datef = "ndi-premium-".strftime("%d%b%y-%HH%M", $this->date);
|
$this->datef = "ndi-premium-".strftime("%d%b%y-%HH%M", $this->date);
|
||||||
|
|
||||||
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->datef.".txt";
|
$this->filename = $this->datef.".txt";
|
||||||
|
|
||||||
if (strlen(trim($this->fournisseur->email_commande)) == 0)
|
$fname = DOL_DATA_ROOT ."/telephonie/ligne/commande/".$this->filename;
|
||||||
|
|
||||||
|
if (strlen(trim($this->fourn->email_commande)) == 0)
|
||||||
{
|
{
|
||||||
return -3;
|
return -3;
|
||||||
}
|
}
|
||||||
@ -78,25 +81,13 @@ class CommandeMethodeTextP
|
|||||||
*/
|
*/
|
||||||
function MailFile($filename)
|
function MailFile($filename)
|
||||||
{
|
{
|
||||||
$sql = "SELECT l.ligne";
|
$subject = "Commande de Lignes N° ".$this->commande_id;
|
||||||
$sql .= " FROM ".MAIN_DB_PREFIX."telephonie_societe_ligne as l";
|
|
||||||
$sql .= " WHERE l.statut = 2";
|
|
||||||
$sql .= " AND l.fk_fournisseur =".$this->fournisseur->id;
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$sendto = $this->fourn->email_commande;
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
$num = $this->db->num_rows();
|
|
||||||
}
|
|
||||||
|
|
||||||
$subject = "Commande de Lignes";
|
|
||||||
|
|
||||||
$sendto = $this->fournisseur->email_commande;
|
|
||||||
|
|
||||||
$from = TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC;
|
$from = TELEPHONIE_LIGNE_COMMANDE_EMAIL_BCC;
|
||||||
|
|
||||||
$message = "Bonjour,\n\nVeuillez trouver ci-joint notre dernière commande.\n\n";
|
$message = "Bonjour,\n\nVeuillez trouver ci-joint notre commande numéro : ".$this->commande_id.".\n\n";
|
||||||
$message .= "\n\nCordialement,\n\n";
|
$message .= "\n\nCordialement,\n\n";
|
||||||
|
|
||||||
$message .= "-- \n";
|
$message .= "-- \n";
|
||||||
@ -120,25 +111,7 @@ class CommandeMethodeTextP
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function LogSql()
|
|
||||||
{
|
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_commande";
|
|
||||||
$sql .= " (datec, fk_user_creat, fk_fournisseur, filename)";
|
|
||||||
$sql .= " VALUES (now(),".$this->user->id.",".$this->fournisseur->id.",'".$this->datef.".txt')";
|
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
|
||||||
|
|
||||||
if ($result)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* Creation du fichier
|
* Creation du fichier
|
||||||
*
|
*
|
||||||
@ -154,7 +127,7 @@ class CommandeMethodeTextP
|
|||||||
fwrite ($fp, "nomclient;");
|
fwrite ($fp, "nomclient;");
|
||||||
fwrite ($fp, "NDI\n");
|
fwrite ($fp, "NDI\n");
|
||||||
|
|
||||||
$ligneids = array();
|
$this->ligneids = array();
|
||||||
|
|
||||||
$sqlall = "SELECT s.nom, s.idp as socid, l.ligne, l.statut, l.rowid";
|
$sqlall = "SELECT s.nom, s.idp as socid, l.ligne, l.statut, l.rowid";
|
||||||
$sqlall .= " , comm.name, comm.firstname";
|
$sqlall .= " , comm.name, comm.firstname";
|
||||||
@ -167,7 +140,7 @@ class CommandeMethodeTextP
|
|||||||
$sqlall .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid";
|
$sqlall .= " WHERE l.fk_soc = s.idp AND l.fk_fournisseur = f.rowid";
|
||||||
|
|
||||||
$sqlall .= " AND l.fk_commercial = comm.rowid ";
|
$sqlall .= " AND l.fk_commercial = comm.rowid ";
|
||||||
$sqlall .= " AND f.rowid =".$this->fournisseur->id;
|
$sqlall .= " AND f.rowid =".$this->fourn->id;
|
||||||
/*
|
/*
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
@ -176,35 +149,35 @@ class CommandeMethodeTextP
|
|||||||
$sql .= " AND l.statut in (1,4)";
|
$sql .= " AND l.statut in (1,4)";
|
||||||
$sql .= " ORDER BY l.statut ASC";
|
$sql .= " ORDER BY l.statut ASC";
|
||||||
|
|
||||||
$result = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($resql)
|
||||||
{
|
{
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$num = $this->db->num_rows();
|
$num = $this->db->num_rows($resql);
|
||||||
|
|
||||||
while ($i < $num)
|
while ($i < $num)
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object();
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
if (strlen($obj->ligne)== 10)
|
if (strlen($obj->ligne)== 10)
|
||||||
{
|
{
|
||||||
$soc = new Societe($this->db);
|
$soc = new Societe($this->db);
|
||||||
$soc->fetch($obj->socid);
|
$soc->fetch($obj->socid);
|
||||||
|
|
||||||
fwrite ($fp, $this->fournisseur->num_client);
|
fwrite ($fp, $this->fourn->num_client);
|
||||||
fwrite ($fp, ";");
|
fwrite ($fp, ";");
|
||||||
fwrite ($fp, $obj->nom);
|
fwrite ($fp, $obj->nom);
|
||||||
fwrite ($fp, ";");
|
fwrite ($fp, ";");
|
||||||
fwrite ($fp, $obj->ligne);
|
fwrite ($fp, $obj->ligne);
|
||||||
fwrite ($fp, "\n");
|
fwrite ($fp, "\n");
|
||||||
|
|
||||||
array_push($ligneids, $obj->rowid);
|
array_push($this->ligneids, $obj->rowid);
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free();
|
$this->db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -218,7 +191,7 @@ class CommandeMethodeTextP
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
foreach ($ligneids as $lid)
|
foreach ($this->ligneids as $lid)
|
||||||
{
|
{
|
||||||
|
|
||||||
$lint = new LigneTel($this->db);
|
$lint = new LigneTel($this->db);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user