dolibarr 21.0.0-beta
ajaxstatusprospect.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2006 Andre Cianfarani <acianfa@free.fr>
3 * Copyright (C) 2005-2009 Regis Houssin <regis.houssin@inodbox.com>
4 * Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
5 * Copyright (C) 2010 Cyrille de Lambert <info@auguria.net>
6 * Copyright (C) 2024 Frédéric France <frederic.france@free.fr>
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 <https://www.gnu.org/licenses/>.
20 */
21
27if (!defined('NOTOKENRENEWAL')) {
28 define('NOTOKENRENEWAL', 1);
29} // Disables token renewal
30if (!defined('NOREQUIREMENU')) {
31 define('NOREQUIREMENU', '1');
32}
33if (!defined('NOREQUIREHTML')) {
34 define('NOREQUIREHTML', '1');
35}
36if (!defined('NOREQUIREAJAX')) {
37 define('NOREQUIREAJAX', '1');
38}
39if (!defined('NOREQUIRESOC')) {
40 define('NOREQUIRESOC', '1');
41}
42
43// Load Dolibarr environment
44require '../../main.inc.php';
45require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
46
55$idstatus = GETPOSTINT('id');
56$idprospect = GETPOSTINT('prospectid');
57$action = GETPOST('action', 'aZ09');
58
59$prospectstatic = new Client($db);
60
61
62// Security check
63if ($user->socid > 0) {
64 if ($idprospect != $user->socid) {
65 accessforbidden('Not allowed on this thirdparty');
66 }
67}
68
69// var_dump( $user, 'societe', $idprospect, '&societe');
70$result = restrictedArea($user, 'societe', $idprospect, '&societe');
71
72$permisstiontoupdate = $user->hasRight('societe', 'creer');
73
74
75/*
76 * View
77 */
78
79top_httphead('application/json');
80
81
82if ($action === "updatestatusprospect" && $permisstiontoupdate) {
83 $prospectstatic->client = 2;
84 $prospectstatic->loadCacheOfProspStatus();
85
86 $response = '';
87
88 $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
89 $sql .= "fk_stcomm=".(int) $db->escape($idstatus);
90 $sql .= " WHERE rowid = ".(int) $db->escape($idprospect);
91
92 $resql = $db->query($sql);
93
94 if (!$resql) {
95 dol_print_error($db);
96 } else {
97 $num = $db->affected_rows($resql);
98 $response = img_action('', $prospectstatic->cacheprospectstatus[$idstatus]['code'], $prospectstatic->cacheprospectstatus[$idstatus]['picto'], 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
99 }
100
101 echo json_encode(array('img' => $response));
102}
Class to manage customers or prospects.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
img_action($titlealt, $numaction, $picto='', $moreatt='')
Show logo action.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
dol_print_error($db=null, $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
if(!defined( 'NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.