New: task #3405 : Ajouter les remises clients aux commandes

This commit is contained in:
Laurent Destailleur 2006-04-29 15:09:44 +00:00
parent 47d395d125
commit 4f04b8b22d
15 changed files with 923 additions and 358 deletions

View File

@ -3,16 +3,23 @@ English Dolibarr changelog
***** Changelog for 2.1 compared to 2.0.1 *****
- Support credit note and discounts (relative and absolute) on
commercial proposal and invoices.
- Added an export tool to export main dolibarr data.
- Added product categories management.
- Graphical enhancements (picto to describe all status).
- New permissions (can restrict access for a commercial user to elements
of its companies only).
- Lot of fixes after 2.0 release not fixed in 2.0.1
- Little enhancements to OSCommerce module.
- Provide PDF generation for orders.
- Building a PDF document for invoices works like other modules. You
can change model just before generating the PDF.
- Can make one payment for several supplier invoices.
- Code cleaner.
- Better compatibility with different PHP version or setup.
- Lot of fixes after 2.0 release not fixed in 2.0.1
***** Changelog for 2.0.1 compared to 2.0 *****

View File

@ -48,6 +48,10 @@ class Commande
var $mode_reglement_id;
var $mode_reglement_code;
var $adresse_livraison_id;
var $date; // Date commande
var $date_livraison; // Date livraison souhaitée
var $remise_percent;
var $remise_absolue;
// Pour board
var $nbtodo;
@ -82,6 +86,9 @@ class Commande
$this->sources[4] = $langs->trans('OrderSource4');
$this->sources[5] = $langs->trans('OrderSource5');
$this->remise = 0;
$this->remise_percent = 0;
$this->products = array();
}
@ -302,14 +309,18 @@ class Commande
}
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'commande (';
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client, model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison) ';
$sql.= 'fk_soc, date_creation, fk_user_author, fk_projet, date_commande, source, note, ref_client,';
$sql.= ' model_pdf, fk_cond_reglement, fk_mode_reglement, date_livraison, fk_adresse_livraison,';
$sql.= ' remise_absolue, remise_percent)';
$sql.= ' VALUES ('.$this->soc_id.', now(), '.$user->id.', '.$this->projetid.',';
$sql.= ' '.$this->db->idate($this->date_commande).',';
$sql.= ' '.$this->source.', ';
$sql.= " '".addslashes($this->note)."', ";
$sql.= " '".$this->ref_client."', '".$this->modelpdf.'\', \''.$this->cond_reglement_id.'\', \''.$this->mode_reglement_id.'\',';
$sql.= " '".($this->date_livraison?$this->db->idate($this->date_livraison):'null').'\',';
$sql.= " '".$this->adresse_livraison_id."')";
$sql.= " '".$this->adresse_livraison_id."',";
$sql.= " '".$this->remise_absolue."',";
$sql.= " '".$this->remise_percent."')";
dolibarr_syslog("Commande.class.php::create sql=$sql");
if ( $this->db->query($sql) )
@ -629,10 +640,11 @@ class Commande
*/
function fetch($id)
{
$sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement';
$sql .= ', '.$this->db->pdate('c.date_commande').' as date_commande, c.fk_projet, c.remise_percent, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.date_livraison, c.fk_adresse_livraison';
$sql .= ' FROM '.MAIN_DB_PREFIX.'commande as c';
$sql .= ' WHERE c.rowid = '.$id;
$sql = 'SELECT c.rowid, c.date_creation, c.ref, c.fk_soc, c.fk_user_author, c.fk_statut, c.amount_ht, c.total_ht, c.total_ttc, c.tva, c.fk_cond_reglement, c.fk_mode_reglement,';
$sql.= ' '.$this->db->pdate('c.date_commande').' as date_commande, '.$this->db->pdate('c.date_livraison').' as date_livraison,';
$sql.= ' c.fk_projet, c.remise_percent, c.remise_absolue, c.source, c.facture, c.note, c.ref_client, c.model_pdf, c.fk_adresse_livraison';
$sql.= ' FROM '.MAIN_DB_PREFIX.'commande as c';
$sql.= ' WHERE c.rowid = '.$id;
$result = $this->db->query($sql) ;
if ( $result )
@ -649,6 +661,7 @@ class Commande
$this->total_ttc = $obj->total_ttc;
$this->date = $obj->date_commande;
$this->remise_percent = $obj->remise_percent;
$this->remise_absolue = $obj->remise_absolue;
$this->source = $obj->source;
$this->facturee = $obj->facture;
$this->note = $obj->note;
@ -871,30 +884,129 @@ class Commande
}
}
/**
*
*
*/
/**
* \brief Applique une remise relative
* \param user User qui positionne la remise
* \param remise
* \return int <0 si ko, >0 si ok
*/
function set_remise($user, $remise)
{
$remise=trim($remise)?trim($remise):0;
if ($user->rights->commande->creer)
{
$remise = ereg_replace(',','.',$remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET remise_percent = '.$remise;
$sql .= " WHERE rowid = $this->id AND fk_statut = 0 ;";
if ($this->db->query($sql) )
$remise=price2num($remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_percent = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
if ($this->db->query($sql))
{
$this->remise_percent = $remise;
$this->update_price();
$this->update_price($this->id);
return 1;
}
else
{
dolibarr_syslog('Commande::set_remise Erreur SQL');
$this->error=$this->db->error();
return -1;
}
}
}
/**
/**
* \brief Applique une remise absolue
* \param user User qui positionne la remise
* \param remise
* \return int <0 si ko, >0 si ok
*/
function set_remise_absolue($user, $remise)
{
$remise=trim($remise)?trim($remise):0;
if ($user->rights->commande->creer)
{
$remise=price2num($remise);
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande';
$sql.= ' SET remise_absolue = '.$remise;
$sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;';
dolibarr_syslog("Commande::set_remise_absolue sql=$sql");
if ($this->db->query($sql))
{
$this->remise_absolue = $remise;
$this->update_price($this->id);
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
}
/**
* \brief Mets à jour le prix total de la proposition
* \return int <0 si ko, >0 si ok
*/
function update_price()
{
include_once DOL_DOCUMENT_ROOT . "/lib/price.lib.php";
/*
* Liste des produits a ajouter
*/
$sql = "SELECT price, qty, tva_tx FROM ".MAIN_DB_PREFIX."commandedet";
$sql.= " WHERE fk_commande = ".$this->id;
if ( $this->db->query($sql) )
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object();
$products[$i][0] = $obj->price;
$products[$i][1] = $obj->qty;
$products[$i][2] = $obj->tva_tx;
$i++;
}
}
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
$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."commande SET";
$sql .= " total_ht='". price2num($this->total_ht)."'";
$sql .= ", tva='". price2num($this->total_tva)."'";
$sql .= ", total_ttc='".price2num($this->total_ttc)."'";
$sql .= ", remise='".price2num($this->total_remise)."'";
$sql .=" WHERE rowid = ".$this->id;
if ( $this->db->query($sql) )
{
return 1;
}
else
{
$this->error=$this->db->error();
return -1;
}
}
/**
* \brief Définit une date de livraison
* \param user Objet utilisateur qui modifie
* \param date_livraison Date de livraison
@ -1146,61 +1258,7 @@ class Commande
}
}
/**
* Mettre à jour le prix
*
*/
function update_price()
{
include_once DOL_DOCUMENT_ROOT . '/lib/price.lib.php';
/*
* Liste des produits a ajouter
*/
$sql = 'SELECT price, qty, tva_tx FROM '.MAIN_DB_PREFIX."commandedet WHERE fk_commande = $this->id";
if ( $this->db->query($sql) )
{
$num = $this->db->num_rows();
$i = 0;
while ($i < $num)
{
$obj = $this->db->fetch_object();
$products[$i][0] = $obj->price;
$products[$i][1] = $obj->qty;
$products[$i][2] = $obj->tva_tx;
$i++;
}
}
$calculs = calcul_price($products, $this->remise_percent);
$totalht = $calculs[0];
$totaltva = $calculs[1];
$totalttc = $calculs[2];
$total_remise = $calculs[3];
$this->remise = $total_remise;
$this->total_ht = $totalht;
$this->total_tva = $totaltva;
$this->total_ttc = $totalttc;
/*
*
*/
$sql = 'UPDATE '.MAIN_DB_PREFIX.'commande set';
$sql .= " amount_ht ='".ereg_replace(',','.',$totalht)."'";
$sql .= ", total_ht ='".ereg_replace(',','.',$totalht)."'";
$sql .= ", tva ='".ereg_replace(',','.',$totaltva)."'";
$sql .= ", total_ttc ='".ereg_replace(',','.',$totalttc)."'";
$sql .= ", remise ='".ereg_replace(',','.',$total_remise)."'";
$sql .= " WHERE rowid = $this->id";
if ( $this->db->query($sql) )
{
return 1;
}
else
{
print 'Erreur mise à jour du prix<p>'.$sql;
return -1;
}
}
/**
* \brief Mets à jour une ligne de commande
* \param rowid Id de la ligne de facture

View File

@ -89,13 +89,14 @@ if ($_POST['action'] == 'add' && $user->rights->commande->creer)
$commande->note = $_POST['note'];
$commande->source = $_POST['source_id'];
$commande->projetid = $_POST['projetid'];
$commande->remise_absolue = $_POST['remise_absolue'];
$commande->remise_percent = $_POST['remise_percent'];
$commande->ref_client = $_POST['ref_client'];
$commande->modelpdf = $_POST['model'];
$commande->cond_reglement_id = $_POST['cond_reglement_id'];
$commande->mode_reglement_id = $_POST['mode_reglement_id'];
$commande->date_livraison = $datelivraison;
$commande->adresse_livraison_id = $_POST['adresse_livraison_id'];
$commande->mode_reglement_id = $_POST['mode_reglement_id'];
$commande->date_livraison = $datelivraison;
$commande->adresse_livraison_id = $_POST['adresse_livraison_id'];
$commande->add_product($_POST['idprod1'],$_POST['qty1'],$_POST['remise_percent1']);
$commande->add_product($_POST['idprod2'],$_POST['qty2'],$_POST['remise_percent2']);
@ -172,6 +173,22 @@ if ($_POST['action'] == 'setconditions' && $user->rights->commande->creer)
if ($result < 0) dolibarr_print_error($db,$commande->error);
}
if ($_REQUEST['action'] == 'setremisepercent' && $user->rights->facture->creer)
{
$commande = new Commande($db);
$commande->fetch($_REQUEST['id']);
$result = $commande->set_remise($user, $_POST['remise_percent']);
$_GET['id']=$_REQUEST['id'];
}
if ($_REQUEST['action'] == 'setremiseabsolue' && $user->rights->facture->creer)
{
$commande = new Commande($db);
$commande->fetch($_REQUEST['id']);
$result = $commande->set_remise_absolue($user, $_POST['remise_absolue']);
$_GET['id']=$_REQUEST['id'];
}
if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
{
/*
@ -209,8 +226,8 @@ if ($_POST['action'] == 'addligne' && $user->rights->commande->creer)
if ($_POST['action'] == 'updateligne' && $user->rights->commande->creer && $_POST['save'] == $langs->trans('Save'))
{
$commande = new Commande($db,'',$_POST['id']);
if (! $commande->fetch($_POST['id']) > 0)
dolibarr_print_error($db);
if (! $commande->fetch($_POST['id']) > 0) dolibarr_print_error($db);
$result = $commande->update_line($_POST['elrowid'],
$_POST['eldesc'],
$_POST['elprice'],
@ -314,7 +331,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print_titre($langs->trans('CreateOrder'));
if ($mesg) print $mesg.'<br>';
$new_commande = new Commande($db);
if ($propalid)
@ -332,7 +349,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
}
$resql = $db->query($sql);
if ( $resql )
{
{
$num = $db->num_rows($resql);
if ($num)
{
@ -340,9 +357,8 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
$soc = new Societe($db);
$soc->fetch($obj->idp);
$nbrow=8;
if ($conf->projet->enabled) $nbrow++;
$nbrow=7;
print '<form name="crea_commande" action="fiche.php" method="post">';
print '<input type="hidden" name="action" value="add">';
@ -359,60 +375,94 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
// Reference client
print '<tr><td>'.$langs->trans('RefCustomer').'</td><td>';
print '<input type="text" name="ref_client" value=""></td>';
print '<td rowspan="'.$nbrow.'" valign="top"><textarea name="note" wrap="soft" cols="50" rows="12"></textarea></td>';
print '<td rowspan="'.$nbrow.'" valign="top"><textarea name="note" wrap="soft" cols="50" rows="8"></textarea></td>';
print '</tr>';
// Client
print '<tr><td>'.$langs->trans('Customer').'</td><td>'.$soc->nom_url.'</td>';
print '<tr><td>'.$langs->trans('Customer').'</td><td>'.img_object($langs->trans("ShowCompany"),'company').' '.$soc->nom_url.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td>';
$html->select_date('','re','','','',"crea_commande");
print '</td></tr>';
// Date de livraison
print "<tr><td>".$langs->trans("DateDelivery")."</td><td>";
if ($conf->global->DATE_LIVRAISON_WEEK_DELAY)
{
$tmpdte = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$tmpdte = time() + ((7*$conf->global->DATE_LIVRAISON_WEEK_DELAY) * 24 * 60 * 60);
$html->select_date($tmpdte,'liv_','','',1,"crea_commande");
}
else
{
$html->select_date(-1,'liv_','','',1,"crea_commande");
}
print "</td></tr>";
// Adresse de livraison
print '<tr><td nowrap>'.$langs->trans('DeliveryAddress').'</td><td>';
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socidp'],'adresse_livraison_id');
if ($numaddress==0)
{
print ' &nbsp; <a href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
// Conditions de réglement
print '<tr><td nowrap>'.$langs->trans('PaymentConditions').'</td><td>';
$html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1);
print '</td></tr>';
// Mode de réglement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements($soc->mode_reglement,'mode_reglement_id');
print '</td></tr>';
}
print "</td></tr>";
// Adresse de livraison
print '<tr><td nowrap>'.$langs->trans('DeliveryAddress').'</td><td>';
$numaddress = $html->select_adresse_livraison($soc->adresse_livraison_id, $_GET['socidp'],'adresse_livraison_id');
if ($numaddress==0)
{
print ' &nbsp; <a href=../comm/adresse_livraison.php?socid='.$soc->id.'&action=create>'.$langs->trans("AddAddress").'</a>';
}
print '</td></tr>';
// Conditions de réglement
print '<tr><td nowrap>'.$langs->trans('PaymentConditions').'</td><td>';
$html->select_conditions_paiements($soc->cond_reglement,'cond_reglement_id',-1,1);
print '</td></tr>';
// Mode de réglement
print '<tr><td>'.$langs->trans('PaymentMode').'</td><td>';
$html->select_types_paiements($soc->mode_reglement,'mode_reglement_id');
print '</td></tr>';
// Remise relative
$relative_discount=$soc->remise_client;
print '<tr><td>'.$langs->trans("CustomerRelativeDiscount").'</td>';
print '<td>';
print '<input type="text" name="remise_percent" size="1" value="'.$relative_discount.'"> %';
print '</td><td>'.img_info().' ';
if ($relative_discount)
{
print $langs->trans("CompanyHasRelativeDiscount",$relative_discount);
}
else
{
print $langs->trans("CompanyHasNoRelativeDiscount");
}
print '</td></tr>';
// Remise avoirs
$absolute_discount=$soc->getCurrentDiscount();
print '<tr><td>'.$langs->trans("CustomerAbsoluteDiscount").'</td>';
print '<td>';
print '<input type="text" name="remise_absolue" size="1" value="0"> '.$langs->trans("Currency".$conf->monnaie);
print '</td><td>'.img_info().' ';
if ($absolute_discount)
{
print $langs->trans("CompanyHasAbsoluteDiscount",$absolute_discount,$langs->trans("Currency".$conf->monnaie));
}
else
{
print $langs->trans("CompanyHasNoAbsoluteDiscount");
}
print '</td></tr>';
// Projet
if ($conf->projet->enabled)
{
print '<tr><td>'.$langs->trans('Project').'</td><td>';
$numprojet=$html->select_projects($soc->id,$projetid,'projetidp');
if ($numprojet==0)
{
print ' &nbsp; <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
}
if ($numprojet==0)
{
print ' &nbsp; <a href=../projet/fiche.php?socidp='.$soc->id.'&action=create>'.$langs->trans("AddProject").'</a>';
}
print '</td></tr>';
}
@ -427,7 +477,7 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
$liste=$model->liste_modeles($db);
$html->select_array("model",$liste,$conf->global->COMMANDE_ADDON_PDF);
print "</td></tr>";
if ($propalid > 0)
{
$amount = ($obj->price);
@ -459,9 +509,9 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
print '<tr><td>';
// multiprix
if($conf->global->PRODUIT_MULTIPRICES == 1)
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size,$soc->price_level);
else
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
print $html->select_produits('','idprod'.$i,'',$conf->produit->limit_size);
print '</td>';
print '<td><input type="text" size="3" name="qty'.$i.'" value="1"></td>';
print '<td><input type="text" size="3" name="remise_percent'.$i.'" value="0">%</td></tr>';
@ -472,12 +522,13 @@ if ($_GET['action'] == 'create' && $user->rights->commande->creer)
}
/*
*
*/
*
*/
print '<tr><td colspan="3" align="center"><input type="submit" class="button" value="'.$langs->trans('CreateDraft').'"></td></tr>';
print '</form>';
print '</table>';
print '</form>';
if ($propalid)
{
/*
@ -649,16 +700,8 @@ else
// Ref
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td></tr>';
print '<td colspan="3">'.$commande->ref.'</td>';
print '</tr>';
// Ref commande client
print '<tr><td>';
@ -667,7 +710,7 @@ else
print '</td>';
if ($_GET['action'] != 'refcdeclient') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&amp;id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient')
{
print '<form action="fiche.php?id='.$id.'" method="post">';
@ -680,41 +723,30 @@ else
{
print $commande->ref_client;
}
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>';
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setnote">';
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
print '</form>';
}
else
{
print nl2br($commande->note);
}
print '</td>';
print '</tr>';
// Société
print '<tr><td>'.$langs->trans('Customer').'</td>';
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
// Statut
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td>';
print '</tr>';
// date de livraison
// Date de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateDelivery');
@ -733,12 +765,28 @@ else
}
else
{
print dolibarr_print_date($commande->date_livraison,'%a %d %B %Y');
print dolibarr_print_date($commande->date_livraison,'%A %d %B %Y');
}
print '</td></tr>';
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setnote">';
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
print '</form>';
}
else
{
print nl2br($commande->note);
}
print '</td>';
print '</tr>';
// adresse de livraison
// Adresse de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
@ -758,7 +806,7 @@ else
}
print '</td></tr>';
// Conditions et modes de réglement
// Conditions et modes de réglement
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
@ -817,29 +865,6 @@ else
// Lignes de 3 colonnes
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('GlobalDiscount').'</td><td align="right">';
print '</td>';
if ($_GET['action'] != 'setdiscount' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=setdiscount&amp;id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
print '</tr></table>';
print '</td>';
if ($user->rights->commande->creer && $_GET['action'] == 'setdiscount')
{
print '<td align="right">';
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
print '<input type="text" class="flat" name="remise" size="3" value="'.$commande->remise_percent.'">%';
print '</td><td><input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
print '<td align="right">'.$commande->remise_percent.'</td><td>%</td>';
}
print '</tr>';
// Total HT
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
@ -853,8 +878,14 @@ else
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
print '</tr>';
print '</table><br>';
print "\n";
/*
* Lignes de commandes
*/
@ -887,7 +918,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>&nbsp;</td><td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
}
$var=true;
@ -943,10 +976,13 @@ else
print '<td align="right"><a href="fiche.php?id='.$id.'&amp;action=deleteline&amp;lineid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
print '<td>&nbsp;</td>';
}
else
{
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
}
print '</tr>';
}
@ -979,7 +1015,7 @@ else
print '<td align="right"><input size="5" type="text" class="flat" name="elprice" value="'.price($objp->subprice).'"></td>';
print '<td align="right"><input size="2" type="text" class="flat" name="elqty" value="'.$objp->qty.'"></td>';
print '<td align="right" nowrap><input size="1" type="text" class="flat" name="elremise_percent" value="'.$objp->remise_percent.'">%</td>';
print '<td align="center" colspan="3"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
print '<td align="center" colspan="4"><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>';
print '</form>';
@ -995,6 +1031,117 @@ else
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="id" value="'.$commande->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerRelativeDiscount');
if ($commande->brouillon) print ' <font style="font-weight: normal">('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')</font>';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editrelativediscount')
{
print '<input type="text" name="remise_percent" size="2" value="'.$commande->remise_percent.'">%';
}
else
{
print $commande->remise_percent?$commande->remise_percent.'%':'&nbsp;';
}
print '</font></td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] != 'editrelativediscount') print $commande->remise_percent?'-'.price($commande->remise_percent*$total/100):$langs->trans("DiscountNone");
else print '&nbsp;';
print '</font></td>';
if ($_GET['action'] != 'editrelativediscount')
{
if ($commande->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrelativediscount&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if ($commande->brouillon && $user->rights->facture->creer && $commande->remise_percent)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;action=setremisepercent&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</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="id" value="'.$commande->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerAbsoluteDiscount');
if ($commande->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>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editabsolutediscount')
{
print '-<input type="text" name="remise_absolue" size="2" value="'.$commande->remise_absolue.'">';
}
else
{
print $commande->remise_absolue?'-'.price($commande->remise_absolue):$langs->trans("DiscountNone");
}
print '</font></td>';
if ($_GET['action'] != 'editabsolutediscount')
{
if ($commande->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editabsolutediscount&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if ($commande->brouillon && $user->rights->facture->creer && $commande->remise_absolue)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;action=setremiseabsolue&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
}
print '</tr>';
print '</form>';
/*
* Ajouter une ligne
*/
@ -1009,6 +1156,7 @@ else
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
// Ajout produit produits/services personalisés
@ -1028,7 +1176,7 @@ else
print '<td align="right"><input type="text" name="pu" size="5"></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="2" value="0">%</td>';
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td>';
print '<td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td>';
print '</tr>';
print '</form>';
@ -1052,7 +1200,7 @@ else
print '<td>&nbsp;</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_percent" value="0">%</td>';
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td></tr>';
print '<td align="center" colspan="4"><input type="submit" class="button" value="'.$langs->trans('Add').'"></td>';
print '</tr>';
print '</form>';
@ -1171,6 +1319,7 @@ else
*/
//$html->show_documents('propal',$filename,$filedir,$urlsource,$genallowed,$delallowed,$propal->modelpdf);
$html->show_documents('commande',$comref,$filedir,$urlsource,$genallowed,$delallowed,$commande->modelpdf);
/*
* Liste des factures
*/

View File

@ -127,113 +127,197 @@ if ($_GET["id"] > 0)
/*
* Commande
*/
$nbrow=8;
if ($conf->projet->enabled) $nbrow++;
$nbrow=8;
if ($conf->projet->enabled) $nbrow++;
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
// Ref
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">'.$commande->ref.'</td>';
print '</tr>';
// Reference
print '<tr><td width="18%">'.$langs->trans("Ref")."</td>";
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans("Source").' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Propale
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print "</td></tr>";
// Ref cde client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td>';
print '<td colspan="2">';
print $commande->ref_client;
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>';
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setnote">';
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
print '<center><input type="submit" class="button" value="'.$langs->trans("Save").'"></center>';
print '</form>';
}
else
{
print nl2br($commande->note);
}
print '</td>';
print '</tr>';
// Client
print "<tr><td>".$langs->trans("Customer")."</td>";
print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a>';
print '</td>';
print '</tr>';
// Statut
print '<tr><td>'.$langs->trans("Status").'</td>';
print "<td colspan=\"2\">".$commande->getLibStatut(4)."</td>\n";
print '</tr>';
// Date
print '<tr><td>'.$langs->trans("Date").'</td>';
print "<td colspan=\"2\">".dolibarr_print_date($commande->date,"%A %d %B %Y")."</td>\n";
print '</tr>';
// Projet
if ($conf->projet->enabled)
{
print '<tr>';
$langs->load("projects");
print '<td>';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans("Project");
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
//if ($_GET["action"] != "classer") print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=classer&amp;id='.$commande->id.'">'.img_edit($langs->trans("SetProject")).'</a></td>';
if ($_GET['action'] != 'refcdeclient') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&amp;id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET["action"] == "classer")
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient')
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="set_ref_client">';
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $commande->ref_client;
}
print '</td>';
print '</tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td>';
print '</tr>';
// Date de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateDelivery');
print '</td>';
if (1 == 2 && $_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editdate_livraison')
{
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
print '<input type="hidden" name="action" value="setdate_livraison">';
$html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print dolibarr_print_date($commande->date_livraison,'%A %d %B %Y');
}
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setnote">';
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
print '</form>';
}
else
{
print nl2br($commande->note);
}
print '</td>';
print '</tr>';
// Adresse de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if (1 == 2 && $_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->soc_id.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editdelivery_adress')
{
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
}
else
{
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
}
print '</td></tr>';
// Conditions et modes de réglement
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
if ($_GET['action'] != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none');
}
print '</td></tr>';
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none');
}
print '</td></tr>';
// Projet
if ($conf->projet->enabled)
{
$html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"projetid");
$langs->load('projects');
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'classer')
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid');
}
else
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none');
}
print '</td></tr>';
}
else
{
$html->form_project($_SERVER["PHP_SELF"]."?id=$commande->id",$commande->fk_soc,$commande->projetid,"none");
}
print "</td>";
print '</tr>';
}
// Lignes de 3 colonnes
// Discount
print '<tr><td>'.$langs->trans("GlobalDiscount").'</td><td align="right">';
print $commande->remise_percent.'%</td><td>&nbsp;';
print '</td></tr>';
// Total HT
print '<tr><td>'.$langs->trans("TotalHT").'</td>';
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Lignes de 3 colonnes
// Total VAT
print '<tr><td>'.$langs->trans("TotalVAT").'</td><td align="right">'.price($commande->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Total TTC
print '<tr><td>'.$langs->trans("TotalTTC").'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Total HT
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '</table>';
// Total TVA
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Total TTC
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
print '</tr>';
print '</table>';
/*
* Lignes de commandes
@ -263,7 +347,9 @@ if ($_GET["id"] > 0)
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right">'.$langs->trans('Discount').'</td>';
print '<td align="right">'.$langs->trans('AmountHT').'</td>';
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print "</tr>\n";
}
@ -305,9 +391,12 @@ if ($_GET["id"] > 0)
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
$total = $total + ($objp->qty * $objp->price);
$i++;
}
$db->free($resql);
@ -316,6 +405,119 @@ if ($_GET["id"] > 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="id" value="'.$commande->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerRelativeDiscount');
if ($commande->brouillon) print ' <font style="font-weight: normal">('.($soc->remise_client?$langs->trans("CompanyHasRelativeDiscount",$soc->remise_client):$langs->trans("CompanyHasNoRelativeDiscount")).')</font>';
print '</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editrelativediscount')
{
print '<input type="text" name="remise_percent" size="2" value="'.$commande->remise_percent.'">%';
}
else
{
print $commande->remise_percent?$commande->remise_percent.'%':'&nbsp;';
}
print '</font></td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] != 'editrelativediscount') print $commande->remise_percent?'-'.price($commande->remise_percent*$total/100):$langs->trans("DiscountNone");
else print '&nbsp;';
print '</font></td>';
if ($_GET['action'] != 'editrelativediscount')
{
if (1 == 2 && $commande->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editrelativediscount&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetRelativeDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if (1 == 2 && $commande->brouillon && $user->rights->facture->creer && $commande->remise_percent)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;action=setremisepercent&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</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="id" value="'.$commande->id.'">';
print '<tr class="liste_total"><td>';
print $langs->trans('CustomerAbsoluteDiscount');
if ($commande->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>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td align="right"><font style="font-weight: normal">';
if ($_GET['action'] == 'editabsolutediscount')
{
print '-<input type="text" name="remise_absolue" size="2" value="'.$commande->remise_absolue.'">';
}
else
{
print $commande->remise_absolue?'-'.price($commande->remise_absolue):$langs->trans("DiscountNone");
}
print '</font></td>';
if ($_GET['action'] != 'editabsolutediscount')
{
if (1 == 2 && $commande->brouillon && $user->rights->facture->creer)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editabsolutediscount&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetAbsoluteDiscount'),1).'</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
if (1 == 2 && $commande->brouillon && $user->rights->facture->creer && $commande->remise_absolue)
{
print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'&amp;action=setremiseabsolue&amp;rowid='.$objp->rowid.'">';
print img_delete();
print '</a></td>';
}
else
{
print '<td>&nbsp;</td>';
}
print '<td>&nbsp;</td>';
}
else
{
print '<td colspan="3"><input type="submit" class="button" value="'.$langs->trans("Save").'"></td>';
}
print '</tr>';
print '</form>';
print '</table>';
print '</div>';
@ -334,7 +536,7 @@ if ($_GET["id"] > 0)
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/facture.php?action=create&amp;commandeid='.$commande->id.'&amp;socidp='.$commande->soc_id.'">'.$langs->trans("CreateBill").'</a>';
}
if ($user->rights->commande->creer)
if ($commande->statut > 0 && $user->rights->commande->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/compta/commande/fiche.php?action=facturee&amp;id='.$commande->id.'">'.$langs->trans("ClassifyBilled").'</a>';
}

View File

@ -718,7 +718,7 @@ if ($_GET['action'] == 'create')
print '<tr><td>'.$langs->trans('Ref').'</td><td colspan="2">'.$langs->trans('Draft').'</td></tr>';
// Societe
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.$soc->nom_url.'</td>';
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="2">'.img_object($langs->trans("ShowCompany"),'company').' '.$soc->nom_url.'</td>';
print '</tr>';
// Date facture

View File

@ -35,6 +35,7 @@ require_once(DOL_DOCUMENT_ROOT."/project.class.php");
require_once(DOL_DOCUMENT_ROOT."/propal.class.php");
require_once(DOL_DOCUMENT_ROOT."/product/stock/entrepot.class.php");
$langs->load("bills");
$user->getrights('commande');
$user->getrights('expedition');
@ -134,59 +135,204 @@ if ($_GET["id"] > 0)
}
// Onglet commande
print '<table class="border" width="100%">';
$nbrow=8;
if ($conf->projet->enabled) $nbrow++;
// Ref
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
print '<td colspan="2">'.$commande->ref.'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td></tr>';
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
print '</tr></table>';
print '</td><td colspan="2">';
print $commande->ref_client;
print '</td>';
$nbrow=3;
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('Note').' :<br>';
print nl2br($commande->note);
print '</td>';
print '</tr>';
print '<table class="border" width="100%">';
// Société
print '<tr><td>'.$langs->trans('Customer').'</td>';
print '<td>';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
// Ref
print '<tr><td width="18%">'.$langs->trans('Ref').'</td>';
print '<td colspan="3">'.$commande->ref.'</td>';
print '</tr>';
// Statut
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
print '</tr>';
// Date
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '</tr>';
print '</table>';
// Ref commande client
print '<tr><td>';
print '<table class="nobordernopadding" width="100%"><tr><td nowrap>';
print $langs->trans('RefCustomer').'</td><td align="left">';
print '</td>';
if ($_GET['action'] != 'refcdeclient') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=refcdeclient&amp;id='.$commande->id.'">'.img_edit($langs->trans('Edit')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="3">';
if ($user->rights->commande->creer && $_GET['action'] == 'refcdeclient')
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="set_ref_client">';
print '<input type="text" class="flat" size="20" name="ref_client" value="'.$commande->ref_client.'">';
print ' <input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print $commande->ref_client;
}
print '</td>';
print '</tr>';
// Société
print '<tr><td>'.$langs->trans('Company').'</td>';
print '<td colspan="2">';
print '<a href="'.DOL_URL_ROOT.'/comm/fiche.php?socid='.$soc->id.'">'.$soc->nom.'</a></td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td>';
print '<td colspan="2">'.dolibarr_print_date($commande->date,'%A %d %B %Y').'</td>';
print '<td width="50%">'.$langs->trans('Source').' : ' . $commande->sources[$commande->source] ;
if ($commande->source == 0)
{
// Si source = propal
$propal = new Propal($db);
$propal->fetch($commande->propale_id);
print ' -> <a href="'.DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id.'">'.$propal->ref.'</a>';
}
print '</td>';
print '</tr>';
// Date de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DateDelivery');
print '</td>';
if ($_GET['action'] != 'editdate_livraison' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdate_livraison&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDateDelivery'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editdate_livraison')
{
print '<form name="setdate_livraison" action="'.$_SERVER["PHP_SELF"].'?id='.$commande->id.'" method="post">';
print '<input type="hidden" name="action" value="setdate_livraison">';
$html->select_date($commande->date_livraison,'liv_','','','',"setdate_livraison");
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
}
else
{
print dolibarr_print_date($commande->date_livraison,'%A %d %B %Y');
}
print '</td>';
print '<td rowspan="'.$nbrow.'" valign="top">'.$langs->trans('NotePublic').' :<br>';
if ($commande->brouillon == 1 && $user->rights->commande->creer)
{
print '<form action="fiche.php?id='.$id.'" method="post">';
print '<input type="hidden" name="action" value="setnote">';
print '<textarea name="note" rows="4" style="width:95%;">'.$commande->note.'</textarea><br>';
print '<center><input type="submit" class="button" value="'.$langs->trans('Save').'"></center>';
print '</form>';
}
else
{
print nl2br($commande->note);
}
print '</td>';
print '</tr>';
// Adresse de livraison
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('DeliveryAddress');
print '</td>';
if ($_GET['action'] != 'editdelivery_adress' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editdelivery_adress&amp;socid='.$commande->soc_id.'&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetDeliveryAddress'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editdelivery_adress')
{
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'adresse_livraison_id','commande',$commande->id);
}
else
{
$html->form_adresse_livraison($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->adresse_livraison_id,$_GET['socid'],'none','commande',$commande->id);
}
print '</td></tr>';
// Conditions et modes de réglement
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentConditions');
print '</td>';
if ($_GET['action'] != 'editconditions' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editconditions&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetConditions'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editconditions')
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'cond_reglement_id');
}
else
{
$html->form_conditions_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->cond_reglement_id,'none');
}
print '</td></tr>';
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('PaymentMode');
print '</td>';
if ($_GET['action'] != 'editmode' && $commande->brouillon) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editmode&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'editmode')
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'mode_reglement_id');
}
else
{
$html->form_modes_reglement($_SERVER['PHP_SELF'].'?id='.$commande->id,$commande->mode_reglement_id,'none');
}
print '</td></tr>';
// Projet
if ($conf->projet->enabled)
{
$langs->load('projects');
print '<tr><td height="10">';
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($_GET['action'] != 'classer') print '<td align="right"><a href="'.$_SERVER['PHP_SELF'].'?action=classer&amp;id='.$commande->id.'">'.img_edit($langs->trans('SetProject')).'</a></td>';
print '</tr></table>';
print '</td><td colspan="2">';
if ($_GET['action'] == 'classer')
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'projetid');
}
else
{
$html->form_project($_SERVER['PHP_SELF'].'?id='.$commande->id, $commande->soc_id, $commande->projet_id, 'none');
}
print '</td></tr>';
}
// Lignes de 3 colonnes
// Total HT
print '<tr><td>'.$langs->trans('TotalHT').'</td>';
print '<td align="right"><b>'.price($commande->total_ht).'</b></td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Total TVA
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td align="right">'.price($commande->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Total TTC
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td align="right">'.price($commande->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
// Statut
print '<tr><td>'.$langs->trans('Status').'</td>';
print '<td colspan="2">'.$commande->getLibStatut(4).'</td>';
print '</tr>';
print '</table><br>';
/**
* Lignes de commandes avec quantité livrées et reste à livrer
*
*/
echo '<br><table class="liste" width="100%">';
echo '<table class="liste" width="100%">';
$sql = "SELECT l.fk_product, l.description, l.price, l.qty, l.rowid, l.tva_tx, l.remise_percent, l.subprice";
$sql.= " FROM ".MAIN_DB_PREFIX."commandedet as l ";
@ -270,7 +416,7 @@ if ($_GET["id"] > 0)
if (! $num)
{
print $langs->trans("None").'<br>';
print $langs->trans("NoArticleOfTypeProduct").'<br>';
}
}
@ -289,7 +435,8 @@ if ($_GET["id"] > 0)
{
print '<div class="tabsAction">';
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->brouillon == 0 && $user->rights->expedition->creer)
// Bouton expedier sans gestion des stocks
if (! $conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
{
print '<a class="butAction" href="'.DOL_URL_ROOT.'/expedition/fiche.php?action=create&amp;commande_id='.$_GET["id"].'">'.$langs->trans("NewSending").'</a>';
}
@ -298,11 +445,8 @@ if ($_GET["id"] > 0)
}
/**
* Formulaire nouvelle expedition depuis un entrepot
*/
if ($conf->stock->enabled && $reste_a_livrer_total > 0 && $commande->brouillon == 0 && $user->rights->expedition->creer)
// Bouton expedier avec gestion des stocks
if ($conf->stock->enabled && $reste_a_livrer_total > 0 && ! $commande->brouillon && $user->rights->expedition->creer)
{
print '<form method="GET" action="'.DOL_URL_ROOT.'/expedition/fiche.php">';

View File

@ -124,7 +124,7 @@ class Facture
$this->amount = $_facrec->amount;
$this->remise_absolue = $_facrec->remise_absolue;
$this->remise_percent = $_facrec->remise_percent;
$this->remise_absolue = $_facrec->remise;
$this->remise = $_facrec->remise;
}
// Definition de la date limite
@ -1154,9 +1154,7 @@ class Facture
}
$this->db->free($result);
/*
*
*/
$calculs = calcul_price($products, $this->remise_percent, $this->remise_absolue);
$this->total_remise = $calculs[3];
$this->amount_ht = $calculs[4];
@ -1222,7 +1220,7 @@ class Facture
}
/**
* \brief Applique une remise relative sur facture
* \brief Applique une remise relative
* \param user User qui positionne la remise
* \param remise
* \return int <0 si ko, >0 si ok
@ -1255,7 +1253,7 @@ class Facture
/**
* \brief Applique une remise absolue sur facture
* \brief Applique une remise absolue
* \param user User qui positionne la remise
* \param remise
* \return int <0 si ko, >0 si ok

View File

@ -117,7 +117,7 @@ class MenuLeft {
$langs->load("users");
$newmenu->add(DOL_URL_ROOT."/admin/index.php?leftmenu=setup", $langs->trans("Setup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/index.php", $langs->trans("GlobalSetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/index.php", $langs->trans("CompanySetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/ihm.php", $langs->trans("GUISetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/modules.php", $langs->trans("Modules"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/boxes.php", $langs->trans("Boxes"));

View File

@ -121,7 +121,7 @@ class MenuLeft {
$langs->load("admin");
$newmenu->add(DOL_URL_ROOT."/admin/index.php?leftmenu=setup", $langs->trans("Setup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/index.php", $langs->trans("GlobalSetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/index.php", $langs->trans("CompanySetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/ihm.php", $langs->trans("GUISetup"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/modules.php", $langs->trans("Modules"));
if ($leftmenu=="setup") $newmenu->add_submenu(DOL_URL_ROOT."/admin/boxes.php", $langs->trans("Boxes"));

View File

@ -10,7 +10,8 @@ ExternalUser=External user
InternalUsers=Internal users
ExternalUsers=External users
GlobalSetup=Global setup
GUISetup=GUI setup
CompanySetup=Company/Fundation setup
GUISetup=Display setup
ErrorModuleRequirePHPVersion=Error, this module require PHP version %s or higher
DictionnarySetup=Dictionnary setup
DisableJavascript=Disable javascript functions

View File

@ -13,7 +13,7 @@ AvailableRights=Available permissions
OwnedRights=Owned permissions
GroupRights=Group permissions
UserRights=User permissions
UserGUISetup=User setup
UserGUISetup=User display setup
DisableUser=Disable
DisableAUser=Disable a user
DeleteUser=Delete

View File

@ -10,7 +10,8 @@ ExternalUser=Utilisateur externe
InternalUsers=Utilisateurs internes
ExternalUsers=Utilisateurs externes
GlobalSetup=Général
GUISetup=Interface
CompanySetup=Institution
GUISetup=Affichage
ErrorModuleRequirePHPVersion=Erreur, ce module requiert une version %s ou supérieure de PHP
DictionnarySetup=Dictionnaires
DisableJavascript=Désactiver les fonctions javascript

View File

@ -473,7 +473,8 @@ class Propal
/*
* Liste des produits a ajouter
*/
$sql = "SELECT price, qty, tva_tx FROM ".MAIN_DB_PREFIX."propaldet WHERE fk_propal = $this->id";
$sql = "SELECT price, qty, tva_tx FROM ".MAIN_DB_PREFIX."propaldet";
$sql.= " WHERE fk_propal = ".$this->id;
if ( $this->db->query($sql) )
{
$num = $this->db->num_rows();

View File

@ -19,6 +19,8 @@ alter table llx_facture add column remise_absolue real DEFAULT 0 after remise_pe
alter table llx_propal add column note_public text after note;
alter table llx_propal add column remise_absolue real DEFAULT 0 after remise_percent;
alter table llx_commande add column remise_absolue real DEFAULT 0 after remise_percent;
ALTER TABLE llx_societe ADD mode_reglement INT( 11 ) DEFAULT NULL ;
ALTER TABLE llx_societe ADD cond_reglement INT( 11 ) DEFAULT '1' NOT NULL ;
ALTER TABLE llx_societe ADD tva_assuj tinyint DEFAULT '1';
@ -148,6 +150,10 @@ insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (29
insert into llx_c_tva(rowid,fk_pays,taux,recuperableonly,note,active) values (292, 5, '0','0','VAT Rate 0',1);
update llx_const set value='neptune' where value='pluton' and name = 'FACTURE_ADDON';
update llx_const set value='azur' where value='orange' and name = 'PROPALE_ADDON';
alter table llx_propal_model_pdf rename to llx_document_model;
alter table llx_document_model add column type varchar(20) NOT NULL after nom;
update llx_document_model set type='propal' where type='';
@ -158,9 +164,6 @@ insert into llx_document_model(nom,type) values('rouget','shipping');
delete from llx_document_model where nom='adytek';
delete from llx_document_model where nom='rouge' and type='order';
delete from llx_document_model where nom='azur' and type='order';
delete from llx_document_model where nom='orange' and type='propal';
update llx_const set value='neptune' where value='pluton' and name = 'FACTURE_ADDON';
update llx_const set value='azur' where value='orange' and name = 'PROPALE_ADDON';
alter table llx_actioncomm add column fk_commande integer after propalrowid;
alter table llx_actioncomm add column fk_commande integer after propalrowid;

View File

@ -40,6 +40,7 @@ create table llx_commande
fk_statut smallint default 0,
amount_ht real default 0,
remise_percent real default 0,
remise_absolue real default 0,
remise real default 0,
tva real default 0,
total_ht real default 0,
@ -48,10 +49,10 @@ create table llx_commande
note_public text,
model_pdf varchar(50),
facture tinyint default 0,
facture tinyint default 0,
fk_cond_reglement integer, -- condition de réglement
fk_mode_reglement integer, -- mode de réglement
date_livraison date default NULL,
date_livraison date default NULL,
fk_adresse_livraison integer, -- adresse de livraison
UNIQUE INDEX (ref)