Reorganize code to reduce memory usage
This commit is contained in:
parent
52c0edeaca
commit
d433c7120f
@ -34,6 +34,7 @@
|
|||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/commonobject.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/cotisation.class.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
require("./pre.inc.php");
|
require("./pre.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/member.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_type.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/adherents/adherent_options.class.php");
|
||||||
@ -864,11 +865,11 @@ if ($rowid && $action != 'edit')
|
|||||||
{
|
{
|
||||||
if ($adh->societe) $name.=' ('.$adh->societe.')';
|
if ($adh->societe) $name.=' ('.$adh->societe.')';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$name=$adh->societe;
|
$name=$adh->societe;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a form array
|
// Create a form array
|
||||||
$formquestion=array(
|
$formquestion=array(
|
||||||
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
|
array('label' => $langs->trans("NameToCreate"), 'type' => 'text', 'name' => 'companyname', 'value' => $name));
|
||||||
@ -1038,7 +1039,7 @@ if ($rowid && $action != 'edit')
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Other attributs
|
// Other attributs
|
||||||
foreach($adho->attribute_label as $key=>$value)
|
foreach($adho->attribute_label as $key=>$value)
|
||||||
{
|
{
|
||||||
@ -1144,7 +1145,7 @@ if ($rowid && $action != 'edit')
|
|||||||
print "<font class=\"butActionRefused\" href=\"#\">".$langs->trans("CreateDolibarrThirdParty")."</font>";
|
print "<font class=\"butActionRefused\" href=\"#\">".$langs->trans("CreateDolibarrThirdParty")."</font>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Supprimer
|
// Supprimer
|
||||||
if ($user->rights->adherent->supprimer)
|
if ($user->rights->adherent->supprimer)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
include_once DOL_DOCUMENT_ROOT.'/includes/modules/mailings/modules_mailings.php';
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -36,45 +36,6 @@ if (! defined('DOL_DOCUMENT_ROOT')) define('DOL_DOCUMENT_ROOT', '..');
|
|||||||
if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/adodbtime/adodb-time.inc.php");
|
if (! defined('ADODB_DATE_VERSION')) include_once(DOL_DOCUMENT_ROOT."/includes/adodbtime/adodb-time.inc.php");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Return true if email syntax is ok
|
|
||||||
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
|
||||||
* \return boolean true if email ok, false if ko
|
|
||||||
*/
|
|
||||||
function ValidEmail($address)
|
|
||||||
{
|
|
||||||
if (eregi(".*<(.+)>", $address, $regs)) {
|
|
||||||
$address = $regs[1];
|
|
||||||
}
|
|
||||||
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
|
|
||||||
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
|
||||||
* \return boolean true si email valide, false sinon
|
|
||||||
*/
|
|
||||||
function check_mail($mail)
|
|
||||||
{
|
|
||||||
list($user, $domain) = split("@", $mail, 2);
|
|
||||||
if (checkdnsrr($domain, "MX"))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Clean a string to use it as a file name.
|
* \brief Clean a string to use it as a file name.
|
||||||
* \param str String to clean
|
* \param str String to clean
|
||||||
@ -739,8 +700,6 @@ function dol_print_email($email,$cid=0,$socid=0,$addlink=0,$max=64)
|
|||||||
|
|
||||||
if (empty($email)) return ' ';
|
if (empty($email)) return ' ';
|
||||||
|
|
||||||
if (! ValidEmail($email)) return "Bad email";
|
|
||||||
|
|
||||||
if (! empty($addlink))
|
if (! empty($addlink))
|
||||||
{
|
{
|
||||||
$newemail='<a href="';
|
$newemail='<a href="';
|
||||||
|
|||||||
@ -26,6 +26,44 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Return true if email syntax is ok
|
||||||
|
* \param address email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
||||||
|
* \return boolean true if email ok, false if ko
|
||||||
|
*/
|
||||||
|
function ValidEmail($address)
|
||||||
|
{
|
||||||
|
if (eregi(".*<(.+)>", $address, $regs)) {
|
||||||
|
$address = $regs[1];
|
||||||
|
}
|
||||||
|
if (eregi("^[^@ ]+@([a-zA-Z0-9\-]+\.)+([a-zA-Z0-9\-]{2}|asso|aero|biz|com|coop|edu|gov|info|int|mil|name|net|org|pro)\$",$address))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Renvoi vrai si l'email a un nom de domaine qui r<EFBFBD>soud via dns
|
||||||
|
* \param mail adresse email (Ex: "toto@titi.com", "John Do <johndo@titi.com>")
|
||||||
|
* \return boolean true si email valide, false sinon
|
||||||
|
*/
|
||||||
|
function CheckMailDomain($mail)
|
||||||
|
{
|
||||||
|
list($user, $domain) = split("@", $mail, 2);
|
||||||
|
if (checkdnsrr($domain, "MX"))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Return lines of an html table from an array
|
* \brief Return lines of an html table from an array
|
||||||
* \remarks Used by array2table function only
|
* \remarks Used by array2table function only
|
||||||
|
|||||||
@ -28,6 +28,7 @@
|
|||||||
require("../../master.inc.php");
|
require("../../master.inc.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/paybox/paybox.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
require_once(DOL_DOCUMENT_ROOT."/lib/company.lib.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/product.class.php");
|
||||||
|
|
||||||
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);
|
$langcode=(empty($_GET["lang"])?'auto':$_GET["lang"]);
|
||||||
|
|||||||
@ -17,28 +17,24 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
*
|
|
||||||
* $Id$
|
|
||||||
* $Source$
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
\file htdocs/telephonie/client/new.php
|
\file htdocs/telephonie/client/new.php
|
||||||
\ingroup telephonie
|
\ingroup telephonie
|
||||||
\brief Creation d'un nouveau client
|
\brief Creation d'un nouveau client
|
||||||
\version $Revision$
|
\version $Id$
|
||||||
*/
|
*/
|
||||||
|
|
||||||
require("pre.inc.php");
|
require("pre.inc.php");
|
||||||
|
require_once(DOL_DOCUMENT_ROOT."/lib/functions2.lib.php");
|
||||||
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
|
|
||||||
|
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
|
||||||
require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php');
|
require_once(DOL_DOCUMENT_ROOT.'/companybankaccount.class.php');
|
||||||
require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/telephonie/lignetel.class.php");
|
||||||
require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
|
require_once(DOL_DOCUMENT_ROOT."/telephonie/telephonie.contrat.class.php");
|
||||||
|
|
||||||
|
if (!$user->rights->telephonie->ligne->creer) accessforbidden();
|
||||||
|
|
||||||
$user->getrights('societe');
|
$user->getrights('societe');
|
||||||
$langs->load("companies");
|
$langs->load("companies");
|
||||||
|
|
||||||
@ -143,7 +139,7 @@ if ($_POST["action"] == 'add')
|
|||||||
$verif = "nok";
|
$verif = "nok";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!check_mail(trim($contact->email)) && $verif == 'ok')
|
if (!CheckMailDomain(trim($contact->email)) && $verif == 'ok')
|
||||||
{
|
{
|
||||||
$mesg = "Email invalide (domaine invalide)";
|
$mesg = "Email invalide (domaine invalide)";
|
||||||
$verif = "nok";
|
$verif = "nok";
|
||||||
@ -248,7 +244,7 @@ if ($_POST["action"] == 'add')
|
|||||||
$verif = "nok";
|
$verif = "nok";
|
||||||
$mesg .= "Tarif France Invalide : $temporel > 0.04 !";
|
$mesg .= "Tarif France Invalide : $temporel > 0.04 !";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($temporel < 0.016 )
|
if ($temporel < 0.016 )
|
||||||
{
|
{
|
||||||
$error = 1031;
|
$error = 1031;
|
||||||
@ -396,7 +392,7 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -431,7 +427,7 @@ if ($_POST["action"] == 'add')
|
|||||||
$ligne->concurrent = $_POST["concurrent"];
|
$ligne->concurrent = $_POST["concurrent"];
|
||||||
$ligne->remise = "0";
|
$ligne->remise = "0";
|
||||||
$ligne->note = $_POST["note"];
|
$ligne->note = $_POST["note"];
|
||||||
|
|
||||||
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -469,7 +465,7 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -501,7 +497,7 @@ if ($_POST["action"] == 'add')
|
|||||||
|
|
||||||
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
if ( $ligne->create($user, $_POST["mode_paiement"]) == 0)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -562,25 +558,25 @@ if ($_POST["action"] == 'add')
|
|||||||
if (!$error)
|
if (!$error)
|
||||||
{
|
{
|
||||||
$db->begin();
|
$db->begin();
|
||||||
|
|
||||||
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
|
$sql = "REPLACE INTO ".MAIN_DB_PREFIX."telephonie_tarif_client";
|
||||||
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
|
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user) VALUES ";
|
||||||
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")";
|
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.")";
|
||||||
|
|
||||||
if (! $db->query($sql) )
|
if (! $db->query($sql) )
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."telephonie_tarif_client_log";
|
||||||
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
|
$sql .= " (fk_tarif, fk_client, temporel, fixe, fk_user, datec) VALUES ";
|
||||||
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())";
|
$sql .= " (".$mobil_id.",".$soc->id.",'".$temporel."','0',".$user->id.",now())";
|
||||||
|
|
||||||
if (! $db->query($sql) )
|
if (! $db->query($sql) )
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $error == 0 )
|
if ( $error == 0 )
|
||||||
{
|
{
|
||||||
$db->commit();
|
$db->commit();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user