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
56a3ddfb81
commit
619feffef1
@ -82,6 +82,18 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
|||||||
Header('Location: propal.php');
|
Header('Location: propal.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes')
|
||||||
|
{
|
||||||
|
if ($user->rights->propale->valider)
|
||||||
|
{
|
||||||
|
$propal = new Propal($db);
|
||||||
|
$propal->fetch($_GET['propalid']);
|
||||||
|
$propal->update_price($_GET['propalid']);
|
||||||
|
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||||
|
$propal->valid($user);
|
||||||
|
}
|
||||||
|
Header ('Location: propal.php?propalid='.$_GET['propalid']);
|
||||||
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'add')
|
if ($_POST['action'] == 'add')
|
||||||
{
|
{
|
||||||
@ -289,16 +301,14 @@ if ($_POST['action'] == "addligne" && $user->rights->propale->creer)
|
|||||||
propale_pdf_create($db, $_POST['propalid'], $propal->modelpdf);
|
propale_pdf_create($db, $_POST['propalid'], $propal->modelpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer)
|
if ($_POST['action'] == 'updateligne' && $user->rights->propale->creer && $_POST["save"] == $langs->trans("Save"))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Mise à jour d'une ligne dans la propale
|
* Mise à jour d'une ligne dans la propale
|
||||||
*/
|
*/
|
||||||
|
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
$propal->fetch($_GET['propalid']);
|
$propal->fetch($_GET['propalid']);
|
||||||
$propal->UpdateLigne($_POST['ligne'], $_POST['subprice'], $_POST['qty'], $_POST['remise']);
|
$propal->UpdateLigne($_POST['ligne'], $_POST['subprice'], $_POST['qty'], $_POST['remise_percent'], $_POST['tva_tx'], $_POST['desc']);
|
||||||
|
|
||||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,15 +331,6 @@ if ($_GET['action'] == 'del_ligne' && $user->rights->propale->creer)
|
|||||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($_GET['valid'] == 1 && $user->rights->propale->valider)
|
|
||||||
{
|
|
||||||
$propal = new Propal($db);
|
|
||||||
$propal->fetch($_GET['propalid']);
|
|
||||||
$propal->update_price($_GET['propalid']);
|
|
||||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
|
||||||
$propal->valid($user);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($_POST['action'] == 'setremise' && $user->rights->propale->creer)
|
if ($_POST['action'] == 'setremise' && $user->rights->propale->creer)
|
||||||
{
|
{
|
||||||
$propal = new Propal($db);
|
$propal = new Propal($db);
|
||||||
@ -401,7 +402,6 @@ if ($_GET['propalid'] > 0)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Confirmation de la suppression de la propale
|
* Confirmation de la suppression de la propale
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
if ($_GET['action'] == 'delete')
|
if ($_GET['action'] == 'delete')
|
||||||
{
|
{
|
||||||
@ -409,6 +409,15 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Confirmation de la validation de la propale
|
||||||
|
*/
|
||||||
|
if ($_GET['action'] == 'validate')
|
||||||
|
{
|
||||||
|
$html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmvalidateProp'), 'confirm_validate');
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fiche propal
|
* Fiche propal
|
||||||
@ -621,7 +630,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
|
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
|
||||||
print '<td align="right" width="50">'.$langs->trans('Discount').'</td>';
|
print '<td align="right" width="50">'.$langs->trans('Discount').'</td>';
|
||||||
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
||||||
print '<td> </td><td> </td>';
|
print '<td width="16"> </td><td width="16"> </td>';
|
||||||
print "</tr>\n";
|
print "</tr>\n";
|
||||||
}
|
}
|
||||||
$var=true;
|
$var=true;
|
||||||
@ -630,8 +639,8 @@ if ($_GET['propalid'] > 0)
|
|||||||
$objp = $db->fetch_object($resql);
|
$objp = $db->fetch_object($resql);
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|
||||||
// Update ligne de propale
|
// Ligne en mode visu
|
||||||
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
if ($_GET['action'] != 'editline' || $_GET['ligne'] != $objp->rowid)
|
||||||
{
|
{
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
if ($objp->fk_product > 0)
|
if ($objp->fk_product > 0)
|
||||||
@ -639,7 +648,8 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
print '<td><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> - '.stripslashes(nl2br($objp->product));
|
print ' '.$objp->ref.'</a>';
|
||||||
|
print ' - '.nl2br(stripslashes($objp->product));
|
||||||
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).')';
|
||||||
@ -652,7 +662,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
{
|
{
|
||||||
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
|
||||||
}
|
}
|
||||||
print ($objp->description && $objp->description!=$obj->product)?'<br>'.$objp->description:'';
|
print ($objp->description && $objp->description!=$objp->product)?'<br>'.$objp->description:'';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -702,25 +712,53 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update ligne de propal
|
// Ligne en mode update
|
||||||
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] == 'editline' && $_GET["ligne"] == $objp->rowid)
|
if ($propal->statut == 0 && $_GET["action"] == 'editline' && $user->rights->propale->creer && $_GET["ligne"] == $objp->rowid)
|
||||||
{
|
{
|
||||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||||
print '<input type="hidden" name="action" value="updateligne">';
|
print '<input type="hidden" name="action" value="updateligne">';
|
||||||
|
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||||
print '<input type="hidden" name="ligne" value="'.$_GET["ligne"].'">';
|
print '<input type="hidden" name="ligne" value="'.$_GET["ligne"].'">';
|
||||||
print '<tr '.$bc[$var].'>';
|
print '<tr '.$bc[$var].'>';
|
||||||
print '<td colspan="2"> </td>';
|
print '<td>';
|
||||||
print '<td align="right"><input name="subprice" type="text" size="6" value="'.$objp->subprice.'"></td>';
|
if ($objp->fk_product > 0)
|
||||||
print '<td align="right"><input name="qty" type="text" size="2" value="'.$objp->qty.'"></td>';
|
{
|
||||||
print '<td align="right" nowrap><input name="remise" type="text" size="2" value="'.$objp->remise_percent.'"> %</td>';
|
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||||
print '<td align="center" colspan="3"><input type="submit" value="'.$langs->trans("Save").'"></td>';
|
if ($objp->fk_product_type) print img_object($langs->trans('ShowService'),'service');
|
||||||
print '</tr>';
|
else print img_object($langs->trans('ShowProduct'),'product');
|
||||||
print '</form>';
|
print ' '.$objp->ref.'</a>';
|
||||||
|
print ' - '.stripslashes(nl2br($objp->product));
|
||||||
|
print '<br>';
|
||||||
|
}
|
||||||
|
print '<textarea name="desc" cols="50" rows="1">'.stripslashes($objp->description).'</textarea></td>';
|
||||||
|
print '<td align="right">';
|
||||||
|
print $html->select_tva("tva_tx",$objp->tva_tx);
|
||||||
|
print '</td>';
|
||||||
|
print '<td align="right"><input size="6" type="text" name="subprice" value="'.price($objp->subprice).'"></td>';
|
||||||
|
print '<td align="right"><input size="2" type="text" name="qty" value="'.$objp->qty.'"></td>';
|
||||||
|
print '<td align="right" nowrap><input size="2" type="text" name="remise_percent" value="'.$objp->remise_percent.'">%</td>';
|
||||||
|
print '<td align="center" colspan="4" valign="center"><input type="submit" class="button" name="save" value="'.$langs->trans("Save").'">';
|
||||||
|
print '<br /><input type="submit" class="button" name="cancel" value="'.$langs->trans("Cancel").'"></td>';
|
||||||
|
print '</tr>' . "\n";
|
||||||
|
/*
|
||||||
|
if ($conf->service->enabled)
|
||||||
|
{
|
||||||
|
print "<tr $bc[$var]>";
|
||||||
|
print '<td colspan="5">Si produit de type service à durée limitée: Du ';
|
||||||
|
print $html->select_date($objp->date_start,"date_start",0,0,$objp->date_start?0:1);
|
||||||
|
print ' au ';
|
||||||
|
print $html->select_date($objp->date_end,"date_end",0,0,$objp->date_end?0:1);
|
||||||
|
print '</td>';
|
||||||
|
print '</tr>' . "\n";
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
print "</form>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = $total + ($objp->qty * $objp->price);
|
$total = $total + ($objp->qty * $objp->price);
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->free($resql);
|
$db->free($resql);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -811,7 +849,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
print '<option value="3">'.$propal->labelstatut[3].'</option>';
|
print '<option value="3">'.$propal->labelstatut[3].'</option>';
|
||||||
print '</select>';
|
print '</select>';
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
print '<tr><td align="center" colspan="2"><input type="submit" value="'.$langs->trans('Valid').'"></td>';
|
print '<tr><td align="center" colspan="2"><input type="submit" value="'.$langs->trans('Validate').'"></td>';
|
||||||
print '</tr></table></form>';
|
print '</tr></table></form>';
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -826,7 +864,7 @@ if ($_GET['propalid'] > 0)
|
|||||||
{
|
{
|
||||||
if ($user->rights->propale->valider)
|
if ($user->rights->propale->valider)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&valid=1">'.$langs->trans('Valid').'</a>';
|
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=validate">'.$langs->trans('Validate').'</a>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -222,14 +222,15 @@ class Propal
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Mise à jour d'une ligne de produit
|
* \brief Mise à jour d'une ligne de produit
|
||||||
* \param id id de la ligne
|
* \param id Id de la ligne
|
||||||
* \param subprice prix unitaire
|
* \param subprice Prix unitaire
|
||||||
* \param qty quantité
|
* \param qty Quantité
|
||||||
* \param remise_percent remise effectuée sur le produit
|
* \param remise_percent Remise effectuée sur le produit
|
||||||
|
* \param desc Description
|
||||||
* \return int 0 en cas de succès
|
* \return int 0 en cas de succès
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function UpdateLigne($id, $subprice, $qty, $remise_percent=0)
|
function UpdateLigne($id, $subprice, $qty, $remise_percent=0, $tva_tx, $desc='')
|
||||||
{
|
{
|
||||||
if ($this->statut == 0)
|
if ($this->statut == 0)
|
||||||
{
|
{
|
||||||
@ -245,6 +246,8 @@ class Propal
|
|||||||
$sql.= " , price='". ereg_replace(",",".",$price)."'";
|
$sql.= " , price='". ereg_replace(",",".",$price)."'";
|
||||||
$sql.= " , remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
$sql.= " , remise_percent='".ereg_replace(",",".",$remise_percent)."'";
|
||||||
$sql.= " , subprice='".ereg_replace(",",".",$subprice)."'";
|
$sql.= " , subprice='".ereg_replace(",",".",$subprice)."'";
|
||||||
|
$sql.= " , tva_tx='".ereg_replace(",",".",$tva_tx)."'";
|
||||||
|
$sql.= " , description='".addslashes($desc)."'";
|
||||||
$sql.= " WHERE rowid = '".$id."';";
|
$sql.= " WHERE rowid = '".$id."';";
|
||||||
|
|
||||||
if ($this->db->query($sql))
|
if ($this->db->query($sql))
|
||||||
@ -254,6 +257,7 @@ class Propal
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$this->error=$this->db->error();
|
||||||
dolibarr_syslog("Propal::UpdateLigne Erreur -1");
|
dolibarr_syslog("Propal::UpdateLigne Erreur -1");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user