noalyss Version-10
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
Acc_Ledger_Search Class Reference

search in ledger More...

+ Collaboration diagram for Acc_Ledger_Search:

Public Member Functions

 __construct ($p_type, $p_all=1, $p_div="")
 return a HTML string with the form for the search
 
 build_name_filter ()
 Build the button for saving the filter for search.
 
 build_search_filter ()
 Build the button for managing the filter for search.
 
 build_search_sql ($p_array, $p_order="", $p_where="")
 this function will create a sql stmt to use to create the list for the ledger,
 
 button_propose_filter ()
 build an HTML string with a button to show the list of saved search
 
 display_list_filter ()
 display a list of saved search
 
 display_search_form ()
 return a html string with the search_form
 
 get_all ()
 
 get_div ()
 
 get_type ()
 
 list_operation ($sql, $offset, $p_paid=0)
 Show all the operation.
 
 list_operation_to_reconcile ($sql, $p_target)
 Show all the operation.
 
 search_form ()
 return a HTML string with the form for the search
 
 select_ledger ($p_selected, $p_div)
 return the html code to create an hidden div and a button to show this DIV.
 
 set_all ($all)
 
 set_div ($div)
 
 set_type ($type)
 

Static Public Member Functions

static build_array (User_Filter_SQL $user_filter_sql)
 use a user_filter row and turns it into an array for javascript purpose
 

Data Fields

 $id
 id of the ledger
 
 $inject_col
 inject_code (callback function ) into list_operation
 

Protected Attributes

 $cn
 Database Connection.
 

Private Attributes

 $all
 Flag to indicate if all ledgers must be searched (1 for yes)
 
 $div
 prefix for id of DOM id
 
 $type
 type of ledger : FIN,ODS,VEN,ACH
 

Detailed Description

search in ledger

Definition at line 33 of file acc_ledger_search.class.php.

Constructor & Destructor Documentation

◆ __construct()

Acc_Ledger_Search::__construct ( $p_type,
$p_all = 1,
$p_div = "" )

return a HTML string with the form for the search

Parameters
$p_typeif the type of ledger possible values=ALL,VEN,ACH,ODS,FIN: uppercase !
$all_type_ledgervalues :
  • 1 means all the ledger of this type
  • 0 No have the "Tous les journaux" availables
$divis the div (for reconciliation)
string$p_typeACH, VEN , ODS or FIN
int$p_all1 means all the ledger
string$p_divprefix of the DOM ID
Todo
the parameter $all_type_ledger is useless : ALL means all the ledgers, VEN all the ledger of sales...

Definition at line 63 of file acc_ledger_search.class.php.

64 {
65 $this->cn=Dossier::connect();
66 $this->set_type($p_type);
67 $this->all=$p_all;
68 $this->div=$p_div;
69 $this->inject_col=null;
70 }
$input_from cn
static connect()

References $p_type, cn, and set_type().

+ Here is the call graph for this function:

Member Function Documentation

◆ build_array()

static Acc_Ledger_Search::build_array ( User_Filter_SQL $user_filter_sql)
static

use a user_filter row and turns it into an array for javascript purpose

Parameters
User_Filter_SQL$user_filter_sql
Returns
array

Definition at line 1380 of file acc_ledger_search.class.php.

1381 {
1382 $record=$user_filter_sql->to_array();
1383
1384 $record['desc']=$record['description'];
1385 $record['r_jrn']=explode(",", $record['r_jrn']??"");
1386 $record['tag']=explode(",",$record['uf_tag']??"");
1387 $record['tag_option']=$record["uf_tag_option"];
1388 $record['p_currency_code']=$record['uf_currency_code'];
1389 return $record;
1390 }

◆ build_name_filter()

Acc_Ledger_Search::build_name_filter ( )

Build the button for saving the filter for search.

Definition at line 287 of file acc_ledger_search.class.php.

288 {
289 $name=new IText($this->div."filter_new");
290 $name->placeholder=_("Nom de la recherche");
291 $r=$name->input();
292 $bt=new IButton($this->div."save_ok",_("Ajout"));
293 $bt->javascript=sprintf("save_filter('%s','%s')",$this->div,Dossier::id());
294 $r.=$bt->input();
295 return $r;
296 }
catch(Exception $exc) if(! $g_user->can_write_action($ag_id)) $r
_("actif, passif,charge,...")

References $name, $r, and _.

◆ build_search_filter()

Acc_Ledger_Search::build_search_filter ( )

Build the button for managing the filter for search.

Parameters
type$p_divid prefix of the div, button, table ..
$this->typeif the type of ledger possible values=ALL,VEN,ACH,ODS,FIN
$all_type_ledgervalues :
  • 1 means all the ledger of this type
  • 0 No have the "Tous les journaux" availables

Definition at line 275 of file acc_ledger_search.class.php.

276 {
277 $json=json_encode(["div"=>$this->div, "ledger_type"=>$this->type, "all_type"=>$this->all,
278 "dossier"=>Dossier::id()]);
280 $r=sprintf('manage_search_filter(%s)', $json);
281 return $r;
282 }
noalyss_str_replace($search, $replace, $string)
$input_from type

References $json, $r, noalyss_str_replace(), and type.

Referenced by display_search_form().

+ Here is the call graph for this function:

◆ build_search_sql()

Acc_Ledger_Search::build_search_sql ( $p_array,
$p_order = "",
$p_where = "" )

this function will create a sql stmt to use to create the list for the ledger,

Parameters
$p_arrayis usually the $_GET,
$p_orderthe order of the row --> not used
$p_whereis the sql condition if not null then the $p_array will not be used
Note
the p_action will be used to filter the ledger but gl means ALL struct array $p_array
(
[gDossier] => 13
[p_jrn] => -1
[date_start] =>
[date_end] =>
[amount_min] => 0
[amount_max] => 0
[desc] =>
[search] => Rechercher
[p_action] => ven
[sa] => l
)
Returns
an array with a valid sql statement, an the where clause => array[sql] array[where]
See also
list_operation
display_search_form
search_form

Definition at line 325 of file acc_ledger_search.class.php.

