Gestion : customer / supplier filter on the amount

This commit is contained in:
Dany De Bontridder 2010-08-03 17:36:38 +00:00
parent 175c716edc
commit 65e4a0de21
3 changed files with 43 additions and 25 deletions

View file

@ -1284,21 +1284,32 @@ function empty_attribute($p_attr) {
* \param $p_search (filter)
* \param $p_action show the action column
* \param $p_sql SQL to filter the number of card must start with AND
* \param $p_amount true : only cards with at least one operation default : false
* \return: string to display
*/
function Summary($p_search="",$p_action="",$p_sql="")
function Summary($p_search="",$p_action="",$p_sql="",$p_amount=false)
{
$str_dossier=dossier::get();
$p_search=FormatString($p_search);
$script=$_SERVER['PHP_SELF'];
// Creation of the nav bar
// Get the max numberRow
$all_tiers=$this->CountByDef($this->fiche_def_ref,$p_search,$p_sql);
$filter_amount='';
$User=new User($this->cn);
$filter_year=" j_tech_per in (select p_id from parm_periode ".
"where p_exercice='".$User->get_exercice()."')";
if ( $p_amount) $filter_amount=' and f_id in (select f_id from jrnx where '.$filter_year.')';
$all_tiers=$this->CountByDef($this->fiche_def_ref,$p_search,$p_sql.$filter_amount);
// Get offset and page variable
$offset=( isset ($_REQUEST['offset'] )) ?$_REQUEST['offset']:0;
$page=(isset($_REQUEST['page']))?$_REQUEST['page']:1;
$bar=jrn_navigation_bar($offset,$all_tiers,$_SESSION['g_pagesize'],$page);
// set a filter ?
// set a filter ?
$search=$p_sql;
$user=new User($this->cn);
@ -1317,8 +1328,9 @@ function empty_attribute($p_attr) {
ad_id=1 and av_text ~* '$p_search')";
}
// Get The result Array
$step_tiers=$this->GetAll($offset,$search,'name');
if ( $all_tiers == 0 ) return "";
$step_tiers=$this->GetAll($offset,$search.$filter_amount,'name');
if ( $all_tiers == 0 || count($step_tiers)==0 ) return "";
$r=$bar;
$r.='<table class="result" style="width:90%;margin-left:5%">
<TR >
@ -1333,9 +1345,17 @@ $r.='</TR>';
return $r;
$i=0;
foreach ($step_tiers as $tiers ) {
$i++;$odd="";
if ($i % 2 == 0 ) $odd='class="odd"';
/* Filter on the default year */
$amount=$tiers->get_solde_detail($filter_year);
/* skip the tiers without operation */
if ( $p_amount && $amount['debit']==0 && $amount['credit'] == 0 && $amount['solde'] == 0 ) continue;
$r.="<TR $odd>";
$e=sprintf('<A HREF="%s?p_action=%s&sb=detail&f_id=%d&%s&sc=sv" title="Détail"> ',
$script,$p_action,$tiers->id,$str_dossier);
@ -1348,15 +1368,10 @@ $r.='</TR>';
"</TD>";
/* Filter on the default year */
$User=new User($this->cn);
$filter_year=" j_tech_per in (select p_id from parm_periode ".
"where p_exercice='".$User->get_exercice()."')";
$a=$tiers->get_solde_detail($filter_year);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$a['debit']);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$a['credit']);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$a['solde']);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$amount['debit']);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$amount['credit']);
$r.=sprintf('<TD align="right"> %15.2f&euro;</TD>',$amount['solde']);
$r.="</TR>";

View file

@ -30,14 +30,7 @@ require_once('class_fiche_def.php');
require_once('class_iaction.php');
require_once('class_fiche_def.php');
require_once('class_ipopup.php');
echo js_include('accounting_item.js');
echo js_include('prototype.js');
echo js_include('scriptaculous.js');
echo js_include('effects.js');
echo js_include('controls.js');
echo js_include('dragdrop.js');
echo JS_CARD;
echo JS_AJAX_FICHE;
echo ICard::ipopup('ipop_newcard');
$ip_cat=new IPopup('ipop_cat');
$ip_cat->title=_('Ajout d\'une catégorie');
@ -102,6 +95,10 @@ if ( $low_action == "list" )
$sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1;
$sel_card->javascript=' onchange="submit(this);"';
echo _('Catégorie :').$sel_card->input();
$nooperation=new ICheckBox('noop');
$nooperation->selected=(isset($_GET['noop']))?true:false;
echo _('Inclure les clients sans opération :').$nooperation->input();
?>
<input type="submit" class="button" name="submit_query" value="<?=_('recherche')?>">
@ -115,9 +112,9 @@ if ( $low_action == "list" )
if ( isset($_GET['cat'])) {
if ( $_GET['cat'] != -1) $sql=sprintf(" and fd_id = %d",$_GET['cat']);
}
echo '<div class="content">';
echo $client->Summary($search,'client',$sql);
$noop=(isset($_GET['noop']))?false:true;
echo '<div class="content">';
echo $client->Summary($search,'client',$sql,$noop);
echo '<br>';

View file

@ -102,6 +102,10 @@ if ( $low_action == "list" )
$sel_card->selected=(isset($_GET['cat']))?$_GET['cat']:-1;
$sel_card->javascript=' onchange="submit(this);"';
echo _('Catégorie :').$sel_card->input();
$nooperation=new ICheckBox('noop');
$nooperation->selected=(isset($_GET['noop']))?true:false;
echo _('Inclure les fournisseurs sans opération :').$nooperation->input();
?>
<input type="submit" class="button" name="submit_query" value="<?=_('recherche')?>">
<input type="hidden" name="p_action" value="supplier">
@ -114,8 +118,10 @@ if ( $low_action == "list" )
if ( isset($_GET['cat'])) {
if ( $_GET['cat'] != -1) $sql=sprintf(" and fd_id = %d",$_GET['cat']);
}
$noop=(isset($_GET['noop']))?false:true;
echo '<div class="content">';
echo $supplier->Summary($search,'supplier',$sql);
echo $supplier->Summary($search,'supplier',$sql,$noop);
echo '<br>';