forked from Wavyzz/dolibarr
Fix: Gestion transaction sur commande
Qual: Ajout des methode fetch sur les lignes commandes, facture, propale New: Debut script migration pour alimenter de maniere retroactive les champs total_ht, total_tva, total_ttc au niveau lignes
This commit is contained in:
@@ -326,19 +326,26 @@ class Commande
|
||||
// Nettoyage parametres
|
||||
$this->brouillon = 1; // On positionne en mode brouillon la commande
|
||||
|
||||
dolibarr_syslog("Commande.class.php::create");
|
||||
|
||||
// V<>rification param<61>tres
|
||||
if ($this->source < 0)
|
||||
{
|
||||
$this->error=$langs->trans("ErrorFieldRequired",$langs->trans("Source"));
|
||||
dolibarr_syslog("Commande.class.php::create ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
if (! $remise) $remise=0;
|
||||
if (! $this->projetid) $this->projetid = 0;
|
||||
|
||||
dolibarr_syslog("Commande.class.php::create");
|
||||
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socidp);
|
||||
$result=$soc->fetch($this->soc_id);
|
||||
if ($result < 0)
|
||||
{
|
||||
$this->error="Failed to fetch company";
|
||||
dolibarr_syslog("Commande.class.php::create ".$this->error);
|
||||
return -2;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@@ -356,6 +363,8 @@ class Commande
|
||||
$sql.= " '".$this->remise_absolue."',";
|
||||
$sql.= " '".$this->remise_percent."')";
|
||||
|
||||
dolibarr_syslog("Commande.class.php::create sql=".$sql);
|
||||
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -407,10 +416,12 @@ class Commande
|
||||
$this->db->query($sql);
|
||||
}
|
||||
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -418,7 +429,8 @@ class Commande
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return 0;
|
||||
$this->db->rollback();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,7 +453,7 @@ class Commande
|
||||
*/
|
||||
function addline($commandeid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0)
|
||||
{
|
||||
dolibarr_syslog("commande.class.php::addline $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
||||
dolibarr_syslog("commande.class.php::addline this->id=$this->id, $commandeid, $desc, $pu, $qty, $txtva, $fk_product, $remise_percent");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
if ($this->statut == 0)
|
||||
@@ -677,8 +689,8 @@ class Commande
|
||||
}
|
||||
|
||||
/**
|
||||
* Lit une commande
|
||||
*
|
||||
* \brief Recup<75>re de la base les caract<63>ristiques d'une commande
|
||||
* \param rowid id de la commande <20> r<>cup<75>rer
|
||||
*/
|
||||
function fetch($id)
|
||||
{
|
||||
@@ -688,10 +700,14 @@ class Commande
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
|
||||
$sql.= ' WHERE c.rowid = '.$id;
|
||||
|
||||
dolibarr_syslog("Commande::fetch sql=$sql");
|
||||
|
||||
$result = $this->db->query($sql) ;
|
||||
if ($result)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
if ($obj)
|
||||
{
|
||||
$this->id = $obj->rowid;
|
||||
$this->ref = $obj->ref;
|
||||
$this->ref_client = $obj->ref_client;
|
||||
@@ -751,9 +767,9 @@ class Commande
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->statut == 0)
|
||||
$this->brouillon = 1;
|
||||
// exp pdf -----------
|
||||
if ($this->statut == 0) $this->brouillon = 1;
|
||||
|
||||
// \todo Utiliser la classe CommandeLigne au lieu de ce code
|
||||
$this->lignes = array();
|
||||
$sql = 'SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice, l.coef,';
|
||||
$sql.= ' p.label, p.description as product_desc, p.ref, p.fk_product_type, p.rowid as prodid';
|
||||
@@ -795,7 +811,8 @@ class Commande
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_syslog("Propal::Fetch Erreur lecture des produits");
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Commande::Fetch Erreur sql=$sql, ".$this->error);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -824,18 +841,24 @@ class Commande
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Order not found";
|
||||
return -2;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
return -1;
|
||||
return -3;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
function set_pdf_model($user, $modelpdf)
|
||||
{
|
||||
if ($user->rights->commande->creer)
|
||||
@@ -2103,9 +2126,53 @@ class CommandeLigne
|
||||
var $product_desc; // Description produit
|
||||
var $ref; // Reference produit
|
||||
|
||||
function CommandeLigne()
|
||||
/**
|
||||
* \brief Constructeur d'objets ligne de commande
|
||||
* \param DB handler d'acc<63>s base de donn<6E>e
|
||||
*/
|
||||
function CommandeLigne($DB)
|
||||
{
|
||||
$this->db= $DB ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recup<75>re l'objet ligne de commande
|
||||
* \param rowid id de la ligne de commande
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT fk_commande, fk_product, description, price, qty, rowid, tva_tx,';
|
||||
$sql.= ' label,';
|
||||
$sql.= ' remise, remise_percent, fk_remise_except, subprice,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc, coef, rang';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet WHERE rowid = '.$rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->fk_propal = $objp->fk_propal;
|
||||
$this->label = $objp->label;
|
||||
$this->desc = $objp->description;
|
||||
$this->qty = $objp->qty;
|
||||
$this->price = $objp->price;
|
||||
$this->subprice = $objp->subprice;
|
||||
$this->tva_taux = $objp->tva_taux;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
$this->produit_id = $objp->fk_product;
|
||||
$this->info_bits = $objp->info_bits;
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->coef = $objp->coef;
|
||||
$this->rang = $objp->rang;
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -202,6 +202,11 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
|
||||
{
|
||||
$commande = new Commande($db);
|
||||
$ret=$commande->fetch($_POST['id']);
|
||||
if ($ret < 0)
|
||||
{
|
||||
dolibarr_print_error($db,$commande->error);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Ecrase $pu par celui du produit
|
||||
// Ecrase $desc par celui du produit
|
||||
|
||||
@@ -2413,25 +2413,28 @@ class FactureLigne
|
||||
/**
|
||||
* \brief Recup<75>re l'objet ligne de facture
|
||||
* \param rowid id de la ligne de facture
|
||||
* \param societe_id id de la societe
|
||||
*/
|
||||
function fetch($rowid, $societe_id=0)
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT fk_product, description, price, qty, rowid, tva_taux, remise, remise_percent,';
|
||||
$sql.= ' subprice, '.$this->db->pdate('date_start').' as date_start,'.$this->db->pdate('date_end').' as date_end,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc';
|
||||
$sql = 'SELECT fk_facture, fk_product, description, price, qty, rowid, tva_taux,';
|
||||
$sql.= ' remise, remise_percent, fk_remise_except, subprice,';
|
||||
$sql.= ' '.$this->db->pdate('date_start').' as date_start,'.$this->db->pdate('date_end').' as date_end,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc, rang,';
|
||||
$sql.= ' fk_code_ventilation, fk_export_compta';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet WHERE rowid = '.$rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->desc = stripslashes($objp->description);
|
||||
$this->fk_facture = $objp->fk_facture;
|
||||
$this->desc = $objp->description;
|
||||
$this->qty = $objp->qty;
|
||||
$this->price = $objp->price;
|
||||
$this->subprice = $objp->subprice;
|
||||
$this->tva_taux = $objp->tva_taux;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
$this->produit_id = $objp->fk_product;
|
||||
$this->date_start = $objp->date_start;
|
||||
$this->date_end = $objp->date_end;
|
||||
@@ -2439,6 +2442,9 @@ class FactureLigne
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->fk_code_ventilation = $objp->fk_code_ventilation;
|
||||
$this->fk_export_compta = $objp->fk_export_compta;
|
||||
$this->rang = $objp->rang;
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
|
||||
@@ -40,6 +40,9 @@ $langs->setDefaultLang($setuplang);
|
||||
$langs->load("install");
|
||||
|
||||
|
||||
dolibarr_install_syslog("Dolibarr install/upgrade process started");
|
||||
|
||||
|
||||
pHeader($langs->trans("DolibarrWelcome"),""); // Etape suivante = license
|
||||
|
||||
print $langs->trans("InstallEasy")."<br>";
|
||||
|
||||
@@ -36,6 +36,10 @@ $langs->setDefaultLang($setuplang);
|
||||
$langs->load("admin");
|
||||
$langs->load("install");
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering etape5.php page");
|
||||
|
||||
|
||||
$success=0;
|
||||
|
||||
if (file_exists($conffile))
|
||||
@@ -191,6 +195,9 @@ print $langs->trans("GoToSetupArea");
|
||||
print '</a>';
|
||||
|
||||
|
||||
dolibarr_install_syslog("Dolibarr install/setup finished");
|
||||
|
||||
|
||||
pFooter(1,$setuplang);
|
||||
|
||||
?>
|
||||
|
||||
@@ -110,18 +110,17 @@ function pFooter($nonext=0,$setuplang='')
|
||||
}
|
||||
|
||||
|
||||
function xxdolibarr_syslog($message)
|
||||
function dolibarr_install_syslog($message)
|
||||
{
|
||||
// Les fonctions syslog ne sont pas toujours install豠ou autoris褳 chez les h补rgeurs
|
||||
if (function_exists("define_syslog_variables"))
|
||||
{
|
||||
// \todo D財ctiver sous Windows (gros probl笥 m謯ire et faute de protections)
|
||||
// if (1 == 2) {
|
||||
define_syslog_variables();
|
||||
openlog("dolibarr", LOG_PID | LOG_PERROR, LOG_USER); # LOG_USER au lieu de LOG_LOCAL0 car non accept矰ar tous les php
|
||||
syslog(LOG_WARNING, $message);
|
||||
closelog();
|
||||
// }
|
||||
// Ajout user a la log
|
||||
$login='install';
|
||||
$message=sprintf("%-8s",$login)." ".$message;
|
||||
|
||||
$fileinstall="/tmp/dolibarr_install.log";
|
||||
$file=@fopen($fileinstall,"a+");
|
||||
if ($file) {
|
||||
fwrite($file,strftime("%Y-%m-%d %H:%M:%S",time())." ".$level." ".$message."\n");
|
||||
fclose($file);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -48,6 +48,9 @@ $langs->load("admin");
|
||||
$langs->load("install");
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering upgrade.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans("DatabaseMigration"),"upgrade2","upgrade");
|
||||
|
||||
|
||||
@@ -92,18 +95,20 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
{
|
||||
print "<tr><td nowrap>";
|
||||
print $langs->trans("ServerConnection")." : $dolibarr_main_db_host</td><td align=\"right\">".$langs->trans("OK")."</td></tr>";
|
||||
dolibarr_install_syslog($langs->trans("ServerConnection")." : $dolibarr_main_db_host ".$langs->trans("OK"));
|
||||
$ok = 1 ;
|
||||
}
|
||||
else
|
||||
{
|
||||
print "<tr><td>Erreur lors de la cr<63>ation de : $dolibarr_main_db_name</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
print "<tr><td>".$langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name)."</td><td align=\"right\">".$langs->trans("Error")."</td></tr>";
|
||||
dolibarr_install_syslog($langs->trans("ErrorFailedToCreateDatabase",$dolibarr_main_db_name));
|
||||
}
|
||||
|
||||
if ($ok)
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
dolibarr_syslog("Connexion r<EFBFBD>ussie <20> la base : $dolibarr_main_db_name");
|
||||
dolibarr_install_syslog("Database connection successfull : $dolibarr_main_db_name");
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -118,6 +123,7 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
$versionarray=$db->getVersionArray();
|
||||
print '<tr><td>'.$langs->trans("DatabaseVersion").'</td>';
|
||||
print '<td align="right">'.$version.'</td></tr>';
|
||||
dolibarr_install_syslog($langs->trans("DatabaseVersion")." : $version");
|
||||
//print '<td align="right">'.join('.',$versionarray).'</td></tr>';
|
||||
}
|
||||
|
||||
@@ -189,9 +195,9 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
{
|
||||
if ($sql)
|
||||
{
|
||||
// Ajout trace sur requete (eventuellement <20> commenter
|
||||
// si beaucoup de requetes)
|
||||
// Ajout trace sur requete (eventuellement <20> commenter si beaucoup de requetes)
|
||||
print('<tr><td valign="top">'.$langs->trans("Request").' '.($i+1)." sql='".$sql."'</td></tr>\n");
|
||||
dolibarr_install_syslog($langs->trans("Request").' '.($i+1)." sql='".$sql);
|
||||
|
||||
if ($db->query($sql))
|
||||
{
|
||||
@@ -219,6 +225,7 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
print '<tr><td valign="top">'.$langs->trans("Request").' '.($i+1).'</td>';
|
||||
print '<td valign="top">'.$langs->trans("Error")." ".$db->errno()." ".$sql."<br>".$db->error()."</td>";
|
||||
print '</tr>';
|
||||
dolibarr_install_syslog($langs->trans("Request").' '.($i+1)." ".$langs->trans("Error")." ".$db->errno()." ".$sql."<br>".$db->error());
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
@@ -234,10 +241,16 @@ if (! isset($_GET["action"]) || $_GET["action"] == "upgrade")
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
print '<tr><td>';
|
||||
print $langs->trans("ProcessMigrateScript").'</td><td align="right">'.$langs->trans("OK").'</td></tr>';
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right">'.$langs->trans("OK").'</td></tr>';
|
||||
$ok = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<tr><td>'.$langs->trans("ProcessMigrateScript").'</td>';
|
||||
print '<td align="right"><div class="error">'.$langs->trans("KO").'</div></td></tr>';
|
||||
$ok = 0;
|
||||
}
|
||||
}
|
||||
|
||||
print '</table>';
|
||||
|
||||
@@ -30,6 +30,7 @@ include_once('./inc.php');
|
||||
include_once('../facture.class.php');
|
||||
include_once('../propal.class.php');
|
||||
include_once('../commande/commande.class.php');
|
||||
include_once('../lib/price.lib.php');
|
||||
|
||||
$grant_query='';
|
||||
$etape = 2;
|
||||
@@ -52,6 +53,9 @@ $langs->load("bills");
|
||||
$langs->load("suppliers");
|
||||
|
||||
|
||||
dolibarr_install_syslog("Entering upgrade2.php page");
|
||||
|
||||
|
||||
pHeader($langs->trans('DataMigration'),'etape5','upgrade');
|
||||
|
||||
|
||||
@@ -93,7 +97,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
|
||||
$db = new DoliDb($conf->db->type,$conf->db->host,$conf->db->user,$conf->db->pass,$conf->db->name);
|
||||
if ($db->connected != 1)
|
||||
{
|
||||
print '<tr><td colspan="4">Erreur lors de la cr<63>ation de : '.$dolibarr_main_db_name.'</td><td align="right">'.$langs->trans('Error').'</td></tr>';
|
||||
print '<tr><td colspan="4">'.$langs->trans("ErrorFailedToConnectToDatabase",$dolibarr_main_db_name).'</td><td align="right">'.$langs->trans('Error').'</td></tr>';
|
||||
$error++;
|
||||
}
|
||||
|
||||
@@ -101,7 +105,7 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
|
||||
{
|
||||
if($db->database_selected == 1)
|
||||
{
|
||||
dolibarr_syslog('Connexion r<EFBFBD>ussie <20> la base : '.$dolibarr_main_db_name);
|
||||
dolibarr_install_syslog('Database connection successfull : '.$dolibarr_main_db_name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -166,18 +170,18 @@ if (isset($_POST['action']) && $_POST['action'] == 'upgrade')
|
||||
|
||||
migrate_modeles($db,$langs,$conf);
|
||||
|
||||
/*
|
||||
migrate_price_commande($db,$langs,$conf);
|
||||
|
||||
migrate_price_propal($db,$langs,$conf);
|
||||
|
||||
migrate_price_facture($db,$langs,$conf);
|
||||
*/
|
||||
|
||||
|
||||
// On commit dans tous les cas.
|
||||
// La proc<6F>dure etant con<6F>ue pour pouvoir passer plusieurs fois quelquesoit la situation.
|
||||
$db->commit();
|
||||
|
||||
migrate_price_facture($db,$langs,$conf);
|
||||
|
||||
$db->close();
|
||||
}
|
||||
|
||||
@@ -595,34 +599,64 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
|
||||
|
||||
|
||||
/*
|
||||
* Mise a jour des totaux facture
|
||||
* Mise a jour des totaux lignes de facture
|
||||
*/
|
||||
function migrate_price_facture($db,$langs,$conf)
|
||||
{
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for invoice");
|
||||
|
||||
print '<br>';
|
||||
print '<b>'.$langs->trans('MigrationInvoice')."</b><br>\n";
|
||||
|
||||
// TODO Ajout requete remplissage champ total_ht, totam_tva, total_ttc
|
||||
// dans table det
|
||||
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."facture";
|
||||
$sql.= " WHERE total_ttc = 0 AND remise_percent != 100";
|
||||
// Liste des lignes facture non a jour
|
||||
$sql = "SELECT fd.rowid, fd.qty, fd.subprice, fd.remise_percent, fd.tva_taux, ";
|
||||
$sql.= " f.rowid as facid, f.remise_percent as remise_percent_global";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."facturedet as fd, ".MAIN_DB_PREFIX."facture as f";
|
||||
$sql.= " WHERE fd.fk_facture = f.rowid";
|
||||
$sql.= " AND (fd.total_ttc = 0 or fd.total_ttc IS NULL) AND fd.remise_percent != 100";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$rowid = $obj->rowid;
|
||||
$qty = $obj->qty;
|
||||
$pu = $obj->subprice;
|
||||
$txtva = $obj->tva_taux;
|
||||
$remise_percent = $obj->remise_percent;
|
||||
$remise_percent_global = $obj->remise_percent_global;
|
||||
|
||||
// On met a jour les 3 nouveaux champs
|
||||
$facligne= new FactureLigne($db);
|
||||
$facligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
|
||||
$facligne->total_ht = $total_ht;
|
||||
$facligne->total_tva = $total_tva;
|
||||
$facligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: facid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
// $facligne->update($rowid);
|
||||
|
||||
|
||||
/* On touche pas a facture mere
|
||||
$facture = new Facture($db);
|
||||
$facture->id=$obj->rowid;
|
||||
$facture->id=$obj->facid;
|
||||
|
||||
if ( $facture->fetch($facture->id) >= 0)
|
||||
{
|
||||
@@ -638,49 +672,92 @@ function migrate_price_facture($db,$langs,$conf)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #3";
|
||||
print "Error #3";
|
||||
$err++;
|
||||
}
|
||||
*/
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #1";
|
||||
print $langs->trans("AlreadyDone");
|
||||
}
|
||||
$db->free();
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error #1 ".$db->error();
|
||||
$err++;
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Mise a jour des totaux propal
|
||||
* Mise a jour des totaux lignes de propal
|
||||
*/
|
||||
function migrate_price_propal($db,$langs,$conf)
|
||||
{
|
||||
if ($conf->propal->enabled)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for propal");
|
||||
|
||||
print '<br>';
|
||||
print '<b>'.$langs->trans('MigrationProposal')."</b><br>\n";
|
||||
|
||||
// TODO Ajout requete remplissage champ total_ht, totam_tva, total_ttc
|
||||
// dans table det
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= " WHERE total = 0 AND remise_percent != 100";
|
||||
// Liste des lignes propal non a jour
|
||||
$sql = "SELECT pd.rowid, pd.qty, pd.subprice, pd.remise_percent, pd.tva_tx as tva_taux, ";
|
||||
$sql.= " p.rowid as propalid, p.remise_percent as remise_percent_global";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propaldet as pd, ".MAIN_DB_PREFIX."propal as p";
|
||||
$sql.= " WHERE pd.fk_propal = p.rowid";
|
||||
$sql.= " AND (pd.total_ttc = 0 or pd.total_ttc IS NULL) AND pd.remise_percent != 100";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$rowid = $obj->rowid;
|
||||
$qty = $obj->qty;
|
||||
$pu = $obj->subprice;
|
||||
$txtva = $obj->tva_taux;
|
||||
$remise_percent = $obj->remise_percent;
|
||||
$remise_percent_global = $obj->remise_percent_global;
|
||||
|
||||
// On met a jour les 3 nouveaux champs
|
||||
$propalligne= new PropaleLigne($db);
|
||||
$propalligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
|
||||
$propalligne->total_ht = $total_ht;
|
||||
$propalligne->total_tva = $total_tva;
|
||||
$propalligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: propalid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
// $propalligne->update($rowid);
|
||||
|
||||
|
||||
/* On touche pas a propal mere
|
||||
$propal = new Propal($db);
|
||||
$propal->id=$obj->rowid;
|
||||
if ( $propal->fetch($propal->id) >= 0 )
|
||||
@@ -697,17 +774,28 @@ function migrate_price_propal($db,$langs,$conf)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #3";
|
||||
print "Error #3";
|
||||
$err++;
|
||||
}
|
||||
*/
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #1";
|
||||
print $langs->trans("AlreadyDone");
|
||||
}
|
||||
|
||||
$db->free();
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error #1 ".$db->error();
|
||||
$err++;
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
@@ -716,31 +804,61 @@ function migrate_price_propal($db,$langs,$conf)
|
||||
|
||||
|
||||
/*
|
||||
* Mise a jour des totaux commande
|
||||
* Mise a jour des totaux lignes de commande
|
||||
*/
|
||||
function migrate_price_commande($db,$langs,$conf)
|
||||
{
|
||||
if ($conf->facture->enabled)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
dolibarr_install_syslog("Upgrade data for order");
|
||||
|
||||
print '<br>';
|
||||
print '<b>'.$langs->trans('MigrationOrder')."</b><br>\n";
|
||||
|
||||
// TODO Ajout requete remplissage champ total_ht, totam_tva, total_ttc
|
||||
// dans table det
|
||||
|
||||
|
||||
|
||||
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."commande";
|
||||
$sql.= " WHERE total_ttc = 0 AND remise_percent != 100";
|
||||
// Liste des lignes commande non a jour
|
||||
$sql = "SELECT cd.rowid, cd.qty, cd.subprice, cd.remise_percent, cd.tva_tx as tva_taux, ";
|
||||
$sql.= " c.rowid as commandeid, c.remise_percent as remise_percent_global";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as cd, ".MAIN_DB_PREFIX."commande as c";
|
||||
$sql.= " WHERE cd.fk_commande = c.rowid";
|
||||
$sql.= " AND (cd.total_ttc = 0 or cd.total_ttc IS NULL) AND cd.remise_percent != 100";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $db->num_rows($resql);
|
||||
$i = 0;
|
||||
if ($num)
|
||||
{
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $db->fetch_object($resql);
|
||||
|
||||
$rowid = $obj->rowid;
|
||||
$qty = $obj->qty;
|
||||
$pu = $obj->subprice;
|
||||
$txtva = $obj->tva_taux;
|
||||
$remise_percent = $obj->remise_percent;
|
||||
$remise_percent_global = $obj->remise_percent_global;
|
||||
|
||||
// On met a jour les 3 nouveaux champs
|
||||
$commandeligne= new CommandeLigne($db);
|
||||
$commandeligne->fetch($rowid);
|
||||
|
||||
$result=calcul_price_total($qty,$pu,$remise_percent,$txtva,$remise_percent_global);
|
||||
$total_ht = $result[0];
|
||||
$total_tva = $result[1];
|
||||
$total_ttc = $result[2];
|
||||
|
||||
$commandeligne->total_ht = $total_ht;
|
||||
$commandeligne->total_tva = $total_tva;
|
||||
$commandeligne->total_ttc = $total_ttc;
|
||||
|
||||
dolibarr_install_syslog("Line $rowid: commandeid=$obj->facid pu=$pu qty=$qty tva_taux=$txtva remise_percent=$remise_percent remise_global=$remise_percent_global -> $total_ht, $total_tva, $total_ttc");
|
||||
print ". ";
|
||||
// $commandeligne->update($rowid);
|
||||
|
||||
/* On touche pas a facture mere
|
||||
$commande = new Commande($db);
|
||||
$commande->id = $obj->rowid;
|
||||
if ( $commande->fetch($commande->id) >= 0 )
|
||||
@@ -757,17 +875,28 @@ function migrate_price_commande($db,$langs,$conf)
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #3";
|
||||
print "Error #3";
|
||||
$err++;
|
||||
}
|
||||
*/
|
||||
$i++;
|
||||
}
|
||||
$db->free();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Erreur #1";
|
||||
print $langs->trans("AlreadyDone");
|
||||
}
|
||||
|
||||
$db->free();
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
else
|
||||
{
|
||||
print "Error #1 ".$db->error();
|
||||
$err++;
|
||||
|
||||
$db->rollback();
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
@@ -9,6 +9,12 @@ ConfFileDoesNotExists=Configuration file <b>%s</b> does not exist !
|
||||
ErrorDirDoesNotExists=Directory %s does not exists.
|
||||
ErrorGoBackAndCorrectParameters=Go backward and correct wrong parameters.
|
||||
ErrorWrongValueForParameter=You may have typed a wrong value for parameter '%s'.
|
||||
ErrorFaileToCreateDatabase=Failed to create database '%'.
|
||||
ErrorFaileToConnectToDatabase=Failed to connect to database '%'.
|
||||
MigrationOrder=Data migration for customers' orders
|
||||
MigrationProposal=Data migration for commercial proposals
|
||||
MigrationInvoice=Data migration for customers' invoices
|
||||
MigrationContract=Data migration for contracts
|
||||
YouCanContinue=You can continue...
|
||||
License=Using license
|
||||
ConfigurationFile=Configuration file
|
||||
|
||||
@@ -23,12 +23,14 @@ ErrorYourCountryIsNotDefined=Your country is not defined. Go to Home-Setup-Edit
|
||||
ErrorRecordIsUsedByChild=Failed to delete this record. This record is used by at least on child records.
|
||||
ErrorWrongValue=Wrong value
|
||||
ErrorWrongValueForParameterX=Wrong value for parameter %s
|
||||
ErrorNoRequestInError=No request in error
|
||||
SeeAbove=See above
|
||||
HomeArea=Home area
|
||||
LastAccess=Last access
|
||||
RequestedUrl=Requested Url
|
||||
DatabaseTypeManager=Database type manager
|
||||
RequestLastAccess=Request for last database access
|
||||
RequestLastAccessInError=Request for last database access in error
|
||||
ReturnCodeLastAccess=Return code for last database access
|
||||
InformationLastAccess=Information for last database access
|
||||
DolibarrHasDetectedError=Dolibarr has detected a technical error
|
||||
|
||||
@@ -9,6 +9,12 @@ ConfFileIsWritable=Le fichier <b>%s</b> est modifiable.
|
||||
ErrorDirDoesNotExists=Le r<>pertoire <b>%s</b> n'existe pas ou n'est pas accessible.
|
||||
ErrorGoBackAndCorrectParameters=Revenez en arri<72>re et corrigez les param<61>tres invalides.
|
||||
ErrorWrongValueForParameter=Vous avez peut-<2D>tre saisi une mauvaise valeur pour le param<61>tre '%s'.
|
||||
ErrorFaileToCreateDatabase=Echec de cr<63>ation de la base '%'.
|
||||
ErrorFaileToConnectToDatabase=Echec de connection <20> la base '%'.
|
||||
MigrationOrder=Migration de donn<6E>es sur les commandes clients
|
||||
MigrationProposal=Migration de donn<6E>es sur les propositions commerciales
|
||||
MigrationInvoice=Migration de donn<6E>es sur les factures clients
|
||||
MigrationContract=Migration de donn<6E>es sur les contrats
|
||||
YouCanContinue=Vous pouvez continuer...
|
||||
License=Licence d'utilisation
|
||||
ConfigurationFile=Fichier de configuration
|
||||
|
||||
@@ -23,12 +23,14 @@ ErrorYourCountryIsNotDefined=Votre pays n'est pas d
|
||||
ErrorRecordIsUsedByChild=Impossible de supprimer cet enregistrement. Ce dernier est utilis<69> en tant que p<>re par au moins un enregistrement fils.
|
||||
ErrorWrongValue=Valeur incorrecte
|
||||
ErrorWrongValueForParameterX=Valeur incorrecte pour le param<61>tre %s
|
||||
ErrorNoRequestInError=Aucune requete en erreur
|
||||
SeeAbove=Voir ci-dessus
|
||||
HomeArea=Espace accueil
|
||||
LastAccess=Derni<6E>re connexion
|
||||
RequestedUrl=Url sollicit<69>e
|
||||
DatabaseTypeManager=Type gestionnaire de base de donn<6E>e
|
||||
RequestLastAccess=Requete dernier acces en base
|
||||
RequestLastAccessInError=Requete dernier acces en base en erreur
|
||||
ReturnCodeLastAccess=Code retour dernier acces en base
|
||||
InformationLastAccess=Information sur le dernier acc<63>s en base
|
||||
DolibarrHasDetectedError=Dolibarr a d<>tect<63> une erreur technique
|
||||
|
||||
@@ -1131,14 +1131,14 @@ function dolibarr_print_error($db='',$msg='')
|
||||
{
|
||||
print "<br>\n";
|
||||
print "<b>".$langs->trans("DatabaseTypeManager").":</b> ".$db->type."<br>\n";
|
||||
print "<b>".$langs->trans("RequestLastAccess").":</b> ".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."<br>\n";
|
||||
print "<b>".$langs->trans("RequestLastAccessInError").":</b> ".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."<br>\n";
|
||||
print "<b>".$langs->trans("ReturnCodeLastAccess").":</b> ".$db->errno()."<br>\n";
|
||||
print "<b>".$langs->trans("InformationLastAccess").":</b> ".$db->error()."<br>\n";
|
||||
}
|
||||
else // Mode CLI
|
||||
{
|
||||
print $langs->trans("DatabaseTypeManager").":\n".$db->type."\n";
|
||||
print $langs->trans("RequestLastAccess").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."\n";
|
||||
print $langs->trans("RequestLastAccessInError").":\n".($db->lastqueryerror()?$db->lastqueryerror():$langs->trans("ErrorNoRequestInError"))."\n";
|
||||
print $langs->trans("ReturnCodeLastAccess").":\n".$db->errno()."\n";
|
||||
print $langs->trans("InformationLastAccess").":\n".$db->error()."\n";
|
||||
|
||||
|
||||
@@ -2325,8 +2325,52 @@ class PropaleLigne
|
||||
var $product_desc; // Description produit
|
||||
var $ref; // Reference produit
|
||||
|
||||
function PropaleLigne()
|
||||
|
||||
/**
|
||||
* \brief Constructeur d'objets ligne de propal
|
||||
* \param DB handler d'acc<63>s base de donn<6E>e
|
||||
*/
|
||||
function PropaleLigne($DB)
|
||||
{
|
||||
$this->db= $DB ;
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Recup<75>re l'objet ligne de propal
|
||||
* \param rowid id de la ligne de propal
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = 'SELECT fk_propal, fk_product, description, price, qty, rowid, tva_tx,';
|
||||
$sql.= ' remise, remise_percent, fk_remise_except, subprice,';
|
||||
$sql.= ' info_bits, total_ht, total_tva, total_ttc, coef, rang';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet WHERE rowid = '.$rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->fk_propal = $objp->fk_propal;
|
||||
$this->desc = $objp->description;
|
||||
$this->qty = $objp->qty;
|
||||
$this->price = $objp->price;
|
||||
$this->subprice = $objp->subprice;
|
||||
$this->tva_taux = $objp->tva_taux;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
$this->produit_id = $objp->fk_product;
|
||||
$this->info_bits = $objp->info_bits;
|
||||
$this->total_ht = $objp->total_ht;
|
||||
$this->total_tva = $objp->total_tva;
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->coef = $objp->coef;
|
||||
$this->rang = $objp->rang;
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
dolibarr_print_error($this->db);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user