New: Debut gestion de la remise fixe sur propale
This commit is contained in:
parent
abbd54f87f
commit
fd72e42f15
@ -425,12 +425,19 @@ if ($_GET['action'] == 'modif' && $user->rights->propale->creer)
|
|||||||
|
|
||||||
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
if ($_POST['action'] == "setabsolutediscount" && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
$propal = new Propal($db);
|
|
||||||
$ret=$propal->fetch($_POST['propalid']);
|
|
||||||
|
|
||||||
if ($_POST["remise_id"])
|
if ($_POST["remise_id"])
|
||||||
{
|
{
|
||||||
$propal->insert_discount($_POST["remise_id"]);
|
$propal = new Propal($db);
|
||||||
|
$propal->id=$_GET['propalid'];
|
||||||
|
$ret=$propal->fetch($_GET['propalid']);
|
||||||
|
if ($ret > 0)
|
||||||
|
{
|
||||||
|
$propal->insert_discount($_POST["remise_id"]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($db,$propal->error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -737,9 +744,9 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '. ';
|
print '. ';
|
||||||
if ($absolute_discount)
|
if ($absolute_discount)
|
||||||
{
|
{
|
||||||
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
print '<br>';
|
||||||
print '.';
|
//print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
|
||||||
// print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id);
|
print $html->form_remise_dispo($_SERVER["PHP_SELF"].'?propalid='.$propal->id,0,'remise_id',$societe->id,$absolute_discount);
|
||||||
}
|
}
|
||||||
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
else print $langs->trans("CompanyHasNoAbsoluteDiscount").'.';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
@ -878,28 +885,6 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
|
|
||||||
// Destinataire
|
|
||||||
/* On gère les contacts sur onglet contact
|
|
||||||
$langs->load('mails');
|
|
||||||
print '<tr><td>';
|
|
||||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
|
||||||
print $langs->trans('MailTo');
|
|
||||||
print '</td>';
|
|
||||||
if ($_GET['action'] != 'editcontact' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editcontact&propalid='.$propal->id.'">'.img_edit($langs->trans('SetReceiver'),1).'</a></td>';
|
|
||||||
print '</tr></table>';
|
|
||||||
print '</td><td colspan="3">';
|
|
||||||
if ($_GET['action'] == 'editcontact')
|
|
||||||
{
|
|
||||||
$html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'contactidp');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$html->form_contacts($_SERVER['PHP_SELF'].'?propalid='.$propal->id,$societe,$propal->contactid,'none');
|
|
||||||
}
|
|
||||||
print '</td>';
|
|
||||||
print '</tr>';
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Projet
|
// Projet
|
||||||
if ($conf->projet->enabled)
|
if ($conf->projet->enabled)
|
||||||
{
|
{
|
||||||
@ -974,7 +959,8 @@ if ($_GET['propalid'] > 0)
|
|||||||
*/
|
*/
|
||||||
print '<table class="noborder" width="100%">';
|
print '<table class="noborder" width="100%">';
|
||||||
|
|
||||||
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice,';
|
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.fk_remise_except,';
|
||||||
|
$sql.= ' pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, pt.info_bits,';
|
||||||
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
$sql.= ' p.label as product, p.ref, p.fk_product_type, p.rowid as prodid,';
|
||||||
$sql.= ' p.description as product_desc';
|
$sql.= ' p.description as product_desc';
|
||||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
$sql.= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt';
|
||||||
@ -1013,7 +999,8 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
{
|
{
|
||||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
print '<td>';
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||||
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||||
else print img_object($langs->trans('ShowProduct'),'product');
|
else print img_object($langs->trans('ShowProduct'),'product');
|
||||||
print ' '.$objp->ref.'</a>';
|
print ' '.$objp->ref.'</a>';
|
||||||
@ -1041,7 +1028,18 @@ if ($_GET['propalid'] > 0)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print '<td>'.stripslashes(nl2br($objp->description));
|
print '<td>';
|
||||||
|
if ($objp->info_bits == 2)
|
||||||
|
{
|
||||||
|
print '<a href="'.DOL_URL_ROOT.'/comm/remx.php?id='.$propal->socidp.'">';
|
||||||
|
print $langs->trans("Discount");
|
||||||
|
print '</a>';
|
||||||
|
if ($objp->description) print ': '.nl2br($objp->description);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print nl2br($objp->description);
|
||||||
|
}
|
||||||
if ($objp->date_start && $objp->date_end)
|
if ($objp->date_start && $objp->date_end)
|
||||||
{
|
{
|
||||||
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
|
||||||
|
|||||||
@ -544,16 +544,16 @@ et non globalement
|
|||||||
/*
|
/*
|
||||||
* Boutons Actions
|
* Boutons Actions
|
||||||
*/
|
*/
|
||||||
if ($obj->statut <> 4 && $user->societe_id == 0)
|
if ($propal->statut <> 4 && $user->societe_id == 0)
|
||||||
{
|
{
|
||||||
print '<div class="tabsAction">';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
if ($obj->statut == 2 && $user->rights->facture->creer)
|
if ($propal->statut == 2 && $user->rights->facture->creer)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>";
|
print '<a class="butAction" href="facture.php?propalid='.$propal->id."&action=create\">".$langs->trans("BuildBill")."</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($obj->statut == 2 && sizeof($propal->getFactureListeArray()))
|
if ($propal->statut == 2 && sizeof($propal->getFactureListeArray()))
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>";
|
print '<a class="butAction" href="propal.php?propalid='.$propal->id."&action=setstatut&statut=4\">".$langs->trans("ClassifyBilled")."</a>";
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2206,7 +2206,7 @@ class FactureLigne
|
|||||||
$sql.= " '".price2num($this->qty)."',";
|
$sql.= " '".price2num($this->qty)."',";
|
||||||
$sql.= " '".price2num($this->txtva)."',";
|
$sql.= " '".price2num($this->txtva)."',";
|
||||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||||
else { $sql.='0,'; }
|
else { $sql.='null,'; }
|
||||||
$sql.= " '".price2num($this->remise_percent)."',";
|
$sql.= " '".price2num($this->remise_percent)."',";
|
||||||
$sql.= " '".price2num($this->subprice)."',";
|
$sql.= " '".price2num($this->subprice)."',";
|
||||||
$sql.= " '".price2num($this->remise)."',";
|
$sql.= " '".price2num($this->remise)."',";
|
||||||
|
|||||||
@ -1670,16 +1670,17 @@ class Form
|
|||||||
* \param selected Valeur à appliquer
|
* \param selected Valeur à appliquer
|
||||||
* \param htmlname Nom du formulaire select. Si none, non modifiable
|
* \param htmlname Nom du formulaire select. Si none, non modifiable
|
||||||
*/
|
*/
|
||||||
function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid)
|
function form_remise_dispo($page, $selected='', $htmlname='remise_id',$socid, $absolute_discount)
|
||||||
{
|
{
|
||||||
global $langs;
|
global $conf,$langs;
|
||||||
if ($htmlname != "none")
|
if ($htmlname != "none")
|
||||||
{
|
{
|
||||||
print '<form method="post" action="'.$page.'">';
|
print '<form method="post" action="'.$page.'">';
|
||||||
print '<input type="hidden" name="action" value="setabsolutediscount">';
|
print '<input type="hidden" name="action" value="setabsolutediscount">';
|
||||||
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
print '<table class="nobordernopadding" cellpadding="0" cellspacing="0">';
|
||||||
print '<tr><td>';
|
print '<tr><td>';
|
||||||
print $langs->trans("AvailableGlobalDiscounts").': ';
|
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)).': ';
|
||||||
|
// print $langs->trans("AvailableGlobalDiscounts").': ';
|
||||||
print $this->select_remises('',$htmlname,'fk_facture IS NULL',$socid);
|
print $this->select_remises('',$htmlname,'fk_facture IS NULL',$socid);
|
||||||
print '</td>';
|
print '</td>';
|
||||||
print '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("UseDiscount").'"></td>';
|
print '<td align="left"> <input type="submit" class="button" value="'.$langs->trans("UseDiscount").'"></td>';
|
||||||
|
|||||||
@ -198,6 +198,7 @@ LawApplicationPart3=vendeur jusqu'
|
|||||||
LawApplicationPart4=leurs prix.
|
LawApplicationPart4=leurs prix.
|
||||||
VATDischarged=TVA acquittée sur les débits.
|
VATDischarged=TVA acquittée sur les débits.
|
||||||
LimitedLiabilityCompanyCapital=SARL au Capital de
|
LimitedLiabilityCompanyCapital=SARL au Capital de
|
||||||
|
UseDiscount=Use discount
|
||||||
|
|
||||||
# oursin PDF model
|
# oursin PDF model
|
||||||
Of=du
|
Of=du
|
||||||
|
|||||||
@ -80,9 +80,9 @@ CustomerRelativeDiscount=Relative customer discount
|
|||||||
CustomerAbsoluteDiscount=Absolute customer discount
|
CustomerAbsoluteDiscount=Absolute customer discount
|
||||||
CustomerRelativeDiscountShort=Relative discount
|
CustomerRelativeDiscountShort=Relative discount
|
||||||
CustomerAbsoluteDiscountShort=Absolute discount
|
CustomerAbsoluteDiscountShort=Absolute discount
|
||||||
CompanyHasRelativeDiscount=This customer has a discount of %s%%
|
CompanyHasRelativeDiscount=This customer has a discount of <b>%s%%</b>
|
||||||
CompanyHasNoRelativeDiscount=This customer has no discount by default
|
CompanyHasNoRelativeDiscount=This customer has no relative discount by default
|
||||||
CompanyHasAbsoluteDiscount=This customer has a %s %s discount credit
|
CompanyHasAbsoluteDiscount=This customer has a <b>%s %s</b> discount credit
|
||||||
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
|
CompanyHasNoAbsoluteDiscount=This customer has no discount credit available
|
||||||
CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users)
|
CustomerAbsoluteDiscountAllUsers=Absolute discounts (granted by all users)
|
||||||
CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself)
|
CustomerAbsoluteDiscountMy=Absolute discounts (granted by yourself)
|
||||||
|
|||||||
@ -82,7 +82,7 @@ PriceRemoved=Price removed
|
|||||||
BarCode=Barcode
|
BarCode=Barcode
|
||||||
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
|
NoteNotVisibleOnBill=Note (not visible on invoices, proposals...)
|
||||||
CreateCopy=Create copy
|
CreateCopy=Create copy
|
||||||
ServiceLimitedDuration=If produced of service type at limited duration:
|
ServiceLimitedDuration=If product is a service with limited duration:
|
||||||
MultiPricesAbility=Activate the multi-prices
|
MultiPricesAbility=Activate the multi-prices
|
||||||
MultiPricesNumPrices=Number of price
|
MultiPricesNumPrices=Number of price
|
||||||
MultiPriceLevelsName=Price categories
|
MultiPriceLevelsName=Price categories
|
||||||
|
|||||||
@ -198,6 +198,7 @@ LawApplicationPart3=vendeur jusqu'
|
|||||||
LawApplicationPart4=leurs prix.
|
LawApplicationPart4=leurs prix.
|
||||||
VATDischarged=TVA acquittée sur les débits.
|
VATDischarged=TVA acquittée sur les débits.
|
||||||
LimitedLiabilityCompanyCapital=SARL au Capital de
|
LimitedLiabilityCompanyCapital=SARL au Capital de
|
||||||
|
UseDiscount=Appliquer remise
|
||||||
|
|
||||||
# oursin PDF model
|
# oursin PDF model
|
||||||
Of=du
|
Of=du
|
||||||
|
|||||||
@ -80,9 +80,9 @@ CustomerRelativeDiscount=Remise client relative
|
|||||||
CustomerAbsoluteDiscount=Remise client fixe
|
CustomerAbsoluteDiscount=Remise client fixe
|
||||||
CustomerRelativeDiscountShort=Remise relative
|
CustomerRelativeDiscountShort=Remise relative
|
||||||
CustomerAbsoluteDiscountShort=Remise fixe
|
CustomerAbsoluteDiscountShort=Remise fixe
|
||||||
CompanyHasRelativeDiscount=Ce client a une remise par défaut de %s%%
|
CompanyHasRelativeDiscount=Ce client a une remise par défaut de <b>%s%%</b>
|
||||||
CompanyHasNoRelativeDiscount=Ce client n'a pas de remises par défaut
|
CompanyHasNoRelativeDiscount=Ce client n'a pas de remises relatives par défaut
|
||||||
CompanyHasAbsoluteDiscount=Ce client a %s %s de remises fixes disponibles
|
CompanyHasAbsoluteDiscount=Ce client a <b>%s %s</b> de remises fixes disponibles
|
||||||
CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remises fixes disponibles
|
CompanyHasNoAbsoluteDiscount=Ce client n'a pas ou plus de remises fixes disponibles
|
||||||
CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur)
|
CustomerAbsoluteDiscountAllUsers=Remises fixes en cours (accordées par tout utilisateur)
|
||||||
CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement)
|
CustomerAbsoluteDiscountMy=Remises fixes en cours (accordées personnellement)
|
||||||
|
|||||||
@ -155,10 +155,66 @@ class Propal extends CommonObject
|
|||||||
* \return int >0 si ok, <0 si ko
|
* \return int >0 si ok, <0 si ko
|
||||||
* \see add_product
|
* \see add_product
|
||||||
*/
|
*/
|
||||||
function insert_discount($idproduct, $qty, $remise_percent=0, $desc='')
|
function insert_discount($idremise)
|
||||||
{
|
{
|
||||||
|
global $langs;
|
||||||
|
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/lib/price.lib.php');
|
||||||
|
include_once(DOL_DOCUMENT_ROOT.'/discount.class.php');
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
|
$remise=new DiscountAbsolute($this->db);
|
||||||
|
$result=$remise->fetch($idremise);
|
||||||
|
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$propalligne=new PropaleLigne($this->db);
|
||||||
|
$propalligne->fk_propal=$this->id;
|
||||||
|
$propalligne->fk_remise_except=$remise->id;
|
||||||
|
$propalligne->desc=$remise->description; // Description ligne
|
||||||
|
$propalligne->tva_tx=$remise->tva_tx;
|
||||||
|
$propalligne->subprice=-$remise->amount_ht;
|
||||||
|
$propalligne->price=-$remise->amount_ht;
|
||||||
|
$propalligne->fk_product=0; // Id produit prédéfini
|
||||||
|
$propalligne->qty=1;
|
||||||
|
$propalligne->remise=0;
|
||||||
|
$propalligne->remise_percent=0;
|
||||||
|
$propalligne->rang=-1;
|
||||||
|
$propalligne->info_bits=2;
|
||||||
|
|
||||||
|
$tabprice=calcul_price_total($propalligne->qty, $propalligne->subprice, 0,$propalligne->tva_tx);
|
||||||
|
$propalligne->total_ht = $tabprice[0];
|
||||||
|
$propalligne->total_tva = $tabprice[1];
|
||||||
|
$propalligne->total_ttc = $tabprice[2];
|
||||||
|
|
||||||
|
$result=$propalligne->insert();
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$result=$this->update_price();
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$this->db->commit();
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->error=$propalligne->error;
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$this->db->rollback();
|
||||||
|
return -2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -211,22 +267,6 @@ class Propal extends CommonObject
|
|||||||
$price = $pu - $remise;
|
$price = $pu - $remise;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Récupère rang max de la propale dans $rangmax
|
|
||||||
$sql = 'SELECT max(rang) FROM '.MAIN_DB_PREFIX.'propaldet';
|
|
||||||
$sql.= ' WHERE fk_propal ='.$propalid;
|
|
||||||
$resql = $this->db->query($sql);
|
|
||||||
if ($resql)
|
|
||||||
{
|
|
||||||
$row = $this->db->fetch_row($resql);
|
|
||||||
$rangmax = $row[0];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
dolibarr_print_error($this->db);
|
|
||||||
$this->db->rollback();
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Insertion ligne
|
// Insertion ligne
|
||||||
$ligne=new PropaleLigne($this->db);
|
$ligne=new PropaleLigne($this->db);
|
||||||
|
|
||||||
@ -239,7 +279,7 @@ class Propal extends CommonObject
|
|||||||
$ligne->remise_percent=$remise_percent;
|
$ligne->remise_percent=$remise_percent;
|
||||||
$ligne->subprice=$subprice;
|
$ligne->subprice=$subprice;
|
||||||
$ligne->remise=$remise;
|
$ligne->remise=$remise;
|
||||||
$ligne->rang=($rangmax+1);
|
$ligne->rang=-1;
|
||||||
$ligne->info_bits=$info_bits;
|
$ligne->info_bits=$info_bits;
|
||||||
$ligne->total_ht=$total_ht;
|
$ligne->total_ht=$total_ht;
|
||||||
$ligne->total_tva=$total_tva;
|
$ligne->total_tva=$total_tva;
|
||||||
@ -553,25 +593,12 @@ class Propal extends CommonObject
|
|||||||
// Anciens indicateurs
|
// Anciens indicateurs
|
||||||
$this->amount_ht += $obj->price * $obj->qty;
|
$this->amount_ht += $obj->price * $obj->qty;
|
||||||
$this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne)
|
$this->total_remise += 0; // Plus de remise globale (toute remise est sur une ligne)
|
||||||
/* \deprecated car simplifie par les 3 indicateurs total_ht, total_tva et total_ttc sur lignes
|
|
||||||
$products[$i][0] = $obj->price;
|
|
||||||
$products[$i][1] = $obj->qty;
|
|
||||||
$products[$i][2] = $obj->tva_tx;
|
|
||||||
*/
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->db->free($result);
|
$this->db->free($result);
|
||||||
}
|
}
|
||||||
/* \deprecated car simplifie par les 3 indicateurs total_ht, total_tva et total_ttc sur lignes
|
|
||||||
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
|
|
||||||
$this->total_remise = $calculs[3];
|
|
||||||
$this->amount_ht = $calculs[4];
|
|
||||||
$this->total_ht = $calculs[0];
|
|
||||||
$this->total_tva = $calculs[1];
|
|
||||||
$this->total_ttc = $calculs[2];
|
|
||||||
$tvas = $calculs[5];
|
|
||||||
*/
|
|
||||||
// Met a jour en base
|
// Met a jour en base
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
||||||
$sql .= " price='". price2num($this->total_ht)."'";
|
$sql .= " price='". price2num($this->total_ht)."'";
|
||||||
@ -592,7 +619,7 @@ class Propal extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Stocke un numéro de rang pour toutes les lignes de
|
* \brief Stocke un numéro de rang pour toutes les lignes de
|
||||||
* detail d'une propale qui n'en ont pas.
|
* detail d'une propale qui n'en ont pas.
|
||||||
*/
|
*/
|
||||||
@ -876,6 +903,8 @@ class Propal extends CommonObject
|
|||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->error="Record Not Found";
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -2069,6 +2098,7 @@ class PropaleLigne
|
|||||||
var $coef;
|
var $coef;
|
||||||
|
|
||||||
var $info_bits; // Bit 0: 0 si TVA normal - 1 si TVA NPR
|
var $info_bits; // Bit 0: 0 si TVA normal - 1 si TVA NPR
|
||||||
|
// Bit 1: 0 ligne normale - 1 si ligne de remise fixe
|
||||||
var $total_ht; // Total HT de la ligne toute quantité et incluant la remise ligne
|
var $total_ht; // Total HT de la ligne toute quantité et incluant la remise ligne
|
||||||
var $total_tva; // Total TVA de la ligne toute quantité et incluant la remise ligne
|
var $total_tva; // Total TVA de la ligne toute quantité et incluant la remise ligne
|
||||||
var $total_ttc; // Total TTC de la ligne toute quantité et incluant la remise ligne
|
var $total_ttc; // Total TTC de la ligne toute quantité et incluant la remise ligne
|
||||||
@ -2141,8 +2171,29 @@ class PropaleLigne
|
|||||||
*/
|
*/
|
||||||
function insert()
|
function insert()
|
||||||
{
|
{
|
||||||
|
dolibarr_syslog("PropaleLigne::insert rang=".$this->rang);
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
|
$rangtouse=$this->rang;
|
||||||
|
if ($rangtouse == -1)
|
||||||
|
{
|
||||||
|
// Récupère rang max de la propale dans $rangmax
|
||||||
|
$sql = 'SELECT max(rang) as max FROM '.MAIN_DB_PREFIX.'propaldet';
|
||||||
|
$sql.= ' WHERE fk_propal ='.$this->fk_propal;
|
||||||
|
$resql = $this->db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
$rangtouse = $obj->max + 1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
dolibarr_print_error($this->db);
|
||||||
|
$this->db->rollback();
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Insertion dans base de la ligne
|
// Insertion dans base de la ligne
|
||||||
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';
|
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'propaldet';
|
||||||
$sql.= ' (fk_propal, description, price, qty, tva_tx,';
|
$sql.= ' (fk_propal, description, price, qty, tva_tx,';
|
||||||
@ -2155,13 +2206,13 @@ class PropaleLigne
|
|||||||
$sql.= " '".price2num($this->qty)."',";
|
$sql.= " '".price2num($this->qty)."',";
|
||||||
$sql.= " '".price2num($this->tva_tx)."',";
|
$sql.= " '".price2num($this->tva_tx)."',";
|
||||||
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
if ($this->fk_product) { $sql.= "'".$this->fk_product."',"; }
|
||||||
else { $sql.='0,'; }
|
else { $sql.='null,'; }
|
||||||
$sql.= " '".price2num($this->remise_percent)."',";
|
$sql.= " '".price2num($this->remise_percent)."',";
|
||||||
$sql.= " '".price2num($this->subprice)."',";
|
$sql.= " '".price2num($this->subprice)."',";
|
||||||
$sql.= " '".price2num($this->remise)."',";
|
$sql.= " '".price2num($this->remise)."',";
|
||||||
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
if ($this->fk_remise_except) $sql.= $this->fk_remise_except.",";
|
||||||
else $sql.= 'null,';
|
else $sql.= 'null,';
|
||||||
$sql.= ' '.$this->rang.',';
|
$sql.= ' '.$rangtouse.',';
|
||||||
if (isset($this->coef)) $sql.= ' '.$this->coef.',';
|
if (isset($this->coef)) $sql.= ' '.$this->coef.',';
|
||||||
else $sql.= ' null,';
|
else $sql.= ' null,';
|
||||||
$sql.= " '".$this->info_bits."',";
|
$sql.= " '".$this->info_bits."',";
|
||||||
@ -2175,15 +2226,16 @@ class PropaleLigne
|
|||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
$this->rang=$rangmax;
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$this->error=$this->db->error();
|
$this->error=$this->db->error()." sql=".$sql;
|
||||||
dolibarr_syslog("PropaleLigne::insert Error ".$this->error);
|
dolibarr_syslog("PropaleLigne::insert Error ".$this->error);
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -2;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user