dolibarr  18.0.6
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  *
7  * This program is free software; you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation; either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <https://www.gnu.org/licenses/>.
19  */
20 
26 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
27 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
28 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
29 if (!defined('NOREQUIREAJAX')) define('NOREQUIREAJAX', '1');
30 if (!defined('NOREQUIRESOC')) define('NOREQUIRESOC', '1');
31 
32 // Load Dolibarr environment
33 require '../../main.inc.php';
34 require_once DOL_DOCUMENT_ROOT.'/societe/class/client.class.php';
35 
36 $idstatus = GETPOST('id', 'int');
37 $idprospect = GETPOST('prospectid', 'int');
38 $action = GETPOST('action', 'aZ09');
39 
40 $prospectstatic = new Client($db);
41 
42 
43 // Security check
44 if ($user->socid > 0) {
45  if ($idprospect != $user->socid) {
46  accessforbidden('Not allowed on this thirdparty');
47  }
48 }
49 
50 // var_dump( $user, 'societe', $idprospect, '&societe');
51 $result = restrictedArea($user, 'societe', $idprospect, '&societe');
52 
53 $permisstiontoupdate = $user->hasRight('societe', 'creer');
54 
55 
56 /*
57  * View
58  */
59 
60 top_httphead('application/json');
61 
62 
63 if ($action === "updatestatusprospect" && $permisstiontoupdate) {
64  $prospectstatic->client = 2;
65  $prospectstatic->loadCacheOfProspStatus();
66 
67  $response = '';
68 
69  $sql = "UPDATE ".MAIN_DB_PREFIX."societe SET ";
70  $sql .= "fk_stcomm=".(int) $db->escape($idstatus);
71  $sql .= " WHERE rowid = ".(int) $db->escape($idprospect);
72 
73  $resql = $db->query($sql);
74 
75  if (!$resql) {
76  dol_print_error($db);
77  } else {
78  $num = $db->affected_rows($resql);
79  $response = img_action('', $prospectstatic->cacheprospectstatus[$idstatus]['code'], $prospectstatic->cacheprospectstatus[$idstatus]['picto'], 'class="inline-block valignmiddle paddingright pictoprospectstatus"');
80  }
81 
82  echo json_encode(array('img' => $response));
83 }
Class to manage customers or prospects.
if(isModEnabled('facture') && $user->hasRight('facture', 'lire')) if((isModEnabled('fournisseur') &&empty($conf->global->MAIN_USE_NEW_SUPPLIERMOD) && $user->hasRight("fournisseur", "facture", "lire"))||(isModEnabled('supplier_invoice') && $user->hasRight("supplier_invoice", "lire"))) if(isModEnabled('don') && $user->hasRight('don', 'lire')) if(isModEnabled('tax') &&!empty($user->rights->tax->charges->lire)) if(isModEnabled('facture') &&isModEnabled('commande') && $user->hasRight("commande", "lire") &&empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) $sql
Social contributions to pay.
Definition: index.php:746
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
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.
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1510
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.