New: Ajout gestion remise/avoirs sur les propales
This commit is contained in:
parent
74fd3687d0
commit
fc0508f8d6
@ -97,7 +97,7 @@ if ($_GET["action"] == 'create')
|
||||
print '<tr><td>'.$langs->trans("Ref").'</td><td colspan="2"><input name="ref" value="'.$numpr.'"></td></tr>';
|
||||
|
||||
// Societe
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->nom_url;
|
||||
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.img_object($langs->trans("ShowCompany"),'company').' '.$soc->nom_url;
|
||||
print '<input type="hidden" name="socidp" value="'.$soc->id.'">';
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -82,7 +82,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
$propalid = 0;
|
||||
$brouillon = 1;
|
||||
}
|
||||
Header('Location: propal.php');
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -96,7 +96,7 @@ if ($_POST['action'] == 'confirm_validate' && $_POST['confirm'] == 'yes')
|
||||
propale_pdf_create($db, $_GET['propalid'], $propal->modelpdf);
|
||||
$result=$propal->valid($user);
|
||||
}
|
||||
Header ('Location: propal.php?propalid='.$_GET['propalid']);
|
||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$_GET['propalid']);
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -135,6 +135,8 @@ if ($_POST['action'] == 'add')
|
||||
$propal->duree_validite = $_POST['duree_validite'];
|
||||
$propal->cond_reglement_id = $_POST['cond_reglement_id'];
|
||||
$propal->mode_reglement_id = $_POST['mode_reglement_id'];
|
||||
$propal->remise_percent = $_POST['remise_percent'];
|
||||
$propal->remise_absolue = $_POST['remise_absolue'];
|
||||
$propal->socidp = $_POST['socidp'];
|
||||
$propal->contactid = $_POST['contactidp'];
|
||||
$propal->projetidp = $_POST['projetidp'];
|
||||
@ -182,7 +184,7 @@ if ($_POST['action'] == 'add')
|
||||
{
|
||||
propale_pdf_create($db, $id, $_POST['model']);
|
||||
|
||||
Header ('Location: propal.php?propalid='.$id);
|
||||
Header ('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$id);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@ -266,7 +268,7 @@ if ($_POST['action'] == 'send')
|
||||
$filename[1] = $_FILES['addedfile']['name'];
|
||||
$mimetype[1] = $_FILES['addedfile']['type'];
|
||||
}
|
||||
// Envoi de la facture
|
||||
// Envoi de la propal
|
||||
$mailfile = new CMailFile($subject,$sendto,$from,$message,$filepath,$mimetype,$filename,$sendtocc);
|
||||
if ($mailfile->sendfile())
|
||||
{
|
||||
@ -291,7 +293,7 @@ if ($_POST['action'] == 'send')
|
||||
else
|
||||
{
|
||||
// Renvoie sur la fiche
|
||||
Header('Location: propal.php?propalid='.$propal->id.'&msg='.urlencode($msg));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&msg='.urlencode($msg));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -433,6 +435,22 @@ if ($_POST["action"] == 'setconditions')
|
||||
if ($resql < 0) dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_REQUEST['propalid']);
|
||||
$result = $propal->set_remise_percent($user, $_POST['remise_percent']);
|
||||
$_GET['propalid']=$_REQUEST['propalid'];
|
||||
}
|
||||
|
||||
if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->propale->creer)
|
||||
{
|
||||
$propal = new Propal($db);
|
||||
$propal->fetch($_REQUEST['propalid']);
|
||||
$result = $propal->set_remise_absolue($user, $_POST['remise_absolue']);
|
||||
$_GET['propalid']=$_REQUEST['propalid'];
|
||||
}
|
||||
|
||||
// Mode de règlement
|
||||
if ($_POST["action"] == 'setmode')
|
||||
{
|
||||
@ -501,7 +519,7 @@ if ($_GET['propalid'] > 0)
|
||||
*/
|
||||
if ($_GET['action'] == 'delete')
|
||||
{
|
||||
$html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete');
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('DeleteProp'), $langs->trans('ConfirmDeleteProp'), 'confirm_delete');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -510,7 +528,7 @@ if ($_GET['propalid'] > 0)
|
||||
*/
|
||||
if ($_GET['action'] == 'validate')
|
||||
{
|
||||
$html->form_confirm('propal.php?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate');
|
||||
$html->form_confirm($_SERVER["PHP_SELF"].'?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate');
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
@ -702,7 +720,7 @@ if ($_GET['propalid'] > 0)
|
||||
if ($propal->statut == 0 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td colspan="2">';
|
||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_project">';
|
||||
$form->select_projects($societe->id, $propal->projetidp, 'projetidp');
|
||||
print '</td><td>';
|
||||
@ -730,31 +748,6 @@ if ($_GET['propalid'] > 0)
|
||||
print '</tr>';
|
||||
}
|
||||
|
||||
// Remise globale
|
||||
/* TODO Remise a mettre sur meme principe que factures
|
||||
print '<tr><td>';
|
||||
print '<table class="nobordernopadding" width="100%"><tr><td>';
|
||||
print $langs->trans('GlobalDiscount');
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'editdiscount' && $propal->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdiscount&propalid='.$propal->id.'">'.img_edit($langs->trans('SetGlobalDiscount'),1).'</a></td>';
|
||||
print '</tr></table>';
|
||||
print '</td><td colspan="3">';
|
||||
if ($_GET['action'] == 'editdiscount' && $propal->brouillon == 1 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_discount">';
|
||||
print '<input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">% ';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
|
||||
print ' <a href="propal/aideremise.php?propalid='.$propal->id.'">?</a>';
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $propal->remise_percent.'%';
|
||||
}
|
||||
print '</td></tr>';
|
||||
*/
|
||||
|
||||
// Amount
|
||||
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>';
|
||||
@ -799,6 +792,7 @@ if ($_GET['propalid'] > 0)
|
||||
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print "</tr>\n";
|
||||
}
|
||||
$var=true;
|
||||
@ -872,16 +866,19 @@ if ($_GET['propalid'] > 0)
|
||||
// Icone d'edition et suppression
|
||||
if ($propal->statut == 0 && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="right"><a href="propal.php?propalid='.$propal->id.'&action=editline&ligne='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=editline&ligne='.$objp->rowid.'">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
print '<td align="right"><a href="propal.php?propalid='.$propal->id.'&action=del_ligne&ligne='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=del_ligne&ligne='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
print '<td align="right">';
|
||||
print ' '; // \todo Mettre critere ordre
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td><td> </td>';
|
||||
print '<td colspan="3"> </td>';
|
||||
}
|
||||
print '</tr>';
|
||||
}
|
||||
@ -889,7 +886,7 @@ if ($_GET['propalid'] > 0)
|
||||
// Ligne en mode update
|
||||
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="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
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"].'">';
|
||||
@ -914,7 +911,7 @@ if ($_GET['propalid'] > 0)
|
||||
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 '<td align="center" colspan="5" 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";
|
||||
/*
|
||||
@ -943,10 +940,122 @@ if ($_GET['propalid'] > 0)
|
||||
dolibarr_print_error($db);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lignes de remise
|
||||
*/
|
||||
|
||||
// Remise relative
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremisepercent">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
print $langs->trans('CustomerRelativeDiscount');
|
||||
if ($propal->brouillon) print ' <font style="font-weight: normal">('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')</font>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] == 'editrelativediscount')
|
||||
{
|
||||
print '<input type="text" name="remise_percent" size="2" value="'.$propal->remise_percent.'">%';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $propal->remise_percent?$propal->remise_percent.'%':' ';
|
||||
}
|
||||
print '</font></td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] != 'editrelativediscount') print $propal->remise_percent?'-'.price($propal->remise_percent*$total/100):$langs->trans("DiscountNone");
|
||||
else print ' ';
|
||||
print '</font></td>';
|
||||
if ($_GET['action'] != 'editrelativediscount')
|
||||
{
|
||||
if ($propal->brouillon && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrelativediscount&propalid='.$propal->id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_percent)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=setremisepercent&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
// Remise absolue
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremiseabsolue">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
print $langs->trans('CustomerAbsoluteDiscount');
|
||||
if ($propal->brouillon) print ' <font style="font-weight: normal">('.($avoir_en_cours?$langs->trans("CompanyHasAbsoluteDiscount",$avoir_en_cours,$langs->trans("Currency".$conf->monnaie)):$langs->trans("CompanyHasNoAbsoluteDiscount")).')</font>';
|
||||
print '</td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><font style="font-weight: normal">';
|
||||
if ($_GET['action'] == 'editabsolutediscount')
|
||||
{
|
||||
print '-<input type="text" name="remise_absolue" size="2" value="'.$propal->remise_absolue.'">';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $propal->remise_absolue?'-'.price($propal->remise_absolue):$langs->trans("DiscountNone");
|
||||
}
|
||||
print '</font></td>';
|
||||
if ($_GET['action'] != 'editabsolutediscount')
|
||||
{
|
||||
if ($propal->brouillon && $user->rights->propale->creer)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editabsolutediscount&propalid='.$propal->id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).'</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_absolue)
|
||||
{
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=setremiseabsolue&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td> </td>';
|
||||
}
|
||||
print '<td> </td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
|
||||
}
|
||||
print '</tr>';
|
||||
print '</form>';
|
||||
|
||||
|
||||
/*
|
||||
* Ajouter une ligne
|
||||
*/
|
||||
|
||||
if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline')
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
@ -958,10 +1067,11 @@ if ($_GET['propalid'] > 0)
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print '<td> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ajout produit produits/services personalisés
|
||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
|
||||
@ -982,7 +1092,7 @@ if ($_GET['propalid'] > 0)
|
||||
print '<td align="right"><input type="text" size="5" name="np_price"></td>';
|
||||
print '<td align="right"><input type="text" size="2" value="1" name="qty"></td>';
|
||||
print '<td align="right" nowrap><input type="text" size="2" value="'.$societe->remise_client.'" name="np_remise">%</td>';
|
||||
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addligne"></td>';
|
||||
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'" name="addligne"></td>';
|
||||
print '</tr>';
|
||||
|
||||
print '</form>';
|
||||
@ -990,7 +1100,7 @@ if ($_GET['propalid'] > 0)
|
||||
// Ajout de produits/services prédéfinis
|
||||
if ($conf->produit->enabled)
|
||||
{
|
||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
|
||||
@ -1013,7 +1123,7 @@ if ($_GET['propalid'] > 0)
|
||||
print '<td> </td>';
|
||||
print '<td align="right"><input type="text" size="2" name="qty" value="1"></td>';
|
||||
print '<td align="right" nowrap><input type="text" size="2" name="remise" value="'.$societe->remise_client.'">%</td>';
|
||||
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne"></td>';
|
||||
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne"></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '</form>';
|
||||
@ -1036,7 +1146,7 @@ if ($_GET['propalid'] > 0)
|
||||
*/
|
||||
if ($_GET['action'] == 'statut')
|
||||
{
|
||||
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'" method="post">';
|
||||
print '<table class="border" width="100%">';
|
||||
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="60" rows="'.ROWS_3.'" wrap="soft" name="note">';
|
||||
print $propal->note;
|
||||
@ -1069,7 +1179,7 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
if ($user->rights->propale->valider)
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=validate">'.$langs->trans('Validate').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=validate">'.$langs->trans('Validate').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1078,7 +1188,7 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
if ($user->rights->propale->creer)
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=modif">'.$langs->trans('Edit').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1087,11 +1197,11 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
if ($propal->statut < 2)
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("BuildPDF").'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("BuildPDF").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("RebuildPDF").'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=builddoc">'.$langs->trans("RebuildPDF").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1104,7 +1214,7 @@ if ($_GET['propalid'] > 0)
|
||||
$file = $conf->propal->dir_output . '/'.$propref.'/'.$propref.'.pdf';
|
||||
if (file_exists($file))
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=presend">'.$langs->trans('Send').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=presend">'.$langs->trans('Send').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1114,7 +1224,7 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
if ($propal->statut == 1 && $user->rights->propale->cloturer)
|
||||
{
|
||||
print '<a class="butAction" href="propal.php?propalid='.$propal->id.'&action=statut">'.$langs->trans('Close').'</a>';
|
||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=statut">'.$langs->trans('Close').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1123,7 +1233,7 @@ if ($_GET['propalid'] > 0)
|
||||
{
|
||||
if ($user->rights->propale->supprimer)
|
||||
{
|
||||
print '<a class="butActionDelete" href="propal.php?propalid='.$propal->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?propalid='.$propal->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
@ -1340,15 +1450,15 @@ else
|
||||
$i = 0;
|
||||
print '<table class="liste" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans('Ref'),'propal.php','p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),'propal.php','s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),'propal.php','p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('DateEndPropalShort'),'propal.php','dfv','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Price'),'propal.php','p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),'propal.php','p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER["PHP_SELF"],'p.ref','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Company'),$_SERVER["PHP_SELF"],'s.nom','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER["PHP_SELF"],'p.datep','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('DateEndPropalShort'),$_SERVER["PHP_SELF"],'dfv','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="center"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Price'),$_SERVER["PHP_SELF"],'p.price','','&socidp='.$socidp.'&viewstatut='.$viewstatut, 'align="right"',$sortfield);
|
||||
print_liste_field_titre($langs->trans('Status'),$_SERVER["PHP_SELF"],'p.fk_statut','','&socidp='.$socidp.'&viewstatut='.$viewstatut,'align="right"',$sortfield);
|
||||
print "</tr>\n";
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="propal.php">';
|
||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
@ -1374,7 +1484,7 @@ else
|
||||
$now = time();
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td><a href="propal.php?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."</a></td>\n";
|
||||
print '<td><a href="'.$_SERVER["PHP_SELF"].'?propalid='.$objp->propalid.'">'.img_object($langs->trans('ShowPropal'),'propal').' '.$objp->ref."</a></td>\n";
|
||||
|
||||
if ($objp->client == 1)
|
||||
{
|
||||
@ -1392,9 +1502,9 @@ else
|
||||
$m = strftime('%m',$objp->dp);
|
||||
|
||||
print strftime('%d',$objp->dp)."\n";
|
||||
print ' <a href="propal.php?year='.$y.'&month='.$m.'">';
|
||||
print ' <a href="'.$_SERVER["PHP_SELF"].'?year='.$y.'&month='.$m.'">';
|
||||
print dolibarr_print_date($objp->dp,'%b')."</a>\n";
|
||||
print ' <a href="propal.php?year='.$y.'">';
|
||||
print ' <a href="'.$_SERVER["PHP_SELF"].'?year='.$y.'">';
|
||||
print strftime('%Y',$objp->dp)."</a></td>\n";
|
||||
|
||||
// Date fin validite
|
||||
|
||||
@ -197,7 +197,7 @@ if ($_POST['action'] == 'add')
|
||||
|
||||
if ($facid > 0)
|
||||
{
|
||||
Header('Location: facture.php?facid='.$facid);
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
|
||||
exit;
|
||||
}
|
||||
else
|
||||
@ -334,7 +334,7 @@ if ($_POST['action'] == 'add')
|
||||
// Fin création facture, on l'affiche
|
||||
if ($facid > 0)
|
||||
{
|
||||
Header('Location: facture.php?facid='.$facid);
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$facid);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -419,7 +419,7 @@ if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST
|
||||
|
||||
if ($_POST['action'] == 'updateligne' && $user->rights->facture->creer && $_POST['cancel'] == $langs->trans('Cancel'))
|
||||
{
|
||||
Header('Location: facture.php?facid='.$_POST['facid']); // Pour réaffichage de la fiche en cours d'édition
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$_POST['facid']); // Pour réaffichage de la fiche en cours d'édition
|
||||
exit;
|
||||
}
|
||||
|
||||
@ -437,7 +437,7 @@ if ($_POST['action'] == 'confirm_delete' && $_POST['confirm'] == 'yes')
|
||||
$fac = new Facture($db);
|
||||
$result = $fac->delete($_GET['facid']);
|
||||
$_GET['facid'] = 0 ;
|
||||
Header('Location: facture.php');
|
||||
Header('Location: '.$_SERVER["PHP_SELF"]);
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -564,7 +564,7 @@ if ($_POST['action'] == 'send' || $_POST['action'] == 'relance')
|
||||
else
|
||||
{
|
||||
// Renvoie sur la fiche
|
||||
Header('Location: facture.php?facid='.$fac->id.'&msg='.urlencode($msg));
|
||||
Header('Location: '.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&msg='.urlencode($msg));
|
||||
exit;
|
||||
}
|
||||
}
|
||||
@ -682,7 +682,7 @@ if ($_GET['action'] == 'create')
|
||||
}
|
||||
|
||||
|
||||
print '<form name="add" action="facture.php" method="post">';
|
||||
print '<form name="add" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="add">';
|
||||
print '<input type="hidden" name="socid" value="'.$soc->id.'">' ."\n";
|
||||
print '<input name="facnumber" type="hidden" value="provisoire">';
|
||||
@ -1388,7 +1388,7 @@ else
|
||||
|
||||
if ($fac->brouillon == 1 && $user->rights->facture->creer)
|
||||
{
|
||||
print '<form action="facture.php?facid='.$fac->id.'" method="post">';
|
||||
print '<form action="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'" method="post">';
|
||||
print '<input type="hidden" name="action" value="set_ref_client">';
|
||||
print '<td colspan="3"><input type="text" name="ref_client" size="20" value="'.$fac->ref_client.'">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'"></td>';
|
||||
@ -1452,7 +1452,7 @@ else
|
||||
print '</td>';
|
||||
if ($_GET['action'] != 'classer')
|
||||
{
|
||||
print '<td align="right"><a href="facture.php?action=classer&facid='.$fac->id.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&facid='.$fac->id.'">';
|
||||
print img_edit($langs->trans('SetProject'),1);
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -1509,7 +1509,9 @@ else
|
||||
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('AmountHT').'</td>';
|
||||
print '<td width="16"> </td><td width="16"> </td><td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print '<td width="16"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
@ -1562,22 +1564,22 @@ else
|
||||
// Icone d'edition et suppression
|
||||
if ($fac->statut == 0 && $user->rights->facture->creer)
|
||||
{
|
||||
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&action=editline&rowid='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=editline&rowid='.$objp->rowid.'">';
|
||||
print img_edit();
|
||||
print '</a></td>';
|
||||
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&action=deleteline&rowid='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=deleteline&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
print '<td align="right">';
|
||||
if ($i > 0)
|
||||
{
|
||||
print '<a href="facture.php?facid='.$fac->id.'&action=up&rowid='.$objp->rowid.'">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=up&rowid='.$objp->rowid.'">';
|
||||
print img_up();
|
||||
print '</a>';
|
||||
}
|
||||
if ($i < $num_lignes-1)
|
||||
{
|
||||
print '<a href="facture.php?facid='.$fac->id.'&action=down&rowid='.$objp->rowid.'">';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=down&rowid='.$objp->rowid.'">';
|
||||
print img_down();
|
||||
print '</a>';
|
||||
}
|
||||
@ -1593,7 +1595,7 @@ else
|
||||
// Ligne en mode update
|
||||
if ($_GET['action'] == 'editline' && $user->rights->facture->creer && $_GET['rowid'] == $objp->rowid)
|
||||
{
|
||||
print '<form name="updateligne" action="facture.php" method="post">';
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="updateligne">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<input type="hidden" name="rowid" value="'.$_GET['rowid'].'">';
|
||||
@ -1651,7 +1653,7 @@ else
|
||||
|
||||
// Remise relative
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="facture.php" method="post">';
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremisepercent">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
@ -1687,7 +1689,7 @@ else
|
||||
}
|
||||
if ($fac->brouillon && $user->rights->facture->creer && $fac->remise_percent)
|
||||
{
|
||||
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&action=setremisepercent&rowid='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=setremisepercent&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -1706,7 +1708,7 @@ else
|
||||
|
||||
// Remise absolue
|
||||
$var=!$var;
|
||||
print '<form name="updateligne" action="facture.php" method="post">';
|
||||
print '<form name="updateligne" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
||||
print '<input type="hidden" name="action" value="setremiseabsolue">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<tr class="liste_total"><td>';
|
||||
@ -1739,7 +1741,7 @@ else
|
||||
}
|
||||
if ($fac->brouillon && $user->rights->facture->creer && $fac->remise_absolue)
|
||||
{
|
||||
print '<td align="right"><a href="facture.php?facid='.$fac->id.'&action=setremiseabsolue&rowid='.$objp->rowid.'">';
|
||||
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=setremiseabsolue&rowid='.$objp->rowid.'">';
|
||||
print img_delete();
|
||||
print '</a></td>';
|
||||
}
|
||||
@ -1792,7 +1794,7 @@ else
|
||||
print '<td align="right"><input type="text" name="pu" size="6"></td>';
|
||||
print '<td align="right"><input type="text" name="qty" value="1" size="2"></td>';
|
||||
print '<td align="right" nowrap><input type="text" name="remise_percent" size="1" value="0">%</td>';
|
||||
print '<td align="center" valign="middle" rowspan="1" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '<td align="center" valign="middle" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
|
||||
print '</tr>';
|
||||
if ($conf->service->enabled)
|
||||
{
|
||||
@ -1859,7 +1861,7 @@ else
|
||||
{
|
||||
if ($user->rights->facture->valider)
|
||||
{
|
||||
print ' <a class="butAction" href="facture.php?facid='.$fac->id.'&action=valid">'.$langs->trans('Validate').'</a>';
|
||||
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=valid">'.$langs->trans('Validate').'</a>';
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -1869,11 +1871,11 @@ else
|
||||
{
|
||||
if ($fac->paye == 0)
|
||||
{
|
||||
print ' <a class="butAction" href="facture.php?facid='.$fac->id.'&action=builddoc">'.$langs->trans('BuildPDF').'</a>';
|
||||
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=builddoc">'.$langs->trans('BuildPDF').'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print ' <a class="butAction" href="facture.php?facid='.$fac->id.'&action=builddoc">'.$langs->trans('RebuildPDF').'</a>';
|
||||
print ' <a class="butAction" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=builddoc">'.$langs->trans('RebuildPDF').'</a>';
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1881,7 +1883,7 @@ else
|
||||
// Supprimer
|
||||
if ($fac->statut == 0 && $user->rights->facture->supprimer && $_GET['action'] != 'delete')
|
||||
{
|
||||
print '<a class="butActionDelete" href="facture.php?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?facid='.$fac->id.'&action=delete">'.$langs->trans('Delete').'</a>';
|
||||
}
|
||||
|
||||
// Envoyer
|
||||
@ -2279,7 +2281,7 @@ else
|
||||
print '</tr>';
|
||||
|
||||
// Lignes des champs de filtre
|
||||
print '<form method="get" action="facture.php">';
|
||||
print '<form method="get" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td class="liste_titre" valign="right">';
|
||||
print '<input class="flat" size="10" type="text" name="search_ref" value="'.$_GET['search_ref'].'">';
|
||||
@ -2308,8 +2310,8 @@ else
|
||||
$var=!$var;
|
||||
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td nowrap="nowrap"><a href="facture.php?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').'</a> ';
|
||||
print '<a href="facture.php?facid='.$objp->facid.'">'.$objp->facnumber.'</a>'.$objp->increment;
|
||||
print '<td nowrap="nowrap"><a href="'.$_SERVER["PHP_SELF"].'?facid='.$objp->facid.'">'.img_object($langs->trans('ShowBill'),'bill').'</a> ';
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?facid='.$objp->facid.'">'.$objp->facnumber.'</a>'.$objp->increment;
|
||||
if ($objp->datelimite < (time() - $conf->facture->client->warning_delay) && ! $objp->paye && $objp->fk_statut == 1 && ! $objp->am) print img_warning($langs->trans('Late'));
|
||||
print '</td>';
|
||||
|
||||
@ -2319,9 +2321,9 @@ else
|
||||
$y = strftime('%Y',$objp->df);
|
||||
$m = strftime('%m',$objp->df);
|
||||
print strftime('%d',$objp->df);
|
||||
print ' <a href="facture.php?year='.$y.'&month='.$m.'">';
|
||||
print ' <a href="'.$_SERVER["PHP_SELF"].'?year='.$y.'&month='.$m.'">';
|
||||
print substr(strftime('%B',$objp->df),0,3).'</a>';
|
||||
print ' <a href="facture.php?year='.$y.'">';
|
||||
print ' <a href="'.$_SERVER["PHP_SELF"].'?year='.$y.'">';
|
||||
print strftime('%Y',$objp->df).'</a></td>';
|
||||
}
|
||||
else
|
||||
|
||||
@ -1213,8 +1213,10 @@ class Facture
|
||||
|
||||
if ($user->rights->facture->creer)
|
||||
{
|
||||
$remise=price2num($remise);
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||
$sql.= ' SET remise_percent = '.price2num($remise);
|
||||
$sql.= ' SET remise_percent = '.$remise;
|
||||
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
|
||||
|
||||
if ($this->db->query($sql))
|
||||
@ -1244,8 +1246,10 @@ class Facture
|
||||
|
||||
if ($user->rights->facture->creer)
|
||||
{
|
||||
$remise=price2num($remise);
|
||||
|
||||
$sql = 'UPDATE '.MAIN_DB_PREFIX.'facture';
|
||||
$sql.= ' SET remise_absolue = '.price2num($remise);
|
||||
$sql.= ' SET remise_absolue = '.$remise;
|
||||
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
|
||||
|
||||
dolibarr_syslog("Facture::set_remise_absolue sql=$sql");
|
||||
|
||||
@ -51,7 +51,6 @@ class Propal
|
||||
var $author;
|
||||
var $ref;
|
||||
var $datep;
|
||||
var $remise;
|
||||
var $products;
|
||||
var $products_qty;
|
||||
var $price;
|
||||
@ -61,6 +60,9 @@ class Propal
|
||||
var $cond_reglement_code;
|
||||
var $mode_reglement_id;
|
||||
var $mode_reglement_code;
|
||||
var $remise;
|
||||
var $remise_percent;
|
||||
var $remise_absolue;
|
||||
var $note;
|
||||
var $note_public;
|
||||
|
||||
@ -91,6 +93,8 @@ class Propal
|
||||
$this->id = $propalid;
|
||||
$this->products = array();
|
||||
$this->remise = 0;
|
||||
$this->remise_percent = 0;
|
||||
$this->remise_absolue = 0;
|
||||
|
||||
$langs->load("propals");
|
||||
$this->labelstatut[0]=$langs->trans("PropalStatusDraft");
|
||||
@ -108,9 +112,9 @@ class Propal
|
||||
|
||||
/**
|
||||
* \brief Ajout d'un produit dans la proposition, en memoire dans l'objet
|
||||
* \param idproduct id du produit à ajouter
|
||||
* \param qty quantité
|
||||
* \param remise_percent remise effectuée sur le produit
|
||||
* \param idproduct Id du produit à ajouter
|
||||
* \param qty Quantité
|
||||
* \param remise_percent Remise relative effectuée sur le produit
|
||||
* \return void
|
||||
* \see insert_product
|
||||
*/
|
||||
@ -134,7 +138,7 @@ class Propal
|
||||
* \brief Ajout d'un produit dans la proposition, en base
|
||||
* \param idproduct Id du produit à ajouter
|
||||
* \param qty Quantité
|
||||
* \param remise_percent Remise effectuée sur le produit
|
||||
* \param remise_percent Remise relative effectuée sur le produit
|
||||
* \param p_desc Descriptif optionnel
|
||||
* \return int >0 si ok, <0 si ko
|
||||
* \see add_product
|
||||
@ -382,8 +386,10 @@ class Propal
|
||||
$this->db->begin();
|
||||
|
||||
// Insertion dans la base
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite, fk_cond_reglement, fk_mode_reglement, date_livraison) ";
|
||||
$sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, remise_percent, remise_absolue,";
|
||||
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite, fk_cond_reglement, fk_mode_reglement, date_livraison) ";
|
||||
$sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, $this->remise_percent, $this->remise_absolue,";
|
||||
$sql.= " 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author,";
|
||||
$sql.= "'".addslashes($this->note)."',";
|
||||
$sql.= "'".addslashes($this->note_public)."',";
|
||||
$sql.= "'$this->modelpdf',".$this->db->idate($this->fin_validite).",";
|
||||
@ -474,20 +480,22 @@ class Propal
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
$calculs = calcul_price($products, $this->remise_percent);
|
||||
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
|
||||
|
||||
$this->remise = $calculs[3];
|
||||
$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
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal SET";
|
||||
$sql .= " price='". price2num($this->total_ht)."'";
|
||||
$sql .= ", tva='". price2num($this->total_tva)."'";
|
||||
$sql .= ", total='". price2num($this->total_ttc)."'";
|
||||
$sql .= ", remise='".price2num($this->remise)."'";
|
||||
$sql .=" WHERE rowid = $this->id";
|
||||
$sql .= ", remise='".price2num($this->total_remise)."'";
|
||||
$sql .=" WHERE rowid = ".$this->id;
|
||||
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
@ -507,15 +515,15 @@ class Propal
|
||||
*/
|
||||
function fetch($rowid)
|
||||
{
|
||||
$sql = "SELECT ref,total,price,remise,tva,fk_soc,fk_soc_contact";
|
||||
$sql = "SELECT ref,total,price,remise,remise_percent,remise_absolue,tva,fk_soc,fk_soc_contact";
|
||||
$sql.= ", ".$this->db->pdate("datep")."as dp";
|
||||
$sql.= ", ".$this->db->pdate("fin_validite")."as dfv, model_pdf";
|
||||
$sql.= ", note, note_public";
|
||||
$sql.= ", fk_projet, fk_statut, remise_percent, fk_user_author";
|
||||
$sql.= ", fk_projet, fk_statut, fk_user_author";
|
||||
$sql.= ", fk_cond_reglement, fk_mode_reglement, date_livraison";
|
||||
$sql.= ", c.label as statut_label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal";
|
||||
$sql.= "," . MAIN_DB_PREFIX."c_propalst as c";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."propal,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."c_propalst as c";
|
||||
$sql.= " WHERE fk_statut = c.id";
|
||||
$sql.= " AND rowid='".$rowid."';";
|
||||
|
||||
@ -536,6 +544,7 @@ class Propal
|
||||
$this->price = $obj->price;
|
||||
$this->remise = $obj->remise;
|
||||
$this->remise_percent = $obj->remise_percent;
|
||||
$this->remise_absolue = $obj->remise_absolue;
|
||||
$this->total = $obj->total;
|
||||
$this->total_ht = $obj->price;
|
||||
$this->total_tva = $obj->tva;
|
||||
@ -551,7 +560,7 @@ class Propal
|
||||
$this->statut_libelle = $obj->statut_label;
|
||||
$this->cond_reglement_id = $obj->fk_cond_reglement;
|
||||
$this->mode_reglement_id = $obj->fk_mode_reglement;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
$this->date_livraison = $obj->date_livraison;
|
||||
|
||||
$this->user_author_id = $obj->fk_user_author;
|
||||
|
||||
@ -737,10 +746,10 @@ class Propal
|
||||
|
||||
|
||||
/**
|
||||
* \brief Définit une remise globale sur la proposition
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param remise Montant remise
|
||||
* \return int <0 si ko, >0 si ok
|
||||
* \brief Définit la date de fin de validité
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param date_fin_validite Date fin
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_echeance($user, $date_fin_validite)
|
||||
{
|
||||
@ -761,7 +770,8 @@ class Propal
|
||||
}
|
||||
}
|
||||
}
|
||||
/**
|
||||
|
||||
/**
|
||||
* \brief Définit une date de livraison
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param date_livraison date de livraison
|
||||
@ -790,13 +800,15 @@ class Propal
|
||||
|
||||
|
||||
/**
|
||||
* \brief Définit une remise globale sur la proposition
|
||||
* \brief Définit une remise globale relative sur la proposition
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param remise Montant remise
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_remise($user, $remise)
|
||||
function set_remise_percent($user, $remise)
|
||||
{
|
||||
$remise=trim($remise)?trim($remise):0;
|
||||
|
||||
if ($user->rights->propale->creer)
|
||||
{
|
||||
$remise = price2num($remise);
|
||||
@ -813,20 +825,53 @@ class Propal
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Propal::set_remise Erreur SQL");
|
||||
dolibarr_syslog("Propal::set_remise_percent Error sql=$sql");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function set_project($user, $project_id)
|
||||
{
|
||||
/**
|
||||
* \brief Définit une remise globale absolue sur la proposition
|
||||
* \param user Objet utilisateur qui modifie
|
||||
* \param remise Montant remise
|
||||
* \return int <0 si ko, >0 si ok
|
||||
*/
|
||||
function set_remise_absolue($user, $remise)
|
||||
{
|
||||
$remise=trim($remise)?trim($remise):0;
|
||||
|
||||
if ($user->rights->propale->creer)
|
||||
{
|
||||
$remise = price2num($remise);
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."propal ";
|
||||
$sql.= " SET remise_absolue = ".$remise;
|
||||
$sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0";
|
||||
|
||||
if ($this->db->query($sql) )
|
||||
{
|
||||
$this->remise_absolue = $remise;
|
||||
$this->update_price();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
dolibarr_syslog("Propal::set_remise_absolue Error sql=$sql");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
function set_project($user, $project_id)
|
||||
{
|
||||
if ($user->rights->propale->creer)
|
||||
{
|
||||
//verif que le projet et la société concordent
|
||||
@ -1190,10 +1235,10 @@ class Propal
|
||||
*/
|
||||
function delete($user)
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $this->id ;";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = $this->id;";
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."propal WHERE rowid = ".$this->id;
|
||||
if ( $this->db->query($sql) )
|
||||
{
|
||||
dolibarr_syslog("Suppression de la proposition $this->id par $user->fullname ($user->id)");
|
||||
@ -1503,6 +1548,7 @@ class Propal
|
||||
$this->price = $src_propal->price;
|
||||
$this->remise = $src_propal->remise;
|
||||
$this->remise_percent = $src_propal->remise_percent;
|
||||
$this->remise_absolue = $src_propal->remise_absolue;
|
||||
$this->total = $src_propal->total;
|
||||
$this->total_ht = $src_propal->total_ht;
|
||||
$this->total_tva = $src_propal->total_tva;
|
||||
@ -1541,8 +1587,10 @@ class Propal
|
||||
$this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
|
||||
|
||||
// Insertion dans la base
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite, fk_cond_reglement, fk_mode_reglement, date_livraison) ";
|
||||
$sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author,";
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."propal (fk_soc, fk_soc_contact, price, remise, remise_percent, remise_absolue,";
|
||||
$sql.= " tva, total, datep, datec, ref, fk_user_author, note, note_public, model_pdf, fin_validite, fk_cond_reglement, fk_mode_reglement, date_livraison) ";
|
||||
$sql.= " VALUES ($this->socidp, $this->contactid, 0, $this->remise, $this->remise_percent, $this->remise_absolue,";
|
||||
$sql.= " 0,0,".$this->db->idate($this->datep).", now(), '$this->ref', $this->author,";
|
||||
$sql.= "'".addslashes($this->note)."',";
|
||||
$sql.= "'".addslashes($this->note_public)."',";
|
||||
$sql.= "'$this->modelpdf',".$this->db->idate($this->fin_validite).",";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user