Application du patch de christophe (sauf gestion tva npr).

Qual: Uniformisation du code entre propale et factures
This commit is contained in:
Laurent Destailleur 2005-10-08 15:54:06 +00:00
parent ebd3a44795
commit af1284c43c
18 changed files with 638 additions and 543 deletions

View File

@ -131,7 +131,7 @@ if ($_GET["action"] == 'create')
print '<option value="'.$contact->idp.'"';
if ($contact->idp == $setcontact)
{
print ' selected';
print ' selected="true"';
}
print '>'.$contact->firstname.' '.$contact->name;
if ($contact->email) { print ' &lt;'.$contact->email.'&gt;'; }
@ -191,7 +191,7 @@ if ($_GET["action"] == 'create')
for ($i = 1 ; $i <= PROPALE_NEW_FORM_NB_PRODUCT ; $i++)
{
print '<tr><td>';
$form->select_produits('',"idprod".$i);
$form->select_produits('',"idprod".$i,'',50);
print '</td>';
print '<td><input type="text" size="2" name="qty'.$i.'" value="1"></td>';
print '<td><input type="text" size="3" name="remise'.$i.'" value="'.$soc->remise_client.'"> %</td></tr>';

View File

@ -423,7 +423,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('propal.php?propalid='.$propal->id, $langs->trans('ValidateProp'), $langs->trans('ConfirmValidateProp'), 'confirm_validate');
print '<br>';
}
@ -739,7 +739,7 @@ if ($_GET['propalid'] > 0)
print ' - '.stripslashes(nl2br($objp->product));
print '<br>';
}
print '<textarea name="desc" cols="50" rows="1">'.stripslashes($objp->description).'</textarea></td>';
print '<textarea name="desc" cols="50" rows="'.ROWS_2.'">'.stripslashes($objp->description).'</textarea></td>';
print '<td align="right">';
print $html->select_tva("tva_tx",$objp->tva_tx);
print '</td>';
@ -798,9 +798,9 @@ if ($_GET['propalid'] > 0)
$var=true;
print '<tr '.$bc[$var].">\n";
print ' <td><textarea cols="50" name="np_desc" rows="1"></textarea></td>';
print ' <td><textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea></td>';
print ' <td align="center">';
print $html->select_tva('np_tva_tx', $conf->defaulttx) . "</td>\n";
$html->select_tva('np_tva_tx', $conf->defaulttx) . "</td>\n";
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="np_qty"></td>';
print ' <td align="right" nowrap><input type="text" size="2" value="'.$societe->remise_client.'" name="np_remise">%</td>';
@ -810,24 +810,27 @@ if ($_GET['propalid'] > 0)
print '</form>';
// Ajout de produits/services prédéfinis
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addligne">';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td colspan="2">';
$html->select_produits('','idprod','',20);
print '<br>';
print '<textarea cols="50" name="np_desc" rows="1"></textarea>';
print '</td>';
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" value="'.$societe->remise_client.'">%</td>';
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne"></td>';
print "</tr>\n";
print '</form>';
if ($conf->produit->enabled)
{
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="propalid" value="'.$propal->id.'">';
print '<input type="hidden" name="action" value="addligne">';
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td colspan="2">';
$html->select_produits('','idprod','',$conf->produit->limit_size);
print '<br>';
print '<textarea cols="50" name="np_desc" rows="'.ROWS_2.'"></textarea>';
print '</td>';
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" value="'.$societe->remise_client.'">%</td>';
print '<td align="center" colspan="3"><input type="submit" class="button" value="'.$langs->trans("Add").'" name="addligne"></td>';
print "</tr>\n";
print '</form>';
}
}
print '</table>';
@ -848,7 +851,7 @@ if ($_GET['propalid'] > 0)
{
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="60" rows="2" wrap="soft" name="note">';
print '<tr><td>'.$langs->trans('Note').'</td><td><textarea cols="60" rows="'.ROWS_3.'" wrap="soft" name="note">';
print $propal->note;
print '</textarea></td></tr>';
print '<tr><td>'.$langs->trans("CloseAs").'</td><td>';

View File

@ -106,30 +106,38 @@ if ($_GET['propalid'])
dolibarr_fiche_head($head, $hselected, $langs->trans("Proposal").": $propal->ref");
print '<table class="border" width="100%">';
print '<table class="border" width="100%">';
print '<tr><td>'.$langs->trans('Company').'</td><td>';
if ($societe->client == 1)
{
$url = DOL_URL_ROOT.'/comm/fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td>'.$langs->trans('Status').'</td><td align="left">'.$propal->statut_libelle.'</td></tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td>';
print dolibarr_print_date($propal->date);
if ($propal->fin_validite)
{
print ' ('.dolibarr_print_date($propal->fin_validite).')';
}
print '</td>';
print '<td>'.$langs->trans('Author').'</td><td>';
$author = new User($db, $propal->user_author_id);
$author->fetch('');
print $author->fullname.'</td></tr>';
print '<tr><td>'.$langs->trans('Company').'</td><td>';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td align="left" width="25%">Conditions de réglement</td>';
print '<td width="25%">'.'&nbsp;'.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td>';
print dolibarr_print_date($propal->date,'%a %d %B %Y');
print '</td>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td>';
if ($propal->fin_validite)
{
print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
print $langs->trans("Unknown");
}
print '</td>';
print '</tr>';
print '<tr><td valign="top" colspan="4">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>';

View File

@ -335,7 +335,7 @@ if ($_POST['action'] == 'addligne' && $user->rights->facture->creer)
$_POST['pu'],
$_POST['qty'],
$_POST['tva_tx'],
0,
$_POST['idprod'],
$_POST['remise_percent'],
$datestart,
$dateend
@ -651,8 +651,10 @@ if ($_GET['action'] == 'create')
print '</td>';
// Notes
print '<td rowspan="5" valign="top">';
print '<textarea name="note" wrap="soft" cols="50" rows="4">';
$nbrows=4;
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
print '<td rowspan="'.$nbrows.'" valign="top">';
print '<textarea name="note" wrap="soft" cols="50" rows="'.ROWS_5.'">';
if (is_object($propal))
{
print $propal->note;
@ -691,10 +693,19 @@ if ($_GET['action'] == 'create')
print '<tr><td colspan="2">&nbsp;</td></tr>';
}
print '<tr><td>'.$langs->trans('RefCdeClient').'</td><td>';
print '<input type="text" name="ref_client" value="'.$ref_client.'">';
print '</td></tr>';
/*
\todo
L'info "Reference commande client" est une carac de la commande et non de la facture.
Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture.
Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1.
*/
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF)
{
print '<tr><td>'.$langs->trans('RefCdeClient').'</td><td>';
print '<input type="text" name="ref_client" value="'.$ref_client.'">';
print '</td></tr>';
}
if ($_GET['propalid'] > 0)
{
print '<input type="hidden" name="amount" value="'.$propal->price.'">'."\n";
@ -707,7 +718,7 @@ if ($_GET['action'] == 'create')
print '<tr><td>'.$langs->trans('Proposal').'</td><td colspan="2">'.$propal->ref.'</td></tr>';
print '<tr><td>'.$langs->trans('GlobalDiscount').'</td><td colspan="2">'.$propal->remise_percent.'%</td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($propal->price).'</td></tr>';
print '<tr><td>'.$langs->trans('VAT').'</td><td colspan="2">'.price($propal->tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($propal->tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($propal->total)."</td></tr>";
}
elseif ($_GET['commandeid'] > 0)
@ -718,7 +729,7 @@ if ($_GET['action'] == 'create')
print '<tr><td>'.$langs->trans('Order').'</td><td colspan="2">'.$commande->ref.'</td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($commande->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('VAT').'</td><td colspan="2">'.price($commande->total_tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($commande->total_tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($commande->total_ttc)."</td></tr>";
}
elseif ($_GET['contratid'] > 0)
@ -737,7 +748,7 @@ if ($_GET['action'] == 'create')
print '<tr><td>'.$langs->trans('Contract').'</td><td colspan="2">'.$contrat->ref.'</td></tr>';
print '<tr><td>'.$langs->trans('TotalHT').'</td><td colspan="2">'.price($contrat->total_ht).'</td></tr>';
print '<tr><td>'.$langs->trans('VAT').'</td><td colspan="2">'.price($contrat->total_tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalVAT').'</td><td colspan="2">'.price($contrat->total_tva)."</td></tr>";
print '<tr><td>'.$langs->trans('TotalTTC').'</td><td colspan="2">'.price($contrat->total_ttc)."</td></tr>";
}
else
@ -754,15 +765,15 @@ if ($_GET['action'] == 'create')
for ($i = 1 ; $i <= $NBLINES ; $i++)
{
print '<tr><td>';
$html->select_produits('','idprod'.$i);
$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="4" name="remise_percent'.$i.'" value="0">%</td>';
print '<td nowrap="nowrap"><input type="text" size="4" name="remise_percent'.$i.'" value="0">%</td>';
print '<td>&nbsp;</td>';
// Si le module service est actif, on propose des dates de début et fin à la ligne
if ($conf->service->enabled)
{
print '<td>';
print '<td nowrap="nowrap">';
print 'Du ';
print $html->select_date('','date_start'.$i,0,0,1);
print '<br>au ';
@ -1221,9 +1232,12 @@ else
print '<table class="nobordernopadding" width="100%"><tr><td>';
print $langs->trans('Project');
print '</td>';
if ($_GET['action'] != 'classer') print '<td align="right"><a href="facture.php?action=classer&amp;facid='.$fac->id.'">';
print img_edit($langs->trans('SetProject'));
print '</a></td>';
if ($_GET['action'] != 'classer')
{
print '<td align="right"><a href="facture.php?action=classer&amp;facid='.$fac->id.'">';
print img_edit($langs->trans('SetProject'));
print '</a></td>';
}
print '</tr></table>';
print '</td><td colspan="3">';
@ -1242,7 +1256,9 @@ else
print '<td>&nbsp;</td><td colspan="3">&nbsp;</td>';
}
print '<td rowspan="9" colspan="2" valign="top">';
$nbrows=8;
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF) $nbrows++;
print '<td rowspan="'.$nbrows.'" colspan="2" valign="top">';
/*
* Paiements
@ -1316,25 +1332,35 @@ else
}
print '</tr>';
print '<tr><td>'.$langs->trans('RefCdeClient').'</td>';
if ($fac->brouillon == 1 && $user->rights->facture->creer)
{
print '<form action="facture.php?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>';
print '</form>';
}
else
{
print '<td colspan="3">'.$fac->ref_client.'</td>';
}
/*
\todo
L'info "Reference commande client" est une carac de la commande et non de la facture.
Elle devrait donc etre stockée sur l'objet commande lié à la facture et non sur la facture.
Pour ceux qui utilisent ainsi, positionner la constante FAC_USE_CUSTOMER_ORDER_REF à 1.
*/
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF)
{
print '<tr><td>'.$langs->trans('RefCdeClient').'</td>';
if ($fac->brouillon == 1 && $user->rights->facture->creer)
{
print '<form action="facture.php?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>';
print '</form>';
}
else
{
print '<td colspan="3">'.$fac->ref_client.'</td>';
}
}
print '<tr><td>'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2" nowrap><b>'.price($fac->total_ht).'</b></td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('VAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>';
print '<tr><td>'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_tva).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
print '<tr><td>'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2" nowrap>'.price($fac->total_ttc).'</td>';
print '<td>'.$langs->trans('Currency'.$conf->monnaie).'</td></tr>';
@ -1474,7 +1500,7 @@ else
print ' - '.stripslashes(nl2br($objp->product));
print '<br>';
}
print '<textarea name="desc" cols="50" rows="1">'.stripslashes($objp->description).'</textarea></td>';
print '<textarea name="desc" cols="50" rows="'.ROWS_2.'">'.stripslashes($objp->description).'</textarea></td>';
print '<td align="right">';
print $html->select_tva('tva_tx',$objp->tva_taux);
print '</td>';
@ -1513,7 +1539,6 @@ else
*/
if ($fac->statut == 0 && $user->rights->facture->creer && $_GET['action'] <> 'valid')
{
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>';
print '<td align="right">'.$langs->trans('VAT').'</td>';
@ -1524,16 +1549,18 @@ else
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '<td>&nbsp;</td>';
print '</tr>';
print "</tr>\n";
// Ajout produit produits/services personalisés
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addligne">';
$var=!$var;
$var=true;
print '<tr '.$bc[$var].'>';
print '<td><textarea name="desc" cols="50" rows="1"></textarea></td>';
print '<td><textarea name="desc" cols="50" rows="'.ROWS_2.'"></textarea></td>';
print '<td align="right">';
print $html->select_tva('tva_tx',$conf->defaulttx);
$html->select_tva('tva_tx',$conf->defaulttx);
print '</td>';
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>';
@ -1551,10 +1578,40 @@ else
print '</tr>';
}
print '</form>';
// Ajout de produits/services prédéfinis
if ($conf->produit->enabled)
{
print '<form action="'.$_SERVER['PHP_SELF'].'" method="post">';
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
print '<input type="hidden" name="action" value="addligne">';
$var=! $var;
print '<tr '.$bc[$var].'>';
print '<td colspan="2">';
$html->select_produits('','idprod','',$conf->produit->limit_size);
print '<br>';
print '<textarea name="desc" cols="50" rows="'.ROWS_2.'"></textarea></td>';
print '<td>&nbsp;</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" valign="middle" rowspan="2" colspan="4"><input type="submit" class="button" value="'.$langs->trans("Add").'"></td>';
print '</tr>';
if ($conf->service->enabled)
{
print '<tr '.$bc[$var].'>';
print '<td colspan="5">Si produit de type service à durée limitée: Du ';
print $html->select_date('','date_start',0,0,1);
print ' au ';
print $html->select_date('','date_end',0,0,1);
print '</td>';
print '</tr>';
}
print '</form>';
}
}
print "</table>\n";
print "</div>\n";
@ -1719,7 +1776,10 @@ else
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Ref').'</td>';
print '<td>'.$langs->trans('RefCdeClient').'</td>';
if ($conf->global->FAC_USE_CUSTOMER_ORDER_REF)
{
print '<td>'.$langs->trans('RefCdeClient').'</td>';
}
print '<td align="center">'.$langs->trans('Date').'</td>';
print '<td align="right">'.$langs->trans('AmountHT').'</td>';
print '</tr>';

