Skip to content

Commit

Permalink
Fix use new extrafields array
Browse files Browse the repository at this point in the history
  • Loading branch information
eldy committed Aug 31, 2019
1 parent ee394d6 commit 74454c3
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 38 deletions.
13 changes: 8 additions & 5 deletions htdocs/webservices/server_actioncomm.php
Expand Up @@ -111,6 +111,9 @@
'fk_element' => array('name'=>'fk_element','type'=>'xsd:string'),
'elementtype' => array('name'=>'elementtype','type'=>'xsd:string'));


$elementtype = 'actioncomm';

//Retreive all extrafield for actioncomm
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -119,9 +122,9 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}

Expand Down Expand Up @@ -308,7 +311,7 @@ function getActionComm($authentication, $id)
//Get extrafield values
$actioncomm->fetch_optionals();

foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$actioncomm_result_fields=array_merge($actioncomm_result_fields, array('options_'.$key => $actioncomm->array_options['options_'.$key]));
}
Expand Down Expand Up @@ -448,7 +451,7 @@ function createActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('actioncomm', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$actioncomm[$key];
Expand Down Expand Up @@ -542,7 +545,7 @@ function updateActionComm($authentication, $actioncomm)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('actioncomm', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$object->array_options[$key]=$actioncomm[$key];
Expand Down
14 changes: 9 additions & 5 deletions htdocs/webservices/server_contact.php
Expand Up @@ -115,6 +115,10 @@
'poste' => array('name'=>'poste','type'=>'xsd:string')
//...
);

$elementtype = 'socpeople';


//Retreive all extrafield for contact
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -123,9 +127,9 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}

Expand Down Expand Up @@ -311,7 +315,7 @@ function getContact($authentication, $id, $ref_ext)
//Get extrafield values
$contact->fetch_optionals();

foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$contact_result_fields=array_merge($contact_result_fields, array('options_'.$key => $contact->array_options['options_'.$key]));
}
Expand Down Expand Up @@ -416,7 +420,7 @@ function createContact($authentication, $contact)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('socpeople', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$contact[$key];
Expand Down Expand Up @@ -663,7 +667,7 @@ function updateContact($authentication, $contact)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('socpeople', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$object->array_options[$key]=$contact[$key];
Expand Down
25 changes: 17 additions & 8 deletions htdocs/webservices/server_order.php
Expand Up @@ -110,6 +110,7 @@
'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
);

$elementtype = 'commandedet';

//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
Expand All @@ -119,10 +120,10 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_line_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
//$value=$object->array_options["options_".$key];
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}
$extrafield_line_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
Expand Down Expand Up @@ -211,6 +212,8 @@
'lines' => array('name'=>'lines','type'=>'tns:LinesArray2')
);

$elementtype = 'commande';

//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -219,10 +222,10 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
//$value=$object->array_options["options_".$key];
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}
$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
Expand Down Expand Up @@ -694,11 +697,13 @@ function createOrder($authentication, $order)
$newobject->demand_reason_id=$order['demand_reason_id'];
$newobject->date_creation=$now;

$elementtype = 'commande';

// Retrieve all extrafield for order
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('commandet', true);
foreach($extrafields->attribute_label as $key=>$label)
$extralabels=$extrafields->fetch_name_optionals_label('commande', true);
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$order[$key];
Expand Down Expand Up @@ -727,11 +732,13 @@ function createOrder($authentication, $order)
$newline->date_start=$line['date_start'];
$newline->date_end=$line['date_end'];

$elementtype = 'commandedet';

// Retrieve all extrafield for lines
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('commandedet', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newline->array_options[$key]=$line[$key];
Expand Down Expand Up @@ -933,11 +940,13 @@ function updateOrder($authentication, $order)
if (! $order['billed']) $result=$object->classifyUnBilled($fuser);
}

$elementtype = 'commande';

//Retreive all extrafield for object
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('commande', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
if (isset($order[$key]))
Expand Down
16 changes: 10 additions & 6 deletions htdocs/webservices/server_productorservice.php
Expand Up @@ -130,6 +130,10 @@
'images' => array('name'=>'images','type'=>'tns:ImagesArray')
);


$elementtype = 'product';


//Retreive all extrafield for product
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -138,9 +142,9 @@
if (is_array($extrafields) && count($extrafields) > 0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}

