A lot of fix on point of sale module

This commit is contained in:
Laurent Destailleur 2009-10-22 00:36:21 +00:00
parent 3cb6df16fd
commit 538736bedb
2 changed files with 159 additions and 132 deletions

View File

@ -54,6 +54,15 @@ else
define('LOG_INFO',6); define('LOG_INFO',6);
define('LOG_DEBUG',7); define('LOG_DEBUG',7);
} }
// Definition of missing functions
if (! function_exists("preg_replace"))
{
function preg_replace($a,$b,$c)
{
}
}
// Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL) // Forcage du parametrage PHP error_reporting (Dolibarr non utilisable en mode error E_ALL)
error_reporting(E_ALL ^ E_NOTICE); error_reporting(E_ALL ^ E_NOTICE);
@ -80,15 +89,16 @@ if (empty($dolibarr_main_data_root))
$dolibarr_main_data_root=str_replace("/htdocs","",$dolibarr_main_document_root); $dolibarr_main_data_root=str_replace("/htdocs","",$dolibarr_main_document_root);
$dolibarr_main_data_root.="/documents"; $dolibarr_main_data_root.="/documents";
} }
// Define some constants // Define some constants
define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem pages php (htdocs) define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem pages php (htdocs)
define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem donnes (documents) define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem donnes (documents)
if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! empty($_SERVER["SCRIPT_URI"])) if ($dolibarr_main_url_root == 'auto' && ! empty($_SERVER["SCRIPT_URL"]) && ! empty($_SERVER["SCRIPT_URI"]))
{ {
$dolibarr_main_url_root=preg_replace('/'.$_SERVER["SCRIPT_URL"].'$/i','',$_SERVER["SCRIPT_URI"]); $dolibarr_main_url_root=str_replace($_SERVER["SCRIPT_URL"],'',$_SERVER["SCRIPT_URI"]);
} }
define('DOL_MAIN_URL_ROOT', $dolibarr_main_url_root); // URL relative root define('DOL_MAIN_URL_ROOT', $dolibarr_main_url_root); // URL relative root
$uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); // $suburi contains url without http* $uri=preg_replace('/^http(s?):\/\//i','',$dolibarr_main_url_root); // $uri contains url without http*
$suburi = strstr ($uri, '/'); // $suburi contains url without domain $suburi = strstr ($uri, '/'); // $suburi contains url without domain
if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now '' if ($suburi == '/') $suburi = ''; // If $suburi is /, it is now ''
define('DOL_URL_ROOT', $suburi); // URL relative root ('/', '/dolibarr', ...) define('DOL_URL_ROOT', $suburi); // URL relative root ('/', '/dolibarr', ...)
@ -96,8 +106,9 @@ if (! empty($dolibarr_main_url_root_static)) define('DOL_URL_ROOT_FULL_STATIC',
/* /*
* Controle validite fichier conf * Include functions
*/ */
if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php")) if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"))
{ {
print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n"; print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
@ -105,13 +116,9 @@ if (! file_exists(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"))
exit; exit;
} }
/*
* Create $conf object
*/
require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2) require_once(DOL_DOCUMENT_ROOT ."/lib/functions.lib.php"); // Need 970ko memory (1.1 in 2.2)
// If password is encoded, we decode it // If password is encoded, we decode it
if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass)) if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_db_encrypted_pass))
{ {
@ -126,6 +133,11 @@ if (preg_match('/crypted:/i',$dolibarr_main_db_pass) || ! empty($dolibarr_main_d
} }
//print memory_get_usage(); //print memory_get_usage();
/*
* Create $conf object
*/
require_once(DOL_DOCUMENT_ROOT."/core/conf.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/conf.class.php");
$conf = new Conf(); $conf = new Conf();
@ -408,4 +420,19 @@ if (! defined('MAGPIE_CACHE_DIR')) { define('MAGPIE_CACHE_DIR', $conf->exte
if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR'); if (! defined('MAIN_LABEL_MENTION_NPR') ) define('MAIN_LABEL_MENTION_NPR','NPR');
/**
* Convert a string into a regex
*
* @param unknown_type $s string to convert
*/
function dol_regify($s)
{
$news=str_replace('/','\/',$s);
$news=str_replace('.','\.',$news);
$news=str_replace('*','\*',$news);
return $news;
}
?> ?>

View File

@ -24,12 +24,12 @@
\brief Fichier de la classe des paiement de factures clients \brief Fichier de la classe des paiement de factures clients
\remarks Cette classe est presque identique a paiementfourn.class.php \remarks Cette classe est presque identique a paiementfourn.class.php
\version $Id$ \version $Id$
*/ */
/** \class Paiement /** \class Paiement
\brief Classe permettant la gestion des paiements des factures clients \brief Classe permettant la gestion des paiements des factures clients
*/ */
class Paiement class Paiement
{ {
@ -88,6 +88,7 @@ class Paiement
$this->id = $obj->rowid; $this->id = $obj->rowid;
$this->ref = $obj->rowid; $this->ref = $obj->rowid;
$this->date = $obj->dp; $this->date = $obj->dp;
$this->datepaye = $obj->dp;
$this->numero = $obj->num_paiement; $this->numero = $obj->num_paiement;
$this->bank_account = $obj->fk_account; $this->bank_account = $obj->fk_account;
$this->bank_line = $obj->fk_bank; $this->bank_line = $obj->fk_bank;
@ -114,9 +115,9 @@ class Paiement
} }
/** /**
* \brief Creation du paiement en base * \brief Create payment in database
* \param user object utilisateur qui cree * \param user object user
* \return int id du paiement cree, < 0 si erreur * \return int id of created payment, < 0 if error
*/ */
function create($user) function create($user)
{ {
@ -124,14 +125,13 @@ class Paiement
$error = 0; $error = 0;
// Nettoyage parametres // Clean parameters
$this->total = 0; $this->total = 0;
foreach ($this->amounts as $key => $value) foreach ($this->amounts as $key => $value) // How payment is dispatch
{ {
$value = price2num($value); $value = price2num($value,'MT');
$val = round($value, 2); $this->amounts[$key] = $value;
$this->amounts[$key] = $val; $this->total += $value;
$this->total += $val;
} }
$this->total = price2num($this->total); $this->total = price2num($this->total);
@ -157,7 +157,7 @@ class Paiement
{ {
$amount = price2num($amount); $amount = price2num($amount);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)'; $sql = 'INSERT INTO '.MAIN_DB_PREFIX.'paiement_facture (fk_facture, fk_paiement, amount)';
$sql .= ' VALUES ('.$facid.','. $this->id.',\''.$amount.'\')'; $sql .= ' VALUES ('.$facid.', '. $this->id.', \''.$amount.'\')';
dol_syslog("Paiement::Create insert paiement_facture sql=".$sql); dol_syslog("Paiement::Create insert paiement_facture sql=".$sql);
$resql=$this->db->query($sql); $resql=$this->db->query($sql);
@ -170,7 +170,7 @@ class Paiement
} }
else else
{ {
dol_syslog('Paiement::Create Montant non numérique'); dol_syslog('Paiement::Create Montant non numerique');
} }
} }