/**
  * add body rows
  * 
  * @alternate, kind of POC or VIP, overwrites the default one
  *
  * @param Tinebase_Record_RecordSet $records
  */
 public function processIteration($_records)
 {
     $json = new Tinebase_Convert_Json();
     $resolved = $json->fromTine20RecordSet($_records);
     foreach ($resolved as $record) {
         $row = $this->_activeTable->appendRow();
         $i18n = $this->_translate->getAdapter();
         foreach ($this->_config->columns->column as $field) {
             $identifier = $field->identifier;
             // TODO: use ModelConfig here to get the POC
             // get type and value for cell
             $cellType = $this->_getCellType($field->type);
             switch ($identifier) {
                 case 'quantity':
                     $value = $record[$identifier];
                     break;
                 default:
                     $value = $record['product_id'][$identifier];
             }
             // create cell with type and value and add style
             $cell = $row->appendCell($value, $cellType);
             if ($field->customStyle) {
                 $cell->setStyle((string) $field->customStyle);
             }
         }
         $i++;
     }
 }
 /**
  * parent converts Tinebase_Record_RecordSet to external format
  * this resolves Image Paths
  * @TODO: Can be removed when "0000284: modlog of contact images / move images to vfs" is resolved.
  * 
  * @param Tinebase_Record_RecordSet  $_records
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param Tinebase_Model_Pagination $_pagination
  * @return mixed
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records = NULL, $_filter = NULL, $_pagination = NULL)
 {
     if (count($_records) == 0) {
         return array();
     }
     Addressbook_Frontend_Json::resolveImages($_records);
     return parent::fromTine20RecordSet($_records, $_filter, $_pagination);
 }
Example #3
0
 /**
  * parent converts Tinebase_Record_RecordSet to external format
  * this resolves Image Paths
  * @TODO: Can be removed when "0000284: modlog of contact images / move images to vfs" is resolved.
  * @param  Tinebase_Record_RecordSet  $_records
  * @param  array $_resolveUserFields
  * @return mixed
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records, $_resolveUserFields = array())
 {
     if (count($_records) == 0) {
         return array();
     }
     Addressbook_Frontend_Json::resolveImages($_records);
     return parent::fromTine20RecordSet($_records, $_resolveUserFields);
 }
 /**
  * converts Tinebase_Record_Abstract to external format
  *
  * @param  Tinebase_Record_Abstract $_record
  * @return mixed
  */
 public function fromTine20Model(Tinebase_Record_Abstract $_record)
 {
     $jsonData = parent::fromTine20Model($_record);
     if (Tinebase_Core::getUser()->hasRight('Calendar', Calendar_Acl_Rights::MANAGE_RESOURCES)) {
         $jsonData['grants'] = Tinebase_Container::getInstance()->getGrantsOfContainer($_record->container_id, TRUE)->toArray();
         $jsonData['grants'] = Tinebase_Frontend_Json_Container::resolveAccounts($jsonData['grants']);
     }
     return $jsonData;
 }
 /**
  * parent converts Tinebase_Record_RecordSet to external format
  * this resolves Image Paths
  *
  * @param Tinebase_Record_RecordSet  $_records
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param Tinebase_Model_Pagination $_pagination
  * @return mixed
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records = NULL, $_filter = NULL, $_pagination = NULL)
 {
     if (count($_records) == 0) {
         return array();
     }
     // TODO: Can be removed when "0000284: modlog of contact images / move images to vfs" is resolved.
     Addressbook_Frontend_Json::resolveImages($_records);
     $this->_appendRecordPaths($_records, $_filter);
     $result = parent::fromTine20RecordSet($_records, $_filter, $_pagination);
     return $result;
 }
 /**
  * add body rows
  * 
  * @alternate, kind of POC or VIP, overwrites the default one
  *
  * @param Tinebase_Record_RecordSet $records
  */
 public function processIteration($_records)
 {
     $json = new Tinebase_Convert_Json();
     $productAggregateIds = $_records->accountable_id;
     $paFilter = new Sales_Model_ProductAggregateFilter();
     $paFilter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'id', 'operator' => 'in', 'value' => $productAggregateIds)));
     $productAggregates = Sales_Controller_ProductAggregate::getInstance()->search($paFilter);
     $pFilter = new Sales_Model_ProductFilter();
     $pFilter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'id', 'operator' => 'in', 'value' => array_unique($productAggregates->product_id))));
     $products = Sales_Controller_Product::getInstance()->search($pFilter);
     $resolved = $json->fromTine20RecordSet($_records);
     foreach ($resolved as $record) {
         $record['accountable_id'] = $productAggregates->getById($record['accountable_id'])->toArray();
         $record['product_id'] = $products->getById($record['accountable_id']['product_id'])->toArray();
         $row = $this->_activeTable->appendRow();
         $i18n = $this->_translate->getAdapter();
         foreach ($this->_config->columns->column as $field) {
             $identifier = $field->identifier;
             // TODO: use ModelConfig here to get the POC
             // get type and value for cell
             $cellType = $this->_getCellType($field->type);
             switch ($identifier) {
                 case 'quantity':
                     $value = intval($record[$identifier]) * intval($record['accountable_id']['quantity']);
                     break;
                 case 'month':
                     $value = $record[$identifier];
                     break;
                 default:
                     $value = $record['product_id'][$identifier];
             }
             // create cell with type and value and add style
             $cell = $row->appendCell($value, $cellType);
             if ($field->customStyle) {
                 $cell->setStyle((string) $field->customStyle);
             }
         }
     }
 }
 /**
  * converts Tinebase_Record_Abstract to external format
  *
  * @param  Tinebase_Record_Abstract $_record
  * @return mixed
  */
 public function fromTine20Model(Tinebase_Record_Abstract $_record)
 {
     self::resolveRelatedData($_record);
     return parent::fromTine20Model($_record);
 }
 /**
  * converts Tinebase_Record_RecordSet to external format
  * 
  * @param Tinebase_Record_RecordSet  $_records
  * @param Tinebase_Model_Filter_FilterGroup $_filter
  * @param Tinebase_Model_Pagination $_pagination
  * 
  * @return mixed
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records = NULL, $_filter = NULL, $_pagination = NULL)
 {
     foreach ($_records as $record) {
         $this->_convertOptions($record);
     }
     $result = parent::fromTine20RecordSet($_records, $_filter, $_pagination);
     return $result;
 }
 /**
  * resolves child records before converting the record set to an array
  *
  * @param Tinebase_Record_RecordSet $records
  * @param Tinebase_ModelConfiguration $modelConfiguration
  * @param boolean $multiple
  */
 protected function _resolveBeforeToArray($records, $modelConfiguration, $multiple = false)
 {
     $this->_resolveMemberroles($records);
     parent::_resolveBeforeToArray($records, $modelConfiguration, $multiple);
 }
 /**
  * Return a single record
  *
  * @param   string $id
  * @return  array record data
  */
 public function getInvoice($id)
 {
     $invoice = $this->_get($id, Sales_Controller_Invoice::getInstance());
     $json = new Tinebase_Convert_Json();
     $resolvedProducts = new Tinebase_Record_RecordSet('Sales_Model_Product');
     $productController = Sales_Controller_Product::getInstance();
     foreach ($invoice['relations'] as &$relation) {
         if ($relation['related_model'] == "Sales_Model_ProductAggregate") {
             if (!($product = $resolvedProducts->getById($relation['related_record']['product_id']))) {
                 $product = $productController->get($relation['related_record']['product_id']);
                 $resolvedProducts->addRecord($product);
             }
             $relation['related_record']['product_id'] = $json->fromTine20Model($product);
         }
     }
     return $invoice;
 }
 /**
  * add body rows
  * 
  * @alternate, kind of POC or VIP, overwrites the default one
  *
  * @param Tinebase_Record_RecordSet $records
  */
 public function processIteration($_records)
 {
     $json = new Tinebase_Convert_Json();
     $addressIds = array_unique($_records->address_id);
     $addresses = NULL;
     $resolved = $json->fromTine20RecordSet($_records);
     foreach ($resolved as $record) {
         $row = $this->_activeTable->appendRow();
         $customer = '';
         $contract = '';
         $debitor = '';
         foreach ($record['relations'] as $relation) {
             if ($relation['related_model'] == 'Sales_Model_Customer') {
                 $customer = $relation['related_record']['number'] . ' - ' . $relation['related_record']['name'];
             } elseif ($relation['related_model'] == 'Sales_Model_Contract') {
                 $contract = $relation['related_record']['number'] . ' - ' . $relation['related_record']['title'];
             }
         }
         $i18n = $this->_translate->getAdapter();
         foreach ($this->_config->columns->column as $field) {
             $identifier = $field->identifier;
             // TODO: use ModelConfig here to get the POC
             // get type and value for cell
             $cellType = $this->_getCellType($field->type);
             switch ($identifier) {
                 case 'costcenter_id':
                     $value = $record[$identifier]['number'] . ' - ' . $record[$identifier]['remark'];
                     break;
                 case 'customer':
                     $value = $customer;
                     break;
                 case 'contract':
                     $value = $contract;
                     break;
                 case 'fixed_address':
                     $value = str_replace("\n", ', ', $record[$identifier]);
                     break;
                 case 'date':
                     $value = substr($record[$identifier], 0, 10);
                     break;
                 case 'cleared':
                     $value = $i18n->_($record[$identifier] == 'CLEARED' ? 'cleared' : 'to clear');
                     break;
                 case 'type':
                     $value = $i18n->_($record[$identifier] == 'INVOICE' ? 'invoice' : 'Reversal Invoice');
                     break;
                 case 'debitor':
                     if (!$addresses) {
                         $filter = new Sales_Model_AddressFilter(array());
                         $filter->addFilter(new Tinebase_Model_Filter_Text(array('field' => 'id', 'operator' => 'in', 'value' => $addressIds)));
                         $addresses = Sales_Controller_Address::getInstance()->search($filter);
                     }
                     $address = $addresses->filter('id', $record['address_id']['id'])->getFirstRecord();
                     if ($address) {
                         $value = $address->custom1;
                     } else {
                         $value = '';
                     }
                     break;
                 default:
                     $value = $record[$identifier];
             }
             // create cell with type and value and add style
             $cell = $row->appendCell($value, $cellType);
             if ($field->customStyle) {
                 $cell->setStyle((string) $field->customStyle);
             }
         }
     }
 }
Example #12
0
 /**
  * converts Tinebase_Record_RecordSet to external format
  * 
  * @param  Tinebase_Record_RecordSet  $_records
  * @param  array $_resolveUserFields
  * @return mixed
  */
 public function fromTine20RecordSet(Tinebase_Record_RecordSet $_records, $_resolveUserFields = array())
 {
     foreach ($_records as $record) {
         $this->_convertOptions($record);
     }
     $result = parent::fromTine20RecordSet($_records, $_resolveUserFields);
     return $result;
 }
 public function toArray()
 {
     $convert = new Tinebase_Convert_Json();
     $contracts = $convert->fromTine20RecordSet($this->_contracts);
     return array('contracts' => $contracts);
 }