View File

@ -96,342 +96,342 @@ $form = new Form($db);
*/
if ($_GET["propalid"])
{
$propal = new Propal($db);
$propal->fetch($_GET["propalid"]);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$hselected=$h;
$h++;
$propal = new Propal($db);
$propal->fetch($_GET["propalid"]);
$h=0;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('CommercialCard');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/compta/propal.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('AccountancyCard');
$hselected=$h;
$h++;
if ($conf->use_preview_tabs)
{
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/apercu.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans("Preview");
$h++;
}
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref);
/*
* Fiche propal
*
*/
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note,';
$sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x';
$sql.= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id;
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
$resql = $db->query($sql);
if ($resql)
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/note.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Note');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/info.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Info');
$h++;
$head[$h][0] = DOL_URL_ROOT.'/comm/propal/document.php?propalid='.$propal->id;
$head[$h][1] = $langs->trans('Documents');
$h++;
dolibarr_fiche_head($head, $hselected, $langs->trans('Proposal').': '.$propal->ref);
/*
* Fiche propal
*
*/
$sql = 'SELECT s.nom, s.idp, p.price, p.fk_projet, p.remise, p.tva, p.total, p.ref,'.$db->pdate('p.datep').' as dp, c.id as statut, c.label as lst, p.note,';
$sql.= ' x.firstname, x.name, x.fax, x.phone, x.email, p.fk_user_author, p.fk_user_valid, p.fk_user_cloture, p.datec, p.date_valid, p.date_cloture';
$sql.= ' FROM '.MAIN_DB_PREFIX.'societe as s, '.MAIN_DB_PREFIX.'propal as p, '.MAIN_DB_PREFIX.'c_propalst as c, '.MAIN_DB_PREFIX.'socpeople as x';
$sql.= ' WHERE p.fk_soc = s.idp AND p.fk_statut = c.id AND x.idp = p.fk_soc_contact AND p.rowid = '.$propal->id;
if ($socidp) $sql .= ' AND s.idp = '.$socidp;
$resql = $db->query($sql);
if ($resql)
{
if ($db->num_rows($resql))
{
$obj = $db->fetch_object($resql);
$societe = new Societe($db);
$societe->fetch($obj->idp);
print '<table class="border" width="100%">';
$rowspan=6;
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td align="left">Conditions de réglement</td>';
print '<td>'.'&nbsp;'.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dolibarr_print_date($propal->date,'%a %d %B %Y');
print '</td>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td>';
if ($propal->fin_validite)
{
print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
print $langs->trans("Unknown");
}
print '</td>';
print '</tr>';
// Destinataire
$langs->load('mails');
print '<tr>';
print '<td>'.$langs->trans('MailTo').'</td>';
$dests=$societe->contact_array($societe->id);
$numdest = count($dests);
if ($numdest==0)
{
print '<td colspan="3">';
print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&amp;action=create&amp;backtoreferer=1">'.$langs->trans('AddContact').'</a>';
print '</td>';
}
else
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
print '<td colspan="2">';
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="set_contact">';
$form->select_contacts($societe->id, $propal->contactid, 'contactidp');
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
if (!empty($propal->contactid))
{
print '<td colspan="3">';
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
$contact=new Contact($db);
$contact->fetch($propal->contactid);
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">';
print $contact->firstname.' '.$contact->name;
print '</a>';
print '</td>';
}
else {
print '<td colspan="3">&nbsp;</td>';
}
}
}
print '</td>';
if ($conf->projet->enabled)
$rowspan++;
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>';
if ($conf->projet->enabled)
{
$langs->load("projects");
print '<tr><td>'.$langs->trans('Project').'</td>';
$numprojet = $societe->has_projects();
if (! $numprojet)
{
print '<td colspan="2">';
print $langs->trans("NoProject").'</td><td>';
print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
print '</td>';
}
else
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
print '<td colspan="2">';
print '<form action="propal.php?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>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
if (!empty($propal->projetidp))
{
print '<td colspan="3">';
$proj = new Project($db);
$proj->fetch($propal->projetidp);
print '<a href="../projet/fiche.php?id='.$propal->projetidp.'" title="'.$langs->trans('ShowProject').'">';
print $proj->title;
print '</a>';
print '</td>';
}
else {
print '<td colspan="3">&nbsp;</td>';
}
}
}
print '</tr>';
}
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
print '<td colspan="2"><input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">% ';
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print ' <a href="propal/aideremise.php?propalid='.$propal->id.'">?</a>';
print '</td>';
print '</form>';
}
else
{
print '<td colspan="3">'.$propal->remise_percent.'%</td>';
}
print '</tr>';
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height="10">'.$langs->trans('VAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut().'</td></tr>';
print '</table><br>';
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
print '</form>';
}
/*
* Lignes de propale
*
*/
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql .= ' WHERE pt.fk_propal = '.$propal->id;
$sql .= ' ORDER BY pt.rowid ASC';
$resql = $db->query($sql);
if ($resql)
{
$num_lignes = $db->num_rows($resql);
$i = 0;
$total = 0;
print '<table class="noborder" width="100%">';
if ($num_lignes)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>';
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('Discount').'</td>';
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
print '<td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
}
$var=true;
while ($i < $num_lignes)
{
$objp = $db->fetch_object($resql);
$var=!$var;
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
{
print '<tr '.$bc[$var].'>';
if ($objp->fk_product > 0)
{
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
if ($objp->fk_product_type)
print img_object($langs->trans('ShowService'),'service');
else
print img_object($langs->trans('ShowProduct'),'product');
print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product));
if ($objp->date_start && $objp->date_end)
{
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
}
if ($objp->date_start && ! $objp->date_end)
{
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
}
if (! $objp->date_start && $objp->date_end)
{
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
}
print $objp->description?'<br>'.$objp->description:'';
print '</td>';
}
else
{
print '<td>'.stripslashes(nl2br($objp->description));
if ($objp->date_start && $objp->date_end)
{
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
}
if ($objp->date_start && ! $objp->date_end)
{
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
}
if (! $objp->date_start && $objp->date_end)
{
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
}
print "</td>\n";
}
print '<td align="right">'.$objp->tva_tx.'%</td>';
print '<td align="right">'.price($objp->subprice)."</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
if ($objp->remise_percent > 0)
{
print '<td align="right">'.$objp->remise_percent."%</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
}
$total = $total + ($objp->qty * $objp->price);
$i++;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print '</table>';
}
if ($db->num_rows($resql))
{
$obj = $db->fetch_object($resql);
$societe = new Societe($db);
$societe->fetch($obj->idp);
print '<table class="border" width="100%">';
$rowspan=6;
print '<tr><td>'.$langs->trans('Company').'</td><td colspan="3">';
if ($societe->client == 1)
{
$url ='fiche.php?socid='.$societe->id;
}
else
{
$url = DOL_URL_ROOT.'/comm/prospect/fiche.php?socid='.$societe->id;
}
print '<a href="'.$url.'">'.$societe->nom.'</a></td>';
print '<td align="left">Conditions de réglement</td>';
print '<td>'.'&nbsp;'.'</td>';
print '</tr>';
print '<tr><td>'.$langs->trans('Date').'</td><td colspan="3">';
print dolibarr_print_date($propal->date,'%a %d %B %Y');
print '</td>';
print '<td>'.$langs->trans('DateEndPropal').'</td><td>';
if ($propal->fin_validite)
{
print dolibarr_print_date($propal->fin_validite,'%a %d %B %Y');
if ($propal->statut == 1 && $propal->fin_validite < (time() - $conf->propal->cloture->warning_delay)) print img_warning($langs->trans("Late"));
}
else
{
print $langs->trans("Unknown");
}
print '</td>';
print '</tr>';
// Destinataire
$langs->load('mails');
print '<tr>';
print '<td>'.$langs->trans('MailTo').'</td>';
$dests=$societe->contact_array($societe->id);
$numdest = count($dests);
if ($numdest==0)
{
print '<td colspan="3">';
print '<font class="error">Cette societe n\'a pas de contact, veuillez en créer un avant de faire votre proposition commerciale</font><br>';
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?socid='.$societe->id.'&amp;action=create&amp;backtoreferer=1">'.$langs->trans('AddContact').'</a>';
print '</td>';
}
else
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
print '<td colspan="2">';
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="set_contact">';
$form->select_contacts($societe->id, $propal->contactid, 'contactidp');
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
if (!empty($propal->contactid))
{
print '<td colspan="3">';
require_once(DOL_DOCUMENT_ROOT.'/contact.class.php');
$contact=new Contact($db);
$contact->fetch($propal->contactid);
print '<a href="'.DOL_URL_ROOT.'/contact/fiche.php?id='.$propal->contactid.'" title="'.$langs->trans('ShowContact').'">';
print $contact->firstname.' '.$contact->name;
print '</a>';
print '</td>';
}
else {
print '<td colspan="3">&nbsp;</td>';
}
}
}
print '</td>';
if ($conf->projet->enabled)
$rowspan++;
print '<td valign="top" colspan="2" width="50%" rowspan="'.$rowspan.'">'.$langs->trans('Note').' :<br>'. nl2br($propal->note).'</td></tr>';
if ($conf->projet->enabled)
{
$langs->load("projects");
print '<tr><td>'.$langs->trans('Project').'</td>';
$numprojet = $societe->has_projects();
if (! $numprojet)
{
print '<td colspan="2">';
print $langs->trans("NoProject").'</td><td>';
print '<a href=../projet/fiche.php?socidp='.$societe->id.'&action=create>'.$langs->trans('AddProject').'</a>';
print '</td>';
}
else
{
if ($propal->statut == 0 && $user->rights->propale->creer)
{
print '<td colspan="2">';
print '<form action="propal.php?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>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print '</form>';
print '</td>';
}
else
{
if (!empty($propal->projetidp))
{
print '<td colspan="3">';
$proj = new Project($db);
$proj->fetch($propal->projetidp);
print '<a href="../projet/fiche.php?id='.$propal->projetidp.'" title="'.$langs->trans('ShowProject').'">';
print $proj->title;
print '</a>';
print '</td>';
}
else {
print '<td colspan="3">&nbsp;</td>';
}
}
}
print '</tr>';
}
print '<tr><td height="10" nowrap>'.$langs->trans('GlobalDiscount').'</td>';
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
print '<form action="propal.php?propalid='.$propal->id.'" method="post">';
print '<input type="hidden" name="action" value="setremise">';
print '<td colspan="2"><input type="text" name="remise" size="3" value="'.$propal->remise_percent.'">% ';
print '</td><td>';
print '<input type="submit" class="button" value="'.$langs->trans('Modify').'">';
print ' <a href="propal/aideremise.php?propalid='.$propal->id.'">?</a>';
print '</td>';
print '</form>';
}
else
{
print '<td colspan="3">'.$propal->remise_percent.'%</td>';
}
print '</tr>';
print '<tr><td height="10">'.$langs->trans('AmountHT').'</td>';
print '<td align="right" colspan="2"><b>'.price($propal->price).'</b></td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height="10">'.$langs->trans('AmountVAT').'</td><td align="right" colspan="2">'.price($propal->total_tva).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
print '<tr><td height="10">'.$langs->trans('AmountTTC').'</td><td align="right" colspan="2">'.price($propal->total_ttc).'</td>';
print '<td>'.$langs->trans("Currency".$conf->monnaie).'</td></tr>';
// Statut
print '<tr><td height="10">'.$langs->trans('Status').'</td><td align="left" colspan="3">'.$propal->getLibStatut().'</td></tr>';
print '</table><br>';
if ($propal->brouillon == 1 && $user->rights->propale->creer)
{
print '</form>';
}
/*
* Lignes de propale
*
*/
$sql = 'SELECT pt.rowid, pt.description, pt.price, pt.fk_product, pt.qty, pt.tva_tx, pt.remise_percent, pt.subprice, p.label as product, p.ref, p.fk_product_type, p.rowid as prodid';
$sql .= ' FROM '.MAIN_DB_PREFIX.'propaldet as pt LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON pt.fk_product=p.rowid';
$sql .= ' WHERE pt.fk_propal = '.$propal->id;
$sql .= ' ORDER BY pt.rowid ASC';
$resql = $db->query($sql);
if ($resql)
{
$num_lignes = $db->num_rows($resql);
$i = 0;
$total = 0;
print '<table class="noborder" width="100%">';
if ($num_lignes)
{
print '<tr class="liste_titre">';
print '<td>'.$langs->trans('Description').'</td>';
print '<td align="right" width="50">'.$langs->trans('VAT').'</td>';
print '<td align="right" width="80">'.$langs->trans('PriceUHT').'</td>';
print '<td align="right" width="50">'.$langs->trans('Qty').'</td>';
print '<td align="right" width="50">'.$langs->trans('Discount').'</td>';
print '<td align="right" width="50">'.$langs->trans('AmountHT').'</td>';
print '<td>&nbsp;</td><td>&nbsp;</td>';
print "</tr>\n";
}
$var=true;
while ($i < $num_lignes)
{
$objp = $db->fetch_object($resql);
$var=!$var;
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
{
print '<tr '.$bc[$var].'>';
if ($objp->fk_product > 0)
{
print '<td><a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
if ($objp->fk_product_type)
print img_object($langs->trans('ShowService'),'service');
else
print img_object($langs->trans('ShowProduct'),'product');
print ' '.$objp->ref.'</a> - '.stripslashes(nl2br($objp->product));
if ($objp->date_start && $objp->date_end)
{
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
}
if ($objp->date_start && ! $objp->date_end)
{
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
}
if (! $objp->date_start && $objp->date_end)
{
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
}
print $objp->description?'<br>'.$objp->description:'';
print '</td>';
}
else
{
print '<td>'.stripslashes(nl2br($objp->description));
if ($objp->date_start && $objp->date_end)
{
print ' (Du '.dolibarr_print_date($objp->date_start).' au '.dolibarr_print_date($objp->date_end).')';
}
if ($objp->date_start && ! $objp->date_end)
{
print ' (A partir du '.dolibarr_print_date($objp->date_start).')';
}
if (! $objp->date_start && $objp->date_end)
{
print " (Jusqu'au ".dolibarr_print_date($objp->date_end).')';
}
print "</td>\n";
}
print '<td align="right">'.$objp->tva_tx.'%</td>';
print '<td align="right">'.price($objp->subprice)."</td>\n";
print '<td align="right">'.$objp->qty.'</td>';
if ($objp->remise_percent > 0)
{
print '<td align="right">'.$objp->remise_percent."%</td>\n";
}
else
{
print '<td>&nbsp;</td>';
}
print '<td align="right">'.price($objp->subprice*$objp->qty*(100-$objp->remise_percent)/100)."</td>\n";
print '<td>&nbsp;</td><td>&nbsp;</td>';
print '</tr>';
}
$total = $total + ($objp->qty * $objp->price);
$i++;
}
$db->free($resql);
}
else
{
dolibarr_print_error($db);
}
print '</table>';
}
}
else
else
{
dolibarr_print_error($db);
dolibarr_print_error($db);
}
print '</div>';
print '</div>';
/*

View File

@ -212,7 +212,7 @@ function pt ($db, $sql, $year) {
if ($num) {
$beg = $obj->dm;
} else {
$beg = 1 ;
$beg = 0 ;
}
if ($beg <= 12 ) {

View File

@ -130,8 +130,9 @@ class Facture
if (! $this->projetid) $this->projetid = 'NULL';
$totalht = ($amount - $remise);
$tva = tva($totalht);
$total = $totalht + $tva;
// NE ME SEMBLE PLUS JUSTIFIE ICI
// $tva = tva($totalht);
// $total = $totalht + $tva;
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facture (facnumber, fk_soc, datec, amount, remise, remise_percent';
$sql .= ', datef, note, fk_user_author, fk_projet';
@ -934,10 +935,17 @@ class Facture
{
// Nettoyage paramètres
if (strlen(trim($qty))==0) $qty=1;
$remise = 0;
if ($fk_product && ! $pu)
{
$prod = new Product($this->db, $fk_product);
$prod->fetch($fk_product);
$pu=$prod->price;
}
$_price = $pu;
$subprice = $pu;
$remise = 0;
$remise_percent = trim($remise_percent);
if ($this->socidp)
@ -972,14 +980,17 @@ class Facture
$subprice = ereg_replace(',','.',$subprice);
$sql = 'INSERT INTO '.MAIN_DB_PREFIX.'facturedet ';
$sql .= ' (fk_facture,description,price,qty,tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)';
$sql .= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',$fk_product,'$remise_percent','$subprice','$remise', ";
if ($datestart) { $sql.= "'$datestart', "; }
else { $sql.=' null, '; }
if ($dateend) { $sql.= "'$dateend' "; }
else { $sql.=' null '; }
$sql .= ','.$ventil;
$sql .=','.($rangmax + 1).')';
$sql.= ' (fk_facture, description, price, qty, tva_taux, fk_product, remise_percent, subprice, remise, date_start, date_end, fk_code_ventilation, rang)';
$sql.= " VALUES ($facid, '".addslashes($desc)."','$_price','$qty','$txtva',";
if ($fk_product) { $sql.= "'$fk_product',"; }
else { $sql.='0,'; }
$sql.= " '$remise_percent','$subprice','$remise',";
if ($datestart) { $sql.= "'$datestart',"; }
else { $sql.='null,'; }
if ($dateend) { $sql.= "'$dateend'"; }
else { $sql.='null'; }
$sql.= ','.$ventil;
$sql.= ','.($rangmax + 1).')';
if ( $this->db->query( $sql) )
{
$this->updateprice($facid);

View File

@ -98,8 +98,9 @@ class FactureFournisseur
if (! $remise) $remise = 0 ;
$totalht = ($amount - $remise);
$tva = tva($totalht);
$total = $totalht + $tva;
// NE ME SEMBLE PLUS JUSTIFIE ICI
// $tva = tva($totalht);
// $total = $totalht + $tva;
$sql = "INSERT INTO ".MAIN_DB_PREFIX."facture_fourn (facnumber, libelle, fk_soc, datec, datef, note, fk_user_author, date_lim_reglement) ";
$sql .= " VALUES ('".$number."','".addslashes($this->libelle)."',";
@ -414,16 +415,10 @@ class FactureFournisseur
$total_tva = $row[1];
$total_ttc = $row[2];
if ($total_ht == '')
$total_ht = 0;
if ($total_tva == '')
$total_tva = 0;
if ($total_ttc == '')
$total_ttc = 0;
}
$total_ht = $total_ht != '' ? $total_ht : 0;
$total_tva = $total_tva != '' ? $total_tva : 0;
$total_ttc = $total_ttc != '' ? $total_ttc : 0;
$sql = "UPDATE ".MAIN_DB_PREFIX."facture_fourn SET";
$sql .= " total_ht = ". ereg_replace(",",".",$total_ht);

View File

@ -525,7 +525,7 @@ class Form
* \param selected Produit présélectionné
* \param htmlname Nom de la zone select
* \param filtretype Pour filtre sur type de produit
* \param limit Limite sur le nombre de lignes retourné
* \param limit Limite sur le nombre de lignes retournées
*/
function select_produits($selected='',$htmlname='productid',$filtretype='',$limit=20)
{

View File

@ -96,20 +96,6 @@ class box_factures_fourn_imp extends ModeleBoxes {
$i++;
}
$i=$num;
while ($i < $max)
{
if ($num==0 && $i==$num)
{
$this->info_box_contents[$i][0] = array('align' => 'center','text'=>$langs->trans("NoSupplierBillsUnpayed"));
$this->info_box_contents[$i][1] = array('text'=>'&nbsp;');
} else {
$this->info_box_contents[$i][0] = array('text'=>'&nbsp;');
$this->info_box_contents[$i][1] = array('text'=>'&nbsp;');
}
$i++;
}
}
else {
dolibarr_print_error($db);

View File

@ -706,28 +706,31 @@ class pdf_crabe extends ModelePDFFactures
}
// Caractéristiques emetteur
$pdf->SetFont('Arial','',9);
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE"))
{
$pdf->MultiCell(80, 4, FAC_PDF_ADRESSE);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
}
$pdf->MultiCell(80, 4, "\n");
$carac_emetteur .= "\n";
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL)
{
$pdf->MultiCell(80, 4, $langs->trans("Phone").": ".FAC_PDF_TEL);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL;
}
if (defined("FAC_PDF_FAX") && FAC_PDF_FAX)
{
$pdf->MultiCell(80, 4, $langs->trans("Fax").": ".FAC_PDF_FAX);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX;
}
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL)
{
$pdf->MultiCell(80, 4, $langs->trans("Email").": ".FAC_PDF_MEL);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL;
}
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW)
{
$pdf->MultiCell(80, 4, $langs->trans("Web").": ".FAC_PDF_WWW);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
}
$pdf->SetFont('Arial','',9);
$pdf->SetXY(12,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
// Client destinataire
$posy=42;

View File

@ -622,28 +622,31 @@ class pdf_propale_azur extends ModelePDFPropales
}
// Caractéristiques emetteur
$pdf->SetFont('Arial','',9);
$carac_emetteur = '';
if (defined("FAC_PDF_ADRESSE"))
{
$pdf->MultiCell(80, 4, FAC_PDF_ADRESSE);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).FAC_PDF_ADRESSE;
}
$pdf->MultiCell(80, 4, "\n");
$carac_emetteur .= "\n";
if (defined("FAC_PDF_TEL") && FAC_PDF_TEL)
{
$pdf->MultiCell(80, 4, $langs->trans("Phone").": ".FAC_PDF_TEL);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Phone").": ".FAC_PDF_TEL;
}
if (defined("FAC_PDF_FAX") && FAC_PDF_FAX)
{
$pdf->MultiCell(80, 4, $langs->trans("Fax").": ".FAC_PDF_FAX);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Fax").": ".FAC_PDF_FAX;
}
if (defined("FAC_PDF_MEL") && FAC_PDF_MEL)
{
$pdf->MultiCell(80, 4, $langs->trans("Email").": ".FAC_PDF_MEL);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Email").": ".FAC_PDF_MEL;
}
if (defined("FAC_PDF_WWW") && FAC_PDF_WWW)
{
$pdf->MultiCell(80, 4, $langs->trans("Web").": ".FAC_PDF_WWW);
$carac_emetteur .= ($carac_emetteur ? "\n" : '' ).$langs->trans("Web").": ".FAC_PDF_WWW;
}
$pdf->SetFont('Arial','',9);
$pdf->SetXY(12,$posy+8);
$pdf->MultiCell(80,4, $carac_emetteur);
// Client destinataire
$posy=42;

