当前位置: 首页>>代码示例>>PHP>>正文


PHP DataObject::Factory方法代码示例

本文整理汇总了PHP中DataObject::Factory方法的典型用法代码示例。如果您正苦于以下问题:PHP DataObject::Factory方法的具体用法?PHP DataObject::Factory怎么用?PHP DataObject::Factory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在DataObject的用法示例。


在下文中一共展示了DataObject::Factory方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Factory

 public static function Factory($header_data, $lines_data, &$errors)
 {
     if (!isset($header_data['transfer_number'])) {
         $gen_id = new WarehouseTransferNumberHandler();
         $header_data['transfer_number'] = $gen_id->handle(new whtransfer());
     }
     $transfer_header = DataObject::Factory($header_data, $errors, 'WHTransfer');
     if (count($errors) == 0 && $transfer_header) {
         if (count($lines_data) > 0) {
             foreach ($lines_data as $line) {
                 $line['wh_transfer_id'] = $transfer_header->id;
                 $line['from_whlocation_id'] = $header_data['from_whlocation_id'];
                 $line['to_whlocation_id'] = $header_data['to_whlocation_id'];
                 $transfer_line = DataObject::Factory($line, $errors, 'WHTransferline');
                 if ($transfer_line) {
                     $transfer_header->unsaved_lines[] = $transfer_line;
                 } else {
                     $errors[] = 'Errors in Transfer Line';
                     break;
                 }
             }
         } else {
             $errors[] = 'No Transfer Lines';
         }
     }
     return $transfer_header;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:27,代码来源:WHTransfer.php

示例2: makeLine

 public static function makeLine($data, $do, &$errors)
 {
     //net value is unit-price * quantity
     if (!isset($data['tax_value'])) {
         //tax  (in the UK at least) is dependent on the tax_rate of the item, and the tax status of the customer.
         //this function is a wrapper to a call to a config-dependent method
         $data['tax_percentage'] = calc_tax_percentage($data['tax_rate_id'], $data['tax_status_id'], $data['net_value']);
         $data['tax_value'] = round(bcmul($data['net_value'], $data['tax_percentage'], 4), 2);
         $data['tax_rate_percent'] = bcmul($data['tax_percentage'], 100);
     } else {
         $tax_rate = DataObjectFactory::Factory('TaxRate');
         $tax_rate->load($data['tax_rate_id']);
         $data['tax_rate_percent'] = $tax_rate->percentage;
     }
     //gross value is net + tax; use bcadd to format the data
     $data['tax_value'] = bcadd($data['tax_value'], 0);
     $data['gross_value'] = bcadd($data['net_value'], $data['tax_value']);
     //then convert to the base currency
     if ($data['rate'] == 1) {
         $data['base_net_value'] = $data['net_value'];
         $data['base_tax_value'] = $data['tax_value'];
         $data['base_gross_value'] = $data['gross_value'];
     } else {
         $data['base_net_value'] = round(bcdiv($data['net_value'], $data['rate'], 4), 2);
         $data['base_tax_value'] = round(bcdiv($data['tax_value'], $data['rate'], 4), 2);
         $data['base_gross_value'] = round(bcadd($data['base_tax_value'], $data['base_net_value']), 2);
     }
     //and to the twin-currency
     $data['twin_net_value'] = round(bcmul($data['base_net_value'], $data['twin_rate'], 4), 2);
     $data['twin_tax_value'] = round(bcmul($data['base_tax_value'], $data['twin_rate'], 4), 2);
     $data['twin_gross_value'] = round(bcadd($data['twin_tax_value'], $data['twin_net_value']), 2);
     return DataObject::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:33,代码来源:InvoiceLine.php

示例3: insert

 function insert($ids = null, $company_id = null, &$errors = array())
 {
     if (empty($ids) || empty($company_id)) {
         $errors[] = 'Invalid/incomplete data trying to insert Company Categories';
         return FALSE;
     }
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     $categories = array();
     foreach ($ids as $id) {
         $category = DataObject::Factory(array('category_id' => $id, 'company_id' => $company_id), $errors, get_class($this));
         if ($category) {
             $categories[] = $category;
         } else {
             $errors[] = 'Error validating Company Category';
             return FALSE;
         }
     }
     $db = DB::Instance();
     foreach ($categories as $category) {
         if (!$category->save()) {
             $errors = $db->ErrorMsg();
             $db->FailTrans();
             $db->completeTrans();
             return FALSE;
         }
     }
     return $db->completeTrans();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:30,代码来源:CompanyInCategories.php

示例4: makeHeader

 public static function makeHeader($data, $do, &$errors)
 {
     if (strtotime(fix_date($data['order_date'])) > strtotime(fix_date(date(DATE_FORMAT)))) {
         $errors[] = 'Order Date cannot be in the future';
         return false;
     }
     if (!isset($data['id']) || $data['id'] == '') {
         //			$generator = new OrderNumberHandler();
         $generator = new UniqueNumberHandler(false, $data['type'] != 'T');
         $data['order_number'] = $generator->handle(DataObjectFactory::Factory($do));
         $data['status'] = 'N';
         $user = getCurrentUser();
         $data['raised_by'] = $user->username;
     }
     //determine the base currency
     $currency = DataObjectFactory::Factory('Currency');
     $currency->load($data['currency_id']);
     $data['rate'] = $currency->rate;
     //determine the twin currency
     $glparams = DataObjectFactory::Factory('GLParams');
     $twin_currency = DataObjectFactory::Factory('Currency');
     $twin_currency->load($glparams->base_currency());
     $data['twin_rate'] = $twin_currency->rate;
     $data['twin_currency_id'] = $twin_currency->id;
     return DataObject::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:26,代码来源:SPOrder.php

示例5: Factory

 public static function Factory(&$data, &$errors, $do)
 {
     $data['due_date'] = $data['transaction_date'];
     if (isset($data['ext_reference']) && !isset($data['our_reference'])) {
         $data['our_reference'] = $data['ext_reference'];
     } elseif (isset($data['reference']) && !isset($data['our_reference'])) {
         $data['our_reference'] = $data['reference'];
     }
     if (isset($data['description']) && !isset($data['comment'])) {
         $data['comment'] = $data['description'];
     }
     if (isset($data['comment']) && !isset($data['description'])) {
         $data['description'] = $data['comment'];
     }
     $mult = static::$multipliers[$data['source']][$data['transaction_type']];
     $data['net_value'] = $data['net_value'] * $mult;
     self::setCurrency($data);
     //the outstanding (os) values are the gross values to begin with
     $prefixes = array('', 'base_', 'twin_');
     foreach ($prefixes as $prefix) {
         $data[$prefix . 'os_value'] = $data[$prefix . 'gross_value'];
     }
     // Validate the Ledger Transactions
     if (empty($data['status'])) {
         $data['status'] = 'O';
     }
     return parent::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:28,代码来源:LedgerTransaction.php

示例6: copyStructure

 function copyStructure($data, &$errors)
 {
     $mfstructures = new MFStructureCollection(DataObjectFactory::Factory('MFStructure'));
     $cc1 = new ConstraintChain();
     $cc1->add(new Constraint('stitem_id', '=', $data->stitem_id));
     $cc1->add(new Constraint('start_date', '<=', fix_date(date(DATE_FORMAT))));
     $cc2 = new ConstraintChain();
     $cc2->add(new Constraint('end_date', '>=', fix_date(date(DATE_FORMAT))));
     $cc2->add(new Constraint('end_date', 'is', 'NULL'), 'OR');
     $sh = new SearchHandler($mfstructures, false);
     $sh->addConstraintChain($cc1);
     $sh->addConstraintChain($cc2);
     $mfstructures->load($sh);
     $wo_structure = array();
     $wo_structures = array();
     $copyfields = array('line_no', 'qty', 'uom_id', 'remarks', 'waste_pc', 'ststructure_id');
     foreach ($mfstructures as $input) {
         $wo_structure['work_order_id'] = $data->id;
         foreach ($copyfields as $field) {
             $wo_structure[$field] = $input->{$field};
         }
         $wo_structures[$input->line_no] = DataObject::Factory($wo_structure, $errors, 'MFWOStructure');
     }
     return $wo_structures;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:25,代码来源:MFWOStructure.php

示例7: Factory

 public static function Factory($data, &$errors = array(), $do_name = null)
 {
     if (empty($data['calendar_week'])) {
         $data['calendar_week'] = date('W', strtotime(fix_date($data['period_start_date'], DATE_TIME_FORMAT, $errors)));
     }
     return parent::Factory($data, $errors, $do_name);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:7,代码来源:EmployeePayPeriod.php

示例8: Factory

 static function Factory($data, &$errors, $do)
 {
     if (!isset($data['id']) || $data['id'] == '') {
         $generator = new ComplaintNumberHandler();
         $data['complaint_number'] = $generator->handle(new $do());
     }
     return parent::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:8,代码来源:Complaint.php

示例9: Factory

 public static function Factory($data, &$errors = array(), $do_name = null)
 {
     if ($data['debit'] > 0) {
         $data['value'] = BCADD($data['debit'], 0);
     } elseif ($data['credit'] > 0) {
         $data['value'] = BCMUL($data['credit'], -1);
     }
     return parent::Factory($data, $errors, $do_name);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:9,代码来源:GLUnpostedTransaction.php

示例10: Factory

 static function Factory($data, &$errors, $do_name = __CLASS__)
 {
     $do = DataObjectFactory::Factory($do_name);
     $db = DB::Instance();
     if (empty($data['docref'])) {
         $data['docref'] = $db->GenID('gl_transactions_docref_seq');
     }
     $glperiod = GLPeriod::getPeriod(fix_date($data['transaction_date']));
     if (!$glperiod || count($glperiod) == 0) {
         $errors[] = 'No period exists for this date';
     }
     $data['glperiods_id'] = $glperiod['id'];
     $data['status'] = $do->newStatus();
     return parent::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:15,代码来源:GLTransactionHeader.php

示例11: save

 public function save($errno, $errstr, $errfile, $errline)
 {
     $db = DB::Instance();
     $db->CompleteTrans();
     $errors = array();
     $flash = Flash::Instance();
     $data = array('error_number' => $errno, 'error_message' => $errstr, 'error_file' => $errfile, 'error_line' => $errline);
     $error = DataObject::Factory($data, $errors, 'ErrorHandler');
     if (!$error || count($errors) > 0 || !$error->save()) {
         $flash->addError('System Error - ' . $errstr . ' in ' . $errfile . ' at ' . $errline);
     } else {
         $flash->addError('System Error (Ref:' . $error->id . ' - ' . $errstr);
     }
     return false;
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:15,代码来源:ErrorHandler.php

示例12: Factory

 public static function Factory($data, &$errors)
 {
     $hash = $data['cb_account_id'];
     $hash .= $data['currency_id'];
     $hash .= $data['payment_type_id'];
     $hash .= $data['reference'];
     $hash .= fix_date($data['payment_date']);
     $hash .= $data['number_transactions'];
     $hash .= $data['payment_total'];
     $progressbar = new progressBar('create_security_key');
     $callback = function ($pl_data, $key) use(&$hash, &$errors) {
         $hash .= $pl_data['plmaster_id'];
         $hash .= bcadd($pl_data['net_value'], 0);
     };
     $progressbar->process($data['PLTransaction'], $callback);
     $data['hash_key'] = self::generateHashcode($hash);
     return parent::Factory($data, $errors, 'PLPayment');
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:18,代码来源:PLPayment.php

示例13: makeHeader

 /**
  *  Build the invoice header, as if from a submitted form
  *
  */
 public static function makeHeader($data, $do, &$errors)
 {
     if (!isset($data['id']) || $data['id'] == '') {
         $generator = new UniqueNumberHandler(false, $data['transaction_type'] != 'T');
         $data['invoice_number'] = $generator->handle(DataObjectFactory::Factory($do));
         $data['status'] = 'N';
     }
     //determine the base currency
     $currency = DataObjectFactory::Factory('Currency');
     $currency->load($data['currency_id']);
     $data['rate'] = $currency->rate;
     //determine the twin currency
     $glparams = DataObjectFactory::Factory('GLParams');
     $twin_currency = DataObjectFactory::Factory('Currency');
     $twin_currency->load($glparams->twin_currency());
     $data['twin_rate'] = $twin_currency->rate;
     $data['twin_currency_id'] = $twin_currency->id;
     $terms = DataObjectFactory::Factory('PaymentTerm');
     $terms->load($data['payment_term_id']);
     $today = date(DATE_FORMAT);
     if (empty($data['invoice_date'])) {
         $data['invoice_date'] = $today;
     }
     if ($data['transaction_type'] == 'I') {
         $data['due_date'] = calc_due_date($data['invoice_date'], $terms->basis, $terms->days, $terms->months);
     } else {
         if (fix_date($data['due_date']) < fix_date($today)) {
             $data['due_date'] = $today;
         }
     }
     $data['original_due_date'] = $data['due_date'];
     //		build the lines - header totals are built from the lines
     //		so initialise the values to zero
     $sums = array('net_value', 'tax_value', 'gross_value');
     $prefixes = array('', 'twin_', 'base_');
     foreach ($prefixes as $prefix) {
         foreach ($sums as $sum) {
             $data[$prefix . $sum] = '0.00';
         }
     }
     return DataObject::Factory($data, $errors, $do);
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:46,代码来源:Invoice.php

示例14: saveAllocation

 static function saveAllocation($transactions, $payment_id, &$errors)
 {
     $db = DB::Instance();
     $db->StartTrans();
     $alloc_id = $db->GenID('pl_allocation_id_seq');
     foreach ($transactions as $id => $value) {
         //			$trans = new PLTransaction();
         //			$trans->load($id);
         $data = array('allocation_id' => $alloc_id, 'transaction_id' => $id, 'payment_id' => $payment_id, 'payment_value' => $value);
         $alloc = DataObject::Factory($data, $errors, 'PLAllocation');
         if (count($errors) > 0 || !$alloc->save()) {
             break;
         }
     }
     if (count($errors) > 0) {
         $db->FailTrans();
         $db->CompleteTrans();
         return false;
     }
     return $db->CompleteTrans();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:21,代码来源:PLAllocation.php

示例15: setUsers

 public static function setUsers($role, $users, &$errors = array())
 {
     if (!$role instanceof Role) {
         $roleid = $role;
         $role = new Role();
         $role = $role->load($roleid);
         if ($role === false) {
             return false;
         }
     }
     $db = DB::Instance();
     $db->StartTrans();
     $query = "delete from hasrole where roleid=" . $db->qstr($role->id);
     $db->Execute($query);
     foreach ($users as $user) {
         $ob = DataObject::Factory(array('roleid' => $role->id, 'username' => $user), $errors, 'HasRole');
         if (count($errors) == 0 && $ob) {
             $ob->save();
         }
     }
     $db->CompleteTrans();
 }
开发者ID:uzerpllp,项目名称:uzerp,代码行数:22,代码来源:Role.php


注:本文中的DataObject::Factory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。