noalyss Version-9
NOALYSS : serveur de comptabilité et ERP (2002)
Loading...
Searching...
No Matches
payment_method_mtable.class.php
Go to the documentation of this file.
1<?php
2
3/*
4 * This file is part of NOALYSS.
5 *
6 * PhpCompta is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * PhpCompta is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with PhpCompta; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20// Copyright (2018) Author Dany De Bontridder <dany@alchimerys.be>
21
22/**
23 * @file
24 * @brief Manage the Payment method
25 * @see Payment_Method_SQL
26 * @see ajax_payment_method.php
27 */
28require_once NOALYSS_INCLUDE."/database/jrn_def_sql.class.php";
29/**
30 * @class Payment_Method_MTable
31 * @brief Manage the Payment method
32 * @see Payment_Method_SQL
33 * @see ajax_payment_method.php
34 */
36{
37
38 function __construct(\Data_SQL $p_table)
39 {
40 parent::__construct($p_table);
41
42 // Column header
43 $this->set_col_label("mp_lib", _("Libellé"));
44 $this->set_col_label("mp_jrn_def_id", _("Enregistrement dans"));
45 $this->set_col_label("mp_fd_id", _("Type de fiche"));
46 $this->set_col_label("mp_qcode", _("Fiche"));
47 $this->set_col_label("jrn_def_id", _("Utilisation dans"));
48 // Hide id
49 $this->set_property_visible("mp_id", FALSE);
50 $this->icon_mod="right";
51
52 // Set value for col
53 $this->set_col_type("mp_qcode","custom");
54 $this->set_col_type("mp_jrn_def_id", "select",
55 $p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type in ('FIN','ODS') and jrn_enable=1 order by 2",1));
56 $this->set_col_type("mp_fd_id", "select",
57 $p_table->cn->make_array("select fd_id,fd_label from fiche_def order by 2",1));
58 $this->set_col_type("jrn_def_id", "select",
59 $p_table->cn->make_array("select jrn_def_id,jrn_def_name from jrn_def where jrn_def_type in ('ACH','VEN') and jrn_enable=1 order by 2",1));
60 $this->set_col_tips("mp_fd_id", 71);
61 $this->set_col_tips("mp_qcode", 72);
62 $this->set_order(["mp_lib","jrn_def_id","mp_jrn_def_id","mp_fd_id","mp_qcode"]);
63
64 }
65
66 function check()
67 {
68 $table=$this->get_table();
69 $cn=$table->cn;
70 $has_error=0;
71
72 if ( trim($table->mp_lib) == "") {
73 $this->set_error("mp_lib", _("Un libellé est obligatoire"));
74 $has_error++;
75 }
76 $count_ledger_target=0;
77 if ( trim($table->mp_jrn_def_id) !="") {
78 $count_ledger_target=$cn->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$table->mp_jrn_def_id]);
79
80 }
81 if ($count_ledger_target == 0 ) {
82 $this->set_error("mp_jrn_def_id", _("Choisissez un journal"));
83 $has_error++;
84 }
85
86 $count_ledger_used=0;
87 if ( trim($table->jrn_def_id) != "") {
88 $count_ledger_used=$cn->get_value("select count(*) from jrn_def where jrn_def_id=$1",[$table->jrn_def_id]);
89 }
90
91 if ($count_ledger_used == 0) {
92 $this->set_error("jrn_def_id", _("Choisissez un journal"));
93 $has_error++;
94 }
95 // if the ledger is financial, the qcode MUST be the default one
96 if ( trim($table->mp_lib) == "") {
97 $this->set_error("mp_lib", _("Un libellé est obligatoire"));
98 $has_error++;
99 }
100
101 if (trim ($table->mp_qcode) != "") {
102 $ledger=new Jrn_def_SQL($cn , $table->jrn_def_id);
103 if ( $ledger->get('jrn_def_type') == 'FIN'){
104 $fiche=new Fiche($cn);
105 if ( $fiche->get_by_qcode($table->mp_qcode,FALSE) == 1) {
106 $this->set_error("mp_qcode",_("Fiche inexistante"));
107 $has_error++;
108 }
109 }
110 }
111 // get the type of the ledger
112 $a_row= $cn->get_row("select jrn_def_type,jrn_def_bank from jrn_def where jrn_def_id = $1",[$table->mp_jrn_def_id]);
113
114 // if ledger FIN then set the mp_qcode to the right card and set mp_fd_id to the same than mp_qcode
115 if ( $a_row['jrn_def_type'] == 'FIN') {
116 $fiche=new Fiche($cn,$a_row['jrn_def_bank']);
117 $table->mp_qcode=$fiche->get_quick_code();
118 $table->mp_fd_id=$cn->get_value("select fd_id from fiche where f_id=$1",[$a_row['jrn_def_bank']]);
119 }
120
121
122 if ( $a_row['jrn_def_type'] != 'FIN' && $table->mp_fd_id == -1)
123 {
124 $this->set_error("mp_fd_id",_("Choisissez un type de fiche"));
125 $has_error++;
126 }
127 if ( $has_error > 0) return FALSE;
128 return TRUE;
129 }
130 /**
131 * For the quickcode
132 * @param type $p_key
133 * @param type $p_value
134 */
135 function input_custom($p_key,$p_value)
136 {
137 $cn=$this->get_table()->cn;
138 switch ($p_key)
139 {
140 case "mp_qcode":
141 $w=new ICard("mp_qcode",$p_value);
142 $w->set_attribute("typecard", "all");
143 $w->autocomplete=0;
144
145 echo $w->input();
146 echo $w->search();
147 break;
148 default:
149 printf (_("Erreur key %s value %s"),$p_key,$p_value);
150 break;
151 }
152 }
153}
foreach($array as $idx=> $m) $w
_("actif, passif,charge,...")
this an abstract class , all the SQL class, like noalyss_sql (table), Acc_Plan_SQL (based on a SQL no...
define Class fiche and fiche def, those class are using class attribut. When adding or modifing new c...
Input HTML for the card show buttons, in the file, you have to add card.js How to use :
ORM abstract of the table public.jrn_def.
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_col_tips($p_key, $p_comment)
Set the info for a column, use Icon_Action\infobulle the message are in message_javascript....
set_col_type($p_key, $p_value, $p_array=NULL)
set the type of a column , it will change in the input db box , the select must supply an array of po...
set_property_visible($p_key, $p_value)
set a column of the data row visible or not
set_error($p_col, $p_message)
set the error message for a wrong input
set_col_label($p_key, $p_display)
set the name to display for a column
Manage the Payment method.
input_custom($p_key, $p_value)
For the quickcode.