Possibilité de modifier le descriptif et le taux de tva y compris sur les lignes de produits prédéfinis.
This commit is contained in:
parent
d9ebf196d9
commit
75258b6cba
@ -435,22 +435,20 @@ class Contrat
|
|||||||
* \param remise_percent Pourcentage de remise de la ligne
|
* \param remise_percent Pourcentage de remise de la ligne
|
||||||
* \param datestart Date de debut prévue
|
* \param datestart Date de debut prévue
|
||||||
* \param dateend Date de fin prévue
|
* \param dateend Date de fin prévue
|
||||||
|
* \param tvatx Taux TVA
|
||||||
* \return int < 0 si erreur, > 0 si ok
|
* \return int < 0 si erreur, > 0 si ok
|
||||||
*/
|
*/
|
||||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $datestart='', $dateend='')
|
function updateline($rowid, $desc, $pu, $qty, $remise_percent=0, $datestart='', $dateend='', $tvatx)
|
||||||
{
|
{
|
||||||
dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $datestart, $dateend");
|
// Nettoyage parametres
|
||||||
|
$qty=trim($qty);
|
||||||
$this->db->begin();
|
$desc=trim($desc);
|
||||||
|
$desc=trim($desc);
|
||||||
if (strlen(trim($qty))==0)
|
|
||||||
{
|
|
||||||
$qty=1;
|
|
||||||
}
|
|
||||||
$remise = 0;
|
|
||||||
$price = ereg_replace(",",".",$pu);
|
$price = ereg_replace(",",".",$pu);
|
||||||
|
$tvatx = ereg_replace(",",".",$tvatx);
|
||||||
$subprice = $price;
|
$subprice = $price;
|
||||||
if (trim(strlen($remise_percent)) > 0)
|
$remise = 0;
|
||||||
|
if (strlen($remise_percent) > 0)
|
||||||
{
|
{
|
||||||
$remise = round(($pu * $remise_percent / 100), 2);
|
$remise = round(($pu * $remise_percent / 100), 2);
|
||||||
$price = $pu - $remise;
|
$price = $pu - $remise;
|
||||||
@ -460,12 +458,17 @@ class Contrat
|
|||||||
$remise_percent=0;
|
$remise_percent=0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
dolibarr_syslog("Contrat::UpdateLine $rowid, $desc, $pu, $qty, $remise_percent, $datestart, $dateend, $tvatx");
|
||||||
|
|
||||||
|
$this->db->begin();
|
||||||
|
|
||||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".addslashes($desc)."'";
|
$sql = "UPDATE ".MAIN_DB_PREFIX."contratdet set description='".addslashes($desc)."'";
|
||||||
$sql .= ",price_ht='" . ereg_replace(",",".",$price)."'";
|
$sql .= ",price_ht='" . ereg_replace(",",".",$price)."'";
|
||||||
$sql .= ",subprice='" . ereg_replace(",",".",$subprice)."'";
|
$sql .= ",subprice='" . ereg_replace(",",".",$subprice)."'";
|
||||||
$sql .= ",remise='". ereg_replace(",",".",$remise)."'";
|
$sql .= ",remise='" . ereg_replace(",",".",$remise)."'";
|
||||||
$sql .= ",remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
$sql .= ",remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
||||||
$sql .= ",qty='$qty'";
|
$sql .= ",qty='$qty'";
|
||||||
|
$sql .= ",tva_tx='". ereg_replace(",",".",$tvatx)."'";
|
||||||
|
|
||||||
if ($datestart > 0) { $sql.= ",date_ouverture_prevue=".$this->db->idate($datestart); }
|
if ($datestart > 0) { $sql.= ",date_ouverture_prevue=".$this->db->idate($datestart); }
|
||||||
else { $sql.=",date_ouverture_prevue=null"; }
|
else { $sql.=",date_ouverture_prevue=null"; }
|
||||||
|
|||||||
@ -18,7 +18,6 @@
|
|||||||
*
|
*
|
||||||
* $Id$
|
* $Id$
|
||||||
* $Source$
|
* $Source$
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -42,14 +41,14 @@ $user->getrights('contrat');
|
|||||||
if (! $user->rights->contrat->lire)
|
if (! $user->rights->contrat->lire)
|
||||||
accessforbidden();
|
accessforbidden();
|
||||||
|
|
||||||
$date_start_update=mktime(12, 0 , 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $_POST["date_start_updateyear"]);
|
$startyear=isset($_POST["date_startyear"])&&$_POST["date_startyear"]?$_POST["date_startyear"]:0;
|
||||||
$date_end_update=mktime(12, 0 , 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $_POST["date_end_updateyear"]);
|
$endyear=isset($_POST["date_endyear"])&&$_POST["date_endyear"]?$_POST["date_endyear"]:0;
|
||||||
$date_start=mktime(12, 0 , 0, $_POST["date_startmonth"], $_POST["date_startday"], $_POST["date_startyear"]);
|
$date_start_update=mktime(12, 0 , 0, $_POST["date_start_updatemonth"], $_POST["date_start_updateday"], $startyear);
|
||||||
$date_end=mktime(12, 0 , 0, $_POST["date_endmonth"], $_POST["date_endday"], $_POST["date_endyear"]);
|
$date_end_update=mktime(12, 0 , 0, $_POST["date_end_updatemonth"], $_POST["date_end_updateday"], $startyear);
|
||||||
|
$date_start=mktime(12, 0 , 0, $_POST["date_startmonth"], $_POST["date_startday"], $endyear);
|
||||||
|
$date_end=mktime(12, 0 , 0, $_POST["date_endmonth"], $_POST["date_endday"], $endyear);
|
||||||
|
|
||||||
/*
|
// Sécurité accés client
|
||||||
* Sécurité accés client
|
|
||||||
*/
|
|
||||||
if ($user->societe_id > 0)
|
if ($user->societe_id > 0)
|
||||||
{
|
{
|
||||||
$action = '';
|
$action = '';
|
||||||
@ -104,32 +103,35 @@ if ($_POST["action"] == 'classin')
|
|||||||
|
|
||||||
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
if ($_POST["action"] == 'addligne' && $user->rights->contrat->creer)
|
||||||
{
|
{
|
||||||
$result = 0;
|
if ($_POST["pqty"] && (($_POST["pu"] && $_POST["desc"]) || $_POST["p_idprod"]))
|
||||||
$contrat = new Contrat($db);
|
|
||||||
$result=$contrat->fetch($_GET["id"]);
|
|
||||||
if (($_POST["p_idprod"] > 0 && $_POST["mode"]=='predefined') || ($_POST["mode"]=='libre'))
|
|
||||||
{
|
{
|
||||||
//print $_POST["desc"]." - ".$_POST["pu"]." - ".$_POST["pqty"]." - ".$_POST["tva_tx"]." - ".$_POST["p_idprod"]." - ".$_POST["premise"]; exit;
|
$result = 0;
|
||||||
$result = $contrat->addline(
|
$contrat = new Contrat($db);
|
||||||
$_POST["desc"],
|
$result=$contrat->fetch($_GET["id"]);
|
||||||
$_POST["pu"],
|
if (($_POST["p_idprod"] > 0 && $_POST["mode"]=='predefined') || ($_POST["mode"]=='libre'))
|
||||||
$_POST["pqty"],
|
{
|
||||||
$_POST["tva_tx"],
|
//print $_POST["desc"]." - ".$_POST["pu"]." - ".$_POST["pqty"]." - ".$_POST["tva_tx"]." - ".$_POST["p_idprod"]." - ".$_POST["premise"]; exit;
|
||||||
$_POST["p_idprod"],
|
$result = $contrat->addline(
|
||||||
$_POST["premise"],
|
$_POST["desc"],
|
||||||
$date_start,
|
$_POST["pu"],
|
||||||
$date_end
|
$_POST["pqty"],
|
||||||
);
|
$_POST["tva_tx"],
|
||||||
}
|
$_POST["p_idprod"],
|
||||||
|
$_POST["premise"],
|
||||||
if ($result >= 0)
|
$date_start,
|
||||||
{
|
$date_end
|
||||||
Header("Location: fiche.php?id=".$contrat->id);
|
);
|
||||||
exit;
|
}
|
||||||
}
|
|
||||||
else
|
if ($result >= 0)
|
||||||
{
|
{
|
||||||
$mesg='<div class="error">'.$contrat->error.'</div>';
|
Header("Location: fiche.php?id=".$contrat->id);
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$mesg='<div class="error">'.$contrat->error.'</div>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -144,7 +146,8 @@ if ($_POST["action"] == 'updateligne' && $user->rights->contrat->creer)
|
|||||||
$_POST["elqty"],
|
$_POST["elqty"],
|
||||||
$_POST["elremise_percent"],
|
$_POST["elremise_percent"],
|
||||||
$date_start_update,
|
$date_start_update,
|
||||||
$date_end_update
|
$date_end_update,
|
||||||
|
$_POST["eltva_tx"]
|
||||||
);
|
);
|
||||||
if ($result > 0)
|
if ($result > 0)
|
||||||
{
|
{
|
||||||
@ -705,6 +708,8 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ligne en mode update
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print "<form action=\"fiche.php?id=$id\" method=\"post\">";
|
print "<form action=\"fiche.php?id=$id\" method=\"post\">";
|
||||||
@ -712,10 +717,16 @@ else
|
|||||||
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
print '<input type="hidden" name="elrowid" value="'.$_GET["rowid"].'">';
|
||||||
// Ligne carac
|
// Ligne carac
|
||||||
print "<tr $bc[$var]>";
|
print "<tr $bc[$var]>";
|
||||||
print '<td colspan="2">';
|
print '<td>';
|
||||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||||
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a><br>';
|
if ($objp->label)
|
||||||
|
{
|
||||||
|
print img_object($langs->trans("ShowService"),"service").' '.$objp->label.'</a><br>';
|
||||||
|
}
|
||||||
print '<textarea name="eldesc" cols="60" rows="1">'.$objp->description.'</textarea></td>';
|
print '<textarea name="eldesc" cols="60" rows="1">'.$objp->description.'</textarea></td>';
|
||||||
|
print '<td align="right">';
|
||||||
|
print $html->select_tva("eltva_tx",$objp->tva_tx);
|
||||||
|
print '</td>';
|
||||||
print '<td align="right"><input size="6" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
|
print '<td align="right"><input size="6" type="text" name="elprice" value="'.price($objp->subprice).'"></td>';
|
||||||
print '<td align="center"><input size="3" type="text" name="elqty" value="'.$objp->qty.'"></td>';
|
print '<td align="center"><input size="3" type="text" name="elqty" value="'.$objp->qty.'"></td>';
|
||||||
print '<td align="right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
|
print '<td align="right"><input size="1" type="text" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||||
@ -730,7 +741,6 @@ else
|
|||||||
print '</td>';
|
print '</td>';
|
||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
print '</tr>' . "\n";
|
|
||||||
print "</form>\n";
|
print "</form>\n";
|
||||||
}
|
}
|
||||||
$i++;
|
$i++;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user