Merge branch 'develop' of git@github.com:Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
60682f075c
@ -124,6 +124,14 @@ if (empty($reshook))
|
|||||||
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// customer preferred shipping method
|
||||||
|
if ($action == 'setshippingmethod' && $user->rights->societe->creer)
|
||||||
|
{
|
||||||
|
$object->fetch($id);
|
||||||
|
$result = $object->setShippingMethod(GETPOST('shipping_method_id','int'));
|
||||||
|
if ($result < 0) setEventMessages($object->error, $object->errors, 'errors');
|
||||||
|
}
|
||||||
|
|
||||||
// assujetissement a la TVA
|
// assujetissement a la TVA
|
||||||
if ($action == 'setassujtva' && $user->rights->societe->creer)
|
if ($action == 'setassujtva' && $user->rights->societe->creer)
|
||||||
{
|
{
|
||||||
@ -239,8 +247,8 @@ if ($id > 0)
|
|||||||
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
||||||
{
|
{
|
||||||
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
|
print '<tr><td>'.$langs->trans("Prefix").'</td><td colspan="3">';
|
||||||
print ($object->prefix_comm?$object->prefix_comm:' ');
|
print ($object->prefix_comm?$object->prefix_comm:' ');
|
||||||
print '</td></tr>';
|
print '</td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($object->client)
|
if ($object->client)
|
||||||
@ -431,6 +439,27 @@ if ($id > 0)
|
|||||||
print '</div></td></tr>';
|
print '</div></td></tr>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Preferred shipping Method
|
||||||
|
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD)) {
|
||||||
|
print '<tr><td class="nowrap">';
|
||||||
|
print '<table width="100%" class="nobordernopadding"><tr><td class="nowrap">';
|
||||||
|
print $langs->trans('SendingMethod');
|
||||||
|
print '<td>';
|
||||||
|
if (($action != 'editshipping') && $user->rights->societe->creer) print '<td align="right"><a href="'.$_SERVER["PHP_SELF"].'?action=editshipping&socid='.$object->id.'">'.img_edit($langs->trans('SetMode'),1).'</a></td>';
|
||||||
|
print '</tr></table>';
|
||||||
|
print '</td><td colspan="3">';
|
||||||
|
if ($action == 'editshipping')
|
||||||
|
{
|
||||||
|
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'shipping_method_id');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$form->formSelectShippingMethod($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->shipping_method_id,'none');
|
||||||
|
}
|
||||||
|
print "</td>";
|
||||||
|
print '</tr>';
|
||||||
|
}
|
||||||
|
|
||||||
// Categories
|
// Categories
|
||||||
if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) {
|
if (!empty( $conf->categorie->enabled ) && !empty( $user->rights->categorie->lire )) {
|
||||||
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
|
print '<tr><td>' . $langs->trans( "Categories" ) . '</td>';
|
||||||
|
|||||||
@ -1320,6 +1320,9 @@ if ($action == 'create')
|
|||||||
print $soc->getNomUrl(1);
|
print $soc->getNomUrl(1);
|
||||||
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
|
print '<input type="hidden" name="socid" value="' . $soc->id . '">';
|
||||||
print '</td>';
|
print '</td>';
|
||||||
|
if (! empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD) && ! empty($soc->shipping_method_id)) {
|
||||||
|
$shipping_method_id = $soc->shipping_method_id;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
print '<td colspan="2">';
|
print '<td colspan="2">';
|
||||||
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1);
|
print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1);
|
||||||
|
|||||||
@ -17,7 +17,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left
|
|||||||
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__);
|
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__);
|
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__);
|
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__);
|
||||||
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/compta/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__);
|
insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm|holiday|deplacement|expensereport', '$conf->hrm->enabled || $conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/hrm/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->hrm->employee->read || $user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__);
|
||||||
|
|
||||||
-- Home - Dashboard
|
-- Home - Dashboard
|
||||||
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'Dashboard', 0, '', '', '', 2, 0, __ENTITY__);
|
insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '1', __HANDLER__, 'left', 90__+MAX_llx_menu__, 'home', '', 1__+MAX_llx_menu__, '/index.php', 'Dashboard', 0, '', '', '', 2, 0, __ENTITY__);
|
||||||
|
|||||||
@ -223,9 +223,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0)
|
|||||||
$idsel='hrm';
|
$idsel='hrm';
|
||||||
|
|
||||||
if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
|
if (empty($noout)) print_start_menu_entry($idsel,$classname,$showmode);
|
||||||
if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/compta/hrm.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget);
|
if (empty($noout)) print_text_menu_entry($langs->trans("HRM"), $showmode, DOL_URL_ROOT.'/hrm/hrm.php?mainmenu=hrm&leftmenu=', $id, $idsel, $classname, $atarget);
|
||||||
if (empty($noout)) print_end_menu_entry($showmode);
|
if (empty($noout)) print_end_menu_entry($showmode);
|
||||||
$menu->add('/compta/hrm.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '');
|
$menu->add('/hrm/hrm.php?mainmenu=hrm&leftmenu=', $langs->trans("HRM"), 0, $showmode, $atarget, "hrm", '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
/* Copyright (C) 2011 Dimitri Mouillard <dmouillard@teclib.com>
|
||||||
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2013-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2012-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2012-2014 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2015 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
* Copyright (C) 2015-2016 Alexandre Spangaro <aspangaro.dolibarr@gmail.com>
|
||||||
*
|
*
|
||||||
* 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
|
||||||
@ -19,7 +19,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \file htdocs/compta/hrm.php
|
* \file htdocs/hrm/hrm.php
|
||||||
* \ingroup hrm
|
* \ingroup hrm
|
||||||
* \brief Home page for HRM area.
|
* \brief Home page for HRM area.
|
||||||
*/
|
*/
|
||||||
@ -180,6 +180,7 @@ CREATE TABLE llx_multicurrency_rate
|
|||||||
|
|
||||||
ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer;
|
ALTER TABLE llx_societe ADD COLUMN fk_multicurrency integer;
|
||||||
ALTER TABLE llx_societe ADD COLUMN multicurrency_code varchar(255);
|
ALTER TABLE llx_societe ADD COLUMN multicurrency_code varchar(255);
|
||||||
|
ALTER TABLE llx_societe ADD COLUMN fk_shipping_method integer AFTER cond_reglement_supplier;
|
||||||
|
|
||||||
ALTER TABLE llx_product_price ADD COLUMN fk_multicurrency integer;
|
ALTER TABLE llx_product_price ADD COLUMN fk_multicurrency integer;
|
||||||
ALTER TABLE llx_product_price ADD COLUMN multicurrency_code varchar(255);
|
ALTER TABLE llx_product_price ADD COLUMN multicurrency_code varchar(255);
|
||||||
|
|||||||
@ -85,6 +85,7 @@ create table llx_societe
|
|||||||
cond_reglement tinyint, -- condition de reglement
|
cond_reglement tinyint, -- condition de reglement
|
||||||
mode_reglement_supplier tinyint, -- mode de reglement fournisseur
|
mode_reglement_supplier tinyint, -- mode de reglement fournisseur
|
||||||
cond_reglement_supplier tinyint, -- condition de reglement fournisseur
|
cond_reglement_supplier tinyint, -- condition de reglement fournisseur
|
||||||
|
fk_shipping_method integer, -- preferred shipping method id
|
||||||
tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA
|
tva_assuj tinyint DEFAULT 1, -- assujeti ou non a la TVA
|
||||||
localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1
|
localtax1_assuj tinyint DEFAULT 0, -- assujeti ou non a local tax 1
|
||||||
localtax1_value double(6,3),
|
localtax1_value double(6,3),
|
||||||
|
|||||||
@ -1114,6 +1114,7 @@ BrowserIsKO=You are using the web browser %s. This browser is known to be a bad
|
|||||||
XDebugInstalled=XDebug is loaded.
|
XDebugInstalled=XDebug is loaded.
|
||||||
XCacheInstalled=XCache is loaded.
|
XCacheInstalled=XCache is loaded.
|
||||||
AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appears with name "CC12345 - SC45678 - The big company coorp", instead of "The big company coorp".
|
AddRefInList=Display customer/supplier ref into list (select list or combobox) and most of hyperlink. Third parties will appears with name "CC12345 - SC45678 - The big company coorp", instead of "The big company coorp".
|
||||||
|
AskForPreferredShippingMethod=Ask for preferred Sending Method for Third Parties.
|
||||||
FieldEdition=Edition of field %s
|
FieldEdition=Edition of field %s
|
||||||
FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced)
|
FillThisOnlyIfRequired=Example: +2 (fill only if timezone offset problems are experienced)
|
||||||
GetBarCode=Get barcode
|
GetBarCode=Get barcode
|
||||||
|
|||||||
@ -469,7 +469,7 @@ class Productbatch extends CommonObject
|
|||||||
* @param DoliDB $db database object
|
* @param DoliDB $db database object
|
||||||
* @param int $fk_product_stock id product_stock for objet
|
* @param int $fk_product_stock id product_stock for objet
|
||||||
* @param int $with_qty doesn't return line with 0 quantity
|
* @param int $with_qty doesn't return line with 0 quantity
|
||||||
* @return int <0 if KO, >0 if OK
|
* @return array <0 if KO, array of batch
|
||||||
*/
|
*/
|
||||||
public static function findAll($db,$fk_product_stock,$with_qty=0)
|
public static function findAll($db,$fk_product_stock,$with_qty=0)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -225,6 +225,20 @@ if ($action=="setaddrefinlist") {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Activate Ask For Preferred Shipping Method
|
||||||
|
if ($action=="setaskforshippingmet") {
|
||||||
|
$setaskforshippingmet = GETPOST('value','int');
|
||||||
|
$res = dolibarr_set_const($db, "SOCIETE_ASK_FOR_SHIPPING_METHOD", $setaskforshippingmet,'yesno',0,'',$conf->entity);
|
||||||
|
if (! $res > 0) $error++;
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//Activate ProfId mandatory
|
//Activate ProfId mandatory
|
||||||
if ($action == 'setprofidmandatory')
|
if ($action == 'setprofidmandatory')
|
||||||
@ -777,6 +791,26 @@ print '</a></td>';
|
|||||||
print '</tr>';
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
|
$var=!$var;
|
||||||
|
print "<tr ".$bc[$var].">";
|
||||||
|
print '<td width="80%">'.$langs->trans("AskForPreferredShippingMethod").'</td>';
|
||||||
|
print '<td> </td>';
|
||||||
|
print '<td align="center">';
|
||||||
|
if (!empty($conf->global->SOCIETE_ASK_FOR_SHIPPING_METHOD))
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=0">';
|
||||||
|
print img_picto($langs->trans("Activated"),'switch_on');
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a href="'.$_SERVER['PHP_SELF'].'?action=setaskforshippingmet&value=1">';
|
||||||
|
print img_picto($langs->trans("Disabled"),'switch_off');
|
||||||
|
}
|
||||||
|
print '</a></td>';
|
||||||
|
print '</tr>';
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
// COMPANY_USE_SEARCH_TO_SELECT
|
// COMPANY_USE_SEARCH_TO_SELECT
|
||||||
$var=!$var;
|
$var=!$var;
|
||||||
|
|||||||
@ -840,6 +840,7 @@ class Societe extends CommonObject
|
|||||||
$sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null");
|
$sql .= ",cond_reglement = ".(! empty($this->cond_reglement_id)?"'".$this->db->escape($this->cond_reglement_id)."'":"null");
|
||||||
$sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null");
|
$sql .= ",mode_reglement_supplier = ".(! empty($this->mode_reglement_supplier_id)?"'".$this->db->escape($this->mode_reglement_supplier_id)."'":"null");
|
||||||
$sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null");
|
$sql .= ",cond_reglement_supplier = ".(! empty($this->cond_reglement_supplier_id)?"'".$this->db->escape($this->cond_reglement_supplier_id)."'":"null");
|
||||||
|
$sql .= ", fk_shipping_method_id = ".(! empty($this->shipping_method_id)?"'".$this->db->escape($this->shipping_method_id)."'":"null");
|
||||||
|
|
||||||
$sql .= ",client = " . (! empty($this->client)?$this->client:0);
|
$sql .= ",client = " . (! empty($this->client)?$this->client:0);
|
||||||
$sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0);
|
$sql .= ",fournisseur = " . (! empty($this->fournisseur)?$this->fournisseur:0);
|
||||||
@ -1018,6 +1019,7 @@ class Societe extends CommonObject
|
|||||||
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
$sql .= ', s.code_client, s.code_fournisseur, s.code_compta, s.code_compta_fournisseur, s.parent, s.barcode';
|
||||||
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
|
$sql .= ', s.fk_departement, s.fk_pays as country_id, s.fk_stcomm, s.remise_client, s.mode_reglement, s.cond_reglement, s.tva_assuj';
|
||||||
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
$sql .= ', s.mode_reglement_supplier, s.cond_reglement_supplier, s.localtax1_assuj, s.localtax1_value, s.localtax2_assuj, s.localtax2_value, s.fk_prospectlevel, s.default_lang, s.logo';
|
||||||
|
$sql .= ', s.fk_shipping_method';
|
||||||
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
|
$sql .= ', s.outstanding_limit, s.import_key, s.canvas, s.fk_incoterms, s.location_incoterms';
|
||||||
$sql .= ', s.fk_multicurrency, s.multicurrency_code';
|
$sql .= ', s.fk_multicurrency, s.multicurrency_code';
|
||||||
$sql .= ', fj.libelle as forme_juridique';
|
$sql .= ', fj.libelle as forme_juridique';
|
||||||
@ -1144,6 +1146,7 @@ class Societe extends CommonObject
|
|||||||
$this->cond_reglement_id = $obj->cond_reglement;
|
$this->cond_reglement_id = $obj->cond_reglement;
|
||||||
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
|
$this->mode_reglement_supplier_id = $obj->mode_reglement_supplier;
|
||||||
$this->cond_reglement_supplier_id = $obj->cond_reglement_supplier;
|
$this->cond_reglement_supplier_id = $obj->cond_reglement_supplier;
|
||||||
|
$this->shipping_method_id = ($obj->fk_shipping_method>0)?$obj->fk_shipping_method:null;
|
||||||
|
|
||||||
$this->client = $obj->client;
|
$this->client = $obj->client;
|
||||||
$this->fournisseur = $obj->fournisseur;
|
$this->fournisseur = $obj->fournisseur;
|
||||||
|
|||||||
154
htdocs/webservices/demo_wsclient_project.php-NORUN
Normal file
154
htdocs/webservices/demo_wsclient_project.php-NORUN
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2016 Ion Agorria <ion@agorria.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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/webservices/demo_wsclient_project.php
|
||||||
|
* \brief Demo page to make a client call to Dolibarr WebServices "server_project"
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This is to make Dolibarr working with Plesk
|
||||||
|
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||||
|
|
||||||
|
require_once '../master.inc.php';
|
||||||
|
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
|
||||||
|
|
||||||
|
$WS_DOL_URL = DOL_MAIN_URL_ROOT.'/webservices/server_project.php';
|
||||||
|
//$WS_DOL_URL = 'http://localhost:8080/'; // To test with Soapui mock. If not a page, should end with /
|
||||||
|
$WS_METHOD1 = 'createProject';
|
||||||
|
$WS_METHOD2 = 'getProject';
|
||||||
|
$ns='http://www.dolibarr.org/ns/';
|
||||||
|
|
||||||
|
|
||||||
|
// Set the WebService URL
|
||||||
|
dol_syslog("Create nusoap_client for URL=".$WS_DOL_URL);
|
||||||
|
$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(
|
||||||
|
'dolibarrkey'=>$conf->global->WEBSERVICES_KEY,
|
||||||
|
'sourceapplication'=>'DEMO',
|
||||||
|
'login'=>'admin',
|
||||||
|
'password'=>'changeme',
|
||||||
|
'entity'=>'');
|
||||||
|
|
||||||
|
|
||||||
|
// Test url 1
|
||||||
|
if ($WS_METHOD1)
|
||||||
|
{
|
||||||
|
$parameters = array(
|
||||||
|
'authentication'=>$authentication,
|
||||||
|
'project'=>array(
|
||||||
|
'ref'=>'REF_TEST_WS',
|
||||||
|
'label'=>'LABEL_WS',
|
||||||
|
'thirdparty_id'=>'1234',
|
||||||
|
'public'=>'1',
|
||||||
|
'status'=>'0',
|
||||||
|
'date_start'=>'2016-04-07T21:24:19Z',
|
||||||
|
'date_end'=>'2016-04-08T08:13:42Z',
|
||||||
|
'budget'=>'1234',
|
||||||
|
'description'=>'DESCRIPTION_WS',
|
||||||
|
)
|
||||||
|
);
|
||||||
|
dol_syslog("Call method ".$WS_METHOD1);
|
||||||
|
$result1 = $soapclient->call($WS_METHOD1,$parameters,$ns,'');
|
||||||
|
if (! $result1)
|
||||||
|
{
|
||||||
|
print $soapclient->error_str;
|
||||||
|
print "<br>\n\n";
|
||||||
|
print $soapclient->request;
|
||||||
|
print "<br>\n\n";
|
||||||
|
print $soapclient->response;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Test url 2
|
||||||
|
if ($WS_METHOD2)
|
||||||
|
{
|
||||||
|
$parameters = array(
|
||||||
|
'authentication'=>$authentication,
|
||||||
|
'id'=>'',
|
||||||
|
'ref'=>'REF_TEST_WS'
|
||||||
|
);
|
||||||
|
dol_syslog("Call method ".$WS_METHOD2);
|
||||||
|
$result2 = $soapclient->call($WS_METHOD2,$parameters,$ns,'');
|
||||||
|
if (! $result2)
|
||||||
|
{
|
||||||
|
print $soapclient->error_str;
|
||||||
|
print "<br>\n\n";
|
||||||
|
print $soapclient->request;
|
||||||
|
print "<br>\n\n";
|
||||||
|
print $soapclient->response;
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* View
|
||||||
|
*/
|
||||||
|
|
||||||
|
header("Content-type: text/html; charset=utf8");
|
||||||
|
print '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">'."\n";
|
||||||
|
echo '<html>'."\n";
|
||||||
|
echo '<head>';
|
||||||
|
echo '<title>WebService Test: '.$WS_METHOD1.'</title>';
|
||||||
|
echo '</head>'."\n";
|
||||||
|
|
||||||
|
echo '<body>'."\n";
|
||||||
|
echo 'NUSOAP_PATH='.NUSOAP_PATH.'<br>';
|
||||||
|
|
||||||
|
echo "<h2>Request:</h2>";
|
||||||
|
echo '<h4>Function</h4>';
|
||||||
|
echo $WS_METHOD1;
|
||||||
|
echo '<h4>SOAP Message</h4>';
|
||||||
|
echo '<pre>' . htmlspecialchars($soapclient1->request, ENT_QUOTES) . '</pre>';
|
||||||
|
//echo '<hr>';
|
||||||
|
echo "<h2>Response:</h2>";
|
||||||
|
echo '<h4>Result</h4>';
|
||||||
|
echo '<pre>';
|
||||||
|
print_r($result1);
|
||||||
|
echo '</pre>';
|
||||||
|
echo '<h4>SOAP Message</h4>';
|
||||||
|
echo '<pre>' . htmlspecialchars($soapclient1->response, ENT_QUOTES) . '</pre>';
|
||||||
|
|
||||||
|
print '<hr>';
|
||||||
|
|
||||||
|
echo "<h2>Request:</h2>";
|
||||||
|
echo '<h4>Function</h4>';
|
||||||
|
echo $WS_METHOD2;
|
||||||
|
echo '<h4>SOAP Message</h4>';
|
||||||
|
echo '<pre>' . htmlspecialchars($soapclient2->request, ENT_QUOTES) . '</pre>';
|
||||||
|
//echo '<hr>';
|
||||||
|
echo "<h2>Response:</h2>";
|
||||||
|
echo '<h4>Result</h4>';
|
||||||
|
echo '<pre>';
|
||||||
|
print_r($result2);
|
||||||
|
echo '</pre>';
|
||||||
|
echo '<h4>SOAP Message</h4>';
|
||||||
|
echo '<pre>' . htmlspecialchars($soapclient2->response, ENT_QUOTES) . '</pre>';
|
||||||
|
|
||||||
|
echo '</body>'."\n";
|
||||||
|
echo '</html>'."\n";
|
||||||
|
?>
|
||||||
433
htdocs/webservices/server_project.php
Normal file
433
htdocs/webservices/server_project.php
Normal file
@ -0,0 +1,433 @@
|
|||||||
|
<?php
|
||||||
|
/* Copyright (C) 2006-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
|
* Copyright (C) 2016 Ion Agorria <ion@agorria.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
|
||||||
|
* the Free Software Foundation; either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \file htdocs/webservices/server_project.php
|
||||||
|
* \brief File that is entry point to call Dolibarr WebServices
|
||||||
|
*/
|
||||||
|
|
||||||
|
// This is to make Dolibarr working with Plesk
|
||||||
|
set_include_path($_SERVER['DOCUMENT_ROOT'].'/htdocs');
|
||||||
|
|
||||||
|
require_once '../master.inc.php';
|
||||||
|
require_once NUSOAP_PATH.'/nusoap.php'; // Include SOAP
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/ws.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/user/class/user.class.php';
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||||
|
|
||||||
|
|
||||||
|
dol_syslog("Call Dolibarr webservices interfaces");
|
||||||
|
|
||||||
|
$langs->load("main");
|
||||||
|
|
||||||
|
// Enable and test if module web services is enabled
|
||||||
|
if (empty($conf->global->MAIN_MODULE_WEBSERVICES))
|
||||||
|
{
|
||||||
|
$langs->load("admin");
|
||||||
|
dol_syslog("Call Dolibarr webservices interfaces with module webservices disabled");
|
||||||
|
print $langs->trans("WarningModuleNotActive",'WebServices').'.<br><br>';
|
||||||
|
print $langs->trans("ToActivateModule");
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create associated types array, with each table
|
||||||
|
$listofreferent=array(
|
||||||
|
'propal' => 'propal',
|
||||||
|
'order' => 'commande',
|
||||||
|
'invoice' => 'facture',
|
||||||
|
'invoice_predefined' => 'facture_rec',
|
||||||
|
'proposal_supplier' => 'commande_fournisseur',
|
||||||
|
'order_supplier' => 'commande_fournisseur',
|
||||||
|
'invoice_supplier' => 'facture_fourn',
|
||||||
|
'contract' => 'contrat',
|
||||||
|
'intervention' => 'fichinter',
|
||||||
|
'trip' => 'deplacement',
|
||||||
|
'expensereport' => 'expensereport_det',
|
||||||
|
'donation' => 'don',
|
||||||
|
'agenda' => 'actioncomm',
|
||||||
|
'project_task' => 'projet_task',
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create the soap Object
|
||||||
|
$server = new nusoap_server();
|
||||||
|
$server->soap_defencoding='UTF-8';
|
||||||
|
$server->decode_utf8=false;
|
||||||
|
$ns='http://www.dolibarr.org/ns/';
|
||||||
|
$server->configureWSDL('WebServicesDolibarrOther',$ns);
|
||||||
|
$server->wsdl->schemaTargetNamespace=$ns;
|
||||||
|
|
||||||
|
// Define WSDL Authentication object
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'authentication',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
array(
|
||||||
|
'dolibarrkey' => array('name'=>'dolibarrkey','type'=>'xsd:string'),
|
||||||
|
'sourceapplication' => array('name'=>'sourceapplication','type'=>'xsd:string'),
|
||||||
|
'login' => array('name'=>'login','type'=>'xsd:string'),
|
||||||
|
'password' => array('name'=>'password','type'=>'xsd:string'),
|
||||||
|
'entity' => array('name'=>'entity','type'=>'xsd:string'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Define WSDL Return object
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'result',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
array(
|
||||||
|
'result_code' => array('name'=>'result_code','type'=>'xsd:string'),
|
||||||
|
'result_label' => array('name'=>'result_label','type'=>'xsd:string'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
// Define other specific objects
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'element',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
array(
|
||||||
|
'id' => array('name'=>'id','type'=>'xsd:int'),
|
||||||
|
'user' => array('name'=>'user','type'=>'xsd:int'),
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'elementsArray',
|
||||||
|
'complexType',
|
||||||
|
'array',
|
||||||
|
'sequence',
|
||||||
|
'',
|
||||||
|
array(
|
||||||
|
'elements' => array(
|
||||||
|
'name' => 'elementsArray',
|
||||||
|
'type' => 'tns:element',
|
||||||
|
'minOccurs' => '0',
|
||||||
|
'maxOccurs' => 'unbounded'
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
$project_elements = array();
|
||||||
|
foreach($listofreferent as $key => $_)
|
||||||
|
{
|
||||||
|
$project_elements[$key] = array('name'=>$key,'type'=>'tns:elementsArray');
|
||||||
|
}
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'elements',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
$project_elements
|
||||||
|
);
|
||||||
|
|
||||||
|
// Define project
|
||||||
|
$project_fields = array(
|
||||||
|
'id' => array('name'=>'id','type'=>'xsd:string'),
|
||||||
|
'ref' => array('name'=>'ref','type'=>'xsd:string'),
|
||||||
|
'label' => array('name'=>'label','type'=>'xsd:string'),
|
||||||
|
'thirdparty_id' => array('name'=>'thirdparty_id','type'=>'xsd:int'),
|
||||||
|
'public' => array('name'=>'public','type'=>'xsd:int'),
|
||||||
|
'status' => array('name'=>'status','type'=>'xsd:int'),
|
||||||
|
'date_start' => array('name'=>'date_start','type'=>'xsd:date'),
|
||||||
|
'date_end' => array('name'=>'date_end','type'=>'xsd:date'),
|
||||||
|
'budget' => array('name'=>'budget','type'=>'xsd:int'),
|
||||||
|
'description' => array('name'=>'description','type'=>'xsd:string'),
|
||||||
|
'elements' => array('name'=>'elements','type'=>'tns:elements')
|
||||||
|
);
|
||||||
|
|
||||||
|
//Retreive all extrafield for thirdsparty
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extrafields=new ExtraFields($db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('project',true);
|
||||||
|
if (count($extrafields)>0) {
|
||||||
|
$extrafield_array = array();
|
||||||
|
}
|
||||||
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
|
{
|
||||||
|
//$value=$object->array_options["options_".$key];
|
||||||
|
$type =$extrafields->attribute_type[$key];
|
||||||
|
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
|
||||||
|
else {$type='xsd:string';}
|
||||||
|
$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
|
||||||
|
}
|
||||||
|
$project_fields=array_merge($project_fields,$extrafield_array);
|
||||||
|
|
||||||
|
$server->wsdl->addComplexType(
|
||||||
|
'project',
|
||||||
|
'complexType',
|
||||||
|
'struct',
|
||||||
|
'all',
|
||||||
|
'',
|
||||||
|
$project_fields
|
||||||
|
);
|
||||||
|
|
||||||
|
// 5 styles: RPC/encoded, RPC/literal, Document/encoded (not WS-I compliant), Document/literal, Document/literal wrapped
|
||||||
|
// Style merely dictates how to translate a WSDL binding to a SOAP message. Nothing more. You can use either style with any programming model.
|
||||||
|
// http://www.ibm.com/developerworks/webservices/library/ws-whichwsdl/
|
||||||
|
$styledoc='rpc'; // rpc/document (document is an extend into SOAP 1.0 to support unstructured messages)
|
||||||
|
$styleuse='encoded'; // encoded/literal/literal wrapped
|
||||||
|
// Better choice is document/literal wrapped but literal wrapped not supported by nusoap.
|
||||||
|
|
||||||
|
// Register WSDL
|
||||||
|
$server->register(
|
||||||
|
'createProject',
|
||||||
|
// Entry values
|
||||||
|
array('authentication'=>'tns:authentication','project'=>'tns:project'),
|
||||||
|
// Exit values
|
||||||
|
array('result'=>'tns:result','id'=>'xsd:string','ref'=>'xsd:string'),
|
||||||
|
$ns,
|
||||||
|
$ns.'#createProject',
|
||||||
|
$styledoc,
|
||||||
|
$styleuse,
|
||||||
|
'WS to create project'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Register WSDL
|
||||||
|
$server->register(
|
||||||
|
'getProject',
|
||||||
|
// Entry values
|
||||||
|
array('authentication'=>'tns:authentication','id'=>'xsd:string','ref'=>'xsd:string'),
|
||||||
|
// Exit values
|
||||||
|
array('result'=>'tns:result','project'=>'tns:project'),
|
||||||
|
$ns,
|
||||||
|
$ns.'#getProject',
|
||||||
|
$styledoc,
|
||||||
|
$styleuse,
|
||||||
|
'WS to get project'
|
||||||
|
);
|
||||||
|
|
||||||
|
// Full methods code
|
||||||
|
/**
|
||||||
|
* Create project
|
||||||
|
*
|
||||||
|
* @param array $authentication Array of authentication information
|
||||||
|
* @param array $project Project info
|
||||||
|
* @return int Id of new order
|
||||||
|
*/
|
||||||
|
function createProject($authentication, $project)
|
||||||
|
{
|
||||||
|
global $db,$conf;
|
||||||
|
|
||||||
|
dol_syslog("Function: createProject 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($project['ref']))
|
||||||
|
{
|
||||||
|
$error++; $errorcode='KO'; $errorlabel="Name is mandatory.";
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$fuser->getrights();
|
||||||
|
|
||||||
|
if ($fuser->rights->projet->creer)
|
||||||
|
{
|
||||||
|
$newobject=new Project($db);
|
||||||
|
$newobject->ref=$project['ref'];
|
||||||
|
$newobject->title=$project['label'];
|
||||||
|
$newobject->socid=$project['thirdparty_id'];
|
||||||
|
$newobject->public=$project['public'];
|
||||||
|
$newobject->statut=$project['status'];
|
||||||
|
$newobject->date_start=dol_stringtotime($project['date_start'],'dayrfc');
|
||||||
|
$newobject->date_end=dol_stringtotime($project['date_end'],'dayrfc');
|
||||||
|
$newobject->budget_amount=$project['budget'];
|
||||||
|
$newobject->description=$project['description'];
|
||||||
|
|
||||||
|
// Retrieve all extrafields for project
|
||||||
|
// fetch optionals attributes and labels
|
||||||
|
$extrafields=new ExtraFields($db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('project',true);
|
||||||
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
|
{
|
||||||
|
$key='options_'.$key;
|
||||||
|
$newobject->array_options[$key]=$project[$key];
|
||||||
|
}
|
||||||
|
|
||||||
|
$db->begin();
|
||||||
|
|
||||||
|
$result = $newobject->create($fuser);
|
||||||
|
if (! $error && $result > 0)
|
||||||
|
{
|
||||||
|
// Add myself as project leader
|
||||||
|
$result = $newobject->add_contact($fuser->id, 'PROJECTLEADER', 'internal');
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$db->commit();
|
||||||
|
$objectresp=array('result'=>array('result_code'=>'OK', 'result_label'=>''),'id'=>$newobject->id,'ref'=>$newobject->ref);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$db->rollback();
|
||||||
|
$error++;
|
||||||
|
$errorcode='KO';
|
||||||
|
$errorlabel=$newobject->error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a project
|
||||||
|
*
|
||||||
|
* @param array $authentication Array of authentication information
|
||||||
|
* @param string $id internal id
|
||||||
|
* @param string $ref internal reference
|
||||||
|
* @return array Array result
|
||||||
|
*/
|
||||||
|
function getProject($authentication,$id='',$ref='')
|
||||||
|
{
|
||||||
|
global $db,$conf,$langs;
|
||||||
|
|
||||||
|
dol_syslog("Function: getProject login=".$authentication['login']." id=".$id." ref=".$ref);
|
||||||
|
|
||||||
|
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)))
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='BAD_PARAMETERS'; $errorlabel="Parameter id and ref can't be both provided. You must choose one or other but not both.";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! $error)
|
||||||
|
{
|
||||||
|
$fuser->getrights();
|
||||||
|
|
||||||
|
if ($fuser->rights->projet->lire)
|
||||||
|
{
|
||||||
|
$project=new Project($db);
|
||||||
|
$result=$project->fetch($id,$ref);
|
||||||
|
if ($result > 0)
|
||||||
|
{
|
||||||
|
$project_result_fields=array(
|
||||||
|
'id' => $project->id,
|
||||||
|
'ref' => $project->ref,
|
||||||
|
'label' => $project->title,
|
||||||
|
'thirdparty_id' => $project->socid,
|
||||||
|
'public' => $project->public,
|
||||||
|
'status' => $project->statut,
|
||||||
|
'date_start' => $project->date_start ? dol_print_date($project->date_start, 'dayrfc') : '',
|
||||||
|
'date_end' => $project->date_end ? dol_print_date($project->date_end, 'dayrfc') : '',
|
||||||
|
'budget' => $project->budget_amount,
|
||||||
|
'description' => $project->description,
|
||||||
|
);
|
||||||
|
|
||||||
|
//Retrieve all extrafields for project
|
||||||
|
$extrafields=new ExtraFields($db);
|
||||||
|
$extralabels=$extrafields->fetch_name_optionals_label('societe',true);
|
||||||
|
|
||||||
|
//Get extrafield values
|
||||||
|
$project->fetch_optionals($project->id,$extralabels);
|
||||||
|
foreach($extrafields->attribute_label as $key=>$label)
|
||||||
|
{
|
||||||
|
$project_result_fields=array_merge($project_result_fields,array('options_'.$key => $project->array_options['options_'.$key]));
|
||||||
|
}
|
||||||
|
|
||||||
|
//Get linked elements
|
||||||
|
global $listofreferent;
|
||||||
|
$elements = array();
|
||||||
|
foreach ($listofreferent as $key => $tablename)
|
||||||
|
{
|
||||||
|
$elements[$key] = array();
|
||||||
|
$element_array = $project->get_element_list($key, $tablename);
|
||||||
|
if (count($element_array) > 0 && is_array($element_array))
|
||||||
|
{
|
||||||
|
foreach ($element_array as $element)
|
||||||
|
{
|
||||||
|
$tmp = explode('_', $element);
|
||||||
|
$idofelement = count($tmp) > 0? $tmp[0] : "";
|
||||||
|
$idofelementuser = count($tmp) > 1? $tmp[1] : "";
|
||||||
|
$elements[$key][] = array('id' => $idofelement, 'user' => $idofelementuser);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$project_result_fields['elements'] = $elements;
|
||||||
|
|
||||||
|
//Result
|
||||||
|
$objectresp = array(
|
||||||
|
'result'=>array('result_code'=>'OK', 'result_label'=>''),
|
||||||
|
'project'=>$project_result_fields
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$error++;
|
||||||
|
$errorcode='NOT_FOUND'; $errorlabel='Object not found for id='.$id.' nor ref='.$ref;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
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"));
|
||||||
Loading…
Reference in New Issue
Block a user