Overview

Namespaces

  • FlexiPeeHP
  • PHP

Classes

  • DateTime
  • FlexiPeeHP\Actions
  • FlexiPeeHP\Adresar
  • FlexiPeeHP\Banka
  • FlexiPeeHP\Cenik
  • FlexiPeeHP\Changes
  • FlexiPeeHP\Company
  • FlexiPeeHP\DodavatelskaSmlouva
  • FlexiPeeHP\EvidenceList
  • FlexiPeeHP\FakturaPrijata
  • FlexiPeeHP\FakturaVydana
  • FlexiPeeHP\FakturaVydanaPolozka
  • FlexiPeeHP\FlexiBeeRO
  • FlexiPeeHP\FlexiBeeRW
  • FlexiPeeHP\Formats
  • FlexiPeeHP\Hooks
  • FlexiPeeHP\InterniDoklad
  • FlexiPeeHP\Kontakt
  • FlexiPeeHP\Nastaveni
  • FlexiPeeHP\Pokladna
  • FlexiPeeHP\PokladniPohyb
  • FlexiPeeHP\Priloha
  • FlexiPeeHP\RadaPokladniPohyb
  • FlexiPeeHP\Relations
  • FlexiPeeHP\SkladovaKarta
  • FlexiPeeHP\SkladovyPohyb
  • FlexiPeeHP\SkladovyPohybPolozka
  • FlexiPeeHP\SkupinaFirem
  • FlexiPeeHP\Smlouva
  • FlexiPeeHP\Status
  • FlexiPeeHP\Stitek
  • FlexiPeeHP\Strom
  • FlexiPeeHP\StromCenik
  • FlexiPeeHP\UcetniObdobi
  • FlexiPeeHP\VyrobniCislo
  • FlexiPeeHP\Zavazek
  • FlexiPeeHP\Zurnal

Interfaces

  • DateTimeInterface
  • Throwable

Traits

  • FlexiPeeHP\Firma
  • FlexiPeeHP\Stitky
  • FlexiPeeHP\Sum

Exceptions

  • Exception
  • Overview
  • Namespace
  • Class
  • Tree
  1:   2:   3:   4:   5:   6:   7:   8:   9:  10:  11:  12:  13:  14:  15:  16:  17:  18:  19:  20:  21:  22:  23:  24:  25:  26:  27:  28:  29:  30:  31:  32:  33:  34:  35:  36:  37:  38:  39:  40:  41:  42:  43:  44:  45:  46:  47:  48:  49:  50:  51:  52:  53:  54:  55:  56:  57:  58:  59:  60:  61:  62:  63:  64:  65:  66:  67:  68:  69:  70:  71:  72:  73:  74:  75:  76:  77:  78:  79:  80:  81:  82:  83:  84:  85:  86:  87:  88:  89:  90:  91:  92:  93:  94:  95:  96:  97:  98:  99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 
<?php
/**
 * FlexiPeeHP - Objekt adresáře.
 *
 * @author     Vítězslav Dvořák <vitex@arachne.cz>
 * @copyright  (C) 2015-2017 Spoje.Net
 */

namespace FlexiPeeHP;

/**
 * Adresář
 *
 * @link https://demo.flexibee.eu/c/demo/adresar/properties položky evidence
 */
class Adresar extends FlexiBeeRW
{
    use Stitky;
    
    /**
     * Evidence užitá objektem.
     *
     * @var string
     */
    public $evidence = 'adresar';

    /**
     * get Email address for Customer with primary contact prefered
     * 
     * @return string email of primary contact or address email or null
     */
    public function getNotificationEmailAddress()
    {
        $email     = null;
        $emailsRaw = $this->getFlexiData($this->getApiURL(),
            ['detail' => 'custom:id,email,kontakty(primarni,email)', 'relations' => 'kontakty']);
        if (is_array($emailsRaw) && !empty($emailsRaw[0])) {
            $emails = $emailsRaw[0];
            if (array_key_exists('email', $emails) && strlen(trim($emails['email']))) {
                $email = $emails['email'];
            }
            if (array_key_exists('kontakty', $emails) && !empty($emails['kontakty'])) {
                foreach ($emails['kontakty'] as $kontakt) {
                    if (($kontakt['primarni'] == 'true') && strlen(trim($kontakt['email']))) {
                        $email = $kontakt['email'];
                        break;
                    }
                }
            }
        }
        return $email;
    }

    /**
     * get cell phone Number for Customer with primary contact prefered
     * 
     * @return string cell phone number of primary contact or address cell number or null
     */
    public function getCellPhoneNumber()
    {
        $mobil     = null;
        $mobilsRaw = $this->getFlexiData($this->getApiURL(),
            ['detail' => 'custom:id,mobil,kontakty(primarni,mobil)', 'relations' => 'kontakty']);
        if (is_array($mobilsRaw)) {
            $mobils = $mobilsRaw[0];
            if (array_key_exists('mobil', $mobils) && strlen(trim($mobils['mobil']))) {
                $mobil = $mobils['mobil'];
            }
            if (array_key_exists('kontakty', $mobils) && !empty($mobils['kontakty'])) {
                foreach ($mobils['kontakty'] as $kontakt) {
                    if (($kontakt['primarni'] == 'true') && strlen(trim($kontakt['mobil']))) {
                        $mobil = $kontakt['mobil'];
                        break;
                    }
                }
            }
        }
        return $mobil;
    }
    
    /**
     * get any phone Number for Customer with primary contact prefered
     * 
     * @return string phone number of primary contact or address's phone number or null
     */
    public function getAnyPhoneNumber()
    {
        $phoneNo    = null;
        $numbersRaw = $this->getFlexiData($this->getApiURL(),
            ['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']);
        if (is_array($numbersRaw) && !empty($numbersRaw[0])) {
            $numbers = $numbersRaw[0];
            if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) {
                $phoneNo = $numbers['mobil'];
            }
            if (array_key_exists('tel', $numbers) && strlen(trim($numbers['tel']))) {
                $phoneNo = $numbers['tel'];
            }
            if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) {
                foreach ($numbers['kontakty'] as $kontakt) {
                    if ($kontakt['primarni'] == 'true') {
                        
                    }
                    if (strlen(trim($kontakt['mobil']))) {
                        $phoneNo = $kontakt['mobil'];
                        break;
                    } elseif (strlen(trim($kontakt['mobil']))) {
                        $phoneNo = $kontakt['mobil'];
                        break;
                    }
                }
            }
        }
        return $phoneNo;
    }
    
    
    /**
     * 
     * 
     * @param Adresar|string|int $address
     * 
     * @return array bank account details
     */
    public function getBankAccountNumber($address = null)
    {
        if (is_null($address)) {
            $address = $this->getMyKey();
        }
        $bucRaw = $this->getColumnsFromFlexibee(['buc', 'smerKod'], ['firma'=> $address ,'evidence' => 'adresar-bankovni-ucet']);
        return (!empty($bucRaw) && array_key_exists(0, $bucRaw)) ? $bucRaw : [];
    }
    
}
FlexiPeeHP API documentation generated by ApiGen