コード例 #1
0
ファイル: BaseDomain.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Domain'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Domain'][$this->getPrimaryKey()] = true;
     $keys = DomainPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getAddressId(), $keys[3] => $this->getName(), $keys[4] => $this->getValid(), $keys[5] => $this->getDescription(), $keys[6] => $this->getNumber());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aAddress) {
             $result['Address'] = $this->aAddress->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collHolidayDomains) {
             $result['HolidayDomains'] = $this->collHolidayDomains->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPropertyValues) {
             $result['PropertyValues'] = $this->collPropertyValues->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collUsers) {
             $result['Users'] = $this->collUsers->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #2
0
 /**
  * Success
  */
 protected function success(Account $account, $balance)
 {
     // TODO: вынести в шаблон
     $props = $account->toArray(false);
     $result = array('id' => (int) $account['id'], 'type' => (int) $account['type_id'], 'name' => $account['name'], 'currency' => (int) $account['currency_id'], 'comment' => $account['description'], 'initBalance' => $balance, 'totalBalance' => $balance, 'state' => (int) $account['state']);
     // Content-Type ставим ручками поскольку не используем шаблоны
     $this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
     return $this->renderText(json_encode(array('result' => array('account' => $result, 'text' => 'Счёт успешно добавлен'))));
 }
コード例 #3
0
ファイル: BaseHoliday.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Holiday'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Holiday'][$this->getPrimaryKey()] = true;
     $keys = HolidayPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getName(), $keys[3] => $this->getDate());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collHolidayDomains) {
             $result['HolidayDomains'] = $this->collHolidayDomains->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #4
0
ファイル: BaseClockingType.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['ClockingType'][serialize($this->getPrimaryKey())])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['ClockingType'][serialize($this->getPrimaryKey())] = true;
     $keys = ClockingTypePeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getIdentifier(), $keys[3] => $this->getLabel(), $keys[4] => $this->getWholeDay(), $keys[5] => $this->getFutureGraceTime(), $keys[6] => $this->getPastGraceTime(), $keys[7] => $this->getApprovalRequired());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collClockings) {
             $result['Clockings'] = $this->collClockings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #5
0
ファイル: BaseBookingType.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['BookingType'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['BookingType'][$this->getPrimaryKey()] = true;
     $keys = BookingTypePeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getIdentifier(), $keys[3] => $this->getLabel(), $keys[4] => $this->getUnit(), $keys[5] => $this->getDisplayUnit());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collBookings) {
             $result['Bookings'] = $this->collBookings->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #6
0
 public function newAccount()
 {
     $account = new Account();
     $account->name = Input::get('name');
     $account->balance = floatval(Input::get('balance'));
     $account->date = Input::get('date');
     $account->fireflyuser_id = Auth::user()->id;
     // dit hele blok kan naar een listener
     $validator = Validator::make($account->toArray(), Account::$rules);
     $validator->fails();
     if ($validator->fails()) {
         //DB::delete('delete from cache'); // moet beter!
         return Redirect::to('/home/account/add')->withErrors($validator)->withInput();
     } else {
         $account->name = Crypt::encrypt($account->name);
         $account->save();
         return Redirect::to('/home');
         exit;
     }
 }
コード例 #7
0
ファイル: BasePlugin.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['Plugin'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['Plugin'][$this->getPrimaryKey()] = true;
     $keys = PluginPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getEntity(), $keys[3] => $this->getEvent(), $keys[4] => $this->getPriority(), $keys[5] => $this->getIdentifier(), $keys[6] => $this->getName(), $keys[7] => $this->getCode(), $keys[8] => $this->getActive(), $keys[9] => $this->getInterval(), $keys[10] => $this->getStart(), $keys[11] => $this->getLastExecutionTime());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
     }
     return $result;
 }