326 {
327 $sql="with cas as (
328 select distinct jr_id
329 from jrn
330 join jrnx on (jr_grpt_id=j_grpt)
331 where
332 exists(select 1 from operation_analytique where j_id=jrnx.j_id) )
333 select jr_id ,
334 jr_montant,
335 substr(jr_comment,1,60) as jr_comment,
336 to_char(jr_ech,'DD.MM.YY') as str_jr_ech,
337 to_char(jr_date,'DD.MM.YY') as str_jr_date,
338 jr_date as jr_date_order,
339 jr_grpt_id,
340 jr_rapt,
341 jr_internal,
342 jrn_def_id,
343 jrn_def_name,
344 jrn_def_ech,
345 jrn_def_type,
346 jr_valid,
347 jr_tech_per,
348 jr_pj_name,
349 p_closed,
350 jr_pj_number,
351 n_text,
352 n_html,
353 (select string_agg(a,' ')
354 from (select '<span style=\"font-size:80%\" class=\"tagcell tagcell-color'||t.t_color::text||'\">'||t_tag||'</span>' a
355 from operation_tag ot join tags t on(ot.tag_id=t.t_id)
356 where ot.jrn_id=X.jr_id
357 ) as tag_ml)
358 as tag_operation
359 ,
360 case
361 when jrn_def_type='VEN' then
362 (select ad_value from fiche_detail where ad_id=1
363 and f_id=(select max(qs_client) from quant_sold join jrnx
364 using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt)
365 where e.jr_id=x.jr_id))
366 when jrn_def_type = 'ACH' then
367 (select ad_value
368 from fiche_detail
369 where ad_id=1
370 and f_id=(select max(qp_supplier) from quant_purchase
371 join jrnx using (j_id) join jrn as e on (e.jr_grpt_id=j_grpt) where e.jr_id=x.jr_id))
372 when jrn_def_type = 'FIN' then
373 (select ad_value from fiche_detail where ad_id=1
374 and f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))
375 end as name,
376 case
377 when jrn_def_type='VEN' then
378 (select ad_value from fiche_detail
379 where ad_id=32
380 and f_id=(select max(qs_client)
381 from quant_sold
382 join jrnx using (j_id)
383 join jrn as e on (e.jr_grpt_id=j_grpt)
384 where e.jr_id=x.jr_id))
385 when jrn_def_type = 'ACH' then (select ad_value
386 from fiche_detail
387 where ad_id=32
388 and f_id=(select max(qp_supplier)
389 from quant_purchase
390 join jrnx using (j_id)
391 join jrn as e on (e.jr_grpt_id=j_grpt)
392 where e.jr_id=x.jr_id))
393 when jrn_def_type = 'FIN' then (select ad_value
394 from fiche_detail
395 where ad_id=32
396 and f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))
397 end as first_name,
398 case
399 when jrn_def_type='VEN' then
400 (select ad_value
401 from fiche_detail
402 where ad_id=23
403 and f_id=(select max(qs_client)
404 from quant_sold
405 join jrnx using (j_id)
406 join jrn as e on (e.jr_grpt_id=j_grpt)
407 where e.jr_id=x.jr_id))
408 when jrn_def_type = 'ACH' then (select ad_value
409 from fiche_detail
410 where ad_id=23
411 and f_id=(select max(qp_supplier)
412 from quant_purchase
413 join jrnx using (j_id)
414 join jrn as e on (e.jr_grpt_id=j_grpt)
415 where e.jr_id=x.jr_id))
416 when jrn_def_type = 'FIN' then (select ad_value
417 from fiche_detail
418 where ad_id=23
419 and f_id=(select qf_other from quant_fin where quant_fin.jr_id=x.jr_id))
420 end as quick_code,
421 ( case
422 when jrn_def_type='VEN' then
423 (select sum(qs_price)+sum(vat) from
424 (select qs_internal,qs_price,case when qs_vat_sided<>0 then 0
425 else qs_vat end as vat
426 from quant_sold
427 where qs_internal=X.jr_internal) as ven_invoice
428 )
429 when jrn_def_type = 'ACH' then
430 (select sum(qp_price)+sum(vat)+sum(qp_nd_tva)+sum(qp_nd_tva_recup)
431 from
432 (select qp_internal,qp_price,qp_nd_tva,qp_nd_tva_recup,qp_vat-qp_vat_sided as vat
433 from quant_purchase
434 where qp_internal=X.jr_internal) as invoice_purchase
435 )
436 else jr_montant
437 end +
438 coalesce( case when jrn_def_type='VEN' then
439 (select sum(case when j102.j_debit is true then 0-j102.J_montant else j102.j_montant end)
440 from jrnx j102 join jrn_tax using(j_id) where j102.j_grpt =X.jr_grpt_id)
441 when jrn_def_type='ACH' then
442 (select sum(case when j103.j_debit is false then 0-j103.J_montant else j103.j_montant end)
443 from jrnx j103 join jrn_tax using(j_id) where j103.j_grpt =X.jr_grpt_id)
444 else
445 0 end ,0) ) as total_invoice,
446 jr_date_paid,
447 to_char(jr_date_paid,'DD.MM.YY') as str_jr_date_paid,
448 cas.jr_id as analytic_op,
449 x.currency_id,
450 (select cr_code_iso from currency c where c.id=x.currency_id) cr_code_iso,
451 x.currency_rate
452 from
453 jrn as X
454 left join jrn_note using(jr_id)
455 left join cas using( jr_id)
456 join jrn_def on jrn_def_id=jr_def_id
457 join parm_periode on p_id=jr_tech_per
458 ";
459
460 if (!empty($p_array))
461 extract($p_array, EXTR_SKIP);
462
464 if (isset($p_array[$op."r_jrn"]))
465 {
466 $r_jrn=$p_array[$op."r_jrn"];
467 }
468 else
469 {
470 $r_jrn=(isset($r_jrn))?$r_jrn:-1;
471 }
472
473 /* if no variable are set then give them a default
474 * value */
475 if ($p_array==null||empty($p_array)||!isset($amount_min))
476 {
477 $amount_min=0;
478 $amount_max=0;
479
480 $desc='';
481 $qcode=(isset($p_array[$this->div."qcode"]))?$p_array[$this->div."qcode"]:"";
483 $periode=new Periode($this->cn);
484 $g_user=new Noalyss_user($this->cn);
485 $p_id=$g_user->get_periode();
486 if ($p_id!=null)
487 {
488 list($date_start, $date_end)=$periode->get_date_limit($p_id);
489 }
490 }
491
492 /* if p_jrn : 0 if means all ledgers, if -1 means all ledger of this
493 * type otherwise only one ledger */
494 $fil_ledger='';
495 $fil_amount='';
496 $fil_date='';
497 $fil_desc='';
498 $fil_sec='';
499 $fil_qcode='';
500 $fil_account='';
501 $fil_paid='';
502 $fil_date_paid='';
503 $fil_hide_operation='';
504 $fil_tag='';
505 $fil_currency="";
506 $fil_vat="";
507
508 $and='';
509 $g_user=new Noalyss_user($this->cn);
510 $p_action=(isset ($ledger_type)) ? $ledger_type:$this->type;
511 if ($p_action=='')
512 $p_action='ALL';
513 if ($r_jrn==-1)
514 {
515
516 /* from compta.php the p_action is quick_writing instead of ODS */
517 if ($p_action=='quick_writing')
518 $p_action='ODS';
519
520
521 $fil_ledger=$g_user->get_ledger_sql($p_action, 3);
522 $and=' and ';
523 }
524 else
525 {
526
527 if ($p_action=='quick_writing')
528 $p_action='ODS';
529
530 $aLedger=$g_user->get_ledger($p_action, 3);
531 $fil_ledger='';
532 $sp='';
533 for ($i=0; $i<count($r_jrn); $i++)
534 {
535 if (isset($r_jrn[$i]))
536 {
537 $a=$r_jrn[$i];
538 $fil_ledger.=$sp.$a;
539 $sp=',';
540 }
541 }
542 $fil_ledger=' jrn_def_id in ('.$fil_ledger.')';
543 $and=' and ';
544
545 /* no ledger selected */
546 if ($sp=='')
547 {
548 $fil_ledger='';
549 $and='';
550 }
551 }
552 //----
553 // Search tags
554 if ( isset($p_array[$op."tag"] ))
555 {
556 $strTag=join(",", $p_array[$op."tag"]);
557 if ($p_array[$op."tag_option"] == 1){
558 // any tag
559 $fil_tag=$and.' jr_id in (select jrn_id from operation_tag where tag_id in ('.sql_string($strTag).')) ';
560 } else {
561 // all tags
562 $aTag=$p_array[$op."tag"];
563 $sub_tag=""; $nb_tag=count($aTag);
564 $and2='';
565 for ($x=0;$x < $nb_tag;$x++) {
566 $sub_tag = " tag_id = ".sql_string($aTag[$x]);
567 $fil_tag=$and.' jr_id in (select jrn_id from operation_tag where '.$sub_tag.')' ;
568 $and=" and ";
569 }
570 }
571 $and=" and ";
572 }
573 /* format the number */
574 $amount_min=abs(toNumber($amount_min));
575 $amount_max=abs(toNumber($amount_max));
576 if ($amount_min>0&&isNumber($amount_min))
577 {
578 $fil_amount=$and.' jr_montant >='.$amount_min;
579 $and=' and ';
580 }
581 if ($amount_max>0&&isNumber($amount_max))
582 {
583 $fil_amount.=$and.' jr_montant <='.$amount_max;
584 $and=' and ';
585 }
586 /* -------------------------------------------------------------------------- *
587 * if both amount are the same then we need to search into the detail
588 * and we reset the fil_amount
589 * -------------------------------------------------------------------------- */
590 if (isNumber($amount_min)&&
591 isNumber($amount_max)&&
592 $amount_min>0&&
593 bccomp($amount_min, $amount_max, 2)==0)
594 {
595 $fil_amount=$and.' ( ';
596
597 // Look in detail
598 $fil_amount.='jr_grpt_id in ( select distinct j_grpt from jrnx where j_montant = '.$amount_min.') ';
599
600 //and the total operation
601 $fil_amount.=' or ';
602 $fil_amount.=' jr_montant = '.$amount_min;
603
604 $fil_amount.=')';
605 $and=" and ";
606 }
607 // date
608 if (isset($date_start)&&isDate($date_start)!=null)
609 {
610 $fil_date=$and." jr_date >= to_date('".$date_start."','DD.MM.YYYY')";
611 $and=" and ";
612 }
613 if (isset($date_end)&&isDate($date_end)!=null)
614 {
615 $fil_date.=$and." jr_date <= to_date('".$date_end."','DD.MM.YYYY')";
616 $and=" and ";
617 }
618 // date paiement
619 if (isset($date_paid_start)&&isDate($date_paid_start)!=null)
620 {
621 $fil_date_paid=$and." jr_date_paid >= to_date('".$date_paid_start."','DD.MM.YYYY')";
622 $and=" and ";
623 }
624 if (isset($date_paid_end)&&isDate($date_paid_end)!=null)
625 {
626 $fil_date_paid.=$and." jr_date_paid <= to_date('".$date_paid_end."','DD.MM.YYYY')";
627 $and=" and ";
628 }
629 // comment
630 if (isset($desc)&&$desc!=null)
631 {
633 $fil_desc=$and." ( upper(jr_comment) like upper('%".$desc."%') or upper(jr_pj_number) like upper('%".$desc."%') ".
634 " or upper(jr_internal) like upper('%".$desc."%')
635 or jr_grpt_id in (select j_grpt from jrnx where j_text ilike '%".$desc."%')
636 or jr_id in (select jr_id from jrn_info where ji_value is not null and ji_value ilike '%$desc%')
637 or jr_id in (select jr_id from jrn_note where upper(n_text) ilike '%$desc%' )
638 )";
639 $and=" and ";
640 }
641 // Poste
642 if (isset($accounting)&&$accounting!=null)
643 {
644 $fil_account=$and." jr_grpt_id in (select j_grpt
645 from jrnx where j_poste::text like '".sql_string($accounting)."%' ) ";
646 $and=" and ";
647 }
648 // Quick Code
649 $qcode=(isset($p_array[$this->div."qcode"]))?$p_array[$this->div."qcode"]:"";
650 if ($qcode!="")
651 {
652 $fil_qcode=$and." jr_grpt_id in ( select j_grpt from
653 jrnx where trim(j_qcode) = upper(trim('".sql_string($qcode)."')))";
654 $and=" and ";
655 }
656
657 // Only the unpaid, paid or all
658 if ( isset($operation_filter)) {
659 switch ($operation_filter) {
660 case "unpaid":
661 $fil_paid=$and."(jr_rapt is null or jr_rapt = '') and jr_valid = true ";
662 $and=" and ";
663 break;
664 case "all":
665 $fil_paid="";
666 break;
667 case "paid":
668 $fil_paid=$and."(coalesce(jr_rapt,'') != '' or jr_rapt = 'paid') and jr_valid = true ";
669 $and=" and ";
670 break;
671 default:
672 throw new Exception(_("ALS01 Etat inconnu"),10);
673
674 }
675 }
676 // Operations which must not be seen in the result
677 if ( isset ($hide_operation) && trim($hide_operation) !="")
678 {
679 $fil_hide_operation=$and.sprintf( ' jr_id not in (%s)',sql_string($hide_operation));
680 $and=" and ";
681 }
682 global $g_user;
683 if ($g_user->admin==0&&$g_user->is_local_admin()==0 && $g_user->get_status_security_ledger()==1 )
684 {
685
686 $fil_sec=$and." jr_def_id in ( select uj_jrn_id ".
687 " from user_sec_jrn where ".
688 " uj_login='".sql_string($_SESSION[SESSION_KEY.'g_user'])."'".
689 " and uj_priv in ('R','W'))";
690 $and=" and ";
691 }
692 if ( isset($p_currency_code) && $p_currency_code !=-1) {
693 $fil_currency=$and." x.currency_id = ".sql_string($p_currency_code);
694 $and=" and ";
695 }
696 // VAT Code
697 if ( isset($tva_id_search) && ! empty (trim($tva_id_search??"")))
698 {
699 $acc_tva=Acc_Tva::build($this->cn, $tva_id_search);
700 if ($acc_tva->tva_id != -1 )
701 {
702 $fil_vat = $and." jr_internal in
703 ( select distinct qp_internal
704 from quant_purchase
705 where qp_vat_code=".sql_string($acc_tva->tva_id ).
706 " union all
707 select distinct qs_internal
708 from quant_sold
709 where qs_vat_code=".sql_string($acc_tva->tva_id ).")";
710 }
711
712 }
713 $where=$fil_ledger.$fil_amount.$fil_date.$fil_desc.$fil_sec.
714 $fil_qcode.$fil_paid.$fil_account.$fil_date_paid.$fil_hide_operation.$fil_tag.$fil_currency.$fil_vat;
715
716 $sql.=" where ".$where;
717
718 // Q?? Why do we return where if it is included in SQL ?
719 return array($sql, $where);
720 }
isNumber($p_int)
isDate($p_date)
Verifie qu'une date est bien formaté en d.m.y et est valable.
sql_string($p_string)
Fix the problem with the quote char for the database.
global $g_user
if no group available , then stop
$op
if(!headers_sent())
– pour utiliser unoconv démarrer un server libreoffice commande libreoffice –headless –accept="socket...
$date_start
if(! isset($_GET['submit_query'])) $p_action
$div
prefix for id of DOM id
static build($db, $p_code)
retrieve TVA rate thanks the code that could be the tva_id or tva_code.
toNumber($p_num)
remove the useless space, change comma by period and try to return a number

