Commit 235154ae59b0f12d9a6577801dcf2892305d4e54

Authored by sergem
1 parent 5c3fdb99

Modified the get_metadata clienttools api call to work with largetext and multiselects

Committed by:Serge Meunier
webservice/clienttools/services/0.2/kt.php
@@ -368,29 +368,48 @@ class kt extends client_service { @@ -368,29 +368,48 @@ class kt extends client_service {
368 } 368 }
369 $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types); 369 $items[]=array("name"=>"__document_type", "index"=>0, "value"=>$document_type, "control_type"=>"lookup", "selection"=>$json_document_types);
370 370
  371 + foreach ($detail as $fieldset) {
  372 + foreach ($fieldset['fields'] as $field) {
  373 +
  374 + $prepArray = array(
  375 + 'fieldset' => $fieldset['fieldset'],
  376 + 'name' => $field['name'],
  377 +
  378 + // Change for value. If blank value is set to 1, change value to ''
  379 + // Overcomes issue of n/a
  380 + 'value' => ($document_id > 0 ? ($field['blankvalue'] == '1' ? '' : $field['value']) : ''),
  381 +
  382 + 'description' => $field['description'],
  383 + 'control_type' => $field['control_type'],
  384 + 'selection' => $field['selection'],
  385 + 'required' => $field['required'],
  386 + 'blankvalue' => $field['blankvalue'],
  387 + 'index' => $index
  388 + );
  389 +
  390 + // Small Adjustment for multiselect to real type
  391 + if ($field['control_type'] == 'multiselect') {
  392 + $prepArray['control_type'] = $field['options']['type'];
  393 + }
  394 +
  395 +
  396 + if (isset($field['options']['ishtml'])) {
  397 + $prepArray['ishtml'] = $field['options']['ishtml'];
  398 + } else {
  399 + $prepArray['ishtml'] = '0';
  400 + }
  401 +
  402 + if (isset($field['options']['maxlength'])) {
  403 + $prepArray['maxlength'] = $field['options']['maxlength'];
  404 + } else {
  405 + $prepArray['maxlength'] = '-1';
  406 + }
  407 +
  408 + $items[] = $prepArray;
  409 + $index++;
  410 + }
  411 + }
371 412
372 - for($i=0;$i<count($detail);$i++) {  
373 -  
374 - for($j=0;$j<count($detail[$i]['fields']);$j++)  
375 - {  
376 - $items[]=array(  
377 - 'fieldset'=>$detail[$i]['fieldset'],  
378 - 'name'=>$detail[$i]['fields'][$j]['name'],  
379 -  
380 - // Change for value. If blank value is set to 1, change value to ''  
381 - // Overcomes issue of n/a  
382 - 'value'=>($document_id > 0 ? ($detail[$i]['fields'][$j]['blankvalue']=='1' ? '' : $detail[$i]['fields'][$j]['value']) : ''),  
383 -  
384 - 'description'=>$detail[$i]['fields'][$j]['description'],  
385 - 'control_type'=>$detail[$i]['fields'][$j]['control_type'],  
386 - 'selection'=>$detail[$i]['fields'][$j]['selection'],  
387 - 'required'=>$detail[$i]['fields'][$j]['required'],  
388 - 'blankvalue'=>$detail[$i]['fields'][$j]['blankvalue'],  
389 - 'index'=>$index  
390 - );  
391 - $index++;  
392 - }  
393 - }  
394 413
395 414
396 $this->setResponse(array('id'=>$title, 'items'=>$items, 'count'=>count($items))); 415 $this->setResponse(array('id'=>$title, 'items'=>$items, 'count'=>count($items)));