Merge remote-tracking branch 'origin/3.5' into develop
Conflicts: htdocs/core/class/html.form.class.php
This commit is contained in:
commit
7078970ed1
@ -27,12 +27,13 @@ require '../../main.inc.php';
|
|||||||
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
|
||||||
|
|
||||||
|
$langs->load("compta");
|
||||||
|
|
||||||
// Security check
|
// Security check
|
||||||
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
|
||||||
if ($user->societe_id) $socid=$user->societe_id;
|
if ($user->societe_id) $socid=$user->societe_id;
|
||||||
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
$result = restrictedArea($user, 'tax', '', '', 'charges');
|
||||||
|
|
||||||
|
|
||||||
$sortfield = GETPOST("sortfield",'alpha');
|
$sortfield = GETPOST("sortfield",'alpha');
|
||||||
$sortorder = GETPOST("sortorder",'alpha');
|
$sortorder = GETPOST("sortorder",'alpha');
|
||||||
$page = GETPOST("page",'int');
|
$page = GETPOST("page",'int');
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2011-204 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU General Public License as published by
|
* it under the terms of the GNU General Public License as published by
|
||||||
@ -73,7 +73,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
|
|||||||
if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'";
|
if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'";
|
||||||
if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'";
|
if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($town) . "%'";
|
||||||
$sql.= " ORDER BY z.zip, z.town";
|
$sql.= " ORDER BY z.zip, z.town";
|
||||||
$sql.= $db->plimit(50); // Avoid pb with bad criteria
|
$sql.= $db->plimit(100); // Avoid pb with bad criteria
|
||||||
}
|
}
|
||||||
else // Use table of third parties
|
else // Use table of third parties
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
|
|||||||
if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'";
|
if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'";
|
||||||
if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'";
|
if ($town) $sql.= " s.town LIKE '%" . $db->escape($town) . "%'";
|
||||||
$sql.= " ORDER BY s.fk_pays, s.zip, s.town";
|
$sql.= " ORDER BY s.fk_pays, s.zip, s.town";
|
||||||
$sql.= $db->plimit(50); // Avoid pb with bad criteria
|
$sql.= $db->plimit(100); // Avoid pb with bad criteria
|
||||||
}
|
}
|
||||||
|
|
||||||
//print $sql;
|
//print $sql;
|
||||||
@ -97,8 +97,8 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
|
|||||||
{
|
{
|
||||||
while ($row = $db->fetch_array($resql))
|
while ($row = $db->fetch_array($resql))
|
||||||
{
|
{
|
||||||
$country = $row['fk_country']?($langs->trans('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->trans('Country'.$row['country_code']):$row['country']):'';
|
$country = $row['fk_country']?($langs->transnoentitiesnoconv('Country'.$row['country_code'])!='Country'.$row['country_code']?$langs->transnoentitiesnoconv('Country'.$row['country_code']):$row['country']):'';
|
||||||
$county = $row['fk_county']?($langs->trans($row['county_code'])!=$row['county_code']?$langs->trans($row['county_code']):($row['county']!='-'?$row['county']:'')):'';
|
$county = $row['fk_county']?($langs->transnoentitiesnoconv($row['county_code'])!=$row['county_code']?$langs->transnoentitiesnoconv($row['county_code']):($row['county']!='-'?$row['county']:'')):'';
|
||||||
|
|
||||||
$row_array['label'] = $row['zip'].' '.$row['town'];
|
$row_array['label'] = $row['zip'].' '.$row['town'];
|
||||||
$row_array['label'] .= ($county || $country)?' (':'';
|
$row_array['label'] .= ($county || $country)?' (':'';
|
||||||
|
|||||||
@ -115,9 +115,9 @@ class box_graph_product_distribution extends ModeleBoxes
|
|||||||
if ($showpropalnb) $nbofgraph++;
|
if ($showpropalnb) $nbofgraph++;
|
||||||
if ($showordernb) $nbofgraph++;
|
if ($showordernb) $nbofgraph++;
|
||||||
|
|
||||||
$paramtitle=$langs->trans("Products").'/'.$langs->trans("Services");
|
$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
|
||||||
if (empty($conf->produit->enabled)) $paramtitle=$langs->trans("Services");
|
if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
|
||||||
if (empty($conf->service->enabled)) $paramtitle=$langs->trans("Products");
|
if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
|
||||||
|
|
||||||
$socid=empty($user->societe_id)?0:$user->societe_id;
|
$socid=empty($user->societe_id)?0:$user->societe_id;
|
||||||
$userid=0; // No filter on user creation
|
$userid=0; // No filter on user creation
|
||||||
|
|||||||
@ -181,7 +181,8 @@ $thirdpartywithuser_fields = array(
|
|||||||
'tva_intra' => array('name'=>'tva_intra','type'=>'xsd:string'),
|
'tva_intra' => array('name'=>'tva_intra','type'=>'xsd:string'),
|
||||||
// For user
|
// For user
|
||||||
'login' => array('name'=>'login','type'=>'xsd:string'),
|
'login' => array('name'=>'login','type'=>'xsd:string'),
|
||||||
'password' => array('name'=>'password','type'=>'xsd:string')
|
'password' => array('name'=>'password','type'=>'xsd:string'),
|
||||||
|
'group_id' => array('name'=>'group_id','type'=>'xsd:string')
|
||||||
);
|
);
|
||||||
|
|
||||||
//Retreive all extrafield for contact
|
//Retreive all extrafield for contact
|
||||||
@ -523,6 +524,7 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
$db->begin();
|
||||||
/*
|
/*
|
||||||
* Company creation
|
* Company creation
|
||||||
*/
|
*/
|
||||||
@ -533,6 +535,25 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
$thirdparty->town=$thirdpartywithuser['town'];
|
$thirdparty->town=$thirdpartywithuser['town'];
|
||||||
$thirdparty->country_id=$thirdpartywithuser['country_id'];
|
$thirdparty->country_id=$thirdpartywithuser['country_id'];
|
||||||
$thirdparty->country_code=$thirdpartywithuser['country_code'];
|
$thirdparty->country_code=$thirdpartywithuser['country_code'];
|
||||||
|
|
||||||
|
// find the country id by code
|
||||||
|
$langs->load("dict");
|
||||||
|
|
||||||
|
$sql = "SELECT rowid";
|
||||||
|
$sql.= " FROM ".MAIN_DB_PREFIX."c_pays";
|
||||||
|
$sql.= " WHERE active = 1";
|
||||||
|
$sql.= " AND code='".$thirdparty->country_code."'";
|
||||||
|
|
||||||
|
$resql=$db->query($sql);
|
||||||
|
if ($resql)
|
||||||
|
{
|
||||||
|
$num = $db->num_rows($resql);
|
||||||
|
if ($num)
|
||||||
|
{
|
||||||
|
$obj = $db->fetch_object($resql);
|
||||||
|
$thirdparty->country_id = $obj->rowid;
|
||||||
|
}
|
||||||
|
}
|
||||||
$thirdparty->phone=$thirdpartywithuser['phone'];
|
$thirdparty->phone=$thirdpartywithuser['phone'];
|
||||||
$thirdparty->fax=$thirdpartywithuser['fax'];
|
$thirdparty->fax=$thirdpartywithuser['fax'];
|
||||||
$thirdparty->email=$thirdpartywithuser['email'];
|
$thirdparty->email=$thirdpartywithuser['email'];
|
||||||
@ -570,6 +591,9 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
$contact->phone_pro = $thirdparty->phone;
|
$contact->phone_pro = $thirdparty->phone;
|
||||||
$contact->phone_mobile = $thirdpartywithuser['phone_mobile'];
|
$contact->phone_mobile = $thirdpartywithuser['phone_mobile'];
|
||||||
$contact->fax = $thirdparty->fax;
|
$contact->fax = $thirdparty->fax;
|
||||||
|
$contact->statut = 1;
|
||||||
|
$contact->country_id = $thirdparty->country_id;
|
||||||
|
$contact->country_code = $thirdparty->country_code;
|
||||||
|
|
||||||
//Retreive all extrafield for thirdsparty
|
//Retreive all extrafield for thirdsparty
|
||||||
// fetch optionals attributes and labels
|
// fetch optionals attributes and labels
|
||||||
@ -591,33 +615,29 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
$edituser = new User($db);
|
$edituser = new User($db);
|
||||||
$db->begin();
|
|
||||||
|
|
||||||
$id = $edituser->create_from_contact($contact,$thirdpartywithuser["login"]);
|
$id = $edituser->create_from_contact($contact,$thirdpartywithuser["login"]);
|
||||||
if ($id > 0)
|
if ($id > 0)
|
||||||
{
|
{
|
||||||
$edituser->setPassword($user,trim($thirdpartywithuser['password']));
|
$edituser->setPassword($fuser,trim($thirdpartywithuser['password']));
|
||||||
|
|
||||||
|
if($thirdpartywithuser['group_id'] > 0 )
|
||||||
|
$edituser->SetInGroup($thirdpartywithuser['group_id'],$conf->entity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$error++;
|
$error++;
|
||||||
$errorcode='NOT_CREATE'; $errorlabel='Object not create : no contact found or create';
|
$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$edituser->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! $error && $id > 0)
|
|
||||||
{
|
|
||||||
$db->commit();
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
$db->rollback();
|
|
||||||
$error++;
|
$error++;
|
||||||
$errorcode='NOT_CREATE'; $errorlabel='Contact not create';
|
$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$contact->error;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$error) {
|
if(!$error) {
|
||||||
|
$db->commit();
|
||||||
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'),'id'=>$socid_return);
|
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'),'id'=>$socid_return);
|
||||||
$error=0;
|
$error=0;
|
||||||
}
|
}
|
||||||
@ -645,6 +665,7 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
|
|||||||
|
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
|
$db->rollback();
|
||||||
$objectresp = array(
|
$objectresp = array(
|
||||||
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
|
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
|
||||||
);
|
);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user