View File

@ -38,67 +38,78 @@
function calcul_price($products, $remise_percent)
{
$total_ht = 0;
$amount_ht = 0;
$tva = array();
$total_tva = 0;
$total_remise = 0;
$num = sizeof($products);
$i = 0;
while ($i < $num)
{
$prod_price = $products[$i][0];
$prod_qty = $products[$i][1];
$prod_txtva = $products[$i][2];
$lprice = $prod_qty * $prod_price;
$amount_ht = $amount_ht + $lprice;
if ($remise_percent > 0)
$total_ht = 0;
$amount_ht = 0;
$total_tva = 0;
$total_ttc = 0;
$total_remise = 0;
$result[5] = array();
if ( sizeof( $products ) )
{
$lremise = ($lprice * $remise_percent / 100);
$lprice = $lprice - $lremise;
$total_remise = $total_remise + $lremise;
foreach ($products as $product)
{
$prod_price = $product[0];
$prod_qty = $product[1];
$prod_txtva = $product[2];
// montant total HT de la ligne
$line_price_ht = $prod_qty * $prod_price;
// incrémentation montant HT hors remise de l'ensemble
$amount_ht += $line_price_ht;
// si une remise est consentie sur l'ensemble
if ($remise_percent > 0)
{
// calcul de la remise sur la ligne
$line_remise = ($line_price_ht * $remise_percent / 100);
// soustraction de cette remise au montant HT de la ligne
$line_price_ht -= $line_remise;
// incrémentation du montant total de remise sur l'ensemble
$total_remise += $line_remise;
}
// incrémentation du montant HT remisé de l'ensemble
$total_ht += $line_price_ht;
// calcul de la TVA sur la ligne
$line_tva = ($line_price_ht * (abs($prod_txtva) / 100));
// incrémentation du montant TTC de la valeur HT, on traite la TVA ensuite
$total_ttc += $line_price_ht;
// traitement de la tva non perçue récupérable
if ( $prod_txtva >= 0 )
{
// ce n'est pas une TVA non perçue récupérable,
// donc on incrémente le total TTC de l'ensemble, de la valeur de TVA de la ligne
$total_ttc += $line_tva;
}
// dans tous les cas, on incrémente le total de TVA
$total_tva += $line_tva;
// on incrémente le tableau de différentiation des taux de TVA
// s'il faut rassembler les tva facturables ou non, du même taux
// dans un même ligne du tableau, remplacer la ligne suivante par :
// $result[5][abs($prod_txtva)] += $line_tva;
$result[5][$prod_txtva] += $line_tva;
$i++;
}
}
$total_ht = $total_ht + $lprice;
$ligne_tva = ($lprice * ($prod_txtva / 100));
$tva[$prod_txtva] = $tva[$prod_txtva] + $ligne_tva;
$i++;
}
/*
* Sommes et arrondis
*/
$j=0;
$result[5] = array();
foreach ($tva as $key => $value)
{
$tva[$key] = round($tva[$key], 2);
$total_tva = $total_tva + $tva[$key];
$result[5][$key] = $tva[$key];
$j++;
}
$total_ht = round($total_ht, 2);
$total_tva = round($total_tva, 2);
$total_ttc = $total_ht + $total_tva;
/*
*
*/
$result[0] = $total_ht;
$result[1] = $total_tva;
$result[2] = $total_ttc;
$result[3] = $total_remise;
$result[4] = $amount_ht;
return $result;
/*
* arrondis
*/
$total_ht = round($total_ht, 2);
$total_tva = round($total_tva, 2);
/*
*
*/
$result[0] = $total_ht;
$result[1] = $total_tva;
$result[2] = $total_ttc;
$result[3] = $total_remise;
$result[4] = $amount_ht;
return $result;
}

