-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcard.php
164 lines (129 loc) · 4.72 KB
/
card.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
<?php
require 'config.php';
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.form.class.php';
dol_include_once('/reloadcustom/class/reloadcustom.class.php');
dol_include_once('/reloadcustom/lib/reloadcustom.lib.php');
if(empty($user->rights->reloadcustom->read)) accessforbidden();
$langs->load('reloadcustom@reloadcustom');
$action = GETPOST('action');
$id = GETPOST('id', 'int');
$ref = GETPOST('ref');
$mode = 'view';
if (empty($user->rights->reloadcustom->write)) $mode = 'view'; // Force 'view' mode if can't edit object
else if ($action == 'create' || $action == 'edit') $mode = 'edit';
$PDOdb = new TPDOdb;
$object = new TReloadCustom;
if (!empty($id)) $object->load($PDOdb, $id);
elseif (!empty($ref)) $object->loadBy($PDOdb, $ref, 'ref');
$hookmanager->initHooks(array('reloadcustomcard', 'globalcard'));
/*
* Actions
*/
$parameters = array('id' => $id, 'ref' => $ref, 'mode' => $mode);
$reshook = $hookmanager->executeHooks('doActions', $parameters, $object, $action); // Note that $action and $object may have been modified by some
if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors');
// Si vide alors le comportement n'est pas remplacé
if (empty($reshook))
{
$error = 0;
switch ($action) {
case 'save':
$object->set_values($_REQUEST); // Set standard attributes
// $object->date_other = dol_mktime(GETPOST('starthour'), GETPOST('startmin'), 0, GETPOST('startmonth'), GETPOST('startday'), GETPOST('startyear'));
// Check parameters
// if (empty($object->date_other))
// {
// $error++;
// setEventMessages($langs->trans('warning_date_must_be_fill'), array(), 'warnings');
// }
// ...
if ($error > 0)
{
$mode = 'edit';
break;
}
$object->save($PDOdb, empty($object->ref));
header('Location: '.dol_buildpath('/reloadcustom/card.php', 1).'?id='.$object->getId());
exit;
break;
case 'confirm_clone':
$object->cloneObject($PDOdb);
header('Location: '.dol_buildpath('/reloadcustom/card.php', 1).'?id='.$object->getId());
exit;
break;
case 'modif':
if (!empty($user->rights->reloadcustom->write)) $object->setDraft($PDOdb);
break;
case 'confirm_validate':
if (!empty($user->rights->reloadcustom->write)) $object->setValid($PDOdb);
header('Location: '.dol_buildpath('/reloadcustom/card.php', 1).'?id='.$object->getId());
exit;
break;
case 'confirm_delete':
if (!empty($user->rights->reloadcustom->write)) $object->delete($PDOdb);
header('Location: '.dol_buildpath('/reloadcustom/list.php', 1));
exit;
break;
// link from llx_element_element
case 'dellink':
$object->generic->deleteObjectLinked(null, '', null, '', GETPOST('dellinkid'));
header('Location: '.dol_buildpath('/reloadcustom/card.php', 1).'?id='.$object->getId());
exit;
break;
}
}
/**
* View
*/
$title=$langs->trans("ReloadCustom");
llxHeader('',$title);
if ($action == 'create' && $mode == 'edit')
{
load_fiche_titre($langs->trans("NewReloadCustom"));
dol_fiche_head();
}
else
{
$head = reloadcustom_prepare_head($object);
$picto = 'generic';
dol_fiche_head($head, 'card', $langs->trans("ReloadCustom"), 0, $picto);
}
$formcore = new TFormCore;
$formcore->Set_typeaff($mode);
$form = new Form($db);
$formconfirm = getFormConfirm($PDOdb, $form, $object, $action);
if (!empty($formconfirm)) echo $formconfirm;
$TBS=new TTemplateTBS();
$TBS->TBS->protect=false;
$TBS->TBS->noerr=true;
if ($mode == 'edit') echo $formcore->begin_form($_SERVER['PHP_SELF'], 'form_reloadcustom');
$linkback = '<a href="'.dol_buildpath('/reloadcustom/list.php', 1).'">' . $langs->trans("BackToList") . '</a>';
print $TBS->render('tpl/card.tpl.php'
,array() // Block
,array(
'object'=>$object
,'view' => array(
'mode' => $mode
,'action' => 'save'
,'urlcard' => dol_buildpath('/reloadcustom/card.php', 1)
,'urllist' => dol_buildpath('/reloadcustom/list.php', 1)
,'showRef' => ($action == 'create') ? $langs->trans('Draft') : $form->showrefnav($object->generic, 'ref', $linkback, 1, 'ref', 'ref', '')
,'showLabel' => $formcore->texte('', 'label', $object->label, 80, 255)
// ,'showNote' => $formcore->zonetexte('', 'note', $object->note, 80, 8)
,'showStatus' => $object->getLibStatut(1)
)
,'langs' => $langs
,'user' => $user
,'conf' => $conf
,'TReloadCustom' => array(
'STATUS_DRAFT' => TReloadCustom::STATUS_DRAFT
,'STATUS_VALIDATED' => TReloadCustom::STATUS_VALIDATED
,'STATUS_REFUSED' => TReloadCustom::STATUS_REFUSED
,'STATUS_ACCEPTED' => TReloadCustom::STATUS_ACCEPTED
)
)
);
if ($mode == 'edit') echo $formcore->end_form();
if ($mode == 'view' && $object->getId()) $somethingshown = $form->showLinkedObjectBlock($object->generic);
llxFooter();