References $a, $accounting, $date_end, $date_start, $desc, $div, $g_user, $i, $ledger_type, $op, $p_action, $p_array, $p_id, $p_order, $periode, $qcode, $r_jrn, $sp, $sql, $type, cn, and if.

◆ button_propose_filter()

Acc_Ledger_Search::button_propose_filter ( )

build an HTML string with a button to show the list of saved search

Returns
string HTML button
Exceptions
Exceptionif $_REQUEST['ac'] is not set

Definition at line 1398 of file acc_ledger_search.class.php.

1399 {
1400 $http=new HttpInput();
1401 $button=HtmlInput::button_action("Recherches sauvées",
1402 sprintf("display_list_filter('%s','%s','%s')"
1403 ,Dossier::id()
1404 , $http->request("ac")
1405 ,$this->type
1406 ),uniqid(),'smallbutton');
1407 return $button;
1408 }
static button_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
button Html with javascript

References $http.

◆ display_list_filter()

Acc_Ledger_Search::display_list_filter ( )

display a list of saved search

Definition at line 1413 of file acc_ledger_search.class.php.

1414 {
1415 require_once NOALYSS_TEMPLATE."/acc_ledger_search-display_list_filter.php";
1416
1417 }

◆ display_search_form()

Acc_Ledger_Search::display_search_form ( )