View File

@ -102,7 +102,8 @@ if ($_POST["action"] == 'update' &&
{
$product->ref = stripslashes($_POST["ref"]);
$product->libelle = stripslashes($_POST["libelle"]);
$product->price = stripslashes($_POST["price"]);
if ( isset( $_POST["price"] ) )
$product->price = stripslashes($_POST["price"]);
$product->tva_tx = $_POST["tva_tx"];
$product->description = stripslashes($_POST["desc"]);
$product->note = stripslashes($_POST["note"]);

View File

@ -481,6 +481,7 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'54','Soci
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d\'administration');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'56','Société anonyme à directoire');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'57','Société par actions simplifiée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Entreprise Unipersonnelle à Responsabilité Limitée (EURL)');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'61','Caisse d\'épargne et de prévoyance');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'62','Groupement d\'intérêt économique');

View File

@ -417,6 +417,8 @@ alter table llx_paiement add fk_user_creat integer;
alter table llx_paiement add fk_user_modif integer;
alter table llx_propal add fin_validite datetime ;
alter table llx_propal add fk_cond_reglement integer after total;
alter table llx_propal add fk_mode_reglement integer after total;
alter table llx_entrepot add statut tinyint default 1;
alter table llx_entrepot add lieu varchar(64);
@ -1375,6 +1377,7 @@ insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'54','Soci
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'55','Société anonyme à conseil d\'administration');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'56','Société anonyme à directoire');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'57','Société par actions simplifiée');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'58','Entreprise Unipersonnelle à Responsabilité Limitée (EURL)');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'61','Caisse d\'épargne et de prévoyance');
insert into llx_c_forme_juridique (fk_pays, code, libelle) values (1,'62','Groupement d\'intérêt économique');
@ -1848,7 +1851,9 @@ insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) v
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (80, 'projet', 'internal', 'PROJECTLEADER', 'Chef de Projet', 1);
insert into llx_c_type_contact(rowid, element, source, code, libelle, active ) values (81, 'projet', 'external', 'PROJECTLEADER', 'Chef de Projet', 1);
alter table llx_commande add ref_client varchar(30) after ref;
alter table llx_facture add ref_client varchar(30) after facnumber;
alter table llx_facture add date_valid date after datef;
alter table llx_facture add model varchar(50) after note;

