diff --git a/doc/html/annotated.html b/doc/html/annotated.html index 8ff53d2..90b373a 100644 --- a/doc/html/annotated.html +++ b/doc/html/annotated.html @@ -87,9 +87,11 @@  CmyboxClass to manage the box  Cpdf_plotabcClasse to generate PDF orders with template Plot  CplotClass plot - CplotLineClass plotLine - CplotslastchangedClass to manage the box - CvignobleboxClass to manage the box + CPlotcultivationtaskClass Plotcultivationtask + CplotcultivationtaskLineClass plotcultivationtaskLine + CplotLineClass plotLine + CplotslastchangedClass to manage the box + CvignobleboxClass to manage the box @@ -97,7 +99,7 @@ @@ -298,9 +298,9 @@

Member Data Documentation

-

Definition at line 58 of file vignoblebox.php.

+

Definition at line 67 of file vignoblebox.php.

-

Referenced by __construct().

+

Referenced by __construct(), and loadBox().

@@ -309,12 +309,12 @@

Member Data Documentation

- +
vignoblebox::$depends = array('mymodule')vignoblebox::$depends
- -

Definition at line 53 of file vignoblebox.php.

+Initial value:
= array(
'vignoble'
)
+

Definition at line 59 of file vignoblebox.php.

@@ -328,7 +328,7 @@

Member Data Documentation

-

Definition at line 73 of file vignoblebox.php.

+

Definition at line 85 of file vignoblebox.php.

@@ -342,7 +342,7 @@

Member Data Documentation

-

Definition at line 68 of file vignoblebox.php.

+

Definition at line 79 of file vignoblebox.php.

@@ -356,9 +356,9 @@

Member Data Documentation

-

Definition at line 63 of file vignoblebox.php.

+

Definition at line 73 of file vignoblebox.php.

-

Referenced by __construct().

+

Referenced by __construct().

@@ -371,7 +371,7 @@

Member Data Documentation

-Go to the documentation of this file.
1 -- ===================================================================
2 -- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 --
4 -- This program is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation; either version 3 of the License, or
7 -- (at your option) any later version.
8 --
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
13 --
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
16 --
17 -- ===================================================================
18 
19 
20 ALTER TABLE llx_plot_extrafields ADD INDEX idx_plot_extrafields (fk_object);
+Go to the documentation of this file.
1 -- ===================================================================
2 -- Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
3 --
4 -- This program is free software; you can redistribute it and/or modify
5 -- it under the terms of the GNU General Public License as published by
6 -- the Free Software Foundation; either version 3 of the License, or
7 -- (at your option) any later version.
8 --
9 -- This program is distributed in the hope that it will be useful,
10 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
11 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 -- GNU General Public License for more details.
13 --
14 -- You should have received a copy of the GNU General Public License
15 -- along with this program. If not, see <http://www.gnu.org/licenses/>.
16 --
17 -- ===================================================================
18 
19 
20 ALTER TABLE llx_plot_extrafields ADD UNIQUE INDEX idx_plot_extrafields (fk_object);
@@ -789,7 +789,7 @@

Member Data Documentation

-

Definition at line 78 of file plot.class.php.

+

Definition at line 79 of file plot.class.php.

@@ -803,7 +803,7 @@

Member Data Documentation

-

Definition at line 70 of file plot.class.php.

+

Definition at line 71 of file plot.class.php.

@@ -817,7 +817,7 @@

Member Data Documentation

-

Definition at line 46 of file plot.class.php.

+

Definition at line 47 of file plot.class.php.

@@ -831,7 +831,7 @@

Member Data Documentation

-

Definition at line 64 of file plot.class.php.

+

Definition at line 65 of file plot.class.php.

@@ -845,7 +845,7 @@

Member Data Documentation

-

Definition at line 80 of file plot.class.php.

+

Definition at line 81 of file plot.class.php.

@@ -859,7 +859,7 @@

Member Data Documentation

-

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

+

Definition at line 83 of file plot.class.php.

@@ -873,7 +873,7 @@

Member Data Documentation

-

Definition at line 68 of file plot.class.php.

+

Definition at line 69 of file plot.class.php.

Referenced by getNomUrl().

@@ -889,7 +889,7 @@

Member Data Documentation

-

Definition at line 58 of file plot.class.php.

+

Definition at line 59 of file plot.class.php.

@@ -903,7 +903,7 @@

Member Data Documentation

-

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

+

Definition at line 73 of file plot.class.php.

@@ -917,7 +917,7 @@

Member Data Documentation

-

Definition at line 74 of file plot.class.php.

+

Definition at line 75 of file plot.class.php.

@@ -931,9 +931,9 @@

Member Data Documentation

-

Definition at line 66 of file plot.class.php.

+

Definition at line 67 of file plot.class.php.

-

Referenced by fetch(), getNomUrl(), info(), and loadObject().

+

Referenced by fetch(), getNomUrl(), info(), and loadObject().

@@ -947,7 +947,7 @@

Member Data Documentation

-

Definition at line 52 of file plot.class.php.

+

Definition at line 53 of file plot.class.php.

Referenced by delete().

@@ -963,7 +963,7 @@

Member Data Documentation

-

Definition at line 76 of file plot.class.php.

+

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

@@ -976,7 +976,7 @@

Member Data Documentation

@@ -188,7 +188,7 @@

Member Data Documentation

@@ -346,9 +346,9 @@

Member Function Documentation

Get custom data directories in document folder.

Directories are created when module is enabled. Example: this->dirs = array("/module/temp");

-

Definition at line 164 of file modVignoble.class.php.

+

Definition at line 168 of file modVignoble.class.php.

-

Referenced by __construct().

+

Referenced by __construct().

@@ -383,9 +383,9 @@

Member Function Documentation

set need_dolibarr_version as minimum version of Dolibarr required by module

Todo:
check issue when version contains -alpha
-

Definition at line 184 of file modVignoble.class.php.

+

Definition at line 188 of file modVignoble.class.php.

-

Referenced by __construct().

+

Referenced by __construct().

@@ -419,11 +419,11 @@

