Fix use new extrafields array

This commit is contained in:
Laurent Destailleur 2019-08-31 13:06:21 +02:00
parent ee394d6fd5
commit 74454c3766
7 changed files with 64 additions and 38 deletions

View File

@ -111,6 +111,9 @@ $actioncomm_fields= array(
'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);
@ -119,9 +122,9 @@ $extrafield_array=null;
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';}
@ -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]));
}
@ -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];
@ -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];

View File

@ -115,6 +115,10 @@ $contact_fields = array(
'poste' => array('name'=>'poste','type'=>'xsd:string')
//...
);
$elementtype = 'socpeople';
//Retreive all extrafield for contact
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
@ -123,9 +127,9 @@ $extrafield_array=null;
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';}
@ -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]));
}
@ -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];
@ -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];

View File

@ -110,6 +110,7 @@ $line_fields = array(
'product_desc' => array('name'=>'product_desc','type'=>'xsd:string')
);
$elementtype = 'commandedet';
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
@ -119,10 +120,10 @@ $extrafield_line_array=null;
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);
@ -211,6 +212,8 @@ $order_fields = array(
'lines' => array('name'=>'lines','type'=>'tns:LinesArray2')
);
$elementtype = 'commande';
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
@ -219,10 +222,10 @@ $extrafield_array=null;
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);
@ -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];
@ -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];
@ -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]))

View File

@ -130,6 +130,10 @@ $productorservice_fields = array(
'images' => array('name'=>'images','type'=>'tns:ImagesArray')
);
$elementtype = 'product';
//Retreive all extrafield for product
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
@ -138,9 +142,9 @@ $extrafield_array=null;
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';}
@ -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]));
}
@ -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];
@ -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];
@ -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]));
}

View File

@ -159,6 +159,8 @@ $project_fields = array(
'elements' => array('name'=>'elements','type'=>'tns:elements')
);
$elementtype = 'project';
//Retreive all extrafield for thirdsparty
// fetch optionals attributes and labels
$extrafields=new ExtraFields($db);
@ -167,10 +169,10 @@ $extrafield_array=null;
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);
@ -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];
@ -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]));
}

View File

@ -120,6 +120,8 @@ $thirdparty_fields= array(
'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);
@ -128,10 +130,10 @@ $extrafield_array=null;
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';}
@ -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]));
}
@ -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];
@ -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];
@ -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};
}

View File

@ -183,6 +183,8 @@ $thirdpartywithuser_fields = array(
'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);
@ -191,9 +193,9 @@ $extrafield_array=null;
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';}
@ -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