noalyss Version-9
parameter_extra_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 (2002-2020) Author Dany De Bontridder <danydb@noalyss.eu>
21
22if (!defined('ALLOWED'))
23 die('Appel direct ne sont pas permis');
24
25/**
26 * @file
27 * @brief extra setting for company
28 */
29/**
30 * @class Parameter_Extra_MTable
31 * @brief extra setting for company
32 */
33
34require_once NOALYSS_INCLUDE."/database/parameter_extra_sql.class.php";
35
37{
38 function __construct(\Data_SQL $p_table)
39 {
40 parent::__construct($p_table);
41 }
42 static function build ($p_id=-1)
43 {
45 $object_sql=new Parameter_Extra_SQL($cn,$p_id);
46 $object=new Parameter_Extra_MTable($object_sql);
47 $object->set_button_add_top(false);
48 $object->set_col_label("pe_code", _("Code"));
49 $object->set_col_label("pe_label", _("Intitulé"));
50 $object->set_col_label("pe_value", _("Valeur"));
51 $object->set_order(['pe_code','pe_label','pe_value']);
52 $object->set_search_table(false);
53 $object->set_callback("ajax_misc.php");
54 $object->add_json_param("op", "company");
55 $object->setCssClass("inner_box w-20");
56
57 return $object;
58
59 }
60 /**
61 * Check before insert or update
62 */
63 function check() {
64 $object=$this->get_table();
65 $cn=$object->cn;
66 $error=0;
67 // duplicate
68 $code=$cn->get_value("select comptaproc.transform_to_code($1)",[ $object->getp("pe_code")]);
69 if ( $cn->get_value("select count(*) from parameter_extra where pe_code =$1 and id != $2",
70 [$code,$object->getp("id")]) > 0 ) {
71 $this->set_error("pe_code", _("Code déjà utilisé"));
72 $error++;
73 }
74 // pe_code cannot be empyt
75 if ( $code == "") {
76 $this->set_error("pe_code", _("ne peut être vide"));
77 $error++;
78 }
79 // pe_code cannot be empyt
80 if ( preg_match('/^ATTR/', $code) == 1 ||
81 preg_match('/^CUSTATTR/', $code) == 1 ||
82 preg_match('/^BENEFATTR/', $code) == 1 )
83 {
84 $this->set_error("pe_code", _("ne peut être pas commencer par ATTR , BENEFATTR ou CUSTATTR"));
85 $error++;
86 }
87 if ($error > 0) { return false;}
88
89 return true;
90 }
91}
$code
catch(Exception $e) $object
this an abstract class , all the SQL class, like noalyss_sql (table), Acc_Plan_SQL (based on a SQL no...
static connect()
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
set_error($p_col, $p_message)
set the error message for a wrong input
check()
Check before insert or update.
abstract of the table public.parameter_extra