From fc0508f8d66de70c301a5da2c6647e6174eddb2a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sat, 8 Apr 2006 11:39:41 +0000 Subject: [PATCH] New: Ajout gestion remise/avoirs sur les propales --- htdocs/comm/addpropal.php | 2 +- htdocs/comm/propal.php | 234 ++++++++++++++++++++++++++++---------- htdocs/compta/facture.php | 58 +++++----- htdocs/facture.class.php | 8 +- htdocs/propal.class.php | 118 +++++++++++++------ 5 files changed, 292 insertions(+), 128 deletions(-) diff --git a/htdocs/comm/addpropal.php b/htdocs/comm/addpropal.php index 55cff9e817b..c75f9d2d90b 100644 --- a/htdocs/comm/addpropal.php +++ b/htdocs/comm/addpropal.php @@ -97,7 +97,7 @@ if ($_GET["action"] == 'create') print ''.$langs->trans("Ref").''; // Societe - print ''.$langs->trans('Company').''.$soc->nom_url; + print ''.$langs->trans('Company').''.img_object($langs->trans("ShowCompany"),'company').' '.$soc->nom_url; print ''; print ''; print ''; diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php index 66d18376685..46f363bf281 100644 --- a/htdocs/comm/propal.php +++ b/htdocs/comm/propal.php @@ -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 '
'; } @@ -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 '
'; } @@ -702,7 +720,7 @@ if ($_GET['propalid'] > 0) if ($propal->statut == 0 && $user->rights->propale->creer) { print ''; - print '
'; + print ''; print ''; $form->select_projects($societe->id, $propal->projetidp, 'projetidp'); print ''; @@ -730,31 +748,6 @@ if ($_GET['propalid'] > 0) print ''; } - // Remise globale -/* TODO Remise a mettre sur meme principe que factures - print ''; - print ''; - if ($_GET['action'] != 'editdiscount' && $propal->brouillon) print ''; - print '
'; - print $langs->trans('GlobalDiscount'); - print 'id.'">'.img_edit($langs->trans('SetGlobalDiscount'),1).'
'; - print ''; - if ($_GET['action'] == 'editdiscount' && $propal->brouillon == 1 && $user->rights->propale->creer) - { - print ''; - print ''; - print '% '; - print ''; - print ' ?'; - print '
'; - } - else - { - print $propal->remise_percent.'%'; - } - print ''; -*/ - // Amount print ''.$langs->trans('AmountHT').''; print ''.price($propal->price).''; @@ -799,6 +792,7 @@ if ($_GET['propalid'] > 0) print ''.$langs->trans('AmountHT').''; print ' '; print ' '; + print ' '; print "\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 ''; + print 'rowid.'">'; print img_edit(); print ''; - print ''; + print 'rowid.'">'; print img_delete(); print ''; - } + print ''; + print ' '; // \todo Mettre critere ordre + print ''; + } else { - print '  '; + print ' '; } print ''; } @@ -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 '
'; + print ''; print ''; print ''; print ''; @@ -914,7 +911,7 @@ if ($_GET['propalid'] > 0) print ''; print ''; print '%'; - print ''; + print ''; print '
'; print '' . "\n"; /* @@ -943,10 +940,122 @@ if ($_GET['propalid'] > 0) dolibarr_print_error($db); } + + /* + * Lignes de remise + */ + + // Remise relative + $var=!$var; + print ''; + print ''; + print ''; + print ''; + print $langs->trans('CustomerRelativeDiscount'); + if ($propal->brouillon) print ' ('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')'; + print ''; + print ' '; + print ' '; + print ' '; + print ''; + if ($_GET['action'] == 'editrelativediscount') + { + print '%'; + } + else + { + print $propal->remise_percent?$propal->remise_percent.'%':' '; + } + print ''; + print ''; + if ($_GET['action'] != 'editrelativediscount') print $propal->remise_percent?'-'.price($propal->remise_percent*$total/100):$langs->trans("DiscountNone"); + else print ' '; + print ''; + if ($_GET['action'] != 'editrelativediscount') + { + if ($propal->brouillon && $user->rights->propale->creer) + { + print 'id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).''; + } + else + { + print ' '; + } + if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_percent) + { + print 'rowid.'">'; + print img_delete(); + print ''; + } + else + { + print ' '; + } + print ' '; + } + else + { + print ''; + } + print ''; + print '
'; + + // Remise absolue + $var=!$var; + print '
'; + print ''; + print ''; + print ''; + print $langs->trans('CustomerAbsoluteDiscount'); + if ($propal->brouillon) print ' ('.($avoir_en_cours?$langs->trans("CompanyHasAbsoluteDiscount",$avoir_en_cours,$langs->trans("Currency".$conf->monnaie)):$langs->trans("CompanyHasNoAbsoluteDiscount")).')'; + print ''; + print ' '; + print ' '; + print ' '; + print ' '; + print ''; + if ($_GET['action'] == 'editabsolutediscount') + { + print '-'; + } + else + { + print $propal->remise_absolue?'-'.price($propal->remise_absolue):$langs->trans("DiscountNone"); + } + print ''; + if ($_GET['action'] != 'editabsolutediscount') + { + if ($propal->brouillon && $user->rights->propale->creer) + { + print 'id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).''; + } + else + { + print ' '; + } + if ($propal->brouillon && $user->rights->propale->creer && $propal->remise_absolue) + { + print 'rowid.'">'; + print img_delete(); + print ''; + } + else + { + print ' '; + } + print ' '; + } + else + { + print ''; + } + print ''; + print '
'; + + /* * Ajouter une ligne */ - if ($propal->statut == 0 && $user->rights->propale->creer && $_GET["action"] <> 'editline') { print ''; @@ -958,10 +1067,11 @@ if ($_GET['propalid'] > 0) print ' '; print ' '; print ' '; + print ' '; print "\n"; // Ajout produit produits/services personalisés - print '
'; + print ''; print ''; print ''; @@ -982,7 +1092,7 @@ if ($_GET['propalid'] > 0) print ''; print ''; print '%'; - print ''; + print ''; print ''; print '
'; @@ -990,7 +1100,7 @@ if ($_GET['propalid'] > 0) // Ajout de produits/services prédéfinis if ($conf->produit->enabled) { - print '
'; + print ''; print ''; print ''; @@ -1013,7 +1123,7 @@ if ($_GET['propalid'] > 0) print ' '; print ''; print '%'; - print ''; + print ''; print "\n"; print '
'; @@ -1036,7 +1146,7 @@ if ($_GET['propalid'] > 0) */ if ($_GET['action'] == 'statut') { - print '
'; + print ''; print ''; print '
'.$langs->trans('Note').'