return a html string with the search_form

Returns
a HTML string with the FORM
See also
build_search_sql
search_form
list_operation

Definition at line 729 of file acc_ledger_search.class.php.

730 {
731 $http=new HttpInput();
732 $r='';
733 $r.='<div id="search_form" style="display:none">';
734 $r.=HtmlInput::title_box(_('Recherche'), "search_form", "hide", "", "n");
735 $r.='<FORM METHOD="GET" >';
736 $r.=$this->search_form();
737
738 $r.=HtmlInput::submit('search', _('Rechercher'));
739
740 $button_search=new IButton("{$this->div}button", _('Recherches sauvées'));
741 $button_search->javascript=$this->build_search_filter();
742 $r.=$button_search->input();
743
744
745
746 $r.=HtmlInput::hidden('ac', $http->request('ac'));
747
748
749 /* when called from commercial.php some hidden values are needed */
750 if (isset($_REQUEST['sa']))
751 $r.=HtmlInput::hidden("sa", $http->request('sa'));
752 if (isset($_REQUEST['sb']))
753 $r.=HtmlInput::hidden("sb", $http->request('sb'));
754 if (isset($_REQUEST['sc']))
755 $r.=HtmlInput::hidden("sc", $http->request('sc'));
756 if (isset($_REQUEST['f_id']))
757 $r.=HtmlInput::hidden("f_id", $http->request('f_id'));
758
759
760
761
762 $r.=HtmlInput::button_hide("search_form");
763 $r.='</FORM>';
764
765 $r.='</div>';
766 $button=new IButton('tfs');
767 $button->label=_("Chercher");
768 $button->javascript="toggleHideShow('search_form','tfs');";
769 $r.=$button->input();
770 return $r;
771 }
$_REQUEST['ac']
build_search_filter()
Build the button for managing the filter for search.
search_form()
return a HTML string with the form for the search
static button_hide($div_name, $class='smallbutton')
Hide the HTML popup.
static hidden($p_name, $p_value, $p_id="")
static title_box($p_name, $p_div, $p_mod="close", $p_js="", $p_draggable="n", $p_enlarge='n', $raw="", $refresh='')
Title for boxes, you can customize the symbol thanks symbol with the mode "custom".
static submit($p_name, $p_value, $p_javascript="", $p_class="smallbutton")
$button_search
Definition recherche.php:96

References $_REQUEST, $button_search, $http, $r, _, build_search_filter(), and search_form().

+ Here is the call graph for this function:

◆ get_all()

Acc_Ledger_Search::get_all ( )

Definition at line 77 of file acc_ledger_search.class.php.

78 {
79 return $this->all;
80 }
$all
Flag to indicate if all ledgers must be searched (1 for yes)

References $all.

◆ get_div()

Acc_Ledger_Search::get_div ( )

Definition at line 82 of file acc_ledger_search.class.php.

83 {
84 return $this->div;
85 }

References $div.

◆ get_type()

Acc_Ledger_Search::get_type ( )

Definition at line 72 of file acc_ledger_search.class.php.

73 {
74 return $this->type;
75 }
$type
type of ledger : FIN,ODS,VEN,ACH

References $type.

◆ list_operation()

Acc_Ledger_Search::list_operation ( $sql,
$offset,
$p_paid = 0 )

Show all the operation.

Parameters
$sqlis the sql stmt, normally created by build_search_sql
$offsetthe offset
$p_paidif we want to see info about payment
// Example
// Build the sql
list($sql,$where)=$Ledger->build_search_sql($_GET);
// Count nb of line
$max_line=$cn->count_sql($sql);
$step=$_SESSION[SESSION_KEY.'g_pagesize'];
$page=(isset($_GET['offset']))?$_GET['page']:1;
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
// create the nav. bar
// show a part
list($count,$html)= $Ledger->list_operation($sql,$offset,0);
echo $html;
// show nav bar
echo $bar;
if(headers_sent() &&DEBUGNOALYSS > 0) $html
foreach(array( 'l', 'gDossier') as $a) if(is_numeric($l)==false) $Ledger
$_GET['qcode']
$cn
Database Connection.
$count
catch(\Exception $e) $bar
navigation_bar($p_offset, $p_line, $p_size=0, $p_page=1, $p_javascript="")
Create a navigation_bar (pagesize)
See also
build_search_sql
display_search_form
search_form
Note
$this->inject_code (string) code into Acc_Ledger_Search\list_operation Example of using inject_col to inject a new column
<?php
function inject_col($param)
{
if (is_array($param))
{
return sprintf("<td> %s // %s</td>", $param['jr_id'], $param['jr_montant']);
} elseif ($param == 'header')
{
return '<th> Operation & montant</th>';
}
}
$acc_ledger_search = new Acc_Ledger_Search('VEN', 1, 1);
$acc_ledger_search->inject_col = "inject_col";
list($sql, $where) = $acc_ledger_search->build_search_sql($_GET);
list($nb_count, $html) = $acc_ledger_search->list_operation($sql . " and " . $where, 0);
printf("There are %s rows", $nb_count);
static echo_var($n_level, $msg, $print=true)
Display the value of a var if DEBUGNOALYSS is greater than $n_level, the debugging info has a certain...
Definition dbg.php:45
print
Type of printing.
if( $delta< 0) elseif( $delta==0)
Returns
array($count, $html_code);

Definition at line 830 of file acc_ledger_search.class.php.

