dolibarr 25.0.0-alpha
stocktransfer_contact.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2005 Patrick Rouillon <patrick@rouillon.net>
3 * Copyright (C) 2005-2016 Destailleur Laurent <eldy@users.sourceforge.net>
4 * Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
5 * Copyright (C) 2011-2015 Philippe Grand <philippe.grand@atoo-net.com>
6 * Copyright (C) 2021 Gauthier VERDOL <gauthier.verdol@atm-consulting.fr>
7 * Copyright (C) 2024-2025 Frédéric France <frederic.france@free.fr>
8 * Copyright (C) 2025 MDW <mdeweerd@users.noreply.github.com>
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22 */
23
30// Load Dolibarr environment
31require '../../../main.inc.php';
32require_once DOL_DOCUMENT_ROOT.'/core/class/html.formcompany.class.php';
33require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
34require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
35require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
36require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/class/stocktransfer.class.php';
37require_once DOL_DOCUMENT_ROOT.'/product/stock/stocktransfer/lib/stocktransfer_stocktransfer.lib.php';
38
47// Load translation files required by the page
48$langs->loadLangs(array('facture', 'orders', 'sendings', 'companies', 'stocks'));
49
50$id = GETPOSTINT('id');
51$ref = GETPOST('ref', 'alpha');
52$lineid = GETPOSTINT('lineid');
53
54$action = GETPOST('action', 'alpha');
55
57$error = 0;
58
59// Load object
60//include DOL_DOCUMENT_ROOT.'/core/actions_fetchobject.inc.php'; // Must be 'include', not 'include_once'.
61if ($id > 0 || !empty($ref)) {
62 $ret = $object->fetch($id, $ref);
63 if ($ret == 0) {
64 $langs->load("errors");
65 setEventMessages($langs->trans('ErrorRecordNotFound'), null, 'errors');
66 $error++;
67 } elseif ($ret < 0) {
68 setEventMessages($object->error, $object->errors, 'errors');
69 $error++;
70 }
71}
72if (!$error) {
73 $object->fetch_thirdparty();
74} else {
75 header('Location: '.dol_buildpath('/stocktransfer/stocktransfer_list.php', 1));
76 exit;
77}
78
79// Security check
80if ($user->socid) {
81 $socid = $user->socid;
82}
83
84
85$permissiontoread = $user->hasRight('stocktransfer', 'stocktransfer', 'read');
86$permissiontoadd = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_addupdatedelete.inc.php and actions_lineupdown.inc.php
87$permissionnote = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_setnotes.inc.php
88$permissiontodelete = $user->rights->stocktransfer->stocktransfer->delete || ($permissiontoadd && isset($object->status) && $object->status < $object::STATUS_TRANSFERED);
89$permissiondellink = $user->hasRight('stocktransfer', 'stocktransfer', 'write'); // Used by the include of actions_dellink.inc.php
90$upload_dir = $conf->stocktransfer->multidir_output[isset($object->entity) ? $object->entity : 1];
91
92// Security check - Protection if external user
93//if ($user->socid > 0) accessforbidden();
94//if ($user->socid > 0) $socid = $user->socid;
95//$isdraft = (($object->statut == $object::STATUS_DRAFT) ? 1 : 0);
96//restrictedArea($user, 'stocktransfer', $object->id, '', '', 'fk_soc', 'rowid', $isdraft);
97//restrictedArea($user, 'stocktransfer', $object->id, '', 'stocktransfer');
98
99if (!$permissiontoread || ($action === 'create' && !$permissiontoadd)) {
101}
102
103
104/*
105 * Add a new contact
106 */
107
108if ($action == 'addcontact' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) {
109 $result = -1;
110 if ($object->id > 0) {
111 $contactid = (GETPOSTINT('userid') ? GETPOSTINT('userid') : GETPOSTINT('contactid'));
112 $result = $object->add_contact($contactid, GETPOST("typecontact") ? GETPOST("typecontact") : GETPOST("type"), GETPOST("source"));
113 }
114
115 if ($result >= 0) {
116 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
117 exit;
118 } else {
119 if ($object->error == 'DB_ERROR_RECORD_ALREADY_EXISTS') {
120 $langs->load("errors");
121 setEventMessages($langs->trans("ErrorThisContactIsAlreadyDefinedAsThisType"), null, 'errors');
122 } else {
123 setEventMessages($object->error, $object->errors, 'errors');
124 }
125 }
126} elseif ($action == 'swapstatut' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) { // Toggle the status of a contact
127 if ($object->id > 0) {
128 $result = $object->swapContactStatus(GETPOSTINT('ligne'));
129 }
130} elseif ($action == 'deletecontact' && $user->hasRight('stocktransfer', 'stocktransfer', 'write')) { // Deletes a contact
131 $result = $object->delete_contact($lineid);
132
133 if ($result >= 0) {
134 header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
135 exit;
136 } else {
138 }
139}
140
141
142/*
143 * View
144 */
145
146llxHeader('', $langs->trans('ModuleStockTransferName'), 'EN:Commercial_Proposals|FR:Proposition_commerciale|ES:Presupuestos');
147
148$form = new Form($db);
149$formcompany = new FormCompany($db);
150$formother = new FormOther($db);
151
152if ($object->id > 0) {
153 $head = stocktransferPrepareHead($object);
154 print dol_get_fiche_head($head, 'contact', $langs->trans("StockTransfer"), -1, 'stock');
155
156
157 // Proposal card
158
159 $linkback = '<a href="'.DOL_URL_ROOT.'/comm/propal/list.php?restore_lastsearch_values=1'.(!empty($socid) ? '&socid='.$socid : '').'">'.$langs->trans("BackToList").'</a>';
160
161
162 $morehtmlref = '<div class="refidno">';
163 // Thirdparty
164 $morehtmlref .= empty($object->thirdparty) ? '' : $object->thirdparty->getNomUrl(1, 'customer');
165 if (!getDolGlobalInt('MAIN_DISABLE_OTHER_LINK') && $object->thirdparty->id > 0) {
166 $morehtmlref .= ' (<a href="'.DOL_URL_ROOT.'/commande/list.php?socid='.$object->thirdparty->id.'">'.$langs->trans("OtherOrders").'</a>)';
167 }
168 // Project
169 if (isModEnabled('project')) {
170 $langs->load("projects");
171 if (!empty($object->fk_project)) {
172 $morehtmlref .= '<br>';
173 $proj = new Project($db);
174 $proj->fetch($object->fk_project);
175 $morehtmlref .= $proj->getNomUrl(1);
176 if ($proj->title) {
177 $morehtmlref .= '<span class="opacitymedium"> - '.dol_escape_htmltag($proj->title).'</span>';
178 }
179 }
180 }
181 $morehtmlref .= '</div>';
182
183 dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1);
184
185 print dol_get_fiche_end();
186
187 $user->rights->stocktransfer->write = $user->hasRight('stocktransfer', 'stocktransfer', 'write');
188 // Contacts lines (modules that overwrite templates must declare this into descriptor)
189 $dirtpls = array_merge($conf->modules_parts['tpl'], array('/core/tpl'));
190 foreach ($dirtpls as $reldir) {
191 $file = dol_buildpath($reldir.'/contacts.tpl.php');
192 if (file_exists($file)) {
193 $res = @include $file;
194 if ($res) {
195 break;
196 }
197 }
198 }
199}
200
201// End of page
202llxFooter();
203$db->close();
$id
Support class for third parties, contacts, members, users or resources.
Definition account.php:47
if(! $sortfield) if(! $sortorder) $object
Definition account.php:100
llxFooter($comment='', $zone='private', $disabledoutputofmessages=0)
Empty footer.
Definition wrapper.php:91
if(!defined('NOREQUIRESOC')) if(!defined( 'NOREQUIRETRAN')) if(!defined('NOTOKENRENEWAL')) if(!defined( 'NOREQUIREMENU')) if(!defined('NOREQUIREHTML')) if(!defined( 'NOREQUIREAJAX')) llxHeader($head='', $title='', $help_url='', $target='', $disablejs=0, $disablehead=0, $arrayofjs='', $arrayofcss='', $morequerystring='', $morecssonbody='', $replacemainareaby='', $disablenofollow=0, $disablenoindex=0)
Empty header.
Definition wrapper.php:73
Class to build HTML component for third parties management Only common components are here.
Class to manage generation of HTML components Only common components must be here.
Class to help generate other html components Only common components are here.
Class to manage projects.
Class for StockTransfer.
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $conf
The main.inc.php has been included so the following variable are now defined:
if(!isModEnabled('ai')||!getDolGlobalString('AI_ASSISTANT_ENABLED')) global $db
API class for accounts.
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='', $noduplicate=0, $attop=0)
Set event messages in dol_events session object.
dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $picto='', $pictoisfullpath=0, $morehtmlright='', $morecss='', $limittoshow=0, $moretabssuffix='', $dragdropfile=0, $morecssdiv='')
Show tabs of a record.
dol_get_fiche_end($notab=0)
Return tab footer of a card.
getDolGlobalInt($key, $default=0)
Return a Dolibarr global constant int value.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0, $nodefault=0)
Return value of a param into GET or POST supervariable.
GETPOSTINT($paramname, $method=0, $nodefault=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
dol_buildpath($path, $type=0, $returnemptyifnotfound=0)
Return path of url or filesystem.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
isModEnabled($module)
Is Dolibarr module enabled.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.
stocktransferPrepareHead($object)
Prepare array of tabs for StockTransfer.