Member Function Documentation

  • Rootstock
  • -

    Definition at line 639 of file modVignoble.class.php.

    +

    Definition at line 721 of file modVignoble.class.php.

    References $conf.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -459,11 +459,11 @@

    Member Function Documentation

    To add unique key if we ask a field of a child to avoid the DISTINCT to discard them

    sql request to extract the data

    -

    Definition at line 432 of file modVignoble.class.php.

    +

    Definition at line 509 of file modVignoble.class.php.

    -

    References $db, $extrafields, and $extrafieldslabels.

    +

    References $db, $extrafields, and $extrafieldslabels.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -505,11 +505,11 @@

    Member Function Documentation

  • Populate values for the example file
  • -

    Definition at line 763 of file modVignoble.class.php.

    +

    Definition at line 845 of file modVignoble.class.php.

    -

    References $db, $extrafields, $extrafieldslabels, $resql, $sql, and $value.

    +

    References $db, $extrafields, $extrafieldslabels, $resql, $sql, and $value.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -537,9 +537,9 @@

    Member Function Documentation

    Get module langage files url stored in langfiles array.

    Language files are stored in /langs/<language code>="">/<module>.lang

    -

    Definition at line 230 of file modVignoble.class.php.

    +

    Definition at line 234 of file modVignoble.class.php.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -568,13 +568,18 @@

    Member Function Documentation

    Each entry is a key, value array in the menu array.

    Todo:
    add permission rules for menu entries

    Define Vignoble top menu entry

    -

    Define plot left menu

    -

    Define plot left menu entry New plot

    -

    Define plot left menu entry Plot List

    + +

    Define plot left menu entry cultivation tasks List

    -

    Definition at line 336 of file modVignoble.class.php.

    +

    Definition at line 362 of file modVignoble.class.php.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -610,9 +615,9 @@

    Member Function Documentation

    Set js array to relative path of js files if module must load js on all pages

    Set hooks array by adding all hooks context managed by module

    -

    Definition at line 570 of file modVignoble.class.php.

    +

    Definition at line 647 of file modVignoble.class.php.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -641,9 +646,9 @@

    Member Function Documentation

    Each row is a permission defined by an id, a label, a boolean and two constant strings.

    Set read, create/modify, delete, export and import permissions for Plot

    -

    Definition at line 285 of file modVignoble.class.php.

    +

    Definition at line 311 of file modVignoble.class.php.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -692,10 +697,11 @@

    Member Function Documentation

  • 'user' to add a tab in user view
  • add plot tab to resource module

    +

    remove project tabs for cultivation project

    -

    Definition at line 263 of file modVignoble.class.php.

    +

    Definition at line 267 of file modVignoble.class.php.

    -

    Referenced by __construct().

    +

    Referenced by __construct().

    @@ -723,9 +729,9 @@

    Member Function Documentation

    Returns
    int 1 if OK, 0 if KO
    -

    Definition at line 716 of file modVignoble.class.php.

    +

    Definition at line 798 of file modVignoble.class.php.

    -

    References $result, $sql, and loadTables().

    +

    References $result, $sql, and loadTables().

    + Here is the call graph for this function:
    @@ -765,9 +771,9 @@

    Member Function Documentation

    Create tables, keys and data required by module Files llx_table1.sql, llx_table1.key.sql llx_data.sql with create table, create keys and create data commands must be stored in directory /vignoble/sql/ This function is called by this->init.

    Returns
    int <=0 if KO, >0 if OK
    -

    Definition at line 753 of file modVignoble.class.php.

    +

    Definition at line 835 of file modVignoble.class.php.

    -

    Referenced by init().

    +

    Referenced by init().

    @@ -795,7 +801,7 @@

    Member Function Documentation

    Returns
    int 1 if OK, 0 if KO
    -

    Definition at line 736 of file modVignoble.class.php.

    +

    Definition at line 818 of file modVignoble.class.php.

    References $sql.

    @@ -810,7 +816,7 @@

    Member Function Documentation

    @@ -623,8 +619,6 @@

    Variable Documentation

    Definition at line 67 of file plot_list.php.

    -

    Referenced by plot\fetchAll().

    - @@ -639,8 +633,6 @@

    Variable Documentation

    Definition at line 68 of file plot_list.php.

    -

    Referenced by plot\fetchAll().

    - @@ -648,14 +640,14 @@

    Variable Documentation

    - +
    if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql = "SELECT"if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) $sql = "SELECT"

    Definition at line 179 of file plot_list.php.

    -

    Referenced by plot\create(), plot\delete(), FormVignoble\displayDicCombo(), plot\fetch(), plot\fetchAll(), modVignoble\getImports(), plot\info(), modVignoble\init(), plot\loadObject(), printView(), modVignoble\remove(), and plot\update().

    +

    Referenced by Plotcultivationtask\create(), plot\create(), Plotcultivationtask\delete(), plot\delete(), FormVignoble\displayDicCombo(), Plotcultivationtask\fetch(), plot\fetch(), Plotcultivationtask\fetchAll(), plot\fetchAll(), modVignoble\getImports(), Plotcultivationtask\info(), plot\info(), modVignoble\init(), Plotcultivationtask\loadObject(), plot\loadObject(), printDocumentModelView(), modVignoble\remove(), Plotcultivationtask\update(), and plot\update().

    @@ -671,8 +663,6 @@

    Variable Documentation

    Definition at line 175 of file plot_list.php.

    -

    Referenced by pdf_plotabc\_pagehead().

    - @@ -680,7 +670,7 @@

    Variable Documentation

    - +
    if ($resql) elseif ($resql) else
    @@ -696,7 +686,7 @@

    Variable Documentation

    -Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    30 // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
    31 // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
    32 // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
    33 // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
    34 // if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
    35 // if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
    36 // if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
    37 // if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
    38 // if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
    39 // if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
    40 // if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
    41 @include './tpl/maindolibarr.inc.php';
    42 
    43 dol_include_once('/vignoble/class/plot.class.php');
    44 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    45 
    46 // Load traductions files requiredby by page
    47 $langs->load("other");
    48 $langs->load("vignoble@vignoble");
    49 
    50 // Get parameters
    51 $id = GETPOST('id', 'int');
    52 $action = GETPOST('action', 'alpha');
    53 $backtopage = GETPOST('backtopage');
    54 $myparam = GETPOST('myparam', 'alpha');
    55 
    56 // Get search field values
    57 $search_ref = GETPOST('search_ref', 'alpha');
    58 $search_label = GETPOST('search_label', 'alpha');
    59 $search_description = GETPOST('search_description', 'alpha');
    60 // Get search all option
    61 $search_all = GETPOST('sall', 'alpha');
    62 // Get CSS options
    63 $optioncss = GETPOST('optioncss', 'alpha');
    64 
    65 // Load variable for pagination
    66 $limit = GETPOST("limit") ? GETPOST("limit", "int") : $conf->liste_limit;
    67 $sortfield = GETPOST('sortfield', 'alpha');
    68 $sortorder = GETPOST('sortorder', 'alpha');
    69 $page = GETPOST('page', 'int');
    70 if ($page == - 1) {
    71  $page = 0;
    72 }
    74 $pageprev = $page - 1;
    75 $pagenext = $page + 1;
    76 if (! $sortfield)
    77  $sortfield = "t.rowid"; // default sort field
    78 if (! $sortorder)
    79  $sortorder = "ASC"; // default sort order
    80 
    81 // Protection if external user
    82 $socid = 0;
    83 if ($user->socid > 0) { // dĂ©fini pour utilisateur externe, Id du tiers sociĂ©tĂ© vide sinon
    84  $socid = $user->socid; // $socid est souvent dans l'url
    85  // accessforbidden();
    86 }
    87 
    88 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
    89 $hookmanager->initHooks(array(
    90  'plotlist'
    91 ));
    96 $extrafields = new ExtraFields($db);
    97 // fetch extra labels and add to search options
    98 $extrafieldslabels = $extrafields->fetch_name_optionals_label('plot');
    99 $search_array_extrafields = $extrafields->getOptionalsFromPost($extrafieldslabels, '', 'search_');
    100 
    106  't.ref' => 'Ref',
    107  't.label' => 'Label',
    108  't.description' => 'Description'
    109 );
    110 //
    116 
    125 $parameters = array();
    126 $reshook = $hookmanager->executeHooks('doActions', $parameters, $currentPlot, $action); // Note that $action and $currentPlot may have been modified by some hooks
    127 if ($reshook < 0)
    128  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    129 
    130 include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
    131 
    132 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter"))
    133 // All test are required to be compatible with all browsers
    134 {
    135  // empty selection boxes
    136  $search_ref = '';
    137  $search_label = '';
    138  $search_description = '';
    139  $search_array_extrafields = array();
    140 }
    141 // TODO Check if action 'confirm_delete' make sense on a list without line tick box
    142 if (empty($reshook)) {
    143  // Action to delete
    144  if ($action == 'confirm_delete') {
    145  $result = $currentPlot->delete($user);
    146  if ($result > 0) {
    147  // Delete OK
    148  setEventMessages("RecordDeleted", null, 'mesgs');
    149  header("Location: " . dol_buildpath('/vignoble/list.php', 1));
    150  exit();
    151  } else {
    152  if (! empty($currentPlot->errors))
    153  setEventMessages(null, $currentPlot->errors, 'errors');
    154  else
    155  setEventMessages($currentPlot->error, null, 'errors');
    156  }
    157  }
    158 }
    159 
    168 llxHeader('', $langs->trans('PlotListTitle'), '');
    169 
    170 $form = new Form($db);
    172 $plot = new plot($db);
    173 
    174 // Put here content of your page
    175 $title = $langs->trans('PlotsList');
    176 
    177 // addJQuery();
    178 
    179 $sql = "SELECT";
    180 $sql .= " t.rowid,";
    181 $sql .= " t.entity,";
    182 $sql .= " t.ref,";
    183 $sql .= " t.label,";
    184 $sql .= " t.description,";
    185 $sql .= " t.tms as date_update,";
    186 $sql .= " t.datec as date_creation";
    187 
    188 // Add fields for extrafields
    189 foreach ($extrafields->attribute_list as $key => $val)
    190  $sql .= ",ef." . $key . ' as options_' . $key;
    191 
    192  // Add fields from hooks
    193 $parameters = array();
    194 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $currentPlot may have been modified by hook
    195 $sql .= $hookmanager->resPrint;
    196 
    197 $sql .= " FROM " . MAIN_DB_PREFIX . "plot as t";
    198 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
    199  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "plot_extrafields as ef on (t.rowid = ef.fk_object)";
    200 
    201 $sql .= " WHERE 1 = 1";
    202 // $sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
    203 
    204 if ($search_entity)
    205  $sql .= natural_search("entity", $search_entity);
    206 if ($search_ref)
    207  $sql .= natural_search("ref", $search_ref);
    208 if ($search_label)
    209  $sql .= natural_search("label", $search_label);
    211  $sql .= natural_search("description", $search_description);
    212 if ($search_all)
    213  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
    214 
    215  // Add search from extra fields
    216 foreach ($search_array_extrafields as $key => $val) {
    217  $crit = $val;
    218  $tmpkey = preg_replace('/search_options_/', '', $key);
    219  $typ = $extrafields->attribute_type[$tmpkey];
    220  $mode = 0;
    221  if (in_array($typ, array(
    222  'int',
    223  'double'
    224  )))
    225  $mode = 1; // Search on a numeric
    226  if ($val && (($crit != '' && ! in_array($typ, array(
    227  'select',
    228  'sellist'
    229  ))) || ! empty($crit))) {
    230  $sql .= natural_search('ef.' . $tmpkey, $crit, $mode);
    231  }
    232 }
    233 // Add where from hooks
    234 $parameters = array();
    235 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $currentPlot may have been modified by hook
    236 $sql .= $hookmanager->resPrint;
    237 
    238 $sql .= $db->order($sortfield, $sortorder);
    239 
    240 // echo var_dump($sql);
    241 
    242 // Count total nb of records
    244 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
    245  $result = $db->query($sql);
    246  $nbtotalofrecords = $db->num_rows($result);
    247 }
    248 
    249 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
    250 
    251 dol_syslog($script_file, LOG_DEBUG);
    256 $resql = $db->query($sql);
    257 
    258 if ($resql) {
    259  $num = $db->num_rows($resql);
    260 
    261  $params = '';
    262 
    263  if ($search_entity != '')
    264  $params .= '&amp;search_entity=' . urlencode($search_entity);
    265  if ($search_ref != '')
    266  $params .= '&amp;search_ref=' . urlencode($search_ref);
    267  if ($search_label != '')
    268  $params .= '&amp;search_label=' . urlencode($search_label);
    269  if ($search_description != '')
    270  $params .= '&amp;search_description=' . urlencode($search_description);
    271  foreach ($search_array_extrafields as $key => $val) {
    272  $tmpkey = preg_replace('/search_options_/', '', $key);
    273  if ($val != '')
    274  $param .= '&search_options_' . $tmpkey . '=' . urlencode($val);
    275 
    276  if ($optioncss != '')
    277  $param .= '&optioncss=' . $optioncss;
    278  }
    279 
    280  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_plot@vignoble');
    281  // selection form
    282  print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
    283  if ($optioncss != '')
    284  print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
    285  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    286  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
    287  print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
    288  print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
    289  // message when global selection activated
    290  if ($search_all) {
    291  foreach ($fieldstosearchall as $key => $val)
    292  $fieldstosearchall[$key] = $langs->trans($val);
    293  print $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall);
    294  }
    295  // message when list not fully displayed
    296  if (! empty($moreforfilter)) {
    297  print '<div class="liste_titre liste_titre_bydiv centpercent">';
    298  print $moreforfilter;
    299  $parameters = array();
    300  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $currentPlot may have been modified by hook
    301  print $hookmanager->resPrint;
    302  print '</div>';
    303  }
    304 
    305  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
    306  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
    307 
    308  print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
    309 
    310  // print Fields title
    311  print '<tr class="liste_titre">';
    312 
    313  if (! empty($arrayfields['t.entity']['checked']))
    314  print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder);
    315  if (! empty($arrayfields['t.ref']['checked']))
    316  print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER['PHP_SELF'], 't.ref', '', $param, '', $sortfield, $sortorder);
    317  if (! empty($arrayfields['t.label']['checked']))
    318  print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, '', $sortfield, $sortorder);
    319  if (! empty($arrayfields['t.description']['checked']))
    320  print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER['PHP_SELF'], 't.description', '', $param, '', $sortfield, $sortorder);
    321  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    322  foreach ($extrafields->attribute_label as $key => $val) {
    323  if (! empty($arrayfields["ef." . $key]['checked'])) {
    324  $align = $extrafields->getAlignFlag($key);
    325  print_liste_field_titre($extrafieldslabels[$key], $_SERVER["PHP_SELF"], "ef." . $key, "", $param, ($align ? 'align="' . $align . '"' : ''), $sortfield, $sortorder);
    326  }
    327  }
    328  }
    329  // Hook fields
    330  $parameters = array(
    331  'arrayfields' => $arrayfields
    332  );
    333  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $currentPlot may have been modified by hook
    334  print $hookmanager->resPrint;
    335  if (! empty($arrayfields['t.datec']['checked']))
    336  print_liste_field_titre($langs->trans("DateCreationShort"), $_SERVER["PHP_SELF"], "t.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
    337  if (! empty($arrayfields['t.tms']['checked']))
    338  print_liste_field_titre($langs->trans("DateModificationShort"), $_SERVER["PHP_SELF"], "t.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
    339  // if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
    340  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, 'maxwidthsearch ');
    341  print '</tr>' . "\n";
    342 
    343  // print Search Fields boxes in title
    344  print '<tr class="liste_titre">';
    345 
    346  if (! empty($arrayfields['t.entity']['checked']))
    347  print '<td class="liste_titre"><input type="text" class="flat" name="search_entity" value="' . $search_entity . '" size="10"></td>';
    348  if (! empty($arrayfields['t.ref']['checked']))
    349  print '<td class="liste_titre"><input type="text" class="flat" name="search_ref" value="' . $search_ref . '" size="10"></td>';
    350  if (! empty($arrayfields['t.label']['checked']))
    351  print '<td class="liste_titre"><input type="text" class="flat" name="search_label" value="' . $search_label . '" size="10"></td>';
    352  if (! empty($arrayfields['t.description']['checked']))
    353  print '<td class="liste_titre"><input type="text" class="flat" name="search_description" value="' . $search_description . '" size="10"></td>';
    354 
    355  // example of a combobox selection for search
    356  // if (! empty($arrayfields['t.fk_rootstock']['checked']))
    357  // print '<td class="liste_titre">' . $formvignoble->displayDicCombo('c_rootstock', 'rootstook', $search_fk_rootstock, 'search_fk_rootstock', true) . '</td>';
    358 
    359  // Search box for Extra fields in title
    360  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    361  foreach ($extrafields->attribute_label as $key => $val) {
    362  if (! empty($arrayfields["ef." . $key]['checked'])) {
    363  $align = $extrafields->getAlignFlag($key);
    364  $typeofextrafield = $extrafields->attribute_type[$key];
    365 
    366  print '<td class="liste_titre' . ($align ? ' ' . $align : '') . '">';
    367 
    368  if (in_array($typeofextrafield, array(
    369  'varchar',
    370  'int',
    371  'double',
    372  'select',
    373  'sellist'
    374  ))) { // print a search box
    375  // get search value if any
    376  $tmpkey = preg_replace('/search_options_/', '', $key);
    377  $value = dol_escape_htmltag($search_array_extrafields['search_options_' . $tmpkey]);
    378  $searchclass = '';
    379  switch ($typeofextrafield) {
    380  case 'select':
    381  print $extrafields->showInputField($key, $value, null, '', 'search_', searchstring);
    382  break;
    383  case 'sellist':
    384  print $extrafields->showInputField($key, $value, null, '', 'search_', searchstring);
    385  break;
    386  case 'varchar':
    387  print '<input class="flat searchstring" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    388  break;
    389  case 'int':
    390  print '<input class="flat searchnum" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    391  break;
    392  case 'double':
    393  print '<input class="flat searchnum" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    394  break;
    395  }
    396  }
    397  print '</td>';
    398  }
    399  }
    400  }
    401  // Fields from hook
    402  $parameters = array(
    403  'arrayfields' => $arrayfields
    404  );
    405  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $currentPlot may have been modified by hook
    406  print $hookmanager->resPrint;
    407  if (! empty($arrayfields['t.datec']['checked'])) {
    408  // Date creation
    409  print '<td class="liste_titre">';
    410  print '</td>';
    411  }
    412  if (! empty($arrayfields['t.tms']['checked'])) {
    413  // Date modification
    414  print '<td class="liste_titre">';
    415  print '</td>';
    416  }
    417  /*
    418  * if (! empty($arrayfields['u.statut']['checked']))
    419  * {
    420  * // Status
    421  * print '<td class="liste_titre" align="center">';
    422  * print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
    423  * print '</td>';
    424  * }
    425  */
    426  // Action column in list title
    427  print '<td class="liste_titre" align="right">';
    428  print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
    429  print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
    430  print '</td>';
    431  print '</tr>' . "\n";
    432  /*
    433  * Fetch the result set and print lines
    434  */
    435  $i = 0;
    436  while ($i < $num) {
    437  $obj = $db->fetch_object($resql);
    438  if ($obj) {
    439  print '<tr>';
    440  $plot->fetch($obj->rowid);
    441  if (! empty($arrayfields['t.entity']['checked']))
    442  print '<td>' . $obj->entity . '</td>';
    443  if (! empty($arrayfields['t.ref']['checked']))
    444  print '<td>' . $plot->getNomUrl(1) . '</td>';
    445  if (! empty($arrayfields['t.label']['checked']))
    446  print '<td>' . $obj->label . '</td>';
    447  if (! empty($arrayfields['t.description']['checked']))
    448  print '<td>' . $obj->description . '</td>';
    449  // Extra fields
    450  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    451  foreach ($extrafields->attribute_label as $key => $val) {
    452  if (! empty($arrayfields["ef." . $key]['checked'])) {
    453  print '<td';
    454  $align = $extrafields->getAlignFlag($key);
    455  if ($align)
    456  print ' align="' . $align . '"';
    457  print '>';
    458  $tmpkey = 'options_' . $key;
    459  print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
    460  print '</td>';
    461  }
    462  }
    463  }
    464  // Fields from hook
    465  $parameters = array(
    466  'arrayfields' => $arrayfields,
    467  'obj' => $obj
    468  );
    469  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $currentPlot may have been modified by hook
    470  print $hookmanager->resPrint;
    471  // Date creation
    472  if (! empty($arrayfields['t.datec']['checked'])) {
    473  print '<td align="center">';
    474  print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
    475  print '</td>';
    476  }
    477  // Date modification
    478  if (! empty($arrayfields['t.tms']['checked'])) {
    479  print '<td align="center">';
    480  print dol_print_date($db->jdate($obj->date_update), 'dayhour');
    481  print '</td>';
    482  }
    483  // Status
    484  /*
    485  * if (! empty($arrayfields['u.statut']['checked']))
    486  * {
    487  * $userstatic->statut=$obj->statut;
    488  * print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
    489  * }
    490  */
    491  // Action column
    492  // TODO check if example of action column exist
    493  print '<td></td>';
    494  print '</tr>';
    495  }
    496  $i ++;
    497  }
    498 
    499  $db->free($resql);
    500 
    501  $parameters = array(
    502  'sql' => $sql
    503  );
    504  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $currentPlot may have been modified by hook
    505  print $hookmanager->resPrint;
    506 
    507  print "</table>\n";
    508  print "</form>\n";
    509 
    510  $db->free($result);
    511 } else {
    512  $error ++;
    513  dol_print_error($db);
    514 }
    515 
    516 // End of page
    517 llxFooter();
    518 $db->close();
    519 
    530 {
    531  $arrayfields['t.ref'] = array(
    532  'label' => $langs->trans("Fieldref"),
    533  'checked' => 1
    534  );
    535  $arrayfields['t.label'] = array(
    536  'label' => $langs->trans("Fieldlabel"),
    537  'checked' => 1
    538  );
    539  $arrayfields['t.description'] = array(
    540  'label' => $langs->trans("Fielddescription"),
    541  'checked' => 0
    542  );
    543  // add extrafields attributes and labels
    544  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    545  foreach ($extrafields->attribute_label as $key => $val) {
    546  $arrayfields["ef." . $key] = array(
    547  'label' => $extrafields->attribute_label[$key],
    548  'checked' => $extrafields->attribute_list[$key],
    549  'position' => $extrafields->attribute_pos[$key],
    550  'enabled' => $extrafields->attribute_perms[$key]
    551  );
    552  }
    553  }
    554  $arrayfields['t.entity'] = array(
    555  'label' => $langs->trans("Entity"),
    556  'checked' => 1,
    557  'enabled' => (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))
    558  );
    559  $arrayfields['t.datec'] = array(
    560  'label' => $langs->trans("DateCreation"),
    561  'checked' => 0,
    562  'position' => 500
    563  );
    564  $arrayfields['t.tms'] = array(
    565  'label' => $langs->trans("DateModificationShort"),
    566  'checked' => 0,
    567  'position' => 500
    568  );
    569 
    570  return $arrayfields;
    571 }
    572 
    576 function addJQuery()
    577 {
    578  print '<script type="text/javascript" language="javascript">
    579  jQuery(document).ready(function() {
    580  function init_myfunc()
    581  {
    582  jQuery("#myid").removeAttr(\'disabled\');
    583  jQuery("#myid").attr(\'disabled\',\'disabled\');
    584  }
    585  init_myfunc();
    586  jQuery("#mybutton").click(function() {
    587  init_myfunc();
    588  });
    589  });
    590  </script>';
    591 }
    592 
    593 
    594 
    $socid
    Definition: plot_list.php:82
    +Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    30 // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
    31 // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
    32 // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
    33 // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
    34 // if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
    35 // if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
    36 // if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
    37 // if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
    38 // if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
    39 // if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
    40 // if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
    41 @include './tpl/maindolibarr.inc.php';
    42 
    43 dol_include_once('/vignoble/class/plot.class.php');
    44 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    45 
    46 // Load traductions files requiredby by page
    47 $langs->load("other");
    48 $langs->load("vignoble@vignoble");
    49 
    50 // Get parameters
    51 $id = GETPOST('id', 'int');
    52 $action = GETPOST('action', 'alpha');
    53 $backtopage = GETPOST('backtopage');
    54 $myparam = GETPOST('myparam', 'alpha');
    55 
    56 // Get search field values
    57 $search_ref = GETPOST('search_ref', 'alpha');
    58 $search_label = GETPOST('search_label', 'alpha');
    59 $search_description = GETPOST('search_description', 'alpha');
    60 // Get search all option
    61 $search_all = GETPOST('sall', 'alpha');
    62 // Get CSS options
    63 $optioncss = GETPOST('optioncss', 'alpha');
    64 
    65 // Load variable for pagination
    66 $limit = GETPOST("limit") ? GETPOST("limit", "int") : $conf->liste_limit;
    67 $sortfield = GETPOST('sortfield', 'alpha');
    68 $sortorder = GETPOST('sortorder', 'alpha');
    69 $page = GETPOST('page', 'int');
    70 if ($page == - 1) {
    71  $page = 0;
    72 }
    74 $pageprev = $page - 1;
    75 $pagenext = $page + 1;
    76 if (! $sortfield)
    77  $sortfield = "t.rowid"; // default sort field
    78 if (! $sortorder)
    79  $sortorder = "ASC"; // default sort order
    80 
    81 // Protection if external user
    82 $socid = 0;
    83 if ($user->socid > 0) { // dĂ©fini pour utilisateur externe, Id du tiers sociĂ©tĂ© vide sinon
    84  $socid = $user->socid; // $socid est souvent dans l'url
    85  // accessforbidden();
    86 }
    87 
    88 // Initialize technical object to manage hooks. Note that conf->hooks_modules contains array
    89 $hookmanager->initHooks(array(
    90  'plotlist'
    91 ));
    96 $extrafields = new ExtraFields($db);
    97 // fetch extra labels and add to search options
    98 $extrafieldslabels = $extrafields->fetch_name_optionals_label('plot');
    99 $search_array_extrafields = $extrafields->getOptionalsFromPost($extrafieldslabels, '', 'search_');
    100 
    106  't.ref' => 'Ref',
    107  't.label' => 'Label',
    108  't.description' => 'Description'
    109 );
    110 //
    116 
    125 $parameters = array();
    126 $reshook = $hookmanager->executeHooks('doActions', $parameters, $currentPlot, $action); // Note that $action and $currentPlot may have been modified by some hooks
    127 if ($reshook < 0)
    128  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    129 
    130 include DOL_DOCUMENT_ROOT . '/core/actions_changeselectedfields.inc.php';
    131 
    132 if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter"))
    133 // All test are required to be compatible with all browsers
    134 {
    135  // empty selection boxes
    136  $search_ref = '';
    137  $search_label = '';
    138  $search_description = '';
    139  $search_array_extrafields = array();
    140 }
    141 // TODO Check if action 'confirm_delete' make sense on a list without line tick box
    142 if (empty($reshook)) {
    143  // Action to delete
    144  if ($action == 'confirm_delete') {
    145  $result = $currentPlot->delete($user);
    146  if ($result > 0) {
    147  // Delete OK
    148  setEventMessages("RecordDeleted", null, 'mesgs');
    149  header("Location: " . dol_buildpath('/vignoble/list.php', 1));
    150  exit();
    151  } else {
    152  if (! empty($currentPlot->errors))
    153  setEventMessages(null, $currentPlot->errors, 'errors');
    154  else
    155  setEventMessages($currentPlot->error, null, 'errors');
    156  }
    157  }
    158 }
    159 
    168 llxHeader('', $langs->trans('PlotListTitle'), '');
    169 
    170 $form = new Form($db);
    172 $plot = new plot($db);
    173 
    174 // Put here content of your page
    175 $title = $langs->trans('PlotsList');
    176 
    177 // addJQuery();
    178 
    179 $sql = "SELECT";
    180 $sql .= " t.rowid,";
    181 $sql .= " t.entity,";
    182 $sql .= " t.ref,";
    183 $sql .= " t.label,";
    184 $sql .= " t.description,";
    185 $sql .= " t.tms as date_update,";
    186 $sql .= " t.datec as date_creation";
    187 
    188 // Add fields for extrafields
    189 foreach ($extrafields->attribute_list as $key => $val)
    190  $sql .= ",ef." . $key . ' as options_' . $key;
    191 
    192  // Add fields from hooks
    193 $parameters = array();
    194 $reshook = $hookmanager->executeHooks('printFieldListSelect', $parameters); // Note that $action and $currentPlot may have been modified by hook
    195 $sql .= $hookmanager->resPrint;
    196 
    197 $sql .= " FROM " . MAIN_DB_PREFIX . "plot as t";
    198 if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label))
    199  $sql .= " LEFT JOIN " . MAIN_DB_PREFIX . "plot_extrafields as ef on (t.rowid = ef.fk_object)";
    200 
    201 $sql .= " WHERE 1 = 1";
    202 // $sql.= " WHERE u.entity IN (".getEntity('mytable',1).")";
    203 
    204 if ($search_entity)
    205  $sql .= natural_search("entity", $search_entity);
    206 if ($search_ref)
    207  $sql .= natural_search("ref", $search_ref);
    208 if ($search_label)
    209  $sql .= natural_search("label", $search_label);
    211  $sql .= natural_search("description", $search_description);
    212 if ($search_all)
    213  $sql .= natural_search(array_keys($fieldstosearchall), $search_all);
    214 
    215  // Add search from extra fields
    216 foreach ($search_array_extrafields as $key => $val) {
    217  $crit = $val;
    218  $tmpkey = preg_replace('/search_options_/', '', $key);
    219  $typ = $extrafields->attribute_type[$tmpkey];
    220  $mode = 0;
    221  if (in_array($typ, array(
    222  'int',
    223  'double'
    224  )))
    225  $mode = 1; // Search on a numeric
    226  if ($val && (($crit != '' && ! in_array($typ, array(
    227  'select',
    228  'sellist'
    229  ))) || ! empty($crit))) {
    230  $sql .= natural_search('ef.' . $tmpkey, $crit, $mode);
    231  }
    232 }
    233 // Add where from hooks
    234 $parameters = array();
    235 $reshook = $hookmanager->executeHooks('printFieldListWhere', $parameters); // Note that $action and $currentPlot may have been modified by hook
    236 $sql .= $hookmanager->resPrint;
    237 
    238 $sql .= $db->order($sortfield, $sortorder);
    239 
    240 // echo var_dump($sql);
    241 
    242 // Count total nb of records
    244 if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST)) {
    245  $result = $db->query($sql);
    246  $nbtotalofrecords = $db->num_rows($result);
    247 }
    248 
    249 $sql .= $db->plimit($conf->liste_limit + 1, $offset);
    250 
    251 dol_syslog($script_file, LOG_DEBUG);
    256 $resql = $db->query($sql);
    257 
    258 if ($resql) {
    259  $num = $db->num_rows($resql);
    260 
    261  $params = '';
    262 
    263  if ($search_entity != '')
    264  $params .= '&amp;search_entity=' . urlencode($search_entity);
    265  if ($search_ref != '')
    266  $params .= '&amp;search_ref=' . urlencode($search_ref);
    267  if ($search_label != '')
    268  $params .= '&amp;search_label=' . urlencode($search_label);
    269  if ($search_description != '')
    270  $params .= '&amp;search_description=' . urlencode($search_description);
    271  foreach ($search_array_extrafields as $key => $val) {
    272  $tmpkey = preg_replace('/search_options_/', '', $key);
    273  if ($val != '')
    274  $param .= '&search_options_' . $tmpkey . '=' . urlencode($val);
    275 
    276  if ($optioncss != '')
    277  $param .= '&optioncss=' . $optioncss;
    278  }
    279 
    280  print_barre_liste($title, $page, $_SERVER["PHP_SELF"], $params, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'object_plot@vignoble');
    281  // selection form
    282  print '<form method="GET" id="searchFormList" action="' . $_SERVER["PHP_SELF"] . '">';
    283  if ($optioncss != '')
    284  print '<input type="hidden" name="optioncss" value="' . $optioncss . '">';
    285  print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    286  print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
    287  print '<input type="hidden" name="sortfield" value="' . $sortfield . '">';
    288  print '<input type="hidden" name="sortorder" value="' . $sortorder . '">';
    289  // message when global selection activated
    290  if ($search_all) {
    291  foreach ($fieldstosearchall as $key => $val)
    292  $fieldstosearchall[$key] = $langs->trans($val);
    293  print $langs->trans("FilterOnInto", $search_all) . join(', ', $fieldstosearchall);
    294  }
    295  // message when list not fully displayed
    296  if (! empty($moreforfilter)) {
    297  print '<div class="liste_titre liste_titre_bydiv centpercent">';
    298  print $moreforfilter;
    299  $parameters = array();
    300  $reshook = $hookmanager->executeHooks('printFieldPreListTitle', $parameters); // Note that $action and $currentPlot may have been modified by hook
    301  print $hookmanager->resPrint;
    302  print '</div>';
    303  }
    304 
    305  $varpage = empty($contextpage) ? $_SERVER["PHP_SELF"] : $contextpage;
    306  $selectedfields = $form->multiSelectArrayWithCheckbox('selectedfields', $arrayfields, $varpage); // This also change content of $arrayfields
    307 
    308  print '<table class="liste ' . ($moreforfilter ? "listwithfilterbefore" : "") . '">';
    309 
    310  // print Fields title
    311  print '<tr class="liste_titre">';
    312 
    313  if (! empty($arrayfields['t.entity']['checked']))
    314  print_liste_field_titre($arrayfields['t.entity']['label'], $_SERVER['PHP_SELF'], 't.entity', '', $param, '', $sortfield, $sortorder);
    315  if (! empty($arrayfields['t.ref']['checked']))
    316  print_liste_field_titre($arrayfields['t.ref']['label'], $_SERVER['PHP_SELF'], 't.ref', '', $param, '', $sortfield, $sortorder);
    317  if (! empty($arrayfields['t.label']['checked']))
    318  print_liste_field_titre($arrayfields['t.label']['label'], $_SERVER['PHP_SELF'], 't.label', '', $param, '', $sortfield, $sortorder);
    319  if (! empty($arrayfields['t.description']['checked']))
    320  print_liste_field_titre($arrayfields['t.description']['label'], $_SERVER['PHP_SELF'], 't.description', '', $param, '', $sortfield, $sortorder);
    321  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    322  foreach ($extrafields->attribute_label as $key => $val) {
    323  if (! empty($arrayfields["ef." . $key]['checked'])) {
    324  $align = $extrafields->getAlignFlag($key);
    325  print_liste_field_titre($extrafieldslabels[$key], $_SERVER["PHP_SELF"], "ef." . $key, "", $param, ($align ? 'align="' . $align . '"' : ''), $sortfield, $sortorder);
    326  }
    327  }
    328  }
    329  // Hook fields
    330  $parameters = array(
    331  'arrayfields' => $arrayfields
    332  );
    333  $reshook = $hookmanager->executeHooks('printFieldListTitle', $parameters); // Note that $action and $currentPlot may have been modified by hook
    334  print $hookmanager->resPrint;
    335  if (! empty($arrayfields['t.datec']['checked']))
    336  print_liste_field_titre($langs->trans("DateCreationShort"), $_SERVER["PHP_SELF"], "t.datec", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
    337  if (! empty($arrayfields['t.tms']['checked']))
    338  print_liste_field_titre($langs->trans("DateModificationShort"), $_SERVER["PHP_SELF"], "t.tms", "", $param, 'align="center" class="nowrap"', $sortfield, $sortorder);
    339  // if (! empty($arrayfields['t.status']['checked'])) print_liste_field_titre($langs->trans("Status"),$_SERVER["PHP_SELF"],"t.status","",$param,'align="center"',$sortfield,$sortorder);
    340  print_liste_field_titre($selectedfields, $_SERVER["PHP_SELF"], "", '', '', 'align="right"', $sortfield, $sortorder, 'maxwidthsearch ');
    341  print '</tr>' . "\n";
    342 
    343  // print Search Fields boxes in title
    344  print '<tr class="liste_titre">';
    345 
    346  if (! empty($arrayfields['t.entity']['checked']))
    347  print '<td class="liste_titre"><input type="text" class="flat" name="search_entity" value="' . $search_entity . '" size="10"></td>';
    348  if (! empty($arrayfields['t.ref']['checked']))
    349  print '<td class="liste_titre"><input type="text" class="flat" name="search_ref" value="' . $search_ref . '" size="10"></td>';
    350  if (! empty($arrayfields['t.label']['checked']))
    351  print '<td class="liste_titre"><input type="text" class="flat" name="search_label" value="' . $search_label . '" size="10"></td>';
    352  if (! empty($arrayfields['t.description']['checked']))
    353  print '<td class="liste_titre"><input type="text" class="flat" name="search_description" value="' . $search_description . '" size="10"></td>';
    354 
    355  // example of a combobox selection for search
    356  // if (! empty($arrayfields['t.fk_rootstock']['checked']))
    357  // print '<td class="liste_titre">' . $formvignoble->displayDicCombo('c_rootstock', 'rootstook', $search_fk_rootstock, 'search_fk_rootstock', true) . '</td>';
    358 
    359  // Search box for Extra fields in title
    360  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    361  foreach ($extrafields->attribute_label as $key => $val) {
    362  if (! empty($arrayfields["ef." . $key]['checked'])) {
    363  $align = $extrafields->getAlignFlag($key);
    364  $typeofextrafield = $extrafields->attribute_type[$key];
    365 
    366  print '<td class="liste_titre' . ($align ? ' ' . $align : '') . '">';
    367 
    368  if (in_array($typeofextrafield, array(
    369  'varchar',
    370  'int',
    371  'double',
    372  'select',
    373  'sellist'
    374  ))) { // print a search box
    375  // get search value if any
    376  $tmpkey = preg_replace('/search_options_/', '', $key);
    377  $value = dol_escape_htmltag($search_array_extrafields['search_options_' . $tmpkey]);
    378  $searchclass = '';
    379  switch ($typeofextrafield) {
    380  case 'select':
    381  print $extrafields->showInputField($key, $value, null, '', 'search_', searchstring);
    382  break;
    383  case 'sellist':
    384  print $extrafields->showInputField($key, $value, null, '', 'search_', searchstring);
    385  break;
    386  case 'varchar':
    387  print '<input class="flat searchstring" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    388  break;
    389  case 'int':
    390  print '<input class="flat searchnum" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    391  break;
    392  case 'double':
    393  print '<input class="flat searchnum" size="4" type="text" name="search_options_' . $tmpkey . '" value="' . $value . '">';
    394  break;
    395  }
    396  }
    397  print '</td>';
    398  }
    399  }
    400  }
    401  // Fields from hook
    402  $parameters = array(
    403  'arrayfields' => $arrayfields
    404  );
    405  $reshook = $hookmanager->executeHooks('printFieldListOption', $parameters); // Note that $action and $currentPlot may have been modified by hook
    406  print $hookmanager->resPrint;
    407  if (! empty($arrayfields['t.datec']['checked'])) {
    408  // Date creation
    409  print '<td class="liste_titre">';
    410  print '</td>';
    411  }
    412  if (! empty($arrayfields['t.tms']['checked'])) {
    413  // Date modification
    414  print '<td class="liste_titre">';
    415  print '</td>';
    416  }
    417  /*
    418  * if (! empty($arrayfields['u.statut']['checked']))
    419  * {
    420  * // Status
    421  * print '<td class="liste_titre" align="center">';
    422  * print $form->selectarray('search_statut', array('-1'=>'','0'=>$langs->trans('Disabled'),'1'=>$langs->trans('Enabled')),$search_statut);
    423  * print '</td>';
    424  * }
    425  */
    426  // Action column in list title
    427  print '<td class="liste_titre" align="right">';
    428  print '<input type="image" class="liste_titre" name="button_search" src="' . img_picto($langs->trans("Search"), 'search.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("Search")) . '" title="' . dol_escape_htmltag($langs->trans("Search")) . '">';
    429  print '<input type="image" class="liste_titre" name="button_removefilter" src="' . img_picto($langs->trans("Search"), 'searchclear.png', '', '', 1) . '" value="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '" title="' . dol_escape_htmltag($langs->trans("RemoveFilter")) . '">';
    430  print '</td>';
    431  print '</tr>' . "\n";
    432  /*
    433  * Fetch the result set and print lines
    434  */
    435  $i = 0;
    436  while ($i < $num) {
    437  $obj = $db->fetch_object($resql);
    438  if ($obj) {
    439  print '<tr>';
    440  $plot->fetch($obj->rowid);
    441  if (! empty($arrayfields['t.entity']['checked']))
    442  print '<td>' . $obj->entity . '</td>';
    443  if (! empty($arrayfields['t.ref']['checked']))
    444  print '<td>' . $plot->getNomUrl(1) . '</td>';
    445  if (! empty($arrayfields['t.label']['checked']))
    446  print '<td>' . $obj->label . '</td>';
    447  if (! empty($arrayfields['t.description']['checked']))
    448  print '<td>' . $obj->description . '</td>';
    449  // Extra fields
    450  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    451  foreach ($extrafields->attribute_label as $key => $val) {
    452  if (! empty($arrayfields["ef." . $key]['checked'])) {
    453  print '<td';
    454  $align = $extrafields->getAlignFlag($key);
    455  if ($align)
    456  print ' align="' . $align . '"';
    457  print '>';
    458  $tmpkey = 'options_' . $key;
    459  print $extrafields->showOutputField($key, $obj->$tmpkey, '', 1);
    460  print '</td>';
    461  }
    462  }
    463  }
    464  // Fields from hook
    465  $parameters = array(
    466  'arrayfields' => $arrayfields,
    467  'obj' => $obj
    468  );
    469  $reshook = $hookmanager->executeHooks('printFieldListValue', $parameters); // Note that $action and $currentPlot may have been modified by hook
    470  print $hookmanager->resPrint;
    471  // Date creation
    472  if (! empty($arrayfields['t.datec']['checked'])) {
    473  print '<td align="center">';
    474  print dol_print_date($db->jdate($obj->date_creation), 'dayhour');
    475  print '</td>';
    476  }
    477  // Date modification
    478  if (! empty($arrayfields['t.tms']['checked'])) {
    479  print '<td align="center">';
    480  print dol_print_date($db->jdate($obj->date_update), 'dayhour');
    481  print '</td>';
    482  }
    483  // Status
    484  /*
    485  * if (! empty($arrayfields['u.statut']['checked']))
    486  * {
    487  * $userstatic->statut=$obj->statut;
    488  * print '<td align="center">'.$userstatic->getLibStatut(3).'</td>';
    489  * }
    490  */
    491  // Action column
    492  // TODO check if example of action column exist
    493  print '<td></td>';
    494  print '</tr>';
    495  }
    496  $i ++;
    497  }
    498 
    499  $db->free($resql);
    500 
    501  $parameters = array(
    502  'sql' => $sql
    503  );
    504  $reshook = $hookmanager->executeHooks('printFieldListFooter', $parameters); // Note that $action and $currentPlot may have been modified by hook
    505  print $hookmanager->resPrint;
    506 
    507  print "</table>\n";
    508  print "</form>\n";
    509 
    510  $db->free($result);
    511 } else {
    512  $error ++;
    513  dol_print_error($db);
    514 }
    515 
    516 // End of page
    517 llxFooter();
    518 $db->close();
    519 
    530 {
    531  $arrayfields['t.ref'] = array(
    532  'label' => $langs->trans("Fieldref"),
    533  'checked' => 1
    534  );
    535  $arrayfields['t.label'] = array(
    536  'label' => $langs->trans("Fieldlabel"),
    537  'checked' => 1
    538  );
    539  $arrayfields['t.description'] = array(
    540  'label' => $langs->trans("Fielddescription"),
    541  'checked' => 0
    542  );
    543  // add extrafields attributes and labels
    544  if (is_array($extrafields->attribute_label) && count($extrafields->attribute_label)) {
    545  foreach ($extrafields->attribute_label as $key => $val) {
    546  $arrayfields["ef." . $key] = array(
    547  'label' => $extrafields->attribute_label[$key],
    548  'checked' => $extrafields->attribute_list[$key],
    549  'position' => $extrafields->attribute_pos[$key],
    550  'enabled' => $extrafields->attribute_perms[$key]
    551  );
    552  }
    553  }
    554  $arrayfields['t.entity'] = array(
    555  'label' => $langs->trans("Entity"),
    556  'checked' => 1,
    557  'enabled' => (! empty($conf->multicompany->enabled) && empty($conf->multicompany->transverse_mode))
    558  );
    559  $arrayfields['t.datec'] = array(
    560  'label' => $langs->trans("DateCreation"),
    561  'checked' => 0,
    562  'position' => 500
    563  );
    564  $arrayfields['t.tms'] = array(
    565  'label' => $langs->trans("DateModificationShort"),
    566  'checked' => 0,
    567  'position' => 500
    568  );
    569 
    570  return $arrayfields;
    571 }
    572 
    576 function addJQuery()
    577 {
    578  print '<script type="text/javascript" language="javascript">
    579  jQuery(document).ready(function() {
    580  function init_myfunc()
    581  {
    582  jQuery("#myid").removeAttr(\'disabled\');
    583  jQuery("#myid").attr(\'disabled\',\'disabled\');
    584  }
    585  init_myfunc();
    586  jQuery("#mybutton").click(function() {
    587  init_myfunc();
    588  });
    589  });
    590  </script>';
    591 }
    592 
    593 
    594 
    $socid
    Definition: plot_list.php:82
    global $user
    Dolibarr current user properties.
    $backtopage
    Definition: plot_list.php:53
    +
    print $_SERVER['PHP_SELF']
    +
    $currentPlot
    Definition: plot_info.php:62
    $search_description
    Definition: plot_list.php:59
    $reshook
    Definition: plot_list.php:126
    $title
    Definition: plot_list.php:175
    $sortfield
    Definition: plot_list.php:67
    +
    $fieldstosearchall
    Definition: plot_list.php:105
    $extrafieldslabels
    Definition: plot_list.php:98
    $formvignoble
    Definition: plot_list.php:171
    @@ -87,7 +90,7 @@
    $search_ref
    Definition: plot_list.php:57
    $arrayfields
    Definition: plot_list.php:115
    $page
    Definition: plot_list.php:69
    -
    Class plot.
    Definition: plot.class.php:39
    +
    Class plot.
    Definition: plot.class.php:40
    $plot
    Definition: plot_list.php:172
    $pagenext
    Definition: plot_list.php:75
    $extrafields
    Definition: plot_list.php:96
    @@ -98,6 +101,7 @@
    $sortorder
    Definition: plot_list.php:68
    $search_all
    Definition: plot_list.php:61
    $myparam
    Definition: plot_list.php:54
    +
    print $_SESSION['newtoken']
    if($page==-1) $offset
    Definition: plot_list.php:73
    $search_label
    Definition: plot_list.php:58
    $search_array_extrafields
    Definition: plot_list.php:99
    @@ -105,14 +109,13 @@
    $form
    Definition: plot_list.php:170
    global $langs
    Dolibarr languages table including user language.
    print
    Definition: plot_info.php:73
    -
    $result
    Definition: plot_notes.php:52
    $script_file
    global $conf
    Dolibarr configuration variable.
    global $db
    Dolibarr Database environment.
    $sql
    Definition: plot_list.php:179
    $nbtotalofrecords
    Definition: plot_list.php:243
    - +
    $resql
    Definition: plot_list.php:256
    $parameters
    ACTIONS
    Definition: plot_list.php:125
    @@ -121,7 +124,7 @@
    -Go to the documentation of this file.
    1 <?php
    2 /* <one line to give the program's name and a brief idea of what it does.>
    3  * Copyright (C) 2016- Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    4  *
    5  * This program is free software: you can redistribute it and/or modify
    6  * it under the terms of the GNU General Public License as published by
    7  * the Free Software Foundation, either version 3 of the License, or
    8  * (at your option) any later version.
    9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 
    33 {
    37  public $results = array();
    38 
    42  public $resprints;
    43 
    47  public $errors = array();
    48 
    52  public function __construct()
    53  {
    54  }
    55 
    63  function addSearchEntry()
    64  {
    65  global $search_boxvalue;
    66  global $langs;
    67 
    68  $this->results[] = array('img'=>'object_plot@vignoble', 'label'=>$langs->trans("Plots"), 'text'=>img_picto('','object_plot@vignoble','style="width:14px"').' '.$langs->trans("Plots"), 'url'=>dol_buildpath('/vignoble/plot_list.php',1).'?mainmenu=vignoble&sall='.urlencode($search_boxvalue));
    69 
    70  return 0;
    71  }
    72 
    82  public function doActions($parameters, &$object, &$action, $hookmanager)
    83  {
    84  $error = 0; // Error counter
    85  $myvalue = 'test'; // A result value
    86 
    87  print_r($parameters);
    88  echo "action: " . $action;
    89  print_r($object);
    90 
    91  if (in_array('somecontext', explode(':', $parameters['context'])))
    92  {
    93  // do something only for the context 'somecontext'
    94  }
    95 
    96  if (! $error)
    97  {
    98  $this->results = array('myreturn' => $myvalue);
    99  $this->resprints = 'A text to show';
    100  return 0; // or return 1 to replace standard code
    101  }
    102  else
    103  {
    104  $this->errors[] = 'Error message';
    105  return -1;
    106  }
    107  }
    108 }
    Class ActionsVignoble define the hooks provided with the module.
    -
    $object
    Definition: plot_card.php:81
    +Go to the documentation of this file.
    1 <?php
    2 /* <one line to give the program's name and a brief idea of what it does.>
    3  * Copyright (C) 2016- Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    4  *
    5  * This program is free software: you can redistribute it and/or modify
    6  * it under the terms of the GNU General Public License as published by
    7  * the Free Software Foundation, either version 3 of the License, or
    8  * (at your option) any later version.
    9  *
    10  * This program is distributed in the hope that it will be useful,
    11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    13  * GNU General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU General Public License
    16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    17  */
    18 
    33 {
    37  public $results = array();
    38 
    42  public $resprints;
    43 
    47  public $errors = array();
    48 
    52  public function __construct()
    53  {
    54  }
    55 
    63  function addSearchEntry()
    64  {
    65  global $search_boxvalue;
    66  global $langs;
    67 
    68  $this->results[] = array('img'=>'object_plot@vignoble', 'label'=>$langs->trans("Plots"), 'text'=>img_picto('','object_plot@vignoble','style="width:14px"').' '.$langs->trans("Plots"), 'url'=>dol_buildpath('/vignoble/plot_list.php',1).'?mainmenu=vignoble&sall='.urlencode($search_boxvalue));
    69 
    70  return 0;
    71  }
    72 
    82  public function doActions($parameters, &$object, &$action, $hookmanager)
    83  {
    84  $error = 0; // Error counter
    85  $myvalue = 'test'; // A result value
    86 
    87  print_r($parameters);
    88  echo "action: " . $action;
    89  print_r($object);
    90 
    91  if (in_array('somecontext', explode(':', $parameters['context'])))
    92  {
    93  // do something only for the context 'somecontext'
    94  }
    95 
    96  if (! $error)
    97  {
    98  $this->results = array('myreturn' => $myvalue);
    99  $this->resprints = 'A text to show';
    100  return 0; // or return 1 to replace standard code
    101  }
    102  else
    103  {
    104  $this->errors[] = 'Error message';
    105  return -1;
    106  }
    107  }
    108 }
    +
    Class ActionsVignoble define the hooks provided with the module.
    __construct()
    Constructor.
    $errors
    Array collecting Errors.
    $results
    Array Hook results.
    addSearchEntry()
    Add a search entry for plot in the Dolibarr select search box.
    +
    $parameters
    Actions.
    global $langs
    Dolibarr languages table including user language.
    -
    $parameters
    ACTIONS
    Definition: plot_card.php:108
    +
    $resprints
    String displayed by executeHook() immediately after return.
    -
    $action
    Definition: plot_card.php:60
    doActions($parameters, &$object, &$action, $hookmanager)
    Overloading the doActions function : replacing the parent&#39;s function with the one below...
    @@ -88,7 +88,7 @@
    @@ -91,7 +92,7 @@
    -

    Definition at line 49 of file module_settings.php.

    +

    Definition at line 50 of file module_settings.php.

    + +

    Referenced by prepareDocumentModel().

    + +
    + + +
    +
    + + + + +
    $select_projects = $project->liste_array()
    +
    + +

    Definition at line 107 of file module_settings.php.

    @@ -223,9 +345,9 @@

    Variable Documentation

    -

    Definition at line 50 of file module_settings.php.

    +

    Definition at line 52 of file module_settings.php.

    -

    Referenced by ModelePDFPlot\liste_modeles(), ModeleVignoble\liste_modeles(), and printView().

    +

    Referenced by ModelePDFPlot\liste_modeles(), ModeleVignoble\liste_modeles(), prepareDocumentModel(), and printDocumentModelView().

    @@ -239,9 +361,39 @@

    Variable Documentation

    -

    Definition at line 47 of file module_settings.php.

    +

    Definition at line 48 of file module_settings.php.

    + +

    Referenced by plot\fetchAll(), modVignoble\getImports(), and prepareDocumentModel().

    + +
    + + +
    +
    + + + + +
    print n
    +
    + +

    Definition at line 99 of file module_settings.php.

    + +
    +
    + +
    +
    + + + + +
    print
    +
    + +

    Definition at line 93 of file module_settings.php.

    -

    Referenced by plot\fetchAll(), and modVignoble\getImports().

    +

    Referenced by printDocumentModelView().

    @@ -251,7 +403,7 @@

    Variable Documentation

    -Go to the documentation of this file.
    1 <?php
    2 /*
    3  * This page is for module administration
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    27 @include '../tpl/maindolibarr.inc.php';
    28 
    29 // Libraries
    30 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
    31 require_once '../lib/admin.html.lib.php';
    32 require_once '../class/plot.class.php';
    33 
    34 // Translations
    35 $langs->load("admin");
    36 $langs->load("errors");
    37 $langs->load("other");
    38 $langs->load("vignoble@vignoble");
    39 
    40 // Access control admin user only
    41 if (! $user->admin) {
    42  accessforbidden();
    43 }
    44 
    45 // Get Parameters
    46 $action = GETPOST('action', 'alpha');
    47 $value = GETPOST('value', 'alpha');
    48 $label = GETPOST('label', 'alpha');
    49 $scandir = GETPOST('scandir', 'alpha');
    50 $type = 'plot';
    51 
    60 if ($action == 'specimen') {
    61  $modele = GETPOST('module', 'alpha');
    62 
    63  $plot = new Plot($db);
    64  $plot->initAsSpecimen();
    65 
    66  // Search template files
    67  $file = '';
    68  $classname = '';
    69  $filefound = 0;
    70  $dirmodels = array_merge(array(
    71  '/'
    72  ), (array) $conf->modules_parts['models']);
    73  foreach ($dirmodels as $reldir) {
    74  $file = dol_buildpath('/vignoble/core/modules/vignoble/doc/pdf_' . $modele . ".modules.php", 0);
    75  if (file_exists($file)) {
    76  $filefound = 1;
    77  $classname = "pdf_" . $modele;
    78  break;
    79  }
    80  }
    81 
    82  if ($filefound) {
    83  require_once $file;
    84 
    85  $module = new $classname($db);
    86 
    87  if ($module->write_file($plot, $langs) > 0) {
    88  header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=vignoble&file=SPECIMEN.pdf");
    89  return;
    90  } else {
    91  setEventMessages($module->error, null, 'errors');
    92  dol_syslog($module->error, LOG_ERR);
    93  }
    94  } else {
    95  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
    96  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
    97  }
    98 }
    99 
    100 // Activate a model
    101 else
    102  if ($action == 'set') {
    103  $ret = addDocumentModel($value, $type, $label, $scandir);
    104  }
    105 
    106  else
    107  if ($action == 'del') {
    108  $ret = delDocumentModel($value, $type);
    109  if ($ret > 0) {
    110  if ($conf->global->PLOT_ADDON_PDF == "$value")
    111  dolibarr_del_const($db, 'PLOT_ADDON_PDF', $conf->entity);
    112  }
    113  }
    114 
    115  // Set default model
    116  else
    117  if ($action == 'setdoc') {
    118  if (dolibarr_set_const($db, "PLOT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
    119  // The constant that was read before the new set
    120  // We therefore requires a variable to have a coherent view
    121  $conf->global->PLOT_ADDON_PDF = $value;
    122  }
    123 
    124  // On active le modele
    125  $ret = delDocumentModel($value, $type);
    126  if ($ret > 0) {
    127  $ret = addDocumentModel($value, $type, $label, $scandir);
    128  }
    129  }
    130 
    135 $dirmodels = array_merge(array(
    136  '/'
    137 ), (array) $conf->modules_parts['models']);
    138 
    140 
    145 {
    146  global $db, $conf, $dirmodels;
    147 
    148  $form = new Form($db);
    149  beginForm('settings','VignobleSetup');
    150 
    151  /*
    152  * Document templates generators
    153  */
    154  $type = 'plot';
    155 
    156  print load_fiche_titre($langs->trans("PlotModelModule"), '', '');
    157 
    158  // Load array def with activated templates
    159  $def = array();
    160  $sql = "SELECT nom";
    161  $sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
    162  $sql .= " WHERE type = '" . $type . "'";
    163  $sql .= " AND entity = " . $conf->entity;
    164  $resql = $db->query($sql);
    165  if ($resql) {
    166  $i = 0;
    167  $num_rows = $db->num_rows($resql);
    168  while ($i < $num_rows) {
    169  $array = $db->fetch_array($resql);
    170  array_push($def, $array[0]);
    171  $i ++;
    172  }
    173  } else {
    174  dol_print_error($db);
    175  }
    176 
    177  print "<table class=\"noborder\" width=\"100%\">\n";
    178  print "<tr class=\"liste_titre\">\n";
    179  print '<td>' . $langs->trans("Name") . '</td>';
    180  print '<td>' . $langs->trans("Description") . '</td>';
    181  print '<td align="center" width="60">' . $langs->trans("Status") . "</td>\n";
    182  print '<td align="center" width="60">' . $langs->trans("Default") . "</td>\n";
    183  print '<td align="center" width="38">' . $langs->trans("ShortInfo") . '</td>';
    184  print '<td align="center" width="38">' . $langs->trans("Preview") . '</td>';
    185  print "</tr>\n";
    186 
    187  clearstatcache();
    188 
    189  $var = true;
    190  foreach ($dirmodels as $reldir) {
    191  foreach (array(
    192  '',
    193  '/doc'
    194  ) as $valdir) {
    195  $dir = dol_buildpath($reldir . "core/modules/vignoble" . $valdir);
    196 
    197  if (is_dir($dir)) {
    198  $handle = opendir($dir);
    199  if (is_resource($handle)) {
    200  while (($file = readdir($handle)) !== false) {
    201  $filelist[] = $file;
    202  }
    203  closedir($handle);
    204  arsort($filelist);
    205 
    206  foreach ($filelist as $file) {
    207  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
    208 
    209  if (file_exists($dir . '/' . $file)) {
    210  $name = substr($file, 4, dol_strlen($file) - 16);
    211  $classname = substr($file, 0, dol_strlen($file) - 12);
    212 
    213  require_once $dir . '/' . $file;
    214  $module = new $classname($db);
    215 
    216  $modulequalified = 1;
    217  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
    218  $modulequalified = 0;
    219  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
    220  $modulequalified = 0;
    221 
    222  if ($modulequalified) {
    223  $var = ! $var;
    224  print '<tr ' . $bc[$var] . '><td width="100">';
    225  print(empty($module->name) ? $name : $module->name);
    226  print "</td><td>\n";
    227  if (method_exists($module, 'info'))
    228  print $module->info($langs);
    229  else
    230  print $module->description;
    231  print '</td>';
    232 
    233  // Active
    234  if (in_array($name, $def)) {
    235  print '<td align="center">' . "\n";
    236  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=del&value=' . $name . '">';
    237  print img_picto($langs->trans("Enabled"), 'switch_on');
    238  print '</a>';
    239  print '</td>';
    240  } else {
    241  print '<td align="center">' . "\n";
    242  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=set&value=' . $name . '&amp;scandir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
    243  print "</td>";
    244  }
    245 
    246  // Default
    247  print '<td align="center">';
    248  if ($conf->global->PLOT_ADDON_PDF == $name) {
    249  print img_picto($langs->trans("Default"), 'on');
    250  } else {
    251  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setdoc&value=' . $name . '&amp;scandir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
    252  }
    253  print '</td>';
    254 
    255  // Info
    256  $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name;
    257  $htmltooltip .= '<br>' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown"));
    258  if ($module->type == 'pdf') {
    259  $htmltooltip .= '<br>' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur;
    260  }
    261  $htmltooltip .= '<br><br><u>' . $langs->trans("FeaturesSupported") . ':</u>';
    262  $htmltooltip .= '<br>' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1);
    263  $htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
    264  $htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
    265  $htmltooltip .= '<br>' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1);
    266  // $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
    267  // $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
    268  $htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
    269 
    270  print '<td align="center">';
    271  print $form->textwithpicto('', $htmltooltip, 1, 0);
    272  print '</td>';
    273 
    274  // Preview
    275  print '<td align="center">';
    276  if ($module->type == 'pdf') {
    277  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=specimen&module=' . $name . '">' . img_object($langs->trans("Preview"), 'bill') . '</a>';
    278  } else {
    279  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
    280  }
    281  print '</td>';
    282 
    283  print "</tr>\n";
    284  }
    285  }
    286  }
    287  }
    288  }
    289  }
    290  }
    291  }
    292 
    293  print '</table>';
    294  print "<br>";
    295 
    296  endForm();
    297 }
    298 
    299 
    300 
    301 
    global $user
    Dolibarr current user properties.
    -
    if($action== 'specimen') else if($action== 'set') else if($action== 'del') else if($action== 'setdoc') $dirmodels
    Process Actions.
    -
    $scandir
    -
    printView($langs, $user)
    Generate and print the view.
    +Go to the documentation of this file.
    1 <?php
    2 /*
    3  * This page is for module administration
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    26 @include '../tpl/maindolibarr.inc.php';
    27 
    28 // Libraries
    29 require_once DOL_DOCUMENT_ROOT . "/core/lib/admin.lib.php";
    30 require_once DOL_DOCUMENT_ROOT . "/projet/class/project.class.php";
    31 require_once '../lib/admin.html.lib.php';
    32 require_once '../class/plot.class.php';
    33 
    34 // Translations
    35 $langs->load("admin");
    36 $langs->load("errors");
    37 $langs->load("other");
    38 $langs->load("vignoble@vignoble");
    39 $langs->load("projet");
    40 
    41 // Access control admin user only
    42 if (! $user->admin) {
    43  accessforbidden();
    44 }
    45 
    46 // Get Parameters
    47 $action = GETPOST('action', 'alpha');
    48 $value = GETPOST('value', 'alpha');
    49 $label = GETPOST('label', 'alpha');
    50 $scandir = GETPOST('scandir', 'alpha');
    51 
    52 $type = 'plot';
    56 if ($action) {
    57  $db->begin();
    58  $res = 0;
    59  if ($action == 'setModuleParam') {
    60  $cultivationproject = GETPOST('cultivationproject', 'int');
    61  if ($cultivationproject) {
    62  $res = dolibarr_set_const($db, "VIGNOBLE_CULTIVATIONPROJECT", $cultivationproject, 'int', 0, '', $conf->entity);
    63  if (! $res > 0)
    64  $error ++;
    65  }
    66  }
    67 
    68  //$dirmodels = prepareDocumentModel($action, $value, $label, $type, $scandir);
    69 
    70  if (! $res > 0)
    71  $error ++;
    72 
    73  if (! $error) {
    74  $db->commit();
    75  setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
    76  } else {
    77  $db->rollback();
    78  setEventMessages($langs->trans("Error"), null, 'errors');
    79  }
    80 }
    81 
    85 $form = new Form($db);
    86 beginForm('settings', 'VignobleSetup');
    87 
    88 // print "<br>";
    89 print load_fiche_titre($langs->trans("Options"), '', '');
    90 
    91 print '<form method="POST" action="' . $_SERVER['PHP_SELF'] . '">';
    92 print '<input type="hidden" name="token" value="' . $_SESSION['newtoken'] . '">';
    93 print '<input type="hidden" name="action" value="setModuleParam">';
    94 
    95 print '<table class="noborder" width="100%">';
    96 print '<tr class="liste_titre">';
    97 print '<td>' . $langs->trans("Parameters") . '</td>' . "\n";
    98 print '<td align="right" width="60">' . $langs->trans("Value") . '</td>' . "\n";
    99 print '<td width="80">&nbsp;</td></tr>' . "\n";
    100 
    102 if (! empty($conf->global->VIGNOBLE_CULTIVATIONPROJECT)) {
    103  $current_project = dolibarr_get_const($db, "VIGNOBLE_CULTIVATIONPROJECT", $conf->entity);
    104 }
    105 $project = new Project($db);
    106 
    107 $select_projects = $project->liste_array();
    108 
    109 print '<tr>';
    110 print '<td>' . $langs->trans("CultivationProject") . '</td>';
    111 print '<td width="60" align="right">';
    112 
    113 print $form->selectarray("cultivationproject", $select_projects, $current_project, 1);
    114 
    115 print '</td><td align="right" rowspan="' . $rowspan . '" class="nohover">';
    116 print '<input type="submit" class="button" value="' . $langs->trans("Modify") . '">';
    117 print '</td>';
    118 print '</tr>';
    119 
    123 //printDocumentModelView($dirmodels);
    124 
    125 endForm();
    126 
    130 function printDocumentModelView($dirmodels)
    131 {
    132  Global $db, $conf, $langs, $user;
    133 
    134  /*
    135  * Document templates generators
    136  */
    137  $type = 'plot';
    138 
    139  print load_fiche_titre($langs->trans("PlotModelModule"), '', '');
    140 
    141  // Load array def with activated templates
    142  $def = array();
    143  $sql = "SELECT nom";
    144  $sql .= " FROM " . MAIN_DB_PREFIX . "document_model";
    145  $sql .= " WHERE type = '" . $type . "'";
    146  $sql .= " AND entity = " . $conf->entity;
    147  $resql = $db->query($sql);
    148  if ($resql) {
    149  $i = 0;
    150  $num_rows = $db->num_rows($resql);
    151  while ($i < $num_rows) {
    152  $array = $db->fetch_array($resql);
    153  array_push($def, $array[0]);
    154  $i ++;
    155  }
    156  } else {
    157  dol_print_error($db);
    158  }
    159 
    160  print "<table class=\"noborder\" width=\"100%\">\n";
    161  print "<tr class=\"liste_titre\">\n";
    162  print '<td>' . $langs->trans("Name") . '</td>';
    163  print '<td>' . $langs->trans("Description") . '</td>';
    164  print '<td align="center" width="60">' . $langs->trans("Status") . "</td>\n";
    165  print '<td align="center" width="60">' . $langs->trans("Default") . "</td>\n";
    166  print '<td align="center" width="38">' . $langs->trans("ShortInfo") . '</td>';
    167  print '<td align="center" width="38">' . $langs->trans("Preview") . '</td>';
    168  print "</tr>\n";
    169 
    170  clearstatcache();
    171 
    172  $var = true;
    173  foreach ($dirmodels as $reldir) {
    174  foreach (array(
    175  '',
    176  '/doc'
    177  ) as $valdir) {
    178  $dir = dol_buildpath($reldir . "core/modules/vignoble" . $valdir);
    179 
    180  if (is_dir($dir)) {
    181  $handle = opendir($dir);
    182  if (is_resource($handle)) {
    183  while (($file = readdir($handle)) !== false) {
    184  $filelist[] = $file;
    185  }
    186  closedir($handle);
    187  arsort($filelist);
    188 
    189  foreach ($filelist as $file) {
    190  if (preg_match('/\.modules\.php$/i', $file) && preg_match('/^(pdf_|doc_)/', $file)) {
    191 
    192  if (file_exists($dir . '/' . $file)) {
    193  $name = substr($file, 4, dol_strlen($file) - 16);
    194  $classname = substr($file, 0, dol_strlen($file) - 12);
    195 
    196  require_once $dir . '/' . $file;
    197  $module = new $classname($db);
    198 
    199  $modulequalified = 1;
    200  if ($module->version == 'development' && $conf->global->MAIN_FEATURES_LEVEL < 2)
    201  $modulequalified = 0;
    202  if ($module->version == 'experimental' && $conf->global->MAIN_FEATURES_LEVEL < 1)
    203  $modulequalified = 0;
    204 
    205  if ($modulequalified) {
    206  $var = ! $var;
    207  print '<tr ' . $bc[$var] . '><td width="100">';
    208  print(empty($module->name) ? $name : $module->name);
    209  print "</td><td>\n";
    210  if (method_exists($module, 'info'))
    211  print $module->info($langs);
    212  else
    213  print $module->description;
    214  print '</td>';
    215 
    216  // Active
    217  if (in_array($name, $def)) {
    218  print '<td align="center">' . "\n";
    219  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=del&value=' . $name . '">';
    220  print img_picto($langs->trans("Enabled"), 'switch_on');
    221  print '</a>';
    222  print '</td>';
    223  } else {
    224  print '<td align="center">' . "\n";
    225  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=set&value=' . $name . '&amp;scandir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '">' . img_picto($langs->trans("Disabled"), 'switch_off') . '</a>';
    226  print "</td>";
    227  }
    228 
    229  // Default
    230  print '<td align="center">';
    231  if ($conf->global->PLOT_ADDON_PDF == $name) {
    232  print img_picto($langs->trans("Default"), 'on');
    233  } else {
    234  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=setdoc&value=' . $name . '&amp;scandir=' . $module->scandir . '&amp;label=' . urlencode($module->name) . '" alt="' . $langs->trans("Default") . '">' . img_picto($langs->trans("Disabled"), 'off') . '</a>';
    235  }
    236  print '</td>';
    237 
    238  // Info
    239  $htmltooltip = '' . $langs->trans("Name") . ': ' . $module->name;
    240  $htmltooltip .= '<br>' . $langs->trans("Type") . ': ' . ($module->type ? $module->type : $langs->trans("Unknown"));
    241  if ($module->type == 'pdf') {
    242  $htmltooltip .= '<br>' . $langs->trans("Width") . '/' . $langs->trans("Height") . ': ' . $module->page_largeur . '/' . $module->page_hauteur;
    243  }
    244  $htmltooltip .= '<br><br><u>' . $langs->trans("FeaturesSupported") . ':</u>';
    245  $htmltooltip .= '<br>' . $langs->trans("Logo") . ': ' . yn($module->option_logo, 1, 1);
    246  $htmltooltip .= '<br>' . $langs->trans("PaymentMode") . ': ' . yn($module->option_modereg, 1, 1);
    247  $htmltooltip .= '<br>' . $langs->trans("PaymentConditions") . ': ' . yn($module->option_condreg, 1, 1);
    248  $htmltooltip .= '<br>' . $langs->trans("MultiLanguage") . ': ' . yn($module->option_multilang, 1, 1);
    249  // $htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
    250  // $htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
    251  $htmltooltip .= '<br>' . $langs->trans("WatermarkOnDraftOrders") . ': ' . yn($module->option_draft_watermark, 1, 1);
    252 
    253  print '<td align="center">';
    254  print $form->textwithpicto('', $htmltooltip, 1, 0);
    255  print '</td>';
    256 
    257  // Preview
    258  print '<td align="center">';
    259  if ($module->type == 'pdf') {
    260  print '<a href="' . $_SERVER["PHP_SELF"] . '?action=specimen&module=' . $name . '">' . img_object($langs->trans("Preview"), 'bill') . '</a>';
    261  } else {
    262  print img_object($langs->trans("PreviewNotAvailable"), 'generic');
    263  }
    264  print '</td>';
    265 
    266  print "</tr>\n";
    267  }
    268  }
    269  }
    270  }
    271  }
    272  }
    273  }
    274  }
    275 
    276  print '</table>';
    277  print "<br>";
    278 }
    279 
    284 {
    285  Global $db, $conf, $langs, $user;
    294  if ($action == 'specimen') {
    295  $modele = GETPOST('module', 'alpha');
    296 
    297  $plot = new Plot($db);
    298  $plot->initAsSpecimen();
    299 
    300  // Search template files
    301  $file = '';
    302  $classname = '';
    303  $filefound = 0;
    304  $dirmodels = array_merge(array(
    305  '/'
    306  ), (array) $conf->modules_parts['models']);
    307  foreach ($dirmodels as $reldir) {
    308  $file = dol_buildpath('/vignoble/core/modules/vignoble/doc/pdf_' . $modele . ".modules.php", 0);
    309  if (file_exists($file)) {
    310  $filefound = 1;
    311  $classname = "pdf_" . $modele;
    312  break;
    313  }
    314  }
    315 
    316  if ($filefound) {
    317  require_once $file;
    318 
    319  $module = new $classname($db);
    320 
    321  if ($module->write_file($plot, $langs) > 0) {
    322  header("Location: " . DOL_URL_ROOT . "/document.php?modulepart=vignoble&file=SPECIMEN.pdf");
    323  return;
    324  } else {
    325  setEventMessages($module->error, null, 'errors');
    326  dol_syslog($module->error, LOG_ERR);
    327  }
    328  } else {
    329  setEventMessages($langs->trans("ErrorModuleNotFound"), null, 'errors');
    330  dol_syslog($langs->trans("ErrorModuleNotFound"), LOG_ERR);
    331  }
    332  }
    333 
    334  // Activate a model
    335  else
    336  if ($action == 'set') {
    337  $ret = addDocumentModel($value, $type, $label, $scandir);
    338  }
    339 
    340  else
    341  if ($action == 'del') {
    342  $ret = delDocumentModel($value, $type);
    343  if ($ret > 0) {
    344  if ($conf->global->PLOT_ADDON_PDF == "$value")
    345  dolibarr_del_const($db, 'PLOT_ADDON_PDF', $conf->entity);
    346  }
    347  }
    348 
    349  // Set default model
    350  else
    351  if ($action == 'setdoc') {
    352  if (dolibarr_set_const($db, "PLOT_ADDON_PDF", $value, 'chaine', 0, '', $conf->entity)) {
    353  // The constant that was read before the new set
    354  // We therefore requires a variable to have a coherent view
    355  $conf->global->PLOT_ADDON_PDF = $value;
    356  }
    357 
    358  // On active le modele
    359  $ret = delDocumentModel($value, $type);
    360  if ($ret > 0) {
    361  $ret = addDocumentModel($value, $type, $label, $scandir);
    362  }
    363  }
    364 
    369  $dirmodels = array_merge(array(
    370  '/'
    371  ), (array) $conf->modules_parts['models']);
    372  return $dirmodels;
    373 }
    374 
    375 
    376 
    global $user
    Dolibarr current user properties.
    + +
    print $_SERVER['PHP_SELF']
    +
    $scandir
    beginForm($currentTab, $page_title="Vignoble Setup")
    Display begining of card form including :
    - +
    $plot
    Definition: plot_list.php:172
    endForm()
    Perform all required operations to end properly a card form.
    -
    if(!$user->admin) $action
    +
    $select_projects
    +
    if($action) $form
    Process actions.
    +
    if(!$user->admin) $action
    +
    print $_SESSION['newtoken']
    global $langs
    Dolibarr languages table including user language.
    -
    print
    Definition: plot_info.php:73
    +
    global $conf
    Dolibarr configuration variable.
    global $db
    Dolibarr Database environment.
    $sql
    Definition: plot_list.php:179
    - - +
    printDocumentModelView($dirmodels)
    Generate and print the document model view.
    + + +
    if(!empty($conf->global->VIGNOBLE_CULTIVATIONPROJECT)) $project
    +
    $resql
    Definition: plot_list.php:256
    -
    $form
    Definition: plot_card.php:266
    +
    prepareDocumentModel($action, $value, $label, $type, $scandir)
    prepare Document Model Actions
    @@ -87,6 +87,9 @@ file  plot.class.php  CRUD class file for the Plot object (Create/Read/Update/Delete)
      +file  plotcultivationtask.class.php + CRUD class file for the Plot Cultivation Task object (Create/Read/Update/Delete).

    Detailed Description

    List of module components group for doxygen documentation.

    @@ -96,7 +99,7 @@ - +
    - +
    * if = $db->plimit($conf->liste_limit + 1, $offset)if($ref== '')
    @@ -225,7 +225,7 @@
    -Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    31 @include './tpl/maindolibarr.inc.php';
    32 
    33 require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
    34 // require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
    35 // require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
    36 dol_include_once('/vignoble/class/plot.class.php');
    37 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    38 // if (!$user->rights->commande->lire) accessforbidden();
    39 
    40 // $langs->load("orders");
    41 $langs->load("vignoble@vignoble");
    42 
    43 // Security check
    44 // $socid=0;
    45 $id = GETPOST("id", 'int');
    46 $ref = GETPOST("ref", 'alpha');
    47 if ($ref == '') {
    48  $ref=null;
    49 }
    50 ;
    51 // if ($user->societe_id) $socid=$user->societe_id;
    52 // $result=restrictedArea($user,'commande',$comid,'');
    53 
    54 /*
    55  * View
    56  */
    57 llxHeader('', $langs->trans('PlotCardTitle'));
    58 
    59 $form = new Form($db);
    61 
    63 
    64 $currentPlot->loadObject($id, $ref, true);
    65 
    66 $currentPlot->info($id, $ref);
    67 $form = new Form($db);
    70 dol_fiche_head($head, 'info', $langs->trans("Plot"), 0, 'plot@vignoble');
    71 
    72 $formvignoble->printObjectRef($form, $langs, $currentPlot);
    73 print '<table width="100%"><tr><td>';
    74 dol_print_object_info($currentPlot,1);
    75 print '</td></tr></table>';
    76 
    77 print '</div>';
    78 
    79 llxFooter();
    80 $db->close();
    $currentPlot
    Definition: plot_info.php:62
    +Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2005-2006 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@capnetworks.com>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    31 @include './tpl/maindolibarr.inc.php';
    32 
    33 require_once DOL_DOCUMENT_ROOT . '/core/lib/functions2.lib.php';
    34 // require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
    35 // require_once DOL_DOCUMENT_ROOT.'/core/lib/order.lib.php';
    36 dol_include_once('/vignoble/class/plot.class.php');
    37 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    38 // if (!$user->rights->commande->lire) accessforbidden();
    39 
    40 // $langs->load("orders");
    41 $langs->load("vignoble@vignoble");
    42 
    43 // Security check
    44 // $socid=0;
    45 $id = GETPOST("id", 'int');
    46 $ref = GETPOST("ref", 'alpha');
    47 if ($ref == '') {
    48  $ref=null;
    49 }
    50 ;
    51 // if ($user->societe_id) $socid=$user->societe_id;
    52 // $result=restrictedArea($user,'commande',$comid,'');
    53 
    54 /*
    55  * View
    56  */
    57 llxHeader('', $langs->trans('PlotCardTitle'));
    58 
    59 $form = new Form($db);
    61 
    63 
    64 $currentPlot->loadObject($id, $ref, true);
    65 
    66 $currentPlot->info($id, $ref);
    67 $form = new Form($db);
    70 dol_fiche_head($head, 'info', $langs->trans("Plot"), 0, 'plot@vignoble');
    71 
    72 $formvignoble->printObjectRef($form, $langs, $currentPlot);
    73 print '<table width="100%"><tr><td>';
    74 dol_print_object_info($currentPlot,1);
    75 print '</td></tr></table>';
    76 
    77 print '</div>';
    78 
    79 llxFooter();
    80 $db->close();
    $currentPlot
    Definition: plot_info.php:62
    $formvignoble
    Definition: plot_info.php:60
    -
    Class plot.
    Definition: plot.class.php:39
    +
    Class plot.
    Definition: plot.class.php:40
    $ref
    Definition: plot_info.php:46
    $head
    Definition: plot_info.php:69
    Class to build HTML component for third parties management Only common components are here...
    @@ -87,7 +87,7 @@ @@ -212,7 +208,7 @@
    @@ -189,8 +185,6 @@

    Definition at line 266 of file plot_card.php.

    -

    Referenced by FormVignoble\printObjectRef(), and printView().

    -
    @@ -247,8 +241,6 @@

    Definition at line 58 of file plot_card.php.

    -

    Referenced by plot\create(), plot\delete(), plot\fetch(), plot\info(), plot\loadObject(), and plot\update().

    - @@ -263,8 +255,6 @@

    Definition at line 81 of file plot_card.php.

    -

    Referenced by pdf_plotabc\_pagefoot(), pdf_plotabc\_pagehead(), pdf_plotabc\_tableau_info(), pdf_plotabc\_tableau_tot(), plot\createFromClone(), ActionsVignoble\doActions(), FormVignoble\getTabsHeader(), FormVignoble\printObjectRef(), and pdf_plotabc\write_file().

    - @@ -283,8 +273,6 @@

    Definition at line 108 of file plot_card.php.

    -

    Referenced by ActionsVignoble\doActions(), and pdf_plotabc\write_file().

    - @@ -313,8 +301,6 @@

    Definition at line 109 of file plot_card.php.

    -

    Referenced by pdf_plotabc\write_file().

    - @@ -323,7 +309,7 @@
    -Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    29 // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
    30 // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
    31 // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
    32 // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
    33 // if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
    34 // if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
    35 // if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
    36 // if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
    37 // if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
    38 // if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
    39 // if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
    40 @include './tpl/maindolibarr.inc.php';
    41 
    42 // load mobule libraries
    43 dol_include_once('/vignoble/class/plot.class.php');
    44 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    45 
    46 // load Dolibarr libraries
    47 include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
    48 include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
    49 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
    50 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
    51 
    52 // Load traductions files requiredby by page
    53 $langs->load("vignoble@vignoble");
    54 // Dolibarr language file @TODO document usage of file other
    55 $langs->load("other");
    56 
    57 // Get parameters
    58 $id = GETPOST('id', 'int'); // object row id
    59 $ref = GETPOST('ref', 'alpha'); // object unique reference
    60 $action = GETPOST('action', 'alpha'); // action to do
    61 $ref = GETPOST('ref', 'alpha');
    62 if ($ref == '') {
    63  $ref = NULL;
    64 } // NEEDED else your record will never be populated when ref is empty !!!
    65 
    66 // echo 'URL param ';var_dump($id);var_dump($ref);var_dump($action);echo '<br />';
    67 $backtopage = GETPOST('backtopage'); // page to redirect when process is done
    68  // add your own parameters like this
    69  // $myparam = GETPOST('myparam','alpha');
    70 
    71 // Prevent direct access through URL
    72 if ($user->socid > 0 || $user->rights->vignoble->level1->level2 == 0) {
    73  // accessforbidden();
    74 }
    75 
    76 if (empty($action) && empty($id) && empty($ref))
    77  $action = 'view';
    78 
    79  // Load object if id or ref is provided as parameter
    80  // echo 'Before object fetch id ';var_dump($id);echo '$ref ';var_dump($ref);echo '$action ';var_dump($action);echo '<br />';
    81 $object = new plot($db);
    82 $extrafields = new ExtraFields($db);
    83 // fetch optionals attributes and labels
    84 $extrafieldslabels = $extrafields->fetch_name_optionals_label($object->table_element);
    85 
    86 // TODO create a function that populate the object when objet id or ref is provided and object is not loaded
    87 if (($id > 0 || ! empty($ref)) && $action != 'add') { // $action should not be there
    88  $result = $object->fetch($id, $ref);
    89  // echo 'After object fetch ';echo '$id ';var_dump($id);echo '$ref ';var_dump($ref);echo '$object ';var_dump($object);echo '<br />';
    90  $id = $object->id; // NEEDED else view is not displayed when only ref is provided
    91  if ($result < 0)
    92  dol_print_error($db);
    93 }
    94 
    95 // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
    96 $hookmanager->initHooks(array(
    97  'plot'
    98 ));
    99 
    108 $parameters = array();
    109 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
    110 if ($reshook < 0)
    111  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    112 
    113 if (empty($reshook)) {
    114  // Action to add record
    115  if ($action == 'add') {
    116  if (GETPOST('cancel')) {
    117  $urltogo = $backtopage ? $backtopage : dol_buildpath('/vignoble/plot_list.php', 1);
    118  header("Location: " . $urltogo);
    119  exit();
    120  }
    121 
    122  $error = 0;
    123 
    124  /* object_prop_getpost_prop */
    125 
    126  $object->entity = $conf->entity;
    127  $object->ref = GETPOST('ref', 'alpha');
    128  $object->label = GETPOST('label', 'alpha');
    129  $object->description = dol_htmlcleanlastbr(GETPOST('description'));
    130  $object->fk_user_author = $user->id;
    131  $object->fk_user_modif = $user->id;
    132 
    133  if (empty($object->ref)) {
    134  $error ++;
    135  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
    136  }
    137 
    138  // Get extrafields values
    139  $ret = $extrafields->setOptionalsFromPost($extrafieldslabels, $object);
    140  if ($ret < 0)
    141  $error ++;
    142 
    143  if (! $error) {
    144  $result = $object->create($user);
    145  if ($result > 0) {
    146  // Creation OK
    147  $urltogo = $backtopage ? $backtopage : dol_buildpath('/vignoble/plot_list.php', 1);
    148  header("Location: " . $urltogo);
    149  exit();
    150  }
    151  {
    152  // Creation KO
    153  setEventMessages($object->error, $object->errors, 'errors');
    154  $action = 'create';
    155  }
    156  } else {
    157  $action = 'create';
    158  }
    159  }
    160 
    161  // Cancel
    162  if ($action == 'update' && GETPOST('cancel'))
    163  $action = 'view';
    164 
    165  // Action to update record
    166  if ($action == 'update' && ! GETPOST('cancel')) {
    167  $error = 0;
    168 
    169  $object->id = GETPOST('id', 'int');
    170  $object->ref = GETPOST('ref', 'alpha');
    171  $object->label = GETPOST('label', 'alpha');
    172  //$object->description = GETPOST('description', 'alpha');
    173  $object->description = dol_htmlcleanlastbr(GETPOST('description'));
    174  //
    175  if (empty($object->ref)) {
    176  $error ++;
    177  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
    178  }
    179  // Fill array 'array_options' with data from add form
    180  $ret = $extrafields->setOptionalsFromPost($extrafieldslabels, $object);
    181  if ($ret < 0)
    182  $error ++;
    183 
    184  if (! $error) {
    185  $result = $object->update($user);
    186  if ($result > 0) {
    187  $action = 'view';
    188  } else {
    189  // Creation KO
    190  if (! empty($object->errors))
    191  setEventMessages(null, $object->errors, 'errors');
    192  else
    193  setEventMessages($object->error, null, 'errors');
    194  $action = 'edit';
    195  }
    196  } else {
    197  $action = 'edit';
    198  }
    199  }
    200 
    201  // Action to delete
    202  if ($action == 'confirm_delete') {
    203  $result = $object->delete($user);
    204  if ($result > 0) {
    205  // Delete OK
    206  setEventMessages("RecordDeleted", null, 'mesgs');
    207  header("Location: " . dol_buildpath('/vignoble/plot_list.php', 1));
    208  exit();
    209  } else {
    210  if (! empty($object->errors))
    211  setEventMessages(null, $object->errors, 'errors');
    212  else
    213  setEventMessages($object->error, null, 'errors');
    214  }
    215  }
    216 
    217  if ($action == 'builddoc') {
    218  // Save last template used to generate document
    219  if (GETPOST('model'))
    220  $object->setDocModel($user, GETPOST('model', 'alpha'));
    221 
    222  // Define output language
    223  $outputlangs = $langs;
    224  $newlang = '';
    225  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
    226  $newlang = $_REQUEST['lang_id'];
    227  if (! empty($newlang)) {
    228  $outputlangs = new Translate("", $conf);
    229  $outputlangs->setDefaultLang($newlang);
    230  }
    231  $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
    232  if ($result <= 0) {
    233  setEventMessages($object->error, $object->errors, 'errors');
    234  $action = '';
    235  }
    236  $action = '';
    237  }
    238 
    239  // Remove file in doc form
    240  if ($action == 'remove_file') {
    241  if ($object->id > 0) {
    242  require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    243 
    244  $langs->load("other");
    245  $upload_dir = $conf->vignoble->dir_output;
    246  $file = $upload_dir . '/' . GETPOST('file');
    247  $ret = dol_delete_file($file, 0, 0, 0, $object);
    248  if ($ret)
    249  setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
    250  else
    251  setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
    252  $action = '';
    253  }
    254  }
    255 }
    256 
    264 llxHeader('', $langs->trans('PlotCardTitle'), '');
    265 
    266 $form = new Form($db);
    268 $formfile = new FormFile($db);
    269 $formactions = new FormActions($db);
    270 
    271 
    272 
    276 if ($action == 'create') {
    277  print load_fiche_titre($langs->trans("NewPlot"), '', 'object_plot@vignoble');
    278 
    279  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
    280  print '<input type="hidden" name="action" value="add">';
    281  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
    282 
    283  dol_fiche_head();
    284  print '<table class="border centpercent">' . "\n";
    285 
    286  print '<tr><td class="fieldrequired">' . $langs->trans("Fieldref") . '</td><td>';
    287  print '<input class="flat" type="text" name="ref" value="' . GETPOST('ref') . '">';
    288  print '</td></tr>';
    289 
    290  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>';
    291  print '<input class="flat" type="text" name="label" value="' . GETPOST('label') . '">';
    292  print '</td></tr>';
    293 
    294  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Description") . '</td><td>';
    295  $doleditor = new DolEditor('description', GETPOST('description'),'', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '99%');
    296  $doleditor->Create();
    297  print "</td></tr>";
    298 
    299  if (! empty($extrafields->attribute_label)) {
    300  print $object->showOptionals($extrafields, 'edit', $parameters);
    301  }
    302 
    303  print '</table>' . "\n";
    304 
    305  dol_fiche_end();
    306 
    307  print '<div class="center"><input type="submit" class="button" name="add" value="' . $langs->trans("Create") . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
    308 
    309  print '</form>';
    310 }
    311 
    315 if (($id || $ref) && $action == 'edit') {
    316  print load_fiche_titre($langs->trans("EditPlot"), $object->label, 'object_plot@vignoble');
    317 
    318  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
    319  print '<input type="hidden" name="action" value="update">';
    320  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
    321  print '<input type="hidden" name="id" value="' . $object->id . '">';
    322 
    323  dol_fiche_head();
    324  print '<table class="border centpercent">' . "\n";
    325 
    326  print '<tr><td class="fieldrequired">' . $langs->trans("Fieldref") . '</td><td>';
    327  print '<input class="flat" type="text" name="ref" value="' . $object->ref . '">';
    328  print '</td></tr>';
    329 
    330  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>';
    331  print '<input class="flat" type="text" name="label" value="' . $object->label . '">';
    332  print '</td></tr>';
    333 
    334  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Description") . '</td><td>';
    335  $doleditor = new DolEditor('description', $object->description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '(50%');
    336  $doleditor->Create();
    337  print "</td></tr>";
    338 
    339  if (! empty($extrafields->attribute_label)) {
    340  print $object->showOptionals($extrafields, 'edit', $parameters);
    341  }
    342  print '</table>';
    343 
    344  dol_fiche_end();
    345 
    346  print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
    347  print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
    348  print '</div>';
    349 
    350  print '</form>';
    351 }
    352 
    356 if (empty($action) || $action == 'view' || $action == 'delete') {
    361  $head = $formvignoble->getTabsHeader($langs, $object);
    362  dol_fiche_head($head, 'card', $langs->trans("Plot"), 0, 'plot@vignoble');
    363 
    364  if ($action == 'delete') {
    365  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
    366  print $formconfirm;
    367  }
    368 
    369  print '<table class="border centpercent">' . "\n";
    370 
    371  $linkback = '<a href="' . dol_buildpath('/vignoble/plot_list.php', 1) . '">' . $langs->trans("BackToList") . '</a>';
    372 
    373  // Ref
    374  print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td>';
    375  print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
    376  print '</td></tr>';
    377  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>' . $object->label . '</td></tr>';
    378  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Fielddescription") . '</td><td>' .(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)). '</td></tr>';
    379  if (! empty($extrafields->attribute_label)) {
    380  print $object->showOptionals($extrafields, 'view', $parameters);
    381  }
    382  print '</table>';
    383 
    384  dol_fiche_end();
    385 
    389  print '<div class="tabsAction">' . "\n";
    390  $parameters = array();
    391  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
    392  if ($reshook < 0)
    393  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    394 
    395  if (empty($reshook)) {
    396  if ($user->rights->vignoble->plot->create) {
    397  print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Modify") . '</a></div>' . "\n";
    398  } else {
    399  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Modify') . '</a></div>' . "\n";
    400  }
    401 
    402  if ($user->rights->vignoble->plot->delete) {
    403  print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>' . "\n";
    404  } else {
    405  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Delete') . '</a></div>' . "\n";
    406  }
    407  }
    408  print '</div>' . "\n";
    409 
    413  print '<div class="fichecenter">'; // global frame
    414  print '<div class="fichehalfleft">'; // left column
    418 // print 'Generated Documentss<br/>';
    419 // $ref = dol_sanitizeFileName($object->ref);
    420 // $file = $conf->vignoble->dir_output . '/' . $ref . '/' . $ref . '.pdf';
    421 // $relativepath = $ref . '/' . $ref . '.pdf';
    422 // $filedir = $conf->vignoble->dir_output . '/' . $ref;
    423 // $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
    424 // $genallowed = $user->rights->vignoble->plot->create;
    425 // $delallowed = $user->rights->vignoble->plot->delete;
    426 // $somethingshown = $formfile->show_documents('vignoble', $ref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
    427 
    428  print '</div>';// left column end
    429  print '<div class="fichehalfright">'; //right column
    433 // print '<div class="ficheaddleft">';
    434 // print 'Linked Orders/Invoice<br/>';
    435 // $linktoelem = $form->showLinkToObjectBlock($object,array());
    436 // $somethingshown=$form->showLinkedObjectBlock($object,$linktoelem);
    437 // print '</div>';
    441 // print '<div class="ficheaddleft">';
    442 // print 'Linked Events<br/>';
    443 // include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
    444 // $formactions = new FormActions($db);
    445 // $somethingshown = $formactions->showactions($object, 'plot', $user->socid,1);
    446 // print '</div>';
    447  print '</div>'; //right column end
    448  print '</div>'; //fichecenter
    449 }
    450 
    451 // End of page
    452 llxFooter();
    453 $db->close();
    454 
    455 
    global $user
    Dolibarr current user properties.
    +Go to the documentation of this file.
    1 <?php
    2 /*
    3  * Copyright (C) 2007-2015 Laurent Destailleur <eldy@users.sourceforge.net>
    4  * Copyright (C) 2016 Bruno GĂ©nĂ©rĂ© <bgenere@webiseasy.org>
    5  *
    6  * This program 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 3 of the License, or
    9  * (at your option) any later version.
    10  *
    11  * This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
    18  */
    19 
    29 // if (! defined('NOREQUIREUSER')) define('NOREQUIREUSER','1');
    30 // if (! defined('NOREQUIREDB')) define('NOREQUIREDB','1');
    31 // if (! defined('NOREQUIRESOC')) define('NOREQUIRESOC','1');
    32 // if (! defined('NOREQUIRETRAN')) define('NOREQUIRETRAN','1');
    33 // if (! defined('NOCSRFCHECK')) define('NOCSRFCHECK','1'); // Do not check anti CSRF attack test
    34 // if (! defined('NOSTYLECHECK')) define('NOSTYLECHECK','1'); // Do not check style html tag into posted data
    35 // if (! defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL','1'); // Do not check anti POST attack test
    36 // if (! defined('NOREQUIREMENU')) define('NOREQUIREMENU','1'); // If there is no need to load and show top and left menu
    37 // if (! defined('NOREQUIREHTML')) define('NOREQUIREHTML','1'); // If we don't need to load the html.form.class.php
    38 // if (! defined('NOREQUIREAJAX')) define('NOREQUIREAJAX','1');
    39 // if (! defined("NOLOGIN")) define("NOLOGIN",'1'); // If this page is public (can be called outside logged session)
    40 @include './tpl/maindolibarr.inc.php';
    41 
    42 // load mobule libraries
    43 dol_include_once('/vignoble/class/plot.class.php');
    44 dol_include_once('/vignoble/class/html.form.vignoble.class.php');
    45 
    46 // load Dolibarr libraries
    47 include_once DOL_DOCUMENT_ROOT . '/core/class/extrafields.class.php';
    48 include_once DOL_DOCUMENT_ROOT . '/core/class/doleditor.class.php';
    49 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formfile.class.php';
    50 include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
    51 
    52 // Load traductions files requiredby by page
    53 $langs->load("vignoble@vignoble");
    54 // Dolibarr language file @TODO document usage of file other
    55 $langs->load("other");
    56 
    57 // Get parameters
    58 $id = GETPOST('id', 'int'); // object row id
    59 $ref = GETPOST('ref', 'alpha'); // object unique reference
    60 $action = GETPOST('action', 'alpha'); // action to do
    61 $ref = GETPOST('ref', 'alpha');
    62 if ($ref == '') {
    63  $ref = NULL;
    64 } // NEEDED else your record will never be populated when ref is empty !!!
    65 
    66 // echo 'URL param ';var_dump($id);var_dump($ref);var_dump($action);echo '<br />';
    67 $backtopage = GETPOST('backtopage'); // page to redirect when process is done
    68  // add your own parameters like this
    69  // $myparam = GETPOST('myparam','alpha');
    70 
    71 // Prevent direct access through URL
    72 if ($user->socid > 0 || $user->rights->vignoble->level1->level2 == 0) {
    73  // accessforbidden();
    74 }
    75 
    76 if (empty($action) && empty($id) && empty($ref))
    77  $action = 'view';
    78 
    79  // Load object if id or ref is provided as parameter
    80  // echo 'Before object fetch id ';var_dump($id);echo '$ref ';var_dump($ref);echo '$action ';var_dump($action);echo '<br />';
    81 $object = new plot($db);
    82 $extrafields = new ExtraFields($db);
    83 // fetch optionals attributes and labels
    84 $extrafieldslabels = $extrafields->fetch_name_optionals_label($object->table_element);
    85 
    86 // TODO create a function that populate the object when objet id or ref is provided and object is not loaded
    87 if (($id > 0 || ! empty($ref)) && $action != 'add') { // $action should not be there
    88  $result = $object->fetch($id, $ref);
    89  // echo 'After object fetch ';echo '$id ';var_dump($id);echo '$ref ';var_dump($ref);echo '$object ';var_dump($object);echo '<br />';
    90  $id = $object->id; // NEEDED else view is not displayed when only ref is provided
    91  if ($result < 0)
    92  dol_print_error($db);
    93 }
    94 
    95 // Initialize technical object to manage hooks of modules. Note that conf->hooks_modules contains array array
    96 $hookmanager->initHooks(array(
    97  'plot'
    98 ));
    99 
    108 $parameters = array();
    109 $reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some hooks
    110 if ($reshook < 0)
    111  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    112 
    113 if (empty($reshook)) {
    114  // Action to add record
    115  if ($action == 'add') {
    116  if (GETPOST('cancel')) {
    117  $urltogo = $backtopage ? $backtopage : dol_buildpath('/vignoble/plot_list.php', 1);
    118  header("Location: " . $urltogo);
    119  exit();
    120  }
    121 
    122  $error = 0;
    123 
    124  /* object_prop_getpost_prop */
    125 
    126  $object->entity = $conf->entity;
    127  $object->ref = GETPOST('ref', 'alpha');
    128  $object->label = GETPOST('label', 'alpha');
    129  $object->description = dol_htmlcleanlastbr(GETPOST('description'));
    130  $object->fk_user_author = $user->id;
    131  $object->fk_user_modif = $user->id;
    132 
    133  if (empty($object->ref)) {
    134  $error ++;
    135  setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
    136  }
    137 
    138  // Get extrafields values
    139  $ret = $extrafields->setOptionalsFromPost($extrafieldslabels, $object);
    140  if ($ret < 0)
    141  $error ++;
    142 
    143  if (! $error) {
    144  $result = $object->create($user);
    145  if ($result > 0) {
    146  // Creation OK
    147  $urltogo = $backtopage ? $backtopage : dol_buildpath('/vignoble/plot_list.php', 1);
    148  header("Location: " . $urltogo);
    149  exit();
    150  }
    151  {
    152  // Creation KO
    153  setEventMessages($object->error, $object->errors, 'errors');
    154  $action = 'create';
    155  }
    156  } else {
    157  $action = 'create';
    158  }
    159  }
    160 
    161  // Cancel
    162  if ($action == 'update' && GETPOST('cancel'))
    163  $action = 'view';
    164 
    165  // Action to update record
    166  if ($action == 'update' && ! GETPOST('cancel')) {
    167  $error = 0;
    168 
    169  $object->id = GETPOST('id', 'int');
    170  $object->ref = GETPOST('ref', 'alpha');
    171  $object->label = GETPOST('label', 'alpha');
    172  //$object->description = GETPOST('description', 'alpha');
    173  $object->description = dol_htmlcleanlastbr(GETPOST('description'));
    174  //
    175  if (empty($object->ref)) {
    176  $error ++;
    177  setEventMessages($langs->transnoentitiesnoconv("ErrorFieldRequired", $langs->transnoentitiesnoconv("Ref")), null, 'errors');
    178  }
    179  // Fill array 'array_options' with data from add form
    180  $ret = $extrafields->setOptionalsFromPost($extrafieldslabels, $object);
    181  if ($ret < 0)
    182  $error ++;
    183 
    184  if (! $error) {
    185  $result = $object->update($user);
    186  if ($result > 0) {
    187  $action = 'view';
    188  } else {
    189  // Creation KO
    190  if (! empty($object->errors))
    191  setEventMessages(null, $object->errors, 'errors');
    192  else
    193  setEventMessages($object->error, null, 'errors');
    194  $action = 'edit';
    195  }
    196  } else {
    197  $action = 'edit';
    198  }
    199  }
    200 
    201  // Action to delete
    202  if ($action == 'confirm_delete') {
    203  $result = $object->delete($user);
    204  if ($result > 0) {
    205  // Delete OK
    206  setEventMessages("RecordDeleted", null, 'mesgs');
    207  header("Location: " . dol_buildpath('/vignoble/plot_list.php', 1));
    208  exit();
    209  } else {
    210  if (! empty($object->errors))
    211  setEventMessages(null, $object->errors, 'errors');
    212  else
    213  setEventMessages($object->error, null, 'errors');
    214  }
    215  }
    216 
    217  if ($action == 'builddoc') {
    218  // Save last template used to generate document
    219  if (GETPOST('model'))
    220  $object->setDocModel($user, GETPOST('model', 'alpha'));
    221 
    222  // Define output language
    223  $outputlangs = $langs;
    224  $newlang = '';
    225  if ($conf->global->MAIN_MULTILANGS && empty($newlang) && ! empty($_REQUEST['lang_id']))
    226  $newlang = $_REQUEST['lang_id'];
    227  if (! empty($newlang)) {
    228  $outputlangs = new Translate("", $conf);
    229  $outputlangs->setDefaultLang($newlang);
    230  }
    231  $result = $object->generateDocument($object->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
    232  if ($result <= 0) {
    233  setEventMessages($object->error, $object->errors, 'errors');
    234  $action = '';
    235  }
    236  $action = '';
    237  }
    238 
    239  // Remove file in doc form
    240  if ($action == 'remove_file') {
    241  if ($object->id > 0) {
    242  require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
    243 
    244  $langs->load("other");
    245  $upload_dir = $conf->vignoble->dir_output;
    246  $file = $upload_dir . '/' . GETPOST('file');
    247  $ret = dol_delete_file($file, 0, 0, 0, $object);
    248  if ($ret)
    249  setEventMessages($langs->trans("FileWasRemoved", GETPOST('file')), null, 'mesgs');
    250  else
    251  setEventMessages($langs->trans("ErrorFailToDeleteFile", GETPOST('file')), null, 'errors');
    252  $action = '';
    253  }
    254  }
    255 }
    256 
    264 llxHeader('', $langs->trans('PlotCardTitle'), '');
    265 
    266 $form = new Form($db);
    268 $formfile = new FormFile($db);
    269 $formactions = new FormActions($db);
    270 
    271 
    272 
    276 if ($action == 'create') {
    277  print load_fiche_titre($langs->trans("NewPlot"), '', 'object_plot@vignoble');
    278 
    279  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
    280  print '<input type="hidden" name="action" value="add">';
    281  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
    282 
    283  dol_fiche_head();
    284  print '<table class="border centpercent">' . "\n";
    285 
    286  print '<tr><td class="fieldrequired">' . $langs->trans("Fieldref") . '</td><td>';
    287  print '<input class="flat" type="text" name="ref" value="' . GETPOST('ref') . '">';
    288  print '</td></tr>';
    289 
    290  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>';
    291  print '<input class="flat" type="text" name="label" value="' . GETPOST('label') . '">';
    292  print '</td></tr>';
    293 
    294  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Description") . '</td><td>';
    295  $doleditor = new DolEditor('description', GETPOST('description'),'', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '99%');
    296  $doleditor->Create();
    297  print "</td></tr>";
    298 
    299  if (! empty($extrafields->attribute_label)) {
    300  print $object->showOptionals($extrafields, 'edit', $parameters);
    301  }
    302 
    303  print '</table>' . "\n";
    304 
    305  dol_fiche_end();
    306 
    307  print '<div class="center"><input type="submit" class="button" name="add" value="' . $langs->trans("Create") . '"> &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '"></div>';
    308 
    309  print '</form>';
    310 }
    311 
    315 if (($id || $ref) && $action == 'edit') {
    316  print load_fiche_titre($langs->trans("EditPlot"), $object->label, 'object_plot@vignoble');
    317 
    318  print '<form method="POST" action="' . $_SERVER["PHP_SELF"] . '">';
    319  print '<input type="hidden" name="action" value="update">';
    320  print '<input type="hidden" name="backtopage" value="' . $backtopage . '">';
    321  print '<input type="hidden" name="id" value="' . $object->id . '">';
    322 
    323  dol_fiche_head();
    324  print '<table class="border centpercent">' . "\n";
    325 
    326  print '<tr><td class="fieldrequired">' . $langs->trans("Fieldref") . '</td><td>';
    327  print '<input class="flat" type="text" name="ref" value="' . $object->ref . '">';
    328  print '</td></tr>';
    329 
    330  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>';
    331  print '<input class="flat" type="text" name="label" value="' . $object->label . '">';
    332  print '</td></tr>';
    333 
    334  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Description") . '</td><td>';
    335  $doleditor = new DolEditor('description', $object->description, '', 160, 'dolibarr_notes', '', false, true, $conf->global->FCKEDITOR_ENABLE_SOCIETE, ROWS_4, '(50%');
    336  $doleditor->Create();
    337  print "</td></tr>";
    338 
    339  if (! empty($extrafields->attribute_label)) {
    340  print $object->showOptionals($extrafields, 'edit', $parameters);
    341  }
    342  print '</table>';
    343 
    344  dol_fiche_end();
    345 
    346  print '<div class="center"><input type="submit" class="button" name="save" value="' . $langs->trans("Save") . '">';
    347  print ' &nbsp; <input type="submit" class="button" name="cancel" value="' . $langs->trans("Cancel") . '">';
    348  print '</div>';
    349 
    350  print '</form>';
    351 }
    352 
    356 if (empty($action) || $action == 'view' || $action == 'delete') {
    361  $head = $formvignoble->getTabsHeader($langs, $object);
    362  dol_fiche_head($head, 'card', $langs->trans("Plot"), 0, 'plot@vignoble');
    363 
    364  if ($action == 'delete') {
    365  $formconfirm = $form->formconfirm($_SERVER["PHP_SELF"] . '?id=' . $object->id, $langs->trans('DeleteMyOjbect'), $langs->trans('ConfirmDeleteMyObject'), 'confirm_delete', '', 0, 1);
    366  print $formconfirm;
    367  }
    368 
    369  print '<table class="border centpercent">' . "\n";
    370 
    371  $linkback = '<a href="' . dol_buildpath('/vignoble/plot_list.php', 1) . '">' . $langs->trans("BackToList") . '</a>';
    372 
    373  // Ref
    374  print '<tr><td class="titlefield">' . $langs->trans("Ref") . '</td><td>';
    375  print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
    376  print '</td></tr>';
    377  print '<tr><td>' . $langs->trans("Fieldlabel") . '</td><td>' . $object->label . '</td></tr>';
    378  print '<tr><td class="tdtop" width="25%">' . $langs->trans("Fielddescription") . '</td><td>' .(dol_textishtml($object->description)?$object->description:dol_nl2br($object->description,1,true)). '</td></tr>';
    379  if (! empty($extrafields->attribute_label)) {
    380  print $object->showOptionals($extrafields, 'view', $parameters);
    381  }
    382  print '</table>';
    383 
    384  dol_fiche_end();
    385 
    389  print '<div class="tabsAction">' . "\n";
    390  $parameters = array();
    391  $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been modified by hook
    392  if ($reshook < 0)
    393  setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
    394 
    395  if (empty($reshook)) {
    396  if ($user->rights->vignoble->plot->create) {
    397  print '<div class="inline-block divButAction"><a class="butAction" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=edit">' . $langs->trans("Modify") . '</a></div>' . "\n";
    398  } else {
    399  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Modify') . '</a></div>' . "\n";
    400  }
    401 
    402  if ($user->rights->vignoble->plot->delete) {
    403  print '<div class="inline-block divButAction"><a class="butActionDelete" href="' . $_SERVER["PHP_SELF"] . '?id=' . $object->id . '&amp;action=delete">' . $langs->trans('Delete') . '</a></div>' . "\n";
    404  } else {
    405  print '<div class="inline-block divButAction"><a class="butActionRefused" href="#">' . $langs->trans('Delete') . '</a></div>' . "\n";
    406  }
    407  }
    408  print '</div>' . "\n";
    409 
    413  print '<div class="fichecenter">'; // global frame
    414  print '<div class="fichehalfleft">'; // left column
    418 // print 'Generated Documentss<br/>';
    419 // $ref = dol_sanitizeFileName($object->ref);
    420 // $file = $conf->vignoble->dir_output . '/' . $ref . '/' . $ref . '.pdf';
    421 // $relativepath = $ref . '/' . $ref . '.pdf';
    422 // $filedir = $conf->vignoble->dir_output . '/' . $ref;
    423 // $urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
    424 // $genallowed = $user->rights->vignoble->plot->create;
    425 // $delallowed = $user->rights->vignoble->plot->delete;
    426 // $somethingshown = $formfile->show_documents('vignoble', $ref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
    427 
    428  print '</div>';// left column end
    429  print '<div class="fichehalfright">'; //right column
    433 // print '<div class="ficheaddleft">';
    434 // print 'Linked Orders/Invoice<br/>';
    435 // $linktoelem = $form->showLinkToObjectBlock($object,array());
    436 // $somethingshown=$form->showLinkedObjectBlock($object,$linktoelem);
    437 // print '</div>';
    441 // print '<div class="ficheaddleft">';
    442 // print 'Linked Events<br/>';
    443 // include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
    444 // $formactions = new FormActions($db);
    445 // $somethingshown = $formactions->showactions($object, 'plot', $user->socid,1);
    446 // print '</div>';
    447  print '</div>'; //right column end
    448  print '</div>'; //fichecenter
    449 }
    450 
    451 // End of page
    452 llxFooter();
    453 $db->close();
    454 
    455 
    global $user
    Dolibarr current user properties.
    $extrafields
    Definition: plot_card.php:82
    +
    print $_SERVER['PHP_SELF']
    +
    $object
    Definition: plot_card.php:81
    $formvignoble
    Definition: plot_card.php:267
    -
    Class plot.
    Definition: plot.class.php:39
    +
    Class plot.
    Definition: plot.class.php:40
    $ref
    Definition: plot_card.php:59
    if($ref== '') $backtopage
    Definition: plot_card.php:67
    $head
    Definition: plot_info.php:69
    @@ -85,7 +87,6 @@
    global $langs
    Dolibarr languages table including user language.
    $parameters
    ACTIONS
    Definition: plot_card.php:108
    print
    Definition: plot_info.php:73
    -
    $result
    Definition: plot_notes.php:52
    global $conf
    Dolibarr configuration variable.
    $action
    Definition: plot_card.php:60
    @@ -99,7 +100,7 @@
    -Go to the documentation of this file.
    1 <?php
    2 
    3 /*
    4  * Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
    5  * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
    6  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
    7  *
    8  * This program is free software; you can redistribute it and/or modify
    9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 3 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    16  * GNU General Public License for more details.
    17  *
    18  * You should have received a copy of the GNU General Public License
    19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    20  */
    21 
    33 {
    34 
    35  var $db;
    36 
    37  var $error;
    38 
    45  function __construct($db)
    46  {
    47  $this->db = $db;
    48 
    49  return 1;
    50  }
    51 
    69  function displayDicCombo($dictable,$dicname, $selected = '', $htmlname = 'varietal_id', $useempty = false)
    70  {
    71  global $conf, $langs, $user;
    72  $langs->load("dict");
    73 
    74  $out = '';
    75 
    76  $sql = "SELECT rowid, code, label, active FROM " . MAIN_DB_PREFIX . $dictable;
    77  $sql .= " WHERE active = 1";
    78 
    79  dol_syslog("Form::select_".$dictable , LOG_DEBUG);
    80  $resql = $this->db->query($sql);
    81  if ($resql) {
    82  $out .= '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">';
    83  if ($useempty)
    84  $out .= '<option value="-1"> &nbsp;</option>';
    85  $num = $this->db->num_rows($resql);
    86  $i = 0;
    87  if ($num) {
    88  while ($i < $num) {
    89  $obj = $this->db->fetch_object($resql);
    90  if ($selected == $obj->rowid) {
    91  $out .= '<option value="' . $obj->rowid . '" selected>';
    92  } else {
    93  $out .= '<option value="' . $obj->rowid . '">';
    94  }
    95  // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
    96  $out .= ($langs->trans($dicname . $obj->code) != $dicname . $obj->code ? $langs->trans($dicname . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
    97  $out .= '</option>';
    98  $i ++;
    99  }
    100  }
    101  $out .= '</select>';
    102  if ($user->admin)
    103  $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
    104  $out .= ajax_combobox($htmlname);
    105  } else {
    106  dol_print_error($this->db);
    107  }
    108 
    109  return $out;
    110  }
    111 
    123  {
    124  $linkback = '<a href="' . dol_buildpath('/vignoble/plot_list.php', 1) . '">' . $langs->trans("BackToList") . '</a>';
    125 
    126  print '<table class="border" width="100%">';
    127  print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td colspan="3">';
    128  print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
    129  print "</td></tr>";
    130  print "</table>";
    131  }
    132 
    137  {
    138  // print load_fiche_titre($langs->trans("plot"));
    139  $head = array();
    140  $h = 0;
    141  $head[$h][0] = 'plot_card.php?id=' . $object->id;
    142  $head[$h][1] = $langs->trans("Card");
    143  $head[$h][2] = 'card';
    144  $h = 1;
    145  $head[$h][0] = 'plot_notes.php?id=' . $object->id;
    146  $head[$h][1] = $langs->trans("Notes");
    147  $head[$h][2] = 'notes';
    148  $h = 2;
    149  $head[$h][0] = 'plot_info.php?id=' . $object->id;
    150  $head[$h][1] = $langs->trans("Info");
    151  $head[$h][2] = 'info';
    152  return $head;
    153  }
    154 }
    global $user
    Dolibarr current user properties.
    -
    $object
    Definition: plot_card.php:81
    +Go to the documentation of this file.
    1 <?php
    2 
    3 /*
    4  * Copyright (C) 2008-2012 Laurent Destailleur <eldy@users.sourceforge.net>
    5  * Copyright (C) 2008-2012 Regis Houssin <regis.houssin@capnetworks.com>
    6  * Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
    7  *
    8  * This program is free software; you can redistribute it and/or modify
    9  * it under the terms of the GNU General Public License as published by
    10  * the Free Software Foundation; either version 3 of the License, or
    11  * (at your option) any later version.
    12  *
    13  * This program is distributed in the hope that it will be useful,
    14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    16  * GNU General Public License for more details.
    17  *
    18  * You should have received a copy of the GNU General Public License
    19  * along with this program. If not, see <http://www.gnu.org/licenses/>.
    20  */
    21 
    33 {
    34 
    35  var $db;
    36 
    37  var $error;
    38 
    45  function __construct($db)
    46  {
    47  $this->db = $db;
    48 
    49  return 1;
    50  }
    51 
    69  function displayDicCombo($dictable,$dicname, $selected = '', $htmlname = 'varietal_id', $useempty = false)
    70  {
    71  global $conf, $langs, $user;
    72  $langs->load("dict");
    73 
    74  $out = '';
    75 
    76  $sql = "SELECT rowid, code, label, active FROM " . MAIN_DB_PREFIX . $dictable;
    77  $sql .= " WHERE active = 1";
    78 
    79  dol_syslog("Form::select_".$dictable , LOG_DEBUG);
    80  $resql = $this->db->query($sql);
    81  if ($resql) {
    82  $out .= '<select class="flat" name="' . $htmlname . '" id="' . $htmlname . '">';
    83  if ($useempty)
    84  $out .= '<option value="-1"> &nbsp;</option>';
    85  $num = $this->db->num_rows($resql);
    86  $i = 0;
    87  if ($num) {
    88  while ($i < $num) {
    89  $obj = $this->db->fetch_object($resql);
    90  if ($selected == $obj->rowid) {
    91  $out .= '<option value="' . $obj->rowid . '" selected>';
    92  } else {
    93  $out .= '<option value="' . $obj->rowid . '">';
    94  }
    95  // Si traduction existe, on l'utilise, sinon on prend le libelle par defaut
    96  $out .= ($langs->trans($dicname . $obj->code) != $dicname . $obj->code ? $langs->trans($dicname . $obj->code) : ($obj->label != '-' ? $obj->label : ''));
    97  $out .= '</option>';
    98  $i ++;
    99  }
    100  }
    101  $out .= '</select>';
    102  if ($user->admin)
    103  $out .= info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"), 1);
    104  $out .= ajax_combobox($htmlname);
    105  } else {
    106  dol_print_error($this->db);
    107  }
    108 
    109  return $out;
    110  }
    111 
    123  {
    124  $linkback = '<a href="' . dol_buildpath('/vignoble/plot_list.php', 1) . '">' . $langs->trans("BackToList") . '</a>';
    125 
    126  print '<table class="border" width="100%">';
    127  print '<tr><td width="25%">' . $langs->trans("Ref") . '</td><td colspan="3">';
    128  print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref');
    129  print "</td></tr>";
    130  print "</table>";
    131  }
    132 
    137  {
    138  // print load_fiche_titre($langs->trans("plot"));
    139  $head = array();
    140  $h = 0;
    141  $head[$h][0] = 'plot_card.php?id=' . $object->id;
    142  $head[$h][1] = $langs->trans("Card");
    143  $head[$h][2] = 'card';
    144  $h = 1;
    145  $head[$h][0] = 'plot_notes.php?id=' . $object->id;
    146  $head[$h][1] = $langs->trans("Notes");
    147  $head[$h][2] = 'notes';
    148  $h = 2;
    149  $head[$h][0] = 'plot_info.php?id=' . $object->id;
    150  $head[$h][1] = $langs->trans("Info");
    151  $head[$h][2] = 'info';
    152  return $head;
    153  }
    154 }
    global $user
    Dolibarr current user properties.
    +
    $head
    Definition: plot_info.php:69
    __construct($db)
    Constructor.
    @@ -84,15 +84,15 @@
    printObjectRef($form, $langs, $object)
    Print the object reference with links to navigate the current list.
    $sql
    Definition: plot_list.php:179
    +
    $resql
    Definition: plot_list.php:256
    -
    $form
    Definition: plot_card.php:266