831 {
832 global $g_parameter, $g_user;
833 bcscale(2);
834 $table=new Sort_Table();
835 $gDossier=dossier::id();
836 $amount_paid=0.0;
837 $amount_unpaid=0.0;
838 $limit=($_SESSION[SESSION_KEY.'g_pagesize']!=-1)?" LIMIT ".$_SESSION[SESSION_KEY.'g_pagesize']:"";
839 $offset=($_SESSION[SESSION_KEY.'g_pagesize']!=-1)?" OFFSET ".Database::escape_string($offset):"";
840 $order=" order by jr_date_order asc,jr_internal asc";
841 // Sort
842 $url="?".CleanUrl();
843 $str_dossier=dossier::get();
844 $table->add(_("Date"), $url,
845 'order by jr_date asc,substring(jr_pj_number,\'[0-9]+$\')::numeric asc',
846 'order by jr_date desc,substring(jr_pj_number,\'[0-9]+$\')::numeric desc',
847 "da", "dd");
848 $table->add(_('Echeance'), $url, " order by jr_ech asc",
849 " order by jr_ech desc", 'ea', 'ed');
850 $table->add(_('Paiement'), $url, " order by jr_date_paid asc",
851 " order by jr_date_paid desc", 'eap', 'edp');
852 $table->add(_('Pièce'), $url,
853 ' order by substring(jr_pj_number,\'[0-9]+$\')::numeric asc ',
854 ' order by substring(jr_pj_number,\'[0-9]+$\')::numeric desc ',
855 "pja", "pjd");
856 $table->add(_('Tiers'), $url, " order by name asc",
857 " order by name desc", 'na', 'nd');
858 $table->add(_('Montant'), $url, " order by jr_montant asc",
859 " order by jr_montant desc", "ma", "md");
860 $table->add(_("Description"), $url, "order by jr_comment asc",
861 "order by jr_comment desc", "ca", "cd");
862
863 $ord=(!isset($_GET['ord']))?'da':$_GET['ord'];
864 $order=$table->get_sql_order($ord);
865
866 // Count
867 $count=$this->cn->count_sql($sql);
868 // Add the limit
869 $sql.=$order.$limit.$offset;
870 // Execute SQL stmt
871 $Res=$this->cn->exec_sql($sql);
872
873 //starting from here we can refactor, so that instead of returning the generated HTML,
874 //this function returns a tree structure.
875
876 $r="";
877
878
880
881 if ($Max==0)
882 {
883 return array(0, _("Aucun enregistrement trouvé"));
884 }
885
886 $r.='<table class="result" id="history_operation_t">';
887
888
889 $r.="<tr >";
890 $r.='<th>'.$table->get_header(0).'</th>';
891 if ($p_paid!=0)
892 {
893 $r.='<th>'.$table->get_header(1).'</td>';
894 }
895 if ($p_paid!=0)
896 {
897 $r.='<th>'.$table->get_header(2).'</th>';
898 }
899 $r.='<th>'.$table->get_header(3).'</th>';
900 $r.=th('Journal');
901 if ( $this->type != "ODS")
902 {
903 $r.='<th>'.$table->get_header(4).'</th>';
904 }
905 $r.="<th>"._("n° interne")."</th>";
906 $r.='<th>'.$table->get_header(6).'</th>';
907 $r.=th('Notes', ' style="width:15%"');
908 $r.='<th>'.$table->get_header(5).'</th>';
909 // if $p_paid is not equal to 0 then we have a paid column
910 if ($p_paid!=0)
911 {
912 $r.="<th> "._('Payé')."</th>";
913 }
914 $r.="<th>"._('Concerne')."</th>";
915 $r.="<th>"._('Document')."</th>";
916 if ( $this->inject_col != null)
917 {
918 $r.=call_user_func($this->inject_col,"header");
919 }
920 $r.="</tr>";
921 // Total Amount
922 $tot=0.0;
923 $gDossier=dossier::id();
924 for ($i=0; $i<$Max; $i++)
925 {
926
927
929
930 if ($i%2==0)
931 {
932 $tr='<TR class="odd">';
933 }
934 else
935 {
936 $tr='<TR class="even">';
937 }
938 $r.=$tr;
939
940 // date
941 $r.="<TD>";
942 $r.=$row['str_jr_date'];
943 $r.="</TD>";
944 // echeance
945 if ($p_paid!=0)
946 {
947 $r.="<TD>";
948 $r.=$row['str_jr_ech'];
949 $r.="</TD>";
950 $r.="<TD>";
951 $r.=$row['str_jr_date_paid'];
952 $r.="</TD>";
953 }
954
955 // pj
956 $r.="<TD>";
957 $r.=$row['jr_pj_number'];
958 $r.="</TD>";
959
960 // Ledger
961 $r.=td($row['jrn_def_name']);
962
963
964 if ($this->type != 'ODS')
965 {
966 // Tiers
967 $other=($row['quick_code']!='')?HtmlInput::card_detail($row['quick_code'],h($row['name'].' '.$row['first_name'])):'';
968 $r.=td($other);
969 }
970
971 // Internal number
972 $r.="<TD>";
973 $r.=sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s </A>',
974 $row['jr_id'], $gDossier, $row['jr_internal']);
975 $r.="</TD>";
976
977 // comment
978 $r.="<TD>";
979 $tmp_jr_comment=h($row['jr_comment']).$row['tag_operation'];
980 $r.=$tmp_jr_comment;
981 if ( $row['analytic_op'] != "")
982 $r.=sprintf('<span style="float:right;background:black;color:white;">&ni;</span>');
983 $r.="</TD>";
984 // Note
985 $r.='<td>';
986 $r.='<span id="als_note'.$row['jr_id'].'" class="font-small">';
987 $r.= substr($row['n_text']??"",0,120);
988 $r.='<span>';
989 $r.='</span>';
990 $r.='</td>';
991
992 // Amount
993 // If the ledger is financial :
994 // the credit must be negative and written in red
995 $positive=0;
996
997 // Check ledger type :
998 if ($row['jrn_def_type']=='FIN')
999 {
1000 $positive=$this->cn->get_value("select qf_amount from quant_fin where jr_id=$1",
1001 array($row['jr_id']));
1002 if ($this->cn->count()!=0)
1003 {
1004 $positive=($positive<0)?1:0;
1005 }
1006 }
1007 $r.="<TD align=\"right\">";
1008 $t_amount=$row['jr_montant'];
1009 if ($row['total_invoice']!=null&&$row['total_invoice']!=$row['jr_montant'])
1010 $t_amount=$row['total_invoice'];
1011 $tot=($positive!=0)?bcsub($tot, $t_amount):bcadd($tot, $t_amount);
1012 //STAN $positive always == 0
1013 if ($row ['jrn_def_type']=='FIN')
1014 {
1015 $r.=( $positive!=0 )?"<font color=\"red\"> - ".nbm($t_amount)."</font>":nbm($t_amount);
1016 }
1017 else
1018 {
1019 $r.=( $t_amount<0 )?"<font color=\"red\"> ".nbm($t_amount)."</font>":nbm($t_amount);
1020 }
1021 $r.="</TD>";
1022
1023
1024 // Show the paid column if p_paid is not null
1025 if ($p_paid!=0)
1026 {
1027 $w=new ICheckBox();
1028 $w->set_range("paid_operation_ck");
1029 $w->name="rd_paid".$row['jr_id'];
1030 $w->selected=($row['jr_rapt']=='paid')?true:false;
1031 // if p_paid == 2 then readonly
1032 $w->readonly=( $p_paid==2)?true:false;
1033 $w->javascript='onclick="operation_payment.check_item(this)"';
1034 $h=new IHidden();
1035 $h->name="set_jr_id".$row['jr_id'];
1036 $r.='<TD>'.$w->input().$h->input().'</TD>';
1037 if ($row['jr_rapt']=='paid')
1038 {
1039 $amount_paid=bcadd($amount_paid, $t_amount);
1040 }
1041 else
1042 {
1043 $amount_unpaid=bcadd($amount_unpaid, $t_amount);
1044 }
1045 }
1046
1047 // Rapprochement
1048 $rec=new Acc_Reconciliation($this->cn);
1049 $rec->set_jr_id($row['jr_id']);
1050 $a=$rec->get();
1051 $r.="<TD>";
1052 if ($a!=null)
1053 {
1054
1055 foreach ($a as $key=> $element)
1056 {
1057 $operation=new Acc_Operation($this->cn);
1058 $operation->jr_id=$element;
1059 $l_amount=$this->cn->get_value("select jr_montant from jrn ".
1060 " where jr_id=$1", array($element));
1061 $r.="<A class=\"detail\" HREF=\"javascript:modifyOperation('".$element."',".$gDossier.")\" > ".$operation->get_internal()."[".nbm($l_amount)."]</A>";
1062 }//for
1063 }// if ( $a != null ) {
1064 $r.="</TD>";
1065
1066 if ($row['jr_valid']=='f')
1067 {
1068 $r.="<TD>"._("Opération annulée")."</TD>";
1069 }
1070 else
1071 {
1072
1073 } // else
1074 //document
1075 if ($row['jr_pj_name']!="")
1076 {
1077 $r.='<td>'.HtmlInput::show_receipt_document($row['jr_id']).'</td>';
1078 }
1079 else
1080 $r.="<TD></TD>";
1081 //< inject_code (string) code into list_operation
1082 // to add an extra column
1083 // (see Acc_Ledger_Search::list_operation).
1084 // All the HTML code must be in inject_code, including the TD tag
1085 if ( $this->inject_col != null)
1086 {
1087 $r.=call_user_func($this->inject_col,$row);
1088 }
1089 // end row
1090 $r.="</tr>";
1091 }
1092 $amount_paid=round($amount_paid, 4);
1093 $amount_unpaid=round($amount_unpaid, 4);
1094 $tot=round($tot, 4);
1095 $r.="<TR>";
1096 $r.='<TD COLSPAN="5">Total</TD>';
1097 $r.=td("").td("");
1098 $r.='<TD ALIGN="RIGHT">'.nbm($tot)."</TD>";
1099 $r.="</tr>";
1100 if ($p_paid!=0)
1101 {
1102 $r.="<TR>";
1103 $r.='<TD COLSPAN="5">'._("Payé").'</TD>';
1104 $r.=td("").td("").td("").td('');
1105 $r.='<TD ALIGN="RIGHT">'.nbm($amount_paid)."</TD>";
1106 $r.="</tr>";
1107
1108 $r.="<TR>";
1109 $r.='<TD COLSPAN="5">'._("Non payé").'</TD>';
1110 $r.=td("").td("").td("").td('');
1111 $r.='<TD ALIGN="RIGHT">'.nbm($amount_unpaid)."</TD>";
1112 $r.="</tr>";
1113 }
1114 $r.="</table>";
1115
1116 return array($count, $r);
1117 }
th($p_string, $p_extra='', $raw='')
Definition ac_common.php:58
td($p_string='', $p_extra='')
surround the string with td
Definition ac_common.php:83
nbm($p_number, $p_dec=2)
format the number with a sep.
global $g_parameter
h( $row[ 'oa_description'])
foreach($array as $idx=> $m) $w
$str_dossier
static escape_string($p_string)
wrapper for the function pg_escape_string
static fetch_array($ret, $p_indice=0, $p_mode=PGSQL_ASSOC)
wrapper for the function pg_fetch_array
static num_row($ret)
wrapper for the function pg_num_rows
$ord
Definition menu.inc.php:116
$table
Definition menu.inc.php:104

