43 |
* Calcul le coût de la communication |
* Calcul le coût de la communication |
44 |
* |
* |
45 |
*/ |
*/ |
46 |
function cout($tarif_achat, $tarif_vente, $ligne) |
function cout($tarif_achat, $tarif_vente, $ligne, $_db) |
47 |
{ |
{ |
48 |
$error = 0; |
$error = 0; |
49 |
|
|
66 |
|
|
67 |
$this->remise = $ligne->remise; |
$this->remise = $ligne->remise; |
68 |
} |
} |
69 |
elseif (substr($this->numero,0,4) == substr($objp->client,0,4) ) /* Tarif Local */ |
/* Tarif Local */ |
70 |
|
/* |
71 |
|
elseif (substr($this->numero,0,4) == substr($objp->client,0,4) ) |
72 |
{ |
{ |
73 |
$dureenat += $objp->duree; |
$dureenat += $objp->duree; |
74 |
$nbnat++; |
$nbnat++; |
|
|
|
75 |
$num = "0033999".substr($this->numero, 1); |
$num = "0033999".substr($this->numero, 1); |
|
|
|
76 |
$this->remise = $ligne->remise; |
$this->remise = $ligne->remise; |
77 |
} |
}*/ |
78 |
else |
else |
79 |
{ |
{ |
80 |
$dureenat += $objp->duree; |
$dureenat += $objp->duree; |
88 |
/* |
/* |
89 |
* |
* |
90 |
* |
* |
91 |
*/ |
*/ |
92 |
|
/* Numéros spéciaux */ |
93 |
if (! $tarif_achat->cout($num, $this->cout_temp_achat, $this->cout_fixe_achat, $tarif_libelle_achat)) |
if (substr($num,4,1) == 8) |
94 |
{ |
{ |
95 |
print "3- Tarif achat manquant pour $num\n"; |
$this->remise = 0; |
96 |
dolibarr_syslog("CommunicationTelephonique::Cout Tarif achat manquant pour $num"); |
$this->cout_temp_vente = 0; |
97 |
$error++; |
$this->tarif_libelle_vente = "Numéros spéciaux"; |
98 |
|
$this->cout_fixe_vente = ereg_replace(",",".", $this->montant); |
99 |
} |
} |
100 |
|
else |
|
if (! $tarif_vente->cout($num, $this->cout_temp_vente, $this->cout_fixe_vente, $this->tarif_libelle_vente)) |
|
101 |
{ |
{ |
102 |
print "3- Tarif vente manquant pour $num\n"; |
/* Fin Numéros spéciaux */ |
103 |
dolibarr_syslog("CommunicationTelephonique::Cout Tarif vente manquant pour $num"); |
if (! $tarif_achat->cout($num, $this->cout_temp_achat, $this->cout_fixe_achat, $tarif_libelle_achat)) |
104 |
$error++; |
{ |
105 |
|
print "3- Tarif achat manquant pour $num\n"; |
106 |
|
dolibarr_syslog("CommunicationTelephonique::Cout Tarif achat manquant pour $num"); |
107 |
|
$error++; |
108 |
|
} |
109 |
|
|
110 |
|
if (! $tarif_vente->cout($num, $this->cout_temp_vente, $this->cout_fixe_vente, $this->tarif_libelle_vente)) |
111 |
|
{ |
112 |
|
print "3- Tarif vente manquant pour $num\n"; |
113 |
|
dolibarr_syslog("CommunicationTelephonique::Cout Tarif vente manquant pour $num"); |
114 |
|
$error++; |
115 |
|
} |
116 |
|
} |
117 |
|
/* Specification VoIP */ |
118 |
|
if ($ligne->techno == 'voip') |
119 |
|
{ |
120 |
|
if (substr($num,4,1) < 6) |
121 |
|
{ |
122 |
|
$lignedest = new LigneTel($_db); |
123 |
|
|
124 |
|
if ($lignedest->fetch("0".substr($num, -9)) == 1) |
125 |
|
{ |
126 |
|
if ($lignedest->techno == 'voip' && ($ligne->client_comm_id == $lignedest->client_comm_id)) |
127 |
|
{ |
128 |
|
$this->remise = 0; |
129 |
|
$this->cout_fixe_vente = 0; |
130 |
|
$this->cout_temp_vente = 0; |
131 |
|
$this->tarif_libelle_vente = "Appel Interne VoIP"; |
132 |
|
} |
133 |
|
} |
134 |
|
} |
135 |
} |
} |
136 |
|
/* Fin VoIP */ |
137 |
|
|
138 |
$this->cout_achat = ( ($this->duree * $this->cout_temp_achat / 60) + $this->cout_fixe_achat); |
$this->cout_achat = ( ($this->duree * $this->cout_temp_achat / 60) + $this->cout_fixe_achat); |
139 |
|
|
166 |
$this->cout_achat = ereg_replace(",",".", $this->cout_achat); |
$this->cout_achat = ereg_replace(",",".", $this->cout_achat); |
167 |
$this->cout_vente = ereg_replace(",",".", $this->cout_vente); |
$this->cout_vente = ereg_replace(",",".", $this->cout_vente); |
168 |
$this->remise = ereg_replace(",",".", $this->remise); |
$this->remise = ereg_replace(",",".", $this->remise); |
169 |
$this->montant = ereg_replace(",",".", $this->montant); |
$this->montant = ereg_replace(",",".", $this->montant); |
170 |
|
|
171 |
$this->dateheure = mktime(substr($this->heure, 0,2), |
$this->dateheure = mktime(substr($this->heure, 0,2), |
172 |
substr($this->heure, 3,2), |
substr($this->heure, 3,2), |