Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
351c4927f4
@ -2629,7 +2629,7 @@ abstract class CommonObject
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
print '<td align="right" width="80">'.$langs->trans('BuyingPrice').'</td>';
|
||||
else
|
||||
print '<td align="right" width="80">'.$langs->trans('BuyingCost').'</td>';
|
||||
print '<td align="right" width="80">'.$langs->trans('CostPrice').'</td>';
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print '<td align="right" width="50">'.$langs->trans('MarginRate').'</td>';
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES))
|
||||
@ -3029,7 +3029,10 @@ abstract class CommonObject
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="30%">'.$langs->trans('Margins').'</td>';
|
||||
print '<td width="20%" align="right">'.$langs->trans('SellingPrice').'</td>';
|
||||
print '<td width="20%" align="right">'.$langs->trans('BuyingPrice').'</td>';
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
print '<td width="20%" align="right">'.$langs->trans('BuyingPrice').'</td>';
|
||||
else
|
||||
print '<td width="20%" align="right">'.$langs->trans('CostPrice').'</td>';
|
||||
print '<td width="20%" align="right">'.$langs->trans('Margin').'</td>';
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES))
|
||||
print '<td align="right">'.$langs->trans('MarginRate').'</td>';
|
||||
|
||||
@ -44,7 +44,14 @@ if (! empty($conf->margin->enabled) && ! empty($object->element) && in_array($ob
|
||||
if (! empty($usemargins))
|
||||
{
|
||||
?>
|
||||
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
|
||||
<td align="right">
|
||||
<?php
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
echo $langs->trans('BuyingPrice');
|
||||
else
|
||||
echo $langs->trans('CostPrice');
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
|
||||
@ -50,8 +50,15 @@ if (! empty($usemargins))
|
||||
if (! empty($conf->global->DISPLAY_MARGIN_RATES)) $colspan++;
|
||||
if (! empty($conf->global->DISPLAY_MARK_RATES)) $colspan++;
|
||||
?>
|
||||
<td align="right"><?php echo $langs->trans('BuyingPrice'); ?></td>
|
||||
<?php
|
||||
<td align="right">
|
||||
<?php
|
||||
if ($conf->global->MARGIN_TYPE == "1")
|
||||
echo $langs->trans('BuyingPrice');
|
||||
else
|
||||
echo $langs->trans('CostPrice');
|
||||
?>
|
||||
</td>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<td colspan="<?php echo $colspan; ?>"> </td>
|
||||
|
||||
@ -73,12 +73,9 @@ if (! empty($idprod))
|
||||
$objp = $db->fetch_object($result);
|
||||
|
||||
$title = $objp->nom.' - '.$objp->ref_fourn.' - ';
|
||||
$label = '';
|
||||
|
||||
if ($objp->quantity == 1)
|
||||
{
|
||||
$label.= price($objp->fprice).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
|
||||
|
||||
$title.= price($objp->fprice);
|
||||
$title.= getCurrencySymbol($conf->currency)."/";
|
||||
|
||||
@ -100,8 +97,6 @@ if (! empty($idprod))
|
||||
$title.=" - ";
|
||||
$title.= price($objp->unitprice).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
|
||||
|
||||
$label.= price($objp->unitprice).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
|
||||
|
||||
$price = $objp->unitprice;
|
||||
}
|
||||
if ($objp->unitcharges > 0 && ($conf->global->MARGIN_TYPE == "2")) {
|
||||
@ -111,6 +106,8 @@ if (! empty($idprod))
|
||||
}
|
||||
if ($objp->duration) $label .= " - ".$objp->duration;
|
||||
|
||||
$label = price($price).getCurrencySymbol($conf->currency)."/".strtolower($langs->trans("Unit"));
|
||||
|
||||
$prices[] = array("id" => $objp->idprodfournprice, "price" => price($price,0,'',0), "label" => $label, "title" => $title);
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -31,11 +31,13 @@ $WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
//$WS_DOL_URL = 'http://localhost:8080/'; // If not a page, should end with /
|
||||
$WS_METHOD_GETTHIRDSPARTY = 'getThirdParty';
|
||||
$WS_METHOD_CREATETHIRDSPARTY = 'createThirdParty';
|
||||
$WS_METHOD_UPDATETHIRDSPARTY = 'updateThirdParty';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
//Chosse action to do
|
||||
//$action='get';
|
||||
$action='create';
|
||||
//$action='update';
|
||||
|
||||
|
||||
// Set the WebService URL
|
||||
@ -121,6 +123,55 @@ if ($action=='create')
|
||||
}
|
||||
}
|
||||
|
||||
// Test URL
|
||||
if ($action=='update')
|
||||
{
|
||||
$thirdparty=array(
|
||||
'id'=>'1',
|
||||
'ref'=>'Test WS Create Client',
|
||||
'ref_ext'=>'WS0001',
|
||||
'fk_user_mod'=>'1',
|
||||
'status'=>'1',
|
||||
'client'=>'1',
|
||||
'supplier'=>'0',
|
||||
'address'=>'Adresse customer',
|
||||
'zip'=>'75000',
|
||||
'town'=>'Paris',
|
||||
'country_id'=>'1',//France
|
||||
'customer_code'=>'-1',//Generate code regarding module configuration
|
||||
'supplier_code'=>'0',
|
||||
'phone'=>'0141414141',
|
||||
'fax'=>'0121212121',
|
||||
'email'=>'webtest1@test.fr',
|
||||
'url'=>' www.test.fr',
|
||||
'profid1'=>'1111111',
|
||||
'profid2'=>'222222',
|
||||
'profid3'=>'333333',
|
||||
'profid4'=>'44444',
|
||||
'profid5'=>'55555',
|
||||
'profid6'=>'66666',
|
||||
'capital'=>'3000',
|
||||
'vat_used'=>'0',
|
||||
'vat_number'=>''
|
||||
//,'options_attr1'=>'Attr1 balbal', //Extra field exemple where field code is attr1
|
||||
//'options_attr2'=>'Attr2 balbal' //Extra field exemple where field code is attr2
|
||||
);
|
||||
|
||||
|
||||
$parameters = array('authentication'=>$authentication,'thirdparty'=>$thirdparty);
|
||||
dol_syslog("Call method ".$WS_METHOD_UPDATETHIRDSPARTY);
|
||||
$result = $soapclient->call($WS_METHOD_UPDATETHIRDSPARTY,$parameters,$ns,'');
|
||||
if (! $result)
|
||||
{
|
||||
print $soapclient->error_str;
|
||||
print "<br>\n\n";
|
||||
print $soapclient->request;
|
||||
print "<br>\n\n";
|
||||
print $soapclient->response;
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
|
||||
@ -219,7 +219,7 @@ $server->register(
|
||||
// Entry values
|
||||
array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
|
||||
// Exit values
|
||||
array('result'=>'tns:result','id'=>'xsd:string'),
|
||||
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
|
||||
$ns,
|
||||
$ns.'#createThirdParty',
|
||||
$styledoc,
|
||||
@ -227,6 +227,20 @@ $server->register(
|
||||
'WS to create a thirdparty'
|
||||
);
|
||||
|
||||
// Register WSDL
|
||||
$server->register(
|
||||
'updateThirdParty',
|
||||
// Entry values
|
||||
array('authentication'=>'tns:authentication','thirdparty'=>'tns:thirdparty'),
|
||||
// Exit values
|
||||
array('result'=>'tns:result'),
|
||||
$ns,
|
||||
$ns.'#updateThirdParty',
|
||||
$styledoc,
|
||||
$styleuse,
|
||||
'WS to update a thirdparty'
|
||||
);
|
||||
|
||||
|
||||
// Register WSDL
|
||||
$server->register(
|
||||
@ -465,6 +479,131 @@ function createThirdParty($authentication,$thirdparty)
|
||||
return $objectresp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update a thirdparty
|
||||
*
|
||||
* @param array $authentication Array of authentication information
|
||||
* @param Societe $thirdparty Thirdparty
|
||||
* @return array Array result
|
||||
*/
|
||||
function updateThirdParty($authentication,$thirdparty)
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
dol_syslog("Function: updateThirdParty login=".$authentication['login']);
|
||||
|
||||
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||
|
||||
// Init and check authentication
|
||||
$objectresp=array();
|
||||
$errorcode='';$errorlabel='';
|
||||
$error=0;
|
||||
$fuser=check_authentication($authentication,$error,$errorcode,$errorlabel);
|
||||
// Check parameters
|
||||
if (empty($thirdparty['id'])) {
|
||||
$error++; $errorcode='KO'; $errorlabel="Thirdparty id is mandatory.";
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$objectfound=false;
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php';
|
||||
|
||||
$object=new Societe($db);
|
||||
$result=$object->fetch($id);
|
||||
|
||||
if (!empty($thirdparty['id'])) {
|
||||
|
||||
$objectfound=true;
|
||||
|
||||
$object->ref=$thirdparty['ref'];
|
||||
$object->name=$thirdparty['ref'];
|
||||
$object->ref_ext=$thirdparty['ref_ext'];
|
||||
$object->status=$thirdparty['status'];
|
||||
$object->client=$thirdparty['client'];
|
||||
$object->fournisseur=$thirdparty['supplier'];
|
||||
$object->code_client=$thirdparty['customer_code'];
|
||||
$object->code_fournisseur=$thirdparty['supplier_code'];
|
||||
$object->code_compta=$thirdparty['customer_code_accountancy'];
|
||||
$object->code_compta_fournisseur=$thirdparty['supplier_code_accountancy'];
|
||||
$object->date_creation=$now;
|
||||
$object->note=$thirdparty['note'];
|
||||
$object->address=$thirdparty['address'];
|
||||
$object->zip=$thirdparty['zip'];
|
||||
$object->town=$thirdparty['town'];
|
||||
|
||||
$object->country_id=$thirdparty['country_id'];
|
||||
if ($thirdparty['country_code']) $object->country_id=getCountry($thirdparty['country_code'],3);
|
||||
$object->province_id=$thirdparty['province_id'];
|
||||
//if ($thirdparty['province_code']) $newobject->province_code=getCountry($thirdparty['province_code'],3);
|
||||
|
||||
$object->phone=$thirdparty['phone'];
|
||||
$object->fax=$thirdparty['fax'];
|
||||
$object->email=$thirdparty['email'];
|
||||
$object->url=$thirdparty['url'];
|
||||
$object->idprof1=$thirdparty['profid1'];
|
||||
$object->idprof2=$thirdparty['profid2'];
|
||||
$object->idprof3=$thirdparty['profid3'];
|
||||
$object->idprof4=$thirdparty['profid4'];
|
||||
$object->idprof5=$thirdparty['profid5'];
|
||||
$object->idprof6=$thirdparty['profid6'];
|
||||
|
||||
$object->capital=$thirdparty['capital'];
|
||||
|
||||
$object->barcode=$thirdparty['barcode'];
|
||||
$object->tva_assuj=$thirdparty['vat_used'];
|
||||
$object->tva_intra=$thirdparty['vat_number'];
|
||||
|
||||
$object->canvas=$thirdparty['canvas'];
|
||||
|
||||
//Retreive all extrafield for thirdsparty
|
||||
// fetch optionals attributes and labels
|
||||
$extrafields=new ExtraFields($db);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label('company');
|
||||
foreach($extrafields->attribute_label as $key=>$label)
|
||||
{
|
||||
$key='options_'.$key;
|
||||
$object->array_options[$key]=$thirdparty[$key];
|
||||
}
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result=$object->update($fuser);
|
||||
if ($result <= 0) {
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
if ((! $error) && ($objectfound))
|
||||
{
|
||||
$db->commit();
|
||||
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''));
|
||||
}
|
||||
elseif ($objectfound)
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
$errorcode='KO';
|
||||
$errorlabel=$object->error;
|
||||
} else {
|
||||
$error++;
|
||||
$errorcode='NOT_FOUND';
|
||||
$errorlabel='Thirdparty id='.$thirdparty['id'].' cannot be found';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
|
||||
}
|
||||
|
||||
return $objectresp;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2013 Marcos García <marcosgdf@gmail.com>
|
||||
*
|
||||
* 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
|
||||
@ -169,7 +170,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
* @depends testAdherentFetch
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentUpdate($localobject)
|
||||
public function testAdherentUpdate(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
@ -177,6 +178,9 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$timestamp = dol_now();
|
||||
|
||||
$localobject->civilite_id = 0;
|
||||
$localobject->login='newlogin';
|
||||
$localobject->societe='New company';
|
||||
$localobject->note='New note after update';
|
||||
@ -188,10 +192,12 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
$localobject->town='New town';
|
||||
$localobject->country_id=2;
|
||||
$localobject->statut=0;
|
||||
$localobject->morphy=0;
|
||||
$localobject->phone='New tel pro';
|
||||
$localobject->phone_perso='New tel perso';
|
||||
$localobject->phone_mobile='New tel mobile';
|
||||
$localobject->email='newemail@newemail.com';
|
||||
$localobject->naiss=$timestamp;
|
||||
$result=$localobject->update($user);
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
@ -207,6 +213,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." id=".$localobject->id." result=".$result."\n";
|
||||
$this->assertLessThan($result, 0);
|
||||
|
||||
$this->assertEquals($localobject->civilite_id, $newobject->civilite_id);
|
||||
$this->assertEquals($localobject->login, $newobject->login);
|
||||
$this->assertEquals($localobject->societe, $newobject->societe);
|
||||
$this->assertEquals($localobject->note, $newobject->note);
|
||||
@ -223,20 +230,54 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals($localobject->phone_perso, $newobject->phone_perso);
|
||||
$this->assertEquals($localobject->phone_mobile, $newobject->phone_mobile);
|
||||
$this->assertEquals($localobject->email, $newobject->email);
|
||||
$this->assertEquals($localobject->naiss, $timestamp);
|
||||
$this->assertEquals($localobject->morphy, $newobject->morphy);
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentMakeSubstitution
|
||||
*
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return Adherent
|
||||
*
|
||||
* @depends testAdherentUpdate
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentMakeSubstitution(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$template = '%DOL_MAIN_URL_ROOT%,%ID%,%CIVILITE%,%FIRSTNAME%,%LASTNAME%,%FULLNAME%,%COMPANY%,'.
|
||||
'%ADDRESS%,%ZIP%,%TOWN%,%COUNTRY%,%EMAIL%,%NAISS%,%PHOTO%,%LOGIN%,%PASSWORD%,%PRENOM%,'.
|
||||
'%NOM%,%SOCIETE%,%ADRESSE%,%CP%,%VILLE%,%PAYS%';
|
||||
|
||||
$expected = DOL_MAIN_URL_ROOT.','.$localobject->id.',0,New firstname,New name,New firstname New name,'.
|
||||
'New company,New address,New zip,New town,,newemail@newemail.com,'.dol_print_date($localobject->naiss,'day').',,'.
|
||||
'newlogin,dolibspec,New firstname,New name,New company,New address,New zip,New town,';
|
||||
|
||||
$result = $localobject->makeSubstitution($template);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals($expected, $result);
|
||||
|
||||
return $localobject;
|
||||
}
|
||||
|
||||
/**
|
||||
* testAdherentValid
|
||||
*
|
||||
* @param Adherent $localobject Member instance
|
||||
* @return Adherent
|
||||
*
|
||||
* @depends testAdherentUpdate
|
||||
* @depends testAdherentMakeSubstitution
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentValid($localobject)
|
||||
public function testAdherentValid(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
@ -260,7 +301,7 @@ class AdherentTest extends PHPUnit_Framework_TestCase
|
||||
* @depends testAdherentValid
|
||||
* The depends says test is run only if previous is ok
|
||||
*/
|
||||
public function testAdherentOther($localobject)
|
||||
public function testAdherentOther(Adherent $localobject)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user