References $_GET, $a, $count, $g_parameter, $g_user, $gDossier, $i, $limit, $Max, $offset, $operation, $ord, $order, $other, $r, $Res, $row, $sql, $str_dossier, $table, $tot, $url, $w, _, cn, DatabaseCore\escape_string(), DatabaseCore\fetch_array(), h, nbm(), DatabaseCore\num_row(), td(), th(), and type.

+ Here is the call graph for this function:

◆ list_operation_to_reconcile()

Acc_Ledger_Search::list_operation_to_reconcile ( $sql,
$p_target )

Show all the operation.

Parameters
$sqlis the sql stmt, normally created by build_search_sql
$offsetthe offset
$p_paidif we want to see info about payment
// Example
// Build the sql
list($sql,$where)=$Ledger->build_search_sql($_GET);
// Count nb of line
$max_line=$this->cn->count_sql($sql);
$step=$_SESSION[SESSION_KEY.'g_pagesize'];
$page=(isset($_GET['offset']))?$_GET['page']:1;
$offset=(isset($_GET['offset']))?$_GET['offset']:0;
// create the nav. bar
// show a part
list($count,$html)= $Ledger->list_operation($sql,$offset,0);
echo $html;
// show nav bar
echo $bar;
See also
build_search_sql
display_search_form
search_form
Returns
HTML string

Definition at line 1149 of file acc_ledger_search.class.php.

1150 {
1151 global $g_parameter, $g_user;
1152 $gDossier=dossier::id();
1153 $limit=" LIMIT ".MAX_RECONCILE;
1154 // Sort
1155 // Count
1156 $count=$this->cn->count_sql($sql);
1157 // Add the limit
1158 $sql.=" order by jr_date asc ".$limit;
1159
1160 // Execute SQL stmt
1161 $Res=$this->cn->exec_sql($sql);
1162
1163 //starting from here we can refactor, so that instead of returning the generated HTML,
1164 //this function returns a tree structure.
1165
1166 $r="";
1167
1168
1170
1171 if ($Max==0)
1172 return array(0, _("Aucun enregistrement trouvé"));
1173 $r.=HtmlInput::hidden("target", $p_target);
1174 $r.='<table class="result">';
1175
1176
1177 $r.="<tr >";
1178 $r.="<th>"._("Selection")."</th>";
1179 $r.="<th>"._("Internal")."</th>";
1180
1181 if ($this->type=='ALL')
1182 {
1183 $r.=th(_('Journal'));
1184 }
1185
1186 $r.='<th>'._("Date").'</th>';
1187 $r.='<th>'._("Pièce").'</td>';
1188 $r.=th(_('tiers'));
1189 $r.='<th>'._("Description").'</th>';
1190 $r.=th(_('Notes'), ' ');
1191 $r.='<th>'._("Montant").'</th>';
1192 $r.="<th>"._('Concerne')."</th>";
1193 $r.="</tr>";
1194 // Total Amount
1195 $tot=0.0;
1196 $gDossier=dossier::id();
1198 for ($i=0; $i<$Max; $i++)
1199 {
1200
1201
1203
1204 if ($i%2==0)
1205 $tr='<TR class="odd">';
1206 else
1207 $tr='<TR class="even">';
1208 $r.=$tr;
1209 // Radiobox
1210 //
1211
1212 $r.='<td><INPUT TYPE="CHECKBOX" name="jr_concerned'.$row['jr_id'].'" ID="jr_concerned'.$row['jr_id'].'" value="'.$row['quick_code'].'"> </td>';
1213 //internal code
1214 // button modify
1215 $r.="<TD>";
1216 // If url contains
1217 //
1218
1219 $href=basename($_SERVER['PHP_SELF']);
1220
1221
1222 $r.=sprintf('<A class="detail" style="text-decoration:underline" HREF="javascript:modifyOperation(\'%s\',\'%s\')" >%s </A>',
1223 $row['jr_id'], $gDossier, $row['jr_internal']);
1224 $r.="</TD>";
1225 if ($this->type=='ALL')
1226 $r.=td($row['jrn_def_name']);
1227 // date
1228 $r.="<TD>";
1229 $r.=$row['str_jr_date'];
1230 $r.="</TD>";
1231
1232 // pj
1233 $r.="<TD>";
1234 $r.=$row['jr_pj_number'];
1235 $r.="</TD>";
1236
1237 // Tiers
1238 $other=($row['quick_code']!='')?'['.$row['quick_code'].'] '.$row['name'].' '.$row['first_name']:'';
1239 $r.=td($other);
1240 // comment
1241 $r.="<TD>";
1242 $tmp_jr_comment=h($row['jr_comment']).$row['tag_operation'];
1243 $r.=$tmp_jr_comment;
1244 $r.="</TD>";
1245 $r.=td(h($row['n_text']), ' style="font-size:0.87em"');
1246 // Amount
1247 // If the ledger is financial :
1248 // the credit must be negative and written in red
1249 $positive=0;
1250
1251 // Check ledger type :
1252 if ($row['jrn_def_type']=='FIN')
1253 {
1254 $positive=$this->cn->get_value("select qf_amount from quant_fin where jr_id=$1",
1255 array($row['jr_id']));
1256 if ($this->cn->count()!=0)
1257 $positive=($positive<0)?1:0;
1258 }
1259 $r.="<TD align=\"right\">";
1260
1261 $r.=( $positive!=0 )?"<font color=\"red\"> - ".nbm($row['total_invoice'])."</font>":nbm($row['total_invoice']);
1262 $r.="</TD>";
1263
1264
1265
1266 // Rapprochement
1267 $rec=new Acc_Reconciliation($this->cn);
1268 $rec->set_jr_id($row['jr_id']);
1269 $a=$rec->get();
1270 $r.="<TD>";
1271 if ($a!=null)
1272 {
1273
1274 foreach ($a as $key=> $element)
1275 {
1276 $operation=new Acc_Operation($this->cn);
1277 $operation->jr_id=$element;
1278 $l_amount=$this->cn->get_value("select jr_montant from jrn ".
1279 " where jr_id=$1", array($element));
1280 $r.="<A class=\"detail\" HREF=\"javascript:modifyOperation('".$element."',".$gDossier.")\" > ".$operation->get_internal()."[".nbm($l_amount)."]</A>";
1281 }//for
1282 }// if ( $a != null ) {
1283 $r.="</TD>";
1284
1285 if ($row['jr_valid']=='f')
1286 {
1287 $r.="<TD>"._("Opération annulée")."</TD>";
1288 }
1289 // end row
1290 $r.="</tr>";
1291 }
1292 $r.='</table>';
1293 return array($count, $r);
1294 }
$href
Definition adm.inc.php:31
static id()
return the 'gDossier' value after a check