Expand Down Expand Up @@ -428,7 +432,7 @@ function getProductOrService($authentication, $id = '', $ref = '', $ref_ext = ''
//Get extrafield values
$product->fetch_optionals();

foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$productorservice_result_fields=array_merge($productorservice_result_fields, array('options_'.$key => $product->array_options['options_'.$key]));
}
Expand Down Expand Up @@ -552,7 +556,7 @@ function createProductOrService($authentication, $product)

$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('product', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$product[$key];
Expand Down Expand Up @@ -721,7 +725,7 @@ function updateProductOrService($authentication, $product)

$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('product', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$product[$key];
Expand Down Expand Up @@ -1099,7 +1103,7 @@ function getProductsForCategory($authentication, $id, $lang = '')
//Get extrafield values
$tmpproduct->fetch_optionals();

foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$products[$iProduct]=array_merge($products[$iProduct], array('options_'.$key => $tmpproduct->array_options['options_'.$key]));
}
Expand Down
12 changes: 7 additions & 5 deletions htdocs/webservices/server_project.php
Expand Up @@ -159,6 +159,8 @@
'elements' => array('name'=>'elements','type'=>'tns:elements')
);

$elementtype = 'project';

//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -167,10 +169,10 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
//$value=$object->array_options["options_".$key];
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}
$extrafield_array['options_'.$key]=array('name'=>'options_'.$key,'type'=>$type);
Expand Down Expand Up @@ -270,7 +272,7 @@ function createProject($authentication, $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)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$project[$key];
Expand Down Expand Up @@ -374,11 +376,11 @@ function getProject($authentication, $id = '', $ref = '')

//Retrieve all extrafields for project
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('societe', true);
$extralabels=$extrafields->fetch_name_optionals_label('project', true);

//Get extrafield values
$project->fetch_optionals();
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$project_result_fields=array_merge($project_result_fields, array('options_'.$key => $project->array_options['options_'.$key]));
}
Expand Down
14 changes: 8 additions & 6 deletions htdocs/webservices/server_thirdparty.php
Expand Up @@ -120,6 +120,8 @@
'vat_used' => array('name'=>'vat_used','type'=>'xsd:string'),
'vat_number' => array('name'=>'vat_number','type'=>'xsd:string'));

$elementtype = 'societe';

// Retrieve all extrafields for thirdsparty
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -128,10 +130,10 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
//$value=$object->array_options["options_".$key];
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}

Expand Down Expand Up @@ -359,7 +361,7 @@ function getThirdParty($authentication, $id = '', $ref = '', $ref_ext = '')
//Get extrafield values
$thirdparty->fetch_optionals();

foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$thirdparty_result_fields=array_merge($thirdparty_result_fields, array('options_'.$key => $thirdparty->array_options['options_'.$key]));
}
Expand Down Expand Up @@ -472,7 +474,7 @@ function createThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('societe', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$newobject->array_options[$key]=$thirdparty[$key];
Expand Down Expand Up @@ -603,7 +605,7 @@ function updateThirdParty($authentication, $thirdparty)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('societe', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='options_'.$key;
$object->array_options[$key]=$thirdparty[$key];
Expand Down Expand Up @@ -705,7 +707,7 @@ function getListOfThirdParties($authentication, $filterthirdparty)
{
$extrafieldsOptions=array();
$obj=$db->fetch_object($resql);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$extrafieldsOptions['options_'.$key] = $obj->{$key};
}
Expand Down
8 changes: 5 additions & 3 deletions htdocs/webservices/server_user.php
Expand Up @@ -183,6 +183,8 @@
'group_id' => array('name'=>'group_id','type'=>'xsd:string')
);

$elementtype = 'socpeople';

//Retreive all extrafield for contact
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
Expand All @@ -191,9 +193,9 @@
if (is_array($extrafields) && count($extrafields)>0) {
$extrafield_array = array();
}
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$type =$extrafields->attribute_type[$key];
$type =$extrafields->attributes[$elementtype]['type'][$key];
if ($type=='date' || $type=='datetime') {$type='xsd:dateTime';}
else {$type='xsd:string';}

Expand Down Expand Up @@ -598,7 +600,7 @@ function createUserFromThirdparty($authentication, $thirdpartywithuser)
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
$extralabels=$extrafields->fetch_name_optionals_label('socpeople', true);
foreach($extrafields->attribute_label as $key=>$label)
foreach($extrafields->attributes[$elementtype]['label'] as $key=>$label)
{
$key='contact_options_'.$key;
$key=substr($key, 8); // Remove 'contact_' prefix
Expand Down

0 comments on commit 74454c3

Please sign in to comment.