View File

@ -28,13 +28,14 @@ create table llx_facture
fk_soc integer NOT NULL,
datec datetime, -- date de creation de la facture
datef date, -- date de la facture
date_valid date, -- date de validation
paye smallint DEFAULT 0 NOT NULL,
amount real DEFAULT 0 NOT NULL,
remise_percent real DEFAULT 0, -- remise globale en pourcent
remise real DEFAULT 0,
remise_percent real DEFAULT 0,
tva real DEFAULT 0,
total real DEFAULT 0,
total_ttc real DEFAULT 0,
tva real DEFAULT 0, -- montant tva apres remise globale
total real DEFAULT 0, -- montant total ht apres remise globale
total_ttc real DEFAULT 0, -- montant total ttc apres remise globale
fk_statut smallint DEFAULT 0 NOT NULL,
@ -43,11 +44,12 @@ create table llx_facture
fk_projet integer, -- projet auquel est associée la facture
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
date_lim_reglement date, -- date limite de reglement
fk_cond_reglement integer DEFAULT 1 NOT NULL, -- condition de reglement (30 jours, fin de mois ...)
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
date_lim_reglement date, -- date limite de reglement
note text,
model varchar(50),
UNIQUE INDEX (facnumber)
)type=innodb;

View File

@ -28,20 +28,26 @@ create table llx_propal
fk_projet integer DEFAULT 0, -- projet auquel est rattache la propale
ref varchar(30) NOT NULL, -- propal number
datec datetime, -- date de creation
datep date, -- date de la propal
fin_validite datetime, -- date de fin de validite
date_valid datetime, -- date de validation
date_cloture datetime, -- date de cloture
datep date, -- date de la propal
fk_user_author integer, -- createur de la propale
fk_user_valid integer, -- valideur de la propale
fk_user_cloture integer, -- cloture de la propale signee ou non signee
fk_statut smallint DEFAULT 0,
fk_statut smallint DEFAULT 0 NOT NULL,
price real DEFAULT 0,
remise_percent real DEFAULT 0,
remise_percent real DEFAULT 0, -- remise globale en pourcent
remise real DEFAULT 0,
tva real DEFAULT 0,
total real DEFAULT 0,
tva real DEFAULT 0, -- montant tva apres remise globale
total_ht real DEFAULT 0, -- montant total ht apres remise globale
total real DEFAULT 0, -- montant total ttc apres remise globale
fk_cond_reglement integer, -- condition de reglement (30 jours, fin de mois ...)
fk_mode_reglement integer, -- mode de reglement (Virement, Prélèvement)
note text,
model_pdf varchar(50),
UNIQUE INDEX (ref)
)type=innodb;