References $a, $count, $g_parameter, $g_user, $gDossier, $href, $i, $limit, $Max, $operation, $other, $r, $Res, $row, $sql, $str_dossier, $tot, _, cn, DatabaseCore\fetch_array(), h, nbm(), DatabaseCore\num_row(), td(), th(), and type.

+ Here is the call graph for this function:

◆ search_form()

Acc_Ledger_Search::search_form ( )

return a HTML string with the form for the search

Returns
a HTML String without the tag FORM or DIV
See also
build_search_sql
display_search_form
list_operation

Definition at line 114 of file acc_ledger_search.class.php.

115 {
116 global $g_user,$g_parameter;
117 $g_parameter=new Noalyss_Parameter_Folder($this->cn);
118 $http=new HttpInput();
119 $r="";
120 $bledger_param=json_encode(array(
121 'dossier'=>Dossier::id(),
122 'type'=>$this->type,
123 'all_type'=>$this->all,
124 'div'=>$this->div
125 ));
126
127 $bledger_param=noalyss_str_replace('"', "'", $bledger_param);
128 $bledger=new ISmallButton('l');
129 $bledger->label=_("choix des journaux");
130 $bledger->javascript=" show_ledger_choice($bledger_param)";
131 $f_ledger=$bledger->input();
132 $hid_jrn="";
133 if (isset($_REQUEST[$this->div.'nb_jrn']))
134 {
135 for ($i=0; $i<$_REQUEST[$this->div.'nb_jrn']; $i++)
136 {
137 if (isset($_REQUEST[$this->div."r_jrn"][$i]))
138 $hid_jrn.=HtmlInput::hidden($this->div.'r_jrn['.$i.']',
139 $_REQUEST[$this->div."r_jrn"][$i]);
140 }
141 $hid_jrn.=HtmlInput::hidden($this->div.'nb_jrn',
142 $_REQUEST[$this->div.'nb_jrn']);
143 } else
144 {
145 $hid_jrn=HtmlInput::hidden($this->div.'nb_jrn', 0);
146 }
147 /* Compute default date for exercice */
148 $period=$g_user->get_periode();
149 $per=new Periode($this->cn, $period);
150 $exercice=$per->get_exercice();
151 list($per_start, $per_end)=$per->get_limit($exercice);
152 $date_end=$per_end->last_day();
153 $date_start=$per_start->first_day();
154
155 $date_start_hidden=HtmlInput::hidden("{$this->div}date_start_hidden", $date_start);
156 $date_end_hidden=HtmlInput::hidden("{$this->div}date_end_hidden", $date_end);
157 /* widget for date_start */
158 $f_date_start=new IDate('date_start', '', $this->div."date_start");
159
160 /* all periode or only the selected one */
161 $f_date_start->value=$http->request("date_start","string",$date_start);
162
163 /* widget for date_end */
164 $f_date_end=new IDate('date_end', '', $this->div."date_end");
165
166 /* all date or only the selected one */
167 $f_date_end->value=$http->request("date_end","string",$date_end);
168
169 /* widget for date term */
170 $f_date_paid_start=new IDate('date_paid_start', '',
171 $this->div."date_paid_start");
172 $f_date_paid_end=new IDate('date_paid_end', '',
173 $this->div."date_paid_end");
174
175 $f_date_paid_start->value=$http->request("date_paid_start","string","");
176 $f_date_paid_end->value=$http->request("date_paid_end","string","");
177
178 /* widget for desc */
179 $f_descript=new IText('desc', "", $this->div."desc");
180 $f_descript->size=40;
181 $f_descript->value=$http->request('desc',"string","");
182
183 /* widget for amount */
184 $f_amount_min=new INum('amount_min', '0', $this->div."amount_min");
185 $f_amount_min->value=$http->request("amount_min","string",0);
186 $f_amount_max=new INum('amount_max', '0', $this->div."amount_max");
187 $f_amount_max->value=$http->request("amount_max","string",0);
188
189
190 /* input quick code */
191 $f_qcode=new ICard($this->div.'qcode');
192
193 $f_qcode->set_attribute('typecard', 'all');
194 /* $f_qcode->set_attribute('p_jrn','0');
195
196 $f_qcode->set_callback('filter_card');
197 */
198 $f_qcode->set_dblclick("fill_ipopcard(this);");
199 // Add the callback function to filter the card on the jrn
200 //$f_qcode->set_callback('filter_card');
201 $f_qcode->set_function('fill_data');
202 $f_qcode->javascript=sprintf(' onchange="fill_data_onchange(%s);" ',
203 $f_qcode->name);
204 $f_qcode->value=$http->request($this->div.'qcode',"string","");
205 $f_qcode->setAfter_clean("");
206 /* $f_txt_qcode=new IText('qcode');
207 $f_txt_qcode->value=(isset($_REQUEST['qcode']))?$_REQUEST['qcode']:'';
208 */
209
210 /* input poste comptable */
211 $f_accounting=new IPoste('accounting', "", $this->div."accounting");
212 $f_accounting->value=$http->request('accounting',"string","");
213 /*
214 * utile ??? Filtre les postes comptables en fonction du journal
215 * if ($this->id==-1)
216 $jrn=0;
217 else
218 $jrn=$this->id; */
219 $f_accounting->set_attribute('jrn', 0);
220 $f_accounting->set_attribute('ipopup', 'ipop_account');
221 $f_accounting->set_attribute('label', 'ld');
222 $f_accounting->set_attribute('account', $this->div.'accounting');
223 $info=Icon_Action::infobulle(13);
224
225 // Status of the operation : paid, unpaid or all
226 $f_paid=new ISelect('operation_filter', null, $this->div.'operation_filter');
227 $f_paid->value=array(["value"=>'all',"label"=>_("Toutes")],
228 ["value"=>'unpaid',"label"=>_("Non payées")],
229 ["value"=>'paid',"label"=>_("Payées")]
230 );
231 $f_paid->selected=$http->request("operation_filter","string","all");
232
233 $r.=dossier::hidden();
234 $r.=HtmlInput::hidden('ledger_type', $this->type,
235 $this->div."ledger_type");
236 $r.=HtmlInput::hidden('ac', $http->request('ac'));
237
238 // to avoid to find a given operation
239 if (isset($_REQUEST['hide_operation']))
240 $r.=HtmlInput::hidden("hide_operation", $http->request('hide_operation'));
241
242 if (isset($_REQUEST['single_operation']))
243 $r.=HtmlInput::hidden("single_operation", $http->request('single_operation'));
244
245 //------
246 // Devise
247 ///-------
248 $currency_id=$http->request("p_currency_code","string",-1);
249 $acc_currency=new Acc_Currency($this->cn);
250
251 $sCurrency=$acc_currency->select_currency();
252 $sCurrency->id=$this->div."p_currency_code";
253 $sCurrency->value[]=array("label"=>_("Toutes"),"value"=>-1);
254 $sCurrency->selected=$currency_id;
255 $tva_id_search=new ITva_Popup("tva_id_search",
256 $http->request("tva_id_search","string",null),
257 $this->div."tva_id_search");
258 ob_start();
259 $search_filter=$this->build_search_filter();
260 require_once NOALYSS_TEMPLATE.'/ledger_search.php';
261 $r.=ob_get_contents();
262 ob_end_clean();
263 return $r;
264 }
catch(Exception $e) $exercice
static infobulle($p_comment)
Display a info in a bubble, text is in message_javascript.
$date_end_hidden

