noalyss Version-9
mobile_device_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-2021) Author Dany De Bontridder <danydb@noalyss.eu>
21
22/**
23 * @file
24 * @brief Manage the table profile_mobile
25 */
26
27/**
28 * @class Mobile_Device_MTable
29 * @brief Manage the table profile_mobile
30 */
32{
33 private $profile_id; //!< profile_mobile.p_id profile
34
36 {
37 parent::__construct($p_table);
38 $this->set_append_row(true);
39 $this->set_delete_row(true);
40 $this->set_col_label("me_code", _("Code Menu"));
41 $this->set_col_label("pmo_order", _("Ordre apparition"));
42 $this->set_col_label("pmo_default", _("EntĂȘtes standards"));
43 $this->set_col_tips("pmo_default",80 );
44 $this->set_property_visible("pmo_id", false);
45 $this->set_property_visible("p_id", false);
46 $this->set_col_type("pmo_default", "select",array(
47 ["value"=>1,"label"=>_("Oui")],
48 ["value"=>0,"label"=>_("Non")]
49 ));
50 $this->set_col_type("me_code","custom");
51 $this->set_col_type("pmo_order","numeric");
52 $this->set_header_option("pmo_order",'style="text-align:right;"');
53 $this->set_callback("ajax_misc.php");
54 $this->add_json_param("op","mobile_device_menu");
55 $this->set_sort_column("pmo_order");
56 $this->set_col_sort(1);
57 $this->set_order(["me_code","pmo_order","pmo_default"]);
58
59
60 $this->set_object_name("profile_menu_mtable");
61 }
62 public function get_profile_id()
63 {
64 return $this->profile_id;
65 }
66
67 public function set_profile_id($profile_id)
68 {
69 $this->profile_id=$profile_id;
70 $this->get_table()->setp('p_id',$profile_id);
71 $this->add_json_param("profile_id",$profile_id);
72 return $this;
73 }
74
75 /**
76 * @brief
77 * @param number $p_id profile_mobile.pmo_id
78 * @param number $profile_id profile_mobile.p_id profile
79 * @return \Mobile_Device_MTable
80 */
81 static function build($p_id,$profile_id)
82 {
85 if ( $p_id== -1) {
86 $profile_mobile->setp("pmo_order",5);
87 $profile_mobile->setp("pmo_default",1);
88 }
89
90 $mobile_device_table=new Mobile_Device_MTable($profile_mobile);
91 /* $mobile_device_table->set_profile_id($profile_id);
92 $mobile_device_table->get_table()->setp('p_id',$profile_id);*/
93 return $mobile_device_table;
94 }
95 function input_custom($p_key,$p_value)
96 {
97
98 if ( $p_key == "me_code") {
99 $select = new ISelect("me_code");
100 $cn=$this->get_table()->get_cn();
101 $select->value=$cn->make_array("select me_code , me_code ||' '||coalesce(me_description,'') from menu_ref
102 where
103 me_type in ('PL','ME') and trim(me_code) != 'new_line'
104 order by me_code");
105 $select->rowsize=17;
106 $select->selected=$p_value;
107 echo td($select->input());
108 return;
109 }
110 }
111 function display_row_custom($p_key, $p_value, $p_id=0)
112 {
113 if ( $p_key == 'me_code') {
114 echo td($p_value);
115 return;
116 }
117 }
118 /**
119 * @brief before inserting or updating, check that the data are correct ,
120 *
121 */
122 function check()
123 {
124 // DB connection
125 $cn=$this->get_table()->cn;
126 // object to insert
127 $profile_mobile_sql=$this->get_table();
128 $profile_mobile_sql->me_code=strtoupper($profile_mobile_sql->getp('me_code'));
129 $me_code=$profile_mobile_sql->me_code;
130
131 $profile_id=$profile_mobile_sql->getp("p_id");
132 $pmo_id=$profile_mobile_sql->getp("pmo_id");
133
134 // check for duplicate
135 if ( $cn->get_value("select count(*) from profile_mobile where p_id = $1 and me_code=$2 and pmo_id <> $3",
136 array($profile_id,$me_code,$pmo_id )) > 0
137 ) {
138 $this->set_error("me_code", _("Doublon"));
139 }
140
141 if (isNumber($profile_mobile_sql->getp("pmo_order")) != 1 ) {
142 $this->set_error("pmo_order", _("doit ĂȘtre un nombre"));
143 }
144
145 if ( $cn->get_value("select count(*) from menu_ref where me_code=$1",[$me_code]) == 0) {
146 $this->set_error ("me_code",_('Menu code invalide'));
147 }
148 if ($this->count_error() > 0) {
149 return false;
150 }
151 return true;
152 }
153}
isNumber($p_int)
Definition: ac_common.php:215
td($p_string='', $p_extra='')
surround the string with td
Definition: ac_common.php:83
static connect()
Html Input , create a tag <SELECT> ... </SELECT> if readonly == true then display the label correspon...
Purpose is to propose a librairy to display a table content and allow to update and delete row ,...
count_error()
returns the nb of errors found
set_delete_row($p_value)
Enable or disable the deletion of rows.
set_append_row($p_value)
Enable or disable the appending of rows.
set_col_sort($p_num)
When adding an element ,we place it thanks the DOM Attribute sort_value set it to -1 if you want one ...
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_header_option($p_key, $p_value)
add extra to column Header, normally class or style
set_object_name($p_object_name)
Set the object_name.
set_sort_column($p_col)
set the column to sort by default
add_json_param($p_attribute, $p_value)
Add json parameter to the current one.
set_callback($p_file)
set the callback function that is passed to javascript
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 table profile_mobile.
$profile_id
profile_mobile.p_id profile
static build($p_id, $profile_id)
check()
before inserting or updating, check that the data are correct ,
__construct(Profile_Mobile_SQL $p_table)
input_custom($p_key, $p_value)
this function let you create your own input , for example for a ITEXT , a IRADIO ,...
display_row_custom($p_key, $p_value, $p_id=0)
When displaying a row, if a column has the type "custom" , we can call this function to display prope...
ORM abstract of the table public.profile_mobile.
$profile_mobile