Merge branch '3.7-webservices-fix' of https://github.com/aaujon/dolibarr into 3.7-webservices-fix
This commit is contained in:
commit
56a2942503
@ -480,7 +480,7 @@ class Categorie extends CommonObject
|
||||
* Link an object to the category
|
||||
*
|
||||
* @param Object $obj Object to link to category
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $type Type of category ('societe', 'member', 'product', 'contact', 'fournisseur)
|
||||
* @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked
|
||||
*/
|
||||
function add_type($obj,$type)
|
||||
@ -493,12 +493,22 @@ class Categorie extends CommonObject
|
||||
|
||||
// For backward compatibility
|
||||
if ($type == 'company') $type='societe';
|
||||
if ($type == 'customer') $type='societe';
|
||||
if ($type == 'supplier') $type='fournisseur';
|
||||
elseif ($type == 'customer') $type='societe';
|
||||
elseif ($type == 'supplier') $type='fournisseur';
|
||||
|
||||
$column_name=$type;
|
||||
if ($type=='contact') $column_name='socpeople';
|
||||
if ($type=='fournisseur') $column_name='societe';
|
||||
/**
|
||||
* llx_categorie_contact => fk_socpeople
|
||||
* llx_categorie_fournisseur, llx_categorie_societe => fk_soc
|
||||
* llx_categorie_member => fk_member
|
||||
* llx_categorie_product => fk_product
|
||||
*/
|
||||
if ($type == 'contact') {
|
||||
$column_name = 'socpeople';
|
||||
} elseif ($type == 'fournisseur' || ($type == 'societe')) {
|
||||
$column_name = 'soc';
|
||||
} else {
|
||||
$column_name = $type;
|
||||
}
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@ -28,6 +28,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
|
||||
|
||||
/**
|
||||
* Class to manage Dolibarr database access for a MySQL database using the mysql extension
|
||||
*
|
||||
* @deprecated Use DoliDBMysqli
|
||||
*/
|
||||
class DoliDBMysql extends DoliDB
|
||||
{
|
||||
|
||||
@ -789,14 +789,15 @@ function dol_get_fiche_head($links=array(), $active='0', $title='', $notab=0, $p
|
||||
|
||||
if ($displaytab > $limittoshow)
|
||||
{
|
||||
$out.='<div id="moretabs" class="inline-block tabsElem">';
|
||||
$tabsname=str_replace ("@", "", $picto);
|
||||
$out.='<div id="moretabs'.$tabsname.'" class="inline-block tabsElem">';
|
||||
$out.='<a href="" data-role="button" style="background-color: #f0f0f0;" class="tab inline-block">'.$langs->trans("More").'...</a>';
|
||||
$out.='<div id="moretabsList" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>';
|
||||
$out.='<div id="moretabsList'.$tabsname.'" style="position: absolute; left: -999em;text-align: left;margin:0px;padding:2px">'.$outmore.'</div>';
|
||||
$out.="</div>\n";
|
||||
|
||||
$out.="<script>";
|
||||
$out.="$('#moretabs').mouseenter( function() { $('#moretabsList').css('left','auto');});";
|
||||
$out.="$('#moretabs').mouseleave( function() { $('#moretabsList').css('left','-999em');});";
|
||||
$out.="$('#moretabs".$tabsname.").mouseenter( function() { $('#moretabsList".$tabsname.").css('left','auto');});";
|
||||
$out.="$('#moretabs".$tabsname.").mouseleave( function() { $('#moretabsList".$tabsname.").css('left','-999em');});";
|
||||
$out.="</script>";
|
||||
}
|
||||
|
||||
|
||||
@ -637,10 +637,21 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
//$date=dol_mktime(12, 0, 0, 1, 1, 1900);
|
||||
//$date=dol_stringtotime('20130101');
|
||||
|
||||
$hasglobalcounter=false;
|
||||
// Extract value for mask counter, mask raz and mask offset
|
||||
if (! preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg)) return 'ErrorBadMask';
|
||||
$masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:'');
|
||||
$maskcounter=$reg[1];
|
||||
if (preg_match('/\{(0+)([@\+][0-9\-\+\=]+)?([@\+][0-9\-\+\=]+)?\}/i',$mask,$reg))
|
||||
{
|
||||
$masktri=$reg[1].(! empty($reg[2])?$reg[2]:'').(! empty($reg[3])?$reg[3]:'');
|
||||
$maskcounter=$reg[1];
|
||||
$hasglobalcounter=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// setting some defaults so the rest of the code won't fail if there is a third party counter
|
||||
$masktri='00000';
|
||||
$maskcounter='00000';
|
||||
}
|
||||
|
||||
$maskraz=-1;
|
||||
$maskoffset=0;
|
||||
$resetEveryMonth=false;
|
||||
@ -659,6 +670,12 @@ function get_next_value($db,$mask,$table,$field,$where='',$objsoc='',$date='',$m
|
||||
if (dol_strlen($maskrefclient_maskcounter) > 0 && dol_strlen($maskrefclient_maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
|
||||
}
|
||||
else $maskrefclient='';
|
||||
|
||||
// fail if there is neither a global nor a third party counter
|
||||
if (! $hasglobalcounter && ($maskrefclient_maskcounter == ''))
|
||||
{
|
||||
return 'ErrorBadMask';
|
||||
}
|
||||
|
||||
// Extract value for third party type
|
||||
if (preg_match('/\{(t+)\}/i',$mask,$regType))
|
||||
@ -993,10 +1010,21 @@ function check_value($mask,$value)
|
||||
{
|
||||
$result=0;
|
||||
|
||||
$hasglobalcounter=false;
|
||||
// Extract value for mask counter, mask raz and mask offset
|
||||
if (! preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg)) return 'ErrorBadMask';
|
||||
$masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:'');
|
||||
$maskcounter=$reg[1];
|
||||
if (preg_match('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$mask,$reg))
|
||||
{
|
||||
$masktri=$reg[1].(isset($reg[2])?$reg[2]:'').(isset($reg[3])?$reg[3]:'');
|
||||
$maskcounter=$reg[1];
|
||||
$hasglobalcounter=true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// setting some defaults so the rest of the code won't fail if there is a third party counter
|
||||
$masktri='00000';
|
||||
$maskcounter='00000';
|
||||
}
|
||||
|
||||
$maskraz=-1;
|
||||
$maskoffset=0;
|
||||
if (dol_strlen($maskcounter) < 3) return 'ErrorCounterMustHaveMoreThan3Digits';
|
||||
@ -1015,6 +1043,12 @@ function check_value($mask,$value)
|
||||
}
|
||||
else $maskrefclient='';
|
||||
|
||||
// fail if there is neither a global nor a third party counter
|
||||
if (! $hasglobalcounter && ($maskrefclient_maskcounter == ''))
|
||||
{
|
||||
return 'ErrorBadMask';
|
||||
}
|
||||
|
||||
$maskwithonlyymcode=$mask;
|
||||
$maskwithonlyymcode=preg_replace('/\{(0+)([@\+][0-9]+)?([@\+][0-9]+)?\}/i',$maskcounter,$maskwithonlyymcode);
|
||||
$maskwithonlyymcode=preg_replace('/\{dd\}/i','dd',$maskwithonlyymcode);
|
||||
|
||||
@ -6,6 +6,7 @@
|
||||
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
|
||||
* Copyright (C) 2009-2011 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@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
|
||||
@ -90,6 +91,7 @@ class modAgenda extends DolibarrModules
|
||||
$this->const[12] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_VALIDATE","chaine","1");
|
||||
$this->const[13] = array("MAIN_AGENDA_ACTIONAUTO_SHIPPING_SENTBYMAIL","chaine","1");
|
||||
$this->const[14] = array("MAIN_AGENDA_ACTIONAUTO_BILL_UNVALIDATE","chaine","1");
|
||||
$this->const[15] = array("MAIN_AGENDA_ACTIONAUTO_BILL_SUPPLIER_UNVALIDATE","chaine","1");
|
||||
|
||||
// New pages on tabs
|
||||
// -----------------
|
||||
|
||||
@ -4,6 +4,7 @@
|
||||
* Copyright (C) 2011-2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Cedric GROSS <c.gross@kreiz-it.fr>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@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
|
||||
@ -493,6 +494,18 @@ class InterfaceActionsAuto extends DolibarrTriggers
|
||||
$object->actionmsg=$langs->transnoentities("InvoiceValidatedInDolibarr",($object->newref?$object->newref:$object->ref));
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
|
||||
$object->sendtoid=0;
|
||||
}
|
||||
elseif ($action == 'BILL_SUPPLIER_UNVALIDATE')
|
||||
{
|
||||
$langs->load("other");
|
||||
$langs->load("bills");
|
||||
|
||||
$object->actiontypecode='AC_OTH_AUTO';
|
||||
if (empty($object->actionmsg2)) $object->actionmsg2=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
||||
$object->actionmsg=$langs->transnoentities("InvoiceBackToDraftInDolibarr",$object->ref);
|
||||
$object->actionmsg.="\n".$langs->transnoentities("Author").': '.$user->login;
|
||||
|
||||
$object->sendtoid=0;
|
||||
}
|
||||
elseif ($action == 'BILL_SUPPLIER_SENTBYMAIL')
|
||||
|
||||
@ -2,6 +2,7 @@
|
||||
/* Copyright (C) 2005-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2014 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@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
|
||||
@ -197,6 +198,7 @@ class InterfaceDemo extends DolibarrTriggers
|
||||
case 'BILL_SUPPLIER_PAYED':
|
||||
case 'BILL_SUPPLIER_UNPAYED':
|
||||
case 'BILL_SUPPLIER_VALIDATE':
|
||||
case 'BILL_SUPPLIER_UNVALIDATE':
|
||||
case 'LINEBILL_SUPPLIER_CREATE':
|
||||
case 'LINEBILL_SUPPLIER_UPDATE':
|
||||
case 'LINEBILL_SUPPLIER_DELETE':
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* Copyright (C) 2013 Philippe Grand <philippe.grand@atoo-net.com>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Marcos García <marcosgdf@gmail.com>
|
||||
* Copyright (C) 2015 Bahfir Abbes <bafbes@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
|
||||
@ -1073,7 +1074,14 @@ class FactureFournisseur extends CommonInvoice
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Triggers call
|
||||
if (! $error && empty($notrigger))
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('BILL_SUPPLIER_VALIDATE',$user);
|
||||
if ($result < 0) $error++;
|
||||
// End call triggers
|
||||
}
|
||||
if ($error == 0)
|
||||
{
|
||||
$this->db->commit();
|
||||
|
||||
@ -328,8 +328,9 @@ if (! empty($force_install_message))
|
||||
$option.='>';
|
||||
$option.=$type.' ';
|
||||
if ($note) $option.=' '.$note;
|
||||
// Experimental
|
||||
if ($type=='mssql') $option.=' '.$langs->trans("Experimental");
|
||||
// Deprecated and experimental
|
||||
if ($type=='mysql') $option.=' ' . $langs->trans("Deprecated");
|
||||
elseif ($type=='mssql') $option.=' '.$langs->trans("Experimental");
|
||||
elseif ($type=='sqlite') $option.=' '.$langs->trans("Experimental");
|
||||
elseif ($type=='sqlite3') $option.=' '.$langs->trans("Experimental");
|
||||
// No available
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
-- Copyright (C) 2010-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
-- Copyright (C) 2013 Cedric Gross <c.gross@kreiz-it.fr>
|
||||
-- Copyright (C) 2014 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
||||
-- Copyright (C) 2015 Bahfir Abbes <bafbes@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
|
||||
@ -74,3 +75,4 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_CREATE','Task created','Executed when a project task is created','project',35);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_MODIFY','Task modified','Executed when a project task is modified','project',36);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('TASK_DELETE','Task deleted','Executed when a project task is deleted','project',37);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('BILL_SUPPLIER_UNVALIDATE', 'Supplier invoice unvalidated', 'Executed when a supplier invoice status is set back to draft', 'invoice_supplier',15);
|
||||
|
||||
@ -644,4 +644,5 @@ ALTER TABLE llx_actioncomm ADD COLUMN recurdateend datetime;
|
||||
|
||||
ALTER TABLE llx_stcomm ADD COLUMN picto varchar(128);
|
||||
|
||||
|
||||
-- New trigger for Supplier invoice unvalidation
|
||||
INSERT INTO llx_c_action_trigger (code, label, description, elementtype, rang) VALUES ('BILL_SUPPLIER_UNVALIDATE','Supplier invoice unvalidated','Executed when a supplier invoice status is set back to draft','invoice_supplier',15);
|
||||
|
||||
@ -64,6 +64,7 @@ DatabaseSuperUserAccess=Database server - Superuser access
|
||||
CheckToCreateDatabase=Check box if database does not exist and must be created.<br>In this case, you must fill the login/password for superuser account at the bottom of this page.
|
||||
CheckToCreateUser=Check box if database owner does not exist and must be created.<br>In this case, you must choose its login and password and also fill the login/password for the superuser account at the bottom of this page. If this box is unchecked, owner database and its passwords must exists.
|
||||
Experimental=(experimental)
|
||||
Deprecated=(deprecated)
|
||||
DatabaseRootLoginDescription=Login of the user allowed to create new databases or new users, mandatory if your database or its owner does not already exists.
|
||||
KeepEmptyIfNoPassword=Leave empty if user has no password (avoid this)
|
||||
SaveConfigurationFile=Save values
|
||||
@ -211,4 +212,4 @@ MigrationCategorieAssociation=Migration of categories
|
||||
MigrationEvents=Migration of events to add event owner into assignement table
|
||||
|
||||
ShowNotAvailableOptions=Show not available options
|
||||
HideNotAvailableOptions=Hide not available options
|
||||
HideNotAvailableOptions=Hide not available options
|
||||
|
||||
@ -557,25 +557,25 @@ function createInvoice($authentication,$invoice)
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$newobject=new Facture($db);
|
||||
$newobject->socid=$invoice['thirdparty_id'];
|
||||
$newobject->type=$invoice['type'];
|
||||
$newobject->ref_ext=$invoice['ref_ext'];
|
||||
$newobject->date=dol_stringtotime($invoice['date'],'dayrfc');
|
||||
$newobject->note_private=$invoice['note_private'];
|
||||
$newobject->note_public=$invoice['note_public'];
|
||||
$newobject->statut= Facture::STATUS_DRAFT; // We start with status draft
|
||||
$newobject->fk_project=$invoice['project_id'];
|
||||
$newobject->date_creation=$now;
|
||||
$new_invoice=new Facture($db);
|
||||
$new_invoice->socid=$invoice['thirdparty_id'];
|
||||
$new_invoice->type=$invoice['type'];
|
||||
$new_invoice->ref_ext=$invoice['ref_ext'];
|
||||
$new_invoice->date=dol_stringtotime($invoice['date'],'dayrfc');
|
||||
$new_invoice->note_private=$invoice['note_private'];
|
||||
$new_invoice->note_public=$invoice['note_public'];
|
||||
$new_invoice->statut= Facture::STATUS_DRAFT; // We start with status draft
|
||||
$new_invoice->fk_project=$invoice['project_id'];
|
||||
$new_invoice->date_creation=$now;
|
||||
|
||||
//take mode_reglement and cond_reglement from thirdparty
|
||||
$soc = new Societe($db);
|
||||
$res=$soc->fetch($newobject->socid);
|
||||
$res=$soc->fetch($new_invoice->socid);
|
||||
if ($res > 0) {
|
||||
$newobject->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
|
||||
$newobject->cond_reglement_id = $soc->cond_reglement_id;
|
||||
$new_invoice->mode_reglement_id = ! empty($invoice['payment_mode_id'])?$invoice['payment_mode_id']:$soc->mode_reglement_id;
|
||||
$new_invoice->cond_reglement_id = $soc->cond_reglement_id;
|
||||
}
|
||||
else $newobject->mode_reglement_id = $invoice['payment_mode_id'];
|
||||
else $new_invoice->mode_reglement_id = $invoice['payment_mode_id'];
|
||||
|
||||
// Trick because nusoap does not store data with same structure if there is one or several lines
|
||||
$arrayoflines=array();
|
||||
@ -598,22 +598,22 @@ function createInvoice($authentication,$invoice)
|
||||
$newline->date_start=dol_stringtotime($line['date_start']);
|
||||
$newline->date_end=dol_stringtotime($line['date_end']);
|
||||
$newline->fk_product=$line['product_id'];
|
||||
$newobject->lines[]=$newline;
|
||||
$new_invoice->lines[]=$newline;
|
||||
}
|
||||
//var_dump($newobject->date_lim_reglement); exit;
|
||||
//var_dump($invoice['lines'][0]['type']);
|
||||
|
||||
$db->begin();
|
||||
|
||||
$result=$newobject->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
|
||||
$result=$new_invoice->create($fuser,0,dol_stringtotime($invoice['date_due'],'dayrfc'));
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
}
|
||||
|
||||
if ($invoice['status'] == 1) // We want invoice to have status validated
|
||||
if (!$error && $invoice['status'] == Facture::STATUS_VALIDATED) // We want invoice to have status validated
|
||||
{
|
||||
$result=$newobject->validate($fuser);
|
||||
$result=$new_invoice->validate($fuser);
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
@ -623,15 +623,16 @@ function createInvoice($authentication,$invoice)
|
||||
if (! $error)
|
||||
{
|
||||
$db->commit();
|
||||
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,
|
||||
'ref'=>$newobject->ref,'ref_ext'=>$newobject->ref_ext);
|
||||
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$new_invoice->id,
|
||||
'ref'=>$new_invoice->ref,'ref_ext'=>$new_invoice->ref_ext);
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
$errorcode='KO';
|
||||
$errorlabel=$newobject->error;
|
||||
$errorlabel=$new_invoice->error;
|
||||
dol_syslog("Function: createInvoice error while creating".$errorlabel);
|
||||
}
|
||||
|
||||
}
|
||||
@ -750,8 +751,8 @@ function updateInvoice($authentication,$invoice)
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice->id.
|
||||
", ref=".$invoice->ref.", ref_ext=".$invoice->ref_ext);
|
||||
dol_syslog("Function: updateInvoice login=".$authentication['login']." id=".$invoice['id'].
|
||||
", ref=".$invoice['ref'].", ref_ext=".$invoice['ref_ext']);
|
||||
|
||||
if ($authentication['entity']) $conf->entity=$authentication['entity'];
|
||||
|
||||
@ -781,10 +782,13 @@ function updateInvoice($authentication,$invoice)
|
||||
|
||||
if (isset($invoice['status']))
|
||||
{
|
||||
if ($invoice['status'] == 0) $result=$object->set_draft($fuser);
|
||||
if ($invoice['status'] == 1)
|
||||
if ($invoice['status'] == Facture::STATUS_DRAFT)
|
||||
{
|
||||
$result=$object->validate($fuser);
|
||||
$result = $object->set_draft($fuser);
|
||||
}
|
||||
if ($invoice['status'] == Facture::STATUS_VALIDATED)
|
||||
{
|
||||
$result = $object->validate($fuser);
|
||||
|
||||
if ($result >= 0)
|
||||
{
|
||||
@ -793,11 +797,12 @@ function updateInvoice($authentication,$invoice)
|
||||
$order->generateDocument($invoice->modelpdf, $outputlangs);
|
||||
}
|
||||
}
|
||||
if ($invoice['status'] == 2)
|
||||
if ($invoice['status'] == Facture::STATUS_CLOSED)
|
||||
{
|
||||
$result = $object->set_paid($fuser,$invoice->close_code,$invoice->close_note);
|
||||
}
|
||||
if ($invoice['status'] == 3) $result=$object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
|
||||
if ($invoice['status'] == Facture::STATUS_ABANDONED)
|
||||
$result = $object->set_canceled($fuser,$invoice->close_code,$invoice->close_note);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -258,8 +258,31 @@ $server->register(
|
||||
'WS to get list of thirdparties id and ref'
|
||||
);
|
||||
|
||||
// Register WSDL
|
||||
$server->register(
|
||||
'deleteThirdParty',
|
||||
// Entry values
|
||||
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string','ref_ext'=>'xsd:string'),
|
||||
// Exit values
|
||||
array('result'=>'tns:result','id'=>'xsd:string'),
|
||||
$ns,
|
||||
$ns.'#deleteThirdParty',
|
||||
$styledoc,
|
||||
$styleuse,
|
||||
'WS to delete a thirdparty from its id, ref or ref_ext'
|
||||
);
|
||||
|
||||
|
||||
// Full methods code
|
||||
/**
|
||||
* Get a thirdparty
|
||||
*
|
||||
* @param array $authentication Array of authentication information
|
||||
* @param string $id internal id
|
||||
* @param string $ref internal reference
|
||||
* @param string $ref_ext external reference
|
||||
* @return array Array result
|
||||
*/
|
||||
function getThirdParty($authentication,$id='',$ref='',$ref_ext='')
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
@ -728,5 +751,88 @@ function getListOfThirdParties($authentication,$filterthirdparty)
|
||||
return $objectresp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a thirdparty
|
||||
*
|
||||
* @param array $authentication Array of authentication information
|
||||
* @param string $id internal id
|
||||
* @param string $ref internal reference
|
||||
* @param string $ref_ext external reference
|
||||
* @return array Array result
|
||||
*/
|
||||
function deleteThirdParty($authentication,$id='',$ref='',$ref_ext='')
|
||||
{
|
||||
global $db,$conf,$langs;
|
||||
|
||||
dol_syslog("Function: deleteThirdParty login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext);
|
||||
|
||||
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 (! $error && (($id && $ref) || ($id && $ref_ext) || ($ref && $ref_ext)))
|
||||
{
|
||||
dol_syslog("Function: deleteThirdParty checkparam");
|
||||
$error++;
|
||||
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id, ref and ref_ext can't be both provided. You must choose one or other but not both.";
|
||||
}
|
||||
dol_syslog("Function: deleteThirdParty 1");
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$fuser->getrights();
|
||||
|
||||
if ($fuser->rights->societe->lire && $fuser->rights->societe->supprimer)
|
||||
{
|
||||
$thirdparty=new Societe($db);
|
||||
$result=$thirdparty->fetch($id,$ref,$ref_ext);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->begin();
|
||||
|
||||
$result=$thirdparty->delete($thirdparty->id, $fuser);
|
||||
|
||||
if ($result > 0)
|
||||
{
|
||||
$db->commit();
|
||||
|
||||
$objectresp = array('result'=>array('result_code'=>'OK', 'result_label'=>''));
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
$errorcode='KO';
|
||||
$errorlabel=$thirdparty->error;
|
||||
dol_syslog("Function: deleteThirdParty cant delete");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref.' nor ref_ext='.$ref_ext;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$error++;
|
||||
$errorcode='PERMISSION_DENIED'; $errorlabel='User does not have permission for this request';
|
||||
}
|
||||
}
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$objectresp = array('result'=>array('result_code' => $errorcode, 'result_label' => $errorlabel));
|
||||
}
|
||||
|
||||
return $objectresp;
|
||||
}
|
||||
|
||||
// Return the results.
|
||||
$server->service(file_get_contents("php://input"));
|
||||
|
||||
@ -53,7 +53,11 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
protected $soapclient;
|
||||
protected $socid;
|
||||
|
||||
protected $ns = 'http://www.dolibarr.org/ns/';
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
@ -68,6 +72,35 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$this->soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($this->soapclient)
|
||||
{
|
||||
$this->soapclient->soap_defencoding='UTF-8';
|
||||
$this->soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// create a third_party, needed to create an invoice
|
||||
$societe=new Societe($db);
|
||||
$societe->ref='';
|
||||
$societe->name='name';
|
||||
$societe->ref_ext='209';
|
||||
$societe->status=1;
|
||||
$societe->client=1;
|
||||
$societe->fournisseur=0;
|
||||
$societe->date_creation=$now;
|
||||
$societe->tva_assuj=0;
|
||||
$societe->particulier=0;
|
||||
|
||||
$societe->create($user);
|
||||
|
||||
$this->socid = $societe->id;
|
||||
|
||||
print __METHOD__." societe created id=".$societe->id."\n";
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
@ -102,10 +135,9 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
// create a third_party, needed to create an invoice
|
||||
|
||||
|
||||
print __METHOD__."\n";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -132,60 +164,55 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
$WS_METHOD = 'createInvoice';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
// load societe first
|
||||
$societe=new Societe($db);
|
||||
$societe->fetch('', '', '209');
|
||||
print __METHOD__." societe loaded id=".$societe->id."\n";
|
||||
|
||||
|
||||
$body = array (
|
||||
["id"] => NULL,
|
||||
["ref"]=> NULL,
|
||||
["ref_ext"]=> "165",
|
||||
["thirdparty_id"]=> "209",
|
||||
["fk_user_author"] => NULL,
|
||||
["fk_user_valid"] => NULL,
|
||||
["date"]=> "2015-04-19 20:16:53",
|
||||
["date_due"]=> "",
|
||||
["date_creation"]=> "",
|
||||
["date_validation"]=> "",
|
||||
["date_modification"]=> "",
|
||||
["type"]=> "",
|
||||
["total_net"]=> "36.30",
|
||||
["total_vat"]=> "6.00",
|
||||
["total"]=> "42.30",
|
||||
["payment_mode_id"]=> 50,
|
||||
["note_private"]=> "Synchronised from Prestashop",
|
||||
["note_public"]=> "",
|
||||
["status"]=> "1",
|
||||
["close_code"]=> NULL ,
|
||||
["close_note"]=> NULL,
|
||||
["project_id"]=> NULL,
|
||||
["lines"] => array(
|
||||
["id"] => NULL,
|
||||
["type"]=> 0,
|
||||
["desc"]=> "Horloge Vinyle Serge",
|
||||
["vat_rate"]=> 20,
|
||||
["qty"]=> "1",
|
||||
["unitprice"]=> "30.000000",
|
||||
["total_net"]=> "30.000000",
|
||||
["total_vat"]=> "6.00",
|
||||
["total"]=> "36.000000",
|
||||
["date_start"]=> "",
|
||||
["date_end"]=> "",
|
||||
["payment_mode_id"]=> "",
|
||||
["product_id"]=> "",
|
||||
["product_ref"]=> "",
|
||||
["product_label"]=> "",
|
||||
["product_desc"]=> "" )
|
||||
);
|
||||
"id" => NULL,
|
||||
"ref" => NULL,
|
||||
"ref_ext" => "165",
|
||||
"thirdparty_id" => $societe->id,
|
||||
"fk_user_author" => NULL,
|
||||
"fk_user_valid" => NULL,
|
||||
"date" => "2015-04-19 20:16:53",
|
||||
"date_due" => "",
|
||||
"date_creation" => "",
|
||||
"date_validation" => "",
|
||||
"date_modification" => "",
|
||||
"type" => "",
|
||||
"total_net" => "36.30",
|
||||
"total_vat" => "6.00",
|
||||
"total" => "42.30",
|
||||
"payment_mode_id" => 50,
|
||||
"note_private" => "Synchronised from Prestashop",
|
||||
"note_public" => "",
|
||||
"status" => "1",
|
||||
"close_code" => NULL ,
|
||||
"close_note" => NULL,
|
||||
"project_id" => NULL,
|
||||
"lines" => array(
|
||||
array("id" => NULL,
|
||||
"type" => 0,
|
||||
"desc" => "Horloge Vinyle Serge",
|
||||
"vat_rate" => 20,
|
||||
"qty" => 1,
|
||||
"unitprice" => "30.000000",
|
||||
"total_net" => "30.000000",
|
||||
"total_vat" => "6.00",
|
||||
"total" => "36.000000",
|
||||
"date_start" => "",
|
||||
"date_end" => "",
|
||||
"payment_mode_id" => "",
|
||||
"product_id" => "",
|
||||
"product_ref" => "",
|
||||
"product_label" => "",
|
||||
"product_desc" => "" ))
|
||||
);
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
@ -200,7 +227,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
@ -210,15 +237,15 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
$this->assertEquals('165', $result['ref_ext']);
|
||||
|
||||
@ -227,11 +254,15 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSInvoicesGetInvoice
|
||||
*
|
||||
* @return int
|
||||
* testWSInvoicesGetInvoiceByRefExt
|
||||
*
|
||||
* Retrieve an invoice using ref_ext
|
||||
* @depends testWSInvoicesCreateInvoice
|
||||
*
|
||||
* @param result invoice created by create method
|
||||
* @return array Invoice
|
||||
*/
|
||||
public function testWSInvoicesGetInvoice()
|
||||
public function testWSInvoicesGetInvoiceByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
@ -239,18 +270,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
$WS_METHOD = 'getInvoice';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
@ -265,7 +285,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$parameters = array('authentication'=>$authentication,'id'=>NULL,'ref'=>NULL,'ref_ext'=>165);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
@ -274,29 +294,31 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
$this->assertEquals('165', $result['result']['invoice']->ref_ext);
|
||||
$this->assertEquals('165', $result['invoice']['ref_ext']);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSInvoicesUpdateInvoice
|
||||
*
|
||||
* @return int
|
||||
* testWSInvoicesUpdateInvoiceByRefExt
|
||||
*
|
||||
* Update an invoice using ref_ext
|
||||
* @depends testWSInvoicesCreateInvoice
|
||||
*
|
||||
* @param result invoice created by create method
|
||||
* @return array Invoice
|
||||
*/
|
||||
public function testWSInvoicesUpdateInvoice()
|
||||
public function testWSInvoicesUpdateInvoiceByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
@ -304,61 +326,51 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_invoice.php';
|
||||
$WS_METHOD = 'updateInvoice';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient)
|
||||
{
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// update status to 2
|
||||
$body = array (
|
||||
["id"] => NULL,
|
||||
["ref"]=> NULL,
|
||||
["ref_ext"]=> "165",
|
||||
["thirdparty_id"]=> "209",
|
||||
["fk_user_author"] => NULL,
|
||||
["fk_user_valid"] => NULL,
|
||||
["date"]=> "2015-04-19 20:16:53",
|
||||
["date_due"]=> "",
|
||||
["date_creation"]=> "",
|
||||
["date_validation"]=> "",
|
||||
["date_modification"]=> "",
|
||||
["type"]=> "",
|
||||
["total_net"]=> "36.30",
|
||||
["total_vat"]=> "6.00",
|
||||
["total"]=> "42.30",
|
||||
["payment_mode_id"]=> 50,
|
||||
["note_private"]=> "Synchronised from Prestashop",
|
||||
["note_public"]=> "",
|
||||
["status"]=> "2",
|
||||
["close_code"]=> NULL ,
|
||||
["close_note"]=> NULL,
|
||||
["project_id"]=> NULL,
|
||||
["lines"] => array(
|
||||
["id"] => NULL,
|
||||
["type"]=> 0,
|
||||
["desc"]=> "Horloge Vinyle Serge",
|
||||
["vat_rate"]=> 20,
|
||||
["qty"]=> "1",
|
||||
["unitprice"]=> "30.000000",
|
||||
["total_net"]=> "30.000000",
|
||||
["total_vat"]=> "6.00",
|
||||
["total"]=> "36.000000",
|
||||
["date_start"]=> "",
|
||||
["date_end"]=> "",
|
||||
["payment_mode_id"]=> "",
|
||||
["product_id"]=> "",
|
||||
["product_ref"]=> "",
|
||||
["product_label"]=> "",
|
||||
["product_desc"]=> "" )
|
||||
);
|
||||
$body = array (
|
||||
"id" => NULL,
|
||||
"ref" => NULL,
|
||||
"ref_ext" => "165",
|
||||
"thirdparty_id" => "209",
|
||||
"fk_user_author" => NULL,
|
||||
"fk_user_valid" => NULL,
|
||||
"date" => "2015-04-19 20:16:53",
|
||||
"date_due" => "",
|
||||
"date_creation" => "",
|
||||
"date_validation" => "",
|
||||
"date_modification" => "",
|
||||
"type" => "",
|
||||
"total_net" => "36.30",
|
||||
"total_vat" => "6.00",
|
||||
"total" => "42.30",
|
||||
"payment_mode_id" => 50,
|
||||
"note_private" => "Synchronised from Prestashop",
|
||||
"note_public" => "",
|
||||
"status" => "2",
|
||||
"close_code" => NULL ,
|
||||
"close_note" => NULL,
|
||||
"project_id" => NULL,
|
||||
"lines" => array(
|
||||
array(
|
||||
"id" => NULL,
|
||||
"type" => 0,
|
||||
"desc" => "Horloge Vinyle Serge",
|
||||
"vat_rate" => 20,
|
||||
"qty" => "1",
|
||||
"unitprice" => "30.000000",
|
||||
"total_net" => "30.000000",
|
||||
"total_vat" => "6.00",
|
||||
"total" => "36.000000",
|
||||
"date_start" => "",
|
||||
"date_end" => "",
|
||||
"payment_mode_id" => "",
|
||||
"product_id" => "",
|
||||
"product_ref" => "",
|
||||
"product_label" => "",
|
||||
"product_desc" => "" ))
|
||||
);
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
@ -373,7 +385,7 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
$parameters = array('authentication'=>$authentication,'invoice'=>$body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->ns,'');
|
||||
}
|
||||
catch(SoapFault $exception)
|
||||
{
|
||||
@ -382,18 +394,17 @@ class WebservicesInvoicesTest extends PHPUnit_Framework_TestCase
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring']))
|
||||
{
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." result=".$result['result']['result_code'].$result['result']['result_label']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
$this->assertEquals('2', $result['result']['invoice']->status);
|
||||
$this->assertEquals('165', $result['ref_ext']);
|
||||
|
||||
|
||||
return $result;
|
||||
|
||||
@ -52,6 +52,13 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
protected $soapclient;
|
||||
|
||||
private $_WS_DOL_URL;
|
||||
private $_ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
@ -67,6 +74,16 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
$this->_WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$this->_WS_DOL_URL."\n";
|
||||
$this->soapclient = new nusoap_client($this->_WS_DOL_URL);
|
||||
if ($this->soapclient) {
|
||||
$this->soapclient->soap_defencoding='UTF-8';
|
||||
$this->soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
@ -117,31 +134,114 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSThirdpartycreateThirdParty
|
||||
*
|
||||
* @return array thirdparty created
|
||||
*/
|
||||
public function testWSThirdpartycreateThirdParty()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$WS_METHOD = 'createThirdParty';
|
||||
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
|
||||
$body = array (
|
||||
"id" => NULL,
|
||||
"ref" => "name",
|
||||
"ref_ext" => "12",
|
||||
"fk_user_author" => NULL,
|
||||
"status" => NULL,
|
||||
"client" => 1,
|
||||
"supplier" => 0,
|
||||
"customer_code" => "",
|
||||
"supplier_code" => "",
|
||||
"customer_code_accountancy" => "",
|
||||
"supplier_code_accountancy" => "",
|
||||
"date_creation" => "", // dateTime
|
||||
"date_modification" => "", // dateTime
|
||||
"note_private" => "",
|
||||
"note_public" => "",
|
||||
"address" => "",
|
||||
"zip" => "",
|
||||
"town" => "",
|
||||
"province_id" => "",
|
||||
"country_id" => "",
|
||||
"country_code" => "",
|
||||
"country" => "",
|
||||
"phone" => "",
|
||||
"fax" => "",
|
||||
"email" => "",
|
||||
"url" => "",
|
||||
"profid1" => "",
|
||||
"profid2" => "",
|
||||
"profid3" => "",
|
||||
"profid4" => "",
|
||||
"profid5" => "",
|
||||
"profid6" => "",
|
||||
"capital" => "",
|
||||
"vat_used" => "",
|
||||
"vat_number" => ""
|
||||
);
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'thirdparty'=>$body);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$thid->ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
$this->assertEquals('name',$result['ref']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSThirdpartygetThirdParty
|
||||
*
|
||||
* @return int
|
||||
* testWSThirdpartygetThirdPartyById
|
||||
*
|
||||
* Use id to retrieve thirdparty
|
||||
* @depends testWSThirdpartycreateThirdParty
|
||||
*
|
||||
* @param result thirdparty created by create method
|
||||
* @return array thirpdarty updated
|
||||
*/
|
||||
public function testWSThirdpartygetThirdParty()
|
||||
public function testWSThirdpartygetThirdPartyById($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_thirdparty.php';
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
$ns='http://www.dolibarr.org/ns/';
|
||||
|
||||
// Set the WebService URL
|
||||
print __METHOD__." create nusoap_client for URL=".$WS_DOL_URL."\n";
|
||||
$soapclient = new nusoap_client($WS_DOL_URL);
|
||||
if ($soapclient) {
|
||||
$soapclient->soap_defencoding='UTF-8';
|
||||
$soapclient->decodeUTF8(false);
|
||||
}
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
@ -151,30 +251,150 @@ class WebservicesThirdpartyTest extends PHPUnit_Framework_TestCase
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>1);
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>$id);
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $soapclient->call($WS_METHOD,$parameters,$ns,'');
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $soapclient->error_str;
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->request;
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $soapclient->response;
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result."\n";
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
$this->assertEquals($id, $result['thirdparty']['id']);
|
||||
$this->assertEquals('name', $result['thirdparty']['ref']);
|
||||
$this->assertEquals('12', $result['thirdparty']['ref_ext']);
|
||||
$this->assertEquals('0', $result['thirdparty']['status']);
|
||||
$this->assertEquals('1', $result['thirdparty']['client']);
|
||||
$this->assertEquals('0', $result['thirdparty']['supplier']);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSThirdpartygetThirdPartyByRefExt
|
||||
*
|
||||
* Use ref_ext to retrieve thirdparty
|
||||
*
|
||||
* @depends testWSThirdpartycreateThirdParty
|
||||
*
|
||||
* @param result thirdparty created by create method
|
||||
* @return array thirdparty
|
||||
*/
|
||||
public function testWSThirdpartygetThirdPartyByRefExt($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_METHOD = 'getThirdParty';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
|
||||
// Test URL
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>'', 'ref'=>'', 'ref_ext'=>'12');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
print $this->soapclient->response;
|
||||
if (! $result || ! empty($result['faultstring'])) {
|
||||
//var_dump($soapclient);
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
$this->assertEquals($id, $result['thirdparty']['id']);
|
||||
$this->assertEquals('name', $result['thirdparty']['ref']);
|
||||
$this->assertEquals('12', $result['thirdparty']['ref_ext']);
|
||||
$this->assertEquals('0', $result['thirdparty']['status']);
|
||||
$this->assertEquals('1', $result['thirdparty']['client']);
|
||||
$this->assertEquals('0', $result['thirdparty']['supplier']);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* testWSThirdpartydeleteThirdParty
|
||||
*
|
||||
* @depends testWSThirdpartycreateThirdParty
|
||||
*
|
||||
* @param result thirdparty created by create method
|
||||
* @return array thirdparty
|
||||
*/
|
||||
public function testWSThirdpartydeleteThirdPartyById($result)
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
$id = $result['id'];
|
||||
|
||||
$WS_METHOD = 'deleteThirdParty';
|
||||
|
||||
// Call the WebService method and store its result in $result.
|
||||
$authentication=array(
|
||||
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||
'sourceapplication'=>'DEMO',
|
||||
'login'=>'admin',
|
||||
'password'=>'admin',
|
||||
'entity'=>'');
|
||||
|
||||
$result='';
|
||||
$parameters = array('authentication'=>$authentication, 'id'=>$id, 'ref'=>'', 'ref_ext'=>'');
|
||||
print __METHOD__." call method ".$WS_METHOD."\n";
|
||||
try {
|
||||
$result = $this->soapclient->call($WS_METHOD,$parameters,$this->_ns,'');
|
||||
} catch(SoapFault $exception) {
|
||||
echo $exception;
|
||||
$result=0;
|
||||
}
|
||||
//if (! $result || ! empty($result['faultstring'])) {
|
||||
print $this->soapclient->error_str;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->request;
|
||||
print "\n<br>\n";
|
||||
print $this->soapclient->response;
|
||||
print "\n";
|
||||
//}
|
||||
|
||||
print __METHOD__." result=".$result['result']['result_code']."\n";
|
||||
$this->assertEquals('OK',$result['result']['result_code']);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user