References $_REQUEST, $g_parameter, $g_user, $http, $r, _, cn, noalyss_str_replace(), and type.

Referenced by display_search_form().

+ Here is the call graph for this function:

◆ select_ledger()

Acc_Ledger_Search::select_ledger ( $p_selected,
$p_div )

return the html code to create an hidden div and a button to show this DIV.

This contains all the available ledgers for the user in READ or RW

Parameters
$p_selectedis an array of checkbox
$p_divdiv suffix for the list of ledgers, base for building the DOMID of elements from the DIV
Note
the choosen ledger are stored in the array r_jrn (_GET)

Definition at line 1303 of file acc_ledger_search.class.php.

1304 {
1305 global $g_user;
1306 $r = '';
1307 /* security : filter ledger on user */
1308 $p_array = $g_user->get_ledger($this->type, 3,false);
1309 ob_start();
1310
1311
1312 /* create a hidden div for the ledger */
1313 echo '<div id="div_jrn'.$p_div.'" >';
1314 echo HtmlInput::title_box(_("Journaux"), $p_div."jrn_search");
1315 echo '<div style="padding:5px">';
1316 echo '<form method="GET" id="'.$p_div.'search_frm" onsubmit="return hide_ledger_choice(\''.$p_div.'search_frm\')">';
1317 $nb_array=(empty($p_array))?0:count($p_array);
1318 echo HtmlInput::hidden('nb_jrn', $nb_array);
1319 echo _('Filtre ').HtmlInput::filter_table($p_div.'tb_jrn', '0,1,2', 2);
1320 echo HtmlInput::anchor_action(_('Inverser sel'),' toggle_checkbox(\''."{$p_div}search_frm".'\')','sel_'.$p_div,"nav");
1321 echo "-";
1322 echo HtmlInput::anchor_action(_('Effacer sel'),' unselect_checkbox(\''."{$p_div}search_frm".'\')','unsel_'.$p_div,"nav");
1323 echo "-";
1324 echo HtmlInput::anchor_action(_('Financier'),' select_checkbox_attribute(\''."{$p_div}search_frm".'\',\'ledger_type\',\'FIN\') ','selfin_'.$p_div,"nav");
1325 echo "-";
1326 echo HtmlInput::anchor_action(_('Vente'),' select_checkbox_attribute(\''."{$p_div}search_frm".'\',\'ledger_type\',\'VEN\') ','selfven_'.$p_div,"nav");
1327 echo "-";
1328 echo HtmlInput::anchor_action(_('Achat'),' select_checkbox_attribute(\''."{$p_div}search_frm".'\',\'ledger_type\',\'ACH\') ','selfach_'.$p_div,"nav");
1329 echo "-";
1330 echo HtmlInput::anchor_action(_('Op.Diverses'),' select_checkbox_attribute(\''."{$p_div}search_frm".'\',\'ledger_type\',\'ODS\') ','selfods_'.$p_div,"nav");
1331 echo '<table class="result" id="'.$p_div.'tb_jrn">';
1332 echo '<tr>';
1333 echo th(_('Nom'));
1334 echo th(_('Description'));
1335 echo th(_('Type'));
1336 echo '</tr>';
1337 echo '<tr>';
1338 echo '<td>';
1339
1340 echo '</td>';
1341 echo '</tr>';
1342 for ($e=0;$e<$nb_array;$e++)
1343 {
1344 $row=$p_array[$e];
1345
1346 $r=new ICheckBox($p_div.'r_jrn'.$e,$row['jrn_def_id']);
1347 $r->set_attribute("ledger_type", $row['jrn_def_type']);
1348 $idx=$row['jrn_def_id'];
1349 if ( $p_selected != null && in_array($row['jrn_def_id'],$p_selected))
1350 {
1351 $r->selected=true;
1352 }
1353 $class=($e%2==0)?' class="even" ':' class="odd" ';
1354 echo '<tr '.$class.'>';
1355 echo '<td style="white-space: nowrap">'.$r->input().$row['jrn_def_name']."(".$row['jrn_def_code'].")".'</td>';
1356 echo '<td >'.$row['jrn_def_description'].'</td>';
1357 echo '<td >'.$row['jrn_def_type'].'</td>';
1358 echo '</tr>';
1359
1360 }
1361 echo '</table>';
1362 echo HtmlInput::hidden('div',$p_div);
1363 echo HtmlInput::submit('save',_('Valider'));
1364 echo HtmlInput::button_close($p_div."jrn_search");
1365 echo '</form>';
1366 echo '</div>';
1367 echo '</div>';
1368
1369 $ret=ob_get_contents();
1370 ob_end_clean();
1371 return $ret;
1372 }
$class
Display the Plugin and for each profile were it is installed or not.
static button_close($div_name, $class='smallbutton')
close button for the HTML popup
static anchor_action($action, $javascript, $id=NULL, $p_class="button", $p_symbole="")
Anchor Html with javascript.

References $class, $e, $g_user, $idx, $nb_array, $p_array, $r, $ret, $row, _, th(), and type.

+ Here is the call graph for this function:

◆ set_all()

Acc_Ledger_Search::set_all ( $all)

Definition at line 96 of file acc_ledger_search.class.php.

97 {
98 $this->all=$all;
99 }

References $all.

◆ set_div()

Acc_Ledger_Search::set_div ( $div)

Definition at line 101 of file acc_ledger_search.class.php.

102 {
103 $this->div=$div;
104 }

References $div.

◆ set_type()

Acc_Ledger_Search::set_type ( $type)

Definition at line 87 of file acc_ledger_search.class.php.

88 {
89 if (! in_array($type, ["ALL","VEN","ACH","ODS","FIN"]))
90 {
91 throw new Exception ("ALS02 : type invalide $type",EXC_PARAM_VALUE);
92 }
93 $this->type=$type;
94 }
const EXC_PARAM_VALUE
Definition constant.php:355

References $type, EXC_PARAM_VALUE, and type.

Referenced by __construct().

Field Documentation

◆ $all

Acc_Ledger_Search::$all
private

Flag to indicate if all ledgers must be searched (1 for yes)

Definition at line 38 of file acc_ledger_search.class.php.

Referenced by get_all(), and set_all().

◆ $cn

Acc_Ledger_Search::$cn
protected

Database Connection.

Definition at line 36 of file acc_ledger_search.class.php.

◆ $div

Acc_Ledger_Search::$div
private

prefix for id of DOM id

Definition at line 39 of file acc_ledger_search.class.php.

Referenced by get_div(), and set_div().

◆ $id

Acc_Ledger_Search::$id

id of the ledger

Definition at line 40 of file acc_ledger_search.class.php.

◆ $inject_col

Acc_Ledger_Search::$inject_col

inject_code (callback function ) into list_operation

Definition at line 41 of file acc_ledger_search.class.php.

◆ $type

Acc_Ledger_Search::$type
private

type of ledger : FIN,ODS,VEN,ACH

Definition at line 37 of file acc_ledger_search.class.php.

Referenced by get_type(), and set_type().


The documentation for this class was generated from the following file: