diff --git a/htdocs/comm/remise.php b/htdocs/comm/remise.php index 720a3e9e76c..f65555fe909 100644 --- a/htdocs/comm/remise.php +++ b/htdocs/comm/remise.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2005 Laurent Destailleur + * Copyright (C) 2004-2006 Laurent Destailleur * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -172,11 +172,12 @@ if ($_socid > 0) /* * Liste de l'historique des remises */ - $sql = "SELECT rc.rowid,rc.remise_client,".$db->pdate("rc.datec")." as dc, u.code"; - $sql .= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; - $sql .= " WHERE rc.fk_soc =". $objsoc->id; - $sql .= " AND u.rowid = rc.fk_user_author"; - $sql .= " ORDER BY rc.datec DESC"; + $sql = "SELECT rc.rowid,rc.remise_client,".$db->pdate("rc.datec")." as dc,"; + $sql.= " u.rowid as user_id, u.code"; + $sql.= " FROM ".MAIN_DB_PREFIX."societe_remise as rc, ".MAIN_DB_PREFIX."user as u"; + $sql.= " WHERE rc.fk_soc =". $objsoc->id; + $sql.= " AND u.rowid = rc.fk_user_author"; + $sql.= " ORDER BY rc.datec DESC"; $resql=$db->query($sql); if ($resql) @@ -186,7 +187,7 @@ if ($_socid > 0) print ''; print ''.$langs->trans("Date").''; print ''.$langs->trans("Discount").''; - print ''.$langs->trans("User").''; + print ''.$langs->trans("User").''; print ''; $i = 0 ; $num = $db->num_rows($resql); @@ -198,7 +199,7 @@ if ($_socid > 0) print ''; print ''.dolibarr_print_date($obj->dc,"%d %B %Y %H:%M").''; print ''.$obj->remise_client.' %'; - print ''.$obj->code.''; + print ''.img_object($langs->trans("ShowUser"),'user').' '.$obj->code.''; print ''; $i++; } diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 21c9b361395..8bcfa1cf3bf 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -94,6 +94,22 @@ if ($_POST['action'] == 'setconditions') if ($result < 0) dolibarr_print_error($facture->db,$facture->error); } +if ($_POST['action'] == 'setremisepercent' && $user->rights->facture->creer) +{ + $fac = new Facture($db); + $fac->fetch($_POST['facid']); + $result = $fac->set_remise($user, $_POST['remise_percent']); + $_GET['facid']=$_POST['facid']; +} + +if ($_POST['action'] == 'setremiseabsolue' && $user->rights->facture->creer) +{ + $fac = new Facture($db); + $fac->fetch($_POST['facid']); + $result = $fac->set_remise_absolue($user, $_POST['remise_absolue']); + $_GET['facid']=$_POST['facid']; +} + if ($_POST['action'] == 'classin') { $facture = new Facture($db); @@ -108,6 +124,28 @@ if ($_POST['action'] == 'set_ref_client') $facture->set_ref_client($_POST['ref_client']); } +// Classe à "validée" +if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->facture->valider) +{ + $fac = new Facture($db); + $fac->fetch($_GET['facid']); + $soc = new Societe($db); + $soc->fetch($fac->socidp); + $result = $fac->set_valid($fac->id, $user, $soc); + if ($result) + { + facture_pdf_create($db, $fac->id); + } +} + +// Classe à "payée" +if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement) +{ + $fac = new Facture($db); + $fac->fetch($_GET['facid']); + $result = $fac->set_payed($user); +} + /* * Insertion facture */ @@ -134,7 +172,7 @@ if ($_POST['action'] == 'add') $facture->cond_reglement_id = $_POST['cond_reglement_id']; $facture->mode_reglement_id = $_POST['mode_reglement_id']; $facture->amount = $_POST['amount']; - $facture->remise = $_POST['remise']; + $facture->remise_absolue = $_POST['remise_absolue']; $facture->remise_percent = $_POST['remise_percent']; $facture->ref_client = $_POST['ref_client']; @@ -303,35 +341,6 @@ if ($_POST['action'] == 'add') } } -// Classe à "validée" -if ($_POST['action'] == 'confirm_valid' && $_POST['confirm'] == 'yes' && $user->rights->facture->valider) -{ - $fac = new Facture($db); - $fac->fetch($_GET['facid']); - $soc = new Societe($db); - $soc->fetch($fac->socidp); - $result = $fac->set_valid($fac->id, $user, $soc); - if ($result) - { - facture_pdf_create($db, $fac->id); - } -} - -// Classe à "payée" -if ($_POST['action'] == 'confirm_payed' && $_POST['confirm'] == 'yes' && $user->rights->facture->paiement) -{ - $fac = new Facture($db); - $fac->fetch($_GET['facid']); - $result = $fac->set_payed($user); -} - -if ($_POST['action'] == 'setremise' && $user->rights->facture->creer) -{ - $fac = new Facture($db); - $fac->fetch($_GET['facid']); - $result = $fac->set_remise($user, $_POST['remise']); -} - if (($_POST['action'] == 'addligne' || $_POST['action'] == 'addligne_predef') && $user->rights->facture->creer) { if ($_POST['qty'] && ( $_POST['desc'] || $_POST['idprod'])) @@ -676,45 +685,77 @@ if ($_GET['action'] == 'create') print '
'; print ''; print '' ."\n"; + print ''; print ''; // Reference print ''; - print ''; + // Societe print ''; print ''; - print ''; - print ''; - - print ''; // Conditions de réglement - print ''; // Mode de réglement - print ''; + // Remise relative + $relative_discount=$soc->remise_client; + print ''; + print ''; + + // Remise avoirs + $absolute_discount=$soc->getCurrentDiscount(); + print ''; + print ''; + // Projet if ($conf->projet->enabled) { $langs->load('projects'); - print ''; } // Note publique + print ''; print ''; - print ''; // Note privée + print ''; print ''; - print '
'.$langs->trans('Ref').''.$langs->trans('Draft').'
'.$langs->trans('Company').''.$soc->nom_url.'
'.$langs->trans('Author').''.$user->fullname.'
'.$langs->trans('Date').''; + // Date facture + print '
'.$langs->trans('Date').''; $html->select_date('','','','','',"add"); print '
'.$langs->trans('PaymentConditions').''; + print '
'.$langs->trans('PaymentConditions').''; $html->select_conditions_paiements($cond_reglement_id,'cond_reglement_id'); print '
'.$langs->trans('PaymentMode').''; + print '
'.$langs->trans('PaymentMode').''; $html->select_types_paiements($mode_reglement_id,'mode_reglement_id'); print '
'.$langs->trans("CustomerRelativeDiscount").''; + print ' %'; + print ''.img_info().' '; + if ($relative_discount) + { + print $langs->trans("CompanyHasRelativeDiscount",$relative_discount); + } + else + { + print $langs->trans("CompanyHasNoRelativeDiscount"); + } + print '
'.$langs->trans("CustomerAbsoluteDiscount").''; + print ' '.$langs->trans("Currency".$conf->monnaie); + print ''.img_info().' '; + if ($absolute_discount) + { + print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie)); + } + else + { + print $langs->trans("CompanyHasNoAbsoluteDiscount"); + } + print '
'.$langs->trans('Project').''; + print '
'.$langs->trans('Project').''; $html->select_projects($societe_id, $projet, 'projetid'); print '
'.$langs->trans('NotePublic').''; + print ''; print '
'.$langs->trans('NotePrivate').''; + print ''; print '