mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-09 19:18:22 +01:00
Prepare select of type of line
This commit is contained in:
@@ -2636,7 +2636,7 @@ else
|
||||
|
||||
|
||||
/*
|
||||
* Lignes de factures
|
||||
* Lines of invoice
|
||||
*/
|
||||
$sql = 'SELECT l.fk_product, l.product_type, l.description, l.qty, l.rowid, l.tva_taux,';
|
||||
$sql.= ' l.fk_remise_except,';
|
||||
@@ -2644,6 +2644,7 @@ else
|
||||
$sql.= ' l.total_ht, l.total_tva, l.total_ttc,';
|
||||
$sql.= ' '.$db->pdate('l.date_start').' as date_start,';
|
||||
$sql.= ' '.$db->pdate('l.date_end').' as date_end,';
|
||||
$sql.= ' l.product_type,';
|
||||
$sql.= ' p.ref, p.fk_product_type, p.label as product,';
|
||||
$sql.= ' p.description as product_desc';
|
||||
$sql.= ' FROM '.MAIN_DB_PREFIX.'facturedet as l';
|
||||
@@ -2657,11 +2658,12 @@ else
|
||||
$num_lignes = $db->num_rows($resql);
|
||||
$i = 0; $total = 0;
|
||||
|
||||
$product_static=new Product($db);
|
||||
|
||||
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>';
|
||||
@@ -2671,7 +2673,6 @@ else
|
||||
print '<td align="right" width="50">'.$langs->trans('TotalHT').'</td>';
|
||||
print '<td width="48" colspan="3"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
}
|
||||
$var=true;
|
||||
while ($i < $num_lignes)
|
||||
@@ -2679,6 +2680,13 @@ else
|
||||
$objp = $db->fetch_object($resql);
|
||||
$var=!$var;
|
||||
|
||||
// Show product and description
|
||||
$type=$objp->product_type?$objp->product_type:$objp->fk_product_type;
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($objp->date_start)) $type=1;
|
||||
if (! empty($objp->date_end)) $type=1;
|
||||
|
||||
// Ligne en mode visu
|
||||
if ($_GET['action'] != 'editline' || $_GET['rowid'] != $objp->rowid)
|
||||
{
|
||||
@@ -2688,20 +2696,21 @@ else
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Affiche ligne produit
|
||||
$text = '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||
if ($objp->fk_product_type==1) $text.= img_object($langs->trans('ShowService'),'service');
|
||||
else $text.= img_object($langs->trans('ShowProduct'),'product');
|
||||
$text.= ' '.$objp->ref.'</a>';
|
||||
// Show product and description
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
$description=($conf->global->PRODUIT_DESC_IN_FORM?'':dol_htmlentitiesbr($objp->description));
|
||||
//print $description;
|
||||
print $html->textwithtooltip($text,$description,3,'','',$i);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM)
|
||||
{
|
||||
print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
}
|
||||
|
||||
// Add description in form
|
||||
if ($conf->global->PRODUIT_DESC_IN_FORM) print ($objp->description && $objp->description!=$objp->product)?'<br>'.dol_htmlentitiesbr($objp->description):'';
|
||||
|
||||
print '</td>';
|
||||
}
|
||||
@@ -2737,9 +2746,11 @@ else
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($objp->fk_product_type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
if ($type==1) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' '.nl2br($objp->description);
|
||||
|
||||
// Show range
|
||||
print_date_range($objp->date_start,$objp->date_end);
|
||||
}
|
||||
print "</td>\n";
|
||||
@@ -2824,17 +2835,27 @@ else
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
print '<a name="'.$objp->rowid.'"></a>'; // ancre pour retourner sur la ligne
|
||||
|
||||
// Show product and description
|
||||
if ($objp->fk_product > 0)
|
||||
{
|
||||
print '<input type="hidden" name="productid" value="'.$objp->fk_product.'">';
|
||||
print '<a href="'.DOL_URL_ROOT.'/product/fiche.php?id='.$objp->fk_product.'">';
|
||||
if ($objp->fk_product_type==1) print img_object($langs->trans('ShowService'),'service');
|
||||
else print img_object($langs->trans('ShowProduct'),'product');
|
||||
print ' '.$objp->ref.'</a>';
|
||||
print ' - '.nl2br($objp->product);
|
||||
$product_static->type=$objp->fk_product_type;
|
||||
$product_static->id=$objp->fk_product;
|
||||
$product_static->ref=$objp->ref;
|
||||
$product_static->libelle=$objp->product;
|
||||
$text=$product_static->getNomUrl(1);
|
||||
$text.= ' - '.$objp->product;
|
||||
print $text;
|
||||
print '<br>';
|
||||
}
|
||||
// <20>diteur wysiwyg
|
||||
else
|
||||
{
|
||||
// TODO Select type (service or product)
|
||||
|
||||
}
|
||||
|
||||
// Description - Editor wysiwyg
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
@@ -2849,10 +2870,16 @@ else
|
||||
print '</textarea>';
|
||||
}
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td align="right">';
|
||||
print $html->select_tva('tva_tx',$objp->tva_taux,$mysoc,$soc,'',$objp->info_bits);
|
||||
print '</td>';
|
||||
|
||||
// Unit price
|
||||
print '<td align="right"><input size="6" type="text" class="flat" name="price" value="'.price($objp->subprice,0,'',0).'"></td>';
|
||||
|
||||
|
||||
print '<td align="right">';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
@@ -2860,6 +2887,7 @@ else
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="right" nowrap>';
|
||||
if (($objp->info_bits & 2) != 2)
|
||||
{
|
||||
@@ -2867,6 +2895,7 @@ else
|
||||
}
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center" rowspan="1" colspan="5" valign="middle"><input type="submit" class="button" name="save" value="'.$langs->trans('Save').'">';
|
||||
print '<br><input type="submit" class="button" name="cancel" value="'.$langs->trans('Cancel').'"></td>';
|
||||
print '</tr>' . "\n";
|
||||
@@ -2910,7 +2939,7 @@ else
|
||||
print '<td colspan="4"> </td>';
|
||||
print "</tr>\n";
|
||||
|
||||
// Ajout produit produits/services personalis<EFBFBD>s
|
||||
// Add free products/services form
|
||||
print '<form name="addligne" action="'.$_SERVER['PHP_SELF'].'#add" method="post">';
|
||||
print '<input type="hidden" name="facid" value="'.$fac->id.'">';
|
||||
print '<input type="hidden" name="action" value="addligne">';
|
||||
@@ -2918,7 +2947,9 @@ else
|
||||
$var=true;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
print '<td>';
|
||||
// <EFBFBD>diteur wysiwyg
|
||||
// TODO Select type (product or service)
|
||||
|
||||
// Editeur wysiwyg
|
||||
if ($conf->fckeditor->enabled && $conf->global->FCKEDITOR_ENABLE_DETAILS)
|
||||
{
|
||||
require_once(DOL_DOCUMENT_ROOT."/lib/doleditor.class.php");
|
||||
@@ -2931,7 +2962,6 @@ else
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
|
||||
$html->select_tva('tva_tx',$conf->defaulttx,$mysoc,$soc);
|
||||
print '</td>';
|
||||
print '<td align="right"><input type="text" name="pu" size="6"></td>';
|
||||
@@ -2951,7 +2981,7 @@ else
|
||||
}
|
||||
print '</form>';
|
||||
|
||||
// Ajout de produits/services pr<EFBFBD>d<EFBFBD>finis
|
||||
// Add predefined services/products form
|
||||
if ($conf->produit->enabled)
|
||||
{
|
||||
print '<tr class="liste_titre">';
|
||||
|
||||
@@ -193,10 +193,11 @@ else
|
||||
'ftotal_ttc'=>$x_coll[$my_coll_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc'=>$x_coll[$my_coll_rate]['dtotal_ttc'][$id],
|
||||
'dtype' =>$x_coll[$my_coll_rate]['dtype'][$id],
|
||||
'ddate_start'=>$x_coll[$my_coll_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_coll[$my_coll_rate]['ddate_end'][$id],
|
||||
'totalht' =>$x_coll[$my_coll_rate]['totalht_list'][$id],
|
||||
'vat' =>$x_coll[$my_coll_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_customer->getNomUrl(1,'',12));
|
||||
//$x_both[$my_coll_rate]['coll']['links'] .= '<a href="../facture.php?facid='.$x_coll[$my_coll_rate]['facid'][$id].'" title="'.$x_coll[$my_coll_rate]['facnum'][$id].'">..'.substr($x_coll[$my_coll_rate]['facnum'][$id],-2).'</a> ';
|
||||
}
|
||||
}
|
||||
// tva payed
|
||||
@@ -223,13 +224,14 @@ else
|
||||
'ptype' =>$x_paye[$my_paye_rate]['ptype'][$id],
|
||||
'payment_id'=>$x_paye[$my_paye_rate]['payment_id'][$id],
|
||||
'payment_amount'=>$x_paye[$my_paye_rate]['payment_amount'][$id],
|
||||
'ftotal_ttc'=>$x_paye[$my_paye_rate]['ftotal_ttc'][$id],
|
||||
'dtotal_ttc'=>$x_paye[$my_paye_rate]['dtotal_ttc'][$id],
|
||||
'ftotal_ttc'=>price2num($x_paye[$my_paye_rate]['ftotal_ttc'][$id]),
|
||||
'dtotal_ttc'=>price2num($x_paye[$my_paye_rate]['dtotal_ttc'][$id]),
|
||||
'dtype' =>$x_paye[$my_paye_rate]['dtype'][$id],
|
||||
'totalht' =>$x_paye[$my_paye_rate]['totalht_list'][$id],
|
||||
'ddate_start'=>$x_paye[$my_paye_rate]['ddate_start'][$id],
|
||||
'ddate_end' =>$x_paye[$my_paye_rate]['ddate_end'][$id],
|
||||
'totalht' =>price2num($x_paye[$my_paye_rate]['totalht_list'][$id]),
|
||||
'vat' =>$x_paye[$my_paye_rate]['vat_list'][$id],
|
||||
'link' =>$invoice_supplier->getNomUrl(1,'',12));
|
||||
//$x_both[$my_paye_rate]['paye']['links'] .= '<a href="../../fourn/facture/fiche.php?facid='.$x_paye[$my_paye_rate]['facid'][$id].'" title="'.$x_paye[$my_paye_rate]['facnum'][$id].'">..'.substr($x_paye[$my_paye_rate]['facnum'][$id],-2).'</a> ';
|
||||
}
|
||||
}
|
||||
//now we have an array (x_both) indexed by rates for coll and paye
|
||||
@@ -275,6 +277,13 @@ else
|
||||
|
||||
foreach($x_both[$rate]['coll']['detail'] as $index => $fields)
|
||||
{
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
@@ -289,15 +298,17 @@ else
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if ($fields['descr']) print ' - ';
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($fields['dtype']==1) $text = img_object($langs->trans('Service'),'service');
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' ';
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
@@ -305,7 +316,7 @@ else
|
||||
{
|
||||
print '<td nowrap align="right">';
|
||||
print price($fields['totalht']);
|
||||
if ($fields['ftotal_ttc'])
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
@@ -318,33 +329,36 @@ else
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
{
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td nowrap align="right">';
|
||||
//print $fields['totalht']."-".$fields['payment_amount']."-".$fields['ftotal_ttc'];
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$payment_static->rowid=$fields['payment_id'];
|
||||
$payment_static->id=$fields['payment_id'];
|
||||
print $payment_static->getNomUrl(2);
|
||||
}
|
||||
if ($fields['ptype'] == 0)
|
||||
if ($type == 0)
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
}
|
||||
else print $fields['payment_amount'];
|
||||
if ($fields['payment_amount'] && $ratiopaymentinvoice) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
else {
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Total collected
|
||||
print '<td nowrap align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($ratiopaymentinvoice) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'));
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td nowrap align="right">';
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'));
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
@@ -398,6 +412,13 @@ else
|
||||
print '</tr>'."\n";
|
||||
foreach($x_both[$rate]['paye']['detail'] as $index=>$fields)
|
||||
{
|
||||
// Define type
|
||||
$type=($fields['dtype']?$fields['dtype']:$fields['ptype']);
|
||||
// Try to enhance type detection using date_start and date_end for free lines where type
|
||||
// was not saved.
|
||||
if (! empty($fields['ddate_start'])) $type=1;
|
||||
if (! empty($fields['ddate_end'])) $type=1;
|
||||
|
||||
$var=!$var;
|
||||
print '<tr '.$bc[$var].'>';
|
||||
|
||||
@@ -412,22 +433,25 @@ else
|
||||
$product_static->ref=$fields['pref'];
|
||||
$product_static->type=$fields['ptype'];
|
||||
print $product_static->getNomUrl(1);
|
||||
if ($fields['descr']) print ' - ';
|
||||
if (dol_string_nohtmltag($fields['descr'])) print ' - '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($fields['dtype']==1) $text = img_object($langs->trans('Service'),'service');
|
||||
if ($type) $text = img_object($langs->trans('Service'),'service');
|
||||
else $text = img_object($langs->trans('Product'),'product');
|
||||
print $text.' ';
|
||||
print $text.' '.dol_trunc(dol_string_nohtmltag($fields['descr']),16);
|
||||
|
||||
// Show range
|
||||
print_date_range($fields['ddate_start'],$fields['ddate_end']);
|
||||
}
|
||||
print dol_trunc($fields['descr'],24).'</td>';
|
||||
print '</td>';
|
||||
|
||||
// Total HT
|
||||
if ($modetax == 0)
|
||||
{
|
||||
print '<td nowrap align="right">';
|
||||
print price($fields['totalht']);
|
||||
if ($fields['ftotal_ttc'])
|
||||
if (price2num($fields['ftotal_ttc']))
|
||||
{
|
||||
//print $fields['dtotal_ttc']."/".$fields['ftotal_ttc']." - ";
|
||||
$ratiolineinvoice=($fields['dtotal_ttc']/$fields['ftotal_ttc']);
|
||||
@@ -440,32 +464,36 @@ else
|
||||
$ratiopaymentinvoice=1;
|
||||
if ($modetax == 0)
|
||||
{
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
if (isset($fields['payment_amount']) && $fields['ftotal_ttc']) $ratiopaymentinvoice=($fields['payment_amount']/$fields['ftotal_ttc']);
|
||||
print '<td nowrap align="right">';
|
||||
if ($fields['payment_amount'] && $fields['ftotal_ttc'])
|
||||
{
|
||||
$paymentfourn_static->rowid=$fields['payment_id'];
|
||||
$paymentfourn_static->id=$fields['payment_id'];
|
||||
print $paymentfourn_static->getNomUrl(2);
|
||||
}
|
||||
if ($fields['ptype'] == 0)
|
||||
if ($type == 0)
|
||||
{
|
||||
print $langs->trans("NotUsedForGoods");
|
||||
}
|
||||
else print $fields['payment_amount'];
|
||||
if ($fields['payment_amount'] && $ratiopaymentinvoice) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
else
|
||||
{
|
||||
print $fields['payment_amount'];
|
||||
if (isset($fields['payment_amount'])) print ' ('.round($ratiopaymentinvoice*100,2).'%)';
|
||||
}
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// VAT payed
|
||||
print '<td nowrap align="right">';
|
||||
$temp_ht=$fields['totalht'];
|
||||
if ($ratiopaymentinvoice) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
if ($type == 1) $temp_ht=$fields['totalht']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_ht,'MT'));
|
||||
print '</td>';
|
||||
|
||||
// VAT
|
||||
print '<td nowrap align="right">';
|
||||
$temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
$temp_vat=$fields['vat'];
|
||||
if ($type == 1) $temp_vat=$fields['vat']*$ratiopaymentinvoice;
|
||||
print price(price2num($temp_vat,'MT'));
|
||||
//print price($fields['vat']);
|
||||
print '</td>';
|
||||
|
||||
@@ -522,8 +522,7 @@ else
|
||||
print '</form>';
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
*
|
||||
* Lines of invoice
|
||||
*/
|
||||
print '<br>';
|
||||
$var=true;
|
||||
@@ -540,6 +539,7 @@ else
|
||||
for ($i = 0 ; $i < sizeof($fac->lignes) ; $i++)
|
||||
{
|
||||
$var=!$var;
|
||||
|
||||
// Affichage simple de la ligne
|
||||
print '<tr '.$bc[$var].'><td>'.$fac->lignes[$i]->description.'</td>';
|
||||
print '<td align="right">'.vatrate($fac->lignes[$i]->tva_taux).'%</td>';
|
||||
@@ -697,7 +697,7 @@ else
|
||||
print '<table width="100%" class="noborder">';
|
||||
|
||||
/*
|
||||
* Liste des paiements
|
||||
* List of payments
|
||||
*/
|
||||
print '<tr><td colspan="2">';
|
||||
$sql = 'SELECT '.$db->pdate('datep').' as dp, pf.amount,';
|
||||
@@ -774,7 +774,7 @@ else
|
||||
|
||||
|
||||
/*
|
||||
* Lignes
|
||||
* Lines of invoice
|
||||
*/
|
||||
print '<br>';
|
||||
print '<table class="noborder" width="100%">';
|
||||
@@ -836,7 +836,7 @@ else
|
||||
if ($fac->lignes[$i]->fk_product)
|
||||
{
|
||||
$productstatic->id=$fac->lignes[$i]->fk_product;
|
||||
$productstatic->type=1;
|
||||
$productstatic->type=$fac->lignes[$i]->product_type;
|
||||
//$productstatic->ref=$fac->lignes[$i]->ref;
|
||||
//print $productstatic->getNomUrl(1).' ('.$fac->lignes[$i]->ref_fourn.') - '.$fac->lignes[$i]->libelle;
|
||||
$productstatic->ref=$fac->lignes[$i]->libelle;
|
||||
|
||||
@@ -2407,7 +2407,7 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1)
|
||||
{
|
||||
$temp = str_replace(" "," ",$temp);
|
||||
}
|
||||
$CleanString = $temp;
|
||||
$CleanString = trim($temp);
|
||||
return $CleanString;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
/* Copyright (C) 2004-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
/* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2006-2007 Yannick Warnier <ywarnier@beeznest.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
@@ -18,10 +18,10 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
\file htdocs/lib/tax.lib.php
|
||||
\ingroup tax
|
||||
\brief Library for tax module
|
||||
\version $Id$
|
||||
* \file htdocs/lib/tax.lib.php
|
||||
* \ingroup tax
|
||||
* \brief Library for tax module
|
||||
* \version $Id$
|
||||
*/
|
||||
|
||||
|
||||
@@ -143,7 +143,7 @@ function vat_by_thirdparty($db, $y, $modetax, $direction)
|
||||
* This function also accounts recurrent invoices
|
||||
* \param db Database handler object
|
||||
* \param y Year
|
||||
* \param q Year quarter (1-4)
|
||||
* \param q Period. If 1-4, it's year quarter.
|
||||
* \param modetax 0 or 1 (option vat on debit)
|
||||
* \param direction 'sell' or 'buy'
|
||||
* \return array List of quarters with vat
|
||||
@@ -196,6 +196,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " 0 as payment_id, 0 as payment_amount";
|
||||
@@ -207,7 +208,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " AND f.rowid = d.".$fk_facture;
|
||||
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
$sql.= " AND d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
@@ -227,6 +229,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
{
|
||||
// Tva sur factures pay<61>s (should be on shipment, done on payment instead !)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " 0 as payment_id, 0 as payment_amount";
|
||||
@@ -245,7 +248,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
// $sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
$sql.= " AND d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND (d.product_type = 0"; // Limit to products
|
||||
$sql.= " AND d.date_start is null AND d.date_end IS NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
@@ -254,7 +258,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
if ($sql && $sql=='TODO') return -2;
|
||||
if ($sql && $sql!='TODO')
|
||||
{
|
||||
dol_syslog("Client::vat_by_quarter sql=".$sql);
|
||||
dol_syslog("Tax.lib.php::vat_by_quarter sql=".$sql);
|
||||
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -273,6 +278,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
}
|
||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||
$list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
||||
|
||||
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
||||
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
||||
@@ -320,6 +327,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
if ($conf->global->MAIN_MODULE_COMPTABILITE)
|
||||
{
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " 0 as payment_id, 0 as payment_amount";
|
||||
@@ -331,7 +339,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " AND f.rowid = d.".$fk_facture;
|
||||
$sql.= " AND f.datef >= '".$y."0101000000' AND f.datef <= '".$y."1231235959'";
|
||||
$sql.= " AND (date_format(f.datef,'%m') > ".(($q-1)*3)." AND date_format(f.datef,'%m') <= ".($q*3).")";
|
||||
$sql.= " AND d.product_type = 1"; // Limit to services
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture;
|
||||
}
|
||||
}
|
||||
@@ -351,6 +360,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
{
|
||||
// Tva sur factures pay<61>s (should be on payment)
|
||||
$sql = "SELECT d.rowid, d.product_type as dtype, d.".$fk_facture." as facid, d.tva_taux as rate, d.total_ht as total_ht, d.total_ttc as total_ttc, d.".$total_tva." as total_vat, d.description as descr,";
|
||||
$sql.= " d.date_start as date_start, d.date_end as date_end,";
|
||||
$sql.= " f.facnumber as facnum, f.type, f.total_ttc as ftotal_ttc,";
|
||||
$sql.= " p.rowid as pid, p.ref as pref, p.fk_product_type as ptype,";
|
||||
$sql.= " pf.".$fk_payment." as payment_id, pf.amount as payment_amount";
|
||||
@@ -366,7 +376,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
$sql.= " AND pa.rowid = pf.".$fk_payment;
|
||||
$sql.= " AND pa.datep >= '".$y."0101000000' AND pa.datep <= '".$y."1231235959'";
|
||||
$sql.= " AND (date_format(pa.datep,'%m') > ".(($q-1)*3)." AND date_format(pa.datep,'%m') <= ".($q*3).")";
|
||||
$sql.= " AND d.product_type = 1"; // Limit to services
|
||||
$sql.= " AND (d.product_type = 1"; // Limit to services
|
||||
$sql.= " OR d.date_start is NOT null OR d.date_end IS NOT NULL)"; // enhance detection of service
|
||||
$sql.= " ORDER BY d.rowid, d.".$fk_facture.", pf.rowid";
|
||||
}
|
||||
}
|
||||
@@ -375,7 +386,7 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
if ($sql && $sql=='TODO') return -2;
|
||||
if ($sql && $sql!='TODO')
|
||||
{
|
||||
dol_syslog("Client::vat_by_quarter sql=".$sql);
|
||||
dol_syslog("Tax.lib.php::vat_by_quarter sql=".$sql);
|
||||
$resql = $db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
@@ -394,6 +405,8 @@ function vat_by_quarter($db, $y, $q, $modetax, $direction)
|
||||
}
|
||||
$list[$assoc['rate']]['dtotal_ttc'][] = $assoc['total_ttc'];
|
||||
$list[$assoc['rate']]['dtype'][] = $assoc['dtype'];
|
||||
$list[$assoc['rate']]['ddate_start'][] = $db->jdate($assoc['date_start']);
|
||||
$list[$assoc['rate']]['ddate_end'][] = $db->jdate($assoc['date_end']);
|
||||
|
||||
$list[$assoc['rate']]['facid'][] = $assoc['facid'];
|
||||
$list[$assoc['rate']]['facnum'][] = $assoc['facnum'];
|
||||
|
||||
Reference in New Issue
Block a user