Returns additional form fields to show when the invoice has not yet been
sent.

@param \Siel\Acumulus\Invoice\Source $source
The Source for which the invoice has not yet been sent.

@return array[]
Array of form fields.
197981
private function getNotSentFields(Source $source)
    {
        $fields = array();
        $fields += array(
            'send' => array(
                'type' => 'button',
                'ajax' => array(
                    'service' => 'invoice_add',
                    'parent_type' => $this->source->getType(),
                    'parent_source' => $this->source->getId(),
                    'type' => $source->getType(),
                    'source' => $source->getId(),
                    'value' => 0,
                ),
                'value' => $this->t('send_now'),
            ),
        );

        return $fields;
    }
959791
public function defineTableAttributes($source = null)
    {
        $attributes = array(
            'title' => Craft::t('Title'),
        );

        // Allow plugins to modify the attributes
        craft()->plugins->call('modifyTagManagerTableAttributes', array(&$attributes, $source));

        return $attributes;
    }
321837
protected function getFieldsExistingMessages()
    {
        $fieldsMessages = [];
        $formObject = $this->getFormObject();

        if ($formObject->formWasSubmitted()
            && $formObject->hasFormResult()
        ) {
            foreach ($this->getFormObject()->getConfiguration()->getFields() as $field) {
                $fieldsMessages[$field->getName()] = $this->getSingleFieldExistingMessages($field);
            }
        }

        return $fieldsMessages;
    }
409402
public static function getDocumentID($source) 
    {
        if ($source instanceof DOMDOCUMENT) {
            foreach(phpQuery::$documents as $id => $document) {
                if ($source->isSameNode($document->document)) {
                    return $id;
                }
            }
        } else if ($source instanceof DOMNODE) {
            foreach(phpQuery::$documents as $id => $document) {
                if ($source->ownerDocument->isSameNode($document->document)) {
                    return $id;
                }
            }
        } else if ($source instanceof phpQueryObject) {
            return $source->getDocumentID();
        } else if (is_string($source) && isset(phpQuery::$documents[$source])) {
            return $source;
        }
    }
776309
public function findSources(string $sources): array
  {
    $patterns = $this->sourcesToPatterns($sources);

    $sources = [];
    foreach ($patterns as $pattern)
    {
      $tmp     = $this->findSourcesInPattern($pattern);
      $sources = array_merge($sources, $tmp);
    }

    $sources = array_unique($sources);
    sort($sources);

    return $sources;
  }
316823
private function sourcesToPatterns(string $sources): array
  {
    if (substr($sources, 0, 5)=='file:')
    {
      $patterns = $this->readPatterns(substr($sources, 5));
    }
    else
    {
      $patterns = [$sources];
    }

    return $patterns;
  }
488025
private function makeArrayFromOptionsWithVoidValues(array $source, array &$destination): array
    {
        $destination = [];

        foreach ($source as $option) {
            $destination[trim($option, "- ")] = "";
        }

        return $destination;
    }
1081560
public function getMetadata($source)
    {
        $fields = $this->query('PRAGMA table_info(' . $this->_escapeIdentifier($source) . ')', null, \PDO::FETCH_ASSOC);

        $attributes = [];
        $primaryKeys = [];
        $autoIncrementAttribute = null;

        foreach ($fields as $field) {
            $fieldName = $field['name'];

            $attributes[] = $fieldName;

            if ($field['pk'] === '1') {
                $primaryKeys[] = $fieldName;
            }

            if ($field['pk'] === '1' && $field['type'] === 'INTEGER') {
                $autoIncrementAttribute = $fieldName;
            }
        }

        $r = [
            Db::METADATA_ATTRIBUTES => $attributes,
            Db::METADATA_PRIMARY_KEY => $primaryKeys,
            Db::METADATA_AUTO_INCREMENT_KEY => $autoIncrementAttribute,
        ];

        return $r;
    }
654487
protected function parse($source): array
    {
        $path = null;
        list($alias, $path) = explode(':', $source, 2);

        $path = ltrim($path, "\\/");
        $paths = $this->resolvePaths($alias);

        return [$alias, $paths, $path];
    }
614651
public function for(Source $source): string
    {
        if (isset($this->presentationModels[$source])) {
            return (string)$this->presentationModels[$source];
        }

        return PresentationModel::class;
    }
150065
public function getMessagesFor(string $fieldName) : array
    {
        $invalidInputException = $this->getInvalidInputExceptionFor($fieldName);

        if ($invalidInputException) {
            return $invalidInputException->getMessages();
        }

        $invalidFormSubmission = $this->getInnerFormSubmissionExceptionFor($fieldName);

        if ($invalidFormSubmission) {
            return $invalidFormSubmission->getFieldMessageMap();
        }

        return [];
    }
1220837
public function getPaths($source)
    {
        $source = $this->cleanSource($source);
        list(, $paths) = $this->parse($source);

        return $paths;
    }
734515
protected function getItemLines()
    {
        $result = array();
        if ($this->invoiceSource->getType() === Source::Order) {
            // Note: getOrderDetailTaxes() is new in 1.6.1.0.
            $lines = method_exists($this->order, 'getOrderDetailTaxes')
                ? $this->mergeProductLines($this->order->getProductsDetail(), $this->order->getOrderDetailTaxes())
                : $this->order->getProductsDetail();
        } else {
            $lines = $this->creditSlip->getOrdersSlipProducts($this->invoiceSource->getId(), $this->order);
        }

        foreach ($lines as $line) {
            $result[] = $this->getItemLine($line);
        }
        return $result;
    }
164059
public function get_file_source_info($source) {
        global $USER;
        list($type, $fileid, $filename) = $this->split_part($source);
        return 'Box ('. fullname($USER) . '): ' . $filename;
    }
1370745
protected function getDropdownLabelsFromSource($source)
    {
        if (is_a($source, DropdownStrategyInterface::class, true)) {
            /** @var DropdownStrategyInterface $source */
            $source = app($source);
            return $source->labels();
        }

        return false;
    }
832517
protected function _fieldsAreNull($entity, $source)
    {
        $nulls = 0;
        $schema = $source->getSchema();
        foreach ($this->_fields as $field) {
            if ($schema->getColumn($field) && $schema->isNullable($field) && $entity->get($field) === null) {
                $nulls++;
            }
        }

        return $nulls === count($this->_fields);
    }
344033
public final static function decode(string $source): array {
		if (is_null($source = json_decode($source, true)) && json_last_error() !== JSON_ERROR_NONE){
			throw new \Exception('Invalid json format!');
		}

		return $source;
	}