コード例 #8
0
ファイル: BaseUser.php プロジェクト: dapepe/tymio
 /**
  * Exports the object as an array.
  *
  * You can specify the key type of the array by passing one of the class
  * type constants.
  *
  * @param     string  $keyType (optional) One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  *                    BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  *                    Defaults to BasePeer::TYPE_PHPNAME.
  * @param     boolean $includeLazyLoadColumns (optional) Whether to include lazy loaded columns. Defaults to true.
  * @param     array $alreadyDumpedObjects List of objects to skip to avoid recursion
  * @param     boolean $includeForeignObjects (optional) Whether to include hydrated related objects. Default to FALSE.
  *
  * @return array an associative array containing the field names (as keys) and field values
  */
 public function toArray($keyType = BasePeer::TYPE_PHPNAME, $includeLazyLoadColumns = true, $alreadyDumpedObjects = array(), $includeForeignObjects = false)
 {
     if (isset($alreadyDumpedObjects['User'][$this->getPrimaryKey()])) {
         return '*RECURSION*';
     }
     $alreadyDumpedObjects['User'][$this->getPrimaryKey()] = true;
     $keys = UserPeer::getFieldNames($keyType);
     $result = array($keys[0] => $this->getId(), $keys[1] => $this->getAccountId(), $keys[2] => $this->getDomainId(), $keys[3] => $this->getDeleted(), $keys[4] => $this->getName(), $keys[5] => $this->getFirstname(), $keys[6] => $this->getLastname(), $keys[7] => $this->getPhone(), $keys[8] => $this->getManagerOf(), $keys[9] => $this->getIsAdmin(), $keys[10] => $this->getEmail(), $keys[11] => $this->getPasswordHash(), $keys[12] => $this->getNumber());
     if ($includeForeignObjects) {
         if (null !== $this->aAccount) {
             $result['Account'] = $this->aAccount->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->aDomain) {
             $result['Domain'] = $this->aDomain->toArray($keyType, $includeLazyLoadColumns, $alreadyDumpedObjects, true);
         }
         if (null !== $this->collClockingsRelatedByCreatorId) {
             $result['ClockingsRelatedByCreatorId'] = $this->collClockingsRelatedByCreatorId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collClockingsRelatedByUserId) {
             $result['ClockingsRelatedByUserId'] = $this->collClockingsRelatedByUserId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collPropertyValues) {
             $result['PropertyValues'] = $this->collPropertyValues->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collSystemLogs) {
             $result['SystemLogs'] = $this->collSystemLogs->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collTransactionsRelatedByCreatorId) {
             $result['TransactionsRelatedByCreatorId'] = $this->collTransactionsRelatedByCreatorId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
         if (null !== $this->collTransactionsRelatedByUserId) {
             $result['TransactionsRelatedByUserId'] = $this->collTransactionsRelatedByUserId->toArray(null, true, $keyType, $includeLazyLoadColumns, $alreadyDumpedObjects);
         }
     }
     return $result;
 }
コード例 #9
0
 private function getExternalContractVariables($contract)
 {
     $contractData = $contract->toArray();
     $contractData = sanatizeBeanArrayForLatex($contractData);
     $contact = new Contact();
     if ($contact->retrieve($contract->clientcontact_id)) {
         $contractData['clientcontactperson'] = $contact->toArray();
     }
     $contact = new Contact();
     if ($contact->retrieve($contract->technicalcontact_id)) {
         $contractData['technicalcontactperson'] = $contact->toArray();
     }
     $contact = new Contact();
     if ($contact->retrieve($contract->contact_id)) {
         $contractData['contactperson'] = $contact->toArray();
     }
     $account = new Account();
     if ($account->retrieve($contract->account_id)) {
         $contractData['account'] = $account->toArray();
     }
     global $timedate;
     $contractData['startdate'] = $timedate->to_display_date($contract->startdate);
     $contractData['minimumduration'] = $timedate->to_display_date($contract->minimumduration);
     global $app_list_strings;
     if ($contract->endperiod == 'other') {
         $contractData['endperiod'] = $timedate->to_display_date($contract->enddate);
     } else {
         $contractData['endperiod'] = $app_list_strings['endperiod_list'][$contract->endperiod];
     }
     if ($contract->cancellationperiod == 'other') {
         $contractData['cancellationperiod'] = $timedate->to_display_date($contract->cancellationdate);
     } else {
         $contractData['cancellationperiod'] = $app_list_strings['cancellationperiod_list'][$contract->cancellationperiod];
     }
     // show address linebreaks in pdf
     $contractData['deliveryaddress'] = preg_replace("/\n/", '\\newline ', $contract->deliveryaddress);
     $contractData['completionaddress'] = preg_replace("/\n/", '\\newline ', $contract->completionaddress);
     $contractData['svnumbers'] = $contract->getSVNumbersArray();
     // TODO: abbreviation and type probably have to be converted in the future
     $contractMatters = explode('^,^', $contract->externalcontractmatter);
     foreach ($contractMatters as &$matter) {
         $matter = $app_list_strings['externalcontractmatter_list'][$matter];
     }
     $contractData['externalcontractmatter'] = implode('\\newline ', $contractMatters);
     $previousCategory = '';
     $costs = $contract->getCostsArray();
     $months = getLanguageStringsPHP('months');
     foreach ($costs as &$cost) {
         $cost['numberOfDetailedCosts'] = count($cost['detailedCosts']);
         if ($previousCategory == $cost['category']) {
             $previousCategory = $cost['category'];
             $cost['category'] = '';
             // TODO @LION i guess that leaving the category field empty should to some kind of marking... please comment.
         } else {
             $previousCategory = $cost['category'];
             $cost['category'] = $app_list_strings['externalcontractmatter_list'][$cost['category']];
         }
         if ('annually' === $cost['paymentinterval'] || 'once' === $cost['paymentinterval'] || 'other' === $cost['paymentinterval']) {
             $enddate = date_parse($contract->enddate);
             // if the payment interval of this cost is once, annually or other, there will be only one detailed cost row.
             // so it is correct to modify the first detailed cost item in the array.
             // set the month for this detailed cost row to the month of the enddate.
             $cost['detailedCosts'][0]['month'] = $enddate['month'];
         }
         // do translation now because paymentinterval will not be read from php code anymore.
         // so it can be in localized form from now on.
         $cost['paymentinterval'] = $app_list_strings['paymentinterval_list'][$cost['paymentinterval']];
         foreach ($cost['detailedCosts'] as &$detailedCosts) {
             $detailedCosts['price'] = formatCurrencyForSmartyLatex($detailedCosts['price'], false);
             // format price for latex template (see #387)
         }
     }
     $positions = $contract->getPositionsArray();
     foreach ($positions as &$position) {
         $position['type'] = $app_list_strings['externalcontractmatter_list'][$position['type']];
         $position['price'] = formatCurrencyForSmartyLatex($position['price'], false);
         // format price for latex template (see #387)
     }
     // convert all currency values / prices before giving them to smarty
     $contractData['finalcosts'] = formatCurrencyForSmartyLatex($contractData['finalcosts'], true);
     return array('numberOfCosts' => count($costs), 'months' => $months, 'contract' => $contractData, 'costs' => $costs, 'positions' => $positions, 'currencySymbol' => currencySymbolToLatexEquivalent(getSugarCrmLocale('default_currency_symbol')));
 }
コード例 #10
0
function getContractVariables($contract)
{
    $contractData = sanatizeBeanArrayForLatex($contract->toArray(true));
    $clientContact = new Contact();
    if ($clientContact->retrieve($contract->clientcontact_id)) {
        $contractData['clientContact'] = sanatizeBeanArrayForLatex($clientContact->toArray(true));
        // Gets data from DB only
        $clientAccount = new Account();
        if ($clientAccount->retrieve($clientContact->account_id)) {
            //$GLOBALS['log']->error('Account variables: variables transferred to latex template: '. var_export($clientAccount->toArray(true),true));
            $contractData['clientContact']['account'] = sanatizeBeanArrayForLatex($clientAccount->toArray(true));
        }
        //gets data from DB only
    }
    // only date is needed (not time) and we have to convert it to the user format
    global $timedate;
    //$GLOBALS['log']->error('Contract variables: date_modified: '. var_export($contract->date_modified,true));
    //$contractData['date_modified'] = $timedate->to_display_date($contract->date_modified);
    $contractData['date_modified'] = $timedate->getDatePart($contract->date_modified);
    //$contractData['startdate'] = $timedate->to_display_date($contract->startdate);
    //$contractData['enddate'] = $timedate->to_display_date($contract->enddate);
    //$contractData['deadline'] = $timedate->to_display_date($contract->deadline);
    // translate
    global $app_list_strings;
    if (isset($contractData['periodofnotice'])) {
        $contractData['periodofnotice'] = $app_list_strings['periodofnotice_list'][$contractData['periodofnotice']];
    }
    //contract currency setup
    $currency = new Currency();
    $currency_id = $currency->retrieve_id_by_name($contract->currency_id);
    //$GLOBALS['log']->error('Contract variables: currency: '. var_export($currency_id,true));
    if ($currency_id) {
        $currency->retrieve($currency_id);
        $contractData['currency_id'] = $currency->iso4217;
        $contractData['currency_symbol'] = $currency->symbol;
    } else {
        $contractData['currency_id'] = $currency->getDefaultISO4217();
        $contractData['currency_symbol'] = $currency->getDefaultCurrencySymbol();
    }
    $contractData['currency_symbol'] = str_replace("€", '\\euro{}', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace('$', '\\$', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace("£", '{\\pounds}', $contractData['currency_symbol']);
    $contractData['currency_symbol'] = str_replace("¥", '{Y\\hspace*{-1.4ex}--}', $contractData['currency_symbol']);
    // Get Sugar user information
    $userData = oqc_getUserVariables();
    $contractData = array_merge($contractData, $userData);
    $outputData = array('contract' => $contractData, 'graphicsDir' => LATEX_GRAPHICS_DIR);
    //$GLOBALS['log']->error('Contract variables: variables transferred to latex template: '. var_export($contractData,true));
    return $outputData;
}