forked from Wavyzz/dolibarr
Qual: Uniformisation du code php pour grer les lignes de propal, facture et commande.
This commit is contained in:
@@ -1529,9 +1529,9 @@ class Commande
|
||||
$sql.= ",remise_percent='".price2num($remise_percent)."'";
|
||||
$sql.= ",tva_tx='".price2num($txtva)."'";
|
||||
$sql.= ",qty='".price2num($qty)."'";
|
||||
//if ($datestart) { $sql.= ",date_start='$datestart'"; }
|
||||
//if ($date_end) { $sql.= ",date_start='$date_end'"; }
|
||||
//else { $sql.=',date_start=null'; }
|
||||
//if ($dateend) { $sql.= ",date_end='$dateend'"; }
|
||||
//if ($date_end) { $sql.= ",date_end='$date_end'"; }
|
||||
//else { $sql.=',date_end=null'; }
|
||||
//$sql.= " info_bits=".$info_bits.",";
|
||||
$sql.= ",total_ht='".price2num($total_ht)."'";
|
||||
@@ -2135,22 +2135,26 @@ class CommandeLigne
|
||||
*/
|
||||
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;
|
||||
$sql = 'SELECT cd.rowid, cd.fk_commande, cd.fk_product, cd.description, cd.price, cd.qty, cd.tva_tx,';
|
||||
$sql.= ' cd.label,';
|
||||
$sql.= ' cd.remise, cd.remise_percent, cd.fk_remise_except, cd.subprice,';
|
||||
$sql.= ' cd.info_bits, cd.total_ht, cd.total_tva, cd.total_ttc, cd.coef, cd.rang,';
|
||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'commandedet as cd';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON cd.fk_product = p.rowid';
|
||||
$sql.= ' WHERE cd.rowid = '.$rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->rowid = $objp->rowid;
|
||||
$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->tva_tx = $objp->tva_tx;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
@@ -2161,6 +2165,11 @@ class CommandeLigne
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->coef = $objp->coef;
|
||||
$this->rang = $objp->rang;
|
||||
|
||||
$this->ref = $objp->product_ref;
|
||||
$this->libelle = $objp->product_libelle;
|
||||
$this->product_desc = $objp->product_desc;
|
||||
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
@@ -2187,7 +2196,7 @@ class CommandeLigne
|
||||
$sql.= " '".addslashes($this->desc)."',";
|
||||
$sql.= " '".price2num($this->price)."',";
|
||||
$sql.= " '".price2num($this->qty)."',";
|
||||
$sql.= " '".price2num($this->txtva)."',";
|
||||
$sql.= " '".price2num($this->tva_tx)."',";
|
||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||
else { $sql.='0,'; }
|
||||
$sql.= " '".price2num($this->remise_percent)."',";
|
||||
@@ -2239,7 +2248,7 @@ class CommandeLigne
|
||||
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
|
||||
if ($fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
else $sql.= ",fk_remise_except=null";
|
||||
$sql.= ",tva_taux='".price2num($this->txtva)."'";
|
||||
$sql.= ",tva_tx='".price2num($this->tva_tx)."'";
|
||||
$sql.= ",qty='".price2num($this->qty)."'";
|
||||
$sql.= ",rang='".$this->rang."'";
|
||||
$sql.= ",coef='".$this->coef."'";
|
||||
|
||||
@@ -374,18 +374,18 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
||||
$soc = new Societe($db);
|
||||
$ret=$soc->fetch($fac->socidp);
|
||||
|
||||
$datestart='';
|
||||
$dateend='';
|
||||
$date_start='';
|
||||
$date_end='';
|
||||
// Si ajout champ produit libre
|
||||
if ($_POST['action'] == 'addligne')
|
||||
{
|
||||
if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday'])
|
||||
{
|
||||
$datestart=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday'];
|
||||
$date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday'];
|
||||
}
|
||||
if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday'])
|
||||
{
|
||||
$dateend=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
|
||||
$date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
|
||||
}
|
||||
}
|
||||
// Si ajout champ produit pr<70>d<EFBFBD>fini
|
||||
@@ -393,11 +393,11 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
||||
{
|
||||
if ($_POST['date_start_predefyear'] && $_POST['date_start_predefmonth'] && $_POST['date_start_predefday'])
|
||||
{
|
||||
$datestart=$_POST['date_start_predefyear'].'-'.$_POST['date_start_predefmonth'].'-'.$_POST['date_start_predefday'];
|
||||
$date_start=$_POST['date_start_predefyear'].'-'.$_POST['date_start_predefmonth'].'-'.$_POST['date_start_predefday'];
|
||||
}
|
||||
if ($_POST['date_end_predefyear'] && $_POST['date_end_predefmonth'] && $_POST['date_end_predefday'])
|
||||
{
|
||||
$dateend=$_POST['date_end_predefyear'].'-'.$_POST['date_end_predefmonth'].'-'.$_POST['date_end_predefday'];
|
||||
$date_end=$_POST['date_end_predefyear'].'-'.$_POST['date_end_predefmonth'].'-'.$_POST['date_end_predefday'];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,8 +445,8 @@ if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') &&
|
||||
$tva_tx,
|
||||
$_POST['idprod'],
|
||||
$_POST['remise_percent'],
|
||||
$datestart,
|
||||
$dateend
|
||||
$date_start,
|
||||
$date_end
|
||||
);
|
||||
}
|
||||
|
||||
@@ -458,13 +458,13 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
||||
$fac = new Facture($db,'',$_POST['facid']);
|
||||
if (! $fac->fetch($_POST['facid']) > 0) dolibarr_print_error($db);
|
||||
|
||||
$datestart='';
|
||||
$dateend='';
|
||||
$date_start='';
|
||||
$date_end='';
|
||||
if ($_POST['date_startyear'] && $_POST['date_startmonth'] && $_POST['date_startday']) {
|
||||
$datestart=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday'];
|
||||
$date_start=$_POST['date_startyear'].'-'.$_POST['date_startmonth'].'-'.$_POST['date_startday'];
|
||||
}
|
||||
if ($_POST['date_endyear'] && $_POST['date_endmonth'] && $_POST['date_endday']) {
|
||||
$dateend=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
|
||||
$date_end=$_POST['date_endyear'].'-'.$_POST['date_endmonth'].'-'.$_POST['date_endday'];
|
||||
}
|
||||
|
||||
$result = $fac->updateline($_POST['rowid'],
|
||||
@@ -472,8 +472,8 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
||||
$_POST['price'],
|
||||
$_POST['qty'],
|
||||
$_POST['remise_percent'],
|
||||
$datestart,
|
||||
$dateend,
|
||||
$date_start,
|
||||
$date_end,
|
||||
$_POST['tva_tx']
|
||||
);
|
||||
|
||||
|
||||
@@ -87,10 +87,10 @@ class Contrat
|
||||
* \param user Objet User qui avtice le contrat
|
||||
* \param line_id Id de la ligne de detail <20> activer
|
||||
* \param date Date d'ouverture
|
||||
* \param dateend Date fin pr<70>vue
|
||||
* \param date_end Date fin pr<70>vue
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function active_line($user, $line_id, $date, $dateend='')
|
||||
function active_line($user, $line_id, $date, $date_end='')
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
@@ -98,7 +98,7 @@ class Contrat
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 4,";
|
||||
$sql.= " date_ouverture = '".$this->db->idate($date)."',";
|
||||
if ($dateend) $sql.= " date_fin_validite = '".$this->db->idate($dateend)."',";
|
||||
if ($date_end) $sql.= " date_fin_validite = '".$this->db->idate($date_end)."',";
|
||||
$sql.= " fk_user_ouverture = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$line_id . " AND (statut = 0 OR statut = 3) ";
|
||||
|
||||
@@ -125,17 +125,17 @@ class Contrat
|
||||
* \brief Active une ligne detail d'un contrat
|
||||
* \param user Objet User qui avtice le contrat
|
||||
* \param line_id Id de la ligne de detail <20> activer
|
||||
* \param dateend Date fin
|
||||
* \param date_end Date fin
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
*/
|
||||
function close_line($user, $line_id, $dateend)
|
||||
function close_line($user, $line_id, $date_end)
|
||||
{
|
||||
global $langs,$conf;
|
||||
|
||||
// statut actif : 4
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet SET statut = 5,";
|
||||
$sql.= " date_cloture = '".$this->db->idate($dateend)."',";
|
||||
$sql.= " date_cloture = '".$this->db->idate($date_end)."',";
|
||||
$sql.= " fk_user_cloture = ".$user->id;
|
||||
$sql.= " WHERE rowid = ".$line_id . " AND statut = 4";
|
||||
|
||||
@@ -567,16 +567,16 @@ class Contrat
|
||||
* \param txtva Taux tva
|
||||
* \param fk_product Id produit
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param datestart Date de debut pr<70>vue
|
||||
* \param dateend Date de fin pr<70>vue
|
||||
* \param date_start Date de debut pr<70>vue
|
||||
* \param date_end Date de fin pr<70>vue
|
||||
* \return int <0 si erreur, >0 si ok
|
||||
*/
|
||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart, $dateend)
|
||||
function addline($desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start, $date_end)
|
||||
{
|
||||
global $langs;
|
||||
global $conf;
|
||||
|
||||
dolibarr_syslog("contrat.class.php::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $datestart, $dateend");
|
||||
dolibarr_syslog("contrat.class.php::addline $desc, $pu, $qty, $txtva, $fk_product, $remise_percent, $date_start, $date_end");
|
||||
|
||||
if ($this->statut == 0)
|
||||
{
|
||||
@@ -611,13 +611,13 @@ class Contrat
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet";
|
||||
$sql.= " (fk_contrat, label, description, fk_product, price_ht, qty, tva_tx,";
|
||||
$sql.= " remise_percent, subprice, remise";
|
||||
if ($datestart > 0) { $sql.= ",date_ouverture_prevue"; }
|
||||
if ($dateend > 0) { $sql.= ",date_fin_validite"; }
|
||||
if ($date_start > 0) { $sql.= ",date_ouverture_prevue"; }
|
||||
if ($date_end > 0) { $sql.= ",date_fin_validite"; }
|
||||
$sql.= ") VALUES ($this->id, '" . addslashes($label) . "','" . addslashes($desc) . "',";
|
||||
$sql.= ($fk_product>0 ? $fk_product : "null");
|
||||
$sql.= ",".price2num($price).", '$qty', $txtva, $remise_percent,'".price2num($subprice)."','".price2num( $remise)."'";
|
||||
if ($datestart > 0) { $sql.= ",".$this->db->idate($datestart); }
|
||||
if ($dateend > 0) { $sql.= ",".$this->db->idate($dateend); }
|
||||
if ($date_start > 0) { $sql.= ",".$this->db->idate($date_start); }
|
||||
if ($date_end > 0) { $sql.= ",".$this->db->idate($date_end); }
|
||||
$sql.= ");";
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
@@ -644,15 +644,15 @@ class Contrat
|
||||
* \param pu Prix unitaire
|
||||
* \param qty Quantit<69>
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param datestart Date de debut pr<70>vue
|
||||
* \param dateend Date de fin pr<70>vue
|
||||
* \param date_start Date de debut pr<70>vue
|
||||
* \param date_end Date de fin pr<70>vue
|
||||
* \param tvatx Taux TVA
|
||||
* \param date_debut_reel Date de debut r<>elle
|
||||
* \param date_fin_reel Date de fin r<>elle
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0,
|
||||
$datestart='', $dateend='', $tvatx,
|
||||
$date_start='', $date_end='', $tvatx,
|
||||
$date_debut_reel='', $date_fin_reel='')
|
||||
{
|
||||
// Nettoyage parametres
|
||||
@@ -673,7 +673,7 @@ class Contrat
|
||||
$remise_percent=0;
|
||||
}
|
||||
|
||||
dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $datestart, $dateend, $tvatx");
|
||||
dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $tvatx");
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
@@ -685,9 +685,9 @@ class Contrat
|
||||
$sql .= ",qty='$qty'";
|
||||
$sql .= ",tva_tx='". price2num($tvatx)."'";
|
||||
|
||||
if ($datestart > 0) { $sql.= ",date_ouverture_prevue=".$this->db->idate($datestart); }
|
||||
if ($date_start > 0) { $sql.= ",date_ouverture_prevue=".$this->db->idate($date_start); }
|
||||
else { $sql.=",date_ouverture_prevue=null"; }
|
||||
if ($dateend > 0) { $sql.= ",date_fin_validite=".$this->db->idate($dateend); }
|
||||
if ($date_end > 0) { $sql.= ",date_fin_validite=".$this->db->idate($date_end); }
|
||||
else { $sql.=",date_fin_validite=null"; }
|
||||
if ($date_debut_reel > 0) { $sql.= ",date_ouverture=".$this->db->idate($date_debut_reel); }
|
||||
else { $sql.=",date_ouverture=null"; }
|
||||
|
||||
@@ -976,10 +976,10 @@ class Facture
|
||||
* \param idproduct
|
||||
* \param qty
|
||||
* \param remise_percent
|
||||
* \param datestart
|
||||
* \param dateend
|
||||
* \param date_start
|
||||
* \param date_end
|
||||
*/
|
||||
function add_product($idproduct, $qty, $remise_percent, $datestart='', $dateend='')
|
||||
function add_product($idproduct, $qty, $remise_percent, $date_start='', $date_end='')
|
||||
{
|
||||
if ($idproduct > 0)
|
||||
{
|
||||
@@ -991,32 +991,32 @@ class Facture
|
||||
}
|
||||
$this->products_qty[$i] = $qty;
|
||||
$this->products_remise_percent[$i] = $remise_percent;
|
||||
if ($datestart) { $this->products_date_start[$i] = $datestart; }
|
||||
if ($dateend) { $this->products_date_end[$i] = $dateend; }
|
||||
if ($date_start) { $this->products_date_start[$i] = $date_start; }
|
||||
if ($date_end) { $this->products_date_end[$i] = $date_end; }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* \brief Ajoute une ligne de facture (associ<63> <20> un produit/service pr<70>d<EFBFBD>fini ou non)
|
||||
* \param facid id de la facture
|
||||
* \param desc description de la ligne
|
||||
* \param pu prix unitaire
|
||||
* \param qty quantit<EFBFBD>
|
||||
* \param txtva taux de tva forc<72>, sinon -1
|
||||
* \param fk_product id du produit/service pred<65>fini
|
||||
* \param remise_percent pourcentage de remise de la ligne
|
||||
* \param datestart date de debut de validit<69> du service
|
||||
* \param dateend date de fin de validit<69> du service
|
||||
* \param ventil code de ventilation comptable
|
||||
* \param facid Id de la facture
|
||||
* \param desc Description de la ligne
|
||||
* \param pu Prix unitaire
|
||||
* \param qty Quantit<EFBFBD>
|
||||
* \param txtva Taux de tva forc<72>, sinon -1
|
||||
* \param fk_product Id du produit/service pred<65>fini
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param date_start Date de debut de validit<69> du service
|
||||
* \param date_end Date de fin de validit<69> du service
|
||||
* \param ventil Code de ventilation comptable
|
||||
* \remarks Les parametres sont deja cens<6E> etre juste et avec valeurs finales a l'appel
|
||||
* de cette methode. Aussi, pour le taux tva, il doit deja avoir ete d<>fini
|
||||
* par l'appelant par la methode get_default_tva(societe_vendeuse,societe_acheteuse,taux_produit)
|
||||
* et le desc doit deja avoir la bonne valeur (a l'appelant de gerer le multilangue)
|
||||
*/
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $datestart='', $dateend='', $ventil = 0)
|
||||
function addline($facid, $desc, $pu, $qty, $txtva, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil = 0)
|
||||
{
|
||||
global $conf;
|
||||
dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$datestart,$dateend,$ventil)");
|
||||
dolibarr_syslog("facture.class.php::addline($facid,$desc,$pu,$qty,$txtva,$fk_product,$remise_percent,$date_start,$date_end,$ventil)");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
if ($this->brouillon)
|
||||
@@ -1079,8 +1079,8 @@ class Facture
|
||||
$ligne->remise_percent=$remise_percent;
|
||||
$ligne->subprice=$subprice;
|
||||
$ligne->remise=$remise;
|
||||
$ligne->datestart=$datestart;
|
||||
$ligne->dateend=$dateend;
|
||||
$ligne->date_start=$date_start;
|
||||
$ligne->date_end=$date_end;
|
||||
$ligne->ventil=$ventil;
|
||||
$ligne->rang=($rangmax+1);
|
||||
$ligne->info_bits=$info_bits;
|
||||
@@ -1122,14 +1122,14 @@ class Facture
|
||||
* \param pu Prix unitaire
|
||||
* \param qty Quantit<69>
|
||||
* \param remise_percent Pourcentage de remise de la ligne
|
||||
* \param datestart Date de debut de validit<69> du service
|
||||
* \param dateend Date de fin de validit<69> du service
|
||||
* \param date_start Date de debut de validit<69> du service
|
||||
* \param date_end Date de fin de validit<69> du service
|
||||
* \param tva_tx Taux TVA
|
||||
* \return int < 0 si erreur, > 0 si ok
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $datestart, $dateend, $txtva)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $date_start, $date_end, $txtva)
|
||||
{
|
||||
dolibarr_syslog("Facture::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $datestart, $dateend, $txtva");
|
||||
dolibarr_syslog("Facture::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva");
|
||||
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||
|
||||
if ($this->brouillon)
|
||||
@@ -1176,8 +1176,8 @@ class Facture
|
||||
$ligne->remise_percent=$remise_percent;
|
||||
$ligne->subprice=$subprice;
|
||||
$ligne->remise=$remise;
|
||||
$ligne->datestart=$datestart;
|
||||
$ligne->dateend=$dateend;
|
||||
$ligne->date_start=$date_start;
|
||||
$ligne->date_end=$date_end;
|
||||
$ligne->total_ht=$total_ht;
|
||||
$ligne->total_tva=$total_tva;
|
||||
$ligne->total_ttc=$total_ttc;
|
||||
@@ -2430,6 +2430,7 @@ class FactureLigne
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->rowid = $objp->rowid;
|
||||
$this->fk_facture = $objp->fk_facture;
|
||||
$this->desc = $objp->description;
|
||||
$this->qty = $objp->qty;
|
||||
@@ -2490,9 +2491,9 @@ class FactureLigne
|
||||
$sql.= " '".price2num($this->remise)."',";
|
||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||
else $sql.= 'null,';
|
||||
if ($this->datestart) { $sql.= "'".$this->datestart."',"; }
|
||||
if ($this->date_start) { $sql.= "'".$this->date_start."',"; }
|
||||
else { $sql.='null,'; }
|
||||
if ($this->dateend) { $sql.= "'".$this->dateend."',"; }
|
||||
if ($this->date_end) { $sql.= "'".$this->date_end."',"; }
|
||||
else { $sql.='null,'; }
|
||||
$sql.= ' '.$this->fk_code_ventilation.',';
|
||||
$sql.= ' '.$this->fk_export_compta.',';
|
||||
@@ -2536,13 +2537,13 @@ class FactureLigne
|
||||
$sql.= ",subprice='".price2num($this->subprice)."'";
|
||||
$sql.= ",remise='".price2num($this->remise)."'";
|
||||
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
|
||||
if ($fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
if ($this->fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
else $sql.= ",fk_remise_except=null";
|
||||
$sql.= ",tva_taux='".price2num($this->txtva)."'";
|
||||
$sql.= ",tva_taux='".price2num($this->tva_taux)."'";
|
||||
$sql.= ",qty='".price2num($this->qty)."'";
|
||||
if ($this->datestart) { $sql.= ",date_start='".$this->datestart."'"; }
|
||||
if ($this->date_start) { $sql.= ",date_start='".$this->date_start."'"; }
|
||||
else { $sql.=',date_start=null'; }
|
||||
if ($this->dateend) { $sql.= ",date_end='".$this->dateend."'"; }
|
||||
if ($this->date_end) { $sql.= ",date_end='".$this->date_end."'"; }
|
||||
else { $sql.=',date_end=null'; }
|
||||
$sql.= ",rang='".$this->rang."'";
|
||||
$sql.= ",info_bits='".$this->info_bits."'";
|
||||
|
||||
@@ -26,12 +26,22 @@
|
||||
\version $Revision$
|
||||
*/
|
||||
|
||||
define('DOL_DOCUMENT_ROOT','../');
|
||||
|
||||
require_once('../translate.class.php');
|
||||
require_once('../lib/functions.inc.php');
|
||||
|
||||
|
||||
$docurl = '<a href="doc/dolibarr-install.html">documentation</a>';
|
||||
$conffile = "../conf/conf.php";
|
||||
|
||||
define('DOL_DOCUMENT_ROOT','../');
|
||||
|
||||
|
||||
// Forcage du log pour les install et mises a jour
|
||||
$conf->syslog->enabled=1;
|
||||
define('SYSLOG_FILE','/tmp/dolibarr_install.log');
|
||||
define('SYSLOG_FILE_NO_ERROR',1);
|
||||
|
||||
|
||||
|
||||
// Forcage du parametrage PHP magic_quots_gpc (Sinon il faudrait a chaque POST, conditionner
|
||||
// la lecture de variable par stripslashes selon etat de get_magic_quotes).
|
||||
@@ -50,9 +60,6 @@ if (get_magic_quotes_gpc())
|
||||
@set_magic_quotes_runtime(0);
|
||||
|
||||
|
||||
$docurl = '<a href="doc/dolibarr-install.html">documentation</a>';
|
||||
$conffile = "../conf/conf.php";
|
||||
|
||||
// Defini objet langs
|
||||
$langs = new Translate('../langs');
|
||||
$langs->setDefaultLang('auto');
|
||||
@@ -61,6 +68,7 @@ $langs->setPhpLang();
|
||||
$bc[false]=' class="bg1"';
|
||||
$bc[true]=' class="bg2"';
|
||||
|
||||
|
||||
function pHeader($soutitre,$next,$action='set')
|
||||
{
|
||||
global $langs;
|
||||
@@ -112,38 +120,7 @@ function pFooter($nonext=0,$setuplang='')
|
||||
|
||||
function dolibarr_install_syslog($message)
|
||||
{
|
||||
// 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Compare 2 versions
|
||||
\param versionarray1 Tableau de version (vermajeur,vermineur,autre)
|
||||
\param versionarray2 Tableau de version (vermajeur,vermineur,autre)
|
||||
\return int <0 si versionarray1<versionarray2, 0 si =, >0 si versionarray1>versionarray2
|
||||
*/
|
||||
function aaversioncompare($versionarray1,$versionarray2)
|
||||
{
|
||||
$ret=0;
|
||||
$i=0;
|
||||
while ($i < max(sizeof($versionarray1),sizeof($versionarray1)))
|
||||
{
|
||||
$operande1=isset($versionarray1[$i])?$versionarray1[$i]:0;
|
||||
$operande2=isset($versionarray2[$i])?$versionarray2[$i]:0;
|
||||
if ($operande1 < $operande2) { $ret = -1; break; }
|
||||
if ($operande1 > $operande2) { $ret = 1; break; }
|
||||
$i++;
|
||||
}
|
||||
return $ret;
|
||||
dolibarr_syslog($message);
|
||||
}
|
||||
|
||||
?>
|
||||
@@ -170,18 +170,16 @@ 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_propal($db,$langs,$conf);
|
||||
|
||||
// migrate_price_commande($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();
|
||||
}
|
||||
|
||||
@@ -617,7 +615,7 @@ function migrate_price_facture($db,$langs,$conf)
|
||||
$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";
|
||||
$sql.= " AND (fd.total_ttc = 0 AND fd.remise_percent != 100) or fd.total_ttc IS NULL";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -651,7 +649,7 @@ function migrate_price_facture($db,$langs,$conf)
|
||||
|
||||
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);
|
||||
$facligne->update();
|
||||
|
||||
|
||||
/* On touche pas a facture mere
|
||||
@@ -720,7 +718,7 @@ function migrate_price_propal($db,$langs,$conf)
|
||||
$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";
|
||||
$sql.= " AND (pd.total_ttc = 0 AND pd.remise_percent != 100) or pd.total_ttc IS NULL";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -754,7 +752,7 @@ function migrate_price_propal($db,$langs,$conf)
|
||||
|
||||
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);
|
||||
$propalligne->update($rowid);
|
||||
|
||||
|
||||
/* On touche pas a propal mere
|
||||
@@ -822,7 +820,7 @@ function migrate_price_commande($db,$langs,$conf)
|
||||
$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";
|
||||
$sql.= " AND (cd.total_ttc = 0 AND cd.remise_percent != 100) or cd.total_ttc IS NULL";
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -856,7 +854,7 @@ function migrate_price_commande($db,$langs,$conf)
|
||||
|
||||
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);
|
||||
$commandeligne->update($rowid);
|
||||
|
||||
/* On touche pas a facture mere
|
||||
$commande = new Commande($db);
|
||||
|
||||
@@ -151,15 +151,16 @@ function sanitize_string($str)
|
||||
|
||||
|
||||
/**
|
||||
\brief Envoi des messages dolibarr dans syslog ou dans un fichier
|
||||
Pour syslog: facility d<>fini par SYSLOG_FACILITY
|
||||
\brief Envoi des messages dolibarr dans un fichier ou dans syslog
|
||||
Pour fichier: fichier d<>fini par SYSLOG_FILE
|
||||
\param message Message a envoyer a syslog
|
||||
Pour syslog: facility d<>fini par SYSLOG_FACILITY
|
||||
\param message Message a tracer
|
||||
\param level Niveau de l'erreur
|
||||
\remarks Cette fonction n'a un effet que si le module syslog est activ<69>.
|
||||
Warning, les fonctions syslog sont buggu<67>s sous Windows et g<>n<EFBFBD>rent des
|
||||
fautes de protection m<>moire. Pour r<>soudre, utiliser le loggage fichier,
|
||||
au lieu du loggage syslog (configuration du module).
|
||||
Si SYSLOG_FILE_NO_ERROR d<>fini, on ne g<>re pas erreur ecriture log
|
||||
*/
|
||||
function dolibarr_syslog($message, $level=LOG_ERR)
|
||||
{
|
||||
@@ -174,12 +175,15 @@ function dolibarr_syslog($message, $level=LOG_ERR)
|
||||
|
||||
if (defined("SYSLOG_FILE") && SYSLOG_FILE)
|
||||
{
|
||||
$file=fopen(SYSLOG_FILE,"a+");
|
||||
if ($file) {
|
||||
if (defined("SYSLOG_FILE_NO_ERROR")) $file=@fopen(SYSLOG_FILE,"a+");
|
||||
else $file=fopen(SYSLOG_FILE,"a+");
|
||||
if ($file)
|
||||
{
|
||||
fwrite($file,strftime("%Y-%m-%d %H:%M:%S",time())." ".$level." ".$message."\n");
|
||||
fclose($file);
|
||||
}
|
||||
else {
|
||||
elseif (! defined("SYSLOG_FILE_NO_ERROR"))
|
||||
{
|
||||
$langs->load("main");
|
||||
print $langs->trans("ErrorFailedToOpenFile",SYSLOG_FILE);
|
||||
}
|
||||
|
||||
@@ -2378,20 +2378,24 @@ class PropaleLigne
|
||||
*/
|
||||
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;
|
||||
$sql = 'SELECT pd.rowid, pd.fk_propal, pd.fk_product, pd.description, pd.price, pd.qty, pd.tva_tx,';
|
||||
$sql.= ' pd.remise, pd.remise_percent, pd.fk_remise_except, pd.subprice,';
|
||||
$sql.= ' pd.info_bits, pd.total_ht, pd.total_tva, pd.total_ttc, pd.coef, pd.rang,';
|
||||
$sql.= ' p.ref as product_ref, p.label as product_libelle, p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pd';
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pd.fk_product = p.rowid';
|
||||
$sql.= ' WHERE pd.rowid = '.$rowid;
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$objp = $this->db->fetch_object($result);
|
||||
$this->rowid = $objp->rowid;
|
||||
$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->tva_tx = $objp->tva_tx;
|
||||
$this->remise = $objp->remise;
|
||||
$this->remise_percent = $objp->remise_percent;
|
||||
$this->fk_remise_except = $objp->fk_remise_except;
|
||||
@@ -2402,6 +2406,11 @@ class PropaleLigne
|
||||
$this->total_ttc = $objp->total_ttc;
|
||||
$this->coef = $objp->coef;
|
||||
$this->rang = $objp->rang;
|
||||
|
||||
$this->ref = $objp->product_ref;
|
||||
$this->libelle = $objp->product_libelle;
|
||||
$this->product_desc = $objp->product_desc;
|
||||
|
||||
$this->db->free($result);
|
||||
}
|
||||
else
|
||||
@@ -2428,7 +2437,7 @@ class PropaleLigne
|
||||
$sql.= " '".addslashes($this->desc)."',";
|
||||
$sql.= " '".price2num($this->price)."',";
|
||||
$sql.= " '".price2num($this->qty)."',";
|
||||
$sql.= " '".price2num($this->txtva)."',";
|
||||
$sql.= " '".price2num($this->tva_tx)."',";
|
||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||
else { $sql.='0,'; }
|
||||
$sql.= " '".price2num($this->remise_percent)."',";
|
||||
@@ -2472,7 +2481,7 @@ class PropaleLigne
|
||||
$this->db->begin();
|
||||
|
||||
// Mise a jour ligne en base
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaledet SET";
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propaldet SET";
|
||||
$sql.= " description='".addslashes($this->desc)."'";
|
||||
$sql.= ",price='".price2num($this->price)."'";
|
||||
$sql.= ",subprice='".price2num($this->subprice)."'";
|
||||
@@ -2480,7 +2489,7 @@ class PropaleLigne
|
||||
$sql.= ",remise_percent='".price2num($this->remise_percent)."'";
|
||||
if ($fk_remise_except) $sql.= ",fk_remise_except=".$this->fk_remise_except;
|
||||
else $sql.= ",fk_remise_except=null";
|
||||
$sql.= ",tva_taux='".price2num($this->txtva)."'";
|
||||
$sql.= ",tva_tx='".price2num($this->tva_tx)."'";
|
||||
$sql.= ",qty='".price2num($this->qty)."'";
|
||||
$sql.= ",rang='".$this->rang."'";
|
||||
$sql.= ",coef='".$this->coef."'";
|
||||
|
||||
Reference in New Issue
Block a user