Merge remote-tracking branch 'origin/3.5' into develop

Conflicts:
	htdocs/core/class/html.form.class.php
This commit is contained in:
Laurent Destailleur 2014-02-05 21:03:05 +01:00
commit 7078970ed1
4 changed files with 48 additions and 26 deletions

View File

@ -27,12 +27,13 @@ require '../../main.inc.php';
require_once DOL_DOCUMENT_ROOT.'/compta/sociales/class/chargesociales.class.php';
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formsocialcontrib.class.php';
$langs->load("compta");
// Security check
$socid = isset($_GET["socid"])?$_GET["socid"]:'';
if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'tax', '', '', 'charges');
$sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int');

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011 Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2010 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2011-204 Laurent Destailleur <eldy@users.sourceforge.net>
*
* 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
@ -73,7 +73,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
if ($zipcode) $sql.=" AND z.zip LIKE '" . $db->escape($zipcode) . "%'";
if ($town) $sql.=" AND z.town LIKE '%" . $db->escape($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
{
@ -87,7 +87,7 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
if ($zipcode) $sql.= " s.zip LIKE '".$db->escape($zipcode)."%'";
if ($town) $sql.= " s.town LIKE '%" . $db->escape($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;
@ -97,8 +97,8 @@ if (! empty($_GET['zipcode']) || ! empty($_GET['town']))
{
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']):'';
$county = $row['fk_county']?($langs->trans($row['county_code'])!=$row['county_code']?$langs->trans($row['county_code']):($row['county']!='-'?$row['county']:'')):'';
$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->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'] .= ($county || $country)?' (':'';

View File

@ -115,9 +115,9 @@ class box_graph_product_distribution extends ModeleBoxes
if ($showpropalnb) $nbofgraph++;
if ($showordernb) $nbofgraph++;
$paramtitle=$langs->trans("Products").'/'.$langs->trans("Services");
if (empty($conf->produit->enabled)) $paramtitle=$langs->trans("Services");
if (empty($conf->service->enabled)) $paramtitle=$langs->trans("Products");
$paramtitle=$langs->transnoentitiesnoconv("Products").'/'.$langs->transnoentitiesnoconv("Services");
if (empty($conf->produit->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Services");
if (empty($conf->service->enabled)) $paramtitle=$langs->transnoentitiesnoconv("Products");
$socid=empty($user->societe_id)?0:$user->societe_id;
$userid=0; // No filter on user creation

View File

@ -181,7 +181,8 @@ $thirdpartywithuser_fields = array(
'tva_intra' => array('name'=>'tva_intra','type'=>'xsd:string'),
// For user
'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
@ -523,6 +524,7 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
}
else
{
$db->begin();
/*
* Company creation
*/
@ -533,6 +535,25 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
$thirdparty->town=$thirdpartywithuser['town'];
$thirdparty->country_id=$thirdpartywithuser['country_id'];
$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->fax=$thirdpartywithuser['fax'];
$thirdparty->email=$thirdpartywithuser['email'];
@ -570,6 +591,9 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
$contact->phone_pro = $thirdparty->phone;
$contact->phone_mobile = $thirdpartywithuser['phone_mobile'];
$contact->fax = $thirdparty->fax;
$contact->statut = 1;
$contact->country_id = $thirdparty->country_id;
$contact->country_code = $thirdparty->country_code;
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
@ -591,33 +615,29 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
*
*/
$edituser = new User($db);
$db->begin();
$id = $edituser->create_from_contact($contact,$thirdpartywithuser["login"]);
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
{
$error++;
$errorcode='NOT_CREATE'; $errorlabel='Object not create : no contact found or create';
}
if (! $error && $id > 0)
{
$db->commit();
}
else
{
$db->rollback();
$error++;
$errorcode='NOT_CREATE'; $errorlabel='Contact not create';
$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$edituser->error;
}
}
else
{
$error++;
$errorcode='NOT_CREATE'; $errorlabel='Object not create : '.$contact->error;
}
if(!$error) {
$db->commit();
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>'SUCCESS'),'id'=>$socid_return);
$error=0;
}
@ -645,6 +665,7 @@ function createUserFromThirdparty($authentication,$thirdpartywithuser)
if ($error)
{
$db->rollback();
$objectresp = array(
'result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel)
);